SlideShare a Scribd company logo
Chomsky
Normal Form
(CNF)
-Sampath Kumar S,
AP/CSE, SECE
Normal Forms:
 In CFG at the RHS of production there may be any
number of terminals and non-terminals in any
combination. We need to normalize such grammar
(i.e., we want the grammar in some specific
format.
 There should be a fixed number of terminals or
non-terminals, in CFG with some criteria.
 There are 2important normal forms:
Chomsky Normal Form (CNF)
Greibach Normal Form (GNF)
11/21/2017
Sampath Kumar S, AP/CSE, SECE
2
Chomsky Normal Form (CNF):
 A CFG is in Chomsky Normal Form (CNF), if each
of its production has one of the two forms:
1. NonTerminal → a string of exactly 2
nonternminals, i.e., A → BC.
2. NonTerminal → one terminal, i.e., A → a.
 In CNF, number of symbols on the RHS of the
production is strictly limited.
 The nature of the symbols on the RHS is also
restricted.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
3
Procedure for converting to CNF:
1. Simplify the CFG (i.e., eliminate null production, unit
production and useless symbols).
2. Include the production of the form A→ BC|a as it is.
3. Eliminate the strings of the terminals on the RHS of
the productions, if it exceeds one. The procedure is
as follows:
Suppose we have the production
S → Aabc, where abc are terminals & A is
nonterminal, then introduce the nonterminal Ci for the
terminal abc as C1 → a, C2 → b, C3 → c.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
4
Procedure (Cont..,):
4. To restrict the number of variable on the RHS, introduce the
new variable and separate them as follows:
Suppose we have the production with n nonterminals, as
shown below with 5 NT
Y → ABCDE
Add n-2 new productions, using n-2 new nonterminals and
modify the production as follow:
Y → AR1
R1 → BR2
R2 → CR3
R3 → DE
Where Ri are the new non-terminals.
Note: The language generated by the new CFG is
the same as that generated by the original
CFG.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
5
Problems to discuss:
94. Convert the following CFG to CNF
S → bA|aB
A→ bAA|aS|a
B → aBB|bS|b
Solution:
Step1: Simplify the CFG
– Given grammar is in simplified form.
Step 2: Identify the production in required form.
- A → b, B → b are in the required format.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
6
Problems to discuss:
Step 3: Identify the productions which is not in required form
and replace every terminal by a variable
[ S → bA|aB
A → bAA|aS
B → aBB|bS ]
S → C2A|C1B
A → C2 AA| C1S|a
B → C1BB| C2S|b
C2 → b
C1 → a
.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
7
Problems to discuss:
Step 4: Identify the production which is not in CNF format.
A → C2 AA
B → C1BB are not in CNF. So add new nonterminals D
& E.
S → C2A|C1B
A → C2 D| C1S|a
B → C1E| C2S|b
C2 → b
C1 → a
D → AA
E → BB
This is the required CNF.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
8
Problems to discuss:
98. Convert the following CFG to CNF
S → AB|aB
A→ aBB|ε
B → bbA
96. Convert the following CFG to CNF
S → ASB|ε
A→ aAS|a
B → SbS|A|bb
97. Convert the following CFG to CNF
S → ASA|aB
A→ B|S
B → b|ε
11/21/2017
Sampath Kumar S, AP/CSE, SECE
9
Problems to discuss:
98. Convert the following CFG to CNF
S → AB|Aa
A→ aAA|a
B → bBB|b
99. Convert the following CFG to CNF
S → AB|CA, A→ a
B → BC|AB, C → aB|b
100. Convert the following CFG to CNF
S → 0A|1B|C
A → 0S|00
B → 1|A
C → 01
11/21/2017
Sampath Kumar S, AP/CSE, SECE
10
Problems to discuss:
101. Convert the following CFG to CNF
S → aAbB
A→ aA|a
B → bB|b
102. Convert the following CFG to CNF
S → ABa
A→ aab
B → Ac
103. Convert the following CFG to CNF
S → ε | (S) |SS
11/21/2017
Sampath Kumar S, AP/CSE, SECE
11
11/21/2017
Sampath Kumar S, AP/CSE, SECE
13
நன்றி
11/21/2017
Sampath Kumar S, AP/CSE, SECE
14

More Related Content

What's hot

Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
hafizhamza0322
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
FellowBuddy.com
 
Lesson 08
Lesson 08Lesson 08
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
Siva Sathya
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Darshan sai Reddy
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
Hanif Durad
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
Dipankar Boruah
 
Heap Management
Heap ManagementHeap Management
Heap Management
Jenny Galino
 
context free language
context free languagecontext free language
context free language
khush_boo31
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
AkhilJoseph63
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
Akhil Kaushik
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Mohammad Ilyas Malik
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
BMS Institute of Technology and Management
 
Mapping
MappingMapping
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
Sampath Kumar S
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Adeel Rasheed
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
Rajkumar R
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
Jothi Lakshmi
 

What's hot (20)

Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Lesson 08
Lesson 08Lesson 08
Lesson 08
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
context free language
context free languagecontext free language
context free language
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
 
Mapping
MappingMapping
Mapping
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 

More from Sampath Kumar S

5.2 primitive recursive functions
5.2 primitive recursive functions5.2 primitive recursive functions
5.2 primitive recursive functions
Sampath Kumar S
 
4.7. chomskian hierarchy of languages
4.7. chomskian hierarchy of languages4.7. chomskian hierarchy of languages
4.7. chomskian hierarchy of languages
Sampath Kumar S
 
4.6 halting problem
4.6 halting problem4.6 halting problem
4.6 halting problem
Sampath Kumar S
 
4.3 techniques for turing machines construction
4.3 techniques for turing machines construction4.3 techniques for turing machines construction
4.3 techniques for turing machines construction
Sampath Kumar S
 
4.2 variantsof turing machines (types of tm)
4.2 variantsof turing machines (types of tm)4.2 variantsof turing machines (types of tm)
4.2 variantsof turing machines (types of tm)
Sampath Kumar S
 
4.1 turing machines
4.1 turing machines4.1 turing machines
4.1 turing machines
Sampath Kumar S
 
3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl
Sampath Kumar S
 
3.4 deterministic pda
3.4 deterministic pda3.4 deterministic pda
3.4 deterministic pda
Sampath Kumar S
 
3.1,2,3 pushdown automata definition, moves & id
3.1,2,3 pushdown automata   definition, moves & id3.1,2,3 pushdown automata   definition, moves & id
3.1,2,3 pushdown automata definition, moves & id
Sampath Kumar S
 
2.5 ambiguity in context free grammars
2.5 ambiguity in context free grammars2.5 ambiguity in context free grammars
2.5 ambiguity in context free grammars
Sampath Kumar S
 
2.4 derivations and languages
2.4 derivations and languages2.4 derivations and languages
2.4 derivations and languages
Sampath Kumar S
 
2.3 context free grammars and languages
2.3 context free grammars and languages2.3 context free grammars and languages
2.3 context free grammars and languages
Sampath Kumar S
 
2.1 & 2.2 grammar introduction – types of grammar
2.1 & 2.2 grammar introduction – types of grammar2.1 & 2.2 grammar introduction – types of grammar
2.1 & 2.2 grammar introduction – types of grammar
Sampath Kumar S
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets
Sampath Kumar S
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfa
Sampath Kumar S
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
Sampath Kumar S
 
1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression
Sampath Kumar S
 
1.4. finite automaton with ε moves
1.4. finite automaton with ε   moves1.4. finite automaton with ε   moves
1.4. finite automaton with ε moves
Sampath Kumar S
 
1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton
Sampath Kumar S
 
1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton
Sampath Kumar S
 

More from Sampath Kumar S (20)

5.2 primitive recursive functions
5.2 primitive recursive functions5.2 primitive recursive functions
5.2 primitive recursive functions
 
4.7. chomskian hierarchy of languages
4.7. chomskian hierarchy of languages4.7. chomskian hierarchy of languages
4.7. chomskian hierarchy of languages
 
4.6 halting problem
4.6 halting problem4.6 halting problem
4.6 halting problem
 
4.3 techniques for turing machines construction
4.3 techniques for turing machines construction4.3 techniques for turing machines construction
4.3 techniques for turing machines construction
 
4.2 variantsof turing machines (types of tm)
4.2 variantsof turing machines (types of tm)4.2 variantsof turing machines (types of tm)
4.2 variantsof turing machines (types of tm)
 
4.1 turing machines
4.1 turing machines4.1 turing machines
4.1 turing machines
 
3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl3.6 & 7. pumping lemma for cfl & problems based on pl
3.6 & 7. pumping lemma for cfl & problems based on pl
 
3.4 deterministic pda
3.4 deterministic pda3.4 deterministic pda
3.4 deterministic pda
 
3.1,2,3 pushdown automata definition, moves & id
3.1,2,3 pushdown automata   definition, moves & id3.1,2,3 pushdown automata   definition, moves & id
3.1,2,3 pushdown automata definition, moves & id
 
2.5 ambiguity in context free grammars
2.5 ambiguity in context free grammars2.5 ambiguity in context free grammars
2.5 ambiguity in context free grammars
 
2.4 derivations and languages
2.4 derivations and languages2.4 derivations and languages
2.4 derivations and languages
 
2.3 context free grammars and languages
2.3 context free grammars and languages2.3 context free grammars and languages
2.3 context free grammars and languages
 
2.1 & 2.2 grammar introduction – types of grammar
2.1 & 2.2 grammar introduction – types of grammar2.1 & 2.2 grammar introduction – types of grammar
2.1 & 2.2 grammar introduction – types of grammar
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfa
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
 
1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression1.5 & 1.6 regular languages & regular expression
1.5 & 1.6 regular languages & regular expression
 
1.4. finite automaton with ε moves
1.4. finite automaton with ε   moves1.4. finite automaton with ε   moves
1.4. finite automaton with ε moves
 
1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton
 
1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton
 

Recently uploaded

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
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
 
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)
 
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
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
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
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 

