Professional Documents
Culture Documents
18CS54 - Atci - Module 3 - Pda
18CS54 - Atci - Module 3 - Pda
PUSHDOLJN AUTOMATA
A
PuAhdouo aulomata (os PDA) M ts a sé1 - tuple (K,z, T, A,%,A), where
K t6 a fioie set of stales
aod
ACK the set of accepting stales,
A t6 the tsanhif00 7elafon. It ?% a $of e subset af
(k x (E Ulet) x T") x (K x T)
Atale oput o Atale strne oF
ymbols l mbol 15 pus h
Pop fpm 00 lop of stack
the op f
stack
A x " xT. It
Confiuratoo of a PDA M t an elemcot of K
Captures the three th:gs that cao make a d'fference o M'a fulure
bebavi or
fth CUTTentE skale
C CECs FC
316
Let C be a Computatioo of M o0 toput e Jhen
C kome
h an
ac ceptng computati on ff C =
(A, o, ¬) F (e,¬,e), fpr
¬ A yidds
Let be that
a
stinS ao element a E . Jhe
M w tff at least one of t s computatioas accepts
accepts
M Tejects 1 f f al of ito computations rejeck
Even very aimple PDA may be able lo accept lanouao es that canno t be
ver
accepted by any FSM, Jhe posev of such mackines comes fronm the ab7lt
Of the htack o Count.
T:1
Stack enpl
final 6tal
(CA,),), (a,¬DComputation
clelc 3 Conc'oualion Machine halt
(pupop
Mack
311
T ia,bf
lel
.
A
C4,a.E ), (6,a )),
CA,b,e,4,b)),
(a,c,e) Ge)),
(G.a,a), Ge),
So
fa, all of the PDAS that oe have bus lt bave
been deleimioistic. So
each machio e followed 0oly a 7gle Computationa path.
abab, e
, bab, a#
a, abab, #
Jhe
follosing nondelêrmini bttc PDA MaCcepts PalEven
alela
alale
elele
blelh
M: (K.2, T, A, s,A). whese
A:i(^,a,t), (4, a) ),
T: 1a,b}
(6,b,e, (s,b))
, abba, £
,bba, a#
, ba, att
, a,bbat fa, at
Halts
, &, abbatt
fe,e
accepl
etample:Egual Numbesh of o's aod b
L: w
eia,bl # ) =#)}
Jhe
follosing nondelarm/otsti c PoA M accepi L
alela
Conaider e strno aabbb a
alble , aabbba, &
blal
M: CK ,2, T,
blelb Aabbba, at
A, s, A) , ohere
h bbba, aat
T: 1aj
bba, baaF ,bba, a#
:S Push POp
A:
i(Ch, a, e ), (6,a)), ,ba, bbaat
(C6, b, e) (a,b)) ,ba,bat,ba,E
POP
(6,a,b), (4,0 ), a,bbaat#
pusb
L la"b": m #o m, n>o
Jhe following nondelemtnrstC PDA M accept ^ L
Jhe following
blale elal e
alela aaab (E,a,
lale8 clale 6 abbb (b,e,e)
blele
blele
M: CK, E,T, A, s ,A), here
alea blae e ae
ele
321
Mefod: Uto ao
End-of Strog Mar ker
Marker
alea blale elale çalor
+le
iele S a
the e 6 be accepted
. Adding a end-of-sting marker 15
languag3
ihm.
paesful tool fo Teducioo nondelevmfn
ELomple R: A a ,B b S+ AAB3
put aab
AAB
PopS 5 veplaces it bH
Poph9 vepíaces t ba.Alouo Atack is aAB
the tuo
Read the fivot characle of ts toput pops a, compases
charad, hees that thet match.
Noo Stack AB.
322
Pop off A and veplaces t by a .
Noo btack is aß
Teads the net charac of its fopa t ,Pops a compares he tao
No tack i B.
b. No stack is b.
Pop off Baod
veplaces itby
eads the last foput charoclé, pops o f f , compare the toDo
Mtto an acceptng btal and bok Ihe stack and the oput stream
ave
emptt. 60 M acce pta
Bottom- up parng
Omple R i A-+a, 8-b, S+AAB}foput h aab,
M fst hifts a onlö the tack. Jhe lop of the otack mathes tbe
TghE- hand de of the fht rule.
M the
apply Tale, pop off a, veplace it orlhA.
hitEb nett a , 0 stack is aA
aPPyrule, so stack is AA
hifEs , apply Tule, ho stack is BAA.
stock vioht hand 4:de of lka rusle.
top of the match e ,to veuerse, Ihe
eSl )
all bat the last of the traosiaionh descsbed below
Tule
X , s ... (nto R.
bottom u
>
8.E.E). (8.T) OC.eX) CG1,.-)
(8ET , (3.T+F) RAS&
Ce. e,x) (3.<)
(g.E,T), (&.F)
( e F),(3.CED)
(.E,F) Ce,id)
(,idd), C%. e)
(e.C.c),(&.e)
( . , ) ,Ce.e)
t t ) ,C8.e)
Cf ta PDA
bottomup (G)
elele
(Pid,E).(p.id)
o , c) Cp.c)
(p.CE) (p)
Cp.EG4) ,(pK)
(p. ,e), (p»))
(p.E, s), ( )
(p tE), (p1t
pE), (p.)
Cp,e, T+E), (p.E)
(p, E,T, (p.E
(p, , F*T), Cp T)
(p, e,), (pT)
(p,)EC),(p.f
(p. f,d), (p f)
324
*Butlding aGrammaxfro a PDA
Restricted Nosmal fovm
Exdmple Coovertn o
( Os1ble
blelb
alela alale
ele 4D-5_clels
K
blelb bble
Tranbitto of Ahould b cbaoged
( , , ) (h,4)
() (C, a, 4), CA,a#)) (Cb,a,a), CA aa)) t ((%,a,b), (%,ab))
(*)C6, b,#) Cs,b4#) # CA,b, a), (,ba) +CA,b,b), (A,bb)
(+)(CA,c, +), (G 9+) #CCh Ca), Cfa) #CCA,C,b),Cf.b))
Set
3 Bu:ld R ab follod:
3.5
3.5 na o las a y Cvealë Tules for tranAS tioob that psh more
al#|# o , b,<h, ab
a lale
alblab ,b, a , <h, ba
elelt
clala
elele, a.a>, <f,e
clbb
b#l* 6ble
blalba 32
bb |bb ,Kf ,a >
, Ca >
LA, c, b f b>
S <a, #a
CCb,a # , (6,a#))
X
Kh #s> > a <h,a,¢> Kf #S>
s,#,s ais,a,a
f>>a <6,a,s> <8,#f>
K f + a < A,a f> <f # f >
X
C ( 7 , 4 p )
( 0,4 (6,a4)
f
Kh#a +a<A,a,s> <5,#,a
ba a <^, a,f > f # a
#a> > a <A, a,a <a,#,as
Rule 32
oeve tranht%0n (,c,),(7,h)
K(a,a K{.E O
ede y tranhition thot pw.he, o
w e(T,e, )
fa a kf. e, 5
N o t r o K 0 n o m
4 a ff > > a
f. E 4>
bE 4 0
f.,4' f, 4 a
fb ' ( . E, f
Rule 3.-3
fov ee tranhtoo((%.c,), ( . ) ) e .
2Ct, a,b
6, C,a, <f.a ey tanAition that punhe s one Avmáo
C Cest the
6, C, b> <f.b> one om , aod euny
lalè , exceptA', o
M do:
, A,
6, ah> c a h>
4b b
h ,t 4
af 7
C f a ,(>
o h, b > c f b , {>
h, 7 C
A4,#.4
a' :
hb '
Bule 3 4 25-B
a<A,a, ><fa>
b,, b , b, 4>K5 , 4,f> ,bf b b,b, f> < f ,bi{2
,f> a <h,a, f <f 1bf>
,,
b a
ha, 5 ><5,b, f> 4 5 > > a <6,a, ><4',# h>
, a,f> , a,f> b<b, >,#, h>
(Rule 3.3) a, >> a <h,a, > , a , A>
(roo p C not applicable
<b, f> a <h,a, < s ,#f 4> , a<h,a, '> <{',b, 5>
Kha 5> b b, < a, 6>>
f ob no trohitom)
a h,0, a,f , f> a4h,a, > <4,#, S
' bks,b Ks b,
,
a, f>> a <h,a,
bb, >14'a, 4>
ka, ' bh,6, 5 > a b ih,b, {'><4', b f>
Kbb > > a<b,a, f><¢',b,
lo4 no trohitom)
, 5>
a,5>> bs,b, 4' > <4 ,a,5
k, > > a<h,o, f 4,#,> f of no tranhitioch)
6, # b,bf h t,'>>a<6,a, 4' > <4,4, f>
<64,5>> b4A,b, f' >
<f,# {>
,a >
a<h, a, 4 <f' ,a,f'
,b > adh,a, <f, b,b h, b, f' 6th,b, >
%4,b: f"
, ,f>-> a<h,a, >
<4 ,b1
,af'>>b<6,b, 4 <4',a,^>
foA (No tonhitoh)
f6 (No t«anaitos)
325-C
Final Rule fo Ie 6ven PDA
S 6, #f
33
CsJ
,a.f a (f.ef)
f.b.f Cf.Ef)
f. . f ' e q'.E')
h, # f cf.f>
6,0,f cfa.f
<s,b1f cfbf
<6,a.f a s , a ,f f af
6,b.f b , b.ff.b.f
a ,afff
,bf
6,af - ,bf f. a,f
(3 K6,#.f'> ,,f <f. *f>
C63
326- A
Stine bobcbab
a
6a.f &
fA
C4
f af
(5
<f 6.f> C6
&
Strino bba cabb
S C
b,f fe,'>
,a,f> [
<fE[&J
<fEf>
Sting abcab C
6,, f '>> s J
f,#f' (1
,a,f> C14
Cbalth)
Conh:der topu tsng abcba
326
bab c bab
S C
bbaccabb
ab cab X
a,f>Ci4 ftaC3
a, e, a>(4
C
fb,f>6 a
,f3
&
M M' not.
delermnibtc,
32T
MODULE 3
Etercibe
L
1. (c) Buld a PDA lo
accept each of the follasfng anguage
L: w e i a , b " : # (u) - 3 . 4(o)}
0.a0aaa bbb
Elsle elele
((a, E,E , C3,E),
((3bE), (48)),
lele
( 4 , b e ), Ca£)S
blele
M- ewe
a
2-0 a ewen b
bb 2o
4-0 4
bbbb 40
Euano. of a's 2 bs
ab
11
2 2 o
oa bb
27
3-3: o
O0obbb
3-1 3 a'k b s
(Equal no.
of
a bbb
4-2 2 Ceo oo of 6
Oobbbb
42 follo-sed by
abbbbb 52 5-82
o bbbbb 53
a a
328
() c 1e a,b}, #a) :no )-o
M (21, 3, la,b,c} , ic, A, i I , it), oheve A (Ci,a,E), 0,c),
CCbe),Ci,c)),
Olele (C,cc), C,¬)S
bec
blele
languaoe
(a)
L$ shere L: àwe ja,b3 #alo) #co)
M: (o,1,22, j a b l ,ia,bt, o,1a 8, A ), where 4
- e l e l
a#|at
al bE
bl alE
m s < 2m
¬ a l
o's
zb b
aaa bb
aaabbb
2 4 <4 aaa a bbb
.S sbo a
nalur al PDA f L
(4) le a Conl ut - free grammaY ooenerale 329
L a b"a":n,m>Os
S aSa |6
8 beblE
DO, m:0
O:O , : I b
aa
a bbo
abbbba
:2 a a bbaa
alela blele
lel# elealle +
lele
a tle ale
ele,)
ale e
A),
Ohere A
CC,&,£), (2,4)1
T, 2 a,b},iat ,
l
21
M:(21,2,3,4,5,C. CCaa,e), C2,a)),
(+,a,a), (4¬) (C2,6, £), C3,e)),
(C6,a,e) ,(5,e)), CC4¢,#), C7.&)
(3, 4 , (1.E)), CC3,b,e) , e,e))
(C4a,4), (C, E)),
(3, a,# , (6.8) (C3,aa, C4E)),
CCs,a,e), (G.E),
((S,4.E) , (7.e)),
330
MODULE 4
Exercines
( Let L: w E ja, bt the frsE, middle and last characlër ^ ofo are
tde ohcal
M alGM,C D
B
bMg blelelelebiee
Meb CMC
G a b alcle
(15) Let L 2ab": n>m Let R,:i (aub) these A on odd oumbes of a'^ a
and a9
eveo number of b'hS. Une contsthopn Bu?id a PDA that accepu L,OR,.
Ma uhcb accepa R,
3,3,4s, {a,b &,1, 23),
A
S C,a,2)
Cb3
(3,a)
(a,,4) DE A
(3,a,4)
(3,b,
(4,a,3)
(46,a)
(3,),(8,3,(2.3),(2,4)
Maohich accepi L,oR, :(20,1), C),C3),(4),
a , b 1 a l , a , ( , 1 ) , }L3,)3) PDA
T SAa fnal
CCO,),5,a), ((a.3), ¬)) 331
CcC) ,a,e), CC,D,a))
e))
CC,), b,a), (3.3),e) CCCa3),b,a), ((, 4),
(CCa.3,bia), ( , 1),E))
(CC, a.e), (C,1),a)
(Cc3,4), b a ) , (e,),¬))
CC), b,a), CC,4) E))
CCCa,),E, a), ((3,1), E)
. (cC,3), a,e), CC4),a))
CcCa,),E, a) ((),E))
. (CC,2, b,a), (t,1).E))
((C9.3), E,a), ((a, 9), e))
CCu), a,e), (C,3, a)) a), C,4),E))
CCC,u), e,
(CC,4),b1a), (Ca,6),e)
(cC,,k, E), (a,1),E))
x CcC), E, e), C.0),e))
Ccc,3,E, ¬), CCa,3), e))
CCC,4), E,E), C(a,u),¬))