Turing Machine 1
Turing Machine 1
Data structures
FSM : only Input string, control, limited power
PDA : Input string, stack, remember, more powerful, CFL
TM : Tape, sequence of infinite symbols, tape head, pointer read
write head
Alan Turing in 1936 gave various models using the concept of
Turing machines.
δ(q , X) = (p ,Y ,R/L)
Block Diagram
• Each cell can store only one symbol.
• The input to and the output from the finite state automaton are
effected by the R/W head which can examine one cell at a time.
• In one move, the machine examines the present symbol under
the R/W head on the tape
• The present state of an automaton to determine
(i) a new symbol to be written on the tape in the cell under the
R/W head,
(ii) a motion of the R/W head along the tape: either the head
moves one cell left (L). or one cell right (R),
(iii) the next state of the automaton, and
(iv) whether to halt or not.
Design a TM that accepts {0n1n | n>=1}.
Solution
Step 1 q0 is the initial state. The RJW head scans the leftmost a , replaces a by x, and moves to the right. M
enters q1
Step 2 On scanning the leftmost b, the RJW head replaces b by y and moves to the right. M enters q2
Step 3 On scanning the leftmost c. the RJW head replaces c by z, and moves to the right. M enters q3
Step 4 After scanning the rightmost c, the RJW heads moves to the left until it finds the leftmost a
Step 5 Steps 1-4 are repeated until all a’s, b's and c's are replaced by x,y,z respectively
q0aabbcc |-xxyq1bzc
|-xq1abbcc |-xxyyq2zc |-xxyyq4zz
|-xaq1bbcc |-xxyyzq2c |-xxyyzq5z
|-xayq2bcc |-xxyyq3zz |-xxyyzzq5
|-xaybq2cc |-xxyq3yzz |-xxyyzzqf
|-xayq3bzc |-xxq3yyzz
|-xaq3ybzc |-xq3xyyzz
|-xq3aybzc |-xxq0yyzz
|-q3xaybzc |-xxyq4yzz
|-xq0aybzc
|-xxq1ybzc
δ (q0,a)=(q1, x, R)
δ (q1,a)=(q1, a, R)
δ (q1,b) =(q2, y, R)
δ (q2,b) =(q2, b, R)
δ (q2,c) =(q3, z, L)
δ (q3,b) =(q3, b, L)
δ (q3,y) =(q3, y, L)
δ (q3,a) =(q3, a, L)
δ (q3,x) =(q0, x, R)
δ (q1,y) =(q1, y, R)
δ (q2,z) =(q2, z, R)
δ (q3,z) |-(q3, z, L)
δ (q0,y) |-(q4, y, R)
δ (q4,z) |-(q5, z, R)
δ (q5, □) |-(qf, □, R)