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 more→→Busy 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 Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Introduction to Propositional Logic → Introduction to Predicate Logic (First-Order Logic) → First-Order Logic Syntax → ZFC Axioms Overview → Axiom Schema of Separation → Axiom Schema of Replacement → Von Neumann Ordinals → Hereditarily Finite Sets → Recursive Definitions on Finite Sets → Well-Founded Relations and Transfinite Recursion → The Axiom of Choice and Equivalent Formulations → Axiom of Choice → Well-Ordering Theorem → Infinite Cardinal Numbers → Cantor's Theorem → Uncountability and the Diagonal Argument → The Cantor Set: An Uncountable Nowhere Dense Example → Uncountable Sets and Cantor Diagonalization → The Halting Problem

Longest path: 88 steps · 513 total prerequisite topics

Prerequisites (7)

Leads To (10)