You are on page 1of 78

18CS54 ATC Module 3 MoDVAE3

PART-B: PushDown Autemata (PDA)

o n of NondAtnintsk) PDA:
t sratz a h i n e a t as bean augnnsntd y
PDA a

a ingka stack

A PDA, Méa r kaple (*,2, A,4»,A), w


set
e stalio
K as a ntt
ta iput alblalset
T h stack alpealbet

gek tt stast stat


statio
ACk, th sut accepng
A i h aton sulatm.

Kx Cu4E}) XT*) x CK xr*)


Stau Sing oBwbdo
Sha i/por6 Si to d n tep
Ayido to
oAtack
tofsta

kxz"x* Lt
A Leguaton ta
PDA ML a d e e t af lo
C a p u i the a n e tinas Unat Cau na a
d
Mswiu ehawteur
Lts AusRAnt (sta
tat al Ast e rad and
%The put
th coutents of stack

TL intkal tewonuraio n. of a PDA, M eu input 9 (9e E)


notational tenventon l dinuterna M's sack a stacna .

oll be wsaten as Cab

hanactoe mede to be pushud


a seamaeA o
nko stack aund stad Loutains sbeleutpua
D
. tt hu status 4Valm ot stak a t p a d

epuatin e, CCa - - CnS

SJEC Mangaluru

-
18CS54 ATC Module 3

Ne ue t
Ne woe
Couweution (Yieldo- ie- ont-ste)

Cekanation of PDA.
be
i, and any
Ket c be ang elenet oF0fe}, t
lemea , and l t w e any
elemmnt
of *
Then
e4
,C,r)h (4, »,gr) % (G,e,T),(4a,a))
E kannsikon tt stRg matehes 2
M may talke

hew
ankon . talen,
I dets , and t
M pops and them
ushea
theu M must matel Eagotmat teb o a
¥I E,
Stack. toweyen e maehan evevyashuu

t ivalent Sayeug
to
Thnaei Ln t s Coutert
t Cuuneut Valu of t .stacb
"ithsut ootthuing tohaek

A towputathon M a ne Saqjumca **euh'aaatzon


39ne suchsuch hat
Co,Ci -.,Cn
intkal tonkgoatcen.
Co As a
Some statt e k and
Cn of ke
m (, 6, F), A
u* and
Sone skang

katC a cenmputatmn M on
Jinput w GEt Thu we'll aytat
* C a n 00cuplzng_oputazon C(9,w,¬)*(4,e,e),

s e w e ¬A.
Runs ou o ainput
e A emputatzOn acubIz uly
statt Qnd t w stad
aupkn

SJEC Mangaluru
-2
18CS54 ATC Module 3

C is a sejeeting Cempukakon C=(% E)*C, w',a)


amd wtnue M has
C i no an aecuping omputatzo n
h
ne mou that t c a w hale hom (4, w',a).
am lenent z . theu,we say tat
-

t w e a staiug ha h t o p u t a i eus ecepts


aecblz w batleast one o
M ujeet.
Combutalkow
MRejees w all oF
denokd L(M), is t set o
The anamaga a
d y M,
all stanqs aeupid g M

NOTE
kamstkon Bnda ss dhndas
t
Suppese,
((1,C,), (V2,Ta)),
TAamsitton
osaw

stak
tu top ah t, matehes
A m u t o l
C matehes
the e i iotie Case
eich
ity baustion trom t o
kau Joe kaken,
ti
e te t/p.
C should deuoved
pepped twm stack
&shodu e ?
uld t pusd brto
sho hs{Hhenl
tam be taken
J K a e kon

nsnd ng

e taen sitheut
sitthowt
te Kamsikon cau
, E , tau
ehaeeng tte stack i ptpig oryte
uotau t a
euto tu stack
them noteng is pushuol
E,
a m s e k o n to talen

SJEC Mangaluru
- 3
18CS54 ATC Module 3

Exanplea:
Coust&uee PDAi t tootng Damamaa
C }*: Th paetasto a balaucd
L w ¬ {D, d computatisw b4 F P A
Cous tlu any valid and valid s i s . Shew
Som
The Atoc t Med heu to Couut n e u m l s n d

+tat Aae mot yet oen watekns


TL grptiul auaetation of POA :

h
M =(K,, 4,o,A),
intuple duvetptn
K-4%3 {C,} ,
T=i c inkal shta A-=4o3
A s daknmd an:
i ((o,C, e), (%,c),
( , , C) (%,)? ,

,LfM de C, 2t puskao o t o ta staek


C tRi Btack, neado to be
Cf M Se aud t t i a

i no C o sep, without acupto


Mhatts
M M ses ), ad an
touountng
is ewti aiput stang, Ms stad to
f , ali
Rarap M acesa
M
tack i ot kunpy, Ajee
F
eouputateon t Tnvald sting (
Vaid seng ( O ) C)
) (o, (, e) (Vo,)C,
(a, ) , e) E («, ()), F(o, C, E)
F(, ), c«) (0, &, )
F(vo, , c) Rejedd nce
( , ¬, e) Atask wtepl
Acebled
SJEC Mangaluru
18CS54 ATC Modulee3
D TaJid stacg ( 2 )Twald stag' )D)
(o,)(), e) E (o, 0), C)
o, C, e)F (%, (), 9 E(Vo, ) , ¬)
F (v0, , c()
Rejetid ina no Atraui hw a n
daktund Ar t i s Case bCtaeat Sruc
Lowbinatie u an teufdnd ao invalid)
Rejestrd nu stac
Not au *fp symabeds a
roesed

