# Pumping Lemma to show that a language is not Context Free [duplicate]

I am trying to use the Pumping Lemma to prove that the following language is not context free:

$$\{0^n\mid \text{n is prime}\}$$

I am having a really difficult time with Pumping Lemma. Up until now I was proving that a language is not regular using the Pumping lemma, but I am not sure how to begin to use the pumping lemma to prove that a language is not Contex-Free.

I appreciate any suggestions,

-

## marked as duplicate by arjafi♦, Davide Giraudo, Amzoti, rschwieb, Brian M. ScottMar 13 '13 at 15:06

Let $s = uvxyz$, then $|s| = |uvxyz| = |u|+|v|+|x|+|y|+|z|$ Now for any $n$ we have: $|uv^nxy^nz| = |u|+n*|v| + |x| + n*|y| + |z| = |u|+ |x|+|z| + n*(|v|+|y|)$
Setting $n = |u|+|x|+|z|$ gives us $$|u|+ |x|+|z| + (|u|+|x|+|z|)\cdot(|v|+|y|) = (|u|+|x|+|z|)\cdot(|v|+|y|+1)$$.
Now if we pick $s$ such that |s| is a prime number strictly larger than the pumping length, and such that $|uz| \geq 2$, we get that $|u|+|x|+|z| \geq 2$. furthermore, $|vy| \geq 1$ and thus $|v|+|y|+1 \geq 2$, which implies that $|uv^nxy^nz|$ is composite, and thus not prime.
With this sort of language pumping lemma for context free languages is no different from pumping lemma for regular languages. Simply take any bit of $0^n$ and repeat it $n+1$ times to make the resulting string of length divisible by $n$.