Theoretical Computer Science 267 (2001) 3–16

www.elsevier.com/locate/tcs

Minimal cover-automata for "nite languages C. Cˆampeanu, N. Sˆantean, S. Yu ∗ Department of Computer Science, Middlesex College, University of Western Ontario, London, Ontario, N6A 5B7, Canada

Abstract A cover-automaton A of a "nite language L ⊆ ∗ is a "nite deterministic automaton (DFA) that accepts all words in L and possibly other words that are longer than any word in L. A minimal deterministic "nite cover automaton (DFCA) of a "nite language L usually has a smaller size than a minimal DFA that accept L. Thus, cover automata can be used to reduce the size of the representations of "nite languages in practice. In this paper, we describe an e0cient algorithm that, for a given DFA accepting a "nite language, constructs a minimal deterministic "nite cover-automaton of the language. We also give algorithms for the boolean operations on c 2001 Elsevier deterministic cover automata, i.e., on the "nite languages they represent. Science B.V. All rights reserved. Keywords: Finite languages; Deterministic "nite automata; Cover language; Deterministic cover automata

1. Introduction Regular languages and "nite automata are widely used in many areas such as lexical analysis, string matching, circuit testing, image compression, and parallel processing. However, many applications of regular languages use actually only "nite languages. The number of states of a "nite automaton that accepts a "nite language is at least one more than the length of the longest word in the language, and can even be in the order of exponential to that number. If we do not restrict an automaton to accept the exact given "nite language but allow it to accept extra words that are longer than the longest word in the language, we may obtain an automaton such that the number of states is signi"cantly reduced. In most applications, we know what is the maximum This research is supported by the Natural Sciences and Engineering Research Council of Canada grants OGP0041630. ∗ Corresponding author. E-mail addresses: [email protected] (C. Cˆampeanu), [email protected] (N. Sˆantean), [email protected] (S. Yu).

c 2001 Elsevier Science B.V. All rights reserved. 0304-3975/01/$ - see front matter PII: S 0 3 0 4 - 3 9 7 5 ( 0 0 ) 0 0 2 9 2 - 9

4

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

length of the words in the language, and the systems usually keep track of the length of an input word anyway. So, for a "nite language, we can use such an automaton plus an integer to check the membership of the language. This is the basic idea behind cover automata for "nite languages. Informally, a cover-automaton A of a "nite language L ⊆ ∗ is a "nite automaton that accepts all words in L and possibly other words that are longer than any word in L. In many cases, a minimal deterministic cover automaton of a "nite language L has a much smaller size than a minimal DFA that accept L. Thus, cover automata can be used to reduce the size of automata for "nite languages in practice. Intuitively, a "nite automaton that accepts a "nite language (exactly) can be viewed as having structures for the following two functionalities: (1) checking the patterns of the words in the language, and (2) controlling the lengths of the words. In a high-level programming language environment, the length-control function is much easier to implement by counting with an integer than by using the structures of an automaton. Furthermore, the system usually does the length-counting anyway. Therefore, a DFA accepting a "nite language may leave out the structures for the length-control function and, thus, reduce its complexity. The concept of cover automata is not totally new. Similar concepts have been studied in diCerent contexts and for diCerent purposes. See, for example, [1, 5, 3, 8]. Most of previous work has been in the study of a descriptive complexity measure of arbitrary languages, which is called “automaticity” by Shallit et al. [8]. In our study, we consider cover automata as an implementing method that may reduce the size of the automata that represent "nite languages. In this paper, as our main result, we give an e0cient algorithm that, for a given "nite language (given as a deterministic "nite automaton or a cover automaton), constructs a minimal cover automaton for the language. Note that for a given "nite language, there might be several minimal cover automata that are not equivalent under a morphism. We will show that, however, they all have the same number of states. 2. Preliminaries Let T be a set. Then by #T we mean the cardinality of T . The elements of T ∗ are called strings or words. The empty string is denoted by . If w ∈ T ∗ then |w| is the length of x. We de"ne T l = {w ∈ T ∗ | |w| = l}; T 6l =

l i=0

T i;

and

T ¡l =

l−1 i=0

T i:

If T = {t1 ; : : : ; tk } is an ordered set, k¿0, the quasi-lexicographical order on T ∗ , denoted ≺, is de"ned by x ≺ y iC |x|¡|y| or |x| = |y| and x = zti v, y = ztj u; i¡j, for some z; u; v ∈ T ∗ and 16i; j6k. Denote x 4 y if x ≺ y or x = y.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

5

We say that x is a pre"x of y, denoted x 4p y, if y = xz for some z ∈ T ∗ . A deterministic "nite automaton (DFA) is a quintuple A = (; Q; q0 ; ; F), where and Q are "nite nonempty sets, q0 ∈ Q, F ⊆ Q and : Q × → Q is the transition function. We can extend from Q × to Q × ∗ by M ) = s (s; M aw) = ((s; M (s; a); w): We usually denote M by . The language recognized by the automaton A is L(A) = {w ∈ ∗ | (q0 ; w) ∈ F}. For simplicity, we assume that Q = {0; 1; : : : ; #Q − 1} and q0 = 0 and # = k. In what follows we assume that is a total function, i.e., the automaton is complete. Let l be the length of the longest word(s) in the "nite language L. A DFA A such that L(A) ∩ 6l = L is called a deterministic 4nite cover-automaton (DFCA) of L. Let A = (Q; ; ; 0; F) be a DFCA of a "nite language L. We say that A is a minimal DFCA of L if for every DFCA B = (Q ; ; ; 0; F ) of L we have #Q6#Q . Let A = (Q; ; ; 0; F) be a DFA. Then (a) q ∈ Q is said to be accessible if there exists w ∈ ∗ such that (0; w) = q, (b) q is said to be useful (coaccessible) if there exists w ∈ ∗ such that (q; w) ∈ F. It is clear that for every DFA A there exists an automaton A such that L(A ) = L(A) and all the states of A are accessible and at most one of the states is not useful (the sink state). The DFA A is called a reduced DFA. 3. Similarity sequences and similarity sets In this section, we describe the L-similarity relation on ∗ , which is a generalization of the equivalence relation ≡L (x ≡L y: xz ∈ L iC yz ∈ L for all z ∈ ∗ ). The notion of L-similarity was introduced in [5] and studied in [3] etc. In this paper, L-similarity is used to establish our algorithms. Let be an alphabet, L ⊆ ∗ a "nite language, and l the length of the longest word(s) in L. Let x; y ∈ ∗ . We de"ne the following relations: (1) x ∼L y if for all z ∈ ∗ such that |xz|6l and |yz|6l, xz ∈ L iC yz ∈ L; (2) x L y if x ∼L y does not hold. The relation ∼L is called similarity relation with respect to L. Note that the relation ∼L is reNexive, symmetric, but not transitive. For example, let = {a; b} and L = {aab; baa; aabb}. It is clear that aab ∼L aabb (since aabw ∈ L and aabbw ∈ L if |aabbw|64; i.e. w = ) and aabb ∼L baa, but aab L baa (since for w = b we have aabb ∈ L; baab ∈= L and |baab| = |aabb|64). The following lemma is proved in [3]: Lemma 1. Let L ⊆ ∗ be a 4nite language and x; y; z ∈ ∗ ; |x|6|y|6|z|. The following statements hold: (1) If x ∼L y; x ∼L z; then y ∼L z.

6

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

(2) If x ∼L y; y ∼L z; then x ∼L z. (3) If x ∼L y; y L z; then x L z. If x L y and y ∼L z, we cannot say anything about the similarity relation between x and z. Example 2. Let x; y; z ∈ ∗ , |x|6|y|6|z|. We may have (1) x L y; y ∼L z and x ∼L z, or (2) x L y; y ∼L z and x L z. Indeed, if L = {aa; aaa; bbb; bbbb; aaab} we have (1) if we choose x = aa, y = bbb, z = bbbb, and (2) if we choose x = aa, y = bba, z = abba. Denition 3. Let L ⊆ ∗ be a "nite language. (1) A set S ⊆ ∗ is called an L-similarity set if x ∼L y for every pair x; y ∈ S. (2) A sequence of words [x1 ; : : : ; xn ] over is called a dissimilar sequence of L if xi L xj for each pair i; j, 16i; j6n and i = j. (3) A dissimilar sequence [x1 ; : : : ; xn ] is called a canonical dissimilar sequence of L if there exists a partition ! = {S1 ; : : : ; Sn } of ∗ such that for each i, 16i6n, xi ∈ Si , and Si is a L-similarity set. (4) A dissimilar sequence [x1 ; : : : ; xn ] of L is called a maximal dissimilar sequence of L if for any dissimilar sequence [y1 ; : : : ; ym ] of L, m6n. Theorem 4. A dissimilar sequence of L is a canonical dissimilar sequence of L if and only if it is a maximal dissimilar sequence of L. Proof. Let L be a "nite language. Let [x1 ; : : : ; xn ] be a canonical dissimilar sequence of L and ! = {S1 ; : : : ; Sn } the corresponding partition of ∗ such that for each i, 16i6n; Si is an L-similarity set. Let [y1 ; : : : ; ym ] be an arbitrary dissimilar sequence of L. Assume that m¿n. Then there are yi and yj , i = j, such that yi ; yj ∈ Sk for some k, 16k6n. Since Sk is a L-similarity set, yi ∼L yj . This is a contradiction. Then, the assumption that m¿n is false, and we conclude that [x1 ; : : : ; xn ] is a maximal dissimilar sequence. Conversely, let [x1 ; : : : ; xn ] a maximal dissimilar sequence of L. Without loss of generality we can suppose that |x1 |6 · · · 6|xn |. For i = 1; : : : ; n, de"ne Xi = {y ∈ ∗ | y ∼L xi