a) Couetruet PPA davgmage, ={a*b*|nzo}


a ud
and
Alue how t emputation {o t stgs aabb

aaabb
Som
PDA woes srack aLoumt a's so hat can pan

T napiet supreerbren of PDA


( blale (

a/e/a
POA) M =
(K, A,o, A) khi
The Bix tuple dneitphono t
f={a?, % is t a inRal stat, A { ,}
K-o3,-{a,b,
d a
,A is

(4s, ), b,(*»,e),(,b,a), (9, }


C a, E),
M the statng ly
all the 2uput 4tmbols an Conpwtd,
-

aceupz
aceestirg Stat and 2 stach np
Cewbutazon f aabb Cowbutazon aaabb
(Vo, aaa bb, e) F(vo, aabb, a)
(e, aabb, E) F (e, abb, a) F(vo, abb, aa)
E (Vo, bb, aa) E(Vo, bb, aaa)
F ( b,a) (n b, aa)D
(1, e, a)
Sinu stackh ir not
Resechd
Aecstd
SJEC Mangaluru
18CS54 ATC Module 3

3) Cuutanet PDA olouing agmg


h wew wea, b}* }
instautareous oluetbtkon CComputalcou
Aso Wa
abcba

tYadk of al t symmlbds preed tn w.


Stack is u e d to keep keap
Th groed peetotiwn:
a/ela )a/ale

)Cele/E
b/e/b b/bje
&ix-tuple dusenanen, M (k,a,4, o, A)
,

The =

A-43
K vo?, {a, b, c3, Ffa,b, ais Hinatal stati,
A is defd betea:

((vo, a, e) (o, a)) ,


N A

(Cvo, b, e), (V», b)


((, c,E, (4, E)9
CCI,a,a)
Cc, b, ), e ) }
Conaputatzow d abcba
(Vo, abcba, e) (o, bcba, a)
E(vo, cba, ba)
( , ba, ba)
C , a, a)
F ( , e, E)

Aceted

e fotosing anguagt
4) Cousfauet PDA

Ako wh
A fa"Rn | n2o?.
SJEC Mangaluru
sng aabbbb -6
18CS54 ATC Module3

Foi Lack a in t t stacng, we push iwo a's outo t stack


Tha
T o aack Ra sting, e pop a sngu d

ie, qrahical subrepeutakon of fDA


