# Pumping Lemma - Clarification of Usage

I'd like to make sure my understanding of the Pumping Lemma is correct.
Consider $L=\{ 0^n1^m2^{n-m}:\, n \ge m \ge 0\}$

I'm going to give 2 solutions to prove that $L$ is not regular. One using "pumping down" and the other using a "cheap trick". I'm not sure whether either solution is correct, so any comments would help clarify my understanding.

Solution 1: Pumping Down
Let p be the pumping length. Let $S= 0^{p+1}1^p2 = xy^iz$ for $i \ge 0$
Now, $|xy| \le p$ implies $y$ contains only $0's$
So, for $i=0,$ $S=xy^0z=xz$ and since $xy$ had only one more $0$ than the number of $1's, \, x$ will not have more 0's than the number of 1's. Hence, $S \notin L$ giving the required contradiction.

Solution 2: Cheap Trick
As before, let p be the pumping length. But this time, $S= 0^p1^p2^0 = 0^p1^p$ which is generally the example proven in most textbooks. However, I'm not sure this is a valid approach, so some clarification would be helpful.

## 1 Answer

Here is a very careful application of the pumping lemma for regular languages, showing all of the relevant details. It uses pumping down with your second choice of word to be pumped.

Suppose that $L$ is regular; then it has a pumping length $p$. Let $w=0^p1^p2^0$; the pumping lemma for regular languages says that we can decompose $w$ as $w=xyz$, where $|xy|\le p$, $|y|\ge 1$, and $xy^kz\in L$ for each $k\ge 0$. Clearly $xy$ is contained in the initial $0^p$ of $w$, so there are $r\ge 0$ and $s>0$ such that $x=0^r$ and $y=0^s$, and therefore $z=0^{p-r-s}1^p$. Then

$$xy^0z=xz=0^r0^{p-r-s}1^p=0^{p-s}1^p\in L\;,$$

but $p-s<p$, so $xy^0z\notin L$. This contradiction shows that $L$ is not regular after all.

• so we can choose the pumping length as well as the word? That was what I was trying to figure out. – EggHead Nov 18 '13 at 3:00
• @EggHead: No, you can never choose the pumping length: you just know that if the language is regular, there is one. I didn’t choose one here: the only thing that I chose was the word $w$, which I chose based on the supposed pumping length (which in fact doesn’t exist, since $L$ isn’t regular). – Brian M. Scott Nov 18 '13 at 3:03
• thanks, for the clarification. I didn't mean choosing a specific pumping length. I meant the pumping length did not have to be the same length as w which is 2p. I also realized that the first solution did not work, since after pumping down, x could still have the same number of 0's as z. – EggHead Nov 18 '13 at 17:10
• @EggHead: Ah, okay. Yes, as long as $|w|\ge p$, $w$ can be as long as you need to make the proof work. – Brian M. Scott Nov 18 '13 at 17:11