For the following language, write grammar independent of the text.

$$\{a^i b^j: j < 2i \text{ and } j \ne i \} $$

I want a hint to start solving this problem. Where should I start?


If $j \neq i$ then either $j < i$ or $j > i$. Hence you can write your language as $$ \{ a^i b^j : j < i \} \cup \{ a^i b^j : i < j < 2i \}. $$ It suffices to find a grammar for each of these two languages. Such questions have been asked and answered on this site.

  • $\begingroup$ This site isn’t for doing your homework for you. $\endgroup$ – Yuval Filmus Apr 20 at 14:18
  • $\begingroup$ You are right :) $\endgroup$ – hermi Apr 20 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.