MathLabs
TheoremProved

Undecidability of the halting problem

Statement

There is no algorithm that, given an arbitrary program (Turing machine) PP and input xx, always correctly decides in finite time whether PP halts when run on xx.

Why is it true?

Suppose such a halting-decider HH existed. Build a program DD that, on input a program QQ, runs HH to check whether QQ halts when run on itself, then does the opposite (loops forever if QQ halts, halts if QQ loops). Running DD on itself as input leads to a contradiction either way, so HH cannot exist.

Proof sketch

Diagonal argument: assume a decider H(P,x)H(P,x) exists that outputs whether PP halts on xx; define D(P)=D(P) = 'loop forever' if H(P,P)H(P,P) says 'halts', else 'halt'; then ask whether D(D)D(D) halts. If it halts, by definition H(D,D)H(D,D) said 'loop forever', a contradiction; if it loops forever, H(D,D)H(D,D) said 'halts', also a contradiction. So HH cannot exist.

Proved by

Topics that use this theorem

Related theorems

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Alan M. Turing (1936). On Computable Numbers, with an Application to the Entscheidungsproblem · DOI:10.1112/plms/s2-42.1.230
  2. Michael Sipser (2012). Introduction to the Theory of Computation