Professional Documents
Culture Documents
tape
tape head
stack head
finite
stack
control
a l p h a b e t
q v p u
q v p u
q p u
q v p
V = Q (s = ,f= for f F)
Solution 1.
1, 0/
0, /0 1, 0/
Solution 2.
Consider a CFG
G = ({S}, {0,1}, {S | 0S1}, S).
, S/1
, /S
, /S
, /0
, S/
0, 0/
1, 1/
Theorem Every CFL can be accepted by a PDA.
, A/xn A x1 x2 xn in R
, /S
, /x1
a, a/ for a in
Theorem
A language L is CFL it can be accepted by a PDA.
Sometimes, constructing the PDA is easier than
constructing CFG.
Example 2
PDA!!!
s p s
(p, s) (s, , )
, / s
a a
p p a
s
s
(q, s) (p, a, s)
(p, a) (q, , )
a, s / s
, / a
a a
p p a
a
a
(q1, a) (p, a, a)
(p, a) (q1, , )
a, a / a
, / a
a a
p p
b
(p, ) (p, a, b)
a,b /
a a
p p b
b
(p, b) (p, a, b)
a, b / b'
a a
p p
b
(p, ) (p, a, b)
a,b' /
b b
p p b
s
s
(r1, s) (p, b, s)
(p, b) (r1, , )
b, s / s
, / b
b b
p p b
b
b
(r2, b) (p, b, b)
(p, b) (r2, , )
b, b / b
, / b
b b
p p b
b
b
(r3, b) (p, b, b)
(p, b) (r3, , )
b, b ' / b '
, / b
b b
p p
a
(p, ) (p, b, a)
b, a /
b b
p p
a
a
,a /
b b
p p b
a
z
z za
, z / z
,b' / za
p p
s
(p, ) (p, , s)
,s /
a,b /
a, b / b'
a,b' /
, / s a, z / z
z b,b'
, / a
,s /
b, a /
b, a / b, z / z
za
,a /
, z / z , / b
za , / b'
Example 3
Construct PDA accepting {x {a, b} | #b ( x) #a ( x) 2#b ( x)}.
Idea
Idea