On NFA reductions. N6A 5B7, London, Ontario, CANADA ilie 2 Department of Computer Science, University of Chile

Size: px
Start display at page:

Download "On NFA reductions. N6A 5B7, London, Ontario, CANADA ilie 2 Department of Computer Science, University of Chile"

Transcription

1 On NFA reductions Lucin Ilie 1,, Gonzlo Nvrro 2, nd Sheng Yu 1, 1 Deprtment of Computer Science, University of Western Ontrio N6A 5B7, London, Ontrio, CANADA ilie syu@csd.uwo.c 2 Deprtment of Computer Science, University of Chile Blnco Encld 212, Sntigo, CHILE gnvrro@dcc.uchile.cl Astrct. We give fster lgorithms for two methods of reducing the numer of sttes in nondeterministic finite utomt. The first uses equivlences nd the second uses preorders. We develop restricted reduction lgorithms tht operte on position utomt while preserving some of its properties. We show empiriclly tht these reductions re effective in lrgely reducing the memory requirements of regulr expression serch lgorithms, nd compre the effectiveness of different reductions. 1 Introduction Regulr expression hndling is t the hert of mny pplictions, such s linguistics, computtionl iology, pttern recognition, text retrievl, nd so on. An elegnt theory gives the support to esily nd efficiently solve mny complex prolems y mpping them to regulr expressions, then otining nondeterministic finite utomton (NFA) tht recognizes it, nd finlly mking it deterministic ( DFA). However, severe ostcle in ny rel implementtion of the ove scheme is the size of the DFA, which cn e exponentil in the length of the originl regulr expression. Although simple lgorithm for minimizing DFAs exists [5], it hs the prolem of requiring prior construction of the DFA to lter minimize it. This cn e infesile ecuse of min memory requirements nd construction cost. A much more promising (nd more chllenging) lterntive is tht of directly reducing the NFA efore converting it into DFA. This hs the dvntge of working over much smller structure (of size polynomil in the length of the regulr expression) nd of uilding the smller DFA without the need to go through lrger one first. However, the NFA stte minimiztion prolem is very hrd (PSPACE-complete, [1]) nd therefore lgorithms such s [11, 13, 14] cnnot e used in prctice. Reserch prtilly supported y NSERC. Corresponding uthor Supported in prt y Fondecyt grnt Reserch prtilly supported y NSERC.

2 2 L. Ilie, G. Nvrro, S. Yu There re lso lgorithms which uild smll NFAs from regulr expressions, see [7, 4], ut they consider the totl size, tht is, they count oth sttes nd trnsitions, nd they increse rtificilly the numer of sttes to reduce the numer of trnsitions. As the implementtion crucilly depends on the numer of sttes, such lgorithms my not help. The pproch we follow is reducing the size of given NFA. The ide of reducing the size of NFAs y merging sttes ws first introduced y Ilie nd Yu [8] who used equivlence reltions. Lter, Chmprnud nd Coulon [2] modified the ide to work for preorders. In this pper we give fst lgorithms to compute these two reductions. We show tht the lgorithm sed on equivlences cn e implemented in O(m log n) time on n NFA with n sttes nd m trnsitions, while tht sed on preorders cn run in O(mn) time. Both results improve the previous work. When strting from regulr expression, the initil NFA, which we wnt to reduce, is the position utomton. Nvrro nd Rffinot [17,18] showed tht its specil properties permit more compct DFA representtion. Our modified reductions re restricted to preserve those properties nd hence my produce NFAs with more sttes thn the originl reductions. Finlly, we empiriclly evlute the impct of the reduction lgorithms. We show tht the numer of NFA sttes cn e reduced y 1% 4%. Those reductions trnslte into huge reductions in the DFA size, with fctors of up to 1 6. We lso compre the lterntives of full reduction versus restricted reduction, since the former yields less NFA sttes ut the ltter permits more compct DFA representtion. The results show tht full reduction is preferle in most cses of interest. 2 Bsic notions We recll here the sic definitions we need throughout the pper. For further detils we refer to [6] or [22]. Let A e n lphet nd A the set of ll words over A; ε denotes the empty word. A lnguge over A is suset of A. A nondeterministic finite utomton (NFA) is tuple M = (Q, A, δ, I, F), where Q is the set of sttes, I Q is the set of initil sttes, F Q is the set of finl sttes, nd δ : Q A 2 Q is the trnsition mpping; δ is extended to δ : 2 Q A 2 Q y δ(s, ) = q S δ(q, ) nd δ(s, ε) = S, δ(s, w) = δ(δ(s, ), w), for S Q, w A. The lnguge recognized y M is L(M) = {w A δ(i, w) F }. For stte q Q, we denote L L (M, q) = {w A q δ(i, w)}, L R (M, q) = {w A δ(q, w) F }; when M is understood, we write simply L L (q) nd L R (q), resp. The reversed utomton of M is M r = (Q, A, δ r, F, I), where q δ r (p, ) iff p δ(q, ).

