Cite

This course has no released version yet: the text at this address may change. Cite a released version when one exists.

/courses/fundamentals/halting-problem
@misc{fundamentals-halting-problem,
  title = {{The halting problem}},
  howpublished = {Lesson 3 of \emph{Fundamentals of computability}, Computability Theory course notes},
  url = {/courses/fundamentals/halting-problem},
  note = {Unreleased working version}
}

To cite a single statement, use the # link that appears next to its heading.

Lesson 3 of 6

The halting problem

Undecidability of the halting problem; many-one reductions; undecidability of totality and of halting on a fixed input.

35 min6 questions
Before this lesson:The universal function and the SMN theorem · Diagonalization and computation (Countability and diagonalization)
Fundamentals of computability · lesson 3 of 6
  1. Programs as numbers
  2. The universal function and the SMN theorem
  3. The halting problem
  4. Computably enumerable sets
  5. Kleene's fixed point theorem
  6. Rice's theorem

This lesson proves that the halting problem is not computable, and introduces the main tool for transferring undecidability from one problem to another: many-one reductions. With them, the undecidability of the halting problem propagates to many other questions about programs — halting on a fixed input, totality, emptiness of the domain — and, outside computability theory, to problems of number theory, group theory and logic.

3.1 The halting set

Definition 3.1.#

The halting set, or halting problem, is

∅′={e∈N:Φe(e) ⁣ ⁣↓}.\emptyset' = \{ e \in \nat : \Phi_e(e)\converge \}.

The set H={⟨e,x⟩:Φe(x) ⁣ ⁣↓}H = \{ \langle e, x \rangle : \Phi_e(x)\converge \} is the general halting set.

The notation ∅′\emptyset', read “zero jump”, comes from the theory of the Turing jump: ∅′\emptyset' is the jump of the empty set. The restriction to the diagonal x=ex = e makes the diagonal argument direct; the general halting set has the same degree of difficulty, as shown below.

Theorem 3.2.#

The set ∅′\emptyset' is not computable.

Proof of Theorem 3.2.

Suppose ∅′\emptyset' is computable. Consider the following algorithm DD: on input xx, decide whether x∈∅′x \in \emptyset'; if so, enter an infinite loop; otherwise, halt with output 00. By Proposition 1.6, DD computes a partial computable function, so it has an index dd, and for every xx,

Φd(x) ⁣ ⁣↓  ⟺  x∉∅′  ⟺  Φx(x) ⁣ ⁣↑.\Phi_d(x)\converge \iff x \notin \emptyset' \iff \Phi_x(x)\diverge.

For x=dx = d, this gives Φd(d) ⁣ ⁣↓  ⟺  Φd(d) ⁣ ⁣↑\Phi_d(d)\converge \iff \Phi_d(d)\diverge, a contradiction.

This is Cantor’s diagonal argument applied to the table whose rows are the partial functions Φe\Phi_e: the algorithm DD differs from row xx at column xx, by converging where it diverges and diverging where it converges. The same argument is presented in the course on countability in a slightly different form, through partial functions without total extensions (Corollary 6.8 of “Diagonalization and computation”).

3.2 Many-one reductions

Definition 3.3.#

Let A,B⊆NA, B \subseteq \nat. A many-one reduction of AA to BB is a total computable function ff such that for all xx,

x∈A  ⟺  f(x)∈B.x \in A \iff f(x) \in B.

We write A≤mBA \leq_m B if such an ff exists, and A≡mBA \equiv_m B if A≤mBA \leq_m B and B≤mAB \leq_m A.

The reduction transforms each question ”x∈Ax \in A?” into a question ”f(x)∈Bf(x) \in B?” with the same answer. When ff is moreover injective, one speaks of a one-one reduction, written A≤1BA \leq_1 B.

Proposition 3.4.#
  1. The relation ≤m\leq_m is reflexive and transitive.
  2. A≤mBA \leq_m B if and only if N∖A≤mN∖B\nat \setminus A \leq_m \nat \setminus B.
  3. If A≤mBA \leq_m B and BB is computable, then AA is computable. Equivalently, if A≤mBA \leq_m B and AA is not computable, then BB is not computable.
