Is $\{a^n b^n c^{2n} \mid n \geqslant 0\}$ a context-free language?

224 Views Asked by At

I tried to solve this excersize but get two different answers

I know that we can do homomorphism $$ h(0)→a,h(1)→b,h(2)→cc $$ and $h^{-1}(L)$ = {$0^n 1^n 2^n | n \geqslant 0$ } that is not CFL

But, if we will do other homomorphism $$g(a)→0, g(b)→0, g(c)→1$$ so $g(L)= \{0^{2n} 1^{2n} \mid n \geqslant 0 \}$ is CFL.

What wrong with the second option?

Thanks

1

There are 1 best solutions below

0
On

There is nothing wrong with the second option except that you cannot conclude anything from it. To be precise, you are trying to use the fact that context-free languages are closed under homomorphisms and inverses of homomorphisms.

Your first argument goes as follows: if $L$ were context-free, then $h^{-1}(L)$ would also be context-free, which is not the case. Thus $L$ is not context-free.

Your second attempt is: if $L$ were context-free, then $g(L)$ would also be context-free. But since $g(L)$ is context-free, there is no contradiction and you cannot conclude that $L$ is not context-free.