( r ; X ) = ([ q ; X ] ; X ; R ) for all X in . In - - PDF document

r x q x x r for all x in in con trol state q
SMART_READER_LITE
LIVE PREVIEW

( r ; X ) = ([ q ; X ] ; X ; R ) for all X in . In - - PDF document

Stupid T uring Mac hine T ric ks Often it is useful to think of the state and the tap e sym b ol as ha ving structure. The comp onen ts of a tap e sym b ol are tr acks . Usually one comp onen t


slide-1
SLIDE 1 Stupid T uring Mac hine T ric ks Often it is useful to think
  • f
the state and the tap e sym b
  • l
as ha ving structure.
  • The
comp
  • nen
ts
  • f
a tap e sym b
  • l
are tr acks.
  • Usually
  • ne
comp
  • nen
t
  • f
the state is the c
  • ntr
  • l,
resp
  • nsible
for running the \program"
  • f
the TM;
  • ther
comp
  • nen
ts hold data. Example Let M = (Q; ; ;
  • ;
q ; B ; F ). Supp
  • se
the program
  • f
M needs to sw ap the con ten ts
  • f
adjacen t tap e cells sometimes.
  • Some
  • f
the states in Q will b e
  • f
the form [q ; X ] and [p; X ], where X is an y sym b
  • l
in . W e also need states r to b egin and s to end.
  • In
state r , M will pic k up the sym b
  • l
scanned in to the data p
  • rtion
  • f
the state.

  • (r
; X ) = ([q ; X ]; X ; R) for all X in .
  • In
con trol state q , M dep
  • sits
the sym b
  • l
in its data comp
  • nen
t and pic ks up the sym b
  • l
that w as there, going to con trol state p.

  • ([q
; X ]; Y ) = ([p; Y ]; X ; L) for all X and Y in .
  • In
con trol state p, M dep
  • sits
its data and en ters state s, mo ving righ t.

  • ([p;
X ]; Y ) = (s; X ; R) for all X and Y in . Example: Multiple T rac ks A common use for m ultiple trac ks is to use
  • ne
trac k for data the
  • ther
for a single \mark."
  • Sym
b
  • ls
  • f
  • are
pairs [A; X ], where X is the \real" sym b
  • l,
and A is either B (blank)
  • r
.

Input sym b
  • l
a is iden tied with [B ; a].

The blank is [B ; B ].
  • Here's
a program to nd the , assuming it is somewhere to the left
  • f
the presen t p
  • sition.
1.
  • (q
; [B ; X ]) = (q ; [B ; X ]; L) 2.
  • (q
; [; X ]) = (p; [B ; X ]; R) Other TM Mo dels While regular
  • r
CF languages are classes
  • f
languages that w e dened b y con v enien t notations (RE's, CF G's, etc.), no
  • ne
supp
  • sed
that they represen ted \ev erything w e can compute." 1
slide-2
SLIDE 2
  • The
purp
  • se
  • f
the TM w as to dene \ev erything w e can compute."

F
  • r
con v enience, w e use recognition
  • f
languages as the space
  • f
p
  • ssibly
computable things;
  • ther
spaces, e.g., computing arithmetic functions, yield the same conclusions.
  • Th
us, it w
  • uld
b e a wkw ard if w e could nd another notion
  • f
\ev erything" that w as dieren t from the TM.

A real computer is an imp
  • rtan
t sp ecial case. Do real computers and TM's dene the same set
  • f
computable things?
  • Our
next steps are to consider p
  • ten
tially more p
  • w
erful notions
  • f
computing and see that the TM mo del w e dened can sim ulate them.

These mo dels are: m ultitap e TM, nondeterministic TM, m ultistac k mac hines, coun ter mac hines, \real" computers. Multitap e TM's Allo w the TM to ha v e some nite n um b er
  • f
tap es k , with a head for eac h tap e.
  • Mo
v e is a function
  • f
the state and the sym b
  • l
scanned b y eac h tap e head.
  • Action
= new state, new sym b
  • l
