Rice's Theorem

Graduate Depth 71 in the knowledge graph I know this Set as goal
Unlocks 19 downstream topics
undecidability semantic-properties computability

Core Idea

Rice's theorem states that every non-trivial semantic property of Turing machines is undecidable. A semantic property is one that depends on the function a TM computes — not its syntactic description — and non-trivial means it is true of some TMs and false of others. Consequently, questions like 'Does this program output 42 on input 5?', 'Does this program halt on all inputs?', or 'Do these two programs compute the same function?' are all undecidable. The proof reduces from the halting problem by showing any non-trivial semantic property could be used to detect halting.

How It's Best Learned

First internalize the syntactic/semantic distinction — properties of program descriptions versus properties of the functions they compute. Then work through the formal proof by contradiction, understanding how any non-trivial semantic property can be co-opted to solve the halting problem.

Common Misconceptions

Explainer

The halting problem showed that one specific question about programs — "does this program halt on this input?" — is undecidable. Rice's theorem is a sweeping generalization: *every* interesting question about what a program computes is undecidable. The key distinction that makes this precise is between syntactic and semantic properties. A syntactic property depends on the description of the Turing machine — its states, transitions, tape alphabet. A semantic property depends only on the function the machine computes, regardless of how it is encoded. "This TM has fewer than 100 states" is syntactic. "This TM outputs 42 on input 5" is semantic.

To see why semantic properties are harder, notice that two machines with wildly different descriptions might compute the same function, and two nearly-identical machines might compute completely different functions. You cannot read off what a program computes from its description without, in effect, running it. Rice's theorem makes this precise: if P is a semantic property that is non-trivial (some TMs have it, some don't), then there is no algorithm that takes a TM description and correctly decides whether that TM has property P.

The proof uses the halting problem reduction you already know. Suppose you had an algorithm A deciding property P. Pick a TM M₀ that has P (exists by non-triviality) and a TM M₁ that lacks P. Given any TM T and input w, build a new TM T_{w} that: (1) first runs T on w, and (2) if T halts, runs as M₀, otherwise diverges forever. The machine T_{w} computes M₀'s function if T halts on w, and computes nothing (or M₁'s function) if T doesn't halt. Now run A on T_{w}: A answers "yes" iff T halts on w. This solves the halting problem — a contradiction. Every part of this construction generalizes to any non-trivial semantic property.

The practical implication is profound: no static analysis tool can be both sound and complete for any semantic property. Tools like type checkers and linters are always either incomplete (they miss some bugs) or unsound (they report false positives) — not from engineering failure, but from fundamental mathematical necessity. Rice's theorem explains why program verification is hard in principle, and why all practical static analysis tools approximate semantic properties through syntactic overapproximations.

Practice Questions 5 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication 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 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsInteger Order of OperationsVariable ExpressionsCombining Like TermsOne-Step EquationsTwo-Step EquationsSolving Multi-Step EquationsEquations with Variables on Both SidesLiteral EquationsSlope-Intercept FormPoint-Slope FormWriting Linear EquationsParallel and Perpendicular Line SlopesGraphing Linear EquationsPiecewise FunctionsStep FunctionsComposition of FunctionsInverse FunctionsRadical Functions and GraphsRational ExponentsExponential Functions and GraphsLogarithms IntroductionBig-O Notation and Asymptotic AnalysisBreadth-First Search (BFS)Shortest Paths in Unweighted GraphsDijkstra's Shortest Path AlgorithmAlgorithm Analysis and Big-O NotationTuring MachinesDeterministic Finite AutomataNondeterministic Finite AutomataRegular Expressions and LanguagesPost Correspondence ProblemRice's Theorem

Longest path: 72 steps · 392 total prerequisite topics

Prerequisites (4)

Leads To (3)