[Math] Subtracting a context-free language from a regular language

context-free-grammarformal-languages

I have the language
$L=\{a, bb\}^*-\{a^ib^i|i\geq1\}$ and I have to show that $L$ is context-free.

The first language is Regular, if I'm not mistaken, and the second is a well known context-free language.

I guess I have to prove the hypothesis using the closure properties (a regular language intersected with a context-free is a context-free) but I don't know where to start.

Best Answer

Hint. Your guess is right, but there is still some work to do. Your language is the intersection of the regular language $\{a,bb\}^*$ and of the complement $C$ of the language $\{a^nb^n \mid n > 0\}$. You probably know that the intersection of a regular language with a context-free language is context-free. The problem is now to prove that $C$ is context-free, since in general, the complement of a context-free language is not context-free.

See the question How to create a grammar for complement of $a^nb^n$? if you don't find the solution yourself.