The halting problem#
We come to one of the most famous and most basic results in computability theory, the undecidability of the halting problem, first proved by Turing in 1936.
Theorem 11
There is no program \(p\) such that for all words \(x\) and \(y\),
Proof. Suppose toward a contradiction that we had such a program \(p\). Modifying \(p\), we get a program \(q\) so that for all \(a\),
In words, running \(q\) on \(a\) diverges iff running \(a\) on itself converges, and vice-versa. And this holds for all \(a\). So in particular it holds for \(q\). And this leads to a contradiction, as we shall see formally just below.
Here’s how this one would actually get \(q\) from \(p\). Assume that \(p\) preserves its input. Let \(p\) have \(k\) instructions. Let
Then \(q\) has the property that we want. But now, take \(a\) to be \(q\). Then
Contradiction!
Tip
Look up this setting of the proof by Geoffrey Pullum in the spirit of Dr. Seuss.
Corollary 3
The set \(\overline{K}\) computably enumerable.
Proof. Suppose towards a contradiction that \(r\) is a program whose domain is \(\overline{K}\). Then just as with \(q\) in the proof above, we again have a contradiction: \([\![r]\!](r)\!\!\downarrow\) iff \([\![r]\!](r)\!\!\uparrow\).
Tip
If you have read the section on the Recursion Theorem, you might enjoy a slightly different proof of Theorem 11.

Assume towards a contradiction that there is a program \(p\) as above. Then we easily modify it to get a program \(q\) so that
By Theorem 9, there is some \(x^*\) so that for all \(y\),
Now we cannot have \([\![x^*]\!](y)\!\!\uparrow\), since if we did, we would also have \([\![x^*]\!](y)\!\!\downarrow\) by the second line above. So, \([\![x^*]\!](y)\!\!\downarrow\). But then by the first line, \([\![x^*]\!](y)\simeq [\![x^*]\!](y) + 1\), and this is impossible.
Corollaries#
There are a number of corollaries to the basic undecidability result. Let us begin by recalling the sets of that we mentioned earlier:
Of these the first two are computable, easily. But all of the others are not. These are all corollaries of Theorem 11, sometimes with additional points provided by the \(s^m_n\)-Theorem.
Corollary 4
\(K\), the set of programs which halt when run on themselves, is undecidable.
Corollary 5
\(K_0\), the set of programs which halt when run on all empty registers, is undecidable.
Exercise 65
For all the sets \(A\) in our reference list, Find a subset of \(A\) which is infinite and computable.
Then do the same for the complement set \(\overline{A}\).
Improvement for one-register programs#
There is also an improved version of the basic result.
Let \(A\) be the set of programs which are tidy and which only use one register.
Corollary 6
The halting problem is undecidable even for programs in \(A\) when run on all emtpy registers.
Exercise 66
The language \(\one\hash\) has infinitely many instructions: the instructions are the words \(\one^k \hash^{\ell}\), where \(k\in \N\) and \(1\leq \ell\leq 5\).
For each finite set \(F\) of \(\one\hash\) instructions, we can consider \(H_F\), the set of programs \(p\) built using the instructions of \(F\) (and no others) such that \(\phifn_p(\ )\dar\).
For example, if \(F = \set{\one\hash, \one\hash\hash}\), then \(H_F\) is decidable. This is because every program built from these two instructions halts.
Find a finite set \(F\) such that \(H_F\) is undecidable.
Rice’s Theorem#
Theorem 12
Let \(S\) be any set of programs, and assume that \(S\) is closed under equivalence of words as one-place functions: if \(x\in S\), and if \([\![x]\!]\) and \([\![y]\!]\) are the same partial function, then \(y\in S\).
If \(S\) is decidable, then \(S\) is either the empty set or the set of all programs.
Proof. If not, we can fix programs \(p\in S\) and \(q\notin S\), and we also can fix a program \(s\) which computes the characteristic function of \(S\).
Now let
Let \(x^*\) be such that \([\![x^*]\!] = [\![f(x^*)]\!]\). If \(x^*\in S\), then \( [\![s]\!](x^*)\simeq 1\). But by definition of \(f\), \([\![f(x^*)]\!](x) = [\![q]\!](x)\) for all \(x\). This tells us that \([\![f(x^*)]\!]\) and \([\![q]\!]\) are the same partial function. So since \(q\notin S\), we have \(f(x^*)\notin S\). This contradicts \(S\) being closed under equivalence. So we have a contradiction in case \(x^*\in S\). But we have a similar contradiction in case \(x^*\notin S\).
Corollary 7
The following sets are undecidable: \(Fin\), \(Inf\), and \(Tot\).
Exercise 67
Show that \(Inf \leq_m Tot\) and \(Tot \leq_m Inf\).
Exercise 68
Show that the following set \(S\) of programs is undecidable:
\(S\) is the set of programs \(p\) which, when run on all empty registers at some point write 1
into R2.
Exercise 69
What about the set of programs which at some point execute their second instruction? Is that set decidable?