Recently uploaded (20)

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
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” .
 
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...
 
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
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
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
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 

2.7 normal forms cnf & problems

  • 2. Normal Forms:  In CFG at the RHS of production there may be any number of terminals and non-terminals in any combination. We need to normalize such grammar (i.e., we want the grammar in some specific format.  There should be a fixed number of terminals or non-terminals, in CFG with some criteria.  There are 2important normal forms: Chomsky Normal Form (CNF) Greibach Normal Form (GNF) 11/21/2017 Sampath Kumar S, AP/CSE, SECE 2
  • 3. Chomsky Normal Form (CNF):  A CFG is in Chomsky Normal Form (CNF), if each of its production has one of the two forms: 1. NonTerminal → a string of exactly 2 nonternminals, i.e., A → BC. 2. NonTerminal → one terminal, i.e., A → a.  In CNF, number of symbols on the RHS of the production is strictly limited.  The nature of the symbols on the RHS is also restricted. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 3
  • 4. Procedure for converting to CNF: 1. Simplify the CFG (i.e., eliminate null production, unit production and useless symbols). 2. Include the production of the form A→ BC|a as it is. 3. Eliminate the strings of the terminals on the RHS of the productions, if it exceeds one. The procedure is as follows: Suppose we have the production S → Aabc, where abc are terminals & A is nonterminal, then introduce the nonterminal Ci for the terminal abc as C1 → a, C2 → b, C3 → c. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 4
  • 5. Procedure (Cont..,): 4. To restrict the number of variable on the RHS, introduce the new variable and separate them as follows: Suppose we have the production with n nonterminals, as shown below with 5 NT Y → ABCDE Add n-2 new productions, using n-2 new nonterminals and modify the production as follow: Y → AR1 R1 → BR2 R2 → CR3 R3 → DE Where Ri are the new non-terminals. Note: The language generated by the new CFG is the same as that generated by the original CFG. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 5
  • 6. Problems to discuss: 94. Convert the following CFG to CNF S → bA|aB A→ bAA|aS|a B → aBB|bS|b Solution: Step1: Simplify the CFG – Given grammar is in simplified form. Step 2: Identify the production in required form. - A → b, B → b are in the required format. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 6
  • 7. Problems to discuss: Step 3: Identify the productions which is not in required form and replace every terminal by a variable [ S → bA|aB A → bAA|aS B → aBB|bS ] S → C2A|C1B A → C2 AA| C1S|a B → C1BB| C2S|b C2 → b C1 → a . 11/21/2017 Sampath Kumar S, AP/CSE, SECE 7
  • 8. Problems to discuss: Step 4: Identify the production which is not in CNF format. A → C2 AA B → C1BB are not in CNF. So add new nonterminals D & E. S → C2A|C1B A → C2 D| C1S|a B → C1E| C2S|b C2 → b C1 → a D → AA E → BB This is the required CNF. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 8
  • 9. Problems to discuss: 98. Convert the following CFG to CNF S → AB|aB A→ aBB|ε B → bbA 96. Convert the following CFG to CNF S → ASB|ε A→ aAS|a B → SbS|A|bb 97. Convert the following CFG to CNF S → ASA|aB A→ B|S B → b|ε 11/21/2017 Sampath Kumar S, AP/CSE, SECE 9
  • 10. Problems to discuss: 98. Convert the following CFG to CNF S → AB|Aa A→ aAA|a B → bBB|b 99. Convert the following CFG to CNF S → AB|CA, A→ a B → BC|AB, C → aB|b 100. Convert the following CFG to CNF S → 0A|1B|C A → 0S|00 B → 1|A C → 01 11/21/2017 Sampath Kumar S, AP/CSE, SECE 10
  • 11. Problems to discuss: 101. Convert the following CFG to CNF S → aAbB A→ aA|a B → bB|b 102. Convert the following CFG to CNF S → ABa A→ aab B → Ac 103. Convert the following CFG to CNF S → ε | (S) |SS 11/21/2017 Sampath Kumar S, AP/CSE, SECE 11
  • 12. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 13

Editor's Notes

  1. School of EECS, WSU