# How to simplify context free grammar?

How to simplify this context-free grammar into a similar one with no unit productions and no useless symbols?

$$S \to ABA \\ A \to aAA \mid aBC \mid bB \\ B \to A \mid bB \mid Cb \\ C \to CC \mid cC$$

Can the simplification result in this CFG?

$$S \to ABA \\ A \to aAA \\ A \to Bb \\ B \to b$$

• The first grammar can produce a $c$… – greybeard Jun 26 '20 at 22:30