Introduction

A language is decidable (recursive) if some TM halts on every input and accepts exactly the strings in the language. It is undecidable if no such TM exists. Many natural questions about automata and grammars are decidable for regular languages, partly decidable for CFLs, and undecidable for Turing machines. The core is the standard decision table, the halting problem, reductions at a qualitative level, and Rice's theorem as a named hammer for nontrivial semantic properties of r.e. languages.

Prerequisites

  • Turing Machines: recognizers, deciders, encodings ⟨M,w⟩\langle M,w\rangle.

Core concepts

Core undecidable languages

  • ATM={⟨M,w⟩∣M accepts w}A_{\mathrm{TM}} = \{ \langle M,w\rangle \mid M \text{ accepts } w \} is r.e. but undecidable (Sipser 4.2).
  • HALTTM={⟨M,w⟩∣M halts on w}\mathrm{HALT}_{\mathrm{TM}} = \{ \langle M,w\rangle \mid M \text{ halts on } w \} is undecidable.
  • ETM={⟨M⟩∣L(M)=∅}E_{\mathrm{TM}} = \{ \langle M\rangle \mid L(M)=\emptyset \} is undecidable.
  • EQTM={⟨M1,M2⟩∣L(M1)=L(M2)}\mathrm{EQ}_{\mathrm{TM}} = \{ \langle M_1,M_2\rangle \mid L(M_1)=L(M_2) \} is undecidable.

Reductions

To prove LL undecidable, reduce a known undecidable problem AA to LL: give a computable map ff such that x∈A⇔f(x)∈Lx \in A \Leftrightarrow f(x) \in L. If LL were decidable, composing with ff would decide AA.

Direction matters: reduce from the known hard problem to the new problem.

Mapping reduction arrow from a known undecidable problem to a target problem
Figure 1. Mapping reduction: computable f transforms instances of a known undecidable language A into instances of L so that membership is preserved; an arrow A to L shows the reduction direction used to prove L undecidable.

Rice's theorem (statement)

Every nontrivial semantic property of r.e. languages is undecidable. More precisely: if PP is a set of r.e. languages that is nonempty and not all r.e. languages, then {⟨M⟩∣L(M)∈P}\{ \langle M\rangle \mid L(M) \in P \} is undecidable. Use it to dismiss questions like "does L(M)L(M) contain 000000?" without a custom reduction.

Decision table by class

QuestionRegularCFLTM / r.e.
MembershipDDundecidable in general (ATMA_{\mathrm{TM}})
EmptinessDDundecidable
FinitenessDDundecidable
EquivalenceDundecidableundecidable
Regularitytrivialundecidableundecidable

(D = decidable.) The finer table below adds DCFL and CSL columns and the standard problems.

QuestionREGDCFLCFLCSLRECRE
Membership w∈Lw \in LDDD (CYK)D (LBA)Dundecidable
Emptiness L=∅L = \emptysetDDDundecidableundecidableundecidable
FinitenessDDDundecidableundecidableundecidable
Universality L=Σ∗L = \Sigma^*DD (complement, then emptiness)undecidableundecidableundecidableundecidable
Equivalence L1=L2L_1 = L_2DD (Senizergues)undecidableundecidableundecidableundecidable
Containment L1⊆L2L_1 \subseteq L_2Dundecidableundecidableundecidableundecidableundecidable
Disjointness L1∩L2=∅L_1 \cap L_2 = \emptysetDundecidableundecidableundecidableundecidableundecidable
Is LL regular?trivially yesD (Stearns)undecidableundecidableundecidableundecidable

Ambiguity of a CFG is undecidable; for a right-linear grammar it is decidable (look for two accepting paths on one string in the matching NFA). Two rows are easy to confuse: DCFL equivalence is decidable, but DCFL containment is not; CFL emptiness is decidable, but CFL universality is not.

Decidability table by language class for membership emptiness finiteness equivalence
Figure 2. Decision table summarizing decidable versus undecidable problems for regular languages, CFLs, and Turing-machine languages.

How it works

Diagonalization sketch for ATMA_{\mathrm{TM}}

Assume a decider HH for ATMA_{\mathrm{TM}}. Build DD that on ⟨M⟩\langle M\rangle runs H(⟨M,⟨M⟩⟩)H(\langle M,\langle M\rangle\rangle) and does the opposite. Then DD on ⟨D⟩\langle D\rangle contradicts. Hence HH cannot exist. ATMA_{\mathrm{TM}} is still r.e. via a universal simulator that accepts when the simulated machine accepts.

