Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.

Similar presentations


Presentation on theme: "Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein."— Presentation transcript:

1 Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein

2 Rina Zviel-Girshin @ASC2 Overview Minimalization Equivalence Minimalization algorithm Examples

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

4 Rina Zviel-Girshin @ASC4 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.

5 Rina Zviel-Girshin @ASC5 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.

6 Rina Zviel-Girshin @ASC6 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).

7 Rina Zviel-Girshin @ASC7 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.

8 Rina Zviel-Girshin @ASC8 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.

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

10 Rina Zviel-Girshin @ASC10 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

11 Rina Zviel-Girshin @ASC11 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.

12 Rina Zviel-Girshin @ASC12 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: pE k q

13 Rina Zviel-Girshin @ASC13 Example States q0 and q1 are 2-equivalent because the is no separation word of length less or equal 2. q0E 2 q1 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

14 Rina Zviel-Girshin @ASC14 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.

15 Rina Zviel-Girshin @ASC15 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.

16 Rina Zviel-Girshin @ASC16 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.

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

18 Rina Zviel-Girshin @ASC18 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.

19 Rina Zviel-Girshin @ASC19 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.

20 Rina Zviel-Girshin @ASC20 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.

21 Rina Zviel-Girshin @ASC21 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}.

22 Rina Zviel-Girshin @ASC22 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}.

23 Rina Zviel-Girshin @ASC23 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.

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

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

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

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

28 Rina Zviel-Girshin @ASC28 Theorem If E k =E k+1 then E k+1 =E k+2. Proof (cont.) pE k+1 q means that pE k q and for each   (p,  )E k  (q,  ). We know that E k =E k+1. So we know that pE k+1 q and for each   (p,  )E k+1  (q,  ). That means that pE k+2 q.

29 Rina Zviel-Girshin @ASC29 Theorem conclusion Conclusion: The computation of equivalence states stops when E k =E k+1.

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

31 Rina Zviel-Girshin @ASC31 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.

32 Rina Zviel-Girshin @ASC32 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.

33 Rina Zviel-Girshin @ASC33 Example Construct a minimal DFA equivalent to a given DFA:

34 Rina Zviel-Girshin @ASC34 Example (cont.) E 0 ={{q0,q3}, {q1,q2}} E 1 =E 0

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

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

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

38 Rina Zviel-Girshin @ASC38 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}. E1E1 ab q0q2q1 q3q1 q2q3q2 q3 q4

39 Rina Zviel-Girshin @ASC39 Another example (cont.) So for the word w=a all the states go to the same class in E 0. Another word of length 1 is w=b. We can see that {q0,q1,q2} go to the same class in E 0 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: E 1 = { {q4}, {q3}, {q0,q1,q2}}

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

41 Rina Zviel-Girshin @ASC41 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 E 2 =E 3 = { {q4}, {q3}, {q0}, {q1,q2}}.

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

43 Rina Zviel-Girshin @ASC43 Any Questions?


Download ppt "Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein."

Similar presentations


Ads by Google