for eac h tap e, and a head motion (L, R,
  • r
S, for \stationary").
  • First
tap e holds the input,
  • ther
tap es are initially blank. Man y T ap es to One T ap e Sim ulati
  • n
T
  • sim
ulate k tap es, use
  • ne
tap e with 2k trac ks.
  • One
trac k holds the con ten ts
  • f
eac h tap e.
  • Another
trac k holds a mark represen ting the head p
  • sition
  • f
that tap e, as
  • W
X Y Z
  • T
  • sim
ulate
  • ne
mo v e
  • f
the m ultitap e TM, the
  • ne-tap
e TM m ust remem b er ho w man y *'s are to its left. 2
slide-3
SLIDE 3 1. Mo v e left, then righ t, visiting all the *'s to see what eac h tap e head is scanning. 2. Decide
  • n
the m ultitap e TM's mo v e, based
  • n
the scanned sym b
  • ls
and its state (remem b ered in the state
  • f
the
  • ne-
tap e TM). 3. Visit eac h * again, making the necessary adjustmen ts: c hange sym b
  • ls
and mo v e *'s
  • ne
cell left
  • r
righ t, as needed.
  • Imp
  • rtan
t
  • bserv
ation for when w e study p
  • lynomial
time TM's: If the m ultitap e TM mak es T (n) mo v es when the input is
  • f
length n, then the
  • ne-tap
e TM mak es O
  • T
2 (n)
  • mo
v es.

Th us, if the m ultitap e TM tak es p
  • lynomial
time, so do es the
  • ne-tap
e TM.

Key p
  • in
t in pro
  • f:
The *'s can't get more than T (n) cells apart, so
  • ne
mo v e is sim ulated in O
  • T
(n)
  • mo
v es
  • f
the
  • ne-
tap e TM. Nondetermini st ic TM Let the TM ha v e a nite set
  • f
c hoices
  • f
mo v e.
  • As
with the (nondeterministic) PD A, there is no \mix-and-m a tc h"; if (p; X ; L) and (q ; Y ; R) are c hoices, w e cannot go to state q , prin t X
  • n
the cell and mo v e righ t, e.g., unless (q ; X ; R) is another c hoice. Nondetermini st ic to Determini sti c Sim ulati
  • n
Let the NTM ha v e
  • ne
tap e, but rst sim ulate with a m ultitap e DTM; later con v ert the m ultitap e DTM to a
  • ne-tap
e DTM.
  • Use
  • ne
tap e
  • f
DTM to hold a queue
  • f
ID's
  • f
the NTM, separated b y sp ecial mark ers (*).
  • When
an ID reac hes the fron t
  • f
the queue, nd all its next ID's, and add them to the bac k
  • f
the queue.
  • Accept
if y
  • u
ev er reac h an ID with an accepting state.

Note that the queue discipline is imp
  • rtan
t, so that the DTM ev en tually reac hes ev ery ID that the NTM can en ter.

In con trast, if w e used a stac k discipline, the NTM migh t reac h acceptance, but the 3
slide-4
SLIDE 4 DTM w
  • uld
go
  • n
some innite c hase
  • f
ID's and nev er reac h the accepting ID
  • f
the NTM. MultiStac k Mac hines Lik e PD A, but with more than
  • ne
stac k.
  • One
stac k is not enough to sim ulate a TM; y
  • u
get
  • nly
CFL's.

While w e ha v en't emphasized the p
  • in
t, all the examples in Section 7.2.3
  • f
non- CFL's are recognized b y TM's.
  • But
2 stac ks is enough!
  • Key
idea: use
  • ne
stac k to hold what is to the left
  • f
the tap e head, use the
  • ther
to hold what is to the righ t. Coun ter Mac hines Tw
  • equiv
alen t w a ys to think
  • f
a coun ter: 1. A stac k with a b
  • ttom-mark
er, sa y Z , and
  • ne
  • ther
sym b
  • l,
sa y X , that can b e placed
  • n
the stac k.

Th us, stac k alw a ys lo
  • ks
lik e X X
  • X
Z . 2. A device that holds a nonnegativ e in teger, with the
  • p
erations add 1, subtract 1, and test-if-0.
  • 1
coun ter = subset
  • f
CFL's, including all regular languages and some nonregular languages lik e f0 n 1 n j n
  • 1g.
  • 2
coun ters = TM!

Pro
  • f
in t w
  • stages:
3 coun ters sim ulate 2 stac ks, then 2 coun ters sim ulate 3 coun ters. 2 Stac ks to 3 Coun ters Supp
  • se
a stac k has r
  • 1
sym b
  • ls.
Think
  • f
the stac k con ten ts as a base-r n um b er, with the sym b
  • ls
as digits 1 through r
  • 1.
  • Use
  • ne
coun ter for eac h stac k, plus
  • ne
\scratc h" coun ter.
  • Multiply
and divide b y r using t w
  • coun
ters.

Subtract r from
  • ne,
add 1 to the
  • ther,
  • r
vice-v ersa.
  • Push
X = m ultiply b y r , then add digit represen ted b y X . 4
slide-5
SLIDE 5
  • P
  • p
= divide b y r , thro w a w a y the remainder.
  • Read
top sym b
  • l
= mo v e from
  • ne
coun ter to the
  • ther,
coun ting in the state mo dulo r to determine the remainder. 3 Coun ters to 2 Coun ters Key idea, represen t coun ters i, j , and k b y the in teger 2 i 3 j 5 k .
  • Store
this n um b er
  • n
  • ne
coun ter, use the
  • ther
coun ter as scratc h.
  • T
est if i = b y mo ving coun t from
  • ne
coun ter to the
  • ther,
coun ting mo dulo 2 in the state.

i = if and
  • nly
if the n um b er is not divisible b y 2.
  • T
ests for j = and k = analogous.
  • Adding
to i, j , k are m ultiplicati
  • ns
  • f
the coun t b y 2, 3, 5, resp ectiv ely .
  • Subtractions
are similarly divisions. Real Computers In
  • ne
sense, a real computer has a nite n um b er
  • f
states, and th us is we aker than a TM.
  • W
e ha v e to p
  • stulate
an innite supply
  • f
tap es, disks,
  • r
some p eriferal storage device to sim ulate an innite TM tap e.
  • Assume
h uman
  • p
erator to moun t disks, k eep them stac k ed neatly
  • n
the sides
  • f
the computer. TM to Real Computer Computer can sim ulate nite con trol, and moun t
  • ne
disk that holds the region
  • f
the TM tap e around the tap e head.
  • When
the tap e head mo v es
  • this
region, the computer prin ts an
  • rder
to ha v e its disk mo v ed to the top
  • f
the left
  • r
righ t pile, and the top
  • f
the
  • ther
pile moun ted. Real Computer to TM Sim ulation is at the lev el
  • f
stored instructions and w
  • rds
  • f
memory .
  • TM
has
  • ne
tap e that holds all the used memory lo cations, and their con ten ts. 5
slide-6
SLIDE 6
  • Other
TM tap es hold the instruction coun ter, memory address, computer input le, and scratc h.
  • Instruction
cycle
  • f
computer sim ulated b y: 1. Find the w
  • rd
indicated b y the instruction coun ter
  • n
the memory tap e. 2. Examine the instruction co de (a nite set
  • f
  • ptions),
and get the con ten ts
  • f
an y memory w
  • rds
men tioned in the instruction, using the scratc h tap e. 3. P erform the instruction, c hanging an y w
  • rds'
v alues as needed, and adding new address-v alue pairs to the memory tap e, if needed. Comparison
  • f
Running Times
  • If
the computer can do a m ultiplicatio n
  • f
w
  • rds
whose length is not limited (e.g., to 64 bits, as
  • n
most computers), then the length
  • f
the longest v alue can double at eac h step, and it tak es O (2 T (n) ) steps
  • f
the TM to sim ulate T (n) steps
  • f
the computer.
  • Ho
w ev er, if w e limit the length
  • f
w
  • rds
to, sa y , 64,
  • r
w e allo w arbitrarily long w
  • rds
but
  • nly
instructions that add at most 1 to the length in
  • ne
step (e.g., addition), then O
  • T
3 (n)
  • steps
  • f
the TM suce to sim ulate T (n) computer steps.

Th us, p
  • lynomial
  • tim
e computer program b ecomes p
  • lynomial-ti
m e TM.

Wh y? Memory tap e can
  • nly
gro w to O
  • T
2 (n)
  • .
Th us,
  • ne
step tak es O
  • T
2 (n)
  • n
the TM, and T (n) steps tak e O
  • T
3 (n)
  • .
6