← Student tools · Problem 11 · Lecture 7 · Round 1 (30 pts)

ALLCFG is undecidable

Build a CFG GM,w that generates everything EXCEPT accepting computation histories of M.

CLO-2R1·30 ptsL7
🔊 Listen

ALLCFG = {⟨G⟩ : L(G) = Σ*}. Sipser proves it undecidable by reducing from ATM. The construction has a key inversion that students often find confusing: we don't build a CFG that recognises accepting computation histories — that would require a CFG to verify a TM, which is beyond CFG power. Instead we build a CFG that recognises everything except accepting computation histories.

Why this matters

CFGs are good at existential structure: "the string has some part that is bad." They can nondeterministically pick a position and check a local property there. They are bad at universal structure: "every part of the string is good." That requires correlating multiple positions without bounded memory — the canonical pumping-lemma failure.

A valid accepting computation history is a universal structure (every adjacent pair is correct). A broken history is existential (some adjacent pair is wrong). So the CFG checks the broken side.

The construction f(⟨M, w⟩) = ⟨GM,w

GM,w generates string x iff x exhibits at least one of these four failures:

  1. x is not formatted as C1 # C2 # … # C.
  2. C1 ≠ q0w (wrong start config).
  3. Some adjacent pair (Ci, Ci+1) violates δ.
  4. C does not contain qaccept.

Then L(GM,w) = Σ* if and only if every string fails at least one check, i.e. no valid accepting history exists for M on w, i.e. M does not accept w. A decider for ALLCFG would decide ¬ATM. Impossible.

🔊 Listen
Sipser's trick · alternate configurations are written backwards Naïve: C₁ # C₂ # C₃ # C₄ → comparing (C₁, C₂) needs positional matching · CFGs can't Trick: C₁ # C₂ᴿ # C₃ # C₄ᴿ # … → each adjacent pair lays out as a palindrome-like structure a b c # c' b' a' C₁ in normal order C₂ reversed Why it helps A palindrome-like structure is exactly what a CFG can match. Stack: push C₁ symbols left-to-right, pop while reading C₂ᴿ right-to-left. Position-matching becomes adjacency, which CFGs handle.

The grammar nondeterministically guesses where a violation occurs, then checks it locally. Crucially: the grammar accepts when it finds a violation. A correctly-formed accepting history goes through the grammar without any violation being detectable — so it is not generated.

🔊 Listen
The CFG works by guessing where a history goes wrong Auto-plays
🔊 Listen
🔊 Listen
🔊 Listen

Sipser: §5.1, Theorem 5.13 (ALLCFG is undecidable). Lecture notes: Module 3 slide 4 covers GM,w. Companion problems: P9 (computation histories), P10 (ELBA, the LBA sibling), P14 (Rice's theorem — does this for arbitrary non-trivial TM properties).