617

IEEE TRANSACTIONS ON COMPUTERS, VOL. C-19, NO. 7, JULY 1970

the State Minimization of Nondeterministic Finite Automata On

TSUNEHIKO KAMEDA,

MEMBER, IEEE, AND

Abstract -The aim of this paper is to obtain a procedure for finding minimum state nondeterministic finite automaton (NDA) equivalent to a given (in general, nondeterministic) finite automaton. Given a

a

finite automaton

we

derive from

a

matrix of 1's and

O's,

called

a

reduced automaton matrix RAM) of X, in a certain.way and show that the RAM. A grid consists grid each state of sl corresponds to of a set of rows and a set of columns of an RAM such that only l's appear at the intersections. It is also shown that the union of all the grids, each of which corresponds to a state of X, covers all the 1 entries of an RAM. We then reverse this analysis in order to "synthesize" a minimum state NDA. First we construct an RAM of a given finite automaton; then we find a set of grids that covers all and only its 1 entries. With the help of the intersection rule described in the text, we construct an NDA whose states correspond to the grids in the set. Unfortunately, this construction does not always yield an NDA which is equivalent to the given automaton. But it is shown that at least one of the NDA's thus constructed is equivalent to the given automaton. Therefore we present a minimization procedure which includes searching. a

over

Index Terms -Equivalence of automata, finite automata theory, nondeterministic automata, reduction of automata, regular events.

INTRODUCTION HE CONCEPT of a nondeterministic (finite) automaton (NDA) was formulated by Rabin and Scott in their classical paper published in 1959 [1]. Recently it has found an extensive use in connection with the study of formal languages. Also, some attempts have been made to investigate and understand properties of NDA's [2]-[6]. Because of their finiteness, most of the problems concerning finite automata are easy to solve, but there are a few problems which have resisted every attempt to solve-a notable example being the problem of minimum star height [11]. Another problem which has been open to date is to find a nonexhaustive procedure for finding a minimum state NDA equivalent to a given NDA. The first published attempt was made by Ott and Feinstein [2]. In this paper we attack the latter open problem. Let N be the number of states of a given finite automaton. Any minimum state NDA equivalent to the given automaton has at most N states. It is clear that there are only finite number of NDA's which have at most N states. Therefore we can always resort to the exhaustive procedure. Namely, we can construct every NDA that has at most N states and pick one with the fewest states and equivalent to the given automaton. But this procedure is too lengthy to be pracManuscript received December 22, 1967; revised January 3, 1969 and October 23, 1969. T. Kameda is with the Department of Electrical Engineering, University of Waterloo, Waterloo, Ontario, Canada. P. Weiner is with the Department of Computer Science, Yale University, New Haven, Conn.

PETER WEINER, MEMBER,

IEEE

tical. Thus our problem is to find a procedure which yields the result with a reasonable amount of work. For an NDA there is no such thing as "canonical" NDA corresponding to the reduced DA which exists uniquely for any deterministic finite automaton (DA). However, we can look at our problem from the following viewpoint. Given an NDA we can always find a DA which is equivalent to it using the. subset construction. Once an equivalent DA is constructed, we can reduce it to get a reduced DA which is equivalent to the given NDA. Therefore even with an NDA we can uniquely associate a reduced DA equivalent to it. Thus we have standardized NDA's in a way, and our problem now is how to find a minimum state NDA equivalent to a given reduced DA. This is the approach we are going to take in this paper. The paper consists of two parts. In Part 1, we present some basic tools for analysis of finite automata, which are relevant to our later discussion, but quite general in nature. In Part 2, we attack the problem of state minimization. The reader is cautioned beforehand that the reduction of an NDA in the sense of [4] and [6] does not mean state minimization in our sense. According to their definition, an NDA is reduced if no two states are equivalent. In this paper, by a minimum NDA we mean a minimum state NDA within a behavior-equivalence class. PART 1: ANALYSIS I. PRELIMINARIES In the following we fix the input alphabet to be 1. Thus X* (the free monoid generated by X with unit e) denotes all finite input sequences, including the null sequence e of length 0. Any subset of X* is called an event. We denote the empty set by 0. A (finite) automaton d over the input alphabet I is a quadruple a? = (S, M, So, F) where S= {s , s2,* s",} (# 0) is the set of states, M: S x 1-+2' (the set of all subsets of S) is the transition function, SO(O 0) c S is the set of initial states, and F C S is the set of final states. If So = {s0}, and if IM(s, a)j = 1 for VseS and V-aiE, then the automaton a? is said to be a deterministic automaton (DA).' Otherwise ./ is said to be a nondeterministic automaton (NDA). The domain of the transition function M may be extended 1 Here denotes the size of the set inside. A DA is sometimes defined with the condition IM(s, a)I < 1. But any such DA can be converted to a DA of our definition by introducing a "dead" state (nonfinal state which has no outgoing transition except to itself).

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

618

to S x X* by a recursive definition. For V seS, VeX-, and Vxe*, M(s, e) = s M(s, xa) = U M(s', a).

from S x l

s'eM(s,x)

Po P

{M(SO,x)Ixex*}

F'-

M'(pi,

T)

SO

=

=

{pePlp nFF# 0}

=

{Ppi PP2.. Pm}

pi -- M(pi, a)=pj for all i,j, and VaeS.

is called the subset construction. We asIt is convenient to further extend the domain ofM to 2' x E* This construction i If picP does not contain any state of X, for sume #j. pi =#pj by then pi is called an empty state. forVRe25 andVxe *. Lemma 1: Let sl be as defined in Definition 2 and let M(R, x) = U M(s, x) seRc = D(d). Given Vpe P, we have the following relations: In the following we shall assume, without mentioning it, 1 ) sca(p) = U scd (s) that M is extended as above whenever necessary. Sep An input sequence xeX* is accepted by sl, iff M(So, x) 2) pr,(p) fn pr,(s) Sep rnF #0. The set 3)pr(p) n prv,(s) = 0 for VseS - p. bh(,4) = {x E X* IM(So, x) nrFF 0} is called the behavior of (or the event recognized by) d. The Proof: dual of an automaton sl = (S, M, SO, F) is defined as 1) sc,(p) = {XjM'(p, X) r) F # 0} = a? = (S, M, F, SO), {xj U M(s, x) n F # 0} Sep

where M is such that for VcTE-, Vsi, and VsjeS,

U

Sep

siE M(sj, ) sjs M(si, a). It is obvious that a? = a. The reverse of a sequence x=-C1Ca2 * *0*k, k> 1 and iTEX, iS = CTk ... CT2C1. The reverse of the null sequence e is defined to be itself, i.e., t= e. The reverse of an event E is defined as E = {k jxeE}. Note that for two events E and E', E = E'E= E'. In the sequel we assume that (VseS)(3xE *)[seM(So, x)]. We also assume FA 0, since otherwise bh(s) = 0 and all the problems concerning the behavior of such sl are trivial.

{xIM(s,x)nF#0} U sca(s). Sep pr,(p) = {x|p = M'(pO, x)} {xlp M(So x)} =

=

2)

=

=

C

{xlp C M(SO, x)}

A [seM(So,x)]} ={xI Sep = nf{xlsEM(So,x)} Sep

nf

Sep

3)

pr.,(s).

(VdsO¢p)[xEpra(p)>sO¢M(So, x)] -

But II. SUBSET CONSTRUCTION s ¢M(SO, x) x 0pry(s). In this section we introduce an operation called the subset Therefore construction,2 and show its rather interesting properties. Definition 1: Given an automaton d =(S, M, SO, F), the Q.E.D. (Vs 0 p)[x e pr,(p) =- x 0 prv,(s)]. succeeding event and preceding event of a state si of 4', sc,,(s,) and pra(si), respectively, are defined by3 If we let p=po=So in part 1 of Lemma 1, we get the following. scd(si) = bh((S, M, si, F)) Corollary (Rabin and Scott [1]): bh(D(d4))=bh(d). pr,,(si) = bh((S, M, SO, si)). Lemma 2: Therefore scd,(si)= {xe *| x)rnF 0} and prv(si) 1) scd(s) = ={xee*IsiEM(So, x)}. Two states of d, si and sj, are said 2) pr,(s)= to be equivalent, written si- s, iff sc(si)= scd(sj). A DA is reduced iff no two distinct states are equivalent. Proof: Easy and left to the reader. Clearly, if s is a DA, then for all i Aj, prd(s,)rnprd(sj)= 0. Definition 2: Given an automaton ' = (S, M, SO, F), Corollary (Rabin and Scott [1]): bh(as) -bh(d). we define the subset DA associated with v/ to be D(si) We now present an interesting but little known theorem, = (P, M', Po, F'), where which was discovered by Brzozowski [8]. Theorem 1 (Brzozowski): Let d =(S, M, SO, F) be a DA, 2 The operation was first used by Rabin and Scott [1] to construct a not necessarily reduced. D(d) is a reduced DA equivalent sl. DA equivalent to a given NDA. Proof: The fact that W=D(,l) is equivalent to ,4 folI The succeeding event and preceding event have been called by lows from the first corollary stated above. Now suppose that Brzozowski [8 ] the derivative and predecessor, respectively.

