计算理论笔记(三)TM Decidablity

本文详细介绍了图灵机模型的构造和工作原理,包括一维无限带、状态转换、停机状态等概念。通过不同类型的图灵机(如符号写入、左移头、右移头机器)和组合机器展示了其灵活性。同时,讨论了如何使用图灵机来决定和半决定语言,以及如何计算和枚举语言。此外,文章探讨了递归理论,包括递归语言、递归枚举和不可计算性。最后,通过实例解释了如何判断一个图灵机是否接受特定输入,以及如何构造决定性和非决定性问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Turing Machine
  • one-way infinite
  • its head can move left and right
  • can read and write
Turing Machine is a 5-tuple P=(K,Σ,δ,s,H)P=(K,\Sigma,\delta,s,H)P=(K,Σ,δ,s,H)
  • KKK is a finite set of states
  • Σ\SigmaΣ is a alphabet containing left end symbol ⊳\rhd and blank symbol ⊔\sqcup
  • s∈Ks\in KsK is the initial state
  • H⊆KH\subseteq KHK is the set of halting states
  • transition function δ:((K−H)×Σ→K×(Σ∪{←,→})\delta:((K-H)\times\Sigma\to K\times(\Sigma\cup\{\leftarrow,\rightarrow\})δ:((KH)×ΣK×(Σ{,})
    • ∀q∈K−H\forall q\in K-HqKH, if δ(q,⊳)=(p,b)\delta(q,\rhd)=(p,b)δ(q,)=(p,b), then b=→b=\rightarrowb=
    • ∀q∈K−H,∀a∈Σ\forall q\in K-H,\forall a\in\SigmaqKH,aΣ, if δ(q,a)=(p,b)\delta(q,a)=(p,b)δ(q,a)=(p,b), then b≠⊳b\neq\rhdb=
A configuration is a member of K×⊳(Σ−{⊳})∗×((Σ−{⊳})∗(Σ−{⊳,⊔})∪{e})K\times\rhd(\Sigma-\{\rhd\})^*\times((\Sigma-\{\rhd\})^*(\Sigma-\{\rhd,\sqcup\})\cup\{e\})K×(Σ{})×((Σ{})(Σ{,}){e})
  • (q,⊳b⊔a,a⊔⊔b)≡(q,⊳b⊔a‾a⊔⊔b)(q,\rhd b\sqcup a,a\sqcup\sqcup b)\equiv(q,\rhd b\sqcup\underline{a}a\sqcup\sqcup b)(q,ba,ab)(q,baab)
  • halting configuration if q∈Hq\in HqH
Yields in one step: (q1,⊳w1a1u1)⊢M(q2,⊳w2a2u2)(q_1,\rhd w_1a_1u_1)\vdash_M(q_2,\rhd w_2a_2u_2)(q1,w1a1u1)M(q2,w2a2u2) if
  • (writing) w1=w2,u1=u2,a2∈Σ−{⊳}w_1=w_2,u_1=u_2,a_2\in\Sigma-\{\rhd\}w1=w2,u1=u2,a2Σ{} and δ(q1,a1)=(q2,a2)\delta(q_1,a_1)=(q_2,a_2)δ(q1,a1)=(q2,a2)
  • (moving left) δ(q1,a1)=(q2,←),w1=w2a2\delta(q_1,a_1)=(q_2,\leftarrow),w_1=w_2a_2δ(q1,a1)=(q2,),w1=w2a2 and either
    • u2=eu_2=eu2=e if u1=eu_1=eu1=e and a1=⊔a_1=\sqcupa1=
    • u2=a1u1u_2=a_1u_1u2=a1u1, otherwise
  • (moving right) δ(q1,a1)=(q2,→),w2=w1a1\delta(q_1,a_1)=(q_2,\rightarrow),w_2=w_1a_1δ(q1,a1)=(q2,),w2=w1a1 and
    • u1=eu_1=eu1=e if u2=eu_2=eu2=e and a2=⊔a_2=\sqcupa2=
    • u1=a2u2u_1=a_2u_2u1=a2u2, otherwise
We say two configurations C⊢M∗C′C\vdash^*_MC'CMC iff
  • C=C′C=C'C=C or
  • ∃C0,C1,…,Ck(k≥1)\exists C_0,C_1,\dots,C_k(k\ge1)C0,C1,,Ck(k1) s.t. C=C0⊢MC1⊢M⋯⊢MCk=C′C=C_0\vdash_MC_1\vdash_M\dots\vdash_MC_k=C'C=C0MC1MMCk=C
MMM halts whenever it reaches a halting configuration
Exercise
  • for any a∈Σ−{⊳}a\in\Sigma-\{\rhd\}aΣ{}, symbol-writing machine Ma=({s,h},Σ,δ,s,{h})M_a=(\{s,h\},\Sigma,\delta,s,\{h\})Ma=({s,h},Σ,δ,s,{h})
    • δ(s,⊳)=(s,→)\delta(s,\rhd)=(s,\rightarrow)δ(s,)=(s,)
    • δ(s,b)=(h,a)\delta(s,b)=(h,a)δ(s,b)=(h,a) for each b∈Σ−{⊳}b\in\Sigma-\{\rhd\}bΣ{}
  • left-head-moving machine M←M_\leftarrowM
    • δ(s,⊳)=(s,→)\delta(s,\rhd)=(s,\rightarrow)δ(s,)=(s,)
    • δ(s,b)=(h,←)\delta(s,b)=(h,\leftarrow)δ(s,b)=(h,) for each b∈Σ−{⊳}b\in\Sigma-\{\rhd\}bΣ{}
  • right-head-moving machine M→M_\rightarrowM
    • δ(s,⊳)=(h,→)\delta(s,\rhd)=(h,\rightarrow)δ(s,)=(h,)
    • δ(s,b)=(h,→)\delta(s,b)=(h,\rightarrow)δ(s,b)=(h,) for each b∈Σ−{⊳}b\in\Sigma-\{\rhd\}bΣ{}
Combining of basic machines
  • Mi=(Ki,Σ,δi,si,Hi),∀i=1,2,3M_i=(K_i,\Sigma,\delta_i,s_i,H_i),\forall i=1,2,3Mi=(Ki,Σ,δi,si,Hi),i=1,2,3
  • Construct M=(K,Σ,δ,s,H)M=(K,\Sigma,\delta,s,H)M=(K,Σ,δ,s,H)
    • K=K1∪K2∪K3∪{h}K=K_1\cup K_2\cup K_3\cup\{h\}K=K1K2K3{h}
    • s=s1s=s_1s=s1
    • H=H2∪H3∪{h}H=H_2\cup H_3\cup\{h\}H=H2H3{h}
    • ∀q∈K−H,∀a∈Σ\forall q\in K-H,\forall a\in\SigmaqKH,aΣ
      • If q∈K1−H1q\in K_1-H_1qK1H1
        • δ(q,a)=δ1(q,a)\delta(q,a)=\delta_1(q,a)δ(q,a)=δ1(q,a)
      • If q∈H1q\in H_1qH1
        • δ(q,0)=(s2,0)\delta(q,0)=(s_2,0)δ(q,0)=(s2,0)
        • δ(q,1)=(s3,1)\delta(q,1)=(s_3,1)δ(q,1)=(s3,1)
        • δ(q,a)=(h,→),∀a∈Σ−{0,1}\delta(q,a)=(h,\rightarrow),\forall a\in\Sigma-\{0,1\}δ(q,a)=(h,),aΣ{0,1}
      • If q∈K2−H2q\in K_2-H_2qK2H2
        • δ(q,a)=δ2(q,a)\delta(q,a)=\delta_2(q,a)δ(q,a)=δ2(q,a)
      • If q∈K3−H3q\in K_3-H_3qK3H3
        • δ(q,a)=δ3(q,a)\delta(q,a)=\delta_3(q,a)δ(q,a)=δ3(q,a)
left-shifting machine S←S_\leftarrowS
  • ∀w∈(Σ−{⊳,⊔})∗:⊳⊔⊔w⊔‾→⊳⊔w⊔‾\forall w\in(\Sigma-\{\rhd,\sqcup\})^*: \rhd\sqcup\sqcup w\underline{\sqcup}\to\rhd\sqcup w\underline{\sqcup}w(Σ{,}):ww
    left-shifting machine
copy machine
  • ∀w∈(Σ−{⊳,⊔})∗:⊳⊔‾w⊔→⊳⊔‾w⊔w⊔\forall w\in(\Sigma-\{\rhd,\sqcup\})^*: \rhd\underline{\sqcup}w\sqcup\to\rhd\underline{\sqcup}w\sqcup w\sqcupw(Σ{,}):www
    在这里插入图片描述
Recognize language
  • input alphabet: Σ0=Σ−{⊳,⊔}\Sigma_0=\Sigma-\{\rhd,\sqcup\}Σ0=Σ{,}
  • M=(K,Σ0,Σ,δ,S,H)M=(K,\Sigma_0,\Sigma,\delta,S,H)M=(K,Σ0,Σ,δ,S,H)
  • initial configuration: given w∈Σ∗w\in\Sigma^*wΣ, MMM starts with (s,⊳⊔‾w)(s,\rhd\underline{\sqcup}w)(s,w)
  • L(M)={w∈Σ0∗L(M)=\{w\in\Sigma_0^*L(M)={wΣ0: MMM halts on w}w\}w}, MMM semidecides L(M)L(M)L(M)
  • Example: Fix some input alphabet Σ0∗\Sigma_0^*Σ0
    • Let a∈Σ0a\in\Sigma_0aΣ0, RaR_aRa semidecides L={w∈Σ0∗L=\{w\in\Sigma_0^*L={wΣ0: www contains a}a\}a}
Let M=(K,Σ,δ,S,{y,n})M=(K,\Sigma,\delta,S,\{y,n\})M=(K,Σ,δ,S,{y,n}) be a TM with input alphabet Σ0\Sigma_0Σ0, we say MMM decides a language L⊆Σ0∗L\subseteq \Sigma_0^*LΣ0 if
  • For every w∈Lw\in LwL, (s,⊳⊔‾w)⊢M∗(y,⊳ua‾v)(s,\rhd\underline{\sqcup}w)\vdash^*_M(y,\rhd u\underline{a}v)(s,w)M(y,uav) for some u,v∈Σ∗u,v\in\Sigma^*u,vΣ and a∈Σa\in\SigmaaΣ
    • MMM accepts www
  • For every w∈Lw\in LwL, (s,⊳⊔‾w)⊢M∗(n,⊳ua‾v)(s,\rhd\underline{\sqcup}w)\vdash^*_M(n,\rhd u\underline{a}v)(s,w)M(n,uav) for some u,v∈Σ∗u,v\in\Sigma^*u,vΣ and a∈Σa\in\SigmaaΣ
    • MMM rejects www
  • A language is recursive/decidable if it is decided by a TM
Example: The following TM decides {anbncn:n≥0}\{a^nb^nc^n:n\ge0\}{anbncn:n0}

在这里插入图片描述

Theorem: If LLL is recursive, it must be recursively enumerable
  • LLL is recursive ⇒∃M=(K,Σ,δ,S,{y,n})\Rightarrow \exists M=(K,\Sigma,\delta,S,\{y,n\})M=(K,Σ,δ,S,{y,n}) decides LLL
    • δ(n,a)=(n,a)\delta(n,a)=(n,a)δ(n,a)=(n,a) for any a∈Σ−{⊳}a\in\Sigma-\{\rhd\}aΣ{}
    • δ(n,⊳)=(n,→)\delta(n,\rhd)=(n,\rightarrow)δ(n,)=(n,)
Theorem: If LLL is recursive, so is L‾\overline{L}L
  • Exchange the role of yyy and nnn
  • False generalization: If LLL is recursive enumerable, so is L‾\overline{L}L
Compute function
  • Let M=(K,Σ,δ,S,H)M=(K,\Sigma,\delta,S,H)M=(K,Σ,δ,S,H) be a TM with input alphabet Σ0\Sigma_0Σ0, let w∈Σ0∗w\in\Sigma_0^*wΣ0, if (s,⊳⊔‾w)⊢M∗(h,⊳⊔‾y)(s,\rhd\underline{\sqcup}w)\vdash^*_M(h,\rhd\underline{\sqcup}y)(s,w)M(h,y) for some h∈Hh\in HhH and y∈Σ0∗y\in\Sigma_0^*yΣ0
    • yyy: output of MMM on www
  • Let f:Σ0∗→Σ0∗f:\Sigma_0^*\to\Sigma_0^*f:Σ0Σ0, we say MMM computes fff if for any w∈Σ0∗w\in\Sigma_0^*wΣ0 M(w)=f(w)M(w)=f(w)M(w)=f(w), i.e. MMM halts with ⊳⊔‾f(w)\rhd \underline{\sqcup}f(w)f(w)
Example: f(w)=wwf(w)=wwf(w)=ww is computed by the following TM

在这里插入图片描述

Enumrator
  • We say a TM MMM enumerates a language LLL if for some state qqq, L={w:(s,⊳⊔‾)⊢M∗(q,⊳⊔‾w)}L=\{w:(s,\rhd\underline{\sqcup})\vdash^*_M(q,\rhd\underline{\sqcup}w)\}L={w:(s,)M(q,w)}
    • qqq is called output state
  • A language is Turing enumerable if some TM enumerates it
Extensions of TM
  • K-tape TM
    • δ:(K−H)×Σk→K×(Σ∪{←,→})k\delta:(K-H)\times\Sigma^k\to K\times(\Sigma\cup\{\leftarrow,\rightarrow\})^kδ:(KH)×ΣkK×(Σ{,})k
    • Theorem: Any k-tape TM can be simulated by a standard TM
    • K-track(conceptually), Σ′=(Σ∪{a‾:a∈Σ})k\Sigma'=(\Sigma\cup\{\underline{a}:a\in\Sigma\})^kΣ=(Σ{a:aΣ})k
  • Two-way Infinite Tape
    • Simulated by 2-tape TM, split indices to N+\mathbb{N^+}N+ and Z−N+\mathbb{Z-N^+}ZN+
  • K-head TM
  • Two-dimensional Tape
    • countable, because ∣N+×N+∣=∣N+∣|\mathbb{N^+\times N^+}|=|\mathbb{N^+}|N+×N+=N+
  • Random Access
  • Non-determinism
A non-deterministic TM(NTM) is 5-tuple M=(K,Σ,Δ,S,H)M=(K,\Sigma,\Delta,S,H)M=(K,Σ,Δ,S,H)
  • Δ⊆((K−H)×Σ)×(K×(Σ∪{←,→}))\Delta\subseteq((K-H)\times\Sigma)\times(K\times(\Sigma\cup\{\leftarrow,\rightarrow\}))Δ((KH)×Σ)×(K×(Σ{,}))
A NTM NNN with input alphabet Σ0\Sigma_0Σ0 semidecides a language L⊆Σ0∗L\subseteq\Sigma_0^*LΣ0 if for any w∈Σ0∗w\in\Sigma_0^*wΣ0, the following is true:
  • w∈Lw\in LwL iff (s,⊳⊔‾w)⊢M∗(h,⊳u⊔‾v)(s,\rhd\underline{\sqcup}w)\vdash^*_M(h,\rhd u\underline{\sqcup}v)(s,w)M(h,uv) for some hhh
Let M=(K,Σ,Δ,S,{y,n})M=(K,\Sigma,\Delta,S,\{y,n\})M=(K,Σ,Δ,S,{y,n}) be a NTM with input alphabet Σ0\Sigma_0Σ0, we say MMM decides a language L⊆Σ0∗L\subseteq \Sigma_0^*LΣ0 if
  • There is a natural number NNN, depending on MMM and www, such that there is no configuration CCC satisfying (s,⊳⊔‾w)⊢MNC(s,\rhd\underline{\sqcup}w)\vdash^N_MC(s,w)MNC
  • w∈Lw\in LwL iff (s,⊳⊔‾w)⊢M∗(y,⊳u⊔‾v)(s,\rhd\underline{\sqcup}w)\vdash^*_M(y,\rhd u\underline{\sqcup}v)(s,w)M(y,uv)
Example: Let CCC be the set of binary strings representing composite number, design a NTM decides CCC
  • ⊳⊔w⊔p⊔q\rhd\sqcup w\sqcup p\sqcup qwpq: non-deterministicly generates a binary string ppp with 2≤p‾≤w‾2\le\overline{p}\le\overline{w}2pw and then non-deterministicly generates a binary string qqq with 2≤q‾≤w‾2\le\overline{q}\le\overline{w}2qw
  • Multiply p‾\overline{p}p with q‾\overline{q}q, compare the product with w‾\overline{w}w
  • Halt with yyy if match, nnn if not
Theorem: A NTM NNN can be simulated by a DTM MMM
  • Choices for every step of NTM is finite (fanout): ∣K×(Σ∪{←,→}∣=∣K∣×(∣Σ∣+2)=Δr|K\times(\Sigma\cup\{\leftarrow,\rightarrow\}|=|K|\times(|\Sigma|+2)\xlongequal{\Delta}rK×(Σ{,}=K×(Σ+2)Δr
  • Construct 3-tap DTM to simulate NTM, by BFS
    • 1st-tape: input
    • 2nd-tape: simulate a branch of NTM on www
    • 3rd-tape: enumerate strings over {1,2,…,r}\{1,2,\dots,r\}{1,2,,r}, addressing one node to access
Church-Turing Thesis
  • Intuitive notation of algorithms equals to Turing Machine that halt on every input
Description of TM
  • Formal description: 5-tuple
  • Implement-level description: diagram
  • High-level description: pseudo code
Fact: Every object OOO can be encoded into a string “OOO
Example: Every TM can be encoded into a string
  • Encoding states
    • i=min⁡j{j:2j≥∣K∣}i=\displaystyle\min_j\{j:2^j\ge|K|\}i=jmin{j:2jK}
    • q{0,1}iq\{0,1\}^iq{0,1}i
    • s:q0is:q0^is:q0i
  • Encoding alphabet
    • t=min⁡j{j:2j≥∣Σ∣+2}t=\displaystyle\min_j\{j:2^j\ge|\Sigma|+2\}t=jmin{j:2jΣ+2}
    • a{0,1}ta\{0,1\}^ta{0,1}t
    • ⊔:a0t\sqcup:a0^t:a0t
    • ⊳:a0t−11\rhd:a0^{t-1}1:a0t11
    • ←:a0t−210\leftarrow:a0^{t-2}10:a0t210
    • →:a0t−211\rightarrow:a0^{t-2}11:a0t211
  • Encoding transition
    • δ:(K−H)×Σ→K×(Σ∪{←,→})\delta: (K-H)\times\Sigma\to K\times(\Sigma\cup\{\leftarrow,\rightarrow\})δ:(KH)×ΣK×(Σ{,})
    • in 4-tuple like (q00,a100,q01,a00)(q00,a100,q01,a00)(q00,a100,q01,a00)
Fact: Given a valid encoding object, a TM is always able to decode it
Example
  • Problem: Given a graph GGG, is GGG connected?
  • Language: L={L=\{L={GGG”: GGG is a connected graph}\}}
  • M=M=M= on input “GGG
    1. select a node of GGG and mark it
    2. repeat the following until no new nodes are marked: for each marked node, mark all its neighbors
    3. if all nodes of GGG are marked, accept “GGG
    4. else reject
Decidable problem/recursive language
  • About DFA/NFA/regular languages
R1 Problem
  • Given a DFA BBB and a string www, does BBB accept www?
  • Language: ADFA={A_\mathrm{DFA}=\{ADFA={BBB”“www”: BBB is a DFA that accepts w}w\}w}
  • MR1=M_\mathrm{R1}=MR1= on input “BBB”“www
    1. simulate BBB on www
    2. if BBB accepts www, accept “BBB”“www
    3. else reject
R1* Problem, for a fixed DFA BBB
  • Given a string www, does BBB accept www?
  • Language: L(B)L(B)L(B)
  • MR1∗=M_\mathrm{R1^*}=MR1= on input www
    1. run MR1M_\mathrm{R1}MR1 on “BBB”“www
    2. if MR1M_\mathrm{R1}MR1 accepts “BBB”“www”, accept www
    3. else reject
R2 Problem
  • Given a NFA BBB and a string www, does BBB accept www?
  • Language: ANFA={A_\mathrm{NFA}=\{ANFA={BBB”“www”: BBB is a NFA that accepts w}w\}w}
  • MR2=M_\mathrm{R2}=MR2= on input “BBB”“www
    1. convert BBB into an equivalent DFA DDD
    2. run MR1M_\mathrm{R1}MR1 on “DDD”“www
    3. if MR1M_\mathrm{R1}MR1 accepts “DDD”“www”, accept “BBB”“www
    4. else reject
R3 Problem
  • Language: AREX={A_\mathrm{REX}=\{AREX={RRR”“www”: RRR is a regex and w∈L(R)}w\in L(R)\}wL(R)}
  • MR3=M_\mathrm{R3}=MR3= on input “RRR”“www
    1. convert RRR into an equivalent NFA BBB
    2. run MR2M_\mathrm{R2}MR2 on “BBB”“www
    3. if MR2M_\mathrm{R2}MR2 accepts “BBB”“www”, accept “RRR”“www
    4. else reject
R4 Problem
  • Given a DFA BBB and a string www, is L(B)=∅L(B)=\varnothingL(B)=?
  • Language: EDFA={E_\mathrm{DFA}=\{EDFA={BBB”: BBB is a DFA and L(B)=∅}L(B)=\varnothing\}L(B)=}
  • MR4=M_\mathrm{R4}=MR4= on input “BBB
    1. mark the initial state of BBB
    2. repeat the following until no new states are marked: for each marked state, mark all its successors by transition function
    3. if no final states are marked, accept “BBB
    4. else reject
Symmetric difference
  • L(A)⊕L(B)={w:w∈L(A)∪L(B)∧w∉L(A)∩L(B)}L(A)\oplus L(B)=\{w:w\in L(A)\cup L(B)\land w\notin L(A)\cap L(B)\}L(A)L(B)={w:wL(A)L(B)w/L(A)L(B)}
  • L(A)⊕L(B)=(L(A)∩L(B)‾)∪(L(A)‾∩L(B))L(A)\oplus L(B)=\left(L(A)\cap\overline{L(B)}\right)\cup\left(\overline{L(A)}\cap L(B)\right)L(A)L(B)=(L(A)L(B))(L(A)L(B))
  • L(A)=L(B)  ⟺  L(A)⊕L(B)=∅L(A)=L(B)\iff L(A)\oplus L(B)=\varnothingL(A)=L(B)L(A)L(B)=
R5 Problem
  • Language: EQDFA={EQ_\mathrm{DFA}=\{EQDFA={AAA”“BBB”: AAA and BBB are two DFAs and L(A)=L(B)}L(A)=L(B)\}L(A)=L(B)}
  • MR5=M_\mathrm{R5}=MR5= on input “AAA”“BBB
    1. construct a DFA CCC s.t. L(C)=L(A)⊕L(B)L(C)=L(A)\oplus L(B)L(C)=L(A)L(B)
    2. run MR4M_\mathrm{R4}MR4 on “CCC
    3. if MR4M_\mathrm{R4}MR4 accepts “CCC”, accept “AAA”“BBB
    4. else reject
CNF
  • A CFG G=(V,Σ,S,R)G=(V,\Sigma,S,R)G=(V,Σ,S,R) is in Chomsky Normal Form(CNF) if every of its rules is in the following forms:
    • A→BCA\to BCABC, for A,B,C∈(V−Σ)A,B,C\in(V-\Sigma)A,B,C(VΣ)
    • A→aA\to aAa, for A∈(V−Σ)A\in(V-\Sigma)A(VΣ) and a∈Σa\in\SigmaaΣ
    • S→eS\to eSe
    • SSS does no appear in the RHS of a rule
Theroem: Every CFG has an equivalent CFG in CNF
  • Given a CFG G=(V,Σ,S,R)G=(V,\Sigma,S,R)G=(V,Σ,S,R), convert it into CNF
  • add a new start symbol S0S_0S0 and a new rule S0→SS_0\to SS0S
  • fix eee-rules: A→eA\to eAe with A≠S0A\ne S_0A=S0
  • fix short rules: A→BA\to BAB with A,B∈(V−Σ)A,B\in(V-\Sigma)A,B(VΣ)
  • fix long rules: A→uA\to uAu with u∈V∗u\in V^*uV and ∣u∣>2|u|>2u>2
  • fix A→u1u2A\to u_1u_2Au1u2 with u1u_1u1 or u2u_2u2 as terminal
Observation: If CFG in CNF generates a string length n(n≥1)n(n\ge1)n(n1), it must take exactly 2n−12n-12n1 steps
  • A→BCA\to BCABC takes n−1n-1n1 steps
  • A→aA\to aAa takes nnn steps
C1 Problem
  • Language: ACFG={A_\mathrm{CFG}=\{ACFG={GGG”“www”: GGG is a CFG that generates w}w\}w}
  • MC1=M_\mathrm{C1}=MC1= on input “GGG”“www
    1. convert GGG into an equivalent CFG G′G'G in CNF
    2. if ∣w∣=0|w|=0w=0
    • if G′G'G has rule S→eS\to eSe, accept “GGG”“www
    • else reject
    1. if ∣w∣≥1|w|\ge1w1, list all the derivations(finite, ≤∣R∣2∣w∣−1\le|R|^{2|w|-1}R2w1) of length 2∣w∣−12|w|-12w1
    • if any listed derivation generates www, accept “GGG”“www
    • else reject
C2 Problem
  • Language: APDA={A_\mathrm{PDA}=\{APDA={PPP”“www”: PPP is a PDA that accepts w}w\}w}
  • MC2=M_\mathrm{C2}=MC2= on input “PPP”“www
    1. convert PPP into an equivalent CFG GGG
    2. run MC1M_\mathrm{C1}MC1 on “GGG”“www
    3. if MC1M_\mathrm{C1}MC1 accepts “GGG”“www”, accept “PPP”“www
    4. else reject
C3 Problem
  • Language: ECFG={E_\mathrm{CFG}=\{ECFG={GGG”: GGG is a CFG and L(G)=∅}L(G)=\varnothing\}L(G)=}
  • MC3=M_\mathrm{C3}=MC3= on input “GGG
    1. mark all the terminals and eee
    2. repeat the following until no new symbols are marked: for each LHS symbol of a rule, mark it if all the RHS symbols are marked
    3. if SSS is not marked, accept “GGG
    4. else reject
Let f:A→Bf:A\to Bf:AB be a function
  • fff is injective if f(a)≠f(a′)f(a)\ne f(a')f(a)=f(a) for any a≠a′a\ne a'a=a
  • fff is surjective if for any b∈Bb\in BbB, there exists a∈Aa\in AaA satisfying f(a)=bf(a)=bf(a)=b
  • fff is bijective if fff is injective and surjective
Equinumerous
  • Two sets AAA and BBB are equinumerous if there exists a bijection f:A→Bf:A\to Bf:AB
  • A set is countable if it is finite or it is equinumerous with ℵ\aleph, and uncountable otherwise
  • Collary: any subset of a countable set is countable
Theorem: Let AAA be a set, the following statements are equivalent:
  • a) AAA is countable
  • b) there exists an injection f:A→ℵf:A\to\alephf:A
  • c) there exists some way to enumerate the elements of AAA such that each element is listed within finite steps
  • Proof:
    • a) => c): there exists a bijection f:A→ℵf:A\to\alephf:A, list the elements of AAA in increasing order of f(a)f(a)f(a), any element a∈Aa\in AaA can be listed in f(a)f(a)f(a) steps
    • c) => b): for each a∈Aa\in AaA, let f(a)f(a)f(a) be # of steps used to list aaa for the first time
    • b) => a): there exists a injection f:A→ℵf:A\to\alephf:A, sort elements of AAA in increasing order of f(a)f(a)f(a), let g(a)g(a)g(a) be the rank of aaa, which is bijective from AAA to ℵ\aleph
