SlideShare uma empresa Scribd logo
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

Mais conteúdo relacionado

Semelhante a Conversion of CFG to CNF.pptx

Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
Shiela Rani
 
Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
JohnSamuel280314
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
ssuser0be977
 
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
1sonalishipu
 
Pda to cfg h2
Pda to cfg h2Pda to cfg h2
Pda to cfg h2
Rajendran
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
Prof. Dr. K. Adisesha
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
AdiseshaK
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
AdiseshaK
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptx
AkhilJoseph63
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
Mohammad Ilyas Malik
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.ppt
MansiMalik22
 

Semelhante a 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
 

Último

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 

Último (20)

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 

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