1 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.

Slides:



Advertisements
Similar presentations
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
Advertisements

3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
1 Introduction to Computability Theory Discussion3: Uses of the Pumping Lemma Prof. Amos Israeli.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
CHAPTER 4 Decidability Contents Decidable Languages
Foundations of (Theoretical) Computer Science
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.1: DFA’s) David Martin With some modifications.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Transparency No. 7-1 Formal Language and Automata Theory Chapter 7 Limitations of Finite Automata (lecture 11 and 12)
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.3: Non-Context-Free Languages) David Martin With.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
1 Non-regular languages. 2 Regular languages Non-regular languages.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
Great Theoretical Ideas in Computer Science.
Extra on Regular Languages and Non-Regular Languages
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Theory of Languages and Automata
CHAPTER 1 Regular Languages
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.1: Turing Machines) David Martin With some modifications.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Foundations of (Theoretical) Computer Science
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.2: The “Halting” Problem) David Martin With modifications.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Lecture #5 Advanced Computation Theory Finite Automata.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 105 theory of computation
Complexity and Computability Theory I
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PROPERTIES OF REGULAR LANGUAGES
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Infiniteness Test The Pumping Lemma Nonregular Languages
Non-regular languages
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
Recap lecture 26 Example of nonregular language, pumping lemma version I, proof, examples,
CHAPTER 1 Regular Languages
Presentation transcript:

Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some modifications by Prof. Karen Daniels, Fall 2009 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

2 §1.4 Nonregular languages  For each possible language L, ; µ L. So ; is the smallest language. And ; is regular L µ  *. So  * is the largest language. And  * is regular  Yet there are languages in between these two extremes that are not regular

3 A nonregular language B = { 0 n 1 n | n ¸ 0 } = { , 01, 0011, ,  } is not regular  Why? Q: how many bits of memory would a DFA need in order to recognize B? A: there appears to be no single number of bits that's big enough to work for every element of B  Remember, the DFA needs to reject all strings that are not in B

4 Other examples  C = { w 2 {0,1} * | n 0 (w) = n 1 (w) } Needs to count a potentially unbounded number of '0's... so nonregular  D = { w 2 {0,1} * | n 01 (w) = n 10 (w) } Needs to count a potentially unbounded number of '01' substrings... so ??  Need a technique for establishing nonregularity that is more formal and... less intuitive?

5 Proving nonregularity  To prove that a language is nonregular, you have to show that no DFA whatsoever recognizes the language Not just the DFA that is your best effort at recognizing the language  The pumping lemma can be used to do that  The pumping lemma says that every regular language satisfies the "regular pumping property" (RPP) Given this, if we can show that a language like B doesn't satisfy the RPP, then it's not regular B = { 0 n 1 n | n ¸ 0 }

6 Pumping lemma, informally  Roughly: "if a regular language contains any 'long' strings, then it contains infinitely many strings"  Start with a regular language and suppose that some DFA M=(Q,,,q 0,F) for it has |Q|=10 states.  What if M accepts some particular string s where s=c 1 c 2  c 15 so that |s|=15? q0q0

7 Pigeonhole principle  With 15 input characters, the machine will visit at most 16 states But there are only 10 states in this machine So clearly it will visit at least one of its states more than once  Let rpt be our name for the first state that is visited multiple times on that particular input s  Let acc be our name for the accepting state that s leads to, namely,  * (q 0,s) = acc  * (q,x) is the set of all states reachable in the machine after starting in state q and reading the entire string x  Let y be our name for the leftmost substring of s for which  * (rpt, y)=rpt Since there are no  transitions in a DFA, a state being "visited multiple times" means that it read at least one character. Therefore, |y| > 0

8 q0q0 ?  rpt?  ?  acc s=c1c1  Ã y !  c 15 sequence of states that M visits after reading the characters below  After reading c 1  c 10 (first 10 chars of s), M must have already been to state rpt and returned to it at least once... because there are only 10 states in M. Of course the repetition could have been encountered earlier than 10 characters too... · 10

9 q0q0 ?  rpt?  ?  acc s=c1c1  Ã y !  c 15 sequence of states that M visits after reading the characters below  Assigning new names to the pieces of s... · 10

10 q0q0 ?  rpt?  ?  acc s= Ã x !Ã y !Ã z ! sequence of states that M visits after reading the characters below  Assigning new names to the pieces of s... So s = xyz as shown above. With these names, the other constraints can be written |y| > 0 |xy| · 10 · 10

11 M accepts other strings too  Consider the string xz q0q0 ?  rpt?  ?  acc s= Ã x !Ã y !Ã z !

