Quiz 2

Reductions — Proving Undecidability

1939 words
10 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Reductions — Proving Undecidability ## 🎯 Learning Objectives - Define mapping reductions and their properties - Reduce the Halting problem to other problems - Apply Rice's theorem to prove undecidability - Distinguish between Turing-recognizable and co-recognizable - Construct reduction functions * * * ## 1. Intr...

Reductions — Proving Undecidability

🎯 Learning Objectives

  • Define mapping reductions and their properties
  • Reduce the Halting problem to other problems
  • Apply Rice's theorem to prove undecidability
  • Distinguish between Turing-recognizable and co-recognizable
  • Construct reduction functions

1. Introduction to Reductions

1.1 Intuition

A reduction is like converting a problem you want to solve into one you already know how to solve. If you know how to decide whether a number is even, you can decide whether a number is odd by checking if (n+1) is even. Similarly, if we know the Halting problem is undecidable, we can prove other problems are undecidable by showing: "If I could decide problem X, I could decide the Halting problem — which is impossible."

1.2 Mapping Reduction

AmBA \leq_m B means: There exists a computable function ff such that wA    f(w)Bw \in A \iff f(w) \in B. (Diagram) Properties:
  • If BB is decidable and AmBA \leq_m B, then AA is decidable
  • If AA is undecidable and AmBA \leq_m B, then BB is undecidable
  • If AmBA \leq_m B and BmCB \leq_m C, then AmCA \leq_m C (transitive)

2. The Halting Problem

2.1 Definition

ATM={M,wM is a TM and M accepts w}A_{TM} = \{\langle M, w \rangle \mid M \text{ is a TM and } M \text{ accepts } w\} Theorem: ATMA_{TM} is undecidable. Proof (diagonalization): Assume HH decides ATMA_{TM}. Construct DD:
  • DD = "On input M\langle M \rangle:
    1. Run HH on M,M\langle M, \langle M \rangle \rangle
    2. If HH accepts, reject; if HH rejects, accept" Then D(D)D(\langle D \rangle) accepts iff DD does not accept D\langle D \rangle — contradiction.

3. Reduction Examples

3.1 Halting Problem HALTTMHALT_{TM}

HALTTM={M,wM halts on w}HALT_{TM} = \{\langle M, w \rangle \mid M \text{ halts on } w\} Reduction from ATMA_{TM}: f(M,w)=M,wf(\langle M, w \rangle) = \langle M', w \rangle where:
  • MM' runs MM on ww
  • If MM accepts, MM' accepts
  • If MM rejects, MM' loops forever Check: M,wATM    M\langle M, w \rangle \in A_{TM} \iff M accepts w    Mw \iff M' halts on w    M,wHALTTMw \iff \langle M', w \rangle \in HALT_{TM}

3.2 Empty Language ETME_{TM}

ETM={ML(M)=}E_{TM} = \{\langle M \rangle \mid L(M) = \emptyset\} Reduction from ATMA_{TM}: f(M,w)=Mf(\langle M, w \rangle) = \langle M'\rangle where:
  • MM' = "On input xx:
    1. If xwx \neq w, reject
    2. Run MM on ww and accept if MM accepts" Check: M,wATM    M\langle M, w \rangle \in A_{TM} \iff M accepts w    L(M)={w}    METMw \iff L(M') = \{w\} \neq \emptyset \iff \langle M' \rangle \notin E_{TM} Wait — we need ff such that wATM    f(w)ETMw \in A_{TM} \iff f(w) \in E_{TM}. Let me fix. f(M,w)=Mf(\langle M, w \rangle) = \langle M'\rangle where:
  • MM' ignores input and runs MM on ww
  • If MM accepts, MM' accepts Then:
  • If MM accepts ww: MM' accepts all inputs → L(M)=ΣL(M') = \Sigma^* \neq \emptysetMETM\langle M' \rangle \notin E_{TM}
  • If MM does not accept ww: MM' hangs or rejects → L(M)=L(M') = \emptysetMETM\langle M' \rangle \in E_{TM} So ATMmETMA_{TM} \leq_m \overline{E_{TM}}, which means ETME_{TM} is undecidable.

3.3 Regular Language REGTMREG_{TM}

