You are on page 1of 27

State Minimization

Completely Specified Machines
STGs may contain redundant states, i.e. states whose
function can be accomplished by other states.
State minimization is the transformation of a given
machine into an equivalent machine with no
redundant states.


State Minimization:
Completely Specified Machines
Two states, si and sj of machine M are distinguishable if and
only if there exists a finite input sequence which when
applied to M causes different output sequences depending
on whether M started in si or sj.
Such a sequence is called a distinguishing sequence for (si, sj).
If there exists a distinguishing sequence of length k for (si,
sj), they are said to be k-distinguishable.


z x=0 E. 0 F. • states A and E are 3-distinguishable. 0 Example: • states A and B are 1-distinguishable. 1 D. 0 x=1 D. 3 . 0 B. since a 1 input applied to A yields an output 1. 0 F. 1 B. 1 C. 0 E. 0 C.State Minimization: Completely Specified Machines PS A B C D E F NS. 0 F. versus an output 101 from E. 0 B. since input sequence 111 applied to A yields output 100. versus an output 0 from B.

If si ~ sj and sj ~ sk. Procedure: Group states of M so that two states are in the same group iff they are equivalent (forms a partition of the states). for all inputs X. 4 . are also equivalent. An equivalence relation partitions the elements of a set into equivalence classes. it is a reflexive. So state equivalence is an equivalence relation (i. sj ). symmetric and transitive relation).e. then si ~ sk.Completely Specified Machines States si and sj (si ~ sj ) are said to be equivalent iff no distinguishing sequence exists for (si. their corresponding X-successors. Property: If si ~sj.

x =1 P3 = (A C)(E)(B D)(F) x =1.Completely Specified Machines PS A B C D E F NS. 1 B. z x=0 E. 0 Pi : partition using distinguishing sequences of length i. 0 x=1 D. Partition: Distinguishing Sequence: P0 = (A B C D E F) P1 = (A C E)(B D F) x =1 P2 = (A C E)(B D)(F) x =1. 1 C. x =1. 0 F. 0 B. 0 B. 0 F. 0 F. 0 C. 0 E. 1 D. x =1 P4 = (A C)(E)(B D)(F) Algorithm terminates when Pk = PK+1 5 .

These may be combined into one state in the reduced (quotient) machine.Completely Specified Machines Outline of state minimization procedure: • All states equivalent to each other form an equivalence class. and create different blocks states that are 1distinguishable within Bi . Iteratively refine this partition by separating the 1-distinguishable states. 2-distinguishable states and so on. • Start an initial partition of a single block. 6 . • To obtain Pk+1. create one block of states that not 1-distinguishable within Bi . for each block Bi of Pk.

Mred is unique up to isomorphism. Theorem: If two states. are equivalent (M1 ~ M2 ) iff. then they are (n-1 )-distinguishable. Definition: Two machines. where n is the number of states in M. M1 and M2.Completely Specified Machines Theorem: The equivalence partition is unique. for every state in M1 there is a corresponding equivalent state in M2 and vice versa. of machine M are distinguishable. si and sj. For every machine M there is a minimum machine Mred ~ M. Theorem. 7 .

0 E. 1 . 0 D. 0 C. z x=0 x=1 . 0 B. 0 . 0 . 0 B. 0 A B C D E F NS. 0 D. 1 F. 0 . z x=0 x=1 E. 0 C. 0 F. 0 . 1 B. 1 . 0 8 .Completely Specified Machines Reduced machine obtained from previous example: PS P4 = (A C)(E)(B D)(F) = PS     NS. 0 . 1 F.

a . (b) Qt +1 := {q  Qi |  (q. F’ ). F ) with no unreachable states. Method: 1.a)  Qj  . q ’0. q 0. end. Q0:= { undefined }. ’.State Minimization of CSMs: Complexity Algorithm DFA ~ DFAmin Input: A finite automaton M = (Q. t :=2. Q1:=F. while there is 0 < i  t. 9 . . a   with (Qi.a)  Qj }. 2. Q2:= Q\F. for all j  t do (a) Choose such an i. Qi := Qi \ Qt +1. . Output: A minimum finite automaton M’ = (Q’. and j  t with  (Qi.a)  Qj. . t := t +1.

State Minimization of CSMs: Complexity 3. 10 ..  ’ ( [q]. (* Denote [q ] the equivalence class of state q . q ’0 := [q0].. a) := [(q.a)] for all q  Q. {Qi } the F’ := { [q]  Q’ | q  F }. Q2. Qt }. *) Q’ := {Q1. and set of all equivalence classes. a  . ..

a)  Qj1 } else Qt +1 := {q  Qi | (q. Qi := Qi \ Qt+1.a)  Qj2}| then Qt +1 := {q  Qi | (q. Choose such an i.j2  t with  j2.a)  Qj2  . where n =|Q| and k = || Modification of the body of the while loop: 1. and choose j1. (i. If |{q  Qi | (q.State Minimization of CSMs: Complexity Standard implementation: O (kn 2).a)  Qj1}|  |{q  Qi | (q.  (Qi. a  . and  (Qi. j1 2. put smallest set in t +1 ) 11 .a)  Qj1  . t := t +1.a)  Qj2 } fI.e.

Goal: Develop an implementation such that all computations can be assigned to transitions containing a state for which the name of the corresponding class is changed. Details in N. Blum IPL ‘96 [Originial O (kn log n) algorithm in Hopcroft 1971] 12 . Suitable data structures achieve an O (kn log n) implementation. the name of the class which contains a given state q changes at most log(n ) times.State Minimization of CSMs: Complexity Note: |Qt +1|  1/2|Qi|. Therefore. for all q  Q.

o ) T (y.z.equivalent and for all 13 .y)  i (o.y) =  (xi ~ yi) (initially all states are equivalent) i=1 Ej +1(x.i.w.o ) Ej (z.y continue to be equivalent if they are inputs the next states are j .e.z.equivalent ) j .State Minimization of CSMs: BDD Implementation X and Y are spaces of all states: |S| E0(x.i.w )] (i.w ) [T (x. states x.y) = Ej (x.

State Minimization: Incompletely Specified Machines Statement of the problem: given an incompletely specified machine M. whenever M is specified. 14 . – there does not exist a machine M’’ with fewer states than M’ which has the same property. find a machine M’ such that: – on any input sequence. M’ produces the same outputs as M.

s3. 0 s3.State Minimization: Incompletely Specified Machines Machine M: PS s1 s2 s3 NS. . 1 x=1 s2. 0 Attempt to reduce this case to usual state minimization of completely specified machines. 0 s2. In this example. z x=0 s3. 15 by setting the don’t care to either 0 and 1. 0 s2. • Brute Force Method: Force the don’t cares to all their possible values and choose the smallest of the completely specified machines so obtained. it means to state minimize two completely specified machines obtained from M.

Machine M’: PS s1 s2 s3 NS. 0 s2. 0 s3. z x=0 s3. so s1 and s2 are not equivalent. 1 x=1 s2. 0 s3. but s3 and s2 assert different outputs under input 0. 0 States s1 and s2 are equivalent if s3 and s2 are equivalent. So this completely specified machine cannot be 16 reduced further (3 states is the minimum). States s1 and s3 are not equivalent either. 0 s2.State Minimization: Incompletely Specified Machines Suppose that the . .is set to be a 0.

0 17 . 0 s3. So number of states is reduced from 3 to 2. 0 A. 1 s1 s2 s3 x=1 s2. 0 B. z x=0 s3. States s3 and s2 are equivalent. 1 s3. 0 s2. z x=0 x=1 A. 1 A. Machine M’’red : PS A B NS.Incompletely Specified Machines Suppose that the .is set to be a 1. 0 States s1 is incompatible with both s2 and s3. 0 s2. Machine M’’: PS NS.

0 s1. s1.State Minimization: Incompletely Specified Machines Can this always be done? Machine M: PS s1 s2 s3 NS. 0 s2. 0 s2. z x=0 s3. 1 x=1 s2. 0 18 .

0 s2.State Minimization: Incompletely Specified Machines Machine M2: PS s1 s2 s3 Machine M3: PS s1 s2 s3 NS. 0 s2. 1 s1. 0 s1. 0 s2. z x=0 s3. z x=0 s3. 0 s1. 0 Machine M2 and M3 are formed by filling in the unspecified entry in M with 0 and 1. Conclusion?: M cannot be minimized further! But is it a correct conclusion? 19 . 0 NS. 0 s1. 0 s2. respectively. Both machines M2 and M3 cannot be reduced. 1 x=1 s2. 1 x=1 s2.

0 s2. 0 s1. s2) and B = (s3. 0 20 . but only where both outputs are specified. s1. 1 x=1 s2. 0 A. 1 A. they generate the same output sequence. 0 A. z x=0 s3. 0 s2.State Minimization: Incompletely Specified Machines Note: that we want to ‘merge’ two states when. A reduced machine Mred can be built as follows. Machine Mred : PS A B NS. s2). Definition: A set of states is compatible if they agree on the outputs where they are all specified. for any input sequence. 0 In this case we have two compatible sets: A = (s1. z x=0 x=1 B. Machine M’’ : PS s1 s2 s3 NS.

So choosing a given compatible may imply that some other compatibles must be chosen too.Incompletely Specified Machines Can we simply look for a set of compatibles of minimum cardinality.) No. 21 . such that every original state is in at least one compatible? (This would be nice since it would lead to a simple unate covering problem. To build a reduced machine we must be able to send compatibles into compatibles.

(s2s5) requires (s1s2).0 s6.0 -. (s4s5) requires (s1s5). (s1s2) requires (s3s6). So. z I2 s1. (s1s6) requires (s1s2).s5.Incompletely Specified Machines PS s1 s2 s3 s4 s5 s6 I1 s3.0 s2.1 s6.1 A set of compatibles that cover all states is: (s3s6).s4. this selection of compatibles requires too many 22 other compatibles. .1 s1.1 I3 s1. (s4s5). But (s3s6) requires (s4s6).s2.- I4 s5.-. (s4s6).1 s1.s2.-.-.- NS.1 s4.. (s1s6). (s2s5).0 -. (s4s6) requires(s4s5)..

1 I3 s1.0 -. So must select also (s4s6) and (s1s5). Selection of minimum set is a binate covering problem !!! 23 .0 s6.0 -.s5.- NS.1 s4.1 s6.-.Incompletely Specified Machines PS s1 s2 s3 s4 s5 s6 I1 s3.s2.0 s2.1 s1.1 Another set of compatibles that covers all states is (s1s2s5).s2. (s3s6).-.- I4 s5. But (s1s2s5) requires (s3s6) (s3s6) requires (s4s6) (s4s6) requires (s4s5) (s4s5) requires (s1s5). z I2 s1.1 s1. (s4s5).s4.-.

every input sequence admissible to sj is also admissible to si . Definition. its application to both M1 and M2 (initially is si and sj. respectively) results in identical output sequences whenever the outputs of M2 are specified. the future behavior of the machine is unpredictable. state sj of M2 provided 1. Definition. for a starting state of a machine if no unspecified next state is encountered. 24 . except possibly at the final step. An input sequence is admissible. or contain. This suggests the definition of admissible input sequence.Incompletely Specified Machines More formally: When a next state is unspecified. and 2. State si of machine M1 is said to cover.

there is a corresponding state si in M1 such that si covers sj.State Minimization: Incompletely Specified Machines Definition. the number of states of M’ does not exceed the number of states of M’’. 25 . Machine M1 is said to cover machine M2 iff for every state sj in M2. The problem of state minimization for an incompletely specified machine M is: find a machine M’ which covers M such that for any other machine M’’ covering M.

“xxx”] 26 . Brayton. See book [Kam. Sangiovanni.• • • Short summary of rest of section Definition of compatible states Method to compute when two states are incompatible Definition of maximal compatible sets – A set is compatible iff all pairs in the set are compatible • Definition of prime compatibles • Solve Quine-McCluskey type problem – Generate all prime compatibles – Solve binate covering problem We will not go into the details of this. Villa.

End of section 27 .