ale aa
v)6/a/Ve
((
hen
(K,z, A, o, A),
M
2
ple dvetpion of PDA, L.|
fa, b}, Efa},
46 is kainikal statz, A={%
V 3
A is dinnd to be:
(4,) ((, b), (V,E)F
((o, b, a),
i ( ( o , a,e), (Vo, aa))
owbutati an 8tang2
TD Lnstantaneeus dineRptim/

aabbbb

-(Vo, abbbb, aa
(4o, aabbbb, ¬)E(V, bbbb, aaaa)

E(V , aa)

F e , e) Accoptel

D.ninlsttc PDA: (or DPDA)


be dubanninistic h Rxts&
A PDA M is a l d to
Mdu whis Mas a chotu o
Mo Cek'natio o
koat to do next.
hes
condeiou mut hotd goool o
The foleing r i t cach
pais of bausikow that copeh
.AM
I.A toutoins no

stat of M, ten
Hie s mo trautikoN
.
F i am ateepting
to
(C,e,e), (p,a)) r any p or a. ie, Mnevn eud
trcnstKens
ehoose petween acabtrng and Lewttnuutng .
Any
ont a aceuptug stat 'must iHhr c o u s n input, o r

pop semetheng staek.


SJEC Mangaluru
18CS54 ATC Module 3

Epotting Neuduiminism
Moves
-

A PDA dusigmsl Aase o mltble conpetng


non-itnntnistie
a nal Abnkaunatim Satd be
e stncine
And s c a
can be shonn ttsoug a

Ex: , abab, &


bab, a
ababt
Vab,ab*

Fxanple
5 Ceusrnet PDA f t elensina lamamge

outo tt stade.
Som T sqmbok of w qe bushl i u wis
Bymorio u be popped odf he stauke

Th rapltal epraetalcon

e/e

ble/b
(K,, A, , A) wt
The Stx tuple dasetpteon
M -
ta ntal stati, A ={4, ?
={a,bt,
e U , 2+{ab
A is dned a4 , (v,e)),
Vop)), (E,9, ( , ) ) (,a,a)
(ae),(vo)(o, b),
(l,b, ), (1,E) }
whew
NOTES because Caunotnot know
M ondliuminds ke ,

He Hexe 2 input.
as nachA th middle of
Aas two chote
had,
e b e e Lach charaelon midelle
tam quwm a t
kas mob yet gotteu to Hu
JE
stays aA Atah , otun a paskes
(In #he case, t
Rac unmbol inds).
ithas Suaehud t u tdl
4 TE can quem hat
to staü y1,
C In t i ease, t taks l -amsetton
cackSymbol Kat B nds).
ko t peps one symbol o
8 SJEC Mangaluru
18CS54 ATC Module3
ceputaton Cau be eprend
Sutpe%e staing is ab ba, tt

toos:
o,abba, &)

1,abba, 8 LNo futtn ove


Vo, bba,a
V, bba, a LN f a t a move
(Te ba, ba

ba,ba
vob,aba
a, a
Yo,E, baba b,abaa
EEE
Lstack lontainy Nolme
Accepled
Sabe

Ceustuet PDA to t l o a agge


6)
h fwe {a,b}"; +(w) -#cw)

O/la
YAN.
a/p/e

nondunninlsie.

T main
A, Vo, A) un
The Sin-tuple duentpton s,
M= (K,,
» t ankal stath, A={4..
K o , * l a , b ? , Fa{a,b}
A dneelto be
CVa,a,4),1+)), ((«, b,¬), Ga,b), ((a4, ba),(,e))?
( voa,t), u,a),
tte Atingabab
Coputaion
,ab ab,e
vo,bab,a
o , ab, &
vo, abaa
,b,aba. o,ba
vo,,
No,6, baba Vo,&, ba Vo,E, ba WoE,£E ,t, ba Aupf
No e No hmha Nonaa Acb Naov SJEC Mangaluru
meve Move
18CS54 ATC Module 3

Coutruct PDA htoukg laugage


a"b"| o<men}
So a/e/a
blaleb/ale bleleVa))b/e/e
stai q)
s t a (at
ito. t
Symur a gt paud ispopbed oflro
Secu, syrmbole a'
hoken b E and ir toute mual
u u t l stac
stah ( Sta ) will Atllceutai
tuu
tuames euby,
shing
ham stack naks
atleaot ont b ko prun. Ln sud sar,
Aawston to stak 2
the sumakning b 8bele te Lput
At statz q ,
aL precte i
**h
M=(E,,A, V, A)
Sin.kuple duuphen af PDA; o iste inaial statu, AS27
2 } - s a , b 3 , l a } ,
K- o, (o, b,),(9I,E)) ,
o b e : t( Coae40,),
A s dud
CCb,yn,E), C(),b,¬),CVa,£)), (,b,6), (V,){
Cwataner PDA awing Xonnymagi

Son Siwe nilan to No F


The PDA is
/e
a/e/a bdow
ad i s dukind
ejale ) ( ,4),(,)
ie, PDA, M-(k,2,A Vo,A) o,b, a),(4)
((n, b, a) , (,E),
( ,E,a) (2A),
-4a ,b,
a ((,)(2,¬))
oista Chitnal stal

A-{2y
- lo SJEC Mangaluru
18CS54 ATC Module 3

th otloving
9) Ceuatsuet PDA

aM bh; m4n: m,n>of

Son Hene Cau be split Auto Bublangmag

a " b : o<m<n} and d"b: o<n<m}


