= state, a = reading and q j

Size: px
Start display at page:

Download "= state, a = reading and q j"

Transcription

1 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 symols whih rete prtiulr string) F Q = the set of finl stte (Finl stte n e (no finl stte) or more thn or it n hve ll sttes s finl sttes. = trnsition funtion (responsile for mking the trnsition/movement from one stte to other stte If mhine hlt t ny finl stte tht mens it is epting tht string nd if it hlts t ny other stte it simply rejets the string. Note: Behviour of the mhine is ontrolled y responsle for swithing of stte from one to other stte. : Q Q where, Q = input stte, = input lphet e.g. q i, q j where, q i = stte, = reding nd q j = move to other stte Note: Deterministi (extly one hoie) (If you re t stte of red the input then fter tht you hve to do the movement) Totl : On every stte we need to define the trnsition for every symol of input lphet i.e. we need to explin expliitly tht where you wnt go fter reding input. Nottions: (i) Stte : q i (ii) Initil stte : q (iii) Finl stte : q s whenever, initil stte eomes finl stte, null string is epted. Note: (i) * q * 2 3,,,,... (ii) q i Therefore, totl q Therefore,, 2, 3,... (iii) q,, *,,, 2, 2,,... (universl lnguge)

2 Finite Automt 5 (iv) q, q i, 2 2,,,,,,... (v) q (not finl, so n t ept ()) q i (vi) q q (vii) 2 n L n n L n is even # n L n mod 2 q q i All the lnguge re sme L,,,,... 2n L n n L n is odd # L,,,,... n L n mod 2 Although given FA orresponds to only one lnguge, given lnguge n hve mny FAs tht ept it. Note tht you must lwys e reful out the empty string: should the FA ept or not. In the preeding exmple, the empty string is epted euse the strt stte is lso n ept stte. Another useful tehnique is rememering speifi symols. In the next exmple you must forever rememer the first symol; so the FA splits into two piees fter the first symol.

3 6 Finite Automt SOLVED PROBLEMS. Construt the DFA for the following m n * * (i) L m, n n (ii) L n nd n 4 n (iii) L n mod 5 2 (iv) L w * w mod 7 (i) q 2 3,,,... Therefore, q 2 3,,,..., 2, 2 2, 2... q i Therefore, q q i (Totl onept follow, we need to define eh nd every stte expliity in DFA). n (ii) L n nd n ,,,,,,... q q q q 4 q 5 Therefore, 5 finl stte, non-finl stte n (iii) mod 5 2 L n,, 2,3, 4 Therefore, totl 5 sttes., q q (iv) L w * w mod 7 m w n mod 7 q 4 w n,, 2,3, 4,5,6 Totl 7 sttes

4 Finite Automt q q q 4 q L2 m n p m, n, p q 6 q q,, 3. Design DFA for the following lnguge: (Set of ll inry strings whih strts with ) w w, * Temp,, q q q 4,, 4. Design DFA tht ends with q q q 5 q 4 5. Design DFA for the following over, (i) The set of ll strings ontining extly 3 s. q q Trp (,)

5 8 (ii) Atlest 3 s: (iii) Atmost 3 s:, q q, q q (,) Finite Automt Trp (4th ) Trnsition tle/tulr : It is mtrix tht lists the new stte given the urrent stte nd the symol red. Exmple : Trnsition tle for the FA tht epts ll inry strings tht egin nd end with the sme symol. Input S A C A A B B A B Stte C D D D C C q q q q q q q q 2 3 q q q 2 4 q q q 3 2 q q q q 4 Exmple: The smllest DFA epts the lnguge L = * q, q, x,, length of n is multiple of 3. () 2 () 3 () 4 (d) 5 () Exmple: Consider the mhine M [GATE-22] [GATE-25] The lnguge reognized y ove mhine is: () * w, / every in w, is followed y extly two 's () * w, every in w, is followed y t lest two 's () * w, w ontins the sustring '',

6 Finite Automt (d) * w, w does not ontin '' s sustring () Comining the mhines: 9 M M 2 L omplement of FSM I = the mhine of lnguge L is given O = the mhine of lnguge L Steps: L L 2 (i) Mke the finl sttes to non-finl sttes nd (ii) Non-finl sttes to finl sttes (Finl non-finl) Prolem: Design DFA whih epts the set of ll inry string whih does not strts with. q q q 4 (, ) Temp, q q q 4 (, ) q 5, * Prolem: Design DFA for L w N w w, is even AND N is even A B C D L L L L2 m n A B ; C C. Therefore, BC Here, first we will hek tht on A stte, s we red we move to B on C stte, s we red we move to C. Therefore, AC stte omplex move to BC stte.

7 2 Finite Automt A A ; C D B B B A D C C C B B B A D C D D AC AD BC BD A A A B D C D B If L mhine hve m stte nd L 2 mhine hve n stte, then the omined mhine L m n stte. If the OR opertion is pplied then * L w, N w is even OR N w is even L 2 h v e A L B C L 2 Therefore, the numer of finl sttes will hnge. As here, A nd C re finl stte, so where the A nd C ome, it will eome finl stte D AC AD BC L L w w L nd w L 2 2 BD So, L is finl nd L 2 is non finl > L nd L 2 L L BC will e finl. If 2 L L L L L L L L = AD nd BC oth will e finl sttes. 2 Non-Deterministi Finite Automt (NFA) A mhine, M Q, q,, F, Where, q Q = the set of sttes (finite) Q = initil/strting stte = input lphet (finite)

8 Finite Automt F Q = finl stte is the suset of Q = trnsition funtion responsile for moving the movement from one stte to nother stte. DFA Q Q totl in this null trnsition is not llowed. Q 2 Q power set of Q NFA Q Power of set Q, 2 PQ, q, q, q, q Q q,q In NFA we hve zero () hoie, one hoie, or more thn one hoie depending upon the sttes, so it is lled non-deterministi. Trnsition in NFA : 2 q j q j q i q k q i q k e.g. q q For * * e.g. q q Also for * * Note: If in DFA, ll the sttes re finl sttes, then lnguge is onsidered s universl lnguge. *, lnguge (like **). *. But, in NFA, if ll the sttes re finl sttes then it is not neessry tht it is universl Design NFA for ***: () q q q (2) OR q q q q q q In NFA, trp stte is not onsidered euse if trnsition is not defined for prtiulr I/P symol or stte, then given string is rejeted utomtilly through the mhine i.e. hek for. e.g. q q f The mhine rejets. or q q f Prolem: Design n NFA over, epting the set of ll inry strings ending with., q q q f Here, we need not to think out other trnsitions. q k

9 22 e.g. Finite Automt, Strt with q q q f, Contining s sustrings, q q q f 4th symol from the eginning is., q q, q f,,, Minimum numer of sttes y NFA is n 4th symol from the ending is. (Minimum sttes), q q q, 2 q q f, 3, Prolem: Design NFA over, epting the set of ll inry strings whih strt nd end with different symol., q q q 4, Note: We n onstrut the sme NFA through more thn one mhine, ut we pply the shortest sttes NFA. Prolem: Define NFA tht epts ll inry strings where the lst symol is or whih ontin only s? Here is one: A B C D, * Prolem: Define NFA for *,

10 Finite Automt 23 Conversion of NFA to DFA:. Eh stte is given y set of sttes from the originl. 2. Strt stte is leled{q } where q ws originl strt stte. 3. While (some stte of DFA is missing trnsition) do: Compute the trnsition y omining the possiilities for eh symol in the set. 4. Mke into ept stte ny set tht ontins t lest one originl ept stte. The following DFA is the result of pplying the preeding lgorithm to the NFA in figure elow. B A D,, C For exmple, onsider the stte {A, B, D}. On, the NFA, if in stte A, n go to sttes A or C, if in stte B dies, nd if in stte D stys in stte D. Thus, on the DFA goes from {A, B, D} to {A, C, D}. Both of these re ept sttes euse they ontin D. AB ABD A AC If there re -trnsitions, then you hve to djust the proess slightly. Do the following: (i) The strt stte eomes the old strt stte nd every stte rehle from there y -trnsitions. (ii) When one lultes the sttes rehle from stte, one inludes ll sttes rehle y -trnsitions fter the destintion stte. This is the result of pplying the preeding lgorithm to the NFA given in figure elow. ACD A B C D, The strt stte onsists of A nd the two sttes you n reh y trnsitions, the stte is thus {A, B, C}

11 24 Finite Automt ABC CD AC C Finite Automt with Output pility: There re two mhine doesn t hve finl sttus. These oth mhines hve the output pity. Mely Mhine: A mely mhine, M is 6 tuple system M Q,q,,,, ' Where, Q = the set of sttes (finite) q Q = initil/strt stte = input lphet, = output lphet, = trnsition funtion responsile for mking the movement/trnsition from one stte to nother stte. ' = output funtion resonsile for produing n output orresponding to every trnsition. Note: In mely mhine for eh is trnsition the output will e generted. Q Q totl orresponding the every trnsition, there is n output ' Q Prolem: Design mely mhine whih find the omplement of inry string. If input is the output/input is nd vie vers. / q / Prolem: Design mely mhine whih inrements the given inry numer y Assume, reding of symols should e from right to left. (/) / q q (, ) / / / OR q q / (/)

12 Finite Automt 25 Prolem: Design mely mhine to dd two inry numer A B Ssum Crry Moore Mhine: A moore mhine, / / / / / No / rry rry / M Q,q,,,, ' Output pility Different from mely mhine in only wy tht they produe the output All omponents re similr like mely mhine Input = string Output = string Contin those set of terminls from whih the output string n e mde So, it my e possile tht (input string is sme s output string) In se of mely mhine, there is n output orresponding to every trnsition ' Q But in se of Moore mhine, there is n output orresponding to every stte ': Q Prolem: Design Moore mhine tht ount the ourene of in inry string. (Numer of times is ville in the string). (It will not ounted seond time) / So, now we will ount the numer of s Therefore, 2(2 times ome) q/ q/ q/ 2 q/ 3 Mely Mhine: Input string w w n then output string = n Moore Mine: Input string w w n then output string n Prolem: Design Moore mhine whih finds the reminder of deiml representtion of inry numer when divided y 3. Reminder,, 2,... inry

13 26 Finite Automt q/ q/ q/2 2 Note: Mely mhine nd Moore mhines re eqully powerful. Moore to Mely mhine (Conversion): (Moore) (Mely) / q / / 2 2 2/ q 2 Note: We need to tth the prtiulr stte output to every trnsitin whih is oming to it. Exmple: q / q / / / (Moore) / / / / q / q / q 2/ q 3/ / / / (Mely) / Mely to Moore (Conversion): / (Mely mhine) (Mely mhine) / q i / q i/ / / When there re two different output, we need to split the stte into two, s there re two output. When ll the inoming trnsition output re sme then we need not to split the stte, we just simply put tht trnsition output into the stte output. q / i /

14 Finite Automt Exmple: 27 / q i / (Mely) q i/ / / / (Need to onnet oth the sttes) Exmple: q / (Mely) / q q / i / / Deision Properties: () Finiteness/Infiniteness (2) Emptyness/non-emptyness (3) Equlness / q/ (Mely). Finiteness / Infiniteness: The steps to hek the ondition re s follows: () Selet the stte whih n t e rehed y the initil stte nd delete them. () Selet those sttes from whih we n t reh to finl stte nd delete them. () If the resulting mhine is free from yles nd self loops then the mhine epts finite lnguge else the mhine epts infinite lnguge. Exmple: q q, q 4 ontins yle so epts infinite lnguge. Exmple: q/ q/ q q, q q q q q 4 No yle or self loop so ept finite lnguge

15 28 Finite Automt 2. Emptyness/non-emptyness: The steps to hek the ondition is given elow () Selet the stte whih n t e rehed from the initil stte nd delete them. () If the resulting mhine is free from finl stte then it will ept empty lnguge otherwise non-empty lnguge Exmple: q q, The mhine doesn t ontin finl stte so epts empty lnguge. Exmple: q q q q q q,,, The mhine ontins finl stte so epts non-empty lnguge. 3. Equlness: Two finite stte mhines M nd M 2 re sid to e equl if oth mhines epts sme set of strings i.e. M M2 L M L M2 Equl mhines need not to ontin sme set of sttes Two mhines M nd M 2 re sid to e isomorphi to eh other if oth of them epts sme lnguge ontins sme numer of sttes hve the sme properties. Steps to hek the equlness of two mhine is given elow: () Construt the trnsition tle tht ontins pir of initil sttes (P, Q) where, P is from mhine M nd Q is from mhine M 2. () Construt the trnsition tle () In the onstrution proess, we get ny pir of the form (finl, non-finl) or (non-finl, finl), stop onstruting the tle nd delres tht the mhines re not equl else fter ompletion of the tle if no suh ondition generted the mhines re equl. Exmple: if M : A B 2 P Q R M : C D A, P A, P C,Q C,Q D, R A, P D,R B, R D, R B,R D,Q A,R Stte (A, R) is (finl, non-finl) so oth the mhines re not equl.

16 Finite Automt Minimiztion of Finite Automt: The proess of deletion nd elimintion of sttes whose presene or sene will not effet the lnguge of the mhine is lled minimiztion/optimiztion of FA. We strt with two exmples. Consider the utomton on the left: 29 2 We n see tht it is not possile to ever visit stte 2. Sttes like this re lled unrehle. We n simply remove them from the utomton without hnging its ehviour. (This will e, indeed, the first step in our minimiztion lgorithm.) In our se, fter removing stte 2, we get the utomton on the right. As it turns out, however, removing unrehle sttes is not suffiient. The next exmple is it more sutle (see the utomton on the left)., 2 2 We now formlize the ove ide. Let A e finite utomton. We will sy tht * w distinguishes etween two sttes p,q Q if either p, wf & q, w F, or p, w F & q, w F. Two sttes p,q Q re lled distinguishle iff there is word tht distinguishes etween them. Sttes tht re indistinguishle will lso e sometimes lled equivlent. Lemm-: Suppose tht B is DFA without unrehle sttes. Then B is minimum if nd only if ll pirs of sttes re distinguishle. Lemm-2: Stte indistinguishility is n equivlene reltion. Lemm-3: Let p, p' nd q, q '. Then, if p ',q ' distinguishle then so re p, q. To minimize A, fter removing unrehle sttes, we will find the equivlene lsses of the indistinguishility reltion nd join ll sttes in eh lss into one stte of the new utomton A. To determine trnsitions, if X is n equivlene lss, we pik ny q X nd define X, Y where Y is the equivlene lss tht ontins q,. To determine whih sttes re equivlent, we will use the following method. Insted of trying to figure out whih sttes re indistinguishle, we will try to figure out whih sttes re distinguishle. Clerly, if p F nd q F then p, q re distinguishle, sine they n e distinguished y. Then we itertively exmine ll pirs of sttes. For eh pir p, q we do this. If we find symol, suh tht p,q nd q, re distinguishle, then we mrk p, q s distinguishle s well. We iterte this untill no more pirs re mrked. When we re done, the non-mrked pirs re equivlent. The omplete lgorithm is given elow.

17 3 Finite Automt Minimizing the Numer of Sttes of DFA: The following three sttements re equivlent:. The set L * is epted y some finite utomton. 2. L is the union of some of the equivlene lsses of right invrint equivlene reltion of finite index. 3. Let equivlene reltion R L e defined y: xr L y if nd only if for ll z in *, xz is in L extly when yz is in L. Then R L is of finite index. Myhill Nerode Theorem: Let A e ny lnguge over * we sy tht string x nd y in * re indistinguishle y A if for every string * z either oth xz nd yz re in A or oth : xz nd yz re not in A. If the numer of suffix of lnguges is finite (x) then Lnguge L is regulr The minimum DFA of L needs tlest k sttes. Exmple: Let L e the lnguge **. L is peted y the DFA. Consider the reltion RM defined y M. As ll sttes re rehle from the strt stte, R M hs six equivlene lsses, whih re * C, C *, C *, C ** C *, C ** * L is the union of three of these lsses, C, C d nd C e. The reltion R L for L hs xr L y, if nd only if either (i) x nd y eh hve no s. d e f Strt e d f, M DFA M epting L. C C C C 2 C d C C =C 3 f C e Digrm showing R is refinement of R. L (ii) x nd y eh hve one, or (iii) x nd y eh hve more thn one. For exmple, if x = nd y =, then xz is in L if nd only if z is n *. But yz is in L under extly the sme onditions. As nother exmple, if x = nd y =, then we might hoose z = to show tht xr L y is flse. Tht is, xz = is in L, ut yz = is not. We my denote the three equivlene lsses of R L y C = *, C 2 = **, nd C 3 = **(+)*. L is the lnguge onsisting of only one of these lsses, C 2. The reltionship of C,..., C f to C, C 2, nd C 3 * is illustrted, in figure. For exmple C C * * C. From RL we my onstrut DFA s follows. Pik representtives for C, C 2 nd C 3, sy, nd. Then let M ' e the DFA shown in figure. For exmple, ', [] is C ), sy i j, then w is i j, whih is lso in C = **., sine if w is ny string in () (note

18 Finite Automt Minimiztion Algorithm: Step-I: Remove unrehle sttes. Step-II: Mrk the distinguishle pirs of sttes. To hieve this tsk, we first mrk ll pirs p, q where p F nd q F s distinguishle. Then, we proeed s follows. repet for ll non-mrked pirs p, q do for eh letter do then mrk p, q untill no new pirs re mrked. if the pir p,, q, is mrked. Step-III: Construt the redued utomton Â. We first determine the equivlene lsses of the indistinguishility reltion. For eh stte q, the equivlene lss of q onsists of ll sttes p for whih the pir p, q is not mrked in Step-II. The sttes of  re the equivlene lsses. The initil stte ˆq is this equivlene lss tht ontins q. The finl sttes ˆF re these equivlene lsses tht onsist of finl sttes of A. The trnsition funtion ˆ is defined s follows. To determine ˆ X,, for some equivlene lss X, pik ny q X Y is the equivlene lss tht ontins q,. Exmple of minimiztion of DFA: nd set ˆ X, 3 Y, B,, AE, A C, AD Step-: Unrehle sttes in ove digrm: F nd G re unrehle sttes, So, we will remove them. So, now the DFA will look like F G B,, A C, AD, AE Step-2: Now, we will proeed to TABLE FILLING PROCESS Note: Vertilly we will red B, C, D, E (not A (first element) Horizontlly we will red A, B, C, D (not E element) So, in this tle we will fill those sttes with x (ross-mrks) whih re distinguishle

19 32 Finite Automt B C D E A B C D (Here, E nd A re distinguishle, so, we hve to put x ross-mrk in there ommon ox). Similrly, in others. Now, the trnsition funtion is onsidered to find out nother wy of distinguishle stte nd it helps to fill the remining prtiulr stte in the tle. So, A, C, B Distinguishle stte D A, C Distinguishle stte C, D A, B Distinguishle stte B, D A, B Distinguishle stte B, D B C D Non-distinguishle stte B, D Distinguishle stte C, D E A B C D D, E Distinguishle stte E, E D, E Distinguishle stte E, E As in the ove tle, we will merge B nd C nd D nd E euse they oth re the non-distinguishle stte. A BC D,E,, (Minimised DFA) Lnguge epting this : e.g ,, -NFA NFA with moves :, L / * The NFA whih hs trnsition even for empty string is lled NFA. It is 5 tuple system Q,q,,, F everything is similr to NFA exept the trnsition funtion whih is given s : Q 2 Q

20 Finite Automt Cpility of NFA is sme s NFA nd DFA. NFA provide progrmming onviniene. 33 e.g. q q Convert NFA with λ trnsition into its equivlent DFA: -lousere q : q q (NFA) The set of ll sttes rehle from q y tking trnsitions inluding q -losure q q,q,q 2 -losure q q,q -losure q 2 q 2 2 Firstly: We will onsider q s the initil stte of n equivlent DFA i.e. q,q,q 2 Now, we need to tell ll the trnsitions,, with respet to initil stte of -losure q If we red t q : q,q,q, -losure q, -losure q, -louser q, 2 2 If we red t q then -losure q -losure -losure q, q, q 2 q,q,q, -louser q, -louser q, -louser q, 2 2 -louser -louser q -louser q, q If we red then t -louser q 2 q,q,q, -louser q q Now, we red for q,q -louser q, trp stte 2 Red for q,q red 2 2 q,q, -louser q q,q 2 2 q,q, losureq q Red t -louser red red q, trp stte 2 q, trp stte 2 initil stte.

21 34 q, -losuer q q Finite Automt,, q, q, q 2 q, q2 trp, [Equivlent DFA with trnsitions]

22 Finite Automt SOLVED PROBLEMS 35. Stte True or Flse with one line explntion. A FSM (Finite Stte Mhine) n e designed to dd two integers of ny ritrry length (ritrry numer of digits). [GATE-994] FALSE, A FSM (Finite Stte Mhine) n t e desgined to dd two integers of ny ritrry length euse FSM hve finite memory nd n t store integer of ny ritrry length. 2. A finite stte mhine with the follows stte tle hs single input X nd single output Z. Ans. present stte next stte, z next stte, z x x A D, B, B B, C, C B, D, D B, C, It the initil stte is unknown, then the shortest input sequene to reh the finl stte C is () () () (d) () The stte digrm whih represents the given stte tle is [GATE-995] / / A B / / / / / D C / From stte A to reh C, the shortest sequene is A B C A D C From B to reh C B C B B C From C to reh C C D C C B C From D to reh C D C D B C So is the shortest input sequene to reh the finl stte C, whtever e the initil stte.

23 36 3. Whih of the following set n e reognized y Deterministi Finite stte Automton? () The numers, 2, 4, 8,... 2 n,... written in inry () The numers, 2, 4,... 2 n,... written in unry () The set of inry string in whih the numer of zeros is the sme s the numer of ones (d) The set {,,,,...} Ans. () The numers, 2, 4, 8,..., 2 n... re represented y,,,,... The pttern in the regulr expression is followed y s. The regulr expression for ove is * The DFA for ove lnguge is q q Finite Automt [GATE-998], So the numers, 2, 4, 8,..., 2 n... written in inry n e reognized y deterministi finite stte utomton. 4. Let L e the set of ll inry strings whose lst two symols re the sme. The numer of sttes in the minimum stte deterministi finite stte utomton epting L is () 2 () 5 () 8 (d) 3 [GATE-998] Ans. () The numer of sttes in the minimum stte deterministi finite stte utomton epting ll inry strings whose lst two symols re the sme is 5. B C A D 5. Consider the regulr expression ( + ) ( + )...n times. The minimum stte finite utomton tht reognizes the lnguge represented y this regulr expression ontins () n sttes () n + sttes () n + 2 sttes (d) None of these [GATE-999] Ans. () The minimum stte finite utomton tht reognizes the lnguge represent y regulr expression ( + ) ( + )... n times is n +. The lnguge ontins strings with extly length n. (n + ) sttes re required to ount length upto n. No trp stte is required sine we re mking miniml FA, not miniml DFA. For exmple, for n = 2 the design is shown elow. q, q, E

24 Finite Automt Given n ritrry non-deterministi finite utomton (NFA) with N sttes, the mximum numer of sttes in n equivlent minimized DFA is t lest [GATE-2] () N 2 () 2 N () 2N (d) N! Ans. () For n ritrry NFA with N sttes, the mximum numer of sttes in n equivlent minimized DFA is 2 N. 7. Consider DFA over {, } epting ll strings whih hve numer of s divisile y 6 nd numer of s divisile y 8. Wht is the mximum numer of sttes tht the DFA will hve? [GATE-2] () 8 () 4 () 5 (d) 48 Ans. (d) A DFA over = {, } epting ll strings whih hve numer of s divisile y 6 nd numer of s divisile y 8 is grid mhine (produt utomt) hving 6 8 = 48 sttes. 8. The finite stte mhine desried y the following stte digrm with A s strting stte, where n r lel is x/y nd x stnds for -it input nd y stnds for 2-it output / A B C / / / / / Ans. () Outputs the sum of the present nd the previous its of the input () Outputs whenever the input sequene ontins () Outputs whenever the input sequene ontins (d) None of the ove [GATE-22] () The stte digrm represents the FSM whih outputs the sum of the present nd previous its of the input. Stte A represents lst it nd B nd C represents lst it is. 9. The smllest finite utomton whih epts the lnguge L = {x length of x is divisile y 3} hs () 2 sttes () 3 sttes () 4 sttes (d) 5 sttes [GATE-22] Ans. () The miniml finite utomton with 3 sttes whih epts the lnguge L = {x length of x is divisile y 3} is s follows: q,, q,. Consider the following deterministi finite stte utomton M., Let S denote the set of seven it inry strings in whih the first, the fourth, nd the lst its re. The numer of strings in S tht re epted y M is () () 5 () 7 (d) 8 [GATE-23]

25 38 Ans. () The given it pttern n e represented s: Finite Automt The four lnks n e filled in 2 4 = 6 wys. Therefore there re 6 suh strings in this pttern. Not ll of these re epted y the mhine. The strings nd its eptne is given elow: epted Only these seven strings given ove re epted. The other strings (9 of them) in this pttern re rejeted, sine they dont rehed the finl stte.. Consider the NFA M shown elow: q, Ans., Let the lnguge epted y M e L. Let L e the lnguge epted y the NFA M, otined y hnging the epting stte of M to non-epting stte nd y hnging the non epting stte of M to epting sttes. Whih of the following sttements is true? [GATE-23] () L {,}* L () L {,}* () L L (d) L L () The given mhine M is q, q, Now the omplementry mhine M is q,, q

26 Finite Automt In the se of DFA, L(M) L(M) ut in the se of NFA this is not true. In ft L(M) nd L(M) hve no onnetion. To find L L(M) we hve to look t M nd diretly find its lnguges. L L(M) ( ) ( )*... ( )*... ( )*. 2. Let M (K,,, s, F) e finite stte utomton, where K {A, B}, {, }, s A, F {B}, (A, ) A, (A, ) B, (B, ) B nd (B, ) A nd (B, ) A A grmmr to generte the lnguge epted y M n e speified s G (V,, R, S), where V K, nd S A. Whih one of the following set of rules will mke L(G) () {A B, A A, B A, B A, B ) () {A A, A B, B B, B A, B ) () {A B, A B, B A, B A, B ) (d) {A A, A A, B B, B A, A ) Ans. () (A, ) A, A A (A, ) B, A B (B, ) B, B B (B, ) A, B A B is finl stte, so B. L(M)? 39 [GATE-24] 3. The following finite stte mhine epts ll those inry strings in whih the numer of s nd s re respetively. () divisile y 3 nd 2 () odd nd even () even nd odd (d) divisile y 2 nd 3 [GATE-24] Ans. () The given finite stte mhine epts ny string w (, )* in whih the numer of s is multiple of 3 nd the numer of s is multiple of Consider the non-deterministi finite utomton (NFA) shown in the figure. Y X Z

27 4 Ans. Finite Automt Stte X is the strting stte of the utomton. Let the lnguge epted y the NFA with Y s the only epting stte e L. Similrly, let the lnguge epted y the NFA with Z s the only epting stte e L2. Whih of the following sttements out L nd L2 is TRUE? () L L2 () L L2 () L2 L (d) None of these [IT-25] () Writing Y nd Z interms of inoming rrows (Arden s method), we get Y X Y Z Z X Z Y Clerly, Y = Z. 5. Consider the mhine M Ans., The lnguge reognized y M is () {w {, }* every in w is followed y extly two s} () {w {, }* every in w is followed y t lest two s} () {w {, }* w ontins the sustring (d) {w {, }* w does not ontin s sustring} [GATE-25] () () is flse, sine M is epting. () is true () is flse, sine ontins s sustring, ut is eing rejeted y the mhine. (d) is flse, sine does not ontin s sustring, ut is eing rejeted y M. 6. The following digrm represents finite stte mhine whih tkes s input inry numer from the lest signifint it / / / / Ans. Q Q Whih one of the following is TRUE? () It omputes s omplement of the input numer () It omputes 2 s omplement of the input numer () It inrements the input numer (d) It derements the input numer () / / / / Q Q The given mhine, exeutes the lgorithm for 2 s omplement when input is given from LSB. [GATE-25]

28 Finite Automt 7. In the utomton elow, s is the strt stte nd t is the only finl stte. 4 s t Ans. Consider the strings u =, v = nd w =. Whih of the following sttements is true? () The utomton epts u nd v ut not w () The utomton epts eh of u, v, nd w () The utomton rejets eh of u, v, nd w (d) The utomton epts u ut rejets v nd w [IT-26] (d) u = : Aepted y utomt. v = : Not epted y utomt w = : Not epted y utomt. 8. A minimum stte determinsiti finite utomton epting the lnguge L {w w (, )*, numer of s nd s in w re divisile y 3 nd 5, respetively} hs [GATE-27] () 5 sttes () sttes () sttes (d) 9 sttes Ans. () L {w s {,} * numer if s nd s in w re divisile y 3 nd 5 respetively}. The minimum stte deterministi finite utomton epting the lnguge L hs sttes. q q 4 q 5 q 6 q 7 q 8 q 9 X q X q X 2 q X 3 q 4 Common Dt for Q. 9 nd Q. 2: Consider the following Finite Stte Automton q X q 5 q q q 2 9. The lnguge epted y this utomton is given y the regulr expression () **** () ( )* () * ( )* (d) *** [GATE-27]

29 42 Ans. () Finite Automt q q q 2 is unrehle from strting stte nd hene n e deleted to give the following digrm: q q q is the initil stte. From q to q the regulr expression is *. After tht, every omintion of nd is epted y q or. So q nd together n e ollpsed into permnent ept stte nd now the digrm eomes., r * ( )* q q 2. The minimum stte utomton equivlent to the ove FSA hs the following numer of sttes () () 2 () 3 (d) 4 [GATE-27] Ans. () The minimum stte FSA is given elow for the regulr expression *( + )* So FSA ontins minimum two sttes q nd q. 2. Consider the following DFA in whih s is the stte nd s, s 3 nd the finl sttes. x x S S S 2 y y x y y x S 3 Wht lnguge does this DFA reognize? () All strings of x nd y () All strings of x nd y whih hve either even numer of x nd even numer of x nd odd numer of y () All strings of x nd y whih hve equl numer of x nd y (d) All strings of x nd y with either even numer of x nd odd numer of y or odd numer of x nd even numer of y [IT-27]

30 Finite Automt 43 Ans. (d) Given DFA n e redesigned s S s q, S s q, S2 s q, S3 s q. Eh stte is q [ = n mod2, = n mod2]. q s n mod 2 =, n mod 2 = [numer of x is even, numer of y is even]. x q x q y y y y x q q x q is finl stte men where numer of x is even nd numer of y is odd. q is finl stte men where numer of x is odd nd numer of y is even. 22. Consider the following finite utomt P nd Q over the lphet {,, }. The strt sttes re indited y doule rrow nd finl sttes re indited y doule irle. Let the lnguges reognized y them e denoted y L(P) nd L(Q) respetively. P p p p 2 p 3 Q q q The utomton whih reognizes the lnguges L(P) L(Q) is: () r r r 2 r 3 () r r r 2 r 3 () r r r 2 r 3

31 44 Finite Automt (d) r r r 2 r 3 (e) None of the ove [IT-27] Ans. () L(P) L(Q) must ontin ll strings ommon to P nd Q. Note tht is ommon to oth P nd Q nd hene must e epted y ny FA epting L(P) L(Q). However, ll of the given mhine rejet. Therefore option (e) i.e. none of these is the right nswer. Common Dt for Q. 23, Q.24 nd Q. 25: Consider the regulr expression: R ( )* ( ) ( )* 23. Whih of the following non-deterministi finite utomt reognizes the lnguge defined y the regulr expression R? Edges leled denote trnsitions on the empty string., S, S () S S 2 S 3, () S S 2, S 3,, S S Ans. () S S 2 S 3 (d) [IT-27] () The lnguge of the given regulr expression R is ontining the sustring or. Option () is the orret mhine for this lnguge. 24. Whih deterministi finite utomton epts the lnguge represented y the regulr expression R? S S 2, S 3 S S 3 () S S 2 S 4

32 Finite Automt 45 () S S S 2 S 3 S 4 S S S S 3, S S 3, () (d) S 2 S 2 Ans. [IT-27] () In option () S3 nd S4 together t s permnent ept nd n therefore e ollpsed into single permnent ept stte s shown elow: S, S S 3, S 2 This mhine lerly epts ll strings ontining the sustrings or, whih is sme s regulr expression R. 25. Whih one of the regulr expressions given elow defines the sme lnguge s defined y the regulr expression R? Ans. + () (()* ()*) ( ) () (()* ()*)*( )* () (()*( ) ()*( )) ( )* + (d) (()*( ) ()*( )) ( ) () R = ( + )*( + ) ( + )* hs following equivlent DFA q, [IT-27] q q3 q2

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 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 information

NON-DETERMINISTIC FSA

NON-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 information

CS 573 Automata Theory and Formal Languages

CS 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 information

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

The 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 information

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Technische 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 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

Nondeterministic Automata vs Deterministic Automata

Nondeterministic 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 information

Nondeterministic Finite Automata

Nondeterministic 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 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

Finite State Automata and Determinisation

Finite 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 information

Worked out examples Finite Automata

Worked 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 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

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

Regular languages refresher

Regular 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 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

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

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

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

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

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

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

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

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

Compiler 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 information

Prefix-Free Regular-Expression Matching

Prefix-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 information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 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 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

2.4 Theoretical Foundations

2.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 information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, 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 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

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

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

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

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

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

State Minimization for DFAs

State Minimization for DFAs Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

More information

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata Desriptionl Complexity of Non-Unry Self-Verifying Symmetri Differene Automt Lurette Mris 1,2 nd Lynette vn Zijl 1 1 Deprtment of Computer Siene, Stellenosh University, South Afri 2 Merk Institute, CSIR,

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

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

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α Disrete Strutures, Test 2 Mondy, Mrh 28, 2016 SOLUTIONS, VERSION α α 1. (18 pts) Short nswer. Put your nswer in the ox. No prtil redit. () Consider the reltion R on {,,, d with mtrix digrph of R.. Drw

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

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

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

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

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

@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata

@#? 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 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

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

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Counting 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 information

CSE 401 Compilers. Today s Agenda

CSE 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 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

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

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

1 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. 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 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

Myhill-Nerode Theorem

Myhill-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 information

Java II Finite Automata I

Java 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 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

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

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

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

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

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

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Running 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 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

Automata and Regular Languages

Automata and Regular Languages Chpter 9 Automt n Regulr Lnguges 9. Introution This hpter looks t mthemtil moels of omputtion n lnguges tht esrie them. The moel-lnguge reltionship hs multiple levels. We shll explore the simplest level,

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

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

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

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

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

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

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

Activities. 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

Activities. 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 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

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

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths Intermedite Mth Cirles Wednesdy 17 Otoer 01 Geometry II: Side Lengths Lst week we disussed vrious ngle properties. As we progressed through the evening, we proved mny results. This week, we will look t

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

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

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

Section 1.3 Triangles

Section 1.3 Triangles Se 1.3 Tringles 21 Setion 1.3 Tringles LELING TRINGLE The line segments tht form tringle re lled the sides of the tringle. Eh pir of sides forms n ngle, lled n interior ngle, nd eh tringle hs three interior

More information

GNFA GNFA GNFA GNFA GNFA

GNFA GNFA GNFA GNFA GNFA DFA RE NFA DFA -NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with in-egree, n unique finl stte with

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

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite! Solutions for HW9 Exerise 28. () Drw C 6, W 6 K 6, n K 5,3. C 6 : W 6 : K 6 : K 5,3 : () Whih of the following re iprtite? Justify your nswer. Biprtite: put the re verties in V 1 n the lk in V 2. Biprtite:

More information

System Validation (IN4387) November 2, 2012, 14:00-17:00

System 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 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

CS241 Week 6 Tutorial Solutions

CS241 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 information

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering Petri Nets Ree Alreht Seminr: Automt Theory Chir of Softwre Engeneering Overview 1. Motivtion: Why not just using finite utomt for everything? Wht re Petri Nets nd when do we use them? 2. Introdution:

More information

State Complexity of Union and Intersection of Binary Suffix-Free Languages

State 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 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

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL:

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL: PYTHAGORAS THEOREM 1 WHAT S IN CHAPTER 1? 1 01 Squres, squre roots nd surds 1 02 Pythgors theorem 1 03 Finding the hypotenuse 1 04 Finding shorter side 1 05 Mixed prolems 1 06 Testing for right-ngled tringles

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

1 From NFA to regular expression

1 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 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 491G Combinatorial Optimization Lecture Notes

CS 491G Combinatorial Optimization Lecture Notes CS 491G Comintoril Optimiztion Leture Notes Dvi Owen July 30, August 1 1 Mthings Figure 1: two possile mthings in simple grph. Definition 1 Given grph G = V, E, mthing is olletion of eges M suh tht e i,

More information

Languages & Automata

Languages & Automata Lnguges & Automt Dr. Lim Nughton Lnguges A lnguge is sed on n lphet which is finite set of smols such s {, } or {, } or {,..., z}. If Σ is n lphet, string over Σ is finite sequence of letters from Σ, (strings

More information

THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY

THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY THEORY OF FORMAL LANGUAGES EXERCISE BOOK A Suite of Exerises with Solutions DRAFT COPY Lu Breveglieri ollortors Gimpolo Agost Alessndro Brenghi Ann Beletsk Stefno Crespi Reghizzi Bernrdo Dl Seno Vinenzo

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

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Dt Strutures nd Algorithm Xioqing Zheng zhengxq@fudn.edu.n String mthing prolem Pttern P ours with shift s in text T (or, equivlently, tht pttern P ours eginning t position s + in text T) if T[s +... s

More information

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1 Chpter 1, Prt 1 Regulr Lnguges CSC527, Chpter 1, Prt 1 c 2012 Mitsunori Ogihr 1 Finite Automt A finite utomton is system for processing ny finite sequence of symols, where the symols re chosen from finite

More information