A Non-Turing-Recognizable Language: Verview
A Non-Turing-Recognizable Language: Verview
A non-Turing-recognizable language
1 O VERVIEW
Thus far in the course we have seen many examples of decidable languagesthey include all of the regular and context-free languages, as well as many other interesting examples. A few examples of undecidable languages came up when we discussed languages about context-free grammars, such as this language: EQCFG = { G, H : G and H are context-free grammars with L( G ) = L( H )}. We did not prove that any of these languages are undecidable, however. The goal for this lecture is to prove that a particular language is not decidable. In fact, we will prove something stronger, which is that a particular language is not Turing-recognizable. The proof will turn out to be remarkably simple, and almost identical to Cantors proof that P (N ) is uncountable from the very rst lecture of the course. This proof uses a technique called diagonalization, and we will see why this name is used.
Before we can describe a non-Turing-recognizable language, we need to briey discuss encodings of Turing machines. For the sake of this particular discussion, and for the rest of this lecture, we will restrict our attention to Turing machines whose input alphabet is = {0, 1}. So, consider the collection of all 1DTMs having input alphabet . The Turing machines in this class can have any number of states, any tape alphabet that includes 0, 1, and the blank symbol B, any possible transition function, and so on. Of course, we do not really want to consider two Turing machines to be different if they function in exactly the same way, and differ only in the names assigned to their states or tape symbols, so we will assume that the Turing machines in this class have state sets of the form Q = {q0 , . . . , qm } for some m 0 and tape alphabets of the form = {0 , . . . , k } for some k 2 (where 0 = B, 1 = 0, 2 = 1, and 3 , . . . , k are any additional tape symbols that might be used). Having made these simple assumptions, there are certainly a countable number of Turing machines in the class we are considering. We will assume that we have picked some encoding scheme that lets us take any Turing machine M from our class and encodes it as a binary string M . If you are interested in a particular encoding scheme, you can nd one in the text in Section 9.1.2; but the specics of the scheme are not really important for this lecture. All that we really need to assume right now is that every Turing machine M in our class has an encodingwhich must surely be true if our encoding is a sensible one. It could, by the way, be the case that some binary strings do not encode a Turing machine at all, or that some Turing machines could be encoded in multiple ways, using our chosen encoding scheme. There might be some reason to avoid encoding schemes that have either of these properties for other purposes, but for this lecture we do not care about these things. Now, if someone hands you a string w , there are two possibilities: either w is a valid encoding of a 1DTM M with input alphabet , or it is not. With this in mind, we will dene for every string w a 1DTM Mw in the following way. 1
1. If w is a valid encoding of a 1DTM M having input alphabet (i.e., w = M ), then we dene Mw to be this Turing machine M. 2. If w is not a valid encoding of any 1DTM having input alphabet , then Mw is dened to be the 1DTM that looks like this: q0
Note that there is nothing special about this particular Turing machineweve just chosen something simple and arbitrary to make sure that Mw is a well-dened Turing machine for every possible string w . So now, if we list all of the 1DTMs that we get in this way: M , M0 , M1 , M00 , M01 , M10 , M11 , M000 , . . . (1)
then we get a list containing every 1DTM whose input alphabet is . (It could be that some Turing machines appear many times in the list, but this is ne.)
Now we are ready to dene our rst undecidable language. It will, in fact, be non-Turingrecognizable. It is as follows: Ld = {w : w L( Mw )} . Here, the Turing machines Mw are as we dened them in the previous section. This means that the language Ld depends upon the choice of an encoding scheme for Turing machines. If you started with a different encoding, you would have a different languagebut its interesting properties (in particular, that it is not Turing-recognizable) would not change. By the way, the subscript d stands for diagonal, which will make more sense later in the lecture. Theorem 1. The language Ld is not Turing-recognizable. Proof. Assume toward contradiction that Ld is Turing-recognizable. By the denition of Turing recognizability, this means that Ld = L( M ) for some 1DTM M having input alphabet . We know that the list (1) dened above includes every such Turing machine, so we may take w to be the lexicographically rst string such that Mw = M, so that Ld = L( Mw ). We now ask ourselves whether or not this particular string w is or is not contained in Ld . We have w L d w L ( Mw ) w L d , where the equivalence (a) follows from the denition Ld = {w : w L( Mw )} and the equivalence (b) follows from the fact that Ld = L( Mw ). We have proved that w Ld w Ld , which is a contradiction. It therefore follows that Ld is not Turing-recognizable.
(a) (b)
You should notice, as I stated in the beginning of the lecture, that this proof is almost identical to Cantors proof that P (N ) is uncountable, which we saw in the rst lecture of the course. You might also notice that the proof has very little to do with Turing machines. If, for instance, you had dened an encoding scheme for DFAs instead of Turing machines, so that (1) was instead a list of all possible DFAs, then the above proof would succeed in constructing a non-regular language rather than a non-Turing-recognizable one. (That would be less interesting, though, because we have other ways to prove languages are not regular.)
W HY IT IS CALLED DIAGONALIZATION
The proof technique that the above proof represents is called diagonalization. Let us now discuss where this name comes from. Imagine rst drawing an innitely large table whose rows are labelled by the 1DTMs M , M0 , M1 , M00 , M01 , M10 , M11 , M000 , . . . and whose columns are labelled by the strings in (in lexicographic order). In the entry indexed by each pair ( Mw , x), place a 1 if Mw accepts x, and a 0 otherwise. In other words: Entry ( Mw , x) is 1 if x L( Mw ) 0 if x L( Mw ).
For instance, the upper left-hand corner of this table might look like this: M M0 M1 M00 M01 M10 M11 . . . 0 1 1 0 1 1 0 . . . 0 0 0 1 0 1 0 0 . . . 1 0 1 1 0 0 0 1 . . . 00 0 0 0 0 0 1 1 . . . 01 0 1 1 1 1 0 0 . . . 10 0 0 1 0 0 0 1 . . . 11 0 1 1 0 1 0 1 . . .
.. .
Of course, the entries in this hypothetical picture are meaninglessI did not pick an encoding scheme for Turing machines and test them on different inputs to gure out the entries in the table. But, if you really did choose an encoding scheme as discussed in Section 2, there would be welldened entries in the table. 3
Now, consider a particular row in the tablefor instance, the one indexed by the Turing machine M10 . You get an innite sequence of 0s and 1s that completely determines the language accepted by M10 . Using the hypothetical entries in the above picture, we would have that M10 accepts , 00, and maybe many other strings whose columns are not pictured. This sequence of 0s and 1s is called the characteristic sequence of the language L( M10 ). What we are after is a language whose characteristic sequence is different from all of the rows in the table. If we have such a language, we know it cannot be Turing-recognizable, because the rows in the table give us the characteristic sequences for every possible Turing-recognizable language (over the alphabet ). This is because every possible 1DTM with input alphabet appears in the list (1), and therefore indexes at least one row of the table. So, how can we build such a sequence? One answer is to look at the diagonal entries of the table: M M0 M1 M00 M01 M10 M11 . . . 0 1 1 0 1 1 0 . . . 0 0 0 1 0 1 0 0 . . . 1 0 1 1 0 0 0 1 . . . 00 0 0 0 0 0 1 1 . . . 01 0 1 1 1 1 0 0 . . . 10 0 0 1 0 0 0 1 . . . 11 0 1 1 0 1 0 1 . . .
.. .
If we ip each of these entries, we will obtain an innite sequence of bits that differs from every row in the table. In the example table above, we obtain the sequence 1101010 when we ip the diagonal entries. The reason why this sequence differs from every row in the table is as follows: 1. The sequence is different from the rst row, because the two sequences must differ in the rst position (because we chose the rst bit of our new sequence to be the negation of the rst bit of the rst row). 2. The sequence is different from the second row, because the two sequences must differ in the second position. 3. Similar reasoning for every other row. The new sequence differs from row k in the k-th position. So, we have obtained the characteristic sequence of a language that is not Turing-recognizable, because it differs from every row in the table. If we think for a moment, then we realize that the 4
language given by this sequence, which we obtained by ipping the diagonal entries of the table, is more succinctly described as follows:
{w : w L( Mw )} .
This is precisely the language Ld . Hopefully you now see why the technique is called diagonalization. It is a very simple and general ideaif you have an innite table like the one above, it allows you to construct a sequence that differs from every row in the table. The entries dont necessarily need to be bits, and the rows and columns can be indexed by anything we want. This turns out to be a very important proof technique in theoretical computer science and mathematics that can be applied in several interesting settings.