Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.

Slides:



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

Prof. Busch - LSU1 Simplifications of Context-Free Grammars.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Recursively Enumerable and Recursive Languages
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Courtesy Costas Busch - RPI1 Context-Free Languages.
Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
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.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
1 More Applications of The Pumping Lemma. 2 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
Homework #7 Solutions. #1. Use the pumping lemma for CFL’s to show L = {a i b j a i b j | i, j > 0} is not a CFL. Proof by contradiction using the Pumping.
1 Non-regular languages. 2 Regular languages Non-regular languages.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch1 More Applications of The Pumping Lemma.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Fall 2003Costas Busch - RPI1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
A Universal Turing Machine
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Context Free Pumping Lemma. CFL Pumping Lemma A CFL pump consists of two non-overlapping substrings that can be pumped simultaneously while staying in.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
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.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Recursively Enumerable and Recursive Languages
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
NPDAs Accept Context-Free Languages
Simplifications of Context-Free Grammars
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Non-regular languages
More Applications of the Pumping Lemma
Chapter 2 Context-Free Language - 02
DPDA Deterministic PDA
More Applications of The Pumping Lemma
Applications of Regular Closure
Presentation transcript:

Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages

Courtesy Costas Busch - RPI2 Take an infinite context-free language Example: Generates an infinite number of different strings

Courtesy Costas Busch - RPI3 A derivation: In a derivation of a long string, variables are repeated

Courtesy Costas Busch - RPI4 Derivation treestring

Courtesy Costas Busch - RPI5 repeated Derivation treestring

Courtesy Costas Busch - RPI6

7 Repeated Part

Courtesy Costas Busch - RPI8 Another possible derivation from

Courtesy Costas Busch - RPI9

10 A Derivation from

Courtesy Costas Busch - RPI11

Courtesy Costas Busch - RPI12

Courtesy Costas Busch - RPI13 A Derivation from

Courtesy Costas Busch - RPI14

Courtesy Costas Busch - RPI15

Courtesy Costas Busch - RPI16

Courtesy Costas Busch - RPI17

Courtesy Costas Busch - RPI18 A Derivation from

Courtesy Costas Busch - RPI19

Courtesy Costas Busch - RPI20

Courtesy Costas Busch - RPI21

Courtesy Costas Busch - RPI22 In General:

Courtesy Costas Busch - RPI23 Consider now an infinite context-free language Take so that it has no unit-productions no -productions Let be the grammar of

Courtesy Costas Busch - RPI24 (Number of productions) x (Largest right side of a production) = Let Example : Let

Courtesy Costas Busch - RPI25 Take a string with length We will show: in the derivation of a variable of is repeated

Courtesy Costas Busch - RPI26

Courtesy Costas Busch - RPI27 maximum right hand side of any production

Courtesy Costas Busch - RPI28 Number of productions in grammar

Courtesy Costas Busch - RPI29 Number of productions in grammar Some production must be repeated Repeated variable

Courtesy Costas Busch - RPI30 Some variable is repeated Derivation of string

Courtesy Costas Busch - RPI31 Last repeated variable repeated Strings of terminals Derivation tree of string

Courtesy Costas Busch - RPI32 Possible derivations:

Courtesy Costas Busch - RPI33 We know: This string is also generated:

Courtesy Costas Busch - RPI34 This string is also generated: The original We know:

Courtesy Costas Busch - RPI35 This string is also generated: We know:

Courtesy Costas Busch - RPI36 This string is also generated: We know:

Courtesy Costas Busch - RPI37 This string is also generated: We know:

Courtesy Costas Busch - RPI38 Therefore, any string of the form is generated by the grammar

Courtesy Costas Busch - RPI39 knowing that we also know that Therefore,

Courtesy Costas Busch - RPI40 Observation: Since is the last repeated variable

Courtesy Costas Busch - RPI41 Observation: Since there are no unit or -productions

Courtesy Costas Busch - RPI42 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free language with lengths and it must be:

Courtesy Costas Busch - RPI43 Reminders Choosing m : The thing to remember about the pumping length m is that you don’t get to choose it! The pumping lemma itself “supplies” this value to you. So you cannot make any assumption about what the value of m is, you simply must use it as a fixed value over which you have no control.