and

y ∈= Xj

for j¡i}:

Note that for each y ∈ ∗ , y ∼L xi for at least one i, 16i6n, since [x1 ; : : : ; xn ] is a maximal dissimilar sequence. Thus, ! = {X1 ; : : : ; Xn } is a partition of ∗ . The remaining task of the proof is to show that each Xi , 16i6n, is a similarity set. We assume the contrary, i.e., for some i, 16i6n, there exist y; z ∈ Xi such that y L z. We know that xi ∼L y and xi ∼L z by the de"nition of Xi . We have the following three cases: (1) |xi |¡|y|; |z|, (2) |y|6|xi |6|z| (or |z|6|xi |6|y|), and (3) |xi |¿|y|; |z|. If (1) or (2), then y ∼L z by Lemma 1. This would contradict our assumption. If (3), then it

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

7

is easy to prove that y xj and z xj , for all j = i, using Lemma 1 and the de"nition of Xi . Then we can replace xi by both y and z to obtain a longer dissimilar sequence [x1 ; : : : ; xi−1 ; y; z; xi+1 ; : : : ; xn ]. This contradicts the fact that [x1 ; : : : ; xi−1 ; xi ; xi+1 ; : : : ; xn ] is a maximal dissimilar sequence of L. Hence, y ∼ z and Xi is a similarity set. Corollary 5. For each 4nite language L; there is a unique number N (L) which is the number of elements in any canonical dissimilar sequence of L. Theorem 6. Let S1 and S2 be two L-similarity sets and x1 and x2 the shortest words in S1 and S2 ; respectively. If x1 ∼L x2 then S1 ∪ S2 is a L-similarity set. Proof. It su0ces to prove that for an arbitrary word y1 ∈ S1 and an arbitrary word y2 ∈ S2 , y1 ∼L y2 holds. Without loss of generality, we assume that |x1 |6|x2 |. We know that |x1 |6|y1 | and |x2 |6|y2 |. Since x1 ∼L x2 and x2 ∼L y2 , we have x1 ∼L y2 (Lemma 1(2)), and since x1 ∼L y1 and x1 ∼L y2 , we have y1 ∼L y2 (Lemma 1(1)). 4. Similarity relations on states Let A = (Q; ; ; 0; F) be a DFA and L = L(A). Then it is clear that if (0; x) = (0; y) = q for some q ∈ Q, then x ≡L y and, thus, x ∼L y. Therefore, we can also de"ne similarity as well as equivalence relations on states. Denition 7. Let A = (Q; ; ; 0; F) be a DFA. We de"ne, for each state q ∈ Q, level(q) = min{|w| | (0; w) = q}; i.e., level(q) is the length of the shortest path from the initial state to q. If A = (Q; ; ; 0; F) is a DFA, for each q ∈ Q, we denote xA (q) = min{w | (0; w) = q}, where the minimumis taken according to the quasi-lexicographical order, and LA (q) = {w ∈ ∗ | (q; w) ∈ F}. When the automaton A is understood, we write xq instead of xA (q) and Lq instead LA (q). The length of xq is equal to level(q), therefore level(q) is de"ned for each q ∈ Q. Denition 8. Let A = (Q; ; ; 0; F) be a DFA and L = L(A). We say that p ≡A q (state p is equivalent to q in A) if for every w ∈ ∗ , (p; w) ∈ F iC (q; w) ∈ F. Denition 9. Let A = (Q; ; ; 0; F) be a DFCA of a "nite language L. Let level(p) = i and level(q) = j, m = max{i; j}. We say that p ∼A q (state p is L-similar to q in A) if for every w ∈ 6l−m , (p; w) ∈ F iC (q; w) ∈ F. Lemma 10. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let x; y ∈ 6l such that (0; x) = p and (0; y) = q. If p ∼A q then x ∼L y.

8

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Fig. 1. If x ∼L y then we do not have always that (0; x) ∼A (0; y).

Proof. Let level(p) = i and level(q) = j, m = max{i; j}, and p ∼A q. Choose an arbitrary w ∈ ∗ such that |xw|6l and |yw|6l. Because i6|x| and j6|y| it follows that |w|6l − m. Since p ∼A q we have that (p; w) ∈ F iC (q; w) ∈ F, i.e. (0; xw) ∈ F iC (0; yw) ∈ F, which means that xw ∈ L(A) iC yw ∈ L(A). Hence x ∼L y. Lemma 11. Let A = (Q; ; ; 0; F) be DFCA of a 4nite language L. Let level(p) = i and level(q) = j; m = max{i; j}, and x ∈ i ; y ∈ j such that (0; x) = p and (0; y) = q. If x ∼L y then p ∼A q. Proof. Let x ∼L y and w ∈ 6l−m . If (p; w) ∈ F, then (0; xw) ∈ F. Because x ∼L y, it follows that (0; yw) ∈ F, so (q; w) ∈ F. Using the symmetry we get that p ∼A q. Corollary 12. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let level (p) = i and level(q) = j; m = max{i; j}; and x1 ∈ i ; y1 ∈ j ; x2 ; y2 ∈ 6l ; such that (0; x1 ) = (0; x2 ) = p and (0; y1 ) = (0; y2 ) = q. If x1 ∼L y1 then x2 ∼L y2 . Example 13. If x1 and y1 are not minimal, i.e. |x1 |¿i, but p = (0; x1 ) or |y1 |¿j, but q = (0; y1 ), then the conclusion of Corollary 12 is not necessarily true. Let L = {a; b; aa; aaa; bab}, so l = 3. A DFCA of L is shown in Fig. 1 and we have that b ∼L bab, but b L a (ba ∈= L; aa ∈ L and |ba| = |aa|63). Corollary 14. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L and p; q ∈ Q; p = q. Then xp ∼L xq i9 p ∼A q. If p ∼A q, and level(p)6level(q) and q ∈ F then p ∈ F. Lemma 15. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let s; p; q ∈ Q such that level(s) = i; level(p) = j, level(q) = m; i6j6m. The following statements are true: (1) If s ∼A p; s ∼A q; then p ∼A q. (2) If s ∼A p; p ∼A q; then s ∼A q. (3) If s ∼A p; p A q; then s A q. Proof. We apply Lemma 1 and Corollary 14.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

9

Lemma 16. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let level(p) = i; level(q) = j; and m = max{i; j}. If p ∼A q then Lp ∩ 6l−m = Lq ∩ 6l−m and Lp ∪ Lq is a L-similarity set. Proof. Let w ∈ Lp ∩ 6l−m . Then (p; w) ∈ F, and |w|6l − m. Since p ∼A q, we have (p; w) ∈ F; so w ∈ Lq ∩ 6l−m . Lemma 17. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. If p ∼A q for some p; q ∈ Q; i = level(p); j = level(q) and i6j; p = q; q = 0. Then we can construct a DFCA A = (Q ; ; ; 0; F ) of L such that Q = Q − {q}; F = F − {q}; and (s; a) if (s; a) = q; (s; a) = p (s; a) = q for each s ∈ Q and a ∈ . Thus; A is not a minimal DFCA of L. Proof. It su0ces to prove that A is a DFCA of L. Let l be the length of the longest word(s) in L and assume that level(p) = i and level(q) = j; i6j. Consider a word w ∈ 6l . We now prove that w ∈ L iC (0; w) ∈ F . If there is no pre"x w1 of w such that (0; w1 ) = q, then clearly (0; w) ∈ F iC (0; w) ∈ F. Otherwise, let w = w1 w2 where w1 is the shortest pre"x of w such that (0; w1 ) = q. In the remaining, it su0ces to prove that (p; w2 ) ∈ F iC (q; w2 ) ∈ F. We prove this by induction on the length of w2 . First consider the case |w2 | = 0, i.e., w2 = . Since p ∼A q; p ∈ F iC q ∈ F. Then p ∈ F iC q ∈ F by the construction of A . Thus, (p; w2 ) ∈ F iC (q; w2 ) ∈ F. Suppose that the statement holds for |w2 |¡l for l 6l − |w1 |. (Note that l − |w1 |6l − j.) Consider the case that |w2 | = l . If there does not exist u ∈ + such that u 4p w2 and (p; u) = q, then (p; w2 ) ∈ F − {q} iC (q; w2 ) ∈ F − {q}, i.e., (p; w2 ) ∈ F iC (q; w2 ) ∈ F. Otherwise, let w2 = uv and u be the shortest nonempty pre"x of w2 such that (p; u) = q. Then |v|¡l (and (p; u) = p). By induction hypothesis, (p; v) ∈ F iC (q; v) ∈ F. Therefore, (p; uv) ∈ F iC (q; uv) ∈ F. Lemma 18. Let A be a DFCA of L and L = L(A). Then x ≡L y implies x ∼L y. Proof. Let l be the length of the longest word(s) in L. Let x ≡L y. So, for each z ∈ ∗ ; xz ∈ L iC yz ∈ L . We now consider all words z ∈ ∗ , such that |xz|6l and |yz|6l. Since L = L ∩ 6l and xz ∈ L iC yz ∈ L , we have xz ∈ L iC yz ∈ L. Therefore, x ∼L y by the de"nition of ∼L . Corollary 19. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L; L = L(A). Then p ≡A q implies p ∼A q. Corollary 20. A minimal DFCA of L is a minimal DFA.