3 On NFA reductions 3 3 NFA reduction with equivlences The ide of reducing the size of NFAs y merging stte ws investigted first y Ilie nd Yu [8]; see lso [9]. We descrie it riefly in this section. Let M = (Q, A, δ, I, F) e n NFA. We define R s the corsest equivlence reltion over Q tht stisfies: (P 1 ) R (F (Q F)) =, (P 2 ) for ny p, q Q, A, ( p R q q δ(q, ), p δ(p, ), q R p ). The equivlence R is the lrgest equivlence over Q which is right-invrint w.r.t. M; see [8,9]. Given R, the lgorithm to reduce the utomton M using it is trivil: simply merge ll sttes in the sme equivlence clss nd modify the trnsitions ccordingly. Here is n exmple. Exmple 1 The NFA in Fig. 4 is reduced using R s shown in Fig. 1; the equivlence clsses re lso shown. clsses of R: {} {1, 2, 3,4, 5,6}, 1,2, 3,4, 5,6, Fig.1. A R(τ) = A pos(τ)/ R for τ = ( + )( + + ) Symmetriclly, the reltion L cn e defined using the reversed utomton. The utomton M cn e reduced ccording to either equivlence. As exmples in [9] show, M cn e reduced more using oth equivlences ut the prolem of finding the est wy to do the reduction is open. Fig. 2 gives n exmple (from [9]) where there is no unique wy to reduce optimlly using oth R nd L c d c 4, 1,3 2 c d 4 1,2 3 c, d c 4 Fig.2. An NFA nd its corresponding quotients modulo R nd L 4 Computing equivlences The lgorithm in [8] for computing R runs in low polynomil time ut the prolem of finding fst lgorithm ws left open. We show here tht n old very fst lgorithm of Pige nd Trjn [19] cn e used to solve the prolem.

4 4 L. Ilie, G. Nvrro, S. Yu Recll some definitions from [19]. For inry reltion E over finite set U we denote, for ny suset S U, E 1 (S) = {x y S such tht xey}. A suset B U is clled stle w.r.t. S if either B E 1 (S) or B E 1 (S) =. A prtition P of U is stle w.r.t. S if ll the locks of P re stle w.r.t. S. P is stle if it is stle w.r.t. ech of its own locks. The reltionl corsest prtition prolem is tht of finding, for given reltion E nd prtition P over set U, the corsest stle refinement of P. Pige nd Trjn [19] gve n lgorithm for this prolem which runs in time O(m log n) nd spce O(m + n), where n = crd(u), m = crd(e). They remrked tht the lgorithm works lso for severl reltions. This lgorithm pplies to our prolem of finding R s follows. For ny A, denote δ = {(p, q) Q Q q δ(p, )}. Then R is the corsest stle refinement of the prtition {F, Q F } w.r.t. ll reltions δ, A. Therefore, if the numer of sttes in our utomton is n nd the numer of trnsitions is m, we hve the following theorem. Theorem 1 The equivlences R nd L cn e computed in time O(m log n) nd spce O(m + n). It is interesting to notice tht, to reduce NFAs y equivlences, we employed n ide from deterministic finite utomt (DFA) reduction nd then, to mke it fst, we used n lgorithm which ws inspired itself from Hopcroft s lgorithm [5] to reduce DFAs. 5 NFA reduction with preorders Chmprnud nd Coulon [2] noticed tht etter reduction cn e otined if the xioms (P 1 ) nd (P 2 ) ove re used to construct preorder reltion insted of n equivlence. Let us denote the lrgest (w.r.t. inclusion) preorder which verifies (P 1 ) nd (P 2 ) y R. It is then immedite tht p R q implies L R (p) L R (q). As in the cse of equivlences, the reltion L is symmetriclly defined using the reversed utomton. Then, p L q implies L L (p) L L (q). The reduction with preorders is more complicted thn with equivlences. First, we cn merge two sttes p nd q s soon s ny of the following conditions is met: (i) p R q nd q R p, (ii) p L q nd q L p, (iii) p R q nd p L q. However, fter merging two sttes, the preorders R nd L must e updted such tht their reltion with the lnguges L R nd L L (see ove) is preserved. For instnce, in the cse (i), ssuming the merged stte of p nd q is denoted q, the updte mounts to removing from R ll pirs (q, s) for which p R s. Cse (ii) is hndled similrly nd (iii) does not need ny updte.

