Module 9 Undecidability What computers cannot do. CS 360: Introduction to the Theory of Computing Winter 2015 Collin Roberts University of Waterloo 1
Topics for this module ◮ An undecidable language ◮ Other undecidable languages ◮ Reduction: how to prove a given language is undecidable ◮ Undecidable problems in automata theory ◮ End of the course In my view this is by far most important and interesting material in CS 360. 2
A language that is not decidable Remember from before: ◮ L is decidable or recursive if there exists a Turing machine M with L = L ( M ) where M halts on all inputs. ◮ L is recursively enumerable if there exists a Turing machine M with L = L ( M ). Are all languages recursive? No. 3
Diagonalization argument The argument is similar to showing there are more real numbers than integers. This is counterintuitive: is one type of infinity bigger than another? Yes. ◮ We say that sets S and T are of equal cardinality if there exists a bijection f between S and T . ◮ (Recall that a function f : S → T is a bijection if it is both injective and surjective.) ◮ If S and T are both finite, then the definition of equal cardinality agrees with our intuition: the sets are of equal cardinality if they have the same number of elements. ◮ For infinite sets, this can feel counter-intuitive: for example, if ◮ S = { even integers } , and ◮ T = { all integers } , and ◮ f ( x ) = x 2 , then f : S → T is a bijection. ◮ S and T are of equal cardinality, even though our intuition might tell us that S is “half” the size of T . Are there bigger and smaller infinities? 4
Countable sets ◮ A set S is countably infinite: of equal cardinality to Z (or any infinite subset of Z ). ◮ A set S is countable: of equal cardinality to a subset of Z . ◮ A countable set S can be described by listing: S = { s 1 , s 2 , s 3 , . . . , s n } for finite S , or S = { s 1 , s 2 , s 3 , . . . } for infinite S . ◮ A set S is uncountable if it is not countable. ◮ If S is uncountable, then any listing S = { s 1 , s 2 , s 3 , . . . } misses some members of S . We know that countable sets exist, e.g. Z , or { even integers } . The positive integers are also countable. But do uncountable sets exist? 5
The real numbers between 0 and 1 are uncountable. Consider S = [0 , 1] ⊂ R . Is S countable? ◮ For a contradiction, assume that S is countable. ◮ Suppose that f : Z + → S is a bijection. . 0 11011010111 · · · s 1 = ◮ Then S = { s 1 , s 2 , . . . } = . 0 1 0001111111 · · · s 2 = { f (1) , f (2) , . . . , } . = . 11 1 000011101 · · · s 3 ◮ List the binary expansions of = . 110 1 11100101 · · · s 4 S , in the order s 1 , s 2 , . . . . . . ◮ Consider the number a that . we get by concatenating the opposite of the i th bit at each position s i in the list. In this example, a = . 1000 · · · . Note: a ∈ S , by the definition of S . 6
The real number a is not one of the s i ! We have constructed a so that it is not one of the s i . ◮ It differs from s 1 in the first bit. ◮ It differs from s 2 in the second bit. ◮ It differs from s i in the i th bit! We see a � = s i for all choices of i . But a ∈ S . So we did not enumerate all of the members of S ! We have a contradiction, and therefore S is not countable. ◮ Note: if we add a to the list, we can again find a missing number. ◮ To show this takes some boring housekeeping, e.g. 0 . 01111111 · · · = 0 . 1000000 · · · . ◮ Actually, R is much larger than Z . Take a measure theory course to learn all the gory details. ◮ Do you find this proof disturbing? If so, then you are not alone! Georg Cantor, who first gave this proof, and created modern set theory, suffered depression and poor psychological health as a result. This is called a diagonalization argument. 7
Building to a proof about Turing machines We will adapt this argument to show that there are undecidable languages. We need to identify each Turing machine M (over the binary alphabet { 0 , 1 } ) with a binary string. ◮ Suppose we have states q 1 , . . . , q r , for some r . ◮ Let q 1 be the start state and let q 2 be the unique accept state. (One accept state is enough as we halt when we enter any accept state.) ◮ Suppose that the tape symbols are X 1 , . . . , X s , for some s . Assume that ◮ X 1 = 0, ◮ X 2 = 1, ◮ X 3 = B , ◮ and the other symbols may be assigned as required. ◮ Refer to direction L as D 1 , and R as D 2 . ◮ Now we can encode the transition function. 8
Building to a proof about Turing machines ◮ Suppose that one transition rule is δ ( q i , X j ) = ( q k , X l , D m ), for some integers i , j , k , l and m . ◮ Encode this rule as 0 i 10 j 10 k 10 l 10 m . ◮ As all of i , j , k , l and m are at least 1, there are no consecutive 1s in this string. ◮ A code for the entire TM M consists of all the n codes for the transitions, in some order, separated by pairs of 1s: 11 C 1 11 C 2 11 · · · 11 C n 11 , where each C i is the code for transition number i in M . ◮ We have encoded a binary string to identify the Turing machine M ; treat it as an integer index for each machine M . f ( M ) is the integer that we produce in this way. ◮ There can be multiple codes for M (but only finitely many). We could renumber the states, for example. We will see soon why this point does not affect the diagonalization argument that we are going to make. ◮ The set of Turing machines is countable. We just built a bijection to a subset of Z . 9
So what about Turing machines? ◮ There are only countably many Turing machines, hence there are only countably many recursively enumerable languages. ◮ But there are uncountably many unary languages. ◮ Here is a bijection from the set of languages over the alphabet { a } to the set S = [0 , 1] defined before, which we proved is not countable: ◮ Given a language L ⊆ { a } ∗ , define � 2 − ( i +1) . f ( L ) = i ≥ 0: a i ∈ L ◮ f is injective. ◮ If a i ∈ L 1 and a i / ∈ L 2 , then the ( i + 1) th bit is 1 in f ( L 1 ) but is 0 in f ( L 2 ). ◮ We can also see how to construct the language L so that f ( L ) equals any desired expansion, so that f is surjective. ◮ If the i th bit is 1 in the expansion, then include a i − 1 in L . ◮ If the i th bit is 0 in the expansion, then exclude a i − 1 from L . ◮ There must be undecidable languages, as there are not enough Turing machines! This proof is completely unsatisfying! What are these undecidable languages? Can we adapt Cantor’s proof somehow? 10
A language about Turing machines Every Turing machine M has an identifier w = f ( M ). ◮ Consider the language L SA = { w | the Turing machine M represented by w accepts w } . ◮ L SA is the language of identifiers for machines that accept when given their own identifiers as inputs. ◮ L SA : The subscript SA indicates self-accepting. ◮ It might seem that we should not be allowed to make this definition, but why is this? Lots of programs process other programs! Remember: w = f ( M ) is basically the code of the program for M . ◮ Parsers, compilers, interpreters, profilers, etc. ◮ For example, a syntax parser whose input is the parser should accept: “Yes, that program uses proper syntax.” It will turn out that L SA is not decidable, but L SA will not be our first example of an undecidable language. 11
An undecidable language Instead, consider L NSA = { w | the Turing machine M represented by w does not accept w } . ◮ L NSA is the language of identifiers for Turing machines that do not accept when given their own identifiers as inputs. ◮ For example, a program that finds syntax errors: it will not accept itself, since it does not have any syntax errors! If M is a properly coded syntax error detector represented by w , then w ∈ L NSA . Is L NSA the language of any Turing machine? ◮ Suppose that L NSA = L ( M ), for some Turing machine M . ◮ Does M accept its own identifier w ? Is w ∈ L NSA ? ◮ Suppose M accepts its own identifier w . ◮ Then w is not in L NSA , which is the language of M . ◮ So M does not accept w . ◮ Suppose M does not accept its own identifier w . ◮ Then w is in L NSA , which is the language of M . ◮ So M accepts w . 12
L NSA is not the language of any Turing machine This tells us that L NSA is not the language of any Turing machine. ◮ We formalize this via a retread of Cantor’s diagonalization argument. ◮ For any Turing machine M , L NSA differs from L ( M ) in at least one position. ◮ If the Turing machine M represented by w accepts w (so that w ∈ L ( M )), then w / ∈ L NSA . ◮ If the Turing machine M represented by w does not accept w (so that w / ∈ L ( M )), then w ∈ L NSA . ◮ L NSA differs from the languages of all Turing machines. ◮ By definition, L NSA is not recursively enumerable. ◮ Then L NSA is also not decidable. (Your text denotes L NSA as L d , where the subscript d reminds us of diagonalization.) ◮ Now we see why the uniqueness of the identifier for a given Turing machine is not crucial for this result. ◮ No identifier can represent a Turing machine M such that L ( M ) = L NSA . 13
Other undecidable languages ◮ Some undecidable languages are recursively enumerable. ◮ Consider L SA , the language of encodings for machines that do accept their encoding. ◮ L SA is recursively enumerable, but undecidable. ◮ We need a new Turing machine, the Universal Turing Machine: an interpreter. 14
Recommend
More recommend