Lecture 10: Rice's Theorem

Undecidability of Non-trivial Semantic Properties of Languages

Background: What Rice's Theorem Talks About

Rice's theorem is about properties of the language recognized by a Turing machine, not properties of the machine's syntax. If a property depends only on \(L(M)\), then it is semantic.

Reference: Rice's theorem (Wikipedia)

Semantic vs Syntactic

  • Semantic: "\(L(M)\) is empty", "\(L(M)\) is regular", "\(L(M)\) is finite".
  • Syntactic: "\(M\) has exactly 12 states", "\(M\)'s start state is \(q_3\)".

Rice applies only to semantic properties of recursively enumerable languages.

Trivial vs Non-trivial Property

A property \(\mathcal{P}\) of RE languages is:

  • Trivial if either every RE language has \(\mathcal{P}\), or none has \(\mathcal{P}\).
  • Non-trivial if some RE language has \(\mathcal{P}\) and some RE language does not.

Rice's theorem: every non-trivial semantic property is undecidable.

Quick Intuition

If we could decide any non-trivial property of \(L(M)\), we could indirectly decide deep behavior questions like acceptance, which is impossible by the undecidability of \(A_{TM}\).

Machine, Input, and Language of the Decision Problem

Objects

  • Machine under test: a Turing machine \(M\).
  • Input to the decider: the encoding \(\langle M \rangle\).
  • Underlying language of \(M\): \(L(M)=\{x\mid M \text{ accepts } x\}\).

Property Language Form

For any semantic property \(\mathcal{P}\) of RE languages, define:

\[ L_{\mathcal{P}}=\{\langle M\rangle \mid L(M)\in \mathcal{P}\}. \]

Reference Undecidable Language

We reduce from:

\[ A_{TM}=\{\langle M,w\rangle \mid M \text{ accepts } w\} \]

\(A_{TM}\) is undecidable.

Theorem Statement (Rice)

Let \(\mathcal{P}\) be a non-trivial property of RE languages. Then \(L_{\mathcal{P}}\) is undecidable.

Formal Proof of Rice's Theorem

Step 1. Fix any non-trivial semantic property \(\mathcal{P}\) of RE languages; define \(L_{\mathcal{P}}=\{\langle M\rangle\mid L(M)\in\mathcal{P}\}\). [Definition]
Explanation: We choose one meaningful language property and turn it into a decision problem on machine encodings.
Step 2. Assume there exists a decider \(R\) for \(L_{\mathcal{P}}\). [Assumption for contradiction]
Explanation: Assume the property is decidable, and we will show this assumption leads to impossibility.
Step 3. Because \(\mathcal{P}\) is non-trivial, choose witness RE languages \(L_+,L_-\) and witness machines \(T_+,T_-\). [Non-triviality + RE witness]
\[ L_+\in\mathcal{P}, \qquad L_-\notin\mathcal{P}, \qquad L(T_+)=L_+, \qquad L(T_-)=L_-. \]
Explanation: \(T_+\) is a witness machine whose language satisfies the property (\(L(T_+)\in\mathcal{P}\)); \(T_-\) is a witness machine whose language does not (\(L(T_-)\notin\mathcal{P}\)). We can choose both because the property is non-trivial.
Step 4. It suffices to derive a decider for \(A_{TM}\), where \(A_{TM}=\{\langle M,w\rangle\mid M\text{ accepts }w\}\). [Reduction target]
Explanation: If \(R\) helps us decide \(A_{TM}\), then \(R\) cannot exist because \(A_{TM}\) is undecidable.
Step 5. Let input \(\langle M,w\rangle\) be arbitrary. Construct machine \(N=N_{M,w}\) by: [Effective construction]
Explanation: We build \(N\) so that its language changes depending on whether \(M\) accepts \(w\).
\[ N(x):\ \text{simulate }M\text{ on }w;\ \text{if }M\text{ accepts }w,\text{ then run }T\text{ on }x;\ \text{otherwise never accept }x, \] where \(T=T_+\) if \(\emptyset\notin\mathcal{P}\), and \(T=T_-\) if \(\emptyset\in\mathcal{P}\).
Step 6. Therefore [By construction]
Explanation: So \(L(N)\) is either \(L(T)\) or \(\emptyset\), exactly according to whether \(M\) accepts \(w\).
\[ L(N)= \begin{cases} L(T), & \text{if } M \text{ accepts } w,\\ \emptyset, & \text{if } M \text{ does not accept } w. \end{cases} \]
Step 7. Case split on whether \(\emptyset\in\mathcal{P}\). [Exhaustive cases]
Explanation: We now analyze both exhaustive possibilities for the empty language.
Step 7.1. Assume \(\emptyset\notin\mathcal{P}\). Then \(T=T_+\) and \(L(T)\in\mathcal{P}\). [Choice of \(T\)]
Explanation: In this branch, we choose the witness machine whose language has property \(\mathcal{P}\).
Step 7.2. From Step 6, \(\langle M,w\rangle\in A_{TM}\iff L(N)=L(T)\in\mathcal{P}\iff \langle N\rangle\in L_{\mathcal{P}}\). [Substitution]
Explanation: Here, \(M\) accepts \(w\) exactly when \(R\) would accept \(\langle N\rangle\).
Step 7.3. Hence \(R(\langle N\rangle)\) decides whether \(\langle M,w\rangle\in A_{TM}\). [From Step 7.2]
Explanation: So this branch already gives a decision procedure for \(A_{TM}\).
Step 7.4. Assume \(\emptyset\in\mathcal{P}\). Then \(T=T_-\) and \(L(T)\notin\mathcal{P}\). [Choice of \(T\)]
Explanation: In the other branch, we choose the witness machine whose language does not have \(\mathcal{P}\).
Step 7.5. From Step 6, \(\langle M,w\rangle\in A_{TM}\iff L(N)=L(T)\notin\mathcal{P}\iff \langle N\rangle\notin L_{\mathcal{P}}\). [Substitution]
Explanation: Now \(M\) accepts \(w\) exactly when \(R\) would reject \(\langle N\rangle\).
Step 7.6. Since \(R\) is a decider, negating \(R(\langle N\rangle)\) decides whether \(\langle M,w\rangle\in A_{TM}\). [Computable complement]
Explanation: Flipping the output of \(R\) gives a decider for \(A_{TM}\) in this branch too.
Step 8. In either case, \(A_{TM}\) is decidable. [From Step 7.3 and Step 7.6]
Explanation: Both branches imply \(A_{TM}\) is decidable, regardless of whether \(\emptyset\in\mathcal{P}\).
Step 9. Contradiction, because \(A_{TM}\) is undecidable. [Known theorem]
Explanation: This contradicts the standard theorem that \(A_{TM}\) cannot be decided.
Step 10. Therefore no decider \(R\) exists for \(L_{\mathcal{P}}\); every non-trivial semantic RE property is undecidable. \(\square\) [Discharge Step 2]
Explanation: So the assumption in Step 2 is false, proving Rice's theorem.

