Rice's theorem
Rice's theorem: every non-trivial property of the language of a Turing machine is undecidable. The statement (semantic and non-trivial properties), the reduction from A_TM through the machine M_w, how to apply it to properties such as emptiness, finiteness, regularity and universality, which questions are NOT covered (syntactic properties such as the number of states or halting within k moves, and behaviour that is not a property of the language, such as halting on the empty input), and the usual traps.
Why it exists
After and the halting problem one would like a quick way to see that a new question about Turing machines is undecidable, without a new reduction every time. Rice's theorem is that quick way for a large family of questions: anything non-trivial about the language a machine recognises is undecidable. GATE uses it in true/false questions about Turing machines ("is it decidable whether is ...?").
Prerequisites
You need , its undecidability and mapping reductions (the halting problem).
Precise definitions
Let be a property of recognisable languages, that is, a set of recognisable languages (for example "the empty language", "languages with at least two strings", "regular languages"). Define the decision problem
- is trivial if it contains all recognisable languages or none of them. Otherwise it is non-trivial: at least one recognisable language has the property and at least one does not.
- The question about is semantic when it depends only on the language : if then and answer alike. (This is what the definition of expresses.)
Rice's theorem. If is a non-trivial property of recognisable languages, then is undecidable.
How it works
The proof
Assume first that the empty language does not have the property (otherwise use the complementary property , which is non-trivial too, and note that a decider for one gives a decider for the other). Since is non-trivial, pick a machine with .
Reduce to . Given construct the machine :
On input : first run on (ignoring ). If accepts , run on and accept if accepts. (If rejects or loops, rejects or loops.)
Then
so . The map is computable (it only writes down a machine). A decider for would decide , which is impossible.
The table runs the construction for the simplest choice of (accept every string). For six real pairs it shows the behaviour of on four inputs : either it accepts all of them (when accepts ) or none (when rejects or loops on ):
The machine M_w of Rice's theorem: start
Computed by a script, not typed| (M, w) | M_w on ε | M_w on a | M_w on ab | M_w on bbb | language of M_w |
|---|---|---|---|---|---|
| M2 and w = aabb | |||||
| M2 and w = aab | |||||
| M1 and w = ab | |||||
| M1 and w = aa | |||||
| M4 and w = a | |||||
| M3 and w = ε |
Step 0
M_w is built from (M, w) in such a way that its language is either everything or nothing, depending only on whether M accepts w. So any non-trivial property of languages that separates 'everything' from 'nothing' would decide A_TM.
Using the theorem
To show that a question about is undecidable: state the property as a set of languages, check that it is a property of the language and that it is non-trivial (give one machine with the property and one without), and conclude.
| question about | property of the language? | non-trivial? | decidable? |
|---|---|---|---|
| yes | yes | no | |
| yes | yes | no | |
| is finite / infinite | yes | yes | no |
| is regular / context-free / decidable | yes | yes | no |
| contains a given string | yes | yes | no |
| contains at least strings | yes | yes | no |
| for two machines | yes (two machines) | – | no (reduce ) |
| is recognisable | yes | no (every is) | yes (the answer is always yes) |
| has an even number of states | no (a property of the machine) | – | yes |
| halts on input within moves | no (a property of the machine's behaviour) | – | yes (simulate moves) |
| halts on the empty input | no | – | no, by the halting problem |
| halts on every input | no | – | no (not by Rice) |
What Rice's theorem does not cover
Properties of the machine, not of the language. "Has an even number of states", "has a transition that writes a blank", "halts within moves on ": these depend on the description of (or on a bounded part of its behaviour) and are decidable by inspecting or simulating the machine for a bounded time. Simulating for moves always terminates; the answer agreed with a second simulator for on all short inputs of six machines.
Behaviour that two machines with the same language may differ on. "Halts on the empty input" and "halts on every input" are not properties of the language, since a machine can accept the same strings while looping or halting elsewhere. Example: the decider for and its halting variant (every halting rejection replaced by an endless loop) accept exactly the same language (checked on all strings up to length ), but the first halts on the input (rejecting) while the second never halts on it. So Rice's theorem does not apply to such questions; they are undecidable by direct reductions from the halting problem instead.
Trivial properties. " is a recognisable language" holds for every machine; the question is decidable (the answer is always yes). The same for the property " is not recognisable".
The language class matters. The theorem is about recognisable languages. For a different model, results change: all the properties above are decidable for DFAs (, , finiteness).
Worked examples
EX 1Apply the theorem
Easy"Is infinite?" The property "infinite" is a property of languages, non-trivial ( is infinite, is not, both are recognisable). Hence the set of machines with an infinite language is undecidable by Rice's theorem.
EX 2Rice does not apply
Easy"Does have more than states?" This is read off the description of , so it is decidable. "Does halt within moves on the input ?" Simulate moves: decidable. Neither is a question about .
EX 3The trap with halting
Medium"Does halt on every input?" looks like a question about all of but is not a property of : is only what accepts. The set of machines that halt on every input is undecidable, but the proof is a separate reduction (from the halting problem), not Rice's theorem.
EX 4Run the proof for a concrete property
MediumProperty = "the language contains the string ". . Take = the machine that accepts every string. Given build = "run on ; if it accepts, accept". If accepts , ; otherwise . So iff accepts . The table shows the machines for , , , and others.
EX 5Typical questions
GATE level(a) "Which of these is undecidable for a Turing machine : (i) is empty; (ii) is regular; (iii) has states; (iv) contains a string of length ?" (i), (ii), (iv) by Rice; (iii) is decidable. (b) "By Rice's theorem, which of the following is decidable?" The one that is not a non-trivial property of . (c) "The set of Turing machines that accept at least one string is:" recursively enumerable but not recursive. (d) "Is it decidable whether two Turing machines accept the same language?" No. (e) "Does Rice's theorem show that it is undecidable whether a TM halts on all inputs?" No, a separate reduction is needed.
Cheat box
Cheat box
- Rice: every non-trivial property of is undecidable (set of with in a non-trivial class of recognisable languages).
- Proof: reduce ; runs on , then on ; or .
- Applies to: emptiness, universality, finiteness, regularity, containing a string, equivalence of two machines.
- Does not apply to: number of states, halting within moves, halting on a given or on all inputs (not properties of the language).
- Trivial properties are decidable.
Traps and GATE patterns
Connections
Across subjects
No cross-subject links yet.
Within this subject
Rice's theorem generalises the reduction used for (halting problem); it uses the machine descriptions and the universal machine (TM variants); the contrast with decidable problems for automata is on the page on decidable languages.
PYQs
6 previous year questions from your book. I re-solved each one myself (0 by running or simulating, 6 by reasoning only); the book's key is shown next to my answer. All PYQs
Which of the following is/are undecidable?
- (a)Given two Turing machines M1, and M2, decide if L(M1) = L(M2).
- (b)Given a Turing machine M, decide if L(M) is regular.
- (c)Given a Turing machine M, decide if M accepts all strings.
- (d)Given a Turing machine M, decide if M takes more than 1073 steps on every string.
Which of the following languages are undecidable? Note
that <M> indicates encoding of the Turing machine M.
L1 = <M> | L(M) = φ}
L2 = {<M, w, q>| M on input w reaches state q in exactly
100 steps}
L3 = {<M>|L(M) is not recursive}
L4 = {<M>|L(M) contains at least 21 members}?- (a)L2 and L3 only
- (b)L1 and L3 only
- (c)L2, L3 and L4 only
- (d)L1, L3 and L4 only
Consider the following problems. L(G) denotes the language generated by a grammar G. L(M) denotes the language accepted by a machine M. (I) For an unrestricted grammar G and a string w, whether w∈L(G). (II) Given a Turing machine M, whether L(M) is regular. (III)Given two grammar G1 and G2, whether L(G1) = L(G2). (IV) Given an NFA N, whether there is a deterministic PDA P such that N and P accept the same language. Which one of the following statement is correct?
- (a)Only I and II are undecidable
- (b)Only III is undecidable
- (c)Only II and IV are undecidable.
- (d)Only I, II and III are undecidable.
Consider the following languages.
L1 = { ⟨M⟩ | M takes at least 2016 steps on some input },
L2 = { ⟨M⟩ | M takes at least 2016 steps on all inputs },
and
L3 = { ⟨M⟩ | M accepts ε },
Where for each Turing machine M, ⟨M⟩ denotes a specific
encoding of M.
Which one of the following is TRUE?- (a)L1 is recursive and L2, L3 are not recursive
- (b)L2 is recursive and L1, L3 are not recursive
- (c)L1, L2 are recursive and L3 is not recursive
- (d)L1, L2, L3 are recursive
Let <M> be the encoding of a Turing machine as a
string over Σ = {0, 1} Let L = { <M> |M is a Turing
machine that accepts a string of length 2014}. Then, L
is :- (a)decidable and recursively enumerable
- (b)undecidable but recursively enumerable
- (c)undecidable and not recursively enumerable
- (d)decidable but not recursively enumerable
Which of the following is/are undecidable? 1. G is a CFG. Is L(G) = φ? 2. G is a CFG. Is L(G) = Σ*? 3. M is a Turing machine. Is L(M) regular? 4. A is a DFA and N is an NFA. Is L(A) = L(N)?
- (a)3 only
- (b)3 and 4 only
- (c)1, 2 and 3 only
- (d)2 and 3 only
Self-check
Question 1
Is it decidable whether a Turing machine accepts the empty language? Why?
Show answerHide
No: "the language is empty" is a non-trivial property of the language, so Rice's theorem applies.
Question 2
Is it decidable whether a Turing machine has at least states?
Show answerHide
Yes: it is a property of the description of the machine, so one just counts.
Question 3
In the proof, what is if loops on ?
Show answerHide
The empty language: never gets past the simulation of on , so it accepts nothing.
Question 4
Why does Rice's theorem not show that "halts on every input" is undecidable?
Show answerHide
It is not a property of the language: two machines with the same language can differ in whether they halt everywhere.
Revision card
One-screen revision
- Non-trivial property of undecidable.
- Proof: property via = "run on , then on ".
- Not covered: properties of the machine (states, moves), halting on inputs.
- Trivial properties and automata questions are decidable.
References
- ·Sipser, Introduction to the Theory of Computation (3rd edition), Problem 5.28 (Rice's theorem) and Section 5.1
- ·Hopcroft, Motwani, Ullman, Introduction to Automata Theory, Languages, and Computation (3rd edition), Section 9.3 (Rice's theorem and properties of recursively enumerable languages)
Verification
scripts/enum-checks/toc_compute.py: the machine M_w of the proof (ignore the input, run M on w, accept if M accepts) was checked on six machines, all strings w up to length 3 and all inputs x up to length 3: M_w accepts x exactly when M accepts w, so L(M_w) is everything or nothing; the machine for a^n b^n and its 'halting variant' (every halting rejection replaced by an endless loop) accept the same language on all strings up to length 8 but the first halts on the input a and the second never halts there, so 'halts on every input' is not a property of the language; 'halts within k moves' agrees with a second simulator for k up to 11 on all short inputs of six machines. The statement and proof of Rice's theorem and the list of undecidable properties are standard textbook results, QUOTED and not machine-proved here (needs verification). The chapter references are from memory; Sipser states the theorem as a problem. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand or by a small script (state counts, derivations, parse-tree and move counts, decomposition counts); tables and animations are machine output and were read, not re-run; No other defect found. Status raised to self-checked; verified needs a textbook or human check.
last verified: never
My notes (saved in this browser)