Recall warm-up
- Is P(Σ*) countable?
Stuck? Peek at 5.1 Countable vs uncountable; diagonalization
- Countable = finite or bijection with ℕ (listable). Σ*, ℕ×ℕ, TMs, RE, CFG, regular languages: countable.
- P(ℕ), P(Σ*) (all languages), infinite binary sequences, ℝ: uncountable (diagonal).
- Countably many TMs ⇒ most languages are not RE.
- What does the universal TM do?
Stuck? Peek at 4.4 Encoding TMs, the universal TM, and the Church–Turing thesis
- ⟨M⟩: binary code of transitions (0ⁱ1 0ʲ1 0ᵏ1 0ˡ1 0ᵐ, separated by 11). TMs are countable.
- Universal TM U: simulates M on w; L(U) = {⟨M,w⟩ : M accepts w} is RE.
- Church–Turing thesis: algorithm ⇔ TM (thesis, not theorem).
- L is RE but not recursive. What is L̅?
Stuck? Peek at 4.3.3 Closure of REC and RE; L and L̅ both RE ⇒ L recursive
- REC closed: ∪ ∩ complement − concat * reversal h⁻¹; not h.
- RE closed: ∪ ∩ concat * reversal h h⁻¹; not complement, not difference.
- L, L̅ ∈ RE ⇒ L ∈ REC. L ∈ RE − REC ⇒ L̅ ∉ RE.
The Hook
Every programmer has wished for a tool that looks at code and says “this will hang”. Turing proved in 1936 that no such tool can work correctly on all programs. The proof is a diagonal argument that turns any claimed halting-checker against itself. This lesson builds the three named languages GATE asks about: L_d (not RE), A_TM and HALT_TM (RE but undecidable).
Predict First
Suppose a program H(P, x) always correctly says whether program P halts on input x. Write D(P): “if H says P halts on input P, loop forever; otherwise halt.” What happens when you run D on D?
Core Concept
Prediction check
If D(D) halts, then H said D does not halt on D — wrong. If D(D) loops, then H said D halts on D — wrong. Either way H is wrong on (D, D). So no correct H exists.
The diagonal language L_d
List all strings w₁, w₂, … and all TMs M₁, M₂, … (TM Mᵢ has code wᵢ).
L_d is not RE. If L_d = L(Mₖ) for some k, ask whether wₖ ∈ L_d: wₖ ∈ L_d ⇔ wₖ ∉ L(Mₖ) = L_d. Contradiction. Its complement, { wᵢ : Mᵢ accepts wᵢ }, is RE (simulate Mᵢ on wᵢ), so L_d is co-RE.
A_TM: acceptance is RE but not recursive
RE: the universal TM recognizes it. Not recursive: if a decider H for A_TM existed, build D(⟨M⟩) = accept iff H rejects ⟨M, ⟨M⟩⟩. Then D accepts ⟨D⟩ ⇔ H rejects ⟨D, ⟨D⟩⟩ ⇔ D does not accept ⟨D⟩. Contradiction. ∎
Consequence (4.3.3): the complement of A_TM is not RE.
| input to D | H says on ⟨M, ⟨M⟩⟩ | D does |
|---|---|---|
| ⟨M⟩ | accept | reject |
| ⟨M⟩ | reject | accept |
| ⟨D⟩ | accept ⇒ D rejects ⟨D⟩ | contradiction |
| ⟨D⟩ | reject ⇒ D accepts ⟨D⟩ | contradiction |
HALT_TM: the halting problem
RE (simulate and accept when it halts) but undecidable: a halting decider would decide A_TM (first check M halts on w, then simulate safely). Its complement is not RE.
Where they sit
Recursive = RE ∩ co-RE (both a language and its complement recognizable).
Putting it together
- Diagonalizing against TMs gives L_d, which no TM recognizes.
- A_TM and HALT_TM are recognizable but undecidable; their complements are not RE.
- Recursive = RE ∩ co-RE.
Visual
language RE? co-RE? recursive? L_d no yes no A_TM (L_u) yes no no complement of A_TM no yes no HALT_TM yes no no complement of HALT_TM no yes no
Worked Examples
Is A_TM recognizable?
Show the full solution
Yes — the universal TM accepts exactly when M accepts w.
Why is the complement of HALT_TM not RE?
Show the full solution
HALT_TM is RE. If its complement were RE too, HALT_TM would be recursive (4.3.3) — but it is undecidable.
Which are true? (i) L_d is RE. (ii) L̅_d is RE. (iii) A_TM is recursive. (iv) The complement of A_TM is co-RE.
Show the full solution
(i) false. (ii) true. (iii) false. (iv) true (its complement A_TM is RE). Answer: (ii) and (iv).
GATE Traps
- A_TM and HALT_TM are RE (recognizable) — undecidable, not unrecognizable.
- Their complements are not RE.
- L_d is not RE, but its complement is RE.
- Undecidable for TMs does not mean undecidable for DFAs/PDAs: “does this DFA accept w?” is decidable.
Memory Hook
The liar machine: “I accept exactly when the oracle says I reject.” No oracle survives the question about the liar itself.
Connect the Dots
Every new undecidability proof can now borrow these results: show that deciding your problem would decide A_TM. That move is called a reduction — next.
Self-Test
- MSQ
Which are RE?
- A_TM
- HALT_TM
- L_d
- complement of A_TM
- MCQ
Is HALT_TM decidable?
- yes
- no, but it is RE
- no, and it is not RE
- only for deterministic TMs
- MCQ
Recursive languages are exactly:
- RE
- co-RE
- RE ∩ co-RE
- RE ∪ co-RE
- MCQ
The complement of L_d is:
- not RE
- RE
- recursive
- regular
Rule Card
- L_d = {wᵢ : wᵢ ∉ L(Mᵢ)}: not RE (co-RE).
- A_TM = {⟨M,w⟩ : M accepts w}: RE, not recursive; complement not RE.
- HALT_TM: RE, undecidable; complement not RE.
- REC = RE ∩ co-RE.
Concept Ledger
- diagonal language L_d
- A_TM (universal language L_u)
- HALT_TM (halting problem)
- undecidable
- co-RE
- REC = RE ∩ co-RE
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- No.
- Simulates M on w given ⟨M, w⟩.
- Not RE.
Self-test answers
- AB — Recognized by simulation.
- C: Not RE.
- D: Not RE.
- B — Undecidable but recognizable.
- A: Turing’s theorem.
- C: It is RE.
- D: All TMs here are deterministic.
- C — Complement theorem.
- A: Too big.
- B: Too big.
- D: Too big.
- B — Simulate Mᵢ on wᵢ.
- A: It is RE.
- C: Then L_d would be recursive.
- D: No.
Flashcards
- Is A_TM RE? Recursive?
Reveal answer
RE yes, recursive no. - Is L_d RE?
Reveal answer
No (its complement is). - Is the complement of HALT_TM RE?
Reveal answer
No. - REC in terms of RE and co-RE?
Reveal answer
REC = RE ∩ co-RE.