Professional Documents
Culture Documents
Ch3 TuringMachine
Ch3 TuringMachine
M HNH M
MY TURING
(Theory of Computation)
Chng 3
The Chomsky
Chomskys Language Hierarchy
Handicapped machines
DFA
Languages accepted by
Turing Machines
Context-Sensitive Languages
anbncn ?
ww ?
Tape is read-only
Tape length is a constant
PDA
Regular Languages
a * a *b*
DFA
Context-Free Languages
a n b n wwR
PDA
What
about:
3/189
4/189
Computability
Computible
(there is an algorithm)
TM:
Equivalence of DFAs
The
formalisms equivalent :
Uncomputible
Equivalence of CFGs
All
5/189
Other
6/189
M t
t tng qu
qut m
my Turing
Input string
Blank symbol
Tape
...
A Turing Machine
b a c
...
Read-Write head
Mt bng v h
hn c
c hai ph
pha tr
tri v
v ph
phi
Mt b nh
nh ph
ph hu h
hn x
xc
nh tr
trng th
thi
Mt cu v
vo
c
t trn bng
Mt chng tr
trnh l
lm ho
hot
ng m
my Turing
7/189
8/189
M t
t chi ti
tit c
cc th
thnh ph
phn TM
Bng
M t
t chi ti
tit c
cc th
thnh ph
phn (2)
l
lm vi
vic :
Mt
c chia th
thnh c
cc lin ti
tip
b
b nh
nh ph
ph hu h
hn :
Ti
Tip c
cn
c n
ni dung t
ti m
mi th
thi i
im
Mi ch
cha m
mt k t
t no
a S
S c
c ch
cha k t
t tr
trng (blank symbol),, ho
hoc #
C th
th thay
i
c n
ni dung
Ph
t gi
gia t nh
nht hai k t
t #
Phn cu c
c ch (usable part) wS*
Ng
Ngi ta vi
vit #w#
Mi ph
phn t
t ca b
b nh
nh ph
ph xc
nh m
mt tr
trng th
thi
B nh
ngha
nh ph
ph
c li
lit k l
lc
nh ngh
cghi :
Chng
c hay ghi (l
(lm thay
i) n
ni dung t
tng c
ca bng
tr
trnh :
Tp h
hp h
hu h
hn c
cc quy t
tc
Di chuy
chuyn m
mt v
v tr
tr qua ph
phi, ho
hoc tr
tri, tng ng v
vi m
mt
Lm thay
i n
ni dung trn bng v
v ni dung b
b nh
nh ph
ph
Ti m
ch duy nh
nht m
mt
c
c, ho
hoc
c ghi
mi th
thi i
im, ch
9/189
10/189
A Turing Machine
Input tape
The Tape
Input String w *
...
...
...
...
Read-Write head
The head moves Left or Right
Read-Write head
Control Unit / Transition Diagram
12/189
Time 0
...
a b
...
...
...
...
Time 1
...
b k
c
1. Reads
Time 1
b k
...
...
Time 2
1. Reads
2. Writes
2. Writes
3. Moves Right
3. Moves Left
13/189
14/189
a b a c
Write
Read
Blank symbol
...
q1
head
Move Left
a b, L
q2
Move Right
q1
a b, R
q2
15/189
16/189
...
a b aa c
current state
...
q1
...
Time 1
...
a b a c
current state
q1
Time 2
a b bb c
a b, R
...
...
q2
q1
q2
17/189
...
...
q1
Time 2
a b bb c
a b, L
q2
q2
18/189
Example:
Determinism (n/ti
n/t
n/ti
n/tt
nh)
Time 1
...
a b a c
current state
Time 2
...
a b, R
...
q2
b d,L q
3
q1
c e,L
q2
g, R
Not Allowed
Allowed
q1
a b b c g
q1
...
q2
a b, R
q2
a d, L
q3
q1
q1
20/189
Halting
Example:
...
a b a c
...
The machine halts if there are
no possible transitions to follow
q1
a b, R
q2
Allowed:
q1
b d, L
No transition
for input symbol c
q3
21/189
22/189
Example:
...
Final States
a b a c
...
q1
a b, R
q2
b d, L
q3
q1
No possible transition
HALT!!!
q2
Allowed
q1
q2
Not Allowed
23/189
q1
24/189
Acceptance
Accept Input
If machine halts
in a final state
Reject Input
If machine halts
in a non-final state
or
If machine enters
an infinite loop
aa* = a+
a a, R
q0
, L
q1
25/189
26/189
a a a
a a a
q0
Time 1
a a a
a a, R
q0
q0
, L
a a a
Time 3
q0
a,
a, R
aa
q1
q0
q0
, L
q1
27/189
28/189
Time 0
a a a
a b a
q0
q1
Halt & Accept
a a, R
q0
, L
q0
q1
29/189
a a, R
, L
q1
30/189
a b a
Time 1
q0
No possible Transition
a a, R
q0
, L
b b, L
a a, R
q0
q1
, L
q1
31/189
32/189
a b a
Time 0
a b a
Time 1
q0
q0
b b, L
a a, R
q0
b b, L
a a, R
, L
q0
q1
, L
q1
33/189
34/189
a b a
Time 2
b b, L
a a, R
q0
q0
q0
, L
Time 3
q0
Time 4
a
q0
q1
Time 5
35/189
q0
36/189
Another TM Example
T = <, Q, P>
Mt cch khc m t ngn gn TM
= {1, #}, hoc = {1} Nu khng mun ch k t trng ca bng
Q = {q1, q2, q3}
P = { q1, 1 1, R, q2,
c mt s chn s 1, v li q1
q2, 1 1, R, q1,
1|1, R
q1, # #, L, q3,
q3, 1 1, L, q3,
2
1
1|1, R
q3, 1 1, R, q3,
q3, 1 #, R, q1 }
1|#, R
#|#, L
q3
1|1, R
Bi
Bitp
tp::M
Mt
thot
hotng
ng
on
onnhn
nhncu
cu111111
111111??
37/189
1|1, L
38/189
a a b b
Time 0
q0
q4
y y, R
q3
, L
y y, R
q0
y y, R
a a, R
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
X, Y
q3
, L
y y, R
q0
q3
, L
y y, R
q0
b y, L
x x, R
q2
40/189
x a b b
Time 2
q1
y y, R
q1
y y, L
a a, L
x a b b
q4
y y, R
a a, R
a x, R
39/189
q4
y y, R
q1
y y, R
a a, R
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
41/189
y y, R
q3
q4
, L
y y, R
q0
y y, R
a a, R
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
42/189
x a y b
Time 3
x a y b
Time 4
q2
q3
y y, R
a a, R
q4
y y, R
, L
y y, R
q0
q2
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
q3
, L
y y, R
q0
q3
, L
y y, R
q0
y y, R
a a, R
q1
y y, L
a a, L
b y, L
q2
q4
y y, R
q3
, L
y y, R
q0
y y, R
q0
q1
q2
46/189
x x y y
Time 8
q2
y y, R
a a, R
a x, R
b y, L
x x, R
q1
q3
q1
y y, L
a a, L
x x y b
, L
y y, R
a a, R
a x, R
45/189
y y, R
44/189
q1
a x, R
q4
q2
x x y b
Time 6
x x, R
Time 7
b y, L
x a y b
q4
q1
y y, L
a a, L
x x, R
q0
y y, R
y y, R
a a, R
a x, R
43/189
q4
y y, R
y y, L
a a, L
b y, L
x x, R
q2
47/189
y y, R
q3
q4
, L
y y, R
q0
y y, R
a a, R
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
48/189
x x y y
Time 9
x x y y
Time 10
q2
q4
y y, R
q3
, L
y y, R
q0
q0
y y, R
a a, R
a x, R
q1
y y, L
a a, L
b y, L
x x, R
q2
q3
, L
y y, R
q0
q1
q3
, L
y y, R
q0
q1
x x y y
Time 12
y y, L
a a, L
b y, L
x x, R
q2
51/189
x x y y
q4
q4
y y, R
a a, R
y y, R
q3
, L
y y, R
q0
a x, R
q1
y y, R
q3
q4
, L
y y, R
q0
a x, R
q1
y y, L
a a, L
x x, R
b y, L
x x, R
If we modify the TM
for the Context-Free Language
b y, L
y y, L
a a, L
y y, R
a a, R
q2
52/189
Observation:
50/189
q3
y y, R
a a, R
a x, R
q2
x x y y
q4
b y, L
x x, R
q3
y y, R
y y, L
a a, L
y y, R
a a, R
a x, R
49/189
q4
y y, R
{a b }
q2
53/189
54/189
TM Accepting anbncn, n1
a/a, R ; y/y, R
a/x, R
b/b, R ; z/z, R
b/y, R
q0
q1
z/z, L ; b/b, L
y/y, L ; a/a, L
c/z, L
q2
q3
x/x, R
y/y, R
z/z, R
#/#, L
q4
y/y, R
q5
Idea:
Idea: Finding
Finding matching
matching
a,b,c
a,b,c and
and replacing
replacing by
by x,y,z
x,y,z
q6
z/z, R
Algorithm
input abc:
q0abc xq1bc xyq2c xq3yz q3xyz xq0yz xyq4z xyzq5B xyzBq6B
input a2b2c2:
q0 a2b2c2 xaq1b2c2 xayq2bc2 xaybq2c2 xayq3bzc xaq3ybzc
xq3aybzc q3xaybzc xq0aybzc xxq1ybzc xxyyq2zc xxyyq3zz
xq3xyyzz xxq0yyzz xxyyq4zz xxyyzzq5B xxyyzzBq6B
55/189
Begin
While Cha g
gp x
x Do
Gp a, ghi x
x ; Do qua R
R While Cha g
gp b
b Od
Gp b, ghi y
y ; Do qua R
R While Cha g
gp c
c Od
Gp c, ghi z
z ; Do qua L
L While Cha g
gp x
x Od
Qua R
R
Od
Do Qua R
R While Gp y
y Od
b/b, R, z/z, R z/z, L, b/b, L
a/a, R, y/y, R
y/y, L, a/a, L
Do Qua R
R While Gp z
z Od
a/x, R
b/y, R
c/z, L
If
Gp #
#
q0
q1
q2
q3
Then Qua L, Yes
Yes
x/x, R
No
Else
No
y/y, R
Fi
z/z, R
End
q4
#/#, L
q5
y/y, R
q6
56/189
z/z, R
Transition Function
A Move to right:
Formal Definitions
for
Turing Machines
q1
a b, R
q2
(q1, a ) = (q2 , b, R)
A Move to left:
q1
c d, L
q2
(q1, c) = (q2 , d , L)
58/189
Turing Machine:
States
Input
alphabet
Configuration
Tape
alphabet
c a b a
q1
M = (Q, , , , q0 , , F )
Instantaneous description:
Transition
function
Initial
state
Set of
Final states
ca q1 ba
blank
59/189
60/189
10
Transition
Time i
Transition process
Time i+1
x a y b
x a y b
q2
q0
A Move:
Time 1
x a y b
Time 2
x a y b
q2
q0
Time 3
x x y b
q2 xayb x q0 ayb
Time 4
x x y b
q1
q1
q2 xayb
x q0
ayb
xx q1
yb
xxy q1 b
61/189
62/189
Transition process
Notation
Input string
Equivalent notation:
q2 xayb
q0 w
Initial configuration:
a a b b
xxy q1 b
q0
63/189
TM computes palindromes
L( M)
| q0
nh du con a
mt tri nht
x1 q f x2 }
Initial state
q3
#|#, R
#|#, R
Vt qua tri
q4
Gp # qua phi
b|#, L
q5
qf F
Odd palindrome
a|#, L
b|#, R
Final state
#|#, L
q6
a|a, L
b|b, L
q7
#|#, R
Odd palindrome
a|a, R
b|b, R
#|#, R
Even palindrome
65/189
# | #, L
q2
a|#, R
q1
nh du con a
mt phi nht
a|a, R
b|b, R Gp # li li
Vt qua phi
={w
64/189
Ex1: w=abbbba?
Ex2: Draw M: L(M)=w#w for = {a, b, c} ?
66/189
11
Definitions
The
languages accepted by TM
are called Recursively Enumerable (lit k quy)
Recursion is related to recursion in programs
Enumerable means there is some TM that can enumerate the strings in the
language
Deterministic
Infinite tape in both directions
We'll
67/189
68/189
Notation
f ( w)
A function
Domain:
Computing Functions
with
Turing Machines
w D
has:
Result Region:
f (w)
f ( w) R
Data representation
Integer Domain
A function may have many parameters
The number of parameters is called arity
Example:
Addition function
f ( x, y ) = x + y
Thp phn
Binary:
101
Nh phn
Unary:
11111
n phn
with 2-arity
Decimal:
72/189
12
In other words:
Definition:
f
A function
is computable if
there is a Turing Machine M such that:
Initial configuration
For all
q f final state
w D
q f f ( w)
f (w)
q0 initial state
q0 w
Final configuration
f
A function
is computable if
there is a Turing Machine M such that:
Initial
Configuration
Final
Configuration
For all
Domain
w D
Domain
73/189
74/189
Example
The function
Input representation
f ( x, y ) = x + y is computable
x, y
are integers
Start
1 1
1 0 1 L 1
initial state q0
Turing Machine:
Input string:
x0 y
unary
Output string:
xy 0
unary
76/189
Computing Function
y
x
Start
1 1
Computing Function
1 0 1 L 1
q0 initial state
x+ y
x+ y
Finish
1 1
1 1 0
q f final state
Finish
1 1
1 1 0
q f final state
77/189
78/189
13
f ( x, y ) = x + y
1 1, R
1 1, R
x = 11 (2)
y = 11 (2)
1 1, L
Time 0
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
x+ y
1 1 0 1 1
q4
79/189
80/189
1 1 0 1 1
Time 1
1 1 0 1 1
q0
q0
1 1, R
1 1 1 1 0
q0
Exercice:
Time 0
Final Result
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
, R
q4
81/189
1 1 0 1 1
Time 3
1 1 1 1 1
q0
1 1, R
82/189
q1
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
83/189
, R
q4
84/189
14
1 1 1 1 1
Time 5
1 1 1 1 1
q1
q1
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
, R
q4
85/189
1 1 1 1 1
Time 7
1 1 1 1 0
q2
1 1, R
1 1, R
q3
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
, R
q4
87/189
88/189
1 1 1 1 0
Time 9
1 1 1 1 0
q3
1 1, R
86/189
q3
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
89/189
, R
q4
90/189
15
1 1 1 1 0
Time 11
q3
1 1, R
1 1 1 1 0
q3
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
1 1, R
1 1, R
1 1, L
q0 0 1, R q1 , L q2 1 0, L q3
, R
q4
91/189
, R
q4
1 1 1 1 0
f ( x) = 2 x
q4
1 1, R
1 1, R
1 1, L
Output string:
1 1
q4
unary
xx
unary
94/189
(2)
A
A Tip!
Tip!
Repeat:
Find rightmost $, replace it with 1
2x
1 1
is integer
93/189
q0 initial state
Finish
is computable
, R
x
Start
(1)
Turing Machine:
Input string:
q0 0 1, R q1 , L q2 1 0, L q3
92/189
1 1 1
q f final state
95/189
96/189
16
TM compute succ(n)
Finish
Start
1 1 1 1
1 1
q0
q3
1 $, R
1 1, L
1 1, R
q 0 , L q1 $ 1, R
1.
1.Replace
Replaceevery
every11with
with$$
2.
2.Repeat:
Repeat:
Find
Findrightmost
rightmost$,
$,
replace
replaceititwith
with11
Go
to
Go toright
rightend,
end,insert
insert11
3.
3.Until
Untilno
nomore
more$$remain
remain
, R
q3
q2
0|1, L
q1
1, L
q3
#|1, L
97/189
0|0, R
#|1, R
Find a 1|1, R
X|X, L
X|X, R
q1
a|X, L
q0
0|1, R
#|#, L
98/189
Another Example
The function is
computable
1|0, L
if
x> y
if
x y
q3
x0 y
Input:
0|0, R
X|#, L
f ( x, y ) =
Increment 1
1|1, R
q2
Input string:
#aaaaaa#
Output string? #110###
Exercice:
Exercice:Draw
DrawTM
TM for
for Inverse?
Inverse?
Output:
or
99/189
100/189
Match a 1 from
Until all of
q2
0|0, R
Erase X
#|#, L
or
x with a 1 from y
y
is matched
( x > y)
( x y)
101/189
wi , $
q1
y | y, L
$ | $, R
$
q2
q3
x | x, L
x
q4
102/189
17
##
0#
P = { q1, 0
q1, 1
q(0), 0
1#
q(0), 1
q(1), 0
q(1), 1
q(0), #
q(1), #
1 | 0, R Restore 0,
#
q(#), 0
to the right q(#), 1
}
0 | #, R
Or
# 1
##
0 | 0, R
Remember 0
0 | #, R
q1
q(0)
0 | 1, R
#, R, q(0),
#, R, q(1),
0, R, q(0),
0, R, q(1),
1, R, q(0),
1, R, q(1),
0, R, q(#),
1, R, q(#),
#, R, q(0),
#, R, q(1)
0 | 0, R
1 | a, R
Remember 1
b | b, R
a | 1, R
b | b, L
b | 0, R
b | b, L
0 | b, R
# | #, L
q(1)
# | 1, R
q3
q1
# | 1, R
1 | #, R
b | b, R
# | 0, L
q4
q5
q6
Restore 1
1 | 1, L
0 | 0, R
1 | 1, R
103/189
1 | 1, R
1 | 1, L
# | 1, L
q2
q#
1 | 0, R
0 | 0, L
1 | 1, R
w w#wRR?
0 | 0, L
104/189
Block Diagram
Turing
Machine
output
106/189
Example:
f ( x, y ) =
x + y if x > y
0
x, y
x, y
Comparer
if x y
Turings Thesis
Adder
x+ y
Eraser
x> y
x y
107/189
18
Turings thesis*:
Any computation carried out
by mechanical means
can be performed by a Turing Machine
(1930)
A computation is mechanical
if and only if
it can be performed by a Turing Machine
Thesis:
Thesis: AA Accepted
Accepted Statement
Statement but
but not
not Demontration
Demontration
109/189
Definition of Algorithm:
110/189
When we say:
There exists an algorithm
We mean:
There exists a Turing Machine
that executes the algorithm
111/189
112/189
aababbcac a
Variations
of the Turing Machine
Read-Write Head
(Left or Right)
Control Unit
Deterministic
114/189
19
We want to prove:
(or Equivalence)
power
116/189
Notion
Demonstration
M1 of first class
there is a machine M 2 of second class
L( M1 ) = L( M 2 )
And vice-versa
First Class
Original Machine
M1
Second Class
Simulation Machine
M2
M1
117/189
Correspondence of the
configurations
Correspondence of the
configurations
Simulation Machine:
d 0 d1
d 0 d1 L
118/189
dn
d n
119/189
Final Configuration
Original Machine:
df
Simulation Machine:
d f
20
Example:
aababbcac a
Time 1
aababbcac a
q1
Time 2
b ab abb c ac a
L,R,S: moves
q2
121/189
Theorem:
q1 a b, S
q2
Proof of Part 1 :
Part 1: Stay-Option Machines
are at least as powerful as
Standard machines
Stay-Option Machines
have the same power with
Standard Turing machines
Proof of Part 2 :
Stay-Option Machine
q1
125/189
124/189
Proof:
122/189
a b, L
q2
q1 a b, L
q2
126/189
21
Example
q1
a b, S
Stay-Option Machine:
q1 a b, S q2
q2
q1
q2
x x, R
baba
q2
q3
aaba
x
127/189
baba
baba
q3
q2
q1
a b a b
b a c d
track 1
track 2
q1
track 1
track 2
a c a b
b d c d
one symbol
track 1
track 2
q2
q1
(b, a ) (c, d ), L
q2
129/189
# a b a c
128/189
a b a b
b a c d
aaba
q1
a b, L
130/189
...
Trivial
131/189
132/189
22
Standard machine
.........
.........
a b c d e
reference point
Right part # d e
Left part
# c b a
.........
133/189
134/189
Standard machine
Standard machine
q2
q1
Right part
q2L
q1L
q2R
q1R
Right part
q1R
Left part
q1L
Standard machine
a b c d e
( x, a ) ( x, g ), L
q2R
q2L
136/189
.........
Time 2
.........
Standard machine
g b c d e
q1
.........
q2
Semi-infinite tape machine
(a, x) ( g , x), R
135/189
Time 1
.........
q2
a g, R
q1
c
a
b
#
.........
q1L
137/189
Right part # d e
Left part
g
c
b
#
q2L
.........
138/189
23
At the border:
Left part
q1R
q1L
(# , # ) (# , # ), R
(# , # ) (# , # ), R
Time 1
Right part # d e
# c b g
Left part
q1L
.........
q1L
q1R
Time 2
Right part # d e
# c b g
Left part
q1R
139/189
Theorem:
.........
140/189
Input File
a b c
read-only
Control Unit
read-write
Tape
g d e
141/189
142/189
Standard machine
a b c
Off-line machine:
Off-line machine
Input File
2. Continue computation as in
Standard Turing machine
a b c
143/189
Tape
a b c
144/189
24
Standard machine
a b c
q1
Off-line machine
Tape
Input File
a b c
a b c
q1
145/189
Reference point
Off-line Machine
Tape
Input File
e f g
a b c d
# a b
# 0 0
e f
0 1
c d
1 0
g
0
146/189
Input File
head position
Tape
head position
147/189
# a b
# 0 0
e f
0 1
Input File
head position
Tape
head position
c d
1 0
g
0
148/189
Theorem:
Off-line Machines
have the same power with
Stansard Machines
Tape 1
a b c
Tape 2
e f g
Input
149/189
150/189
25
Multitape Standard
Time 1
Tape 2
e f g
q1
a b c
q1
Time 2
a g c
q2
q1
e d g
q2
(b, f ) ( g , d ), L, R
q2
151/189
152/189
Standard Multitape
Multitape Machine
Tape 1
Tape 2
e f g h
a b c
Standard machine:
Standard machine with four track tape
a
0
e
0
b
1
f
0
c
0
g h
1 0
Tape 1
head position
Tape 2
head position
153/189
Reference point
#
#
#
#
a
0
e
0
b
1
f
0
c
0
g h
1 0
154/189
Theorem:
Tape 1
head position
Tape 2
head position
155/189
Multi-tape machines
have the same power with
Standard Turing Machines
156/189
26
L = {a nb n }
Standard machine:
L = {a nb n }
Acceptance Time
Standard machine
Two-tape machine
n2
times
Two-tape machine:
b n to tape 2
n
Leave a on tape 1
( n steps)
( n steps)
Copy
( n steps)
157/189
158/189
y
Multidimensional machines simulate
Standard machines:
c a
MOVES: L,R,U,D
U: up
D: down
x
Use one dimension
HEAD
Position: +2, -1
159/189
160/189
Two-dimensional machine
y
Standard machines simulate
Multidimensional machines:
c
a
Standard machine:
Use a two track tape
Standard Machine
x
q1
c
symbols
a
b
1
1
2
1
#
#
#
#
coordinates
1
q1
162/189
27
Standard machine:
Theorem:
MultiDimensional Machines
have the same power
with Standard Turing Machines
163/189
164/189
Nondeterministic choices
a b, L
q2
a b, L
a c, R
q3
Choice 1
b b c
q2
Time 0
a b c
q1
q1
a c, R
q2
q3
Time 1
q1
Choice 2
c b c
q3
166/189
Notion
Input string w is accepted if
this a possible computation
q0 w
Initial configuration
x qf y
Final Configuration
Final state
167/189
168/189
28
Non-Deterministic Choices
Computation 1
Computation 2
q1
q1
q4
q5
q4
q6
169/189
q3
q2
q3
q2
Deterministic machine:
q5
q6
q7
q7
170/189
Simulation
a b, L
Deterministic machine:
q2
NonDeterministic machine
Time 0
q1
a b c
a c, R
q3
q1
Deterministic machine
Stores computations in a
two-dimensional tape
#
#
#
#
# # #
a b c
q1
# # #
# #
#
#
#
Computation 1
171/189
172/189
NonDeterministic machine
a b, L
Time 1
q2
b b c
Choice 1
c b c
q3
Choice 2
q2
q1
a c, R
#
#
#
#
q3
Deterministic machine
# # # # # #
b b c #
Computation 1
q2
#
c b c #
Computation 2
q3
#
173/189
Repeat
Execute a step in each computation:
If there are two or more choices
in current computation:
1. Replicate configuration
2. Change the state in the replica
174/189
29
Remark:
The simulation
in the Deterministic machine
takes time exponential time compared
to the NonDeterministic machine
175/189
176/189
Description of transitions of M
Tape 1
Description of M
Universal
Turing
Machine
Tape 2
Tape contents of M
Tape 3
State of M
179/189
Three tapes
180/189
30
Encoding in Tape 1
Encoding in Tape 1
Tape 1
Tape 1
Description of M
Description of M
We encode
Alphabet Encoding
Symbols:
Encoding:
State Encoding
M as a string of symbols
11
111
1111
States:
q1
q2
q3
q4
Encoding:
11
111
1111
181/189
182/189
Encoding in Tape 1
Encoding in Tape 1
Tape 1
Tape 1
Description of M
Description of M
Move:
Encoding:
11
Transition Encoding
Transition:
(q1, a) = (q2 , b, L)
Encoding:
1 0 1 0 11 0 11 0 1
Using 0 for Separator
183/189
184/189
Encoding in Tape 1
Tape 1
Tape
Description of M
Transitions:
(q1, a) = (q2 , b, L)
1 contents of Universal TM M:
Machine Encoding
TM is described
with a binary string of 0s and 1s
(q2 , b) = (q3 , c, R)
Encoding:
1 0 1 0 11 0 11 0 1 00 11 0 1 10 111 0 111 0 11
Using 00 for Transition Separator
185/189
186/189
31
Can
Can
Theorem:
TM 1,
TM 2,
...
187/189
188/189
Proof
The idea is to use a multitape TM M
to perform simulation:
Tape
1:
keeps program
# and *, i.e.,
Tape
Tape
Tape
#0*r0#1*r1#10*r2##i*ri#
189/189
32