We have a language $$ L = \{\text{w element of } \{a,b\}^* \mid \#(a,w) = \#(b,w)^2 \} $$ where $ \#(a,w) $ means the number of letters $a$ in $w$
I would like to show that this language is not context-free.
Assume that L is context-free. Let p be the constant from Pumping Lemma.
$$ w = a^{p^2}b^p $$
Let uvxyz be the decomposition of w as in the lemma. Since $ \mid vxy \mid \le p $ we have to consider three cases:
- $v$ and $y$ contain only letters from block of $a$'s
In this case $s'=uv^2xy^2z$ should be the part of language L. But number of letters b in $s'$ is p and number of letters a is more then $p^2$. Contradiction $s' \notin L$. - Similar explenation when $v$ and $y$ contain only leters from block of $b$'s
-
$vxy$ contains letters $a$ and $b$
But how to show contradiction in this case?
In the 3rd case there exist constants $c_1, c_2>0$, such that
$$\#(a,uv^nxy^nz)\le c_1 n$$
but
$$\#(b,uv^nxy^nz)\ge c_2 n.$$
Then you have $c_1 n \ge (c_2 n)^2.$