Slides Notes Unit 1
Slides Notes Unit 1
edition), published by Thomson Course Technology 2006. They are copyrighted materials and may not be used in other course settings outside of the University of Iowa in their current form or modied form without the express written permission of one of the copyright holders. During this course, students are prohibited from selling notes to or being paid for taking notes by any person or commercial rm without the express written permission of one of the copyright holders.
Decidability of TM Language
Problem:
AT M = { M, w |M is a TM that accepts w}
Solution
Theorem 4.11:
decidable.
A recognizer of AT M is the following TM called the Turing Universal Machine U : U = On input M, w , where M is a TM and w is a string: 1. Simulates M on w; 2. If M ever enters its accept state, accept; if M ever enters its reject state, reject ".
Note:
Facts
1. So far we have tackled only solvable (decidable) problems; 2. Theorem 4.11 states that AT M is unsolvable (undecidable); 3. Since AT M is undecidable, to solve this problem we need to expand our problem solving methodology by a new method for proving undecidability.
Diagonalization
The proof of undecidability of the halting problem uses Georg Cantor (1873) technique called diagonalization; Cantors problem was to measure the size of innite sets; The size of nite sets is measured by counting the number of their elements;
can we measure the size of an innite set by counting the number of its elements?
Question:
Fact
The size of innite sets cannot be measured by counting their elements because this procedure does not halt!
The set of strings over {0, 1} is an innite set; The set N of natural number is an innite set; Both of them are larger than any nite set. How can we compare them? Design a mapping f : N {0, 1} by:
1. f (0) = ; 2. f (n) = {x {0, 1} ||x| = n}.
Fact
f actually maps N on P({0, 1} ).
Since |x| = |y| for any x, y f (n), | | is an equivalence relation on {0, 1} and we can consider f : N {0, 1} /| |.
Cantors Solution
Two nite sets have the same size if their elements can be paired; Since this method do not rely on counting elements it can be used for both nite and innite sets.
The Correspondence
Consider two sets, A and B and f : A B a function.
f is one-to-one if it never maps two different elements of A into the same element of B, i.e., a, b A(a = b f (a) = f (b)); f is onto if it hits every element of B, i.e., b B, a A such that f (a) = b; f is called a correspondence if it is both one-to-one and onto.
Example Correspondences
Let N be the set of natural numbers, N = {1, 2, 3, . . .} and let E be the set of even natural numbers, E = {2, 4, 6, . . .}; Intuitively one may believe that size(N ) > size(E). However, using Cantor method we can show that N and E have the same size by constructing a correspondence f : N E; The correspondence f is dened by f (n) = 2n, Figure 1.
Figure 1:
Note:
1. n1 , n2 N , n1 = n2 , f (n1 ) = 2n1 , f (n2 ) = 2n2 i.e., f (n1 ) = f (n2 ); 2. n E, n = 2m, m N , i.e., n = f (m). Hence, f is a correspondence and thus sizeof (N ) = sizeof (E).
Denition 4.12
A set is countable if either it is nite or it has the same size as N .
A Complex Correspondence
Let Q be the set of positive rational numbers, Q = { m |m, n N }. n
Intuitively, Q seems to be much larger than N ; Yet we can show that sizeof (Q) = sizeof (N ) by constructing the correspondence c : N Q shown in Figure 2.
Correspondence c : Q N
1. Put N on two axes; 2. Line i contains all rational numbers that have numerator i, i.e. { ji Q|i N f ixed, j N }; 3. Column j contains all rational numbers that have denominator j, i.e. { ji Q|i N , j N f ixed}; 4. Number
i j
3. Continue this way skipping the elements that may generate i repetitions, such i that would generate a copy of 1 . 1
E
1
1 1
2
1 2
3
1 3
4
1 4
5
1 5
...
...
Figure 2:
A correspondence of N and Q
Uncountable Sets
A set for which no correspondence with N can be established is called uncountable.
Example of uncountable set:
The set R of real numbers is uncountable! Cantor proved that R is uncountable using the diagonalization method.
Proof:
Suppose that such a correspondence f : N R exits and deduce a contradiction showing that f fail to work properly. We construct an x R that cannot be the image of any n N .
Construction
Figure 3:
Listing R
Notation:
Formal Construction of x
Construct x (0, 1) by the following procedure:
x = 0.d1 d2 d3 d4 . . . where i N [di (x) = di (f (i))] x has an innite number of decimals constructed by the rule:
Note:
i N chose di a digit different from the i-th digit of f(i)
Consequence: i N , x = f (i). Hence, x does not belong to the list R; thus f is not a correspondence.
Application
Theorem 4.17 shows that some languages are not decidable or even Turing recognizable.
Reason:
There are uncountable many languages yet only countable many Turing machines. Because each Turing machine can recognize a single language and there are more languages than Turing machines some languages are not recognized by any Turing Machine. Such languages are not Turing recognizable!
Corollary 4.18
Some languages are not Turing-recognizable.
Proof:
2. Each Turing machine M has an encoding into a string M ; 3. If we omit those strings that are not Turing machines we can obtain a list of all Turing machines.
Fact 1
The set of all languages is uncountable. To show that the set of all languages is uncountable we show rst that the set of all innite binary sequences is uncountable.
Proof idea:
Assuming that B is countable we can set it into a list fb : N B. By the method of diagonalization we can construct an innite binary string y, such that y = fb (i) for any i N ;
Construction:
y = d1 d2 . . . dj . . . such that
Corollary
The set of all languages is uncountable. by construction: Let L be the set of all languages over .
Proof:
We will show that L is uncountable by constructing a correspondence B L. Since B is uncountable, and has the same size as L it result that L is uncountable.
Characteristic Sequences
Since is an alphabet, is countable. Let = {s1 , s2 , s3 , . . .} be the set of all strings over ; For each language A L there is a unique innite binary sequence A B constructed by: the i-th bit of A , A (i) = 1 if si A and A (i) = 0 if si A. A is the characteristic function of A in The function f : L B where f (A) = A is one-to-one and onto and hence it is a correspondence.
Proof:
1. f is one-to-one: L1 , L2 L, L1 = L2 L1 = L2 ; 2. f is onto: B there is a language L L with f (L) = . For = {s1 , s2 , . . .}, L = {si |si di () = 1}.
Conclusion
Since B is uncountable, L is uncountable.
={0 1 0 1
Fact 2
For M a TM, the language L(M ) is undecidable. We are ready to prove that the language
AT M = { M, w |M is a T M and M accepts w}
is undecidable.
Proof
Proceeds by contradiction, assuming that AT M is decidable.
Suppose that H is a decider of AT M . On input M, w where M is a TM and w is a string, H halts and accepts if M accepts w. Furthermore, H halts and reject if M fails to accept w.
Equational Expression of H
accept, if M accepts w; H( M, w ) = reject, if M does not accept w.
Proof, Continuation
Construct a new TM D that uses H as a subroutine.
D calls H to determine what M does when its input is M If M accepts M then D rejects; if M rejects M then D accepts.
The Machine D
D = "On input M , where M is a TM: 1. Run H on input M, M 2. Output the opposite of what H outputs: accepts if H rejects and rejects if H accepts".
Note
Running a machine on its own description is a common technique in computer sciences. Example, running a compiler on its own description allows compiler implementation and optimization.
In Conclusion
accept, if M does not accept M ; D( M ) = reject, if M accepts M .
Summarizing
Assume that H decides AT M ; Use H to build D that accepts M when M rejects it and rejects M when M accepts it; H and D performs as follows:
H accepts M, w exactly when M accepts w; D rejects M exactly when M accepts M ; D rejects D exactly when D accepts D .
Where Is Diagonalization?
To make the use of diagonalization obvious we construct the list of all Turing machines running on Turing machines as input in Figures 4,5,6.
M1 M2 M3 M4 M1 accept accept accept M2 accept accept M3 accept accept M4 accept ... ... ...
Mj
Running H
Figure 5 shows the result of running H on the machine in Figure 4.
M1 M2 M3 M4 M1 accept accept reject accept M2 reject accept reject accept M3 accept accept reject reject M4 reject accept reject reject ... ... ... ... ...
Figure 5:
Running D on D
Figure 6 shows the result of running H on the machine in Figure 4 when D is present.
M1 M2 M3 M4 D M1 accept accept reject accept reject M2 reject accept reject accept reject M3 accept accept reject reject accept M4 reject accept reject reject accept ... ... ... ... ... ... D accept accept reject accept ??? ... ... ... ... ... ...
Figure 6:
A contradiction occurs at D, D
Observation
We can construct a Turing-unrecognizable language.
AT M is an example of Turing undecidable language. But it is Turing recognizable; Now we construct a language which is Turing-unrecognizable; This construction relies on the fact that if both a language and its complement are Turing-recognizable the language is decidable.
That is:
for any undecidable language, either the language or its complement is not Turing-recognizable.
A New Concept
Co-Turing-recognizable language.
Complement of a language A is the language consisting of all strings that does not belong to A; A language is co-Turing-recognizable if it is the complement of a Turing-recognizable language.
An Important Result
A language is decidable iff it is both Turing-recognizable and co-Turing recognizable.
Theorem 4.22:
That is: A language A is decidable iff both A and C(A) are Turing-recognizable
Proof
if:
Assume that A is decidable. Since complement of a decidable language is decidable it result that both A and C(A) are Turing-recognizable. For L decidable, decided by M , the TM M that decides L is: M = On any input w: 1. Run M on w 2. If M accepts reject; if M rejects accept".
Proof, Continuation
only if:
Assume that both A and C(A) are Turing-recognizable. Let M1 be a recognizer for A and M2 a recognizer for C(A). Then the following TM M is a decider for A: M = "On input w: 1. Run both M1 and M2 on w in parallel; 2. If M1 accepts w accept; if M2 accepts w reject."
Observations
Running two machines M1 and M2 by a machine M in parallel means that M has two tapes, one for simulating M1 and other for simulating M2 ; M takes turns, simulating one step of each machine, which continues until one of the machines halts; Because w A or w C(A) either M1 or M2 must accepts w; Because M halts whenever M1 or M2 accepts, M always halts, so it is a decider. Further, it accepts all strings from A and rejects all strings not in A.
Conclusion
M is a decider for A, thus A is decidable.
Corollary
C(AT M ) is not Turing-recognizable.
Proof:
1. If C(AT M ) also were Turing-recognizable then AT M would be decidable. 2. But we have proved (Theorem 4.11) that AT M is not decidable. 3. Hence, C(AT M ) cannot be Turing-recognizable.
Application 1
Let A be a Turing-recognizable language consisting of descriptions of Turing machines:
A = { M1 , M2 , . . .}
where every Mi is a decider. Prove that some decidable language LD is not decided by any decider Mi whose description appears in A.
Solution Sketch
Use the diagonalization method to construct a decider D whose language is not among those decided by Mi , i = 1, 2, . . .. Since A is Turing-recognizable there is an enumerator E that enumerates the elements of A. Let M1 , M2 , . . . be the output of E. Let = {s1 , s2 , . . .} be a list of all strings over the alphabets of A.
The decider for D is: D = On input w: 1. Let i be the index of w on the list of strings , i.e., si = w. 2. Run Mi on input w 3. If Mi accepts, reject; if Mi rejects, accept".
Note:
D is a decider because each Mi is a decider. But D does not appear on the list
Application 2
Let A and B be two disjoint languages. Say that a language C separates A and B if A C and B C. Show that any two disjoint co-Turingrecognizable languages are separable by some decidable language.
Solution Sketch
Let A and B be two languages such that A B = and A and B are Turing-recognizable (by denition). Let J be the TM that recognizes A and K be the TM that recognizes B. Then the language C decided by the following TM T separates A and B:
T = On input w: 1. Simulate J and K on w by alternating the steps of the two machines; 2. If J accepts rst, reject. If K accepts rst, accept".
rates A and B