10

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Proof. Let A = (Q; ; ; 0; F) be a minimal DFCA of a "nite language L. Suppose that A is not minimal as a DFA for L(A), then there exists p; q ∈ Q such that p ≡L q, then p ∼A q. By Lemma 17 it follows that A is not a minimal DFCA, contradiction. Remark 21. Let A be a DFCA of L and A a minimal DFA. Then A may not be a minimal DFCA of L. Example 22. We take the DFAs:

Fig. 2. Minimal DFA is not always a minimal DFCA.

The DFA A in Fig. 2 is a minimal DFA and a DFCA of L = {; a; aa} but not a minimal DFCA of L, since the DFA B in Fig. 2 is a minimal DFCA of L. Theorem 23. Any minimal DFCA of L has exactly N (L) states. Proof. Let A = (Q; ; ; 0; F) be DFCA of a "nite language L, and #Q = n. Suppose that n¿N (L). Then there exist p; q ∈ Q; p = q, such that xp ∼L xq (because of the de"nition of N (L)). Then p ∼A q by Lemma 14. Thus, A is not minimal, a contradiction. Suppose that N (L)¿n. Let [y1 ; : : : ; yN (L) ] be a canonical dissimilar sequence of L. Then there exist i; j; 16i; j6N (L) and i = j, such that (0; yi ) = (0; yj ) = q for some q ∈ Q. Then yi ∼L yj . Again a contradiction. Therefore, we have n = N (L). 5. The construction of minimal DFCA The "rst part of this section describes an algorithm that determines the similarity relations between states. The second part is to construct a minimal DFCA assuming that the similarity relation between states is known. An ordered DFA is a DFA where (i; a) = j implies that i6j, for all states i; j and letters a. Obviously for such a DFA #Q − 1 is the sink state. 5.1. Determining similarity relation between states The aim is to present an algorithm which determines the similarity relations between states.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

11

Let A = (Q; ; ; 0; F) a DFCA of a "nite language L. De"ne D−1 (A) = {s ∈ Q|(s; w) ∈= F, for all w ∈ ∗ }; for each s ∈ Q let 's (A) = min{w|(s; w) ∈ F}, and Di (A) = {s ∈ Q ||'s | = i}, for each i = 0; 1; : : :, where minimum is taken according to the quasi-lexicographical order. If the automaton A is understood then we write Di and 's instead of Di (A) and respectively 's (A). Lemma 24. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L; and p ∈ Di ; q ∈ Dj . If i = j; i; j¿0 then p q. Proof. We can assume that i¡j. Then obviously (p; 'p ) ∈ F and (q; 'p ) ∈= F. Since l¿|xp | + |'p |; l¿|xq | + |'q |, and i¡j, it follows that |'p |¡|'q |. So, we have that |'p |6 min(l − |xp |; l − |xq |). Hence, p q. Lemma 25. Let A = (Q; ; 0; ; F) be an ordered DFA accepting L; p; q ∈ Q − D−1 ; and either p; q ∈ F or p; q ∈= F. If for all a ∈ ; (p; a) ∼A (q; a); then p∼A q. Proof. Let a ∈ and (p; a) = r and (q; a) = s. If r ∼A s then for all w such that |w|¡l − max{|xA (s)|; |xA (r)|}, xA (r)w ∈ L iC xA (s)w ∈ L. Using Lemma 10 we also have: xA (q)aw ∈ L iC xA (s)w ∈ L for all w ∈ ∗ ; |w|6l − |xA (s)|, and xA (p)aw ∈ L iC xA (r)w ∈ L for all w ∈ ∗ ; |w|6l − |xA (r)|. Hence xA (p)aw ∈ L iC xA (q)aw ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (r)|; |xA (s)|}. Because |xA (r)|6|xA (q)a| = |xA (q)| + 1 and |xA (s)|6|xA (p)a| = |xA (p)| + 1, we get xA (p)aw ∈ L iC xA (q)aw ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (p)|; |xA (q)|} − 1. Since a ∈ is chosen arbitrary, we conclude that xA (p)w ∈ L iC xA (q)w ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (p)|; |xA (q)|}, i.e. xA (p) ∼A xA (q). Therefore, by using Lemma 11, we get that p ∼A q. Lemma 26. Let A = (Q; ; 0; ; F) be an ordered DFA accepting L such that (0; w) = s implies |w| = |xs | for all s ∈ Q. Let p; q ∈ Q − D−1 . If there exists a ∈ such that (p; a) A (q; a); then p A q. Proof. Suppose that p ∼A q. Then for all aw ∈ l−m ; (p; aw) ∈ F iC (q; aw) ∈ F, where m = max{level(p); level(q)}. So ((p; a); w) ∈ F iC ((q; a); w) ∈ F for all w ∈ l−m−1 . Since |x(p;a) | = |xp | + 1 and |x(q;a) | = |xq | + 1 it follows by de"nition that (p; a) ∼A (q; a). This is a contradiction. Our algorithm for determining the similarity relation between the states of a DFA (DFCA) of a "nite language is based on Lemmas 25 and 26. However, most of DFA (DFCA) do not satisfy the condition of Lemma 26. So, we shall "rst transform the given DFA (DFCA) into one that does. Let A = (QA ; ; A ; 0; FA ) be a DFCA of L. We construct the minimal DFA for the language 6l , B = (QB ; ; B ; 0; FB ) (QB = {0; : : : ; l; l + 1}, B (i; a) = i + 1, for all i; 06i6l; B (l + 1; a) = l + 1, for all a ∈ ; FB = {0; : : : ; l}). The DFA B will have exact l + 2 states.

12

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Now we use the standard Cartesian product construction (for details see, e.g., [2]) for the DFA C = (QC ; ; C ; q0 ; FC ) such that L(C) = L(A) ∩ L(B), (taking the automata in this order) and we eliminate all inaccessible states. Obviously, L(C) = L and C satis"es the condition of Lemma 26. Lemma 27. For the DFA C constructed above; if C ((0; 0); w) = (p; q); then |w| = q. Proof. We have C ((0; 0); w) = (p; q), so B (0; w) = q therefore |w| = q. Lemma 28. For the DFA C constructed above we have (p; q) ∼C (p; r). Proof. If p ∈ D−1 (A), the lemma is obvious. Suppose now that p ∈= D−1 and q6r. Then r6l so B (q; w) ∈ FB and B (r; w) ∈ FB for w ∈ 6l−r . It follows that C ((p; q); w) ∈ FC iC C ((p; r); w) ∈ FC , i.e. (p; q) ∼C (p; r). Lemma 29. For the DFA C constructed above we have that (#Q − 1; l + 1 − i) ∼C *; * ∈ Dj ; j = i; : : : ; l; 06i6l. Proof. We have that C ((#Q − 1; l + 1 − i); w) ∈= FC for all w ∈ ∗ , C (*; w) ∈= FC for |w|¡j. It is clear that level((#Q − 1; l + 1 − i) = l + 1 − i and level(*)6l − j6l − i. Let w ∈ 6(l−(l+1−i)) = 6i−1 . Since both C (*; w) ∈= FC and C ((#Q−1; l+1−i); w) ∈= FC it follows the conclusion. Now we are able to present an algorithm, which determines the similarity relation between the states of C. Note that QC is ordered by that (pA ; pB )¡(qA ; qB ) if pB ¡qB or pB = qB and pA ¡qA . Attaching to each state of C is a set of similar states. For *; + ∈ QC , if * ∼C + and *¡+, then + is stored in the set of similar states for *. We assume that QA = {0; 1; : : : ; n − 1} and A is reduced (so n − 1 is the sink state of A). (1) Compute Di (C); −16i6l. (2) Initialize the similarity relation by specifying: (a) For all (n − 1; p); (n − 1; q) ∈ QC , (n − 1; p) ∼C (n − 1; q). (b) For all (n−1; l+1−i) ∈ QC ; (n−1; l+1−i) ∼C * for all * ∈ Dj (C); j = i; : : : ; l, 06i6l. (3) For each Di (C); −16i6l, create a list Listi , which is initialized to ∅. (4) For each * ∈ QC − {(n − 1; q) | q ∈ QB }, following the reversed order of QC , do the following: Assuming * ∈ Di (C). (a) For each + ∈ Listi , if C (*; a) ∼C C (+; a) for all a ∈ , then * ∼C +. (b) Put * on the list Listi . By Lemma 24 we need to determine only the similarity relations between states of the same Di (C) set. Step 2(a) follows from Lemma 28, 2(b) from Lemma 29 and Step 4 from Lemma 15.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

