Вы находитесь на странице: 1из 7

Pumping Lemma

Let L be a regular language. There is


an integer n 1 such that any string
w L with |w| n can be rewritten
as w = xyz such that y e, |xy| n,
and xyiz L for each i 0.

The pumping lemma asserts the


existence of certain points in strings
where a substring can be repeatedly
inserted without affecting the
acceptability of the string.
b

a,b a,b a,b a


a,b

Regular language for this FSA:

(a | b)((a | b)(a | b)b)*(a | b) (a | b) a(a | b)*


Take any string in the language with length n 5
(number of states in the FSA)
w = ababababb
x=a
y = bab
z = ababb
After “pumping” i = 4 times:
w = abababab(babbabbabbab)abbabb
What we do when repeating the string y is
entering the loop ((a | b)(a | b)b)*

Can you give different x, y and z so that the


condition is still fulfilled?
BUT…
We usually use the pumping lemma to prove
that a language is NOT regular.

To do so we have to prove that given a


string w, of length greater than n, every
possible combination xyz with y e, |xy|
n, makes xyiz L for any i 0.
EXAMPLE 1

The language L = {0k1k : k 0} is not


regular.

Let’s suppose that L is regular. If we choose


|w| = 0n1n…
xyiz = (xy) yi-1z
= 0k(0j)i-10n-k1n
= 0n + j(i-1)1n

This string is clearly not in L, since it has


more 0’s than ones when i > 1. We have
reached a contradiction and therefore L is
not regular.

TIP: When pumping choose i > 1 if you


want one part of the string to increase
and i = 0 if you want it to decrease.
EXAMPLE 2

The language L = { x : x {0, 1}* and


# 0s = # 1s} is not regular.

Assume the language is regular. We can


choose w to be 0n1n as in the previous
example. Then,

x = 0n-j-k
y = 0j for some j > 0
z = 0k1n

The pumping lemma says we can take any i


0, so if we make i = 0,

xyiz = xy0z
= 0n-j1n

This string is not in the language L, since it


has more 0’s than ones when j > 0. We
have reached a contradiction and therefore L
is not regular.
EXAMPLE 3

The language of even length


palindromes L = {wwR : w {a,b}*} is
not regular.

Let’s assume L is regular. It is very


important to pick an appropriate initial string.
In this case, if we choose w = anbban …

x = an-j-k
y = aj for j > 0
z = akbban

xyiz = xy0z
= an-j-k (aj)0akbban
= an-jbban

It is not hard to see that xy0z is not a


palindrome, since it has at least one more a
at the end of the string than at the
beginning when j > 0.
Could you make this same example
“pumping” up instead of down?

Yes, we could have also tried this approach:

x = an-j-k
y = aj for j > 0
z = akbban

xyiz = an-j-k(aj)i akbban


= an-j-k ajiakbban
= an+j(i-1)bban

Which is not a palindrome either since if i >


1 there are more a’s at the beginning than at
the end of the string.

TIP: Always make sure that |w| n and that


|xy| n with y e for the given n.

Вам также может понравиться