Docsity

Methods for Decision and Recognition in CS: Understanding Recursive Languages and Rice's T, Slides of Theory of Automata

Partial preview of the text

Download Methods for Decision and Recognition in CS: Understanding Recursive Languages and Rice's T and more Slides Theory of Automata in PDF only on Docsity!

Chapter Eighteen:

Uncomputability

The Church-Turing Thesis gives a definition of computability, like a

border surrounding the algorithmically solvable problems.

regular languages CFLs

L ( a * b *)

recursive { an^ b n } languages

{ an^ b n^ cn }

Beyond that border is a wilderness of uncomputable problems. This

is one of the great revelations of twentieth-century mathematics: the

discovery of simple problems whose algorithmic solution would be

very useful but is forever beyond us.

Switching To Java-Like Syntax

• In this chapter we switch from using Turing

machines to using a Java-like syntax

• All the following ideas apply to any Turing-

equivalent formalism

• Java-like syntax is easier to read than TMs

• Note, this is not real Java; no limitations

• In particular, no bounds on the length of a

string or the size of an integer

Decision Methods

• Total TMs correspond to decision methods in

our Java-like notation

• A decision method takes a String

parameter and returns a boolean value

• (It always returns, and does not run forever)

• Example, { ax | x ∈ Σ*}:

boolean ax(String p) { return (p.length()>0 && p.charAt(0)=='a'); }

Recursive Languages

• Previous definition: L is a recursive language

if and only if it is L ( M ) for some total TM M

• New definition: L is a recursive language if

and only if it is L (m) for some decision method

m

• These definitions are equivalent because

Java is Turing-equivalent

Recognition Methods

• For methods that might run forever, a broader

term

• A recognition method takes a String

parameter and either returns a boolean value

or runs forever

• A decision method is a special kind of

recognition method, just as a total TM is a

special kind of TM

{ a

n

b

n

c

n

} Decision Method

• L (anbncn1) = L (anbncn2) = { a n^ b n^ c n }

  • But anbncn2 is a decision method , showing that the

language is recursive and not just RE

boolean anbncn2(String p) { String as = "", bs = "", cs = ""; while (true) { String s = as+bs+cs; if (s.length()>p.length()) return false; else if (p.equals(s)) return true; as += 'a'; bs += 'b'; cs += 'c'; } }

RE Languages

• Previous definition: L is a recursively

enumerable (RE) language if and only if it is

L ( M ) for some TM M

• New definition: L is an RE language if and

only if it is L (m) for some recognition method m

• These definitions are equivalent because

Java is Turing-equivalent

run Examples

  • sigmaStar("abc") returns true, so the run in this fragment would return true:
  • ax("ba") returns false, so the run in this fragment would return false:

String s = "boolean sigmaStar(String p) {return true;}"; run(s,"abc");

String s = "boolean ax(String p) { " + " return (p.length()>0 && p.charAt(0)=='a'); " + "} "; run(s,"ba");

run Examples, Continued

  • anbncn1("abbc") runs forever, so the run in this

fragment would never return:

String s = "boolean anbncn1(String p) { " + " String as = "", bs = "", cs = ""; " + " while (true) { " + " String s = as+bs+cs; " + " if (p.equals(s)( return true; " + " as += 'a'; bs += 'b'; cs += 'c'; " + " } " + "} "; run(s,"abbc");

Outline

  • 18.1 Decision and Recognition Methods
  • 18.2 The Language L (^) u
  • 18.3 The Halting Problems
  • 18.4 Reductions Proving a Language Is Recursive
  • 18.5 Reductions Proving a Language is Not Recursive
  • 18.6 Rice's Theorem
  • 18.7 Enumerators
  • 18.8 Recursively Enumerable Languages
  • 18.9 Languages That Are Not RE
  • 18.10 Language Classifications Revisited
  • 18.11 Grammars and Comnputability
  • 18.12 Oracles
  • 18.13 Mathematical Uncomputabilities

The Perils Of Infinite Computation

  • You run a program, and wait… and wait…
  • You ask, “Is this stuck in an infinite loop, or is it just taking a long time?”
  • No sure way for a person to answer such questions
  • No sure way for a computer to find the answer for you…

int j = 0; for (int i = 0; i < 100; j++) { j += f(i); }

Is L u Recursive?

• That is, is it possible to write a decision

method with this specification:

• Just like the run method, but does not run

forever, even when run(p,in) would

  • shortcut(p,in) returns true if run(p,in) would
  • return true, and returns false if run(p,in)
  • would return false or run forever. */ boolean shortcut(String p, String in) { ... }

Example

• For example, the shortcut in this fragment:

• It would return false, even though

anbncn1("in") would run forever

String x = "boolean anbncn1(String p) { " + " String as = "", bs = "", cs = ""; " + " while (true) { " + " String s = as+bs+cs; " + " if (p.equals(s)) return true; " + " as += 'a'; bs += 'b'; cs += 'c'; " + " } " + "} "; shortcut(x,"abbc")