SlideShare a Scribd company logo
1 of 58
Turing Machines (TM)
Model of Computation
Rama Bansal Turing Machines 2
Outlines
• Structure of Turing machines
• Deterministic Turing machines (DTM)
– Accepting a language
– Computing a function
• Composite Turing machines
• Multitape Turing machines
• Nondeterministic Turing machines (NTM)
• Universal Turing machines (UTM)
Rama Bansal Turing Machines 3
Structure of TM
CONTROL
UNIT
TAPE
TAPE
HEAD
Finite set of states
Move left or right one
cell at a time
Store input for the TM
Can be of any length
Can read from and write on tape
Start state
A single halt state
Rama Bansal Turing Machines 4
What does a TM do?
• Determine if an input x is in a language.
– That is, answer if the answer of a problem P for
the instance x is “yes”.
• Compute a function
– Given an input x, what is f(x)?
Rama Bansal Turing Machines 5
How does a TM work?
• At the beginning,
–A TM is in the start state (initial state)
–its tape head points at the first cell
–The tape contains , following by input
string, and the rest of the tape contains
.
Rama Bansal Turing Machines 6
How does a TM work?
• For each move, a TM
– reads the symbol under its tape head
– According to the transition function on the
symbol read from the tape and its current state,
the TM:
• write a symbol on the tape
• move its tape head to the left or right one cell or not
• changes its state to the next state
Rama Bansal Turing Machines 7
When does a TM stop working?
• A TM stops working,
– when it gets into the special state called
halt state. (halts)
• The output of the TM is on the tape.
– when the tape head is on the leftmost cell
and is moved to the left. (hangs)
– when there is no next state. (hangs)
Rama Bansal Turing Machines 8
How to define deterministic TM (DTM)
• a quintuple (Q, , , , s), where
– the set of states Q is finite, not containing halt state h,
– the input alphabet  is a finite set of symbols not
including the blank symbol ,
– the tape alphabet  is a finite set of symbols containing ,
but not including the blank symbol ,
– the start state s is in Q, and
– the transition function  is a partial function from Q 
({})  Q{h}  ({})  {L, R, S}.
Rama Bansal Turing Machines 9
Example of a DTM
• M=
({s,p1,p2,p3,p4,q1,q2},
{0,1},{0,1,@}, , s} 1/,R
q2
h
q1
/1,L
@/,R
/,L
s
p1
p4 p2
p3
/@,R
0/,R
0/0,R
1/1,R
/,L
0/,L
0/0,L
1/1,L
/,R
Rama Bansal Turing Machines 10
How a DTM works
1/,R
q2
h
q1
/1,L
@/,R
/,L
s
p1
p4 p2
p3
/@,R
0/,R
0/0,R
1/1,R
/,L
0/,L
0/0,L
1/1,L
/,R
0 1 0 0 0 0 0 @    1
On the input 0001000,
the TM halts.
Rama Bansal Turing Machines 11
How a DTM works
1/,R
q2
h
q1
/1,L
@/,R
/,L
s
p1
p4 p2
p3
/@,R
0/,R
0/0,R
1/1,R
/,L
0/,L
0/0,L
1/1,L
/,R
0 0 0 0 0 0 0 @   
On the input 0000000,
the TM hangs.
Rama Bansal Turing Machines 12
Configuration
Definition
• Let T = (Q, , , , s) be a DTM.
A configuration of T is an element of
Q  {h}  ({}) ({}) ({})
• Can be written as
– (q,l,a,r) or
– (q,lar)
string to the right of tape head
symbol under tape head
string to the left of tape head
Current state
Rama Bansal Turing Machines 13
Yield the next configuration
Definition
• Let T = (Q, , , , s) be a DTM, and (q1, 1a11)
and (q2, 2a22) be two configurations of T.
We say (q1, 1a11) yields (q2, 2a22) in one step,
denoted by (q1, 1a11) T (q2, 2a22), if
– (q1, a1) = (q2,a2,s), 1=2 and 1=2,
– (q1, a1) = (q2,b,R), 2=1b and 1=a22,
– (q1, a1) = (q2,b,L), 1=2a2 and 2=b1.
Rama Bansal Turing Machines 14
Yield in zero step or more
Definition
• Let T=(Q, , , , s) be a DTM, and (q1, 1a11) and
(q2, 2a22) be two configurations of T.
We say (q1, 1a11) yields (q2, 1a22) in zero step or
more, denoted by (q1, 1a11) -*
T (q2, 1a22), if
– q1=q2, 1 =2, a1= a2, and 1= 2, or
– (q1,1a11)-T (q, a) and (q, a)-*
T (q2,1a22)
for some q in Q, and  in *, and a in .
Rama Bansal Turing Machines 15
Yield in zero step or more: Example
(s,0001000)
(p1,@0001000)
(p2,@001000)
(p2,@001000)
(p3,@001000)
(p4,@00100)
(p4,@00100)
(p1,@00100)
(p2,@0100)
(p2,@0100)
(p3,@0100)
1/,R
q2
h
q1
/1,L
@/,R
/,L
s
p1
p4 p2
p3
/@,R
0/,R
0/0,R
1/1,R
/,L
0/,L
0/0,L
1/1,L
/,R
(p4,@010)
(p4,@010)
(p1,@010)
(p2,@10)
(p2,@10)
(p2,@10)
(p3,@10)
(p4,@1)
(p4,@1)
(p1,@1)
(q1,@)
(q1,@)
(q2,)
(h ,1)
Rama Bansal Turing Machines 16
TM accepting a language
• Definition
Let T=(Q, , , , s) be a TM, and w*.
T accepts w if (s, , , w) |-T
* (h, , , 1).
The language accepted by a TM T, denoted
by L(T), is the set of strings accepted by T.
Rama Bansal Turing Machines 17
Example of language accepted by a TM
L(T)={0n10n | n0}
• T halts on 0n10n
• T hangs on 0n+110n at p3
• T hangs on 0n10n+1 at q1
• T hangs on 0n 12 0n at q1
1/,R
q2
h
q1
/1,L
@/,R
/,L
s
p1
p4 p2
p3
/@,R
0/,R
0/0,R
1/1,R
/,L
0/,L
0/0,L
1/1,L
/,R
Rama Bansal Turing Machines 18
TM computing a function
• Definition
Let T=(Q, , , , s) be a TM, and f be a
function from * to *.
T computes f if, for any string w in *,
(s, , , w) |-T
* (h, , , f(w)).
Rama Bansal Turing Machines 19
Example of TM Computing Function
p3p2
/1,R
s p1 p4
/,R /,L
1/1,R 1/1,R
1/1,L
/,R
h
1/,L
Rama Bansal Turing Machines 20
Example of TM Computing Function
1/1,L
0/0,L
p3p2
/1’,L
1/@,R
s p1
r2
/,R
0’/0,R
1’/1,R
/,L
/,S
0/0,R
1/1,R
q2 q1
r1
h
0’/0,R
1’/1,R
0/0,L
1/1,L
0’/0’,L
1’/1’,L
0/0,L
1/1,L
0’/0’,L
1’/1’,L
0/0,R
1/1,R/0’,L
0/@,R
@/1,R
@/0,R
Rama Bansal Turing Machines 21
Composite TM
• Let T1 and T2 be TM’s.
• T1  T2 means executing T1 until T1 halts
and then executing T2.
• T1 -a T2 means executing T1 until T1 halts
and if the symbol under the tape head when
T1 halts is a then executing T2.
Rama Bansal Turing Machines 22
Example of Composite TM
T0-0
Tout1
0
1
Terase1
Ts
0

