Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

Lecture 13:

Turing Machines

cs302: Theory of Computation


University of Virginia David Evans
Computer Science http://www.cs.virginia.edu/evans
The Story So Far

ng
Lem umpi
For ma
s
P

CFL
ma rs

te s
d G r am
Indexe

la
Vio
0 n1 n
01
n n 2n
g
m pin
0n t es Pu r RLs
la o
Vio ma F
Lem
Described by DFA, NFA, RegExp, w De
scr
ib
RegGram Gr ed b
am y
ma LL(k
r )

De
scri
be PDA
Regular Languages

ND
db
C FLs

yC
c
inisti

FG
rm
Dete

,
g u a ges
LL(k)
Lan ng u ages
-F re e La
ex t
Cont

Lecture 13: Turing Machines 2


ng
Lem umpi
The Story So Far (Simplified)

For ma
s
P

CFL
la te s
Vio
0n1n
g
m pin
0n t es Pu r RLs
la o
Vio ma F
Lem
Described by DFA, NFA, RegExp, w
RegGram

De
sc ND
rib PD
Regular Languages

ed A
by
CF
,G
es
La nguag
x t-F ree
e
Cont

Lecture 13: Turing Machines 3


Computability Story: This Week

Languages recognizable by
any mechanical computing
machine

Lecture 13: Turing Machines 4


Computability Story: Next Week
Undecidable Problems

Decidable Problems

Recognizable Languages

Lecture 13: Turing Machines 5


Computability  Complexity (April)

Decidable Problems
Decidable Problems

NP

Note: not known if P  NP or P = NP


Problems that can be solved Problems that can be solved by a
by a computer (eventually). computer in a reasonable time.

Lecture 13: Turing Machines 6


Exam 1

Lecture 13: Turing Machines 7


Exam 1
• Problem 4c: Prove that the language {0n1n2} is
not context-free.
Pumping lemma for CFLs says
Lengths of strings in L: there must be some way of
n = 0 0 + 02 = 0 picking s = uvxyz such that
n = 1 1 + 12 = 2 m = |v| + |y| > 0 and uvixyiz in L for
n = 2 2 + 22 = 6 all i.
n = 3 3 + 32 = 12 So, increasing i by 1 adds m
... symbols to the string, which must
n = k k + k2 produce a string of a length that is
not the length of a string in L.
Lecture 13: Turing Machines 8
n n2
Recognizing {0 1 }

DPDA with two stacks?

DPDA with three stacks?

...
?

Lecture 13: Turing Machines 9


n n2
3-Stack DPDA Recognizing {0 1 }
0, ε/ε/ε $/$/$
0, ε/ε/ε +/ε/+
Count
Start 0s 1, +/ε/ε ε/+/ε 1, +/$
ε/ε
ε/
/+ ε
/+/ε
/ ε
$  /ε 1s 1, $/+/+ $/ε/ε
/ ε
$/$  b->r
1, ε /$ 1s
$/
1, 1, +/ε/ε ε/+/ε r->b

ε
Done +/
1, ε/$/$ ε/ε/ε / ε
/ +
ε
1,
Lecture 13: Turing Machines 10
Can it be done with 2 Stacks?

Lecture 13: Turing Machines 11


Simulating 3-DPDA with 2-DPDA

A B
Lecture 13: Turing Machines 12
Simulating 3-DPDA with 2-DPDA +
pushB($)
pushB(popA())
...
pushB(popA(#))
# pushB(popA())
...
pushB(popA(#))
res = popA()
pushA(popB(#))
# pushA(popB())
pop green ...
$
3-DPDA popB($)
A B
Lecture 13: Turing Machines 13
2-DPDA + Forced ε-Transitions

Need to do lots of stack


manipulation to simulate
# 3-DPDA on one transition:
need transitions with no
input symbol (but not
nondeterminism!)
#
$
A B
Lecture 13: Turing Machines 14
Impact of Forced ε-Transitions

What is the impact of adding


non-input consuming transitions?
#
DPDA in length n input:
runs for  n steps
DPDA+ε in length n input:
#
can run forever!
$
A B
Lecture 13: Turing Machines 15
Is there any computing
machine we can’t simulate
with a 2-DPDA+?

Lecture 13: Turing Machines 16


What about an NDPDA?

Use one stack to simulate the


NDPDA’s stack.

Use the other stack to keep track


of nondeterminism points: copy
of stack and decisions left to
make.

A B
Lecture 13: Turing Machines 17
Turing Machine?

Tape Head

A B
Lecture 13: Turing Machines 18
Turing Machine

...

FSM
Infinite tape: Γ*
Tape head: read current square on tape,
write into current square,
move one square left or right
FSM: like PDA, except:
transitions also include direction (left/right)
final accepting and rejecting states
Lecture 13: Turing Machines 19
Turing Machine Formal Description
...

FSM
7-tuple: (Q, , Γ, δ, q0, qaccept, qreject)
Q: finite set of states
: input alphabet (cannot include blank symbol, _)
Γ: tape alphabet, includes  and _
δ: transition function: Q  Γ  Q  Γ  {L, R}
q0: start state, q0  Q
qaccept: accepting state, qaccept  Q
qreject: rejecting state, qreject  Q (Sipser’s notation)
Lecture 13: Turing Machines 20
Turing Machine Computing Model
x Initial configuration:

x x x x x x x _ _ _ _ ...

blanks
input
FSM
q0 TM Configuration: Γ*  Q  Γ*

tape contents current tape contents


left of head FSM state head and right

Lecture 13: Turing Machines 21


TM Computing Model
δ*: Γ*  Q  Γ*  Γ*  Q  Γ*

The qaccept and qreject states are final:

δ*(L, qaccept, R)  (L, qaccept, R)


δ*(L, qreject, R)  (L, qreject, R)

Lecture 13: Turing Machines 22


TM Computing Model
δ*: Γ*  Q  Γ*  Γ*  Q  Γ*
u, v  Γ*, a, b  Γ
a b ...

u v
FSM
q
δ*(ua, q, bv) = (uac, qr, v) if δ(q, b) = (qr, c, R)
δ*(ua, q, bv) = (u, qr, acv) if δ(q, b) = (qr, c, L)
Also: need a rule to cover what happens at left edge of tape

Lecture 13: Turing Machines 23


Thursday’s Class
Read Chapter 3:
• Robustness It contains the most bogus sentence in the
whole book. Identify it for +25 bonus points
of TM model (only 1 guess allowed!)
• Church-
Turing
Thesis

Lecture 13: Turing Machines 24

You might also like