计算理论笔记(三)TM Decidablity

本文详细介绍了图灵机模型的构造和工作原理,包括一维无限带、状态转换、停机状态等概念。通过不同类型的图灵机(如符号写入、左移头、右移头机器)和组合机器展示了其灵活性。同时,讨论了如何使用图灵机来决定和半决定语言,以及如何计算和枚举语言。此外,文章探讨了递归理论,包括递归语言、递归枚举和不可计算性。最后,通过实例解释了如何判断一个图灵机是否接受特定输入,以及如何构造决定性和非决定性问题。
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)
  • K K K is a finite set of states
  • Σ \Sigma Σ is a alphabet containing left end symbol ⊳ \rhd and blank symbol ⊔ \sqcup
  • s ∈ K s\in K sK is the initial state
  • H ⊆ K H\subseteq K HK 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-H qKH, if δ ( q , ⊳ ) = ( p , b ) \delta(q,\rhd)=(p,b) δ(q,)=(p,b), then b = → b=\rightarrow b=
    • ∀ q ∈ K − H , ∀ a ∈ Σ \forall q\in K-H,\forall a\in\Sigma qKH,aΣ, if δ ( q , a ) = ( p , b ) \delta(q,a)=(p,b) δ(q,a)=(p,b), then b ≠ ⊳ b\neq\rhd b=
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 ∈ H q\in H qH
Yields in one step: ( q 1 , ⊳ w 1 a 1 u 1 ) ⊢ M ( q 2 , ⊳ w 2 a 2 u 2 ) (q_1,\rhd w_1a_1u_1)\vdash_M(q_2,\rhd w_2a_2u_2) (q1,w1a1u1)M(q2,w2a2u2) if
  • (writing) w 1 = w 2 , u 1 = u 2 , a 2 ∈ Σ − { ⊳ } w_1=w_2,u_1=u_2,a_2\in\Sigma-\{\rhd\} w1=w2,u1=u2,a2Σ{} and δ ( q 1 , a 1 ) = ( q 2 , a 2 ) \delta(q_1,a_1)=(q_2,a_2) δ(q1,a1)=(q2,a2)
  • (moving left) δ ( q 1 , a 1 ) = ( q 2 , ← ) , w 1 = w 2 a 2 \delta(q_1,a_1)=(q_2,\leftarrow),w_1=w_2a_2 δ(q1,a1)=(q2,),w1=w2a2 and either
    • u 2 = e u_2=e u2=e if u 1 = e u_1=e u1=e and a 1 = ⊔ a_1=\sqcup a1=
    • u 2 = a 1 u 1 u_2=a_1u_1 u2=a1u1, otherwise
  • (moving right) δ ( q 1 , a 1 ) = ( q 2 , → ) , w 2 = w 1 a 1 \delta(q_1,a_1)=(q_2,\rightarrow),w_2=w_1a_1 δ(q1,a1)=(q2,),w2=w1a1 and
    • u 1 = e u_1=e u1=e if u 2 = e u_2=e u2=e and a 2 = ⊔ a_2=\sqcup a2=
    • u 1 = a 2 u 2 u_1=a_2u_2 u1=a2u2, otherwise
We say two configurations C ⊢ M ∗ C ′ C\vdash^*_MC' CMC iff
  • C = C ′ C=C' C=C or
  • ∃ C 0 , C 1 , … , C k ( k ≥ 1 ) \exists C_0,C_1,\dots,C_k(k\ge1) C0,C1,,Ck(k1) s.t. C = C 0 ⊢ M C 1 ⊢ M ⋯ ⊢ M C k = C ′ C=C_0\vdash_MC_1\vdash_M\dots\vdash_MC_k=C' C=C0MC1MMCk=C