From ATMA_{\mathrm{TM}} to HALT

Reduce: given ⟨M,w⟩\langle M,w\rangle, build M′M' that runs MM on ww and accepts if that accepts; if MM would reject, M′M' loops. Then MM accepts ww iff M′M' halts on ww.

Algorithms and pseudocode

Deciders exist for regular and many CFL problems (earlier notes). For TMs, the "algorithm" is often a proof that none exists. A recognizer for ATMA_{\mathrm{TM}}:

Text
U(<M,w>)          // universal recognizer
1  simulate M on w
2  if M accepts: accept
3  if M rejects: reject
4  // if M loops, U loops

Mathematical explanation

Recursive vs r.e.

LL decidable ⇔\Leftrightarrow LL and L‾\overline{L} both r.e. Consequently, ATMA_{\mathrm{TM}} r.e. and undecidable implies ATM‾\overline{A_{\mathrm{TM}}} is not even r.e.

Why CFG equivalence is undecidable

For a TM MM, write an accepting computation as C1#C2R#C3#C4R⋯C_1 \# C_2^R \# C_3 \# C_4^R \cdots. The set of strings that are not such a history for MM on blank input is a CFL: a PDA guesses one local defect (wrong start, no accept at the end, or one pair Ci,Ci+1C_i, C_{i+1} that does not follow by δ\delta; the reversal of every second configuration lets the stack compare them). This CFL is Σ∗\Sigma^* iff MM has no accepting computation. So CFG universality is undecidable, and equivalence follows by comparing with a fixed grammar for Σ∗\Sigma^*.

Post's correspondence problem

An instance is a list of dominoes (t1,b1),…,(tk,bk)(t_1, b_1), \ldots, (t_k, b_k) of strings; a solution is a nonempty index sequence i1…imi_1 \ldots i_m with ti1⋯tim=bi1⋯bimt_{i_1} \cdots t_{i_m} = b_{i_1} \cdots b_{i_m}. PCP is undecidable (it encodes TM computations), but it is RE: try all sequences in order of length. PCP over a one-letter alphabet is decidable. PCP reduces to CFG ambiguity and to CFG intersection-emptiness, which is how those two problems are shown undecidable.

Worked examples

Example 1: table lookup

Emptiness of DFA: decidable. Emptiness of TM: undecidable. Equivalence of CFG: undecidable. Membership in CFG: decidable.

Example 2: Rice application

"Does L(M)L(M) contain at least one even-length string?" Nontrivial semantic property ⇒\Rightarrow undecidable by Rice.

Example 3: not Rice

"Does MM have more than 10 states?" is a syntactic property of the description, decidable by reading ⟨M⟩\langle M\rangle. Rice does not apply.

Example 4: reduction direction

Wrong: "reduce HALT to my easy problem." Right: reduce HALT (hard) to the problem you claim is hard. For a mapping reduction A≤mBA \le_m B:

Known factConclusion
BB decidableAA decidable
BB REAA RE
AA undecidableBB undecidable
AA not REBB not RE
A≤mBA \le_m BA‾≤mB‾\overline{A} \le_m \overline{B} (same ff)

Nothing follows from "AA decidable" or "BB undecidable". Since ATM‾\overline{A_{\mathrm{TM}}} is not RE, any BB with ATM‾≤mB\overline{A_{\mathrm{TM}}} \le_m B is not RE; this is how ETME_{\mathrm{TM}} and EQTMEQ_{\mathrm{TM}} are shown not RE.

Example 5: decidable TM special cases

Some questions about TMs are decidable because they bound the run or ignore the language:

  • "Does MM halt on ww within 100 steps?" Decidable: simulate 100 steps.
  • "Does MM ever move left on input ww?" Decidable: if after ∣w∣+∣Q∣+1|w| + |Q| + 1 right moves it has not moved left, it is in the blanks and some state has repeated, so it moves right forever.
  • "Does MM have more than 10 states?" Decidable (syntax).
  • "Does MM ever enter state qq on input ww?" Undecidable: reduce ATMA_{\mathrm{TM}} with q=qacceptq = q_{\mathrm{accept}}.

Example 6: Rice, and how far up the ladder

Rice's theorem says only "undecidable"; the finer question is whether the set of machine codes is RE, co-RE, or neither.