Theorem: Let Σ\SigmaΣ be an alphabet, Σ∗\Sigma^*Σ is countable
  • If Σ=∅\Sigma=\varnothingΣ=, Σ∗={e}\Sigma^*=\{e\}Σ={e} is countable
  • Suppose Σ≠∅\Sigma\ne\varnothingΣ=, enumerate all strings in Σ∗\Sigma^*Σ by increasing order of length
  • A string of length iii can be listed within ∣Σ∣0+∣Σ∣1+∣Σ∣2+⋯+∣Σ∣i|\Sigma|^0+|\Sigma|^1+|\Sigma|^2+\cdots+|\Sigma|^iΣ0+Σ1+Σ2++Σi steps
    • ∣Σ∣k|\Sigma|^kΣk denotes # of strings with length kkk
  • Therefore Σk\Sigma^kΣk is countable
  • Collary: the set of all Turing machines is countable
Theorem: Let Σ\SigmaΣ be some non-empty alphabet and L\mathcal{L}L be the set of all languages over Σ\SigmaΣ, L\mathcal{L}L is uncountable
  • Supposed L\mathcal{L}L is countable, the languages in L\mathcal{L}L can be listed as L1,L2,L3,…L_1,L_2,L_3,\dotsL1,L2,L3,
  • Since Σ∗\Sigma^*Σ is countable, the strings in Σ∗\Sigma^*Σ can be listed as s1,s2,s3,…s_1,s_2,s_3,\dotss1,s2,s3,
  • Diagonalization: D={si:si∉Li}D=\{s_i:s_i\notin L_i\}D={si:si/Li} is a language over Σ\SigmaΣ
    • for any si∈Ds_i\in DsiD iff si∉Lis_i\notin L_isi/Li, therefore D≠LiD\ne L_iD=Li, therefore D∉LD\notin\mathcal{L}D/L