5 On NFA reductions 5 An open prolem here is how to merge the sttes using the two preorders such tht the reduction of the NFA is optiml; see the exmple in Fig. 2. Since the preorder requirement is weker thn equivlence, p R q implies tht p R q nd q R p. The converse is not true in generl (see [2] for n exmple). Therefore, using preorders we hve chnce to otin etter reduction of the NFA. It remins to investigte how much etter. 6 Computing preorders We give here n lgorithm to compute the preorders R nd L. Assuming tht Q = {1, 2,..., n} nd the numer of trnsitions is m, our lgorithm runs in time O(mn) nd spce O(n 2 ). The est lgorithm given y Chmprnud nd Coulon [2] runs in time O(mn 2 ). We shll compute the complement R of R y the lgorithm preorder(m) from Fig. 3; ω is the reltion which is R t the end. According to the definition of R, its complement R is the smllest reltion over Q such tht (P 1) (F (Q F)) R, (P 2) for ny i, j Q, A, ( i δ(i, ), j δ(j, ), i R j i R j ). So, we dd (i, j) to R sed on the fct tht there is i δ(i, ) for which the numer of those j δ(j, ) with i R j is precisely crd(δ(j, )); tht is, ll j s. Therefore, we shll compute some mtrices of counters N(), for ny A; N() is n n mtrix such tht N() ij = crd({l δ(j, ) i R l}), for ll i, j Q. We strt with ll these counters set to zero nd updte them nytime there is new informtion on R ; ny new pir dded to R is enqueued (steps 9 nd 19) nd lter dequeued (step 11) nd processed such tht ll counters involved re dequtely updted (step 14). Anytime such counter N() ik reches mximum vlue crd(δ(k, )) (step 15), ll pirs (j, k) such tht i δ(j, ) re dded to R if not lredy there (steps 16 18). Let us show tht the lgorithm preorder(m) computes correctly the preorder R. First, it is cler tht R is otined y dding ll pirs in (P 1 ) nd then using (P 2 ) s long s pirs cn still e dded. Assume then R = {(i 1, j 1 ),..., (i r, j r ),..., (i s, j s )}, where the first r pirs re dded ecuse of (P 1) nd the remining ones due to (P 2 ). We show tht the lgorithm preorder(m) computes the sme reltion. Denote y ω the reltion computed y the lgorithm. Oviously, ω R. Assume there is (i t, j t ) in R ut not in ω; consider such pir with the lowest index t. It must e tht t > r since ll pirs in F (Q F) re certinly dded to ω. As (i t, j t ) is in R, there must e n i δ(i t, ) such tht (i t, j t ) ws dded to R ecuse ll pirs (i, j ), j δ(j t, ), were lredy in R. Thus, t lest one of

