Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Pushdown Automata

Example 1:
Construct a PDA machine for the following language :
L = { an bn | n ≥ 1 }
with the input string : ( aabb)
Solution :
• We must find the procedure :
input Stack’s operations Top of stack
1 Read (a) Push (a) Z0 → a
2 Read (a) Push (a) a
3 Read (b) Pop (a) a
4 Read (b) Pop (a) a
5 Read (λ) accepted Z0
• The transition function :
δ(q0, a, Z0 ) = ( q0, aZ0)
δ(q0, a, a ) = ( q0, aa)
δ(q0, b, a ) = ( q1, ꜫ )
δ(q1, b, a ) = ( q1, ꜫ )
δ(q1, λ, Z0 ) = ( q2, Z0 )
• The Transition Diagram :

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (b, a ̸ ꜫ )

q0 (b, a ̸ ꜫ ) q1 (λ , Z0 ̸ Z0) q2
Example 2:
Construct a PDA machine for the following language :
L = { w| na(w) = nb(w) }
Solution :
We must find the procedure :
input Stack’s operations Top of stack
1 Read (a) Push (a) Z0 → a
2 Read (b) Push (b) Z0 → b
3 Read (a) Push (a) a
4 Read (b) Push (b) b
5 Read (a) Pop (b) b
6 Read (b) Pop (a) a
7 Read (λ) Accepted Z0
(a, a ̸ aa )
(a, Z0 ̸ a Z0 )
(a, b ̸ ꜫ )
(b, a ̸ ꜫ )
q0 (λ, Z0, ̸ Z0 ) q1

(b, Z0 ̸ b Z0 )
(b, b ̸ bb )
Example 3:
Construct a PDA machine for the following language :
L = { an bn cm| n, m ≥ 1 }
Solution :

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (b, a ̸ ꜫ ) (c, Z0 ̸ Z0)

q0 (b, a ̸ ꜫ ) q1 (c , Z0 ̸ Z0) q2
Example 4:
Construct a PDA machine for the following language :
L = { an bm cn| n, m ≥ 1 }
Solution :

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (b, a ̸ a ) (c, a ̸ ꜫ )

q0 (b, a ̸ a) q1 (c, a ̸ ꜫ) q2 (λ , Z0 ̸ Z0) q3


Example 4:
Construct a PDA machine for the following language :
L = { am+n bm cn| n, m ≥ 1 }
Solution :

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (b, a ̸ ꜫ ) (c, a ̸ ꜫ )

q0 (b, a ̸ ꜫ) q1 (c, a ̸ ꜫ) q2 (λ , Z0 ̸ Z0) q3


Example 5:
Construct a PDA machine for the following language :
L = { an bm+n cm| n, m ≥ 1 }
Solution :
L = { an bn bm cm| n, m ≥ 1 }

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (b, a ̸ ꜫ ) (b, b ̸ bb ) (c, b ̸ ꜫ)

q0 (b, a ̸ ꜫ) q1 (b, Z0 ̸ bZ0) q2 (c, b ̸ ꜫ) q3 (λ , Z0 ̸ Z0) q4


Example 6:
Construct a PDA machine for the following language :
L = { an bm cm+n| n, m ≥ 1 }
Solution :

(a, a ̸ aa )
(a, Z0 ̸ a Z0 ) (c, b ̸ ꜫ )

(c, b ̸ ꜫ ) q1 (λ , Z0 ̸ Z0) q2
q0

(b, a ̸ ba ) (c, a ̸ ꜫ )
(b, b ̸ bb )

You might also like