Chapter 5 Turing Machines
Chapter 5 Turing Machines
Turing Machines
1
Turing Machines:
computer.
2
A Turing Machine
Tape
...... ......
Read-Write head
Control Unit
3
The Tape
No boundaries -- infinite length
...... ......
Read-Write head
Read-Write head
The head at each time step:
1. Reads a symbol
2. Writes a symbol
3. Moves Left or Right
5
Example:
Time 0
...... a b a c ......
Time 1
...... a b k c ......
1. Reads a
2. Writes k
3. Moves Left
6
Time 1
...... a b k c ......
Time 2
...... a f k c ......
1. Reads b
2. Writes f
3. Moves Right
7
The Input String
...... a b a c ......
head
Head starts at the leftmost position
of the input string
Are treated as left and right brackets for the
input written on the tape.
8
9
States & Transitions
Read Write
Move Left
q1 a b, L q2
Move Right
q1 a b, R q2
10
Determinism
Turing Machines are deterministic
q1 q1
q3 a d, L q3
b d, L
a b, R q2 q1
q1 No possible transition
b d, L q3 HALT!!!
Halting
- the machine halts if there are no possible transitions to follow.
12
Final States
q1 q2 Allowed
q1 q2 Not Allowed
If machine halts
in a non-final state
Reject Input or
If machine enters
an infinite loop
14
Turing Machine Example
A Turing machine that accepts the
language: aa *
a a, R
, L
q0 q1
15
Time 0 a a a
q0
a a, R
, L
q0 q1
16
Time 1 a a a
q0
a a, R
, L
q0 q1
17
Time 2 a a a
q0
a a, R
, L
q0 q1
18
Time 3 a a a
q0
a a, R
, L
q0 q1
19
Time 4 a a a
q1
, L
q0 q1
20
Rejection Example
Time 0 a b a
q0
a a, R
, L
q0 q1
21
Time 1 a b a
q0
No possible Transition
a a, R Halt & Reject
, L
q0 q1
22
Infinite Loop Example
b b, L
a a, R
, L
q0 q1
23
Time 0 a b a
q0
b b, L
a a, R
, L
q0 q1
24
Time 1 a b a
q0
b b, L
a a, R
, L
q0 q1
25
Time 2 a b a
b b, L q0
a a, R
, L
q0 q1
26
Another Turing Machine Example
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
27 x x, R
Time 0 a a b b
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
28 x x, R
Time 1 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
29 x x, R
Time 2 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
30 x x, R
Time 3 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
31 x x, R
Time 4 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
32 x x, R
Time 5 x a y b
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
33 x x, R
Time 6 x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
34 x x, R
Time 7 x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
35 x x, R
Time 8 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
36 x x, R
Time 9 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
37 x x, R
Time 10 x x y y
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
38 x x, R
Time 11 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
39 x x, R
Time 12 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
40 x x, R
Time 13 x x y y
q4
Halt & Accept
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
41 x x, R
Undecidability
Turing Decidable
Turing Acceptable
Undecidable Problems
42
Recognizability and Decidability
A language is recognizable if there is a Turing Machine that
recognizes it.
A language is decidable if there is a Turing Machine that
decides it.
43
44
Cont….
45
Cont….
46
Language Accepted by Turing Machine/ Turing Acceptable
The T.M accepts all the language even though they are recursive
enumerable.
Recursive means repeating same set of rules for any number of
times.
Enumerable means a list of elements.
TM also accepts the computable functions, such as addition,
multiplication, subtraction, division and many more.
47
Undecidable Problems