Proof of Proposition 3.4.
  1. The identity reduces AA to AA. If ff reduces AA to BB and gg reduces BB to CC, then g∘fg \circ f is total computable and x∈A  ⟺  f(x)∈B  ⟺  g(f(x))∈Cx \in A \iff f(x) \in B \iff g(f(x)) \in C.
  2. The same ff works: x∉A  ⟺  f(x)∉Bx \notin A \iff f(x) \notin B.
  3. χA=χB∘f\chi_A = \chi_B \circ f is total computable.

To show that a set BB is not computable, it therefore suffices to reduce a non-computable set, typically ∅′\emptyset', to BB. Most reductions from ∅′\emptyset' are built with the SMN theorem: from ee, one computes the index of a program whose behavior depends on whether Φe(e)\Phi_e(e) converges.

Proposition 3.5.#
  1. ∅′≡mH\emptyset' \equiv_m H.
  2. ∅′≤m{e:Φe(0) ⁣ ⁣↓}\emptyset' \leq_m \{ e : \Phi_e(0)\converge \}, and ∅′≤m{e:dom(Φe)≠∅}\emptyset' \leq_m \{ e : \mathrm{dom}(\Phi_e) \neq \emptyset \}.
  3. ∅′≤mTot\emptyset' \leq_m \mathrm{Tot} and N∖∅′≤mTot\nat \setminus \emptyset' \leq_m \mathrm{Tot}, where Tot={e:Φe is total}\mathrm{Tot} = \{ e : \Phi_e \text{ is total} \}.

In particular, none of these sets is computable.

Proof of Proposition 3.5.
  1. e↦⟨e,e⟩e \mapsto \langle e, e \rangle reduces ∅′\emptyset' to HH. Conversely, let zz be the function of Example 2.4, with Φz(e,x)(y)≃Φe(x)\Phi_{z(e, x)}(y) \simeq \Phi_e(x) for all yy. Then ⟨e,x⟩∈H  ⟺  Φe(x) ⁣ ⁣↓  ⟺  Φz(e,x)(z(e,x)) ⁣ ⁣↓  ⟺  z(e,x)∈∅′\langle e, x \rangle \in H \iff \Phi_e(x)\converge \iff \Phi_{z(e, x)}(z(e, x))\converge \iff z(e, x) \in \emptyset', so ⟨e,x⟩↦z(e,x)\langle e, x \rangle \mapsto z(e, x) reduces HH to ∅′\emptyset'. (The function n↦z(π0(n),π1(n))n \mapsto z(\pi_0(n), \pi_1(n)) is total computable, since the inverses π0,π1\pi_0, \pi_1 of the pairing function are.)
  2. With the same zz, the function Φz(e,e)\Phi_{z(e, e)} is total if e∈∅′e \in \emptyset' and nowhere defined otherwise. So e↦z(e,e)e \mapsto z(e, e) reduces ∅′\emptyset' to both sets, and also to Tot\mathrm{Tot}, which proves the first half of item 3.
  3. For the second half, let gg be total computable, given by Corollary 2.3, such that
