Professional Documents
Culture Documents
Lecture 6
PUSHDOWN AUTOMATA
PUSHDOWN AUTOMATA
A pushdown automata (PDA) is essentially an NFA with a
stack.
On a transition the PDA:
1. Consumes an input symbol.
2. Goes to a new state (or stays in the old).
3. Replaces the top of the stack by any string (does nothing, pops
the stack, or pushes a string onto the stack)
PUSHDOWN AUTOMATA
FORMAL DEFINITION OF A
PUSHDOWN AUTOMATON (PDA)
A pushdown automaton is a 6-tuple (Q, , ,, q0, F), where Q, ,
and F are all finite sets, and
FORMAL DEFINITION OF A
PUSHDOWN AUTOMATON (PDA)
TRANSITION FUNCTION : Q x x P(Q x )
FORMAL DEFINITION OF A
PUSHDOWN AUTOMATON (PDA)
Actions of the PDA
If (q, a, Z) contains (p, ) among its actions, then one thing
the PDA can do in state q, with a at the front of the input,
and Z on top of the stack is:
1. Change the state to p.
2. Remove a from the front of the input (but a may be ).
3. Replace Z on the top of the stack by .
Input
Stack
q1
q2
q3
q4
{(q2,$)}
{(q2,0)}
{(q3, )}
{(q3, )}
{(q4, )}
Input
Stack
q1
q2
q3
{(q2,$)}
{(q2,0)}
{(q3, )}
{(q3, )}
{(q4, )}
q4
(q1, , ) = {(q2, $)}. Push the $symbol to mark the bottom of the stack.
(q2, 0, ) = {(q2, 0)}. Push 0 onto the stack for each 0 read from the input.
(q2, 1, 0) = {(q3, )}. When we see a 1, go to state q3 and pop one 0.
(q3, 1, 0) = {(q3, )}. Pop one 0 from the stack for every 1 read from input.
(q3, , $) = {(q4, )}. Accept if stack bottom is reach and last state is accept.
Input
Stack
q1
q2
{(q2,$)}
{(q2,0)}
q3
{(q3, )}
{(q3, )}
{(q4, )}
q4
q1
, $
0, 0
q2
1, 0
q4
, $
q3
1, 0
Stack is empty
11
12
0
$
13
0
0
$
14
0
0
0
$
15
0
0
$
16
0
$
17
q3
18
q4
Stack is empty
19
b,a
q1
, $
q3
,$
q4
q2
a, a
q5
b,
q6
c,a
, $
q7