Chomsky's normal form
Overview
Chomsky's normal form (CNF) is a method to simplify context-free grammar.
Every grammar in CNF is context-free, and every
Grammar is in CNF if all the productions follow either of the following set of rules:
- Start symbol generates null.
- A nonterminal generates two nonterminals.
- A nonterminal generates one terminal.
Steps to convert grammar to CNF
The following steps are used to convert context-free grammar into Chomsky's normal form.
- Introduce a new start variable that produces the old start variable.
- Remove the null productions from non-starting variables.
- Remove the unit productions.
- Convert all rules such that the right side has one terminal and two variables. New variables can be introduced to convert the rules.
Example
Let's consider the following CFG:
Step 1: Add a new start state
Step 2: Remove null productions
Remove null productions iteratively. Replace the values of the variables that produce null in any other production.
Step 2.1: Removing
Step 2.2: Removing
Step 3: Remove unit productions
Step 3.1: Replace the productions produced by in and
Step 3.2: Replace the productions produced by in
Step 4: Incorporate one terminal and two variables in each production
Step 4.1: Introduce where occurs with a variable
Step 4.2: Introduce where occurs with another variable
Result
The following grammar is in CNF.
Note: A single CFG can produce different Chomsky's normal forms.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved