Lecture 07

Pumping Lemma for CFLs

Lemma If $$L$$ is a CFL, then there is $$p>0$$ (pumping length) such that every string $$s\in L$$ of length $$|s|\geq p$$ can be decomposed as $$s=uvxyz$$ where

1. $$\forall i\geq 0$$, $$uv^ixy^iz\in L$$
2. $$|v|+|y|>0$$ (and $$|x|>0$$ and $$|u|+|z|>0$$).
3. $$|vxy|\leq p$$

Proof Let $$G$$ be a grammar that generates $$L$$ and is in Chomsky Normal form. Let $$m$$ be the number of variables in $$G$$.

Prop If $$G$$ is in Chomsky Normal form, any parse tree that generates a string of length $$l\geq 2^d+1$$ must have depth $$>d$$.

Let $$p=2^{m+1}$$, for any $$s\in L$$ of length $$|s|\geq p$$, then parse tree that generate $$s$$ has depth $$>m$$. So there is a path from the root to a terminal symbol in $$s$$ that has length $$\geq m+1$$ in the parse tree. By pigeonhole principle, one variable appears at least twice in this path.

S
/ \
/ R \
/ / \ \
/ / R \ \
/ / / \ \ \
|u|v| x |y|z|

S
/ \
/ R \
/ / \ \
/ / R \ \
/ / / \ \ \
|u|v| R |y|z|
/ \
|vxy|

The parse tree tells that there is a derivation

1. $$S\rightarrow uRz$$
2. $$R\rightarrow vRy$$
3. $$R\rightarrow x$$

Following the derivation $$1$$, then derivation $$2$$, and derivation $$3$$, we obtain the string $$uv^ixy^iz\in L$$.

The rule applied at the top $$R$$ must be $$R\rightarrow AB$$ for some variables $$A,B$$. The variable does not generate the lower $$R$$ must generate a string of length $$\geq 1$$ as $$v$$ or $$y$$.

By pigeonhole, we can find repeated variable in a path where the substrr from the top variable has depth $$\leq m+1$$, so the string $$vxy$$ generated by the substree has length $$\leq 2^{m+1}$$.

Using the Pumping Lemma

Ex. Show that $$L=\{0^n1^n2^n:\geq 0\}$$ is not context-free.

Proof Fix any $$p>0$$, choose $$0^p1^p2^p$$.

If $$L$$ is context-free, $$\exists u,v,x,y,z$$ such that $$s=uvxyz$$ and $$|vxy|\leq p$$. The string $$vxy$$ cannot contain all $$0,1,2$$, and $$vy$$ must contain some characters, so $$uv^2xy^2z$$ cannot have same number of $$0,1,2$$ so $$uv^2xy^2z\not\in L$$

Language Hierarchy Theorem $$I$$

Finite Languages $$\subset$$ Regular Languages $$\subset$$ Context-free Languages

Glimpse Beyond

PDA $$\neq$$ Deterministic PDA (book 2.4).

$$L_1=\{w\#w^R:w\in\{0,1\}^*\}$$, $$L_1\in DPDA$$ $$L_2=\{ww^R:w\in\{0,1\}^*\}$$, $$L_2\not\in DPDA$$

Quote "Every complex problem has solution that is simple, elegant, and wrong" -- whoever