← back to Theory of Computation

Decidability

Maheshwari & Smid · Ch. 7 · Introduction to Theory of Computation

A language is decidable if a Turing machine always halts with the correct answer. It is recognizable if the machine halts on "yes" inputs but may loop forever on "no" inputs. The halting problem is recognizable but not decidable: no algorithm can determine whether an arbitrary program halts.

All languages Recognizable (Turing-recognizable) Decidable a^n b^n, primes, sorting Halting problem (recognizable, not decidable) Not even recognizable

The halting problem

Can we write a program that takes any program P and input I and decides whether P(I) halts? No. The proof is by wpdiagonalization: assume such a decider H exists, then build a program D that calls H on itself and does the opposite. D halts if and only if D does not halt. Contradiction.

Scheme
Python

Rice's theorem

The halting problem is just one instance of a general result. wpRice's theorem: every nontrivial semantic property of programs is undecidable. "Does this program output 42?" Undecidable. "Does this program ever print anything?" Undecidable. "Is this program equivalent to that one?" Undecidable. The only decidable properties are trivial ones (true for all programs or false for all programs).

Reductions

To prove a new problem is undecidable, reduce a known undecidable problem to it. If the halting problem can be transformed into your problem, then your problem is at least as hard. Reductions are the main proof technique in decidability and complexity theory.

Scheme
Python
Neighbors
  • ๐Ÿ”‘ Logic Ch.7 โ€” Gรถdel's incompleteness theorem and undecidability are deeply related: the halting problem is a logical statement
  • ๐Ÿ“ Proofs Ch.7 โ€” diagonalization: Cantor's diagonal argument proves the same impossibility result as the halting problem proof
  • ๐Ÿงฎ Lean โ€” proof assistants can only check decidable properties; undecidable questions cannot be automated