6 6 L. Ilie, G. Nvrro, S. Yu preorder(m) - given: n NFA M - returns: R 1. for q Q, A do //1 4: preprocessing 2. compute δ r (q, ) s linked list 3. compute crd(δ(q, )) 4. initilize ll N()s with s 5. ω, C newqueue() //5 19: processing 6. for i F do //6 8: initilize ω 7. for j Q F do //ω will e R t the end 8. ω ω {(i, j)} 9. enqueue(c,(i, j)) 1. while C do 11. (i, j) dequeue(c) //11 19: updtes due to 12. for A do //(i, j) eing dded to ω 13. for k δ r (j, ) do 14. N() ik N() ik + 1 //14: updte counter 15. if N() ik = crd(δ(k, )) then //15 18: updte ω 16. for j δ r (i, ) do //when counter is mximl 17. if (j, k) ω then 18. ω ω {(j, k)} 19. enqueue(c,(j, k)) 2. return ω Fig.3. Algorithm for computing preorders those pirs (i, j ) is not in ω. Since the index of (i, j ) is strictly smller thn t, contrdiction is otined. The time complexity of the ove lgorithm is O(m+n 2 ) for the preprocessing nd proportionl to n n (crd(δ r (i, )) + crd(δ r (j, ))) = O(mn) i=1 j=1 A for processing. Therefore, the time complexity is O(mn). The spce complexity is O(n 2 ). We hve proved the following theorem. Theorem 2 The preorders R nd L cn e computed in time O(mn) nd spce O(n 2 ). 7 Position utomton We recll in this section the well-known construction of the position utomton 3, discovered independently y Glushkov [3] nd McNughton nd Ymd [12]. 3 This utomton is sometimes clled Glushkov utomton; e.g., in [18].

7 On NFA reductions 7 Let α e regulr expression. The sic ide of the position utomton is to ssume tht ll occurrences of letters in α re different. For this, ll letters re mde different y mrking ech letter with unique index, clled its position in α. The set of positions of α is pos(α) = {1, 2,..., α A }, where α A is the numer of letter occurrences in α. We shll denote lso pos (α) = pos(α) {}. The expression otined from α y mrking ech letter with its position is denoted α A, where A = { i A, 1 i α A }. For instnce, if α = ( + ), then α = 1 ( ). Notice tht pos(α) = pos(α). The sme nottion is lso used for unmrking, tht is, =. Three mppings first, lst, nd follow re then defined s follows (see [3]). For ny regulr expression α nd ny i pos(α), we hve: first(α) = {i i w L(α)}, lst(α) = {i w i L(α)}, follow(α, i) = {j u i j v L(α)}. (1) We extend follow y follow(α, ) = first(α). Also, let lst (α) stnd for lst(α) if ε L(α) nd lst(α) {} otherwise. The position utomton for α is where A pos (α) = (pos (α), A, δ pos,, lst (α)) δ pos = {(i,, j) j follow(α, i), = j }. Besides the property of ccepting the lnguge expressed y the originl regulr expression, tht is, L(A pos (α)) = L(α), the position utomton hs two very importnt properties. First, the numer of sttes is lwys α A +1, which mkes it work etter then Thompson s utomton [2] in it-prllel regulr expression serch lgorithms [18]. Second, ll trnsitions incoming to ny given stte re lelled y the sme letter, property exploited y Nvrro nd Rffinot [17, 18] in regulr expression serch lgorithms to represent the DFA using O(2 α A + A ) it-msks of length α A, rther thn O(2 α A A ). Exmple 2 Consider the regulr expression τ = ( + )( + + ). The mrked version of τ is τ = ( )( ). The vlues of the mppings first, lst, nd follow for τ nd the corresponding position utomton A pos (τ) re given in Fig. 4. The position utomton cn e computed esily in cuic time using the inductive definitions of first, lst, nd follow, ut Brüggemnn-Klein [1] showed how to compute it in qudrtic time. 8 Reducing the position utomton In this section we show how the position utomton cn e reduced using equivlences nd/or preorders such tht its essentil properties re preserved.

