In the grammar I have a rule "D → bD | D". How do I remove unit production from this rule for converting it to cnf?
The grammar is this:
S → DBC | Ba
B → 0B1 | 01 |
C → aCb | aC | Bb
D → bD | D
In the grammar I have a rule "D → bD | D". How do I remove unit production from this rule for converting it to cnf?
The grammar is this:
S → DBC | Ba
B → 0B1 | 01 |
C → aCb | aC | Bb
D → bD | D
The production
D → Ddoes not contribute anything to the grammar, so you can just delete it. Moreover, the nonterminalDis useless because it cannot derive any sentence; it has no non-recursive production.Before removing unit productions, you should first reduce your grammar by removing unproductive and unreachable productions.