You are on page 1of 162
| Chaprec 4: | Finite Aurtomata Le Regular Ex preaston - > “Theory of : Compurtartion = Also anown as automata theory. ~is a Aevyitical ranch of computer science. ead | mathematica deal with the loqe of com purt erttoa with reapod a ts Simple _machinco refer to ca curtomnerla. ota enables the sdenHet to undersrarel , hous machine < compute the _ function 4 wlve +he problems, poblems mgt be very simple Vike caluulectiog 4! the driving ditance between 4 he citica and as cor weather prediction. |= This Aheory woo +o) develop | methods to “describe 4 and “analyse dynamic ‘behaviour ot discrete system. =TOC includes 3 certegories! | D Aurtemata th-cory an / tanguaqeo - a 4) lomputabi lity ahesry, - : LD Ginplerity theory 2 > Butemerta “Theory and len > study | of abstract mochines y “automata as well at “Computational pnblems * “That can be solved using them. = Here, cuddo merta Ts a self operating machine or control _|_ mechanism _deotgnect Ae automatically Follows a@ Aetermined | Sequence of operations cuch as bell ortileers in mechanteal clock . - = Here, “abstract machine | is a ¢ mode| sf computer construc “ted 4p allow 0 ad and precise analysts - of [how the Computer worn. = Aa atsstrack machine waa developed | by Alan Turtag io io o “omputer. ‘Scanned with CamSeanner |-Introduced “with the ai _anctions re ‘ \ Anite state \ SG Hy \ puah dawn Qudomectd t ] Turing machine = — Figs Cletsea st aus moda 3) Computability Theory. | -Deals with - the caaeo “Ake they "not possible. -for example! * Halting problem acne eae a Faring machine. « This onblem is £824 “AD oe _ eve ® by wing any _compurtarhonal model. ‘Scanned with CamSeanner I) “falls under concrete pmblema, | Some of the Feminologien used 10 Too ; : - Lt symbol T=ahe omalieat building Mock. of any tanguage. =may be alprabet for any digit. [ | for example! a,b, 014)----- tape C2) jratinite set of symbols. _> yeprsonted by re L-ter example | £=<0/44 is an alphabet st binary iy. T= tO4, a,--- 94 ic an alphabet of dect mal AL attgit . ! = darby £2 1A BCh 4 steing j-a Finite Sequene of Symbols “elected from some i alphabets. ngprenlly ceneted by Ses! and length of a string [steneted bby Iw. empty sing: \s the sting with cer occurance | vepeaantted aué. ‘Scanned with CamSeanner i — te _ _ for example > £= 40,63 ~ ee [lets Q that means qenereding of call ane strings Lkewirg length 2. | No. of stdage alels a= 4, Land dhey are = ab, 04, aa, bb. : | | + danguage ‘=O language oe cot of strings choosen from some | 2* or we can soy language is a subset of <* : ican be formed “oer “S' which can be finite or | tonite. o | For example? 22 ja\b3 : 7 | CA = toa, ab, ba, bby koa set of all sroings whee i length & & a -tintte language . = 4 € a, aa, ab, bbb. 2 a set of all strings _ehee length & made from any combi na-trens of a ! and b Incluctirg null stringy | is an tnfintie language. & powers: of alprabet : SS [Say 2=dtabk Tahen = sor alt strings ower 2 of Vength G, eI _| Sta set of all ett over = ot length 4, Stl 9 z =dai vy “e nena : | B%= set fall Steg over 2 of length a, 9% 24 ie = ab, ba, ta, bb} 2. set of al stein ever S of length & 9358 21 aba, bab, aaa, bbb, abb, bba,aab, baay GZ so on, or ‘Scanned with CamSeanner : alphabet ao; = =n 7 : — 2% 5 dwie tsa string of length m over Gy > 0 “| Kleen closuye'-_ a = Given an alprakel 2, its closure can be defined as the D ee = gdb - ‘Dn ee ‘Scanned with CamSeanner | eee = o q | 45 _ a. 4s | > 4 % | 4 | D - oe - » Dales) = Fig: A Aramitin table 2 Destan a Deh thot accepks the Janquae of all a> aS Tor, O84, 010, 0104044400, O10... cheng starting with “OL” ay S25 4S —2 5 qe = @o% i 3. Ending with “Ol” < be az Poi, 0 01, 04, 4001, OOO!, OLOLOLO4, OLII....0}.--] i 4 o ~ } mee o- = + ee 547 @e" é | | : ne | ald ‘Scanned with CamSeanner -| Gating with OL of ending with OL “lz 2 Of, o14t, d10!, O000!, Aids. th. -- _ e/a —— —— 89 ending with 04 == 4 : — Starting with 01 BND ending ith OF. [lz JOLol, 010001, 041410! O1OLOloL,..... 3 gS 9=3@Q i x rs = (te ‘Scanned with CamSeanner tea W! Mod 1 We (0,0) *} > comlaind no. of a exec S562 = and any combination 6 “hs. = re = - q[ as {w! nalw) 24, we (bY elt in Ng LW) $3) Wo € Ca, b)*4 Gas 40: a=, WE La, b)*} a= 4a, a Pa bab, abbb, bbbbabbb, --. - 4 & 4. As Yar na lw) PT, WE (a,b) 4 244, ab, ba,,abu, Aaals, baapabaa, abba: a4 _Qa ae . | “sa Reh ia Ke § de {ina WY) <3, wee Lak)*F az hab, ababiabb, aabbb, aaabbb.-.., 9- ‘Scanned with CamSeanner +4. | Reviews get theor _A = isa callectia af some _itema_Lelement)~ | We often use captial letlers te_denote_o ob. To | define a set we can simply lst all the elemowts > | fn curly _brackels. / ; - Example! - _ she set of natural number, N= 44,%9,---4 zs | the set of integers ; Ze deer aM Od) 8) oF chee | | Types of wet | Equality of sets _ | Two sets A and G@ are «aid to he equality if i they have the same elements. They are denoted — I by: A=. ? thus if B2B and BA, shen AB, _ Aloo if xeR > KEB and xB xeA, then A=, {| Eg! fre 20,2,i,0,uy | Betuxis a vowel? - - then 928. - | | Power set ; a a | The set or collection of all pPssible cubsete of any | set § is called power set of S. It is denoted by : PO) or 25. on I P Eq! Uf S=4424 then ik subset are UF, 403, fo Ro, the power set “of S ic “ 332 90/484, 8 S404 ‘Scanned with CamSeanner i mpty set oe a -A set having no element is called the emply Set null or void set. ated by the Creek letter (phi) ov 24. - Example + M= ini is a male student ina giths | com pus 4 is an empty sot. | Subset : -Q «ek A is said to be a subset of the sef Brf [every element of A is ciloo an element of G. [-Ahis relation fs denoted by ALG. = Her, 8 is alo known cla the superset of A and we write os BA. | Sqmbolically, ACB 1s defined a neh 3 Les. Fore element of set A is also an element of get @ but there ic at leoot one element of B [which ic nok an element of As then @ is known ae the | pwper subset of B. |-This velation ts cenvted by ACB | Gepcx isa leter in English alphabet } | Gejre is a vowel}s ces Then, Bea. : Operations on sets. | Union ' [The union of too sets Mand 6 is defined aa. the set of all elements which celong qo. A or @ of bth. 7 fn symbol, we denote j+ by AUB and reat ow ‘Scanned with CamSeanner Pees tee cau! AUBe M:% EA of © Ya | Cxample! dot id sun, earth i ee be ym on earth} - [ sun, ‘earthy uimosn, warty (=the intersechon of . ae 5 all elements — ‘belenging "to. bath seks Aland 6. Tis denoted by AMG. __7 Symbolically, | ANG= teu CA end LEB Example! ek A= {sun, aorthy B= dearth, moon} _ Then ANg= dearth. “Dye foxy _ dhe difference | cf 40 sek and @ e « h all elements of A but Dst _dbolongin to ~ i cst —We denote it a-a. “e “ I = Symbalically, An! BE = cry 1 GA asd xe gay = -Example! aT. op Aaet ir 4 sun, earth? , Bo J eacth | ——__, ae : fray Ao Bz 4sun, : — : ‘Scanned with CamSeanner | Complement LThe complement of a set A is ihe set of all element in +he universal seb UD that do net belong +04 . ~ ble cdenoje it by A and yond an "A bar! - Symbolicaally, -@ shes 2% EV and Ay = fxrt Gans - Example! det ve iru isa student of class one} Ra\x: x is o male student of class one} B= U-A@z Axx is a female student of clus onof, Carteovan products! |--24 A ana B are gets, then each element ot A can be Patred with each elamt of G,and the v@ults can be writen a2 ordered pairs. The set of all such ofdered pairs ds called cartestan product of AandB. [= 4p is denoted by Ax and. veod as “A: cay @”, | Example’, det fF reas Ws ee S. | FAB AS : | then e XB =U5 95 x 2645 = 4014), 19), G6) 15,9), (416) 1 (4, 9- Relations | |= A elation jc an aasociation petueetija! property of, various objects. [= Relations cin be represented by sek of ordered Pais | Carb) where a bears a relation to db. i> Sets of ordered pains are commonly wed ‘Scanned with CamSeanner Lon tahich, for exompla, calendar year ae Lpalved with aubmobila production figure ' | witth stock mor ket avaraged , erage tem peratures L and dayd ieith ! Se Graphs: a ~— l= Graphe are mathematkal Easy to consteuct NPA than: in. DFA -for a given” - regular language ew in NFA the ability quea | some thing about Ss outpuk is often ex preaed- La Gey NEA is not DFA but each NEA can be Ltransleted te DFA. LB Unlike DEA NER comtiina €-transitfons thot __Meano on reading empty symbol, ft xn tranamit _ fem one _tahich, patie Ahe value ts nota ing) it eran TE ssingle element & S Z| 8 fens emply finite sot ‘Scanned with CamSeanner | Examprens T@ An NFA — ‘all the with a : a © Ending ett Starting ith Ol” d= 401, O40, 0100, 011f001,. . mew arr to ee ete i Asstgoment I @ Differences between NEW pA _DFA. . = OFA NFA [por every Every DEA is an NFA but aot vice versa. adhere iS an equivalent DPA fu evey NEA. athe conversim of NFA do OPA con be done woing a technique called subset conatructoa. py “NEA x4 30 Gx (60 €4 3 2 . Here Q is a part f 98 bet & is ret part of Q. Some examples 4. d= 4 set fall ee over (0,4) thal starts with 04, Od —@—— © Figs fn NEA | Step lt: Draw a transition table der the given NPA Yz\)o|14 = A | Ba] 4. «x b{/e |B | Srepa! Draw a transition apie for an equivalent DFA. | Ys} o |e i I sa )e | >d | . Dela | eD iG B wie ‘Scanned with CamSeanner Step 8: Gnstud a DEA bvede on a ‘traroitig table fam step 2. ! { | | _| Fig. An equivalent DPA for tha given NFA, 8 Qos 2 —=@_— Fry: As NEA D| dadset H all strings over (0,1) that ence Sth TS EGiepuE/ 21 00a | >A] A [ines __ _ _4 6 bs o ar i Step 2? Yelto [a : +o |o [aa - ‘Scanned with CamSeanner > al}a {aa — Fig: fr equivalent OFA for the geen uf Ke =i find the equivalent DFA for m= C2A,8,64, Carn), $A, $4 J the NFA where, & is iven by a +e 8 a= 2A | AB 8 A ra = AB ] AS Seo | ale 3a | aa [ce Here, D 1d a dead state 96 | as _| Co” } *BC | A | @ |e. * Ci. D-| AB ek = L De = | a | Sep 3 ; {Set Ma oN : | e== eae yo -| | B ab : = — 2302 | tp: fine equivalent De _____—— 4 ‘Scanned with CamSeanner A Ain dnl DFA ‘Scanned with CamSeanner Deriqn an NEA for a language -that accepts all the strings ever (Ord) In phich the second lagt symbol & always 4. Then convert that NFA te fs equivalent DFA. De as 4 440, 0141, 0 04000L0,. aro ye fff ‘Scanned with CamSeanner | | | __| Conversion of E-NFA to NFR oT = Tho Finite automata is modified permit \transacttan vttheut an input symbol then we get Lon NPA with @-Arangitien. or 7 NFA. | Consider on NEA : : [eee ae ee Eee. Gee beer a ee ee Gy! An E-NGA where @ 2,4,, and F have some meaning as non] NFA Nao and { defines a makiplying from | @x CEVE) —3 98 estate tT ay ‘empl oF null ghing "= closure oo (3 8et of all etates of the automola whith can be Tveoched from 4 on a path labelled by @. | Por example: aaa 7 E= closure (qo)= 4 40) GG E— clasure Cq,)= 4,7 a} = enclosure C4a)= 44h ‘Scanned with CamScanner Sees eee ee gees raced 6-30-36. Convert . following E-NER to NFA ® Ce, ofthe Qu © e* 0 e* era et poA-ASDA A988 > 4o-—->¢4 QoS ab =39 P— D— 5D d—d)-— YD | -e* 0 ere Het BI Bom CO BOLO O> 4 Sb p>. So 033 i 1 eo et et 4 Ee [ C5t¢3>b5>4 C3¢C >a 3 | . Sr | ae oo & ex ie M3) P DAD Vo) AD —?) ‘Scanned with CamSeanner 4) Reguior expressions _ Anite automata: Machine like descr! peiea acl Regular expression i Migeboric deocripton 4 ot Be Regular expression ‘a some languages that automata Aescribes. be ade fire -exactly the Ms of the (3 A yeqular language regular ‘Scanned with CamSeanner “y qenotey closure Geeeaeaeseeeaneca athe set of vequlay expreasion can be defined by Ahe following euteo'3, Le Every letter of | Z con be made into a requir expreasiony null string € . Usel is a regular = preston, | 2 Tf od and 12 ave reqular expreactons then ® Cra) ii) dad v) yl* |G) vivo wet ; | owe all regular expreastons . ae (8. Nothing ele is alco a regular expressions. dt Regular | The lanquage ‘L' is Expreasidsn and nite Automata => det M=l@, 2,8, 4%: 7) be a Finite Automaton Set qular if there exists a machine ‘M! such that L= LOM). i >This -concludes dhat if any language a vegulor then definately Anere exists a Finite automaton the prceasea oF represents “Ahod lerquoge | Some Srampleo : eet ‘yr’ means vege “ex preaston = a 4. rsa d= jad ‘Scanned with CamSeanner ao OS _ ‘Loe lan : © _ . ye ax L> Aset of all string firmed drm he 7 combinortton of ats fnclud ing NOU string 4 r4 €; @, aa, aaaa--.a, ____ SG SS mS ‘Scanned with CamScanner [5 Wuite a seqular expression over alphabet Lo, i) containing second letter as ‘0’ 7 ee \ az 410,000, d010, 000440--..0,-----F y= Coad) 0 (Or4)* Ord | O43 O— © as oh | ou a il 6. kin'te a reqular expression over alphabet 0,4) whose fifth sym bol fom right end is J. Ww ian i a= 4410016, 10000, OoLolos, (4ssadT) LG, v= (otd)* 4 Cord) Cord) (044) (ort) F. fer atleast one pair of consecutive Gon be used ao find veguiar expres fe > Mnite mocka — ee = Slates thot if Pand @ ore tea | regular eepreosbna over 2 ond if P_doeatt corti, @ then the following equation inet el R= @+RP hao a unique wluton Le R= QP™ = Proof : | k= Gree @ pn the BHS ‘[Repladag @ with (rap), in eqn @ we get, | Bey ea ae R= Qt COr app = Qt gr+ap? ——B, | fins replacing R with (8+ @P) on tha AAI in oq? | R= A+ QP+ C+ ap)pe = Or BP + GP% ApS a we get | When we ao on : 4 veplachg the value Re Or Qrr gpr+ eae —— ot R a FUrhULULr CC : =8 Let 04 phy 984 prs) ——— | > Gee —— —} = 4h, med a ‘Scanned with CamScanner Use Of Arden's theorem to find of a DFA. Aasumption for applying Arden thesrem!y ] {. The trangitton Stagram muak nor have NULL transition. a. Th must hove only ono initial state. yequlac 2S ee | Steet: Create equations for all the lates of the BFA i having (n! state with initial ate as qt: | 44 = Gut quart ---- Fann +e O- | 48s 4 + yor ---- + qnwnae =——— ©. {| GN= 4, Fin gWant ---. + Qnenn — = —_- © Here, wy vepresent the yet: ‘of labels of edges fom arate gq: to q; , if no such edge exists Athen wy = Ob Step a! Solve the e_t to 4 dhe equatim fer the | Final sete nterw sf wy ‘Scanned with CamSeanner =e | Sree i = Wat ar e—Gq - a qi ee ab — @. os 4 ig = 424 —— @ = [an eqn © BE hbrgbegb ——_} = yb +9, 6+ 4a ab [Gee 7 a “b+ agb Palab 1s? Ga = eS “94,6 + 9, lo+4b) ‘ a Ht b (b+ab) Tete 7g Taio | Bowing = et Re ART ) —— 2" © =O reece 1 9) = 9,4 + V+ qaa + eee 4 40+ yaa ee eS } ag, = eq at 9,0 Co+ab) Faq + A Gis Gy (arb lor aa) a ——————— a ‘ = im oe ——— — ee = ‘Scanned with CamSeanner Az (a+b (bta5)¥aa)* ~T Rpelying eens Toe] | Hence regular expression of qhen Fioite aultomeds i | = € Cat bCbtab)*Ua)* lL = Catb Ub +a) *aq)* Fz bt 9 Ge Wb44 A da onde bi a : z | Palling She value of @LO mG. 9g = 9,6 +4, a {ler gz = C4o9 + 4 bor (40b+ 4, 4)4 [043 = Jo (abt ba) + 4; (ob+aa) | or qs. = Jo (ab+ ba) (bb taa)* | Now — substituting qqy fo 249 ©. ! at agbla + (ab+qa)bie al glaatbb)+ 4sCba nb) +e ~ = 4 C00 4bb) 4 95 (ab tba) obraa)* & 6A 4 a0) 4 rt ‘Scanned with CamSeanner & = 4g(aa bv )x (ab}ba) (bb raa)® (barat) f+ é -o=_€ {Ca arb) +Cabrba) Cobraa) *( bata} | = — | Chapter 2' Properties of vaqular sets 7 2 ‘| Clesure “prpertie of Regular sets. | Theorem 43 = | Statement | The cfarnily of vequar sets ef iis closed under union, concatenation and kleeneclasure~ Proof : @ Union: . __| Metement: TF UA are how reqular lou 104 then the union of that languages ie, LLULL oe LLito : 11S Ahoo rogue. | Proof! der UW & UW ae two reqular ta a] nguagéo: hen Ahory ____ | reapective reqular expressions be Ts rf te, Us Lard) & La Lira) definitions on kla know that = : i rd aD is aloo ular then, —— “| Ue es Liv) s Lots Cad ae - ] _[y wo contract a PR for core te ee erica a Tat. S - Then, Ls fa} ane Leite Tab} ‘Scanned with CamSeanner Tega tia: Now, ve heed 2 Jaye jar) > darby I d _ ‘ dD : [ ok 4 | O. a5 oO ; eC hohe - s hg: & foe L i 4 9 Since there exist a FACDH ona) for the language hich is generated atter the union operations on regular language - the -frnily of regular sets is called Under union 8 proved. ~ Conca tenation : 3 Statement: Sf Wand LL are hoo cepalar Languages then, .| Uda as also raqulan. as 4 Orovfs a a . ; tet 1 Zed be the “use lar eepreasion fir generedng reqular languages UL & 12 respectively. 4 re, Utis tl and Ura)= ‘Scanned with CamScanner By definition! rd-e9-es algo reqular then U.tas Lend). cere) SULrd-72) Bao regular for sure. for example det risa and tl2b rhytsab 0-500 Rigi A FA dor Ul. By: A Pa fe be Then’, 0 === G6 Cyt FO fe Ce lord Conca tenation! Kleene claure of star claure Proof | regular 2 Preacion fe, lord | Fam definttions * Ts veqular then | Uts Urry is abo regular fee sure ‘Scanned with CamSeanner i | Statement! IF L & a reqular language then so dew & IL let Lbe a regular Nanguage which B represented ey _— — 3 = “for example S ile rz0 then rt 20% 7 | Bus 403 & ttv4) = 4 Eo, 00,000,---.}, 026 6" = | c ‘hg: fe PA for ic Arq? FA for U {| = . . i | Theorem a : The family of regular seb te claed under complementahin, I oR, . ‘ Lif Lis reqular then the complement of L ie, LT ctboo vegular., a = Proof! let we wnsider a DPA M2 (Q@ 2,5) % 7) that recognica the language L then the complement - of L fe, | ae T= et-L and this language Tis aloo accepted by a | dra A. aes | oHee M Bi accept all the Sage ent are. jet F i by | M and yice-venta + a | 6 fn Ahis situate, we can construct a co. | We CG, 2,8, 401 B-F) LOThis will reese the situation that means “ol fral_| sites will become non--final states ae non- final sate _ vont beceme = Fina) one. | : : ji ‘Scanned with CamSeanner a sy for examp ei Anen LU)= 20, 00, O04, OL44,--* : a ya = - ss ater E — —~ ee {| ef _ i Ags FR for L 7 : I i: ao | Hence , the family of regula seb also claed zee Launder complementrtion. = ; | Thestem 3! gi |The amily of reqular sets is desed Under, imbenectis -] Pread) : = | ter UL and Ld ave. thes veqular lang uagea generated. by pyd and v2 vespectivay. . te Us ls) and a Loy -_ | By Demo anis lacs, - = f (LAU2 UU 4° : = Faking CHS, Sa | _U is regulay (Theerem 9J : ae | Wis a reqular CTheerem 19 ae [U4 cite vegula Ctheovem 1], a ya) B alge veguiar (Theorem a - ea ‘Scanned with CamSeanner [Next example c= ak é i = ls 0-0 —=O--O) FA for v5 fA for £2: FA for rl Arh. ‘Scanned with CamSeanner “Theorem 4 ‘the fer of re reqular se aiff erence if U AW ae 4S rage language then Ss aoe (Li-v2), Prof ! det U and 19 ara yegular language? generated thrugh regular exprassions rl and oD reopective|y, kle hove} [ U-te> uae - — Proof > oo * REST = | Raking RHS.- tu i a regular by definches, | ; . i 2 isa reguist fa a. _ - jt Att is regular [Theorem 8}. I Hence, y ta is alo regulay « proved. = oo ty” as Fab ed a € 5 Ls ib cay ae ee oe ‘Scanned with CamSeanner a ar ee = Thesrem § e reversal of 4 regular Language & also regular. - 3 the reversal of a language L, written as L* ic the language _consiticg of the reversal of Hi crmge ~ That means rf string lwo) of 4he any language b= atada3---.an then reversal of that string ‘(a= ANG pag ---- 99 WA ‘Scanned with CamSeanner — 4 : fig: BRA M. Then woe Should conytruct aasther FA M such thal [the string iz recognized: from final site toa” \ initial sate of M. be In reverse. order : fu 2 css ae a Figs 6 fa Mt |? Ts 0 vot ec easay That that he 3 one. Tr ean ba non det PRT be non- se herminthe- alog. 2) 5 = sauence wiaeang Shana nu feces ‘Scanned with CamScanner ri&= ba Ulrd)2 4b a} Aton on stings: that aorlea by — sulle tH tuting sting for each symbol: ee xam ple + Ff we atad---- | hus) = bias) nar)... h lon). That means’, , if uc et | Then, nis {hae e* lues . S' is called hemo morphism. an be 4 string | nm & then ‘Scanned with CamSeanner | ie —(Q _| ig: A FA dor uw) _ Heve, a Wa —7 ab : ae Wl) = 1, Ob, dvab , ababab, ----- 4 Figs 4 FA for WL) = Since, the extst a finite automorta for the larqu cE. “Ren from +he homemerphre function e— aver longuoge- the resultant is aloo [Soma paiemss = GG S2{O4} and 2!z 30,403 : - : Aigo, hto)= ot Sa = Kw chid)> Ld am = “Fina bCoto) ond hi) Glen bf. be foo, 01} aan = “ Z | hC1o) 72 7 = ia = Thais) — fn 7 “s ‘Scanned with CamSeanner EY oLAsgod OL, OLLLdoL 3 dy a and als AL, S$ cease neo)= gine - # Trverse | hho mayne ¢ p hism! eee oo (> let hiS—s s' & 4 homomorphism and hl é2'* inverse hamemarphisin of +t thot language L ie. etPAE can be i Spee : ullacttan of all a shel in) The desure “poperty of regular mee aloo holds fue fw 2 homamorp him. ‘Scanned with CamSeanner umping lemma for alae wet ak lon is said to be ular Ff cn onl : age 5S ae fan oo nite “srate machines reco gnicea Oe | me F 5 & ular 2 lan eo are not | = which” "require. memory « FO ree Gare or count the str ~ For example! A> Boe or ie at ne 4 et. || Even . ide hen we donat know whether ib is + Witts not . __ | Fer “example: L=tab} 1 then - {666 — Faqs PSM for a | Buk fe b= fab absab,- --- ‘Scanned with CamSeanner ememand of ESM is “very limited _ ae = ahich are not “Yecognicedt by any finvte state reaching. = language is finite then it & requ lac fer we finite | langu eg, requiat out ya language : Sif there & no pattern in an infinite age then the construction of EA is almost impasitle moa techntque which & wed to age is Not R. ular. " r actually oa negativéty test becaura Uf any | __| lenguage decease paar th’ test, the language & not Lrveaular fo sure_but if the tonguage pastes the tak, guarantee the longuage 2 regular. EB Up Lis a regular language _ ard n be the con such Ho for “avery sting wo ia L guch hal - WwlzNn, LG can be divided into 3-pars fe, we XYZ oad Econ an — © V#@ WY is never null) ; |@ il on : y " 4 _ @ Por all izo, the sting XYz fs abo in po 7 [a ler W bea regular language) recegniced ty « MT i D=4Q. 5,4, 418) having” n numbers of total states. filso, let Ww be a string such that WEL and uz alata wecagrieed fey 401% %93J- = \ \ 4 ‘Scanned with CamSeanner | Gee a a naa When (myn) then in hat in Fa at Ah gi infinite . [pHere, Phe language migitt cartaln | String. that ed on & WP: oe Mg. a “there won't be ‘According do pigesn tele panei ple, | sont Tditind state for all the symbels ina string | there & enly tn’. number Ca Fes. —— we construct tuo different States” 3 Tn the case, bi & F uch thd OL te (690 and 6; 2 & Ss : Salen wa break we X¥Z as -follows) = ae alate. — N= it Gipa Qing --- + & — = 1 ZF Oj Osa eg --~--- App bHewe, X dakeo us to 0; once, 2V qakes uw fom py back too Tea 2 Bret) = “gee & balntes of 9. Cue cae ae F= Oo Hera, X con be empty i Mm aee Vike 729 and z car be empty In a case Vee fe Buea” hea i. ‘befdeen, empty since {Ih ‘Scanned with CamSeanner Pumping Lemma, | Here Ls Zab, aabb,aaabbb, ......3 a ! 2 We shall solve THB problem by contradiction, let w __assume the given languge Lf veqular. 7 | Naw, aking “23, w= acabbb = XYZ. > lwisé. | Case £: sa] |The substcing Y comfaing only ats port i, | where X= é {| Ye aaa, (yl70 | | Z=abbb , ixyl=s £6 : - —_ frail isa, xyes Cana)’ bbb iz Ojta---.. i242) xV'z= (aaa)*pbb =aadaaabbb — | | Sabb? abkh ge 7 | Case a = eS - : ____ The substring ¥ cumainr only bs park 2) kbs aaabbb - i 7 7 = Qaq Cobb)i a ‘Scanned with CamSeanner | For all 4, Sz: peor || “= aal@b)' bb I Put tad xY2z 20a (ab) 6b = aaababbb Ae { i Gonclaoioa, - : ; - | “Gn all three case we cfeund. that. xG'x foi lal) value of ‘Ite fe 04,9-~--» Ae not exit io ~ __ the given language L. Thot means the substrhg ¥ | Cannet be pumped voing Tha technique. Hence, there 1% certracichon in our assumphra go, the | p= sen La{ ato] n 244 is nok regular. = {abb, aabtba, aaa bobbi, =. We shall sole the problem by can traci let wo | Qasume aed geen bn 2 li regular. | bbebise =xY2 3 [ui=9. a 7 ‘Scanned with CamSeanner | Gee Ti Me sbsttiag Y coiain: we aaabbbbsb . | where x26 a ae oo Y= aaa Wyls8 — I £= bbbbbe byl23 29. = as | \ | Por all 3, xvz = (aadlbnpebb iz, xy22 = Caaapobbey I 2 aaaaaabbbbee == - | = abbe — orkbh | Care 3! K=Q0aQ | Y= bbbb : i jaa : | Gr all value of +, x¥2 = aaalbbbb)' fs 01,%3,-.. (Saris & , x¥%2 = aaa lbpbby2 . = aaa bbbbbobb “2b G abn. 1 : = oe 7 X | ‘sab ebbb. i i] X¥*zZ = Qa Cab) * bbb a : 7 oo oe ‘Scanned with CamScanner | Assignment Q. — an [nz fs net tequlay. - Here ls 2 abb, qabbbb, ~ naa bbvbvo,---- 4 TWe shall galve the prblem oy cantradivtion. Let wy assume the — tonquage Lis regular: | Taleing N23, We aaabbbbbb = XYZ =) Jol= —— |The substring Y conteing only cs part Ve, d= aaabybeil | where X= €& [ Yeaaq W170 zebobbbb |xvi=B 49. , x¥iz = Caaa)ibbbbbb — f204,2-- --- —x¥3z_= Caaa)* bbbbbb = aanoa cabo bub ¢ an pen ‘Scanned with CamSeanner (ase 8! The Y euntatnt both a's R's part 1 LY G2 aaabh -_ _ Xveze aa 4bbpavbe t bbb Fike in all ‘three ease we found that X¥iZ “for all valu-ae 42 120,4,4,---. does wot exist tM the given lan - That means the Substring canner be pumped voig dhic eonece Hence, this & contradiction in our assumption <6, the given language i al Inzs aot vegulay. Dye EE aw & ig not “regular, det Bs abb | | 7 aboaba | lic abbpoa =xVZ 3 tale a | “we ashe gslve, the . poblem ~ contradic : ‘i assume the iven eset Lis regular, Te ing - aso . Cue Ts : 8 a ~-——J. lt ‘Scanned with CamScanner [Case I! X= 9 a Y= bevba Soe 2ce€é 7 : for all t, xylz= Galbobba)!) i201 2S---- a for ts &, x¥4z = a Cbbbba)* Zabbbbabboog EL. sede a Cone/Tll’ Xx ab Ae Bb - z7v ba 2 Por al we GQ Wd)' 04 , 4 01,93, - Dut/t= d x22 aaleb)* ba | Csnclugiow, a | Since thesetusa cavea does nat exdt en the in : gen language fer all values «fF Tein kY'Z. The : given language B rat regular. z ‘Scanned with CamSeanner sy lzo/n ts prime number is nat regular, | 4 00, 000, 00000, 0000000, go000000000, . -. « a We sha)! Solve As pa Hem by ton tradichon . Lef wo atmo gin! lan. juoge L is regular. >mid. follows Jzl>d. lyt>o fine lelpd, Ing d pixel = (te yl) yxe! each greater than — Ginew Ser and |x) a the: product muot be campusite number. — algorithm “fos the paver exit. 90 algoritha. -for that problem exists, ‘Scanned with CamSeanner al Vecision proparty’ 5A decision property a clas of lan eee is calgenthre thet takes 4 ‘wel description of a lengua, C&! DEA) and tells whether or not some property holds . . a Examples il Testing emptines of a Raqular Language + > ler ug represent a regular langueg2- by any fate "cuts mode then the emptiness queatton & whether [there Bony path From start te some accep hy chte, TF so Ahen the qyven” language % -non- empty. > Rut if Phe actdpting ciate ie, final stata we all separated from the start state then. the 1 { language B said te be empty. for example! | {== O4xX SS This B non ry ‘Scanned with CamSeanner ‘OT Tosting membership in a regular language . [> This test can be cone by testing emptinea of 7 _ regular language i : : : i - 3 Sdecting Ahe sting throm Ane language bl, that need — te be tered whether if -falls under Abed language et not. a Then actiog fom is Hs Initial to tho services of stalea ing “input symbst Z “checking whether it reaches to finite state ay wot. lf the siting finally veaches +o -fival’ state) then it tthe mem ber of “Net Wrest alge rot. — Cet [ - 7 —— Sint ee y . ~ west X wa blake ivalance problem or whether | “deoe regular. sors. “eva 2 So, tu bcegular “seb are. identiaal of thor intersectian | (% eme and the 7} le the intersect oem ‘Scanned with CamSeanner | tM 302) aqua) 0 SCM) = od Pe aes ae : u L - h “i ae ape a _ || Shows only accepted ___ ghows only _ accephed aap eeeeeea ae >This “means that the equivalence problem fr a0 | S(4B and ctu) ws exactly the same co the emptiness pwblem for | SUMt) Vs US) | u/c) asi = | > Stace, there j& oO solution fer emptinea of ra gular language. 7 the problem equivalence of regular ____ languages is solvable for sure - 4 heather '@ regular _ sc & flaite is galvabie, | saa finiteness pabiem. 2 Tf a FA accep: any string thea length of had Sas ass Tega een ey aac aad We gular language , the. podem 5 there ext 9 Fit thal vecaqnieen TNen we seek cee 1 ‘Scanned with CamSeanner =F 9 . 1» We ™ perform pus exit ta ping lemma tert, and tf ther ext 4 FA fr Abert partiuilac languages. Then the ee of finiteness of requlew language. B solvable sure. _ - ‘Scanned with CamScanner Chapter 3 Context Free Gvammars “> Grammar : A set of yuleo to define td Senter. | in _any languages. on | | > Grammar ® of quse types: : a | | @ Grtext sensitive grammar Ram is a bey. de play oe tennis. : : — ee | Cont ext Free grammars Ram fs a boy. Ram plas Femi (2A contect Free Grammar (CFG) generates contad | Pree languages. 4 |= These lang: es have gveat prachcal stgnifreance in defining programming language and in ssi plifying = the translation fee _prgramming languages. — = | ie : | Context free Grammar CCFG)!s | CFG can be defined ao i G2 (va, Ve, Pt) [where Vn = @ finite set of non-terminals, generally _|| vepresentes by capital letters &, 8,60, --. c A finite sot of terminals, generally represented _ I letters a, ', td, -—~... ; starting nen-teyminal — : "| & Pe Spibductiva cules. in CPG AP represents ene Oa UNe) Ae [ = Evey regular language Ra context free langue ithat means “the -family of regular ne ta 2 "| proper subset sf context free language ‘Scanned with CamScanner v Non- Ambintouy ] _&G ce Jeterministe. Nom Non- Cra starting fon- terminal a2 : = Z ie (ven an bef Fahy ‘Scanned with CamSeanner _gsv9 a Saab > ab La ea: S—=3aAb : 2 aaAvb [°. As aAb]y => aabb Teta S 64 $= aAb > aa hey Tr Q> aby = aaAbbh 07 A a4bI | 3 aaabob Tr ase a a>dab, Qabb, aaabbb, canted as {ab Jn>1} : r ithe | ce jugut jae Carb } qe We language 2. fottesing 45 Construct a CEG | | presence_of thie _alprabet maken cel i a ea oo det (6G be G=}¥a,Ve, PS} — Sse oes - : ‘Scanned with CamScanner EE & ~ | b= 4S a8Sa : : | 82 aa — a | paasaq [~S3aS 7 / > aacaag ESacJ 7 + : — = | §-3 bsb ~ { —s baSab Tre Ba asa Li - | baasaay [1 Sa asay : t 3 baacaab re S$3eJ 3 kisite a CEG pe the regular expression | rz 0*4 (oti)* det CG be G= funjVe, O84 | where, Vn = 4 St ves} oad = =] ghorting nee Fev b=43 > ho Gopat == | ApAE _ : 3 - . — _ | S7/,40 - ee | ope C93 044s oa L0 ceaszes ‘Scanned with CamSeanner 3 0004s pref? &. : | 2080 S18 | i> OA/E “| B-> 06/e8 42 /€ —. I | 83 A418 : [Ss oaris A208, 62187, 2001l0a [B08 I[AVET a eettes— ania | fg rtCrsrs | 00140108 [--@50879 | Ss oettoto Po ase] | i —_ @ sive a CPG which Generated string having equal number f as and bs. __ set OG be 4 Vn Ve, PSF Where, ‘Scanned with CamSeanner S—-aSb == ae ae Sbhb ie . $3 asbj > aq bSaby Cz Sa bay i 7 aababbh ot Se] 024 Ss asbs. - S-s bSaS =n : | = Ss aSbs H > aaSbSbs [oS ages, i =o aoe) [S93 eg, 1 > aabaSbsby [85 ashi. eaaa ea 02 T8363. ‘Scanned with CamScanner T Bacus Naue fom (One). _ > Netedtton cheehnique_ efor context frea grammer, _olten wed ty desatba the Sot of language o7 | “computing _cuch” 2 programming languages, documents — ene dastruction _set ond communicahon _ protocels~ 83 ba/ab- 7 > bAR laSla “82 468 /bS/a_ i | Sentemtial _ form a [> any string derivable | fom gente nfal pia a . “39 sentence _is a _sentenha al form hat hao anly terminal “sym is 2 3 a Por example, if G Cas Ve, PS) : Here Sa aba ma sentental form oS al but S Saab | fe ‘a3 e€J is a sentence. : . Hence, | a frm oS an long do OnU Ve) such that $3~< bat ei €%e 7 guch _ that sa W then it eo a sentence. ‘Scanned with CamSeanner Productin ules i weil rin lo —3in in in each step, the: eight pen- pen- ter enteral We rnost non— terminal in s¢ otal fame ‘ ~yeplaced_ 3 4. Derivation tree ! z wan sidered rooted tree, thet graphically: rep reve! the __ semantic infornation of @ string derived Qa Aven grammar, 3 alse known oo Vorsetrea or syntox free oF genera “ten tree: “othe tree is aloo called ad Pose trea Since it is wed for pacing . Here, parsing & the proven of daletr a particular Sequence of terminal and & woh er ws veto nicable to the he language “dofined - by the “grammar. (> Represe natin jechnique * Kot Nox start — symbol. . Intermediate n or verhicea - cay > labelled Wh combination sf beth cterminala and + “non—termin comartimes only nen—termina) ssyenbol 2] ‘Scanned with CamScanner ] —) | =) | + deaf nodeo or vertices -» Labelled hy only ferrin ethe number of branches is defined by prod uch "ules. Examples : “© Given, = oot — Dib] bT | Le _Is+ aoe ae for the string. Ca +b 0 #0) Find iP MD n> RMD {iP Parsetrea- 1) UND. | S31 Satan = atl tsa) - 3 atbte Ce Lote) : = aba Claes > OLbee Ee Is ang a arbec CyIa Piay ‘Scanned with CamSeanner ii) Pavsetree BMD S —— wotnode RMD >> ~S4&— vot node AA x x — Cat vac) = © Given’, oe oo ——___ S— b8 / a6 oo Arb) bs fang a Gs ajas ) boa. i... fer the slag bbaababa) 99 a @ imp @&mp - © Paaetree, : 51 S— be — 7 3 bbe6 Co a baa, 7 —_ > bbase C8037 a — bba0aA B [> saay 7 - 3 bb49b3e CR y57 =. 7 bpaaba@A® C~.")raa7 ‘Scanned with CamSeanner (> bvraabab® [-.' a 9b) | > be aa baba U- Bey ad. —D) RHD SS bB > bbBo Of. Ba vBBI. => be$a [e345 => bb aa U-. B-3asJ — -5 pbaaha SaaAny Bp beaabaha | > boaababa Api ae DUD S08 ‘Scanned with CamSeanner _ Ambigutty In Grameoars! = ss Given; a $3 Ae ——_— Poa - - a _6a5 : : : a a Pca2c : = = —— ——— for the string , abe _ 9 LMD ~ a) AMD : - 8A Abc SABC — > abe TT Asal — AB. _ Sabl fC. Ba — Abe CATS ee ee) abe : 3d Ss Abc ») 3 s5A8e sp S— Abc : > abe AB — AbC : — abe = abe = abl sabe > abe A abe - 1 ) fs ABC 5 = Abe Aa — — Abe ec > abe a : ab c - Cone |usian’ - 34 gyammor GB sad +o be ambi wellG) if there exis mere no $e a string | Aveo. that sti ne derivates 3 But, a stilng _c20 hee maltle erie, ie , : as jike 2. example hed Six derivates for the Senarsiha ~ ‘Scanned with CamSeanner but t single derivertion. “Aves. | chee fr the sentence aaa whekher the gram is on }grouUo or net 7 © Gren, 83 aSb/ sje [Check for the senten ca bb whether the : grammar is oem big fous one Ss SaJ = => aasa S2aij : 2 3 qaaa aa | [> 8-> $a p aaSo ia __ 8) {348 a ‘Scanned with CamScanner To string _ SS Than One dertvatina AG Sn eS 2 above as he Ne Gerlvatiin Frees ey iP ‘Scanned with CamSeanner —%) Sash] S8/€ tl UMD amd ) S—->aSb WS ash i) 3— aSb — aaSbb = aakbb 3 assy => aabb 3 aabb —> aaSbSbh | 7 > aabb wy) 83 ash 9S >858 vi) $3 SS ee Oa a sbs = fasb 2 aasSbbs > Saaseh : > aabb _ 3 aabb © ho ae am™ at eS ae a $ = ’ lV : ZN ie Faspy : : aa ome b 1 _ ec A e . a i 2 \ : $d e As ' as be Jm™ 7 . AS hoc ; 4, eeoeb 1 : é ns — Conclusro Hee, in the abore string There exist more theo one. der 7 ~ = S8rivathon Anees sa it ts rn bigvsun - = ‘Scanned with CamSeanner “grammar daken care st grammar ~containg | » p ce dence : : Examples ee (Des e+e a _ - G3EKE : — ‘ ca t Exid io : oo _ - Per the “string “Cte ivi) oj E> +E DaeEtretEe a tdaidrid és e+e ee RE _ idaidatia ‘Scanned with CamScanner | | |) The _ qrammay above found to be ambigrous «ince ve exist Mera than one derivation trea for 4 | seeing Ud +id tid) and Cid tid wid) Yeoth the cava rule -fy assaciatvit{ and precedence => lid tia) ais fo Hs left ip. [yla this ease, the i Recursive - | Gre Tl! Dealing Gith the rule of precedene. i => E+ ee) a : Ee ta Tee ANN ‘Scanned with CamSeanner => When there are more than .one operator in a_qiven qrammar, we define _levela for each _ |_operators . >the operator with higher precedence ts kept at lower level and the operate with lower | precedence BR bept at higher }eve) _ 18.0. Simpiiftcotion of CFG. SA CG con be simplified by following says! @Removal af useless sym bol |— non= generating I— non— reachable @ Remowl of unit pad uctin '@® Remeval of aull productitn : © Removal af uo el-eas symbols. a |b Those symbols hich denot play any rola in the ~ | derivatin of any ctrtng tn LUG) > @ Non - generating Symbols | let uo consider an symbo| Y such that + = a Y=2 wo _wehere “Well and win WF. 27M meane, ¥ leads do a siting of terminals herefoe TY! ts generating cymbal, = 1 non- generating symbols are ‘those cahich (Ce en ‘Scanned with CamSeanner fang Symbol A guch that & > us | ter ue senside| I im ——Tinere We LCq) | and aloo SSA. ‘This mens iqhe symbol | __symnboa S$ divectly ot or Indivectly | | s Hee, symbal a i “called veathable _symnboal. b _symbals | > Hence, non- -reacha ave. thace, |cannot be reac hed from the starting symbol. Some numeri cala! | © 38— 5 ABla Eee Se = — Hera’) S$ >3A8 | ean = oo | ASD : | | _ Step i sfind non generat ng __symvel + = | Herve , B ik non- generating — symioo)_ “stme it is not = deriving any _ terminals . => Removing” call production _ cules thert seerrtain non qene | rating cymbols | The grammar | becom ea 00 834 H : = —— eae Step a: 0: Find non-reachable | _ ssyenbol 7 — : Sine A connot be raached fom charting “agrneo | Sy Ts nan-reachable symbe 3 Remve all piductoa rule fam the aun ‘grammer ch ental Ae - ‘Scanned with CamSeanner @ —>aB | bx = ® 4-2 Bad] wSx/4 B > aS /bOx =. | xX— Sop jaez/oo Gepty 8308 7 @-> bx | 4 = BAd B aS8 A osx B-> bBx | Aa : Xs Sed X— abu | X— ad / a l | Step £. Find non generating bol. | HereBD) i non Generating Symbol . since it 12 att _eriving any terminal. > Bemev' ol ductin rules 3h oa er Hratng agra. ne ee ‘Scanned with CamScanner | Step 2s nd non ‘Find non reachable ym oo). : ——“T Since, Since, ABBE canr cemnot be “reached 7 | Symbol) vB nen “veachable nro |. —Remeve all production vale, from the ¢ | hich contain A+ 3-5 bX - 7 kad 8 he simpiiped I@ S-sac/] se Se | @ 3 bSCa - B—aSB]bec | o Le Cy aBC [ad | S—9ae G3 088 “C3 a8e | $3 so _ Ros bBc a C3 ad 43 bSCa | Step 4! “Find non generating © “y symbole | Here 8 2% “nen _ generating aml since Vos nef deriving ang terminal. a | Reming al produchon rulea thet cntatn i Symbol. The grammer becemoo_ ow | gaat > bSCa : : : ee _ the vredued cre: ‘Scanned with CamSeanner ma) Remeval. of unit production Sf prductioa of tne fen, One terminal —3 one tecmin ot an &> 6 a — whee, & and BG are none termina + : Suthile Cthere exut a unit peduchoa, A—6)~ = $ select a unit product» AG, such Ahat there exit a producttin Bax, wnere « bs the = sequence of terminal. Por (every Aen cae production Bx) Add productta faa dt — —_ Eliminate AB from the grammar. Example » 4, SAG” Aa L B= C]b - cd | DE _ __ ea —___|# gy Step O Be — $22 asi preaucian Step © fading ; Boa and from whe « gfammate eg Dae SAG a ‘Scanned with CamSeanner | Srep® Replacing ¢ -5p ees eee f Ss 4B | naa | can : a. 1 c34 7 = Daa : : : a [ | Ste @ Replacing Bae by B39 in the gra: = AB _4rarmmar . Bead - coo te : 7 Bralb oO - oe . | =reacha ble | syn tools 1 Sens! Remeving all n-raachable Syminls we gd SAB Ava 8 alb G O Co fa/B B= [ob | a abe 1a ee — doin’ Step © CF Sanne produchyn. ae = O38 oe 7 _Gep @ Adding B-> 4/kans elimir \ qracn man. 2 - - = ——$_____—— 84a S36 = a 8 bb A 28 / Sa ‘Scanned with CamSeanner B= wb = : B54 [be I i i i —" Gep @ Adding By bb] ab eliminating S38. Sa6a S bb]a/be B32 bb]a/be lf | | 2 a/be/bb | | Se Ben i | alee { | Sep © Removing all non-re achable Symbala ce ge, S— Gala [pe bb Nf te ae) bo ‘Scanned with CamSeanner year >] 20) Fo Tle) a a TOF THE - a a E> T/E+T i 2 | Step _ Fat - — Ese TF ore unit production, = es E>aT Nowy Fal can be replaced with the help of T L—a/b/ta/to/ss[t F— 8) Jajbj/to)t6/t4 7 tb To.FIT €E Cote | | Step 27 T3F can be replaced with the help of F | SA a/b/ta/Tb/to/u P {| = €)/a/b | Tale) Tot. : TS 8 Taf] Le) a/b/ ta) Te) 10/14. E53 Ett /t+l/le)/a/b/1a/%) eee which B veduced cFiy- . @ Removal of é- productions ondNullable Non-terminala. Lt any prduction in the form of Aoe Koollea ec productions . | sve. cannot eliminate all €-productine that means if eis in cea = cannet be removed. - Gut TF © % not in L(G) 3 can be removes - oo sb Nullable fen- term!n ——— ‘Scanned with CamSeanner | Algorithm 7 ! - —_—_;—— ‘OME G@-3€ Kb be eliminated Yhen ae : | look for all the. production | yules whose i eontam Fp. : = | — . © then each occuvance A in hose producti, _vules is replaced by €. The vesuttant prductin tule i added tn the grammar. thereby vero ving PARE ; | 1 frm tt |@ this wv Necessary in order to keep a Ling of the _qrammar. original mel ‘Scanned with CamScanner S3aA tor Sa AR) fin i iL H Bow @ $3 Aaac BaA/e B>oBlé Coc S$ ABA As a4 A+3e B-+ ba @7eE Cac. Step t> Hens ARE ABBE KK _Step 2> Lek all the pyducton i RHS and then replace S— ABAC on @ nullable null terminal rulea Ehort eotaia 9 46 by & bY |e a a bye: 7c > ce | Step BF Now add 432e€ & B3e7, $7c on tha g rsmmor removing | Are UBwE _ from the grommar. $— apace SC 42a B73 vB ‘Scanned with CamSeanner 1S 0nc/ AGC) OC a SAAC) Be c/pec/ Be —— | A oma ba bB Cac saABC - Sm Sep sy Sa neae $3@GAC aA = AC AC = 2S AAC/AYC : a + | S-9 ABAC | BRC] PBC BC] ANe fac] A= one Borel _ firs yedweed grammars _—- ‘Scanned with CamSeanner nullable pull termincd - _ Ske > look at the prduchta rules thet contain S on ce RH-S and thea replace & bye: S650 7 S— bss removing S> ase ued used grammar. & ) Design a Ch for - regular exp reason |e Catb)* bb Care)* Wreh | | _S-3 Abbs poebyeh & free fom € -production A> aA |oAje : : _.. a ae) bare — ‘Scanned with CamSeanner <= == 1b Aa bA eee 8 Abba fre aA b | aoa 3 A 3aA/a/be]b- —~ oie Dometic ——. => bo8 Le S AbbQ/bbS . D| $3 Abbe gaag O68 __ —3 Abb 34 =o ~7. $3 Abba /AbS 263 23/4 /bO/> g $+ AbbB/bbe ) Abb n- aA]a/bp)b B reduced gramme. 6248 /4/)38) b 7 i 3.3) Normal cforms. is Said te ba 1A norwal form if tr ibs grammar is prducton rules have some special 0¢ - [ ool — | oe A2Ba 7 | here A,B C are non-terminals dia is terminal. Replace @ by Co and & by Cb in the grammar Shere there are required. > " Ss» GA | CoB | A> GAA] CaS Ja 8 Gia [Gs/b tara : ii ft Biase Pie dlace AA by Yq and Be by Xg fia Fhe “¥femmar =i where there are required a ea Ga) ioe 7 ‘Scanned with CamSeanner iy 83 1A /08 & > 48 / 05/0 B—> 068/41. gan i = = —~ —— To be in normal corm) A-—>B¢e or ASQ ohere A,B A Care nonterminal & a & terminal. —$ Y) Replace 4 by Cy and 0 by Co in the grammar where there are required. SA 1 CoB. A CAA] CoS /6 By CoBB/4, Gat CoD D) Replace AA by Xe and Be by XQ iA the grammar Wher there are -nagulred. $3 A/O8 | Ae Cs Ya] GC/o 03> Coxe /t Cosh Xa —> AA _. which & im conf, ae ‘Scanned with CamSeanner @ S$ DabSbja/ans #3 bS/anAb . Sy Replace a by Po and b by @ in the grammar where thera are voquired. = 9883 /a/ Ag. A= Gs / Pang. Pa Q@- b. > Replace AR by xX ia the grammar where there sore: requind: $3 PG S8/a | PAG A OS/ 0x8 {| pP3a _ g8 FAX AR “Replace CG vy Rand SO by B in the grammare where thera are vequire d. ~ S3HN/a / 049g &3GS/PKG Pag 635 x AA | M306 nla 9. “9 Replace AG by Y and X@ by Z in the grammar here there ove veguire d+ ‘Scanned with CamSeanner S— NN Ja /PY AR QS) pz p> 4 — grav ing xX AA : M~ 9 Noa S8 Ya 88 =z 7X8 | 4 SabAB # > bAB/E &B->oAa/A)E : (BIN Here, AGE & B3E are E prductng | hich must be removed from the. grammar. » S- abAB B— bAB 83 BAG = abe 3 b8 5 Ba. $3 abAag/ane [ p> bAgses : 7 e353 844/Ba/p 8 i = yy Ss abas A>bAB 65BAQ S3qb8 Ho ae elaee ba Fa a sab. b za — B38 : = 7 8.5 abAB/abb JabA jab a 7 A> bAB/bE) bA/b i . 83 Cha Jo) AaJAfa ‘Scanned with CamSeanner | D! by Xq a [ Ste WAS | tate B Dh to Vos tots = | @ 3 %oAe [x08 Ka /b- = — |B 3 6A Na /BXa Ain Pa /A —. -— [ %a a {Ee oe _ : “Repuce Yate by Yan) AB BY Kaa And BA by Ken. | 83 Yeo Rb / Xab8 /XaeA/ XoXo. A > Noten] X08 /tA/b- |B > Koa Yq / Xa /AXa/G /A. Nab = Xa Xp. : i kag — A8- | Kea 3 BA | = a Xa b ‘ il - a ae tere BA lunit prducha which must be vemoved \ 1 I iL | TT | firm the grammar. Since B30 Hence. $3 Kab kaa) Yan? / Yao 9/Xa Xo. A-3 Xb kag /%ok /YoA/o. canta / Bxa/ A Xa /a/ to kna/¥62/ Noa /b AB AXaXo. — Sin (NE i ‘Scanned with CamSeanner 83 TST /aB 7 $3 46 $$ T-3 Bs A> 08 [bas _ 1 | 85 /é 5 ~ So pod: Drawbacks of «NE Don (Nf there & reotricHen on the number of “symbols on the AHS. of production i-@ not more | than to symbols ave. permitted - ( If there“ only one See | none of vartableo- je, a ‘Scanned with CamSeanner | ‘ acc Example | S—-ae/Be | A aelbAsa ammar tao GME + BS se/beia Ba bB/beA/a ca. © S908 /aB9/ bAB/aB/BC/bBC/dAC/al ~ AS aB/bA/a a Gaseeiaaas uae 4 b8/bA/a is in GNF ‘Scanned with CamSeanner { ee S— abaSa / aba _—— A a a Repiace a by A and b by B in the pnd wehung ~ wohere there are required: ; | S$ aB4SA/a GA 434 . Bob is in GNE © SAB I A => BSla - B+ SA)b : Bo® det c= Ay : A> As : B= Ag : id Aa > Ar 9 ey | As ABA, Ja tes : Ag— Ai Aa |b "yy which i nef In = force ff 7 } Ag AMelb ps sABASAD Tr Ap Asay 7 3 431 Ag Ae Jaf Ag ct sa ea fa fig Ag ee : Sf _ohich im left rece ‘Scanned with CamSeanner “left “yecu raion _if there” 15 production cg the fora! .. . A> Aa then it & said to _be tn left recureion fer D> Aap there ill be A PB eee : : Here, 63 € is nace -prduchsa that _ rouot be removed, 8 AS eee — CG ae BB Je E As | Ag Si Ag BAg Ae ahs Foie E ax 8 ‘fla, aha Ar] b) By / a : SS ls aeShel yale Asa/b “where Bs —> AiAg Aa Bs / AL AsAr : lere Bs WU new variable Introduced in @ grammar. *. As > afiahs Ba) bGs] af As [b - => anF a “he , As As Ja : > a Ag Ae Gad) bG2 AL [ Agha Ar, [bas hae = GNE Ga 3 AAs LL =. > BAG AL Bs | 3 AAs, | beaAiAa] a a AsaA1As) be bAihs]ahy ts GE B32 F,A3A2 G3 / AAA > 2 FgAz Ga Ay Ag Ash2 Bs | b83A/Ag As ArGq ] aAs A Ais Ag Aa Bo | 6A, As AisAr6s / 4 As AgA2 Gs [ aatebe Ain: is Ag Ae J BBAIAs AA, | 4 Asm VAs Aa Aa / bi ada Aa [as Ashe 3 aN 4 GNF ‘Scanned with CamSeanner | ; Chapter- 4 Push Down Aurtomada, inite aurfortate 2 language “CCF LS) such chine ghoula yead 1S thea vecogalee $4 S ¢ exam pl 2 abba, 7 2e ean conclude that ce gaa fintte outomek a provided with memory thea i that care they (ca ye coqnit e CFLs . — This idea leds te tha generatisn of puohderin automh, PDA R essentall finite, automata eoith tha contol ¢ — a input tape 4,4 a stack (memo) +0 stored hat if | veach. =) PDA = FA + stad. =| Here, stack is lat In Fist Out CUTPO) ox Cicgk Tn last Od i (Paley list. Phed means symbols can be popped out fomvel the hp of stack eal \hen & new symbol & Sere , the top one bemae i _ second and second becomes third cL re on, PDA “composed of | ——_— SF An input cape — eS Fig! ® PDA manhine ‘Scanned with CamScanner fe an Ts tape, 2 and ot the same time also veads from the stack ‘op l= Now, ie depends gen the finite entry), that Ghat ic _*he neat state anck whet call happen the stack ‘top. soo = 7 &_ POR con Ge defined “ae P= (@ 2/7, 5, aq, Be F) — Where, _G= non-empty finite set of ciates in PDR machina. | 2+ nen- empty | finite sete input symbels . (<= set of olphebets in a sek an inital state in PDA machine, a sumbal ; uoed to marl the _betiom of the stad. 2 non-empty finite set of final state in a PDA machine cde S$ is 4 dransi ton function ond defined a0! =e = QOxj}2veyx F—4 Bx Define “configuratia of PDA. > wi of PDA deineo transite function 6 “Pe and s_agiven by? 5] _sqnbd,, eohtch _eatght | be > nll string cle, een tne, top of the _ the stack. a ned tobe shack symbol - that _ replaceo the i _ the stack. ae SS ‘Scanned with CamSeanner * Cone a Tr P=, then is poped out drm tho \ “stack 5 “Cone b! it Pe, then stack & unchange | ney er pushed i (ase 8: q into nor popped oud, 2 YO! then Y is pushed into the top of the stack. Pas a) Determ| —ppAS*~*~*~”*C«S Non Determine PDA : ‘DSi Ox J20E ‘xP ax fT HS: Ox pave ¥ xh Sey 2 can be transit ints a single 2 3 Can be, transit inte moe shite, push ng of popping dhan one state, purhing intya one symbol at a rme. popping out more 2 _syenbo | from a _ crack, ata He. “1D Centre symbo) | is known, =) Centre sy symbe | is knowa, for exaaple + ab? : 2a % pushed « ‘undit b Appears, em soon co b appease: : i popped out against en ple’. wor 7 ¢aca we dont — tose hae fe push ant b. when do pop oud 7 [awe - a ~ —_— a 2a orb is pushed ints the 7 oS stato until 'e arrives, ao . "goon aa te arrives all a's Rvs eo popped at ~ _ | agetnat each a's & bs. : ‘Scanned with CamSeanner ign a POR for the lonquage L={atb”/nzd J ow | 2= (ab) and check fer the string | aabb. : (ase let PDA be p> C8, 2, $40) So) | where, Ge £40 %, 9g} s2 44,63 = gabe = an i fe dey cond its Ara nsition qunet on =: oe ee eee we ‘Scanned with CamSeanner ee Gee [Ree ) OF aabb | State terput cteing —iepubegenbel Rules: Stack psiaier _oputctring is “symbe! Rules , Next state Reroniaing sin ee e foe = a ee a accepted ‘Scanned with CamSeanner Design the yy) thet acceups the language, { welab)ty wo has the seme no of a's and b's 4 and teot it bring woz ‘babbaa Pillows boy b cd viceversa, LO mixed _of ¢ equal: no- ok as bis. 7 7 azeJaz) ~ - (0; 25/ bes) a a) tetrad ‘Scanned with CamSeanner LO XKOG, 21 euch Beh & VV RIM 0M /m24 ond A\st for the sting (u) = aabbbb ge LF dabs, aabbbv, aaabbbbhb,....} I eon douvle at; into the stack for eath gccurane a. The mq all at int : 4 a popping os agains each by fom the la, %sJaaz) (bya Je) Ca, dfaaa) i —) SSI} (4) (ase) g CE, 20/0) te.) &4), (4, 1 Zo) ) OR SL4o,E/€):-> (4, , Zo) 2 (C41, 01 Fo), (41,04 F ob Lo orate : 3.4142), Cea eae a | 4-((9), ba), C90, €)) ? mn rat =(Qubpy Carey, f Phones © (Ga, €7%e) 1 (44 %e)) © do nothing (aceptana by fieetl state). Sie inputstring input syrnbo! Rules Stack Neri state Kemaining Jo 94 bbbb ht - 4 Zo U1 aabbbb a 9, Oabbbb a 2 aa, gy abbbb : 91, abbbb a 3 aaaat, 4% bbbob 4 bbbob b 4 am %o 4, bbb - 4y bbb b 5 aaz 4, bb ; 9, 68 b 5 QZ ay b 4 6 b S %o Ta . 9. = - 6 2 dp = ‘Scanned with CamSeanner ~ | Here all a's ave pushed od into the a stack and | alt as an San | popped out ggaiwt each b's alternative {x . dab [nod (a, Ze faze) | @ Gra, oh, gialehet Z Chala =. = | ba/a) - i =O Os Cba/a)- ee ool @ -D oo 8Q- 7 : Caled — C a ‘Scanned with CamScanner Aeeiies pate pene “sien (e,24f%) io. wen © fo ela,y* 3p-PA a= 4aca, abcba , bbacabb,-._.-.. Ll : _ Oy Zo) bas) toinfe: : QZ fr) bah 7 : i 1Qee gem, oe (E,%0 Fe) =O Ce af bay) Graaad——~ — the bb) — i " f fo : ». ww Jus € (a,bjt > MPA ( Oo Je) I ytoaaee) Aitie Ss elz, ie (4a ¢), Cold) > = Yah “Ca,alan) oad bey NA Chive) ‘Scanned with CamSeanner Cinsaea) : : (41 , Qaaa, 40) = —l- : ~ [ | (4 , aaa , azo) _ [wun ne _cente (pp) | cpus 3 _ | G49 aq 20) (42,44, Zo) me centre : Goan | pee { (dead configurerton state), (411.0, 009%) 43.0 , ao) recent | sene | cous) | e 7 (9,,€ 00%) Can, eo) Cae Ete) CH, oa IY L dead co paifiqu raha 142. POR CEG. (Aas, Construction of DOA ~ let Gz (WnVe, 9S) be bea cantext ies iG we. hove Censhucted a Push Down ® Where coning only ow water 9 machine -P ager fer pale ap He sas ‘let P= (Qi 2,8, Sree ‘Scanned with CamSeanner dead cordigumeun_ ded yal eee ZA a | equivalent — ae Gq cto equivalent PDA. men ot oe aoe anes yammar Ca), Me eR Aeterna CA euch CP) such = ice pea renais permanently in a after ae femme 8 mre seo Vay set of nanctern eee = soto ten Ln eMivals ane Ve, | and transition funchon Sis defined ly Gollesing | Li? (Eel, (q,3) CHere, 6 Starting nen-terminel” in | Cpuahing sin stock) “Fry : i i) G, A), (qi) fer each rule A-ax tn CFG (pushing win stack replocing #) . *) (aa), la €)) ) for each EV Cpopring out-«f-ctade), i$ PDA “p rs i puning 7 the. ctart symbol Sf 2 grammar i iG en its Pally empty cle = A entering tate the next | gate q+ |B Oa ik sttequent step (t either veplacea top mat symbol |W on the stock provided +hob i+ Ba non-termind . Asx). [37 0¢ pops the topmast uymbal from the stack pvovided Med it ic the terminal: | Exam ples’ 3 Design o PDA foc follesing CFG! |G eve, 0) whera Vn-ASt let PDA ® given ae . mae 2, MPS) 401 ZorF QS ‘Scanned with CamSeanner

You might also like