# CFG for this language $\{a^k b^m c^n \mid 1 \leq k, m, n, n \leq 2k\}$ [duplicate]

I'm kinda new in this topic and I don't know how to figure out the rules to make a CFG out of this language, if anyone could give me an idea or hint so I can try to solve it knowing that, I would be very thankful.

Thank you for yout time.

• Please don't re-post questions. You posted this question this question previously: cs.stackexchange.com/q/124126/755. It was closed as a dup, and you deleted it and re-posted it. That's discouraged here. – D.W. Apr 15 '20 at 5:15

## 1 Answer

Ignore $$b^m$$ at first. Once you have the rest figured out, adding it in will be easy.

Try to build a CFG for $$a^k c^k$$. This is a classic CFG problem, so you've probably seen it in class.

Then, try to modify your CFG to generate $$a^k c^{2k}$$. This is a relatively small change.

Now, modify this new CFG to generate $$a^k c^n \mid n \leq 2k$$. You should only need to add new production rules, without deleting or modifying your existing ones.

Finally, add in the $$b^m$$. This part should be a trivial change.

Good luck! I hope this helps!