then au ML as or mie b's
le h
dastcbed i
NOTE
&olmkon ko sublanaageo is alvead
(T Amallu POA
elub theoe tuso
No 1 48. No, we

blale

iteanu d tale, M=( E.z4, , A)


.'PDA disetpko
o h R {Vo,9,V2 V3,2}a3 a,b}, Vois hi inikalstati, +{2Vs.
A A d*ned below
(l,b,a), (vE), ((, be), ) , |
1C0,a,e), A) , {tK),(v,E)),
e,a),(4a,E)), tt,b,), V»,4),(s,E,a),s,¬)
cneas d RAdneing Nondaliantntsma

')wing a Bottem of Stack Masker


- Pus Botom-of-ttac Masun (+) , butau we stant

Sxawple Cewoida PDA elbtainnd. tr QNo.. Ontd


We add a new start Stati, Juot to Þeskrm pushng *
H stask
a/ela b/ale / e

ie, EC ale btls


/a/E e/a/e
SJEC Mangaluru
18CS54 ATC Module 3

2) ina a End-of Sang Mas Le


to k, a

- We nend to deliet an 2nd t nput So, a d


tesninaon ehaael $
blale bleJe
ele/v bla

Nowdeinminism and Halktng


PDA M - ( K , E , , A , s,A)
-Ne know t a t a oputalzon C of a

on a sbakng w a aubina Cevmputakon d


C (4,e, e), f some ¬A
-,e) e
atlhast m
of
C of M
Lembntathon
-
We s a hat a
lnna CendkRew hdds;

*C l am acupng Cembutalzon or ne
wiz t u
tonkauatcon m
C C ds a
takeu.
Jmstion imA atcam be

e eewe nputation ofM


that M kalls M w
-
ne sa
Cn w nalli that
hw we say
amd decs nob atupt,
LF M als on w

M jel w
e m e Aaugnage h.
PD A haE amesa
.

Ket M be a
EL h a n M ill Aalk and aceept.
Than,
Tn u p u t w,
is pen: ble thal
not accapt w, eF
we shil M ai
L ,

ill 1ot RujLet At alHun


shown bele
a
the PDA
Cesrdn
kxauple netRu aecupl
aale PDA hat may
elela o r ryu
SJEC Mangaluru
18CS54 ATC Module 3

- Hw, PDA Cceeps ts lanamag L(M)-4a}.

e o, a,e) +(Vi, a, a) E, E)
Aup
put RxCapt a, M *l m
Howeue a nang ote

ts th pooble Cempuatin
Coputo
staing aa,
For eg
For 2 tak hao not yet Aaltid
Coigunat on pak aaa)
E ( , Ra,a) F(V%,aa, aa) F , aa,
(o, aa,E)
aaaaa) F
F o a a ,aaaa) F(V,aa, unles ib
wles aisput isis8.
iz aiuput e.
h aiput
M
M ill newe n'sh Andng

ebsevations/Note_
DPDA exs k
eFLs stht
Th a

that PDA moy


a.t t ble
n o t halt
dput
Mor e n & nding
Lg Altrakad aloo
Yte mininmcze a PDA. 1e

3.Th exfb no algeH PDA alsnady


mertmal

a
unduedalsle
4okatu

d n e z o us a P DA
ALtianative eauivaleu au t
, A) Follet ng
Folloutng
(K,z,r, A,
.

-ot PDA , M be
PDA.
altmateve dntious
of
ALasonalu
pu
push any Btsnge
pop and
* We aldew M to
9 h a d n t t o w:

kngR kambel,
ut 2 may pus
M ma Olyw a

wwwou ettiem
and push only
a
ng ynbo.
8)M maypo
w orly okeu s4
We alo M o aceapts iE p a t and stade is
nadg w 2 i wam aecepkag stak
emba - 13 SJEC Mangaluru
18CS54 ATC Module 3