13

Remark 30. The above algorithm has complexity O((n × l)2 ), where n is the number of states of the initial DFA (DFCA) and l is the maximum accepted length for the "nite language L. 5.2. The construction of a minimal DFCA As the input to the algorithm, we have the above DFA C and, for each * ∈ QC , a set S* = {+ ∈ QC | * ∼C + and *¡+}. The output is D = (QD ; ; D ; q0 ; FD ), a minimal DFCA for L. We de"ne the following: i = 0; qi = 0; T = QC − Sqi , (x0 = ); while (T = ∅) do the following: i = i + 1; qi = min{s ∈ T }; T = T − Sqi ; (xi = min{w|C (0; w) ∈ Si }); m = i. Then QD = {q0 ; : : : ; qm−1 }; q0 = 0; D (qi ; a) = qj iC s = min Sqi and C (s; a) ∈ Sqj ; FD = {i | Si ∩ FC = ∅}. Note that the constructions of xi above are useful for the proofs in the following only, where the min (minimum) operator for xi is taken according to the lexicographical order. According to the algorithm we have a total ordering of the states QC : (p; q)6(r; s) if (p; q) = (r; s) or q¡s or q = s and p¡r. Hence D (i; a) = j iC D (0; xi a) = j. Also, from the construction (i.e. the total order on QC ) it follows that 0 = | x0 | 6|x1 |6 · · · 6 |xm−1 |. Lemma 31. The sequence [x0 ; x1 ; : : : ; xm−1 ] constructed above is a canonical L-dissimilar sequence. Proof. We construct the sets Xi = {w ∈ ∗ |(0; w) ∈ Si }. Obviously Xi = ∅. From Lemma 10 it follows that Xi is a L-similarity set for all 06i6m − 1. Let w ∈ ∗ . Because (Si )16i6m−1 is a partition of Q, w ∈ Xi for some 06i6 n − 1, so (Xi )06i6n−1 is a partition of ∗ and therefore [x0 ; x1 ; : : : ; xn−1 ] is a canonical L-dissimilar sequence. Corollary 32. The automaton D constructed above is a minimal DFCA for L. Proof. Since the number of states is equal to the number-of-elements of a canonical L-dissimilar sequence, we only have to prove that D is a cover automaton for L. Let w ∈ 6l . We have that D (0; w) ∈ FD iC C ((0; 0); w) ∈ Si such that Si ∩ FC = ∅, i.e. xi ∼C w. Since |w|6l, xi ∈ L iC w ∈ L (because C is a DFCA for L).

14

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

6. Boolean operations We shall use similar constructions as in [2] for constructing DFCA of languages which are a result of boolean operations between "nite languages. The modi"cations are suggested by the previous algorithm. We "rst construct the DFCA which satis"es the assumption of Lemma 26 and afterwards we can minimize it using the general algorithm. Since the minimization will follow in a natural way we shall present only the construction of the necessary DFCA. Let Ai = (Qi ; ; i ; 0; Fi ) be a DFCA of the "nite languages Li , li = max{|ww ∈ Li }; i = 1; 2. 6.1. Intersection We construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F); where l = min{l1 ; l2 }, ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 ; p ∈ Q2 ; q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1) and F = {(s; p; q) | s ∈ F1 ; p ∈ F2 ; q6l}: Theorem 33. The automaton A constructed above is a DFCA for L = L(A1 ) ∩ L(A2 ). Proof. We have the following relations: w ∈ L1 ∩ L2 iC |w|6l and w ∈ L1 and w ∈ L2 iC |w|6l and w ∈ L(A1 ) and w ∈ L(A2 ). The rest of the proof is obvious. 6.2. Union Assuming that l1 ¿l2 , we construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l+1}; ; ; (0; 0; 0); F), where l = max{l1 ; l2 }, m = min{l1 ; l2 }; ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 , p ∈ Q2 , q6l, and ((s; p; l+1); a) = (1 (s; a); 2 (p; a); l+1) and F = {(s; p; q) | s ∈ F1 or p ∈ F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 34. The automaton A constructed above is a DFCA for L = L(A1 ) ∪ L(A2 ). Proof. We have the following relations: w ∈ L1 ∪ L2 iC |w|6m and w ∈ L1 or w ∈ L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) or w ∈ L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious. 6.3. Symmetric di9erence Assuming that l1 ¿l2 , we construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F);

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

15

where l = max{l1 ; l2 }; m = min{l1 ; l2 }; ((s; p; q); a) = (1 (s; a); 2 (p; a); q + 1), for s ∈ Q1 , p ∈ Q2 ; q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1) and F = {(s; p; q) | s ∈ F1 exclusive or p ∈ F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 35. The automaton A constructed above is a DFCA for L = L(A1 ),L(A2 ). Proof. We have the following relations: w ∈ L1 ,L2 iC |w|6m and w ∈ L1 xor w ∈ L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) xor w ∈ L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious. 6.4. Di9erence We construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F); where l = max{l1 ; l2 }; m = min{l1 ; l2 } and ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 ; p ∈ Q2 , q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1). If l1 ¡l2 then F = {(s; p; q) | s ∈ F1 and p ∈= F2 ; q6m} and otherwise, F = {(s; p; q) | s ∈ F1 and p ∈= F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 36. The automaton A constructed above is a DFCA for L = L(A1 ) − L(A2 ). Proof. We have the following relations: w ∈ L1 −L2 iC |w|6m and w ∈ L1 and w ∈= L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) and w ∈= L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious.

References [1] J.L. BalcRazar, J. Diaz, J. GabarrRo, Uniform characterisations of non-uniform complexity measures, Inform. and Control 67 (1985) 53–89. [2] C. Cˆampeanu, Regular languages and programming languages, Rev. Roumaine Linguistique – CLTA 23 (1986) 7–10. [3] C. Dwork, L. Stockmeyer, A time complexity gap for two-way probabilistic "nite-state automata, SIAM J. Comput. 19 (1990) 1011–1023. [4] J.E. Hopcroft, J.D. Ullman, Introduction to Automata Theory, Languages, and Computation, Addison-Wesley, Reading, MA, 1979. [5] J. Kaneps, R. Freivalds, Minimal Nontrivial Space Space Complexity of Probabilistic One-Way Turing Machines, in: B. Rovan (Ed.), Proc. Mathematical Foundations of Computer Science, BanskTa Bystryca, Czechoslovakia, August 1990, Lecture Notes in Computer Science, vol. 452, Springer, New York, 1990, pp. 355 –361. [6] J. Kaneps, R. Freivalds, Running time to recognise non-regular languages by 2-way probabilistic automata, in ICALP’91, Lecture Notes in Computer Science, vol. 510, Springer, New York, 1991, pp. 174 –185. [7] J. Paredaens, R. Vyncke, A class of measures on formal languages, Acta Inform. 9 (1977) 73–86. [8] J. Shallit, Y. Breitbart, Automaticity I: Properties of a Measure of Descriptional Complexity, J. Comput. System Sci. 53 (1996) 10–25.

16

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

[9] A. Salomaa, Theory of Automata, Pergamon Press, Oxford, 1969. [10] K. Salomaa, S. Yu, Q. Zhuang, The state complexities of some basic operations on regular languages, Theoret. Comput. Sci. 125 (1994) 315–328. [11] S. Yu, Regular languages, in: G. Rozenberg, A. Salomaa (Eds.), Handbook of Formal Languages, Springer, Berlin, 1997. [12] S. Yu, Q. Zhung, On the State Complexity of Intersection of Regular Languages, ACM SIGACT News 22 (3) (1991) 52–54.

www.elsevier.com/locate/tcs

Minimal cover-automata for "nite languages C. Cˆampeanu, N. Sˆantean, S. Yu ∗ Department of Computer Science, Middlesex College, University of Western Ontario, London, Ontario, N6A 5B7, Canada

