[studies in fuzziness and soft computing] formal languages and applications volume 148 || finite...

31
3 Finite Automata* Sheng Yu Department of Computer Science University of Western Ontario London, Ontario, Canada N6A 5B7 E-mail: syuClcsd.uwo.ca The finite automata model is one of the oldest in formal language theory. For example, finite state machines were used to model neuron nets by McCulloch and Pitts in 1943 [48J; automata with output were introduced by Mealy [50J and Moore [53J in the mid fifties; and the introduction of nondeterministic finite automata by Rabin and Scott in 1959 [58J. Finite automata have had a wide range of applications. One of the most well-known applications has been lexical analysis in programming language compilation [1, 2J. Other notable applications include circuit design [7J, text editing, and pattern matching [37J. Their application in the recent years has been extended to include parallel processing [3, 18, 26J, image generation and compression [4, 14, 15, 17, 69J, type theory for object-oriented languages [55], DNA computing [16, 28], etc. There is a very large amount of established research on finite automata. One can find a long list of excellent books that include chapters dedicated to finite automata, e.g., [29,60,49,21, 32, 61, 70, 57, 6J. Many results, including many recent results, on finite automata are considered to be very important and interesting. However, only a very limited amount of material can be in- cluded in this chapter. Besides the very basic results, we select those relatively recent results that are of general interest and have not been included in the standard texts. We choose, for instance, some basic results on alternating finite automata and fuzzy automata. In this chapter, we first describe three basic types of finite automata (FA): deterministic finite automata (DFA), nondeterministic finite automata (NFA), and alternating finite automata (AFA). All the three types of abstract ma- chines accept exactly the same family of languages, the regular languages. We then describe cover automata for finite languages and fuzzy automata for lexical analysis. * Part of the material is from [72]. C. Martín-Vide et al. (eds.), Formal Languages and Applications © Springer-Verlag Berlin Heidelberg 2004

Upload: gheorghe

Post on 08-Dec-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

3

Finite Automata*

Sheng Yu

Department of Computer Science University of Western Ontario London, Ontario, Canada N6A 5B7 E-mail: syuClcsd.uwo.ca

The finite automata model is one of the oldest in formal language theory. For example, finite state machines were used to model neuron nets by McCulloch and Pitts in 1943 [48J; automata with output were introduced by Mealy [50J and Moore [53J in the mid fifties; and the introduction of nondeterministic finite automata by Rabin and Scott in 1959 [58J.

Finite automata have had a wide range of applications. One of the most well-known applications has been lexical analysis in programming language compilation [1, 2J. Other notable applications include circuit design [7J, text editing, and pattern matching [37J. Their application in the recent years has been extended to include parallel processing [3, 18, 26J, image generation and compression [4, 14, 15, 17, 69J, type theory for object-oriented languages [55], DNA computing [16, 28], etc.

There is a very large amount of established research on finite automata. One can find a long list of excellent books that include chapters dedicated to finite automata, e.g., [29,60,49,21, 32, 61, 70, 57, 6J. Many results, including many recent results, on finite automata are considered to be very important and interesting. However, only a very limited amount of material can be in­cluded in this chapter. Besides the very basic results, we select those relatively recent results that are of general interest and have not been included in the standard texts. We choose, for instance, some basic results on alternating finite automata and fuzzy automata.

In this chapter, we first describe three basic types of finite automata (FA): deterministic finite automata (DFA), nondeterministic finite automata (NFA), and alternating finite automata (AFA). All the three types of abstract ma­chines accept exactly the same family of languages, the regular languages. We then describe cover automata for finite languages and fuzzy automata for lexical analysis.

* Part of the material is from [72].

C. Martín-Vide et al. (eds.), Formal Languages and Applications© Springer-Verlag Berlin Heidelberg 2004

56 Sheng Yu

3.1 Deterministic Finite Automata

A (deterministic or nondeterministic) finite automaton consists of a finite set of states, a finite alphabet of input symbols, and a set of transition rules. If the next state is always uniquely determined by the current state and the current input symbol, we say that the automaton is deterministic.

Formally, we define a deterministic finite automaton as follows: A deterministic finite automaton (DFA) A is a quintuple (Q, E, 8, s, F),

where Q is the finite set of states; E is the input alphabet; 8 : Q x E ---+ Q is the state transition function; sEQ is the starting state; and F ~ Q is the set of final states.

Note that, in general, we do not require the transition function 8 to be total, i.e., to be defined for every pair in Q x E. If 8 is total, then we call A a complete IJFil.

In the above definition, we also do not require that a DFA is connected if we view a DFA as a directed graph where states are nodes and transitions between states are arcs between nodes. A DFA such that every state is reachable from the starting state and reaches a final state is called a reduced DFA. A reduced DFA may not be a complete DFA.

Fig. 3.1. A deterministic finite automaton AI

Example 1. A DFA ill = (Q1, E 1, 81 , s1, F1) is shown in Figure 3.1, where Q1 = {O, 1, 2, 3}, E1 = {a, b}, 81 = 0, F1 = {3}, and 81 is defined as follows:

81{0, a) = 1, 81{1,a) = 1, 81{2,a) = 1, 81{3,a) =3,

81(0, b) = 1, 81{1,b) = 2, 81{2,b) =3, 81(3, b) = 3.

The DFA A1 is reduced and complete. Note that in a state transition diagram, we always represent final states with double circles and non-final states with single circles. 0

3 Finite Automata 57

A configuration of A = (Q, E, 6, s, F) is a word in Q E*, Le., a state q E Q followed by a word x E E* where q is the current state of A and x is the remaining part of the input. The starting configuration of A for an input word x E E* is sx. Accepting configurations are defined to be elements of F (followed by the empty word A).

A computation step of A is a transition from a configuration a to a con­figuration (3, denoted by a f- A (3, where f- A is a binary relation on the set of configurations of A. The relation f- A is defined by: for px, qy E QE*, px f- A qy if x = ay for some a E E and 6(p, a) = q. For example, Oabb f- At Ibb for the DFA AI. We use f- instead of f- A if there is no confusion. The kth power of f-, for k ~ 0, denoted f-k, is defined by a f-o a for all configurations a E Q E* j and a f-k (3, for k > 0 and a, (3 E QE*, if there exists 'Y E QE* such that a f-k-l 'Y and 'Y f- (3. The transitive closure and the reflexive and transitive closure of f- are denoted f-+ and f-*, respectively.

A configuration sequence of A is a sequence of configurations C1. ... , Cn, of A, for some n ~ 1, such that Ci f-A CHI for each i, 1 :5 i :5 n - 1. A configuration sequence is said to be an accepting configuration sequence if it starts with a starting configuration and ends with an accepting configuration.

The language accepted by a DFA A = (Q, E, 6, s, F), denoted L(A), is defined as follows:

L(A) = { w I sw f-* f for some f E F }.

For convenience, we define the extension of 6, 6* : Q x E* -+ Q, inductively as follows. We set 6*(q, A) = q and 6*(q, xa) = 6(6*(q, x), a), for q E Q, a E E, and x E E*. Then, we can also write

L(A) = {w 16*(s,w) = f for some f E F}.

The collection of all languages accepted by DFA is denoted CDFA. We call it the family of DFA languages. We will see later that the families of languages accepted by deterministic, nondeterministic, and alternating finite automata are the same. This family is again the same as the family of languages denoted by regular expressions. It is called the family of regular languages.

In the remaining of this section, we state several basic properties of DFA languages.

Theorem 3.1.1 The family of DFA languages, CDFA, is closed under union and intersection.

Proof Let Ll, L2 ~ E* be two arbitrary DFA languages such that Ll = L(Al) and L2 = L(A2) for some complete DFA Al = (Ql,E,61,SI,F1 ) and A2 = (Q2,E,62,S2,F2).

We first show that there exists a DFA A such that L(A) = Ll U L2. We construct A = (Q, E, 6, s, F) as follows:

Q = Ql X Q2,

58 Sheng Yu

s = (S1' S2), F = (F1 X Q2) U (Q1 X F2), and 0: Q1 X Q2 -+ Q1 X Q2 is defined by 0((P1,P2),a) = (01(P1,a) , 02(P2,a)).

The intuitive idea of the construction is that, for each input word, A runs A1 and A2 in parallel, starting from both the starting states. Having finished reading the input word, A accepts the word if either A1 or A2 accepts it. Therefore, L(A) = L(A1) U L(A2).

For intersection, the construction is the same except that F = F1 X F2. 0

Note that, in the above proof, the condition that A1 and A2 are complete is not necessary in the case of intersection. However, if either A1 or A2 is incomplete, the resulting automaton is incomplete.

Theorem 3.1.2 LDFA is closed under complementation.

Proof Let L E LDFA. It is clear that there is a complete DFA A = (Q, E, 0, s, F) such that L = L(A). Then, the complement of L, denoted L, is accepted by A = (Q, E, 0, s, Q - F). 0

3.2 Nondeterministic Finite Automata

The nondeterministic finite automata (NFA) model is a generalization of the DFA model where, for a given state and an input symbol, the number of possible transitions can be greater than one. An NFA is shown in Figure 3.2, where there are two possible transitions for state 0 and input symbol a: to state 0 or to state 1.

Formally, a nondeterministic finite automaton A is a quintuple (Q, E, 0, s, F) where Q, E, s, and F are defined exactly the same way as for a DFA, and o : Q x E -+ 2Q is the transition function, where 2Q denotes the power set of Q.

Fig. 3.2. A nondeterministic finite a.utoma.ton A2

A DFA can be considered an NFA, where each value of the transition function is either a singleton or the empty set.

The computation relation f- A: QE* x QE* of an NFA A is defined as follows: px f-A qy if x = ay and q E o(p,a) for p,q E Q, x,y E E*, and a E E. Then the language accepted by A is

3 Finite Automata 59

L(A) = { w I sw ~A f, for some f E F }.

Two automata are said to be equivalent if they accept exactly the same language.

Denote by CNFA the family of languages accepted by NFA. We show that CD FA = CNFA·

Lemma 3.2.1 For each NFA A of n states, there exists a complete DFA A' of at most 2n states such that L(A') = L(A).

Proof. Let A = (Q, E, 15, s, F) be an NFA such that IQI = n. We construct a DFA A' such that each state of A' is a subset of Q and the transition function is defined accordingly. More precisely, we define A' = (Q', E, 15', s', F') where Q' = 2Q; 15' : Q' x E --+ Q' is defined by, for H,P2 E Q' and a E E, r5'(Pb a) = P2 if

P2 = {q E Q I there exists p E Pi such that q E r5(p,a) };

s' = {s}; and F' = {P E Q'I PnF -I0}. Note that A' has 2n states. It is straightforward to show that L(A) = L(A'). However, we omit the

proof here. 0

The method used above is called the subset construction. In the worst case, all the subsets of Q are necessary. Then the resulting DFA would consist of 2n

states if n is the number of states of the corresponding NFA. Note that if the resulting DFA is not required to be a complete DFA, the empty subset of Q is not needed. So, the resulting DFA consists of 2n - 1 states in the worst case. However, in most cases, not all the subsets are necessary. Thus, it suffices to construct only those subsets that are reachable from {s}.

NFA can be further generalized to have state transitions without reading any input symbol. Such transitions are called >..-transitions in the following definition.

A nondeterministic finite automaton with >..-transitions (>..-NFA) A is a quintuple (Q, E, 15, s, F) where Q, E, s, and F are the same as for an NFA; and 15 : Q x (E U {>..}) --+ 2Q is the transition function.

Fig. 3.3. A >.-NFA A3

Figure 3.3 shows the transition diagram of a >..-NFA, where the transition function 15 can also be written as follows:

60 Sheng Yu

8(0, a) = {O}, 8(1,b) = {I}, 8(2, c) = {2}.

and 8(q, X) = 0 in all other cases.

8(0, A) = {I}, 8(1, A) = {2},

For a A-NFA A = (Q, 17, 8, s, F), the binary relation f-A: Q17* x Q17* is defined as follows: px f- A qy, for p, q E Q and x, y E 17*, if x = ay and q E 8(p, a) or if x = y and q E 8(p, A). The language accepted by A is again defined as

L(A) = {w I sw f-~ J, for some J E F}.

For example, the language accepted by A3 of Figure 3.3 is

We are going to show that for each A-NFA, there exists an NFA that accepts exactly the same language. First, we give the following definition.

Let A = (Q, 17, 8, s, F) be a A-NFA. The A-closure of a state q E Q, denoted A-closure(q), is the set of all states that are reachable from q by zero or more A-transitions, i.e.,

A-closure(q) = {p E Q I q f-~ p }.

Theorem 3.2.1 For each A-NFA A, there exists an NFA A' such that L(A) = L(A').

Proof Let A = (Q,17,8,s,F) be a A-NFA. We construct an NFA A' (Q, 17, 8', s, F') where for each q E Q and a E 17,

8'(p,a) = c5(p,a) U u c5(q, a) , qEA-closure(p )

and F' = {q I A-closure(q) n F i=- 0 }.

The reader can verify that L(A) = L(A'). o

Consider A-NFA A3 which is shown in Figure 3.3. We have A-closure(O) = {O, 1, 2}, A-closure(l) = {I, 2}, and A-closure(2) = {2}. An equivalent NFA is shown in Figure 3.4, which is obtained by following the construction specified in the above proof.

Let M1 = (QI,17,c5I,s1,F1) and M2 = (Q2,17,82,s2,F2) be two A-NFA and assume that Q1 n Q2 = 0. Then it is straightforward to construct A­NFA M1 +M2, M 1M2, and Mi such that L(M1 +M2) = L(M1) U L(M2)' L(M1M2) = L(MdL(M2)' and L(Mi) = (L(M1))*' respectively. The con­structions are illustrated by the diagrams in Figure 3.5. Formal definitions of the A-NFA are listed below:

3 Finite Automata 61

Fig. 3.4. An NFA Aa

• Union M1 +M2 = (Q, E, 8, s, F) such that L(M1 +M2) = L(M1) UL(M2), where Q = Q1 UQ2 U {s}, S ¢ Q1 UQ2, F = F1 UF2, and

8(s,>.) = {S1,S2}, 8(q,a) = 81(q,a) if q E Q1 and a E Eu {>.}, 8(q, a) = 82(q, a) if q E Q2 and a E E U {>.}.

• Catenation M1M2 = (Q, E, 8, s, F) such that L(M1M2) = L(M1)L(M2), where Q = Q1 U Q2, S = S1, F = F2, and

8(q,a) = 81(q,a) if q E Q1 and a E E or q E Q1 - F1 and a = >., 8(q,>') = 81(q,>.) U {S2} if q E F1, 8(q, a) = 82(q, a) if q E Q2 and a E E U {>.}.

• Star Mi = (Q,E,8,s,F) such that L(Mi) = (L(MI))*, where Q = Q1 U {s}, s ¢ Q1, F = F1 U {s }, and

8(s,>.) = {sI}, 8(q, >.) = 81(q, >.) U {sI} if q E F1, 8(q, a) = 81 (q, a) if q E Q1 and a E E or q E Q1 - F1 and a = >..

Intersection and complementation are more convenient to do using the DFA representation.

Another form of generalization of NFA is defined in the following. A NFA with nondeterministic starting state (NNFA) A = (Q, E, 8, S, F) is

an NFA except that there is a set of starting states S rather than exactly one starting state. Thus, for an input word, the computation of A starts from a nondeterministic ally chosen starting state.

Clearly, for each NNFA A, we can construct an equivalent >.-NFA A' by adding to A a new state s and a >.-transition from s to each of the starting states in S, and defining s to be the starting state of A'. Thus, NNFA ac­cept exactly the same family of languages as NFA (or DFA or >.-NFA). Each NNFA can also be transformed directly to an equivalent DFA using a subset construction, which is similar to the one for transforming an NFA to a DFA except that the starting state of the resulting DFA is the set of all the starting states of the NNFA. So, we have the following:

Theorem 3.2.2 For each NNFA A of n states, we can construct an equiva­lent DFA A' of at most 2n states.

62 Sheng Yu

M/

0 M/

0

0 Ml

0

(a) Union

0 1..

..

MId2

(b) Catenation

(c) Star

o o

M .. M

0 M2

0

Fig. 3.5. Union, Catenation, and Star operations on A-NFA

Each NNFA has a matrix representation defined as follows [61J: Let A = (Q,E,8,S, F) be an NNFA and assume that Q = {ql,q2, ... ,qn}. A mapping h of E into the set of n x n Boolean matrices is defined by setting the (i,j)th entry in the matrix h(a) , a E E, to be 1 if qj E 8(qi, a), i.e., there is an a-transition from qi to qj. We extend the domain of h from E to E* by

h() { I if w = A, w = h(wo)h(a) if w = woa,

where I is the n x n identity matrix and the juxtaposition of two matrices denotes the multiplication of the two Boolean matrices, where 1\ and V are

3 Finite Automata 63

the basic operations. A row vector 7r of n entries is defined by setting the ith entry to 1 if qi E S. A column vector ~ of n entries is defined by setting the ith entry to 1 if qi E F. The following theorem has been proved in [61].

Theorem 3.2.3 Let wE E*. Then w E L(A) if and only if 7rh(w)~ = 1.

3.3 Alternating Finite Automata

The notion of alternation is a natural generalization of nondeterminism. It received its first formal treatment by Chandra, Kozen, and Stockmeyer in 1976 [11, 12, 38]. Various types of alternating 'lUring machines (ATM) and alternating pushdown machines and their relationship to complexity classes have been studied [13, 18, 33, 34, 46, 39, 56, 59, 19, 30]. Such machines are useful for a better understanding of many questions in complexity theory. It is proved in [12] that alternating finite automata (AFA) are precisely as powerful as deterministic finite automata as far as language recognition is concerned. It is also shown in [12] that there exist k-state AFA such that any equivalent complete DFA has at least 22k states. A more detailed treatment of alternating finite automata and their operations can be found in [24].

The study of Boolean automata was initiated by Brzozowski and Leiss [5] at almost the same time period as AFA were introduced. Boolean automata are essentially AFA except that they allow multiple initial states instead of exactly One initial state in the case of an AFA. Boolean automata have been further studied in [41, 43, 44, 45].

AFA are a natural extension of NFA. In an NFA, if there are two or more possible transitions for the current state and the current input symbol, the outcomes of all the possible computations for the remaining input word are logically ORed. Consider the NFA A4 shown in Figure 3.6 with the input

Fig. 3.6. An NFA A4

abbb. When starting at state 0 and reading a, the automaton has two possible

64 Sheng Yu

moves: to state 1 or to state 2. If we denote by a Boolean variable Xo whether there is a successful computation for abbb from state 0, and by Xl and X2

whether there is a successful computation for the remaining of the input bbb from state 1 and state 2, respectively, then the relation of the computations can be described by the equation

Xo = Xl V X2.

This relation, represented by the equation, captures the essence of nondeter­minism. The definition of AFA extends this idea and allows arbitrary Boolean operations in place of the "V" operation. For example, we inay specify that

Xo = (-,xI) /\ X2·

It means that there is a successful computation for abbb from state 0 if and only if there is no successful computation for bbb from state 1 and there is a successful computation for bbb from state 2.

More specifically, an AFA works in the following way: When the automaton reads an input symbol a in a given state q, it will activate all states of the automaton to work on the remaining part of the input in parallel. Once the states have completed their tasks, q will compute its value by applying a Boolean function on those results and pass on the resulting value to the state by which it was activated. A word w is accepted if the starting state computes the value of 1. It is rejected otherwise. We now formalize this idea.

Denote by the symbol B the two-element Boolean algebra B = ({O, I}, V, /\, -,,0,1). Let Q be a set. Then BQ is the set of all mappings of Q into B. Note that u E BQ can be considered as a vector of IQI entries, indexed by elements of Q, with each entry being from B. For u E BQ and q E Q, we write uq to denote the image of q under u. If P is a subset of Q then ulp is the restriction of u to P.

An alternating finite automaton (AFA) is a quintuple A = (Q, E, s, F, g) where

Q is the finite set of states; E is the input alphabet; SEQ is the starting state; F ~ Q is the set of final states; g is a function of Q into the set of all functions of E x BQ into B.

Note that for each state q E Q, g(q) is a function from E x BQ into B, which we will often denote by gq in the sequel. For each state q E Q and a E E, we define gq(a) to be the Boolean function BQ - B such that

gq(a)(u) = gq(a,u), u E BQ.

Thus, for u E BQ, the value of gq(a)(u), also gq(a,u), is either 1 or O. We define the function gQ : Ex BQ - BQ by putting together the IQI

functions gq : Ex BQ - B, q E Q, as follows. For a E E and u,v E BQ, gQ(a, u) = v if and only if gq(a, u) = Vq for each q E Q. For convenience, we will write g(a, u) instead of gQ(a, u) in the following.

3 Finite Automata 65

Example 2. We define an AFA As = (Q,E,s,F,g) where Q = {qO,ql,q2}, E = {a, b}, s = qo, F = {q2}, and 9 is given by

State a b qo ql/\ q2 ° ql q2 ql /\ q2 q2 ql /\ q2 ql V q2

Note that we use 7j instead of -,q for convenience.

We define f E BQ by the condition

fq = 1 <=> q E F,

o

and we call f the characteristic vector of F. The characteristic vector for F of As is f = (fqO' fql> f q2) = (0,0,1).

We extend 9 to a function of Q into the set of all functions E* x BQ -t B as follows:

( ) _ {Uq , if w = A, gq W,U - gq(a,g(w',u)), ifw = aw' with a E E and w' E E*,

where w E E* and U E BQ. Now we define the acceptance of a word and the acceptance of a language

by an AFA. Let A = (Q, E, s,F,g) be an AFA. A word wE E* is accepted by A if and

only if gs(w, I) = 1, where f is the characteristic vector of F. The language accepted by A is the set

L(A) = {w E E* I gs(w, I) = I}.

Let w = aba. Then w is accepted by As of Example 2 as follows: gqo(aba, I)

= gql (ba, I) /\ gq2 (ba, I) = (gql (a, I) /\ gq2 (a, I)) /\ (gql (a, I) V gq2 (a, I)) = (gq2(A, I) /\ (gql (A, I) /\ gq2(A, I))) /\ (gq2(A, I) V gql (A, I) /\gq2(A,I)) = (fq2 /\ (fql /\ f q2)) /\ (fq2 V fql /\ fq2) = (1/\ (IT /\ 1)) /\ (1 vIT /\ 1) =1 If we denote each U E BQ by a vector (uqO ' uql> uq2 ) and write f = (0,0,1),

then we can rewrite the above: gqo(aba, I)

= gqo(a,g(ba,l)) = gqo (a, g(b, g( a, I))) = gqO (a, g(b, g(a, (0, 0, 1)))) = gqo(a,g(b, (0, 1, 1))) = gqo(a, (0, 1, 1)) =1

66 Sheng Yu

Consider again the example of AFA As. We may use the following system of equations instead of a table to represent the transitions of As:

where a variable Xi represents state qi, 0 ::; i ::; 2, respectively; and>' appear­ing in the third equation specifies that q2 is a final state.

In general, an AFA A = (Q, E, s, F, g) can be represented by

Xq = La. gq(a, X) + eq, q E Q aEE

where X is the vector of variables X q , q E Q, and

{ >. if q E F, e -q - 0 otherwise,

(3.1)

for each q E Q. Note that all the terms of the form a· 0 or 0, a E E, can be omitted.

For each AFA A, we call such a system of equations the equational repre­sentation of A. At this moment, we consider the system of equations solely as an alternative form to present the definition of an AFA.

NFA are a special case of AFA. The NFA A2 of Figure 3.2 can be repre­sented by

{ Xo = a· (Xo V Xl) + b . Xo Xl = a . X 2 + b . X2 X 2 = b,X3

X3 = a . X3 + b . X3 + >. Let E be an alphabet. We define the L-interpretation as follows:

Notation Interpretation 0 0 1 E* 1\ n V U --, complement

a, aE E {a} >. {.x}

set catenation + U = language equivalence

Under this interpretation, the systems of equations defined above become systems of language equations.

3 Finite Automata 67

Formally, a system of language equations over an alphabet E is a system of equations of the following form under the L-interpretation:

Xi = La. fla ) (X) + Ci, i = 0, ... ,n aEE

(3.2)

for some n ~ 0, where X = (Xo, . .. ,Xn)j for each a E E and i E {O, ... , n}, fiCa) (X) is a Boolean functionj and Ci = oX or 0.

The following result has been proved in [5].

Theorem 3.3.1 Any system of language equations of the form (9.2) has a unique solution for each Xi, i = 0, ... ,n. Furthermore, the solution for each Xi is regular.

The following results can be found in [23].

Theorem 3.3.2 Let A be an AFA and E the equational representation of A. Assume that the variable Xo corresponds to the starting state of A. Then the solution for Xo in E under the L-interpretation is exactly L(A).

Theorem 3.3.3 For each system of language equations of the form (3.2), there is an AFA A such that the solution for Xo is equal to L(A).

It is easy to observe that an AFA is a DFA if and only if each function gq(a,X), q E Q and a E E, in its equational representation (3.1) is either a single variable or empty. An AFA is an NFA if and only if each function in its equational representation (3.1) is defined using only the V operation.

Such systems of language equations and their solutions have been further studied in [42, 44, 45]. Naturally, one may view that each such system of language equations corresponds directly to a set of solutions in the form of extended regular expressions. However, it remains open how we can solve such a general system of language equations by directly manipulating extended regular expressions without resorting to transformations of the corresponding AFA.

Let A = (Q, E, s, F, g) be an AFA and f the characteristic vector of F. We construct an NNFA

where Qv =BQ, Sv = {u E BQ I Us = l}j Fv = {f}, Ov : Qv x E ---+ 2Qv is defined by ov(u, a) = {u' I g(a, u') = u}, for each

u E Qv and a E E. We show that Av accepts the same language as A does.

Claim. L(Av) = L(A).

68 Sheng Yu

Proof We first prove that for u E Qv (= BQ) and x E E*,

ux f-Av f <==> g(x, f) = u (3.3)

by induction on the length of x. For x = .x, one has u = f and g(.x, f) = f. Now assume that the statement

holds for all words up to a length l, and let x = axo with a E E and Xo EEl. Let u = g(x, f). Then we have u = g(a,g(xo'!)). Let u' = g(xo, f)· By

the definition of Ov, we have u' E Ov (u, a). We also have u' Xo f-Av f by the induction hypothesis. Therefore,

u x = u axo f-Av U' Xo f-Av f .

For the converse, let u x f-Av f. Then

u x = u axo f-Av u' Xo f-Av f

for some u' E Qv. Thus, u' = g(xo, f) by the induction hypothesis and u = g(a,u') by the definition of ov. Therefore, u = g(a,u') = g(a,g(xo,f)) g(x, f). Thus, (3) holds.

By (3.3) and the definition of Bv, we have L(Av) = L(A). 0

We have the following results.

Theorem 3.3.4 If L is accepted by an n-state AFA, then it is accepted by an NNFA with at most 2n states.

Theorem 3.3.5 If L is accepted by an n-state AFA, then LR is accepted by a DFA with at most 2n states.

NFA and DFA are special cases of AFA. So, the transformations from NFA or DFA to AFA are straightforward.

Let A = (Q,E,o,s,F) be an NFA. We can construct an equivalent AFA A' = (Q, E, s, F, g), where 9 is defined as follows: for each q E Q, a E E, and u E BQ,

gq(a, u) = 0 <==> up = 0 for all p E o(q, a) .

More intuitively, the equational representation of A' is

Xq = La. V Xp + eq, for q E Q, aEE pE6(q,a)

where eq = .x if q E F and eq = 0 otherwise. A proof for L(A) = L(A') can be found in [24].

An s-AFA A = (Q, E, s, F, g) is an AFA such that the value of gq(a), for any q E Q and a E E, does not depend on the status of s, that is, in the equational representation of A, the variable X8 does not appear on the righthand side of any equation.

We have the following result. A proof can be found in [72].

3 Finite Automata 69

Theorem 3.3.6 L is accepted by a complete 2k-state DFA if and only if LR is accepted by a (k + I)-state s-AFA.

Corollary 3.3.1 Let A be an n-state DFA and L = L(A). Then LR is ac­cepted by an s-AFA with at most flog n 1 + 1 states.

As an example, we construct a 3-state s-AFA A which is equivalent to the 4-state DFA Al of Figure 3.1 as follows:

A = (QA, E, SA, FA,g) where QA = {O, 1, 2}, SA = 0, FA = 0. The en­coding of the states of Al is shown in the following. Note that we denote a 2-bit Boolean vector as a 2-bit binary number, i.e., we write X l X2 instead of (Xl,X2).

State of Al 0 1 2 3 Encoding X l X2 000110 11

The equational representation of A is

{ Xo = a· (Xl 1\ X 2 ) + b· (XI) Xl = a· (Xl 1\ X2) + b· (Xl V X2) X 2 = a· 1 + b . (Xl)

and the characteristic vector of FA is f = (0,0,0). We now consider the basic operations of AFA. Let

A(l) = (Q(1), E, S(l), F(l), g(1))

be an (m + I)-state s-AFA and

A(2) = (Q(2), E, s(2), F(2), g(2))

be an (n + I)-state s-AFA. Assume that Q(l) n Q(2) = 0. We construct an (m + n + I)-state AFA A = (Q,E,s,P,g) such that

L(A) = L(A(1)) U L(A(2)) as follows:

Q = (Q(1) - {s(1)}) U (Q(2) - {s(2)}) U {s}, S ~ Q(l) U Q(2), P = { p(l) U p(2) if s(1) ~ p(l) and S(2) ~ p(2),

(p(1) U p(2) U {s}) n Q otherwise. We define 9 as follows. For a E E and u E BQ,

gs(a, u) = g;~;) (a, u) V g;zl) (a, u),

and for q E Q - {s},

au _ {g~l)(a,u) if q E Q(1), gq( , ) - (2) ( )·f E Q(2) gq a, u 1 q .

70 Sheng Yu

An (m + n + I)-state AFA A = (Q, E, 8, F,g) such that L(A) = L(A(1)) n L(A(2)) is constructed as above except the following:

gs(a, u) = g;~;) (a, u) 1\ g;ZL (a, u)

and 8 is in F if and only if both 8(1) E F(1) and 8(2) E F(2). For complementation, we construct an m-state s-AFA

such that L(A) = L(A(l)), where the function 9 is the same as g(1) except

that gS(l) (a, u) = g~~;) (a, u); and F' = {8(1)} U F(1) if 8(1) ~ F(1) and F' = F(l) - {8(1)} otherwise.

Let L1 = L(A(l)) and L2 = L(A(2)). We can easily construct an AFA to accept a language which is obtained by an arbitrary combination of Boolean operations on L1 and L2, e.g., L = (L1 U L2) n (L1 n L2). The only essential changes are the functions for 8 and whether 8 is in the final state set, which are all determined by the respective Boolean operations.

Other AFA operations, e.g., catenation, star, and shuffle, have been de­scribed in [24, 23).

Although alternation is a generalization of nondeterminism, the reader may notice that AFA are backwards deterministic. We have also shown that a language L is accepted by a 2n-state DFA if and only if it is accepted by an s-AFA of n + 1 states reversely (Le., words are read from right to left). Due to the above observation, we introduce a variation of s-AFA which we call r-AFA. A detailed description of r-AFA and their bitwise implementation can be found in [63).

3.4 Cover Automata

Finite languages are perhaps the most often used but the least studied family of languages in the formal language family hierarchy. Finite languages have many practical applications [71, 10]. However, many finite languages used in applications need thousands or even millions of states if they are repre­sented by deterministic finite automata (DFA) or similar structures. In [9], deterministic finite cover automata (DFCA) were introduced as an alterna­tive representation of finite languages. Experiments have shown that, in many cases, DFCA are much smaller in size than their corresponding minimal DFA [65).

Let L be a finite language and l the length of the longest word(s) in L. Intuitively, a DFCA A for L is a DFA that accepts all words in L and possibly additional words of length greater than l. So, a word w is in L if and only if it is accepted by A (as a DFA) and it has a length less than or equal to l. Note

3 Finite Automata 71

that checking the length of a word is usually not an extra burden in practice since the length of an input word is kept anyway in most applications.

In order to explain intuitively the notion of a DFCA, we give a very simple example. Let E = {a, b, c} be the alphabet and L = {abc, ababc, abababc} a finite language over E . Clearly, the length of the longest word in L is 7, i.e., l = 7. The minimal DFA accepting L is shown in Figure 3.7, which has 8 states (9 if we count also the sink state) . A minimal DFCA is shown in Figure 3.8, which has only 4 states (5 if we count also the sink state).

Fig. 3.7. The minimal DFA accepting L

Fig. 3.8. The minimal DFCA for L with l = 7

First, we give the definitions and notation for cover languages, cover au­tomata, and the similarity relation. Then we list some basic results, which are related to cover automata. Detailed explanations and proofs can be found in [9, 65, 8, 25).

Let S be a finite set of symbols and n a nonnegative integer. We define sn = {w E S* Ilwl = n}, where Iwl denotes the number of appearances of symbols in w, i.e., the length of w. We also define S5:n = Uf=OSi.

If T = {tl ' ... , tk} is an ordered set, k > 0, the lexicographic ordering on T*, denoted ...:, is defined by: x ...: y iff Ixl < Iyl or Ixl = Iyl and x = ztiV, Y = ztjU, i < j, for some z,u,v E T* and 1 ~ i,j ~ k . Denote x ~ y if x"': y or x = y .

We say that x is a prefix of y, denoted x ~p y, if Y = xz for some z E T*.

Definition 1 Let L c E* be a finite language over an alphabet E and l the length of the longest word(s) in L. A language L' over E is called a cover language of L if L' n E5:1 = L .

Definition 2 A cover automaton for a finite language L is a finite automaton A such that the language accepted by A, i.e., L(A}, is a cover language of L . If

72 Sheng Yu

A is a DFA, then A is called a deterministic finite cover automaton (DFCA) forL.

We often use the term cover automaton casually to mean DFCA in this chapter.

Similarity relation is the basis for the minimization of DFCA. In the fol­lowing, we give the basic definitions regarding the similarity relation (on 17*), which is a generalization of the equivalence relation =L (x =L y: xz E L iff yz E L for all Z E 17*).

We first define the similarity relation on words with respect to a finite language, and then the similarity relation on states of a DFA that accepts a finite language. The notion of similarity between words was first introduced in [35], and then studied in [20], [9], [65], etc.

Definition 3 Let L be a finite language over the alphabet 17 and l the length of the longest word(s) in L. Let x, y E 17*. We define the following relation:

• x '" L Y if for all Z E 17* such that Ixzl ::; land Iyzl ::; I, xz E L iff yz E Lj

and we will write x 7-L Y if x '" L Y does not hold.

The relation "'Lis called the similarity relation with respect to L. We will use x '" y instead of x '" L Y when L is clearly understood from the context. Note that the relation", L is reflexive, symmetric, but NOT transitive.

Lemma 3.4.1 Let L S;; 17* be a finite language and x, y, z E 17*, Ixl ::; Iyl ::; 14 The following statements hold:

(1) Ifx "'L y, X "'L z, then y "'L z. (2) If x "'L y, Y "'L z, then x "'L z. (3) If x "'L y, Y7-LZ, then xrfLz, (4) If x "'L y, X7-LZ, then yrfLz

So, in other words, if Ixl ::; Iyl ::; Izi and x "'L y, then we have x "'L Z iff Y "'L Z

Proof The first three statements were proved in [20], we now prove the last statement: Let x '" L Y and xrf LZ and assume that Y'" LZ, Then from statement (2) we get x "'L z, which is contrary to our assumption. So, we have y7-Lz.D

If x rf L Y and y '" L Z, we cannot say anything about the similarity relation between x and z. Similarly, if x rf L Y and y rf L Z, we cannot conclude anything either between x and z.

Definition 4 Let L E 17* be a finite language.

1. A set S S;; 17* is called an L-similarity set if x '" L Y for every pair x, yES. 2. A sequence of words (Xl, ... ,xn ) over 17 is called a dissimilar sequence of

L if Xi 7-L Xj for each pair i, j, 1 ::; i, j <5. nand i =f. j.

3 Finite Automata 73

3. A dissimilar sequence (Xl, ... , xn) is called a canonical dissimilar sequence of L if there exists a partition 7r = {8l , ... , 8n } of E* such that for each i, 1 ::; i ::; n, Xi E 8i , and 8i is a L-similarity set.

4. A dissimilar sequence (Xb ... , xn) of L is called a maximal dissimilar sequence of L if for any dissimilar sequence (Yb"" Yrn) of L, m ::; n.

Theorem 3.4.1 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 finite language. Let (Xb .. " xn) be a canonical dissimilar sequence of L and 7r = {8l , ... , 8n } the corresponding partition of E* such that for each i, 1 ::; i ::; n, 8 i is an L-similarity set. Let (Yl,"" Yrn) be an arbitrary dissimilar sequence of L. Assume that m > n. Then there are Yi and Yj, i =1= j, such that Yi, Yj E 8k for some k, 1 ::; k ::; n. Since 8k is a L-similarity set, Yi "'L Yj. This is a contradiction. Then, the assumption that m > n is false, and we conclude that (Xl, ... ,Xn ) is a maximal dissimilar sequence.

Conversely, let (Xl, ... ,Xn ) a maximal dissimilar sequence of L. Without loss of generality we can suppose that IXII ::; ... ::; IXnl. For i = 1, ... ,n, define

Xi = {y E E* I Y "'L Xi and Y f/. Xj for j < i}.

Note that for each Y E E*, Y "'LXi for at least one i, 1 ::; i ::; n, since (Xl, ... , Xn) is a maximal dissimilar sequence. Thus, 7r = {XI, ... , Xn} is a partition of E*. The remaining part of the proof is to show that each Xi, 1 ::; i ::; n, is a similarity set.

We assume the contrary, i.e., for some i, 1 ::; i ::; n, there exist y, z E Xi such that y7-Lz. We know that Xi "'L Y and Xi "'L Z by the definition of Xi. We have the following three cases: (1) IXil < lyl,lzl, (2) IYI ::; IXil ::; Izl (or Izl ::; IXil ::; IYD, and (3) IXil > lyl,14 If (1) or (2), then Y "'L Z by Lemma 3.4.1. This would contradict our assumption. If (3), then it is easy to prove that Y 7- Xj and z 7- Xj, for all j =1= i, using Lemma 3.4.1 and the definition of Xi. Then we can replace Xi by both Y and z to obtain a longer dissimilar sequence (Xl, ... ,Xi-l,y,z,Xi+l, ... ,Xn ). This contradicts the fact that (x}, ... , Xi-I, Xi, Xi+b ... , xn) is a maximal dissimilar sequence of L. Hence, Y '" z and Xi is a similarity set. 0

Corollary 3.4.1 For each finite language L, there is a unique number N(L) which is the number of elements in any canonical dissimilar sequence of L.

Theorem 3.4.2 Let 81 and 82 be two L-similarity sets and Xl and X2 the shortest words in 81 and 82, respectively. If Xl "'L X2 then 81 U 82 is a L-similarity set.

Proof. In order to prove that 81 U 82 is a L-similarity set, it suffices to show that for an arbitrary word Yl E 81 and an arbitrary word Y2 E 82, Yl "'L Y2

74 Sheng Yu

holds. Without loss of generality, we assume that IXII ::; IX21. We know that IXII ::; IYII and IX21 ::; IY21· Since Xl "'L X2 and X2 "'L Y2, we have Xl "'L Y2 (Lemma 3.4.1 (2)), and since Xl "'L YI and Xl "'L Y2, we have YI "'L Y2 (Lemma 3.4.1 (1)). 0

In the following, we define the similarity relation on the set of states of a DFA or a DFCA. Note that if a DFA A accepts a finite language L, then A is also a DFCA for L.

Definition 5 Let A = (Q, E, 8, 0, F) be a DFA (or a DFCA). We define, for each state q E Q,

level(q) = min{lwll 8(0, w) = q},

i.e., level(q) is the length of the shortest path (in the directed graph associated with the automaton) from the initial state to q.

Let A = (Q,E,8,0,F) be a DFA. For each state q E Q, we denote XA(q) = min{w I 8(0,w) = q}, where the minimum is taken according to the lexicographic ordering, and LA(q) = {w E E* 18(q,w) E F}. When the automaton A is understood, we write Xq instead of XA(q) and Lq instead LA(q).

Definition 6 Let A = (Q, E, 8, 0, F) be a DFCA for a finite language L with l being the longest word{s) in L. Let p, q E Q and m = max{level(p), level(q)}. We say that p "'A q if for every wE E9-m , 8(p, w) E F iff 8(q, w) E F.

We use the notation p '" q instead of p "'A q whenever A is clearly understood from the context.

Using the previous definitions we can observe some simple properties:

Theorem 3.4.3 Let A = (Q, E, 8, 0, F) be a DFCA of a finite language L and p, q E Q. Then p "'A q if and only if Xp "'L Xq.

Proof. Let l denote the length of the longest word(s) in L. Let level(p) = i and level(q) = j. Clearly, Ixpl = i and IXql = j by definition. Let m = max{i,j}. Then the condition w E ES,I-m is the same as the condition w E E* such that both Ixpwl ::; land Ixqwl ::; l. We know that, by definition, p "'A q means that 8(p,w) E F iff 8(q,w) E F for each wE ES,I-m; and xp "'L Xq means that xpw E L iff XqW E L for each w E E* such that IXpwl ::; land IxqWI ::; l. Then, clearly, p "'A q if and only if xp '" L x q. 0

All words that reach the same state in a DFA or a DFCA are similar.

Lemma 3.4.2 Let A = (Q, E, 8, 0, F) be a DFCA of a finite language L. Let q E Q and X,Y E E* such that 8(0, x) = 8(0,y) = q. Then X "'L y.

3 Finite Automata 75

Proof. Clearly, for all w E E*, including those w such that Ixwl ~ land Iywl ~ l, 8(0, xw) and 8(0, yw) reach exactly the same state. So, xw E L iff yw E L . 0

Similarity on states implies similarity on words:

Lemma 3.4.3 Let A = (Q, E, 8, 0, F) be a DFCA of a finite language L . Let u,v E E* such that 8(0,u) = P and 8(0, v) = q. lfp ""A q then u ""L V .

Proof. Since P ""A q, we have xp ""L Xq by Theorem 3.4.3. By Lemma 3.4.2, we know that xp "" L U and Xq ""LV. Therefore, Xq "" L U and then u ""LV by using (1) of Lemma 3.4.1. 0

Note that similarity on words does not necessarily imply similarity on states. The following is a counter example. Example: Let L = {a,b,aa,aaa,bab} . Then l = 3. The following is a DFCA of L. Let x = band y = bab. Clearly, x ""L y. However, 8(0, x) f 8(0,y) .

a,b

F ig. 3.9. If x '" L y, then it is not necessarily true that 8(0, x} "'A 8(0, y}

It always holds that x ""L y implies 8(0, x) ""A 8(0, y) if both x and yare the shortest words that, from the initial state, reach their destination states, respectively.

Lemma 3.4.4 Let A = (Q, E, 8, 0, F) be a DFCA of a finite language L. Let s,p,q E Q such that level(s) = i, level(p) = j, level(q) = m, i ~ j ~ m. The following statements are true:

1. Ifs""AP, S""Aq, thenp""Aq. 2. If S""AP, P""A q, thens""Aq. 3. Ifs""AP,pfAq, thensfAq· 4· Ifs""AP, sfAq, thenpfAq·

Proof. Lemma 3.4.1 and Theorem 3.4.3. o

We are now ready to state the theorem that is the basis for minimizing DFCAs.

76 Sheng Yu

Theorem 3.4.4 Let A = (Q, E, 8, 0, F) be a DFCA for a finite language L. Assume that p '" L q for some p, q E Q such that p i= q and level (P) :::; leve1(q). Then we can construct a DFCA A' for L in the following way: A' = (Q',E,8',0,F') where Q' = Q - {q}, F' = F - {q}, and

8' (t, a) = {8(t, a), if 8(t, a) i= q, p, 8(t, a) = q

for each t E Q' and a E E.

Proof It suffices to prove that A' is a DFCA of L. Let 1 be the length of the longest word(s) in L and assume that 1evel(p) = i and 1eve1(q) = j, i :::; j. Consider a word w E E$L. We now prove that w E L iff 8'(0,w) E F'.

If there is no prefix WI of W such that 8(0, wI) = q, then clearly 8'(0, w) E F' iff 8(0, w) E F. Otherwise, let w = WIW2 where WI is the shortest prefixofw such that 8(0, WI) = q. In the remaining, it suffices to prove that 8'(p, W2) E F' iff 8(q, W2) E F. We prove this by induction on the length of W2. First consider the case IW21 = 0, Le., W2 = >.. Since p "'A q, P E F iff q E F. Then p E F' iff q E F by the construction of A'. Thus, 8'(P,w2) E F' iff 8(q,w2) E F. Suppose that the statement holds for IW21 < l' for some l' :::; 1 - IWII. (Note that 1 - IWII :::; 1 - j.) Consider the case that IW21 = 1'. If there does not exist u E E+ such that u ::5p W2 (u is a prefix of W2) and 8(p, u) = q, then 8(p, W2) E F - {q} iff 8(q, W2) E F - {q}, Le., 8' (p, W2) E F' iff 8(q, W2) E F. Otherwise, let W2 = uv and u be the shortest nonempty prefix of W2 such that 8(P,u) = q. Then Ivl < l' (and 8'(p,u) = p). By induction hypothesis, 8'(p, v) E F' iff 8(q, v) E F. Therefore, 8'(p, uv) E F' iff 8(q, uv) E F. 0

Definition 7 A DFCA A = (Q, E, 8, 0, F) for a finite language L is said to be a minimal DFCA for L if, for any DFCA A = (Q',E,8',O',F') for L, #Q:::; #Q'

For a finite language, there may be several minimal DFCA that have dif­ferent structures. The minimal Deterministic Finite Cover Automata for a finite language are not unique up to an isomorphism (Le., renaming of the states).

Using the previous theorem we can easily prove the following corollary.

Corollary 3.4.2 A DFCA A for a finite language L is a minimal DFCA for L if and only if no two distinct states of A are similar.

Proof. A = (Q, E, 8, 0, F) be a DFCA for L. If there exist two distinct states p, q E Q such that p '" q, then A is not minimal by Theorem 3.4.4. For the other direction of the proof, if A is not minimal, then there exists a DFCA A' = (Q', E, 8', 0', F') of L such that #Q' < #Q. Then there exist p, q E Q such that xp and Xq reach the same state in A'. By Lemma 3.4.2, we have xp "'L x q . Therefore, p ""A q by Theorem 3.4.3. 0

Theorem 3.4.5 Any minimal DFCA of L has exactly N(L) states.

3 Finite Automata 77

Proof. Let A = (Q, E, 8, 0, F) be a minimal DFCA of a finite language Land #Q = n. Suppose that n > N(L). Then there exist p,q E Q, p i: q, such that xp "'L Xq (because of the definition of N(L». Thenp "'A q by Theorem 3.4.3. Thus, A is not minimal by Theorem 3.4.4. A contradiction.

Suppose that N(L) > n. Let (Yl,"" YN(L» be a canonical dissimilar sequence of L. Then there exist i,j, 1 ~ i,j ~ N(L) and i i: j, such that 8(0, Yi) = 8(0, Yj) = q for some q E Q. Then Yi "'L Yj. Again a contradiction.

Therefore, we have n = N (L). 0

The above results lay a foundation for the construct of minimal DFCA for finite languages. As a straightforward algorithm, we can repeatedly merge similar states and obtain a minimal DFCA. However, the complexity of this simple algorithm is pretty high. The reader may refer to [8, 25] for efficient algorithms that construct a minimal DFCA from a given DFA or DFCA of a finite language.

3.5 Fuzzy Automata

In most of the currently available compilers and operating systems, input strings are treated as crisp tokens. A string is either a token or a non-token; there is no middle ground. For example in UNIX, if you enter "yae", it does not mean ''yaec'' to the system. If you type "spelll" (the key sticks), it will also not be treated as "spell" although there is no confusion. Would it be more friendly if the system would ask you whether you meant "yacc" in the first case and "spell" in the second case, or simply decide for you if there is no confusion? Sure. There are many different ways available which can be used to implement the above idea. Various models of fuzzy automata have been introduced in, e.g., [54], [67], [52], [31], [68]. However, what is needed here is a model that is so simple, so easy to implement, and so efficient to run that it makes sense to be utilized.

Here we describe a very simple model for this purpose. The fuzzy automa­ton model we describe in this chapter follows those described in [54], [40], [51], [67], [31], [68], etc. in principle. Fuzzy languages and grammars were formally defined by Lee and Zadeh in [40]. Maximin automata as a special class of pseudo automata were studied by Santos [66, 67]. A more restricted Mealy type model was also studied by Mizumoto et al. [51].

Many of the following basic definitions on fuzzy languages can be found in [40].

Definition 8 Let E be a finite alphabet and f : E* -+ M a function, where M is a set of real numbers in [0,1]. Then we call the set

L= {(w, f(w» I w E E*}

-a fuzzy language over E and f the membership function of L.

78 Sheng Yu

In the following, we often use f- to denote the membership function of £. L

Let £ be a fuzzy language over E and f- : E* -+ M the membership L

function of £. Then, for each m EM, denote by S"i (m) the set

S-(m) = {w E E* I f-(w) = m}. L L

Note that S- as a function is just /::;1. L L

- -Definition 9 Let L1 and L2 be two Juzzy languages over E. Then the basic operations on £1 and £2 are define in the following:

(1) The membership Junction f"i of the union £ =£1 U £2 is defined by

f-(w) = max{f- (w), f- (w)}, wE E*. L L1 L2

(2) The membership Junction f- of the intersection £ =£1 n £2 is defined by L

f-(w) = min{f- (w),f- (w)), wE E*. L L1 L2

(3) The membership Junction f- of the complement of £1 is defined by L

f-(w) = 1- f- (w), wE E*. L L1

- - -(4) The membership Junction f- of the concatenation L =L1 . L2 is defined L

by

f-(w) = max{min(f- (x),f- (y)) I w = xy, x,y E E*}, wE E*. L L1 L2

- -* (5) The membership Junction f- of the star operation L=L1 is defined by L

Xl, .•. ,Xn E E*,n ~ O}, wE E*,

assuming that min0 = 1. - -+

(6) The membership Junction fI., of the + operation L=L1 is defined by

Xl, .•. , Xn E E*, n ~ I}, w E E*.

3 Finite Automata 79

Since fuzzy languages are just a special class of fuzzy sets, the equivalence and inclusion relations between two fuzzy languages are the equivalence and

'" '" equivalence relations between two fuzzy sets. Let Ll and L2 be two fuzzy languages over E. Then

£1 = £2 iff f~ (w) = f~ (w) for all w E E*, L1 L2

and

'" Definition 10 Let L be a juzzy language over E and f~ : E* ---+ M the L

membership junction of £. We call L a regular juzzy language if

(1) the set {m EM I 8"i(m) -# 0} is finite and (2) for each m E M,8"i(m) is regular.

It is obvious that the first condition can be replaced by

(1') M is finite.

For convenience, when we write f~ : E* ---+ M, we mean that M = {f~(w) I L L

wE E*}, i.e., for each m E M,8"i(m) -# 0. Also, the second condition in the above definition can be replaced by

(2') for each m E M, {w E E* I h(w) ~ m} is regular.

We choose (2) instead of (2') since it can be used more directly in the subse­quent proofs.

Example 3. Let £1 be a fuzzy language over E = {a, b} and f ~ : L1

{

I,

f~ (x) = 0.7, L1 0.5,

0,

'" Then Ll is a regular fuzzy language.

if x E a*, if x E a*ba*, if x E a*ba*ba*, otherwise.

Example 4. The membership function f~ of £2 over E = {a, b} is defined by L2

f~ (x) = Ixlallxl, L2

where Ixl denotes the length of x and Ixla the number of appearances of a in '" x. Then L2 is not a regular fuzzy language.

The next theorem can be easily proved.

80 Sheng Yu

Theorem 3.5.1 Regular fuzzy languages are closed under union, intersec­tion, complement, concatenation, and star operations.

Definition 11 A nondeterministic finite automaton with fuzzy (final) states

(FS-NFA or FS-FA) A is a 5-tuple A= (Q, E, 15, s, FA) where Q, E, 15, and s

are the same as in an NFA , and FA: Q --+ [0,1] is the degree function for the fuzzy final-state set.

Define

d- (x) = max{F o4(q) I q E c5*(s, x)}. A

Note that 15* is the transitive and reflexive closure of 15 defined as for a normal

NFA. Then we say that x is accepted by A with degree d-(x). The fuzzy A

language accepted by A, denoted £(A), is the set {(x,d-(x)) I x E E*}. A

Example 5. Let E = {a, b} . An FS-NFA A is the following:

1

-8~G--"--G-"-.G~G~G~@ o ~ 0 0 0 0.6 1 0.8

G~G~G~B~G o 0 0 POI

G 0.8

Then d-(sleep) = 1, d-(spelllll) = 0.8, and d- (sle) = O. A A A

Definition 12 A deterministic finite automaton with fuzzy states (FS-DFA)

A = (Q, E, 15, s, F-) is an FS-NFA with 15 being a function Q x E --+ Q instead A

of a relation. Hence, for each x E E* , d-(x) = F-(q) where q = c5*(s,x). A A

Define d- (x) = 0 if 15* (s, x) is not defined. A

Theorem 3.5.2 Let £ be a fuzzy language. Then £ is a regular fuzzy language iff it is accepted by an FS-DFA.

3 Finite Automata 81

- -Proof. Let f~ : E* --+ M be the membership function of L. Assume that L L

is a regular fuzzy language. Then M is finite and, for each m EM, 8Z (m) is a regular set. Assume that M = {ml, ... , m n }. We construct a DFA Ai = (Qi' E,8i , si,Fi) for each i, 1::; i::; n, such that L(Ai) = 8Z(mi )' Define an

FS-DFA A= (Q, E, 8, s, F~) to be the cross product of AI. ... , An with A

. {mi' q(i) E Fi for some i, 1 ::; i ::; n, FA «q(1) , ... , q(n»)) = and q(j) ¢ Fj , for all j =f. i

0, otherwise.

Note that if (q(1), . .. ,q(n») is reachable from (S1' ... ,sn) in A. then it is im­possible to have q(i) E Fi and q{j) E Fj for i =f. j since L(Ai) n L(Aj ) = 0 for - -i =f. j, 1::; i,j ::; n. Obviously, A accepts L.

For the other direction of the proof, let A= (Q, E, 8, s, F~) be an FS-DFA. A

Define M = {m IF~ (q) = m for some q E Q}.

A

M is a finite set. For each m EM, define

Am = (Q,E,8,s,Fm)

where Fm = {q IF~ (q) = m}. Let L = L(A.), i.e. f~ = d~. Then clearly, for A L A

each m E M, 8Z(m) = L(Am) is regular. L is a regular fuzzy language. 0

Theorem 3.5.3 A fuzzy language is accepted by an FS-NFA iff it is accepted by an FS-DFA.

_ ,....., rv ,..." f't,J,..." ,....,1

Proof. It suffices to show that if L=L (A) for an FS-NFA A then L=L (A ) ,.....,1 '"'-I""'" ,.....,1

for some FS-DFA A. Let A= (Q,E,8,s,F~). The construction of A= A

-' (Q', E, 8', s', FA) is straightforward. We can just use the standard subset-construction method and, for each P E Q' (P ~ Q), define

-' -FA (P) = max{m I m =F~ (q),q E Pl· A

f't,J ,....,,.....,1 It is clear that L = L(A ). o

An extension of the Myhill-Nerode Theorem is given below, which can be easily proved.

Theorem 3.5.4 (The extended Myhill-Nerode theorem) The following three statements are equivalent:

82 Sheng Yu

1. L is a regular fuzzy language over E . 2. L is the union of some of the equivalence classes of a right invariant

equivalence relation of finite index. 3. Let the relation R'i ~ E* x E* be defined by xR'iY iff for all z E

E*, f~(xz) = f~(yz). Then R~ is an equivalence relation of finite index. L L L

More detailed description of fuzzy automata can be found in [47]. The fuzzy automata model we have described is very simple. However, it can be easily used in lexical analysis and parsing. A fuzzy lexical analyzer based on the model is proposed in [47].

3.6 Conclusion

In this chapter, we have described the three basic models of automata, DFA, NFA, and AFA, for regular languages, cover automata for finite languages, and fuzzy automata for fuzzy regular languages. Because of the limit on the number of pages for the chapter, all the descriptions are sketchy. However, the basic concepts of those models have been given, as well as many necessary references. Hope that this chapter is a good introduction for further study on finite automata.

References

1. A.V. Aho and J.D. Ullman, The Theory of Parsing, Translation, and Compil­ing, Vol. 1, Prentice-Hall, Englewood Cliffs, 1972.

2. A.V. Aho, R. Sethi, and J.D. Ullman, Compilers - Principles, Techniques, and Tools, Addison-Wesley, Reading, 1986.

3. J.C.M. Baeten and W.P. Weijland, Process Algebm, Cambridge University Press, Cambridge, 1990.

4. J. Berstel and M. Morcrette, Compact Representation of Patterns by Finite Automata, Pixim 89: L'Image Numerique Ii Paris, Andre Gagalowicz, ed., Hermes, Paris, 1989, pp. 387-395.

5. J .A. Brzozowski and E. Leiss, On Equations for Regular Languages, Finite Automata, and Sequential Networks, Theoretical Computer Science, 10 (1980), 19-35.

6. J.A. Brzozowski and C.-J.H. Seger, Asynchronous Circuits, Springer-Verlog, New York, 1995.

7. J.A. Brzozowski and M. Yoeli, Digital Networks, Prentice-Hall, Englewood Cliffs, 1976.

8. C. Campeanu, A. Paun, S. Yu, An Efficient Algorithm for Constructing Min­imal Cover Automata for Finite Languages, International Journal of Founda­tions of Computer Science, 13, 1 (2002), 83-97.

9. C. Campeanu, N. Santean, S. Yu, Minimal Cover-Automata for Finite Lan­guages, Proceedings of the Third International Workshop on Implementing A u­tomata (WIA'98) 1998, 32-42. An extended version appeared in Theoretical Computer Science, 267 (2002), 3-16.

3 Finite Automata 83

10. J.-M. Champarnaud and D. Maurel, Automata Implementation, Third Inter­national Workshop on Implementing Automata, LNCS 1660, Springer, 1999.

11. A.K. Chandra and L.J. Stockmeyer, Alternation, FOCS, 17 (1976), 98-108. 12. A.K. Chandra, D.C. Kozen, L.J. Stockmeyer, Alternation, Journal of the ACM,

28 (1981), 114-133. 13. J.H. Chang, O.H. Ibarra and B. Ravikumar, Some Observations Concerning

Alternating Turing Machines Using Small Space, Inform. Process. Lett., 25 (1987), 1-9.

14. K. Culik II and S. Dube, Rational and Affine Expressions for Image Descrip­tion, Discrete Applied Mathematics, 41 (1993), 85-120.

15. K. Culik II and S. Dube, Affine Automata and Related Techniques for Gener­ation of Complex Images, Theoretical Computer Science, 116 (1993), 373-398.

16. K. Culik II and T. Harju, Splicing Semigroups of Dominoes and DNA, Discrete Applied Mathematics, 31 (1991), 261-277.

17. K. Culik II and J. Kari, Image Compression Using Weighted Finite Automata, Computer and Graphics, 17,3 (1993), 305-313.

18. V. Diekert and G. Rozenberg edited, The Book of Traces, World Scientific, 1995.

19. D. Drusinsky and D. Harel, On the Power of Bounded Concurrency I: Finite Automata, Journal of the ACM, 41 (1994), 517-539.

20. C. Dwork and L. Stockmeyer, A Time Complexity Gap for Two-Way Proba­bilistic Finite-State Automata, SIAM Journal on Computing, 19 (1990), 1011-1023.

21. S. Eilenberg, Automata, Languages, and Machines, Vol. A, Academic Press, New York, 1974.

22. S. Eilenberg, Automata, Languages, and Machines, Vol. B, Academic Press, New York, 1974

23. A. Fellah, Alternating Finite Automata and Related Problems, PhD Disserta­tion, Dept. of Math. and Computer ScL, Kent State University, 1991.

24. A. Fellah, H. Jiirgensen, S. Yu, Constructions for Alternating Finite Automata, Intern. J. Computer Math., 35 (1990), 117-132.

25. H. Goeman, On Minimizing Cover Automata for Finite Languages in O(nlogn) Time, Seventh International Conference on Implementation and Application of Automata, 121-130.

26. L. Guo, K. Salomaa, and S. Yu, Synchronization Expressions and Languages, Proceedings of the Sixth IEEE Symposium on Parallel and Distributed Process­ing, (1994), 257-264.

27. M.A. Harrison, Introduction to Formal Language Theory, Addison-Wesley, Reading, 1978.

28. T. Head, Formal Language Theory and DNA: An Analysis of the Generative Capacity of Specific Recombinant Behaviors, Bull. Math. Bioi., 49 (1987), 737-759.

29. F.C. Hennie, Finite-State Models for Logical Machines, Wiley, New York, 1968. 30. T. Hirst and D. Harel, On the Power of Bounded Concurrency II: Pushdown

Automata, Journal of the ACM, 41 (1994), 540-554. 31. N. Honda, M. Nasu and S. Hirose, F-Recognition of Fuzzy Languages, FUzzy

Automata and Decision Processes, edited by M.M. Gupta, G.N. Sari dis and B.R. Gaines, North-Holland, 1977, 149-168.

32. J.E. Hopcroft and J.D. Ullman, Introduction to Automata Theory, Languages, and Computation, Addison-Wesley, Reading, 1979, 189-196.

84 Sheng Yu

33. K. Inoue, I. Takanami, and H. Tanaguchi, Two-Dimensional Alternating Turing Machines, Proc. 14th Ann. ACM Symp. On Theory of Computing, (1982), 37-46.

34. K. Inoue, I. Takanami, and H. Tanaguchi, A Note on Alternating On-line Turing Machines, Information Processing Letters, 15, 4 (1982), 164-168.

35. J. Kaneps, R. Frievalds, Running Time to Recognize Non-Regular Languages by 2-Way Probabilistic Automata, in ICALP'91, LNCS, Springer-Verlag, New­York/Berlin (1991), vol 510, 174-185.

36. S.C. Kleene, Representation of Events in Nerve Nets and Finite Automata, Automata Studies, 1996, pp.2-42, Princeton Univ. Press, Princeton, N.J.

37. D.E. Knuth, J.H. Morris, and V.R. Pratt, Fast Pattern Matching in Strings, SIAM Journal on Computing, 6, 2 (1977), 323-350.

38. D. Kozen, On Parallelism in Turing Machines, Proceedings of 17th FOCS, (1976), 89-97.

39. R.E. Ladner, R.J. Lipton and L.J. Stockmeyer, Alternating Pushdown Au­tomata, Proc. 19th IEEE Symp. on Foundations of Computer Science, Ann Arbor, MI, (1978), 92-106.

40. E.T. Lee and L.A. Zadeh, Note on Fuzzy Languages, Information Sciences, 1 (1969), 421-434.

41. E. Leiss, Succinct Representation of Regular Languages by Boolean Automata, Theoretical Computer Science, 13 (1981), 323-330.

42. E. Leiss, On Generalized Language Equations, Theoretical Computer Science, 14 (1981), 63-77.

43. E. Leiss, Succinct Representation of Regular Languages by Boolean Automata II, Theoretical Computer Science, 38 (1985), 133-136.

44. E. Leiss, Language Equations over a One-letter Alphabet with Union, Con­catenation and Star: A Complete Solution, Theoretical Computer Science, 131 (1994), 311-330.

45. E. Leiss, Unrestricted Complementation in Language Equations over a One­letter Alphabet, Theoretical Computer Science, 132 (1994), 71-84.

46. P.A. Lindsay, Alternation and w-type Turing Acceptors, Theoretical Computer Science, 43 (1986), 107-115.

47. A. Mateescu, A. Salomaa, K. Salomaa, S. Yu, Lexical Analysis with a Simple Finite-Fuzzy-Automaton Model, Journal of Universal Computing, 1, 5 (1995).

48. W.S. McCulloch and W. Pitts, A Logical Calculus of the Ideas Immanent in Nervous Activity, Bull. Math. Biophysics, 5 (1943), 115-133.

49. R. McNaughton, Counter-Free Automata, MIT Press, Cambridge, 1971. 50. G.H. Mealy, A Method for Synthesizing Sequential Circuits, Bell System Tech­

nical J., 34, 5 (1955), 1045-1079. 51. M. Mizumoto, J. Toyoda, and K. Tanaka, Fuzzy Languages, Systems, Com­

puters, Controls, 1 (1970), 36-43. 52. M. Mizumoto, J. Toyoda, and K. Tanaka, Various Kinds of Automata with

Weights, Journal of Computer and System Sciences, 10 (1975), 219-236. 53. E.F. Moore, Gedanken Experiments on Sequential Machines, Automata Stud­

ies, 1966, pp. 129-153, Princeton Univ. Press, Princeton, N.J. 54. M. Nasu and N. Honda, Fuzzy Events Realized by Finite Probabilistic Au­

tomata, Information and Control, 12 (1968), 284-303. 55. O. Nierstrasz, Regular Types for Active Objects, OOPSLA '93, 1-15. 56. W.J. Paul, E.J. Prauss and R. Reischuck, On Alternation, Acta Inform., 14

(1980), 243-255.

3 Finite Automata 85

57. D. Perrin, (Chapter 1) Finite Automata, Handbook of Theoretical Computer Science, Vol. B, edited by J. van Leeuwen, The MIT Press, 1990.

58. M.O. Rabin and D. Scott, Finite Automata and Their Decision Problems", IBM J. Res., 3, 2 (1959), 115-125.

59. W.L. Ruzzo, Tree-size Bounded Alternation, Journal of Computer and System Sciences, 21 (1980), 218-235.

60. A. Salomaa, Theory of Automata, Pergamon Press, Oxford, 1969. 61. A. Salomaa, Jewels of Formal Language Theory, Computer Science Press,

Rockville, Maryland, 1981. 62. K. Salomaa and S. Yu, Loop-Free Alternating Finite Automata, Technical Re­

port 482, Department of Computer Science, The Univ. of Western Ontario, 1996.

63. K. Salomaa, X. Wu, and S. Yu, An Efficient Implementation of Regular Lan­guages Using r-AFA, Proceedings of the Second International Workshop on Implementing Automata (WlA'97), Springer LNCS 1436, 176-184.

64. K. Salomaa, S. Yu, Q. Zhuang, The State Complexities of Some Basic Oper­ations on Regular Languages, Theoretical Computer Science, 125 (1994), 315-328.

65. N. Santean, Towards a Minimal Representation for Finite Languages: Theory and Pmctice, MSc Thesis, Department of Computer Science, The University of Western Ontario, 2000.

66. E.s. Santos, Maximin Automata, Information and Control, 13 (1968), 363-377. 67. E.S. Santos, Realization of Fuzzy Languages by Probabilistic, Max-Product,

and Maximin Automata, Information Sciences, 8 (1975), 39-53. 68. E.S. Santos, Regular Fuzzy Expressions Fuzzy Automata, Fuzzy Automata and

Decision Processes, edited by M.M. Gupta, G.N. Sandis and B.R. Gaines, No~h-Holland, 1977, 169-175.

69. J. Shallit and J. Stolfi, Two Methods for Generating Fractals, Computers & Gmphics, 13 (1989), 185-191.

70. D. Wood, Theory of Computation, Wiley, New York, 1987. 71. D. Wood and S. Yu, Automata Implementation, Second International Work­

shop on Implementing Automata, LNCS 1436, Springer, 1998. 72. S. Yu, Chapter 2: Regular Languages, in Handbook of Formal Languages, edited

by G. Rozenberg and A. Salomaa, Springer 1997. 73. S. Yu and Q. Zhuang, On the State Complexity of Intersection of Regular

Languages, ACM SIGACT News, 22, 3, (1991), 52-54.