Set of ⟨M⟩\langle M \rangleStatus
L(M)≠∅L(M) \ne \emptyset; ε∈L(M)\varepsilon \in L(M); ∣L(M)∣≥3\lvert L(M)\rvert \ge 3RE, not decidable (search for accepted strings by dovetailing)
L(M)=∅L(M) = \emptyset (ETME_{\mathrm{TM}})co-RE, not RE
MM halts on ε\varepsilonRE, not decidable
L(M)L(M) finite; L(M)=Σ∗L(M) = \Sigma^*; L(M)L(M) regular; L(M1)=L(M2)L(M_1) = L(M_2)neither RE nor co-RE
MM has an even number of statesdecidable (not a property of L(M)L(M))

A test for "not RE" (Rice-Shapiro theorem): if the set is RE, then (a) whenever LL has the property so does every RE superset of LL, and (b) LL has the property only if some finite subset of LL has it. "L(M)=∅L(M) = \emptyset" fails (a), since ∅\emptyset has it and {ε}\{\varepsilon\} does not; "L(M)L(M) is infinite" fails (b). Both sets are therefore not RE.

Example 7: a PCP instance

Dominoes 1=(b,ca)1 = (b, ca), 2=(a,ab)2 = (a, ab), 3=(ca,a)3 = (ca, a), 4=(abc,c)4 = (abc, c). The sequence 2,1,3,2,42, 1, 3, 2, 4 gives top a⋅b⋅ca⋅a⋅abc=abcaaabca \cdot b \cdot ca \cdot a \cdot abc = abcaaabc and bottom ab⋅ca⋅a⋅ab⋅c=abcaaabcab \cdot ca \cdot a \cdot ab \cdot c = abcaaabc, a solution, and no shorter sequence works. The instance (a,aa),(b,bb)(a, aa), (b, bb) has no solution: every top is shorter than its bottom, so the top string can never catch up.

Important properties and observations

  • Undecidable does not mean "unknown"; it means "no algorithm exists".
  • r.e. languages are closed under union and intersection, not under complement.
  • Recursive languages are closed under complement, union, intersection.
  • Always mark whether a TM problem is about syntax of ⟨M⟩\langle M\rangle or about L(M)L(M).

Common misconceptions.

  • Reversing reduction arrows.
  • Applying Rice to syntactic properties.
  • Applying Rice to a property of a restricted model (DFAs, CFGs); Rice is about TMs and RE languages only, and emptiness of a DFA is decidable.
  • Using Rice for trivial properties ("L(M)L(M) is RE" is true for every MM, so it is decidable).
  • Thinking CFL universality is decidable because CFL emptiness is.
  • Saying ATMA_{\mathrm{TM}} is not r.e. (it is r.e., but undecidable).

GATE examination perspective

  • TABLE FIRST. Regular / CFL / TM columns.
  • RICE OR REDUCE. Pick the shorter tool.
  • RECOGNIZER EXISTS IS NOT DECIDER EXISTS.
  • DIRECTION OF REDUCTION. From known undecidable to target.
  • FINE TABLE. CFL: membership, emptiness, finiteness D; universality, equivalence, ambiguity, regularity, disjointness undecidable. DCFL equivalence D.
  • RE / CO-RE. "L(M)L(M) nonempty" is RE; "L(M)L(M) empty" is co-RE; "finite", "regular", "equal" are neither.
  • PCP. Undecidable in general, decidable over a unary alphabet, RE by enumeration.

Summary

Sources

  1. M. Sipser, Introduction to the Theory of Computation, 3rd ed., Cengage Learning, Section 4.1 (decidable problems concerning regular and context-free languages), Section 4.2 (undecidability; a Turing-unrecognizable language), Section 5.1 (undecidable problems from language theory; reductions via computation histories), Section 5.2 (a simple undecidable problem: PCP), Section 5.3 (mapping reducibility).
  2. J. E. Hopcroft, R. Motwani, J. D. Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Pearson Addison-Wesley, Section 9.2 (an undecidable problem that is RE), Section 9.3 (undecidable problems about TMs; Rice's theorem), Section 9.4 (Post's correspondence problem), Section 9.5 (other undecidable problems; ambiguity of CFGs).
  3. P. Linz, An Introduction to Formal Languages and Automata, 6th ed., Jones & Bartlett Learning, Section 12.1 (the halting problem; reducing one undecidable problem to another), Section 12.2 (undecidable problems for RE languages), Section 12.3 (the Post correspondence problem), Section 12.4 (undecidable problems for context-free languages).

Next steps