Академический Документы
Профессиональный Документы
Культура Документы
CS411-2014F-11
Turing Machines
David Galles
Department of Computer Science
University of San Francisco
11-0:
Turing Machines
11-1:
Turing Machines
abbcba
...
Read/write head
11-2:
Turing Machines
: (K H) 7 K ( {, })
11-3:
Turing Machines
11-4:
Turing Machines
q0
q1
q2
q3
X
(q1 , X) (n, 1)
(n, ) (n, X)
(q1 , ) (q1 , ) (q2 , ) (q1 , )
(n, 0)
(q3 , Z) (n, ) (n, X)
(q3 , ) (q3 , ) (n, ) (q0 , )
Z
(y, Z)
(q2 , )
(n, Z)
(q3 , )
11-5:
Turing Machines
q0
q1
q2
q3
(q1 , X) no
(q1 , ) (q1 , )
no
(q3 , Z)
(q3 , ) (q3 , )
no
no
yes
no
no
(q0 , ) (q3 , )
11-6:
Turing Machines
11-7:
Turing Machines
q0
(q1 , X)
no
no
no
no
(q4 , )
no
q1
(q1 , )
(q2 , Y )
no
no
(q1 , )
(q1 , )
no
q2
no
(q2 , ) (q3 , Z)
no
no
(q2 , )
(q2 , )
q3
(q3 , )
(q3 , ) (q3 , ) no
(q0 , )
(q3 , )
(q3 , )
q4
no
no
(q4 , )
(q4 , )
(q4 , )
no
yes
11-8:
Turing Machines
11-9:
Turing Machines
q0
q1
q2
q3
q4
q2
(q1 , X)
(q1 , )
(q3 , Z)
(q3 , )
(q4 , )
no
(q4 , X) yes
no
yes
(q1 , ) (q2 , ) (q1 , ) (q2 , )
no
no
(q3 , ) no
no
no
(q0 , ) (q3 , )
(q4 , ) (q5 , ) (q4 , ) (q5 , )
(q3 , Z) no
no
no
11-10:
11-11:
K = {s, h}
s=s
H = {h}
= {((s, b), (h, a)) : b
Writes an a on the tape, and then halts.
11-12:
K = {s, h}
s=s
H = {h}
= {((s, b), (h, )) : b
Moves the head to the left, and then halts.
11-13:
Connecting Diagrams:
a
M1
M2
M3
Run M1 until it halts, and then examine the symbol
under the read/write head
If the symbol is an a, execute M2 until it halts
If the symbol is a b, execute M3 until it halts
11-14:
Connecting Diagrams:
M1
M1
M2
a,b,c
M2
M1
M2
11-15:
Shorthand:
Ma = a
M = L
M = R
R R a = RRa = R2 a
R
R
x=
x=
11-16:
Shift-right machine
Convert w to w
11-17:
Shift-right machine
Convert w to w
x=
R L
x=
x=
RxLL
11-18:
Copy machine
Convert w to w w
11-19:
Copy machine
Convert w to w w
x=
R R xL L x
11-20:
Shift-left machine
Convert w to w
11-21:
Shift-left machine
Convert w to w
x=
x=
x=
LxRR
x=
11-22:
11-23:
M COPY
M LEFT-SHIFT
11-24:
Successor
Convert w (where w is the binary
representation of an integer) to v (where v is
the binary representation of (w + 1)
11011 11100
1111 10000
11-25:
Successor
Convert w (where w is the binary
representation of an integer) to v (where v is
the binary representation of (w + 1)
1L
R1R 0 L
11-26:
Predecessor
Convert w (where w is the binary
representation of an integer) to v (where v is
the binary representation of (w 1)
11100 11011
1111 10000
11-27:
Predecessor
Convert w (where w is the binary
representation of an integer) to v (where v is
the binary representation of (w 1)
0L
11-28:
Add
Convert w; v to w + v
(first, convert to 0 . . . 0; w + v )
11-29:
Add
Convert w; v to w + v
(first, convert to 0 . . . 0; w + v )
Result >= 0
M PRED
R ; M SUCC L
Result < 0
RL
11-30:
Add
Convert w; v to w + v
(first, convert to 0 . . . 0; w + v )
1L
0L
R;
L
;
R1R 0 L
RL (end computation)
11-31:
11-32:
R
;
L;
x=
;L RxR ;
(end computation)
11-33:
Add: Convert w; v to w + v
1L
0L
R;
L
;
R1R 0 L
;
R
;
L;
x=
;L RxR ;
(end computation)
11-34:
11-35:
yes
no
,0
0
R
0
11-36:
11-37:
11-38:
BL C R
B
L
R L
B.C
AL
done
11-39:
11-40:
11-41:
A
a
yes
BL C R
no
R
yes
,a
a
B,C
AL
11-42:
Non-Halting TMs
Ra
yes
11-43:
Deciding TM
11-44:
Semi-Deciding TM
11-45:
Semi-Deciding TM
RaR
a
yes
11-46:
Recursive Languages
L}
Is LREC closed under complementation?
That is, if L LREC , must L LREC ?
11-47:
Recursive Languages
L}
LREC is closed under complementation?
L LREC = L LREC (flip yes/no states)
11-48:
r.e. Languages
11-49:
r.e. Languages
11-50:
r.e. Languages