The halting problem
Parent: turing-machines
The first — and most-reduced-from — undecidable problem: there is no algorithm that decides, for an arbitrary program and input, whether it halts.
Undecidability of haltingNo Turing machine decides, for arbitrary
(M, x), whetherMhalts on inputx.
ProofSuppose a machine
H(M,x)always halts and correctly answers "doesMhalt onx?". BuildD(M): runH(M,M); if it says "halts", loop forever; if "doesn't halt", halt. Now feedDits own code and ask aboutD(D):
- if
H(D,D)= "halts", then by constructionD(D)loops — so it does not halt;- if
H(D,D)= "doesn't halt", thenD(D)halts. Either wayHis wrong on(D,D). SoHcannot exist. ∎
It's the same diagonal / self-reference move as Cantor, Russell, and Gödel: build the object that does the opposite of what's predicted about itself.
Consequences — undecidability spreads by reduction
- Rice's theorem: every non-trivial semantic property of a program (of what it computes) is undecidable — halting is just the first domino (recursively-enumerable-languages).
- Reductions: "does
Mever print0?", "do two programs compute the same function?", the Entscheidungsproblem (history), Post's correspondence problem, generalized Collatz — all shown undecidable by reducing halting to them. - One-sided: halting is recognizable but not decidable — you can confirm halting (wait), never confirm non-halting.
Ties to the thread
"Does this iteration/agent converge / terminate?" is the halting problem in disguise — undecidable in general (recursion-is-a-phase-transition). You recover a usable answer only by relaxing (a termination certificate / ranking function, a tolerance, a horizon). The uncomputable growth of the wait time is the busy-beaver.