IM(si,

-5r.,(s)

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

619

Note that an SCM of .' is unique within permutation of

rows and columns. Example: If we apply the subset construction to the dual

# of the DA X, shown in Fig. 1(a), we get the reduced DA shown in Fig. l(b) (Theorem 1). An SCM of X0 is shown in Fig. l(c). It is seen that rows 2 and 3 cover row 1. Definition 4: Let d and ' be as defined in Definition 3. A characteristic event of a? is defined for each nonempty state

Final

(a) 1 2 3 4

(b)

q0

q1

q2

q3

0 1 1 0

0 0 0 1

1

1

1 1 0

1

qicQ as

chifi =(rf(qi). Since W is a DA, we have (see the note after Definition 1) ch-l r) chM' = 0 for i 1j.

1 1

(c)

Thus

(d)

were

hypothesis,

=

seqi

U seqj

seqi

U seqi

U seqi

=

pr,(s)

=

and

I*-ch(.4)

together

form

a

U ch. sc,(sj)= jlcij= 1 i

Proof: Let s/i = (S, M, si, F). From the two corollaries in Section II, it follows that

bh(4i) = bh(D(,4i)).

scj'(s).

Let X, Q, M", and qo be as defined above. Then

D(s1i) = (Q, M", qo, G),

U Prd(s) ftr,(s)= seqj

pry,(s)

m

i=l1

Theorem 2:

Using Lemma 2, we get U

1, 2, **,

partition of X*, where ch(,s) = U chr.

equivalent. By the

scw(qi) = scw(qj) which implies (by Lemma 1) that U sc,(s)

i=

m

Fig. 1. Reduction of a DA. (a) Given DA, 1*. (b) D(Y). (c) SCM of -*. (d) .*

two distinct states qi and qj of

ch-fl,

where G

U pry(s) seqj

U prd(s). seqj

= =

{qjeQlsiEqj}

{qjeQlcij = 1}.

Therefore The last equality says that the union of the (nonempty) events in a subset of the set {prd(s)IseS} is identical to the bh(D(-4i)) = U prD( 1)(qJ) qjc-G union of the events in another subset distinct from the first = U pr,(qj). subset. This is a contradiction to the fact that the preceding events of a DA are mutually disjoint. Q.E.D. Theorem 1 is significant in its own right and has some Thus it follows that interesting applications, which are discussed in Kameda sc,d(si)=bh(=i) and Weiner [7]. = U

U5Tr (q3)

cjj= 1

= U ch. STATE COMPOSITION MATRIX AND ITS PROPERTIES Q.E.D. jlcij= 1 In this section we shall investigate the relation among the Corollary: Two states of an automaton are equivalent succeeding events of the states of a finite automaton. For iff the corresponding rows in an SCM of the automaton this purpose we introduce the concept of the state composihave an identical pattern of l's and O's. tion matrix and investigate its properties. The above corollary is useful for the reduction Example: Definition 3: Given an automaton 4=(S, M, SO, F), let of a DA. It is seen that states 2 and 3 of the DA .' of Fig. 1(a) @ = D(s?) = (Q, M", qo, F"). A state composition matrix are since the corresponding rows in the SCM equivalent, contains for each state sieS and column (SCM) of shown in Fig. l(c) have an identical pattern of l's and O's. for each nonempty state (refer to Definition 2) qiEQ, with Thus the two states can be merged, yielding the reduced the (i, j) element DA X equivalent to X' (Fig. 1(d)). and d4/' be two NDA's. A configura_ 1 if si E- qj Definition 5: Let tion of is subset of the states of The configurations tj lo otherwise. C and C' of and d', respectively, equivalent, written A row of an SCM covers another row if the former has a 1 in C C', iff U scd(s) = U scd,(s'). every column in which the latter has a 1. sec s'ec' III.

a row

a

./

a

.'

.a.

are

620

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

q0

qI

q2

1

1

p0

Pi

2

P2

3

P3

2,3

2

1

1,3

2,3

(a)

(a)

q0

qI

q2

p0 P1

(b)

1

P2

1

P3

1

(c)

Fig. 2. Example for illustrating various concepts. (a) Given NDA, sl. (b) X4 = D(sa?). (c) le= D(X4).

Theorem 2 says that a state si of / is equivalent to the configuration {qjIcij= 1} of W. Corollary to Theorem 2: scd (si) D sc (sJ), iff the row (of an SCM of a?) corresponding to si covers the row corresponding to sJ. Corollary to Theorem 2: Any state of an NDA, whose row in the SCM is the union4 of some other rows, can be elimninated without changing the behavior of the NDA. Proof: Let {s} C. Modify the transition function M of d as follows: M'(s', a)=M(s', u)uC-{s} for VceX and Vs'IseM(s', a). It is clear that for no {s'} such that seM(s', a), sc,(s') is affected by this modification. Thus s can be eliminated without changing the behavior of the NDA. Q.E.D. Definition 6: An NDA is called irreducible iff it has no state such that the state is equivalent to any other configuration. It should be noted that there may be an NDA which is equivalent to an irreducible NDA but has fewer states. Therefore an irreducible NDA is, in general, different from a minimum state NDA. In fact, finding a minimum state NDA rather than an irreducible NDA is the objective of this paper. We mention here that given any matrix of l's and O's, one can construct a DA which has an SCM identical to the given matrix [7]. IV. REDUCED AUTOMATON MATRIX The main objective of this section is to introduce a few matrices which are derived from an automaton. Throughout the section, we let a? = (S, M, SO, F) be a given automaton, a = D(JZ) = (P, M', po, F'), and W = D(,4)

=(Q, M", qo, F"). Also we let SkeS, pieP, and qje Q.

4 Union is taken component-wise. The union operation is defined by OuO=O and Oul = luO= Iul = 1.

1

I 1

(b) Fig. 3. SM and EAM of d. (a) SM of d. (b) EAM of .-.

Definition 7: A states map (SM) of a? contains a row for each nonempty state of X, and a column for each nonempty state of W. The (i, j) entry contains pir-qj, or is blank if pinqj=0. An elementary automaton matrix (EAM) of sl is obtained from an SM of as by replacing each nonblank entry by a 1. Its (i, j) element is denoted by eij. Example: We construct an SM and EAM of the NDAQd of Fig. 2(a). Since we have D(d) and D(,d) available in Fig. 2(b) and (c), respectively, we simply follow Definition 7 to get an SM and EAM of 4, shown in Fig. 3(a) and (b), respectively. Theorem 3: U ch[ sc_(pi)= jleij= 1 Proof: By Theorem 2, sc (sk) = U ch. jJCkp

= 1

But by part 1 of Lemma 1,

sca(pi) = and since it is clear that = {lIeij= 1}, we have

SC(pi

U

ktskEpi

SCd(Sk),

{JICkj=1

U CM U |ilCkj= 1 ks|SkcPi

for k such that SkEPi} =

U

jleij= 1

ch?. Q.E.D.

Corollary: sca(pi)- sc,(pj), iff the row (of an EAM of d) corresponding to pi covers the row corresponding to pj. By covering we mean the same as in an SCM. (See Definition 3.) Thus we can carry out the reduction of the DA X, not only using an SCM but also using an EAM of a?. Namely two states of X which have an identical pattern of l's and O's in the corresponding rows of an EAM of d can be merged. We also note that the reduction of can be carried out as well by merging any set of states whose corresponding

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA { q0}

(PoI

1

pI1 !p3}

tP2)

is obtained from an RSM of sl by replacing each nonblank entry by a 1. Note that the reduced DA associated with 1 and a? are W and 4, respectively. Therefore the transpose of an RAM of s is an RAM of a?. Theorem 4: Let I be an equivalence class of automata. A unique (within permutation of the rows and columns) RAM exists for all automata in I. Proof: Let sdeI. By definition, an RAM of a? is an SCM of X, which is unique for Vt4/I except the names of the states. On the other hand, an SCM of a DA is unique within permutation of rows and columns. (See Theorems 1 and 2.) Hence follows the theorem. Q.E.D. Note that the converse of Theorem 4 is not true. Namely, two automata having the same RAM may belong to different equivalence classes.

{ q2})

{ qI}

1 2, 3

2,3

3

1

1,3

rq1)

tq21

(a)

( 4.1

p0}

1

(pP1 P3}

1

1

1

( P2}

I

(b) Fig. 4. RSM and RAM of s. (a) RSM of a. (b) RAM of sl.

columns have an identical pattern of l's and 0's. This follows from the fact that the definitions of X and are symmetric. The above observation implies, in terms of an SM, the following. Two states of X(W) which have an identical pattern of blank entries in the corresponding rows (columns) of an SM of a? can be merged. We shall call two rows (columns) equivalent if they have an identical pattern of blank entries. Definition 8: A reduced states map (RSM) of d is obtained from

an

by merging

SM of

all the

equivalent

rows

and

columns. The merging of two rows (columns) means the replacing of the two rows (columns) by a new row (column), each entry of which is the union of the entries in the corresponding column (row). Example: We consider the NDA 4 of Fig. 2(a) again. An SM of a? was obtained in Fig. 3(a). It is seen that the rows Pi and p3 are equivalent. Merging the two rows, we obtain an RSM shown in Fig. 4(a). No two columns are equivalent, since no two columns of Fig. 3(a) have an identical pattern of blank entries. Definition 9: The reduced DA associated with X, denoted = (P, M', p-, F'), is obtained from X4 as follows: P

=

{[P]IpeP},

where [p] is the equivalence class of the states of X containing p. Very often we shall consider [p] as consisting of states of v, namely [p] = {sj(3p'e [p])[sep']}.

M'([pi], a)

=

PO =

[pj]

M'(pi, a)

=

pj

for

Va

S.

[Po]

Ft= {[P]IPeF}. is obtained from X and W' in the SM is obtained from I and (Definition

Lemma 3: An RSM of

same manner as an

7).

621

Proof: Easy and left to the reader. Definition 10: A reduced automaton matrix (RAM) of

V. GRIDS AND COVERS In this section, we introduce the concepts of a grid and a cover, and then relate them with states of an automaton. Definition 11. Given an EAM (or RAM), if all the entries at the intersections of a set of rows {pi, , Pja} and a set of columns {qj,* qjb}. are l's, then this set of l's is said to form a grid. We represent the grid by g= (pi, , 7 Pia; qj, qjb). The grid g is said to contain the pair (pi,qJ), if ie{i1, * , ia} and j{j, v.j * jb}. A grid g1 tontains, or is an extension of another grid g2, written g1 :Dg2, if all the pairs contained in g2 are also contained in g1. Definition 12: A set of grids forms a cover if every 1 in the EAM (or RAM) belongs to at least one grid in the set. A minimum cover is a cover which consists of the minimum number of grids. Definition 13: Given a cover over an EAM (or RAM), a cover map (CM) is obtained by replacing each 1 in the EAM (or RAM) by the names of all the grids (in the given cover) it belongs to. If we connect the same name with horizontal and vertical lines, we will see a "grid" in the conventional sense of the word Theorem 5: Given an automaton a?, 1) an SM (RSM) of d is a CM, namely, the states of v1 appear as a cover over an EAM (RAM) of X, and 2) in the CM above, all the initial states of d appear in the row corresponding to po(po) and all the final states of d appear in the column corresponding to q0 (cu). (For the definitions of p,po0, q0, and 40, see Section IV.) Proof: 1) It is clear that any 1 in an EAM (RAM) belongs to at least one grid which corresponds to a state of Suppose a state s of d appears at two points in a CM, which are neither in the same row nor the same column. That is to say, sepj1nqj, and sepi2,rqj2, where i10i2 and il #2. These relations imply that sepirnqj2 and sepi2nqjl. Therefore s must appear also at (i1, j2) and (i2, jI). The case where the two points (i1, ji) and (i2, j2) are in the same row or in the same column is trivial. 2) follows from the construction of D(d) and D(J2). Q.E.D. Example: It is seen that in Figs. 3(a) and 4(a), the states of sl appear as a cover, and that the initial state 1 appears ---

