Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA for L strting from ny other y the Stte Minimiztion Algorithm.
Deciding Equivlence of DFAs With this lgorithm: We cn check whether two DFAs A nd B represent the sme regulr lnguge. Just minimize oth A nd B nd see if the otined utomt re isomorphic (equl up to stte renming).
Two lgorithms In this lecture we will see two lgorithms for minimizing DFAs. They oth work y prtitioning the sttes of the DFA into equivlence clsses. The lgorithms differ y how they do the prtitioning Top Down From lrge prtitions to smller ones Bottom up From unit prtitions to lrger ones
Equivlence Reltions nd Prtitions A prtition of set A is set {C 1,C 2,,C k } of susets of A such tht: C i C i C j = for i j C 1 C 2 C k = A C 1 C 2... C 3 C k
Now if we define reltion ~ on A y: x ~ y iff x nd y elong to the sme prtition set; then this reltion will stisfy the properties of n equivlence reltion: x ~ x (reflexivity) x ~ y y ~ x (symmetry) x ~ y nd y ~ z x ~ z (trnsitivity) The correspondence etween prtitions nd equivlence reltions goes oth wys. If we hve n equivlence reltion on A then there is n ssocited prtition of the set A. Its clsses re clled equivlence clsses of. The clss contining x is [x] = { y A y x}.
Equivlence of Sttes Definition. Two sttes p nd q of DFA re equivlent (nottion: p q) when, for every string w: w leds from p to finl stte if nd only if w leds from q to finl stte. Non-equivlent sttes re clled distinguishle. To show tht two sttes re distinguishle, we need to find only one string tht leds from one of them to finl stte, nd leds from the other to non-finl stte. The empty string distinguishes every finl stte from every non-finl stte. Thus, if p q, then p nd q re either oth finl or oth non-finl.
Exmple Sttes 0 nd 1 re distinguishle, since from 0 -> 1 Non-finl from 1 -> 3, Finl Sttes 1 nd 2 re indistinguishle y ny string over the lphet {,} All strings tht led from 1 or 2, tht end up in finl stte from 1, lso led to finl stte from 2!
p 0 0 q 0 1 1 r 1 Testing two finl (or two non-finl) sttes for equivlence is more difficult. In this exmple, q nd r re equivlent. No string eginning with 0 cn distinguish them: the two pths converge fter the first rc. For strings eginning with 1, the two pths will lternte etween q nd r while reding the initil 1's; s soon s the first 0 is red (if ever), the pths will converge t p.
Miniml Automt Definition. A DFA is miniml iff 1. All its sttes re rechle from the strt stte; 2. All its sttes re distinguishle. Theorem. Two miniml utomt for the sme lnguge re isomorphic.
The quotient The Quotient (Stte Collpse) Construction. Stte equivlence reltion hs this fundmentl property: If p q then for every Σ, δ(p,) δ(q,). Indeed, if string w distinguishes δ(p,) from δ(q,), then the string w will distinguish p from q.
The quotient construction Given ny DFA A We cn construct the quotient DFA A 1. Its sttes re the equivlence clsses of the sttes of A 2. Its trnsition reltion is δ (C,) = C where 1. δ(x,)=y 2. C is the clss tht contins x 3. C is the clss tht contins y 3. The strt stte of A is the equivlence clss of the strt stte of A, 4. The finl sttes of A re equivlence clsses of finl sttes of A.
p Quotient Exmple 0 0 q 0 1 1 1 r Here is the quotient of the DFA of our exmple. p 0,1 q,r 1 0 Theorem. For ny DFA, A, in which ll sttes re rechle from the strt stte, the utomton A is miniml.
Minimiztion Algorithm Any minimiztion lgorithm hs two prts: Eliminte sttes of the input DFA tht re not rechle from the strt stte. Do the quotient construction on the resulting DFA. The first step is esy. The second is esy once we mnge to prtition the sttes into equivlence clssses. There re two possile wys to do this 1. Top down - equivlence clsses of re found y n itertive construction tht produces sequence of finer nd finer prtitions. 2. Bottom up we construct smll (size 2) prtitions nd then merge them (Algorithm in the Hein Text ook)
Top Down pproch Define p i q to men p nd q cnnot e distinguished y strings of length i. We cn lwys compute directly 0 ; it hs two clsses: finl sttes nd non-finl sttes. The fct p i+1 q p i q nd δ(p,) i δ(q,) for every Σ is the sis for effectively constructing i+1 when i is known. For ech equivlence clss, try nd rek it into two or more new equivlence clsses y finding some symol which distinguishes two sttes in the current clss.
Structure Bse Cse If n equivlence clss hs only one stte, we re done with tht stte. It cnnot e roken down into finer equivlence. Itertive Step We repet this construction until ( i+1 )= ( i ). Going further on would not chnge the equivlence reltion. At this point we hve our desired. Note the worst we cn do is hve every stte in its own equivlence clss, in which cse the originl DFA ws lredy miniml.
Exmple We wnt the miniml utomton equivlent to the following. 1 2 3 4 5 6 7 8
Automt nd Forml Lnguges 1 2 3 4 5 6 7 8 First remove the unrechle stte 4 1 2 3 5 6 7 8 The trnsition tle is now useful. Lecture 10 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Tim Sherd 17
Automt nd Forml Lnguges 1 2 3 5 6 7 8 We strt with 0 ; its two clsses re X= {1,2,5,6,7} nd Y={3} The equivlence clss {3} is done. It cnnot e further roken down into finer equivlences. So concentrte on {1,2,5,6,7} Lecture 10 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Focus on the colors, not the sttes 1 2 3 5 6 7 8 X X X X Y X X X Y Y X X X Y Tim Sherd 18
Automt nd Forml Lnguges Now we need to find 1 ; We need to look t the tle for the sttes in X={1,2,5,6,7} without distinguishing etween sttes in the sme 0 clss. We do this y oserving the different colors or symols in ech column of the new trnsition tle. Recll we cn ignore the columns leled y Y= {3} ecuse it is lredy fully refined (s smll s possile). 1 2 3 5 6 7 8 2 7 7 8 3 7 7 6 3 3 6 7 5 3 1 2 3 5 6 7 8 X X X X Y X X X Y Y X X X Y Lecture 10 Tim Sherd 19
Automt nd Forml Lnguges 1 2 3 5 6 7 8 2 7 8 3 7 7 6 3 6 7 5 3 1 2 3 5 6 7 8 X X X Y X X X Y X X X Y Two elements of the sme 0 clss elong to the sme 1 clss when their corresponding columns re equl (I.e. hve the sme color or symol.) So in this tle we hve three different ptterns X/X, X/Y, nd Y/X, nd thus we rek {1,2,5,7,8} into three different equivlent clsses. X/X {1,5,7} = U {3} = Y X/Y {2,8} = V Rememer to propgte the Y/X {6} = W lredy done sttes {3}. Now identify new color (or symol) to ech of these sets. And redo the tle. 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Lecture 10 1 2 3 5 6 7 8 V U U V Y U U W Y Y W U U Y Tim Sherd 20
Automt nd Forml Lnguges 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 1 2 3 5 6 7 8 V U U V Y U U W Y Y W U U Y Ignoring the two done sttes Y={3} nd W={6} (of size 1). We try nd further refine U= {1,5,7} nd V={2,8}. We note tht V={2,8} cnnot e further refined, ut {1,5} cn e distinguished from {7} ecuse the trnsition on differs. So nming these two sttes {1,5} = T {7} = Z We re led to the finl trnsition digrm, Becuse further distinction Between {1,5}, nd {2,8} Is not possile. Lecture 10 1 = T 2 = V 3 = Y 5 = T 6 = W 7 = Z 8 = v V Z T V Y Z Z W Y Y W Z T Y Tim Sherd 21
Automt nd Forml Lnguges 1 = T 2 = V 3 = Y 5 = T 6 = W 7 = Z 8 = v V Z T V Y Z Z W Y Y W Z T Y 1,5 2,8 3 Redundnt columns T={1,5} V={2,8} Y={3} W={6} Z={7} V={2,8} Z={7} T={1,5} Y={3} Z={7} 6 7 W={6} Y={3} Y={3} Z={7} T={1,5} Lecture 10 Tim Sherd 22
Bottom up (in Text Book) Remove sttes not rechle from the strt stte (4)
Bottom up, strt with smll equivlences Compute ll distinct pirs of sttes Where oth prts of the pir re either Both finl, or oth non-finl [(5,8),(5,7),(5,6),(7,8),(6,8),(6,7), (2,8),(2,5),(2,7),(2,6),(1,8),(1,5), (1,7),(1,6),(1,2)] Note tht 3 is the only finl stte, so It prticiptes in no pir
Keep only good pirs [(5,8),(5,7), (5,6), (7,8),(6,8),(6,7),(2,8),(2,5),(2,7), (2,6),(1,8),(1,5),(1,7),(1,6),(1,2)] [(5,7),(2,8),(1,5),(1,7)] A pir (x,y) is good if 1. Its δ is the sme on ll letters δ(x,) = δ(y,) for ll OR 2. The pir ( δ(x,), δ(y,) ) is lredy in the current set of pirs forll Exmple (5,7) ( δ(5,), δ(7,) ) = (7,8) ( δ(5,b), δ(7,b) ) = (6,5)
Repet Repet until no more pirs cn e removed [(5,8),(5,7), (5,6),(7,8),(6,8),(6,7),(2,8),(2,5), (2,7),(2,6),(1,8),(1,5),(1,7),(1,6),(1,2)] [(5,7),(2,8),(1,5),(1,7)] [(2,8),(1,5)] So the equivlences re {{3},{4},{6},{7},{2,8},{1,5}}
Prtition {{3},{4},{6},{7},{2,8},{1,5}}
New DFA δ({3},) = {1,5} δ({3},) = {3} δ({4},) = δ({4},) = δ({6},) = δ({6},) = δ({7},) = δ({7},) = δ({2,8},) = δ({2,8},) = δ({1,5},) = δ({1,5},) =