I'm learning about Context Free Grammars, and I've been understanding them so far, but this problem is kind of making my head spin.
I have the following rules:
S --> aSb | bB | epsilon
B --> bbB | bB | epsilon
And I'm almost certain that they are incorrect. I understand how I would do just i <= j instead of the actual language, but the idea of doing j <= 3i is really hard to grasp for me and I don't really understand how I should represent that in a CFG.
I've read some questions and threads on here about designing CFG, but they didn't really help me with a strategy to determine the answer.
Thanks in advance for your help!
For any a
in a string you have to have 1, 2, or 3 b
s in the string.
The b
s have to follow the a
s.
You can have zero a
s.
S = A S B | e
A = a
B = b | bb | bbb
Zero a
s implies no b
s.
One a
allows for 1, 2, or 3 b
s.
Through recursion through S
you can have any number of a
s.