THEORY OF COMPUTATION / 6. DECIDABILITY & REDUCTIONS
Decidability, Reductions & Rice's Theorem
What computers fundamentally cannot do — proven mathematically
EXPLANATION
Decidability theory draws a sharp line: some problems have no algorithmic solution, not because we haven't found one yet, but because it's been mathematically PROVEN that none can exist.
Key decidability results:
DECIDABLE (algorithms exist):
- ATM complement: is this DFA equivalent to that DFA? → YES, decidable
- Does this CFG generate the empty language? → decidable
- Does this DFA accept any strings? → decidable (check if accept state reachable)
- Is this number prime? → decidable (Miller-Rabin, AKS)
- Does this regex match this string? → decidable
UNDECIDABLE (proven impossible):
- ATM = {⟨M, w⟩ | TM M accepts input w} — the ACCEPTANCE problem. Recognizable but not decidable.
- HALTTM = {⟨M, w⟩ | TM M halts on w} — the HALTING problem.
- ETM = {⟨M⟩ | L(M) = ∅} — does TM accept NO strings?
- EQTM = {⟨M1,M2⟩ | L(M1) = L(M2)} — do two TMs accept same language?
- REGULARTM = {⟨M⟩ | L(M) is regular} — undecidable!
- Does program P have a bug? → undecidable in general
Mapping Reductions (A ≤m B — A reduces to B):
A computable function f such that: w ∈ A ↔ f(w) ∈ B
- If B is decidable and A ≤m B → A is decidable
- If A is undecidable and A ≤m B → B is undecidable
- Standard technique: to prove X is undecidable, show ATM ≤m X
Rice's Theorem — the most powerful undecidability result:
"Any non-trivial property of the language recognized by a TM is undecidable."
Non-trivial: some TMs have it, some don't.
Examples of non-trivial properties:
- Does TM accept the empty string?
- Does TM accept any string?
- Does TM accept all strings?
- Is the language regular? Context-free? Finite?
- Does TM halt in fewer than 1000 steps on some input?
ALL of these are undecidable by Rice's Theorem.
Practical implications:
- No perfect static analysis tool (cannot detect all bugs)
- No perfect malware detector (malware detection reduces to halting problem)
- No perfect type inference for all programs (some type systems undecidable)
- No perfect program equivalence checker
- Software verification is fundamentally limited
What we CAN do (approximations):
- Bounded model checking: check for bugs up to depth k
- Abstract interpretation: over-approximate program behavior (may have false positives)
- Type systems: conservative — reject some correct programs but catch many bugs
- Fuzzing: find bugs probabilistically, not exhaustivelyDIAGRAM
REDUCTION: ATM ≤m HALTTM
To decide ATM (does M accept w?):
Transform input ⟨M, w⟩ into ⟨M', w⟩ where:
M' = M but modified to never loop (it halts-and-rejects instead of looping)
If HALTTM were decidable:
⟨M, w⟩ → [transform] → ⟨M', w⟩ → [HALTTM decider] → halts?
If yes: run M on w, output whatever M outputs
If no: output REJECT
This would decide ATM → contradiction (ATM undecidable)
Therefore HALTTM is undecidable ∎
RICE'S THEOREM — what it kills:
Property Decidable?
────────────────────────────────────────────
Does M accept "hello"? ✗ NO (non-trivial)
Does M accept ANY string? ✗ NO (non-trivial)
Does M accept ALL strings? ✗ NO (non-trivial)
Is L(M) regular? ✗ NO (non-trivial)
Is L(M) finite? ✗ NO (non-trivial)
Does M halt on all inputs? ✗ NO (non-trivial)
Does M have exactly 5 states? ✓ YES (not about L(M)!)
Is M's description length < 100? ✓ YES (not about L(M)!)CODE