a?.

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

622

in the row corresponding to po (Po) and the final states 2 and This explains why the name intersection rule has been 3 appear in the column corresponding to qo (40). chosen, and also makes the application of the rule very easy. Example: We apply the intersection rule to the DA R of 2(b). The natural subset assignment is shown in Fig. PART 2: SYNTHESIS the figure, where S is the set of states of a?. Let us determine In Part 2 we attack the problem of finding a minimum N(3, 0) as an example: NDA equivalent to a given automaton, which is the final N(3, 0) = n f(M(p, 0)) objective of the whole paper. One time-honored method of .113 ef(p) synthesis is to turn analysis "inside out." We shall resort to = f(M(P2, 0)) n f(M(P3, 0)) this method here. One vital tool of our analysis in Part 1 was = f(P2)nf(PO) the subset construction. In the following section we introduce an inverse operation of the subset construction and = {1,3}r{1},- >1}. investigate its properties. Now a question presents itself: Is the intersection rule VI. INTERSECTION RULE really an inverse of the subset construction? Or-more preTo begin with, we recall the following relationship of a cisely, is bh(I(S, f, NJ)) = bh(g), where is the natural given NDA d=(S, M', So, F') to its subset DA D(JI) subset assignment? Later we shall answer this question =(PI M, PoQ F):5 affirmatively. (See Lemma 5.) Then the next natural question is: How can one find a 1) po=So 2) (VseS)(VpeP)[seF'=t [se-p=s>peF]], i.e., all final subset assignment for which bh(I(Z, f, X)) =bh() states of 4 are only contained in final states of D(d) and such that the size of Z is minimum? As a matter of fact, 3) (Voce1)(Vs, Vs'eS)(VpeP)[s'eM'(s, )=> [sep=:. s' answering this question is precisely the ultimate objective eM(p, a)]f], i.e., if there is a transition from s to s' under of this paper. For the time being we shall drop the minia in 4, then there also is a transition under af in D(,f) mality requirement on Z and investigate properties of from any subset containing s to a subset containing s'. various subset assignments. Definition 16: A subset assignment to a DA X4 Now suppose we are only shown D(vt). Is it possible to is legitimate iflf bh(I(Z, f, X))= bh(g). A cover is legitimate reconstruct d/? This question motivates the following two iff its associated subset assignment is legitimate. definitions. Thus if 9 = D(d) for some NDA a?, the legitimacy of Definition 14: Let .4=(P, M, Po, F) be a DA. The pair implies bh(I(Z, f, 9))= bh(d). In the rest of this is called a subset assignment to X if Z is a finite set section we let X and be as defined in Definition 15. and f: P-+2z- {0} is a function. Such an f is called a Lemma 4: For V. bh(I(Z, f, f))(bh(.4). subset assignment function. The natural subset assignment Proof: See Appendix I. to the subset DA D(sl) is KS, f >, where S is the set of states Lemnm 5: The natural subset assignment is legitimate. of d and f(p)= {slsep} for VpeP. The subset assignment Proof: Let d = (S, M', So, F) and X4= D(d4). We want to associated with a cover over an EAM (or RAM) of an NDA show bh(I(S, f V))=bh(Y4) for the natural subset assignd assigns to each state of X= D(./) (or X) the set of grids ment . Let I(S, f, X)=(S, N, ZO, G). Then for VoeX, appearing in the corresponding row of the EAM (or RAM). VseS and peP, According to this definition, the natural subset assign1) Z0 =PO = S ment to D(v1) is the subset assignment associated with the => seF' p=> peF] seG, of an over d. a CM 2) as EAM) cover over an SM (considered = let be and a DA, Definition 15: Let X (P, M, po, F) so that be a subset assignment to X. Then I(Z, f, A4) is F' c G. the NDA (Z, N, Z0, G), where for VzeZZ, VpeP, and Voe-, 3) srE M'(s a) =[sE p =s'e M(p, )] 1) Zo=f(pO) 2) zeG,z[zEf(p)=>peFJ s' E N(s, a),

3) z'cN(z, a)zf(p)=z'-f(M(p, ))]. so that I(Z, f, £) is called the NDA obtained by the intersection

rule from M. Definition 15, among other things, specifies the transition function N of I(Z, f, X). It is easy to see that the definition amounts to N(z, a) = l f(M(p, a)) for Vz E Z and Vacr ES. plzef(p)

5 Note that we have switched the previous notations from M to M' and F to F, and vice versa, since in this section we are mainly concerned with D(d) and would like to avoid primed symbols.

=

M'(s, a) c- N(s,a ). #N(Z0, x)nG 0. Thus it is clear that M'(So, x)r)F'00= This implies that bh(./)c bh(I(S, f, 9i)). But bh(sl) = bh(.*)

by the corollary to Lemma 1 and bh(I(S, f, R))cbh(.) by Q.E.D. Lemma 4. Hence bh(I(S, f, .t))=bh(P*). Note that I(S, f, X) is not necessarily identical to d, as is exemplified by the following example. Example: Fig. 2(b) shows § = D(./) with the natural subset assignment , where S is the set of states of d.*

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

623 0

(a) Fig. 5. NDA obtained from X by the intersection rule.

I(S, f, AR) is shown in Fig. 5. Note that I(S, f, i) although the two NDA's are equivalent, as may be verified by constructing D(I(S, f, A)). The implication of the following theorem is that the search for a legitimate subset assignment to any DA -1 may be restricted to the subset assignments to . (, M, Po' F) be the reduced DA Theorem 6: Let 4=(P equivalent to M. If is a legitimate subset assignment to M, then is a legitimate subset assignment of -, where

(b)

Fig. 6. Intersection rule applied to .*. (a) -. (b) NDA obtained from -7 by the intersection rule.

VII. SUBSET ASSIGNMENTS ASSOCIATED WITH COVERS First we state a basic theorem which follows as a corollary to our previous theorems. = and Proof: Let I(Z, f, X) (Z, N, ZO, G) I(Z, 7, X-) Theorem 7: Given any automaton sl, there exists a legitVa we have and the For =(Z, N', ZO, G'). ec, VzzeZ, VpeP, imate cover over an RAM of / such that the NDA obtained relations. following the by intersection rule using the subset assignment asso1) zeZ0or.zef(Po) ciated with the cover is a minimum NDA. Proof: Follows from Theorems 4, 6, and Lemma 5. zej([po]) Choose a minimum NDA in the equivalence class I of => zeZ'O, Theorem 4. Its RSM shows a cover with the desired so that property. Q.E.D. Definition 17: A legitimate subset assignment to a DA such that the size of Z is minimum possible is called a 2) ze G [zef(p)=r>peF] minimum legitimate subset assignment. A minimum legitimate cover is a legitimate cover consisting of the minimumnum[z E [p]) >[pI C- F] ber of grids. z-zeG', Theorem 7 implies that we have only to consider covers so that over an RAM of a given NDA, in order to obtain a minimum NDA. Next we shall show that we can further restrict G = G'. the domain of search for a minimum legitimate cover. 3) z' E N(z, cr) [z E f(p) => z' E f(M(p, a))] Definition 18: A grid is called a prime grid iff it cannot be [z C f([p]) => z' ef(M([p], ))] properly contained in any other grid. Lemma 6: For any grid there exists at least one prime grid z'cEN'(z, a) that contains it. so that Lemma 7: Let a? = (S, M', SO, F') be an NDA, = (P, M, po, F) be D(.4), and let sieS and PkEEP such that N(z, a) N'(z, a). Si Pk. The grid over an EAM (or RAM) of 4 corresponding We may deduce, as in the proof of Lemma 5, that to (see Theorem 5) can be extended to the row of the EAM bh(I(Z, f, .M))sbh(I(Z, 7, i)). But bh(I(Z, 7, M ))bh(4) by (orsiRAM) corresponding to Pk iff Lemma 4 and bh(MJ)=bh(I(Z, f, 9)) by our assumption, which together yield bh(I(Z, 7, _4_)) bh(I(Z, f, gB)). Hence SC,d(Si) C- Sca(Pk)bh(I(Z, 7, Mi)) = bh(I(Z, f, M)) = bh(Q). Q.E.D. Proof: Note Example: The a for our running example 4 is shown in Fig. 6(a). Note that I(S, f, g) shown in Fig. 6(b) is equivalent U chi' (Theorem 2) sc,d(si) = jlcij= but not identical to I(S, f, tv). 1

f([p])= p'eU[PI f(p').

=

Z'

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

624

and

q0

