Theory of Computation
Theory of Computation
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, %, plUf 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 NOY 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>8BWi 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} bbcee 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 laneGaett 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 byeChomsky 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 Iab 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?