This preview shows pages 1–3. Sign up to view the full content.
Module 6
Pushdown automata
The automaton for contextfree languages
CS 360: Introduction to the Theory of Computing
Daniel G. Brown, University of Waterloo
6.1
Topics for this module
•
Pushdown automata deﬁnitions
•
Languages of pushdown automata
•
The equivalence of pushdown automata and contextfree grammars
•
Deterministic PDAs
The theorem that relates CFLs and PDAs was discovered by a few people, but one was the famous
linguist Noam Chomsky.
6.2
1
Pushdown automata
Pushdown automaton
We need a new machine to accept contextfree languages.
Our new machine is called a
pushdown automaton
.
•
The basic limitation of DFA/NFAs: no ability to keep inﬁnite memory.
–
Important
: FAs can keep a
ﬁnite
amount of memory:
k
bits can be stored by multiplying
the state space by 2
k
.
•
Pushdown automata have inﬁnite memory, but only accessed in proscribed order.
–
Things added to the memory recently must be read before things added long in the past.
–
This is why
L
=
{
ss

s
∈
Σ
*
}
won’t be accepted by them: we’d have to look back very
far in the memory.
6.3
From an
ε
NFA to a PDA
We treat the memory as a stack, and have a ﬁnite automaton controlling it.
Each transition is of the form:
•
If top letter on the memory stack is
b
, and next letter in the input is a (or
ε
, if we don’t read an
input letter), and the controlling FA is in state
q
, then:
•
Go to state
r
, take the
b
off the top of the memory stack, eat the letter
a
from the input (again,
a
might be
ε
), and write word
w
onto the top of the memory stack.
6.4
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentEnvisioning a PDA
a
w
Each move:
•
Take top plate off stack, next letter in input sequence (or
ε
transition).
•
Based on current state, go to different state, (maybe) put new plates on stack.
Important
: PDAs are also nondeterministic.
6.5
More tweaks in how they work
The stack must never be empty:
•
There is a special “stack empty” symbol
Z
0
.
–
If
Z
0
is on the top of the stack, we make sure it gets returned to bottom of stack after the
next move.
•
The string put on the stack may be empty (stack gets 1 symbol shorter), or long.
•
It does not have to just be 0 or 1 letters long!
•
It
must
be of ﬁnite length.
And, again, very important: PDAs are by deﬁnition nondeterministic unless otherwise stated.
(Deterministic PDAs are not as powerful as nondeterministic ones!)
6.6
Formal deﬁnitions
Doesn’t seem too bad, but turns into a 7tuple!
A PDA is a 7tuple,
M
= (
Q
,
Σ
,
Γ
,
δ
,
q
0
,
Z
0
,
F
)
, where:
•
Q
= ﬁnite set of states for control
•
Σ
= ﬁnite input alphabet
•
Γ
= ﬁnite stack alphabet (often, it’s just
Γ
=
{
Z
0
}∪
Σ
)
•
δ
= transition function
•
q
0
= start state for machine
•
Z
0
= stack start letter (bottom of stack character)
•
F
= accepting states for ﬁnite control
6.7
What do all of these elements mean?
This is the end of the preview. Sign up
to
access the rest of the document.
 Winter '08
 JohnWatrous

Click to edit the document details