1 / 37

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

15-453. FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A. MINIMIZING DFAs. THURSDAY Jan 24. 0. 1. 0. 1. 1. 0. 1. 0. IS THIS MINIMAL?. NO. 0. 1. 1. 0. IS THIS MINIMAL?. THEOREM.

baylee
Download Presentation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA

  2. MINIMIZING DFAs THURSDAY Jan 24

  3. 0 1 0 1 1 0 1 0 IS THIS MINIMAL? NO

  4. 0 1 1 0 IS THIS MINIMAL?

  5. THEOREM For every regular language L, there exists a UNIQUE(up to re-labeling of the states) minimal DFA M such that L = L(M)

  6. 0 0 0 0 NOT TRUE FOR NFAs

  7. EXTENDING  Given DFA M = (Q, Σ, , q0, F) extend  to : Q Σ* → Q as follows: ^ ^ (q, ε) = q ^ (q, ) = (q, ) ^ ^ (q, 1 …k+1) = ( (q, 1 …k), k+1) ^ Note: (q0, w)  F  M accepts w String w  Σ* distinguishes states q1 and q2iff ^ ^ (q1, w)  F  (q2, w)  F

  8. EXTENDING  Given DFA M = (Q, Σ, , q0, F) extend  to : Q Σ* → Q as follows: ^ ^ (q, ε) = q ^ (q, ) = (q, ) ^ ^ (q, 1 …k+1) = ( (q, 1 …k), k+1) ^ Note: (q0, w)  F  M accepts w String w  Σ* distinguishes states q1 and q2iff ^ ^ exactly ONE of (q1, w), (q2, w) is a final state

  9. 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 iff for all w  Σ*, (p, w)  F (q, w)  F Fix M = (Q, Σ, , q0, F) and let p, q  Q DEFINITION: ^ ^

  10. q1 1 0 0,1 1 q0 q2 0 0 1 q3 ε distinguishes accept from non-accept states

  11. p ~ q iffp is distinguishable from q / Fix M = (Q, Σ, , q0, F) and let p, q, r  Q Define relation ~ : p ~ qiffp is indistinguishable from q Proposition: ~ is an equivalence relation p ~ 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 ^ ^ ^

  12. Fix M = (Q, Σ, , q0, F) and let p, q, r  Q so ~ partitions the set of states of M into disjoint equivalence classes Proposition: ~ is an equivalence relation [q] = { p | p ~ q } Q q q0

  13. 0 1 0 1 1 0 1 0

  14. Algorithm MINIMIZE Input: DFA M Output: DFA MMIN such that: MMMIN(that is, L(M) = L(MMIN)) MMIN has no inaccessible states MMIN is irreducible || all states of MMIN are pairwise distinguishable Theorem: MMIN is the unique minimum DFA

  15. Intuition:States of MMIN will be blocks of equivalent states of M We’ll find these equivalent states with a “Table-Filling” Algorithm

  16. (1)DM = { (p,q) | p,q Q and p ~ q } / TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q0, F) Output: (2) EM = { [q] | q  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 indistinguishable IDEA:

  17. q0 Base Case: p accepts and q rejects  p ~ q q1 / (1) DM = { (p,q) | p,q  Q and p ~ q } / qi qn q0 q1 qi qn TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q0, F) Output: (2) EM = { [q] | q  Q }

  18. q0 Base Case: p accepts and q rejects  p ~ q q1 / (1) DM = { (p,q) | p,q  Q and p ~ q } / qi p ~ q / qn ~ / q0 q1 qi qn TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q0, F) Output: (2) EM = { [q] | q  Q } Recursion: if there is σΣ and states p, q satisfying D D  (p, ) = p  D q  (q, ) = Repeat until no more new D’s

  19. q0 q1 D D q2 D q3 D D D q0 q1 q2 q3 0,1 0 1 0 0 1 q0 q1 q2 q3 1

  20. 0 1 0 1 1 0 1 0 q1 q0 q0 q2 q3 q1 D D q2 q3 D D q0 q1 q2 q3

  21. ^ ^ (p, w)  F and (q, w)  F Claim: If p, q are distinguishedby Table-Filling algorithm, then p ~ q / Proof: 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 q Suppose (p, q) is marked D at a later point. Then there are states p, q, and string w such that: 1. (p, q) are marked D p ~ q(by induction) /  2. p = (p,) and q = (q,), where   Σ The string w distinguishes p and q!

  22. Suppose the pair (p, q) is not marked Dby the algorithm, yet p ~ q (a “bad pair”) / ^ ^ (p, w)  F and (q, w)  F Claim: If p, q are not distinguished by Table-Filling algorithm, then p ~ q Proof (by contradiction): Then there is a string w such that: (Why is |w| >0 ?) So, w = w, where   Σ Of all such bad pairs, let p, q be a pair with the shortest w Let p = (p,) and q = (q,) Then (p, q) is also a bad pair, but with a SHORTER w !

  23. Algorithm MINIMIZE Input: DFA M Output: 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,  ) ] Must show MIN is well defined!

  24. Algorithm MINIMIZE Input: DFA M Output: 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 M

  25. 0 0 1 1 0 0 1 0 1 1 MINIMIZE q0 q1 q2

  26. 1 0 0,1 0 q4 q0 q1 1 1 0 q5 0 0,1 q0 1 q2 q1 D q3 q3 D D q4 D D q5 D D D D q0 q1 q3 q4 q5

  27. 1 0 0,1 0 q4 q0 q1 1 1 0 q5 0 q0 q1 D q3 q3 D D q4 D D q5 D D D D q0 q1 q3 q4 q5

  28. *MMIN is the unique minimal DFA equivalent to M Claim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMIN

  29. *MMIN is the unique minimal DFA equivalent to M Claim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMIN Note:If Mis 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 MMIN So, by Claim, both Mminand M are isomorphic to MMIN NOT TRUE for NFAs !

  30.  *MMIN is the unique minimal DFA equivalent to M Claim: Suppose MMMIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and MMIN Proof:We construct a map from MMIN to M recursively Base Case: q0 MIN→q0 Recursive Step: If p → p Then q → q q q

  31. Base Case: q0 MIN→ q0 Recursive Step: If p → p Then q → q q q   We need to prove: That is, for all q  MMIN there is a q  M such that q → q The map is defined everywhere The map is well defined If q  MMIN, there is a string w such that MIN(q0 MIN,w) = q The map is a bijection ^ ^ Let q = (q0,w). q will map to q

  32. Base Case: q0 MIN→ q0 Recursive Step: If p → p Then q → q q q   The map is well defined Suppose there exist q and q such that q → q and q → q We show that q and q are indistinguishable, so it must be that q = q

  33. Suppose there exist q and q such that q → q and q → q Suppose q and q are distinguishable MMIN M u u w w Accept Accept q q q0 q0 MIN Contradiction! v w v w Reject Reject q q q0 q0 MIN

  34. Base Case: q0 MIN→ q0 Recursive Step: If p → p Then q → q q q   The map is onto For all q Mthere is a q  MMIN such that q → q If q M, there is w such that (q0,w) = q ^ ^ Let q = MIN(q0 MIN,w)

  35. The map is 1-1 Suppose there are distinct p and q such that p → q and q → q Suppose p and q are distinguishable MMIN M u u w w Accept Accept q p q0 q0 MIN Contradiction! v w v w Reject Reject q q q0 q0 MIN

  36. How can we prove that two regular expressions are equivalent?

  37. WWW.FLAC.WS Finish reviewing Chapter 1 of the book and read 2.1 & 2.2 for next time

More Related