The pushdown automata
Informal defition (Figure 2.12)
State control
Input source
Stack
Formal definition (Definition 2.13)
Q: set of states
Σ: input alphabet
Γ: stack alphabet
δ: transition function
Q × Σε × Γε → ℘(Q × Γε)
q0: start state
q0 ∈ Q
F: accept states
F ⊆ Q
All sets are finite.
By convention, $ is a special start-of-stack character
Examples: 2.14 – 2.19
Context free grammar to pushdown automaton
pushdown automaton
Σ: grammar terminals
Γ: terminals, variables, and the marker $
actions
start by placing $ on the stack
next place start variable on the statck
while ...
if top of stack is terminal a
if next input symbol is a
pop top of stack
otherwise
abandon this branch
if top of stack is variable A
pop A
push right hand side of some rule for A
there may be many non-determinate choices
if top of stack is terminal $
enter the accept state
Some of these actions will require a series of state transitions
Figure 2.23
Be sure to reverse the right hand side of the rule!
Let’s try it out:
Example 2.25
Pushdown automaton to context free grammar
This is the hard one.
Preliminary modifications to the pushdown automaton
Adam Whitley’s slides 9 & 10 are better than the textbook’s
Create qaccept as the only accept state
Route existing accept states to qaccept
Empty the stack before accepting
Use qcleanup
Each transition does one of the following
Pushes a symbol on the stack
Pops a symbol off the stack
Outline of construction (p. 122)
Suppose PDA P is (Q, Σ, Γ, δ, q0, qaccept)
Construct grammar G!
Variables of G are {Ap,q | p,q ∈ Q}
Terminals of G are Σ
Start variable of G is Aq0,qaccept
Building the rules!
For each p ∈ Q;
Add the rule Ap,p → ε
For each p, q, r ∈ Q;
Add the rule Ap,r → Ap,q Aq,r
For each p, q, r, s ∈ Q;
u ∈ Γ and a, b ∈ Σε
where (r, u) ∈ δ(p, a, ε) and (q, ε) ∈ δ(s, b, u)
Add the rule Ap,q ⇒ a Ar,s b
Look at Figures 2.28 and 2.29
Claims 2.30 and 2.31
Ap,q generates the string x
iff
x can bring P from p with empty stack to q with empty stack