Pushdown Automata
Pushdown Automata
Dr, 1
Overview
2
Push down Automata (PDA)
• This is similar to the FSM, but has additional memory
• This memory uses a stack, which has two operations:
• Push (add a new symbol at the top) Used to manipulate the
• Pop (read and remove the top symbol) stacks from the states
FSM
Stack
inputs
0 0 0 1 1 1
start
Criteria: All inputs are
completely consumed
Z0
δ
Z0 = top T1 T2 T3 T4 T5 T6
symbol and
also marks the X Z0
Bottom of the X accept
stack Z0 X X X
X
Marker to Push 0 X X Pop 1
X Z0
count the
number of Z0 Z0 Pop 1
zeros on the Z0 9
input Push 0 Pop 1
Push 0
State q State p
State
Operations
• Note that transitions of the PDA is the form:
a, x y … a …
Input string
This implies that if “a” is seen in the input string, and there is an
“x” symbol on top of the stack,
“y” is then added and the “x” is removed
10
State Operations
(Replace)
Push symbol
Input symbol a, b c
a, b c
q1 q2
b c
Transition to state q 2 11
f
f
replace $
$
State Operation
(Push)
Push symbol
Input symbol a,
c
Top stack symbol
a,
q1 q2
c c
b b
Transition to state q 2 12
f f
push
$ $
State Operation
(Pop)
Push symbol
Input symbol a, b
a, b
q1 q2
b
Transition to state q 2 f 13
f
pop $
$
State Operation (No
change)
Push symbol
Input symbol a,
Top stack symbol
a,
q1 q2 Note: the Automaton will
halts or rejects input if
b b there is an attempt to
Transition to state q2 f
perform a pop or replace
f operation on an empty 14
$
No change $ stack.
Condition for PDA acceptance or
rejection
15
Empty stack indicator
($)
16
Familiar
Example
• Consider the Machine to accept the PDA for the language {an bn | n ≥ 1}
: 17
.
Sequence of moves (Goes to
“˫”)
• To describe the sequence of moves of the previous
example, the following holds:
• (q0, 000111, Z0) ˫ (q0, 00111, 0Z0) ˫
• (q0,0111, 00Z0) ˫ (q0, 111, 000Z0) ˫
• (q1, 11, 00Z0) ˫ (q1, 1,0Z0) ˫
• (q1, , Z0) ˫ (q2, , Z0 )
18
Sequence of moves (Goes to
“˫”)
• In a situation where there is an extra 1 eg. 0001111 on
the input, this gives the following sequence:
• (q0, 0001111, Z0) ˫ (q0, 001111, 0Z0) ˫
• (q0,01111, 00Z0) ˫ (q0, 1111, 000Z0) ˫
• (q1, 111, 00Z0) ˫ (q1, 11, 0Z0) ˫ (q1, 1, Z0) ˫
• (f, , Z0)
19
• Consider the Machine to accept the PDA for the language {an b2n | n ≥ 1}
• Consider the Machine to accept the PDA for the language {WcWr}
• Consider the Machine to accept the PDA for the language {WWr }
THANK
YOU!
20