Recall warm-up
- To prove P undecidable, which direction of reduction?
Stuck? Peek at 5.3 Reductions and proving undecidability
- A ≤ₘ B: computable f, x ∈ A ⇔ f(x) ∈ B. A ≤ B ⇔ A̅ ≤ B̅. Transitive.
- B dec ⇒ A dec; A undec ⇒ B undec; B RE ⇒ A RE; A not RE ⇒ B not RE.
- Prove P hard: A_TM ≤ P. E_TM co-RE not RE; NE_TM RE; EQ_TM, TOTAL, FINITE neither.
- Is the complement of A_TM RE?
Stuck? Peek at 5.2 The diagonal language and the halting problem
- L_d = {wᵢ : wᵢ ∉ L(Mᵢ)}: not RE (co-RE).
- A_TM = {⟨M,w⟩ : M accepts w}: RE, not recursive; complement not RE.
- HALT_TM: RE, undecidable; complement not RE.
- REC = RE ∩ co-RE.
- Decider vs recognizer?
Stuck? Peek at 4.3.1 Recursive vs recursively enumerable; deciders and recognizers
- Recognizer: accepts L, may loop outside. RE = recognizable = semi-decidable = enumerable.
- Decider: halts always. Recursive = decidable.
- REC ⊆ RE. Enumerator ⇔ recognizer (dovetailing). Shortlex enumeration ⇔ recursive.
The Hook
A code-review bot that checks “does this program ever print ‘hello’?”, “does it accept any palindrome?”, “is its output the same as the reference solution?”. Rice’s theorem says every such bot must fail on some program — any question about what a program’s language is, as opposed to how the program is written, is undecidable unless the answer is the same for all programs.
Predict First
“Does M have more than 10 states?” and “Is L(M) finite?” — which one does Rice’s theorem cover?
Core Concept
Prediction check
Only “Is L(M) finite?” — a property of the language. “More than 10 states” is a property of the machine’s code: just count, so it is decidable. Rice says nothing about it.
Rice’s theorem
“Property of the language” means: if L(M₁) = L(M₂) then both or neither have it. Proof idea: assume ∅ lacks P (else use the complement); pick M_P with L(M_P) ∈ P; reduce A_TM by building M′ that first runs M on w and, if accepted, behaves like M_P. L(M′) has P ⇔ M accepts w.
When Rice does not apply
- Trivial properties: “L(M) is RE” (always true) — decidable (answer yes).
- Machine properties: “M has 5 states”, “M halts on ε within 100 steps”, “M ever writes a 1 within 10 steps on input 0” — decidable by inspection or bounded simulation.
- “M halts on ε” is about M’s behaviour, not L(M) — Rice doesn’t apply directly, but it is undecidable anyway (reduction from HALT).
| question | decidable? | why |
|---|---|---|
| L(M) = ∅? | no | Rice |
| L(M) is regular? | no | Rice |
| L(M) contains “ab”? | no | Rice (but RE) |
| M has ≤ 7 states? | yes | read the code |
| M halts on ε within 50 steps? | yes | simulate 50 steps |
| L(M) is RE? | yes | trivial: always true |
RE or not? (Rice–Shapiro, short form)
Rice says undecidable; it does not say whether the property is RE. Rule of thumb: “L(M) contains some particular string / is non-empty” is RE (guess and check); “L(M) is empty / finite / = Σ* / regular” is not RE. A property of RE languages can only be RE if it is closed upward and witnessed by a finite set of strings.
Post Correspondence Problem (PCP)
PCP is undecidable (alphabet with ≥ 2 symbols); it is RE (try all sequences). For a one-letter alphabet it is decidable. PCP is the usual tool for proving grammar questions undecidable: ambiguity of CFGs, emptiness of the intersection of two CFLs, universality of CFGs.
Putting it together
- Rice: any non-trivial question about what a TM accepts is undecidable.
- Questions about the code or bounded runs are decidable.
- PCP is undecidable and powers grammar undecidability results.
Visual
Rice checklist 1. Property of L(M)? (same language ⇒ same answer) no → Rice silent 2. Non-trivial over RE languages? no → trivially decidable 3. Yes and yes → undecidable. RE? only if "witnessed by finitely many strings" (≠ ∅, contains w)
Worked Examples
Is { ⟨M⟩ : L(M) = {ab} } decidable?
Show the full solution
No — a non-trivial property of L(M) (Rice).
Is { ⟨M⟩ : M moves left at least once on input ε } decidable?
Show the full solution
It is about M’s behaviour, so Rice does not apply. Undecidable? Think: if M never moves left it only moves right through blanks after finitely many states repeat — within |Q| + 1 steps on blanks it either moved left or is in a right-moving cycle. So it is decidable by simulating a bounded number of steps.
Which are undecidable? (i) L(M) is context-free (ii) M has an even number of states (iii) L(M) = L(M′) for a fixed M′ with L(M′) = Σ* (iv) PCP over {0,1}
Show the full solution
(i) Rice ✓. (ii) decidable. (iii) Rice (“L(M) = Σ*”) ✓. (iv) undecidable ✓. Answer: (i), (iii), (iv).
GATE Traps
- Rice only covers properties of L(M), and only non-trivial ones.
- Rice gives undecidability, not non-RE-ness.
- Bounded questions (within k steps) are decidable.
- PCP over a one-letter alphabet is decidable.
Memory Hook
Rice: you can read a program’s source, but you can’t read its soul. Anything about what it accepts — undecidable; anything about how it looks — fine.
Connect the Dots
Undecidability is now in your hands. The last lesson collects every answer into one master table: which questions are decidable for regular, DCFL, CFL, CSL, recursive and RE languages — the most reused fact sheet in GATE TOC.
Self-Test
- MSQ
Which are undecidable by Rice’s theorem?
- L(M) is finite
- L(M) contains 101
- M has exactly 3 states
- L(M) is regular
- MCQ
{ ⟨M⟩ : L(M) ≠ ∅ } is:
- decidable
- RE but undecidable
- co-RE but not RE
- neither
- MCQ
PCP is undecidable for alphabets of size:
- 1
- ≥ 2
- only 3
- none
- MCQ
Rice’s theorem does NOT apply to:
- L(M) is empty
- L(M) = Σ*
- M halts within 20 steps on ε
- L(M) is a CFL
Rule Card
- Rice: non-trivial property of L(M) ⇒ undecidable. Not for code/bounded-behaviour properties or trivial ones.
- ≠ ∅, contains w: RE. = ∅, finite, = Σ*, regular, CFL: not RE.
- PCP: undecidable (|Σ| ≥ 2), RE; unary decidable. Used for CFG ambiguity, CFL ∩ emptiness, CFG universality.
Concept Ledger
- Rice’s theorem
- non-trivial property
- property of the language vs of the machine
- Post Correspondence Problem (PCP)
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- A_TM ≤ P.
- No.
- A decider always halts; a recognizer may loop on non-members.
Self-test answers
- ABD — Non-trivial language properties.
- C: A code property, decidable.
- B — Dovetail to find an accepted string; Rice ⇒ undecidable.
- A: Rice.
- C: It is RE.
- D: It is RE.
- B — Unary PCP is decidable.
- A: Decidable.
- C: Too narrow.
- D: It is undecidable.
- C — Bounded behaviour of M.
- A: Applies.
- B: Applies.
- D: Applies.
Flashcards
- Rice’s theorem?
Reveal answer
Every non-trivial property of the language of a TM is undecidable. - Does Rice apply to “M has 5 states”?
Reveal answer
No — that is about the machine; decidable. - Is PCP decidable?
Reveal answer
No (|Σ| ≥ 2); unary PCP is decidable. - Is {⟨M⟩ : L(M) ≠ ∅} RE?
Reveal answer
Yes (but undecidable).