Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 14Slide 15Slide 17Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39Slide 40Slide 41Slide 42Slide 43FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY15-453MINIMIZING DFAsTHURSDAY Jan 24IS THIS MINIMAL?11110000NOIS THIS MINIMAL?0101THEOREMFor every regular language L, there exists a UNIQUE (up to re-labeling of the states) minimal DFA M such that L = L(M)NOT TRUE FOR NFAs0000EXTENDING Given DFA M = (Q, Σ, , q0, F) extend to : Q Σ* → Q as follows: (q, ε) = (q, ) =(q, 1 …k+1 ) = ( (q, 1 …k ), k+1 ) ^^^^^String w Σ* distinguishes states q1 and q2 iff (q1, w) F (q2, w) F ^^q(q, )^Note: (q0, w) F M accepts wEXTENDING Given DFA M = (Q, Σ, , q0, F) extend to : Q Σ* → Q as follows: (q, ε) = (q, ) =(q, 1 …k+1 ) = ( (q, 1 …k ), k+1 ) ^^^^^String w Σ* distinguishes states q1 and q2 iff q(q, )^Note: (q0, w) F M accepts wexactly ONE of (q1, w), (q2, w) is a final state^ ^Fix M = (Q, Σ, , q0, F) and let p, q Q DEFINITION:p is distinguishable from q iff there is a w Σ* that distinguishes p and q p is indistinguishable from q iff p is not distinguishable from q ifffor all w Σ*, (p, w) F (q, w) F^^00,100111q0q1q2q3ε distinguishes accept from non-accept statesFix M = (Q, Σ, , q0, F) and let p, q, r Q Define relation ~ :p ~ q iff p is indistinguishable from q p ~ q iff p is distinguishable from q /Proposition: ~ is an equivalence relationp ~ p (reflexive)p ~ q q ~ p (symmetric)p ~ q and q ~ r p ~ r (transitive)Proof (of transitivity): for all w, we have: (p, w) F (q, w) F (r, w) F ^^^Fix M = (Q, Σ, , q0, F) and let p, q, r Q Proposition: ~ is an equivalence relationso ~ partitions the set of states of M into disjoint equivalence classesq0Qq[q] = { p | p ~ q }11110000Algorithm MINIMIZEInput: DFA MOutput: DFA MMIN such that:MMMIN (that is, L(M) = L(MMIN))MMIN has no inaccessible statesMMIN is irreducibleall states of MMIN are pairwise distinguishable||Theorem: MMIN is the unique minimum DFAIntuition: States of MMIN will be blocks of equivalent states of MWe’ll find these equivalent states witha “Table-Filling” AlgorithmTABLE-FILLING ALGORITHMInput: DFA M = (Q, Σ, , q0, F) (2) EM = { [q] | q Q }(1) DM = { (p,q) | p,q Q and p ~ q }/• We know how to find those pairs of states that ε distinguishes…• Use this and recursion to find those pairs distinguishable with longer strings• Pairs left over will be indistinguishableIDEA:Output:TABLE-FILLING ALGORITHMInput: DFA M = (Q, Σ, , q0, F) Output:(2) EM = { [q] | q Q }(1) DM = { (p,q) | p,q Q and p ~ q }/q0q1qiqnq0q1qiqnBase Case: p accepts and q rejects p ~ q/TABLE-FILLING ALGORITHMInput: DFA M = (Q, Σ, , q0, F) Output:(2) EM = { [q] | q Q }(1) DM = { (p,q) | p,q Q and p ~ q }/q0q1qiqnq0q1qiqnRecursion: if there is σ Σand states p, q satisfying D DD (p, ) = p (q, ) =q~/p ~ q/Base Case: p accepts and q rejects p ~ q/Repeat until no more new D’s101010,10q0q0q1q1q2q2q3q3q0q1q2q3D D DDDD11110000q0q0q1q1q2q2q3q3D DDDq0q1q2q3Claim: If p, q are distinguished by Table-Filling algorithm, then p ~ qProof: By induction on the length of the string distinguishing them.If (p, q) is marked D at the start, then one’s in F and one isn’t, so ε distinguishes p and qThen there are states p, q, and string w such that:(p, w) F and (q, w) F ^ ^2. p = (p,) and q = (q,), where ΣThe string w distinguishes p and q!/Suppose (p, q) is marked D at a later point. 1. (p, q) are marked D p ~ q (by induction)/Claim: If p, q are not distinguished by Table-Filling algorithm, then p ~ qProof (by contradiction):Suppose the pair (p, q) is not marked D by the algorithm, yet p ~ q (a “bad pair”) /Then there is a string w such that:(p, w) F and (q, w) F ^ ^Of all such bad pairs, let p, q be a pair with the shortest w So, w = w, where ΣLet p = (p,) and q = (q,)Then (p, q) is also a bad pair, but with a SHORTER w !(Why is |w| >0 ?)Algorithm MINIMIZEInput: DFA MOutput: DFA MMIN(1) Remove all inaccessible states from M(2) Apply Table-Filling algorithm to get:EM = { [q] | q is an accessible state of M }QMIN = EM, q0 MIN = [q0], FMIN = { [q] | q F }MIN( [q], ) = [ ( q, ) ]Must show MIN is well defined!Define: MMIN = (QMIN, Σ, MIN, q0 MIN, FMIN)Algorithm MINIMIZEInput: DFA MOutput: DFA MMIN(1) Remove all inaccessible states from M(2) Apply Table-Filling algorithm to get: EM = { [q] | q is an accessible state of M }Define: MMIN = (QMIN, Σ, MIN, q0 MIN, FMIN)QMIN = EM, q0 MIN = [q0], FMIN = { [q] | q F }MIN( [q], ) = [ ( q, ) ]Claim: MMIN M1010101010q0q1q2MINIMIZE101010,10q0q1q3q5q401q20,1q0q0q1q1q3q3q4q4DDDDD Dq5q5DDD10100,10q0q1q3q5q401q0q0q1q1q3q3q4q4DDDDD Dq5q5DDD*MMIN is the unique minimal DFA equivalent to MClaim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMIN*MMIN is the unique minimal DFA equivalent to MClaim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMINNote: If M is minimal, then M has no inaccessible states and is irreducible. (So the Claim implies *)Corollary to the Claim: If M has no inaccessible states and is irreducible, then M is minimal. Proof: Let Mmin M be minimal. Then Mmin MMINSo, by Claim, both Mmin and M are isomorphic to MMINNOT TRUE for NFAs !Proof: We construct a map from MMIN to M recursivelyBase Case: q0 MIN → q0Recursive Step:If p → pq qThen q → q*MMIN is the unique minimal DFA equivalent to MClaim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMINBase Case: q0 MIN → q0Recursive Step:If p → pq qThen q → qWe need to
View Full Document