/@,R
s h
q2 hq1
/1,L@/,R
/,L
1/,R
hs
p1 p4p2 p3
0/,R
0/0,R
1/1,R
/,L 0/,L
0/0,L
1/1,L
/,R
h
T0-0
Terase1
Ts
Tout1
1
Rama Bansal Turing Machines 23
Nondeterministic TM
• An NTM starts working and stops working
in the same way as a DTM.
• Each move of an NTM can be
nondeterministic.
Rama Bansal Turing Machines 24
Each Move in an NTM
• reads the symbol under its tape head
• According to the transition relation on the symbol
read from the tape and its current state, the TM
choose one move nondeterministically to:
– write a symbol on the tape
– move its tape head to the left or right one cell or not
– changes its state to the next state
Rama Bansal Turing Machines 25
How to define nondeterministic TM (NTM)
• a quintuple (Q, , , , s), where
– the set of states Q is finite, and does not contain halt
state h,
– the input alphabet  is a finite set of symbols, not
including the blank symbol ,
– the tape alphabet  is a finite set of symbols containing ,
but not including the blank symbol ,
– the start state s is in Q, and
– the transition fn :Q({})2Q{h}({}){L,R,S}.
Rama Bansal Turing Machines 26
Configuration of an NTM
Definition
• Let T = (Q, , , , s) be an TM.
A configuration of T is an element of Q     
• Can be written as
– (q,l,a,r) or
– (q,lar)
string to the right of tape head
string to the left of tape head
symbol under tape head
Rama Bansal Turing Machines 27
Yield the next configuration
Definition
• Let T = (Q, , , , s) be an NTM, and (q1, 1a11)
and (q2, 2a22) be two configurations of T.
We say (q1, 1a11) yields (q2, 2a22) in one step,
denoted by (q1, 1a11) T (q2, 2a22), if
– (q2,a2,S)  (q1, a1), 1=2 and 1=2,
– (q2,b,R)  (q1, a1), 2=1b and 1=a22,
– (q2,b,L)  (q1, a1), 1=2a2 and 2=b1.
Rama Bansal Turing Machines 28
NTM accepting a language/computing a function
• Definition
Let T = (Q, , , , s) be an NTM.
Let w* and f be a function from * to *.
T accepts w if (s, , , w) |-T
* (h, , , 1).
The language accepted by a TM T, denoted by L(T),
is the set of strings accepted by T.
T computes f if, for any string w in *, (s, , , w) |-T
*
(h, , , f(w)).
Rama Bansal Turing Machines 29
Example of NTM
• Let L={ww| w{0,1}*}
s
p u
q0 t0
r0
h
/@,R
0/0,L
1/1,L
0/0,L
1/1,L
/,L
0/0,R
1/1,R
/,R
q1 t1
r1
0/0,L
1/1,L
/,L 0/0,R
1/1,R
@/,Lv
0/0,R
1/1,R
/@,L
Rama Bansal Turing Machines 30
Multitape TM
• TM with more than one tape.
• Each tape has its own tape head.
• Each tape is independent.
CONTROL
UNIT
TAPE
TAPE
Rama Bansal Turing Machines 31
2-Tape Turing Machine
• a quintuple (Q, , , , s), where
– the set of states Q is finite, and does not contain the halt
state h,
– the input alphabet  is a finite set of symbols, not
including the blank symbol ,
– the tape alphabet  is a finite set of symbols containing ,
but not including the blank symbol ,
– the start state s is in Q, and
– the transition function  is a partial function from
Q  ({})2  Q{h}  ({})2  {L, R, S}2 .
Rama Bansal Turing Machines 32
Example of 2-Tape Turing Machine
q2h
,/(,),(L,R)
s p1
p4
p2 p3
,/(,),(R,S)
0,/(0,),(R,S)
1,/(1,),(R,S)
0,/(0,0),(L,R)
1,/(1,1),(L,R)
,/(,),(R,S)
0,/(0,),(R,S)
1,/(1,),(R,S)
,/(,),(L,L)
0,0/(,),(L,L)
1,1/(,),(L,L)
,/(,),(R,R),/(1,),(L,L)
Rama Bansal Turing Machines 33
Equivalence of 2-tape TM and single-tape TM
Theorem:
For any 2-tape TM T, there exists a single-
tape TM M such that for any string  in *:
– if T halts on  with  on its tape, then M halts
on  with  on its tape, and
– if T does not halt on , then M does not halt on
.
Rama Bansal Turing Machines 34
How 1-tape TM simulates 2-tape TM
• Marking the position of each tape head in the
content of the tape
• Encode content of 2 tapes on 1 tape
– When to convert 1-tape symbol into 2-tape symbol
• Construct 1-tape TM simulating a transition in 2-
tape TM
• Convert the encoding of 2-tape symbols back to 1-
tape symbols
cannot be done all at once because the tape is infinite
Rama Bansal Turing Machines 35
Encoding 2 tapes in 1 tape
• New alphabet contains:
– old alphabet
– encoding of a symbol on tape 1 and a symbol on tape 2
– encoding of a symbol on tape 1 pointed by its tape head and a
symbol on tape 2
– encoding of a symbol on tape 1 and a symbol on tape 2 pointed
by its tape head
– encoding of a symbol on tape 1 pointed by its tape head and a
symbol on tape 2 pointed by its tape head
 0 1 1 1 0  
 0 1 0 1   
 0 1 1 1 0  
 0 1 0 1   
