0% found this document useful (0 votes)
73 views74 pages

Theory of Computation

Uploaded by

taranesvar.cs21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
73 views74 pages

Theory of Computation

Uploaded by

taranesvar.cs21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 74
Rush Down Aulorala, (ppd) qa ¥ The Contert . foe language have @ type ob MWlornatey that dletines them. hk automalon called " push down auromaten” i a extension ef NFA with 6 - RANA Hep + PDA = NFA with @-hansibon +> Stack, ~ * Stock Can bo ead, pushed and ~ popped only at the top. ¥ The presence eh Skate means that, unlike the knits Gutrrmatoo, the PDA Can wmenbe! an thbinile amount~ b whorppakon. SS. * Thee aque too dpberenr wsiens ob pdy F One that accepts by entering fn arcopring inte | 2. One thar accepts by emptying iB Stack , Push Down _Automala a_ eral Accept |refect fe pen ob pushdown Autoreala The push Gown Autormata (PDA) P Us clopenod 8 | pollovo i 52% | [P= (8.8%, 8%. SP) 5 a lO" | @:A xine Sot of Stale, Like Stales Ob 2 4): A Rinite set ob tbpuk Syrobols - | ri A binite stotr alphabet - This (8 Set O, Yak ae altewo2d fo push onto the Stack. &: The tansibon funebon. § takes as asgume, triple . binie Qutomalep , b Symbols Ne a $1G,4+x) 4. a Stale eb a. a: Of & either am snpue symbet & 4 or as €, the eropty Steing x. Strat gymbot tobich ig merobe ob fe ‘ ae : the output oh f a bintls Seb of paus (2), { | Whee p B the neostate, P > Shing ob stack sybale Phat veplaw “Kan the fop bp Stack - | BE 8(40,2,5)= (4%, 08) %: Stark Stale - Ee Sy mbet of Stack. Fos The Seb of awepting a or fa sales Bansiion déagvan> for PDA: el _ 0, 0/€ E, Xo] €, 4% correspond fp the states Ob the PDA tert State and deubly eiscleg 1. The poclos 2 An acow jIrdicakts the S Sales ase accepting Stabs” 3 The ares correspond Fp hansibons ob. the PDA wp tho Zollow ng Sense. * AP are labelled frus fom amps 819,40 > Pr) input Ns X on fop ob Stace & placed by ow. a, xo /estantandbg Desuiprons oh 2 PDAd % The Configuration, eh a PDA, Ub tiple (9, w,%) * |: the stak aie aa 7 t+ the remaining i)p # PY) Stack content - This U cated nstantarrous desceipbep or tp 0h PDA. (0.90.46) ~ (pap) Moves 0b PDA the. mos ch the push clown automate Fone étate ton be vepresonied ly the cumont Stale to next Syrnbel Thee aso too types ob Moves. I: Moves by) Consuming an input Syrmbel- y g fe 2- Move by @-bransixpon. Moves by consuming “an input symp. (g,, a2, xX) FH (preter yx) aepresent: Ablix veodlng eppur Sgro bot ‘a’ This move State pl and weplace Statle wm stake '9', reoves to Syrobeh x by YY: Now AY. Epsilon fransibon (P ato, x2) H— (41 at0/ 4x). This move wepresepts that Zmm Stat P14. on put — Symbo ta' by hot Conauro ing any . tpput syrond that & é anel veploces the top Symbad ob Stace x fo. Theo cinporkank principles of instuntaneous Aescuiptirn 0b PDA I. 2b & Computabon is digas gor a PDAP, ten the Computaben formed by adding the Same addipenal foput_ Shing. 0 the gnd ef the input p ach Uistantancous clesceipbon alo gal 3-% a Conmputabon & Legal for Ons tantanrous & 2a fellow PDA P, Ther the same add iHoney cach instartancous 2. 2b a Computanon Ago) for computaton Jormed oy adding . Sea Symbols §— pelpw. the Star © desteipron & also Legal: ppa ep, and Some Cb the umed, then- we can tail 0} the ppput &__pok consumecy ‘ s tatl f ; 5 enc Femove this tall form the thput oe Uigtantorcous dlesciphon, and the resulting will still be Leg computaben i. Suppose. the PDA p= (4Pah, $0.1}, $7.79, & 9 RHA) has tre. Following transibrm faunchens & S(4,0,%)= $(9,x%)} a. 8(4,0,x)= £(9,x0F° 3 8 (Huxd= £09, xd? 4. 8(9, 60 = $(pey 5-8(pe,v) = fp OF 6 Slp.xd= Flpxx} 7.8 (plz: $lped}. Stabog fom the Ininas ID, Shew al) eeachable desuipron © wren the Input Srirg © FOF x oon ¥ O10 ol (4, 0 2) FE (Give) ped (Pre) (eecepled) pou (4, 001, %e YE (4, OV Aa) EE (41, X¥%—) F~ (4, 1, Xa) L— Bre, xx%) Fe (Pre x) F— (Pr é1%0) Caccep hd) ole —_— 4 - 6, x xk) FPS (4.0107 26) t= (9 ¥Fe) 4, 0-*%) E~ Sa Lp. 6 _ [accepted Q- Suppose, PDE P= (£993, £09, 6X73, B.4ep 2, $92) hag the followin} —pransibon fainebons, I £(%,0,2)= $£4n®F 9+ SC il: 2) = $ (%,xX2)F 3-3 (40,0-x) > f 64,64 4-8 (401,*) = £ Go xx? & 8 (9,02) = FOn YR 6.8 (41,2) = $0e,O4 T 8 (0:¥) = £04, YN} 8+ 8a) =F (9? . Stating fpr the Initial ID ghow all xeachable 28 wher the input © & 9) bovor b> olloor 2) ON ONO ) 4) dooo tl (6, ob0011, 2) Fe (4), 000!) 2 re (/00", 2) (4, 01, Yyz) = (4, 11, VY IE (4111, ¥72) (4, €, yx) (4tcepted) 5 on (4¢, 0 007, 2N— (9), N001,BDL—_ (90 1001, Z) E> Ge, 00178) (4, oN!) EG <) Le (mer (accepted) _9) olloilo (Qe, 01101103) (4, N00, I Go,to10, 2) (40,010, x4) 1-(4o. 110,82) (461002) (0, x3) te exd : l| This Shing nog oe 8). off oo! . | (Fe. otioo!,z) — (401 Hoo), 2) (4 100! a ool, 7) (0, 01, XX) H— (901 1,2) (4, é x2). ‘ _ Coot accepted). danguage tb 2 pos > Megpiaoce by Fina} state EP (BBT 8, a,20PD ho a PDA. Then Alp), the Longuage accepted dy p by final Stade, a ALP= feo] Cote) (4,6 od} fox Some Stak 9 & p and any Stace Shing of | 2 Pttepkance by Eoply Stack . Fos cach PDA P=C 84,1 S& %,% X(P) = $00] (4,120) HE (96,62) por any State Z-cner necessaiily ‘final state) Povbloms bs Design a PDA 10 awep the Language be [EWE] co Soup e. 17 { Race ee ater te 5 Assume ~ p1eJ0 . ® : Nelo : TD ob Stack : &% ' : ; wwsh wbput tnlb S4ace apt! WwOds Inputs of} JS P ie oO tho Symbol C. @ Top ob Stack +0 ipso $ Pop rep ob the sae - © tp op Stace) ipo @® ip-e = wach fra) Stale diy pop top Ob the Stack. Transiben fincrsod guoe ae 84, 0, %) = (%, 0%) ininallg eBpuk ar be oO oe) Bete, 1,30) = (16.12 /e : “olelo 840, 0,0) = l%,00) -. ; eee a & (9,11) = (40.1D / eres 8 (40, 0.1) = (40, of) 8(9,10) = (4%; 10)°- tohen ¢’ & hcounterd, don'p Change Stace symbols bub Move fp next stale . 8 (4016, 7) > G1,%) 84,60 = (ID Slgoie,D = Cod 8 (41, 010) = (m9 whee ipput and Stack Sybet Slahiy 2 GO axa Same , the Stalk ; Syrbet iP Ay daasg (Gr 6/%) + 4,2) Ss lohen endieh ijp is \Gwached: §ol tha final stale 9 | R= fo, I 25 4 = fone} P= $%,0,17 fo= $403 % = % Fe $43) The» PDA p= CQiS,T, 8%, zo,FP > Whe | | Transiboo dliagearn : ol? ¢ ojo 0, of i He a C.%ol%o és Aor —@) ro) O,1JoF h of/o Steng acceptance ° \ A ak w= O1e10., oe 4o, of¢t0, Ze) b= Go: clo, 02) PF (45,0401 10%) -—(9g,10; 10%) L (4),0,0%) (46%) 1-( 42, %) The Shing is accopled by PDA. Bavoed (My tect, 2) LE eee i) (tol 1%) K-(4n 1, 01%) undefined, The shing ts not actepled by pa: i 2 ObeauB a pops tp atcepk the’ Language k- farbo/o zis by final slalr- I The PDA Should accept ~ 1’ mumbo ob V9 followed by * 7’ number ob b's, ; : ¥ Rush all the Symbels onte the Stack ant] b’ comes. ¥ Once the Symbol ‘bh’ Kk encountered, Check Whethe fer ee Symba'b, thee Should be corres poneling ‘a! gyrobat oy the State. * AL the tnd of the i/p Shing, ip the Stack 2repky, thon there axe ~n’ numbe Ob as and bie. There foxe the siving 18 acceplee! by PDA. Steps: \ det % be the Stout state . Xp be the inital Stack Syrobet. a As long 4% the next YP Symbad FO be Stanned kk ly : b Lsgespech ve ob te Content &b the Stack,~ Keep Pus re all the Simbel and _ rama th % State. he é 3%, 0.2) = (902%) _ 8 (440 = (4,400 : Step a: : : : S the next ip Symbol & ‘b', then ib top eb | the Stain ts 'a', then “pop the top ob the Stock ary mow +0 hee Stele 9. 8 (90,6 4) = (4p © Steps: Now ,; the machere 1s th State 91. APA the next toput Syrmbel to be wed ke ~b’, check ¢orth the top & tre stack - vt For every thput'b!, there Shoutd be correspond’ey al th the grace, which eoill be popped. (9, By a) = (ae) , Step A! When tho oud oh ipput is wached, and ap Stack Contath € 2% Xo, change. te accephing orale 92. Eh, x) = (9989. The PDA Ps C841, & 40, %,F) 1 ‘ Q* F448 ey) ion i 4+ fab} S(1024,2) > (Bor &%) P= $ 0,23 8 (4, axa) = (40-29) Zor 84.60) = Gu) F= $992 89/62) = Gre $9 6170) =(¥2/6) Transiboo diagram {tte He Mert fi, 200% auales. pale Abts o- Q) C1 elo ‘g ahh Alp ae Be Sraing acceptanee 4 lb Q2y 60 = aabb | Ni a 2: iT 20 4%) G. @o, aabb, %) 1 (Fo Abb, az) }-—(40, bb, aa%e).A- (4b: (91 6.2) 42,6) ,Caweptedl) Gaosabb, 2) = Co, bey ais) {41 b-R8). P-[apel nie) The String Ig bot accepted by -PDA- the PDA to. Accept a+ Sting Ob balanced &. obra ‘The pevanthesis to be consideced ase 0, paranthesis - ome Valid Stings oe fOle- ba. Stops: ' ke Gy bo tro. Stat Stal be Eno. inebal, Stace Syrotel c do Geep a: : on tale %, i Scarred Yyrobot & ¢C,C, push the ayrobo} onto tho Slack . 8l%, C20) = (4o,C%) 8 (90, Er) = (%, F%) Sepa! Gh the next thpuk Symbol & “YC “I and fop ob the, grare ke ow fy Pep the SAC apres Bl 40, 2 = (HO 8(% 10) * (WO Sips ap the nevt Input HO b(4 7 D = (4) Step 4! ney the lend ob We input ol edached ard) more 2» final Sak 809 4) = (49-6) J and Stade. The PDA P= (84,1, & %, %iF) Q= 4 40,4923 S-(07, 6D T= {G03 FHf¢oo? TransIBOD Luneron- 8( 410, %)= (40, C20) (40, 0,70) = (40, 0%) §( 4,3, © =(9, 6) » §(40, 1D) = @ne) $4190 = (4n€) Sl4n UD = (4,0 §(9,,€,20) =(22,6) Transinsen dinarar \ rut $ C, Ho) C2 de ae ee ‘ » Ye 6,3: Tee Sting Acceptance . w= COD 11, We (461 £3, 2) =" POT LH (40, 3], tL) 6, BD) L- (01 €/4) 12, €) (accopte+) wo~ (TI Saed cae) Cay, &,020) Zo) Ke, J, Ei (e, (3,3) ( %, £3, (20) i ae ) “Ihe. Shring is not accepted by PDA. < * re Ese Tavera ph ge Yi Olly © NTu se Qt Cy Purl, ete -tie Hrrbole «) aed 7 boc ah a Fath = (hore) [ oes J *G, Wr = Lt, Io) So 4 mete eel Ph Alte don gn a By Ww t 7 ¢! ‘y », 0, 0 Sse o J te 7 Choo) E (4%, © 20) = CU, 22 CH 1,0) = Cae cos E(hc of = (4,0) ee Fl, = (4,1) HU, 0, 1) = (god q “8 Gi 6205 = (4420) Gk Hp Steel W 2 Choa = (65 4 Get) =(%,@) aloe ve “ty \r et he ole Mp Qlcto 2 ef” (4) % ACO 0% ole te L1O 10% to lor 4 Obtath a PDA tp accept the language ta fabbe? 2=farb9?] nei? . oe = Neve *P’ purnbes of als Should be follovacd! by ‘an’ numbte oh b's * Fox eath a Stack a) 8 40.4, x0) = (9%, 40%) 8(9,a/a) = (4, 44a) Shop a: HIP Symbol > change ® slb 2, Top ob State sa, Pope ona a E140;b, a) = Cn) Slop a iJpob pop top bh Bath Sot a Keron (fame alo An bad’ Gy, €) Llop hy! wher the and bf inpul Be watched, Sok & AOPNY + and frp eh Mak & &, Gow atcepbhng Hale 4a 80M 040) (49, %). the PPA Pe (0, 4,6,8, etn). Bs P4909 459 A SSab4 — rota af S10, a %e) = (4p, 003%) ne % 8 40,0)» 4o, aoa) %>% 8 (4,64) = (yy 0) Fs £494 89, b,ad> Oye) BG ez) (4%) Gye) Tearsinon diag to a, aaa “ by, 70] 00. b,a]e Gybetle_ as 6, A) sing acceptance O= aabbbb. (4, aabbbb,%) + (%, abbbb , aa%) -—~ (4, bbbb. aaaa%e) b= (44, bbb, 200%) L~ (4, bby aaze) H— (4b 4%) H-(9u€/%) 1H 9,%0) — Caccopled) _ Book pr ble rp 2 DH{D A pra tp accept the Janguage d= for) 07] wn 3/9 2 . Steph The Shing Should Contain gual rumba op xolg ith —Sepouatel rm’ pumber ob 18, ltl] 06100.-)), |P=>0 Push ~0° Onto Sack. Stack > 0]xo- (4, 0, 20) * (4c, 2) 8(%, 0,0) = (4,0 D.« Stop 2: p>] Top 0 Statk > p 7 change fo ancther clabe and : does no perpoona aunty atvon. $l%, 1.0) = 410) S41, 1,0) = 40) Step 3: vohen ewe peuk of “ot 3 Ontountered, PoP the hp Oh Fhe Stack and Change td other State $(91, 0.0) = (49,6) £(23,00) = (42, Stepy: cohen end oh wbput i ezached, veplace xo hye. S(42, €rto) = (45,€) - | The PDA Pe (8,40, 6,40, oF), GQ = $40,492,959 oe Bz foro. (47078) = (40, 0%.) Ke $ x0} \5 8 (46,00) > (46.00) oe S(4o,1,0) = (4,0) oa § (41,10) = (4,0) Fe $433 514, 0,0) = (42,e) Transibeo diagrarn ee, ae F By 0,0[D% 100 o,0]€ @ 1,00 ay 0, 0/¢ LAG) sting acopkance w= 90100 ( 0100, %) K— (90, 0100, 0%) J— 1.4, 100, 00%) p~ (%,00,00%0) }H49,0, 0%) b~ C99, 6,26) — (93,0) » Caccepled) , b. Obtath PDA foo language Le f 0PM 0 Pron 217 | sa Nexe PDA Should —_acrept ~r nurnbex ob O% Aollewed ty ~m' pumbe ob i's , 3 Then again tho Shing Contain 'r' nurobs Op ©'s and YY number ob "8. | Steph : nial Slak =F. D>o Pa? Dnibal Hack Symbel = Z , State Syrobel a4. push “0” opto Gace un] ~1’ appears. Sl %, 0/2) = (4o,0%) S40, 0:0.) = (40,00) Step 2: aa ip >! ahange #2) anotha stak and St0uk =>0 push ° onre Stack wnkl 6! Appear. Sl4,1,0) =, 116) BLO. = (id o anoihe Stale» State >] 8%, 0.1) = G21) §(%,0,0 = 48 Step 4: p>! pep Stack Syrmbel and charge to Static > oO another State - 8(42,1,0= 43, &(%3,1,0) = (43, ©) Step 5: When ud eb thpuk wz wWached, % & OM rep of Siack, — golo accepting Stal 8(43,€,%) = (24,0 the PDA P= COST, 8, % dork) & Q= £40,%, 42,1445 ‘ 5(%,0,%) = (4c, 0%) & = foi} §(%,1.0) 8 (4, 0,0) =! (40,00) ici) P= f Olek} 8(Ipht = GW Je = Yo 8 (10.D= ba.) 5(43,¢,26) Xt 8(99,0,0 2G) =64,6) F 2 $4) 80%, 10) £436) Sl 43,110) =( 95,6) a ——— Faansi bon aliagrarm tal¢. ¢ oxo 0, mt) 1, oft 020 Gy) Bo 2 ht sf ae 4, ofto tae shing acceptance . w= Olo?l. 9p 1/070) (ae0101, %) (4 101,00) b- (90 01,1070) (2 H( 45,€:%2) F-(4918) Caceepted) | Am Erophy Stack fo. Hnal Gale « Thegrem: Th b= NCP) for,.Some\ PDP Pu= (8, $, T, Sy, Jo, Zo), then thee BQ PDA Pe Guth that’ x= & (Pp) ©, Yefe () 6) Xo nayas os ‘ : Ce Pe Simulata fp and _accels ‘ah Py Lies te way * USC yo, a now symbol» which & not a Syrebot ob T F Yo & both the statt Gynbel of Pe and a ‘Mauer oD the boltore of the Stach.» Ib Pe sees %» on the top eb Stack, then it Kpows that Py could empty Ike Stuck en the same eoput ¥ We alto weed wo.ctatt sta p, eohose furtdn & FO push Mo, the Sot” Sfrobol ob by > pita dnd op 6b the . State Ane ent ale dy, then sptast, stale o°0b Phe ox sop * Te Siroulater By una tha Shak of Fy te empty, whieh Fe dletects because TES Yoes Sy, ontd —“Hha’’ top eh’ the” Stack | * Finally — we weed another hero State Pr, cohreh & the _ aktepting State 0b. Pe. this PDA. \ fransfeis fo Sale pp COheneviea It Ascoves that. Ry oould have Lmpried jt ack - “he $eeibicareo fe ik as follows Re - (ete, 2, rvtia, 6 Rw thee Sp & deed bg bh SE (Ril -te)= (Fo, %xe) Sp ik Stoxt stale , Pe maker g spontances = Rensikoy 4 the Staut Shab 6b Py, pushing ig Stack Sypobol X% onlb: the Stack 2 At a =é an .& For all Stale ¢ th ®, toput “al to By ow ARCs d > Skace syrobols yt F ’ S& (4, 4,Y) Contac alt pais ¢P Luly ary 3. In AddiBon go vule le), Sr (% €/%) Contawis (Bye) for every Salis PB. Pena 8\ “1 (ora “1 Design 2 PDA Lohich paveessex Siege of os and 1s and aecepls ih the number of ols &s @pual ro. reunobet ob Ns. Accept it by erophy tack and convet th to ‘PDA Accept it by Binal: stace.; q The PDA Py le acceptance by empiy stack . m= (G41, ive fe, & FP) by i debihea) 2 ™ , $44, 8: - = “Ge02) ; 2 Ne, 0,0) * - (46.00) : bu ( 4110) * = : 2)" . SC 91,1,0) = (4) 8y C4), ¢,%) <9) a: fox all Seals 9 8 &, tput Symbols ah g ov are and y BS Sy l4,a,y) contars every pair that & 0 S 4, 4,Y) Py Simulates 8. Fox ail accepting Stale 9 «BF ard “tact, Symbol Y we OP YE Xo, By (Qpeiy) contains (P,€) a By this, milk, tohonevet Pe accepts, Pry Car Staet emptying ils — Stack Loi thout Consuming any more lhpub. A> For all Stace » syrobels y th F o> ¥2% Su (ney) = (18, One in Skate p tobi ch only oecuns when Pe has accepted , Ix Pops avery sy! bol on ils sack, eon! the Stack & armpty - No fate "A donated: » a9 Ns) srundapns aq | © obtadi a PDA to cap ‘tha "language Le farbr] 0 213 by Binal Skate And fab} Zod. T= {0,203 F243 beotdteusery a bp & dofined by Sp (ter 2) = (4,, 026) Srl 404) = Go,a0) $F (4b AD = (4/0 SF (9,60) =(% O Sp (114,20) = (42) %) pnts fuz ( QvtRrs, 4, Tush Se BA) D Here no Anal Sie Tension dia gear Q= £40.41, 92, BPD 4 = $4, b} Te $a Hof ® bak. Sw ts olepened by Su (B,€,x0) = (ee 0%) $y (%, 0,22) = (40, 2%) Sy (90,418) = 40, 2a) Sw (%, b, a) = (46) Sm Car bra) Iu 9 8w (41, €, 20) = (4.,%0) n(42,€,a) = (BO 8u (92,6, 6) =(PO) Su (42,6; 20) =(P2) Su (p.6, a) = (0) Sv Cpe, b) 4h 6) Q, Fo] OX a ae be _ b, ae ay Gi Hl @) © Ee (41y by 07%) H= (41, € 7 vo) Taensiboo diagram. Steirg acceptance wo= aabb (fj, aabb, Xe) b= (Ae, aabbz0xe) -( 49, Abb, Azete) K— (40, bb, ar%eXe) , --( 22, €,%) 1—(P €:%) EU RE), Equivalence ©b RDA's and FG's. Three ways op debining crus. 1 the Cooter - fee fanguages i.e.) te fanguages lepine "9 CFO's 2... The Janguages that aso accepted Py Penal state by Some PDA. §x3or ; s 3. The danguages that we accopiad by empty Stace by Some PDA 1 Q | ibm Gaatomars' fp - Pith Doon Autoroala « det G=(uT,Q.5) be @ CFG. Conshuce & PDAP, that accepts 4(G) by PRY, State follew , P= @, twtr, & 4,9) rohese.( transibon \ funchon , & & depined by 1 Fox “heh vastiable\'A/-° | — Benen) {G6 ] 4>8 B ia produenon ob Pf ae fine ai teamnbal “a”, § (4,44) = SG OR ps 1. construct the PDA for the following grammar. E> ELE] E¥E) a. art a 4 we L Uke cae Non- Terminal (v):§E} ‘ oki Termibal (1: f+, ¥, a7 pon p= (£43, Fife 4 Hah SS 4, E). G be debtned as 8 (4.0.6) = [@.e+) , ex) -@/O} 8 (4D = 4 OF 809, x.¥) =F 8 (4,010) = {1 F Mr bos arara (4, a1a¥a, BK (4.08988, E+E) (4, avara, Gre) (4, 4.084 +) (4.08% E) EH (4, a EFE_) H(q,0¥4, ate) (axa 2 (408) — (4.44) (aie). the grammar Ss S08 1808 / sososis ] 81sosos /é the Same Language bY 2 convert toe PDA that = ACeOpi& op iy Stack. ca i Toswinal’ $0,1,6% | Non- tovmninal } v vattabk +. “pon P= € $93) S, foe St, 8% 3) Whee ots dlepenedl by $ (46,5) = $ (4, s0sigos) , (4,$050915). (4,91 90S )EVEDF Sla,oe)- Qe , S(and =-@O §(4,€,6) = GO {as0, Gea ue) , Ges oyt Sting accepfanc. fo= ojoolo (4, o10010,3) (4, 010010, $091908) -— (4, 010010, 808180 SCSIs% ae tas 4, oroolo, 081808081905) +0 4,10010, “7 $0:S08/S0S) esac C4,,10010, 1.900.51808) L_ (4, ob /0, $o's0s/s0s) (92,0010, 0s0sisos) (2 0101 go 51606) (90/0, 091808 (4, 10,5108) KC940 180s) (9, 07805) (2.608 H 4,020.3) —C 96,9) (% 60). 4 convat the @tammee 8-5 0AA 40 @ Ppa that A> 08]1S]o accepe Ene Same Lang wage by. emphy «stack & Tesoinab: $0,!% Nop-terminal | £4 ,8} PRA P= ($43, 8, Soars, 6 US) whee § & given by 8(VerS) = {Goan} fe 8(9.6,A) > $.(9,08) 1 0,19) @.OF \ w=oAA 8(4,010) = Ge olsos OPA 81D = GE ALL re 00, 0A) F190) to= 000 dy (4,000,$) - [ 4, 000 » 0A) + (4,00.A0) bl (40,0) H(9,€) 3. Consbuct the PoA for to guarmmanr S> ap]ba Bo b] 6S /aBB A sialas bn Tosroural ' ab Non- tesrojnap! § A,B Poa P=(f4b (mk}. $80 1B ah}, & 4.3) toh 8% debined bf 8(4,6,5) = $(4,48) » @, BAF 8 (4,¢,8) 24,6) , 6b @,4BR)} 54 = 10,4» (8, 2S) GB bAALF 8(4,a,a) = (a3 : Sabb) = SQOQh. to = abba (4,abba,$) L ( 4,abba, a8) 1-(4,bbaB) (4rbba, bs) HC. 4,bars) C 4yba, AY O44 (45 ao) Five) ty Corrie Hie GG for d= f010?/mieeg Bnasaee IE to Conshuct = PDA. CEG Sa AIA A—>o0A/E Non- Terminal: 9A Fevrjnal: 0,),€- Pon P= ( 9}, $013, $01,537 5 HS) - > whee § & debned by 8(4,€,5) >§(4, Ain} Slare/a) = (Gi 0A), HEY 8400) = HO $ (4,1) = (46) & (%6) = GE) (4:6) FECA AY CIA) (46) LE (16 OF AO Awm PDA #0 _Greammar dee G(T PD and P= $ S, 97,2,9f)F , Whee are97 2. and. X18 Stack element Rule 1: The pwduction for Start Symbol is given by S> fo, %0. 44) 1» wre I eR Rule 2. Ib the rapping funcBon ph PDA 8(9;, 2,2) = OO), whee 97,47 E8 Then Mhe producbon Tle Us covillen as L972, 4J— a. Rule 3: fh the mapping function 6h oA, Sat, 02) (9-AB) Then the production mule ik lovitten as Lark, J] —> aft A WK] £4 B, 4], | ‘ av _ Niet % a h 5 1 Whee 95, qa abt? a ao ie 8 —— Rule 4 ger! 8/ ap a2) A149. A, a] Pevblems 1 Gorvect He Ppa pe ( $43, fo4, $7,204; 8,4, %, ta CFE, a St doped by ® S(2.n%) = f@ xzx)f 4 S(@14x) ~ £4,203 OS (2OW = FRx} 4 Siaexd = $0,€) DER x = $Cpepes #) $0.02) = $ (2,2. Sa — Stobs = (P95 Stag 3mbd = $ Xe Initial Stack Simhol = xe Inirsol Stab = 4, ‘The porduchons axe Using mule 1° Seitt Syrobe} | Ps So 4, %,4] Pa: b> 14, %, pl Uf Bx Pe} —> if 2_~. Fo, Gx Po z fe ez) ) £(Pn, 0 -h 3 QD £@ Pe: peje ee 9 str, 0,2) ~f Pas: fF a Rial a * ” : Ck] > els may Peck =a % convest Who following PDn tp CFG Gmaminas thew bu iver Wy | pa (447%, 90,14, 14 %h, 5 %y Aer rid a) 8%, 0,2.) fo. xm} By S/4.0,0) Gi, wo} % S841, > » {aR A) 819, CK) » $Pey} ©) S(pe,yx): Ser,er4 f) SUP 1y) = frre}, Latte Syroba i$ Pl: 3» ff, % 9] Pa. g-» fa, Ho, B) ©) S09, Dt) = {(2, %%)} Pa. $4,709] 2 Ol4,7,9] [9,%, 7]. Pa 19% 4] S014, 0) CP, 20.9] pe [4,%, PF) > ola, 2I le, 2,6) Po! 4, Fe,P] > 0 [4,x,P] LP 2,8), 1) 84,0, = flava} — 4 Pr [449] > 0f4,¥,4] fa,x,9] Pe [9.ra] > fax.) [P.x,9] PI: £O,x, PF] > OF 8x,9) £2,%-P] Po: [9,x, A> 012,%/0) CPx,P) _ | | | | 2 $a txd= {Gy} pn [a9 > 169%, 9] ee he ee a SE x) = per} ps: [ar Ale o) Sp. &x) = 4 (PROF py: XP) se £) S(RLY) = {Rexx pis pra] > IPx, fax pe [Px 9] > VERx.8 fpx,9] PT” [Rx PF) —> IEP x,97 [9B] pis [Px iB) > IL Px, CRA). unit fe : To elimina useless Syrmbels. Macheries Contex- Fee _danguages Se eB Generating yy wo for gomw terminal “Wo | j if . : : x Nowa) fosms fox CFG. 9 % B wochable ip thew i a decivation §>>axp for a= some a and B- how Nowaal! Zar. a ’ A esol s\Sybot . is "Both gonevatirg, ort penchable. | an. ‘a. grammas. at preisioes. cup 0 BENE w. wo cannes . consiclec the grammar P-> BclAB ABC ABC >> Vorables : : a/aBe yas aS a > terminals San I & atl b— A>aS ]sD St A Sieoplibicatiens _oh grammay. 4 x Boal, \S p uuucter fyortol.. } Blinninate cymbals 2x8) Gx4 {e.xs $ C > ab] DD a = | 4 D> ada ~ Those Vaniables OF tesminale tbat “do rot appoos any dedvation ch a termtbal\ ‘ehtng ' prom” thé tart ssyimeet. Gonsraling © ab 5 2. Himinate _e- productions Bob, Cee ‘goo Aa] ABC : with Bec AwaS these preductions oh fam Are for some vecunble A- sa abi, A—>ae 5 Bo aBalb \'roi i F 5 © cab. 5) Hliminale uit productions go Berg ane gereraling. a h = Those prductions ob the fiom A>B fs Variables Db nor gneraling. = ont B: F © 92 en\be Reachability ho ane Eliminating ssess Syrobet a 2 Bs — y J A syrobet "x! 6 wsofal for grammas 6 (vr 729) A,B, caso mae ongtre i thee |b Some desivation eb form 3 axp Seo, whee the ‘resultant gaara 4 sw ie Th Sb XH MOF Useful, then ve Wselees: 2 aha] abe 0A a) Aas: san ? B->aBalb Q4ane C= abb - Q. flirminale useless production from, Gvammat SeaSes | cle Cal Generating: 5a" revating cut} ss asbsle. Ct nok generating Final Grarernat & Ssasbsle 3: Fund the grammar epuivalent to S>ABICA 4 Asal’ B>BejaB , C2aBlb/” with no useles symbok a 7 de Generating: Axa, cob Sata $3.64, Ait,S aro atin, Ava Bene fh cae a Teo Bis Ok | Grerating: 7 . Thawgh 8, A and ¢ ate weachabe . {yee 2 apace The eruivalene gratomat coithouk:- useless siprobet ) [sca teamneg twaSloase, Ae 3 eb A Constr “the” folloverng §— CFG Gi=(V,T, PS) whore, v= foxiyt T= $0NY ard pz $s-sxyfo, x-+13. Remove useless Syrabel goom ie S>xy/o tay Guorovating: ; S,x% ae generating Yu nok gpnevating - oso" one a XE TAR AR & 9 ie @ Eliminating —£- predictions Eliminating @. productions tan. be\ done “by idewibyrg —pullable vaxiable A veriable-is ‘nutlable “py Be 2p ‘Wis nillable,’ ‘then’, thenevet A appeare io @ pooduction boay ,* Satf BS cap, A->é, Nake, oo. vetsions 6h prooluclion . Ad\IA in + Bo cap (without ee) QgHB Ser lifeoith AED oe 8 acd. snl B> tapjeD N OY zetmove e- prvduthions farm tne gramme’ Se ABC | An aca | B>bac]e C> chBlé Lowe here €- productione are Be ant Boe ke An aclale Aa aclalale C-> caB] oA C3 cABILAL* A> aejaje a aclale|s Sr ape] Ke. Heve ¢. productions ae BE. and C+ Je os pacjac ee A> Belale S> ABc/Ac] AB/A Bs aca” A? Bclaje/e eatenalan Be bac/ba C2 cAB/eA Ine hoge => he ( By¥.€ ate Pullable prduchions) S > ABC] Ac/nelacle| B/A A> be/ajc[B Bo bAC/ ba] bC}b C> chBlea] eBle | (Gf utmioat €- pwduction from the. Grarmas a) $2 abe B baje How B>e & hullohl pwduction $2 abB] ab B>bb/b- d)sobs J 1S] € ese $2€ & Pullable production so s]1s] ol). Sa] Abj aBa Avbje B> bly hese ADE and Bre- av nutahle , Preductrons $-> a/ Ab] aba] b/aa Aob Bo>b/A 3 Eliminating nit _parductions A unit whw beth A and By awe Vaniablee preeluttion (Ba production of fom A>8B Wi Eliminate unit production firm the grarane em BD Preduction fem the grammar. SOA IBC L—> afbf La] Io £0/2! ba sg HTD A> 0S[00 ele Baila T> Ff THF \ cot. E> t/E4+T 4 Howe S>C and BA ase unit povductrons. reductions , Heve E57, To F and Fo ae anit PI S> oAlIB/01 A~> 08/00 Fot F > afb} Za) 9) 20/911 (E).4\y (> \\oy C301 T9F a ies 2 firoplipicatson Ob Feammar. D Eliminake €- pacduetton, \ 2 Eliminate unit peoductton. 2) Eliminete Useless production : ° | B> Ilosloo | | | | T> afb) La] Lb] 20) Ufle)] THF | eat | c-> ayo) Sa) 16) 16)°9:]Ce) [74¥F EH: [| = te casanee gremnin b tow | D Simpiity the followoerg — grammen. 9 a]bj fa] Lb) 20] Th | $3 4A] ABB 1 A» @aale Ps ajo) Gal %b) PJ UPD wy yy gevbecwuid § | : > a] bj £2] 4b) 20) § | Be bb] bbe | T> al bf tajIb/L£0/ £1) (EQPTHRY 4 C28 pw duction Ase i nullable production ) ¢ E> afb] 2a/tb/dof2i/ (ey ITREJ ERT... 9 | 9 ah Jaga |a Ax aadjaa i B= ba} bbc ee ee le UIE production. , | sy anck Here ¢28 & unit paveluction Oso t Saal aBaja Ou4,¢ Cla Axroaahlaa 868/60 O Ginceeake te C2 'bB/bbe ONG.’ Eliminate _uselegs _qumbo onwac aclc trom 3 9 aA | ob Generating: S30, Asaoa a on) alla Not - genevating . Bre } S> aala P tenor vest vous Axaadlao . [c7 Fm §, 4 i wachable - 0 AnclacleCla the final Gramma daablal Sabla Cy ac le Ar aahlag 3 Vielen | Q sue WO) AASB] EG pyaae No-vielery Rook fafys . Oa il ea osqsp| ag ng sila) Cr © he ao saale fen | (\ bake | Saghelafi,|bs Bioko khan (yf lane Gaett te gies CP Cr aCalESblelb wo cor. T Ac = = Osaka 0-34 Sas mie may tlnady io ewe a Cyr dD, ne gs h,S Hy =) Ost As Brae essa, — o> Shy len VAAL bye Chomsky Noxeal_ Yovm (CNP) The gvaromat ts ch Chomsky Normal foro tpl the productions «3G Ow «i the following fom . ye ADB, where A/B,C awe non-tesminal . 2. fsa, > Nontamial andar us tearuhal. ine bas no useless symbols: So the grammes Gt wil be conver) 40 owe able euminating useless Symbols, Preductons and é- productions unit Process oh converting grammar (99 —— ibis OnE. mau Ua elroinabing é- precluctions, h Siroplify the Qzami agro Unit pxoductions and wseluss 2 Now add al) the productions of the’ foorn “P? BC and A> such brat the production beay, contacts hoo non-tevminals ahd Single neretel on the wight Side Ob the production. A) donionil3 Sp the production has the form - Leh A> XiXoNg... Xe Whee K>O ten CNF 4 tals Asx Y, > x22 Yo-> x2 98 . 5 Nl R Vy > Hie, paloran: | 1k Begid toith the grammar Sa Aspe As asia Bo SbS)Albb imminele there a) Ara thewe ary Uselees Symobalt? Btiminale b) Eliminate €> prveluctrons © Elireinat knit pwductons. Eliwinake _e- prvdluctions , 82€ & nullable production S> Asa] AB A» ansjalaa B> SbS/A [bb] ob /bS/® Eliminate pit prnduction, Boa $3 ASb/AB Ax an sjafaar “74 - 89 Sbs/bb] sb[bs[b/ aAs/afan- Eliminate useless Sytmbet Guenexating ' A+a, Bobb S248 SO A, BS Ae genmling Syrmbele Reachability dom S$: AB a2 Seachabb. qo «wesultant gearemary & $2 psp / AB Ax ans) alas Bo sb6)bb).sb/b5/e]aAs/alaa one fox the follewthg grammar «ff. $2.aB/bA Azas [bArla-* L B> bs/aBelb @. Fird No e€- psoduction and fe unit produetson Gliminale wselees production. Generating: Reachability: 5 mms, pand Baw wa A>, Bob, & is also genesating . Ablix — Sienplifioats on, the grarenmat Ut S2.@B/bA a3 a Avas] bAsla Babs /aBB/b ONE tala ht xa, Y>b. Urn VP BB ! S> xBlyA noxs Nua ao vs]xvie XB] YA A> XS} yu/a B> ys}/xvib Xoa yob V2AA Vv BB Br A grammar tb chomsey Normal ‘Ypsro epuivalenk- | tre fellewihg grammar S>Anlaa Arable Babba Fliroinak _€- preduction - S> AbjaB/B \nivicac Axaab _— Bobbalbb. Ebroimte _onit preduction 858) aB] bbAlbb , : Asaab ag Bo bbAlbb Eliminate useless —pwoduttion. Genesatiogy S.A, B ate generating gyrmbels Reachability 1 From 8, A and B& ase veachable . The Simplified. Ca & $3 AB) AB] bba Jhb Avaab s fx bbAlbb. (NE ur x34 en yoo we S-> AB/xB/bbAlyY => bb > yA am Araab cyeya Bo bbs] yy (Aah KA Ya 0 XA yh Nvlaeian leas S-> 5B) xB Vi oe _ Me S85 AB] xB [yy] YY A> 2A ay (Ax \SV <8 82 ees) Sie > yy BOB oy) xn ka. APA 3 yos Xb srearelt v= YA Ao Yo = XA vane a9 XA* ri 4. Convert tre following §— grammat Saab AB Aa base B2Bhale €: prvduction hoe and Bre Jirninat Ss abAB] abs | abB/ab A> bAB] ba] ba] b B2 Baal Ba/Aala No unit prducton No wselees production XA HYSB: $3 xy aa) aya [x¥B) xy S> xAB] RA) xB/xXY SRY RA[zB/xY Roxy > VP AB. A> YU] xA) yolb B> Bax | Bx /Axja.* Vo BA B> Vx /Bx /Ax]a. eto (NE quo Punabie productions: Gasibach Noval Horm. (GNF) Lab Recwusion The wesuttant grammat tp (NF & G> 2U/xA] 2B) XY Z>KY ure xa yob A> yu) xa [y¥B/b Bs yx Bx/Axla V> BA A grammar is Said to be fn) .Gwe iy Query, pardon oh the grammar & oh the form Non terminal => (ingle terminal) (sting ob ron- tesrninal) Non- terminal -» single terminal . 2% ) WY Uy Ghy te fe Wo lua Fell ‘Tok A CFG containing mules ob the form A> fe] B peer i called tte sea ba Ce, atten’) The — targuage generate by “Guch vule & Ob’ the _ aS par. 54 wo uplee be mule ‘A Aa/B oe, A PBIB B> 4Blx. ‘Vasiable » then the language same while ro Lege - vectensive A~ the B& & new gewrasl by A is Bx mus ave used eb dasivations. mong, ph --necussio Aspe reansion can be elimtnaled by the following Schenws ey AAG) Ai os [Rete are valle A epe reansive mul, thew A> pi |B then cheese @ Jos ase alt semasning A-miles pete noo-Fesrminal, say 8. Ral (new B= ules, x ao a/aig 2h *" ve Wp | # rp anne PY - | 2 hae as pifpiB ” hse ad 1 tonvest the org B= (fan aes Ase $683, na) a Me ‘boas eg er asl asailb i jimae SP pe Gwen Ganon eb oe vars haha ~ I. As pshilb *Y ng L pasa | 1 ai Grsbach normal form and = Aihala Bs sub A & AB. ain Ag sina Aa]@ tej Sub As wii, is aw 4 Pr aS mm bas Aa/a ab Apt [Beal oo : "tere, Ds “8 Lt vecensive Jak x, be? ‘new non- terminal Z> AlAs Aa | AiAaae™ xy a [ex ) Aa pi) Bo] Pr] B®, . didi ne} 0.9.9 608 i ns bighg] a | bAsnaz [az® Sere [Aa ag | eur Pa vw | = Sub Ag & Aas) gel : } Az baaAahi|a Ai] bas naxdi Jax ar [6 —> © Now Az is th GNF siasd (simian | sina | fs Sub) Ag’ to Ay i) A> bASAs savas | aArAs] b Ag haatsAs/aziits/ bAs cre ch Gireibath Nowel foo & Ay baa honras]| AAiAg | bAg Am RArAs] ah as] bas J azar] sods Aa> bAgA2 AI] GA1 | DASA Aa >bAs he] a] 6 Ashoz/ aX (2)eomert dhe CFE to GNF So Arla A> ssfb. Given grammar bb ONE Reramby Vomtables, =A, and AsAz Y Ape Aaja, —>OD C5 Az Ara) b ay sb Od & hak A> Aye lemles Hew As & kept cri? OD peceee + wing, @ athe U4), volkey 41>), Rebetelhen d==4, Left tececion Clnereke U per le nan e fi ve tt A.%¢ len, Ib Ey fF 1] 9-1 go Ale atscade FR aaa] bar) aaza, J bza,/ OA ALZ | Az] AZAR] BAAR Lo tS®. Har Ay 8. tb. GNF foun 5 Sith Ao th 2 Co) now SBE E foo Sub Ad ALO Al —> GArds | baa Jaaxa2]|bzA2}a., The Ch th GNF (form. Bb ArPARFa] bas] GA A2] bzAz/a A290] 6) aAiz/bx 2 Ani] baijaaseay| bra, aaa [ba | oARAR/b2AT. @ Convert the gramman Gr thy tp GNF. S> xa] BB Bs b) aa Xb Ava Gb NF the given gramme Rerarmirg the variables. son xan AAs BoA. tovitten a the grammar Can be Ay eds] ng —> O- Aq 6/A.A4 —>® Aa>b Fe asea. —>@ OO. ae ch Geth Andy > tf Aa b/Ai Ag Sub Ay th At Ag yb] Aa Aare | hats ha b Ay ee [eae (Sab nz b) Hee Ag Sb Lop recuse zo sgn] MUX —7O Ag > b[bAsr4] 02) bA9M4X —9® Aa, As, Ay tet GNF fox Sib Aa>b and Ag th O, Ai->b Aa] bag] bAsag ag | berg [bAsAgxAg.. Aa>b Ag 2a Ags bjbasnal bx]baayyx. X > bag] bAshg Aa] bxA4] btadarag] brea Baa nga?) baA43] baahaz uz : Fetes pom: | Conwst CF& chtp Gale 85 ash Sab. Puroping seroma “fev 0rt ib Ag th % = : ; . “en 6 ag|bnonaraa | bm] 683400] | ht od be a cet. ‘then thew exust 4 Constant *n ‘ . x bag] baana hy | euch wt ib OC Bay arg ibe dha i a atlas! “7p, then we Gan. tovile - R= Uvlony, Sdyeck to | é | ing Condition . The Gyraromat th GNF foam B | dollewing | ds yor h 2p, The middle peabon Ub rok tro long . 2 vee. Sine ‘v and ‘x’ axe the pisces to be Pumped, atbast. one ob, the ghings , coe pump musk por be empty This condibion Sayss) that + For all P20, wvieoaly Bis : Toot &, the hoo shings Vand & mag be ‘pumped any Durobe op times» ebetuding 6, and the wesulting Shing toil! Srl! be q@ membe ob b- ye SPS foa_poovitg the language rot_1 ‘be BSB ering Purnpig '_demma . 1 Assume that the language ~ 1° ts Context Bree . 94) Taka the ghing x frm ke 1 8 cattulae the, lenge ob oe Me ial =n. Av tb la) zn, then we can haae the rig ‘zs avi and oo conditions Should Sabispicd (and may Ce id |veox} €n iY ey veges oh OD > Way I ab te abowe eo condinens ae Satispud , MEP Me fellewoing Shed eld Suth that too cendibons ate Satisjud | tor all i20, uvhorly ib Bo For at P20, uv'eory a abe: d i z= wviwrly , . S . | that does ro. 3 Fox any vatue eb T, geta Shing © uv ont ag b Ss ko nob eu re long tp the language guage i su vorinl'y. |b Sheu Bbae Ianguage d= farbeeh|n13, HS net context frea | = ah BO (bem tn | | Janguage. , | . ‘i | xa arerery hn 1 ASsume the Sanguage “tba CFE ‘ifaan. ub feo, zz ahh” (bP-m)""e? & Tare the Sing 2:aPbPeP Pure ze arb? (bem) cP gL arbrcP eb 3. dengeh ch Shing, 121 = Dtnen=3n. | put RL2P, sn 9n : puris®, z= arbr(p-mc? gL. $0 SBE Shiga \ean be bya oik 5 Substring ass Fox the values (20,9 the Shings' dlecs ret belong fot. 42 uvery | J. The given danguage trek CFe Ae Reuvwry . rend . eee @ srew thar d= farbPerdn] nzoz isnot Ce | on wos =? FT pssume the language “ky & a CFL. avd 4 Take the string x=aPbreUD ey WET 3+ dength ob» Shing Ia] = 40 Ja) => 4920. x can be bwak “thie F Shirgs Such as \D Wer) en SO the Shi 9 per R= uvway WT) yad> nem at OY VFB sey wr Le avi 4 zeunory = arbrerd?- > . BoM ee, team, ywox=bP Vash y acl?

You might also like