Grammar for $L=\{a^{i+1}b^{i}c^{2j}d^je^{2j}|i,j>0\}$ I'm supposed to write grammar for this language: $$L=\{a^{i+1}b^{i}c^{2j}d^je^{2j}\mid i,j&gt;0\}$$
This is what I have so far:
$$\begin{align}
S &amp;\to aXbY \; \\
X &amp;\to aXb \;|\; a \\
Y &amp;\to ccYdE \;|\; ccdE \\
Ed &amp;\to dE \; \\
dE &amp;\to dee \; \\
eE &amp;\to eee \; \\
\end{align}$$
Edit:
Thank you for answers, I looked at the https://en.wikipedia.org/wiki/Noncontracting_grammar#Example and edited my grammar:
Is this correct? Is it necessary to do
$$\begin{align}
Ed &amp;\to dE \; \\
dE &amp;\to dee \; \\
eE &amp;\to eee \; \\
\end{align}$$
or can I just do
$$\begin{align}
Ed &amp;\to dee \; \\
E &amp;\to ee \; \\
\end{align}$$
Your answer is correct.
The alternative with $E\to ee$ is incorrect, as it might generate 'ee' in between 'd's. You must first shift all the E's to the end and only then make them into $ee$.
I would generate $cc$ and $ee$ together, and play with the $D$'s, i.e., $Y\to cc YD ee$, etc. This will be slightly more simple, though equivalent.