0

So I have a question:

Give a CFG for $a^i b^j : 2i < j$.

And this is my approach:

$$S \to AB$$ $$A \to aAb | e$$ $$B \to b | bB$$

Thanks, a confirmation, or correction, along with how you tested (and tips for testing future problems of mine) will be greatly appreciated. Thanks.

TMM
  • 9,976
Gaak
  • 221

1 Answers1

1

The grammar above accepts $abb$ which doesn't satisfy the requirements.

If you work through a few examples, the pattern will become clear. The above accepts the language $a^i b^j$ where $i < j$. This might give a hint for an easy repair to the above grammar.

If not:

$$A \to aAbb | \epsilon$$

copper.hat
  • 172,524