Context-Free Language Induction by Evolution of Deterministic Push-Down Automata Using Genetic Programming

Size: px
Start display at page:

Download "Context-Free Language Induction by Evolution of Deterministic Push-Down Automata Using Genetic Programming"

Transcription

1 Context-Free Lnguge Induction y Evolution of Deterministic Push-Down Automt Using Genetic Progrmming Afr Zomorodin Computer Science Deprtment Stnford University P. O. Box 7171 Stnford, CA fr@cs.stnford.edu Astrct The process of lerning often consists of Inductive Inference, mking generliztions from smples. The prolem here is finding generliztions (Grmmrs) for Forml Lnguges from finite sets of positive nd negtive smple sentences. The focus of this pper is on Context-Free Lnguges (CFL s) s defined y Context-Free Grmmrs (CFG s), some of which re ccepted y Deterministic Push-Down Automt (D-PDA). This pper descries met-lnguge for constructing D-PDA s. This lnguge is then comined with Genetic Progrmming to evolve D-PDA s which ccept lnguges. The technique is illustrted with two fvorite CFL s. 1 Introduction nd Overview Intelligent ehvior often consists of Inductive Inference, mking generliztions from smple incidents. The prolem discussed here is finding generliztions for Forml Lnguges from finite sets of positive nd negtive smple sentences. A positive sentence is defined e sentence ccepted y the grmmr of lnguge nd hence included in the lnguge. A negtive sentence is defined ccordingly. Chomsky (Chomsky 1962) divides ll lnguges nd utomt into four clsses, from the most powerful (type 0 corresponding to Turing Mchines nd unrestricted grmmrs) to the lest powerful (type 3 corresponding to Finite Stte Mchines nd Regulr Expressions.) Context- Free Lnguges nd Grmmrs (type 2) re of fundmentl importnce in Computer Science since high-level procedurl progrmming lnguges, such s Pscl or C cn e represented y CFG s nd prsed y Deterministic Push-Down Automt (D-PDA). A D-PDA is defined to e finite-stte mchine coupled with ottom-less stck. The mchine is cple of reding letters off n input tpe, pushing symols onto stck, nd popping them off the stck. The mchine rejects the sentence if it reds off the end of the sentence (eyond the end-of-sentence mrker) or if it reches the stte. It ccepts the sentence if it reches n stte regrdless of the sttus of its stck. Automtic genertion of D-PDA s would e dvntgeous in nlysis of new progrmming lnguges. An utomticlly generted D-PDA could educte the resercher out the idiosyncrsies or fults of the lnguge nd provide lterntive unknown wys of prsing the lnguge. Another motivtion for the desirility of utomticlly defined D-PDA s is from theoreticl stndpoint. Evolution of D-PDA s cn e viewed s step towrd the evolution of Turning Mchines cple of lerning more complex lnguges. In this pper, lnguge is developed cple of encoding the structure of ny utomt in the spce of D-PDA's. This lnguge is then successfully used long with Genetic Progrmming (GP) to evolve D-PDA s which ccept lnguges. The reminder of this pper is orgnized s follows: Section 2 descries some previous work on lnguge induction. Section 3 provides some motivtion for using Genetic Progrmming. Section 4 presents new pproch to GP lnguge induction nd descries met-lnguge. Section 5 gives results of the ppliction of the work on two CFL s. Section 6 presents discussion of the lessons lerned in this reserch. Section 7 provides some future directions nd section 8 concludes this pper. 2 Previous Work Much work hs een crried out in lnguge-inference since Gold (Gold 1967) initilly estlished the possiility of inferring lnguges from sentences. The inference methods hve included enumertive methods, hill climing (Tomit 1982), higher order enhnced recurrent neurl nets (Giles 1990), second-order recurrent neurl nets (Wtrous 1992), nd Genetic Progrmming (Duny 1994). Most of this work consists in inferring Regulr Lnguges nd the corresponding Deterministic Finite Automt (DFA s). Tomit (Tomit 1982) ws successful in evolving DFA s using hill climing nd sttic numer of sttes. He did, however, encounter prolem when his lgorithm filed to find the correct mchine y climing locl hill. Duny, Petry, nd Buckles (Duny et l. 1994) relized the usefulness of GP for inferring Regulr Lnguges y representing DFA s s S-Expressions nd llowing GP to determine the numer of sttes needed. In their trnsltion scheme, the progrm generted is never evluted s progrm ut is the DFA (This is nlogous to the DNA eing the living creture.) A prolem tht emerged, however, ws tht ck pointers, pointers from