Courtesy Costas Busch - RPI44 Reminders Choosing w : A good place to start is with a string that incorporates the pumping length m in it somehow, e.g. a m b m if your alphabet is {a, b}. The right string can reduce the number of different partitions you must consider. As you work through more and more examples of these types of proofs, you gather insight into the types of strings that will work best. So the best way to get better at choosing w is to read examples and, even better, to work problems.

Courtesy Costas Busch - RPI45 Reminders Choosing the partition of w : The thing to remember about the partition of w into its parts u, v, x, y & z is, again, that you don’t get to choose it! The partition is, in some sense, chosen for you. But it is never explicitly given to you (the way you can think of the pumping length as being given to you), so you must consider all possible partitions. Remember, that for each partition of w, you must show that for some integer i, the string uv i xy i z is not in L.

Courtesy Costas Busch - RPI46 Reminders Choosing i : You do get to choose this, and you’re given quite a bit of freedom. You may pick i so that it is any integer greater than 1, or even 0. It doesn’t make sense to select i = 1, since that would describe w, a string which you already know to be in L.) You may even choose i differently in different cases of your proof. This is useful, for example, if some cases work only if you “pump down” to i = 0, while others work only if you “pump up” to i = 2 or i = 3.

Courtesy Costas Busch - RPI47 Cautions Be sure that the w you choose is actually in the language L you are trying to prove something about! If not, the pumping lemma doesn’t guarantee anything about whether pumping that w should give strings in L. Also, be sure that your string w is long enough: it must have length at least m. In the pumping lemma for context-free languages, when you pump a particular string, note that the i describing the number of repetitions of v must be the same i describing the number of repetitions of y. So it doesn’t help your proof to show a “pumped” string uv 0 xy 2 z which is not in L, since 0 ≠ 2.

Courtesy Costas Busch - RPI48 Applications of The Pumping Lemma

Courtesy Costas Busch - RPI49 Context-free languages Non-context free languages

Courtesy Costas Busch - RPI50 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Courtesy Costas Busch - RPI51 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Courtesy Costas Busch - RPI52 Pumping Lemma gives a magic number such that: Pick any string with length We pick:

Courtesy Costas Busch - RPI53 We can write: with lengths and

Courtesy Costas Busch - RPI54 Pumping Lemma says: for all

Courtesy Costas Busch - RPI55 We examine all the possible locations of string in

Courtesy Costas Busch - RPI56 Case 1: is within

Courtesy Costas Busch - RPI57 Case 1: and consist from only

Courtesy Costas Busch - RPI58 Case 1: Repeating and

Courtesy Costas Busch - RPI59 Case 1: From Pumping Lemma:

Courtesy Costas Busch - RPI60 Case 1: From Pumping Lemma: However: Contradiction!!!

Courtesy Costas Busch - RPI61 Case 2: is within

Courtesy Costas Busch - RPI62 Case 2: Similar analysis with case 1

Courtesy Costas Busch - RPI63 Case 3: is within

Courtesy Costas Busch - RPI64 Case 3: Similar analysis with case 1

Courtesy Costas Busch - RPI65 Case 4: overlaps and

Courtesy Costas Busch - RPI66 Case 4: Possibility 1:contains only

Courtesy Costas Busch - RPI67 Case 4: Possibility 1:contains only

Courtesy Costas Busch - RPI68 Case 4: From Pumping Lemma:

Courtesy Costas Busch - RPI69 Case 4: From Pumping Lemma: However: Contradiction!!!

Courtesy Costas Busch - RPI70 Case 4: Possibility 2:contains and contains only

Courtesy Costas Busch - RPI71 Case 4: Possibility 2:contains and contains only

Courtesy Costas Busch - RPI72 Case 4: From Pumping Lemma:

Courtesy Costas Busch - RPI73 Case 4: From Pumping Lemma: However: Contradiction!!!

Courtesy Costas Busch - RPI74 Case 4: Possibility 3:contains only contains and

Courtesy Costas Busch - RPI75 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2

Courtesy Costas Busch - RPI76 Case 5: overlaps and

