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

Slides:



Advertisements
Similar presentations
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Advertisements

4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
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.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
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.
Costas Busch - RPI1 Grammars. Costas Busch - RPI2 Grammars Grammars express languages Example: the English language.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
Costas Buch - RPI1 Simplifications of Context-Free Grammars.
Fall 2006Costas Busch - RPI1 The Post Correspondence Problem.
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.
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.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
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.
Costas Busch - RPI1 More Applications of the Pumping Lemma.
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:
Chapter 12: Context-Free Languages and Pushdown Automata
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 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
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.
Costas Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
Costas Busch - LSU1 The Post Correspondence Problem.
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.
 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.
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
The Post Correspondence Problem
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:

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

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

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

Costas Busch - RPI4 Derivation treestring

Costas Busch - RPI5 repeated Derivation treestring

Costas Busch - RPI6

7 Repeated Part

Costas Busch - RPI8 Another possible derivation from

Costas Busch - RPI9

10 A Derivation from

Costas Busch - RPI11

Costas Busch - RPI12

Costas Busch - RPI13 A Derivation from

Costas Busch - RPI14

Costas Busch - RPI15

Costas Busch - RPI16

Costas Busch - RPI17

Costas Busch - RPI18 A Derivation from

Costas Busch - RPI19

Costas Busch - RPI20

Costas Busch - RPI21

Costas Busch - RPI22 In General:

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

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

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

Costas Busch - RPI26

Costas Busch - RPI27 maximum right hand side of any production

Costas Busch - RPI28 Number of productions in grammar

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

Costas Busch - RPI30 Some variable is repeated Derivation of string

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

Costas Busch - RPI32 Possible derivations:

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

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

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

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

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

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

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

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

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

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:

Costas Busch - RPI43 Applications of The Pumping Lemma

Costas Busch - RPI44 Context-free languages Non-context free languages

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

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

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

Costas Busch - RPI48 We can write: with lengths and

Costas Busch - RPI49 Pumping Lemma says: for all

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

Costas Busch - RPI51 Case 1: is within

Costas Busch - RPI52 Case 1: and consist from only

Costas Busch - RPI53 Case 1: Repeating and

Costas Busch - RPI54 Case 1: From Pumping Lemma:

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

Costas Busch - RPI56 Case 2: is within

Costas Busch - RPI57 Case 2: Similar analysis with case 1

Costas Busch - RPI58 Case 3: is within

Costas Busch - RPI59 Case 3: Similar analysis with case 1

Costas Busch - RPI60 Case 4: overlaps and

Costas Busch - RPI61 Case 4: Possibility 1:contains only

Costas Busch - RPI62 Case 4: Possibility 1:contains only

Costas Busch - RPI63 Case 4: From Pumping Lemma:

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

Costas Busch - RPI65 Case 4: Possibility 2:contains and contains only

Costas Busch - RPI66 Case 4: Possibility 2:contains and contains only

Costas Busch - RPI67 Case 4: From Pumping Lemma:

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

Costas Busch - RPI69 Case 4: Possibility 3:contains only contains and

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

Costas Busch - RPI71 Case 5: overlaps and

Costas Busch - RPI72 Case 5: Similar analysis with case 4

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

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