Turing Machine

rajendranjrf 22,174 views 109 slides Jan 18, 2016
Slide 1
Slide 1 of 109
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108
Slide 109
109

About This Presentation

Turing Machine


Slide Content

Source of Slides: Introduction to Automata Theory, Languages, and Computation
By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman

Dept. of Computer Science & IT, FUUAST
Theory of Computation
2
Turing MachineTuring Machine
Church-Turing’s ThesisChurch-Turing’s Thesis
Any mathematical problem
solving that can be described
by an algorithm can be modeled
by a Turing Machine.

Dept. of Computer Science & IT, FUUAST
Theory of Computation
3
Turing MachineTuring Machine
1) 1) Multiple trackMultiple track
2) Shift over Turing Machine2) Shift over Turing Machine
3) Nondeterministic3) Nondeterministic
4) Two way Turing Machine4) Two way Turing Machine
5) Multitape Turing Machine5) Multitape Turing Machine
6) Multidimensional Turing Machine6) Multidimensional Turing Machine
7) Composite Turing Machine7) Composite Turing Machine
8) Universal Turing Machine8) Universal Turing Machine
Types of Turing Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
4
Turing MachineTuring Machine
Formal Definition

Dept. of Computer Science & IT, FUUAST
Theory of Computation
5
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
6
Turing MachineTuring Machine
1.Start in state q
0
2.Read symbol under head
3.Write new symbol
4.Shift left/right
5.Enter new state q
j
Steps

Dept. of Computer Science & IT, FUUAST
Theory of Computation
7
Turing MachineTuring Machine
Notational Conventions For Turing Machines

Dept. of Computer Science & IT, FUUAST
Theory of Computation
8
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
9
Turing MachineTuring Machine
Moves for input 0011:
Moves for input 0010:

Dept. of Computer Science & IT, FUUAST
Theory of Computation
10
Turing MachineTuring Machine
Transition Diagram for 0011 input

Dept. of Computer Science & IT, FUUAST
Theory of Computation
11
Pushdown AutomataPushdown Automata
A Turing Machine M computes a function ( proper subtraction) for
0
m
10
n
on the tape.
means if m ≥ n then m - n else if m < n then 0

Dept. of Computer Science & IT, FUUAST
Theory of Computation
12
Turing MachineTuring Machine
Evaluating function

Dept. of Computer Science & IT, FUUAST
Theory of Computation
13
Turing MachineTuring Machine
Evaluating function

Dept. of Computer Science & IT, FUUAST
Theory of Computation
14
Turing MachineTuring Machine
Transition Table for the function

Dept. of Computer Science & IT, FUUAST
Theory of Computation
15
Turing MachineTuring Machine
Transition Diagram for

Dept. of Computer Science & IT, FUUAST
Theory of Computation
16
Turing MachineTuring Machine
Transition Table for the function
Transition Diagram for

Dept. of Computer Science & IT, FUUAST
Theory of Computation
17
0 0 1 1 B B
q
0
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
18
X 0 1 1 B B
q
1
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
19
X 0 1 1 B B
q
1
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
20
X 0 Y 1 B B
q
2
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
21
X 0 Y 1 B B
q
2
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
22
X 0 Y 1 B B
q
0
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
23
X 0 Y 1 B B
q
0
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
24
X X Y 1 B B
q
1
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
25
X X Y 1 B B
q
1
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
26
X X Y Y B B
q
2
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
27
X X Y Y B B
q
2
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
28
X X Y Y B B
q
0
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
29
X X Y Y B B
q
0
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
30
X X Y Y B B
q
3
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
31
X X Y Y B B
q
3
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

Dept. of Computer Science & IT, FUUAST
Theory of Computation
32
X X Y Y B B
q
4
Turing MachineTuring Machine
A Turing Machine M that accepts the language { 0
n
1
n
| n ≥0 }

