Automata Lectuee6
Automata Lectuee6
FACULTYOFCOMPUTERSANDINFORMATION
جامعة المنوفية
Today Proverb
العلم نور
Knowledge is power
Pushdown Automata
(PDA)
2
Pushdown Automata (PDA)
Definition:
•PDA is an extension of the nondeterministic finite automaton
with transition.
• The pushdown automaton can remember an infinite amount of
information.
• FA to Reg Lang
• PDA is the automata for CFLs
PDA == [ -NFA + “a stack” ]
•Why a stack?
• The stack can be read, pushed and popped only at the
top.
Input string -NFA Accept / reject
old state input symbols Stack top new state(s) new Stack top(s)
δ: Q x ∑ x => Q x
ε, ε → Z0
0011 0. ε → 0
1, 0 → ε
ε, Z0 → ε
1, 0 → ε
• PDA that recognizes L = { 0n1n | n ≥ 0 }
ε,ε → Z0
11
001
01 0, ε → 0
11
1, 0 → ε
ε, Z0 → ε
1 1, 0→ ε
$ $
The Transition Function (δ)
old state input symb. Stack top new state(s) new Stack top(s)
δ: Q x ∑ x => Q x
δ(q, a, X) = {(p, Y), …}
1. state transition from q to p X Y
a
2. a is the next input symbol q p
3. X is the current stack top
symbol
rminnism
ism
Y=? Action
4. Y is the replacement for X;
it is in * (a string of stack
ddeetteermi
Current
state
Next
a, X / Y state
qi qj
q0 q1 q2
, Z0/Z0
, Z 0 / Z0 , Z 0 / Z0
, 0 / 0
, 1 / 1
Go to acceptance
Switch to
popping mode
q0 q1 q2
, Z0 / Z0 ), ( / , Z0 / Z0
, Z0 / Z0 Go to acceptance (by final
state) when you see the
(, ( / ( ( stack bottom symbol
Switch to (, Z0 / ( Z0
popping mode
To allow adjacent
blocks of nested
paranthesis
Example
• Another Design of Language of Balanced
Parenthesis.
(,Z0 / ( Z0 ∑ = { (, ) }
= {Z0, ( }
(,( / ( (
), ( / Q = {q0, q1}
, Z0/ Z0
start
q0 q1
, Z0/ Z0