Abstract A cover-automaton A of a "nite language L ⊆ ∗ is a "nite deterministic automaton (DFA) that accepts all words in L and possibly other words that are longer than any word in L. A minimal deterministic "nite cover automaton (DFCA) of a "nite language L usually has a smaller size than a minimal DFA that accept L. Thus, cover automata can be used to reduce the size of the representations of "nite languages in practice. In this paper, we describe an e0cient algorithm that, for a given DFA accepting a "nite language, constructs a minimal deterministic "nite cover-automaton of the language. We also give algorithms for the boolean operations on c 2001 Elsevier deterministic cover automata, i.e., on the "nite languages they represent. Science B.V. All rights reserved. Keywords: Finite languages; Deterministic "nite automata; Cover language; Deterministic cover automata

1. Introduction Regular languages and "nite automata are widely used in many areas such as lexical analysis, string matching, circuit testing, image compression, and parallel processing. However, many applications of regular languages use actually only "nite languages. The number of states of a "nite automaton that accepts a "nite language is at least one more than the length of the longest word in the language, and can even be in the order of exponential to that number. If we do not restrict an automaton to accept the exact given "nite language but allow it to accept extra words that are longer than the longest word in the language, we may obtain an automaton such that the number of states is signi"cantly reduced. In most applications, we know what is the maximum This research is supported by the Natural Sciences and Engineering Research Council of Canada grants OGP0041630. ∗ Corresponding author. E-mail addresses: [email protected] (C. Cˆampeanu), [email protected] (N. Sˆantean), [email protected] (S. Yu).

c 2001 Elsevier Science B.V. All rights reserved. 0304-3975/01/$ - see front matter PII: S 0 3 0 4 - 3 9 7 5 ( 0 0 ) 0 0 2 9 2 - 9

4

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

length of the words in the language, and the systems usually keep track of the length of an input word anyway. So, for a "nite language, we can use such an automaton plus an integer to check the membership of the language. This is the basic idea behind cover automata for "nite languages. Informally, a cover-automaton A of a "nite language L ⊆ ∗ is a "nite automaton that accepts all words in L and possibly other words that are longer than any word in L. In many cases, a minimal deterministic cover automaton of a "nite language L has a much smaller size than a minimal DFA that accept L. Thus, cover automata can be used to reduce the size of automata for "nite languages in practice. Intuitively, a "nite automaton that accepts a "nite language (exactly) can be viewed as having structures for the following two functionalities: (1) checking the patterns of the words in the language, and (2) controlling the lengths of the words. In a high-level programming language environment, the length-control function is much easier to implement by counting with an integer than by using the structures of an automaton. Furthermore, the system usually does the length-counting anyway. Therefore, a DFA accepting a "nite language may leave out the structures for the length-control function and, thus, reduce its complexity. The concept of cover automata is not totally new. Similar concepts have been studied in diCerent contexts and for diCerent purposes. See, for example, [1, 5, 3, 8]. Most of previous work has been in the study of a descriptive complexity measure of arbitrary languages, which is called “automaticity” by Shallit et al. [8]. In our study, we consider cover automata as an implementing method that may reduce the size of the automata that represent "nite languages. In this paper, as our main result, we give an e0cient algorithm that, for a given "nite language (given as a deterministic "nite automaton or a cover automaton), constructs a minimal cover automaton for the language. Note that for a given "nite language, there might be several minimal cover automata that are not equivalent under a morphism. We will show that, however, they all have the same number of states. 2. Preliminaries Let T be a set. Then by #T we mean the cardinality of T . The elements of T ∗ are called strings or words. The empty string is denoted by . If w ∈ T ∗ then |w| is the length of x. We de"ne T l = {w ∈ T ∗ | |w| = l}; T 6l =

l i=0

T i;

and

T ¡l =

l−1 i=0

T i:

If T = {t1 ; : : : ; tk } is an ordered set, k¿0, the quasi-lexicographical order on T ∗ , denoted ≺, is de"ned by x ≺ y iC |x|¡|y| or |x| = |y| and x = zti v, y = ztj u; i¡j, for some z; u; v ∈ T ∗ and 16i; j6k. Denote x 4 y if x ≺ y or x = y.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

5

We say that x is a pre"x of y, denoted x 4p y, if y = xz for some z ∈ T ∗ . A deterministic "nite automaton (DFA) is a quintuple A = (; Q; q0 ; ; F), where and Q are "nite nonempty sets, q0 ∈ Q, F ⊆ Q and : Q × → Q is the transition function. We can extend from Q × to Q × ∗ by M ) = s (s; M aw) = ((s; M (s; a); w): We usually denote M by . The language recognized by the automaton A is L(A) = {w ∈ ∗ | (q0 ; w) ∈ F}. For simplicity, we assume that Q = {0; 1; : : : ; #Q − 1} and q0 = 0 and # = k. In what follows we assume that is a total function, i.e., the automaton is complete. Let l be the length of the longest word(s) in the "nite language L. A DFA A such that L(A) ∩ 6l = L is called a deterministic 4nite cover-automaton (DFCA) of L. Let A = (Q; ; ; 0; F) be a DFCA of a "nite language L. We say that A is a minimal DFCA of L if for every DFCA B = (Q ; ; ; 0; F ) of L we have #Q6#Q . Let A = (Q; ; ; 0; F) be a DFA. Then (a) q ∈ Q is said to be accessible if there exists w ∈ ∗ such that (0; w) = q, (b) q is said to be useful (coaccessible) if there exists w ∈ ∗ such that (q; w) ∈ F. It is clear that for every DFA A there exists an automaton A such that L(A ) = L(A) and all the states of A are accessible and at most one of the states is not useful (the sink state). The DFA A is called a reduced DFA. 3. Similarity sequences and similarity sets In this section, we describe the L-similarity relation on ∗ , which is a generalization of the equivalence relation ≡L (x ≡L y: xz ∈ L iC yz ∈ L for all z ∈ ∗ ). The notion of L-similarity was introduced in [5] and studied in [3] etc. In this paper, L-similarity is used to establish our algorithms. Let be an alphabet, L ⊆ ∗ a "nite language, and l the length of the longest word(s) in L. Let x; y ∈ ∗ . We de"ne the following relations: (1) x ∼L y if for all z ∈ ∗ such that |xz|6l and |yz|6l, xz ∈ L iC yz ∈ L; (2) x L y if x ∼L y does not hold. The relation ∼L is called similarity relation with respect to L. Note that the relation ∼L is reNexive, symmetric, but not transitive. For example, let = {a; b} and L = {aab; baa; aabb}. It is clear that aab ∼L aabb (since aabw ∈ L and aabbw ∈ L if |aabbw|64; i.e. w = ) and aabb ∼L baa, but aab L baa (since for w = b we have aabb ∈ L; baab ∈= L and |baab| = |aabb|64). The following lemma is proved in [3]: Lemma 1. Let L ⊆ ∗ be a 4nite language and x; y; z ∈ ∗ ; |x|6|y|6|z|. The following statements hold: (1) If x ∼L y; x ∼L z; then y ∼L z.

6

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

(2) If x ∼L y; y ∼L z; then x ∼L z. (3) If x ∼L y; y L z; then x L z. If x L y and y ∼L z, we cannot say anything about the similarity relation between x and z. Example 2. Let x; y; z ∈ ∗ , |x|6|y|6|z|. We may have (1) x L y; y ∼L z and x ∼L z, or (2) x L y; y ∼L z and x L z. Indeed, if L = {aa; aaa; bbb; bbbb; aaab} we have (1) if we choose x = aa, y = bbb, z = bbbb, and (2) if we choose x = aa, y = bba, z = abba. Denition 3. Let L ⊆ ∗ be a "nite language. (1) A set S ⊆ ∗ is called an L-similarity set if x ∼L y for every pair x; y ∈ S. (2) A sequence of words [x1 ; : : : ; xn ] over is called a dissimilar sequence of L if xi L xj for each pair i; j, 16i; j6n and i = j. (3) A dissimilar sequence [x1 ; : : : ; xn ] is called a canonical dissimilar sequence of L if there exists a partition ! = {S1 ; : : : ; Sn } of ∗ such that for each i, 16i6n, xi ∈ Si , and Si is a L-similarity set. (4) A dissimilar sequence [x1 ; : : : ; xn ] of L is called a maximal dissimilar sequence of L if for any dissimilar sequence [y1 ; : : : ; ym ] of L, m6n. Theorem 4. A dissimilar sequence of L is a canonical dissimilar sequence of L if and only if it is a maximal dissimilar sequence of L. Proof. Let L be a "nite language. Let [x1 ; : : : ; xn ] be a canonical dissimilar sequence of L and ! = {S1 ; : : : ; Sn } the corresponding partition of ∗ such that for each i, 16i6n; Si is an L-similarity set. Let [y1 ; : : : ; ym ] be an arbitrary dissimilar sequence of L. Assume that m¿n. Then there are yi and yj , i = j, such that yi ; yj ∈ Sk for some k, 16k6n. Since Sk is a L-similarity set, yi ∼L yj . This is a contradiction. Then, the assumption that m¿n is false, and we conclude that [x1 ; : : : ; xn ] is a maximal dissimilar sequence. Conversely, let [x1 ; : : : ; xn ] a maximal dissimilar sequence of L. Without loss of generality we can suppose that |x1 |6 · · · 6|xn |. For i = 1; : : : ; n, de"ne Xi = {y ∈ ∗ | y ∼L xi

