Explain Chomsky normal form in TOC

Data Structure AlgorithmsComputer ScienceComputers

Chomsky’s Normal Form Stands as CNF.

A context free grammar is in CNF, if the production rules satisfy one of the following conditions

  • If there is start Symbol generating ε. Example − A-> ε
  • If a non-terminal generates two non-terminals. Example − S->AB
  • If a non-terminal generates a terminal. Example − S->a


Let's take G1 Production rules, as given below −

G1={ S->AB,

G1 satisfies the rule specified for CNF. So, it is in CNF.

Now, let's consider G2 production rules, as shown below

G2={ S->aA,

G2 does not satisfy the rules specified for CNF, as S->aA contains a terminal followed by a non-terminal.

So, G2 is not in CNF

Consider another example to check whether the given grammar is in CNF or not.

The grammar is as follows −

A->aBB| ε

The given grammar is not in CNF because, S->aA ,A->aBB, B->Aa contains terminals followed by non-terminals.

Published on 12-Jun-2021 11:52:58