The Pumping Lemma for Regular Sets

Download Report

Transcript The Pumping Lemma for Regular Sets

3.2 Pumping Lemma for Regular Languages
Given a language L, how do we know whether it is regular or
not? If we can construct an FA to accept the language or a
regular expression denoting the language, then it is a regular.
But if we can not, we still can not make sure that it is not regular.
So, we have develop methods to show irregular languages.
We have already mentioned one method in section 3.1 to show
that a language L is not regular, if the number of equivalence
classes of the relation R L is infinite.
The second method we shall introduce is the pumping lemma for
regular languages.
If a language L is finite, then it is easy to figure out whether or
not a given string is in L. L is finite, it is sure that we can list
them all. So, L is a regular language.
Theorem 2: Let L be a finite language. Then L is regular.
Proof:
It is easy to construct an NFA as follows to accept the finite
set L={1,  2, …, n}.
q1

q0
1



2
q2
qn
n

p1
p2
pn


qf
Lemma 4(The pumping lemma): Let L be an infinite regular
language over an alphabet . Then there is a constant n such that
for each string  in L with | |  n,  can be written as  = xyz,
where |xy|  n and |y|  1, and for all k  0, xy kz  L.
Proof :
Since L is regular, by the Myhill-Nerode theorem there is a
minimal DFA M = (Q, , , q 0, F) accepting L. Let n be |Q|.
If  L and ||  n. Let  =a 1 a 2…a m, where m  n.
Let q i= ( q 0, a 1 a 2…a i), i = 1, 2, …, m.
Since there are only n states in Q and m  n, by the pigeon
hole theorem there are two states of q 0 , q 1 , q 2 , …, and q n
are same, say 0  i  j  n and q i = q j.
q i = ( q 0, a 1 a 2…a i) = ( q 0, a 1 a 2…a j) = q j.
We have that q i= ( q 0, a 1 a 2…a i) = ( q i, a (i+1) …a j).
Hence, q i= ( q i, a (i+1) …a j ) = ( q i, (a (i+1) …a j) k) , for all k  0.
Let x = a 1 a 2…a i, y = a (i+1) …a j, and z = a (i+1) …a m.
We have that ( q 0, xy k z) = ( q i, y k z) = ( q i, z)
= ( q 0, xyz)  F, for all k  0.
Therefore,  = xy k z, where |xy|  n and |y|  1, and xy k z  L,
for all k  0.
For a true statement ” x P(x)   n Q(n) ”, where P( ) and Q( ) are
two predicates, suppose that we want to show that for some y P(y) is
not true. We can first assume that P(y) were true. And show there is
an n such that Q(n) is false. That the predicate Q(n) is false leads to a
contradiction. Hence, P(y) is not true.
The pumping lemma says that
( L)( L is regular and |L| is infinite  (  n ) ( (   in L, |  |  n)
(  x, y and z, |xy|  n and |y|  1,  = xyz)(  i  0) (xy i z  L)))
Therefore, L is regular and |L| is infinite, we have that
“ n, ” such that “  in L, |  |  n,  x, y and z,  = xyz,
where |xy|  n and |y|  1, and xy i z  L, for all i  0.”
To show that a set L is not regular by contradiction, we first assume
that L were regular and  n in the pumping lemma. And show that
“  in L, |  |  n,  x, y and z,  = xyz, where |xy|  n and |y|  1,
 i  0 such that xy i z  L.”
Example 6: Let L={0 i1 i | i>0}. Show that L is not regular.
Solution :
Assume that L were regular. Let n be the constant in the pumping
lemma.
Choose = 0 n 1 n. We have that   L and | | > n.
Let = xyz, where |xy|  n and |y|  1.
Since |xy|  n and |y|  1, we have that x = 0 |x| and y = 0 |y|.
It is obvious that xy i z  L for i1, since the number of 0s is
not equal to that of 1s in the string xy i z. Contradict to the
assumption that L is regular.
Example 7: Let L be the regular expressions over an alphabet
={0, 1}. Show that L is not regular.
Solution :
Assume that L were regular. Let n be the constant in the pumping
lemma.
Choose = ( n 0*)*…)*). We have that   L and | | > n.
Let = xyz, where |xy|  n and |y|  1.
Since |xy|  n and |y|  1, we have that x = ( |x| and y = ( |y|.
It is obvious that xy i z  L for i1, since the number of the
left parentheses is not equal to that of right parentheses in the
string xy i z. Contradict to the assumption that L is regular.
Example 8: Let L = { in {0, 1}* | i = the number of 0’s in ,
and j = the number of 1’s in , i , j  1 and gcd(i, j)=1}. Show
that L is not regular.
Solution :
Assume that L were regular. Let n be the constant in the pumping
lemma.
Choose = 0 t 1 s, where s =2*3*5*…*p n, p n is the nth
prime number and t = p n+1. We have that   L and | | > n.
Let = xyz, where |xy|  n and |y|  1. Hence, x = 0 |x| and y = 0 |y|.
Consider the case that i = 0, xy i z = xz = 0 t - |y| 1 s.
Since t - |y| < p n+1, we have that gcd(t - |y| , s) > 1. Then
xz  L. Contradiction.