The Pumping Lemma for CFL’s

Slides:



Advertisements
Similar presentations
The Pumping Lemma for CFL’s
Advertisements

CS 3240: Languages and Computation Properties of Context-Free Languages.
1 Introduction to Computability Theory Lecture7: The Pumping Lemma for Context Free Languages Prof. Amos Israeli.
1 Module 33 Non-context free languages –Intuition and Examples CFL Pumping Lemma –Comparison to regular language pumping lemma –What it means –Proof overview.
127 The Chomsky Hierarchy(review) Recursively Enumerable Sets Turing Machines Post System Markov Algorithms,  -recursive Functions Regular Expression.
The Pumping Lemma for CFL’s
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.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
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.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
1 Non-regular languages. 2 Regular languages Non-regular languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
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 L= { w c w R : w  {a, b}* } is accepted by the PDA below. Use a construction like the one for intersection for regular languages to design a PDA that.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
Context Free Pumping Lemma. CFL Pumping Lemma A CFL pump consists of two non-overlapping substrings that can be pumped simultaneously while staying in.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
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,
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Limitations.
 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:
Context-Free Languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Properties of Context-Free Languages
Lecture 15 Pumping Lemma.
7. Properties of Context-Free Languages
Lecture 22 Pumping Lemma for Context Free Languages
Non-Context-Free Languages Sections: 2.3 page 123 October 17, 2008
Lecture 14 Grammars – Parse Trees– Normal Forms
Jaya Krishna, M.Tech, Assistant Professor
More on Context Free Grammars
Context Free Pumping Lemma Some languages are not context free!
Relationship to Left- and Rightmost Derivations
Infiniteness Test The Pumping Lemma Nonregular Languages
Chapter Fourteen: The Context-Free Frontier
Definition: Let G = (V, T, P, S) be a CFL
7. Properties of Context-Free Languages
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Properties of Context-Free Languages
Department of Computer Science & Engineering
The Pumping Lemma for CFL’s
Bottom-up parsing Pumping Theorem for CFLs
Cpt S 317: Spring 2009 Sampath Kumar S, AP/CSE, SECE
CS21 Decidability and Tractability
More Applications of the Pumping Lemma
COSC 3340: Introduction to Theory of Computation
Chapter 2 Context-Free Language - 02
CS21 Decidability and Tractability
Limitations of pushdown automata
The Pumping Lemma for CFL’s
Applications of Regular Closure
The Pumping Lemma for CFL’s
Limitations of context-free languages
Intro to Theory of Computation
Presentation transcript:

The Pumping Lemma for CFL’s Statement Applications

Intuition Recall the pumping lemma for regular languages. It told us that if there was a string long enough to cause a cycle in the DFA for the language, then we could “pump” the cycle and discover an infinite sequence of strings that had to be in the language.

Intuition – (2) For CFL’s the situation is a little more complicated. We can always find two pieces of any sufficiently long string to “pump” in tandem. That is: if we repeat each of the two pieces the same number of times, we get another string in the language.

Statement of the CFL Pumping Lemma For every context-free language L There is an integer n, such that For every string z in L of length > n There exists z = uvwxy such that: |vwx| < n. |vx| > 0. For all i > 0, uviwxiy is in L.

Proof of the Pumping Lemma Start with a CNF grammar for L – {ε}. Let the grammar have m variables. Pick n = 2m. Let |z| > n. We claim (“Lemma 1 ”) that a parse tree with yield z must have a path of length m+2 or more.

Proof of Lemma 1 If all paths in the parse tree of a CNF grammar are of length < m+1, then the longest yield has length 2m-1, as in: m variables one terminal 2m-1 terminals

Back to the Proof of the Pumping Lemma Now we know that the parse tree for z has a path with at least m+1 variables. Consider some longest path. There are only m different variables, so among the lowest m+1 we can find two nodes with the same label, say A. The parse tree thus looks like:

Parse Tree in the Pumping-Lemma Proof v y x w Can’t both be ε. < 2m = n because a longest path chosen

Pump Zero Times u y u y A w A v x A w

Pump Twice u y u y A v x A v x A v x A w A w

Pump Thrice Etc., Etc. u y u y A v x A v x A v x A w A v x A w

Using the Pumping Lemma Non-CFL’s typically involve trying to match two pairs of counts or match two strings. Example: The text uses the pumping lemma to show that {ww | w in (0+1)*} is not a CFL.

Using the Pumping Lemma – (2) {0i10i | i > 1} is a CFL. We can match one pair of counts. But L = {0i10i10i | i > 1} is not. We can’t match two pairs, or three counts as a group. Proof using the pumping lemma. Suppose L were a CFL. Let n be L’s pumping-lemma constant.

Using the Pumping Lemma – (3) Consider z = 0n10n10n. We can write z = uvwxy, where |vwx| < n, and |vx| > 1. Case 1: vx has no 0’s. Then at least one of them is a 1, and uwy has at most one 1, which no string in L does.

Using the Pumping Lemma – (4) Still considering z = 0n10n10n. Case 2: vx has at least one 0. vwx is too short (length < n) to extend to all three blocks of 0’s in 0n10n10n. Thus, uwy has at least one block of n 0’s, and at least one block with fewer than n 0’s. Thus, uwy is not in L.