2 sttes to previous sttes, were hrd to evolve in their trnsltion scheme. In other words, the system ws not cple of evolving D-PDA s which ccept regulr lnguges with mny ckpointers. The prolem fced y Duny nd others stems from the fct tht stte-mchine is directed grph nd n S-expression is tree. Duny s solution to this prolem ws trnsltion scheme to convert DFA s to S- expressions. In this scheme, DFA s with ckpointers re hrd to evolve. These ckpointers represent conditionl finite nd infinite loops which re sic uilding locks of stte-mchines. 3 Motivtion For Using Genetic Progrmming In lnguge induction, we re essentilly serching the entire spce of D-PDA's to find generlized solution which hs lerned lnguge. Genetic Algorithms re effective serch lgorithms which do not fll into locl minim, unlike hill climing (Tomit 1982.) Conventionl genetic lgorithms, however, re not directly pplicle to the prolem t hnd ecuse their chromosomes hve constnt length nd the numer of sttes in the solution D-PDA is unknown. Genetic Progrms my e viewed s Genetic Algorithms with vrile-sized chromosomes. 4 A New Approch GP is not directly pplicle to the genertion of D-PDA s. As Duny explins, [u]nless mechnism cn e dded to the GP to more esily ccount for ck pointers, there will continue to e simple DFA s which re difficult to evolve using their trnsltion scheme (Duny et l. 1992). Trditionlly, S-expressions re used in GP ecuse the cross-over of two S-expressions is lwys syntcticlly vlid. S-expressions, however, cnnot represent loops nd ckpointers elegntly. One possile solution to the ckpointer prolem is the invention of nother set of lnguges which hve closure under the cross-over opertion. Another pproch would e to dd level of indirection into the GP pipeline. The ltter pproch is presented in this pper. 4.1 APDAL: A PDA Lnguge The pproch tken here is different from previous work done in this field in tht the GP generted progrm is not the solution ut rther the constructing progrm for the solution. The encoding lnguge is met-lnguge which descries the structure of D-PDA. This dds level of indirection to the trditionl pipeline of GP. Figure 1 shows prtil representtion of the GP pipeline. In ech genertion, D-PDA is constructed y running n progrm from the popultion. Once constructed, the D-PDA is sked to evlute numer of sentences. The progrm s fitness depends on it s D-PDA s performnce insmuch s n niml s DNA fitness depends on the niml s survivl. GP ultion of Progrms D-PDA construction D-PDA Fitness Evlution + Sentences - Figure 1: GP prolem solving pipeline The encoding lnguge, APDAL, consists of numer of mcros. A Lisp-like mcro is executed efore ny of its prmeters re. In APDAL, the prmeters re mcros themselves which crete D-PDA sttes or pseudo-sttes (s defined elow) nd ttch their cretion to the stte or pseudo-stte creted y the clling mcro. The APDAL mcros re: READ (rity 3): cretes red stte nd ttches it to the previous stte. The red stte hs pointers to three other sttes s specified y its three prmeter mcros. A red stte reds chrcter off smple sentence nd depending on the chrcter (,, or empty), chooses trnsition to nother stte. POP (rity 3): like READ, except the creted stte reds chrcter off the D-PDA's stck. PUSHA, PUSHB (rity 1): cretes pseudo-stte which pushes n A or B onto the stck, respectively. A pseudo-stte is stte which cn only e pointed to y one stte. REJECT, ACCEPT (rity 0): ttches the clling mcro s stte to the reject or ccept stte. For exmple, if REJECT is the first rgument to READ, it will point the red stte's first pointer to the reject stte. A specil scheme is used to solve the ckpointer prolem: During the ssemly of D-PDA from n

