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

Contenu connexe

Tendances

Tendances (20)

TOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal FormTOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal Form
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Lesson 05
Lesson 05Lesson 05
Lesson 05
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
Pumping lemma for cfl
Pumping lemma for cflPumping lemma for cfl
Pumping lemma for cfl
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.ppt
 
Code generation
Code generationCode generation
Code generation
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Properties of Regular Expressions
Properties of Regular ExpressionsProperties of Regular Expressions
Properties of Regular Expressions
 
2.7 normal forms cnf & problems
2.7 normal forms  cnf & problems2.7 normal forms  cnf & problems
2.7 normal forms cnf & problems
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
 
Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfg
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 

En vedette

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
 
Hospital Management System
Hospital Management SystemHospital Management System
Hospital Management SystemPranil Dukare
 

En vedette (15)

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
 
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
 
Hospital Management System
Hospital Management SystemHospital Management System
Hospital Management System
 

Similaire à 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
 
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
 
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
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructionswarda aziz
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauagesdanhumble
 

Similaire à 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
 
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
 
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
 
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
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauages
 

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

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

Dernier

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
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
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
 

Dernier (20)

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
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
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
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
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...
 

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 .