Φg(e)(x)≃{0if Φe(e)[x] ⁣ ⁣↑,undefinedif Φe(e)[x] ⁣ ⁣↓.\Phi_{g(e)}(x) \simeq \begin{cases} 0 & \text{if } \Phi_e(e)[x]\diverge,\\ \text{undefined} & \text{if } \Phi_e(e)[x]\converge. \end{cases}

This is a definition by cases with a computable condition (Proposition 1.4). If e∉∅′e \notin \emptyset', then Φe(e)[x] ⁣ ⁣↑\Phi_e(e)[x]\diverge for every xx, and Φg(e)\Phi_{g(e)} is total. If e∈∅′e \in \emptyset', then Φe(e)[x] ⁣ ⁣↓\Phi_e(e)[x]\converge for all large xx, and Φg(e)\Phi_{g(e)} is not total. So gg reduces N∖∅′\nat \setminus \emptyset' to Tot\mathrm{Tot}.

The second half of item 3 is stronger than it looks. The lesson on computably enumerable sets shows that N∖∅′\nat \setminus \emptyset' is not computably enumerable, and that sets reducible to a computably enumerable set are computably enumerable. Hence Tot\mathrm{Tot} is not computably enumerable; and by item 2 of Proposition 3.4, its complement is not either. Totality is strictly harder than halting, a fact made precise by the arithmetic hierarchy.

3.3 Undecidable problems in mathematics

Reductions from the halting problem show that many natural mathematical problems are undecidable. The following results are admitted; each is proved by coding computations into the problem considered.

  • The Entscheidungsproblem. The set of (codes of) valid formulas of first-order logic is not computable (Church, Turing, 1936). Later work showed that a language with a single binary relation symbol suffices.
  • The word problem for groups. There is a finitely presented group for which the set of words equal to the identity is not computable (Novikov, 1955; Boone, 1959).
  • Hilbert’s tenth problem. The set of polynomial equations with integer coefficients having a solution in integers is not computable (Matiyasevich, 1970, completing work of Davis, Putnam and Robinson). More precisely, every computably enumerable set (in the sense of the next lesson) is Diophantine, and therefore ∅′\emptyset' reduces to the solvability of Diophantine equations.

3.4 Exercises

Exercise 3.6 ★.

Show that if AA is computable and B≠∅B \neq \emptyset, B≠NB \neq \nat, then A≤mBA \leq_m B. What happens if B=∅B = \emptyset or B=NB = \nat?

Solution

Fix b1∈Bb_1 \in B and b0∉Bb_0 \notin B, and let f(x)=b1f(x) = b_1 if x∈Ax \in A and f(x)=b0f(x) = b_0 otherwise; ff is total computable and reduces AA to BB. If B=∅B = \emptyset, then A≤mBA \leq_m B forces A=∅A = \emptyset, since no f(x)f(x) lies in BB; similarly, A≤mNA \leq_m \nat forces A=NA = \nat.

Exercise 3.7 ★.

Show that {e:Φe(e) ⁣ ⁣↓=0}\{ e : \Phi_e(e)\converge = 0 \} is not computable.

Solution

Let gg be total computable with Φg(e)(y)≃0\Phi_{g(e)}(y) \simeq 0 if Φe(e) ⁣ ⁣↓\Phi_e(e)\converge, and undefined otherwise; it exists by Corollary 2.3, since the right-hand side is a partial computable function of (e,y)(e, y). Then e∈∅′  ⟺  Φg(e)(g(e)) ⁣ ⁣↓=0e \in \emptyset' \iff \Phi_{g(e)}(g(e))\converge = 0, so gg reduces ∅′\emptyset' to the set.

Exercise 3.8 ★★.#

Let Inf={e:dom(Φe) is infinite}\mathrm{Inf} = \{ e : \mathrm{dom}(\Phi_e) \text{ is infinite} \}. Show that ∅′≤mInf\emptyset' \leq_m \mathrm{Inf} and N∖∅′≤mInf\nat \setminus \emptyset' \leq_m \mathrm{Inf}.

Solution

The reduction e↦z(e,e)e \mapsto z(e, e) of Proposition 3.5 sends e∈∅′e \in \emptyset' to an index of a total function, whose domain is infinite, and e∉∅′e \notin \emptyset' to an index of the nowhere defined function. The reduction gg of item 3 sends e∉∅′e \notin \emptyset' to an index of a total function, and e∈∅′e \in \emptyset' to an index of a function whose domain is {x:Φe(e)[x] ⁣ ⁣↑}\{ x : \Phi_e(e)[x]\diverge \}, a finite initial segment of N\nat.

3.5 Notes and references

Turing proved in 1936 that no machine decides whether a given machine is circle-free, and deduced the unsolvability of the Entscheidungsproblem; Church obtained the latter independently with the λ-calculus. Many-one reducibility was introduced by Post in 1944, in the paper that founded the study of computably enumerable sets and their degrees. Davis’ survey and Matiyasevich’s book on Hilbert’s tenth problem, and Lyndon and Schupp’s book on combinatorial group theory, present the undecidability results listed above.

  • A. M. Turing, On computable numbers, with an application to the Entscheidungsproblem, Proceedings of the London Mathematical Society (2) 42 (1936), 230–265.
  • A. Church, A note on the Entscheidungsproblem, Journal of Symbolic Logic 1 (1936), 40–41.
  • E. L. Post, Recursively enumerable sets of positive integers and their decision problems, Bulletin of the American Mathematical Society 50 (1944), 284–316.
  • M. Davis, Hilbert’s tenth problem is unsolvable, American Mathematical Monthly 80 (1973), 233–269.
  • Y. V. Matiyasevich, Hilbert’s Tenth Problem, MIT Press, 1993.
  • R. C. Lyndon and P. E. Schupp, Combinatorial Group Theory, Springer, 1977.