and

y ∈= Xj

for j¡i}:

Note that for each y ∈ ∗ , y ∼L xi for at least one i, 16i6n, since [x1 ; : : : ; xn ] is a maximal dissimilar sequence. Thus, ! = {X1 ; : : : ; Xn } is a partition of ∗ . The remaining task of the proof is to show that each Xi , 16i6n, is a similarity set. We assume the contrary, i.e., for some i, 16i6n, there exist y; z ∈ Xi such that y L z. We know that xi ∼L y and xi ∼L z by the de"nition of Xi . We have the following three cases: (1) |xi |¡|y|; |z|, (2) |y|6|xi |6|z| (or |z|6|xi |6|y|), and (3) |xi |¿|y|; |z|. If (1) or (2), then y ∼L z by Lemma 1. This would contradict our assumption. If (3), then it

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

7

is easy to prove that y xj and z xj , for all j = i, using Lemma 1 and the de"nition of Xi . Then we can replace xi by both y and z to obtain a longer dissimilar sequence [x1 ; : : : ; xi−1 ; y; z; xi+1 ; : : : ; xn ]. This contradicts the fact that [x1 ; : : : ; xi−1 ; xi ; xi+1 ; : : : ; xn ] is a maximal dissimilar sequence of L. Hence, y ∼ z and Xi is a similarity set. Corollary 5. For each 4nite language L; there is a unique number N (L) which is the number of elements in any canonical dissimilar sequence of L. Theorem 6. Let S1 and S2 be two L-similarity sets and x1 and x2 the shortest words in S1 and S2 ; respectively. If x1 ∼L x2 then S1 ∪ S2 is a L-similarity set. Proof. It su0ces to prove that for an arbitrary word y1 ∈ S1 and an arbitrary word y2 ∈ S2 , y1 ∼L y2 holds. Without loss of generality, we assume that |x1 |6|x2 |. We know that |x1 |6|y1 | and |x2 |6|y2 |. Since x1 ∼L x2 and x2 ∼L y2 , we have x1 ∼L y2 (Lemma 1(2)), and since x1 ∼L y1 and x1 ∼L y2 , we have y1 ∼L y2 (Lemma 1(1)). 4. Similarity relations on states Let A = (Q; ; ; 0; F) be a DFA and L = L(A). Then it is clear that if (0; x) = (0; y) = q for some q ∈ Q, then x ≡L y and, thus, x ∼L y. Therefore, we can also de"ne similarity as well as equivalence relations on states. Denition 7. Let A = (Q; ; ; 0; F) be a DFA. We de"ne, for each state q ∈ Q, level(q) = min{|w| | (0; w) = q}; i.e., level(q) is the length of the shortest path from the initial state to q. If A = (Q; ; ; 0; F) is a DFA, for each q ∈ Q, we denote xA (q) = min{w | (0; w) = q}, where the minimumis taken according to the quasi-lexicographical order, and LA (q) = {w ∈ ∗ | (q; w) ∈ F}. When the automaton A is understood, we write xq instead of xA (q) and Lq instead LA (q). The length of xq is equal to level(q), therefore level(q) is de"ned for each q ∈ Q. Denition 8. Let A = (Q; ; ; 0; F) be a DFA and L = L(A). We say that p ≡A q (state p is equivalent to q in A) if for every w ∈ ∗ , (p; w) ∈ F iC (q; w) ∈ F. Denition 9. Let A = (Q; ; ; 0; F) be a DFCA of a "nite language L. Let level(p) = i and level(q) = j, m = max{i; j}. We say that p ∼A q (state p is L-similar to q in A) if for every w ∈ 6l−m , (p; w) ∈ F iC (q; w) ∈ F. Lemma 10. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let x; y ∈ 6l such that (0; x) = p and (0; y) = q. If p ∼A q then x ∼L y.

8

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Fig. 1. If x ∼L y then we do not have always that (0; x) ∼A (0; y).

Proof. Let level(p) = i and level(q) = j, m = max{i; j}, and p ∼A q. Choose an arbitrary w ∈ ∗ such that |xw|6l and |yw|6l. Because i6|x| and j6|y| it follows that |w|6l − m. Since p ∼A q we have that (p; w) ∈ F iC (q; w) ∈ F, i.e. (0; xw) ∈ F iC (0; yw) ∈ F, which means that xw ∈ L(A) iC yw ∈ L(A). Hence x ∼L y. Lemma 11. Let A = (Q; ; ; 0; F) be DFCA of a 4nite language L. Let level(p) = i and level(q) = j; m = max{i; j}, and x ∈ i ; y ∈ j such that (0; x) = p and (0; y) = q. If x ∼L y then p ∼A q. Proof. Let x ∼L y and w ∈ 6l−m . If (p; w) ∈ F, then (0; xw) ∈ F. Because x ∼L y, it follows that (0; yw) ∈ F, so (q; w) ∈ F. Using the symmetry we get that p ∼A q. Corollary 12. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let level (p) = i and level(q) = j; m = max{i; j}; and x1 ∈ i ; y1 ∈ j ; x2 ; y2 ∈ 6l ; such that (0; x1 ) = (0; x2 ) = p and (0; y1 ) = (0; y2 ) = q. If x1 ∼L y1 then x2 ∼L y2 . Example 13. If x1 and y1 are not minimal, i.e. |x1 |¿i, but p = (0; x1 ) or |y1 |¿j, but q = (0; y1 ), then the conclusion of Corollary 12 is not necessarily true. Let L = {a; b; aa; aaa; bab}, so l = 3. A DFCA of L is shown in Fig. 1 and we have that b ∼L bab, but b L a (ba ∈= L; aa ∈ L and |ba| = |aa|63). Corollary 14. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L and p; q ∈ Q; p = q. Then xp ∼L xq i9 p ∼A q. If p ∼A q, and level(p)6level(q) and q ∈ F then p ∈ F. Lemma 15. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let s; p; q ∈ Q such that level(s) = i; level(p) = j, level(q) = m; i6j6m. The following statements are true: (1) If s ∼A p; s ∼A q; then p ∼A q. (2) If s ∼A p; p ∼A q; then s ∼A q. (3) If s ∼A p; p A q; then s A q. Proof. We apply Lemma 1 and Corollary 14.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

9

Lemma 16. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. Let level(p) = i; level(q) = j; and m = max{i; j}. If p ∼A q then Lp ∩ 6l−m = Lq ∩ 6l−m and Lp ∪ Lq is a L-similarity set. Proof. Let w ∈ Lp ∩ 6l−m . Then (p; w) ∈ F, and |w|6l − m. Since p ∼A q, we have (p; w) ∈ F; so w ∈ Lq ∩ 6l−m . Lemma 17. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L. If p ∼A q for some p; q ∈ Q; i = level(p); j = level(q) and i6j; p = q; q = 0. Then we can construct a DFCA A = (Q ; ; ; 0; F ) of L such that Q = Q − {q}; F = F − {q}; and (s; a) if (s; a) = q; (s; a) = p (s; a) = q for each s ∈ Q and a ∈ . Thus; A is not a minimal DFCA of L. Proof. It su0ces to prove that A is a DFCA of L. Let l be the length of the longest word(s) in L and assume that level(p) = i and level(q) = j; i6j. Consider a word w ∈ 6l . We now prove that w ∈ L iC (0; w) ∈ F . If there is no pre"x w1 of w such that (0; w1 ) = q, then clearly (0; w) ∈ F iC (0; w) ∈ F. Otherwise, let w = w1 w2 where w1 is the shortest pre"x of w such that (0; w1 ) = q. In the remaining, it su0ces to prove that (p; w2 ) ∈ F iC (q; w2 ) ∈ F. We prove this by induction on the length of w2 . First consider the case |w2 | = 0, i.e., w2 = . Since p ∼A q; p ∈ F iC q ∈ F. Then p ∈ F iC q ∈ F by the construction of A . Thus, (p; w2 ) ∈ F iC (q; w2 ) ∈ F. Suppose that the statement holds for |w2 |¡l for l 6l − |w1 |. (Note that l − |w1 |6l − j.) Consider the case that |w2 | = l . If there does not exist u ∈ + such that u 4p w2 and (p; u) = q, then (p; w2 ) ∈ F − {q} iC (q; w2 ) ∈ F − {q}, i.e., (p; w2 ) ∈ F iC (q; w2 ) ∈ F. Otherwise, let w2 = uv and u be the shortest nonempty pre"x of w2 such that (p; u) = q. Then |v|¡l (and (p; u) = p). By induction hypothesis, (p; v) ∈ F iC (q; v) ∈ F. Therefore, (p; uv) ∈ F iC (q; uv) ∈ F. Lemma 18. Let A be a DFCA of L and L = L(A). Then x ≡L y implies x ∼L y. Proof. Let l be the length of the longest word(s) in L. Let x ≡L y. So, for each z ∈ ∗ ; xz ∈ L iC yz ∈ L . We now consider all words z ∈ ∗ , such that |xz|6l and |yz|6l. Since L = L ∩ 6l and xz ∈ L iC yz ∈ L , we have xz ∈ L iC yz ∈ L. Therefore, x ∼L y by the de"nition of ∼L . Corollary 19. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L; L = L(A). Then p ≡A q implies p ∼A q. Corollary 20. A minimal DFCA of L is a minimal DFA.

