Simplification removes unnecessary productions while preserving the language.
Removal of Λ-Productions
Removed by adding alternative productions. All combinations of nullable symbols must be considered to preserve language.
For a given CFG , an equivalent CFG (with no null-productions) can be derived using the following steps:
- Initialize
- Find all nullable non-terminals () of using FindNull algorithm.
- For each in :
- Add all productions that can be obtained by deleting one or more occurences of nullable non-terminals in , to
- Remove -productions and productions from
Ambiguity is preserved after the elimination of null productions. May increase the number of productions significantly.
Removal of Unit Productions
Removed by substitution. For a given CFG , an equivalent CFG (with no unit-productions) can be derived using the following steps:
- Initialize
- For each :
- Find all non-terminals derivable from (set of )
- For each :
- For each , add to
- Delete all unit productions from