SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 

Tendances (20)

2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
Finite automata
Finite automataFinite automata
Finite automata
 
Pda to cfg h2
Pda to cfg h2Pda to cfg h2
Pda to cfg h2
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
2.7 normal forms cnf & problems
2.7 normal forms  cnf & problems2.7 normal forms  cnf & problems
2.7 normal forms cnf & problems
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
CFG to CNF
CFG to CNFCFG to CNF
CFG to CNF
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machine
 
Automata
AutomataAutomata
Automata
 
Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 

Similaire à Chomsky Normal Form

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
Jisock
 
Geometry working with line segments
Geometry working with  line segmentsGeometry working with  line segments
Geometry working with line segments
rfarinas
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
lavishka_anuj
 

Similaire à Chomsky Normal Form (15)

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

Dernier

Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
PirithiRaju
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
Lokesh Kothari
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
PirithiRaju
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 

Dernier (20)

Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
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...
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Creating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsCreating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening Designs
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 

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