To convert a context-free grammar to Chomsky normal form, first add a fresh start symbol. Remove epsilon productions, retaining the exceptional start production only when the empty word is to remain in the language; then remove unit productions and symbols that cannot participate in a terminal derivation. Replace each terminal occurring in a right-hand side of length at least two by a new nonterminal that produces that terminal. Finally split every right-hand side of length greater than two into binary productions using fresh nonterminals.
Add a fresh start symbol with .
Find the nullable nonterminals, add the variants obtained by omitting nullable occurrences, and remove all epsilon productions. Omit as well because the requested language excludes .
Remove every unit production by copying the non-unit productions reachable from to .
Remove nonterminals that are unreachable from or cannot derive a terminal word.
In every right-hand side of length at least two, replace a terminal by a fresh nonterminal with .
Replace each right-hand side of length greater than two by a chain of binary productions using fresh nonterminals.
Each remaining production is of the required binary or terminal form, and these transformations preserve every nonempty generated word. Thus .
A context-free grammar is in Chomsky normal form when every production is of one of the forms
where are nonterminal symbols and is a terminal symbol. Under this strict convention there is no epsilon production, so such a grammar cannot generate the empty word. Conversion of an arbitrary grammar therefore gives
If , the two languages are equal. An alternative extended convention permits the exceptional start production ; under that convention conversion preserves the whole language.