Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which.

Download Report

Transcript Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which.

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
Definition9.1
A turingmachineM is defined by
Control unit
M  (Q,Σ,,q0 , ,F),
where
Read-write head
Q is theset of internalstates,
Σ is theinput alphabet,
Γ is a finiteset of symbolscalled
thetapealphabet,
δ is the transition function,
 T is a specialsymbolcalled
theblank,
q0  Q is theinitialstate,
F  Q is theset of finalstates.
Halt state: A Turing machine will halt
whenever it enters a final state or
reaches a configuration for which δ
is not defined.
Tape
δ:Q Γ  Q  Γ  {L,R}
Example 9.1 The following figure shows the
situation before and after the move caused by
the transition δ(p,a) (q,d,R)
.
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
q0
a a
Q  {q0 , q1},
δ(q0 ,a)  (q0 ,b,R),
  {a, b},
  {a, b, },
F  {q1}
q0
δ(q0 ,b)  (q0 ,b,R),
b a
δ(q0 , )  (q1, ,L),
q0
b b
q1
b b
Example 9.3 Consider the Turing machine defined by
Q  {q0 , q1},
δ(q0 ,a)  (q1,a,R),
  {a, b},
  {a, b, },
F  {q1}
δ(q0 ,b)  (q1,b,R),
δ(q0 , )  (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 (initialstate)
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 (finalstate)
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 ak ak 1
an
a1a2 ak 1qak an .
If δ (q, ak )  ( p, b, L), then wewrite
a1a2  ak 1qak ak 1  an
a1a2  pak 1bak 1  an
If δ (q, ak )  ( p, b, R), then wewrite
a1a2  ak 1qak ak 1  an
a1a2  ak 1bpak 1  an
Definition9.3
Let M  (Q,Σ,,q0 , ,F) be a T uringmachine.T hen thelanguage
acceptedby M is
L( M )  {w    : q0 w
*
x1q f x2 for some q f  F , x1 , x2  *}
Example9.6 For Σ  {0,1}, design a T uringmachinethatacceptsthelanguage
denotedby theregular expression00*.
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},
δ(q0 ,0 )  (q0 ,0,R),
F  {q1}
δ(q0 , )  (q1, ,R).
Example9.7 For Σ  {a, b}, design a T uringmachinethatacceptsthelanguage
L  {a nb n : n  1}.
Solution
Q  {q0 , q1 , q2 , q3 , q4 },
F  {q4 }
  {a, b}
  {a, b, x, y, }
δ (q0 ,a)  (q1,x,R),
δ(q2 ,y)  (q2 ,y,L),
δ(q0 ,y)  (q3 ,y,R),
δ (q1, a )  (q1,a,R),
δ(q2 , a)  (q2 ,a,L),
δ(q3 , y)  (q3 ,y,R),
δ (q1, y )  (q1,y,R),
δ(q2 , x)  (q0 ,x,R),
δ(q3 , )  (q4 , ,R).
δ (q1, b)  (q2 ,y,L),
q0 aabb
xq1abb
xq2 ayb
q2 xayb
xq0 ayb
......
xxq1 yb
Definition9.4
A function f wit h domain D is said to be T uring- computableor just
computableif thereexistssome T uringmachineM  (Q,Σ,,q0 , ,F)
such that
q0 w
*
for all w  D.
M
q f f ( w),
q f  F,
Example9.9 Given twopositiveintegersx and y, design a T uringmachine
thatcomputesx  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 },
δ (q0 ,1 )  (q0 ,1,R),
F  {q4 }
δ (q0 , 0)  (q1,1,R),
  {0,1}
  {0,1, }
δ (q1, )  (q2 , ,L),
δ (q1,1)  (q1,1,R),
δ (q2 ,1)  (q3 ,0 ,L),
δ (q3 ,1)  (q3 ,1,L),
δ (q3 , )  (q4 , ,R).
q0111011 * 111q0 011
1111q111 * 111111q1
11111q21
1111q310 * q3 111110
q4111110
Example9.10 Design a T uringmachinethatcopiesstringsof 1's. Morepresicely,
find a machinethatperformsthecomputation q0 w *
qf 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),
δ (q0 , )  (q1 , , L),
δ (q , )  (q ,1, L),
2
1
Repeat Steps 2 and 3 until there are no
δ (q1 ,1)  (q1 ,1, L),
more x’s.
δ (q1 , )  (q3 , , R),
q0111 * xq011 * xxq01 * xxxq0 * xxq1x
* xx1q2 * xxq111 * xq1 x11
* x1q211 * x11q21 * x111q2 * x11q111 * x1q1111 * xq11111* q1 x1111
* 1q21111* 11q2111 * 111q211 * 1111q21 * 11111q2 * 1111q111
*1q21111 * 11q2111 * 111q211 * 111q1111 * 11 q11111 * 1q111111
4.
* 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
Definit ion9.4
A funct ion f wit h domain D is said t o be T uring- comput ableor just
comput ableif t hereexist ssome T uringmachineM  (Q,Σ,,q0 , ,F)
such t hat
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
Definit ion12.3
Let wM be a st ring t hatdescribes a T uringmachineM  (Q,Σ,,q0 , ,F) ,
and let w be a st ringin M's alphabet .We will assume t hatwM and w are
encodedas a st ringof 0's and 1's. A solut ionof t hehalt ingproblemis
a T uringmachineH, which for any wM and w performst hecomput at io
n
q0 wM w *
x1q y x2
if M applied t o w halt s,and
q0 wM w * y1qn y2
if M applied t o w does not halt .Here q y and qn are bot h final st at esof 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.