12 M accepts other strings too  Consider the string xz  * (q 0,x) = rpt  * (rpt,z) = acc (from previous slide) So xz 2 L(M) too q0q0 ?  rpt?  acc s= Ã x !Ã z !

13 M accepts other strings too  Consider the string xyyz  * (q 0,xy)=rpt (from 2 slides ago)  * (rpt,y)=rpt (from same previous result)  * (rpt,z)=acc (from same previous result) So xyyz 2 L(M) also  Apparently we can repeat y as many times as we want q0q0 ?  rpt ?  acc s= à x ! yy à z !

14 p-regular-pumpable strings  Definition (not in textbook) A string s is said to be p-regular-pumpable in a language L µ  * if there exist x,y,z 2  * such that 1.s=xyz ("x,y,z are a decomposition of s") 2.|y|>0 3.|xy| · p 4.For all i ¸ 0, x y i z 2 L ("the y part of s can be pumped to produce other strings in the language") It follows that s must be a member of L for it to be p-pumpable  The 15-character string s in the previous example was 10-pumpable in L(M)

15 p-regular-pumpable languages  Definition A language L is p-regular- pumpable if for every s 2 L such that |s| ¸ p, the string s is p-pumpable in L in other words, "every long enough string in L is pumpable"  Our previous example language was 15-regular-pumpable

16 RPP(p) and RPP  Definition RPP(p) is the class of languages that are p-regular-pumpable. In other words, RPP(p) = { L µ  * | L is p-regular-pumpable}  Definition RPP is the class of languages that are p- regular pumpable for some p. In other words,  Lots of notation and apparent complexity, but the idea is simple: RPP is the class of languages in which every long string is pumpable

17 Pumping lemma Theorem 1.70 (rephrased) If L µ  * is recognized by a p-state DFA, then L 2 RPP(p) Proof Just like our example, but use p instead of the constant 15 (number of states) Corollaries  REG µ RPP  Primary application of Pumping Lemma

18 Proving a language nonregular  First unravel these definitions, but it amounts to proving that L is not a member of RPP. Then it follows that L isn't regular Proving that L isn't in RPP allows you to concentrate on the language rather than considering all possible proposed programs that might recognize it

19 Unraveling RPP: a direct rephrasing Rephrasing L is a member of RPP if  There exists p ¸ 0 such that For every s 2 L satisfying |s| ¸ p,  There exist x,y,z 2  * such that 1.s=xyz 2.|y|>0 3.|xy| · p 4.For all i ¸ 0, x y i z 2 L ( 9 p) ( 8 s) ( 9 x,y,z) ( 8 i) !!! Pretty complicated

20 Nonregularity proof by contradiction Claim Let B = { 0 n 1 n | n ¸ 0 }. Then B is not regular Proof We show that B is not a member of RPP by contradiction. So assume that B 2 RPP (and hope to reach a contradiction soon). Then there exists p ¸ 0 associated with the definition in RPP. We let s = 0 p 1 p. (Not the exact same variable as in the RPP property, but an example of one such possible setting of it.) Now we know that s 2 B because it has the right form.

21 Proof continued  Now |s| = 2p ¸ p. By assumption that B 2 RPP, there exist x,y,z such that 1.s=xyz ( = 0 p 1 p, remember) 2.|y|>0 3.|xy| · p 4.For all i ¸ 0, x y i z 2 B  Part (3) implies that xy because the first p-many characters of s=xyz are all 0  So y consists solely of '0' characters ... at least one of them, according to (2)

22 Proof continued  But consider: s = xyz = xy 1 z = 0 p 1 p (where we started) y consists of one or more '0' characters so xy 2 z contains more '0' characters than '1' characters. In other words,  xy 2 z = 0 p+|y| 1 p so xy 2 z B = { 0 n 1 n | n ¸ 0 }.  This contradicts part (4)!!  Since the contradiction followed merely from the assumption that B 2 RPP (and right and meet and true reasoning about which we have no doubt), that assumption must be wrongQED 2

23 Observations  We needed (and got) a contradiction that was a necessary consequence of the assumption that B 2 RPP and then relied on the Theorem 1.70 corollaries  RPP mainly concerns strings that are longer than p So you should concentrate on strings longer than p... even though p is a variable. But clearly |0 p 1 p |>p  In our example we didn't "do" much: after our initial choice of s and thinking about the implications we found a contradiction right away Many other choices of s would work, but many don't, and even some that do work require more complex arguments—for example, s=0 b p/2 c +1 1 b p/2 c +1 Choosing s wisely is usually the most important thing

24 Picture so far ALL FIN Each point is a language in this Venn diagram REG RPP B = { 0 n 1 n | n ¸ 0 } { 0101,  } 0 * (101)*