pumping lemma for context free languages
the pumping lemma for context-free languages
isnt regular, doesnt pertain the pumping lemma
recognized by cfg

recognized by
pertains the pumping lemma, but isnt regular (prove it)
if
is a context-free language, then there is a number
(the pumping length) where, if
is any string in
of length at least
, then
may be divided into five pieces (strings)
satisfying the conditions
is being divided into
, condition 2 says that either
or
is not the empty string. otherwise the theorem would be trivially true. condition 3 states that the pieces
,
, and
together have length at most
. this technical condition sometimes is useful in proving that certain languages are not context free.
[cite:;from @sipser_comp_2012 theorem 2.34]
- for each
,
-
, and
-
.
[cite:;from @sipser_comp_2012 theorem 2.34]
use the pumping lemma to show that the language
is not context free.
we assume that
is a CFL and obtain a contradiction. let
be the pumping length for
that is guaranteed to exist by the pumping lemma. select the string
. clearly
is a member of
and of length at least
. the pumping lemma states that
can be pumped, but we show that it cannot. in other words, we show that no matter how we divide
into
, one of the three conditions of the lemma is violated. first, condition 2 stipulates that either
or
is nonempty. then we consider one of two cases, depending on whether substrings
and
contain more than one type of alphabet symbol.
is a CFL must be false.
thus we have proved that B is not a CFL.
[cite:;from @sipser_comp_2012 example 2.36]
we assume that
- when both
and
contain only one type of alphabet symbol,
does not contain both
’s and
’s or both
’s and
’s, and the same holds for
. in this case, the string
cannot contain equal numbers of
's,
's, and
's. therefore, it cannot be a member of
. that violates condition 1 of the lemma and is thus a contradiction.
- when either
or
contains more than one type of symbol,
may contain equal numbers of the three alphabet symbols but not in the correct order. hence it cannot be a member of
and a contradiction occurs.
thus we have proved that B is not a CFL.
[cite:;from @sipser_comp_2012 example 2.36]
let
. use the pumping lemma to show that
is not a cfl. assume that
is a cfl and obtain a contradiction. let
be the pumping length given by the pumping lemma.
this time choosing string
is less obvious. one possibility is the string
. it is a member of
and has length greater than
, so it appears to be a good candidate. but this string can be pumped by dividing it as follows, so it is not adequate for our purposes.
let's try another candidate for
. intuitively, the string
seems to capture more of the "essence" of the language
than the previous candidate did. in fact, we can show that this string does work, as follows.
we show that the string
cannot be pumped. this time we use condition 3 of the pumping lemma to restrict the way that
can be divided. it says that we can pump
by dividing
, where
.
first, we show that the substring
must straddle the midpoint of
. otherwise, if the substring occurs only in the first half of
, pumping
up to
moves a 1 into the first position of the second half, and so it cannot be of the form
. similarly, if
occurs in the second half of
, pumping
up to
moves a 0 into the last position of the first half, and so it cannot be of the form
.
but if the substring
straddles the midpoint of
, when we try to pump
down to
it has the form
, where
and
cannot both be
. this string is not of the form
. thus
cannot be pumped, and
is not a CFL.
[cite:;taken from @sipser_comp_2012 example 1.75]
this time choosing string
we show that the string
first, we show that the substring
but if the substring
[cite:;taken from @sipser_comp_2012 example 1.75]
where is
, defined by
in the ladder of language hierarchy?
does pertain the pumping property, but it isnt regular, try to find
equivalence relations.
it is recognized by the following grammar:

it is recognized by the following grammar:
recognized by cfg
if we consider
where
is the pumping length provided by the pumping lemma, and then consider the cases where 1. we try to pump with a string of
's and
's on the left side, we'd notice that we'd get a string that isnt formed of the proper lumps of the form
, 2. we try to pump on the left side before with a string of
's, we wouldnt be able to have any
's to pump with on the right side to keep lengths equal, because of the third condition of the pumping lemma,
, here we have
as
, so
cannot contain any symbols, 3. try to pump with only
's, we'd be violating the condition
after pumping repeatedly. this way we'd be showing that each case leads to a contradiction.