Proof Flow Diagram

Input pair <M,w> instance of A_TM Computable transform f construct N = N_M,w if M accepts w: L(N)=L(T) else: L(N)=empty Feed to decider R input: <N> for L_P Branch A: empty not in P M accepts w iff L(N)=L(T) in P M not accept iff L(N)=empty not in P So R decides A_TM Contradiction Branch B: empty in P Choose T with L(T) not in P Invert R output to decide A_TM Decider for A_TM again Contradiction

Takeaway: Any total decider for a non-trivial semantic property would force a decider for \(A_{TM}\), which is impossible.

Undecidable Property Examples via Rice's Theorem

For each example below, the input is \(\langle M\rangle\), and we ask whether \(L(M)\) has the stated property.

Example 1: Emptiness

\[E_{TM}=\{\langle M\rangle\mid L(M)=\emptyset\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L=\emptyset)\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\emptyset\in\mathcal{P}\), \(\Sigma^*\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(E_{TM}\) is undecidable. [Rice's theorem]

Example 2: Non-emptiness

\[NE_{TM}=\{\langle M\rangle\mid L(M)\neq\emptyset\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L\neq\emptyset)\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\Sigma^*\in\mathcal{P}\), \(\emptyset\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(NE_{TM}\) is undecidable. [Rice's theorem]

Example 3: Finiteness

\[FINITE_{TM}=\{\langle M\rangle\mid L(M)\text{ is finite}\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L\text{ is finite})\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\{0,1\}\in\mathcal{P}\), \(\Sigma^*\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(FINITE_{TM}\) is undecidable. [Rice's theorem]

Example 4: Infiniteness

\[INF_{TM}=\{\langle M\rangle\mid L(M)\text{ is infinite}\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L\text{ is infinite})\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\Sigma^*\in\mathcal{P}\), \(\{0,1\}\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(INF_{TM}\) is undecidable. [Rice's theorem]

Example 5: Regularity

\[REG_{TM}=\{\langle M\rangle\mid L(M)\text{ is regular}\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L\text{ is regular})\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\emptyset\in\mathcal{P}\), \(\{0^n1^n\mid n\ge 0\}\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(REG_{TM}\) is undecidable. [Rice's theorem]

Example 6: Universality

\[ALL_{TM}=\{\langle M\rangle\mid L(M)=\Sigma^*\}\]
Step 1. Define \(\mathcal{P}(L)\iff (L=\Sigma^*)\). [Property definition]
Step 2. \(\mathcal{P}\) is semantic and non-trivial (\(\Sigma^*\in\mathcal{P}\), \(\emptyset\notin\mathcal{P}\)). [Witness languages]
Step 3. Therefore \(ALL_{TM}\) is undecidable. [Rice's theorem]

Important Boundary

Rice's theorem does not apply to syntactic properties of machine descriptions. Example: "Does \(M\) have exactly 7 states?" is decidable by direct inspection of \(\langle M\rangle\).

🏠