SlideShare a Scribd company logo
1 of 10
Chomsky Normal Form
Continuation
By: Jasmine Peniel Combo
BSCS 2-3
Recall that:
• A CFG is said to be in Chomsky Normal Form
if every production is of one of these two
forms:
1. A -> BC (body is two variables).
2. A -> a (body is a single terminal).
• Theorem: If L is a CFL, then L – {ε} has a CFG
in CNF.
Recall the first steps:
• Step 1
Make sure the start symbol (S) doesn't
appear on right hand side. If so, add new
Start symbol.
Step 2
Remove ε-productions.
Step 3
Remove unit rules
Step 4: Break right sides longer than two into
a chain of productions with right sides of two
variables
So with the continuation of the previous example,
• S0 → ASA | aB | a | SA | AS
• S → ASA | aB | a | SA | AS
• A → b | ASA | aB | a | SA | AS
• B → b
Introduce new variables.
So for S0 → ASA & S → ASA , we replace SA with a new
variable, A1 therefore:
• S0 → ASA | aB | a | SA | AS
• S → ASA | aB | a | SA | AS
• A → b | ASA | aB | a | SA | AS
• B → b
S0 → A A1 | aB | a | SA | AS
S → A A1 | aB | a | SA | AS
A → b | A A1 | aB | a | SA | AS
A1 → SA
B → b
Recall:
1. A -> BC (body is two
variables).
Step 5: Make sure that the productions are in
either these two forms:
1. A -> BC (body is two variables).
2. A -> a (body is a single terminal).
• S0 → A A1 | aB | a | SA | AS
• S → A A1 | aB | a | SA | AS
• A → b | A A1 | aB | a | SA | AS
• A1 → SA
• B → b
So we replace right hand sides with the wrong form by introducing a
new variable just like the previous step. In this example, A2
• S0 → A A1 | aB | a | SA | AS
• S → A A1 | aB | a | SA | AS
• A → b | A A1 | aB | a | SA | AS
• A1 → SA
• B → b
S0 → A A1 | A2 B| a | SA | AS
S → A A1 | A2 B | a | SA | AS
A → b | A A1 | A2 B | a | SA | AS
A1 → SA
A2 → a
B → b
Example #2:
• S → aXbX
• X → aY | bY | ε
• Y → X | c
Remove ε-productions. Then since the right hand of S
contains X,
X → ε
S → aXbX
Consider all cases,
Case 1: S → a ε bX
S → abX
Case 2: S → aXb ε
S → aXb
Case 3: S → a ε b ε
S → ab
The variable X is nullable and
therefore, also Y so,
X → ε
Y → X
Y → ε
X → aY | bY
X → a | b add this new
production to X
Example #2
• From previous step we obtain,
S → aXbX | abX | aXb | ab
X → aY | bY | a | b
Y → X | c
Now we eliminate unit productions such as
Y → X so,
S → aXbX | abX | aXb | ab
X → aY | bY | a | b
Y → aY | bY | a | b | c
Recall that:
If A =>* B by a series of unit
productions, and B ->  is a
non-unit-production, then
add production A -> .
Example #2
S → aXbX | abX | aXb | ab
X → aY | bY | a | b
Y → aY | bY | a | b | c
Now we replace longer productions with shorter ones
by adding new variables.
D → aX
E → bX
New grammar:
S → DE | aE |Db| ab
X → aY | bY | a | b
Y → aY | bY | a | b | c
D → aX
E → bX
Example #2
S → DE | aE |Db| ab
X → aY | bY | a | b
Y → aY | bY | a | b | c
D → aX
E → bX
Then we correct the productions with wrong forms and
introduce new variables F & G:
F → a
G → b
Example #2
Final CNG in Chomsky Normal Form:
S → DE | FE |DF| FG
X → FY | GY | a | b
Y → FY | GY | a | b | c
D → FX
E → GX
F → a
G → b

