1 / 43

Complexity and Computability Theory I

Complexity and Computability Theory I. Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein. Overview. Minimalization Equivalence Minimalization algorithm Examples. Example over  ={0,1}. Consider the following automata that accept L =  *. A: B:. C:. Minimalization.

ralphg
Télécharger la présentation

Complexity and Computability Theory I

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. Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein

  2. Overview • Minimalization • Equivalence • Minimalization algorithm • Examples Rina Zviel-Girshin @ASC

  3. Example over ={0,1} Consider the following automata that accept L = *. A: B: C: Rina Zviel-Girshin @ASC

  4. Minimalization • Input A DFA A • Output A DFA B such that L(B)=L(A) • B accepts the same language A does • B has a minimal number of states among all DFA’s accepting the language • Such B will be called the minimal DFA of A. Rina Zviel-Girshin @ASC

  5. Minimalization Idea • We will convert a non minimal DFA into a minimal DFA.  • What do we mean when we say: “The automaton is not minimal”. • That means exist at least two states which can be unified into one.  Rina Zviel-Girshin @ASC

  6. Unification • Two states can be unified if they have the same behavior. • For all possible strings, whether we are in one state or another, we get the same result – • either both lead to accepting the string (to an accepting state) or • both lead to rejection of the string (to a non accepting state). Rina Zviel-Girshin @ASC

  7. Example from real life • An automaton which decides whether to take an umbrella • We have two states: • one “there is rain outside” and • another “drops of water are falling from the sky” • then on input “I have to go out”, both will lead to the same conclusion of the need of umbrella. • Therefore the states can be unified. Rina Zviel-Girshin @ASC

  8. Example of automaton q0 and q2 have the same behavior. For each letter go to the same state: for 1 to q3 and for 0 to q1. Rina Zviel-Girshin @ASC

  9. Example (cont) The minimal automaton: Rina Zviel-Girshin @ASC

  10. State equivalence • States that have the same behavior and therefore can be united called equivalent states. • Informally: Two states are equivalent if there is no string which leads from one to an accepting state and from the other to a non accepting state. • Formally: Two states p and q are equivalent iff for all w* ’(q,w)F iff ’(p,w)F Rina Zviel-Girshin @ASC

  11. Separating words • If two states p and q are not equivalent then there is a string w which leads from one state to an accepting state and from the other to a non accepting state. • Such a word w is called a separation word for the two states. • Either ’(q,w)F and ’(p,w)F or ’(q,w)F and ’(p,w)F • We can also say that p and q are separated by w. Rina Zviel-Girshin @ASC

  12. k-equivalence • Informally: Two states p and q are k-equivalent if they have no separating word of length not exceeding k (less or equal k) • Notation: pEkq Rina Zviel-Girshin @ASC

  13. Example • States q0 and q1 are 2-equivalent because the is no separation word of length less or equal 2. q0E2q1 • But states q0 and q1 are not 3-equivalent because there is a word w=000 that separates them. ’(q0,000)=q3F and ’(q1,000)=q4F Rina Zviel-Girshin @ASC

  14. k-equivalence • Formally: Two states p and q are k-equivalent if”f for all w* such that |w|k ’(q,w)F iff ’(p,w)F  Other formulations of the same definition. • If there is a separating word its length is greater than k. • For all words of length not greater than k p and q are equivalent. Rina Zviel-Girshin @ASC

  15. Equivalence of states • Two states are equivalent if they are k-equivalent for all k.  or • There is no separating word of any length between the states. Rina Zviel-Girshin @ASC

  16. Example • In this example q0 and q2 are equivalent because after first letter of the word they go to the same state. • That means that for each word with length greater than 1 they behave in the same way. Rina Zviel-Girshin @ASC

  17. Example • So there is no separation word of any length between q0 and q2. Rina Zviel-Girshin @ASC

  18. Terminology • We will use the term set of states Q for the set of all states of an automaton. • The “clusters” of an equivalence relation states are called classes. • Q can be divided into classes of states. • In previous example: {q0,q2} is called a class. Rina Zviel-Girshin @ASC

  19. Minimalization algorithm technique • The minimalization algorithm will use the dynamic programming technique. • We will incrementally separate the set of states into equivalent subsets using k equivalence. Rina Zviel-Girshin @ASC

  20. Minimalization algorithm technique (cont.) • Step by step we will find whether there is a separating word of the class and divide the class which it separates into subclasses. • At each step we will increase the length of separating word starting with 0. • At each step we will use the result of the previous step and apply a simple checking mechanism on the classes derived in the previous step. Rina Zviel-Girshin @ASC

  21. Example • There is a word of length 0 that separates between q0 and q1,q2. • So we can divide the Q into two classes: {q0},{q1,q2}. Rina Zviel-Girshin @ASC

  22. Example (cont.) • The class with only one state can't be divided into subclasses. • But the class with more than one state can be divided. So lets check the class {q1,q2}. Rina Zviel-Girshin @ASC

  23. Example (cont.) • For any word of length equal to 1 both of them lead to the same state q0. • So there is no separation word between q1 and q2. • That means that they are 1-equivalent. Rina Zviel-Girshin @ASC

  24. Example (cont.) • The classes of Q remain the same: {q0},{q1,q2}. • So it is a final partition of Q. Rina Zviel-Girshin @ASC

  25. Example (cont.) • The minimal automaton has two states {q0},{q1,q2}. Rina Zviel-Girshin @ASC

  26. When to stop? • When do we stop to compute Ei? • When there is no difference between the equivalent subsets of the last two states: Ek=Ek+1. • Why? • Because for each letter of  we go to equivalent classes. Rina Zviel-Girshin @ASC

  27. Theorem If Ek=Ek+1 then Ek+1=Ek+2. Proof: • Assume that Ek=Ek+1 and prove that for any pair of states p and q pEk+1q iff pEk+2q. • If pEk+2q then pEk+1q .If there is no separation word of length k+2 so there is obviously no separation word of length less than k+2. Rina Zviel-Girshin @ASC

  28. Theorem If Ek=Ek+1 then Ek+1=Ek+2. Proof (cont.) • pEk+1q means that pEkq and for each (p,)Ek(q,). • We know that Ek=Ek+1. • So we know that pEk+1q and for each (p,)Ek+1(q,). That means that pEk+2q. Rina Zviel-Girshin @ASC

  29. Theorem conclusion Conclusion: • The computation of equivalence states stops when Ek=Ek+1. Rina Zviel-Girshin @ASC

  30. Minimalization algorithm Input: A DFA A. Output: A minimal state DFA B. • Divide Q into two subsets: • final states F and • non final states Q-F. Rina Zviel-Girshin @ASC

  31. Minimalization algorithm (cont.) 2. While in the previous step a change was made do at step j+1 for each j-equivalence class C (subset in the previous step) for each pair of states p and q in C for each  if (p,) is not j-equal to (q,) than divide C into classes in such way that p and q will be in different classes. Rina Zviel-Girshin @ASC

  32. Minimalization algorithm (cont.) 3. The set of the states in B is the set of classes resulting from the step 2. 4. The starting state of B will be the class that includes the starting state of A. 5. The final states of B will be the classes including final states of A. 6. Transition function of B: for each state P in B and  (P,)=R if for all pP A(p,)R. Rina Zviel-Girshin @ASC

  33. Example • Construct a minimal DFA equivalent to a given DFA:  Rina Zviel-Girshin @ASC

  34. Example (cont.) E0={{q0,q3}, {q1,q2}} E1=E0 Rina Zviel-Girshin @ASC

  35. Example (cont.) So the minimal DFA is: Rina Zviel-Girshin @ASC

  36. b Another example • Construct a minimal DFA equivalent to a given DFA Rina Zviel-Girshin @ASC

  37. b Another example (cont.) 1. First lets find the states that are 0-equivalent: E0 = { F, Q-F} = { {q4}, {q0,q1,q2,q3}} Rina Zviel-Girshin @ASC

  38. Another example (cont.) 2. Now we find the states that are 1-equivalent. The only class that can be divided is {q0,q1,q2,q3}. Rina Zviel-Girshin @ASC

  39. Another example (cont.) • So for the word w=a all the states go to the same class in E0. • Another word of length 1 is w=b. • We can see that {q0,q1,q2} go to the same class in E0 and q3 goes to the other class. • So q3 should be separated from other states in its class. • The separation word is b. • The result is: E1 = { {q4}, {q3}, {q0,q1,q2}} Rina Zviel-Girshin @ASC

  40. Another example (cont.) 3. Now we find the states that are 2-equivalent. The only class that can be divided is {q0,q1,q2}. ab is a separating word So q0 san be separated from q1,q2. E2 = { {q4}, {q3}, {q0}, {q1,q2}} Rina Zviel-Girshin @ASC

  41. Another example (cont.) 4. Now we find the states that are 3-equivalent. • The only class that can be divided is {q1,q2}. • It can't be divided. • Over a q1,q2 both go to q3 and than behave the same way. • Over b each of them stay in the same non accepting state. • So E2=E3= { {q4}, {q3}, {q0}, {q1,q2}}. Rina Zviel-Girshin @ASC

  42. Another example (cont.) The resulting automaton is: Rina Zviel-Girshin @ASC

  43. Any Questions? Rina Zviel-Girshin @ASC

More Related