3 Pages

lec11

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

Word Count: 2189

Document Preview

322 CSE - Introduction to Formal Methods in Computer Science The Myhill-Nerode Theorem Dave Bacon Department of Computer Science & Engineering, University of Washington The pumping lemma for regular languages is nice, but it has one fatal drawback, and that is that it is not a complete characterization of whether a language is regular. In other words this means that there are languages which are not...

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 The Myhill-Nerode Theorem Dave Bacon Department of Computer Science & Engineering, University of Washington The pumping lemma for regular languages is nice, but it has one fatal drawback, and that is that it is not a complete characterization of whether a language is regular. In other words this means that there are languages which are not regular, but which obey the pumping lemma. Here we will describe a condition which, unlike the pumping lemma, can be used as a complete test for whether a language is regular or not. It is called the Myhill-Nerode theorem. I. TWO EQUIVALENCE RELATIONS To begin let us start with two useful equivalence relations. The first equivalence relation is defined over any language. Let A be a language in . Then we say that the strings x and y are indistinguishable by A if and only if, for every string z , either both x and y are in the language or both x and y are not in the language. When two strings are indistinguishable with respect to A, we write x A y. Lets give an example. Consider the language A = {01k |k 0} {00}. The two strings 01 and 011 are indistinguishable in A. Why? Because 01z is in A iff z 1 . Similarly 011z is in A iff z 1 . Thus the strings 01z and 011z are both in A at the same time, or both not in A at the same time. Now, A is an equivalence relation. Recall that a relation is an equivalence relation if it is reflexive, symmetric, and transitive. The first of these means that x A x which is clearly true. The second of these means that x A y = y A x, which is also clearly true since our definition was symmetric. The final of these means that if x A y and y A z, then x A z which is the only slightly tricky one, but if you give it a little thought you will see it is true. Now given that A is an equivalence relation what can we do? Recall that if we have an equivalence relation we can divide the set the relation is defined over into equivalence classes. These equivalence classes are subsets of the set we are working with which are disjoint (the intersection of any two is empty) and which are complete (the union of all of the equivalence classes is the entire set.) In other words equivalence relations give us a way to define equivalence classes, and these equivalence classes fully partition the set we are working on. Lets work out an example for the language we considered above A = {01k |k 0} {00} (we work with the alphabet = {0, 1}. ) It is easy to see, by generalizing our example above, the {01k |k > 0 are equivalent to each other. Note that 0 is not equivalent over A to 01, since, 00 is in A, but 010 is not in A. Further, using similar reasoning 00 is not equivalent to 0. Further is not equivalent to any other string in A, since there is no portion of A which ends with arbitrary strings. But is equivalent to strings which are not in A. Indeed, all of the elements that are not in A are equivalent to each other (you should check this.) Thus the equivalence classes of A are {0}, {00}, {01k |k > 0}, and - A. Next lets give another equivalence relation, but this time defined over a DFA M . To do this we will need to define a concept called delta-star. The transition function of a DFA, tell us, given a current state, and a symbol, what new state to transition to. tell us, given a current state, and a string, what new state would the DFA end up, starting at the current state and then reading that particular string. We can define inductively. First note that : Q Q. Then define this function as Delta-star definition: 1. Base case: (q, ) = q 2. Inductive step: For x and a , (q, xa) = ( (q, x), a) Okay, given the definition of we can now begin to define our new equivalence relation. Given a DFA M = (Q, , , q0 , F ), we say that two string x and y are indistinguishable, if and only if (q0 , x) = (q0 , y). In other words the two strings are indistinguishable if, starting at the initial state, one ends up at the same state upon reading either x or y. If this is true, we write x M y. Again, it is easy to check that M is and equivalence relation. Thus we can use this equivalence relation to partition up into equivalence classes as before. Further note that M only has a finite number of equivalence classes, since the equivalence is defined by ending up in the same state, and there are only a finite number of states for a DFA. Further note that if the DFA is made up of reachable states, then the number of equivalence classes will just be equal to the number of states of the machine M . 2 II. A LEMMA AND A NEW METHOD FOR PROVING A LANGUAGE NOT REGULAR Now lets prove a useful lemma relating the equivalence class of a machine M and the language accepted by this machine, L(M ). The lemma is as follows: If A = L(M ) for a DFA M , then for any x, y , if x M y then x A y. Notice that at this point this is only an if statement, not an if and only if (yet!). So why is this true? Lets prove it! Let A = L(M ) and M = (Q, , , q0 , F ). Therefore w A if and only if (q0 , w) F . Suppose also that x M y. Then (q0 , x) = (q0 , y). Let z . Then (q0 , xz) = (yz) (since after we get to the state reached by both x and y the DFA will proceed deterministically.) Therefore xz A if and only if (q0 , xz) F . Further since (q0 , xz) = (yz) this means that xz A if and only if (q0 , yz) F . But (q0 , yz) F if and only if yz A. Therefore xz A if and only if yz A. It thus follows that x A y. What good is this lemma? Well, it tells us something nice. It says that whenever two elements arrive at the same state in M , they are in the same equivalence class of A . This means that each equivalence class of A is a union of equivalence classes of M . One nice consequence of this is, since M has equivalence which classes are finite in number, that we can now show that If A is regular, then A has a finite number of equivalence classes. Why is this true? If A is regular, then there is a DFA M which recognizes the language A. Our lemma from above tells us that A has at most the number of equivalence classes of M (this largest case comes about when A equivalence classes are identical to the equivalence classes of M .) Since the number of equivalence classes of M is finite, this implies that the number of equivalence classes of A is finite. Okay well now that we've proved this, what good is it? Well now we have a new method for proving that languages are not regular! How? Well, again, by contradiction. We proceed by assuming that the language, A, we are considering is regular. Then if we can show that the number of equivalence classes under A is not finite, then we have proved a contradiction to our deduction above. To prove that the number of equivalence classes under A is not finite, we don't really need to identify all of the equivalence classes: all we really need to do is to provide an infinite sequence of strings and prove that they are not equivalent to each other. Lets do an example! Consider the language A = {0n 1n |n 0}. Lets prove that this language is not regular, using the corollary above. Assume that A is regular and therefore, by the above corollary, it has a finite number of equivalence classes. Lets examine the sequence of strings x1 , x2 , . . . where xi = 0i , where i 1. Let us show that no two of these are equivalent to each other with respect to A. Consider 0i and 0j where i = j. Let z = 1i . Now 0i z = 0i 1i which is in A. But 0j z = 0j 1i is not in A. Thus these two strings 0i and 0j are not equivalent to each other. Thus, since the sequence of string x1 , x2 , . . . is infinite, we have shown that the number of equivalence classes of A is infinite. This contradicts our assumption that the number of equivalence classes of A is finite. Thus A must not be regular. Wah-lah. Okay, so we have a brand spanking new method for showing that a language is not regular. But does this method provide us anything more than the pumping lemma did? Well the answer to that is the reason I'm blabbing on about this. This is the fact that, unlike the pumping lemma, this method is always guaranteed to work. The statement of this is the Myhill-Nerode theorem. III. 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 . We have already proved one direction of this theorem (that if A is regular, then it has a finite number of equivalence classes under A .) Now lets prove the opposite direction: that if A has a finite number of equivalence classes, then A is regular. We will do this by our favorite trick, by showing that if A has a finite number of equivalence classes, then we can construct a DFA M which recognizes A. Let M = (Q, , , q0 , F ) be the DFA we are going to construct. Further let A1 , A2 , . . . , Ar denote the equivalence classes of A . The Ai are disjoint and partition . Define the states of the DFA as Q = {q1 , . . . , qr }. Our goal will be to define the transition function and q0 and F such that (q0 , x) = qr if and only if x Ar . Lets begin by defining q0 . Let q0 = qi such that Ai . In other words, the start state corresponds to the equivalence class that contain...

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 Minimizing DFAsDave BaconDepartment of Computer Science & Engineering, University of WashingtonLast time we discussed the Myhill-Nerode theorem: Myhill-Nerode Theorem A is regular if an
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