Computability & the Halting Problem

Difficulty
Importance

The problem

Before optimizing an algorithm, it's worth knowing whether a correct algorithm can exist at all — computability theory draws the line between problems that are solvable by any program, however slow, and problems that provably are not, no matter how clever the approach.

Why now

Proof techniques already gave the tool (proof by contradiction) this topic's central result depends on; functions and relations gave the vocabulary for what a computation even is. Without both, 'no algorithm can ever solve this' isn't a claim you could prove — it would just be an unproven suspicion.

Mental model

The halting problem asks: can a program determine, for any other program and input, whether it will eventually stop or run forever? The proof that it can't is a self-reference trick — assume such a checker exists, then build a program that does the opposite of what the checker predicts about itself, producing a contradiction. This is the same proof-by-contradiction move from proof-techniques, now turned on computation itself.

Requires

Used in

Projects

  • Write out, in your own words, the diagonalization proof that the halting problem is undecidable, checking each step against the formal version
  • Find and explain a real tool (linter, type checker) that sacrifices completeness specifically because of undecidability

Examples

  • No general algorithm can determine, for arbitrary code, whether a given loop will terminate — some cases require case-by-case human reasoning
  • TypeScript's type checker is deliberately less powerful than a full proof system partly to keep type checking decidable and fast

Resources

Mastery checklist