Chapter 8 Decidability 8.1 Decision Problems A decision problem P is a set of questions, each of which has a yes or no answer. The single question ''Is 8 a perfect square?'' is an example of the type of question under consideration in a decision problem. A decision problem usually consists of an infinite number of related questions. For example, the problem PSQ of determining whether an arbitrary natural number is a perfect square consists of the following questions: p0 : Is 0 a perfect square? p1 : Is 1 a perfect square? p2 : Is 2 a perfect square? . . A solution to a decision problem P is an algoritm that determines the appropriate answer to every question p P . An algorithm that solves a decision problem should be 1. Complete 2. Mechanistic 3. Deterministic. A procedure that satisfies the preceding properties is often called effective. A problem is decidable if it has a representation in which the set of accepted input strings form a recursive language. Since computations of deterministic multitrack and multitape machines can be simulated on a standard Turing machine, solutions using these machines also establishes the decidability of a problem. 8.2 The Church-Turing Thesis The Church-Turing thesis asserts that every solvable decision problem can be transformed into an equivalent Turing machine problem. The Church-Turing thesis for decision problems: There is an effective procedure to solve a decision problem if, and only if, there is a Turing machine that halts for all input strings and solves the problem. The extended Church-Turing thesis for decision problems A decision problem P is partially solvable if, and only if, there is a Turing machine that accepts precisely the elements of P whose answer is yes. A proof by the Church-Turing thesis is a shortcut often taken in establishing the existence of a decision algorithm. Rather than constructing a Turing machine solution to a decision problem, we describe an intuitively effective procedure that solves the problem. The Church-Turing thesis asserts that a decision problem P has a solution if, and only if, there is a Turing machine that determines the answer for every p P . If no such Turing machine exists, the problem is said to be undecidable. 8.3 The Halting Problem for Turing Machines Theorem 3.1 The halting problem for Turing machines is undecidable. Proof: The proof is by contradiction. Assume that there is a Turing machine H that solves the halting problem. A string is accepted by H if i. the input consists of the representation of a Turing machine M followed by a string w ii. the computation of M with input w halts. If either of these conditions is not satisfied, H rejects the input. The operation of the machine H is depicted by the fig 28 Figure 28: Halting Machine The machine H is modified to construct a Turing machine H ' . The computations of H ' are the same as H except H ' loops indefinitely whenever H terminates in an accepting state, that is, whenever M halts on input w . The transition function of H ' is constructed from that of H by adding transitions that causes H ' to move indefinitely to the right upon entering an accepting configuration of H . H ' is combined with a copy machine to construct another Turing machine D . The input to D is a Turing machine representation R (M ) . A computation of D begins by creating the string R( M ) R( M ) from the input R (M ) . The computation continues by running H ' on R( M ) R( M ) . Figure 29: Turing Machine D with R(M) as input The input to the machine D may be the representation of any Turing machine with alphabet 0,1, B . In particular, D is such a machine. Consider a computation of D with input R (D ) . Rewriting the previous diagram with M replaced by D and R (M ) by R (D ) , we get Figure 30: Turing Machine D with R(D) as input Examining the preceding computation, we see that D halts with input R (D ) if, and only if, D does not halt with input R (D ) . This is obviously a contradiction. However, the machine D can be constructed directly from a machine H that solves the halting problem. The assumption that the halting problem is decidable produces the preceding contradiction. Therefore, we conclude that the halting problem is undecidable. Corollary 3.1 The language LH = {R(M )w | R(M )} where R (M ) is the representation of a Turing machine M and M halts with input w over {0,1}* is not recursive. 8.4 A Universal Machine The machine U is called a universal Turing machine since the outcome of the computation of any machine M with input w can be obtained by the computation of U with input R ( M ) w . Figure 31: Universal Machine Theorem 4.1 The language LH is recursively enumerable. Proof: A deterministic three-tape machine U is designed to accept LH by halting. A computation of U begins with the input on tape 1. The encoding scheme presented in Section 8.3 is used to represent the input Turing machine. If the input string has the form R ( M ) w , the computation of M with input w is simulated on tape 3. The universal machine uses the information encoded in the representation R (M ) to simulate the transitions of M . A computation of U consists of the following actions: 1. If the string does not have the form R ( M ) w for a Turing machine M and string w , U moves indefinitely to the right. 2. The string w is written on tape 3 beginning at position one. The tape head is then repositioned at the leftmost square of the tape. The configuration of tape 3 is the initial configuration of a computation of M with input w . 3. A single 1, the encoding of state q0 , is written on tape 2. 4. A transition of M is simulated on tape 3. The transition of M is determined by the symbol scanned on tape 3 and the state encoded on tape 2. Let x be the symbol from tape 3 and qi the state encoded on tape 2. a. Tape 1 is scanned for a transition whose first two components match en(qi ) and en(x ) . If there is no such transition, U halts accepting the input. b. Assume tape 1 contains the encoded transition en(qi )0en( x)0en(q j )0en( y )0en(d ) . Then i. en(qi ) is replaced by en( q j ) on tape 2. The symbol y is written on tape 3. The tape head of tape 3 is moved in the direction Example 4.3-2n specified by 5. The next transition of M is simulated by repeating steps 4 and 5. ii. iii. The simulations of the universal machine U accepts the strings in LH . The computations of U loop indefinitely for strings in {0,1}* LH . Since LH = L(U ) , LH is recursively enumerable. Corollary 4.1 The recursive languages are a proper subset of the recursively enumerable languages. Proof: The acceptance of LH by the universal machine demonstrates that LH is recursivelyenumerable while Corollary 3.1 established that LH is not recursive. Note: A language L is recursive if both L and L are recursively enumerable. Corollary 4.2 The language LH is not recursively enumerable. 8.5 The Post Correspondence Problem The undecidable problems presented in the preceding sections have been concerned with the properties of Turing machines or mathematical systems that stimulate Turing machines. The Post correspondence problem is a combinatorial question that can be described as a simple game of manipulating dominoes. A domino consists of two strings from a fixed alphabet, one on the top half of the domino and the other on the bottom The game begins when one of the dominoes is placed on a table. Another domino is then placed to the immediate right of the domino on the table. This process is repeated, constructing a sequence of adjacent dominoes. A Post correspondence system can be thought of as defining a finite set of domino types. We assume that there is an unlimited number of dominoes of each type; playing a domino does not limit the number of future moves. A string is obtained by concatenating the strings in the top halves of a sequence of dominoes. We refer to this as the top string. Similarly, a sequence of dominoes defines a bottom string. The game is successfully completed by constructing a finite sequence of dominoes in which the top and bottom strings are identical. Consider the Post correspondence system defined by dominoes in fig 32, Figure 32: Post Correspondence System The sequence in fig 33 Figure 33: Post Correspondence Solution is a solution to this Post correspondence system. Formally, a Post Correspondence System consists of an alphabet and a finite set of ordered pairs [ui , vi ], i = 1,2,, n, where ui , vi . A solution to a Post correspondence system is a sequence i1 , i2 ,, ik such that ui1ui 2 ui k = vi1vi 2 vi k . The problem of determining whether a Post correspondence system has a solution is the Post correspondence problem. Example 5.1 The Post correspondence system with alphabet [aaa, aa ], [baa, abaaa ] has a solution. Figure 34: Example 5.1 {a , b} and ordered pairs