0% found this document useful (0 votes)
23 views29 pages

Toc - Module 3

The document discusses context-free grammars (CFG) and their properties, including ambiguity and derivation processes. It provides examples of generating strings using CFGs and explores the concepts of leftmost and rightmost derivations. Additionally, it touches on the construction of pushdown automata (PDA) for specific languages.

Uploaded by

charanhg1234
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)
23 views29 pages

Toc - Module 3

The document discusses context-free grammars (CFG) and their properties, including ambiguity and derivation processes. It provides examples of generating strings using CFGs and explores the concepts of leftmost and rightmost derivations. Additionally, it touches on the construction of pushdown automata (PDA) for specific languages.

Uploaded by

charanhg1234
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/ 29
Thay 4 Compatalyoa @ Module- 3 * Conte gree qvarnmas A qrommar é1 = Cv,T:SiP) » said tobe a ton free grotnrnar i all production pp hawt orn ‘ aa whut Ae and 2 CYUTY® A language Lu stm said to be contact free grorunar dj and ody thee vy condos free grammar and’ suththat. t= EC4): © Obtar a cf w geal any no Hf as 4 ae = aaaq-. 3 Sas SoG oe oe © Grensrate sbring Connintong Of abtuast one ‘a’ Zfay as §— as - a $38 : © Guwokt Oo String conmisteng Ony nb g a's and bs. s3.08 SobS aac 2 @ ceurat oO Shing conabng dun mo 4 ols s— oaS 2 S76 @ y (a } temnding attiat oy tno 9’ 4 a ds and bs whee tring Ungth & 0 musdiple gs As alb Sa € Suurade Ory no gs and b's with atuast one 'a’ S— bs bis aah SaA © A => aA| @BEbAl Goma 0 ching 4 as and Bs hawung tu Substving ab S—+ AObA A = of agA|baAle Gout a UG - L-f{wlngle) modr-0, whue we farb}”} S> Elbs $7 SoSaS L {an |e} s—7asb soe fo b™ [n70 , mon} eas pb aablé g> blbé a ® v6 gerunate gia Language ff at polindiorat ouu 7 fab) @ 2 Ss aSa S> psad or: asA] bsbl e, Sa] ble Oban C QECFA te guurate ©. Strings of. a andl b° ane ec is S—> aAdlvale S SAS al bal @ ottan’ a cee a sy to Gara a abving 4 a's and Bs stantang wtth ab. S— abA oe A = GaA[bAl€ 0. ree nae V si ( oktan a cha t guwar a sbing J a's and b's ending with ab S~ Aab A> aAlbale @ Obtain a CFH guurck a cheng pee fiat wefan) ae s— aSa|bsb 53 ol ble CFG , 2) @ obtan o gor language F140 ]E Cab sng tw)= he Cu} > 55 aBlba 7 po asl banla ga bslageld ¥ Deady abon Treen Aapenost CP Obey A say tmnast cnrel cuighitmmost —cludvabion ancl Regrdnuont drivabibn bres i" te ntring wabbbb PAH gramman anc aloo wave ath daivakion YABIX ADVAB ancl 6> 5b Ayémost curivabon Uy Wet teat fy Gl © ° 0 o = e egh: most dinivalion sa AG = Asb = Ab > abb = asbb 3a ABbh 5 0 Asb bb 35 aaeeer 4 aasbbbb © > aa bbbb @ Hain ty ytost ond aighimast clnivation ancl albo obtaxn olnivation ©) abc babb Ss aABb &~> bab Arc Bae Bab Lipmost derivation © Sy aA@b S> abAbBL S>abubBb saabcbagb $9 abe babb Righmast clarivahon S—7 a ABb Sy aAasb sa ahabb $4 abAbabb 5 abc babb ~ — V dytewest ond nyhmest clavvahon for the qparrnar rasle AS aapb} bal bb forty ating t) aabbba 2) baa bab LYbroct curivation So AS sS—maas S—> aa As S— aa bs s— aabbas $= aabb bas 5 aabbba Right most dui vahon ‘ § S—> AS Se ts lege 5 AAAS wate S=>AA ba oa S$ A bb ba ss aa.bbba 2» baabab Lipmost clunivation Sag meboss) — baas — boobs — baabas - = baabab Rightmost SAAS SPAMS S— ARAS S+ AA ob S— A abab $9 baabab ® ® “ow OL) chine ates alghimast ctuivation bth grammar S—s a8|ba \ ~ ; A> aS] bAA| ae , a Re peu eo ‘pring aaabba bbba “3 < oa ak ee Ltmost, duivaton 5. Rightnnst dwivation S> a8 ne ey : Skat Pox 3 a8 > aaabe aaa > aaabse 2 eed > AAAbbAB \ a > agabbag a Comat ~~ aaabbabs x ice aaabbabbsA yoo aabbabs - ~ aaa bbabbbar : er aaabbabbba, © ona eae oe aaes ~~ aaa8Be aaakse6 aaabbaBe aaabbaeB aaabbabs B aaabbOabbre aagbb abbbars aaabbabbba Pare tree : Es bre ES ce ES Exe E> Eve E> ie ‘ —— Bouin Lymust and rfapebwest chnivation Jor woe id tide ih . : Hrceoeinvatent Righedraost elvivation E> E+E ener E >idte ee b> creee Ens il tEXE i ‘ LAV e>erexid a iat idee. - e => eridxid — Eidt idx id, ¢ > idsideial: a A ‘ wbiguow Gwamumeu : CONC conte tel a grammar ancl chuck vif ait is ambiguow ov not! wr tel+rolarel Ac onc Eee E> Exe ee e- ©) a I~sid a7 Lytmast claivalvon, Coed C> 1+e E> ide E E> td+ Exe E> id+ I¥€ cm tht dF co jd sidx i Oo 2 @® @6 © @ sun to pomt bud ase chiyjererct qu te ame sodina id4id eid pure Gubee grammar is ambiguow. Rightrnost cluuvahon Cittde v ES EXE EPE+HEKE SES EH EXE Gree ES cnet Ext exeaeytd coerce id cageideid yey jyid eae E> €4 iu s x Ce cr 3 << ae Eo ide ide ta aye @% ~ Ts the fotlowerg qaramar ambiguoun? saslx XO ax] a pr dbing aaa Latmo st clans = sone a wath stat ena . 53 X25 Sans vpuy ma, See S$> aa Gas $3aax S> aaax: s7 aaa S>aoaa 57 08 AZ a > % “ L be ome) @ (2 \ 60 R © ne @ Snpee @ The giuin grammar in abi ambiguous @ Show that su grammar db ambigusv> for tu sking aa bb ab 53aB|bAY Arasl baal a B bs] aBa|b < 5 Liftmost duivation sa 08 gs 0.088 s> aabs% 5 aa.b0AG ga aabbae 59 aabbab Yerot hatin. gy iG S> Qs . Se SSE ae a ) Sa agdogb oy n 4 s> aabbQe , Sa aabbab — : S=> aabbab S ar Rorecannticd: Tw gun graamas dambgiouy © s 0) how that Hu S| “grammar i mbigiou 63 Aelaaé AX | A@ BO). jprahig aab x eas = = me : biee oe Q San BY Sa08 Q Saf hab S$? aab 3 aab we es ; a ge eow” > ©" conaeter g ane shoe Pammar “s—> sb9]e B ambigiow + for shring abababa = S shsla “6 S> sbsf < “ : S> sbsbs > sbs eet an Ss abs aces S~sabsbs . Seams Sm ababs See < Ss abobsbs ee S~abababs Ss ababoba ( OOa. S Soa @) oo ® @ Tht grormos iy aorbigiun @ B te gollowng grammar ambiguou s— 1cts| ict ses| in i oe fo. fr Shing ibtibtaca, > Svicts sides soribtictses gaibtibt ses g-ribb btacs gy ibeietac® So ictses S> ibtses Sr ibt (ekses S~ibbibtses S> ibtibtaes \ Ss iblibt aca eve y ‘Tu jaronas i, anbigaous Pu Down Automata © Contruct a eva to accept Hu fouloivuig language 4 ~ AN Lf ot WO [nyt @) A ES > Lefabb, aabbbb, oaabbbbbb-.J - $C 5,0,22)*C90, 020) S aa bbb 88( 40,0, 0)= (qo,aa) per Le 5040, b, a= C4¢, 08) DSP aa eI SCai,b. 0)? C426) ‘ S (aa 1b)9) = Cris) (ener i eee § (426420) °(4972) > Coa lac) : f “Gee, R fe, PADS akan nya) K ee £- fa,by tes 5+ fa0y fash So [ageing (wel) Gale) ) Gog k@ 5C4004%) > (40,0) sea Sag Hs §Cas,0,0)= (q,aa) 3 5Gqe, ba) > Cqs,ba) Wek 8(41,b, 0)= (ara) §(41,¢.4)= C426) 8(q2.612)* Can 9 os oy § (ab): (4.9) 8 Lae qi angsy Sab S: 40° ang | ® Grotud a PDA fort=forl? | zt} = = hd for, G01, coon Y Co, 20/020) Gna 10 ein 00) | Goole? e,201 70 y — (Fo } 8( 40,0128) = q (40, 0x8) 5( 40,010) * (40, 00) 8(405 110) (41,0 5C41) 1,0) Cvne) 8(42,6%) = CH, 9 @ fe Gi 9h a ord {40h he fond pei L POA Jor anpunge EE Mg Cw) Mle) bwe caw 4 @ tab, aabh, aoabbb= == wor? ae A aabb xi aot (G:a0]20) (bale) [a Cable) He § (qo, &,20) = C40 220) . Ue Crot 8Cqo,a,0) = C40) aa) & {aany S Layo, b ,26) = (qo, bad) Baby ; Bae RE CanED) SL H0y oe § (qo,a,b) = (40,€) bio 340) ba) = C9) oo § (a0, B62) = CW 4) @ w dah P tet a POA tor tu language L= Zwer® | we Cab)¥ wl idremere 4 SY grat state LL abcba, arabbcbbaa- way (bib |b») Gal “2 fee toe) G@ble ac) | 20) Ge" _§ _6 ©, al@) ® 6,20]20 (e201) abcba BS 8Cqo,0,20) Go, 120) Rego ti nCrob § (qo,b) 20) ~ (qo. b20) 5 (ay0,0 0) > (40199) § Lao» by b) = Cao, bb) 5a, 0, 8) = (aeab) Sao by 2} Get) 6 C4 #6,0)= (41 4) SC 40, 8 = Cn») § C401 C20) * Cay) § (41, a, b)* Car §(41b a)* (4) 5a 8) - (428) 8 {yor 4192) tLaokh 8-4 qol Adar, Tracy 1} computaon Morl quishen paper Module 3 © ortay ws annem guan fo gma Se gut PH tzprension (atb)* (q-b) E> Etele-€ Es €xE| cle E> (EJIL Ia alble 7 E> ert fe-tT Toyquxe [fel | e> colt | taalble Cae at => +f ex iGEas @* ce) E71 +69) C147) 4c) cere) Gm aceD os Cath) *C 2-1) (279 Carb) ¥Ca-T) cat) ¥C9 Gary CaF) Ca #) CE) ch ae|bele Give Leip anc Read ancl pase tree forthe ahing “ aaabob" “7 EMD ai 44 ed Sow a 8 SPAB STS be eS mag Ab& ia . Garg Aba® 3 , aQaaas Abab® - aaacs ‘ A Babe - anag \ “Abab aaabs ) 2 aA bab aaa baw aakbab ae ‘ aaa babs& aaadbar aaababe aadebab . aaababy een Powe tree Ee ; : ® @ Reaiyy © POA dor a Ger Neapting paluseome Lom). Lwew® LWweCarH)®Y whos wt © Hh ou SCY Ww ancl sow Tp yorthy abring “aah —— 5 Labbcba, aabbebbaa...3 (bib) bb) Cbya0l b2e) | chal) Galeen feet °c IS @) @ (a fa) @) C, Al ce) Cubl b) (CG0]28) abcba . ha : &C40,a, zo) = qo, 420) ‘ §( 90 ib) = (qo, bS) 8 (401a,0) = ( qo, aa) § (qe. b,b) = C4o bb) §( 90, b,z0) e (Co bze) § (40. 8,b) = Cae, ab) 5(go,c,m0)* 649) §(an cb) > Cav) $C 2%) + (029 (um, a)+ Ca, ba) $ (40% b) = C41, ab) an €,20) > Can. 202. 8 Gonotruct a Ces 7 tu younwuig Language: ) wae gor tu Jounwuig guag : ti In>=0, m>:04 *) Ltionoe 110 €C4,b)*} ND) US fis froe w) Led ami a ¥) dbtan a q ) 4 asondbs wih tqial no apa’s and be ramman to guunate a languages ching O's ancl is hauig a C0.1)" with attest one oceiiiner gro Subutving 000. aa 9) iD) Ses atten [osb S> adpge G- Cv, BS) Ve Usy T {ab} p> § Sasa] bsb, sre} Sn stant cymbol. i) Sa Z10lz ex ao oz zie Sp 0) ie cv?) E ve{sit} Te {ony p(s tilt, a ozjizle sa stant Symbol: W) aac 6 6,10.) vfs} Ted aby Ps 83 > EJasby 8 & stark symbol S— Aoook K— GJOA|IA &: (ut PS) ie ve{ SKY bn (ra Te oy P= { SrAoCOA, A> ELORTIAY 50 stontaymbol- | @ dyine with ecample: 0) Grammar 2) Wuuvation . . N 3) hiftmest ancl Ryghmest cluvation #) Amaiguous qromman 5) Panne tree: — FP) Grammar. oltre pbs mee and 8-7 are produttion in qari G, ue os ane sing ep minal andl cr nontomival. , & and & ane nontermina the nontiminal K proclucen th tring OLB @ by replay the Rehltereninall 6 in 0 BY by esa oprty leg. thu procluction Sep andl can be written a AY LBY 9 on Ayemost and Righmost cuuivation 0 shyt mast vauable & replacect Jiforost clerivation inane desvation pour at SAO Step, Hur the deaivaion uy said to be Uy most replaced ot auable J» Wht move: In tly deuvation peur 7a vightmast_ v bat most Cag akep than the devvation sav roid to "09 © Ambiguous grammar: Lt GLYTM) be a tondicl fee grammar, A grammar Sa conbiguovr Yard iy athe exist at Lost one string WET* Jor which Aw0 or more cbiyyuort paue tee waist by ether oppying ws dYimest or Tht mest derivation. © owe dee It G- CVTPS) be a CFG, The tree cduuvation bee with Hy qewra prepertien ) Tu rest hos labs 2) Guus votre hap a labdl whith din (VUTUE) 3) Gay ue)rade has a labeb pom onol an tnknor waka. apa label 4mm v WYO waar Laban Aare Ke KS Kr are daileon A spor ye A> X11 KSK3-- Xn must be production ih p. tun Ex: id+ideid sete Ere Enid t ° £6 corde: Go SEE [OE Oérorpk: S> ETE] EKE , ES ieh ger id LMD= idtid-+ id RMD: tring idsidyid “S47 RE S> QQ Ex€ go ETE = idt€ — EL Exe ~ idr€ (dt Exe — E+ Evtal ih GFE Ida tole € Ea iaviel jole Wl¥e id etole ied = tatidatel. iar a4 folowuig gramman os Oubigetous by trbuip tring: ab S aslasbs|e i. ' ; : © Show Wat the Vs GS agase \ tmp Sas 7 aaSbs aaebs > aabe — aab RQ Sx2 NaS TB SLE —rOE SBE PAwed nak RMD $— aSbs => asbé = aasb = aab dyene We é CEG : aa she goUaiaing, langaagen. aan a sek aut pene ou? fab} 2) Le fo, mt Inzoy OLA ustminen 43 CEG: wnkct-fre qranman worwitng Sea grammar vuly 5 a Awockruple -Cv,T,P.s) whune VO Mon fanunal sy mboo T ah 6 duminal P stkey poduttion » $U storbtymbol - S> asa S— psb S= ald) ¢, 6-@,T.0.5) ve 2S T Lavy Pf S$ aSa, GB s—> bsb, salle} Si» stoaksymbol 3) s— ost}! Bsa aSailbs be , s3eé 2(vr.eS a ye : @ Cv. TRS) i vets Toy ae : P€ > ost |i) ={a.b) Sd skanbsyrbol. Pd s—aSalbsb} SO stank symal © ign cee for founwing languany d% Rept te aot abl string whit no nue than aly whun TZ Ca.b) 7 Seagavas Ve eg ; ; 8 646 bel ¢ a= (vtes) Ve $5.84 T=fa,by RP S— Bababa® , gaaley Sub storkyymbo! 2) To acupt Hu ck oa ntrinng with any number a's anol bs with atleast oua 7 Sm-adbla Ax aa|bAIE G: (vers) ved sity T+Lavy p-{ SaaAla, oA—raaldales Six task symbol @| @ L ut @ bet granunan. | ' S$ aBlbA A> alas |bAr e— b} bs| 088 rh aking cabbabab-yie y Vuiiation thee Crasseted > Ldtmost duivation 8) Right most cbntotion 7 Lapmost: duvivation: Rigimost dunivation Seon S—> aB ao& BE aase aoed aaBbs aabbs aabb a8 aabbas aan a aa bbabs a aie qa bbabae ie einen aa beabab tie Duivoilion bree (pare bee)

You might also like