Chapter 9 Turing Machines
What would happen if we change the stack in Pushdown
Automata into some other storage device?
Truing Machines, which maintains that any
computational process, such as those carried out by
present-day computers.
9.1 The standard Turing Machine
Definition 9.1
A turing machine M is defined by
Control unit
M (Q,Σ,,q0 , ,F ),
where
Read-write head
Q is the set of internal states,
Σ is the input alphabet,
Γ is a finite set of symbols called
Tape
δ:Q Γ Q Γ {L,R}
the tape alphabet,
δ is the transitio n function,
T is a special symbol called
the blank,
Example 9.1 The following figure shows the
situation before and after the move caused by
the transition δ(p,a) (q,d,R).
q0 Q is the initial state,
F Q is the set of final states.
Halt state: A Turing machine will halt
whenever it enters a final state or
reaches a configuration for which δ
is not defined.
State p
a b c
δ(p,a) (q,d,R)
State q
d b c
We can think of a Turing machine as a computer.
Processing unit with a
finite memory.
Control unit
Read-write head
Tape
A secondary storage of unlimited capacity.
Example 9.2 Consider the Turing machine defined by
Q {q0 , q1},
δ(q 0 ,a) (q0 ,b,R),
{a, b},
δ(q 0 ,b) (q0 ,b,R),
{a, b, },
q0
a a
F {q1}
q0
b a
δ(q 0 , ) (q1, ,L),
q0
b b
q1
b b
Example 9.3 Consider the Turing machine defined by
Q {q0 , q1},
δ(q 0 ,a) (q1,a,R),
{a, b},
δ(q 0 ,b) (q1,b,R),
{a, b, },
F {q1}
δ(q 0 , ) (q1, ,R),
δ(q1,a) (q0 ,a,L),
δ(q1,b) (q0 ,b,L),
δ(q1, ) (q0 , ,L).
It is clear that the machine, whatever the initial information on its
tape, will run forever, with the read-write head moving alternately
right then left, but making no modifications to the tape. This is an
instance of a Turing machine that does not halt. We say that the
machine is in an infinite loop.
What is a Standard Turing machine ?
q0 (initial state )
a1 a2
3. Input (all or
some of them)
an
1. The tape is unbounded in
both directions, allowing any
number of left and right moves.
2. The Turing machine is
deterministic.
q f (final state )
b1 b2
bm
3. Output (all or
some of them)
We denote the following configuration of a Turing machine
q
a1 a2
to be
ak 1 a k ak 1
an
a1a2 ak 1qak an .
If δ (q, ak ) ( p, b, L), then we write
a1a2 ak 1qak ak 1 an
a1a2 pak 1bak 1 an
If δ (q, ak ) ( p, b, R), then we write
a1a2 ak 1qak ak 1 an
a1a2 ak 1bpak 1 an
Definition 9.3
Let M (Q,Σ,,q0 , ,F ) be a Turing machine. Then the language
accepted by M is
L( M ) {w : q0 w
*
x1q f x2 for some q f F , x1 , x2 *}
Example 9.6 For Σ {0,1}, design a Turing machine that accepts the language
denoted by the regular expression 00*.
Solution
(1) Starting at the left end of the input and check if the first one is a 0.
(2) If we reach a blank without encountering anything but 0, we terminate and
accept the string. If the input contains a 1 anywhere, the string is not in L(00*),
and we halt in a nonfinal state.
Q {q0 , q1},
δ(q 0 ,0 ) (q0 ,0,R),
F {q1}
δ(q 0 , ) (q1, ,R).
Example 9.7 For Σ {a, b}, design a Turing machine that accepts the language
L {a nb n : n 1}.
Solution
Q {q0 , q1 , q2 , q3 , q4 },
F {q4 }
{a, b}
{a, b, x, y, }
δ(q 0 ,a) (q1,x,R),
δ(q 2 ,y) (q2 ,y,L),
δ(q 0 ,y) (q3 ,y,R),
δ(q1, a) (q1,a,R),
δ(q 2 , a ) (q2 ,a,L),
δ(q 3 , y ) (q3 ,y,R),
δ(q1, y ) (q1,y,R),
δ(q 2 , x) (q0 ,x,R),
δ(q 3 , ) (q4 , ,R).
δ(q1, b) (q2 ,y,L),
q0 aabb
xq1abb
xq2 ayb
q2 xayb
xq0 ayb
......
xxq1 yb
Definition 9.4
A function f with domain D is said to be Turing - computable or just
computable if there exists some Turing machine M (Q,Σ,,q0 , ,F )
such that
q0 w
*
for all w D.
M
q f f ( w),
q f F,
Example 9.9 Given two positive integers x and y, design a Turing machine
that computes x y.
Solution In the tape, represent integers x and y by a number x of 1’s and a
number y of 1’s, and put a 0 between x and y.
Q {q0 , q1 , q2 , q3 , q4 },
δ(q 0 ,1 ) (q0 ,1,R),
F {q4 }
δ(q 0 , 0) (q1,1,R),
{0,1}
δ(q1,1) (q1,1,R),
{0,1, }
δ(q1, ) (q 2 , ,L),
δ(q 2 ,1) (q3 ,0 ,L),
δ(q 3 ,1) (q3 ,1,L),
δ(q 3 , ) (q 4 , ,R).
q0111 011 * 111q0 011
1111q111 * 111111q1
11111q21
1111q310 * q3 111110
q4111110
Example 9.10 Design a Turing machine that copies strings of 1' s. More presicely,
find a machine that performs the computatio n q0 w * q f ww,
for any w {1} .
F {q3}
Solution:
To solve the problem, we
implement the following intuitive
process:
1. Replace every 1 by x.
δ (q0 ,1) (q0 , x, R),
2.
Find the rightmost x and replace it with 1.
δ (q1 , x) (q2 ,1, R),
3.
Travel to the right end of the current
nonblank region and create a 1 there.
δ (q2 ,1) (q2 ,1, R ),
4.
Repeat Steps 2 and 3 until there are no
more x’s.
q0111 * xq011 * xxq01 * xxxq0 * xxq1 x
δ (q0 , ) (q1 , , L),
δ (q2 , ) (q1 ,1, L),
δ (q1 ,1) (q1 ,1, L),
δ (q1 , ) (q3 , , R),
* xx1q2 * xxq111 * xq1 x11
* x1q211 * x11q21 * x111q2 * x11q111 * x1q1111 * xq11111 * q1x1111
* 1q21111 * 11q2111 * 111q211 * 1111q21 * 11111 q2 * 1111q111
*1q21111 * 11q2111 * 111q211 * 111q1111 * 11 q11111 * 1q111111
* q1111111 * q1 111111 * q3111111
Chapter 12 Limits of Algorithmic Computation
Definition 12.1 An algorithm is a finite sequence of precise
instructions for performing a computation or for solving a problem.
Computability and Decidablity
Definition 9.4
A function f with domain D is said to be Turing - computable or just
computable if there exists some Turing machine M (Q,Σ,,q0 , ,F )
such that
q0 w * M q f f ( w),
q f F,
for all w D.
Definition 12.2
When the results of a computation for a problem is a simple “yes” or
“no”, the problem is called a decision problem.
If a decision problem is computable, the problem is called decidable,
otherwise, it is undecidable.
Turing Machine Halting Problem
Definition 12.3
Let wM be a string that describes a Turing machine M (Q,Σ,,q0 , ,F ) ,
and let w be a string in M' s alphabet. We will assume that wM and w are
encoded as a string of 0' s and 1' s. A solution of the halting problem is
a Turing machine H, which for any wM and w performs the computatio n
q0 wM w *
x1q y x2
if M applied to w halts, and
q0 wM w *
y1qn y2
if M applied to w does not halt. Here q y and qn are both final states of H .
Theorem 12.1 There does not exist any Turing machine H that
behaves as required by Definition 12.3. There halting problem is
therefore undecidable.
© Copyright 2026 Paperzz