8 8 L. Ilie, G. Nvrro, S. Yu first(τ) = {1, 2} lst(τ) = {1, 2,3, 4,5, 6} i follow(τ, i) 1 {3, 4,6} 2 {3, 4,6} 3 {3, 4,6} 4 {3, 4,5, 6} 5 {3, 4,5, 6} 6 {3, 4,6} Fig.4. A pos(τ) for τ = ( + )( + + ) Consider regulr expression α nd define the equivlence l over pos (α) y i l j iff the letter lelling ll trnsitions incoming to i is the sme s the one for j. The ide is to reduce the position utomton such tht the trnsitions incoming to given stte re still lelled the sme. Therefore, ny sttes we merge must e in l. Using equivlences, sy R, we merge ccording to the equivlence R l. Fig. 5 shows n exmple. clsses of R l : {} {1, 3, 5} {2, 4, 6} 1, 3,5 2, 4,6 Fig.5. A pos(τ)/ R l for τ = ( + )( + + ) Using preorders, we do just s efore with the restriction imposed y l. 9 Experimentl results In this section we im t estlishing how significnt is the reduction otined using equivlences, nd its relevnce to regulr expression serch lgorithms. In prticulr, we re interested in compring two choices: full right-equivlence, where the properties of the position utomton re not preserved (Section 3), nd restricted right-equivlence, where those properties re preserved (Section 8).

9 On NFA reductions 9 While full right-equivlence cn potentilly yield lrger reductions in numer of NFA sttes, it requires representtion of O(2 n f A ) cells for the DFA (n f is the numer of reduced NFA sttes, A is the lphet). Restricted right-equivlence my yield more sttes, ut permits more compct representtion in O(2 nr + A ) cells for the DFA (n r is the numer of NFA sttes fter the restricted reduction). We hve tested regulr expressions on DNA, hving 1 to 1 lphet symols, verging over 1, expressions per length, with density of opertors from.1 to.4 (Section 9.1 gives more detils on the genertion process). For ech such expression, we uilt its position utomton (Section 7), nd then pplied full nd restricted reduction. Figure 6 shows the reductions otined, s frction of the originl numer of sttes (which ws lwys n = 1 + α A ecuse of Glushkov s construction). There is second version of the full reduction, where the NFA is previously modified to include self-loop t the initil stte, for serch purposes. This permits no further restricted reduction, ut llows slightly etter full reduction, s it cn e seen. Both reduction fctors tend to stilize s n grows, eing etter for higher density of opertors in the regulr expression. It is lso cler tht full reduction gives sustntilly etter reductions compred to restricted reduction (1%-2% etter). Frction of full NFA sttes Density of opertors: 1% Restricted right equivlence Full right equivlence Full right equivlence, serch.87 Numer of chrcters Frction of full NFA sttes Density of opertors: 2% Restricted right equivlence Full right equivlence Full right equivlence, serch.78 Numer of chrcters Frction of full NFA sttes Density of opertors: 3% Restricted right equivlence Full right equivlence Full right equivlence, serch Numer of chrcters Frction of full NFA sttes Density of opertors: 4% Restricted right equivlence Full right equivlence Full right equivlence, serch.6 Numer of chrcters Fig. 6. Reduction fctors in numer of sttes otined over position utomt uilt from regulr expressions of lengths 1 to 1 nd density of opertors from.1 to.4, uilt from DNA text.