10

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Proof. Let A = (Q; ; ; 0; F) be a minimal DFCA of a "nite language L. Suppose that A is not minimal as a DFA for L(A), then there exists p; q ∈ Q such that p ≡L q, then p ∼A q. By Lemma 17 it follows that A is not a minimal DFCA, contradiction. Remark 21. Let A be a DFCA of L and A a minimal DFA. Then A may not be a minimal DFCA of L. Example 22. We take the DFAs:

Fig. 2. Minimal DFA is not always a minimal DFCA.

The DFA A in Fig. 2 is a minimal DFA and a DFCA of L = {; a; aa} but not a minimal DFCA of L, since the DFA B in Fig. 2 is a minimal DFCA of L. Theorem 23. Any minimal DFCA of L has exactly N (L) states. Proof. Let A = (Q; ; ; 0; F) be DFCA of a "nite language L, and #Q = n. Suppose that n¿N (L). Then there exist p; q ∈ Q; p = q, such that xp ∼L xq (because of the de"nition of N (L)). Then p ∼A q by Lemma 14. Thus, A is not minimal, a contradiction. Suppose that N (L)¿n. Let [y1 ; : : : ; yN (L) ] be a canonical dissimilar sequence of L. Then there exist i; j; 16i; j6N (L) and i = j, such that (0; yi ) = (0; yj ) = q for some q ∈ Q. Then yi ∼L yj . Again a contradiction. Therefore, we have n = N (L). 5. The construction of minimal DFCA The "rst part of this section describes an algorithm that determines the similarity relations between states. The second part is to construct a minimal DFCA assuming that the similarity relation between states is known. An ordered DFA is a DFA where (i; a) = j implies that i6j, for all states i; j and letters a. Obviously for such a DFA #Q − 1 is the sink state. 5.1. Determining similarity relation between states The aim is to present an algorithm which determines the similarity relations between states.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

11

Let A = (Q; ; ; 0; F) a DFCA of a "nite language L. De"ne D−1 (A) = {s ∈ Q|(s; w) ∈= F, for all w ∈ ∗ }; for each s ∈ Q let 's (A) = min{w|(s; w) ∈ F}, and Di (A) = {s ∈ Q ||'s | = i}, for each i = 0; 1; : : :, where minimum is taken according to the quasi-lexicographical order. If the automaton A is understood then we write Di and 's instead of Di (A) and respectively 's (A). Lemma 24. Let A = (Q; ; ; 0; F) be a DFCA of a 4nite language L; and p ∈ Di ; q ∈ Dj . If i = j; i; j¿0 then p q. Proof. We can assume that i¡j. Then obviously (p; 'p ) ∈ F and (q; 'p ) ∈= F. Since l¿|xp | + |'p |; l¿|xq | + |'q |, and i¡j, it follows that |'p |¡|'q |. So, we have that |'p |6 min(l − |xp |; l − |xq |). Hence, p q. Lemma 25. Let A = (Q; ; 0; ; F) be an ordered DFA accepting L; p; q ∈ Q − D−1 ; and either p; q ∈ F or p; q ∈= F. If for all a ∈ ; (p; a) ∼A (q; a); then p∼A q. Proof. Let a ∈ and (p; a) = r and (q; a) = s. If r ∼A s then for all w such that |w|¡l − max{|xA (s)|; |xA (r)|}, xA (r)w ∈ L iC xA (s)w ∈ L. Using Lemma 10 we also have: xA (q)aw ∈ L iC xA (s)w ∈ L for all w ∈ ∗ ; |w|6l − |xA (s)|, and xA (p)aw ∈ L iC xA (r)w ∈ L for all w ∈ ∗ ; |w|6l − |xA (r)|. Hence xA (p)aw ∈ L iC xA (q)aw ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (r)|; |xA (s)|}. Because |xA (r)|6|xA (q)a| = |xA (q)| + 1 and |xA (s)|6|xA (p)a| = |xA (p)| + 1, we get xA (p)aw ∈ L iC xA (q)aw ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (p)|; |xA (q)|} − 1. Since a ∈ is chosen arbitrary, we conclude that xA (p)w ∈ L iC xA (q)w ∈ L, for all w ∈ ∗ ; |w|6l − max{|xA (p)|; |xA (q)|}, i.e. xA (p) ∼A xA (q). Therefore, by using Lemma 11, we get that p ∼A q. Lemma 26. Let A = (Q; ; 0; ; F) be an ordered DFA accepting L such that (0; w) = s implies |w| = |xs | for all s ∈ Q. Let p; q ∈ Q − D−1 . If there exists a ∈ such that (p; a) A (q; a); then p A q. Proof. Suppose that p ∼A q. Then for all aw ∈ l−m ; (p; aw) ∈ F iC (q; aw) ∈ F, where m = max{level(p); level(q)}. So ((p; a); w) ∈ F iC ((q; a); w) ∈ F for all w ∈ l−m−1 . Since |x(p;a) | = |xp | + 1 and |x(q;a) | = |xq | + 1 it follows by de"nition that (p; a) ∼A (q; a). This is a contradiction. Our algorithm for determining the similarity relation between the states of a DFA (DFCA) of a "nite language is based on Lemmas 25 and 26. However, most of DFA (DFCA) do not satisfy the condition of Lemma 26. So, we shall "rst transform the given DFA (DFCA) into one that does. Let A = (QA ; ; A ; 0; FA ) be a DFCA of L. We construct the minimal DFA for the language 6l , B = (QB ; ; B ; 0; FB ) (QB = {0; : : : ; l; l + 1}, B (i; a) = i + 1, for all i; 06i6l; B (l + 1; a) = l + 1, for all a ∈ ; FB = {0; : : : ; l}). The DFA B will have exact l + 2 states.

12

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

Now we use the standard Cartesian product construction (for details see, e.g., [2]) for the DFA C = (QC ; ; C ; q0 ; FC ) such that L(C) = L(A) ∩ L(B), (taking the automata in this order) and we eliminate all inaccessible states. Obviously, L(C) = L and C satis"es the condition of Lemma 26. Lemma 27. For the DFA C constructed above; if C ((0; 0); w) = (p; q); then |w| = q. Proof. We have C ((0; 0); w) = (p; q), so B (0; w) = q therefore |w| = q. Lemma 28. For the DFA C constructed above we have (p; q) ∼C (p; r). Proof. If p ∈ D−1 (A), the lemma is obvious. Suppose now that p ∈= D−1 and q6r. Then r6l so B (q; w) ∈ FB and B (r; w) ∈ FB for w ∈ 6l−r . It follows that C ((p; q); w) ∈ FC iC C ((p; r); w) ∈ FC , i.e. (p; q) ∼C (p; r). Lemma 29. For the DFA C constructed above we have that (#Q − 1; l + 1 − i) ∼C *; * ∈ Dj ; j = i; : : : ; l; 06i6l. Proof. We have that C ((#Q − 1; l + 1 − i); w) ∈= FC for all w ∈ ∗ , C (*; w) ∈= FC for |w|¡j. It is clear that level((#Q − 1; l + 1 − i) = l + 1 − i and level(*)6l − j6l − i. Let w ∈ 6(l−(l+1−i)) = 6i−1 . Since both C (*; w) ∈= FC and C ((#Q−1; l+1−i); w) ∈= FC it follows the conclusion. Now we are able to present an algorithm, which determines the similarity relation between the states of C. Note that QC is ordered by that (pA ; pB )¡(qA ; qB ) if pB ¡qB or pB = qB and pA ¡qA . Attaching to each state of C is a set of similar states. For *; + ∈ QC , if * ∼C + and *¡+, then + is stored in the set of similar states for *. We assume that QA = {0; 1; : : : ; n − 1} and A is reduced (so n − 1 is the sink state of A). (1) Compute Di (C); −16i6l. (2) Initialize the similarity relation by specifying: (a) For all (n − 1; p); (n − 1; q) ∈ QC , (n − 1; p) ∼C (n − 1; q). (b) For all (n−1; l+1−i) ∈ QC ; (n−1; l+1−i) ∼C * for all * ∈ Dj (C); j = i; : : : ; l, 06i6l. (3) For each Di (C); −16i6l, create a list Listi , which is initialized to ∅. (4) For each * ∈ QC − {(n − 1; q) | q ∈ QB }, following the reversed order of QC , do the following: Assuming * ∈ Di (C). (a) For each + ∈ Listi , if C (*; a) ∼C C (+; a) for all a ∈ , then * ∼C +. (b) Put * on the list Listi . By Lemma 24 we need to determine only the similarity relations between states of the same Di (C) set. Step 2(a) follows from Lemma 28, 2(b) from Lemma 29 and Step 4 from Lemma 15.

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

