SlideShare ist ein Scribd-Unternehmen logo
1 von 15
CHOMSKY NORMAL FORM
(CNF)
&
LEFTMOST DERIVATION (LMD)
M A D E B Y :
D I M P Y C H U G H ( 1 8 3 3 )
D R I S H T I B H A L L A ( 1 8 3 8 )
DEFINITION
If a Context Free Grammar or CFG has only productions of the form
Nonterminal -> string of exactly two non-terminals
or
Nonterminal -> one terminal
then, it is said to be in Chomsky Normal Form, CNF.
Example: S → AS | a
A → SA | b
STEPSFOR CONVERSION
• The conversion to Chomsky Normal Form has four main steps:
1. Get rid of all λ-Productions .
2. Eliminate Non-terminal Unit Productions.
A → B , B → b
A → b
3. Elimination of more than one terminals by a non- terminal in a production.
4. Replace every production that is too long by shorter productions.
A → BCD
A → BE
E → CD
THEOREM-1
STATEMENT- If L is a language generated by some CFG, then there is another CFG that
generates all the non- λ words of L, all of whose productions are of one of two basic forms:
Nonterminal-> string of only Non-terminals
or
Nonterminal -> one terminal
PROOF- Let us start with the CFG-
S -> X1 | X2aX2 | aSb | b
Xl -> X2X2 | b
X2 -> aX2 | aaX1
Now, in order to convert it into the above form , we introduce new productions :
A->a and B->b
After conversion we have,
S -> X1 X1 -> X2X2
S -> X2AX2 X1 -> B
S -> ASB X2 -> AX2
S -> B X2 -> AAX1
Thus, we have converted the original CFG into the desired form.
STATEMENT- For any context- free language L, the non- λ words of L can be generated by a
grammar in which all the productions are in CNF.
PROOF - Let our initial CFG is
S -> XI X2 X3 X8
S -> X3 X5
S -> b
Now, in order to get the given CFG in CNF form we’ll add certain new non-terminals , i.e.
S -> XI X2 X3 X8
S -> XI R1
R1 -> X2 X3 X8
R1 -> X2 R2
R2 -> X3 X8
THEOREM-2
Consider another CFG
X -> X1aX2bX3
Apply Theorem 1 and add productions A->a and B->b to get string of solid non-terminals.
Now,
X -> X1AX2BX3
X -> X1R1
R1 -> AX2BX3
R1 -> AR2
R2 -> X2BX3
R2 -> X2R3
R3 -> BX3
In this way, we have converted the long productions with long strings of non-terminals into sequences
of productions with exactly 2 non-terminals on RHS. Thus, the new grammar in CNF generates the
same language as the old grammar.
Ques16 i). The following CFG has unit productions. Convert the following CGF into CNF.
S -> X
X -> Y
Y-> Z
Z ->aa
Sol16). S -> X -> Y => S -> Y
S -> Y -> Z => S -> Z
S -> Z -> aa =>S ->aa
Since S->aa is not in CNF , we introduce a new production A->a to
transform it to CNF.
Thus, the new grammar in CNF form is :
A -> a
S -> AA
QUESTIONS
Ques14 v). Convert the following CGF into CNF.
S -> ABABAB
A -> a|λ
B -> b|λ
Sol13). Removing λ productions,
A -> a ---------1
B -> b ---------2
S -> ABABAB
Using Theorem 2,
S -> AR1 ---------3
R1 -> BABAB
R1 -> BR2 ---------4
R2 -> ABAB
R2 -> AR3 ---------5
R3 -> BAB
R3 -> BR4 ---------6
R4 -> AB ---------7
Thus, the new grammar in CNF form comprises of (1,2,3,4,5,6,7).
Ques14 iv). Convert the following CGF into CNF.
E -> E + E
E -> E*E
E -> (E)
E -> 7
The terminals here are +, *, (, ), 7.
Sol12). E -> 7 --------------1
Using Theorem 1, we add new productions that will help in converting CGF to CNF.
F -> + --------------2
G -> * --------------3
H-> ( --------------4
I -> ) --------------5
Now , we have
E -> EFE
E -> ER1 --------------6
R1 -> FE --------------7
E -> EGE
E -> ER2 --------------8
R2 -> GE --------------9
E -> HEI
E -> HR3 -------------10
R3 -> EI -------------11
Thus, the new grammar in CNF form comprises of (1,2,3,4,5,6,7,8,9,10,11).
LEFT MOST DERIVATIONS
• The leftmost non-terminal in a working string is the first non-terminal that we encounter
when we scan the string from left to right.
For example : In the string abNbaXYa , the leftmost nonterminal is N.
• If a word w is generated by a CFG by a certain derivation and at each step in the derivation, a
rule of production is applied to the leftmost non-terminal in the working string, then this
derivation is called a leftmost derivation.
Ques17 i)Find the leftmost derivation for the word “abba” in the grammar:
S -> AA
A -> aB
B -> bB | λ
Sol18)(i). The following is a leftmost derivation:
S -> AA
S -> aBA
S -> abBA
S -> abbBA
S -> abbλA
S -> abbaB
S -> abbaλ
S -> abba
QUESTIONS
Ques17 ii) Find the leftmost derivation for the word “abbabaabbbabbab” in the CFG:
S->SSS|aXb
X->ba|bba|abb
Sol18)(ii). The following is a leftmost derivation:
S -> SSS
S -> aXbSS
S -> abbabSS
S -> abbabaXbS
S -> abbabaabbbS
S -> abbabaabbbaXb
S -> abbabaabbbabbab
ADVANTAGES..
• CNF Grammar can be used to determine whether a string is a member of the
language associated with it or not .
• It can be used to find the no. of production steps required to generate a string. The
key advantage is that in Chomsky Normal Form, every derivation of a string of n
letters has exactly 2 n − 1 steps.
Example : S -> AX|AB
A -> a
X -> SB
B -> b
The string to be generated is “ aabb” having n(no. of letters in a string ) =4.
The following is a leftmost derivation:
1) S -> AX
2) S -> aX
3) S -> aSB
4) S -> aABB
5) S -> aaBB
6) S -> aabB
7) S -> aabb
Here, A string of n(n=4) letters has exactly 2n-1(2*4-1=7) steps .
THANK YOU !!!

