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

REGULARTM is undecidable

Use the {0n1n} gadget to make L(M') regular iff M accepts w.

CLO-2R1·30 ptsL6
🔊 Listen

"Can my program's language be described by a regex?" is a natural classification question. It would be useful to know — regular languages have linear-time matchers, predictable behavior, no need for stack or tape. Sadly, the question is undecidable in general. This is the simplest example of a structural language property that Rice's theorem will later unify.

What we prove

REGULARTM = {⟨M⟩ : L(M) is a regular language} is undecidable.

🔊 Listen

Reduce ATM to REGULARTM. Given ⟨M, w⟩, build M' with two branches:

Construction

M' = "on input x:
  1. if x has form 0n1n: accept;
  2. else: simulate M on w; accept x iff M accepts w."

Why 0n1n? Because it's the canonical non-regular decidable language. The construction needs a "non-regular base case" that M' can recognize on its own; {0n1n} is the simplest.

🔊 Listen

So ⟨M, w⟩ ∈ ATM ⇔ ⟨M'⟩ ∈ REGULARTM. A decider for REGULARTM ⇒ decider for ATM. Contradiction ⇒ REGULARTM undecidable.

🔊 Listen
L(M') flips between {0n1n} and Σ* Auto-plays
🔊 Listen

Take M = "always halts and rejects" (so M(w) = reject for every w). Then for every choice of w:

Take M' = "always halts and accepts everything", w = anything. M accepts w. Branch 2 always accepts. L(M') = Σ*, regular. ⟨M'⟩ ∈ REGULARTM.

🔊 Listen
🔊 Listen
  1. Forgetting branch 1. Without the unconditional accept of 0n1n, L(M') = ∅ when M doesn't accept w — and ∅ is regular. The construction fails.
  2. Confusing "regular" with "decidable". {0n1n} is decidable but not regular. The gadget needs decidable + non-regular.
  3. "M' must be deterministic." Not required. The TM model here is the standard deterministic TM; M' just uses a polynomial gadget on its input.
  4. Mixing up the direction. ⟨M, w⟩ ∈ ATM ⇔ L(M') regular. Don't flip it.
🔊 Listen
🔊 Listen

Total time: 8 minutes.