Lecture 9 2010 SDU Lecture9: Turing Machine. 2010 SDU 2 Historical Note Proposed by Alan Turing in...
-
Upload
clinton-patrick-walker -
Category
Documents
-
view
215 -
download
0
description
Transcript of Lecture 9 2010 SDU Lecture9: Turing Machine. 2010 SDU 2 Historical Note Proposed by Alan Turing in...
Lecture 9 2010 SDU
Lecture9: Turing Machine
2010 SDU 2
Historical Note
Proposed by Alan Turing in 1936 in:
On Computable Numbers, with an application to the Entscheidungsproblem, Proc. Lond.
Math. Soc. (2) 42 pp 230-265 (1936-7); correction ibid. 43, pp 544-546 (1937).
2010 SDU 3
Turing Machine (TM)
. . .
Finite State
control
Bi-directionRead/Write
2010 SDU 4
Turing Machines
A Turing Machine is a step-wise computing device, which consists of
1. An infinitely long tape that is divided into tape squares (or tape cells)
2. A head that scans (is positioned at) a particular tape square at each time step, and
3. A finite control that maintains the current state.
2010 SDU 5
Turing Machines (cont.)
Each combination of a state and a scanned tape symbol determinesthe next state, the symbol written on the scanned square, and the move (L or R) of the tape head
a c b b c c
q2
tape
headfinite control
q pa b, L At state q, if the scanned symbol is a,
then go to state p, write b on the scannedsquare, and move the head to the left
2010 SDU 6
Computation of a Turing Machine (cont.)
.At the beginning:1. The tape contains the input on the leftmost squares,2. The rest of the tape is filled with blank symbols,3. The head is at the leftmost cell, and4. The state is q0
The Turing machine halts when it enters qaccept or qreject, and in these states it accepts or rejects, respectively
2010 SDU 7
Turing Machines (cont.)
A Turing machine is a 7-tuple(Q, , , , q0, qaccept, qreject), where Q, , are finite sets,1. Q is a set of states,2. is the input alphabet,3. is the tape alphabet, where -{} and is the special
blank symbol to indicate the untouched tape area4. : (Q-{qaccept, qreject}) Q{L, R} is the transition
function, //TM is a deterministic machine5. q0 is the start state,
6. qaccept is the accept state, and
7. qreject is the reject state that is different from qaccept.
They are called halting states
2010 SDU 8
Configurations
a c b b c c
q2
tapehead
finite control
A configuration of a Turing machine consists of the contents of its tape, the head position, and the state. If the tape contents are a1,…,am, …, the head is located on the kth square, and the state is q, then we write a1…ak-1qak…am to denote the configuration. The segment of blanks filling the tape is omitted but at least one symbol (possibly ) is required after the state.
In the above, the configuration is acbbccq2
2010 SDU 9
Configurations (cont.)The action of a TM can be viewed as rewriting of the configurations.A configuration C1 yields C2 if the Turing machine can go from C1
to C2 in a single step. uaqibv yields uqjacv if (qi, b) = (qj, c, L) qibv yields qjcv if (qi, b) = (qj, c, L) uqibv yields ucqjv’ if (qi, b) = (qj, c, R), where v’ is v if |v| > 0 and if
|v| = 0The start configuration of M on w is q0w.
An accept configuration (A reject configuration) is one in which the state is qaccept (qreject). Accept configurations and reject configurations are halting configurations.
Note! A TM may never halt on an specified input!How about DFA, NFA, PDA?
2010 SDU 10
The languages of Turing MachinesA Turing machine M accepts (rejects) a string w if it eventually enters an accept (a reject) state for input w, i.e.: there is a sequence of configurations C1, C2, …, Cm, such that: C1 is the start configuration of M on w; each Ci can yield Ci+1; Cm is an accept configuration.
The language recognized by a Turing machine M is defined as the collection of all the strings accepted by the Turing machine.
A Turing machine M decides a language L, if M recognizes L and halts on all inputs, and M is called a decider. We prefer deciders.
A language is Turing-recognizable if there is a Turing machine that recognizes it.
A language is Turing-decidable (or simply decidable) if there is a Turing machine that decides it.
2010 SDU 11
Example of TMA TM for recognizing (better deciding )L={w#w | w {0,1}*}
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
All unspecified transitionsgo to a reject state.
={0, 1, #}; ={0, 1, #, , x}
a L (R) means a a , L(R)a, b L (R) means a L (R) and b L (R)
2010 SDU 12
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
0 1 0 # 0 01
2010 SDU 13
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # 0 01
2010 SDU 14
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # 0 01
2010 SDU 15
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # 0 01
2010 SDU 16
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # 0 01
2010 SDU 17
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # x 01
2010 SDU 18
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # x 01
2010 SDU 19
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # x 01
2010 SDU 20
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # x 01
2010 SDU 21
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x 1 0 # x 01
2010 SDU 22
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 01
2010 SDU 23
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 01
2010 SDU 24
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 01
2010 SDU 25
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 01
2010 SDU 26
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 0x
2010 SDU 27
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 0x
2010 SDU 28
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 0x
2010 SDU 29
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 0x
2010 SDU 30
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x 0 # x 0x
2010 SDU 31
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x 0x
2010 SDU 32
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x 0x
2010 SDU 33
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x 0x
2010 SDU 34
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x 0x
2010 SDU 35
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 36
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 37
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 38
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 39
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 40
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 41
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 42
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 43
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
2010 SDU 44
How a TM works
q0
r1p1
p2
q2
q1
qA
q3
r2
#R
xR
R
1x,R0,1R
#R
xR
1x,L
0x,R
0,1R
#R
xR
0x,L
0,1,xL
#L
0,1LxR
x x x # x xx
Accept
2004 SDU 45
An implementary description
M=“on input string w1. Zig-zag across the tape to corresponding positions on either side of
the # symbol to check on whether these positions contain the same symbol. If they do not, reject. Cross off symbols as they are checked to keep track of which symbols correspond.
2. When all symbols to the left of the # have been crossed off, check for any remaining symbols to the right of the #. If any symbols remain, reject; otherwise accept.”
– Note: For most TMs, we prefer high-level descriptions to exact description of the 7 components because going to that level of detail can be cumbersome for most TMs but tiniest ones.
2004 SDU 46
Example of TM for {0n1n2n | n > 0}
q0
q5q4
q3
q1
0x,R
xR
yR
yRzR
L
0RyRAll unspecified transitions
go to a reject state.
q2
1y,R
1RzR
2z, L
={0, 1}; ={0, 1, , x, y, z}
0L1LyLzL
2004 SDU 47
An implementary description
M = “On input string w:1. Zig-zag across the tape to corresponding positions to check
on whether these positions contain a 0, 1, and 2 respectively. If they do not, reject. Cross off symbols as they are checked to keep track of which symbols correspond.
2. When all the 0’s have been crossed off, check for any remaining 1’s or 2’s. If any such symbols remain, reject; otherwise accept.”
Designing TM: Example 3
start q1
R
+ R = R q2
- L q9
R
+ LL = L x L - L
q3
# L
q4
xR+R
# R
x,R q5
= R
q7= R
x,R
q6 accept
xR
- R
R +R
xR
Design a TM that decides {#n +m = k | n+m=k}
q0# R
R
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L
a1
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an
xn $,L
…
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
Yes
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an
$ xn,L
xn $,L
…
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
x3 x7
Beg?
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
$ x7
a3
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
x3 x7
Yes
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
x3 x7
Beg?
x9
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
$ x7
a3
x9
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
$ x7
b3
x9
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
x3 x7
Temp
x9
Testing whether the head is at the beginning of the tape
Tape alphabet: {x1,…,xn} Add a new tape symbol: $
1. Read the current symbol, remember it, type $, and move left;2. Read the current symbol. If it is $, restore the remembered symbol and go to “Yes”. If it is not $, move right, restore the remembered symbol and go to “No”.
Beg?
x1 $,L$ x1,L
a1
x1,…,xn R
Yes
x1,R
L No
b1
Temp
Design a fragment of a TM that, from a state “Beg?”, goes to a state “Yes” or “No”, depending on whether you are at the beginning of the tape or not, without corrupting the contents of the tape.
an x1,…,xn R bn
$ xn,L
xn $,L
xn,R
…
x3 x7
No
x9
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
Shift
Shifting tape contents
Shift Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.
- 0,RShift
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. Read the current symbol, remember it, type 0 and move right.
- 0,RShift
1. If the current symbol is blank, type 0 and you are done.
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.
00,R Remembered 0
Remembered 110,R
- 0,RShift
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the previously remembered symbol and move right.
Remembered 0
Remembered 1
00,R
10,R
- 0,RShift
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the previously remembered symbol and move right.
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift
Shifting tape contents
Done
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
Shifting tape contents
1 0
1 1 -
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Done
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
Shifting tape contents
0 0
1 1 -
Done
Remembered 000,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
Remembered 111,R
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Shifting tape contents
0 1
1 1 -
Done
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Shifting tape contents
0 1
1 0 -
Done
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.
Shifting tape contents
0 1
1 0 1
Done
Remembered 0
Remembered 111,R
00,R
01,R 10,R
00,R
10,R
- 0,RShift Done
- 1,R
- 0,R
1. If the current symbol is blank, type 0 and you are done.2. Read the current symbol, remember it, type 0 and move right.3. While the current symbol is not -, remember it, type the the previously remembered symbol and move right.• Once you see a blank, type the remembered symbol and you are done.
Design a fragment of a TM that, beginning from the current cell, shifts the contents of the tape right, typing in the current cell a 0. Assume the tape alphabet is {0,1,-}.