Unit V (TM) - Part1n
Unit V (TM) - Part1n
Context-sensitive
Context-free
Regular
2
A TM accepts a language if it enters into a final state
for any input string w.
………. B B 0 1 1 0 0 B B
Finite
Control
q0 a, X, L q1
Note: Here Γ– {B} means subset of tau excluding Blank
Rules for Constructing/computing Operations in Turing Machine:
Transition Table
a
q0 q1,X,R
Example :Construct TM for L= {0n1n|n>=1}
Solution: The set of strings generated from the above language L={ 01,0011,000111,……..}
Let us construct Turing Machine for string 0011
B X X Y Y B
Control
unit
0,0,R 0,0,L
Y,Y,R Y,Y,L
0,X,R 1,Y,L
qq0 qq1 qq2
X,X,R
Y,Y,R Y,Y,R
qq3 B,B,R
qqf
Example :Construct TM for L= {0n1n|n>=1}
Solution: The set of strings generated from the above language L={ 01,0011,000111,……..}
Let us construct Turing Machine for string 0011
B 0 0 1 1 B
0,0,R 0,0,L
Y,Y,R Y,Y,L
0,X,R 1,Y,L
qq2
qq0 qq1
X,X,R
Y,Y,R Y,Y,R
qq3 qqf
B,B,R
δ(q0,0) -> (q1, X,R)
δ(q1,0) -> (q1, 0,R)
Transition function of above Turing Machine: δ(q1,1) -> (q2, Y,L)
δ(q2,0) -> (q2, 0,L)
δ(q1,Y) -> (q1, Y,R)
δ(q2,Y) -> (q2, Y,L)
δ(q2,X) -> (q0, X,R)
δ(q0,Y) -> (q3, Y,R)
δ(q3,Y) -> (q3, Y,R)
δ(q3,B) -> (qf, B,R)
Transition function table of TM for above language
State 0 1 X Y B
q0 q1,X,R q3,Y,R
q3 q3,Y,R qf,B,R
qf Halt &
Accept
0,0,R 0,0,L
Y,Y,R Y,Y,L
B 0 0 1 1 B
0,X,R 1,Y,L
qq2
qq0 qq1
X,X,R
Y,Y,R Y,Y,R
qq3 qqf
B,B,R
B B B 1 1 1 1 1 1 1 B B B
1,1,R
1,1,R
HALT
B,1,R B,B,L 1,B,R
qq1
qq0 qq2 qq3
Instantaneous description for the string 0011 on above turing machine
q00011⊢Xq1011 ⊢X0q111 ⊢Xq20Y1 ⊢q2X0Y1 ⊢Xq00Y1 ⊢XXq1Y1 ⊢XXYq11⊢XXq2YY
⊢Xq2XYY ⊢XXq0YY ⊢XXYq3Y ⊢XXYYq3 ⊢XXYYBqf Halt and accepted by final state
Explanation: Step1: q00011 means initially , TM takes string 0011 at state q0.
Step2: Xq1011 means reader reads 0 from tape and updates with X and move to right of X.
state changes to q1. (Note: X,0,R in transition diagram)
Step3: X0q111 means reader reads 0 from tape and makes no updating and remains on q1
and moves right of 0 . (Note: 0,0,R in transition diagram)
Step4: Xq20Y1 means reader reads 1 from tape and updates with Y and moves to left of
0.state changes to q2. (Note: Y,1,L in transition diagram)
Step5: q2X0Y1 means reader reads 0 on q2 and makes no updating and reader moves to left
of X and state remains to q2. (Note: 0,0,L in transition diagram)
Step6: Xq00Y1 means reader reads X from tape and makes no updating and moves to right
of X. state changes to q0. (Note: X,X,R in transition diagram)
Step7: XXq1Y1 means reader reads 0 from tape at q0 and updates with X and moves to right
of X. State changes to q1. (Note: 0,X,R in transition diagram)
Step8: XXYq11 means reader reads Y from tape at q1 and makes no updating and moves to
right of Y. state remains to q1. (Note: Y,Y,R in transition diagram)
Step9: XXq2YY means reader reads symbol 1 from tape at state q1 and updates with Y and
reader moves to left of Y symbol and state changes to q2. (Note: 1,Y,L in transition diagram)
Step10: Xq2XYY means reader reads symbol Y from tape and makes no updating and
reader moves to left of X symbol and state remains to q2. (Note: Y,Y,L in transition diagram)
Step11: XXq0YY means reader reads symbol X on state q2 and makes no updating and
reader moves to right of X. State changes to q0. (Note: X,X,R in transition diagram)
Step12: XXYq3Y means reader reads Y on q0 and makes no updating and moves to right
of Y. State changes to q3. (Note: Y,Y,R in transition diagram)
Step13: XXYYq3 means reader reads Y on q3 and makes no updating and moves to right
of Y. State remains to q3. (Note: Y,Y,R in transition diagram)
Step14: XXYYBqf means reader reads B (Blank cell) on q3 and updates with B and moves
to right of B. State changes to qf. Now processing halt and given string is accepted at final
state qf. (Note: B,B,R in transition diagram)
Practice Q:
1. Construct Turing machine and write Instantaneous description for L={aⁿbⁿcⁿ|n>=1}
2. Construct Turing machine and write Instantaneous description for L={wcw|w ∈(a,b)*}
3. Construct Turing machine and write Instantaneous description for L={wwR|w ∈(a,b)*}
TM as computer of integer functions
1. TM as adder
2. TM as substractor
3. TM as multiplication
4. TM as unary to
binary converter
X Y
1 11 1
2 1 111
3 10 0
HALTING PROBLEM
w Halt
Program Not Halt
Dec-halt(P,I) Un-Dec-halt(dec-halt)
{ {
If P halts on I If (dec-halt(P,I) == halt)
return halts loop forever
else else
return loop return
} }
Note that it's not actually running the programs, it's looking at their code and deciding
based on the code structure.
This is the proof by contradiction