Download presentation
Presentation is loading. Please wait.
Published bySavanah Cliburn Modified over 9 years ago
1
Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death
2
Parse Tree Describes derivation of a string from a CFG Examples: S→aSaa|B B→BB|b|ε S S S B BB aa aa b b S a for each a L S (S) | SS | S* | S+S S S S SS (a+b)*
3
Pumping Lemma for Context Free Languages If L is a CFL then there is some number p such that for any string s in L where |s|>p we can divide s into 5 substrings s=uvxyz in a way to satisfy all of the following: 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p
4
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Proof: Consider the CFG for L. The grammar has a finite number of production rules. If a string is long enough, some variable must have been reached twice. S R R uvxyz S R u x z S uz R vy R vxy R
5
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Example: Consider: If any of a,b,c are not part of vy then we definitely fail rule 1. Because of rule 3 if v contains the letter ‘a’ then y cannot contain the letter ‘b’
6
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Example:. Consider: If neither a,c or b,d are not part of vy then we definitely fail rule 1. Because of rule 3 if v contains the letter ‘a’ then y cannot contain the letter ‘c’ If v contains the letter ‘b’ then y cannot contain the letter ‘d’
7
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Example: Consider: If I modify the first set of ‘a’s then I must also modify the second set. If v contains one of the first set of ‘a’s then y cannot contain one of the second set due to rule 3. The case for the ‘b’s is similar.
8
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Example: Prove its not context free for extra credit! Triple extra credit if you show the following first: If |∑|=1 then for any language, if L is context free then L is also regular
9
Pumping Lemma for Context Free Languages Does EqLenCat Preserve Regularity? No, Let A=a*, B=b*, Does EqLenCat Preserve Context Freeness? No, Let,. Then If A,B are regular, is EqLenCat Context Free? Yes, by construction of PDA. Idea: Build a PDA which simulate the FSA for A, where it pushes a character onto the stack for each input. It then non- deterministically switches to the FSA for B, where it pops from the stack for each input. Accept if in accept state of B with empty stack
10
Pumping Lemma for Context Free Languages If A,B are regular, is EqLenCat Context Free? Modified Concatenation Construction: a a a stack AB ε ε Push ‘a’ on each transition Pop ‘a’ on each transition
11
Pumping Lemma for Context Free Languages Does YesNo Preserve Regularity? Yes, Does YesNo Preserve Context Freeness? No. Idea: show that for an arbitrary context free language L, YesNo(L) is context free iff its complement is context free
12
Pumping Lemma for Context Free Languages Does YesNo Preserve Context Freeness? Consider a CFL language L whose complement is not context free. We will assume that L contains ε. We will also assume that ‘$’ is not a character in Σ. Let Since So if YesNo preserves context-freeness then L complement must be context free
13
Here Be an extra slide
14
Pumping Lemma for Context Free Languages 1.For each i≥0, 2.|vy|>0 3.|vxy|≤p Proof: Consider the CFG for L. The grammar has a finite number of production rules. If a string is long enough, some rule must have been applied twice. S R R uvxyz S R u x z S R R uvxyz R vy
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.