Weitere ähnliche Inhalte

Was ist angesagt?

Based and indexed addressing
Based and indexed addressingBased and indexed addressing
Based and indexed addressingJaveria Yaqoob
 
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptAnkush138
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfixSelf-Employed
 
Context free langauges
Context free langaugesContext free langauges
Context free langaugessudhir sharma
 
Library management system project
Library management system project Library management system project
Library management system project Jaya Manchanda
 
Three address code generation
Three address code generationThree address code generation
Three address code generationRabin BK
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
Non regular languages
Non regular languagesNon regular languages
Non regular languageslavishka_anuj
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 
Computational logic Propositional Calculus proof system
Computational logic Propositional Calculus proof system Computational logic Propositional Calculus proof system
Computational logic Propositional Calculus proof system banujahir1
 
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsIntroduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsAshu
 
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMS
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMSNEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMS
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMSESCOM
 

Was ist angesagt? (20)

Based and indexed addressing
Based and indexed addressingBased and indexed addressing
Based and indexed addressing
 
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
 
Library management system project
Library management system project Library management system project
Library management system project
 
Three address code generation
Three address code generationThree address code generation
Three address code generation
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
context free language
context free languagecontext free language
context free language
 
Non regular languages
Non regular languagesNon regular languages
Non regular languages
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Computational logic Propositional Calculus proof system
Computational logic Propositional Calculus proof system Computational logic Propositional Calculus proof system
Computational logic Propositional Calculus proof system
 
Data structure-question-bank
Data structure-question-bankData structure-question-bank
Data structure-question-bank
 
System proposal
System proposalSystem proposal
System proposal
 
The propositional calculus
The propositional calculusThe propositional calculus
The propositional calculus
 
Recursion DM
Recursion DMRecursion DM
Recursion DM
 
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 SolutionsIntroduction to Computer theory Daniel Cohen Chapter 2 Solutions
Introduction to Computer theory Daniel Cohen Chapter 2 Solutions
 
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMS
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMSNEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMS
NEURAL NETWORK Widrow-Hoff Learning Adaline Hagan LMS
 
Splay tree
Splay treeSplay tree
Splay tree
 
Ppt on inverse trigonometric functions
Ppt on inverse trigonometric functionsPpt on inverse trigonometric functions
Ppt on inverse trigonometric functions
 

Andere mochten auch

Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfgRajendran
 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanM Khan
 
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
 
Context free languages
Context free languagesContext free languages
Context free languagesJahurul Islam
 
B.tech admission in india
B.tech admission in indiaB.tech admission in india
B.tech admission in indiaEdhole.com
 
Turing Machine
Turing MachineTuring Machine
Turing MachineAyAn KhAn
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfaAbdul Aziz
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Abhimanyu Mishra
 
