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 s∈K is the initial state
- H ⊆ K H\subseteq K H⊆K is the set of halting states
- transition function
δ
:
(
(
K
−
H
)
×
Σ
→
K
×
(
Σ
∪
{
←
,
→
}
)
\delta:((K-H)\times\Sigma\to K\times(\Sigma\cup\{\leftarrow,\rightarrow\})
δ:((K−H)×Σ→K×(Σ∪{←,→})
- ∀ q ∈ K − H \forall q\in K-H ∀q∈K−H, 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 ∀q∈K−H,∀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,⊳b⊔a,a⊔⊔b)≡(q,⊳b⊔aa⊔⊔b)
- halting configuration if q ∈ H q\in H q∈H
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' C⊢M∗C′ 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(k≥1) 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=C0⊢MC1⊢M⋯⊢MCk=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=K1∪K2∪K3∪{h}
- s = s 1 s=s_1 s=s1
- H = H 2 ∪ H 3 ∪ { h } H=H_2\cup H_3\cup\{h\} H=H2∪H3∪{h}
-
∀
q
∈
K
−
H
,
∀
a
∈
Σ
\forall q\in K-H,\forall a\in\Sigma
∀q∈K−H,∀a∈Σ
- If
q
∈
K
1
−
H
1
q\in K_1-H_1
q∈K1−H1
- δ ( 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
q∈H1
- δ ( 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
q∈K2−H2
- δ ( 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
q∈K3−H3
- δ ( q , a ) = δ 3 ( q , a ) \delta(q,a)=\delta_3(q,a) δ(q,a)=δ3(q,a)
- If
q
∈
K
1
−
H
1
q\in K_1-H_1
q∈K1−H1
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∈(Σ−{⊳,⊔})∗:⊳⊔⊔w⊔→⊳⊔w⊔

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∈(Σ−{⊳,⊔})∗:⊳⊔w⊔→⊳⊔w⊔w⊔

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
w∈L,
(
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
w∈L,
(
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:n≥0}

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
h∈H 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 δ:(K−H)×Σk→K×(Σ∪{←,→})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^+} Z−N+
- 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\})) Δ⊆((K−H)×Σ)×(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 w∈L iff ( s , ⊳ ⊔ ‾ w ) ⊢ M ∗ ( h , ⊳ u ⊔ ‾ v ) (s,\rhd\underline{\sqcup}w)\vdash^*_M(h,\rhd u\underline{\sqcup}v) (s,⊳⊔w)⊢M∗(h,⊳u⊔v) 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 w∈L iff ( s , ⊳ ⊔ ‾ w ) ⊢ M ∗ ( y , ⊳ u ⊔ ‾ v ) (s,\rhd\underline{\sqcup}w)\vdash^*_M(y,\rhd u\underline{\sqcup}v) (s,⊳⊔w)⊢M∗(y,⊳u⊔v)
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 ⊳⊔w⊔p⊔q: non-deterministicly generates a binary string p p p with 2 ≤ p ‾ ≤ w ‾ 2\le\overline{p}\le\overline{w} 2≤p≤w and then non-deterministicly generates a binary string q q q with 2 ≤ q ‾ ≤ w ‾ 2\le\overline{q}\le\overline{w} 2≤q≤w
- 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:2j≥∣K∣}
- “ 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 ⊳:a0t−11
- ← : a 0 t − 2 10 \leftarrow:a0^{t-2}10 ←:a0t−210
- → : a 0 t − 2 11 \rightarrow:a0^{t-2}11 →:a0t−211
- Encoding transition
- δ : ( K − H ) × Σ → K × ( Σ ∪ { ← , → } ) \delta: (K-H)\times\Sigma\to K\times(\Sigma\cup\{\leftarrow,\rightarrow\}) δ:(K−H)×Σ→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”
- select a node of G G G and mark it
- repeat the following until no new nodes are marked: for each marked node, mark all its neighbors
- if all nodes of G G G are marked, accept “ G G G”
- 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”
- simulate B B B on w w w
- if B B B accepts w w w, accept “ B B B”“ w w w”
- 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
- run M R 1 M_\mathrm{R1} MR1 on “ B B B”“ w w w”
- if M R 1 M_\mathrm{R1} MR1 accepts “ B B B”“ w w w”, accept w w w
- 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”
- convert B B B into an equivalent DFA D D D
- run M R 1 M_\mathrm{R1} MR1 on “ D D D”“ w w w”
- if M R 1 M_\mathrm{R1} MR1 accepts “ D D D”“ w w w”, accept “ B B B”“ w w w”
- 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)\} w∈L(R)}
-
M
R
3
=
M_\mathrm{R3}=
MR3= on input “
R
R
R”“
w
w
w”
- convert R R R into an equivalent NFA B B B
- run M R 2 M_\mathrm{R2} MR2 on “ B B B”“ w w w”
- if M R 2 M_\mathrm{R2} MR2 accepts “ B B B”“ w w w”, accept “ R R R”“ w w w”
- 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”
- mark the initial state of B B B
- repeat the following until no new states are marked: for each marked state, mark all its successors by transition function
- if no final states are marked, accept “ B B B”
- 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:w∈L(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”
- 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)
- run M R 4 M_\mathrm{R4} MR4 on “ C C C”
- if M R 4 M_\mathrm{R4} MR4 accepts “ C C C”, accept “ A A A”“ B B B”
- 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 A→BC, for A , B , C ∈ ( V − Σ ) A,B,C\in(V-\Sigma) A,B,C∈(V−Σ)
- A → a A\to a A→a, for A ∈ ( V − Σ ) A\in(V-\Sigma) A∈(V−Σ) and a ∈ Σ a\in\Sigma a∈Σ
- S → e S\to e S→e
- 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 S0→S
- fix e e e-rules: A → e A\to e A→e with A ≠ S 0 A\ne S_0 A=S0
- fix short rules: A → B A\to B A→B with A , B ∈ ( V − Σ ) A,B\in(V-\Sigma) A,B∈(V−Σ)
- fix long rules: A → u A\to u A→u with u ∈ V ∗ u\in V^* u∈V∗ and ∣ u ∣ > 2 |u|>2 ∣u∣>2
- fix A → u 1 u 2 A\to u_1u_2 A→u1u2 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(n≥1), it must take exactly 2 n − 1 2n-1 2n−1 steps
- A → B C A\to BC A→BC takes n − 1 n-1 n−1 steps
- A → a A\to a A→a 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”
- convert G G G into an equivalent CFG G ′ G' G′ in CNF
- if ∣ w ∣ = 0 |w|=0 ∣w∣=0
- if G ′ G' G′ has rule S → e S\to e S→e, accept “ G G G”“ w w w”
- else reject
- if ∣ w ∣ ≥ 1 |w|\ge1 ∣w∣≥1, list all the derivations(finite, ≤ ∣ R ∣ 2 ∣ w ∣ − 1 \le|R|^{2|w|-1} ≤∣R∣2∣w∣−1) of length 2 ∣ w ∣ − 1 2|w|-1 2∣w∣−1
- 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”
- convert P P P into an equivalent CFG G G G
- run M C 1 M_\mathrm{C1} MC1 on “ G G G”“ w w w”
- if M C 1 M_\mathrm{C1} MC1 accepts “ G G G”“ w w w”, accept “ P P P”“ w w w”
- 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”
- mark all the terminals and e e e
- 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
- if S S S is not marked, accept “ G G G”
- else reject
Let f : A → B f:A\to B f:A→B 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 b∈B, there exists a ∈ A a\in A a∈A 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:A→B
- 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 a∈A can be listed in f ( a ) f(a) f(a) steps
- c) => b): for each a ∈ A a\in A a∈A, 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 si∈D 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 si∈D 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 A∪B
-
M
∪
=
M_\cup=
M∪= on input “
w
w
w”
- run M A M_\mathrm{A} MA and M B M_\mathrm{B} MB on “ w w w”
- if at least one of them accepts w w w, accept “ w w w”
- else reject
If A A A and B B B are recursive, so is A ∘ B A\circ B A∘B
-
M
∘
=
M_\circ=
M∘= on input “
w
w
w”
- enumerate all possible division ( u , v ) (u,v) (u,v) with u v = w uv=w uv=w
- run M A M_\mathrm{A} MA on u u u and M B M_\mathrm{B} MB on v v v
- if both of them accepts u u u and v v v, accept “ w w w”
- else reject
If A A A and B B B are R.E., so is A ∪ B A\cup B A∪B
-
M
∪
=
M_\cup=
M∪= on input “
w
w
w”
- run M A M_\mathrm{A} MA and M B M_\mathrm{B} MB on “ w w w”
- if one of them halts, halt
If A A A and B B B are R.E., so is A ∘ B A\circ B A∘B
-
M
∘
=
M_\circ=
M∘= on input “
w
w
w”
- non-deterministically divide w w w into u v uv uv
- run M A M_\mathrm{A} MA on u u u and M B M_\mathrm{B} MB on v v v
- if both of them halt, halt
本文详细介绍了图灵机模型的构造和工作原理,包括一维无限带、状态转换、停机状态等概念。通过不同类型的图灵机(如符号写入、左移头、右移头机器)和组合机器展示了其灵活性。同时,讨论了如何使用图灵机来决定和半决定语言,以及如何计算和枚举语言。此外,文章探讨了递归理论,包括递归语言、递归枚举和不可计算性。最后,通过实例解释了如何判断一个图灵机是否接受特定输入,以及如何构造决定性和非决定性问题。
1万+

被折叠的 条评论
为什么被折叠?