REGTM={ML(M) is regular}REG_{TM} = \{\langle M \rangle \mid L(M) \text{ is regular}\} Reduction from ATMA_{TM}: Transform M,w\langle M, w \rangle into M\langle M' \rangle where:
  • MM' = "On input xx:
    1. If xx is of form 0n1n0^n1^n, accept
    2. Run MM on ww; if MM accepts, accept" Then:
  • If MM accepts ww: L(M)=ΣL(M') = \Sigma^* (regular)
  • If MM does not accept ww: L(M)={0n1n}L(M') = \{0^n1^n\} (not regular) Thus ATMmREGTMA_{TM} \leq_m REG_{TM}, so REGTMREG_{TM} is undecidable.

4. Rice's Theorem

4.1 Statement

Theorem: Any non-trivial property of Turing machine languages is undecidable. A property PP of languages is:
  • Non-trivial: Some recognizable languages have it, some don't
  • Semantic: Only depends on L(M)L(M), not on MM's implementation Examples of undecidable properties:
  • Is L(M)L(M) empty?
  • Is L(M)L(M) regular?
  • Is L(M)L(M) finite?
  • Does L(M)L(M) contain the string ε\varepsilon?
  • Is L(M)=ΣL(M) = \Sigma^*?

4.2 Proof Sketch

  1. Let PP be a non-trivial property
  2. Assume WLOG that \emptyset does NOT have property PP (otherwise use P\overline{P})
  3. Let BB be a language with property PP (exists because PP is non-trivial)
  4. Reduce ATMA_{TM} to PP: Transform M,w\langle M, w \rangle to M\langle M' \rangle where MM':
    • On input xx, run MM on ww; if MM accepts, run a TM that recognizes BB on xx
  5. If MM accepts ww: L(M)=BL(M') = B (has property PP)
  6. If MM doesn't accept ww: L(M)=L(M') = \emptyset (does NOT have property PP)
  7. Deciding PP would decide ATMA_{TM} → impossible

5. Common Pitfalls

Pitfall 1: Reversing the Reduction Direction

The mistake: Reducing BB to ATMA_{TM} to prove BB is undecidable. Why students make it: The logic "this problem is hard" suggests it must reduce to something. How to catch it: To prove BB undecidable, reduce a KNOWN undecidable problem (ATMA_{TM}) TO BB. If BB were decidable, ATMA_{TM} would be decidable. Correct approach: ATMmBA_{TM} \leq_m B to prove BB undecidable.

Pitfall 2: Assuming Rice's Theorem Applies to Syntactic Properties

The mistake: Using Rice's theorem to prove properties about the machine itself (number of states, running time) are undecidable. Why students make it: Rice's theorem sounds like "everything about TMs is undecidable." How to catch it: Rice's theorem applies only to SEMANTIC properties — properties of the language L(M)L(M), not of the machine MM itself. Correct approach: Does the property depend only on L(M)L(M)? If it depends on how MM works (state count, time complexity), Rice's theorem doesn't apply.

Pitfall 3: Forgetting to Show Both Directions

The mistake: Only showing one direction of the reduction. Why students make it: It's easier to reason about one direction. How to catch it: A reduction requires wA    f(w)Bw \in A \iff f(w) \in B. Both directions must hold for the reduction to be valid. Correct approach: Prove both directions: If wAw \in A then f(w)Bf(w) \in B, AND if f(w)Bf(w) \in B then wAw \in A.

6. Key Concepts Reference

ConceptDefinitionApplication
Mapping reductionff computable, wA    f(w)Bw \in A \iff f(w) \in BProving undecidability
** ATMA_{TM} **{M,wM\{ \langle M, w \rangle \mid M accepts w}w \}Prototypical undecidable problem
** HALTTMHALT_{TM} **{M,wM\{ \langle M, w \rangle \mid M halts on w}w \}Undecidable via ATMA_{TM} reduction
Rice's theoremNon-trivial semantic properties undecidableQuick undecidability proofs
** m\leq_m **Reduction directionAmBA \leq_m B means AA reduces to BB
TM-recognizableSome TM halts-accepts on strings in LLAlso called semi-decidable
Co-TM-recognizableComplement is TM-recognizableL\overline{L} is recognizable

7. 📝 Practice Questions

Q1: Prove that HALTTMHALT_{TM} is undecidable by reduction from ATMA_{TM}.
Answer:
Define reduction f(M,w)=M,wf(\langle M, w \rangle) = \langle M', w \rangle where:
  • MM' runs MM on ww
  • If MM accepts, MM' halts (accepts)
  • If MM rejects, MM' enters infinite loop
  • If MM loops (doesn't halt), MM' also loops
Then: M,wATM\langle M, w \rangle \in A_{TM} (M accepts w) ⇒ M halts on w ⇒ M' halts on w ⇒ M,wHALTTM\langle M', w \rangle \in HALT_{TM}. And M,wATM\langle M, w \rangle \notin A_{TM} (M doesn't accept w) ⇒ M either rejects or loops ⇒ M' loops ⇒ M,wHALTTM\langle M', w \rangle \notin HALT_{TM}.
Thus ATMmHALTTMA_{TM} \leq_m HALT_{TM}, so HALTTMHALT_{TM} is undecidable. Q2: Use Rice's theorem to prove that ETME_{TM} (empty language) is undecidable.
Answer:
ETM={ML(M)=}E_{TM} = \{\langle M \rangle \mid L(M) = \emptyset\}. This is a semantic property of TM languages:
  • It's non-trivial: some TMs accept \emptyset (e.g., TM that immediately rejects), some don't (e.g., TM that accepts everything).
  • It's semantic: it depends only on L(M)L(M), not on MM's implementation.
By Rice's theorem, any non-trivial semantic property is undecidable. Therefore ETME_{TM} is undecidable. Q3: Show that the complement of ATMA_{TM} (the set of M,w\langle M,w \rangle where MM does NOT accept ww) is not Turing-recognizable.
Answer:
If ATM\overline{A_{TM}} were Turing-recognizable, then both ATMA_{TM} and ATM\overline{A_{TM}} would be recognizable, making ATMA_{TM} decidable. But ATMA_{TM} is undecidable. Therefore ATM\overline{A_{TM}} is not Turing-recognizable.
More formally: A language is decidable iff both it and its complement are Turing-recognizable. Since ATMA_{TM} is not decidable (it's undecidable), and ATMA_{TM} IS Turing-recognizable (the universal TM recognizes it), its complement ATM\overline{A_{TM}} must NOT be Turing-recognizable. Q4: Construct a reduction from ATMA_{TM} to ETME_{TM}.
Answer:
f(M,w)=Mf(\langle M, w \rangle) = \langle M' \rangle where MM':
  • On input xx:
    1. If xwx \neq w, reject
    2. Run MM on ww; if MM accepts, accept
Then:
  • If MM accepts ww: L(M)={w}L(M') = \{w\} \neq \emptysetMETM\langle M' \rangle \notin E_{TM}
  • If MM doesn't accept ww: L(M)=L(M') = \emptysetMETM\langle M' \rangle \in E_{TM}
This shows ATMmETMA_{TM} \leq_m \overline{E_{TM}}. So ETME_{TM} is undecidable (if it were decidable, so would ETM\overline{E_{TM}} and thus ATMA_{TM}). Q5: Why doesn't Rice's theorem apply to the property "M has exactly 25 states"?
Answer: Because this is a syntactic property of the TM description, not a semantic property of the language L(M)L(M). It depends on how the machine is constructed, not on which strings it accepts. Rice's theorem only applies to semantic properties of the LANGUAGE. The number of states is a property of the machine representation M\langle M \rangle, not of L(M)L(M). Q6: Prove Rice's theorem: Any non-trivial property of TM languages is undecidable.
Answer: (Sketch)
  1. Let PP be non-trivial property of TM languages
  2. Assume \emptyset does NOT satisfy PP (if it does, work with P\overline{P})
  3. Let BB be a language that DOES satisfy PP (exists because P is non-trivial)
  4. Define reduction f(M,w)=Mf(\langle M, w \rangle) = \langle M' \rangle:
    • MM' on input xx: runs MM on ww; if MM accepts, runs a recognizer for BB on xx
  5. If MM accepts ww: L(M)=BL(M') = BM\langle M' \rangle has property PP
  6. If MM doesn't accept ww: L(M)=L(M') = \emptysetM\langle M' \rangle doesn't have property PP
  7. Thus ATMmPA_{TM} \leq_m P, so PP is undecidable. Q7: Show that ATMA_{TM} is Turing-recognizable but not co-Turing-recognizable.
Answer:
ATMA_{TM} is Turing-recognizable: The universal TM UU recognizes ATMA_{TM}. On input M,w\langle M, w \rangle, UU simulates MM on ww and accepts if MM accepts. If MM loops, UU loops. So UU recognizes ATMA_{TM}.
ATMA_{TM} is NOT co-Turing-recognizable: If ATM\overline{A_{TM}} were also recognizable, then ATMA_{TM} would be decidable (since both ATMA_{TM} and its complement are recognizable). But ATMA_{TM} is undecidable. Therefore ATM\overline{A_{TM}} is not recognizable. Q8: Define the language EQTM={M1,M2L(M1)=L(M2)}EQ_{TM} = \{\langle M_1, M_2 \rangle \mid L(M_1) = L(M_2)\}. Show it's undecidable.
Answer:
Reduce ETME_{TM} to EQTMEQ_{TM}. Let MrejectM_{reject} be a TM that rejects all inputs (L(MrejectM_{reject}) = ∅). Define f(M)=M,Mrejectf(\langle M \rangle) = \langle M, M_{reject} \rangle.
Then: METM    L(M)=    L(M)=L(Mreject)    M,MrejectEQTM\langle M \rangle \in E_{TM} \iff L(M) = \emptyset \iff L(M) = L(M_{reject}) \iff \langle M, M_{reject} \rangle \in EQ_{TM}.
Since ETME_{TM} is undecidable, EQTMEQ_{TM} is undecidable. (Also follows from Rice's theorem: "does M₁ equal M₂?" is a non-trivial semantic property.)

8. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.