13

Remark 30. The above algorithm has complexity O((n × l)2 ), where n is the number of states of the initial DFA (DFCA) and l is the maximum accepted length for the "nite language L. 5.2. The construction of a minimal DFCA As the input to the algorithm, we have the above DFA C and, for each * ∈ QC , a set S* = {+ ∈ QC | * ∼C + and *¡+}. The output is D = (QD ; ; D ; q0 ; FD ), a minimal DFCA for L. We de"ne the following: i = 0; qi = 0; T = QC − Sqi , (x0 = ); while (T = ∅) do the following: i = i + 1; qi = min{s ∈ T }; T = T − Sqi ; (xi = min{w|C (0; w) ∈ Si }); m = i. Then QD = {q0 ; : : : ; qm−1 }; q0 = 0; D (qi ; a) = qj iC s = min Sqi and C (s; a) ∈ Sqj ; FD = {i | Si ∩ FC = ∅}. Note that the constructions of xi above are useful for the proofs in the following only, where the min (minimum) operator for xi is taken according to the lexicographical order. According to the algorithm we have a total ordering of the states QC : (p; q)6(r; s) if (p; q) = (r; s) or q¡s or q = s and p¡r. Hence D (i; a) = j iC D (0; xi a) = j. Also, from the construction (i.e. the total order on QC ) it follows that 0 = | x0 | 6|x1 |6 · · · 6 |xm−1 |. Lemma 31. The sequence [x0 ; x1 ; : : : ; xm−1 ] constructed above is a canonical L-dissimilar sequence. Proof. We construct the sets Xi = {w ∈ ∗ |(0; w) ∈ Si }. Obviously Xi = ∅. From Lemma 10 it follows that Xi is a L-similarity set for all 06i6m − 1. Let w ∈ ∗ . Because (Si )16i6m−1 is a partition of Q, w ∈ Xi for some 06i6 n − 1, so (Xi )06i6n−1 is a partition of ∗ and therefore [x0 ; x1 ; : : : ; xn−1 ] is a canonical L-dissimilar sequence. Corollary 32. The automaton D constructed above is a minimal DFCA for L. Proof. Since the number of states is equal to the number-of-elements of a canonical L-dissimilar sequence, we only have to prove that D is a cover automaton for L. Let w ∈ 6l . We have that D (0; w) ∈ FD iC C ((0; 0); w) ∈ Si such that Si ∩ FC = ∅, i.e. xi ∼C w. Since |w|6l, xi ∈ L iC w ∈ L (because C is a DFCA for L).

14

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

6. Boolean operations We shall use similar constructions as in [2] for constructing DFCA of languages which are a result of boolean operations between "nite languages. The modi"cations are suggested by the previous algorithm. We "rst construct the DFCA which satis"es the assumption of Lemma 26 and afterwards we can minimize it using the general algorithm. Since the minimization will follow in a natural way we shall present only the construction of the necessary DFCA. Let Ai = (Qi ; ; i ; 0; Fi ) be a DFCA of the "nite languages Li , li = max{|ww ∈ Li }; i = 1; 2. 6.1. Intersection We construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F); where l = min{l1 ; l2 }, ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 ; p ∈ Q2 ; q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1) and F = {(s; p; q) | s ∈ F1 ; p ∈ F2 ; q6l}: Theorem 33. The automaton A constructed above is a DFCA for L = L(A1 ) ∩ L(A2 ). Proof. We have the following relations: w ∈ L1 ∩ L2 iC |w|6l and w ∈ L1 and w ∈ L2 iC |w|6l and w ∈ L(A1 ) and w ∈ L(A2 ). The rest of the proof is obvious. 6.2. Union Assuming that l1 ¿l2 , we construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l+1}; ; ; (0; 0; 0); F), where l = max{l1 ; l2 }, m = min{l1 ; l2 }; ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 , p ∈ Q2 , q6l, and ((s; p; l+1); a) = (1 (s; a); 2 (p; a); l+1) and F = {(s; p; q) | s ∈ F1 or p ∈ F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 34. The automaton A constructed above is a DFCA for L = L(A1 ) ∪ L(A2 ). Proof. We have the following relations: w ∈ L1 ∪ L2 iC |w|6m and w ∈ L1 or w ∈ L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) or w ∈ L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious. 6.3. Symmetric di9erence Assuming that l1 ¿l2 , we construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F);

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

15

where l = max{l1 ; l2 }; m = min{l1 ; l2 }; ((s; p; q); a) = (1 (s; a); 2 (p; a); q + 1), for s ∈ Q1 , p ∈ Q2 ; q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1) and F = {(s; p; q) | s ∈ F1 exclusive or p ∈ F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 35. The automaton A constructed above is a DFCA for L = L(A1 ),L(A2 ). Proof. We have the following relations: w ∈ L1 ,L2 iC |w|6m and w ∈ L1 xor w ∈ L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) xor w ∈ L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious. 6.4. Di9erence We construct the following DFA: A = (Q1 × Q2 × {0; : : : ; l + 1}; ; ; (0; 0; 0); F); where l = max{l1 ; l2 }; m = min{l1 ; l2 } and ((s; p; q); a) = (1 (s; a); 2 (p; a); q+1), for s ∈ Q1 ; p ∈ Q2 , q6l, and ((s; p; l + 1); a) = (1 (s; a); 2 (p; a); l + 1). If l1 ¡l2 then F = {(s; p; q) | s ∈ F1 and p ∈= F2 ; q6m} and otherwise, F = {(s; p; q) | s ∈ F1 and p ∈= F2 ; q6m} ∪ {(s; p; q) | s ∈ F1 and m¡q6l}. Theorem 36. The automaton A constructed above is a DFCA for L = L(A1 ) − L(A2 ). Proof. We have the following relations: w ∈ L1 −L2 iC |w|6m and w ∈ L1 and w ∈= L2 , or m¡|w|6l and w ∈ L1 iC |w|6m and w ∈ L(A1 ) and w ∈= L(A2 ), or m¡|w|6l and w ∈ L(A1 ). The rest of the proof is obvious.

References [1] J.L. BalcRazar, J. Diaz, J. GabarrRo, Uniform characterisations of non-uniform complexity measures, Inform. and Control 67 (1985) 53–89. [2] C. Cˆampeanu, Regular languages and programming languages, Rev. Roumaine Linguistique – CLTA 23 (1986) 7–10. [3] C. Dwork, L. Stockmeyer, A time complexity gap for two-way probabilistic "nite-state automata, SIAM J. Comput. 19 (1990) 1011–1023. [4] J.E. Hopcroft, J.D. Ullman, Introduction to Automata Theory, Languages, and Computation, Addison-Wesley, Reading, MA, 1979. [5] J. Kaneps, R. Freivalds, Minimal Nontrivial Space Space Complexity of Probabilistic One-Way Turing Machines, in: B. Rovan (Ed.), Proc. Mathematical Foundations of Computer Science, BanskTa Bystryca, Czechoslovakia, August 1990, Lecture Notes in Computer Science, vol. 452, Springer, New York, 1990, pp. 355 –361. [6] J. Kaneps, R. Freivalds, Running time to recognise non-regular languages by 2-way probabilistic automata, in ICALP’91, Lecture Notes in Computer Science, vol. 510, Springer, New York, 1991, pp. 174 –185. [7] J. Paredaens, R. Vyncke, A class of measures on formal languages, Acta Inform. 9 (1977) 73–86. [8] J. Shallit, Y. Breitbart, Automaticity I: Properties of a Measure of Descriptional Complexity, J. Comput. System Sci. 53 (1996) 10–25.

16

C. Cˆampeanu et al. / Theoretical Computer Science 267 (2001) 3–16

[9] A. Salomaa, Theory of Automata, Pergamon Press, Oxford, 1969. [10] K. Salomaa, S. Yu, Q. Zhuang, The state complexities of some basic operations on regular languages, Theoret. Comput. Sci. 125 (1994) 315–328. [11] S. Yu, Regular languages, in: G. Rozenberg, A. Salomaa (Eds.), Handbook of Formal Languages, Springer, Berlin, 1997. [12] S. Yu, Q. Zhung, On the State Complexity of Intersection of Regular Languages, ACM SIGACT News 22 (3) (1991) 52–54.