More Related Content

What's hot

Automata theory
Automata theoryAutomata theory
Automata theorycolleges
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing ThesisHemant Sharma
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOCAbhayDhupar
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problemsSampath Kumar S
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machineMian Munib
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsRajendran
 
Pushdown Automata Theory
Pushdown Automata TheoryPushdown Automata Theory
Pushdown Automata TheorySaifur Rahman
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and boundAbhishek Singh
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1Rajendran
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 

What's hot (20)

Automata theory
Automata theoryAutomata theory
Automata theory
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
push down automata
push down automatapush down automata
push down automata
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machine
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Pushdown Automata Theory
Pushdown Automata TheoryPushdown Automata Theory
Pushdown Automata Theory
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 

Similar to Chomsky Normal Form

Theory of computation Lecture Slide(Chomsky Normal Form).pptx
Theory of computation Lecture Slide(Chomsky Normal Form).pptxTheory of computation Lecture Slide(Chomsky Normal Form).pptx
Theory of computation Lecture Slide(Chomsky Normal Form).pptxcustomersupport14
 
Theory of competition topic simplification of cfg, normal form of FG.pptx
Theory of competition topic simplification of cfg, normal form of FG.pptxTheory of competition topic simplification of cfg, normal form of FG.pptx
Theory of competition topic simplification of cfg, normal form of FG.pptxJisock
 
Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Abhimanyu Mishra
 
Chomsky_Greibach-Hector-Chavez.ppt
Chomsky_Greibach-Hector-Chavez.pptChomsky_Greibach-Hector-Chavez.ppt
Chomsky_Greibach-Hector-Chavez.pptMANMEETKAUR846308
 
NORMAL-FORMS.ppt
NORMAL-FORMS.pptNORMAL-FORMS.ppt
NORMAL-FORMS.pptSadagopanS
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
 
Simplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationSimplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationNikhil Pandit
 
Geometry working with line segments
Geometry working with  line segmentsGeometry working with  line segments
Geometry working with line segmentsrfarinas
 
Theory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal FormsTheory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal FormsRushabh2428
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammarlavishka_anuj
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptMansiMalik22
 

Similar to Chomsky Normal Form (16)

Theory of computation Lecture Slide(Chomsky Normal Form).pptx
Theory of computation Lecture Slide(Chomsky Normal Form).pptxTheory of computation Lecture Slide(Chomsky Normal Form).pptx
Theory of computation Lecture Slide(Chomsky Normal Form).pptx
 
Theory of competition topic simplification of cfg, normal form of FG.pptx
Theory of competition topic simplification of cfg, normal form of FG.pptxTheory of competition topic simplification of cfg, normal form of FG.pptx
Theory of competition topic simplification of cfg, normal form of FG.pptx
 
Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3
 
Chomsky_GreibachNF.ppt
Chomsky_GreibachNF.pptChomsky_GreibachNF.ppt
Chomsky_GreibachNF.ppt
 
Chomsky_Greibach-Hector-Chavez.ppt
Chomsky_Greibach-Hector-Chavez.pptChomsky_Greibach-Hector-Chavez.ppt
Chomsky_Greibach-Hector-Chavez.ppt
 
NORMAL-FORMS.ppt
NORMAL-FORMS.pptNORMAL-FORMS.ppt
NORMAL-FORMS.ppt
 
NORMAL-FORMS.ppt
NORMAL-FORMS.pptNORMAL-FORMS.ppt
NORMAL-FORMS.ppt
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
 
Simplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationSimplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of Computation
 
Geometry working with line segments
Geometry working with  line segmentsGeometry working with  line segments
Geometry working with line segments
 
Ambiguity Grammar.pptx
Ambiguity Grammar.pptxAmbiguity Grammar.pptx
Ambiguity Grammar.pptx
 
