SlideShare a Scribd company logo
1 of 9
CONVERSION
OF CFG INTO
CNF
BY,
RISHIKESH
AG E N DA
WHAT IS CFG?
WHAT IS CNF?
SOLVING A PROBLEM
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
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
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
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
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
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
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

More Related Content

Similar to Conversion of CFG to CNF.pptx (11)

Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
 
Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
 
Context Free Languages by S.Mandal-1.ppt
Context Free Languages by S.Mandal-1.pptContext Free Languages by S.Mandal-1.ppt
Context Free Languages by S.Mandal-1.ppt
 
Pda to cfg h2
Pda to cfg h2Pda to cfg h2
Pda to cfg h2
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptx
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.ppt
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 

Conversion of CFG to CNF.pptx

  • 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