





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























state transition from q to p
2.^
a is the next input symbol
3.^
X is the current stack
top^
symbol
4.^
Y is the replacement for X;it is in
* (a string of stack symbols)i.
Set Y =
^ for:
Pop(X)
ii.^
If Y=X: stack top isunchanged iii.^
If Y=Z
: X is poppedk
and is replaced by Y inreverse order (i.e., Z
will be 1
the new stack top)
4
old state
Stack top input symb.
new state(s) new Stack top(s)
q^
p
Action
i)^
Pop(X)
ii)^
Pop(X)Push(X)
iii)^
k^
Pop(X)Push(Z
)k Push(Z
)k- …Push(Z
Push(Z
q^ i^
q^ j
a, X^
/ Y
PDA for L
wwr
: Transition Diagram
q^0
q^1
q^2
0, Z^0
/0Z^0 1, Z^0
/1Z^0 0, 0/000, 1/011, 0/101, 1/
0, 0/^
1, 1/^
/Z^0 , 0/0 , 1/
/Z^0
Example 2: language of balancedparanthesis (another design)
(,Z/ ( Z^0 q^0
0 (,( / ( (), ( /
start
q^1 ,Z/ Z^0
0
0
^ q - current state ^ w - remainder of the input (i.e., unconsumed part) ^ y - current stack contents as a string from top to bottomof stack
Checklist:- input exhausted?- in a final state? Checklist:- input exhausted?- is the stack empty?
PDAs accepting by final state and emptystack are equivalent^ ^
PF
<= PDA accepting by final state (^) PF^ = (Q
,∑,F
, δ
,qF ,Z 0
,F) 0
^ P
<= PDA accepting by empty stackN (^) P = (QN
,∑,N
, δ
,qN ,Z 0
) 0
^ Theorem:
19
Example: Matching parenthesis “(” “)” P:^ N
( {q^ }, {(,)}, {Z^0
,Z}, δ 01
, q^ N^0 , Z)^0
δ:^ N
δ(q^ N^0
,(,Z^ ) = { (q^0
,ZZ 01
) } 0
δ(q^ N^0
,(,Z^ ) = { (q^1
, ZZ 01
) } 1
δ(q^ N^0
,),Z^ ) = { (q^1
δ(q^ N^0
) = { (q 0
q^0 start
(,Z/Z^0
Z 1 0 (,Z/Z^1
Z 1 1 ),Z/^1 ,Z/^0
(,Z/Z^ Z^0 1 q^0
0 (,Z/Z^1
Z 1 1 ),Z/^ ^1 ^ ,Z/^0
start
p^0
p^ f
X^0
0
P:^ f^
( {p^ ,q^0
,p^ }, {(,)}, {X 0 f^
,Z,Z 00
}, δ 1 f , p^ , X 0
p^ )0 , f^
δ:^ f^
δ(p^ f^0 ,^ ,X^0
) = { (q
,Z) } 00
δ(q^ f^0 ,(,Z) = { (q^0
,ZZ 01
) } 0
δ(q^ f^0 ,(,Z) = { (q^1
, ZZ 01
) } 1
δ(q^ f^0 ,),Z) = { (q^1
,^ ) } 0
δ(q^ f^0 ,^ ,Z^0
) = { (q
,^ ) } 0
δ(p^ f^0 ,^ ,X^0
) = { (p
, X) }f^0
20
P^ F
==> P
N^
construction
^ of P
^ U {X
/ZX 00 0
Newstart
q^0
p^ e
PF