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

Graduate Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
5topics build on this
445prerequisites beneath it
See this on the map →
Decidable LanguagesCantor's Diagonalization Argument+2 more→→Recognizability vs. Decidability
halting-problem undecidability diagonalization HALT_TM

Core Idea

The halting problem asks: given a Turing machine M and input w, does M halt on w? Turing proved in 1936 that no TM can decide this — HALT_TM is undecidable. The proof uses diagonalization: assume a decider H exists, construct a machine D that does the opposite of what H predicts for D itself, yielding a contradiction. The halting problem is the canonical undecidable problem; hundreds of other undecidable problems are proved undecidable by reducing the halting problem to them.

How It's Best Learned

Follow the diagonalization argument carefully, constructing the contradiction step-by-step. Then read Turing's original 1936 paper for historical context. Finally, practice the reduction technique by showing ε_TM (does M accept ε?) is undecidable via a reduction from HALT_TM.

Common Misconceptions

Explainer

You've established that decidable languages are those with Turing machines that always halt with a correct answer. The natural next question is: are *all* languages decidable? The halting problem provides the definitive answer — no — and it does so through one of the most elegant arguments in all of mathematics. The question is deceptively simple: given a description of a Turing machine M and an input w, does M eventually halt when run on w, or does it loop forever?

At first, this seems like it should be solvable. After all, you can examine the code of a program and often tell whether it will terminate. But the halting problem asks for a *universal* solution — an algorithm that works for *every* possible program and *every* possible input. Turing proved in 1936 that no such algorithm exists. The proof is a masterpiece of self-reference and contradiction, closely related to the diagonalization technique you know from Cantor's work on countability.

Here's how the argument works. Assume, for contradiction, that a Turing machine H exists that decides the halting problem: H(⟨M, w⟩) accepts if M halts on w, and rejects if M loops. Now construct a new machine D that takes a Turing machine description ⟨M⟩ as input, runs H(⟨M, ⟨M⟩⟩) to ask "does M halt when given its own description?", and then *does the opposite* — if H says M halts, D loops forever; if H says M loops, D halts and accepts. Now ask: what happens when D is given its own description? D(⟨D⟩) runs H(⟨D, ⟨D⟩⟩). If H says D halts on ⟨D⟩, then D loops — contradicting H's answer. If H says D loops on ⟨D⟩, then D halts — again contradicting H. Either way, H gives the wrong answer. Since we derived a contradiction from the assumption that H exists, no such H can exist.

The halting problem's significance extends far beyond this single result. It is the canonical undecidable problem — the starting point for proving that hundreds of other problems are also undecidable. The technique is reduction: to show that some new problem X is undecidable, you show that if you *could* decide X, you could use that ability to decide the halting problem — which you've already proved impossible. For example, the question "does Turing machine M accept the empty string?" is undecidable because you can transform any halting-problem instance into this form. Note the critical distinction: the halting problem is recognizable (you can run M on w and accept if it halts — you just can't detect the looping case), but it is not decidable. This gap between recognizability and decidability becomes a central theme in computability theory.

Practice Questions 5 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 → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Two-Way Finite Automata → NFA to DFA Conversion (Subset Construction) → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Pushdown Automata (PDA) → Equivalence of CFGs and Pushdown Automata → Closure Properties of Context-Free Languages → Limitations of Context-Free Languages → Pumping Lemma for Context-Free Languages → Turing Machines → Variants of Turing Machines and Equivalence → Universal Turing Machine and Self-Simulation → Church-Turing Thesis and Computability → Decidable Languages → The Halting Problem

Longest path: 97 steps · 445 total prerequisite topics

Prerequisites (4)

Leads To (1)