Suppose $$L=\{1^i0^j1^k\mid i+2j=k\}$$
How can I construct a context-free grammar for $L$?
This is homework. Here is my attempt for the case when $L$ is defined with $i+2j=3k$ instead.
\begin{align*} S&\to aaaSc| bbbBcc| abBc| aabBc|\lambda\\ B&\to bbbBcc| \lambda \end{align*}
But it's not true because it accepts the string $s=a^2b^4c^3 \notin L$. How can I correct the above grammar?