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

Undecidable Problems and the Halting Problem

Graduate Depth 98 in the knowledge graph ☐ I know this ☆ Set as goal
3topics build on this
448prerequisites beneath it
See this on the map →
Diagonalization and UncomputabilityRecognizability vs. Decidability→→Reduction Techniques for Proving Undecidability
undecidability halting-problem limits

Core Idea

The halting problem—determining whether a Turing machine halts on a given input—is undecidable. This is proved by contradiction: if a halting decider existed, a diagonalization argument would construct a machine that produces a contradiction. The halting problem represents a fundamental limit on computation.

How It's Best Learned

Follow the diagonal construction proof carefully. Understand why the self-reference ('a machine that halts iff it loops') creates a logical contradiction. Work through small examples of the argument.

Explainer

From your study of recognizable languages, you know that Turing machines can accept languages — saying "yes" for strings in the language, though possibly looping forever on strings outside it. A decidable problem is one where a Turing machine always halts with a correct yes or no answer. The halting problem asks the seemingly reasonable question: given a Turing machine M and an input w, does M halt on w? The shocking answer is that no algorithm can solve this problem in general.

The proof uses diagonalization, a technique of self-reference that forces a contradiction. Suppose a decider H exists that correctly answers "yes" or "no" for every (M, w) pair. Now construct a new machine D that takes a Turing machine description M as input and does the following: D runs H on the pair (M, M) — asking whether M halts when given its own description as input. If H says "yes, M halts on M," then D deliberately loops forever. If H says "no, M does not halt on M," then D halts. Now ask: what happens when D is run on its own description? If D halts on D, then by construction H said "no" — meaning D does not halt on D. Contradiction. If D does not halt on D, then H said "yes" — meaning D does halt on D. Contradiction again. Either way, H gave the wrong answer, so H cannot exist.

This result reveals a fundamental limit of computation, not a limitation of current technology or programming skill. No faster computer, cleverer algorithm, or future programming language can solve the halting problem. The argument works for any computational model equivalent to Turing machines, which by the Church-Turing thesis includes everything we consider "computable." The undecidability of the halting problem is not an engineering obstacle — it is a mathematical theorem about the structure of computation itself.

The halting problem is the first and most important undecidable problem, but it is far from the only one. Once you have one undecidable problem, you can prove others undecidable through reductions — showing that if you could solve the new problem, you could use it to solve the halting problem, which you know is impossible. This technique reveals that virtually every non-trivial semantic property of programs is undecidable: Does this program ever print "hello"? Does it compute the same function as that program? Is it free of infinite loops? Rice's theorem formalizes this, establishing that any non-trivial property of the language recognized by a Turing machine is undecidable. The halting problem is thus not an isolated curiosity but the gateway to a vast landscape of unsolvable problems.

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 → Recognizability vs. Decidability → Undecidable Problems and the Halting Problem

Longest path: 99 steps · 448 total prerequisite topics

Prerequisites (2)

Leads To (1)