Pumping lemma: if you pump to $uv^0wx^0y$, wouldn’t $|vx| \ngeq 1$

context-free-grammarformal-grammarpumping-lemma

For pumping lemma for CFLs, for strings $s$ in $L$, they follow the form $s = uvwxy$ and $|vwx| \leq n$, $|vx| \geq 1$, and $uv^iwx^iy \in L$ for $i \geq 0$.

If I want to prove a language is not CFL, could I not just pump to $uv^0wx^0p$ which would imply $|vx| \ngeq 1$, breaking a rule of PL?

Best Answer

  • The pumping lemma for CFLs says, very roughly, that all sufficiently long strings in a context-free language can be pumped, and when pumped, the resulting strings will always belong to that language.

  • In symbols, for every long string in a CFL, there's a way to decompose it into the form $\mathsf{uvwxy}$ with certain constraints on what $\mathsf{u,v,w,x,y}$ are, such that $\mathsf{uv}^k\mathsf{wx}^k\mathsf{y}$ is always part of the language for any $k\geq 0$.

  • To prove that a language is not CFL, you generally argue "Suppose this language is context-free such that strings longer than $N$ are sufficiently long. Here I've made a carefully-constructed string longer than $N$. This means it can be decomposed into the appropriate form, obeying all the constraints. But look—no matter how it is decomposed, I can pump it to produce a string not in the language. This is a contradiction, so the language is not actually context-free."

  • Your argument says, roughly "What if I decompose the string into the required form $\mathsf{uvwxy}$ then pump it down so that the resulting string doesn't have that pumpable form (because it's become too short)?" But that's not actually a problem—sometimes if you pump down a sufficiently long string, you'll get a string that is too short to be pumpable.

    The argument should be "What if I decompose the string into the required form $\mathsf{uvwxy}$ then pump it down so that it isn't in the language anymore?" To use the pumping lemma, the evidence you're looking for is whether your starting string (in the correct form) can be pumped to produce strings that aren't in the language.


Consider the language $\{\mathtt{a}\mathtt{b}^n\mathtt{c}^n\mathtt{a} : n \geq 0\}$. It's context-free. Still, you can take a string like $\mathtt{a}\mathtt{b}^N\mathtt{c}^N\mathtt{a}$ (which is pumpable) and pump it down to make a string like $\mathtt{a}\mathtt{a}$ which isn't pumpable—you can't find a pumpable decomposition where $|\mathsf{vx}|\geq 1$. Still, the language is context-free—turning a pumpable string into a string that is too short to pump doesn't prove anything about being context-free.