Context free presentation
Context free presentationContext free presentation
Context free presentationTelma Ventura
 
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
 
Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4Abhimanyu Mishra
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Hospital Management System
Hospital Management SystemHospital Management System
Hospital Management SystemPranil Dukare
 

Andere mochten auch (18)

Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfg
 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel Khan
 
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
 
Context free languages
Context free languagesContext free languages
Context free languages
 
L3 cfg
L3 cfgL3 cfg
L3 cfg
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 
B.tech admission in india
B.tech admission in indiaB.tech admission in india
B.tech admission in india
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Context free presentation
Context free presentationContext free presentation
Context free presentation
 
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
 
Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4Theory of automata and formal languages Unit 4
Theory of automata and formal languages Unit 4
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Hospital Management System
Hospital Management SystemHospital Management System
Hospital Management System
 

Ähnlich wie CNF & Leftmost Derivation - Theory of Computation

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
 
Conversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxConversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxRishikesh990460
 
2.7 normal forms cnf & problems
2.7 normal forms  cnf & problems2.7 normal forms  cnf & problems
2.7 normal forms cnf & problemsSampath Kumar S
 
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
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfAdiseshaK
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfAdiseshaK
 
V cse cs6503 model qb1 1
V  cse cs6503  model qb1 1V  cse cs6503  model qb1 1
V cse cs6503 model qb1 1Ezhumalai p
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsAlexander Yakushev
 
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
 
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
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA Rebaz Najeeb
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptxHebaEng
 
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
 
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
 

