Here

advertisement
Name_____________________________ Answer on this sheet. Staple the pages
Here is a re-statement of the pumping lemma for context free languages. Make sure that you
understand the statement of the theorem before you try any problems. This time I will lead you
through the problems, hopefully with better luck
Pumping Lemma for Context Free languages
Let L be any context free language. Then there is a constant k, depending on L,
such that
if z is any word in L and |z| > k
then we can write
z = uvwxy such that
1. |vwx| < k
2. |vx| > 0 i.e. both v and x are not λ
3. uviwxiy is in L for i = 0,1,2,3…..
The pumping lemma cannot prove that a language is context free but it can show that a language
is NOT context free.
Look at the statement of the theorem again (or possibly for the first time!).
So, to show that a language is NOT context free all you have to do is produce one word in L of
length greater than or equal to k that does not satisfy the theorem. Usually this means you have
to come up with one word that gets "pumped out of the language."
One word is all that it takes.
OK …Let's go back to L = { aibici}. Intuitively, you can see that L is not context free because a
single stack would not be enough to recognize this language.
So we use the pumping lemma to show that this is not context free.
We need to find one word in L that does not satisfy the conclusions of the theorem..
Let
z = akbkck, where k is the constant of the theorem.
Notice that |z| = 3k > k so z satisfies the hypothesis of the theorem.
The theorem says that if L is context free then we know that z = akbkck can be written
z = uvwxy where
1. |vwx| < k
2. |vx| > 0 i.e. both v and x are not λ
3. uviwxiy is in L for i = 0,1,2,3…..
For example if k = 10, z = aaaaabbbbbccccc and z MIGHT look something like this
Notice that |vwx| = 9 < k and |vx| = 6 > 0.
0r perhaps z could be broken up as
To prove that L is NOT context free we will show that z cannot be pumped no matter how it is
factored or broken up into uvwxy. We need to show that for SOME i, any i,
uviwxiy is NOT in L.
We really don't know exactly what v and x look like but we can look at the possibilities one by one
and eliminate each one. We have to reason the best we can about the shape of v and x
1. v and x cannot contain a's, b's and c's. That is vx is made up of only two symbols Why?
You answer here. Hint: what do you know about |vwx|? How many a's b's c's are in z?
1. If vx consists of a's and b's what do you know about uv2wx2y? For example,
2. If vx consists of b's and c's. What can you say about uv2wx2y? For example
3. If vx consists of only one letter. What can you say about uv2wx2y? For example
With that in mind explain why is uv2wx2y is not in L.
By the way, why can it not be true that x or x contains two different letters. For example why can't
v = aaabb? or x = bcc?
What would uv3wx3y look like?
So to use the pumping lemma to show that a language L is not context free you must:
1. Come up with a word in L that satisfies s the hypotheses of the theorem
2. Show that the conclusion of the theorem does not hold for this word. To do that you
usually have to reason about the shape of v and x and usually show that uv iwxiy is not in
L…even for one value of i.
2. Problem:
Show L = {arbscrds} is not context free.
Again we need a word that satisfies the hypotheses of the theorem.
Let z = akbkckdk where k is the constant of the theorem
Then if L is context free:
z = uvwxy
where ( you fill in)
1___________________________________
2.__________________________________
3._________________________________
Now vx can contain at most (how many)_______ different symbols. Why?
The symbols must be consecutive for example a and b, or b and c, or c and d.
If vx is made up of a's and b's what is the problem?
If vx is made up of b's and c's what is the problem?
If vx is made up of c's and d's what is the problem?
Conclusion?
3. Problem: If L= { aibjck| 0 < i < j < k} use the pumping lemma to show that L is not context free.
First you need a word in the language that satisfies the hypotheses of the pumping lemma.
If k is the constant of the lemma try
z = akbkck
You know that if either v or x contains more than one type of symbol then uv2wx2y is not in the
language. Why?????
So v and x contains just one type of symbol. That means it is always the case that vx does NOT
contain one of the symbols.
Make cases: Hint: you may have to pump down in some cases.
1. a's do not appear in v or x. What is the problem
2. b's do not appear in v or x. What is the problem?
3. c's do not appear in v or x. What is the problem.
4. Problem:
L = {ss | w Є {a,b}* }.
We showed in class that this is not context free without the pumping lemma. Now use the
pumping lemma.
Again we need a word in the language that satisfies the hypotheses of the theorem. The obvious
choice is
z = akbkakbk where k is the constant of the theorem.
Then
z = uvwxy where
1.________________________________-
2.________________________________
3._________________________________
This one is a little trickier.
Look at a typical word:
If vwx occurs in the first half of the string, for example
What is the problem ? (Hint look at uv2wx2y)
If vwx occurs in the second half of the string, for example
What is the problem ? (Hint look at uv2wx2y)
So vxw must be part in the first half of z and part in the second half of z. For example
Now pump down. What is the problem?
5. Do problem 17 on page 220. Do not use the pumping lemma use the theorem in the chapter.
6
a.Prove that L1 = {ai b2i cj
} is context free. Hint: Find a CF Grammar
b. Prove that L2 = {aj bi c2i
} is context free. Hint: Find a CF Grammar
c. Describe ( using set notation) L1 ∩ L2 ? Use the pumping lemma to show that L1 ∩ L2 is not
context free.
Download