Push Down Automata With Exampless
Push Down Automata With Exampless
Automaton
Working Memory
Stack
Input
Memory Output
CPU Memory
n bits
Program Memory
Pushdown Automaton
stack
top
Finite State Control
δ
q
..
Accept/Reject
states
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ stack push
q0 q1 q2 stack top
symbol
input symbol
symbol
ϵ, $ → ϵ
initial state
accepting states a, b → c
qi qj
transition for every state, input symbol, and stack symbol
states
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ stack push
q0 q1 q2 stack top
symbol
input symbol
symbol
ϵ, $ → ϵ
initial state
accepting states a, b → c
qi qj
transition for every state, input symbol, and stack symbol
states
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ stack push
q0 q1 q2 stack pop
symbol
input symbol
symbol
ϵ, $ → ϵ
initial state
accepting states a, b → c
qi qj
transition for every state, input symbol, and stack symbol
input input
··· a ··· ··· a ···
a, b → c
qi qj
stack stack
top top
b c
.. ..
$ $
input input
··· a ··· ··· a ···
a, ϵ → c
stack
qi qj stack
top
c
top
b b
.. ..
$ $
input input
··· a ··· ··· a ···
a, b → ϵ
qi qj
stack stack
top
b
top
x x
.. ..
$ $
input input
··· a ··· ··· a ···
a, ϵ → ϵ
qi qj
stack stack
top top
b b
.. ..
$ $
stack
top
HALT
c
→ transition on ϵ
a ,b
ϵ, ϵ → c
multiple ϵ, b → c
transitions
a,
b→
c
no symbol consumed
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ ϵ, $ → $
q0 q1 q2 q3
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ ϵ, $ → $
q0 q1 q2 q3
ϵ, ϵ → $ 1, 0 → ϵ ϵ, $ → $
q0 q1 q2 q3
ϵ, ϵ → $ 1, 0 → ϵ ϵ, $ → $
q0 q1 q2 q3
The PDA rejects the string w because there is no transition possible from
the configuration (q2 , 01, $)
d d
→
a,
b b→ d d
ϵ, b → b→
a, ϵ,
a, ϵ, c
c→ → a, ϵ, b
d d b→ →
e e
0, ϵ → 0 1, 0 → ϵ
ϵ, ϵ → $ 1, 0 → ϵ ϵ, $ → $
q0 q1 q2 q3
b, ϵ → b b, b → ϵ
a, ϵ → a a, a → ϵ
#, ϵ → ϵ ϵ, $ → $
q0 q1 q2
b, ϵ → b b, b → ϵ
a, ϵ → a a, a → ϵ
ϵ, ϵ → ϵ ϵ, $ → $
q0 q1 q2
0, ϵ → 0 1, ϵ → ϵ 2, 0 → ϵ
ϵ, ϵ → ϵ 2, 0 → ϵ ϵ, $ → ϵ
q0 q1 q2 q3
ϵ, $ → ϵ
ϵ, $ → ϵ
a, ϵ → a b, a → ϵ
ϵ, ϵ → $ ϵ, ϵ → ϵ
start q0 q1 q2 c, $ → $
ϵ, $ → $
ϵ, $ → $
ϵ, ϵ → ϵ
ϵ, $ → $
b, ϵ → ϵ q4 q3
ϵ, $ → $
c, a → ϵ
c, a → ϵ q5
The intuition behind the pumping lemma is that a long enough string
in a context-free language must have a repeated pattern in its
derivation tree, and this pattern can be pumped up or down without
leaving the language
The following languages that are not context-free, and hence cannot be
decided by a PDA
L6 = {an b n c n |n ≥ 0}
L7 = {an b m c n d m |n, m ≥ 0}
2
L8 = {an |n ≥ 0}