Find a CFG for $\{a^ib^jc^k \mid i,j,k\ge0 , \text{if } j=1 \text{ then } i=k\}$

I've tried but I can't figure out any solution. Is there any hint for me to solve the question?

• There are three pieces. One for $j=0$. One for $j=1$. One for $j\ge2$. Find the CFG for each piece. Then you get $S\to S_1\mid S_2\mid S_3$. – Apass.Jack Mar 13 at 1:08
• Please read how to ask a good homework question. Besides an explicit question, it is expected of you to show your partial progress, thoughts and/or where you got stuck. It will help draw more better answers faster. Otherwise, this post might be closed or downvoted. – Apass.Jack Mar 13 at 1:12
• My apologies, I am new here and haven't read the rules. I have solved the questions and uploaded my answer. – Martin Chou Mar 13 at 4:22
• @MartinChou Please undo your edits and post an answer to your question instead. – orlp Mar 13 at 7:42

$$S =>S_1 \mid S_2 \mid S_3$$

$$S_1 =>AC$$

$$S_2 => aS_2c \mid b$$

$$S_3 => AbbBC$$

$$A =>aA \mid epsilon$$

$$B =>bB \mid epsilon$$

$$C =>cC \mid epsilon$$