halting_lecturenotes
halting_lecturenotes
1 Review
Key point. Turing machines can be encoded as strings, and other Turing machines can read
those strings to peform “simulations”.
Intuitively, for recognizability we allow our TM to run forever on inputs that are not in
the language, while for decidability we require that the TM halt on every input.
Now recall our two most important results:
Theorem 1. There exist (uncountably many!) languages which are not Turing-recognizable.
Proof. (intuitive) There are as many strings as natural numbers, because every (finite) string
over a finite alphabet can be encoded as a binary number. There are as many TMs as strings,
because every TM can be encoded as a string. Thus, both the strings and the TMs are
countably infinite.
There are as many languages as real numbers. Every language is a subset of the set of
strings; we can think of this subset as being encoded by an infinite binary sequence (i.e. a
real number) with 1s at indices corresponding to strings in the language and 0s everywhere
else.
Thus there are more languages than Turing machines; we conclude that some (indeed,
“most”) languages are not recognized by any TM.
Now we will construct a specific undecidable language.
1
Definition 3. The language XT M = {hM i : M does not accept hM i}
Proof 1. (by Epimenides’ paradox) Suppose we had a Turing machine M deciding this lan-
guage. What happens when we run M with input hM i? If we claim it accepts, then by
definition it ought to reject; if it rejects, then it ought to accept! Either way, we have a
contradiction.
Alternatively, here’s a proof that it’s not even Turing-recognizable.
Proof 2. (by diagonalization) Suppose we constructed an (infinite) chart listing all the Turing
machines and all encodings of Turing machines. We write 1 in cell [i, j] if Mi accepts hMj i
and 0 otherwise:
hM1 i hM2 i hM3 i · · ·
M1 0 1 1
M2 1 1 1
M3 1 0 1
.. ..
. .
(The particular arrangement of 1s and 0s is unimportant—it will depend on our encoding
scheme.) Note that by reading the 1s from the ith row, we get the language decided by
Mi . Does XT M appear in any row of this list? Not the first row: M1 rejects hM1 i, so hM1 i
must be in XT M . Not the second row: M2 accepts hM2 i, so hM2 i must not be in XT M .
Continuing with this procedure, we can show that XT M is not the same as any row of this
enumeration of TMs, and as a consequence is not decided by any TM.
2
No.
Theorem 3. AT M is undecidable.
Proof. Suppose, towards contradiction, that we had a TM M deciding AT M . Then we could
construct a TM N deciding XT M , as follows:
• Given input hP i:
• Run M on hP, P i.
• If M accepts, reject.
• If M rejects, accept.
Clearly, N is a TM deciding XT M . But we know that there no such TM exists! Because the
existence of M implies the existence of N , we conclude that M also does not exist.
Clarification. Understand why AT M is recognizable but not decidable.
Key point. There is no Turing machine which can predict the output of all other Turing
machines. However, there are Turing machines which can predict the output of some other
Turing machines.
3
• Otherwise, we know that P terminates, and it is “safe” to simulate it on w. Do so.
• If P accepts, accept.
• If P rejects, reject.
Key point. There is no Turing machine which finds infinite loops in all other Turing ma-
chines (though again, it may do so for a restricted subset). This is a problem which would
have real, practical benefits if it were soluble, but it’s not.
• Construct a new TM P 0 which rejects if its input is not w, and otherwise simulates P
on w.
• Run M on hP i.
• If M accepts, reject.
• If M rejects, accept.
We have a contradiction.
5 Reductions
In working through these examples we’ve come across a very powerful proof technique: to
prove that some language is undecidable, we assume that we have a decider, and show that
this implies the existence of a decider for a known undecidable problem. This technique is
called reduction.
There are several different kinds of reduction; the kind that we’ve discussed so far is
called Turing reduction (for reasons that are hopefully obvious). The general idea is that
4
we assume we have a TM which computes the solution to one problem, and we use that to
compute the solution to another problem.
To say that a solver for B allows us to solve A (“A reduces to B”), we write
A ≤T B
(I’ve always found this notation weird. An easy way to remember it is that if A is reducible
to B, the machine that computes B is at least as powerful as the machine that computes
A: it is definitely powerful enough to solve A, and maybe other problems as well. So A is
“easier than” B.)
Question. AT M ≤T XT M , or vice-versa?
Vice-versa.
• Run M on P 0
• If M accepts, accept.
• If M rejects, reject.
Once again, a contradiction.
5
Definition 8. The language EQT M = {(hM i, hN i) : L(M ) = L(N )}
Proof. Suppose we have a decider M for EQT M . Construct the following decider for ET M :
• Given input hP i:
7 Next Class
It seems like every interesting language of Turing machines we’ve come up with is undecid-
able. Is there any property of Turing machines which can be decided?