Build a CFG GM,w that generates everything EXCEPT accepting computation histories of M.
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.
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.
GM,w generates string x iff x exhibits at least one of these four failures:
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.
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.
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).