10 1 L. Ilie, G. Nvrro, S. Yu As explined, the ove does not immeditely men tht full reduction is etter, ecuse its DFA representtion must hve one tle per lphet letter. Figure 7 shows the reduction frction in the representtion of the DFA, compred to tht of the position utomton. This time the difference etween the serch nd the originl utomton re negligile. As it cn e seen, the restricted reduction is convenient only for n 1 to n 3, depending on the opertor density. Note, on the other hnd, tht those short expression lengths imply tht even the originl position utomton is not prolemtic in terms of spce or construction cost. Tht is, full reduction ecomes superior precisely when the spce prolem ecomes importnt. Frction of full DFA cells Density of opertors: 1% Restricted right equivlence Full right equivlence Full right equivlence, serch Numer of chrcters Frction of full DFA cells Density of opertors: 2% Restricted right equivlence Full right equivlence Full right equivlence, serch Numer of chrcters Frction of full DFA cells Density of opertors: 3% Restricted right equivlence Full right equivlence Full right equivlence, serch Frction of full DFA cells Density of opertors: 4% Restricted right equivlence Full right equivlence Full right equivlence, serch Numer of chrcters Numer of chrcters Fig. 7. Reduction fctors in DFA sizes otined over position utomt uilt from regulr expressions of lengths 1 to 1 nd density of opertors from.1 to.4, uilt from DNA text. Figure 8 shows the sme results in logrithmic scle, to show how lrge re the svings due to full reductions when n ecomes lrge. The second version of NFA (for serching) is omitted since the difference in DFA size is unnoticele. As noted in [17,18], DFA spce nd construction cost cn e trded for serch cost s follows: A single tle of O(2 n ) entries cn e split into k tles of size O(2 n/k ) ech, so tht ech such tle hs to e ccessed for ech text chrcter in order to uild the originl entry. Hence the serch cost ecomes

11 On NFA reductions 11 O(k) per text chrcter. If min memory is limited, huge DFA ctully mens lrger serch time, nd reduction in its size trnslte into etter serch times. We hve computed the numer of tles needed with nd without reductions ssuming tht we dedicte 4 megytes of RAM to the DFA. For the highest opertor density we hve otined speedups of up to 5% in serch times, tht is, we need 2/3 of the tles needed y the originl utomton. Frction of full DFA cells Density of opertors: 1% Restricted right equivlence Full right equivlence Frction of full DFA cells Density of opertors: 2% Restricted right equivlence Full right equivlence.1 Numer of chrcters 1e-5 Numer of chrcters Frction of full DFA cells e-5 Density of opertors: 3% Restricted right equivlence Full right equivlence Frction of full DFA cells e-5 Density of opertors: 4% Restricted right equivlence Full right equivlence 1e-6 Numer of chrcters 1e-6 Numer of chrcters Fig. 8. Reduction fctors in DFA sizes otined over position utomt uilt from regulr expressions of lengths 1 to 1 nd density of opertors from.1 to.4, uilt from DNA text. Note the logrithmic scle. 9.1 Generting Regulr Expressions The choice of test ptterns is lwys prolemtic when deling with regulr expressions, since there is no cler concept of wht rndom regulr expression is nd, s fr s we know, there is no pulic repository of regulr expressions ville, except for dozen of trivil exmples. We hve chosen to generte rndom regulr expressions s follows: 1. We choose se rel-world text, in this cse DNA from Homo Spiens. 2. We choose n nd pick rndom text sustring of length n.

12 12 L. Ilie, G. Nvrro, S. Yu 3. We choose n opertor density γ We pply recursive procedure to convert string of length l into regulr expression: () An empty string is converted into n empty regulr expression. In the rest, we ssume nonempty string. () With proility 1 γ we choose tht the expression will e the conctention of two suexpressions: left prt of l chrcters nd right prt of l l chrcters, where l is chosen uniformly in the rnge 1 l l 1. We recursively convert oth suprts into regulr expressions e 1 nd e 2. The resulting expression is e 1 e 2. If l = 1 we simply write down the string chrcter. (c) Otherwise, if the prent in the recursion hs just generted Kleene closure opertor, we choose to dd union opertor, if not, we choose with the sme proility etween Kleene closure nd union. (d) If we chose tht the expression will hve union opertor, we choose left prt of l chrcters nd right prt of l l chrcters, where l is chosen uniformly in the rnge l l. We recursively convert oth suprts into regulr expressions e 1 nd e 2. The resulting expression is e 1 e 2. (e) If we chose to dd Kleene closure opertor t the end of the string, we recursively generte regulr expression e 1 for the string. The resulting expression is e 1. The ove procedure is just one of the mny possile lterntives to generte rndom regulr expressions one could rgue for, ut it hs couple of dvntges. First, it permits determining the length n (numer of chrcters of A) in dvnce. Second, it tkes the chrcters from the text, respecting its distriution. Third, it permits us to choose expressions with more or less opertors y vrying γ. We show experiments with γ =.1 to γ =.4. Exmples otined from our tests, with n = 1, re ACAT(T ε)tt AG(T ε) nd A(CAT(ε T ) ((ε ε T) T A ) (ε ε GT)), respectively. 1 Conclusion We hve developed fster lgorithms to implement two existing NFA reduction techniques. We hve lso dpted them to work over position utomt while preserving their properties tht llow compct DFA representtion. Finlly, we hve empiriclly ssessed the prcticl impct of the reductions, s well s the convenience of preserving or not the position utomt properties. Future work involves empiriclly evluting the impct of using preorders insted of equivlences. The former re more complex nd slower to compute, nd it is not cler which is the optiml wy to pply the different reductions, hence the importnce of determining their prcticl vlue.

