← Student tools · Problem 14 · Lecture 8 · Round 1 (30 pts)

Rice's theorem · which TM properties are decidable?

Every nontrivial semantic property of L(M) is undecidable.

CLO-1CLO-2R1·30 ptsL8
🔊 Listen

Rice's theorem is the master undecidability theorem. After proving a handful of specific languages undecidable (ETM, REGULARTM, EQTM, …), one starts to wonder: is there a unifying reason? Rice's answer is yes — and it is sweeping. Every nontrivial property of what a program does is undecidable.

This is why static-analysis tools always say "may be" rather than "is". A linter can tell you "this variable is unused" (syntactic, decidable). It cannot tell you "this function returns prime numbers" (semantic, undecidable by Rice).

Rice's theorem (1953)

Let P be a property of recognizable languages such that (1) P is nontrivial (some L(M) has it, some doesn't) and (2) P depends only on L(M), not on the particular description of M. Then LP = {⟨M⟩ : L(M) has P} is undecidable.

The theorem is one line, but its consequences span every introductory undecidability lecture in computer science.

🔊 Listen

The crucial dichotomy:

Type About Examples Decidable?
SyntacticM itself"M has 5 states", "M's alphabet is binary"Yes — just inspect ⟨M⟩
SemanticL(M)"L(M) is empty", "L(M) is finite", "L(M) ∋ ε"No — Rice (if nontrivial)

"Depends only on L(M)" means: if L(M1) = L(M2), then P(M1) = P(M2). This is the formal definition of semantic.

🔊 Listen

Assume LP is decidable. Take a TM T with L(T) = ∅, and another TM TP with L(TP) having property P. (WLOG ∅ does not have P; otherwise apply to ¬P.) Build M' from ⟨M, w⟩:

Construction of M'

M' = "on input x:
  1. simulate M on w;
  2. if M accepts w: simulate TP on x;
  3. accept x iff TP accepts."

If M accepts w: L(M') = L(TP) has P. If M does not accept w: L(M') = ∅ does not have P. So ⟨M, w⟩ ∈ ATM ⇔ ⟨M'⟩ ∈ LP. A decider for LP ⇒ decider for ATM. Contradiction.

🔊 Listen
Decide if Rice applies Auto-plays
🔊 Listen

Apply Rice to the property P = "L(M) contains the binary encoding of some prime."

  1. Nontrivial? Yes — TM1 = "accept only 10" has P (10 = 2 is prime). TM2 = "accept only 1" lacks P.
  2. Semantic? Yes — depends only on L(M), not on how M is written.

So "does this program ever accept a prime?" is undecidable. By the same argument, every program-behavior question about output is undecidable in general. This is why pattern-matching and runtime testing replace formal verification in everyday practice.

🔊 Listen
🔊 Listen
  1. "Rice says everything is undecidable." No — only nontrivial semantic properties. Syntactic and trivial ones can be decidable.
  2. Confusing "M halts on w" with "L(M) ∋ w". Different! "M halts" includes rejecting halts; "w ∈ L(M)" means M accepts. The first is HALTTM, the second is ATM — both undecidable by reduction, but different statements.
  3. "P is nontrivial" must check both sides. Some L(M) has P and some L(M) doesn't. If P is true of every recognizable language (e.g. "L(M) is recognizable"), it's trivial.
  4. Forgetting the construction direction. Reduce ATM to LP, not the reverse.
  5. "Recursion theorem is needed." Not for the reduction proof. The recursion theorem gives an alternative shorter proof but isn't required.
🔊 Listen
🔊 Listen

Total time: 12 minutes.