SlideShare una empresa de Scribd logo
1 de 14
Chomsky Normal Form
Muhammad Zeeshan khan
Raheel Khan
Introduction
 A useful form for dealing with context free grammars
is the Chomsky normal form. This is a particular form
of writing a CFG which is useful for understanding
CFGs and for proving things about them. It also makes
the parse
 tree for derivations using this form of the CFG a
binary tree.
Introduction
A special form of grammars
A grammar where every production is either of the form
A BC or A C→ →
(where A, B, C are arbitrary variables And can arbitrary
symbol).
Example:
S AS | a→
A SA | b→
(If language contains ", then we allow S ! "where S is start
symbol, and forbid S on RHS.)
General Grammars
 Production Rules
 Of the form A B→
 A is a string of terminals and variables
 B is a string of terminals and variables
 To apply a rule, replace any occurrence of A
 with the string
Chomsky Normal Form
Said to be Context free grammar.
..If a CFG has only productions of the form non-
terminal A string of two non-terminals Or non-terminal
A one terminal then the CFG is said to be in Chomsky
Normal Form (CNF).
..Increment of terminal
Why is importamt
The key advantage is that in Chomsky Normal Form, every
derivation of a string of n letters has exactly 2n − 1
steps.
Thus: one can determine if a string is in the language by
exhaustive search of all derivations.
Uses
 Simplicity of proofs
There are plenty of proofs around context-free grammars, including
reducibility and equivalence to automata. Those are the simpler the
more restricted the set of grammars you have to deal with is.
Therefore, normal forms can be helpful there.
 Enables parsing
While PDAs can be used to parse words with any grammar, this is
often inconvenient. Normal forms can give us more structure to work
with, resulting in easier parsing algorithms.
As a concrete example, the CYK algorithm uses Chomsky normal form.
Greibach normal form, on the other hand, enables recursive-descent
parsing; even though backtracking may be necessary, space
complexity is linear.
Proof ldea
 Any context-free language is generated by a context-
free grammar in Chomsky
PROOF IDEA
 We can convert any grammar G into Chomsky normal
form.
 The conversion has several stages wherein rules that
violate the conditions are replaced with equivalent ones
that are satisfactory.
Simple explanation
 If we can put a CFG into CNF, then we
 can calculate the “depth” of the longest
 branch of a parse tree for the derivation
 of a string.
A (parse tree)
B C
 a
Steps for CNF
 1. Remove λ- Productions
 2. Remove Unit Productions
 3. Remove Useless Symbols
Remove ε - Productions
Example : take A CFG
 S → ASB
 A → aAS | a |e
 B → SbS | A | bb
Next we need to eliminate the " rules. Eliminating A → e
yields
 S → ASB |SB
 A → aAS | a |aS
 B → SbS | A | bb | e
Remove Unit Productions
 Now we have a new " rule., B → ε. Lets remove it
 S → ASB |SB |S|AS
 A → aAS | a |aS
 B → SbS | A | bb
Next we need to remove all unit rules. Lets begin by
removing B→ A
 S → ASB |SB |S|AS
 A → aAS | a |aS
 B → SbS | aAS | a |aS | bb
now Where A is useless for the grammer..
. Remove Useless Symbols
Example: Let G be
S AB | a; A b→ →
 S and A are generating, B is not. If we eliminate
 B we have to eliminate because its non-generating
symbol so the grammar is
 S a; A b→ →
Thank You
Kingsoft Office
Make Presentation much more fun

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

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
 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
 
Unit iii
Unit iiiUnit iii
Unit iii
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
 
Nfa vs dfa
Nfa vs dfaNfa vs dfa
Nfa vs dfa
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
 
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
 
Lesson 08
Lesson 08Lesson 08
Lesson 08
 
Lesson 12
Lesson 12Lesson 12
Lesson 12
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushik
 
Lesson 11
Lesson 11Lesson 11
Lesson 11
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite Automat
 
Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
L3 cfg
L3 cfgL3 cfg
L3 cfg
 
Hima1
Hima1Hima1
Hima1
 
Class7
 Class7 Class7
Class7
 

Destacado

Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsRajendran
 
Backus Naur and Chomsky Normal Forms
Backus Naur and Chomsky Normal FormsBackus Naur and Chomsky Normal Forms
Backus Naur and Chomsky Normal FormsAshutosh Pandey
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammarlavishka_anuj
 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur formgrahamwell
 
Turing Machine
Turing MachineTuring Machine
Turing MachineAyAn KhAn
 

Destacado (8)

Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
 
Backus Naur and Chomsky Normal Forms
Backus Naur and Chomsky Normal FormsBackus Naur and Chomsky Normal Forms
Backus Naur and Chomsky Normal Forms
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur form
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Compilers
CompilersCompilers
Compilers
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 

Similar a Chomsky by zeeshan khan and Raheel Khan

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
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxAliZaib71
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free GrammerHASHIR RAZA
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLPkartikaVashisht
 
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
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Finals-review.pptx
Finals-review.pptxFinals-review.pptx
Finals-review.pptxamara jyothi
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxwoodruffeloisa
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammarAfshanKhan51
 
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.ppt1sonalishipu
 
contextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfcontextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfry54321288
 
Csr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCsr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCSR2011
 
replacement grammars
replacement grammarsreplacement grammars
replacement grammarsRajendran
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarniveditJain
 
Debugging Chomsky's Hierarchy
Debugging Chomsky's HierarchyDebugging Chomsky's Hierarchy
Debugging Chomsky's HierarchyHussein Ghaly
 
Chapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.pptChapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.pptFamiDan
 
Instaduction to instaparse
Instaduction to instaparseInstaduction to instaparse
Instaduction to instaparseAlex Schoof
 

Similar a Chomsky by zeeshan khan and Raheel Khan (20)

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
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptx
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free Grammer
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
 
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
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Finals-review.pptx
Finals-review.pptxFinals-review.pptx
Finals-review.pptx
 
CFG to CNF
CFG to CNFCFG to CNF
CFG to CNF
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docx
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammar
 
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
 
contextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfcontextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdf
 
TOA_WEEK 14.pptx
TOA_WEEK 14.pptxTOA_WEEK 14.pptx
TOA_WEEK 14.pptx
 
Csr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminskiCsr2011 june17 15_15_kaminski
Csr2011 june17 15_15_kaminski
 
replacement grammars
replacement grammarsreplacement grammars
replacement grammars
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Debugging Chomsky's Hierarchy
Debugging Chomsky's HierarchyDebugging Chomsky's Hierarchy
Debugging Chomsky's Hierarchy
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Chapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.pptChapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.ppt
 
Instaduction to instaparse
Instaduction to instaparseInstaduction to instaparse
Instaduction to instaparse
 

Último

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Último (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Chomsky by zeeshan khan and Raheel Khan

  • 1. Chomsky Normal Form Muhammad Zeeshan khan Raheel Khan
  • 2. Introduction  A useful form for dealing with context free grammars is the Chomsky normal form. This is a particular form of writing a CFG which is useful for understanding CFGs and for proving things about them. It also makes the parse  tree for derivations using this form of the CFG a binary tree.
  • 3. Introduction A special form of grammars A grammar where every production is either of the form A BC or A C→ → (where A, B, C are arbitrary variables And can arbitrary symbol). Example: S AS | a→ A SA | b→ (If language contains ", then we allow S ! "where S is start symbol, and forbid S on RHS.)
  • 4. General Grammars  Production Rules  Of the form A B→  A is a string of terminals and variables  B is a string of terminals and variables  To apply a rule, replace any occurrence of A  with the string
  • 5. Chomsky Normal Form Said to be Context free grammar. ..If a CFG has only productions of the form non- terminal A string of two non-terminals Or non-terminal A one terminal then the CFG is said to be in Chomsky Normal Form (CNF). ..Increment of terminal
  • 6. Why is importamt The key advantage is that in Chomsky Normal Form, every derivation of a string of n letters has exactly 2n − 1 steps. Thus: one can determine if a string is in the language by exhaustive search of all derivations.
  • 7. Uses  Simplicity of proofs There are plenty of proofs around context-free grammars, including reducibility and equivalence to automata. Those are the simpler the more restricted the set of grammars you have to deal with is. Therefore, normal forms can be helpful there.  Enables parsing While PDAs can be used to parse words with any grammar, this is often inconvenient. Normal forms can give us more structure to work with, resulting in easier parsing algorithms. As a concrete example, the CYK algorithm uses Chomsky normal form. Greibach normal form, on the other hand, enables recursive-descent parsing; even though backtracking may be necessary, space complexity is linear.
  • 8. Proof ldea  Any context-free language is generated by a context- free grammar in Chomsky PROOF IDEA  We can convert any grammar G into Chomsky normal form.  The conversion has several stages wherein rules that violate the conditions are replaced with equivalent ones that are satisfactory.
  • 9. Simple explanation  If we can put a CFG into CNF, then we  can calculate the “depth” of the longest  branch of a parse tree for the derivation  of a string. A (parse tree) B C  a
  • 10. Steps for CNF  1. Remove λ- Productions  2. Remove Unit Productions  3. Remove Useless Symbols
  • 11. Remove ε - Productions Example : take A CFG  S → ASB  A → aAS | a |e  B → SbS | A | bb Next we need to eliminate the " rules. Eliminating A → e yields  S → ASB |SB  A → aAS | a |aS  B → SbS | A | bb | e
  • 12. Remove Unit Productions  Now we have a new " rule., B → ε. Lets remove it  S → ASB |SB |S|AS  A → aAS | a |aS  B → SbS | A | bb Next we need to remove all unit rules. Lets begin by removing B→ A  S → ASB |SB |S|AS  A → aAS | a |aS  B → SbS | aAS | a |aS | bb now Where A is useless for the grammer..
  • 13. . Remove Useless Symbols Example: Let G be S AB | a; A b→ →  S and A are generating, B is not. If we eliminate  B we have to eliminate because its non-generating symbol so the grammar is  S a; A b→ →
  • 14. Thank You Kingsoft Office Make Presentation much more fun