SC,(Pk)= U 1 ch' (Theorem 3). From the constructions of an SCM of a? and EAM of a,, it should be clear that si is extendable to Pk {jjcjj 1} C {f'ekl = 1l. Thus we have si is extendable to Pk'* SCd(S() C SC4(Pk). Q.E.D. Lemma 8: Let a? and X be as defined in Lemma 7. If scd(si) c sca(pk), then (Voce-)(VseM'(sj, Sca(M(Pk, 0)) . Proof: It is clear that u U SC,d(Si) = (U c7e 6( seM'(si,a) scd(s))) (Si) where (si)=e if si E F' and 0 otherwise. Similarly we have scQ(pk) = ( aUo SC(M(pk, C)) U (Pk)

c))[scd(s)

P2

y

y

P3

P4

P5

e

q5

q6

8

6

8

6)e

q7

a

a

q8

q9

11

T

P6

P7

(a) Input State Init ial

Final

(Pk) = e if Pk E F and 0 otherwise.

q4

p1

=

where

q3

P0

lIekl=

`

q2

q1

0

1

po

P4

P0

p1

P5

p0

p2

P6

Pi

P3

P2

P7

P2

P7

P5

P1

P6

PO

P3 P3

_*

P7 PO By taking the derivative (Brzozowski [9J) of both sides of Po P0 Po Po a scV(M(pk,l)) b(Pk) (U ( U sc4(s)) U b(sd) C (U a,E aGe seM'(si,a) (b) with respect to a, we get Fig. 7. Example of illegitimate minimum cover. (a) CM. (b) DA associated with the CM. U SC.,(s) C sca(M(pk, C)). seM'(si a) Q.E.D. without going back to the original RAM. Note, however, Hence follows the lemma. Theorem 8: If a legitimate cover is given, we can derive a that when both rows and columns are eliminated, we have legitimate cover consisting only of prime grids which are to make sure that the eliminated row (or column) is a union extensions of the grids in the given cover. Moreover, the of some other rows (or columns) in the original RAM. number of the prime grids in the new cover is no more than Lemma 10: There exists an RAM such that no minimum the number of grids in the given cover. cover over it is legitimate.6 Proof: See Appendix II. Proof: We shall give an example of such an RAM. Corollary: In finding a minimum legitimate cover, we Fig. 7 shows the reduced DA associated with an NDA (not have only to consider prime grids over an RAM. shown) and a minimum cover over the RAM of the NDA. It is clear that the cover shown is the only minimum cover. VIII. MINIMIZATION PROCEDURE That is is not legitimate can be shown by actually constructQ.E.D. now we ing an NDA using the intersection rule. in the sections, previous With the preparations ofNDA's. minimization our procedure are ready to describe Minimization Procedure: We present two lemmas before describing our procedure. 1) Given an NDA, construct its RAM and find a miniThe first lemma, which is presented without proof since it is a mum cover. of the great finding prime grids simple, usually simplifies Let io be the number of grids in the minimum cover 2) deal. can be RAM above and set i= io an found of row expressed Lemma 9: If a (column) of each cover containing i prime grids, test elimination For the a) rows other (columns), as a union4 of some it is legitimate. whether of the the row (column) does not affect finding prime grids, cover is found, set i= i+ 1, and go If no in legitimate is included b) row (column) provided that the eliminated a. to be that can step of the first (second) coordinate every prime grid extended to that row (column). 6 This lemma was proved by Professor S. Even of Harvard University, When we eliminate either rows or columns only, as who also provided us with an example in the proof. one one them eliminate we Lemma can by described in 9,

625

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

It is obvious that the process should terminate after a finite number of cycles. In fact, an upper bound on the number of cycles is given by MIN(/, n, m), where 1, n, m are, respectively, the number of states in the given NDA, that in the reduced DA associated with the given NDA, and that in the reduced DA associated with the dual of the given NDA. Example: We apply our procedure to the NDA / of Fig. 2(a). The reduced DA X associated with a?, shown in Fig. 8(a), was obtained from X (Fig. 2(b)). An RAM of .4 was obtained before (Fig. 4(b)). In this case we have a unique minimum cover shown in Fig. 8(b). Fig. 8(c) shows the subset assignment associated with this cover. Using the intersection rule, we obtain the NDA shown in Fig. 8(d). It can be easily verified that the cover we used is legitimate, by applying the subset construction of the NDA of Fig. 8(d) and showing that it is equivalent to X. In the above example, the only minimum cover turned out to be legitimate. At present we do not know how typical this is, although we do know that this is not always the case (see Lemma 10). In the above form our minimization procedure requires that every cover be tested in some systematic way until a legitimate cover is found. This may take the following steps. We let X = (P, M, Po, F) be the reduced DA associated with the given NDA. 1) Apply the intersection rule to X to obtain X = I(Z, f, -i) = (Z, N, ZO, G), where is the subset assignment associated with the chosen cover. 2) Construct D(.,#). 3) Reduce D(Xk) and test if it is equivalent to -. We shall show that the steps 2 and 3 can be replaced by a simpler test. Lemma 11: Given the CM of a legitimate cover over an RAM, let X and X/ be as defined above. Suppose the cover contains a grid z=(p1,. , Pa; ql, * qb)-7 Then

A

A2

A1

AO

A

0

0

0

0

c

cc

p1

1

a

A

cc

a,

Cy O

1

(b)

(a)

0

(d)

(c)

Fig. 8. Minimization of .l of Fig. 2(a). (a) Xd. (b) CM. (c) X with . (d) I(Z,f, -l).

This, together with (1), completes the proof. Now let D(.&k)=(U, L, uo, H). Lemma 12: For Vu E U and Vp E P, u

p'n:(Va G )[L(u, a) M(p, v)] A [uE H -

Q.E.D.

p E F].

Q.E.D. Proof: Similar to the proof of Lemma 8. Definition 19: A set of grids in a row of a CM spans the row iff at least one grid in the set appears in each nonblank entry in the row. Theorem 9: Using the current notations, we have the following. 1) (3fae1)[L(u, a) does'not span the row M(p, a) of the RAM v[M(p, a)eGAL(u, a)OH]]=-p. 2) (Vxe *)[L(u, x) spans the row M(po, x) A [M(po, x)eG

--tcL(uo, x)eH]]=:>bh(.A)=bh(X).

Proof: 1) Suppose L(u, a) does not span the row a). Then M(p, -U chk scX(z) U sca,(z) (Lemma 1) scD(A)(L(u, a)) = zeL(u,a) Proof: The RAM mentioned in the theorem can be U scJf(z) (Lemma 11) considered as an SCM of M. (See the proof of Theorem 4.) c zef(L(u,a)) Since z is a grid, the SCM of X has l's at the intersections of (Lemma 11). c sci(M(p, a)) rows, P1,-. , Pa and the columns q1, qb. Therefore it follows from Theorem 2 that Note that the second line above is a proper cotainment. b Thus u -, p by Lemma 12. The rest follows from the fact that 1, i= ,a. 2,-ch', U (1) sc,4(pi) M(p, )EG A L(u,a) H ) L(u, a) -, M(p, a). = Consider now the automata, k =(Z, N, z, G) and X 2) The condition implies that there is a homomorphism a. It follows from Lemma 4 that (P, M, pi, F) for i= 1, 2, 0: U-+P such that i= 1,2,---,a, bh(.,k) ' bh(4), (Vu e U)[O(L(u, a)) = M(O (u), a)] which means and a. sc,A(z) c (Pi), 11 2, ueH H (u)eF. Therefore it follows that bh(')= bh(D(#))= bh(gB). Q.E.D. Now we can replace the steps 2 and 3 above by the fol7 Strictly speaking, we should use double indexing likepi * * ,pi., but lowing. no confusion should arise here. b

k= 1

...

,

626

IEEE TRANSACTIONS ON COMPUTERS, 3ULY 1970

2') Consider the list of pairs (ui, pi), where uie U, pi,P, starting with (u0, po). 3') Given a pair (u, p), test L(u, a) and M(p, a) against the condition of part 1 of Theorem 9 for each aec. If it is satisfied, then u-op and the cover under test is illegitimate. Otherwise add the pair (L(u, a), M(p, a)) to the list, if it is not already there. 4') Repeat 3') for each new pair. If the process terminates without detecting illegitimacy, then the cover under test is legitimate.

CONCLUSION After obtaining some basic results in Part 1, in Part 2 we presented a minimization procedure for NDA's, which is more efficient than the only existing procedure, namely the exhaustive search. Except for few examples, most of the samples we have tried have the property that there exists a minimum cover that is legitimate. But at the time of writing, we do not know in quantitative terms how often it is the case. At present we are looking for a more efficient method of finding legitimate covers. APPENDIX I PROOF OF LEMMA 4 Let lg(x) be the length of the sequence x with the provision that lg(e) = 0. We first prove

N(ZO, x) c f(M(po, x)) by the induction on lg(x). 1) lg(x) = 0: This implies x = e. Thus we have

N(ZO, e) = ZO

=

f(M(po, e)).

(2)

APPENDIX II PROOF OF THEOREM 8 Let be the subset assignment associated with the given cover and let 4X = I(Z, f, A) and X = D(X) =(U, L, u0 -). (The entries which are not important in our present discussion are indicated by -.) Let X = (U, L, o0,-) be the reduced DA associated with X. We now consider an RSM of M and the subset assign ment associated with it. We know by Theorem 6 that I(Z, h, X') is equivalent to X, and hence to M. The fact that the grid (in an RSM of M) corresponding to zeZ can be extended to the row corresponding to u s U means that scA(z) c sc-(u) (Lemma 7). We modify the legitimate subset assignment function h to get another subset assignment function h', which will be shown to be legitimate, and to be the subset assignment function associated with a cover containing only prime grids. Case 1: In an RSM of M there is no grid z which can be extended to a row u such that z u. In this case no vertical extension of any grid is possible. (See the comment after Definition 13.) We now extend all the grids horizontally as far as possible, so that all the grids are converted to prime grids. In this process the function is not changed. Therefore h= h and now we have a legitimate cover containing only prime grids. Case 2: There exists a grid z extendable to a row u such that z u. In this case we define h' by the following recursive definition. a) h'(u) = h(u) u {z}. This corresponds to the extension of z to u. b) h'(L(u, a)) = h(L(u, a)) u K(z, a) for Vaec2

where K is the transition function of I(Z, h, '). This makes 2) Assume true for all x such that lg(x) < 1. Let x = a1a2 ... sure that a1, and x'=xa1, where aie-E for i= 1, 2, , 1. (Vae)(VzeZ)[K(z, a) c K'(z, a)] (3) N(ZO, x') = N(N(Zo, x), a1) where K' is the transition function of I(Z, h', X). Note that - U N(z, a1) the extensions implied by 2) are always possible because of zeN(Zo,x) Lemmas 7 and 8. U c N(z, a1) zef(M(po,x)) c) For each z'e K(z, a) - h(L(u, a)), replace z and u in a) u ( ln f(M(p, a,)) by z' and L(u, a). This makes sure that (3) holds true zef(M(po,x)) Pjzef(p) for each extension implied by b). f(M(M(po, x), ad)) After this process terminates, we find a new pair z and u = f(M(po, x)). which satisfies the condition of Case 2, and apply the process. Finally we will arrive at Case 1 and all the grids We now can prove the lemma as follows. will be extended to prime grids. By (3) and Lemma 4, we For Vxe*, conclude that

IEEE TRANSACTIONS ON COMPUTERS, VOL. C-19, NO. 7, JULY 1970

the State Minimization of Nondeterministic Finite Automata On

TSUNEHIKO KAMEDA,

MEMBER, IEEE, AND

Abstract -The aim of this paper is to obtain a procedure for finding minimum state nondeterministic finite automaton (NDA) equivalent to a given (in general, nondeterministic) finite automaton. Given a

a

finite automaton

we

derive from

a

matrix of 1's and

O's,

called

a

reduced automaton matrix RAM) of X, in a certain.way and show that the RAM. A grid consists grid each state of sl corresponds to of a set of rows and a set of columns of an RAM such that only l's appear at the intersections. It is also shown that the union of all the grids, each of which corresponds to a state of X, covers all the 1 entries of an RAM. We then reverse this analysis in order to "synthesize" a minimum state NDA. First we construct an RAM of a given finite automaton; then we find a set of grids that covers all and only its 1 entries. With the help of the intersection rule described in the text, we construct an NDA whose states correspond to the grids in the set. Unfortunately, this construction does not always yield an NDA which is equivalent to the given automaton. But it is shown that at least one of the NDA's thus constructed is equivalent to the given automaton. Therefore we present a minimization procedure which includes searching. a

over

Index Terms -Equivalence of automata, finite automata theory, nondeterministic automata, reduction of automata, regular events.

INTRODUCTION HE CONCEPT of a nondeterministic (finite) automaton (NDA) was formulated by Rabin and Scott in their classical paper published in 1959 [1]. Recently it has found an extensive use in connection with the study of formal languages. Also, some attempts have been made to investigate and understand properties of NDA's [2]-[6]. Because of their finiteness, most of the problems concerning finite automata are easy to solve, but there are a few problems which have resisted every attempt to solve-a notable example being the problem of minimum star height [11]. Another problem which has been open to date is to find a nonexhaustive procedure for finding a minimum state NDA equivalent to a given NDA. The first published attempt was made by Ott and Feinstein [2]. In this paper we attack the latter open problem. Let N be the number of states of a given finite automaton. Any minimum state NDA equivalent to the given automaton has at most N states. It is clear that there are only finite number of NDA's which have at most N states. Therefore we can always resort to the exhaustive procedure. Namely, we can construct every NDA that has at most N states and pick one with the fewest states and equivalent to the given automaton. But this procedure is too lengthy to be pracManuscript received December 22, 1967; revised January 3, 1969 and October 23, 1969. T. Kameda is with the Department of Electrical Engineering, University of Waterloo, Waterloo, Ontario, Canada. P. Weiner is with the Department of Computer Science, Yale University, New Haven, Conn.

PETER WEINER, MEMBER,

IEEE

tical. Thus our problem is to find a procedure which yields the result with a reasonable amount of work. For an NDA there is no such thing as "canonical" NDA corresponding to the reduced DA which exists uniquely for any deterministic finite automaton (DA). However, we can look at our problem from the following viewpoint. Given an NDA we can always find a DA which is equivalent to it using the. subset construction. Once an equivalent DA is constructed, we can reduce it to get a reduced DA which is equivalent to the given NDA. Therefore even with an NDA we can uniquely associate a reduced DA equivalent to it. Thus we have standardized NDA's in a way, and our problem now is how to find a minimum state NDA equivalent to a given reduced DA. This is the approach we are going to take in this paper. The paper consists of two parts. In Part 1, we present some basic tools for analysis of finite automata, which are relevant to our later discussion, but quite general in nature. In Part 2, we attack the problem of state minimization. The reader is cautioned beforehand that the reduction of an NDA in the sense of [4] and [6] does not mean state minimization in our sense. According to their definition, an NDA is reduced if no two states are equivalent. In this paper, by a minimum NDA we mean a minimum state NDA within a behavior-equivalence class. PART 1: ANALYSIS I. PRELIMINARIES In the following we fix the input alphabet to be 1. Thus X* (the free monoid generated by X with unit e) denotes all finite input sequences, including the null sequence e of length 0. Any subset of X* is called an event. We denote the empty set by 0. A (finite) automaton d over the input alphabet I is a quadruple a? = (S, M, So, F) where S= {s , s2,* s",} (# 0) is the set of states, M: S x 1-+2' (the set of all subsets of S) is the transition function, SO(O 0) c S is the set of initial states, and F C S is the set of final states. If So = {s0}, and if IM(s, a)j = 1 for VseS and V-aiE, then the automaton a? is said to be a deterministic automaton (DA).' Otherwise ./ is said to be a nondeterministic automaton (NDA). The domain of the transition function M may be extended 1 Here denotes the size of the set inside. A DA is sometimes defined with the condition IM(s, a)I < 1. But any such DA can be converted to a DA of our definition by introducing a "dead" state (nonfinal state which has no outgoing transition except to itself).

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

618

to S x X* by a recursive definition. For V seS, VeX-, and Vxe*, M(s, e) = s M(s, xa) = U M(s', a).

from S x l

s'eM(s,x)

Po P

{M(SO,x)Ixex*}

F'-

M'(pi,

T)

SO

=

=

{pePlp nFF# 0}

=

{Ppi PP2.. Pm}

pi -- M(pi, a)=pj for all i,j, and VaeS.

is called the subset construction. We asIt is convenient to further extend the domain ofM to 2' x E* This construction i If picP does not contain any state of X, for sume #j. pi =#pj by then pi is called an empty state. forVRe25 andVxe *. Lemma 1: Let sl be as defined in Definition 2 and let M(R, x) = U M(s, x) seRc = D(d). Given Vpe P, we have the following relations: In the following we shall assume, without mentioning it, 1 ) sca(p) = U scd (s) that M is extended as above whenever necessary. Sep An input sequence xeX* is accepted by sl, iff M(So, x) 2) pr,(p) fn pr,(s) Sep rnF #0. The set 3)pr(p) n prv,(s) = 0 for VseS - p. bh(,4) = {x E X* IM(So, x) nrFF 0} is called the behavior of (or the event recognized by) d. The Proof: dual of an automaton sl = (S, M, SO, F) is defined as 1) sc,(p) = {XjM'(p, X) r) F # 0} = a? = (S, M, F, SO), {xj U M(s, x) n F # 0} Sep

where M is such that for VcTE-, Vsi, and VsjeS,

U

Sep

siE M(sj, ) sjs M(si, a). It is obvious that a? = a. The reverse of a sequence x=-C1Ca2 * *0*k, k> 1 and iTEX, iS = CTk ... CT2C1. The reverse of the null sequence e is defined to be itself, i.e., t= e. The reverse of an event E is defined as E = {k jxeE}. Note that for two events E and E', E = E'E= E'. In the sequel we assume that (VseS)(3xE *)[seM(So, x)]. We also assume FA 0, since otherwise bh(s) = 0 and all the problems concerning the behavior of such sl are trivial.

{xIM(s,x)nF#0} U sca(s). Sep pr,(p) = {x|p = M'(pO, x)} {xlp M(So x)} =

=

2)

=

=

C

{xlp C M(SO, x)}

A [seM(So,x)]} ={xI Sep = nf{xlsEM(So,x)} Sep

nf

Sep

3)

pr.,(s).

(VdsO¢p)[xEpra(p)>sO¢M(So, x)] -

But II. SUBSET CONSTRUCTION s ¢M(SO, x) x 0pry(s). In this section we introduce an operation called the subset Therefore construction,2 and show its rather interesting properties. Definition 1: Given an automaton d =(S, M, SO, F), the Q.E.D. (Vs 0 p)[x e pr,(p) =- x 0 prv,(s)]. succeeding event and preceding event of a state si of 4', sc,,(s,) and pra(si), respectively, are defined by3 If we let p=po=So in part 1 of Lemma 1, we get the following. scd(si) = bh((S, M, si, F)) Corollary (Rabin and Scott [1]): bh(D(d4))=bh(d). pr,,(si) = bh((S, M, SO, si)). Lemma 2: Therefore scd,(si)= {xe *| x)rnF 0} and prv(si) 1) scd(s) = ={xee*IsiEM(So, x)}. Two states of d, si and sj, are said 2) pr,(s)= to be equivalent, written si- s, iff sc(si)= scd(sj). A DA is reduced iff no two distinct states are equivalent. Proof: Easy and left to the reader. Clearly, if s is a DA, then for all i Aj, prd(s,)rnprd(sj)= 0. Definition 2: Given an automaton ' = (S, M, SO, F), Corollary (Rabin and Scott [1]): bh(as) -bh(d). we define the subset DA associated with v/ to be D(si) We now present an interesting but little known theorem, = (P, M', Po, F'), where which was discovered by Brzozowski [8]. Theorem 1 (Brzozowski): Let d =(S, M, SO, F) be a DA, 2 The operation was first used by Rabin and Scott [1] to construct a not necessarily reduced. D(d) is a reduced DA equivalent sl. DA equivalent to a given NDA. Proof: The fact that W=D(,l) is equivalent to ,4 folI The succeeding event and preceding event have been called by lows from the first corollary stated above. Now suppose that Brzozowski [8 ] the derivative and predecessor, respectively.

IM(si,

-5r.,(s)

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

619

Note that an SCM of .' is unique within permutation of

rows and columns. Example: If we apply the subset construction to the dual

# of the DA X, shown in Fig. 1(a), we get the reduced DA shown in Fig. l(b) (Theorem 1). An SCM of X0 is shown in Fig. l(c). It is seen that rows 2 and 3 cover row 1. Definition 4: Let d and ' be as defined in Definition 3. A characteristic event of a? is defined for each nonempty state

Final

(a) 1 2 3 4

(b)

q0

q1

q2

q3

0 1 1 0

0 0 0 1

1

1

1 1 0

1

qicQ as

chifi =(rf(qi). Since W is a DA, we have (see the note after Definition 1) ch-l r) chM' = 0 for i 1j.

1 1

(c)

Thus

(d)

were

hypothesis,

=

seqi

U seqj

seqi

U seqi

U seqi

=

pr,(s)

=

and

I*-ch(.4)

together

form

a

U ch. sc,(sj)= jlcij= 1 i

Proof: Let s/i = (S, M, si, F). From the two corollaries in Section II, it follows that

bh(4i) = bh(D(,4i)).

scj'(s).

Let X, Q, M", and qo be as defined above. Then

D(s1i) = (Q, M", qo, G),

U Prd(s) ftr,(s)= seqj

pry,(s)

m

i=l1

Theorem 2:

Using Lemma 2, we get U

1, 2, **,

partition of X*, where ch(,s) = U chr.

equivalent. By the

scw(qi) = scw(qj) which implies (by Lemma 1) that U sc,(s)

i=

m

Fig. 1. Reduction of a DA. (a) Given DA, 1*. (b) D(Y). (c) SCM of -*. (d) .*

two distinct states qi and qj of

ch-fl,

where G

U pry(s) seqj

U prd(s). seqj

= =

{qjeQlsiEqj}

{qjeQlcij = 1}.

Therefore The last equality says that the union of the (nonempty) events in a subset of the set {prd(s)IseS} is identical to the bh(D(-4i)) = U prD( 1)(qJ) qjc-G union of the events in another subset distinct from the first = U pr,(qj). subset. This is a contradiction to the fact that the preceding events of a DA are mutually disjoint. Q.E.D. Theorem 1 is significant in its own right and has some Thus it follows that interesting applications, which are discussed in Kameda sc,d(si)=bh(=i) and Weiner [7]. = U

U5Tr (q3)

cjj= 1

= U ch. STATE COMPOSITION MATRIX AND ITS PROPERTIES Q.E.D. jlcij= 1 In this section we shall investigate the relation among the Corollary: Two states of an automaton are equivalent succeeding events of the states of a finite automaton. For iff the corresponding rows in an SCM of the automaton this purpose we introduce the concept of the state composihave an identical pattern of l's and O's. tion matrix and investigate its properties. The above corollary is useful for the reduction Example: Definition 3: Given an automaton 4=(S, M, SO, F), let of a DA. It is seen that states 2 and 3 of the DA .' of Fig. 1(a) @ = D(s?) = (Q, M", qo, F"). A state composition matrix are since the corresponding rows in the SCM equivalent, contains for each state sieS and column (SCM) of shown in Fig. l(c) have an identical pattern of l's and O's. for each nonempty state (refer to Definition 2) qiEQ, with Thus the two states can be merged, yielding the reduced the (i, j) element DA X equivalent to X' (Fig. 1(d)). and d4/' be two NDA's. A configura_ 1 if si E- qj Definition 5: Let tion of is subset of the states of The configurations tj lo otherwise. C and C' of and d', respectively, equivalent, written A row of an SCM covers another row if the former has a 1 in C C', iff U scd(s) = U scd,(s'). every column in which the latter has a 1. sec s'ec' III.

a row

a

./

a

.'

.a.

are

620

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

q0

qI

q2

1

1

p0

Pi

2

P2

3

P3

2,3

2

1

1,3

2,3

(a)

(a)

q0

qI

q2

p0 P1

(b)

1

P2

1

P3

1

(c)

Fig. 2. Example for illustrating various concepts. (a) Given NDA, sl. (b) X4 = D(sa?). (c) le= D(X4).

Theorem 2 says that a state si of / is equivalent to the configuration {qjIcij= 1} of W. Corollary to Theorem 2: scd (si) D sc (sJ), iff the row (of an SCM of a?) corresponding to si covers the row corresponding to sJ. Corollary to Theorem 2: Any state of an NDA, whose row in the SCM is the union4 of some other rows, can be elimninated without changing the behavior of the NDA. Proof: Let {s} C. Modify the transition function M of d as follows: M'(s', a)=M(s', u)uC-{s} for VceX and Vs'IseM(s', a). It is clear that for no {s'} such that seM(s', a), sc,(s') is affected by this modification. Thus s can be eliminated without changing the behavior of the NDA. Q.E.D. Definition 6: An NDA is called irreducible iff it has no state such that the state is equivalent to any other configuration. It should be noted that there may be an NDA which is equivalent to an irreducible NDA but has fewer states. Therefore an irreducible NDA is, in general, different from a minimum state NDA. In fact, finding a minimum state NDA rather than an irreducible NDA is the objective of this paper. We mention here that given any matrix of l's and O's, one can construct a DA which has an SCM identical to the given matrix [7]. IV. REDUCED AUTOMATON MATRIX The main objective of this section is to introduce a few matrices which are derived from an automaton. Throughout the section, we let a? = (S, M, SO, F) be a given automaton, a = D(JZ) = (P, M', po, F'), and W = D(,4)

=(Q, M", qo, F"). Also we let SkeS, pieP, and qje Q.

4 Union is taken component-wise. The union operation is defined by OuO=O and Oul = luO= Iul = 1.

1

I 1

(b) Fig. 3. SM and EAM of d. (a) SM of d. (b) EAM of .-.

Definition 7: A states map (SM) of a? contains a row for each nonempty state of X, and a column for each nonempty state of W. The (i, j) entry contains pir-qj, or is blank if pinqj=0. An elementary automaton matrix (EAM) of sl is obtained from an SM of as by replacing each nonblank entry by a 1. Its (i, j) element is denoted by eij. Example: We construct an SM and EAM of the NDAQd of Fig. 2(a). Since we have D(d) and D(,d) available in Fig. 2(b) and (c), respectively, we simply follow Definition 7 to get an SM and EAM of 4, shown in Fig. 3(a) and (b), respectively. Theorem 3: U ch[ sc_(pi)= jleij= 1 Proof: By Theorem 2, sc (sk) = U ch. jJCkp

= 1

But by part 1 of Lemma 1,

sca(pi) = and since it is clear that = {lIeij= 1}, we have

SC(pi

U

ktskEpi

SCd(Sk),

{JICkj=1

U CM U |ilCkj= 1 ks|SkcPi

for k such that SkEPi} =

U

jleij= 1

ch?. Q.E.D.

Corollary: sca(pi)- sc,(pj), iff the row (of an EAM of d) corresponding to pi covers the row corresponding to pj. By covering we mean the same as in an SCM. (See Definition 3.) Thus we can carry out the reduction of the DA X, not only using an SCM but also using an EAM of a?. Namely two states of X which have an identical pattern of l's and O's in the corresponding rows of an EAM of d can be merged. We also note that the reduction of can be carried out as well by merging any set of states whose corresponding

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA { q0}

(PoI

1

pI1 !p3}

tP2)

is obtained from an RSM of sl by replacing each nonblank entry by a 1. Note that the reduced DA associated with 1 and a? are W and 4, respectively. Therefore the transpose of an RAM of s is an RAM of a?. Theorem 4: Let I be an equivalence class of automata. A unique (within permutation of the rows and columns) RAM exists for all automata in I. Proof: Let sdeI. By definition, an RAM of a? is an SCM of X, which is unique for Vt4/I except the names of the states. On the other hand, an SCM of a DA is unique within permutation of rows and columns. (See Theorems 1 and 2.) Hence follows the theorem. Q.E.D. Note that the converse of Theorem 4 is not true. Namely, two automata having the same RAM may belong to different equivalence classes.

{ q2})

{ qI}

1 2, 3

2,3

3

1

1,3

rq1)

tq21

(a)

( 4.1

p0}

1

(pP1 P3}

1

1

1

( P2}

I

(b) Fig. 4. RSM and RAM of s. (a) RSM of a. (b) RAM of sl.

columns have an identical pattern of l's and 0's. This follows from the fact that the definitions of X and are symmetric. The above observation implies, in terms of an SM, the following. Two states of X(W) which have an identical pattern of blank entries in the corresponding rows (columns) of an SM of a? can be merged. We shall call two rows (columns) equivalent if they have an identical pattern of blank entries. Definition 8: A reduced states map (RSM) of d is obtained from

an

by merging

SM of

all the

equivalent

rows

and

columns. The merging of two rows (columns) means the replacing of the two rows (columns) by a new row (column), each entry of which is the union of the entries in the corresponding column (row). Example: We consider the NDA 4 of Fig. 2(a) again. An SM of a? was obtained in Fig. 3(a). It is seen that the rows Pi and p3 are equivalent. Merging the two rows, we obtain an RSM shown in Fig. 4(a). No two columns are equivalent, since no two columns of Fig. 3(a) have an identical pattern of blank entries. Definition 9: The reduced DA associated with X, denoted = (P, M', p-, F'), is obtained from X4 as follows: P

=

{[P]IpeP},

where [p] is the equivalence class of the states of X containing p. Very often we shall consider [p] as consisting of states of v, namely [p] = {sj(3p'e [p])[sep']}.

M'([pi], a)

=

PO =

[pj]

M'(pi, a)

=

pj

for

Va

S.

[Po]

Ft= {[P]IPeF}. is obtained from X and W' in the SM is obtained from I and (Definition

Lemma 3: An RSM of

same manner as an

7).

621

Proof: Easy and left to the reader. Definition 10: A reduced automaton matrix (RAM) of

V. GRIDS AND COVERS In this section, we introduce the concepts of a grid and a cover, and then relate them with states of an automaton. Definition 11. Given an EAM (or RAM), if all the entries at the intersections of a set of rows {pi, , Pja} and a set of columns {qj,* qjb}. are l's, then this set of l's is said to form a grid. We represent the grid by g= (pi, , 7 Pia; qj, qjb). The grid g is said to contain the pair (pi,qJ), if ie{i1, * , ia} and j{j, v.j * jb}. A grid g1 tontains, or is an extension of another grid g2, written g1 :Dg2, if all the pairs contained in g2 are also contained in g1. Definition 12: A set of grids forms a cover if every 1 in the EAM (or RAM) belongs to at least one grid in the set. A minimum cover is a cover which consists of the minimum number of grids. Definition 13: Given a cover over an EAM (or RAM), a cover map (CM) is obtained by replacing each 1 in the EAM (or RAM) by the names of all the grids (in the given cover) it belongs to. If we connect the same name with horizontal and vertical lines, we will see a "grid" in the conventional sense of the word Theorem 5: Given an automaton a?, 1) an SM (RSM) of d is a CM, namely, the states of v1 appear as a cover over an EAM (RAM) of X, and 2) in the CM above, all the initial states of d appear in the row corresponding to po(po) and all the final states of d appear in the column corresponding to q0 (cu). (For the definitions of p,po0, q0, and 40, see Section IV.) Proof: 1) It is clear that any 1 in an EAM (RAM) belongs to at least one grid which corresponds to a state of Suppose a state s of d appears at two points in a CM, which are neither in the same row nor the same column. That is to say, sepj1nqj, and sepi2,rqj2, where i10i2 and il #2. These relations imply that sepirnqj2 and sepi2nqjl. Therefore s must appear also at (i1, j2) and (i2, jI). The case where the two points (i1, ji) and (i2, j2) are in the same row or in the same column is trivial. 2) follows from the construction of D(d) and D(J2). Q.E.D. Example: It is seen that in Figs. 3(a) and 4(a), the states of sl appear as a cover, and that the initial state 1 appears ---

a?.

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

622

in the row corresponding to po (Po) and the final states 2 and This explains why the name intersection rule has been 3 appear in the column corresponding to qo (40). chosen, and also makes the application of the rule very easy. Example: We apply the intersection rule to the DA R of 2(b). The natural subset assignment is shown in Fig. PART 2: SYNTHESIS the figure, where S is the set of states of a?. Let us determine In Part 2 we attack the problem of finding a minimum N(3, 0) as an example: NDA equivalent to a given automaton, which is the final N(3, 0) = n f(M(p, 0)) objective of the whole paper. One time-honored method of .113 ef(p) synthesis is to turn analysis "inside out." We shall resort to = f(M(P2, 0)) n f(M(P3, 0)) this method here. One vital tool of our analysis in Part 1 was = f(P2)nf(PO) the subset construction. In the following section we introduce an inverse operation of the subset construction and = {1,3}r{1},- >1}. investigate its properties. Now a question presents itself: Is the intersection rule VI. INTERSECTION RULE really an inverse of the subset construction? Or-more preTo begin with, we recall the following relationship of a cisely, is bh(I(S, f, NJ)) = bh(g), where is the natural given NDA d=(S, M', So, F') to its subset DA D(JI) subset assignment? Later we shall answer this question =(PI M, PoQ F):5 affirmatively. (See Lemma 5.) Then the next natural question is: How can one find a 1) po=So 2) (VseS)(VpeP)[seF'=t [se-p=s>peF]], i.e., all final subset assignment for which bh(I(Z, f, X)) =bh() states of 4 are only contained in final states of D(d) and such that the size of Z is minimum? As a matter of fact, 3) (Voce1)(Vs, Vs'eS)(VpeP)[s'eM'(s, )=> [sep=:. s' answering this question is precisely the ultimate objective eM(p, a)]f], i.e., if there is a transition from s to s' under of this paper. For the time being we shall drop the minia in 4, then there also is a transition under af in D(,f) mality requirement on Z and investigate properties of from any subset containing s to a subset containing s'. various subset assignments. Definition 16: A subset assignment to a DA X4 Now suppose we are only shown D(vt). Is it possible to is legitimate iflf bh(I(Z, f, X))= bh(g). A cover is legitimate reconstruct d/? This question motivates the following two iff its associated subset assignment is legitimate. definitions. Thus if 9 = D(d) for some NDA a?, the legitimacy of Definition 14: Let .4=(P, M, Po, F) be a DA. The pair implies bh(I(Z, f, 9))= bh(d). In the rest of this is called a subset assignment to X if Z is a finite set section we let X and be as defined in Definition 15. and f: P-+2z- {0} is a function. Such an f is called a Lemma 4: For V. bh(I(Z, f, f))(bh(.4). subset assignment function. The natural subset assignment Proof: See Appendix I. to the subset DA D(sl) is KS, f >, where S is the set of states Lemnm 5: The natural subset assignment is legitimate. of d and f(p)= {slsep} for VpeP. The subset assignment Proof: Let d = (S, M', So, F) and X4= D(d4). We want to associated with a cover over an EAM (or RAM) of an NDA show bh(I(S, f V))=bh(Y4) for the natural subset assignd assigns to each state of X= D(./) (or X) the set of grids ment . Let I(S, f, X)=(S, N, ZO, G). Then for VoeX, appearing in the corresponding row of the EAM (or RAM). VseS and peP, According to this definition, the natural subset assign1) Z0 =PO = S ment to D(v1) is the subset assignment associated with the => seF' p=> peF] seG, of an over d. a CM 2) as EAM) cover over an SM (considered = let be and a DA, Definition 15: Let X (P, M, po, F) so that be a subset assignment to X. Then I(Z, f, A4) is F' c G. the NDA (Z, N, Z0, G), where for VzeZZ, VpeP, and Voe-, 3) srE M'(s a) =[sE p =s'e M(p, )] 1) Zo=f(pO) 2) zeG,z[zEf(p)=>peFJ s' E N(s, a),

3) z'cN(z, a)zf(p)=z'-f(M(p, ))]. so that I(Z, f, £) is called the NDA obtained by the intersection

rule from M. Definition 15, among other things, specifies the transition function N of I(Z, f, X). It is easy to see that the definition amounts to N(z, a) = l f(M(p, a)) for Vz E Z and Vacr ES. plzef(p)

5 Note that we have switched the previous notations from M to M' and F to F, and vice versa, since in this section we are mainly concerned with D(d) and would like to avoid primed symbols.

=

M'(s, a) c- N(s,a ). #N(Z0, x)nG 0. Thus it is clear that M'(So, x)r)F'00= This implies that bh(./)c bh(I(S, f, 9i)). But bh(sl) = bh(.*)

by the corollary to Lemma 1 and bh(I(S, f, R))cbh(.) by Q.E.D. Lemma 4. Hence bh(I(S, f, .t))=bh(P*). Note that I(S, f, X) is not necessarily identical to d, as is exemplified by the following example. Example: Fig. 2(b) shows § = D(./) with the natural subset assignment , where S is the set of states of d.*

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

623 0

(a) Fig. 5. NDA obtained from X by the intersection rule.

I(S, f, AR) is shown in Fig. 5. Note that I(S, f, i) although the two NDA's are equivalent, as may be verified by constructing D(I(S, f, A)). The implication of the following theorem is that the search for a legitimate subset assignment to any DA -1 may be restricted to the subset assignments to . (, M, Po' F) be the reduced DA Theorem 6: Let 4=(P equivalent to M. If is a legitimate subset assignment to M, then is a legitimate subset assignment of -, where

(b)

Fig. 6. Intersection rule applied to .*. (a) -. (b) NDA obtained from -7 by the intersection rule.

VII. SUBSET ASSIGNMENTS ASSOCIATED WITH COVERS First we state a basic theorem which follows as a corollary to our previous theorems. = and Proof: Let I(Z, f, X) (Z, N, ZO, G) I(Z, 7, X-) Theorem 7: Given any automaton sl, there exists a legitVa we have and the For =(Z, N', ZO, G'). ec, VzzeZ, VpeP, imate cover over an RAM of / such that the NDA obtained relations. following the by intersection rule using the subset assignment asso1) zeZ0or.zef(Po) ciated with the cover is a minimum NDA. Proof: Follows from Theorems 4, 6, and Lemma 5. zej([po]) Choose a minimum NDA in the equivalence class I of => zeZ'O, Theorem 4. Its RSM shows a cover with the desired so that property. Q.E.D. Definition 17: A legitimate subset assignment to a DA such that the size of Z is minimum possible is called a 2) ze G [zef(p)=r>peF] minimum legitimate subset assignment. A minimum legitimate cover is a legitimate cover consisting of the minimumnum[z E [p]) >[pI C- F] ber of grids. z-zeG', Theorem 7 implies that we have only to consider covers so that over an RAM of a given NDA, in order to obtain a minimum NDA. Next we shall show that we can further restrict G = G'. the domain of search for a minimum legitimate cover. 3) z' E N(z, cr) [z E f(p) => z' E f(M(p, a))] Definition 18: A grid is called a prime grid iff it cannot be [z C f([p]) => z' ef(M([p], ))] properly contained in any other grid. Lemma 6: For any grid there exists at least one prime grid z'cEN'(z, a) that contains it. so that Lemma 7: Let a? = (S, M', SO, F') be an NDA, = (P, M, po, F) be D(.4), and let sieS and PkEEP such that N(z, a) N'(z, a). Si Pk. The grid over an EAM (or RAM) of 4 corresponding We may deduce, as in the proof of Lemma 5, that to (see Theorem 5) can be extended to the row of the EAM bh(I(Z, f, .M))sbh(I(Z, 7, i)). But bh(I(Z, 7, M ))bh(4) by (orsiRAM) corresponding to Pk iff Lemma 4 and bh(MJ)=bh(I(Z, f, 9)) by our assumption, which together yield bh(I(Z, 7, _4_)) bh(I(Z, f, gB)). Hence SC,d(Si) C- Sca(Pk)bh(I(Z, 7, Mi)) = bh(I(Z, f, M)) = bh(Q). Q.E.D. Proof: Note Example: The a for our running example 4 is shown in Fig. 6(a). Note that I(S, f, g) shown in Fig. 6(b) is equivalent U chi' (Theorem 2) sc,d(si) = jlcij= but not identical to I(S, f, tv). 1

f([p])= p'eU[PI f(p').

=

Z'

IEEE TRANSACTIONS ON COMPUTERS, JULY 1970

624

and

q0

SC,(Pk)= U 1 ch' (Theorem 3). From the constructions of an SCM of a? and EAM of a,, it should be clear that si is extendable to Pk {jjcjj 1} C {f'ekl = 1l. Thus we have si is extendable to Pk'* SCd(S() C SC4(Pk). Q.E.D. Lemma 8: Let a? and X be as defined in Lemma 7. If scd(si) c sca(pk), then (Voce-)(VseM'(sj, Sca(M(Pk, 0)) . Proof: It is clear that u U SC,d(Si) = (U c7e 6( seM'(si,a) scd(s))) (Si) where (si)=e if si E F' and 0 otherwise. Similarly we have scQ(pk) = ( aUo SC(M(pk, C)) U (Pk)

c))[scd(s)

P2

y

y

P3

P4

P5

e

q5

q6

8

6

8

6)e

q7

a

a

q8

q9

11

T

P6

P7

(a) Input State Init ial

Final

(Pk) = e if Pk E F and 0 otherwise.

q4

p1

=

where

q3

P0

lIekl=

`

q2

q1

0

1

po

P4

P0

p1

P5

p0

p2

P6

Pi

P3

P2

P7

P2

P7

P5

P1

P6

PO

P3 P3

_*

P7 PO By taking the derivative (Brzozowski [9J) of both sides of Po P0 Po Po a scV(M(pk,l)) b(Pk) (U ( U sc4(s)) U b(sd) C (U a,E aGe seM'(si,a) (b) with respect to a, we get Fig. 7. Example of illegitimate minimum cover. (a) CM. (b) DA associated with the CM. U SC.,(s) C sca(M(pk, C)). seM'(si a) Q.E.D. without going back to the original RAM. Note, however, Hence follows the lemma. Theorem 8: If a legitimate cover is given, we can derive a that when both rows and columns are eliminated, we have legitimate cover consisting only of prime grids which are to make sure that the eliminated row (or column) is a union extensions of the grids in the given cover. Moreover, the of some other rows (or columns) in the original RAM. number of the prime grids in the new cover is no more than Lemma 10: There exists an RAM such that no minimum the number of grids in the given cover. cover over it is legitimate.6 Proof: See Appendix II. Proof: We shall give an example of such an RAM. Corollary: In finding a minimum legitimate cover, we Fig. 7 shows the reduced DA associated with an NDA (not have only to consider prime grids over an RAM. shown) and a minimum cover over the RAM of the NDA. It is clear that the cover shown is the only minimum cover. VIII. MINIMIZATION PROCEDURE That is is not legitimate can be shown by actually constructQ.E.D. now we ing an NDA using the intersection rule. in the sections, previous With the preparations ofNDA's. minimization our procedure are ready to describe Minimization Procedure: We present two lemmas before describing our procedure. 1) Given an NDA, construct its RAM and find a miniThe first lemma, which is presented without proof since it is a mum cover. of the great finding prime grids simple, usually simplifies Let io be the number of grids in the minimum cover 2) deal. can be RAM above and set i= io an found of row expressed Lemma 9: If a (column) of each cover containing i prime grids, test elimination For the a) rows other (columns), as a union4 of some it is legitimate. whether of the the row (column) does not affect finding prime grids, cover is found, set i= i+ 1, and go If no in legitimate is included b) row (column) provided that the eliminated a. to be that can step of the first (second) coordinate every prime grid extended to that row (column). 6 This lemma was proved by Professor S. Even of Harvard University, When we eliminate either rows or columns only, as who also provided us with an example in the proof. one one them eliminate we Lemma can by described in 9,

625

KAMEDA AND WEINER: STATE MINIMIZATION OF NONDETERMINISTIC FINITE AUTOMATA

It is obvious that the process should terminate after a finite number of cycles. In fact, an upper bound on the number of cycles is given by MIN(/, n, m), where 1, n, m are, respectively, the number of states in the given NDA, that in the reduced DA associated with the given NDA, and that in the reduced DA associated with the dual of the given NDA. Example: We apply our procedure to the NDA / of Fig. 2(a). The reduced DA X associated with a?, shown in Fig. 8(a), was obtained from X (Fig. 2(b)). An RAM of .4 was obtained before (Fig. 4(b)). In this case we have a unique minimum cover shown in Fig. 8(b). Fig. 8(c) shows the subset assignment associated with this cover. Using the intersection rule, we obtain the NDA shown in Fig. 8(d). It can be easily verified that the cover we used is legitimate, by applying the subset construction of the NDA of Fig. 8(d) and showing that it is equivalent to X. In the above example, the only minimum cover turned out to be legitimate. At present we do not know how typical this is, although we do know that this is not always the case (see Lemma 10). In the above form our minimization procedure requires that every cover be tested in some systematic way until a legitimate cover is found. This may take the following steps. We let X = (P, M, Po, F) be the reduced DA associated with the given NDA. 1) Apply the intersection rule to X to obtain X = I(Z, f, -i) = (Z, N, ZO, G), where is the subset assignment associated with the chosen cover. 2) Construct D(.,#). 3) Reduce D(Xk) and test if it is equivalent to -. We shall show that the steps 2 and 3 can be replaced by a simpler test. Lemma 11: Given the CM of a legitimate cover over an RAM, let X and X/ be as defined above. Suppose the cover contains a grid z=(p1,. , Pa; ql, * qb)-7 Then

A

A2

A1

AO

A

0

0

0

0

c

cc

p1

1

a

A

cc

a,

Cy O

1

(b)

(a)

0

(d)

(c)

Fig. 8. Minimization of .l of Fig. 2(a). (a) Xd. (b) CM. (c) X with . (d) I(Z,f, -l).

This, together with (1), completes the proof. Now let D(.&k)=(U, L, uo, H). Lemma 12: For Vu E U and Vp E P, u

p'n:(Va G )[L(u, a) M(p, v)] A [uE H -

Q.E.D.

p E F].

Q.E.D. Proof: Similar to the proof of Lemma 8. Definition 19: A set of grids in a row of a CM spans the row iff at least one grid in the set appears in each nonblank entry in the row. Theorem 9: Using the current notations, we have the following. 1) (3fae1)[L(u, a) does'not span the row M(p, a) of the RAM v[M(p, a)eGAL(u, a)OH]]=-p. 2) (Vxe *)[L(u, x) spans the row M(po, x) A [M(po, x)eG

--tcL(uo, x)eH]]=:>bh(.A)=bh(X).

Proof: 1) Suppose L(u, a) does not span the row a). Then M(p, -U chk scX(z) U sca,(z) (Lemma 1) scD(A)(L(u, a)) = zeL(u,a) Proof: The RAM mentioned in the theorem can be U scJf(z) (Lemma 11) considered as an SCM of M. (See the proof of Theorem 4.) c zef(L(u,a)) Since z is a grid, the SCM of X has l's at the intersections of (Lemma 11). c sci(M(p, a)) rows, P1,-. , Pa and the columns q1, qb. Therefore it follows from Theorem 2 that Note that the second line above is a proper cotainment. b Thus u -, p by Lemma 12. The rest follows from the fact that 1, i= ,a. 2,-ch', U (1) sc,4(pi) M(p, )EG A L(u,a) H ) L(u, a) -, M(p, a). = Consider now the automata, k =(Z, N, z, G) and X 2) The condition implies that there is a homomorphism a. It follows from Lemma 4 that (P, M, pi, F) for i= 1, 2, 0: U-+P such that i= 1,2,---,a, bh(.,k) ' bh(4), (Vu e U)[O(L(u, a)) = M(O (u), a)] which means and a. sc,A(z) c (Pi), 11 2, ueH H (u)eF. Therefore it follows that bh(')= bh(D(#))= bh(gB). Q.E.D. Now we can replace the steps 2 and 3 above by the fol7 Strictly speaking, we should use double indexing likepi * * ,pi., but lowing. no confusion should arise here. b

k= 1

...

,

626

IEEE TRANSACTIONS ON COMPUTERS, 3ULY 1970

2') Consider the list of pairs (ui, pi), where uie U, pi,P, starting with (u0, po). 3') Given a pair (u, p), test L(u, a) and M(p, a) against the condition of part 1 of Theorem 9 for each aec. If it is satisfied, then u-op and the cover under test is illegitimate. Otherwise add the pair (L(u, a), M(p, a)) to the list, if it is not already there. 4') Repeat 3') for each new pair. If the process terminates without detecting illegitimacy, then the cover under test is legitimate.