ettud ons:
dhas Been
Aocup okam te ipeat
auptng stai, ugasdles he ouleulo
Mlando. au

h Btack
ohan t hut has lem Ceusunnd
s A-
staik 2mpby , Aegaidlen o tk stati M

NOT E T albove meutiod altinatin dknittous o


PDA L 4uivalswt, ie, ome lanarmage l t aseplol

ta e t acid
AoaPDA unng. o n dRtton,
Sowme PDA i n Racl of he ettwn dunekous.

Example: Acpbing tnal staa aleue


a PDA M thhat aerpls aderptng
stakamd py
ve doustuet a meus PDA M VEat acups atvg stat
tal
alene, ohee LCM) = LCM).

- Moil
M Jae a t a t Vace
Sngkacbtongtat
T teustueton o e u d s a lenes

1.
Lonall ut M
2. CrLat a meuw stast statt y,.
Add t kanstkon ((ve, e) , (V f u k botom.markw
inte shack
aeepkng stat
3. Crat a new
L
. FeR n e aoLinq Atat 9y M do;
Add u kaaetton (lU,2,t),(Vae <))
55 Make
M ake
VAce
t 0 aceubting stat ai M

- 14 SJEC Mangaluru
18CS54 ATC Module 3

xample:
) Coutuct PDA ot t danguaga,
wwe{C,>}:panedtads
a
balaud }
A
stal nmeted
oo nal

Son: auelding, to
2 gnnal
coustrnkd PPA
ke aeady
have akeady
dnokon a

ootaiu PDA Jo
th stebs daoetbed alien,
we com
ing
stat
/ec
ele

dangnage,
L=fa"b"| n>i
L=fa"b"| n2i}
Causraet P DA s
A a l statmetod:

yenaal PDA

b/le
PDAby nal ele/# Hale #/e,
Stati

SJEC Mangaluru

Is
18CS54 ATC Module3

ottai PpA o g du
L a" b"e|n,mi}
So

Alta native
Mark f Final Sta appramch
Uing Bottom oSack
Dene PDA|
NOW

l z t i s : (,),LI,13,
W
tat a prhul bulaed

So Celc PDA E3,T,A, %, A)


, -4 (0, 1 £, 4,35 ha
in
{ C , t, 4?.
4is sh wn
/</e
diaga, A

a b :a'b:ar-3j+13 M- ,V,}, {a,bi


3) /elaa a, , Vo, }}/
ele ( E/a/e

) {e$a,b}:#w) =a -#tw)} i9. })


M -{{u, £a ,b}, ia, b3, A, ,
Sons (,E),
n ((,a,e), (4a, a)), ((,a, ,
(%,6)u,b4),(,+))f
CVo,b,¬), (Ve, bb)), (,b,aa),
SJEC Mangaluru
18CS54 ATC Module 3

{ a"b" ] menéam}
5)
Som:
aea b/ale
6/6/ Haale
M =
(vo,v3, ia,}, fas, 4, , i,})
o A= (0, a,t), (Vo, a)), ((%, E, a),(),e)),
((, b,a), (V,e)), (C, b,a a),(V, ¬)) {

)h we {ab}* w=*
OR

a
Aastous
ww", mita a adaikonal
Sindlan to
sheron belens
N

PDA
a/e/a blEle
elele
(CJo
blelb
b3, A, , {3)
( v o 3 , a,b}, {a,
(,b,a), (v, b)),
s u A{ (% a,e), (
, a)),
, e)), ((o, 6,t), (*),£)),((a%4,),Ct,f)
((a0, ),
b,
( , e))
CC1,a,4), , ) , ((1,b,8),

SJEC Mangaluru
18CS54 ATC Module 3

Som:
)lale
b/ale

ale/ /4lle

m,n>o
L"|m, nmnf
) Sa
son
wsh a
bush b"
a
pe bon aeai0
sao b
po am
on

aela

belbJelb (
ble/b
a/b/e
To blale blale

SJEC Mangaluru

You might also like