Ähnlich wie CNF & Leftmost Derivation - Theory of Computation (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
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Conversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxConversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptx
 
CFG to CNF
CFG to CNFCFG to CNF
CFG to CNF
 
2.7 normal forms cnf & problems
2.7 normal forms  cnf & problems2.7 normal forms  cnf & problems
2.7 normal forms cnf & problems
 
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
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
V cse cs6503 model qb1 1
V  cse cs6503  model qb1 1V  cse cs6503  model qb1 1
V cse cs6503 model qb1 1
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
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
 
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
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Class5
Class5Class5
Class5
 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
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
 
pos and do not care ppt.pptx
pos and do not care ppt.pptxpos and do not care ppt.pptx
pos and do not care ppt.pptx
 

Mehr von Drishti Bhalla

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures Drishti Bhalla
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & NetworkingDrishti Bhalla
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - MathematicsDrishti Bhalla
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - MathematicsDrishti Bhalla
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsDrishti Bhalla
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - JavaDrishti Bhalla
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringDrishti Bhalla
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRMDrishti Bhalla
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instructionDrishti Bhalla
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4Drishti Bhalla
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System ThreatsDrishti Bhalla
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software EngineeringDrishti Bhalla
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management SystemDrishti Bhalla
 

Mehr von Drishti Bhalla (16)

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & Networking
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - Mathematics
 
Holy Rivers - Hindi
Holy Rivers - HindiHoly Rivers - Hindi
Holy Rivers - Hindi
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRM
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instruction
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System Threats
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 

Kürzlich hochgeladen

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 

Kürzlich hochgeladen (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

CNF & Leftmost Derivation - Theory of Computation

  • 1. CHOMSKY NORMAL FORM (CNF) & LEFTMOST DERIVATION (LMD) M A D E B Y : D I M P Y C H U G H ( 1 8 3 3 ) D R I S H T I B H A L L A ( 1 8 3 8 )
  • 2. DEFINITION If a Context Free Grammar or CFG has only productions of the form Nonterminal -> string of exactly two non-terminals or Nonterminal -> one terminal then, it is said to be in Chomsky Normal Form, CNF. Example: S → AS | a A → SA | b
  • 3. STEPSFOR CONVERSION • The conversion to Chomsky Normal Form has four main steps: 1. Get rid of all λ-Productions . 2. Eliminate Non-terminal Unit Productions. A → B , B → b A → b 3. Elimination of more than one terminals by a non- terminal in a production. 4. Replace every production that is too long by shorter productions. A → BCD A → BE E → CD
  • 4. THEOREM-1 STATEMENT- If L is a language generated by some CFG, then there is another CFG that generates all the non- λ words of L, all of whose productions are of one of two basic forms: Nonterminal-> string of only Non-terminals or Nonterminal -> one terminal PROOF- Let us start with the CFG- S -> X1 | X2aX2 | aSb | b Xl -> X2X2 | b X2 -> aX2 | aaX1 Now, in order to convert it into the above form , we introduce new productions : A->a and B->b
  • 5. After conversion we have, S -> X1 X1 -> X2X2 S -> X2AX2 X1 -> B S -> ASB X2 -> AX2 S -> B X2 -> AAX1 Thus, we have converted the original CFG into the desired form.
  • 6. STATEMENT- For any context- free language L, the non- λ words of L can be generated by a grammar in which all the productions are in CNF. PROOF - Let our initial CFG is S -> XI X2 X3 X8 S -> X3 X5 S -> b Now, in order to get the given CFG in CNF form we’ll add certain new non-terminals , i.e. S -> XI X2 X3 X8 S -> XI R1 R1 -> X2 X3 X8 R1 -> X2 R2 R2 -> X3 X8 THEOREM-2
  • 7. Consider another CFG X -> X1aX2bX3 Apply Theorem 1 and add productions A->a and B->b to get string of solid non-terminals. Now, X -> X1AX2BX3 X -> X1R1 R1 -> AX2BX3 R1 -> AR2 R2 -> X2BX3 R2 -> X2R3 R3 -> BX3 In this way, we have converted the long productions with long strings of non-terminals into sequences of productions with exactly 2 non-terminals on RHS. Thus, the new grammar in CNF generates the same language as the old grammar.
  • 8. Ques16 i). The following CFG has unit productions. Convert the following CGF into CNF. S -> X X -> Y Y-> Z Z ->aa Sol16). S -> X -> Y => S -> Y S -> Y -> Z => S -> Z S -> Z -> aa =>S ->aa Since S->aa is not in CNF , we introduce a new production A->a to transform it to CNF. Thus, the new grammar in CNF form is : A -> a S -> AA QUESTIONS
  • 9. Ques14 v). Convert the following CGF into CNF. S -> ABABAB A -> a|λ B -> b|λ Sol13). Removing λ productions, A -> a ---------1 B -> b ---------2 S -> ABABAB Using Theorem 2, S -> AR1 ---------3 R1 -> BABAB R1 -> BR2 ---------4 R2 -> ABAB R2 -> AR3 ---------5 R3 -> BAB R3 -> BR4 ---------6 R4 -> AB ---------7 Thus, the new grammar in CNF form comprises of (1,2,3,4,5,6,7).
  • 10. Ques14 iv). Convert the following CGF into CNF. E -> E + E E -> E*E E -> (E) E -> 7 The terminals here are +, *, (, ), 7. Sol12). E -> 7 --------------1 Using Theorem 1, we add new productions that will help in converting CGF to CNF. F -> + --------------2 G -> * --------------3 H-> ( --------------4 I -> ) --------------5 Now , we have E -> EFE E -> ER1 --------------6 R1 -> FE --------------7 E -> EGE E -> ER2 --------------8 R2 -> GE --------------9 E -> HEI E -> HR3 -------------10 R3 -> EI -------------11 Thus, the new grammar in CNF form comprises of (1,2,3,4,5,6,7,8,9,10,11).
  • 11. LEFT MOST DERIVATIONS • The leftmost non-terminal in a working string is the first non-terminal that we encounter when we scan the string from left to right. For example : In the string abNbaXYa , the leftmost nonterminal is N. • If a word w is generated by a CFG by a certain derivation and at each step in the derivation, a rule of production is applied to the leftmost non-terminal in the working string, then this derivation is called a leftmost derivation.
  • 12. Ques17 i)Find the leftmost derivation for the word “abba” in the grammar: S -> AA A -> aB B -> bB | λ Sol18)(i). The following is a leftmost derivation: S -> AA S -> aBA S -> abBA S -> abbBA S -> abbλA S -> abbaB S -> abbaλ S -> abba QUESTIONS
  • 13. Ques17 ii) Find the leftmost derivation for the word “abbabaabbbabbab” in the CFG: S->SSS|aXb X->ba|bba|abb Sol18)(ii). The following is a leftmost derivation: S -> SSS S -> aXbSS S -> abbabSS S -> abbabaXbS S -> abbabaabbbS S -> abbabaabbbaXb S -> abbabaabbbabbab
  • 14. ADVANTAGES.. • CNF Grammar can be used to determine whether a string is a member of the language associated with it or not . • It can be used to find the no. of production steps required to generate a string. The key advantage is that in Chomsky Normal Form, every derivation of a string of n letters has exactly 2 n − 1 steps. Example : S -> AX|AB A -> a X -> SB B -> b The string to be generated is “ aabb” having n(no. of letters in a string ) =4. The following is a leftmost derivation: 1) S -> AX 2) S -> aX 3) S -> aSB 4) S -> aABB 5) S -> aaBB 6) S -> aabB 7) S -> aabb Here, A string of n(n=4) letters has exactly 2n-1(2*4-1=7) steps .