End of Simulation
Dept. of Computer Science & IT, FUUAST
Theory of Computation
33
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
34
Evaluating function
0 0 0 0 0 1 0 0 0 B B
q
0
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
35
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
36
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
37
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
38
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
39
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
40
Evaluating function
B 0 0 0 0 1 0 0 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
41
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
42
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
43
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
44
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
45
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
46
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
47
Evaluating function
B 0 0 0 0 1 1 0 0 B B
q
0
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
48
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
49
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
50
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
51
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
52
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
53
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
54
Evaluating function
B B 0 0 0 1 1 0 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
55
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
56
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
57
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
58
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
59
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
60
Evaluating function
B B 0 0 0 1 1 1 0 B B
q
0
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
61
Evaluating function
B B B 0 0 1 1 1 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
62
Evaluating function
B B B 0 0 1 1 1 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
63
Evaluating function
B B B 0 0 1 1 1 0 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
64
Evaluating function
B B B 0 0 1 1 1 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
65
Evaluating function
B B B 0 0 1 1 1 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
66
Evaluating function
B B B 0 0 1 1 1 0 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
67
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
68
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
69
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
70
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
71
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
72
Evaluating function
B B B 0 0 1 1 1 1 B B
q
3
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
73
Evaluating function
B B B 0 0 1 1 1 1 B B
q
0
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
74
Evaluating function
B B B B 0 1 1 1 1 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
75
Evaluating function
B B B B 0 1 1 1 1 B B
q
1
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
76
Evaluating function
B B B B 0 1 1 1 1 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
77
Evaluating function
B B B B 0 1 1 1 1 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
78
Evaluating function
B B B B 0 1 1 1 1 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
79
Evaluating function
B B B B 0 1 1 1 1 B B
q
2
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
80
Evaluating function
B B B B 0 1 1 1 1 B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
81
Evaluating function
B B B B 0 1 1 1 B B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
82
Evaluating function
B B B B 0 1 1 B B B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
83
Evaluating function
B B B B 0 1 B B B B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
84
Evaluating function
B B B B 0 B B B B B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
85
Evaluating function
B B B B 0 B B B B B B
q
4
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
86
Evaluating function
B B B 0 0 B B B B B B
q
6
Turing MachineTuring Machine
Final State

Dept. of Computer Science & IT, FUUAST
Theory of Computation
87
End of Simulation
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
88
Turing MachineTuring Machine
0
m
10
n
1
Multiplication

Dept. of Computer Science & IT, FUUAST
Theory of Computation
89
Turing MachineTuring Machine
0
m
10
n
1
Multiplication

Dept. of Computer Science & IT, FUUAST
Theory of Computation
90
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
91
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
92
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
93
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
94
Turing MachineTuring Machine
Variants of Turing Machine
A normal TM is a 7-tuple
(Q, Σ, G, δ, q
0
, q
accept
, q
reject
) where:
everything is the same as a TM except the
transition function:
δ: Q x G
k
→ Q x G
k
x {L, R}
k
δ(q
i
, a
1
,a
2
,…,a
k
) = (q
j
, b
1
,b
2
,…,b
k
, L, R,…, L) =
“in state q
i
, reading a
1
,a
2
,…,a
k
on k tapes, move to
state q
j
, write b
1
,b
2
,…,b
k
on k tapes, move L, R on
k tapes as specified.”
oMultitape Turing Machine:

Dept. of Computer Science & IT, FUUAST
Theory of Computation
95
Turing MachineTuring Machine
k-tape TM
011001110100
q
0
input tape
finite control

k read/write
heads
011001
“work tapes”

011001110100 …
0 …

Dept. of Computer Science & IT, FUUAST
Theory of Computation
96
Turing MachineTuring Machine
Informal description of k-tape TM:
 Input written on left-most squares of tape #1
 Rest of squares are blank on all tapes
 At each point, take a step determined by
•current k symbols being read on k tapes
•current state of finite control
 A step consists of
•writing k new symbols on k tapes
•moving each of k read/write heads left or right
•changing state