M M M halts whenever it reaches a halting configuration
Exercise
  • for any a ∈ Σ − { ⊳ } a\in\Sigma-\{\rhd\} aΣ{}, symbol-writing machine M a = ( { 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_\leftarrow M
    • δ ( 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_\rightarrow M
    • δ ( 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
  • M i = ( K i , Σ , δ i , s i , H i ) , ∀ i = 1 , 2 , 3 M_i=(K_i,\Sigma,\delta_i,s_i,H_i),\forall i=1,2,3 Mi=(Ki,Σ,δi,si,Hi),i=1,2,3
  • Construct M = ( K , Σ , δ , s , H ) M=(K,\Sigma,\delta,s,H) M=(K,Σ,δ,s,H)
    • K = K 1 ∪ K 2 ∪ K 3 ∪ { h } K=K_1\cup K_2\cup K_3\cup\{h\} K=K1K2K3{h}
    • s = s 1 s=s_1 s=s1
    • H = H 2 ∪ H 3 ∪ { h } H=H_2\cup H_3\cup\{h\} H=H2H3{h}
    • ∀ q ∈ K − H , ∀ a ∈ Σ \forall q\in K-H,\forall a\in\Sigma qKH,aΣ
      • If q ∈ K 1 − H 1 q\in K_1-H_1 qK1H1
        • δ ( q , a ) = δ 1 ( q , a ) \delta(q,a)=\delta_1(q,a) δ(q,a)=δ1(q,a)
      • If q ∈ H 1 q\in H_1 qH1
        • δ ( q , 0 ) = ( s 2 , 0 ) \delta(q,0)=(s_2,0) δ(q,0)=(s2,0)
        • δ ( q , 1 ) = ( s 3 , 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 ∈ K 2 − H 2 q\in K_2-H_2 qK2H2
        • δ ( q , a ) = δ 2 ( q , a ) \delta(q,a)=\delta_2(q,a) δ(q,a)=δ2(q,a)
      • If q ∈ K 3 − H 3 q\in K_3-H_3 qK3H3
        • δ ( q , a ) = δ 3 ( q , a ) \delta(q,a)=\delta_3(q,a) δ(q,a)=δ3(q,a)
left-shifting machine S ← S_\leftarrow S
  • ∀ 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\sqcup w(Σ{,}):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Σ, M M M 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: M M M halts on w } w\} w}, M M M semidecides L ( M ) L(M) L(M)
  • Example: Fix some input alphabet Σ 0 ∗ \Sigma_0^* Σ0
    • Let a ∈ Σ 0 a\in\Sigma_0 aΣ0, R a R_a Ra semidecides L = { w ∈ Σ 0 ∗ L=\{w\in\Sigma_0^* L={wΣ0: w w w 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 M M M decides a language L ⊆ Σ 0 ∗ L\subseteq \Sigma_0^* LΣ0 if
  • For every w ∈ L w\in L wL, ( s , ⊳ ⊔ ‾ w ) ⊢ M ∗ ( y , ⊳ u a ‾ 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\Sigma aΣ
    • M M M accepts w w w
  • For every w ∈ L w\in L wL, ( s , ⊳ ⊔ ‾ w ) ⊢ M ∗ ( n , ⊳ u a ‾ 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\Sigma aΣ
    • M M M rejects w w w
  • A language is recursive/decidable if it is decided by a TM
Example: The following TM decides { a n b n c n : n ≥ 0 } \{a^nb^nc^n:n\ge0\} {anbncn:n0}

在这里插入图片描述

Theorem: If L L L is recursive, it must be recursively enumerable
  • L L L is recursive ⇒ ∃ M = ( K , Σ , δ , S , { y , n } ) \Rightarrow \exists M=(K,\Sigma,\delta,S,\{y,n\}) M=(K,Σ,δ,S,{y,n}) decides L L L
    • δ ( 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 L L L is recursive, so is L ‾ \overline{L} L
  • Exchange the role of y y y and n n n
  • False generalization: If L L L 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 ∈ H h\in H hH and y ∈ Σ 0 ∗ y\in\Sigma_0^* yΣ0
    • y y y: output of M M M on w w w
  • Let f : Σ 0 ∗ → Σ 0 ∗ f:\Sigma_0^*\to\Sigma_0^* f:Σ0Σ0, we say M M M computes f f f 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. M M M halts with ⊳ ⊔ ‾ f ( w ) \rhd \underline{\sqcup}f(w) f(w)
Example: f ( w ) = w w f(w)=ww f(w)=ww is computed by the following TM

在这里插入图片描述

Enumrator
  • We say a TM M M M enumerates a language L L L if for some state q q q, 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)}
    • q q q 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 N N N 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 ∈ L w\in L wL 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 h h h
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 M M M decides a language L ⊆ Σ 0 ∗ L\subseteq \Sigma_0^* LΣ0 if
  • There is a natural number N N N, depending on M M M and w w w, such that there is no configuration C C C satisfying ( s , ⊳ ⊔ ‾ w ) ⊢ M N C (s,\rhd\underline{\sqcup}w)\vdash^N_MC (s,w)MNC
  • w ∈ L w\in L wL 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 C C C be the set of binary strings representing composite number, design a NTM decides C C C
  • ⊳ ⊔ w ⊔ p ⊔ q \rhd\sqcup w\sqcup p\sqcup q wpq: non-deterministicly generates a binary string p p p with 2 ≤ p ‾ ≤ w ‾ 2\le\overline{p}\le\overline{w} 2pw and then non-deterministicly generates a binary string q q q 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 y y y if match, n n n if not
Theorem: A NTM N N N can be simulated by a DTM M M M
  • 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}r K×(Σ{,}=K×(Σ+2)Δ r
  • Construct 3-tap DTM to simulate NTM, by BFS
    • 1st-tape: input
    • 2nd-tape: simulate a branch of NTM on w w w
    • 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 O O O can be encoded into a string “ O O O
Example: Every TM can be encoded into a string
  • Encoding states
    • i = min ⁡ j { j : 2 j ≥ ∣ K ∣ } i=\displaystyle\min_j\{j:2^j\ge|K|\} i=jmin{j:2jK}
    • q { 0 , 1 } i q\{0,1\}^i q{0,1}i
    • s : q 0 i s:q0^i s:q0i
  • Encoding alphabet
    • t = min ⁡ j { j : 2 j ≥ ∣ Σ ∣ + 2 } t=\displaystyle\min_j\{j:2^j\ge|\Sigma|+2\} t=jmin{j:2jΣ+2}
    • a { 0 , 1 } t a\{0,1\}^t a{0,1}t
    • ⊔ : a 0 t \sqcup:a0^t :a0t
    • ⊳ : a 0 t − 1 1 \rhd:a0^{t-1}1 :a0t11
    • ← : a 0 t − 2 10 \leftarrow:a0^{t-2}10 :a0t210
    • → : a 0 t − 2 11 \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 ( q 00 , a 100 , q 01 , a 00 ) (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 G G G, is G G G connected?
  • Language: L = { L=\{ L={ G G G”: G G G is a connected graph } \} }
  • M = M= M= on input “ G G G
    1. select a node of G G G 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 G G G are marked, accept “ G G G
    4. else reject
Decidable problem/recursive language
  • About DFA/NFA/regular languages
R1 Problem
  • Given a DFA B B B and a string w w w, does B B B accept w w w?
  • Language: A D F A = { A_\mathrm{DFA}=\{ ADFA={ B B B”“ w w w”: B B B is a DFA that accepts w } w\} w}
  • M R 1 = M_\mathrm{R1}= MR1= on input “ B B B”“ w w w
    1. simulate B B B on w w w
    2. if B B B accepts w w w, accept “ B B B”“ w w w
    3. else reject
R1* Problem, for a fixed DFA B B B
  • Given a string w w w, does B B B accept w w w?
  • Language: L ( B ) L(B) L(B)
  • M R 1 ∗ = M_\mathrm{R1^*}= MR1= on input w w w
    1. run M R 1 M_\mathrm{R1} MR1 on “ B B B”“ w w w
    2. if M R 1 M_\mathrm{R1} MR1 accepts “ B B B”“ w w w”, accept w w w
    3. else reject
R2 Problem
  • Given a NFA B B B and a string w w w, does B B B accept w w w?
  • Language: A N F A = { A_\mathrm{NFA}=\{ ANFA={ B B B”“ w w w”: B B B is a NFA that accepts w } w\} w}
  • M R 2 = M_\mathrm{R2}= MR2= on input “ B B B”“ w w w
    1. convert B B B into an equivalent DFA D D D
    2. run M R 1 M_\mathrm{R1} MR1 on “ D D D”“ w w w
    3. if M R 1 M_\mathrm{R1} MR1 accepts “ D D D”“ w w w”, accept “ B B B”“ w w w
    4. else reject
R3 Problem
  • Language: A R E X = { A_\mathrm{REX}=\{ AREX={ R R R”“ w w w”: R R R is a regex and w ∈ L ( R ) } w\in L(R)\} wL(R)}
  • M R 3 = M_\mathrm{R3}= MR3= on input “ R R R”“ w w w
    1. convert R R R into an equivalent NFA B B B
    2. run M R 2 M_\mathrm{R2} MR2 on “ B B B”“ w w w
    3. if M R 2 M_\mathrm{R2} MR2 accepts “ B B B”“ w w w”, accept “ R R R”“ w w w
    4. else reject
R4 Problem
  • Given a DFA B B B and a string w w w, is L ( B ) = ∅ L(B)=\varnothing L(B)=?
  • Language: E D F A = { E_\mathrm{DFA}=\{ EDFA={ B B B”: B B B is a DFA and L ( B ) = ∅ } L(B)=\varnothing\} L(B)=}
  • M R 4 = M_\mathrm{R4}= MR4= on input “ B B B
    1. mark the initial state of B B B
    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 “ B B B
    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)=\varnothing L(A)=L(B)L(A)L(B)=
R5 Problem
  • Language: E Q D F A = { EQ_\mathrm{DFA}=\{ EQDFA={ A A A”“ B B B”: A A A and B B B are two DFAs and L ( A ) = L ( B ) } L(A)=L(B)\} L(A)=L(B)}
  • M R 5 = M_\mathrm{R5}= MR5= on input “ A A A”“ B B B
    1. construct a DFA C C C s.t. L ( C ) = L ( A ) ⊕ L ( B ) L(C)=L(A)\oplus L(B) L(C)=L(A)L(B)
    2. run M R 4 M_\mathrm{R4} MR4 on “ C C C
    3. if M R 4 M_\mathrm{R4} MR4 accepts “ C C C”, accept “ A A A”“ B B B
    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 → B C A\to BC ABC, for A , B , C ∈ ( V − Σ ) A,B,C\in(V-\Sigma) A,B,C(VΣ)
    • A → a A\to a Aa, for A ∈ ( V − Σ ) A\in(V-\Sigma) A(VΣ) and a ∈ Σ a\in\Sigma aΣ
    • S → e S\to e Se
    • S S S 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 S 0 S_0 S0 and a new rule S 0 → S S_0\to S S0S
  • fix e e e-rules: A → e A\to e Ae with A ≠ S 0 A\ne S_0 A=S0
  • fix short rules: A → B A\to B AB with A , B ∈ ( V − Σ ) A,B\in(V-\Sigma) A,B(VΣ)
  • fix long rules: A → u A\to u Au with u ∈ V ∗ u\in V^* uV and ∣ u ∣ > 2 |u|>2 u>2
  • fix A → u 1 u 2 A\to u_1u_2 Au1u2 with u 1 u_1 u1 or u 2 u_2 u2 as terminal
Observation: If CFG in CNF generates a string length n ( n ≥ 1 ) n(n\ge1) n(n1), it must take exactly 2 n − 1 2n-1 2n1 steps
  • A → B C A\to BC ABC takes n − 1 n-1 n1 steps
  • A → a A\to a Aa takes n n n steps
C1 Problem
  • Language: A C F G = { A_\mathrm{CFG}=\{ ACFG={ G G G”“ w w w”: G G G is a CFG that generates w } w\} w}
  • M C 1 = M_\mathrm{C1}= MC1= on input “ G G G”“ w w w
    1. convert G G G into an equivalent CFG G ′ G' G in CNF
    2. if ∣ w ∣ = 0 |w|=0 w=0
    • if G ′ G' G has rule S → e S\to e Se, accept “ G G G”“ w w w
    • else reject
    1. if ∣ w ∣ ≥ 1 |w|\ge1 w1, list all the derivations(finite, ≤ ∣ R ∣ 2 ∣ w ∣ − 1 \le|R|^{2|w|-1} R2w1) of length 2 ∣ w ∣ − 1 2|w|-1 2w1
    • if any listed derivation generates w w w, accept “ G G G”“ w w w
    • else reject
C2 Problem
  • Language: A P D A = { A_\mathrm{PDA}=\{ APDA={ P P P”“ w w w”: P P P is a PDA that accepts w } w\} w}
  • M C 2 = M_\mathrm{C2}= MC2= on input “ P P P”“ w w w
    1. convert P P P into an equivalent CFG G G G
    2. run M C 1 M_\mathrm{C1} MC1 on “ G G G”“ w w w
    3. if M C 1 M_\mathrm{C1} MC1 accepts “ G G G”“ w w w”, accept “ P P P”“ w w w
    4. else reject
C3 Problem
  • Language: E C F G = { E_\mathrm{CFG}=\{ ECFG={ G G G”: G G G is a CFG and L ( G ) = ∅ } L(G)=\varnothing\} L(G)=}
  • M C 3 = M_\mathrm{C3}= MC3= on input “ G G G
    1. mark all the terminals and e e e
    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 S S S is not marked, accept “ G G G
    4. else reject
Let f : A → B f:A\to B f:AB be a function
  • f f f 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
  • f f f is surjective if for any b ∈ B b\in B bB, there exists a ∈ A a\in A aA satisfying f ( a ) = b f(a)=b f(a)=b
  • f f f is bijective if f f f is injective and surjective
Equinumerous
  • Two sets A A A and B B B are equinumerous if there exists a bijection f : A → B f:A\to B f: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 A A A be a set, the following statements are equivalent:
  • a) A A A is countable
  • b) there exists an injection f : A → ℵ f:A\to\aleph f:A
  • c) there exists some way to enumerate the elements of A A A such that each element is listed within finite steps
  • Proof:
    • a) => c): there exists a bijection f : A → ℵ f:A\to\aleph f:A, list the elements of A A A in increasing order of f ( a ) f(a) f(a), any element a ∈ A a\in A aA can be listed in f ( a ) f(a) f(a) steps
    • c) => b): for each a ∈ A a\in A aA, let f ( a ) f(a) f(a) be # of steps used to list a a a for the first time
    • b) => a): there exists a injection f : A → ℵ f:A\to\aleph f:A, sort elements of A A A in increasing order of f ( a ) f(a) f(a), let g ( a ) g(a) g(a) be the rank of a a a, which is bijective from A A A 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 i i i 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 k k k
  • 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 L 1 , L 2 , L 3 , … L_1,L_2,L_3,\dots L1,L2,L3,
  • Since Σ ∗ \Sigma^* Σ is countable, the strings in Σ ∗ \Sigma^* Σ can be listed as s 1 , s 2 , s 3 , … s_1,s_2,s_3,\dots s1,s2,s3,
  • Diagonalization: D = { s i : s i ∉ L i } D=\{s_i:s_i\notin L_i\} D={si:si/Li} is a language over Σ \Sigma Σ
    • for any s i ∈ D s_i\in D siD iff s i ∉ L i s_i\notin L_i si/Li, therefore D ≠ L i D\ne L_i D=Li, therefore D ∉ L D\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 i i i 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 k k k
  • 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 L 1 , L 2 , L 3 , … L_1,L_2,L_3,\dots L1,L2,L3,
  • Since Σ ∗ \Sigma^* Σ is countable, the strings in Σ ∗ \Sigma^* Σ can be listed as s 1 , s 2 , s 3 , … s_1,s_2,s_3,\dots s1,s2,s3,
  • Diagonalization: D = { s i : s i ∉ L i } D=\{s_i:s_i\notin L_i\} D={si:si/Li} is a language over Σ \Sigma Σ
    • for any s i ∈ D s_i\in D siD iff s i ∉ L i s_i\notin L_i si/Li, therefore D ≠ L i D\ne L_i D=Li, therefore D ∉ L D\notin\mathcal{L} D/L
