Professional Documents
Culture Documents
Pushdown Automata
1. Final State Acceptability: In final state acceptability, a PDA accepts a string when, after reading the
entire string, the PDA is in a final state. From the starting state, we can make moves that end up in a
final state with any stack values. The stack values are irrelevant as long as we end up in a final state.
For a PDA (Q, ∑, S, δ, q0, Z0, F), the language accepted by the set of final states F is −
L(PDA) = {w | (q0, w, Z0) →* (qf , ε, Z0), q ∈ F} for any input stack string Z0. (see Solution-1 (a) and (b))
2. Empty Stack Acceptability: Here a PDA accepts a string when, after reading the entire string, the
PDA has emptied its stack.
For a PDA (Q, ∑, S, δ, q0, Z0, F), the language accepted by the empty stack is −
L(PDA) = {w | (q0, w, Z0) →* (q, ε, ε), q ∈ Q}. (see Solution-1 (c) and (d))
(a) (b)
Example-3: Design a PDA that accepts an equal number of a’s and equal number of b’s
where, either n number of a’s followed by n number of b’s or n number of b’s followed
by n number of a’s.
Solution: δ(𝑞0 , a, 𝑍0 ) → (𝑞0 , a𝑍0 ) δ(𝑞0 , a, 𝑍0 ) → (𝑞0 , a𝑍0 )
δ(𝑞0 , b, 𝑍0 ) → (𝑞0 , b𝑍0 ) δ(𝑞0 , b, 𝑍0 ) → (𝑞0 , b𝑍0 )
δ(𝑞0 , a, 𝑎) → (𝑞0 , a𝑎) δ(𝑞0 , a, 𝑎) → (𝑞0 , a𝑎)
δ(𝑞0 , b, 𝑏) → (𝑞0 , b 𝑏) 𝑜𝑟 δ(𝑞0 , b, 𝑏) → (𝑞0 , b 𝑏)
δ(𝑞0 , b, 𝑎) → (𝑞0 , Λ) δ(𝑞0 , b, 𝑎) → (𝑞1 , Λ)
δ(𝑞0 , a, 𝑏) → (𝑞0 , Λ) δ(𝑞1 , b, 𝑎) → (𝑞1 , Λ)
δ(𝑞0 , Λ, 𝑍0 ) → (𝑞𝑓 , 𝑍0 ) δ(𝑞0 , a, 𝑏) → (𝑞1 , Λ)
δ(𝑞1 , a, 𝑏) → (𝑞1 , Λ)
(a)
δ(𝑞1 , Λ, 𝑍0 ) → (𝑞𝑓 , 𝑍0 )
(b)
Transition Diagrams are as follows:
(a) (a)
Example-4: Design a PDA which accepts the language: L= {w ∈ {a, b}* : w has equal number of a’s and b’s}.
Solution: δ(𝑞0 , a, 𝑍0 ) → (𝑞0 , a𝑍0 )
δ(𝑞0 , a, 𝑍0 ) → (𝑞0 , a𝑍0 ) δ(𝑞0 , b, 𝑍0 ) → (𝑞0 , b𝑍0 )
δ(𝑞0 , b, 𝑍0 ) → (𝑞0 , b𝑍0 ) δ(𝑞0 , a, 𝑎) → (𝑞0 , a𝑎)
δ(𝑞0 , a, 𝑎) → (𝑞0 , a𝑎) δ(𝑞0 , b, 𝑏) → (𝑞0 , b 𝑏)
δ(𝑞0 , b, 𝑏) → (𝑞0 , b 𝑏) δ(𝑞0 , b, 𝑎) → (𝑞1 , Λ)
δ(𝑞0 , b, 𝑎) → (𝑞0 , Λ) δ(𝑞1 , b, 𝑎) → (𝑞1 , Λ)
δ(𝑞0 , a, 𝑏) → (𝑞0 , Λ) δ(𝑞0 , a, 𝑏) → (𝑞1 , Λ)
δ(𝑞0 , Λ, 𝑍0 ) → (𝑞𝑓 , 𝑍0 ) δ(𝑞1 , a, 𝑏) → (𝑞1 , Λ)
δ(𝑞1 , Λ, 𝑍0 ) → (𝑞𝑓 , 𝑍0 )
(a)
(b)
Transition Diagrams are as follows:
(a) (b)
Example-5: Design a PDA which accepts the language: L= {𝑎𝑛 𝑏𝑚 | 𝑚, 𝑛 ≥ 1 𝑎𝑛𝑑 𝑛 ≠ 𝑚}.
Solution:
Example-6: Design a PDA which accepts the language: L= {𝑎𝑚+𝑛 𝑏𝑚 𝑐 𝑛 | 𝑚, 𝑛 ≥ 1}.
Solution:
Example-7: Design a PDA which accepts the language: L= {𝑎𝑛 𝑏𝑚+𝑛 𝑐 𝑚 | 𝑚, 𝑛 ≥ 1}.
Solution:
Example-8: Design a PDA which accepts the language: L= {𝑎𝑛 𝑏2𝑛 | 𝑛 ≥ 1}.
Solution:
Example-9: Design a PDA which accepts the language: L= {𝑎𝑛 𝑏𝑛 𝑐 𝑚 | 𝑚, 𝑛 ≥ 1}.
Solution:
Example-10: Design a PDA which accepts the language: L= {𝑤𝑐𝑤 𝑅 | 𝑤 ∈ {𝑎, 𝑏}+ }.
Solution:
Example-11: Design a PDA which accepts the language: L= {𝑤𝑤 𝑅 | 𝑤 ∈ {𝑎, 𝑏}+ }.
Solution:
Important Point:
• PDA is a type of machine in which stack is use as a memory so it able to remember strings but in
Finite State Machine (FSM) does not have memory to remember arbitrarily strings.
• PDA is more powerful than the FSM.
Justification: Any language which can be acceptable by FSM can also be acceptable by PDA. PDA also
accepts a class of language which even cannot be accepted by FSM. Thus PDA is much more powerful
than FSM.
• NPDA (Non deterministic Pushdown Automata) and DPDA (Deterministic Pushdown Automata) are
not equivalent in power. NPDA is more powerful than DPDA which means for every language for
which a DPDA exist, there exist an NPDA but there are some languages that are accepted by NPDA
but are not accepted by DPDA.
• The two stack pushdown automata is equivalent to the Turing machines if we are only talking about
computability and not time complexity.