0% found this document useful (0 votes)
31 views78 pages

FLAT Part 2

The document discusses context-free languages and derivation trees, explaining their properties and the process of simplification in context-free grammars (CFG). It covers the concepts of leftmost and rightmost derivations, as well as the construction of reduced grammars. The document also emphasizes the importance of eliminating unnecessary variables to achieve a simplified grammar structure.

Uploaded by

Pawanpreet Singh
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)
31 views78 pages

FLAT Part 2

The document discusses context-free languages and derivation trees, explaining their properties and the process of simplification in context-free grammars (CFG). It covers the concepts of leftmost and rightmost derivations, as well as the construction of reduced grammars. The document also emphasizes the importance of eliminating unnecessary variables to achieve a simplified grammar structure.

Uploaded by

Pawanpreet Singh
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/ 78
| || : ' 23 Sept-,2024 | Menday — +e CONTEXT FREE LANGUAGES: | ¢ ‘weefjTr’ene OO OOO OOOO wwe Pow 2 ADK A EVN KS - XE (vy 0) = - - ' f Seb of Stren - 1 Vasdab le” % # ; | Pree tue will nebrusent Ahe conlxt free | longuage [4xcammax with oarnrievation 4 Tree - > _Th we Fave the Grarman: | G= (Ww, 28,5), then Ashe denievatkon {nee will hove following properhes: Ir Every vertex Ahe Pree 45 2 variable, Term — len on 31 _anay be null 7 | Root of Tree ° Stinting Symbol 3: 7 3 All the frternal nrocles] internal vernkcs ane Se Saeeeyeg sas wgseewseagagasagees _ the _vaniables - | M2, Mg ve Ns ae Labeltcl with 4: dhe xX, Xo) Xq yee Xs, and rf ale thus - mods dre Chillin of “a rock N babethd- , vithn , tun us haue th produchon: 4 > - 7 Seal 7 oa s ) _6=) Vertex fabellad with Terminal on Aas = eof Node : - Oni oes esenees GC: “Subpose “we have ‘Giramman Gh: (f5,A% fab} 504s lass, A= sb i, 8) The_Denievation Tree wit be as follows Te | Ke Sub ~Tree Le Secu ‘ olenievation Tree. a tC Cancatenale label of leat vode-y > S>s55 aS > aaas S aabas Sea ba - These terminals ant Pnown ay yield # denievalé Tree - L THEOREM: Set we Ase hav'ng the tonuxt nomenon fx Ayrammar P_& = (me, PhS) é Cha then. Aheie fee a e ¥ ard hen it Clentwatenr fh fea ne coith me a NN," SOS VL } | | 1 | ) | | ; | | | | | | | | i | = 30, Sept, 2024 AL DERIVATION TREES: ~ ~Moncloy si ern nee — -_ ee ee owe iG) Phen ie Se a deruialion Ares ea “unt_muat hove A-» abe : oe eee aa es I ii TP we areca the : doxminale _ Porn Left 3 20 Oo ight / then dho.is Known as Ae yield of Ae denievatron = Tee. eee 4% fas S> aas[a, A dbA Eee[ba Shas | tal — — 5 +*5aabhaa’ _ 5 3 @AS 5 aSbAS > A@qbas => aabbasy- \aabbaa. = Here we are choosing Left rnast vaycrble Denievation Thee: OF the Sentential String ) ; OO — _—~ ; eye | Concalencl, the. _ ea ody from Left Ao Koel + ae ged of the dre i aabbaa. | : ee 7 fis we. Qu neplaa'n dha Left most vam ohly fon 60, it “pl eT ryrnost Ef ee ézaenty we can have night nos! Dewvaten IS >» aAS = aha > asta aS bbaa 7 aabbaa. ft taking Ahe variables : 6 >aAs 3 aha =asbAa 7 24 bAa => aabbaa: Ss ae > 7 agen? > gains) 2 aabby > arbbaa Tr we ane Araving Som Tsien pe ASMHOHRHAKRHKHKRAKARARARAAEES a 3 lo ae: RB 8 & 8 *| | ra ere 6 nr 37 OB] IA, A70[05| tA, Bal [isjoge ¥ w= gollolo! : e Left most Denievalion : e e => 06 = 068 7 00156 > OOWAB > OOllgs> @ Oolloie, » Oollolg® => Ootlofot e oe « Right Most Ooievahor’ Le ) 15508 40088 +008! ~y 0015! =? OCOllAl => oa] oonost = OOlletal 7 oolleros _ 5 Randomly arg he variabla ao z . 5208) OBB > 00156 = 0015! 7 ONAL =7 z oollost = Oollolal 7 oollolel - 2 hl a 2 revel “Thee Left most Denievation: 2. [Denievatton ton 1 erie . 2 | 5 2 = | 2 Z = 2 = = = = = < | — = Corcaeraing a A Fenmimmads we ged — (yield Of the = Sool a | 5 | Devievatin fon night-most Derievation Tree : [2 Varad ae ae tie te de eh | | ee ss) e 7 = 3 ca — o ~ Gncbdenating au the . ~ldenminkds , ate a i «= ge: 7 : > Yield of the Tree * oolfolol : : oS) | oe : oy ' = AmeicuiTy IN CFG: [A_tenminal Staing w ,undy the tial Fi . _|_44rammax known os Arabi aus , a... ei _ | Th thers. exaty two Or nan ——— =- Aras 4rr (a see I O: G: (454 a,b) +, # $B oa ae whene b= —\ i fs75 +5| or oLal be ~ Vela le : ae q eS eB |. x = 2 fa © Soin: | 5 StS > AtS > Ats*S5 > ataxs = La “| : ataxb - r = Thus ts the Left rnast Penal — a 7 oe j pe + Amothen left one Os Derisaatiag oo eo [S> St53 9 _STS*S > atSxs > ataxs a | > ataxb . : The Penal (a jot 5" Pp. a > : wf cea = — a : 6 6°. [g° om : 66 6 a = of the Tee Yield of the Tx 7 ataxb ataxb - o 3 t Rk a a oa = in dhs ning Ms mown. ribijrae) | a AMCEG © Calhd abi ft ee xa 2 | Som sig ao pwhich a uy | 9 fas ‘5s psf. we have to Pe i a 2 Ahwt fr 4 ambi — S| Sei eeommm ae abababa_ most _ Denievation ee SoS Shs = Sbsb5 = =pstebsbS 7 ——~ababsbs> ababa ba = iat 7 a ow => Anothee option * oe : Syabs > absbs 7 ababs = ababstsowe [ ahababs > abababa @ ————— [ s G ® S @ © ~ : Ss a ee ee 1 6)_th} (3) @ @ © © e = ds _@ @) Qa) al : as i f € Tendon vey ue (AN Can Felons bel this fen ne / © aunbr gous _— . vw QO: aol absbh| aAh , A—bs/aAAb eu id boliy. a Jat paper et ’ a ee bet Nm a 7 YY ze as < a ye ST eee — = = abababb z Dp _ absb => abako ts 2. baba 2 D> 2 a > CRO 2 2D vy — e 4a) © YU = | 7 @ = = : | “Therefore, thus ds Ambiguous Yrammay = @ S—aBlab , A 2B |a, 6> Abb |b a | 5 Solution Sab 5 : Sa ak ¥ ab - © | - a £ a es |“ ov i aaa reat — —— a = em e370 ous ae DSaAaBeb > — a aaabBh qanabbb— 2 . —_Szab bb => aabb >» qaABbb = aaa bbb => aagbbh > SIMPLIFICATION OF CFG: ( Recluction of CF G) Te Prudu Sons all the Syrnbols au not ei Lid 7 fhe diriatten “Cece ,: > 8 SOKRAAAKESHAALE us wit | nedua them > 7 Lrammn at the_ Lagucy rn ae : Same Jenmunale ‘Then wst_tam" nemnou Lhe © | m Ure 4rornrnian =p Te ain Sip lfc on» “8 Gz (45 A,6,5 FF 4 bdt, Pot ——* ___| where : i (SAB A> ,B2) BPE Pd x7 © “Taye {abs 5 Ga carctng Hus ‘Say tone oo will geF Some . a —_ rl C — = ge Ed —— “(eu ot 2, ke yes jprks ee fora the Stash 25 be |E—y A 4- |B— { Sim fly “loony Ine vaaable, ) ae = \ a 2 ae - | we_can ebiminale Use from Ue _4ramrnan 5 — 2\we Gn i ee those vasiables p which ave rok t octunung 1m any | dentimfixl m Bafta fecenny onary “tetrad for. p : | Suchas Ed cL : D = > (dare eclualian D Aule which au Tot Ae, at D last ue get the Simplification of CFG. 5 > | F ut fom Semple vaughh plang another a Simple Vasabli: that 4 f no” ase» these 2 | fey aL must | be Oliminated ” 2 ¥ october, 2024 Prondog ; 2 > CONSTRUCTION OF REDUCED GRAMMAR: So RRR 7 Gz (Vy, 2,75) = >| we ‘may be pi a Variable , which & not : | yeoaaching PA Aenminals. we wit 44 = : [tema ‘Such tind of Variables. © “3 we i Fau _80me Els that ma’ © mull element, we aay nop Su . > = dit as wets to ‘Simply mmnare 2 a a 4 “Suppose ute. a Laxinbk Agglacn: eno _ oa ma “f' then Vawable a — os 2 A— fo es “draped trom! eo . i — ti Such can alc be hrammar inorder ty Sh mpl is o y ae | S80, here we will uye two _thonems to |_‘simmplify Ahi” 4ramman > : ee lz IP Gis CRG Such that 1G) £ ont e | a we can find equivaberit Yram| G", Such shat each vaniable wan drives Gone tenminal Stnin Clantial Step fowands Thinimi “gabon oP Grammar) tet we have Gromman = (w,€ +f, 3) oe and Het we dlefine Qramman G’= ¢ Cay 2, 25) e Se a) Constnuction of Ww’ : © | Here final ly uly __ Will alefine @ Set 2) ‘u) = PAE Ww] thene exists Aus) We axe — « Hi oe ii wip = WPULAE Vn | there exis A— x e ae (wiae)? t — © — Wvaniai les of Prreucots © _ Pe Aa aD) v — (84 = a Ua A) T a ao == acum _¢ ie we G fide A thon. uh. will Ti fat ~ yhen thie Sitiaties Come, hun we win 5&p heu = - eer = 2 —LL_ © b)| constuction of Pi = i — Stning « ao 2 faa] awe (woes =| Ler ee ae eee a D = Ris _rninirmiaation af Gromman: y Soaaqga7oomeres ep pps -Gi= (45,4, 8,5 Ef, ta, bd? F5-7AB, Aa Bb, 8, eods, S) Soin: we have Ao find a fquualent Yrammar_G' T Ge Wupe bes) 9) Construction Of Yn': Se ee ne en |W: £48, E 7 fA = Dineclly denieving the Variables «| w,- Ag ep U $f = 754,68 EF 2 = F5 AB EF UP = 154) HES _ : a Wee Wg | ee Uy" = 1oA) 6) E a= oe b) tangtnactton of Pe (Pf pa Ab, aya, 656, Cod Poe ae hrs ECU e a CC e+ —_/_ 9» ees Thenctone, - ae aia ages £4, 24 " gies iy 5 622 bab oe o & r r Every | Seaman aa 2,05), © _we can ‘construct Yromman G!= | Un’, ze) re 2) auch that e@veng Symbol _in Vwi F - a ans in Some Senien jah, form. —Tiltig tic dn vation of @ Strin a= Ons 21, P29) : a a nies ae a) | v= £39 Leet ° wit = wid Sx € fWwUetf[ AX EP Such dhat A wi anid & Contains x 4 a wie wri - | and Syriots in Vasiable Set and te inal ae tt bor Bip: (ys Wit! (fer Some! ) : Wye wr \— Name thes Stas LK ae wht nduk Vania, 4 ult as terminals) ANUAAAADAD Dns bruchon of nS, 1 Pe ener aes —e 6 oclpben, 2024 Teesday Fiat Ture (AClen Mst) r ae a ee ane dropped | Sada ,A+bBB , Bab, c~raB 1% produ tap = a ‘Appying finst Theorern. |G: (Vn, 2, FS) | Vn = ( 6, c) | 2: (@ P= ao A b6B, 67ab, =! Lt Ms derieve the q q: (wi, €, 5) > consinu chon of Yn': Ww, = 85 Wy = 1830 4ac3 = £4/8 oF wy: $A,8,C} U {54 = 55,48, F wy 2 $5,A,B, FUP = F5/AiB,c3 es W, 2 We Eilean 2 Wns 15, 4/8 C5 > cons dnuction | fi fe Pi: SAX JA € (vue )*f p> F570Aa A> bee, Boab, >a Bj aoe aad thuehou G': Ls) ab) , 1s ate Ab, Set WY aly 3 a Applyons and [heorern: a= (n'y #57, 5) jon nsdnuchian 2 of Wwe: : atoi 0,2 _199,U £4, A} . 15,A,af | qx | A>, AG Wi £ AGar - ans WK 4 wy = 15,A,a5U 2b) Bj = {5,A,8,b ,a3 y= {5,A,8, b aU p = 75, Ay 6, aj b5 W, = Wy 3 Zo Wy £5,A) 8, &) OF | pistes a Vy!, £! and | BD HD NS MS BS TD 1S FS HS SSNS) US WO MD MD HD | ‘Vwl= We AVN | le £5,465 6,4, 4 A$ 3,48, 3 15,4, Gf sls ~@ j 7 ; BI =a “8, qb ay, 4 CET Fa, bh 4 = 1 iy Po p 4 co eee eee : - fe {sake A> 68, Br aby — 7 a ~ a Thenefox, the minimized Yrammnay i | i = {5,48} , %a,bi ts 24ha, An b88, | ab, 3 ? o > {6 find dhe —_ Grammar, the precech e 7 eo e | Mie Theorem | and Gi is Ae ryutt | After then find | Marg theorem em 2 (apply ° 7 on the _Yramman_| 4) “AEG a thes uta, (ue cul cui ged He cata flommang saree The _Segtnt 7 cu be same i ie fa te Sequence aud “Tate the in aftzeninan. mney a “~ tm iged—& e ¢ = ee « fay, 8S b bs ie | Hae ' | 13 13 19 13) . | october , 2024 Wednesda t Qt G = (F5,A,B,CF, €a/b3 (P57 AGIA 4 oaee (ng te oo “c9@6| 55, 5 3s) (oe ean Z | Step 4: fet Gi (Vn) 2 Re ot 7 Construction hn rr—“EE : ffacy | a ac? U f5,.42 45,4, C5 w3: (5,4, ¢% U p = {5,Aje. C3. fa Ev | Aa, XE (Wie)* * aa Wis $5 Am Co a Gorstnuchon of Pl: Pif(Ana, A, ae (Wa)™ P: fSoac , Aa, cab t Guz Cs ach {a,b3, {59 Ac, AD, C75, tena, tae Ue get 4 of Snead [-2pplying Honem a Terre ee . | dd & _ Fae te G's (yyt eee 57 pt 3) A 45,814 (2 FS ACLU fa/bj = = 45,A,%, 9, 63 Wye $54, C4, DIV G = BAC ab5 = 2 we < .. | oY —a cond ruchen of Vn, "é! an and P™ aa —_ — b4 . — [Wt Wy AV! Le ch st FSA) — — EW RE oe PY FAK AC WKy geqqaqg if | Pr: §saAc, Aa, 6265 ‘le Thunfor, tu_mintmized Grammar Mt _ _€ GE (4% 9 tab, 2 AC, Aa 4, & | 5) = = lemraran oF NULL PRODUCTIONS: | LIVIN" IYI YO Am A (This produchon is ~ Rrown —e dy Nutt produchon ; $ = Popes = aA |as|A , APA Su, St, aft want erase Remou the mn production, then cus ‘utd foltnas a preocedune _ then ute __ vail nabs Aha produdhions a follows + _ Pe 3-28 /ais: fl variables Said bi be Wathable vanabh, | 4 a to mw af br nub bip hie Ah 30, us frau Aronem ) 20 kernow Tun Vawall, ‘Theorem: Hf ab Yyramman , 4 (vay SP, 5), we Can find © os equialunt Lyvam mast G” that has’ ng nuit" productos , Such. Phat UG) = L(a@) - Shi L(G@)= LG) - 23 dt ve fraue _lyramman G'= (vm, 2, P53) TT | (orstnuchon of st of nullable variable Wy: {AeWw | aA >A EPH a i We: k i | | | | 1 | | | Ss . : | ae ae > [Wi 1S i : 2 Wit = wi ~fon Some i< [vw = Wy. WF 7 e = Se f uniable variables e i a eo Condnuction of P!: e ARRAN AREDETEER a If Productions of P withoot Fauung any rultable a variable aun be mudd In Me Sd pl @ T « Th) ADX%x we Xe InP < thin _tndude e | Aa id, ey WP © whene, = X= Xp ORK = Sudv that o&, 2... oe $A ; EXAMPLE : « | € 505 (ap Ae | Bea bes, a i @ * Consiructn of Mulable vanable, * 6 | — ‘ Wd, = an € he {ay Bf U u {5% = § Saat e we. 495A, BiU B= 45 hy 8 os a ‘ ws | me ae BUYS dL fi) seas giver Sas) sa F = (Re rnowirg raiable > TT erably oe if) SAB “gives 3 48, 3 36 > : oe po dhe end) wus wii be hawhs Dre Vasiecla | a ~ | Gis (bh, BY, 14,55, 15745, Sa $4 AB 2D Sah, $28 | 03b3 2 [10 october, 2024 ne a a > ELIMINATION OF ONIT PRODUCTION: © : ARRAN AAAI 2 A Produclion in which Single ignrabla cu another 7 variable, then it & hnown a bro anit. Pro duchon- 2 - ASB a SoA . os B62 C 4a SE L1G): taj — 3 Th Instead of Huse variables, wé wm 3 a aE Aen He Language coil be 2 _ Same. - » =] =— oe _ PROCEDURE: a JFSEECH - 4 “Theorem: Tp we Pour Srammar G then we shave ne =] egutvalen| Grammay_G! ee fh has‘ ng nul 1 null produetton and unit pret’ yon: _ wv rf SS Exp: T Gq = (Wn, 3,P, 9) i \ : : : {- Find Lyrarnman Gg equuvalent to G cohich a not having mall productions - oe a : a) construction _ of set of vantables desevabll Tran ae oo wo(a) = a3 | : © Gnducle hat variable rp Win A) = wij ta ciw ber, cews (A p y wi (A) © wy (A) IVwl One Wnike So ue wil bes having PS lVul Se corti (A) = 497 (A) lon Som _ 5 way way b) Construction of A Productions: Aw oe mone und Predictions wut be jncludeat inthis Set fy ue wih inclade the produclaon A> o when | = even, Ue ane faving 62% am ‘ fyen yamman j 4 : ha 6. Wa # vol Un EXAMPLE: 7 oe bxp: | 5 AG, aaa, $6 |b, cD pa, —_ | Cr2a on 7 s. oe i 2 3 Thene (§ no mull production sn Ae Yin Yyramman.: = BVSSDD a ay tomst nuchion of Sel of Vartabls [We(s) 2 f5p0 ws) = 193 biz 134 win A): witAu fac] 9 638, CE wr (ayy Suppase * a 21485 7 ‘ ATS sec. coh ‘) Weisy Wr CS) 4 wl) = $53 Wo(A) > %A$ wa): {As UG = LAF Go(A) = wi (A) 2s wiA)= fA5 wi)? 18 wi (6) = 164 U Fc £8, 5s —_luay (8) 2 £6, GU £04 + 9G,6,05 DFSECKCKC SF IISIPVEEGCOCSEGS SDP www Pry |_| | lwgie)= 46 G03 Uses= 48,c0cf eS ay (B) = TS) oF 26,C, BEF i | i | YX 5 - 9 | _tWo(c)= C3. ae 4 Z| wees fcyo Spy: Fi a a ees scoaaetes = —= _ | (QO: iGoOejyu rE i _ = ed CO: WCQ — _ | oe Wee a oe | wt itr) lwo Co) - {D3 _F W Co) = {Du FE5-= 70/5 er wr): foerUJ= WEI w - CO) = 42d) * w(p)= £0, ¢f iv) wo(€): £35 & FE5 = TEGO GP? TES WoL) 2 wy) = we) & * ae eagle of Productions: : Saducd alt the pred which ee rion— [oi a hii) $7 N6 Aya. "Bob, 67 -t Ba”, ic val D2a el). J ——— =yllet Gis” CFG, we can find ¢ Aw iE Sond te find yoo Oo iseet Elimination of null Produchins Step Dp 2: Elrmination of anil Productions . D+ Sky's: ay ply. an Lo find Gy) 50 Ahad _ pp eur uiahle o Inives Some denmin - | Siren oa 4 : Blep4: Ad , Pnaedwu tv find |, So Ahal Wd tung Dp - vant py 4 tenminal appear in Some SAlorbal Dp | form: a | 7 The four, ys WALL tue Ms the deal aa: 2 dnd "the Yule a e will 2 | find the ehulelond rave aN only Hhnoughe | Yathe mathod: 7 | 2 1 2 = = = 2 3 4 — i | . \ eee eee _ =) a Me a | “- __ te | Remove unit Production: Sa XY ee “Yo .Zlb ' a2 Mm MOON Na 2. | Rernove _ ‘Null Pnocluction __s=ASA|a6bl|b = Soin for 1: : : Step l: Thene is 70 Tull production in Ahe Siven Grammar: Ey eeeeeeqeee Q) construction of Set of voniables — Wwo(S) =495 W(s) = i550 G = 455 Yi eo | fon variable x WoW) = 15 - w= in0 p=: ee w(x) 4 E tee ee Woe TYG ee ps SFU eG Tye as wy $Y} : Mehta a. _ 5 {Mj 2 fy, Zz, M,N a | toy Yong = Ty, 2 NG a Fa Hem N} e = ” (Me TY 2, M)NG on: a | ; eC ) 7... sims pa pa Wz) = A £25, _ = Dl eee teh 0 my = 82/5 = D w, 4232 fzmy Ving = ABM i 2 = = 2p co for vari coble M: Dp | wo(m) =~ 4 2 w, (mM) 2 iMy,UINg = TM ON§ a Ww (M) 2 EMONZ U P= MONG, ob) Censtnuclion of Prodluction : = i) Indu al the _psoductene (hich au _non- 2 nit a ¥) SOX, Xa, Yob |NDO a iti) Mode, Zo Ma Os 5 6-1 Remove Null Poduchor = a 5 AsA[aa [5 3 Lo A=> 6 _ a a> bE = a ee a by | Slept Corudnuchion a atiaBh,_vani vars abl _— Apo e a [ne bay = Tee - - ee ss i Was ts, At oo w, 2 45, Mg: 25, AG a WK P5/ AB, 3 oe “S708, S28 ee Sie oe io A7 OA/E [Bol Bje wy: TA) BF Ww, > 2A, 65 U 295 eee koaoy Ug? 15, A) 83 aa: Ww, 2 W2| oe | wK2 2S A, 85 ‘ 7 Conaluclion A Procackn Redo P | ise AGA [saa] sae[s>aa jis2 Oi = tp _A>0A : __—_——. —— ff b> |B. Se = aaddaeanana | Rumove haa OW, aoe == 6 Do

You might also like