0% found this document useful (0 votes)
68 views

TAFL Unit-3

Uploaded by

Md Mohsin
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)
68 views

TAFL Unit-3

Uploaded by

Md Mohsin
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/ 36
uy UNIT: 2 ReguLAR & Non Recuiae Gemma VIII Ed rs aii ~~* Grammars let G=V.T/5.P.8 _ mn where s "= Va Finite non- Set whose elements are = Called varfabter = 3 T/3 = Finite non-empty set whese elements are = calle terminate. (5%) =3 3s P= Finite set whose elements are g—o B IS where emt felr nevi ge (vusy* Ty The elewents of P are called productibn or I; production rules or Rewiring rules =. Le Gz Sheetal variable he Can element of V) called Lp the Stating Symmtol + Exconple Ps -A aR A — abe tiie Gia {VT Sh > {fap fave}. PA} S— 008 /11F fo oor /= = Gre { {s.r} forps Ps (ump) heft Most Rorivadions — S00 ooS/nt soe pos? 7 E> DoF £2 00F/s par eee Rerivation > A derivation A> w 4s called a Left 7 most oerivation Tf we “9-5 Ase a- a Bo b tc Sol” so nee, cS > = AGS Bers abc £25 abe Ase abe Right Most Rerivation ?- A olerivatzon A Sw Lb called most derivation + (Rm) o rv o production ont to the right raost Variable at ewery wep: bx oe: Crops os poe g SEARS pge A> & BRS Abe —b —_ toe BEES Abe Axa = cv production ong te the LE most variable at ener stip. If we abe _ & em ao A Bo a a a /_$8Rs ww Ae Find the derivation tree of a xb+ Axb (peer that y QD S$ —ssrs/sxs ® 5 a8/sa ® meme DHS A> aS/bAA/o : B—> bS/aBB/b y Ss eage String. o.narbbo. bbba. , A — SbA/SS/ bo &y-uhrp String aabbac i) RMD * Wamp dik) Parse tree dd RMD ii) Parse tree S > StS/S4S §— > a/b UN Ss AN s ix Sk a b o b Hence Proved: Ox b+ Ab eer % L (Oy LMpD Ss Sok aB Ss 820.86 Qube g Be 888s ono BBR 6 Obs aanbBe Bb & = *5 dambb8B & PEebes gaabboBe s £28, nAabb_bRB ¢ B28 ganbbabb@ gg S2URS gaa bbabbbA gg AB%s anabboabbbo Odo bba bbba - + ® PRP FORAANAARAHAAANRAANRAA RAE MMII PHAN Oxbamo. § S2a8S, AS g APSHA, g $bAS § $2 AabAS s Aba, aobbas Proves j ®) é z 8 W Romeo 5 S240S, BAS ge, aAw sAPHh, ashaa go fiba, aSbbaw Freoved aabbag Fruoved Ct a het Gr be the Grammar 9s 0B S— iA A— 0/08/1AA B-> 1/18/0868 for tne string OostoloL 1M: 2b Firth Lyip foo RMD =< Sgn) Rerfvabiory Tree ety Sols — LM — Sy bad a 8 og =, o EO EB S voag PEs oossg ¢ SSE posing — 3S s posse _. a og 22 88s ponoiag eq S§ A225 voniorog —— a. g S30 sfoon ota | iis ty Reo —=8 S308 r — GaatEs OB 6 S95 ponotad 8 0B — LOB. O95 B gL £ : 8 g A225 [oorto101 | tl. sles ook, oT £25 vo lst C s $2 potsat s- s 29S oottost Proved i 4 © Pambiguty I A terménil ctrtny w © L(G) & igneous ff ok eoxutst Lavo or more derivation tree “for W (or there, esetst tuo or more boft Most Qerfyation LLmp) of wh. Guoss- Ge (fst, fob, +. ffs} SP Protuctin} pe §— sts S —— S#S/a/b St ye ot oxb e £ ¢g eS UN oN Rin WN \ — / | { | an et, phere cere tate: daxtvectlon Ss =< The Keb dirivation of string atath shduced be TS: turo derivation trees HQ Teefore g | 4 setg= e+oxb a aanbipeeus (jemonrs Quias TF Or ate the Grammar S— > Sbs sou WO OF Taso 01 " SNES that G as HA SSERRRAEIANS As fasaba . abuba , nbobaba_. — ~ oN oN \ Ss / J. / . AN ii | {| The Lmp derfvetion of sre abtubo tnoluced °f tro derivation ree » Therefore String = aba sth ambiguenns Gromner Qu0s5-D Shou Lat ie premanar Sun S—abSb &8— aAb A— bs A—> wAAb s& atten : . Show Bhat he greawivar sore pal g§—a8 S—> Ob A OAB/O B—> ABb/b ws on-biputous PPRPRRRRR RPP PP PPA 29H9 AG aggagaegnna Q Consider the gramntrar fver, below: \ | ——> E+E /£-£ | EXE [E+E/a/b OftatreliMD, RAD for the oy sting = atb*xatb ; okt Concider the gree page | nthe s— (4) fa RE Woncteewivl= (4 O24 LoLs /s flepnetrea=? whet ore the terminals norm kerminals eo aie sipotals asia Find parce tree find nhs following sandeneex h {a.) Lmp=7 Gb (0,(0.)) > 4 amon 2 Git) (0s (Cosa), (ara))) . Parse tree=t | eee ee oe IE : ke {o- pbab ,abobabb ~ —— 3 ANN Zo. WUUUCEde veddddd _ t= abab ~~ — -4 s g YN, oN OH a b er MDs bye He fy Rod pay xe gbeetes exe te. pe Sc+eu ete 5 LE ex eie bE: pte rete |e 2S er+exere go 0+ be E+E 5 £22 ereketh eos iy ¢ £2% E+Exatb 04+ b ®O+E & naar E Eb ob eath Es ° E Hb HH ath] Bw y =Sa a+b €atb sv@- S—— (L)/a L— Ls/s Termmal = Lif Non-Terminal= ( )y & Storting Symbol = $ PRRRARARAPRAPRPPANVAVFRIAIVIIAVAAKNNAK EA & =~ oN SS —~ Ss Ts, a =~ aw S ae aa ag ae tS =p. (LiltiS)) oS (1, (559) PH, (1,((Y),9) g Abs, ge (4, (C4,8),8)) ss (WL cLs), (Ul) SHES (1061.5), (4,8) SEES (5,049), (hal) SAPS (5,((5,9), (hi 8))) SEE (8088), (6, ))) SS* > (a, (59), (818)) S*5 (0, ((0,g),(5,5)) S——> (0, (( 014), (8,9))) SSA (04 (Cas), (0,99) SARA (0 (C0, 0), (ayay)) (a,(a,0)) Hmm ¢___4(L) GAPHS (1,8) sts (s8,) e284 (a8) gS2Hs (ay) g LES, (4, (L8)) g HPS (4,15,5)) & S2%s (a(a,8)) §& SS, (0,(a,0)) ReMeD S— () SEES, (4,8) 3 24 (1, (1) oboe, (4, (us) S$2%5 (1, Chia)) g £84 (1, (8,4) § S24 (h(a) Los § PSs (5,(2,4)) | ee (a, (aa) ee a bddddddd lid / Dy ow GEG ob eu ¥ bee bbudd vyweevvebbb Rubeld) s- Construction of a bet N= (100%. WO, S. &, dy Fe Tw wlar Grammar for o DFA ts in TOD) than et £5 obtained ba Conc Fg. PRR Aameols Corres pondin to several trovsition, V the fitst from Bo and ne fast berwtratiog at come feral state- & for the grammar (Gi) tobe conctructerts production, Should correspond fo transition, Alo, there Abould be provition fr Lermérating tho Qevivatipn once ou Trovattion tevmmdratirg at Vsome firal state 24 encountered. With thts ddead in! mend, we conctruct G as T= B 2 ? S= Where P te chine bee the fobtowaicg rules fy inctudect In P LF 6 (%.0)=%. A; —— a. As 43 ¢ F- Rutetide- At ——* 2 AZ and Aj—esa are inetuded in Pit Slapal=% . azer. 1 ——@E2» for Yo State 2 for a : i 4 5(4e doe Fh 8 (4 .a)= Yer : ‘Acams00 he Ay —> a Ay t ‘A : Ar —> O,Ay A= a-Ao &—3 & Pro 8 (4b) —> 1, 6F 8 (4 b> Wg EF as: ha ' = AID AAG > AoebeAy Ay : A;~>b Aiea > Ap=>b 6 = [Lem]. {4.9}. 8: s} Regular . Construct o Girammar of ger DFA. Ov LECCLCLCEELELEAS AALAND for % State 8( Yo 5b) > YF F 54.7? WHF Fro b-Ag Rae OA Ay —>b Aye / | [vn ir VUE or alt de productions inn P for arti iN for 9, Stete -™ 4 (4,0) — HEF (ta 4)— 49, FP —~ Ay —> fy A; ba FIN Aye Ai & aN for 4, Sti EN Gantt Qtlatet AY ahs Aa—> Pfs =~ Ay— & As—>b ot for 4s State ( aL (45.2) —5 4er 3b) lth al A,— OAs a ot Ay—e 3 LS Gi= [Lav AiAsiAs}. fans}, P, As) eS Gimpliication of Context free- Grammar. = Ina CRG Ht may nak be neces 4 fo use abt the deriving inv gontonces. Swe, ia cw context-free seul Che) Le), to elintrate those ard production in tN Te seeast ma oe iho darivatibn. of sentences . Ao Roo Al ana eh 20 aod Eve ™ toe eon FOA B—D Suis Ge {ev 7. P, st = [ESAGE-FY,(a,bae) past Reduced Grraommar :- Gi= {tsA.B) , (arbi), Pst» plo S— AB A> O& Ba b/d © Construction of reduced Girammar het Giz {1 PS} , we define GI= { vir! pls os follow , . a } . Stept: Construction of ton- terminals (v') We define Wi EV be recursion’ ly ={AEB, there erctet 0. productinn ‘ Ro w thre we eh CTF Wy = ©, Somevarfabke will & remain after tno apblation of “at prodiscdifon 5 anal ZS uai= 6) — Way = WU PAE, there exist Some production Ps Avet — aE fsum}* L Ww) aad By. He aafihation oF Wr. Wi C Wi for alt. dar V fas only a findte Number of varfables, Lk = bho for = ~ Sore KEV] therefore We hee for some Toa. . Ve hy ae Skop-8'- Construction of pl oS Pefaar a.ae(vus)"? .65fvir) pis} a (We are got to prove that every variable thy wn derives Some terminal string So tf SEV, L(a)=6) y 4 — = het G4{vue, Fs} yer * production = o> AB tS ASO owl Bob ol B— Dd al Food a rd thes retails Aradeynar equivalent to the Gyiormar (61). ; Notes(f) tle construct 0 Girammar Gy, equivalnt to He : gaer Grammar 6 , So that every variahle Or Git > dertves Some Lorminal ‘string. dD We construct a Girammar Gy'= {Vv £) Ps f equiwlant | bo fee Gi So AB eset sgmpot dn Gy! appears in , Some eats sontencial , Se teat form of 6) whiok, 28 : equivalnt to G' ond Roncet Gy. Gl ws required’ Gragemar Wy = 1 A-8-€} ' Wye hh U LS} - . = fas.eyofs} > {A.8.6,$} Wa= Ws v{o} , = {A BES} Ufo} = 1 A+B. ES} Quiea > S— ofa A—> Sb/ bée/ DoA C— abb / ppd p— ada E—> 0 Saree 1 {Ct ks Wy U fark] =) fac. RE} Wes Ws U fs} SPACES} ye Mov to] [= faces}] 93 Sy pl= 5 —9 afla c — abb eE°— ac PPPPREER IN IIINII) III If A — Sblbocc eS w, = {st Ws ewiufan} ~{s,a,a} Ws > ws ol b€} We 2 wsuU gp ={5,0;A,b,C} P" 2 5 5 ana & — sbibcc Cc —abb G"={(5,A,c), (a,b),P" 5} e e S> AB/CA B> BC/ AB Am ®& Cm a8/b SIs w= {A.C} w= we U{Sa} 2 {Ae 6.8} Wa= Wa vf 6} Wa= {A,80,8} S> ABICR 8 Be/AB AS C— 48/b (A=nuly) ull) > ye Y » > D 3 > 3 ‘ db Elimination of A- production pe bee alice VA CFG may fave productions of the form A> A. The production A—sA 4s sust used to grease A. So a production of the, form AA, where A is a Variable/ Non- terminals, iS called a p- production. In Hus section we ge a construction ty eldmenate AW paodict av. “3 Notes A variable /Non-torminal in a CEG fs nullable of ‘ ~ * 3 A= A. 5 5 Theorem 2- If G= (Vv, T/d, PS) 48 & CFG. Then wecan ‘ find 0 CFG Cy having ne A~ productions 3 Such that , 3 LUG) = Lla)~ A ? of ¥ 9 Steb-L Construction of the set*nulleble vanables We find the nullable variables recursively; ub Wy= [A € Win A ss tn Pt GD Wrasse We u {A ENni/ There exists a production A> a with o € but} By defonition of Wis Wi Wing for alt 2. As Vu is fintte s Wear= Wie for some KE IV) Sos Whey = the for ol 5, het Wet, Steprs id Consfruction of p'. \ any rac whose R:H:S does not Ave mi le variable is: sncluded sn P\ 4f A> X1Xa-—-— Xe fs an P, the productims of +e From, A> Ag-—— Ke Ore tnetuded én P? whors Apexi SF OXI EW. oF Ext or A’ Me ye Wo and Hyg —— OK EA. va ) GD gives several productions in Pp’, The’ productons are obtained either not erect one nuWable variable om the ReH-S oF A X)x,—— x or by ir@ Some or abl nullable variables” provided eorce appears on the RH-S after erasing. het Cy = (Nye Ee PLS). Cy Aas no nut? productions. Kiimination of Unit Productions. A ented free Nar may fare production of the form A—> B.A\B E\N- ‘ Definition + vA unit production fn a CFG, Gi ino produchor, of dhe form AB where & and @ are Variables in Gr: Theorem’ TFG is oCRh, we can find CFG, whicly far wo null production or unit production< suck Hat L(G). L(h) RARER ETE ADVAN VAD AVIV AVVVAVV INNS SA ¢ UUU Ue ddd dd dee thd lelbdd dd del?’ Proofs We can opply cérollasty.2 of theorem to grammar Gr to got @ Grroneaar G= (Vn, PS) . nul productios such that L(6') = L(G), utthout P het A be on variable tn Vn: Slebts Construction of the Set of vanobles derivable fiom A: Refine WiC) recustatvely a follows: We (a) = {A} Wr lAl= Wi(a) U{ BE WW} CB ae in P waite CE bsiCalp dofinition of WIA), WiCR) < Wis, (A) + As Vw ex Finite. Whe (B) = Welad for some KC IVI. So, Whej (= Wil) for ol. 380. het W(A)= Wk (A) + TRen WA) Is He Set of all Variables cerivable fren A: Steb-2%- Gnstructio of A Productions in Gy * The A’~ productiox in Gy ane eifkor (<) the non-unit production ing! o- (2) Ao whenever Boo th bn o with BEW(A) and Ae Uy: wu » (I) Corwerse (1) a& BE WEA) . Now we dofing Gin, &. PS), where P, ig conctructed Used sted & for ewer AEN: Choma Normet Form ene) -— pig ENE Eee Proof t- (Construction of a setae one) Elimination of nutl~ productos oud rile preduchan. . aoe hn ory theorem ‘ho the neg to eldininate ® 1% Productions. bet the getammar Hes binned bo @ = (Ww. E, P58). 6 G Skbd Evinthattn eMerwinold om Rete. é We define, Cis Ws 9B. Bis'), whore P, andl Vp) are Constructed & ow Follows UA the productibrs gn P of the’ form. Asa or ABc are e Lroludid in Phy AM the varfabled in Ny ane dnetuoled dr Vii. UD Consider A~> X)Xg -- My, ULL come terminalas RHS Df F Xi fs @ terminals a8, OAd & HOW Variable aro the Variables ory the His, are retained. The resulttis Production Fs aclded t y+ That, we gel Gy~ (WV, FS) Step.g s— Resi the number of variables on RoHS for ong production tr Py, the ReHeS asnagcts of either aw sikglv ferminal (or A fr Soa) or two or more Variables. Wie define Gia= (Vas, , S) as follows: DB Aliproductom fr Pare added to PB iF are fr the required Form, AM, the variables fre Vai ae cold to Vy. Q aa w Conrider A AiAy~~ fr, Where 33. lo Sitroduce Rew Productfans A> AiGs Cr Rg ty. ~ ++ Greg > Amy A dure nero varfable sc), C.. Cornas These are added b> Pp” and Va» respectively. = Tru, we get GO, de Chomsty normal form. S Before proving: that Gry isthe requtred on eel We constructor to the Contesct- eee genic five On Sreonple « “el reenannanaras Quits: Find the Gremmar fm Chomsky Normal Form equs a G fs S— cABD A— 48 A — bAB eb pod t= There ts ho Ax production and Unit ~productin Stepes- Ebinination of termiral on RHes S—> 0nd SC AD) Cu Pe OB A C38 . Coe A> bars A> CahB, Cab Bob pod Gls {SAB Cuca 0}, (o.b.d), Pl,s} Pe S$ AD S>OP , PaAD A> GB A> GRR, YORB AS GY Bob poe G"= (S.A, 8.0.9), (bid) sesh S—— aAbB A— aA/a B— b8/b Sainz SO There fs no r- production ard unit ~ produetion ~~ SD ELiminabior of Jermiral om RHS S— aAbB SP CLAGQB 5 GA, Cy>b A> 0A AS GA , Ge Ate, BR- bB B35C.B , Cy5b Bb Gis} (8,818, C1.C8) (ab), Pash S—3 CAC Ca AGe , 63% 5.5 7, [OSPR » oqat A>GA A x & 8B CaB/b 2 [CS AB creas sy LC Arb), Pst Ca, Ce, Qua:- Find wo Grammar fr CNE go ~s/tsa)s}/p/4 (S berg. tition Variable) , LECLELTP PRAT AR Va aaaaeaeace. pl: Sous SeeTS2ST 5 C90 5 O27, a>) Cg J SOO SCaCa8 04 fb} 4 ore {S38 Cai) Cpr ty" 9 Gre (Sina esr, Ce Coren Ces), (Pit), ish 2 SNe 9S pans > Oa” > S>4qs : S>[s2)s] [rfr Cy=T , G20, C4 =) , Os] 8> CaS Cg CagSCg t Gr] (Sita tase4sCs), (O21 Tevet) pl s} eeeeee. Ps SoCs 8 Ca8lsCySOs Os Sa 04805 , 01-6404 55 SCoCe - C3 OC, S> b/4 a: Cy Ca SCs, es3tyes ae S— ASA /bA A> B/S S BOL S6"- Steb4: Unit production A? BLAS wWo(A) =fas Vg (A= WU e w, (A) = Wo v fA} Wy = W) = wou 18,S) = 1A, 8.S¢ Steba Elimination of ferminal on ReHos § — ASA /bA Bina hely , CeoSA Boe Ax € AS ASA|bA G(s, A,B.B) (b,c), Pst PRR PAPPAD DRADER &B RRR AARa Rnd. € & Mn SEI | PATE 2 S$ ASA SIAC 149SA S3bA » Gb SICA B23 Cc A?mC AO ASA ADAG + C-PSA psbA A> Cah 1 Catb Giz { (8.0.8, Ces) (0), ms) Gireibach Normal Form (ane) Conbertick a grennar dn GNF forme equlvalentte He gpemmrer: S— AA /a A> SS /b _Skeptt= Euintrate mull production and unit procluction (here £8 se neither nuk productownor untt production) SI 12g — Cheek gee Parmer fs tn NF or nat AL owner fs tn ONE firm. Siepa- Replace alt nonterminal or variable with nao none terminal SA, thee) A> As (let) Ay Agha] a As AL Arb Note Gne Production :- A an A= v¥ yt AO (&NFP form) A> GAB (GNF firm) Steps Ais RaAy Aye fe ALA As—b Aya (CGNne) As—b (Gne) Pi A2An (Not in GNA) As > A,A, (Not in GNF) Noter- Chetek production by gbven rule Rule me—> PsP ( Fat A, — AsAg ty) ie [aoa Ee ow con) Ay > AA Ch!) pate (4>2) Ay = AyAY Ra= APA [any (228) As ASA, AL (Notin GE) (Grvert) 7 Ay => any (Gre) LRARRARAPRARRR RRR AR AMAA ananaaanaananne.e ' { § HARE 072222999900) if St Checked that @loft recusnton 's present or not tr ghee Production Left recitation condition A> A%,/ Aa / RIP A procuctiow ABB = A B,2/ Pz] Z.~ production ZL 4, [a |--— L2 OZ /OsZ/ en Pa fiche [Ay /b (vate proat® of Ax) A a ae Pp, a ‘ . A, precluetinn AP On b CGNR) AS OAZ/ bz Ans 2~production see Sil Malo GNF. forny Zr Aah (su = Aa Ay) Al3'% [Ag hy KJ 2p — aie Zo Aghz Ag ah; |b < Rar oh Z/bz— Z— AgAr/Ag AZ J Z— Aafi | Ay Az Z— Ag Ay CNot th Give) Z— OALAL/ bAL[aAzAy /bZA, GNF) ZA PAALZ (Not tw Ge) ZL OAL /bAZ/On,Z%/ b2AIZ (&NE) A Aaa (Not InGne AP OAT AD /bAL] aA)ZAr | bzAD (ONE) G=] tit Z),(a.b), Pry rad etyrs SA) Ue Ply Ay a /aPipy | bAd [OA ZA] bz Ay Aa aa) | b/ aa)z] oz Z> AA) Ai] BAL OA)ZAY/bZA)/ AAPA) bA/Z) ON 22] bZAyZ Aa JisJd e i Wid of oa ft ti PACA PReERe \ ae | Ck a € 2 J t+ Faumping Lemma for Context free language Rampirg komma for CFL gies @ method of an stl ae Me pi ed Sure ino Confoset free Cera). Tb ts to “prove that certain tanga aco CEL. The construction be make wie et Brorouing tiv Pumbhy femme (ietds Seine dectidon abporithm regard Che. d Motion rpeetivg Gr het LOG). be eflargeoge, of hen 46 can Hird o nature nov (mn) suck chet Slewp-t Oiery ZE L(G) wlth IZ] >n Can be weiter as assis for Some i ME@s [vre) > [wor] £ Jor) t le;g it UF ios €k for K=i aaaabbbbcree Ek for RHR Oo aobbanbbbbbcece ¢ thea Hence, Lt fs not CAL Show tat f= for, Pus a prime noo} ws rota CEL. “ befaa, Daa, aarans acasoaa-——. a be Lis a CER, het be He natural nos (m) obtain “ wing He pamper Lerma ho= tt a a a saa ew Steps. Choose Lz WUWOAWRODAO Os dt (Z}>ne Ws Ag ne ee Yl du a eae , tl 7 ’ wr AAK > Corerir Wandoe contarn UH roe of ol b df 6 y Jwrl > L Juwse| tol >t ( fe © cupiss- Find the cubteble value of > 5S Uvkwoeky EL for Ket OR OOKAAAARA E] for K=2 AO DARACCOCRR ORE yf (breoz 45 is net privesa) YUU REECE besa se secerroes ee bbe ube b uuu l OUT Ke ED mosey payer} Hierorch Rev , ¥ E(suv)* ACY, oF, BE(BW) ye(euyt ay $3 xe ey 2p AB Abee sens tb Rofo A> be wo oN Yob Bob xO A x3 A QAbD— CubcDbeD| $ Chomsk: | {

You might also like