2 Pages

lec9

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

Word Count: 1403

Document Preview

322 CSE - Introduction to Formal Methods in Computer Science The Pumping Lemma for Regular Languages Dave Bacon Department of Computer Science & Engineering, University of Washington So far we have talked about regular languages and showed that they are captured in a variety of different models: they are accepted by NFAs and they correspond to the languages of regular expressions. In other words, we have...

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 Pumping Lemma for Regular Languages Dave Bacon Department of Computer Science & Engineering, University of Washington So far we have talked about regular languages and showed that they are captured in a variety of different models: they are accepted by NFAs and they correspond to the languages of regular expressions. In other words, we have lived and breathed regular languages deep down to our very basic sole. But are all languages regular? Consider a quintessential example, the language Lb = {w|w = 0k 1k , k 1}. Is this language regular? Well consider a deterministic finite automata which is designed to accept Lb . Let that machine have q states. Now suppose that we consider the machine on inputs in the set {0i } with 1 i q. By the pigeon hole principle, there must exists two inputs to the machine, call them 0i and 0j with 1 i = j q such that the machine is in the same state for these inputs. Now think about what happens when the machine enters such a state. I could have entered it with 0i or 0j . Suppose it enters on 0i . Then the machine should accept if it next reads 1i but reject if it next reads 1j . But this contradicts the fact that it could have gotten to the state via reading 0j . Thus it is impossible for the language Lb to be accepted by a DFA and hence the language is not regular. The above intuition is quantified by a lemma called the pumping lemma for regular languages. I. THE PUMPING LEMMA Lets begin by stating the pumping lemma and then given some idea about what it means and then proving it. Pumping Lemma for Regular Languages If L is a regular language, then there exists a constant n (which depends on L) such that for every string w in the language L, such that the length of w is greater than or equal to n, we can divide w into three strings, w = xyz where 1. y is not the empty string, y = {}. 2. The size of xy is less than or equal to n: |xy| n. 3. For all k 0, the string xy k z is also in L. Intuitively what this says is that we can always find a nonempty string y not far from the beginning of the string w L that can be "pumped": by repeating y any number of times (including zero times, i.e. deleting it) you obtain a string which is still in the language. The pumping lemma tells us that all regular languages must possess the pumping property. Thus we can show that a language is not regular by showing that it violates the pumping lemma. However, just because a language satisfies the pumping lemma, this does not mean the language is regular. In other words there are non-regular languages which obey the pumping lemma. Thus we should be careful and not use the pumping lemma to prove that a language is regular! We should only use it to prove that some language is not regular. Later we will give a condition which is both necessary and sufficient for a language to be regular. Now lets prove the pumping lemma. This proof will hopefully also give us intuition about why the pumping lemma holds. Proof: (Pumping Lemma for regular languages) Let M = (Q, , , q1 , F ) be a DFA which recognizes the language L. Let n be number of states in M : i.e. n = |Q|. Let w = w1 w2 . . . wp be a string in L where p n. The machine, on reading this string, will enter the states r1 , r2 , . . . , rp+1 . Among the first n + 1 states in this sequence, there must be two states which are the same, by the pigeon hole principle. Call the first of these rj and the second of these rk . j and l must be less than or equal to n + 1. Let x = w1 wj-1 , y = wj wl-1 and z = wl . . . wp . The string x takes r1 to rj , the string y takes rj to rl the and string z takesrl to rp . But rj is equal to rl ! Thus the system must loop between those two states. Therefore xy i z must be accepted by the machine for i 0. Further we have that y = since j = l. Finally we have that |xy| n. Thus we have proven the pumping lemma. 2 II. A. EXAMPLES An Example, Redux Let's use the pumping lemma first to show that the language above Lb = {w|w = 0k 1k } is not regular. Assume that Lb is regular (for contradiction.) Let n be the pumping length in the pumping lemma and let w = 0n 1n . w is in Lb . The pumping lemma tells us that w can be split up into three pieces s = xyz satisfying the lemmas conditions. Consider the following three cases 1. y is made up entirely of 0s. Then xy 2 z will have more 0s than 1s and hence is not in Lb . But the pumping lemma says that xy k z should be in L, so this is a contradiction. 2. Similarly if y is made up entirely of 1s then this leads to a contradiction. 3. Thus the only case left to check is if y contains both 0s and 1s. But then xy 2 z = xyyz will have strings which are out of order, i.e. there will be some 1s before some 0s. In other words xy 2 z is not in Lb . This is a contradiction of the pumping lemma. Thus we cannot avoid a contradiction in the three possible cases for y. Notice that, having picked n, any old string of length n or greater will work to provide a contradiction. Further note that we made no use of the restriction that |xy| n. B. Example: Balanced Strings Suppose that we consider the language B = {w|w has an equal number of 0s and 1s} and want to know whether it is regular at not. Suppose we choose the string 0n 1n and n is the pumping length in the lemma. Then it would seem that we could apply the pumping lemma because if we let x and z be the empty string, then y k = (0n 1n )k is still in B. But wait, this would then violate |xy| n. If |xy| n, then y must consist only of 0s, so xyyz is not in B. Thus 0n 1n cannot be pumped. Another observation is that the choice of the string really matters. If we had choosen, for example (01)n instead, we would have been in trouble. Why? Because we could set x = , y = (01) and z = (01)n-1 . Then xy i z B for all i, y = , and |xy...

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 String MatchingDave BaconDepartment of Computer Science & Engineering, University of WashingtonSuppose that you are given a short pattern and a long text and you wish to determine if th
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science The Myhill-Nerode TheoremDave BaconDepartment of Computer Science & Engineering, University of WashingtonThe pumping lemma for regular languages is nice, but it has one fatal drawback,
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