CONCLUSION After obtaining some basic results in Part 1, in Part 2 we presented a minimization procedure for NDA's, which is more efficient than the only existing procedure, namely the exhaustive search. Except for few examples, most of the samples we have tried have the property that there exists a minimum cover that is legitimate. But at the time of writing, we do not know in quantitative terms how often it is the case. At present we are looking for a more efficient method of finding legitimate covers. APPENDIX I PROOF OF LEMMA 4 Let lg(x) be the length of the sequence x with the provision that lg(e) = 0. We first prove

N(ZO, x) c f(M(po, x)) by the induction on lg(x). 1) lg(x) = 0: This implies x = e. Thus we have

N(ZO, e) = ZO

=

f(M(po, e)).

(2)

APPENDIX II PROOF OF THEOREM 8 Let be the subset assignment associated with the given cover and let 4X = I(Z, f, A) and X = D(X) =(U, L, u0 -). (The entries which are not important in our present discussion are indicated by -.) Let X = (U, L, o0,-) be the reduced DA associated with X. We now consider an RSM of M and the subset assign ment associated with it. We know by Theorem 6 that I(Z, h, X') is equivalent to X, and hence to M. The fact that the grid (in an RSM of M) corresponding to zeZ can be extended to the row corresponding to u s U means that scA(z) c sc-(u) (Lemma 7). We modify the legitimate subset assignment function h to get another subset assignment function h', which will be shown to be legitimate, and to be the subset assignment function associated with a cover containing only prime grids. Case 1: In an RSM of M there is no grid z which can be extended to a row u such that z u. In this case no vertical extension of any grid is possible. (See the comment after Definition 13.) We now extend all the grids horizontally as far as possible, so that all the grids are converted to prime grids. In this process the function is not changed. Therefore h= h and now we have a legitimate cover containing only prime grids. Case 2: There exists a grid z extendable to a row u such that z u. In this case we define h' by the following recursive definition. a) h'(u) = h(u) u {z}. This corresponds to the extension of z to u. b) h'(L(u, a)) = h(L(u, a)) u K(z, a) for Vaec2

where K is the transition function of I(Z, h, '). This makes 2) Assume true for all x such that lg(x) < 1. Let x = a1a2 ... sure that a1, and x'=xa1, where aie-E for i= 1, 2, , 1. (Vae)(VzeZ)[K(z, a) c K'(z, a)] (3) N(ZO, x') = N(N(Zo, x), a1) where K' is the transition function of I(Z, h', X). Note that - U N(z, a1) the extensions implied by 2) are always possible because of zeN(Zo,x) Lemmas 7 and 8. U c N(z, a1) zef(M(po,x)) c) For each z'e K(z, a) - h(L(u, a)), replace z and u in a) u ( ln f(M(p, a,)) by z' and L(u, a). This makes sure that (3) holds true zef(M(po,x)) Pjzef(p) for each extension implied by b). f(M(M(po, x), ad)) After this process terminates, we find a new pair z and u = f(M(po, x)). which satisfies the condition of Case 2, and apply the process. Finally we will arrive at Case 1 and all the grids We now can prove the lemma as follows. will be extended to prime grids. By (3) and Lemma 4, we For Vxe*, conclude that