4.6.20 · D3Theory of Computation

Worked examples — Rice's theorem

3,462 words16 min readBack to topic

Before we shoot, one ultra-quick refresher of the words and symbols we will use in every example. Read them once, then never guess again.

Rice's theorem, compressed to a checklist we will run on each example:

Recall The reduction gadget from the parent (one-paragraph refresher — we cite it in Ex 1's verify)

Start from an acceptance question: "does accept the input ?", i.e. is ? (This is acceptance, not mere halting — may halt by rejecting, and that counts as "does not accept".) The parent builds a gadget machine that on any input first simulates on ; if that simulation accepts, it then runs a fixed yes-witness machine on . Result: if accepts then ; if not (reject or loop), never gets past step 1, so . The gadget flips between a yes-language and a no-language exactly according to whether — and that flip is only possible because both a yes-witness and a no-witness exist. ::: This is why non-triviality (two r.e. witnesses) is the whole engine.


The scenario matrix

Every question about "what does this program do?" falls into exactly one of these cells. The whole page is designed so each row gets its own worked example. (Recall = the property viewed as a set of r.e. languages, defined just above.)

# Cell (the case class) Semantic? Non-trivial? Verdict Hits example
A Plain semantic, both witnesses obvious yes yes undecidable Ex 1
B Semantic but the "no" witness is the empty language yes yes undecidable Ex 2
C The degenerate empty property yes no (trivial) decidable Ex 3
D The degenerate full property all r.e. yes no (trivial) decidable Ex 4
E Syntactic trap — looks semantic, is about the code no Rice silent → decidable Ex 5
F Real-world word problem (a linter / security check) yes yes undecidable Ex 6
G Undecidable but still r.e. (limiting/finer case) yes yes undecidable, & r.e. Ex 7
H Exam twist — property mentions the machine's steps but reduces to subtle yes undecidable Ex 8
I Complement flip, so we flip yes yes undecidable Ex 9
Figure — Rice's theorem

Figure 1 — the map of cases. The big blue region is "semantic and non-trivial ⇒ undecidable". The two grey corners (C and D) are the only safe harbours where a decider exists — the trivial properties and all r.e. The red band (E) is the syntactic trap where Rice is silent. Each yellow/green dot is one example below, planted in the region it lives in. Read the whole page as: "which coloured region does my question land in?"


The worked examples

Figure — Rice's theorem

Figure 2 — undecidable does not mean unrecognizable. The outer blue box is all r.e. (recognizable) languages; the inner green box is the recursive (decidable) ones. The yellow star is the decision problem from Ex 7: it sits inside the r.e. box but outside the green decidable box. The red arrow is the dovetailing semi-decider from step 2 — it can say YES when the answer is YES, which is exactly what "r.e." means, yet it can loop forever when the answer is NO, which is why it is not a decider. Contrast this with Ex 2's "infinite", which lands outside the whole blue box (not even r.e.).


The one thing to walk away with

Recall Self-test

Which cell is "Is a context-free language?" ::: Cell A/B — semantic, non-trivial (yes-witness , r.e.; no-witness any r.e. non-CFL such as ) ⇒ undecidable. Which cell is "Does 's start state have out-degree 3?" ::: Cell E — syntactic, Rice silent, decidable by inspection. Which cell is "Is the set of all strings, i.e. ?" ::: Cell A — semantic, non-trivial (yes-witness , r.e.; no-witness , r.e.) ⇒ undecidable.


Connections

  • Parent: Rice's theorem — the machine behind every verdict here.
  • A_TM and undecidability — the source of every reduction.
  • Halting Problem — Ex 8's contrast case.
  • Mapping reductions — the flip used in Ex 9.
  • Recursive vs Recursively Enumerable languages — the heart of Ex 7.
  • Rice-Shapiro theorem — refines Ex 7's "is it r.e.?" question.
  • Turing Machines — the model under all of it.