If A A A and B B B are recursive, so is A ∪ B A\cup B AB
  • M ∪ = M_\cup= M= on input “ w w w
    1. run M A M_\mathrm{A} MA and M B M_\mathrm{B} MB on “ w w w
    2. if at least one of them accepts w w w, accept “ w w w
    3. else reject
If A A A and B B B are recursive, so is A ∘ B A\circ B AB
  • M ∘ = M_\circ= M= on input “ w w w
    1. enumerate all possible division ( u , v ) (u,v) (u,v) with u v = w uv=w uv=w
    2. run M A M_\mathrm{A} MA on u u u and M B M_\mathrm{B} MB on v v v
    3. if both of them accepts u u u and v v v, accept “ w w w
    4. else reject
If A A A and B B B are R.E., so is A ∪ B A\cup B AB
  • M ∪ = M_\cup= M= on input “ w w w
    1. run M A M_\mathrm{A} MA and M B M_\mathrm{B} MB on “ w w w
    2. if one of them halts, halt
If A A A and B B B are R.E., so is A ∘ B A\circ B AB
  • M ∘ = M_\circ= M= on input “ w w w
    1. non-deterministically divide w w w into u v uv uv
    2. run M A M_\mathrm{A} MA on u u u and M B M_\mathrm{B} MB on v v v
    3. if both of them halt, halt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值