3 APDAL progrm, the sttes re numered cumultively s they re creted. The pseudo-sttes creted y PUSHA nd PUSHB re not numered. Furthermore, vrile (let s cll it LASTSTATE) keeps trck of the lst stte creted. The following two specil mcros llow n APDAL progrm to chnge the vlue of this vrile: DEC (rity 1): DEC is specil opertor which does not crete stte, ut decrements LASTSTATE. Note: DEC lwys decrements LASTSTATE regrdless of whether cll will e used or NOT. If the current stte is the strt stte, LASTSTATE is not decremented. TOLAST (rity 0): This mcro ttches the clling mcro s stte to the stte specified y LASTSTATE. Therefore, ny stte cn point to ny of the previously creted sttes y using DEC to decrement LASTSTATE, nd TOLAST to chieve the connection. The vlue of LASTSTATE is updted to e the numer of the lst stte creted every time READ, POP, or TOLAST re clled. Strt Figure 3: Strt Stte Strt Red Figure 4: Strt nd Red sttes 4.2 An Exmple: n n The est wy to ecome comfortle with APDAL is to see the development of D-PDA from n APDAL progrm. Consider the progrm in Figure 2. This progrm develops D-PDA for the lnguge n n (n s followed y n s.) Push Strt Red (PUSHA (TOLAST)) (REJECT) (DEC (TOLAST)) (REJECT) (REJECT) (ACCEPT))) (REJECT) (REJECT)) (TOLAST)) Push Figure 5: Specil Mcro TOLAST Strt Red Figure 2: Progrm for n n The construction of ny D-PDA egins with defult Strt Stte (Figure 3). The first mcro in the progrm is READ mcro which cretes red stte nd ttches it to the Strt stte (Figure 4). Note tht the red stte hs three stte-trnsition pointers for chrcters,, nd nothing (end of line mrker). The sttes creted y the READ mcro s three prmeters will ttch themselves to these pointers. The next mcro is PUSHA mcro which cretes pseudo-stte to push n onto the D-PDA s stck if n ws red y the red stte (Figure 5). PUSHA is onerity mcro nd its prmeter is cll to TOLAST which connects the push stte s pointer to the red stte, the lst rel stte creted. Execution of the entire APDAL progrm in Figure 2 results in the D-PDA in Figure 6. The interested reder should confirm tht the D-PDA is in fct stte mchine ccepting the CFL n n. Red,, Figure 6: D-PDA for CFL n n (See Figure 2) 4.3 Implementtion APDAL ws implemented nd deugged in Ansi-C using Symntec 7.0 on Mcintosh. The code ws ported to Sun SPARCsttion 20 Model 61 nd compiled using GNU s gcc. DGPC (Dve s Genetic Progrmming Code) y Dvid André ws used to generte nd evolve APDAL progrms.

4 Ojective Terminl Set Function Set nd rity Fitness Cses Rw Fitness Stndrd Fitness Hits Wrpper Other Prms. Success Predicte Evolve progrm whose output is D-PDA which ccepts CFL. ACCEPT, REJECT, TOLAST READ (3), POP (3), PUSHA (1), PUSHB (1), DEC (1) For ech developed D-PDA: numer of positive nd negtive smples from the lnguge. The fitness for which the D-PDA produces the right output ( Ntp + Ntn) 1 C, where 2 NtpNtn NfnNfp C = ( Ntn + Nfn)( Ntn + Nfp)( Ntp + Nfn)( Ntp + Nfp) where: Ntp = Numer of True Positives, Ntn = Numer of True Negtives, Nfp = Numer of Flse Positives, Nfn = Numer of Flse Negtives. Sme s Rw Fitness. None. M = 3000 individuls, T = 75 stte trnsitions, G = 200 genertions, Crossover(node) = 80%, Crossover(leves) = 10%, Muttion = 0% The Stndrd Fitness equls zero. (PUSHB ) (PUSHB (DEC (REJECT )) (DEC ) (REJECT ) ) (REJECT )) ) Figure 7: Solution t genertion 11 for n n D-PDA uses ""'s to count the numer of ""'s. Push Push Strt Red Red Useless rnch: It will never get here since it pushes 's on the stck. For some reson, the D-PDA is concerned with not leving ny ""'s on the stck. But there re no "Push " sttes. Tle 1: Genetic Progrmming Prmeters 4.4 Genetic Progrmming Prmeters Tle 1 summrizes the GP prmeters tht were used for the first lnguge discussed in the Results section. Similr prmeters were used for the other lnguge. 5 Results Two lnguges were chosen for this reserch. The lnguges re: n n nd lnced prenthesis. Both lnguges re fvorites in Computer Science s exmples of CFL s nd re frequently used to demonstrte the difference etween Regulr Lnguge nd CFL y the Pumping Lemm for Regulr Lnguges (Hopcroft nd Ullmn 1979.) 5.1 n n n n is very smll lnguge since for ny n, the frction of strings of length up to 2n elonging to this lnguge is: Figure 8: An exct solution for n n n + 1, 2n since the lnguge only ccepts one string from every schem of even-length nd none from schem of oddlength. A set of ten positive nd nineteen negtive smple sentences were chosen for the lnguge. The numer of negtive smples is higher ecuse the lnguge is very restrictive (most sentences do not elong to the lnguge.) In smple run, the est-of-genertion for genertion 0 hd fitness of with 16 Hits. The solution emerged in genertion 11 nd is shown in Figure 7. The D-PDA generted y the progrm is shown in Figure 8. Note the following: The D-PDA uses s to count s. While this is izrre to humn, it is only so ecuse humns ssocite counting s with the symol. The mchine does not differentite etween symols nd uses one for counting purposes. Also note tht the solution in Figure 7 is not only n exct solution, it is lmost the sme s the humn-generted one in Figure 6!

