All grammars are not always optimized, which means the grammar may consist of some extra symbols (non-terminals) which increase the length of grammar.
So, we have to reduce the grammar by removing such useless symbols.
The properties to reduce grammar are explained below −
The use of reducing grammar is as follows −
A symbol X is useful if there is a derivation of the form
S=>* aXb =* w
Otherwise, the symbol X is useless. Note that in a derivation, finally, we should get a string of terminals and all these symbols must be reachable from the start symbol S.
Those symbols and productions which are not at all used in the derivation are useless.
Consider the following example for removing symbol
S->aAa|bBb| ε A->C|a B->C|b C->CDE| ε D->A|B|ab
The useless symbols from the given grammar is E. Because E is not a derivative on the right hand side (RHS).
After removing the useless symbol, the production is as follows