The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

16
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007

Transcript of The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Page 1: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

The Halting Problem – Undecidable Languages

Lecture 31Section 4.2

Wed, Oct 31, 2007

Page 2: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

The Acceptance Problem for Turing Machines

• The Acceptance Problem for Turing Machines: Given a Turing machine M and a string w, does M accept w?

• The language isATM = {M, w | M accepts w)}.

Page 3: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

ATM is Turing-Recognizable

• Theorem: ATM is Turing-recognizable.

• Proof:• Build a Turing machine U that will

read a representation of M and simulate it on the input w.

Page 4: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

ATM is Turing-Recognizable

• If U halts in the accept state, then accept M, w.

• If U halts in the reject state, then reject M, w.

• The problem is that U may run forever.

• That is why U is only a recognizer, not a decider.

Page 5: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Universal Turing Machines

• A universal Turing machine is a Turing machine that can read a description of any Turing machine and simulate it.

• Do universal Turing machines really exist?

Page 6: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Universal Turing Machines

• Yes. (We call them programmable computers.)

• They read a description of a Turing machine. (We call the description a program.)

• Then they simulate the Turing machine. (We say they execute the program.)

Page 7: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages• Theorem: There exist Turing-

unrecognizable languages.• Lemma: The set of all Turing

machines is a countably infinite set.

• Proof of the Lemma:• Each Turing machine has a finite

description: (Q, , , , q0, qacc, qrej).

Page 8: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Express each description in binary, perhaps by using ASCII.

• Thus, the set of all Turing machines is represented by a set of finite binary strings.

• We already know that every set of finite binary strings is countable.

• (They can be arranged in lexicographical order.)

Page 9: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Lemma: The set of infinite binary strings is uncountable.

• Proof of the Lemma:• We need to use a diagonalization

argument, which is based on proof by contradiction.

Page 10: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Suppose the set is countable.• Then the set of all infinite binary

strings can be listed w1, w2, w3, and so on.

• Create a binary array that is infinite to the right and down by letting row i be the bits in wi, for i = 1, 2, 3, …

Page 11: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Define an infinite binary string w as follows.• If the ith bit in row i is 0, set the ith bit of w

to 1.• If the ith bit in row i is 1, set the ith bit of w

to 0.

0 if1

1 if0

ii

iii w

ww

Page 12: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Certainly, w is an infinite binary string.

• But w cannot be in the list of all infinite binary strings because it disagrees with every wi in the list.

• This is a contradiction.• Therefore, the set must be

uncountable.

Page 13: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• Proof of the Theorem:• Suppose that every language is

recognizable.• Then for every language L, there is a

Turing machine M that recognizes it.• That is, L(M) = L.

Page 14: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• For any language L, create an infinite binary string s as follows.• Make a list of all binary strings and order

it lexicographically.

• For the ith word wi in the list, if wi is in L, then the ith bit of s is 1.

• If wi is not in L, then the ith bit of s is 0.

Page 15: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• This is a one-to-one correspondence between the set of all languages and the set of all infinite binary strings.

• Thus, the set of all languages is uncountable.

Page 16: The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.

Turing-Unrecognizable Languages

• But for every language, there is (supposedly) a Turing machine that accepts it.

• That would require uncountably many Turing machines.

• This is a contradiction.• Thus, there exist languages that are

not Turing-recognizable.