Halting Problem
- H={H=\{H={“MMM”“www”: MMM is a TM that halts on w}w\}w}
- HHH is R.E.
- If HHH is recursive, then all R.E. languages are recursive
- HHH is not recursive
Lemma: HHH is recursively enumerable
- Universal TM: U=U=U= on input “MMM”“www”
- run MMM on “www”
- if MMM halts on “www”, halts on “MMM”“www”
- UUU halts on “MMM”“www” ⟺ \iff⟺ MMM halts on w ⟺ w \iffw⟺ “MMM”“www”∈H\in H∈H
- UUU semidecides HHH
Lemma: If HHH is recursive, so are all R.E. languages
- Also: HHH is complete for the class of R.E. languages
- Let AAA be a R.E. language and MMM be a TM that semidecides AAA
- Is w∈Aw\in Aw∈A? ⟺ \iff⟺ Does MMM halt on www? ⟺ \iff⟺ “MMM”“www”∈H\in H∈H
- If HHH is recursive, there exists a TM MHM_HMH that decides HHH
- MA=M_\mathrm{A}=MA= on input www
- run MHM_\mathrm{H}MH on “MMM”“www”
- if MHM_\mathrm{H}MH accepts “MMM”“www”, accept www
- else reject
Theorem: HHH is not recursive
- H={H=\{H={“MMM”“www”: MMM is a TM that halts on w}w\}w}
- H′={H'=\{H′={“MMM”: MMM is a TM that halts on “MMM”}\}}
- Hd={H_d=\{Hd={“MMM”: MMM is a TM that does not halt on “MMM”}\}}
- Claim: If HHH is recursive, then HdH_dHd is also recursive
- If HHH is recursive, there exists a TM MHM_HMH that decides HHH
- Md=M_\mathrm{d}=Md= on input “MMM”
- run MHM_\mathrm{H}MH on “MMM”““MMM””
- if MHM_\mathrm{H}MH accepts “MMM”““MMM””, reject “MMM”
- else accept
- Claim: HdH_dHd is not R.E.
- Suppose HdH_dHd is R.E., there exists a TM DDD semidecides HdH_dHd
- DDD on input “MMM”
- halts if “MMM”∈Hd\in H_d∈Hd, therefore MMM does not halt on “MMM”
- does not halt if “MMM”∉Hd\notin H_d∈/Hd, therefore MMM halts on “MMM”
- Barber Dilemma: DDD on input “DDD”
- halts if DDD does not halt on “DDD”
- does not halt if DDD halts on “DDD”
Lemma: LLL is recursive iff LLL and L‾\overline{L}L is both R.E.
- sufficiency: recursive under complement
- LLL and L‾\overline{L}L are both recursive, therefore also R.E.
- necessity: MLM_LML and ML‾M_{\overline{L}}ML semidecides LLL and L‾\overline{L}L, respectively
- M∗=M^*=M∗= on input www
- run MLM_\mathrm{L}ML and ML‾M_\mathrm{\overline{L}}ML on www in parallel
- if MLM_\mathrm{L}ML halts, accept www
- else if ML‾M_\mathrm{\overline{L}}ML halts, reject www
- M∗=M^*=M∗= on input www
Theorem: The class of R.E. languages is not closed under complement
- HHH and H‾\overline{H}H are both R.E., then HHH is recursive
Definition
- Let AAA and BBB be two languages over ΣA\Sigma_AΣA and ΣB\Sigma_BΣB, respectively
- AAA reduction from AAA to BBB is a computable function f:ΣA∗→ΣB∗f:\Sigma_A^*\to\Sigma_B^*f:ΣA∗→ΣB∗
Theorem
- Suppose that there is a reduction fff from AAA to BBB, if BBB is recursive, so is AAA
- MA=M_\mathrm{A}=MA= on input www
- compute f(w)f(w)f(w)
- run MBM_\mathrm{B}MB on f(w)f(w)f(w)
- if MBM_\mathrm{B}MB accepts f(w)f(w)f(w), accept www
- else reject
- A⪯BA\preceq BA⪯B
Theorem: The following problems are undecidable
- A={A=\{A={“MMM”: MMM is a TM that halts on e}e\}e}
- Given a TM MMM and a string www
- Mw=M_w=Mw= on input www
- run MMM on uuu
- if MMM halts on uuu, halts
- MwM_wMw halts on eee (“MwM_wMw”∈A\in A∈A) ⟺ \iff⟺ MwM_wMw halts on every input ⟺ Mw\iff M_w⟺Mw halts on www (“MMM”“www”∈H\in H∈H)
- Notice: “MwM_wMw” is used as input of AAA
- H⪯AH\preceq AH⪯A
- B={B=\{B={“MMM”: MMM is a TM that halts on some strings}\}}
- f(f(f(“MMM”“www”)=)=)=“MwM_wMw”
- H⪯BH\preceq BH⪯B
- C={C=\{C={“MMM”: MMM is a TM that halts on every string}\}}
- f(f(f(“MMM”“www”)=)=)=“MwM_wMw”
- H⪯CH\preceq CH⪯C
- D={D=\{D={"M1M_1M1"“M2M_2M2”: M1M_1M1 and M2M_2M2 are two TMs that halts on the same string}\}}
- Let M∗M^*M∗ be a TM with S∈H ⟺ M∗S\in H\iff M^*S∈H⟺M∗ halts on every input
- f(f(f(“MMM”)=)=)=“MMM”“M∗M^*M∗”
- C⪯DC\preceq DC⪯D
- E1={E_1=\{E1={“MMM”: MMM is a TM that L(M)L(M)L(M) is regular}\}}
- E2={E_2=\{E2={“MMM”: MMM is a TM that L(M)L(M)L(M) is context-free}\}}
- E3={E_3=\{E3={“MMM”: MMM is a TM that L(M)L(M)L(M) is recursive}\}}
- Given a TM MMM and a string www
- f(f(f(“MMM”“www”)=)=)=“MwM_wMw”
- Mw=M_w=Mw= on input vvv
- run MMM on www
- run UUU on “MMM”“vvv”
- if “MMM”“www”∉H\notin H∈/H, does not halt in step 1, L(Mw)=∅L(M_w)=\varnothingL(Mw)=∅
- if “MMM”“www”∈H\in H∈H, L(Mw)=L(U)=HL(M_w)=L(U)=HL(Mw)=L(U)=H
- L(Mw)L(M_w)L(Mw) is regular/context-free/recursive iff “MMM”“www”∉H\notin H∈/H
- H⪯E1‾,E2‾,E3‾H\preceq \overline{E_1},\overline{E_2},\overline{E_3}H⪯E1,E2,E3
- There is a certain fixed TM MMM, for which the following problem is undecidable:
- Given a string www, does MMM halt on www?
- Language: L(M)L(M)L(M)
- Run UUU on “MMM”“www”
Rice’s Theorem
- Suppose L\mathcal{L}L is a proper, non-empty subset of all R.E. languages, the following is undecidable: given a TM MMM, is L(M)∈LL(M)\in\mathcal{L}L(M)∈L?
- S={S=\{S={“MMM”: MMM is a TM that L(M)∈L}L(M)\in\mathcal{L}\}L(M)∈L}
- Proof:
- Assume ∅∉L\varnothing\notin\mathcal{L}∅∈/L, otherwise let L\mathcal{L}L be its complement
- Let a language A∈LA\in\mathcal{L}A∈L and a TM MAM_\mathrm{A}MA that semidecides AAA
- f(f(f(“MMM”“www”)=)=)= on input uuu
- run MMM on www
- run MAM_\mathrm{A}MA on uuu
- if “MMM”“www”∉H\notin H∈/H, L(f(L(f(L(f(“MMM”“www”))=∅))=\varnothing))=∅
- if “MMM”“www”∈H\in H∈H, L(f(L(f(L(f(“MMM”“www”))=L(MA)=A∈L))=L(M_A)=A\in\mathcal{L}))=L(MA)=A∈L
- H⪯SH\preceq SH⪯S
- Given a TM MMM, does MMM halt on eee?
- L={L\mathcal{L}=\{LL={L: LLL is R.E. and e∈L}e\in L\}e∈L}
- Given a TM MMM, does MMM halt on some input?
- L={L\mathcal{L}=\{LL={L: LLL is R.E. and L≠∅}L\ne\varnothing\}L=∅}
- Given a TM MMM, does MMM halt on every input?
- L={Σ∗}\mathcal{L}=\{\Sigma^*\}L={Σ∗}
- Given a TM MMM, is L(M)L(M)L(M) regular/context-free/recursive?
- L={L\mathcal{L}=\{LL={L: LLL is regular/context-free/recursive}\}}
Theorem: A language LLL is R.E. iff it is Turing enumerable
- Assume LLL is infinite
- sufficiency:
- Let MMM be a TM that enumerates LLL
- Construct a TM M′M'M′ to semidecide LLL
- M′=M'=M′= on input www
- run MMM to enumerate LLL
- every time MMM outputs a string, compare it with www, and halt if they match
- necessity:
- Let MMM be a TM that semidecides LLL
- Construct a TM M′M'M′ to enumerate LLL
- Name all strings over Σ\SigmaΣ as s1,s2,…s_1,s_2,\dotss1,s2,… in lexicographical order
- M′=M'=M′= on input www
- for i=1,2,…i=1,2,\dotsi=1,2,…
- run MMM on s1,s2,…,sis_1,s_2,\dots,s_is1,s2,…,si at most iii steps
- if MMM hatls on sjs_jsj in iii steps, output sjs_jsj
Definition
- Let MMM be a TM enumerates LLL, we say MMM lexicographically enumerate LLL if whenever (q,⊳⊔‾w)⊢M+(q,⊳⊔‾w′)(q,\rhd\underline{\sqcup}w)\vdash^+_M(q,\rhd\underline{\sqcup}w')(q,⊳⊔w)⊢M+(q,⊳⊔w′)
- w′w'w′ is after www in lexico order
Theorem: A language is recursive iff it is lexico Turing enumerable
- sufficiency:
- Let MMM be a TM that decides LLL
- Construct a TM M′M'M′ to lexico enumerate LLL
- M′=M'=M′= on input www
- generate all strings voer Σ\SigmaΣ in lexico order
- run MMM on each string www to see if w∈Lw\in Lw∈L
- if MMM accepts www, accept
- else reject
- necessity:
- Let MMM be a TM that lexico enumerates LLL
- Construct a TM M′M'M′ to decide LLL
- M′=M'=M′= on input www
- run MMM to enumerate LLL until MMM outputs a string is after www in lexico order
- if www is among strings that output, accept www
- else reject