Context free grammar L={$a^{m}$ $b^{n}$ $c^{k}$| n,m,k >= 0, n>= m+k}

468 Views Asked by At

Write a context free grammar for the following:

$$L=\{a^{m}b^{n}c^{k}\mid n,m,k \ge 0, n\ge m+k\}$$

I am having some trouble writing the above cfg from the language. So far I have:

$$\begin{align*} S&\to S_1S_2S_3\\ S_1&\to aS_1b\\ S_1&\to \lambda\\ S_2&\to bS_2\\ S_2&\to \lambda\\ S_3&\to bS_3c\\ S_3&\to \lambda \end{align*}$$

Am I oversimplifying this question or is it straight forward?