A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

The Halting Problem

College Depth 87 in the knowledge graph I know this Set as goal
59topics build on this
513prerequisites beneath it
See this on the map →
Cantor's Diagonalization ArgumentFunctions as Sets and Their Characteristics+5 moreBusy Beaver Function and Non-ComputabilityComputability Reductions+8 more
undecidability diagonalization computability

Core Idea

The halting problem asks whether there exists a Turing machine that, given any program and input, correctly determines whether that program halts on that input. Turing proved in 1936 that no such machine can exist. The proof uses diagonalization: assume a halting oracle H exists and construct a machine D that runs H on itself then does the opposite — D's behavior contradicts H's prediction, yielding a contradiction. This is the paradigmatic undecidability result and the template for hundreds of subsequent proofs.

How It's Best Learned

Carefully trace through the diagonalization argument to see exactly where the contradiction arises. Then practice reducing other problems to the halting problem — recognizing it as the canonical hard problem from which undecidability spreads.

Common Misconceptions

Explainer

From your study of Turing machines, you know that a Turing machine is a precise mathematical model of computation: a tape, a finite set of states, and transition rules. Every algorithm corresponds to some Turing machine. The halting problem asks whether there exists a Turing machine H that, given the description of any program P and an input x, correctly outputs "halts" if P eventually terminates on x and "loops" if it does not. Turing proved in 1936 that no such H can exist — a landmark result that established the outer limits of what computation can do.

The proof is a proof by contradiction that uses diagonalization, the same technique Cantor used to show that the real numbers are uncountable. Assume H exists. Then construct a new machine D as follows: D takes a program description ⟨P⟩ as input, runs H on the pair (⟨P⟩, ⟨P⟩) — that is, asks H whether P halts when given its own description as input — and then does the opposite of whatever H predicts: if H says "halts," D loops forever; if H says "loops," D halts immediately.

Now ask what happens when D is given its own description ⟨D⟩ as input. If H says D halts on input ⟨D⟩, then D loops — but H said it halts, contradiction. If H says D loops on input ⟨D⟩, then D halts — but H said it loops, contradiction. Every possible answer H could give is wrong. Since D is a well-defined Turing machine and ⟨D⟩ is a valid input, the assumed oracle H fails on a specific case. The only consistent conclusion is that H cannot exist.

A critical distinction the proof does not make: it says no *general* algorithm works for all programs, not that no specific program's halting behavior can ever be known. For many individual programs — a loop with a fixed counter, a program with no loops at all — halting is trivially decidable. Undecidability is a claim about the impossibility of a single algorithm covering every case.

The halting problem is the canonical undecidable problem because undecidability of other problems is often proved by reduction to it. If you can show that solving problem X would let you solve the halting problem, then X must also be undecidable. This reduction technique — which you will see in Rice's theorem and beyond — makes the halting problem not just a historical curiosity but the central node in the entire web of undecidability results.

Practice Questions 3 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraIntroduction to Propositional LogicIntroduction to Predicate Logic (First-Order Logic)First-Order Logic SyntaxZFC Axioms OverviewAxiom Schema of SeparationAxiom Schema of ReplacementVon Neumann OrdinalsHereditarily Finite SetsRecursive Definitions on Finite SetsWell-Founded Relations and Transfinite RecursionThe Axiom of Choice and Equivalent FormulationsAxiom of ChoiceWell-Ordering TheoremInfinite Cardinal NumbersCantor's TheoremUncountability and the Diagonal ArgumentThe Cantor Set: An Uncountable Nowhere Dense ExampleUncountable Sets and Cantor DiagonalizationThe Halting Problem

Longest path: 88 steps · 513 total prerequisite topics

Prerequisites (7)

Leads To (10)