Pumping Lemma for Context-free Languages

Slides:



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

1 Introduction to Computability Theory Lecture7: The Pumping Lemma for Context Free Languages Prof. Amos Israeli.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
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.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
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.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
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.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
1 Background Information for the Pumping Lemma for Context-Free Languages Definition: Let G = (V, T, P, S) be a CFL. If every production in P is of the.
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.
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.
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.
A Universal Turing Machine
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.
Critique this PDA for L= { u u R v v R : u ∈ {0,1}* and v ∈ {0,1}+ } u0εu0 u1εu1 uεεvε v00vε v11vε vεεfε sεεtε t0εt0 t1εt1 t00tε t11tε tεεuε After you.
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,
Costas Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
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.
A Universal Turing Machine
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PDAs Accept Context-Free Languages
More NP-complete Problems
PROPERTIES OF REGULAR LANGUAGES
NPDAs Accept Context-Free Languages
Simplifications of Context-Free Grammars
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
Context Free Pumping Lemma Some languages are not context free!
DPDA Deterministic PDA
Definition: Let G = (V, T, P, S) be a CFL
COSC 3340: Introduction to Theory of Computation
The Pumping Lemma for CFL’s
Elementary Questions about Regular Languages
Non-regular languages
Properties of Context-Free Languages
Undecidable problems:
Mathematical Preliminaries
More Applications of the Pumping Lemma
COSC 3340: Introduction to Theory of Computation
Chapter 2 Context-Free Language - 02
DPDA Deterministic PDA
More Applications of The Pumping Lemma
The Pumping Lemma for CFL’s
Applications of Regular Closure
The Pumping Lemma for CFL’s
Presentation transcript:

Pumping Lemma for Context-free Languages Costas Busch - LSU

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

A possible derivation: In a derivation of a “long” enough string, variables are repeated A possible derivation: Costas Busch - LSU

Derivation Tree Repeated variable Costas Busch - LSU

Derivation Tree Repeated variable Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Putting all together Costas Busch - LSU

We can remove the middle part Costas Busch - LSU

Costas Busch - LSU

We can repeated middle part two times 1 2 Costas Busch - LSU

Costas Busch - LSU

We can repeat middle part three times 1 2 3 Costas Busch - LSU

Costas Busch - LSU

Repeat middle part times 1 i Costas Busch - LSU

For any Costas Busch - LSU

We inferred that a family of strings is in From Grammar and given string We inferred that a family of strings is in for any Costas Busch - LSU

Arbitrary Grammars Consider now an arbitrary infinite context-free language Let be the grammar of Take so that it has no unit-productions and no -productions (remove them) Costas Busch - LSU

Let be the number of variables Let be the maximum right-hand size of any production Example: Costas Busch - LSU

Claim: Proof: Take string with . Then in the derivation tree of there is a path from the root to a leaf where a variable of is repeated Proof: Proof by contradiction Costas Busch - LSU

Derivation tree of We will show: some variable is repeated Costas Busch - LSU

First we show that the tree of has at least levels of nodes Suppose the opposite: At most Levels Costas Busch - LSU

Maximum number of nodes per level The maximum right-hand side of any production Costas Busch - LSU

Maximum number of nodes per level Costas Busch - LSU

Maximum number of nodes per level At most Level : nodes Levels Level : nodes Maximum possible string length = max nodes at level = Costas Busch - LSU

maximum length of string : Therefore, maximum length of string : However we took, Contradiction!!! Therefore, the tree must have at least levels Costas Busch - LSU

Thus, there is a path from the root to a leaf with at least nodes Variables Levels symbol (leaf) Costas Busch - LSU

Since there are at most different variables, some variable is repeated Pigeonhole principle END OF CLAIM PROOF Costas Busch - LSU

Take to be the deepest, so that only is repeated in subtree Take now a string with From claim: some variable is repeated subtree of Take to be the deepest, so that only is repeated in subtree Costas Busch - LSU

We can write Strings of terminals yield yield yield yield yield Costas Busch - LSU

Example: Costas Busch - LSU

Possible derivations Costas Busch - LSU

Example: Costas Busch - LSU

Remove Middle Part Yield: Costas Busch - LSU

Repeat Middle part two times 1 2 Yield: Costas Busch - LSU

Costas Busch - LSU

Repeat Middle part times 1 i Yield: Costas Busch - LSU

Costas Busch - LSU

Therefore, If we know that: then we also know: For all since Costas Busch - LSU

Observation 1: At least one of or is not Since has no unit and -productions At least one of or is not Costas Busch - LSU

Observation 2: since in subtree only variable is repeated subtree of Explanation follows…. Costas Busch - LSU

since no variable is repeated in subtree of Various yields since no variable is repeated in Maximum right-hand side of any production Costas Busch - LSU

Thus, if we choose critical length then, we obtain the pumping lemma for context-free languages Costas Busch - LSU

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

Applications of The Pumping Lemma Costas Busch - LSU

Non-context free languages Costas Busch - LSU

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

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

Let be the critical length of the pumping lemma Pick any string with length We pick: Costas Busch - LSU

From pumping lemma: we can write: with lengths and Costas Busch - LSU

Pumping Lemma says: for all Costas Busch - LSU

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

Case 1: is in Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

From Pumping Lemma: However: Contradiction!!! Costas Busch - LSU

Case 2: is in Similar to case 1 Costas Busch - LSU

Case 3: is in Similar to case 1 Costas Busch - LSU

Case 4: overlaps and Costas Busch - LSU

Sub-case 1: contains only contains only Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

From Pumping Lemma: However: Contradiction!!! Costas Busch - LSU

Sub-case 2: contains and contains only Costas Busch - LSU

By assumption Costas Busch - LSU

Costas Busch - LSU

From Pumping Lemma: However: Contradiction!!! Costas Busch - LSU

Sub-case 3: contains only contains and Similar to sub-case 2 Costas Busch - LSU

Case 5: overlaps and Similar to case 4 Costas Busch - LSU

Case 6: overlaps , and Impossible! Costas Busch - LSU

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