Open In Colab

The halting problem

We come to one of the most famous and most basic results in computability theory.

Theorem 2

There is no program \(p\) such that for all words \(x\) and \(y\),

\[\begin{split}\begin{array}{lcl} \phifn^2_p(x,y) & = & \left\{ \begin{array}{ll} \one & \mbox{if $\phifn_x(y)\dar$}\\ \hash & \mbox{if $\phifn_x(y)\uparrow$} \end{array} \right. \end{array} \end{split}\]

Here is the proof. Suppose toward a contradiction that we had such a program \(p\). Modifying \(p\), we get a program \(q\) so that for all \(a\),

\[\begin{split} \begin{array}{lcl} \phifn^1_q(a) & = & \left\{ \begin{array}{ll} \uparrow & \mbox{if $\phifn_a(a)\dar$}\\ \downarrow& \mbox{if $\phifn_a(a)\uparrow$} \end{array} \right. \end{array} \end{split}\]

Here’s how this would be done. Assume that \(p\) preserves its input. Let \(p\) have \(k\) instructions. Let

\[ q \quadeq \copyprog_{1,2,3} + p + \one^3\hash^5 + \one^2 \hash^3 + \one^{k + 2} \hash^4 \]

Then \(q\) has the property that we want. But now, take \(a\) to be \(q\). Then

\[ \phifn_q(q)\dar \quadiff \phifn_q(q)\uparrow. \]

Contradiction!

Tip

Look up this setting of the proof by Geoffrey Pullum in the spirit of Dr. Seuss.

Corollaries

There are a number of corollaries to the basic undecidability result.

Corollary 1

The set of programs which halt when run on all empty registers is undecidable.

Corollary 2

The set of programs which halt when run on themselves is undecidable.

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 3

The halting problem is undecidable even for programs in \(A\) when run on all emtpy registers.

Exercise 40

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.