2 Pages

lec12

Course: CS 322, Fall 2009
School: Washington
Rating:
 
 
 
 
 

Word Count: 1341

Document Preview

322 CSE - Introduction to Formal Methods in Computer Science Minimizing DFAs Dave Bacon Department of Computer Science & Engineering, University of Washington Last time we discussed the Myhill-Nerode theorem: Myhill-Nerode Theorem A is regular if and only if A has a finite number of equivalence classes. In addition there is a DFA M with A = L(M ) having precisely one state for each equivalence class of A...

Register Now

Unformatted Document Excerpt

Coursehero >> Washington >> Washington >> CS 322

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
322 CSE - Introduction to Formal Methods in Computer Science Minimizing DFAs Dave Bacon Department of Computer Science & Engineering, University of Washington Last time we discussed the Myhill-Nerode theorem: Myhill-Nerode Theorem A is regular if and only if A has a finite number of equivalence classes. In addition there is a DFA M with A = L(M ) having precisely one state for each equivalence class of A . Further we also discussed how the DFA constructed from this theorem, i.e. using the equivalence classes of A , was the smallest (fewest number of states) DFA which accepted A. Now this is great if you are given a nice description of A . But what if you aren't given a nice description of A, but instead are given a DFA which recognizes A. Is there a nice way to construct the minimal sized DFA accepting the A? One way to proceed would be to look at individual states and then see whether they are equivalent under A . But this is a real pain. So we proceed differently. Rather than starting with individual states and clumping them together, we start with all the states clumped together and then separate them as we go along. Let M = (Q, , , q0 , F ) be the DFA we are going to minimize. To do this we will use an equivalence relation on states. For each i 0 define an equivalence relation i on the set of states Q via p i q if and only if for all strings of length less than i, z , |z| i, (p, z) F if and only if (q, z) F . How will we use this equivalence condition among states? The basic idea is that if this equivalence condition holds for all i, then the inputs which reach the states p and q should all go to the states in the minimal DFA for L(M ). Lets formalize this. Let A = L(M ). Let p, q Q and suppose that every state of M is reachable from the start state q0 . Then p i q for all i 0 if and only if the equivalence class of M corrsponding to p and q lie in the same equivalence class of A . Now lets prove this. First of all if p i q for all i 0, then for any z , if (q0 , x) = q and (q0 , y) = p, then we know that (q0 , xz) F if and only if (q0 , yz) F . But this means that xz A if and only if yz A. Therefore any two states which reach p and q are in the same equivalence class of A . Next suppose that p and q are not equivalent under i for some i. Then these is some z with |z| i, such that only one of (p, z) and (q, z) is in F . Since p and q are both reachable from the start state q0 , there are strings x and y such that (q0 , x) = q and (q0 , y) = p. Therefore only one of (q0 , xz) and (q0 , yz) is in F . But this means that only one of xz and yz is in A. This means x and y are in different equivalence classes of A . I. MINIMZING DFAS Okay so given the definition of i between states, how do we use this to minimize DFAs? The meta idea is that if we can establish which states are equivalent under i for all i 0, then these states can be grouped together in the minimal DFA. But how do we show find equivalent states for this seemingly infinite series of i 0 conditions? We do this inductively and show that after a finite number of states this induction terminates. In particular lets begin by finding which states are equivalent under 0 . p and q are equivalent under 0 if and only if for z = , (p, z) F if and only if (q, z). This is equivalent to (p, ) F if and only if (q, varepsilon) F . But this means that p and q are equivalent under i if they either both lie in F or both lie Q in - F . Thus the two equivalence classes of 0 are F and Q - F . Now lets show how, given the i it is easy to figure out i+1 . Begin by noting that states which are equivalent under i+1 are equivalent under i since they must agree for all string z of length |z| i. To also make sure that they agree on strings z of length |z | = i + 1, we just need to check that after reading the first character of z , we arrive at states that are equivalent under i . In other words p i+1 q if and only if p i q and for all a , (p, a) i (q, a). Thus we see how to inductively get i+1 equivalence classes from i equivalence classes. But does this process stop? First note that if the equivalence classes of i are equal to the equivalence classes of i+1 , then the equivalence classes of i+2 will be the same as those of i+1 . In other words, once we hit a place where going to the next i+1 yields the same set of equivalent states, then we are done. Thus we have a way to construct the minimal DFA. We start with 0 and then proceed to construct i+1 from i until this repeats. At this point, we stop. We then collapse all of the states which are in the same equivalence class to the same state in our new DFA. Outgoing links are then guaranteed to be correct during this collapse. 2 Finally we see that this process must always terminate. Why? Because at each step we either increase the number of equivalence classes or we leave the number of equivalence classes the same. Since we start with all of the states in the same equivalence class, this means that after |Q| - 1 states we must eventually terminate. II. EXAMPLE Lets do an example. Consider the DFA a b b / q1 o q4 a a ?? BB > `BB || BB || ?? b BB|| b BB | ?? |B ?? a |||| BBB || BBBb | ~|| b b / / q7 o q5 q6 q a f 9 8 U b a x / q2 / q3 a a To start with we remove q4 since it is not reachable. Then after applying the equivalence of states for 0 the two equivalence clases are {q1 , q2 , q5 , q6 , q7 , q8 } and {q3 }. Now what happens? Well lets look at states in the first set and see where they go. Under an a, q1 q...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Introduction to Context-Free GrammarsDave BaconDepartment of Computer Science & Engineering, University of WashingtonIn the last few lectures we finished up talking about regular langua
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Chomsky Normal FormDave BaconDepartment of Computer Science & Engineering, University of WashingtonA useful form for dealing with context free grammars is the Chomksy normal form. This
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Pushdown AutomataDave BaconDepartment of Computer Science & Engineering, University of WashingtonOkay now that we've talked a little about context free grammars, a natural question to a
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Pushdown Automata And Context-Free LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonHaving introduced pushdown automata, we will now show that pu
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Closure Properties of Context-Free LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonPreviously we showed how regular operations were closed under
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Turing MachinesDave BaconDepartment of Computer Science & Engineering, University of WashingtonToday we finally make it up to.computers! Well at least to the model which best captures w
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science DecidabilityDave BaconDepartment of Computer Science & Engineering, University of WashingtonIn the last lecture we introduced the Turing machine. We talked about how it worked, and show
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceMidterm TopicsThe midterm will be Friday, May 9th in class. It will be 50 minutes in length and will be closed book. The midterm will cover everything covered in class up to and including the first half o
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceFinal TopicsThe nal will be Monday, June 9 from 2:30-4:20 in EEB 045. It will be 110 minutes in length and will be closed book. It will cover everything in the class with slightly more coming from the mat
Washington - CS - 322
CSE322: Formal Models in Computer Science Partial Solutions to Sample FinalSpring 2006This handout has (partial) solutions to some of the problems in the sample final exam that was handed out in class on Friday, May 26. I have not given solutions
Washington - CS - 322
1 CSE 322: Formal Models in Computer Science April 2, 2008 HandoutN,S,W,ENNN,EQQQ Fremont Troll o QQQ y QQQ QQQ QQQ N,S,W N QQQ Q@ E G Queen Anne Ave o Villa Sophia o W iRRR y RRR RRR N S RRR W R Space Needle o yNWGas Works Park o
Washington - CS - 322
CSE 322 Introduction to Formal Models in Computer ScienceDefining from In the definition of DFAs, the transition function explicitly describes, for each character a , the name of the state reached on a when started at state q. This is precisely
Washington - CS - 322
Washington - CS - 322
CSE 322: Formal Models in Computer Science Website: http:/www.cs.washington.edu/322 Lecture Times: MWF 1:30-2:30 in EE 045 (in the dungeon of EE.) Instructor: Dave Bacon Office: CSE 460 Email: dabacon@cs.washington.edu Phone: 206-221-6503 Office hour
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Winter 2005 Course InformationInstructor: TAs:Anna R. Karlin Neva Cherniavsky Ning ChenPGA 594 PGA 378 PGA 310karlin@cs.washington.edu nchernia@cs.washington.edu ning@cs.washington.edu543-9344 685-
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #0 January 3, 2005 Due: Wednesday, January 5Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Questions: 1. For each of the following topics, indicate your level of comfort on a scale o
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #1 January 5, 2005 Due: Wednesday, January 12Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Problems:1. Gale and Shapley published their paper on the stable marriage problem in 196
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #2 January 12, 2005 Due: Wednesday, January 19 Reading Assignment: K&T, Section 5.1, 5.2, 5.4, 5.6, 5.7, 5.9 Questions: 1. (Kleinberg and Tardos, Chapter 4, Problem 5) Let's consider a long, quiet
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #4 January 27, 2005 Due: Wednesday, February 2Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming, section 11.6 in new book. Problems:1. Let G = (V, E) be a g
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #5 February 2, 2005 Due: Wednesday, February 9Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming Problems: 1. Your friends have written a very fast piece of ma
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #6 Due: Wednesday, February 16Reading Assignment: Linear programming handouts, chapter on randomized algorithms, other randomized algorithms handouts (we'll send out mail about them.) Problems:
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #7 Due: Wednesday, Feb 23Problems:1. QuickSelect is the following simple algorithm for finding the k-th smallest element in an unsorted set S. QuickSelect(S, k): (a) Pick a pivot element p uni
Washington - CS - 521
Name:1 2 3 4 total/ 9 /10 /16 /39 /74CSE 521 Final ExamMarch 15, 2004 Instructions: You have 1 hour and 50 minutes to complete the exam. The exam is closed book, closed notes. Please do not turn the page until you are instructed to do so.
Washington - CS - 421
Measuring efficiency: The RAM modelnRAM = Random Access Machine Time # of instructions executed in an ideal assembly languagennComplexity and Representative ProblemsWinter 2005 Paul Beameneach simple operation (+,*,-,=,if,call) takes on
Washington - CS - 421
Undirected Graph G = (V,E)1 2 3 11 10Graph TraversalWinter 2005 Paul Beame12 4 5 6 7 8 13 9Directed Graph G = (V,E)1 2 3 11 12 4 5 6 7 8 13 9n n nGraph TraversalLearn the basic structure of a graph Walk from a fixed starting vertex s to
Washington - CS - 421
Greedy AlgorithmsnHard to define exactly but can give general propertiesn nGreedy AlgorithmsWinter 2005 Paul BeamenSolution is built in small steps Decisions on how to build the solution are made to maximize some criterion without looking t
Washington - CS - 421
Dynamic ProgrammingnDynamic ProgrammingnGive a solution of a problem using smaller sub-problems where all the possible sub-problems are determined in advance Useful when the same sub-problems show up again and again in the solutionDynamic Pro
Washington - CS - 421
Bipartite MatchingnnGiven: A bipartite graph G=(V,E)ME is a matching in G iff no two edges in M share a vertexnNetwork FlowWinter 2005 Paul BeameGoal: Find a matching M in G of maximum possible sizeBipartite MatchingBipartite Matchin
Washington - CS - 421
Dealing with NP-completenessWinter 2005 Paul BeameWhat to do if the problem you want to solve is NP-hardnYou might have phrased your problem too generallyne.g., in practice, the graphs that actually arise are far from arbitrary n maybe they
Washington - CSE - 590
Washington - CSEP - 590
Homeland Security / Cyber Security Autumn 2005N.B. CONTINUALLY IN FLUX Version 24: November 22 Course Requirements: Red Team Exercise (~25%): You are a member of a 5-6 person team of engineers and policy professionals that has been hired by the Depa