Professional Documents
Culture Documents
Solution
What is CNF?
Chomsky normal form is the normalized form of Context free Grammar
No, All CFG’s May or May Not CNF but all CNF’s are always CFG’s.
1. S->abAB
2. A->bAB
3. A->Λ
4. B->BAa
5. B->A
6. B->Λ
Solution
1. S->ABAB 1. S->ABAB
2. S->ABB (Reduced Productions from Production 1)
3. S->ABA S->TT
4. S->AB T->AB
5. A->BAB 2. S->ABB
6. A->BB (Reduced Productions from Production 2)
7. A->BA S->TB
8. A->b 3. S->ABA
9. B->BAA (Reduced Productions from Production 3)
10. B->BA S-> TA
11. B->AA
4. S->AB
12. B->a
5. A->BAB
13. B->a
(Reduced Productions from Production 5)
14. A->a
A-> BT
6. A->BB
7. A->BA
8. A->b
9. B->BAA
(Reduced Productions from Production 9)
B->MA
M->BA
10. B->BA
11. B->AA
12. B->a
13. B->a
14. A->a
Final CNF
1. S->TT
2. T->AB
3. S->TB
4. S-> TA
5. S->AB
6. A-> BT
7. A->BB
8. A->BA
9. A->b
10. B->MA
11. M->BA
12. B->BA
13. B->AA
14. B->a
15. B->a
16. A->a
Example Question 2: Covert the following given CFG into its respective CNF form.
S->ABA
A->aA
A->Λ
B->bB
B->Λ
Solution
1. S->ABA 1. S->ABA
2. S->BA S->MA
3. S->AA M->AB
4. S->AB
5. S->a
6. S->b 2. S->BA
7. A->AA 3. S->AA
8. A->a 4. S->AB
9. B->BB 5. S->a
10. B->b 6. S->b
7. A->AA
8. A->a
9. B->BB
10. B->b
Final CNF
S->MA
M->AB
S->BA
S->AA
S->AB
S->a
S->b
A->AA
A->a
B->BB
B->b