2

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.

3SAT
  • 7,627
Crysis85
  • 243

1 Answers1

0

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.

J.-E. Pin
  • 42,871
  • I discarted the idea of finding the complement of the context-free language (since it's not closed), didn't think about finding the complement "by hand" and proving it's context-free too! Thanks – Crysis85 Feb 13 '16 at 19:03
  • You're welcome. – J.-E. Pin Feb 13 '16 at 19:17
  • I just thought that the language $a^nb^n$ is deterministic context free and the DCF class of languages is closed under complement. So there is no need to build the complement grammar to show that it's context free. – Crysis85 Feb 15 '16 at 18:28
  • If you know about deterministic context free languages, yes, it is the shortest way. – J.-E. Pin Feb 15 '16 at 18:48