Section 5.1 The Turing machine 2IT70 Automata and Process...
Transcript of Section 5.1 The Turing machine 2IT70 Automata and Process...
Section 5.1
The Turing machine
2IT70 Automata and Process Theory
Technische Universiteit Eindhoven
June 12, 2013
The Turing machine
AutomatonInput Yes/No
Tape
figure 5.1, page 137
2 IT70 (2013) Section 5.1 2 / 20
An example Turing machine
s tτ [�/�]L
a[�/1]R b[1/�]L
example 5.1, page 138
2 IT70 (2013) Section 5.1 3 / 20
An example Turing machine
s tτ [�/�]L
a[�/1]R b[1/�]L
initial state s, initial tape instance �
(s, �) aÐ→ (s,1�) aÐ→ (s,11�) a
Ð→ (s,111�) τ
Ð→
(t,111) bÐ→ (t,11) b
Ð→ (t, 1)↓
example 5.1, page 138
2 IT70 (2013) Section 5.1 3 / 20
Formal definition
Turing machine M = (S, A, D, �, →, ↑, ↓)S states
A alphabet
D data elements
empty cell symbol or blank � ∉ D
→ ⊆ S ×A τ ×D� ×D� × {L,R} × S transitions
notation sa[d/e]LÐÐÐÐ→ t or s
a[d/e]RÐÐÐÐ→ t
initial state ↑
↓ ⊆ S final states
definition 5.2, page 138
2 IT70 (2013) Section 5.1 4 / 20
Transition system of a Turing machine
tape instance xcy
x , y ∈ D∗�and c ∈ { d ∣ d ∈ D } ∪ {�}
if x ≠ ε then x = dx ′ with d ∈ D
if y ≠ ε then y = y ′e with e ∈ D
definition 5.3, page 139
2 IT70 (2013) Section 5.1 5 / 20
Transition system of a Turing machine
tape instance xcy
x , y ∈ D∗�and c ∈ { d ∣ d ∈ D } ∪ {�}
if x ≠ ε then x = dx ′ with d ∈ D
if y ≠ ε then y = y ′e with e ∈ D
transition system of Turing machine M = (S, A, D, �, →, ↑, ↓)states { (s, z) ∣ s ∈ S, z tape instance}, alphabet Aτ
(s, xdy) aÐ→ (t, xe⟩y) if s a[d/e]R
ÐÐÐÐ→ t
(s, xdy) aÐ→ (t, x⟨ey) if s a[d/e]L
ÐÐÐÐ→ t
initial state (↑, �), final states {(s, z) ∣ s↓ }left-check wc⟨ = wc, ε⟨ = � and right-check ⟩cw = cw , ⟩ε = �
definition 5.3, page 139
2 IT70 (2013) Section 5.1 5 / 20
Example transition system
τ[�/�]L τ[�/�]Ra[�/1]R b[1/�]L
� 1� 11� 111�
� � 1 11
a a a
τ τ τ
bbτ
a
τ
b
example 5.4, page 140
2 IT70 (2013) Section 5.1 6 / 20
Language accepted by TM
definition Turing machine M = (S, A, D, �, →, ↑, ↓)L(M) = {w ∈ A∗ ∣ (↑, �) w
ÐÐ↠ (s, z) ∧ s↓ }
definition 5.5, page 140
2 IT70 (2013) Section 5.1 7 / 20
Language accepted by TM
definition Turing machine M = (S, A, D, �, →, ↑, ↓)L(M) = {w ∈ A∗ ∣ (↑, �) w
ÐÐ↠ (s, z) ∧ s↓ }a[�/�]R
L(M) = { an ∣ n ⩾ 0}�
a
definition 5.5, page 140
2 IT70 (2013) Section 5.1 7 / 20
Language accepted by TM
definition Turing machine M = (S, A, D, �, →, ↑, ↓)L(M) = {w ∈ A∗ ∣ (↑, �) w
ÐÐ↠ (s, z) ∧ s↓ }a[�/�]R
L(M) = { an ∣ n ⩾ 0}�
a
τ[�/�]La[�/1]R b[1/1]L
τ[�/�]Rc[1/�]R
τ[�/�]LL(M) = { anbncn ∣ n ⩾ 0}
definition 5.5, page 140
2 IT70 (2013) Section 5.1 7 / 20
Language accepted by TM (cont.)
s1 s2 s3 s4τ[�/�]L
a[�/1]R b[1/1]Lτ[�/�]R
c[1/�]Rτ[�/�]L
L(M) = { anbncn ∣ n ⩾ 0}
� 1� 11�
1111�11
11 1 � �
a a
τ
bb
τ
c c τ
example 5.7, page 141
2 IT70 (2013) Section 5.1 8 / 20
Another computatble language
s1 s2 s3 s4τ[�/�]Lτ[�/�]L
a[�/a]R τ[a/a]Lτ[�/�]R
a[a/�]R
b[�/b]R τ[b/b]L b[b/�]RL(M) = {ww ∣ w ∈ {a,b}∗ }
example 5.8, page 141
2 IT70 (2013) Section 5.1 9 / 20
Another computatble language (cont.)
τ[�/�]Lτ[�/�]La[�/a]R τ[a/a]L
τ[�/�]Ra[a/�]R
b[�/b]R τ[b/b]L b[b/�]R
L(M) = {ww ∣ w ∈ {a,b}∗ }
� a� aa� aab�
�abb abb aab aab
aab ab b � �
a a b
τ
τττ
τ
a a b τ
example 5.8, page 141
2 IT70 (2013) Section 5.1 10 / 20
The reactive Turing machine
AutomatonInput yes/no
Tape
figure 5.2, page 136
2 IT70 (2013) Section 5.1 11 / 20
The reactive Turing machine
AutomatonInputi
Outputo
Tape
input port i and output port o
figure 5.2, page 136
2 IT70 (2013) Section 5.1 11 / 20
The reactive Turing machine (cont.)
reactive Turing machine M computes if
only i?d , o!d and τ -steps and inputs precede outputs
if w ∈ L(M) then w = i?d1⋯i?dn ⋅ o!e1⋯o!emfor suitable di , ej ∈ D, n,m ⩾ 0
every input sequence has exactly one output sequence
if i?d1⋯i?dn ⋅ o!e1⋯o!em ∈ L(M)i?d1⋯i?dn ⋅ o!e
′1⋯o!e
′m′ ∈ L(M)
and
then m = m′ and o!ej = o!e′j for j = 1 . . .m
defnition 5.11, page 143
2 IT70 (2013) Section 5.1 12 / 20
A Turing machine computing addition
s1 s2 s3 s4
s5
s6 s7i?+[�/�]L
i?n[�/n]R τ[n/n]L
τ[�/�]R τ[�/�]L τ[�/�]R
i?m[n/n+m]Rτ[0/0]Lτ[1/1]L o!n[n/n]R
τ[�/�]L
τ[2/0]Lτ[0/1 ]Lτ[�/1]L
τ[1/0]Lτ[2/1]L
input alphabet {0,1,+}, data alphabet {0,1,2}fM ∶ {w+v ∈ {0,1,+}∗ ∣ ∣w ∣ = ∣v ∣ } with fM(w+v) = w + v
2 IT70 (2013) Section 5.1 13 / 20
A Turing machine computing addition
i?+[�/�]L
i?n[�/n]R τ[n/n]L
τ[�/�]R τ[�/�]L τ[�/�]R
i?m[n/n+m]Rτ[0/0]Lτ[1/1]L o!n[n/n]R
τ[�/�]L
τ[2/0]Lτ[0/1 ]Lτ[�/1]L
τ[1/0]Lτ[2/1]L
� 1� 11� 110�
�110 110 110 110
110 110 120 121�
�1001
�001 101
121 121
1001 001 01 1 � �
i?1 i?1 i?0
i?+
τττ
τ
i?0 i?1 i?1
τ
ττ
ττ
τ
o!1 o!0 o!0 o!1 τ
2 IT70 (2013) Section 5.1 14 / 20
A copier Turing machine
s1 s2 s3 s4 s5 s6
i?a[�/a]Ri?b[�/b]R
τ[�/�]L
τ[a/a]Lτ[b/b]L
τ[�/�]R
o!a[a/a]Ro!b[b/b]R
τ[�/�]L
τ[a/a]Lτ[b/b]L
τ[�/�]R
o!a[a/a]Ro!b[b/b]R
τ[�/�]L
fM ∶ {a,b}∗ → {a,b}∗ with fM(w) = ww
example 5.13, page 143
2 IT70 (2013) Section 5.1 15 / 20
A copier Turing machine (cont.)i?a[�/a]Ri?b[�/b]R
τ[�/�]L
τ[a/a]Lτ[b/b]L
τ[�/�]R
o!a[a/a]Ro!b[b/b]R
τ[�/�]L
τ[a/a]Lτ[b/b]L
τ[�/�]R
o!a[a/a]Ro!b[b/b]R
τ[�/�]L
� a� ab� abb�
�abb abb abb abb
abb abb abb abb�
�abb abb abb abb
abb abb abb abb� abb�
i?a i?b i?b
τ
τ τ τ
τ
o!a o!b o!b
τ
τ τ τ
τ
o!a o!b o!b τ
2 IT70 (2013) Section 5.1 16 / 20
A comparing Turing machine
s1 s2 s3 s4
s6s5
i?n[�/n]R
i?>[�/�]L
τ[n/n]L
τ[�/�]R
i?n[n/�]Ri?0[1/�]R
o!no[�/�]Li?1[0/�]R
i?m[n/�]R
o!yes[�/�]L
i?m[n/�]Ro!no[�/�]L
fM(w>v) = yes if w > v as numbers, no otherwise
assumes input number of equal length
example 5.14, page 143
2 IT70 (2013) Section 5.1 17 / 20
A comparing Turing machine
i?n[�/n]R
i?>[�/�]L
τ[n/n]L
τ[�/�]R
i?n[n/�]Ri?0[1/�]R
o!no[�/�]Li?1[0/�]R
i?m[n/�]R
o!yes[�/�]L
i?m[n/�]Ro!no[�/�]L
1 > 0 1 > 1 0 > 1
� 1�
�1 1
1 �
�
i?1
i?>
τ
τ
i?0
o!yes
� 1�
�1 1
1 �
�
i?1
i?>
τ
τ
i?1
o!no
� 0�
�0 0
0
� �
i?0
i?>
τ
τ
i?1
o!no
2 IT70 (2013) Section 5.1 18 / 20
Decision problems
definition L ⊆ A∗ and predicate P on L
P is decidable if fP ∶ L→ {yes ,no} is computable
halting problem given TM M and input x
does a TM exist deciding whether M terminates on input x?
TM M encoded as string wM
L = {wM ⋅ x ∣ TM M, x input for M }P(wM ⋅ x) = true iff M terminates on x
definition 5.25 and theorem 5.26. page 150
2 IT70 (2013) Section 5.1 19 / 20
Proof of the Halting Problem
suppose the halting problem is decidable
TM H such that H(wM ⋅ x) = { yes if M(x) = yes/nono if M(x) =∞
2 IT70 (2013) Section 5.1 20 / 20
Proof of the Halting Problem
suppose the halting problem is decidable
TM H such that H(wM ⋅ x) = { yes if M(x) = yes/nono if M(x) =∞
TM H ′ such that H ′(wM ⋅ x) = { ∞ if H(wM ⋅ x) = yesno if H(wM ⋅ x) = no
2 IT70 (2013) Section 5.1 20 / 20
Proof of the Halting Problem
suppose the halting problem is decidable
TM H such that H(wM ⋅ x) = { yes if M(x) = yes/nono if M(x) =∞
TM H ′ such that H ′(wM ⋅ x) = { ∞ if H(wM ⋅ x) = yesno if H(wM ⋅ x) = no
TM H such that H(wM) = H ′(wM ⋅wM)
does H halt on input wH?
2 IT70 (2013) Section 5.1 20 / 20