So, I have an exercise in which I have to write a context free grammar for this language:

$ $ L = \{x \in L(a^∗b^∗c^∗) : |x|_a > |x|_c; |x|_b > 0; |x|_c ≥ 0\}$ $

meaning every string with any number of $ a$ ‘s, $ b$ ‘s and $ c$ ‘s in that order, with the amount of $ a$ ‘s greater than the amount of $ c$ ‘s and the amount of $ b$ ‘s greater than zero.

I am having trouble figuring out the rule that makes sure there are more $ a$ s than $ c$ s.

I have: $ $ \begin{align}S&\to aABC | ab\ A&\to aA | a\ B&\to bB | b\ C&\to cC | c\ \end{align}$ $ I know this is wrong because I should be adding an $ a$ every time I add a $ c$ , but I don’t know how to write that.