This slide describes the conversion of CFG to CNF.
CFG stands for context free grammar.
CNF stands for Chomsky Normal Form
It is type-2 grammar.
It is accepted by push down automata.
Every CNF is generated from CFG
2. AG E N DA
WHAT IS CFG?
WHAT IS CNF?
SOLVING A PROBLEM
3. C F G
CFG stands for Context Free Grammar.
It is a type-2 Grammar.
The productions can be of the form,
α -> β
|α|<=|β|
α ∈ V
|α|=1
β ∈ (V ∪ T)
CFG contains the following four components,
G=(V,T,P,S)
Example:
S->aSb
S->ab
P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
3
4. C N F
CNF stands for Chomsky Normal Form
Every CFL is generated by a CFG, in which all
productions are of the form,
A->BC
A->a
Where A,B,C – Variables and a – Terminal.
This form of CFG is CNF.
In order to find the CNF, the following operations are to
be performed,
Eliminate use-less symbols,
Eliminate ε-production,
Eliminate unit production.
P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
4
5. P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
5
1.Consider the grammar ({S,A,B},{a,b},P,S) has the productions,
S->bA|aB
A->bAA|aS|a
B->aBB|bs|b
Solution:
Step-1: Find the productions which are already in CNF:
A->a
B->b
Step-2: Replace the terminals on the right by new variables:
(i) S->bA
S->𝐶𝑏𝐴
𝐶𝑏->b
6. P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
6
Step-2: Replace the terminals on the right by new variables:
(ii) S->aB
S->𝐶𝑎𝐵
𝐶𝑎->a
(iii) A->bAA
A->𝐶𝑏AA
𝐶𝑏->b
This is not in CNF form
(iv)A->aS
A->𝐶𝑎𝑆
𝐶𝑎->a
(v) B->aBB
B->𝐶𝑎BB
𝐶𝑎->a
This is not in CNF form
7. P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
7
Step-2: Replace the terminals on the right by new variables:
(vi) B->bS
B-> 𝐶𝑏S
𝐶𝑏->b
Step-3: According to CNF Theorem, the (RHS) body should contain only two variables:
(i) A-> 𝐶𝑏𝐴𝐴
A-> 𝐶𝑏𝐷1
𝐷1->AA
𝐶𝑏->b
(ii) B-> 𝐶𝑎𝐵𝐵
B-> 𝐶𝑎𝐷2
𝐷2->BB
𝐶𝑎->a
8. F I N A L A N S W E R :
THUS THE RESULTANT PRODUCTIONS IN CNF
ARE,
P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
8
S-> 𝐶𝑏A| 𝐶𝑎B
A-> 𝐶𝑎S| 𝐶𝑏𝐷1|a
B-> 𝐶𝑏S| 𝐶𝑎 𝐷2|b
𝐶𝑎->a
𝐶𝑏->b
𝐷1->AA
𝐷2->BB
9. T H A N K YO U
Presented by,
Δ RISHIKESH B
811720104084
P
R
E
S
E
N
T
A
T
I
O
N
T
I
T
L
E
9