Courtesy Costas Busch - RPI77 Case 5: Similar analysis with case 4

Courtesy Costas Busch - RPI78 There are no other cases to consider (since, string cannot overlap, and at the same time)

Courtesy Costas Busch - RPI79 In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free

Courtesy Costas Busch - RPI80 More Applications of The Pumping Lemma

Courtesy Costas Busch - RPI81 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free language with lengths and it must be:

Courtesy Costas Busch - RPI82 Context-free languages Non-context free languages

Courtesy Costas Busch - RPI83 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Courtesy Costas Busch - RPI84 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Courtesy Costas Busch - RPI85 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

Courtesy Costas Busch - RPI86 We can write: with lengths and Pumping Lemma says: for all

Courtesy Costas Busch - RPI87 We examine all the possible locations of string in

Courtesy Costas Busch - RPI88 Case 1: is within the first

Courtesy Costas Busch - RPI89 Case 1: is within the first

Courtesy Costas Busch - RPI90 Case 1: is within the first

Courtesy Costas Busch - RPI91 Case 1: is within the first Contradiction!!! However, from Pumping Lemma:

Courtesy Costas Busch - RPI92 is in the first Case 2:

Courtesy Costas Busch - RPI93 is in the first Case 2:

Courtesy Costas Busch - RPI94 is in the first Case 2:

Courtesy Costas Busch - RPI95 is in the first Case 2: Contradiction!!! However, from Pumping Lemma:

Courtesy Costas Busch - RPI96 is in the first overlaps the first Case 3:

Courtesy Costas Busch - RPI97 is in the first overlaps the first Case 3:

Courtesy Costas Busch - RPI98 is in the first overlaps the first Case 3:

Courtesy Costas Busch - RPI99 is in the first overlaps the first Case 3: Contradiction!!! However, from Pumping Lemma:

Courtesy Costas Busch - RPI100 Overlaps the first in the first Case 4: Analysis is similar to case 3

Courtesy Costas Busch - RPI101 Other cases: is within or Analysis is similar to case 1:

Courtesy Costas Busch - RPI102 More cases: overlaps or Analysis is similar to cases 2,3,4:

Courtesy Costas Busch - RPI103 Since, it is impossible to overlap: There are no other cases to consider nor

Courtesy Costas Busch - RPI104 In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free

Courtesy Costas Busch - RPI105 Context-free languages Non-context free languages

Courtesy Costas Busch - RPI106 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Courtesy Costas Busch - RPI107 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Courtesy Costas Busch - RPI108 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

Courtesy Costas Busch - RPI109 We can write: with lengths and Pumping Lemma says: for all

Courtesy Costas Busch - RPI110 We examine all the possible locations of string in There is only one case to consider

Courtesy Costas Busch - RPI111

Courtesy Costas Busch - RPI112

Courtesy Costas Busch - RPI113

Courtesy Costas Busch - RPI114

Courtesy Costas Busch - RPI115 Since, for we have:

Courtesy Costas Busch - RPI116

Courtesy Costas Busch - RPI117 Contradiction!!! However, from Pumping Lemma:

Courtesy Costas Busch - RPI118 We obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free

Courtesy Costas Busch - RPI119 Context-free languages Non-context free languages

Courtesy Costas Busch - RPI120 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Courtesy Costas Busch - RPI121 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Courtesy Costas Busch - RPI122 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

Courtesy Costas Busch - RPI123 We can write: with lengths and Pumping Lemma says: for all

Courtesy Costas Busch - RPI124 We examine all the possible locations of string in

Courtesy Costas Busch - RPI125 Most complicated case: is in

Courtesy Costas Busch - RPI126

Courtesy Costas Busch - RPI127 Most complicated sub-case:and

Courtesy Costas Busch - RPI128 Most complicated sub-case:and

Courtesy Costas Busch - RPI129 Most complicated sub-case:and

Courtesy Costas Busch - RPI130 and

Courtesy Costas Busch - RPI131

Courtesy Costas Busch - RPI132 However, from Pumping Lemma: Contradiction!!!

Courtesy Costas Busch - RPI133 When we examine the rest of the cases we also obtain a contradiction

Courtesy Costas Busch - RPI134 In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free