13 On NFA reductions 13 References 1. Brüggemnn-Klein, A., Regulr expressions into finite utomt, Theoret. Comput. Sci. 12 (1993) Chmprnud, J.-M., nd F. Coulon, NFA reduction lgorithms y mens of regulr inequlities, in: Z. Ésik, Z. Fülöp, eds., Proc. of DLT 23 (Szeged, 23), Lecture Notes in Comput. Sci. 271, Springer-Verlg, Berlin, Heidelerg, 23, Glushkov, V.M., The strct theory of utomt, Russin Mth. Surveys 16 (1961) Hgenh, C., nd Muscholl, A., Computing ǫ-free NFA from regulr expressions in O(nlog 2 (n)) time, Theor. Inform. Appl. 34 (4) (2) Hopcroft, J., An nlog n lgorithm for minimizing sttes in finite utomton, Proc. Internt. Sympos. Theory of mchines nd computtions, Technion, Hif, 1971, Acdemic Press, New York, 1971, Hopcroft, J.E., nd Ullmn, J.D., Introduction to Automt Theory, Lnguges, nd Computtion, Addison-Wesley, Reding, Mss., Hromkovic, J., Seiert, S., nd Wilke, T., Trnslting regulr expressions into smll ǫ-free nondeterministic finite utomt, J. Comput. System Sci. 62 (4) (21) Ilie, L., nd Yu, S., Algorithms for computing smll NFAs, in: K. Diks, W. Rytter, eds., Proc. of the 27th MFCS, (Wrszw, 22), Lecture Notes in Comput. Sci., 242, Springer-Verlg, Berlin, Heidelerg, 22, Ilie, L., nd Yu, S., Reducing NFAs y invrint equivlences, Theoret. Comput. Sci. 36 (23) Jing, T., nd Rvikumr, B., Miniml NFA prolems re hrd, SIAM J. Comput. 22(6) (1993), Kmed, T., nd Weiner, P., On the stte minimiztion of nondeterministic finite utomt, IEEE Trns. Computers C-19(7) (197) McNughton, R., nd Ymd, H., Regulr expressions nd stte grphs for utomt, IEEE Trns. on Electronic Computers 9 (1) (196) Melnikov, B. F., A new lgorithm of the stte-minimiztion for the nondeterministic finite utomt, Koren J. Comput. Appl. Mth. 6(2) (1999) Melnikov, B. F., Once more out the stte-minimiztion of the nondeterministic finite utomt, Koren J. Comput. Appl. Mth. 7(3) (2) Nvrro, G., NR-grep: Fst nd Flexile Pttern Mtching Tool, Softwre Prctice nd Experience 31 (21) Nvrro, G., nd Rffinot, M., Fst Regulr Expression Serch, Proc. WAE 99, Lecture Notes Comput. Sci. 1668, Springer-Verlg, Berlin, Heidelerg, 1999, Nvrro, G., nd Rffinot, M., Compct DFA Representtion for Fst Regulr Expression Serch, Proc. WAE 1, Lecture Notes Comput. Sci. 2141, Springer- Verlg, Berlin, Heidelerg, 21, Nvrro, G., nd Rffinot, M., Flexile Pttern Mtching in Strings. Prcticl On- Line Serch Algorithms for Texts nd Biologicl Sequences, Cmridge University Press, Cmridge, Pige, R., nd Trjn, R.E, Three Prtition Refinement Algorithms, SIAM J. Comput. (1987) 16(6) Thompson, K., Regulr expression serch lgorithm, Comm. ACM 11 (6) (1968)

