Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
|
|
- Phoebe McCormick
- 5 years ago
- Views:
Transcription
1 Univerity of Southern Cliforni Computer Siene Deprtment Compiler Deign Fll 6 Lexil Anlyi Smple Exerie nd Solution Prof. Pedro C. Dini USC / Informtion Siene Intitute 4676 Admirlty Wy, Suite Mrin del Rey, Cliforni 99 pedro@ii.edu Lexil Anlyi Smple Exerie Fll 6
2 Univerity of Southern Cliforni Computer Siene Deprtment Prolem : Conidering the lphet Σ = {,} derive Non-Determiniti-Finite Automton (NFA) uing the Thompon ontrution tht i le to reognie the entene generted y the regulr expreion *( )*. Doe the entene w = elong to the lnguge generted y thi regulr expreion? Jutify. Solution: Conidering impliftion of the omintion of the NFA during the Thompon ontrution (e.g., equene of two -trnition n e onidered ingle -trnition) poile NFA i hown elow nd where the trt tte i the tte leled The word w = elong to the lnguge generted y thi RE eue there i pth from the trt tte to the epting tte tht pell out the word, repetively the pth,,4,6,8,,,,,,. Prolem : Strting from the NFA you derived in prolem, onvert it to DFA uing the u-et ontrution deried in l. Verify tht the DFA yield the me output the originl NFA for the me input tring w. Solution: Uing the -loure nd DFAedge omputtion deried in l, we hve the following mpping of et of tte of the NFA to et of tte of the DFA: I = -loure () = {,,, 4, } I = DFAedge(I,) = -loure ({,,, 4, }, ) = {6} I = DFAedge(I,) = -loure ({,,, 4, }, ) = {,,, 4,, 7} I = DFAedge(I,) = -loure ({6}, ) = Ierr I4 = DFAedge(I,) = -loure ({6}, ) = {8,,, } I = DFAedge(I,) = -loure ({,,, 4,, 7}, ) = {6, 9,,, } I6 = DFAedge(I,) = -loure ({,,, 4,, 7}, ) = {,,, 4,, 7} = I I7 = DFAedge(I4,) = -loure ({8,,, }, ) = Ierr I8 = DFAedge(I4,) = -loure ({8,,, }, ) = {,, } I9 = DFAedge(I,) = -loure ({6, 9,,, }, ) = Ierr I = DFAedge(I,) = -loure ({6, 9,,, }, ) = {8,,,, } I = DFAedge(I8,) = -loure ({,, }, ) = Ierr I = DFAedge(I8,) = -loure ({,, }, ) = {,, } = I8 I = DFAedge(I,) = -loure ({8,,,, }, ) = Ierr I4 = DFAedge(I,) = -loure ({8,,,, }, ) = I8 Effetively there re only 8 tte hown in the DFA elow nd thi i lerly not the miniml DFA tht n reognie thi regulr expreion. Lexil Anlyi Smple Exerie Fll 6
3 Univerity of Southern Cliforni Computer Siene Deprtment, Ierr I I I4 I8 I I I For the input entene w = in hi DFA we would reh the tte I8, through tte I, I4 nd I8 nd thu epting thi tring. Prolem : Strting from the DFA you ontruted in the previou prolem, onvert it to miniml DFA uing the minimition lgorithm deried in l. Verify tht the DFA yield the me output the originl NFA for the me input tring w. Solution: The firt prtition would hve the two et of tte P = {I, I, I, Ierr} nd = {I4, I, I8, I}. A eond prtition would mintin nd prtition P into {I, I, Ierr} nd generte P = {I} ine I goe to itelf on nd to on. Next the lgorithm would generte = {I) nd next generte P = {Ierr} leving P = {I}. The finl DFA would hve therefore tte h hown elow., P P P Agin on the input tring w = the DFA would trvere P,, nd loop in therefore epting the tring. Importnt Note: If you try to pply the me ontrution, i.e. prtitioning the et of tte trting with n inomplete DFA where the trp tte i miing you might e urpried to find tht you reh t n inorret miniml DFA. Lexil Anlyi Smple Exerie Fll 6
4 Univerity of Southern Cliforni Computer Siene Deprtment Prolem 4: Conidering the lphet Σ = {,} ontrut Non-Determiniti-Finite Automton (NFA) uing the Thompon ontrution tht i le to reognie the entene generted y the regulr expreion (**)**. Doe the entene w = elong to the lnguge generted y thi regulr expreion? Jutify. Solution: The NFA i hown elow nd where the trt tte i tte leled S = -loure () = {,,, 4,,, } thi i finl tte eue of S = DFAedge(S,) = -loure (S, ) = {, 6, 8} S = DFAedge(S,) = -loure (S, ) = {,, 4,,, } finl tte DFAedge(S,) = -loure (S, ) = {, 6, 8} = S DFAedge(S,) = -loure (S, ) = {,, 4,,, } = S S = DFAedge(S,) = -loure (S, ) = {,, 4, 9,,, } finl tte S4 = DFAedge(S,) = -loure (S, ) = {6, 7, 8} DFAedge(S4,) = -loure (S4, ) = {,, 4, 9,,, } = S DFAedge(S4,) = -loure (S4, ) = {6, 7, 8} = S4 DFAedge(S,) = -loure (S, ) = {, 6, 8} = S DFAedge(S,) = -loure (S, ) = {,, 4,,, } = S Thi reult in the DFA hown elow with trting tte S. S S S S S S4 S4 Thi DFA n e further minimie y reogniing tht S, S nd S form elf-ontined prtition nd S nd S4 nother prtition reulting in the DFA on the right-hnd-ide. Lexil Anlyi Smple Exerie 4 Fll 6
5 Univerity of Southern Cliforni Computer Siene Deprtment Prolem : Conider the lphet Σ = {,}.. Contrut Non-Determiniti-Finite Automton (NFA) uing the Thompon ontrution tht i le to reognie the entene generted y the regulr expreion RE = ()*.()*.. Do the entene w = nd w = elong to the lnguge generted y thi regulr expreion? Jutify.. Convert the NFA in prt ) to DFA uing the uet ontrution. Show the mpping etween the tte in the NFA nd the reulting DFA. d. Minimie the DFA uing the itertive refinement lgorithm diued in l. Show your intermedite prtition reult nd doule hek the DFA uing the entene w nd w. Solution: ) A poile ontrution (lredy implified to hve only ingle -trnition etween tte) would reult in the NFA hown elow nd where the trt tte i leled. 4 6 ) Both word re reognied y thi NFA. Regrding the word there i pth from tte to the epting tte 6, nmely:,,,,4,,4,,6. Regrding the word the utomton my reh tte 6 following the pth,,,4,,4,,4,,6. ) Uing the uet ontrution we rrive t the following uet nd trnition. S = -loure () = {,,, 4,, 6} thi i finl tte eue of tte 6 S = DFAedge(S,) = -loure (goto(s, )) = {, 4,, 6} finl tte SE = DFAedge(S,) = -loure (goto(s, )) = { } S = DFAedge(S,) = -loure (goto(s, )) = {4,, 6} finl tte S = DFAedge(S,) = -loure (goto(s, )) = {, 4,, 6} finl tte DFAedge(S,) = -loure (goto(s, )) = {4,, 6} = S DFAedge(S,) = -loure (goto(s, )) = { } = SE DFAedge(S,) = -loure (goto(s, )) = {, 4,, 6} = S DFAedge(S,) = -loure (goto(s, )) = { } = SE Thi reult in the DFA hown elow with trting tte S. S SE S S S, d) Thi DFA n e further minimie y uing the itertive refinement prtitioning yeilding the equene of prtition indited elow. Lexil Anlyi Smple Exerie Fll 6
6 Univerity of Southern Cliforni Computer Siene Deprtment S SE S S S S P SE S S S P, P, Initil prtitioning on finl tte Prtitioning on S P SE S S S S SE S S P,, Prtitioning on finl miniml DFA Lexil Anlyi Smple Exerie 6 Fll 6
7 Univerity of Southern Cliforni Computer Siene Deprtment Prolem 6: Minimie the FA hown elow over the lphet {,}. Mke ure to onvert it firt into DFA nd them pply the itertive refinement lgorithm diued in l. trt 4 Solution: The firt oervtion i tht there re ome tte for whih one of the trnition on the lphet ymol i miing. Thi i the e with tte "" nd "". A uh need to ugment thi FA with "trp-tte" tht i non-epting hown elow in ). The reminder DFA reult from the pplition of the itertive prtitioning lgorithm deried in l. trt trt P 4, 4 P, ) Augmented DFA trt ) Prtion ed on epting nd non-epting tte trt P P 4 P, 4 P, P ) Prtion ed on '' trnition d) Prtion ed on '' trnition trt trt P 4 P e) Prtion ed on '' trnition P, f) Minimied DFA, Lexil Anlyi Smple Exerie 7 Fll 6
8 Univerity of Southern Cliforni Computer Siene Deprtment Prolem 7: Conider the DFA elow with trting tte nd epting tte :, 4, ) Uing the Kleene ontrution lgorithm derive regulr expreion. ) Symplify the expreion found in ) ove. Solution: Before engging in very long equene of ontention nd ymoli opertion we mke the oervtion tht tte 4 i trp-tte. A uh we n fely ignore it ine it i not n epting tte. Wht thi men i tht we n ue the lgorithm imply with k = nd need to ue it to ompute R there re pth from the trt tte to the finl tte vi tte. Expreion for k = R = () R = ( ) R = () R = () R = ( ) Expreion for k = R = R (R )*R R = () R = R (R )*R R = ( ) R = R (R )*R R = () R = R (R )*R R = () R = R (R )*R R = ( ) Expreion for k = R = R (R )*R R = R = () R = R (R )*R R = ( ) ( )* ( ) ( ) = ( ) * R = R (R )*R R = ( ) ( )* () () = *() R = R (R )*R R = () ( )* ( ) () = () * R = R (R )*R R = ( ) ( )* ( ) ( ) = * R = R (R )*R R = ( ) ( )* () = ( ) * () R = R (R )*R R = () ( )* () = () *() Expreion for k = R = R (R )*R R = R = () R = R (R )*R R = ( ) * () (() *())* () * ( )* R = R (R )*R R = *() (() *())* () *() * () R = R (R )*R R = () *() (() *())* () * () * R = R (R )*R R = *() (() *())* () * * R = R (R )*R R = ( ) * () (() *())* () *() ( ) * () R = R (R )*R R = () *() (() *())* () *() () *() Lexil Anlyi Smple Exerie 8 Fll 6
9 Univerity of Southern Cliforni Computer Siene Deprtment Clerly thee expreion hve lot of redundnt term. In ft we re only intereted in R = ( ) * () (() *())* () * ( )* ine the trting tte i tte nd the only epting tte i tte. ) To implify the expreion found ove i very hrd, there re lot of prtil term in thi expreion. Inted you follow the edge in the DFA nd try to ompoe the regulr expreion (in ome ene ignoring wht you hve done in the previou tep). The implet wy to look t thi prolem i to ee tht there i prefix ( ) nd then you return to tte either y (*) or (), o ompt regulr expreion would e R = ( )(() ())* muh more ompt regulr expreion tht R ove. Prolem 8: Conider the lphet Σ = {; }. Define hort, poily the hortet, regulr expreion tht generte tring over Σ tht ontin extly one nd t let one. Solution: The tring mut either trt with one or n, o we n ue * preffix to ount for ny poile numer of leding efore the firt. The ingle mut hve t let one either preeeding it or jut efore it. After thi ingle there n e ny numer of triling. A poile (lthough not neerily unique) regulr expreion denoting the ought lnguge i R = *( )*. Prolem 9: Given n NFA with -trnition how do you derive n equivlent NFA without thoe - trnition? Jutify. Solution: For thoe tte with -trnition merge the edge of the tte t the end of thoe trnition into the urrent tte. Iterte until there re no -trnition left. You till hve NFA ut there will e t more multiple edge with the lel lel out of given tte. Prolem : Given n NFA with everl ept tte, how how to onvert it onto NFA with extly one trt tte nd one epting tte. Solution: The initl tte i the me in the originl NFA. A to the epting tte jut dd - trnition from the orignl epting tte to new epting tte nd lel tht epting tte the only epting tte of the new NFA. Lexil Anlyi Smple Exerie 9 Fll 6
10 Univerity of Southern Cliforni Computer Siene Deprtment Prolem : Given the Finite Automton elow with initil tte nd lphet {,} nwer the following quetion: 4, () Why i thi FA Non-Determiniti Finite Automton (NFA)? () Convert thi NFA to DFA uing the loure omputtion. () Minimie the reulting DFA. (d) Wht i the Regulr Expreion mthed y thi NFA? You re dvied not to ue the utomti Kleene ontrution or try to look t the input NFA ut rther the orretly minimied DFA. Solution: () Thi FA i lredy DFA, the only trnition tht re miing ll go to the trp tte. () The uet ontrution, whih in thi e yield the me originl DFA on the left where we hve noted the uet eh tte tnd for. {} {} {} {4} {},, () Uing the itertive prtition refinement we hve the following prtition (elow left) nd the reulting minimied DFA on the right gin with the tte releled. Notie tht thi i peil e where the refinement lgorithm nnot refine ny u-et of tte given tht the originl DFA w lredy miniml. {} P {} {} P {4} {} P,, (d) Bed on the lt DFA the regulr expreion identified y thi FA mut hve extly two oneutive ymol poily preeded y ingle ymol. For intne, the tring i in the lnguge ut the tring or re not. The regulr expreion n e denoted y *. Lexil Anlyi Smple Exerie Fll 6
11 Univerity of Southern Cliforni Computer Siene Deprtment Prolem : Drw the mllet DFA tht ept the lnguge derived y the regulr expreion (** **). Solution: A poile trnltion guided y the ide of the Thompon ontrution i hown elow. 6, 4 Uing the itertive refinement lgorithm for DFA minimition indeed onfirm tht thi i the mllet poile DFA. The equene of refinement i hown elow., 4 6, 4 6 4, 6, 4 6 4, 6 4, 6 Prolem : Given the regulr expreion RE = ( *)*(*) over the lphet Σ = {,} do the following trnformtion:. Derive NFA uing the Thompon ontrution ple of identifying the tring generted y thi regulr expreion.. Convert the NFA otined in ) to DFA.. Minimie the reulting DFA uing the itertive refinement lgorithm diued in l. d. Determine in how mny tep i the equene proeed. Jutify. Solution: Regrding ) the NFA i given elow. Here we mde ome very imple implifition tht two or more equene of -trnition n e onverted to ingle -trnition. Thi utntilly redue the numer of tte in the NFA nd thiu filitte the ontrution of the equivlent DFA. Lexil Anlyi Smple Exerie Fll 6
12 Univerity of Southern Cliforni Computer Siene Deprtment Applying the uet ontrution we hve the following tte S = -loure () = {,, 4, 7, 8,,,,, 4, } thi i finl tte eue of S = DFAedge(S,) = -loure (goto(s, )) = {} S = DFAedge(S,) = -loure (goto(s, )) = {,,, 4, 7, 8, 9,,, 4, } finl S = DFAedge(S,) = -loure (goto(s, )) = {} S4 = DFAedge(S,) = -loure (goto(s, )) = {,,, 4, 6, 7, 8,,, 4, } finl S = DFAedge(S,) = -loure (goto(s, )) = {} = S S6 = DFAedge(S,) = -loure (goto(s, )) = {,,, 4, 7, 8, 9,,,, 4, } finl S7 = DFAedge(S,) = -loure (goto(s, )) = {} = S S8 = DFAedge(S,) = -loure (goto(s, )) = {} = S S9 = DFAedge(S4,) = -loure (goto(s4, )) = {} = S S = DFAedge(S4,) = -loure (goto(s4, )) = {,,, 4,, 7, 8, 8,,,, 4, } = S6 S = DFAedge(S6,) = -loure (goto(s6, )) = {,,, 4, } finl S = DFAedge(S6,) = -loure (goto(s6, )) = {,,, 4, 7, 8, 9,,, 4, } = S S = DFAedge(S,) = -loure (goto(s, )) = {} = S S4 = DFAedge(S,) = -loure (goto(s, )) = {,,, 4, 6, 7, 8,,, 4, }= S4 So there re totl of 7 tte, S, S, S, S, S4, S6, S nd the orreponding DFA i hown y the tle elow (old tte re finl tte) nd then in the figure elow the tle. Next Stte Current Stte S S S S S S4 S S S6 S S S S4 S S6 S6 S S S S S4, 4 6 Lexil Anlyi Smple Exerie Fll 6
13 Univerity of Southern Cliforni Computer Siene Deprtment, P 4 6 initil refinement on eptne riteri 6, 4 refinement of on P P, 4 6 P refinement of on P, P 4 6 refinement of P on P P P6 P P, 4 6 refinement of on P P6 P P, 4 6 finl refinement with 6 tte P Prolem 4: Given the DFA elow derie in Englih the et of tring epted y it., Solution: Any tring over the lphet tht ontin ny numer of oneutive, inluding none with preffix of ero or more oneutive. Lexil Anlyi Smple Exerie Fll 6
14 Univerity of Southern Cliforni Computer Siene Deprtment Prolem : Given regulr lnguge L. i.e., lnguge deried y regulr expreion, prove tht the revere of L i lo regulr lnguge (Note: the revere of lnguge L i L R where for eh word w in L, w R i in L R. Given word w over the given lphet, w R i ontruted y pelling w kwrd). Solution: If L i regulr lnguge then there exit DFA M tht reognie it. Now given M we n ontrut M tht reognie the revere of L with repet to the input lphet. We now derie how to ontrut M. M i repli of M ut revering ll the edge. The finl tte of M i the tte tht ued to e the trt tte of M. The trt tte of M i new tte with -trnition to the tte in M tht ued to e the finl tte of M. Now eue M might hve multiple finl tte M i y ontrution NFA. Given the equivlene of NFA nd regulr expreion we hve hown tht if L i regulr o i L R. Prolem 6: Drw the DFA ple of reogniing the et of ll tring eginning with whih interpreted the inry repreenttion of n integer (uming the lt digit to e proeed i the let ignifint) i ongruent to ero modulo i.e., the numeri vlue of thi inry repreenttion i multiple of. Solution: The hrd prt out thi prolem i tht you need to keep trk with the lredy oerved it wht the reminder of the diviion y i. Given tht you hve reminder you would need no more tht tte, one for eh of the reminder vlue through eing the tte tht repreent reminder of ero the epting tte, in thi e tte S. The DFA elow omplihe thi. You n verify thi DFA y trying the numer in inry or in inry. Notie tht in the lt tte S ny dditionl men you re hifting the it y one it, i.e., multiplying y, hene tying in the me tte. S S S S Prolem 7: Conider the lphet Σ = {,}.. Conider the Non-Determiniti Finite Automton (NFA) depited elow. Why i thi utomton non-determiniti? Explin the vriou oure on indeterminy.. Do the entene w = nd w = elong to the lnguge reognied y thi FA? Jutify.. Convert the NFA in prt ) to DFA uing the uet ontrution. Show the mpping etween the tte in the NFA nd the reulting DFA. d. Minimie the DFA uing the itertive refinement lgorithm deried in l. Show your intermedite prtition reult nd doule hek the DFA uing the entene w nd w. Lexil Anlyi Smple Exerie 4 Fll 6
15 Univerity of Southern Cliforni Computer Siene Deprtment 4 6 trt Solution: ) Thi i indeed NFA for two reon. Firt, it inlude -trnition. Seond, in tte there re two trnition on the me terminl or lphet ymol, "". ) Regrding the word there i pth from tte to the epting tte 6, nmely:,4,,6. Regrding the word the utomton will never e le to reh the tte 6 in order to pell out the hrter will neerily e in tte nd to reh tht tte we nnot hve two oneutive "" hrter we we would e either in tte or tte 4. ) Uing the uet ontrution we rrive t the following uet nd trnition. S = -loure ({}) = {,, 4} thi i not finl tte. S = DFAedge(S,) = -loure (goto(s, )) = {,,, 6} finl tte S = DFAedge(S,) = -loure (goto(s, )) = {} S9 = DFAedge(S,) = -loure (goto(s, )) = {,, 6} finl tte S4 = DFAedge(S,) = -loure (goto(s, )) = {,, 6} finl tte. S = DFAedge(S,) = -loure (goto(s, )) = {,, 6} finl tte. DFAedge(S,) = -loure (goto(s, )) = {} = S DFAedge(S4,) = -loure (goto(s4, )) = {,, 6} = S finl tte. DFAedge(S4,) = -loure (goto(s4, )) = {,, 6} = S4 finl tte. S6 = DFAedge(S,) = -loure (goto(s, )) = {, 6} finl tte. S7 = DFAedge(S,) = -loure (goto(s, )) = {, 6} finl tte. DFAedge(S6,) = -loure (goto(s6, )) = {, 6} = S6 finl tte. S8 = DFAedge(S6,) = -loure (goto(s6, )) = { } DFAedge(S7,) = -loure (goto(s7, )) = { } = S8 DFAedge(S7,) = -loure (goto(s7, )) = {, 6} = S7 finl tte. DFAedge(S8,) = -loure (goto(s8, )) = { } = S8 DFAedge(S8,) = -loure (goto(s8, )) = { } = S8 DFAedge(S9,) = -loure (goto(s9, )) = {,, 6} = S9 DFAedge(S9,) = -loure (goto(s9, )) = {} = S Thi reult in the DFA hown elow with trting tte S. trt S S S9 S S4 S S7 S6 S8, Lexil Anlyi Smple Exerie Fll 6
16 Univerity of Southern Cliforni Computer Siene Deprtment d) We n try to minimie thi DFA uing the itertive refinement lgorithm deried in l. The figure elow depit poile equene of refinement. For eh tep we indite the riteri ued to diriminte etween tte in the previou prtition. A n e een, the lgorithm led to no refinement, o thi i prtiulr e where the u-et lgorithm tht help u derive the DFA from it originl NFA doe yield miniml DFA. P P P P trt S S S S9 S4 S S7 S6 S8, trt S S S9 S S4 S S7 S6, S8 trt S S S S4 S9 S S7 S6, S8 P P P () Prtition etween epting nd non-epting tte () Dirimintion ed on "" trnition () Dirimintion ed on "" trnition trt P S P S S P9 S9 S4 S S7 S6 P P S8, trt P S P S S P6 S S4 P9 S9 S7 S6 P P S8, trt P S P7 P S S P6 S S4 P9 S9 S7 S6 P P S8, (d) Dirimintion ed on "" trnition (e) Dirimintion ed on "" trnition (f) Diriminion ed on "" trnition Lexil Anlyi Smple Exerie 6 Fll 6
17 Univerity of Southern Cliforni Computer Siene Deprtment Prolem 8: Conider the DFA elow with trting tte nd epting tte : trt ) Derie in Englih the et of tring epted y thi DFA. ) Uing the Kleene ontrution lgorithm derive the regulr expreion reognied y thi utomton ymplifying it muh poile. Solution: ) Thi utomton reognie ll non-null tring over the {,} lphet tht end with "". ) The derivtion re hown elow with the oviou ymplifition. Expreion for k = R = ( ) R = () R = () R = ( ) Expreion for k = R = R (R )*R R = ( ). ( )*. ( ) ( ) = * R = R (R )*R R = ( ). ( )*. () () = * * R = R (R )*R R = (). ( )*. ( ) () = + + R = R (R )*R R = (). ( )*. ( ) ( ) = (* ) Expreion for k = R = R (R )*R R = ( * * ). (* )*. ( + + ) ( * ) R = R (R )*R R = ( * * ). (* )*. ( + + ) ( * * ) R = R (R )*R R = ( * * ). (* )*. ( + + ) ( + + ) R = R (R )*R R = ( * * ). (* )*. ( + + ) (* ) L = R = ( * * ). (* )*. ( + + ) ( * * ) A n e een the implifition of ny of thee regulr expreion eyond the expreion for k= i firly omplited. Thi method, lthough orret y deign led to regulr expreion tht re fr from eing miniml or even the mot ompt repreenttion of the regulr lnguge the DFA reognie. Lexil Anlyi Smple Exerie 7 Fll 6
18 Univerity of Southern Cliforni Computer Siene Deprtment Prolem 9: For the regulr expreion depited elow nwer the following quetion: RE = ( - +)?. (e E). (-9)+ ) Uing the Thompon ontrution (or implifition thereof) derive NFA tht reognie the tring peified y thi RE. ) Convert the NFA in ) to n equivlent DFA uing the uet ontrution. ) Mke ure the DFA M found in ) ove i miniml (you do not need to how tht it i in ft miniml) nd ontrut the DFA M tht ept the omplement of the regulr lnguge the firt DFA ept. Show tht M doe ept the word w = "e" whih i not epted y the originl DFA. Solution: ) The figure elow depit the NFA with -trnition nd where we hve implified the trnition on numeri digit. 'e' '' trt '-' 4 6 'E' 7... '9' 8 9 '+' ) We ue the uet ontrution y tring for every et of tte the other poile tte the NFA ould e in if it were to trvere -edge only. The lit elow depit the reult of thi ontrution where we lo derie the omputtion of edge DFA edge uing the funtion DFA_edge nd then omputing the e-loure of the reulting intermedite et of tte. -loure({}) DFA_edge(S,'-') DFA_edge(S,'+') DFA_edge(S,'e') DFA_edge(S,'E') DFA_edge(S,'<digit>') DFA_edge(S,'-') DFA_edge(S,'+') DFA_edge(S,'e') DFA_edge(S,'E') DFA_edge(S,'<digit>') = {,,,, 4} = S = -loure({}) = {,, 4} = S = -loure({}) = {,, 4} = S = -loure({}) = {, 6, 7} = S = -loure({}) = {, 6, 7} = S = -loure( {} ) = SE; error tte = -loure( {} ) = SE; error tte = -loure( {} ) = SE; error tte = -loure({}) = {, 6, 7 } = S = -loure({}) = {, 6,7 } = S = -loure( {} ) = SE; error tte DFA_edge(S,'-') = -loure( {} ) = SE; error tte DFA_edge(S,'+') = -loure( {} ) = SE; error tte DFA_edge(S,'e') = -loure( {} ) = SE; error tte DFA_edge(S,'E') = -loure( {} ) = SE; error tte DFA_edge(S,'<digit>') = -loure( {8} ) = { 6, 7, 8, 9, } = S; DFA_edge(S,'-') = -loure( {} ) = SE; error tte DFA_edge(S,'+') = -loure( {} ) = SE; error tte DFA_edge(S,'e') = -loure( {} ) = SE; error tte DFA_edge(S,'E') = -loure( {} ) = SE; error tte DFA_edge(S,'<digit>') = -loure( {8} ) = { 6, 7, 8, 9, } = S; The figure elow depit the DFA reulting from the pplition of the uet ontrution. Notie tht thi i fully peified DFA where eh tte inlude trnition for ll the hrter in the onidered lphet. Lexil Anlyi Smple Exerie 8 Fll 6
19 Univerity of Southern Cliforni Computer Siene Deprtment trt '-' '+' S 'e' 'E' '' '9'... S... '' '9' '' '9' 'e' 'E' '-' '+'... 'e' 'E' '' S S 'e' 'E' '-' '+' SE... '9' 'e' 'E' '-' '+' ''... '9' ) Let M e the DFA found in ). Thi DGA i in ft miniml. Informl proof: All tte re required. S i the trt tte. S pture the ft tht we hve oerved ign.. Stte S pture to ft we need to oerve t let one digit. All the digit re then ptured y tte S. Stte SE i the trp error tte. Let M e thi firt DFA. We ontrut M y mking ll epting tte of M non-epting tte nd ll non-epting tte of M epting tte of M. The tte trt i unhnged. Thi i DFA we only hnge the tte of non-epting tte. The trt tte i till ingleton nd ll trnition re lerly identified in the newly reted DFA hown elow. '-' '+' S S 'e' 'E' 'e' 'E' ''... S ''... '9' trt '' '9'... '' '9' S... '' '9' 'e' 'E' '-' '+'... 'e' 'E' '-' '+' SE '9' 'e' 'E' '-' '+' In thi newly reted DFA the input tring w = "e" tke the DFA to tte SE whih i n epting tte n thi "omplement" mhine. Lexil Anlyi Smple Exerie 9 Fll 6
20 Univerity of Southern Cliforni Computer Siene Deprtment Prolem Conider the lphet Σ = {,, }.. Conider the Non-Determiniti Finite Automton (NFA) depited elow. Why i thi utomton non-determiniti? Explin the vriou oure on indeterminy.. Do the entene w = nd w = elong to the lnguge generted y thi FA? Jutify.. Convert the NFA in prt ) to DFA uing the uet ontrution. Show the mpping etween the tte in the NFA nd the reulting DFA. d. By inpetion n you derive regulr expreion (RE) thi NFA detet?,, 4,, trt 6, Solution: ) Thi FA i non-determiniti for t let one of it tte there re two trnition on the me lel to two ditint tte. Thi i the e with tte where on '' the FA goe to tte nd 6. Similrly, tte nd exhiit the me ehvior. ) The entene w = elong to the lnguge epted y thi FA there i pth through tte, nd tht peel out thi ord nd tte i n epting tte. A to the word w = ny word tht egin with '' led to tte 4 whih i trp nd non-epting tte. A uh w doe not elong to the lnguge reognied y thi FA. ) A implified u-et ontrution i hown elow: S = -loure ({}) = {} thi i not finl tte. DFAedge(S, ) = -loure (goto(s, )) = {,6} = S DFAedge(S, ) = -loure (goto(s, )) = {4} DFAedge(S, ) = -loure (goto(s, )) = {4} DFAedge(S, ) = -loure (goto(s, )) = {4} = S = S = S DFAedge(S, ) = -loure (goto(s, )) = {,4} = S4 DFAedge(S, ) = -loure (goto(s, )) = {4,} = S DFAedge(S, ) = -loure (goto(s, )) = {4} DFAedge(S, ) = -loure (goto(s, )) = {4} DFAedge(S, ) = -loure (goto(s, )) = {4} = S = S = S DFAedge(S4, ) = -loure (goto(s4, )) = {4} = S DFAedge(S4, ) = -loure (goto(s4, )) = {4} = S DFAedge(S4, ) = -loure (goto(s4, )) = {,4} = S4 DFAedge(S, ) = -loure (goto(s, )) = {4} = S DFAedge(S, ) = -loure (goto(s, )) = {4,} = S DFAedge(S, ) = -loure (goto(s, )) = {4} = S Lexil Anlyi Smple Exerie Fll 6
21 Univerity of Southern Cliforni Computer Siene Deprtment In thi ontrution we hve implified the reulting DFA y mking the trnition etween tte {,6} on '' direlty move to tte 4 whih i trp or error tte. A more mehnil proedure would hve een the retion of n dditionl trp tte tht i equivlent to tte 4.,4,,6, 4,, trt 4,, d) By inpetion of the two pth from tte to either tte or tte we n immeditely ee tht the lnguge epted y thi FA n e deried y the regulr expreion RE = * *. Prolem Conider the lphet Σ = {,, }. Contrut DFA tht ept the following lnguge. Argue tht your DFA i miniml (with repet to the numer of tte) or ue the DFA minimition lgorithm to how tht tht i the e.. {w {,} w = n, w = m,m,n N}. {w {, } w = n, n N} nd w doen t ontin the utring Solution:. trt. 6, 7,, trt 4 Lexil Anlyi Smple Exerie Fll 6
22 Univerity of Southern Cliforni Computer Siene Deprtment Prolem Develop regulr expreion (RE) tht detet the longet tring over the lphet {-} with the following propertie:. The tring egin with n hrter nd end with hrter;. After the firt, the tring n inlude n lterntion of two uequene, nmely equene tht egin with hrter followed y ero or more hrter ending with n e hrter nd uequene tht egin with hrter ut doe not hve ny hrter until terminting t hrter.. If t ny point in the uequene there i x hrter, tht peifi equene i onidered terminted, i.e., the x t the e hrter in the firt type of equene nd the t hrter in the eond type of equene. 4. The two uequene nnot e neted ut n e repeted in ny lternting order. A n exmple the tring efghte i to e epted well the tring xfft Quetion: e. Develop regulr expreion tht pture the truture of the eptle tring deried ove. Ue hort-hnd to pture uet of hrter in the lphet o tht your deritpion nd the orreponding FA re kept hort. f. Uing the regulr expreion define in etion ) devie the orreponding Non-Determiniti Finite Automton (NFA) uing the Thompon ontrution deried in l. g. Convert the NFA in etion ) to DFA uing the uet ontrution. Show the mpping etween the tte in the NFA nd the reulting DFA. h. Minimie the DFA derived in etion ) (or how it i lredy miniml) uing the itertive refinement lgorithm deried in l. Solution: ) Among the mny poile olution for regulr expreion the one elow eem to e the mot intuitive. Here we ue the hort-hnd notstx for ll hrter in the lphet exept nd t i.e., notstx = {-r, u, v, y, }. RE =. [ (. ( * ). (x e) ) (. ( notstx * ). (x t) ) ] *. ) The NFA elow reflet the truture of the RE preented ove where we hve lo ompreed ome -trnition for revity, in prtiulr the one tht reflet Kleene loure nd lterntion trt 4 /{tx} ) The uet ontrution of thi NFA i hown elow where gin we hve merged trnition on hrter with nlogou ehvior. Lexil Anlyi Smple Exerie Fll 6
23 Univerity of Southern Cliforni Computer Siene Deprtment 7,9 trt,,,4,7,9 6,8,,,,4,,,,6,,,4,,4,,6 7 /tx 8, /tx d) The minimition of thi DFA uing the itertive refinement lgorithm i ummried elow. We egin y imple prtitionetween the epting tte nd the non-epting tte. Thi immeditely low u to iolte the epting tte 7. The eond prtition ued the hrter the dirimintig token howing tht tte,,,4,,,,6 nd,,,4,,4,,6 my e equivlent. The lt prtition digrm reflet the ft tht ll tte re dijoint. Lexil Anlyi Smple Exerie Fll 6
24 Univerity of Southern Cliforni Computer Siene Deprtment Lexil Anlyi Smple Exerie 4 Fll 6 P P P P6 P7 trt,,,4,7,9,,,4,,,,6 6,8, 7 7,9 /tx /tx 8,,,,4,,4,,6 P P P6 P7 trt,,,4,7,9,,,4,,,,6 6,8, 7 7,9 /tx /tx 8,,,,4,,4,,6 P8 P trt /tx /tx P P trt,,,4,7,9,,,4,,,,6 6,8, 7 7,9 /tx /tx 8,,,,4,,4,,6 P P trt,,,4,7,9,,,4,,,,6 6,8, 7 7,9 /tx /tx 8,,,,4,,4,,6 P trt,,,4,7,9,,,4,,,,6 6,8, 7 7,9 /tx /tx 8,,,,4,,4,,6
25 Univerity of Southern Cliforni Computer Siene Deprtment Prolem Given the DFA elow over the lphet {,} determine the following:. Ue the dynmi-progrmming Kleene lgorithm to derive the regulr expreion tht denote the lnguge epted y it. Mke ure your lelling of the DFA tte i orret nd tht the DFA i ompletely peified, i.e., eh tte h trnition on ll the lphet hrter.. Derie uintely wht re the word epted y thi DFA?, trt Solution:. Ue the dynmi-progrmming Kleene lgorithm to derive the regulr expreion tht denote the lnguge epted y it. Mke ure your lelling of the DFA tte i orret nd tht the DFA i ompletely peified, i.e., eh tte h trnition on ll the lphet hrter. Expreion for k = R = () R = () R = () R = Ø R = ( ) R = Ø R = Ø R = () R = ( ) Expreion for k = R = R (R )*R R = ()() * () () = () R = R (R )*R R = ()() * () () = () R = R (R )*R R = ()() * () () = () R = R (R )*R R = R = Ø R = R (R )*R R = R = ( ) R = R (R )*R R = R = Ø R = R (R )*R R = R = Ø R = R (R )*R R = R = () R = R (R )*R R = R = ( ) Lexil Anlyi Smple Exerie Fll 6
26 Univerity of Southern Cliforni Computer Siene Deprtment Expreion for k = R = R (R )*R R = (). ( ) *. Ø () = () R = R (R )*R R = (). ( ) *. ( ) () = ( + ) R = R (R )*R R = (). ( ) *. Ø () = () R = R (R )*R R = ( ) ( )* Ø Ø = Ø R = R (R )*R R = ( ) ( )* ( ) ( ) = ( * ) R = R (R )*R R = ( ) ( )* Ø Ø = Ø R = R (R )*R R = (). ( )*. Ø Ø = Ø R = R (R )*R R = (). ( )*. ( ) () = (). ()* R = R (R )*R R = (). ( )*. Ø ( ) = ( ) Expreion for k = R = R (R )*R R = (). ()*. Ø () = Ø R = R (R )*R R = (). ()*. (). ()* ( + ) R = R (R )*R R = (). ()*. ( ) () = (). ()* R = R (R )*R R = Ø. ()*. Ø Ø = Ø R = R (R )*R R = Ø. ()*. (). ()* ( * ) = ( * ) R = R (R )*R R = Ø. ()*. ( ) Ø = Ø R = R (R )*R R = ( ). ()*. Ø Ø = Ø R = R (R )*R R = ( ). ()*. (). ()* (). ()* = ()*. (). ()* R = R (R )*R R = ( ). ()*. ( ) ( ) = ()* The lnguge reognied y thi DFA n e expreed y the regulr expreion R. L = R = (). ( )*. ( ) = (). ( )* =.*. Derie uintely wht re the word epted y thi DFA? Thi utomton reognie ll inrie tring tht denote integer tht re non-negtive power of two nd uh n e deried y the ompt regulr expreion: *. Lexil Anlyi Smple Exerie 6 Fll 6
CSCI565 - Compiler Design
CSCI565 - Compiler Deign Spring 6 Due Dte: Fe. 5, 6 t : PM in Cl Prolem [ point]: Regulr Expreion nd Finite Automt Develop regulr expreion (RE) tht detet the longet tring over the lphet {-} with the following
More informationCompiler 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 informationCompiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
University of Southern Cliforni Computer Siene Deprtment Compiler Design Spring 7 Lexil Anlysis Smple Exerises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sienes Institute 47 Admirlty Wy, Suite
More informationCS 573 Automata Theory and Formal Languages
Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple
More informationNON-DETERMINISTIC FSA
Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is
More informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS
The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their
More informationMATH4455 Module 10 Evens, Odds and Ends
MATH4455 Module 10 Even, Odd nd End Min Mth Conept: Prity, Ple Vlue Nottion, Enumertion, Story Prolem Auxiliry Ide: Tournment, Undireted grph I. The Mind-Reding Clultor Prolem. How doe the mind-reding
More informationCS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6
CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized
More information4. UNBALANCED 3 FAULTS
4. UNBALANCED AULTS So fr: we hve tudied lned fult ut unlned fult re more ommon. Need: to nlye unlned ytem. Could: nlye three-wire ytem V n V n V n Mot ommon fult type = ingle-phe to ground i.e. write
More informationNondeterministic Automata vs Deterministic Automata
Nondeterministi Automt vs Deterministi Automt We lerned tht NFA is onvenient model for showing the reltionships mong regulr grmmrs, FA, nd regulr expressions, nd designing them. However, we know tht n
More informationProject 6: Minigoals Towards Simplifying and Rewriting Expressions
MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy
More informationWorked out examples Finite Automata
Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will
More informationNondeterministic Finite Automata
Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)
More informationSolutions Problem Set 2. Problem (a) Let M denote the DFA constructed by swapping the accept and non-accepting state in M.
Solution Prolem Set 2 Prolem.4 () Let M denote the DFA contructed y wpping the ccept nd non-ccepting tte in M. For ny tring w B, w will e ccepted y M, tht i, fter conuming the tring w, M will e in n ccepting
More information= state, a = reading and q j
4 Finite Automt CHAPTER 2 Finite Automt (FA) (i) Derterministi Finite Automt (DFA) A DFA, M Q, q,, F, Where, Q = set of sttes (finite) q Q = the strt/initil stte = input lphet (finite) (use only those
More informationFinite State Automata and Determinisation
Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions
More informationRegular 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 informationMinimal 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 informationis the cut off frequency in rads.
0 ELETRIAL IRUITS 9. HIGH RDER ATIVE FILTERS (With Tle) Introdution Thi development explin how to deign Butterworth (Mximlly Flt) or heyhev (Equl Ripple) Low P, High P or Bnd P tive filter. Thi tretment
More informationThoery 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 informationCSCI 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 informationRunning an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/
Running n NFA & the suset lgorithm (NFA->DFA) CS 350 Fll 2018 gilry.org/lsses/fll2018/s350/ 1 NFAs operte y simultneously exploring ll pths nd epting if ny pth termintes t n ept stte.!2 Try n exmple: L
More informationCS103B 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 informationHomework 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 informationNFA 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 informationTable 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 informationTutorial 2 Euler Lagrange ( ) ( ) In one sentence: d dx
Tutoril 2 Euler Lgrnge In one entene: d Fy = F d Importnt ft: ) The olution of EL eqution i lled eterml. 2) Minmum / Mimum of the "Mot Simple prolem" i lo n eterml. 3) It i eier to olve EL nd hek if we
More information1 From NFA to regular expression
Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work
More informationFirst 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 informationLet'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 informationTechnische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution
Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton:
More informationLecture 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 information2.4 Theoretical Foundations
2 Progrmming Lnguge Syntx 2.4 Theoretil Fountions As note in the min text, snners n prsers re se on the finite utomt n pushown utomt tht form the ottom two levels of the Chomsky lnguge hierrhy. At eh level
More informationAUTOMATA 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 informationRegular languages refresher
Regulr lnguges refresher 1 Regulr lnguges refresher Forml lnguges Alphet = finite set of letters Word = sequene of letter Lnguge = set of words Regulr lnguges defined equivlently y Regulr expressions Finite-stte
More informationPrefix-Free Regular-Expression Matching
Prefix-Free Regulr-Expression Mthing Yo-Su Hn, Yjun Wng nd Derik Wood Deprtment of Computer Siene HKUST Prefix-Free Regulr-Expression Mthing p.1/15 Pttern Mthing Given pttern P nd text T, find ll sustrings
More informationa b [^ab] ^a [^ab] [^ab]
Genertion of Pttern-Mtcing Algoritm y Extended Regulr Expreion Ikuo NAKATA 3 Summry. It i dicult to expre te denition of te comment of C lnguge in regulr expreion. However, te denition cn e expreed y imple
More informationCMSC 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 informationAssignment 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 information1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.
1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the
More informationConvert 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 informationThe Shortest Path Problem Graph Algorithms - 3
Algorithm Deign nd Anli Vitor Admhik C - pring Leture Feb, Crnegie Mellon Univerit The hortet Pth Problem Grph Algorithm - The hortet Pth Problem Given poitivel weighted grph G with oure verte, find the
More informationFABER 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 informationFirst 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 informationCSE 355 Homework Two Solutions
CSE 355 Homework Two Solution Due 2 Octoer 23, tart o cla Pleae note that there i more than one way to anwer mot o thee quetion. The ollowing only repreent a ample olution. () Let M e the DFA with tranition
More informationDeterministic 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 informationFormal 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 informationBi-quad filters realization on AIC Codecs
pplition Report pril Bi-qud filter reliztion on IC Code HP Softwre BSTRCT Thi pplition report provide informtion regrding filter eqution nd o-effiient formt repreenttion tht n e ued to relize digitl filter
More informationTypes 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 informationCS 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 informationTypes 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 information1 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 information1. 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 informationCMPSCI 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 informationAlpha Algorithm: Limitations
Proess Mining: Dt Siene in Ation Alph Algorithm: Limittions prof.dr.ir. Wil vn der Alst www.proessmining.org Let L e n event log over T. α(l) is defined s follows. 1. T L = { t T σ L t σ}, 2. T I = { t
More informationCompiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
Compiler Design Spring 2011 Lexical Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292 pedro@isi.edu
More informationTOPIC: LINEAR ALGEBRA MATRICES
Interntionl Blurete LECTUE NOTES for FUTHE MATHEMATICS Dr TOPIC: LINEA ALGEBA MATICES. DEFINITION OF A MATIX MATIX OPEATIONS.. THE DETEMINANT deta THE INVESE A -... SYSTEMS OF LINEA EQUATIONS. 8. THE AUGMENTED
More informationCS415 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 informationBottom-Up Parsing. Canonical Collection of LR(0) items. Part II
2 ottom-up Prsing Prt II 1 Cnonil Colletion of LR(0) items CC_LR(0)_I items(g :ugmented_grmmr){ C = {CLOURE({ })} ; repet{ foreh(i C) foreh(grmmr symol X) if(goto(i,x) && GOTO(I,X) C) C = C {GOTO(I,X)};
More informationChapter 4 State-Space Planning
Leture slides for Automted Plnning: Theory nd Prtie Chpter 4 Stte-Spe Plnning Dn S. Nu CMSC 722, AI Plnning University of Mrylnd, Spring 2008 1 Motivtion Nerly ll plnning proedures re serh proedures Different
More informationFormal 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 informationGrammar. 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 informationCS 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 informationCS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014
S 224 DIGITAL LOGI & STATE MAHINE DESIGN SPRING 214 DUE : Mrh 27, 214 HOMEWORK III READ : Relte portions of hpters VII n VIII ASSIGNMENT : There re three questions. Solve ll homework n exm prolems s shown
More informationDesigning 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 informationThe 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 informationMyhill-Nerode Theorem
Overview Myhill-Nerode Theorem Correspondence etween DA s nd MN reltions Cnonicl DA for L Computing cnonicl DFA Myhill-Nerode Theorem Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute
More informationTest Generation from Timed Input Output Automata
Chpter 8 Test Genertion from Timed Input Output Automt The purpose of this hpter is to introdue tehniques for the genertion of test dt from models of softwre sed on vrints of timed utomt. The tests generted
More informationJava II Finite Automata I
Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression
More informationCS241 Week 6 Tutorial Solutions
241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.
More informationMath 2142 Homework 2 Solutions. Problem 1. Prove the following formulas for Laplace transforms for s > 0. a s 2 + a 2 L{cos at} = e st.
Mth 2142 Homework 2 Solution Problem 1. Prove the following formul for Lplce trnform for >. L{1} = 1 L{t} = 1 2 L{in t} = 2 + 2 L{co t} = 2 + 2 Solution. For the firt Lplce trnform, we need to clculte:
More informationCSE 401 Compilers. Today s Agenda
CSE 401 Compilers Leture 3: Regulr Expressions & Snning, on?nued Mihel Ringenurg Tody s Agend Lst?me we reviewed lnguges nd grmmrs, nd riefly strted disussing regulr expressions. Tody I ll restrt the regulr
More informationEECS 141 Due 04/19/02, 5pm, in 558 Cory
UIVERSITY OF CALIFORIA College of Engineering Deprtment of Electricl Engineering nd Computer Sciences Lst modified on April 8, 2002 y Tufn Krlr (tufn@eecs.erkeley.edu) Jn M. Rey, Andrei Vldemirescu Homework
More informationCompiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro Diniz
Compiler Design Spring 2010 Lexical Analysis Sample Exercises and Solutions Prof. Pedro Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292 pedro@isi.edu
More informationClosure 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 informationCounting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs
Isomorphism of Grphs Definition The simple grphs G 1 = (V 1, E 1 ) n G = (V, E ) re isomorphi if there is ijetion (n oneto-one n onto funtion) f from V 1 to V with the property tht n re jent in G 1 if
More informationEE Control Systems LECTURE 8
Coyright F.L. Lewi 999 All right reerved Udted: Sundy, Ferury, 999 EE 44 - Control Sytem LECTURE 8 REALIZATION AND CANONICAL FORMS A liner time-invrint (LTI) ytem cn e rereented in mny wy, including: differentil
More informationSystem Validation (IN4387) November 2, 2012, 14:00-17:00
System Vlidtion (IN4387) Novemer 2, 2012, 14:00-17:00 Importnt Notes. The exmintion omprises 5 question in 4 pges. Give omplete explntion nd do not onfine yourself to giving the finl nswer. Good luk! Exerise
More informationCS 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 informationLecture 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 informationCoalgebra, Lecture 15: Equations for Deterministic Automata
Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined
More informationMid-Term Examination - Spring 2014 Mathematical Programming with Applications to Economics Total Score: 45; Time: 3 hours
Mi-Term Exmintion - Spring 0 Mthemtil Progrmming with Applitions to Eonomis Totl Sore: 5; Time: hours. Let G = (N, E) e irete grph. Define the inegree of vertex i N s the numer of eges tht re oming into
More informationInstructions. An 8.5 x 11 Cheat Sheet may also be used as an aid for this test. MUST be original handwriting.
ID: B CSE 2021 Computer Orgniztion Midterm Test (Fll 2009) Instrutions This is losed ook, 80 minutes exm. The MIPS referene sheet my e used s n id for this test. An 8.5 x 11 Chet Sheet my lso e used s
More informationFinite 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 informationAP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals
AP Clulus BC Chpter 8: Integrtion Tehniques, L Hopitl s Rule nd Improper Integrls 8. Bsi Integrtion Rules In this setion we will review vrious integrtion strtegies. Strtegies: I. Seprte the integrnd into
More information@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata
g Text Serh @#? ~ Mrko Berezovský Rdek Mřík PAL 0 Nondeterministi Finite Automt n Trnsformtion NFA to DFA nd Simultion of NFA f Text Serh Using Automt A B R Power of Nondeterministi Approh u j Regulr Expression
More informationp-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 informationHadamard-Type Inequalities for s-convex Functions
Interntionl Mthemtil Forum, 3, 008, no. 40, 965-975 Hdmrd-Type Inequlitie or -Convex Funtion Mohmmd Alomri nd Mlin Dru Shool o Mthemtil Siene Fulty o Siene nd Tehnology Univeriti Kebngn Mlyi Bngi 43600
More informationCSCI 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 information22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:
22: Union Fin CS 473u - Algorithms - Spring 2005 April 14, 2005 1 Union-Fin We wnt to mintin olletion of sets, uner the opertions of: 1. MkeSet(x) - rete set tht ontins the single element x. 2. Fin(x)
More information3 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 informationActivities. 4.1 Pythagoras' Theorem 4.2 Spirals 4.3 Clinometers 4.4 Radar 4.5 Posting Parcels 4.6 Interlocking Pipes 4.7 Sine Rule Notes and Solutions
MEP: Demonstrtion Projet UNIT 4: Trigonometry UNIT 4 Trigonometry tivities tivities 4. Pythgors' Theorem 4.2 Spirls 4.3 linometers 4.4 Rdr 4.5 Posting Prels 4.6 Interloking Pipes 4.7 Sine Rule Notes nd
More informationIntermediate 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 informationState Complexity of Union and Intersection of Binary Suffix-Free Languages
Stte Complexity of Union nd Intersetion of Binry Suffix-Free Lnguges Glin Jirásková nd Pvol Olejár Slovk Ademy of Sienes nd Šfárik University, Košie 0000 1111 0000 1111 Glin Jirásková nd Pvol Olejár Binry
More information6.5 Improper integrals
Eerpt from "Clulus" 3 AoPS In. www.rtofprolemsolving.om 6.5. IMPROPER INTEGRALS 6.5 Improper integrls As we ve seen, we use the definite integrl R f to ompute the re of the region under the grph of y =
More informationAlgorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:
Eidgenössishe Tehnishe Hohshule Zürih Eole polytehnique fédérle de Zurih Politenio federle di Zurigo Federl Institute of Tehnology t Zurih Deprtement of Computer Siene. Novemer 0 Mrkus Püshel, Dvid Steurer
More informationConverting 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 informationGM1 Consolidation Worksheet
Cmridge Essentils Mthemtis Core 8 GM1 Consolidtion Worksheet GM1 Consolidtion Worksheet 1 Clulte the size of eh ngle mrked y letter. Give resons for your nswers. or exmple, ngles on stright line dd up
More informationName 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 informationTrigonometry Revision Sheet Q5 of Paper 2
Trigonometry Revision Sheet Q of Pper The Bsis - The Trigonometry setion is ll out tringles. We will normlly e given some of the sides or ngles of tringle nd we use formule nd rules to find the others.
More information