Recursive ⊊\subsetneq R.E.
Theorem: Let Σ\SigmaΣ be an alphabet, Σ∗\Sigma^*Σ is countable
  • If Σ=∅\Sigma=\varnothingΣ=, Σ∗={e}\Sigma^*=\{e\}Σ={e} is countable
  • Suppose Σ≠∅\Sigma\ne\varnothingΣ=, enumerate all strings in Σ∗\Sigma^*Σ by increasing order of length
  • A string of length iii can be listed within ∣Σ∣0+∣Σ∣1+∣Σ∣2+⋯+∣Σ∣i|\Sigma|^0+|\Sigma|^1+|\Sigma|^2+\cdots+|\Sigma|^iΣ0+Σ1+Σ2++Σi steps
    • ∣Σ∣k|\Sigma|^kΣk denotes # of strings with length kkk
  • Therefore Σk\Sigma^kΣk is countable
  • Collary: the set of all Turing machines is countable
Theorem: Let Σ\SigmaΣ be some non-empty alphabet and L\mathcal{L}L be the set of all languages over Σ\SigmaΣ, L\mathcal{L}L is uncountable
  • Supposed L\mathcal{L}L is countable, the languages in L\mathcal{L}L can be listed as L1,L2,L3,…L_1,L_2,L_3,\dotsL1,L2,L3,
  • Since Σ∗\Sigma^*Σ is countable, the strings in Σ∗\Sigma^*Σ can be listed as s1,s2,s3,…s_1,s_2,s_3,\dotss1,s2,s3,
  • Diagonalization: D={si:si∉Li}D=\{s_i:s_i\notin L_i\}D={si:si/Li} is a language over Σ\SigmaΣ
    • for any si∈Ds_i\in DsiD iff si∉Lis_i\notin L_isi/Li, therefore D≠LiD\ne L_iD=Li, therefore D∉LD\notin\mathcal{L}D/L
If AAA and BBB are recursive, so is A∪BA\cup BAB
  • M∪=M_\cup=M= on input “www
    1. run MAM_\mathrm{A}MA and MBM_\mathrm{B}MB on “www
    2. if at least one of them accepts www, accept “www
    3. else reject
If AAA and BBB are recursive, so is A∘BA\circ BAB
  • M∘=M_\circ=M= on input “www
    1. enumerate all possible division (u,v)(u,v)(u,v) with uv=wuv=wuv=w
    2. run MAM_\mathrm{A}MA on uuu and MBM_\mathrm{B}MB on vvv
    3. if both of them accepts uuu and vvv, accept “www
    4. else reject
If AAA and BBB are R.E., so is A∪BA\cup BAB
  • M∪=M_\cup=M= on input “www
    1. run MAM_\mathrm{A}MA and MBM_\mathrm{B}MB on “www
    2. if one of them halts, halt
If AAA and BBB are R.E., so is A∘BA\circ BAB
  • M∘=M_\circ=M= on input “www
    1. non-deterministically divide www into uvuvuv
    2. run MAM_\mathrm{A}MA on uuu and MBM_\mathrm{B}MB on vvv
    3. if both of them halt, halt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值