Theory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal FormsTheory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal Forms
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Lec13 solved example
Lec13 solved exampleLec13 solved example
Lec13 solved example
 
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

Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfSwapnil Therkar
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physicsvishikhakeshava1
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 

Recently uploaded (20)

Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physics
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 

Chomsky Normal Form

  • 1. Chomsky Normal Form Continuation By: Jasmine Peniel Combo BSCS 2-3
  • 2. Recall that: • A CFG is said to be in Chomsky Normal Form if every production is of one of these two forms: 1. A -> BC (body is two variables). 2. A -> a (body is a single terminal). • Theorem: If L is a CFL, then L – {ε} has a CFG in CNF.
  • 3. Recall the first steps: • Step 1 Make sure the start symbol (S) doesn't appear on right hand side. If so, add new Start symbol. Step 2 Remove ε-productions. Step 3 Remove unit rules
  • 4. Step 4: Break right sides longer than two into a chain of productions with right sides of two variables So with the continuation of the previous example, • S0 → ASA | aB | a | SA | AS • S → ASA | aB | a | SA | AS • A → b | ASA | aB | a | SA | AS • B → b Introduce new variables. So for S0 → ASA & S → ASA , we replace SA with a new variable, A1 therefore: • S0 → ASA | aB | a | SA | AS • S → ASA | aB | a | SA | AS • A → b | ASA | aB | a | SA | AS • B → b S0 → A A1 | aB | a | SA | AS S → A A1 | aB | a | SA | AS A → b | A A1 | aB | a | SA | AS A1 → SA B → b Recall: 1. A -> BC (body is two variables).
  • 5. Step 5: Make sure that the productions are in either these two forms: 1. A -> BC (body is two variables). 2. A -> a (body is a single terminal). • S0 → A A1 | aB | a | SA | AS • S → A A1 | aB | a | SA | AS • A → b | A A1 | aB | a | SA | AS • A1 → SA • B → b So we replace right hand sides with the wrong form by introducing a new variable just like the previous step. In this example, A2 • S0 → A A1 | aB | a | SA | AS • S → A A1 | aB | a | SA | AS • A → b | A A1 | aB | a | SA | AS • A1 → SA • B → b S0 → A A1 | A2 B| a | SA | AS S → A A1 | A2 B | a | SA | AS A → b | A A1 | A2 B | a | SA | AS A1 → SA A2 → a B → b
  • 6. Example #2: • S → aXbX • X → aY | bY | ε • Y → X | c Remove ε-productions. Then since the right hand of S contains X, X → ε S → aXbX Consider all cases, Case 1: S → a ε bX S → abX Case 2: S → aXb ε S → aXb Case 3: S → a ε b ε S → ab The variable X is nullable and therefore, also Y so, X → ε Y → X Y → ε X → aY | bY X → a | b add this new production to X
  • 7. Example #2 • From previous step we obtain, S → aXbX | abX | aXb | ab X → aY | bY | a | b Y → X | c Now we eliminate unit productions such as Y → X so, S → aXbX | abX | aXb | ab X → aY | bY | a | b Y → aY | bY | a | b | c Recall that: If A =>* B by a series of unit productions, and B ->  is a non-unit-production, then add production A -> .
  • 8. Example #2 S → aXbX | abX | aXb | ab X → aY | bY | a | b Y → aY | bY | a | b | c Now we replace longer productions with shorter ones by adding new variables. D → aX E → bX New grammar: S → DE | aE |Db| ab X → aY | bY | a | b Y → aY | bY | a | b | c D → aX E → bX
  • 9. Example #2 S → DE | aE |Db| ab X → aY | bY | a | b Y → aY | bY | a | b | c D → aX E → bX Then we correct the productions with wrong forms and introduce new variables F & G: F → a G → b
  • 10. Example #2 Final CNG in Chomsky Normal Form: S → DE | FE |DF| FG X → FY | GY | a | b Y → FY | GY | a | b | c D → FX E → GX F → a G → b