5 5.2 Blnced Prentheses For lnced prentheses, the symol ws used to denote ( nd the symol ws used to denote ). There were 11 positive smples nd 12 negtive smples. The est-of-genertion for genertion 0 hd fitness of with 15 hits. At genertion 24, solution emerged. The progrm is shown in Figure 9 nd the generted D-PDA in Figure 10. The solution generted for the lnced prentheses is rther clever. It hs the first pop stte in n unfortunte position (right fter the strt stte.) This pop stte is checking to see if there re enough open prentheses in the sentence y popping the stck. When the mchine is ctivted, however, the stck is empty. The D-PDA s solution is to push on the stck in order to rech the red stte. Another interesting spect of this D-PDA is tht it pushes nd n for every open prenthesis onto the stck. It uses the symol to count the numer of open prentheses, so efore mking ny decisions in pop stte, it lwys pops off ll the s. Other thn the misplced pop stte, the solution hs exctly the numer of ctive sttes s the humn-generted solution nd it hs the sme structure too! 6 Discussion The successful genertion of D-PDA s using APDAL nd GP ws the fruit of the lessons lerned during the design of APDAL nd the mny unsuccessful runs which led to design nd prmeter chnges. I will now riefly discuss some of the issues rised y the APDAL-GP system. A fst implementtion of APDAL is n importnt concern. The memory for the sttes in the progrm is therefore not dynmiclly llocted ut is tken off n sttic glol rry of sttes. The sme memory is then used for ll the individuls nd for ll the genertions. Thus, the system cn e used on computers with smll mount of memory nd is lso fster since it is not llocting nd dellocting memory hundreds of thousnds of times per run. Another interesting implementtion issue is how the sttes re connected. The finl implementtion uses stck: every stte is responsile for ttching itself to the lst stte y popping the stck nd in turn llowing other sttes to e connected to it y pushing its successor pointers onto the stck. The stck is not needed y DGPC ut is included so tht the lnguge cn e used to generte D-PDA s for other purposes. At first, the stndrd fitness of n individul ws defined to e the mximum numer for hits minus the individul s numer of hits. Becuse of this definition, however, the numer of positive nd negtive smple sentences hd to e the sme (ten smple sentences were used for ech ctegory.) In ddition, popultion of 1000 ws used for 100 Genertions with n llotted time of 100 ticks per string (M = 1000, G= 100, T= 100.) The first successful individul for the lnguge n n ws evolved on the second run on genertion 17 s shown in Figure 11. (PUSHB (TOLAST (PUSHB (PUSHA )) (DEC ) (REJECT ) (REJECT )) (PUSHB ) ) (REJECT ))) Figure 9: Solution t genertion 24 for Blnced Prentheses The D-PDA gets rid of the useless 's it pushes on the stck. It is counting with the symol "". Strt Push Intelligent ehvior: The D-PDA pushes "" on the stck in order to rech the Red Stte! The D-PDA pops off ll the ""'s ecuse it is counting with 's nd wnts to see if there re ny ""'s left on the stck. If there re, there were too mny "("'s, This is the reject stte for too mny 's (too mny ")"'s) Red Push Push Push The D-PDA pushes n "" nd "" on the stck for every Red, This is useless since there is lwys n "" on top of "" in the stck. Figure 10: Clrifying Digrm of solution for Blnced Prentheses (PUSHA(PUSHA(TOLAST))(PUSHA(PU SHB(TOLAST)))(DEC(TOLAST))(REJECT)(ACCEPT )(ACCEPT))(REJECT)(ACCEPT)(REJECT)))(PUS HB(REJECT))(REJECT)(TOLAST)(ACCEPT))(PUSHB(TO LAST))))(REJECT)(ACCEPT)(TOLAST)))(PUSHA(REJ ECT))(DEC(TOLAST)))(PUSHA(PUSHA(REJECT)))(PUS HB(REJECT))(DEC(TOLAST)))(DEC(PUSHA(ACCEPT))))) Figure 11: First successful individul, Genertion 17, Second Run

6 The individul is not only long nd composed of mny more sttes thn needed, ut lso is defective. The discerning user cn oserve tht it ccepts the string which is clerly not in the lnguge n n. The following list of prole cuses for the evolution of this defective individul were identified: The ottomless stck ( stck which lwys returns n empty-stck-symol when popped while empty) llowed the individul to get lrge nd llow for defects. The llotted time of 100 times llowed lrge individuls to tke long time nd successfully process the smple sentences (the longest time the humn solution tkes for string is 34 ticks.) The individuls should e punished more for running out of time, hence incresing the selective pressure to remin smll. The lnguge is very restrictive nd more negtive smples re needed. The lst cuse seemed more prole nd the lck of enough negtive smples hd lwys een disturing fctor. The uthor noted tht the reson the string ws ccepted y the D-PDA ws the lck of enough negtive smples with more s thn s nd tht the D-PDA hd lerned the smples. The stndrd fitness ws chnged to involve correltion which llows for different numers of positive nd negtive smples. Nine more negtive sentences with more s thn s nd sentences strting with s were dded. After mking these chnges, the runs ecme unsuccessful. Mny of the runs would hve est-ofgenertion individuls with up to 23 hits, ut none of the runs were le to solve the prolem. The numer of genertions ws incresed to 200 with no result nd then up to 250 without ny chnge. The uthor oserved, however, tht there were usully no improvements in fitness fter out genertion 150. This ment the popultion size ws too smll. The popultion size ws incresed to 2000 nd fitness improved remrkly. A solution ws found when popultion ws rised to Hving lrge popultion mens tht solution could presumly e found y rndom chnce (essentilly chnging our serch lgorithm from the Genetic Algorithm to Rndom Serch.) Fitness ws set to e the sme for ll the individuls in the popultion (fitness = 1) for severl runs. No solution emerged from this rndom serch. Further, no improvements were seen in the numer of hits of individuls in the genertions. Therefore, the Genetic Algorithm ws responsile for generting solutions. The llowed time for processing string ws then reduced from 100 to 75 nd solution ws still found, except it ws smller. The numer of possile nodes in the Result-Producing Brnch (RPB) ws lso lowered from 50 to 30 nd the result ws even smller progrms. The lessons lerned here were: A smll numer of nodes in the RPB long with smll llotted time for string processing would pply enough selective pressure to keep the progrms smll. The prolem spce is too ig to e solved with popultion of Further, 100 genertions is enough to solve the prolems. The serch spce is extremely lrge ( very rough estimte of 30 8 ) nd popultion of 3000 will not help the rndom serch lgorithm to find solution to the D-PDA prolem. 7 Future Work Future directions include: Testing with vriety of CFL s Anlysis of dependility of the APDAL-GP system to develop D-PDA's for deterministic CFL's. Extension of APDAL to hndle lnguges with more thn 2 symols (with eventul extension to hndle ny lnguge regrdless of numer of symols.) Evolution of more complex stte mchines from the Chomsky Hierrchy 8 Conclusions Genetic Progrmming with APDAL encoding lnguge is powerful system to develop D-PDA's which lern CFL from smll set of smple sentences from the lnguge. The contriution of this reserch is the encoding of D-PDA's into Lisp-like lnguge nd the ppliction of GP to inferring CFL's. Acknowledgments The ide for APDAL ws induced to me y Frédéric Gruu's Genetic Micro Progrmming of Neurl Networks (Gruu 1994). I would like to thnk Professor Koz persuding me tht this project topic ws superior to my other ones, nd for his mny helpful comments. I would lso like to thnk Dvid André nd Scott Brve for DGPC. Finlly, my thnks go to my dvisor Mggie Johnson for introducing me to CS Theory nd for her incredile notes on the suject. References Chomsky, Nom Context Free Grmmr nd Pushdown Storge. Qurterly Progress Report 65. The MIT Reserch Lortory in Electronics. MIT Duny, B. D., Petry, F. E., nd Buckles, W. P Regulr lnguge induction with genetic progrmming. In Proceedings of the First IEEE Conference on Evolutionry Computtion. IEEE Press. Volume I. Pges Giles, C. L., Miller, C. B., Chen D., Chen, H. H., Sun, G. Z., nd Lee, Y. C Lerning nd Extrcting Finite Stte Automt with Second-Order Recurrent Neurl Networks. Neurl Computtion 4,

7 Gold, E. M "Lnguge Identifiction in the Limit," Inform. Contr. 10, pp Gruu, Frédéric Genetic micro progrmming of neurl networks. In Kinner, Kenneth E. Jr. (editor). Advnces in Genetic Progrmming. Cmridge, MA: The MIT Press. Pges Hollnd, John H Adpttion in Nturl nd Artificil Systems. Ann Aror, MI: University of Michign Press. Hopcroft J., Ullmn J Introduction to Automt Theory, Lnguges, nd Computtion. Reding. MA: Addison Wesley. Koz, John R Genetic Progrmming: On The Progrmming of Computers y Nturl Selection. Cmridge, MA: MIT Press. Tomit, Msru Dynmic Construction Of Finite- Stte Automt From Exmples Using Hill-Climing. Proceedings to the Fourth Annul Cognitive Sciences Conference. Pges Wltrous, Rmond L. nd Kuhn, Gry M Induction of Finite-Stte Lnguges Using Second- Order Recurrent Networks. Neurl Computtion 4. Pges

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Genetic Programming. Outline. Evolutionary Strategies. Evolutionary strategies Genetic programming Summary

Genetic Programming. Outline. Evolutionary Strategies. Evolutionary strategies Genetic programming Summary Outline Genetic Progrmming Evolutionry strtegies Genetic progrmming Summry Bsed on the mteril provided y Professor Michel Negnevitsky Evolutionry Strtegies An pproch simulting nturl evolution ws proposed

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3 2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

Normal Forms for Context-free Grammars

Normal Forms for Context-free Grammars Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

1B40 Practical Skills

1B40 Practical Skills B40 Prcticl Skills Comining uncertinties from severl quntities error propgtion We usully encounter situtions where the result of n experiment is given in terms of two (or more) quntities. We then need

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

p-adic Egyptian Fractions

p-adic Egyptian Fractions p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Model Reduction of Finite State Machines by Contraction

Model Reduction of Finite State Machines by Contraction Model Reduction of Finite Stte Mchines y Contrction Alessndro Giu Dip. di Ingegneri Elettric ed Elettronic, Università di Cgliri, Pizz d Armi, 09123 Cgliri, Itly Phone: +39-070-675-5892 Fx: +39-070-675-5900

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

Part 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages

Part 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages Automt & lnguges A primer on the Theory of Computtion Lurent Vnbever www.vnbever.eu Prt 5 out of 5 ETH Zürich (D-ITET) October, 19 2017 Lst week ws ll bout Context-Free Lnguges Context-Free Lnguges superset

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q

More information

This lecture covers Chapter 8 of HMU: Properties of CFLs

This lecture covers Chapter 8 of HMU: Properties of CFLs This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata CSC4510 AUTOMATA 5.1 Definitions nd Exmples 5.2 Deterministic Pushdown Automt Definitions nd Exmples A lnguge cn be generted by CFG if nd only if it cn be ccepted by pushdown utomton. A pushdown utomton

More information

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

More information

Revision Sheet. (a) Give a regular expression for each of the following languages:

Revision Sheet. (a) Give a regular expression for each of the following languages: Theoreticl Computer Science (Bridging Course) Dr. G. D. Tipldi F. Bonirdi Winter Semester 2014/2015 Revision Sheet University of Freiurg Deprtment of Computer Science Question 1 (Finite Automt, 8 + 6 points)

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

2.4 Linear Inequalities and Interval Notation

2.4 Linear Inequalities and Interval Notation .4 Liner Inequlities nd Intervl Nottion We wnt to solve equtions tht hve n inequlity symol insted of n equl sign. There re four inequlity symols tht we will look t: Less thn , Less thn or

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010 CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Thoery of Automata CS402

Thoery of Automata CS402 Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

More on automata. Michael George. March 24 April 7, 2014

More on automata. Michael George. March 24 April 7, 2014 More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch. Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

19 Optimal behavior: Game theory

19 Optimal behavior: Game theory Intro. to Artificil Intelligence: Dle Schuurmns, Relu Ptrscu 1 19 Optiml behvior: Gme theory Adversril stte dynmics hve to ccount for worst cse Compute policy π : S A tht mximizes minimum rewrd Let S (,

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, section 003, George Mson University, Fll 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 7 1. Prove (p q) (p q), () (5pts) using truth tles. p q

More information

Learning Moore Machines from Input-Output Traces

Learning Moore Machines from Input-Output Traces Lerning Moore Mchines from Input-Output Trces Georgios Gintmidis 1 nd Stvros Tripkis 1,2 1 Alto University, Finlnd 2 UC Berkeley, USA Motivtion: lerning models from blck boxes Inputs? Lerner Forml Model

More information

CSC 311 Theory of Computation

CSC 311 Theory of Computation CSC 11 Theory of Computtion Tutoril on DFAs, NFAs, regulr expressions, regulr grmmr, closure of regulr lnguges, context-free grmmrs, non-deterministic push-down utomt, Turing mchines,etc. Tutoril 2 Second

More information

Section 4: Integration ECO4112F 2011

Section 4: Integration ECO4112F 2011 Reding: Ching Chpter Section : Integrtion ECOF Note: These notes do not fully cover the mteril in Ching, ut re ment to supplement your reding in Ching. Thus fr the optimistion you hve covered hs een sttic

More information

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

More information

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy: Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

Lexical Analysis Part III

Lexical Analysis Part III Lexicl Anlysis Prt III Chpter 3: Finite Automt Slides dpted from : Roert vn Engelen, Florid Stte University Alex Aiken, Stnford University Design of Lexicl Anlyzer Genertor Trnslte regulr expressions to

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

Bridging the gap: GCSE AS Level

Bridging the gap: GCSE AS Level Bridging the gp: GCSE AS Level CONTENTS Chpter Removing rckets pge Chpter Liner equtions Chpter Simultneous equtions 8 Chpter Fctors 0 Chpter Chnge the suject of the formul Chpter 6 Solving qudrtic equtions

More information

DFA minimisation using the Myhill-Nerode theorem

DFA minimisation using the Myhill-Nerode theorem DFA minimistion using the Myhill-Nerode theorem Johnn Högerg Lrs Lrsson Astrct The Myhill-Nerode theorem is n importnt chrcteristion of regulr lnguges, nd it lso hs mny prcticl implictions. In this chpter,

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages C 314 Principles of Progrmming Lnguges Lecture 6: LL(1) Prsing Zheng (Eddy) Zhng Rutgers University Ferury 5, 2018 Clss Informtion Homework 2 due tomorrow. Homework 3 will e posted erly next week. 2 Top

More information

Parsing and Pattern Recognition

Parsing and Pattern Recognition Topics in IT Prsing nd Pttern Recognition Week Context-Free Prsing College of Informtion Science nd Engineering Ritsumeikn University this week miguity in nturl lnguge in mchine lnguges top-down, redth-first

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!) CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun: CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

More information