Dept. of Computer Science & IT, FUUAST
Theory of Computation
97
Turing MachineTuring Machine
Theorem: Every k-tape TM has an equivalent single-tape TM.
Proof: Simulate k-tape TM on a 1-tape TM.
. . . abab
aa
bbcd
. . .
. . .
(input tape)
#abab#aa#bbcd#. . .
• add new symbol x for
each old x
•marks location of “virtual
heads”

Dept. of Computer Science & IT, FUUAST
Theory of Computation
98
Turing MachineTuring Machine
Theorem:
The time taken by the one-tape TM to
simulate n moves of the k-tape TM is
O(n
2
).

Dept. of Computer Science & IT, FUUAST
Theory of Computation
99
Turing MachineTuring Machine
oNondeterministic Turing Machine (NTM):
A nondeterministic Turing Machine (NTM) differs from the
deterministic variety by having a transition function δ such that
for each state q and tape symbol X, δ(q, X) is a set of triples
{(q
1
,Y
1
,D
1
), (q
2
,Y
2
,D
2
), ……….. (q
k
,Y
k
,D
k
)}
Where k is any finite integer. The NTM can choose, at each step,
any of the triples to be the next move. It cannot, however, pick a
state from one, a tape symbol from another, a the direction from
yet another.

Dept. of Computer Science & IT, FUUAST
Theory of Computation
100
Turing MachineTuring Machine
Theorem: Every NTM has an equivalent (deterministic) TM.
Proof: Simulate NTM with a deterministic TM
C
start
• computations of M are a tree
• nodes are configurations
• fanout is b = maximum number of
choices in transition function
• leaves are accept/reject
configurations.
accrej

Dept. of Computer Science & IT, FUUAST
Theory of Computation
101
Turing MachineTuring Machine
Simulating NTM M with a deterministic TM:
Breadth-first search of tree
•if M accepts: we will encounter accepting leaf and
accept
•if M rejects: we will encounter all rejecting leaves,
finish traversal of tree, and reject
•if M does not halt on some branch: we will not halt
as that branch is infinite…

Dept. of Computer Science & IT, FUUAST
Theory of Computation
102
Turing MachineTuring Machine
Simulating NTM M with a deterministic TM:
ouse a 3 tape TM:
•tape 1: input tape (read-only)
•tape 2: simulation tape (copy of M’s tape at point
corresponding to some node in the tree)
•tape 3: which node of the tree we are exploring (string
in {1,2,…b}*)
oInitially, tape 1 has input, others blank

Dept. of Computer Science & IT, FUUAST
Theory of Computation
103
Turing MachineTuring Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
104
Turing MachineTuring Machine
Turing Machine and Computer
oA computer can simulate Turing Machine.
oA Turing Machine can simulate a computer.

Dept. of Computer Science & IT, FUUAST
Theory of Computation
105
Turing MachineTuring Machine
Simulating a Turing Machine by Computer

Dept. of Computer Science & IT, FUUAST
Theory of Computation
106
Turing MachineTuring Machine
Simulating a Computer by Turing Machine
Both addresses and
contents are written in
binary. The marker
symbol * and # are
used to find the ends
of addresses and
contents. Another
marker,$, indicates
the beginning of the
sequence of
addresses and
contents
Both addresses and
contents are written in
binary. The marker
symbol * and # are
used to find the ends
of addresses and
contents. Another
marker,$, indicates
the beginning of the
sequence of
addresses and
contents

Dept. of Computer Science & IT, FUUAST
Theory of Computation
107
Turing MachineTuring Machine
A universal Turing machine is a Turing machine T
u
that
works as follows. It is assumed to receive an input string
of the form e(T )e(z), where T is an arbitrary TM, z is a
string over the input alphabet of T , and e is an encoding
function whose values are strings in {0, 1} . The

computation performed by T
u
on this input string satisfies
these two properties:
1. T
u
accepts the string e(T )e(z) if and only if T accepts z.
2. If T accepts z and produces output y, then T
u
produces
output e(y).
Universal Turing Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
108
Turing MachineTuring Machine
Universal Turing Machine

Dept. of Computer Science & IT, FUUAST
Theory of Computation
109
Turing MachineTuring Machine
END
Tags