Creating the production for a CFG

199 Views Asked by At

I have to create the productions for a CFG that follows

$$\{a^ib^jc^k : j = i + k\}$$

I can get close to the answer. I found

$$\begin{align*} &A\to aAb \mid B\\ &B\to bBc \mid \epsilon \end{align*}$$

but that allows c's in the wrong place. I need help creating the productions.

1

There are 1 best solutions below

1
On BEST ANSWER

the language L may be rewritten as $\{ a^ib^îb^kc^k \}$ - now it should be easier to come up with a grammar:

$ S \to AB \\ A \to aAb \,|\, \epsilon \\ B \to bBc \,|\, \epsilon $