14 14 L. Ilie, G. Nvrro, S. Yu 21. Wu, S., nd Mmer, U., Fst text serching llowing errors, Comm. ACM 35(1) (1992) Yu, S., Regulr Lnguges, in: G. Rozenerg, A. Slom, Hndook of Forml Lnguges, Vol. I, Springer-Verlg, Berlin, 1997,

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

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

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

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

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

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

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

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

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

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

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

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

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

More information

Model Reduction of Finite State Machines by Contraction

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

More information

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

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

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

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

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

More information

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

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

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

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

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

More information

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

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

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

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

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

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

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

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

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

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

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

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

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

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

p-adic Egyptian Fractions

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

More information

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

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

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers 80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input

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

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

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

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

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

Regular Languages and Applications

Regular Languages and Applications Regulr Lnguges nd Applictions Yo-Su Hn Deprtment of Computer Science Yonsei University 1-1 SNU 4/14 Regulr Lnguges An old nd well-known topic in CS Kleene Theorem in 1959 FA (finite-stte utomton) constructions:

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

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

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

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

More information

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

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

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

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

More information

Parse trees, ambiguity, and Chomsky normal form

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

More information

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

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

More information

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

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

Non-deterministic Finite Automata

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

More information

Lexical Analysis Finite Automate

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

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

Lecture 9: LTL and Büchi Automata

Lecture 9: LTL and Büchi Automata Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled

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

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Mehryr Mohri Cournt Institute nd Google Reserch mohri@cims.nyu.com Preliminries Finite lphet Σ, empty string. Set of ll strings over

More information

Surface maps into free groups

Surface maps into free groups Surfce mps into free groups lden Wlker Novemer 10, 2014 Free groups wedge X of two circles: Set F = π 1 (X ) =,. We write cpitl letters for inverse, so = 1. e.g. () 1 = Commuttors Let x nd y e loops. The

More information

Tutorial Automata and formal Languages

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

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

More information

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

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

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

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

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

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

FABER Formal Languages, Automata and Models of Computation

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

More information

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

DFA minimisation using the Myhill-Nerode theorem

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

More information

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University U.U.D.M. Project Report 07:4 Frey Frctions Rickrd Fernström Exmensrete i mtemtik, 5 hp Hledre: Andres Strömergsson Exmintor: Jörgen Östensson Juni 07 Deprtment of Mthemtics Uppsl University Frey Frctions

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

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

ɛ-closure, Kleene s Theorem,

ɛ-closure, Kleene s Theorem, DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene

More information

The size of subsequence automaton

The size of subsequence automaton Theoreticl Computer Science 4 (005) 79 84 www.elsevier.com/locte/tcs Note The size of susequence utomton Zdeněk Troníček,, Ayumi Shinohr,c Deprtment of Computer Science nd Engineering, FEE CTU in Prgue,

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

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

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

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7 CS103 Hndout 32 Fll 2016 Novemer 11, 2016 Prolem Set 7 Wht cn you do with regulr expressions? Wht re the limits of regulr lnguges? On this prolem set, you'll find out! As lwys, plese feel free to drop

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

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

SWEN 224 Formal Foundations of Programming WITH ANSWERS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming

More information

Name Ima Sample ASU ID

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

More information

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

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

More information

Formal Language and Automata Theory (CS21004)

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

More information

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.3 Regular Expressions

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

More information

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations. Lecture 3 3 Solving liner equtions In this lecture we will discuss lgorithms for solving systems of liner equtions Multiplictive identity Let us restrict ourselves to considering squre mtrices since one

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

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

In-depth introduction to main models, concepts of theory of computation:

In-depth introduction to main models, concepts of theory of computation: CMPSCI601: Introduction Lecture 1 In-depth introduction to min models, concepts of theory of computtion: Computility: wht cn e computed in principle Logic: how cn we express our requirements Complexity:

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

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

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

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

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information