How to use the Pumping Lemma How do we develop the hunch

advertisement
How to use the Pumping Lemma
This is a detailed description of how we apply the Pumping Lemma to decide that a language is not regular.
Let’s say that we have the hunch that a language such as L = {aj bk ci : j = i + k} is not regular.
How do we develop the hunch?
As it’s usually said in these cases, experience and practice is very important to decide, at first sight, whether
a language is regular or not. As a general rule, regular languages can’t deal with comparisons (whereas
CFL’s can deal with one comparison) involving different entities/qualities/properties. I know this is hard to
understand, but it’s harder to explain. Let’s try to make it clearer with some examples:
• L = {an bn } First, we see that there’s one comparison (it’s implicit), since this language can be written
in the following way: L = {aj bi : j = i}. Now, are we checking two different ”qualities”? Yes, we are.
On one hand, we are ”working” with a’s, and the other, with b’s.
• L = {an an } This is very similar to the previous one. So, we can express the language this way:
L = {aj ai : j = i}. Now, we have again one comparison. But, do we have two qualities? At first sight
it seems we are not, since we are only checking a’s. So this language should be regular. If we think
about it, what it’s saying is that we should have an even number of a’s (so, number of a’s equal to
even).
• Strings with even number of a’s and b’s. This is regular. We have two qualities/properties to check
(even a’s and even b’s), but they are not related each other, so no problem.
Applying the pumping lemma
Let’s take a look to our language. On one hand, we have number of a’s (one property), and on the other,
number of b’s and c’s (one different from the other). We are comparing both of them, so it looks like the
language shouldn’t be regular.
To prove it, we can use the pumping lemma. It’s not that this pumping lemma decides whether a
language is regular or not. What we know is that if a language is regular, then it fulfills the pumping lemma.
Therefore, if we can prove that this language doesn’t fulfill the pumping lemma, it means that the language
is not regular. (this proof is normal and doesn’t use any advanced trick).
So, first of all, we have to choose an arbitrary number. We can’t work with finite sets, since the pumping
lemma only applies to infinite sets. So, we choose an arbitrary number and work with ALL the strings that
are larger or equal to this number.
Let m be this arbitrary number. The next step consists in choosing a string w, w ∈ L, whose length is
larger or equal than m. In our case, we could’ve chosen w = am bm , since its length is larger than m. But
maybe we don’t see that. So let’s go for a normal and simple reasoning.
We can choose w = am/2 bm/4 cm/4 , since it has length equal to m. This is a bit complicated, so I’ll solve
it in next section, just to show that it’s possible to deal with any case. Since we can choose any string whose
length is larger than m. Thus, we choose w = a2m bm cm .
We have already the string. Now, it comes the part we should pay more attention to. We have to generate ALL possible decompositions of this string w=xyz, such that (AND THIS IS VERY IMPORTANT!!!)
|xy| < m and |y| ≥ 1 (this comes from the pumping lemma).
Let’s do it. We have w = a2m bm cm . Since |xy| < m, z should have some a’s. Following the same
arguments, x and y can only have a’s. Thus, x = ak and y = aj , where j ≥ 1 since |y| ≥ 1 (i.e we have at
least one a). Having these x and y, z = a(2m−k−j) bm cm .
Now, we’ve done all the difficult stuff. It’s only a question of pumping y, obtaining w 0 = xy i z =
k ji 2m−k−j m m
a a a
b c = a2m−j(i−1) bm . If we choose i=0, w 0 = a(2m−j) bm cm . Since j ≥ 1, 2m − j < 2m, and
this w’ doesn’t belong to the language. Thus, the pumping lemma doesn’t hold and the language L can’t be
regular.
1
Another String
Imagine that we want to make things really complicated (or we don’t know how to make them easy) and we
want to choose another string (at most, the whole thing will be more cumbersome and tiresome, but it’s not
more difficult). This could be w = am/2 bm/4 cm/4 .
At the moment of making the decomposition, we know that |xy| < m and |y| ≥ 1 (from the pumping
lemma). Since |w| = m, now x and y may have b’s and c’s. So, at the moment of considering all possible
decompositions, we should take this into account. Which are the possibilities?
• x and y have neither b’s nor c’s: x = ak , y = aj and z = a(m/2−k−j) bm/4 cm/4 .
• y has some b’s: x = ak , y = am/2−k bj and z = bm/4−j cm/4 .
• x has some b’s: x = am/2 bk , y = bj and z = bm/4−k−j cm/4 .
• y has only c’s: x = am/2 bm/4 ck , y = cj and z = cm/4−j−k .
• y has b’s and c’s: x = am/2 bk , y = bm/4−k cj and z = cm/4−j .
• y has a’s, b’s and c’s: x = ak , y = am/2−k bm/4 cj and z = cm/4−j .
Now, we have to pump all possible cases, and check that the new string w’ falls out in all of them.
As you can see, choosing a nice string makes the proof very easy.
Another String for an bn
In the lectures you have a fully described method to study the regularity of the language L = {a n bn }.
Now, just think what would change if we take a string like w = am/2 bm/2 .
At the moment of making the decomposition, we know that |xy| < m and |y| ≥ 1. Since |w| = m, now x
and y may have b’s. So, at the moment of considering all possible decompositions, we should take this into
account. Which are the possibilities?
• x and y have no b’s: x = ak , y = aj and z = a(m−k−j) bm .
• y has some b’s: x = ak , y = am−k bj and z = bm−j .
• y has only b’s: x = am bk , y = bj and z = bm−k−j .
Instead of working only with one, now we have three.
2
Download