Rama Bansal Turing Machines 36
How the tape content is changed
0 1 1 1 0 
1

1

1

0



0



Rama Bansal Turing Machines 37
Tape format
c(b,) # c(a,) c(b,) c(c,) c(d,) …
What’s read on tape 1 and 2
seperator
Encoded tape content
Rama Bansal Turing Machines 38
Simulating transitions in 2-tape TM in 1-tape TM
p qa1,a2/(b1,b2),(d1,d2)
p
q
T_tape1 (a1,b1,d1)
T_tape2 (a2,b2,d2)
c(a1,a2)
Rama Bansal Turing Machines 39
T_tape1(0,1,d)
S
#/#,R
c(?,x)/c(?,x),R
c(?,x)/c(?,x),R
c(0,?)/c(1,?),d
c(0,?)/c(1,?),d
It is not possible that
c(1,?) is found because
c(0,?) is wriiten in cell 1.
? and x are 0, 1, or 
c(1,x)/c(1,x),L
1/c(1,),L
Remember symbol
under tape head in
tape 1
#/#,L
#/#,L
#/#,L
not #/not #,L
not #/not #,L
not #/not #,L
c(?,x)/c(1,x),R
Convert 1-tape symbol
into 2-tape symbol
Update the first cell
h
c(?,?)/c(?,?),R
Rama Bansal Turing Machines 40
Tcleanup
pn
p1
c(0,)|0,S
c(1,)|1,S
c(,)|,S
|, L
#/,R
?|,R
|, L
h|, R|, R
/,L
0|0,L
1|1,L
|,R
Rama Bansal Turing Machines 41
Tencode
s h
/,L
0/0,R
1/1.R
/,L
/,R
/,R
/#,R /,L #/c(,),R /#,L
Rama Bansal Turing Machines 42
Equivalence of 2-tape TM and single-tape TM
Proof:
Let T = (Q, , , , s) be a 2-tape TM.
We construct a 1-tape TM M=(K, , ’, ’, s’) such that
– ’ =  {c(a,b)| a,b are in {}} {c(a,b)| a,b
are in {}} {c(a,b)|a,b are in {}} 
{c(a,b)|a,b are in {}}  {#}
We need to prove that:
– if T halts on  with output , then M halts on  with
output , and
– if T does not halt on , then M does not halt on 
Rama Bansal Turing Machines 43
if T halts on  with output 
Rama Bansal Turing Machines 44
if T does not halt on 
• If T loops, then M loops.
• If T hangs in a state p, M hangs
somewhere from p to the next state.
Rama Bansal Turing Machines 45
Equivalence of NTM and DTM
Theorem: For any NTM Mn, there exists a DTM Md
such that:
– if Mn halts on input  with output , then Md halts on
input  with output , and
– if Mn does not halt on input , then Md does not halt on
input .
Proof:
Let Mn = (Q, , , , s) be an NTM.
We construct a 2-tape TM Md from Mn as follows:
Rama Bansal Turing Machines 46
Construct a DTM equivalent to an NTM
WriteInitialConfiguration
Set WorkingTape
FindStateinCurrentConfiguration
WriteAllPossibleNextConfiguration
EraseCurrentConfiguration
FindNewConfiguration
h
a is any symbol, q is any state in Q Depend on Mn
Tape 1: simulate Mn’s tape
Tape 2: store configuration tree
Rama Bansal Turing Machines 47
How Md works
s 0 1* 0 1  #
 0 01 1 
q0 1# 0 1  #
s 0 1# 0@ 1  #
Current state: s
- - -- -- - - *
@
Current state: q
0 1 q# 0 1  #
-- -- -- - - *
*
Current state: s
WriteInitialConfiguration
Set Working Tape
FindStateinCurrentConfiguration
WriteAllPossibleNextConfiguration
EraseCurrentConfiguration
FindNewConfiguration
h
s q
0/0,R/@,S /,R
Tape 2
Tape 1
Rama Bansal Turing Machines 48
WriteAllPossibleNextConfiguration
pq1
q2
qn
a/b1,d1
a/b2,d2
a/bn,dn
Writeq1b1d1 Writeq2b2d2 Writeqnbndn
a,p
For each (p,a,qi,bi,di), 1  i n
Rama Bansal Turing Machines 49
Example: WriteAllPossibleNextConfiguration
s q
0/0,R/@,S
/,R
WriteqR Writes@R
,s
Writeq0R
…
Nondeterministic
move
Deterministic
move
Rama Bansal Turing Machines 50
if Mn halts on input  with output 
• Then, there is a positive integer n such that
the initial configuration (s, ) of Mn yeilds a
halting configuration (h, ) in n steps.
• From the construction of Md, the
configuration (h, ) must appear on tape 2
at some time.
• Then, Md must halt with  on tape 1.
Rama Bansal Turing Machines 51
if Mn does not halt on input 
• Then, Mn cannot reach the halting
configuration. That is, (s, ) never yields a
halting configuration (h, ).
• From the construction of Md, the
configuration (h,) never appears on tape 2.
• Then, Md never halt.
Rama Bansal Turing Machines 52
Universal Turing Machine
• Given the description of a DTM T and an
input string z, a universal TM simulates how T
works on input z.
• What’s need to be done?
– How to describe T and z on tape
• Use an encoding function
– How to simulate T
Rama Bansal Turing Machines 53
Encoding function
• Let T=(Q, , , s) be a TM. The encoding function
e(T) is defined as follows:
– e(T)=e(s)#e(),
– e()=e(m1)#e(m2)#...#e(mn)#, where  = {m1, m2,..., mn}
– e(m)=e(p),e(a),e(q),e(b),e(d), where m = (p, a, q, b, d)
– e(z)=1e(z1)1e(z2)1…1e(zm)1, where z=z1z2…zm is a string
– e()=0, e(ai)=0i+1, where ai is in 
– e(h)=0, e(qi)=0i+1, where qi is in Q
– e(S)=0, e(L)=00, e(R)=000
Rama Bansal Turing Machines 54
Example of Encoded TM
• e()=0 , e(a1)=00 , e(a2)=000
• e(h)=0, e(q1)=00, e(q2)=000
• e(S)=0, e(L)=00, e(R)=000
• e(a1a1a2) = 1e()1e(a1)1e(a1)1e(a2)1e()1
= 101001001000101
• e(m1) = (q1),e(a1),e(q2),e(a2),e(R)
= 00,00,000,000,000
• e(m2) = e(q2),e(),e(h),e(),e(S)
= 000,0,0,0,0
• e() = e(m1)#e(m2)#...#
= 00,00,000,000,000#000,0,0,0,0#...#
• e(T) = e(s)#e()
= 00#00,00,000,000,000#000,0,0,0,0#...#
• Input = e(Z)|e(T)|
= 101001001000101|00#00,00,000,000,000#000,0,0,0,0#...#|
q1 q2 h
a1/a2,R /,s
Rama Bansal Turing Machines 55
Universal Turing Machine
Tape 1: I/O tape, store the transition function of T and
input of T
Tape 2: simulate T’s tape
Tape 3: store T’s state
CopyInputToTape2
CopyTape2ToTape1UpdateStateOnTape3
UpdateTape2 FindRightMove
CopyStartStateToTape3
0
 (halt)
Rama Bansal Turing Machines 56
How UTM Works
CopyInputToTape2
CopyTape2ToTape1UpdateStateOnTape3
UpdateTape2 FindRightMove
CopyStartStateToTape3
halt0 0
1 0 0 1 0 1
1 0 0 1 0 1 | 0 0
# 0 0 , 0 0 , 0 0 0 , 0 0 0 , 0 0 0
# 0 0 0 , 0 , 0 , 0 , 0 # ... # |
Tape 1
Tape 3
Tape 2
1 0 0 0 1 0 1
0 0 00
a2 
Rama Bansal Turing Machines 57
Church-Turing Thesis
• Turing machines are formal versions of
algorithms.
• No computational procedure will be
considered an algorithm unless it can be
presented as a Turing machine.
Rama Bansal Turing Machines 58
Checklist
• Construct a DTM,
multitape TM, NTM
accepting languages or
computing function
• Construct composite
TM
• Prove properties of
languages accepted by
specific TM
• Prove the relationship
between different types
of TM
• Describe the
relationship between
TM and FA
• Prove the relationship
between TM and FA

More Related Content

What's hot

What's hot (20)

Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Turing machine implementation
Turing machine implementationTuring machine implementation
Turing machine implementation
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Turing machine
Turing machineTuring machine
Turing machine
 
Introduction to Turing Machine
Introduction to Turing MachineIntroduction to Turing Machine
Introduction to Turing Machine
 
Turing machine
Turing machineTuring machine
Turing machine
 
Turing machine Introduction
Turing machine IntroductionTuring machine Introduction
Turing machine Introduction
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Working principle of Turing machine
Working principle of Turing machineWorking principle of Turing machine
Working principle of Turing machine
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
 
Turing machine seminar report
Turing machine seminar reportTuring machine seminar report
Turing machine seminar report
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing Machine
 
Turing machine
Turing machineTuring machine
Turing machine
 
Turing machine
Turing machineTuring machine
Turing machine
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 

Similar to Turing Machines (TM)

Theta join (M-bucket-I algorithm explained)
Theta join (M-bucket-I algorithm explained)Theta join (M-bucket-I algorithm explained)
Theta join (M-bucket-I algorithm explained)Minsub Yim
 
chapter1 (1).ppt
chapter1 (1).pptchapter1 (1).ppt
chapter1 (1).pptNateHigger
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation parmeet834
 
Automata 2FA presentation Slide.pptx
Automata 2FA presentation Slide.pptxAutomata 2FA presentation Slide.pptx
Automata 2FA presentation Slide.pptxShamimAhammadRasel
 
Quadrature Amplitude Modulation. QAM Transmitter.ppt
Quadrature Amplitude Modulation. QAM Transmitter.pptQuadrature Amplitude Modulation. QAM Transmitter.ppt
Quadrature Amplitude Modulation. QAM Transmitter.pptStefan Oprea
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Editor IJARCET
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Editor IJARCET
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguagesissbp
 
Estimating structured vector autoregressive models
Estimating structured vector autoregressive modelsEstimating structured vector autoregressive models
Estimating structured vector autoregressive modelsAkira Tanimoto
 
Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataeugenesri
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataparmeet834
 
PushdownAutomata.ppt
PushdownAutomata.pptPushdownAutomata.ppt
PushdownAutomata.pptRSRS39
 
Time series Modelling Basics
Time series Modelling BasicsTime series Modelling Basics
Time series Modelling BasicsAshutosh Kumar
 

Similar to Turing Machines (TM) (20)

TuringMachines.pdf
TuringMachines.pdfTuringMachines.pdf
TuringMachines.pdf
 
Theta join (M-bucket-I algorithm explained)
Theta join (M-bucket-I algorithm explained)Theta join (M-bucket-I algorithm explained)
Theta join (M-bucket-I algorithm explained)
 
chapter1 (1).ppt
chapter1 (1).pptchapter1 (1).ppt
chapter1 (1).ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation
 
Automata 2FA presentation Slide.pptx
Automata 2FA presentation Slide.pptxAutomata 2FA presentation Slide.pptx
Automata 2FA presentation Slide.pptx
 
Quadrature Amplitude Modulation. QAM Transmitter.ppt
Quadrature Amplitude Modulation. QAM Transmitter.pptQuadrature Amplitude Modulation. QAM Transmitter.ppt
Quadrature Amplitude Modulation. QAM Transmitter.ppt
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguages
 
Estimating structured vector autoregressive models
Estimating structured vector autoregressive modelsEstimating structured vector autoregressive models
Estimating structured vector autoregressive models
 
Unit iv
Unit ivUnit iv
Unit iv
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 
Mergesort
MergesortMergesort
Mergesort
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
PushdownAutomata.ppt
PushdownAutomata.pptPushdownAutomata.ppt
PushdownAutomata.ppt
 
Time series Modelling Basics
Time series Modelling BasicsTime series Modelling Basics
Time series Modelling Basics
 

More from parmeet834

Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 tocparmeet834
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata parmeet834
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...parmeet834
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...parmeet834
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Daparmeet834
 
Pushdown Automata
Pushdown AutomataPushdown Automata
Pushdown Automataparmeet834
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOCparmeet834
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Finite Automata
Finite AutomataFinite Automata
Finite Automataparmeet834
 
1 introduction
1 introduction1 introduction
1 introductionparmeet834
 

More from parmeet834 (12)

DFA
DFA DFA
DFA
 
Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 toc
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Da
 
Pushdown Automata
Pushdown AutomataPushdown Automata
Pushdown Automata
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOC
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
1 introduction
1 introduction1 introduction
1 introduction
 

Recently uploaded

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Turing Machines (TM)

  • 1. Turing Machines (TM) Model of Computation
  • 2. Rama Bansal Turing Machines 2 Outlines • Structure of Turing machines • Deterministic Turing machines (DTM) – Accepting a language – Computing a function • Composite Turing machines • Multitape Turing machines • Nondeterministic Turing machines (NTM) • Universal Turing machines (UTM)
  • 3. Rama Bansal Turing Machines 3 Structure of TM CONTROL UNIT TAPE TAPE HEAD Finite set of states Move left or right one cell at a time Store input for the TM Can be of any length Can read from and write on tape Start state A single halt state
  • 4. Rama Bansal Turing Machines 4 What does a TM do? • Determine if an input x is in a language. – That is, answer if the answer of a problem P for the instance x is “yes”. • Compute a function – Given an input x, what is f(x)?
  • 5. Rama Bansal Turing Machines 5 How does a TM work? • At the beginning, –A TM is in the start state (initial state) –its tape head points at the first cell –The tape contains , following by input string, and the rest of the tape contains .
  • 6. Rama Bansal Turing Machines 6 How does a TM work? • For each move, a TM – reads the symbol under its tape head – According to the transition function on the symbol read from the tape and its current state, the TM: • write a symbol on the tape • move its tape head to the left or right one cell or not • changes its state to the next state
  • 7. Rama Bansal Turing Machines 7 When does a TM stop working? • A TM stops working, – when it gets into the special state called halt state. (halts) • The output of the TM is on the tape. – when the tape head is on the leftmost cell and is moved to the left. (hangs) – when there is no next state. (hangs)
  • 8. Rama Bansal Turing Machines 8 How to define deterministic TM (DTM) • a quintuple (Q, , , , s), where – the set of states Q is finite, not containing halt state h, – the input alphabet  is a finite set of symbols not including the blank symbol , – the tape alphabet  is a finite set of symbols containing , but not including the blank symbol , – the start state s is in Q, and – the transition function  is a partial function from Q  ({})  Q{h}  ({})  {L, R, S}.
  • 9. Rama Bansal Turing Machines 9 Example of a DTM • M= ({s,p1,p2,p3,p4,q1,q2}, {0,1},{0,1,@}, , s} 1/,R q2 h q1 /1,L @/,R /,L s p1 p4 p2 p3 /@,R 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R
  • 10. Rama Bansal Turing Machines 10 How a DTM works 1/,R q2 h q1 /1,L @/,R /,L s p1 p4 p2 p3 /@,R 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R 0 1 0 0 0 0 0 @    1 On the input 0001000, the TM halts.
  • 11. Rama Bansal Turing Machines 11 How a DTM works 1/,R q2 h q1 /1,L @/,R /,L s p1 p4 p2 p3 /@,R 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R 0 0 0 0 0 0 0 @    On the input 0000000, the TM hangs.
  • 12. Rama Bansal Turing Machines 12 Configuration Definition • Let T = (Q, , , , s) be a DTM. A configuration of T is an element of Q  {h}  ({}) ({}) ({}) • Can be written as – (q,l,a,r) or – (q,lar) string to the right of tape head symbol under tape head string to the left of tape head Current state
  • 13. Rama Bansal Turing Machines 13 Yield the next configuration Definition • Let T = (Q, , , , s) be a DTM, and (q1, 1a11) and (q2, 2a22) be two configurations of T. We say (q1, 1a11) yields (q2, 2a22) in one step, denoted by (q1, 1a11) T (q2, 2a22), if – (q1, a1) = (q2,a2,s), 1=2 and 1=2, – (q1, a1) = (q2,b,R), 2=1b and 1=a22, – (q1, a1) = (q2,b,L), 1=2a2 and 2=b1.
  • 14. Rama Bansal Turing Machines 14 Yield in zero step or more Definition • Let T=(Q, , , , s) be a DTM, and (q1, 1a11) and (q2, 2a22) be two configurations of T. We say (q1, 1a11) yields (q2, 1a22) in zero step or more, denoted by (q1, 1a11) -* T (q2, 1a22), if – q1=q2, 1 =2, a1= a2, and 1= 2, or – (q1,1a11)-T (q, a) and (q, a)-* T (q2,1a22) for some q in Q, and  in *, and a in .
  • 15. Rama Bansal Turing Machines 15 Yield in zero step or more: Example (s,0001000) (p1,@0001000) (p2,@001000) (p2,@001000) (p3,@001000) (p4,@00100) (p4,@00100) (p1,@00100) (p2,@0100) (p2,@0100) (p3,@0100) 1/,R q2 h q1 /1,L @/,R /,L s p1 p4 p2 p3 /@,R 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R (p4,@010) (p4,@010) (p1,@010) (p2,@10) (p2,@10) (p2,@10) (p3,@10) (p4,@1) (p4,@1) (p1,@1) (q1,@) (q1,@) (q2,) (h ,1)
  • 16. Rama Bansal Turing Machines 16 TM accepting a language • Definition Let T=(Q, , , , s) be a TM, and w*. T accepts w if (s, , , w) |-T * (h, , , 1). The language accepted by a TM T, denoted by L(T), is the set of strings accepted by T.
  • 17. Rama Bansal Turing Machines 17 Example of language accepted by a TM L(T)={0n10n | n0} • T halts on 0n10n • T hangs on 0n+110n at p3 • T hangs on 0n10n+1 at q1 • T hangs on 0n 12 0n at q1 1/,R q2 h q1 /1,L @/,R /,L s p1 p4 p2 p3 /@,R 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R
  • 18. Rama Bansal Turing Machines 18 TM computing a function • Definition Let T=(Q, , , , s) be a TM, and f be a function from * to *. T computes f if, for any string w in *, (s, , , w) |-T * (h, , , f(w)).
  • 19. Rama Bansal Turing Machines 19 Example of TM Computing Function p3p2 /1,R s p1 p4 /,R /,L 1/1,R 1/1,R 1/1,L /,R h 1/,L
  • 20. Rama Bansal Turing Machines 20 Example of TM Computing Function 1/1,L 0/0,L p3p2 /1’,L 1/@,R s p1 r2 /,R 0’/0,R 1’/1,R /,L /,S 0/0,R 1/1,R q2 q1 r1 h 0’/0,R 1’/1,R 0/0,L 1/1,L 0’/0’,L 1’/1’,L 0/0,L 1/1,L 0’/0’,L 1’/1’,L 0/0,R 1/1,R/0’,L 0/@,R @/1,R @/0,R
  • 21. Rama Bansal Turing Machines 21 Composite TM • Let T1 and T2 be TM’s. • T1  T2 means executing T1 until T1 halts and then executing T2. • T1 -a T2 means executing T1 until T1 halts and if the symbol under the tape head when T1 halts is a then executing T2.
  • 22. Rama Bansal Turing Machines 22 Example of Composite TM T0-0 Tout1 0 1 Terase1 Ts 0  /@,R s h q2 hq1 /1,L@/,R /,L 1/,R hs p1 p4p2 p3 0/,R 0/0,R 1/1,R /,L 0/,L 0/0,L 1/1,L /,R h T0-0 Terase1 Ts Tout1 1
  • 23. Rama Bansal Turing Machines 23 Nondeterministic TM • An NTM starts working and stops working in the same way as a DTM. • Each move of an NTM can be nondeterministic.
  • 24. Rama Bansal Turing Machines 24 Each Move in an NTM • reads the symbol under its tape head • According to the transition relation on the symbol read from the tape and its current state, the TM choose one move nondeterministically to: – write a symbol on the tape – move its tape head to the left or right one cell or not – changes its state to the next state
  • 25. Rama Bansal Turing Machines 25 How to define nondeterministic TM (NTM) • a quintuple (Q, , , , s), where – the set of states Q is finite, and does not contain halt state h, – the input alphabet  is a finite set of symbols, not including the blank symbol , – the tape alphabet  is a finite set of symbols containing , but not including the blank symbol , – the start state s is in Q, and – the transition fn :Q({})2Q{h}({}){L,R,S}.
  • 26. Rama Bansal Turing Machines 26 Configuration of an NTM Definition • Let T = (Q, , , , s) be an TM. A configuration of T is an element of Q      • Can be written as – (q,l,a,r) or – (q,lar) string to the right of tape head string to the left of tape head symbol under tape head
  • 27. Rama Bansal Turing Machines 27 Yield the next configuration Definition • Let T = (Q, , , , s) be an NTM, and (q1, 1a11) and (q2, 2a22) be two configurations of T. We say (q1, 1a11) yields (q2, 2a22) in one step, denoted by (q1, 1a11) T (q2, 2a22), if – (q2,a2,S)  (q1, a1), 1=2 and 1=2, – (q2,b,R)  (q1, a1), 2=1b and 1=a22, – (q2,b,L)  (q1, a1), 1=2a2 and 2=b1.
  • 28. Rama Bansal Turing Machines 28 NTM accepting a language/computing a function • Definition Let T = (Q, , , , s) be an NTM. Let w* and f be a function from * to *. T accepts w if (s, , , w) |-T * (h, , , 1). The language accepted by a TM T, denoted by L(T), is the set of strings accepted by T. T computes f if, for any string w in *, (s, , , w) |-T * (h, , , f(w)).
  • 29. Rama Bansal Turing Machines 29 Example of NTM • Let L={ww| w{0,1}*} s p u q0 t0 r0 h /@,R 0/0,L 1/1,L 0/0,L 1/1,L /,L 0/0,R 1/1,R /,R q1 t1 r1 0/0,L 1/1,L /,L 0/0,R 1/1,R @/,Lv 0/0,R 1/1,R /@,L
  • 30. Rama Bansal Turing Machines 30 Multitape TM • TM with more than one tape. • Each tape has its own tape head. • Each tape is independent. CONTROL UNIT TAPE TAPE
  • 31. Rama Bansal Turing Machines 31 2-Tape Turing Machine • a quintuple (Q, , , , s), where – the set of states Q is finite, and does not contain the halt state h, – the input alphabet  is a finite set of symbols, not including the blank symbol , – the tape alphabet  is a finite set of symbols containing , but not including the blank symbol , – the start state s is in Q, and – the transition function  is a partial function from Q  ({})2  Q{h}  ({})2  {L, R, S}2 .
  • 32. Rama Bansal Turing Machines 32 Example of 2-Tape Turing Machine q2h ,/(,),(L,R) s p1 p4 p2 p3 ,/(,),(R,S) 0,/(0,),(R,S) 1,/(1,),(R,S) 0,/(0,0),(L,R) 1,/(1,1),(L,R) ,/(,),(R,S) 0,/(0,),(R,S) 1,/(1,),(R,S) ,/(,),(L,L) 0,0/(,),(L,L) 1,1/(,),(L,L) ,/(,),(R,R),/(1,),(L,L)
  • 33. Rama Bansal Turing Machines 33 Equivalence of 2-tape TM and single-tape TM Theorem: For any 2-tape TM T, there exists a single- tape TM M such that for any string  in *: – if T halts on  with  on its tape, then M halts on  with  on its tape, and – if T does not halt on , then M does not halt on .
  • 34. Rama Bansal Turing Machines 34 How 1-tape TM simulates 2-tape TM • Marking the position of each tape head in the content of the tape • Encode content of 2 tapes on 1 tape – When to convert 1-tape symbol into 2-tape symbol • Construct 1-tape TM simulating a transition in 2- tape TM • Convert the encoding of 2-tape symbols back to 1- tape symbols cannot be done all at once because the tape is infinite
  • 35. Rama Bansal Turing Machines 35 Encoding 2 tapes in 1 tape • New alphabet contains: – old alphabet – encoding of a symbol on tape 1 and a symbol on tape 2 – encoding of a symbol on tape 1 pointed by its tape head and a symbol on tape 2 – encoding of a symbol on tape 1 and a symbol on tape 2 pointed by its tape head – encoding of a symbol on tape 1 pointed by its tape head and a symbol on tape 2 pointed by its tape head  0 1 1 1 0    0 1 0 1     0 1 1 1 0    0 1 0 1   
  • 36. Rama Bansal Turing Machines 36 How the tape content is changed 0 1 1 1 0  1  1  1  0    0   
  • 37. Rama Bansal Turing Machines 37 Tape format c(b,) # c(a,) c(b,) c(c,) c(d,) … What’s read on tape 1 and 2 seperator Encoded tape content
  • 38. Rama Bansal Turing Machines 38 Simulating transitions in 2-tape TM in 1-tape TM p qa1,a2/(b1,b2),(d1,d2) p q T_tape1 (a1,b1,d1) T_tape2 (a2,b2,d2) c(a1,a2)
  • 39. Rama Bansal Turing Machines 39 T_tape1(0,1,d) S #/#,R c(?,x)/c(?,x),R c(?,x)/c(?,x),R c(0,?)/c(1,?),d c(0,?)/c(1,?),d It is not possible that c(1,?) is found because c(0,?) is wriiten in cell 1. ? and x are 0, 1, or  c(1,x)/c(1,x),L 1/c(1,),L Remember symbol under tape head in tape 1 #/#,L #/#,L #/#,L not #/not #,L not #/not #,L not #/not #,L c(?,x)/c(1,x),R Convert 1-tape symbol into 2-tape symbol Update the first cell h c(?,?)/c(?,?),R
  • 40. Rama Bansal Turing Machines 40 Tcleanup pn p1 c(0,)|0,S c(1,)|1,S c(,)|,S |, L #/,R ?|,R |, L h|, R|, R /,L 0|0,L 1|1,L |,R
  • 41. Rama Bansal Turing Machines 41 Tencode s h /,L 0/0,R 1/1.R /,L /,R /,R /#,R /,L #/c(,),R /#,L
  • 42. Rama Bansal Turing Machines 42 Equivalence of 2-tape TM and single-tape TM Proof: Let T = (Q, , , , s) be a 2-tape TM. We construct a 1-tape TM M=(K, , ’, ’, s’) such that – ’ =  {c(a,b)| a,b are in {}} {c(a,b)| a,b are in {}} {c(a,b)|a,b are in {}}  {c(a,b)|a,b are in {}}  {#} We need to prove that: – if T halts on  with output , then M halts on  with output , and – if T does not halt on , then M does not halt on 
  • 43. Rama Bansal Turing Machines 43 if T halts on  with output 
  • 44. Rama Bansal Turing Machines 44 if T does not halt on  • If T loops, then M loops. • If T hangs in a state p, M hangs somewhere from p to the next state.
  • 45. Rama Bansal Turing Machines 45 Equivalence of NTM and DTM Theorem: For any NTM Mn, there exists a DTM Md such that: – if Mn halts on input  with output , then Md halts on input  with output , and – if Mn does not halt on input , then Md does not halt on input . Proof: Let Mn = (Q, , , , s) be an NTM. We construct a 2-tape TM Md from Mn as follows:
  • 46. Rama Bansal Turing Machines 46 Construct a DTM equivalent to an NTM WriteInitialConfiguration Set WorkingTape FindStateinCurrentConfiguration WriteAllPossibleNextConfiguration EraseCurrentConfiguration FindNewConfiguration h a is any symbol, q is any state in Q Depend on Mn Tape 1: simulate Mn’s tape Tape 2: store configuration tree
  • 47. Rama Bansal Turing Machines 47 How Md works s 0 1* 0 1  #  0 01 1  q0 1# 0 1  # s 0 1# 0@ 1  # Current state: s - - -- -- - - * @ Current state: q 0 1 q# 0 1  # -- -- -- - - * * Current state: s WriteInitialConfiguration Set Working Tape FindStateinCurrentConfiguration WriteAllPossibleNextConfiguration EraseCurrentConfiguration FindNewConfiguration h s q 0/0,R/@,S /,R Tape 2 Tape 1
  • 48. Rama Bansal Turing Machines 48 WriteAllPossibleNextConfiguration pq1 q2 qn a/b1,d1 a/b2,d2 a/bn,dn Writeq1b1d1 Writeq2b2d2 Writeqnbndn a,p For each (p,a,qi,bi,di), 1  i n
  • 49. Rama Bansal Turing Machines 49 Example: WriteAllPossibleNextConfiguration s q 0/0,R/@,S /,R WriteqR Writes@R ,s Writeq0R … Nondeterministic move Deterministic move
  • 50. Rama Bansal Turing Machines 50 if Mn halts on input  with output  • Then, there is a positive integer n such that the initial configuration (s, ) of Mn yeilds a halting configuration (h, ) in n steps. • From the construction of Md, the configuration (h, ) must appear on tape 2 at some time. • Then, Md must halt with  on tape 1.
  • 51. Rama Bansal Turing Machines 51 if Mn does not halt on input  • Then, Mn cannot reach the halting configuration. That is, (s, ) never yields a halting configuration (h, ). • From the construction of Md, the configuration (h,) never appears on tape 2. • Then, Md never halt.
  • 52. Rama Bansal Turing Machines 52 Universal Turing Machine • Given the description of a DTM T and an input string z, a universal TM simulates how T works on input z. • What’s need to be done? – How to describe T and z on tape • Use an encoding function – How to simulate T
  • 53. Rama Bansal Turing Machines 53 Encoding function • Let T=(Q, , , s) be a TM. The encoding function e(T) is defined as follows: – e(T)=e(s)#e(), – e()=e(m1)#e(m2)#...#e(mn)#, where  = {m1, m2,..., mn} – e(m)=e(p),e(a),e(q),e(b),e(d), where m = (p, a, q, b, d) – e(z)=1e(z1)1e(z2)1…1e(zm)1, where z=z1z2…zm is a string – e()=0, e(ai)=0i+1, where ai is in  – e(h)=0, e(qi)=0i+1, where qi is in Q – e(S)=0, e(L)=00, e(R)=000
  • 54. Rama Bansal Turing Machines 54 Example of Encoded TM • e()=0 , e(a1)=00 , e(a2)=000 • e(h)=0, e(q1)=00, e(q2)=000 • e(S)=0, e(L)=00, e(R)=000 • e(a1a1a2) = 1e()1e(a1)1e(a1)1e(a2)1e()1 = 101001001000101 • e(m1) = (q1),e(a1),e(q2),e(a2),e(R) = 00,00,000,000,000 • e(m2) = e(q2),e(),e(h),e(),e(S) = 000,0,0,0,0 • e() = e(m1)#e(m2)#...# = 00,00,000,000,000#000,0,0,0,0#...# • e(T) = e(s)#e() = 00#00,00,000,000,000#000,0,0,0,0#...# • Input = e(Z)|e(T)| = 101001001000101|00#00,00,000,000,000#000,0,0,0,0#...#| q1 q2 h a1/a2,R /,s
  • 55. Rama Bansal Turing Machines 55 Universal Turing Machine Tape 1: I/O tape, store the transition function of T and input of T Tape 2: simulate T’s tape Tape 3: store T’s state CopyInputToTape2 CopyTape2ToTape1UpdateStateOnTape3 UpdateTape2 FindRightMove CopyStartStateToTape3 0  (halt)
  • 56. Rama Bansal Turing Machines 56 How UTM Works CopyInputToTape2 CopyTape2ToTape1UpdateStateOnTape3 UpdateTape2 FindRightMove CopyStartStateToTape3 halt0 0 1 0 0 1 0 1 1 0 0 1 0 1 | 0 0 # 0 0 , 0 0 , 0 0 0 , 0 0 0 , 0 0 0 # 0 0 0 , 0 , 0 , 0 , 0 # ... # | Tape 1 Tape 3 Tape 2 1 0 0 0 1 0 1 0 0 00 a2 
  • 57. Rama Bansal Turing Machines 57 Church-Turing Thesis • Turing machines are formal versions of algorithms. • No computational procedure will be considered an algorithm unless it can be presented as a Turing machine.
  • 58. Rama Bansal Turing Machines 58 Checklist • Construct a DTM, multitape TM, NTM accepting languages or computing function • Construct composite TM • Prove properties of languages accepted by specific TM • Prove the relationship between different types of TM • Describe the relationship between TM and FA • Prove the relationship between TM and FA