SlideShare a Scribd company logo
1 of 10
Convert PDA to CFG
• Given a PDA M = (Q, €, F, 6, qO, ZO, {}), we construct a CFG G = (V,
€, P, S)
– V = {[q, A, p] | q, p are in Q, A is in F+{S}}
– P is a set of productions constructed as follows:
• S c [qO, ZO, q] for all q in Q
• for each (p, s) in 6(q, a, A), where a is in € + {s}, we define
production:
[q, A, p] c a € + {s} and B are
in
• for each (p, B1B2…Bm) in 6(q, a, A), where a is
in
F [q, A, qm+1] -> a [q1, B1, q2] [q2, B2, q3] …[qm, Bm, qm+1]
for all q, q1, q2, …, qm+1 in Q
Deterministic PDA’s
• A PDA is deterministic if there is at most one move for any
input symbol, any top stack symbol, and at any state.
• A no move or move without advancing input string are
possible in a deterministic PDA.
• A move without advancing input string implies that no
other move exists.
• The pushdown automaton for wcwR is deterministic.
Deterministic PDA’s
• The set of languages accepted by deterministic PDD’s is
only a subset of the languages accepted by
nondeterministic PDA’s.
• A regular language is language accepted by a DPDA.
• Not all languages accepted by DPAD are regular.
• All languages accepted by DPAD have an unambiguous
CFG.
• Not all unambiguous languages are accepted by DPAD.
Grammatical Format
• Eliminate useless symbols
– derivable from S
– can derive a string of terminals
• Eliminate s-productions
– A -> s is an s-production.
• Eliminate unit productions
– A -> B is a unit production if both A and B are variables.
• For any CFG G and s is not in L(G), there exists
an equivalent context -free grammar with no
useless symbol, s-production, and unit production.
Eliminating Useless Symbols
• Given a CFG G = (V, T, P, S), withL(G ) is not empty, we
can effectively find an equivalent CFG G’ = (V’, T, P’, S)
such that for each A in V’ there is some w in T* for which
A=>*w.
• Given a CFG G = (V, T, P, S), we can effectively find an
equivalent CFG G’ = (V’, T’, P’, S) such that for each X in
(V’+T’) there exist a and þ in (V’+T’)* for which
S =>* aXþ.
Eliminatingssss-productions
• If s is not in L(G), we can eliminate all s-productions.
• A variable is nullable if A =>* s.
• For A -> X1X2…Xn, add the following productions A ->
Y1Y2…Yn
– If Xi is not nullable, then Yi = Xi.
– If Xi is nullable, then Yi = Xi or Yi = s.
– If Xi is nullable for (i = 1, …, n), don’t add A => s.
Eliminating Unit Productions
• If A=>*B and for all nonunit production B->X, add
– A->X
• Eliminate all unit productions.
Eliminating Useless Symbols and sss
and Unit Productions
1. Eliminate s-productions
2. Eliminate unit productions
3. Eliminate useless symbols.
Chomsky Normal Form (CNF)
• If aCFG has only productions of the form, it is called
Chomsky Normal Form (CNF)
– A -> BC, or
– A -> a
where A, B, and C are variables and a is a terminal.
• Any context-free language with e can be generated by a
context-free grammar in which all productions are in CNF.
Chomsky Normal Form (CNF)
• If aCFG has only productions of the form, it is called
Chomsky Normal Form (CNF)
– A -> BC, or
– A -> a
where A, B, and C are variables and a is a terminal.
• Any context-free language with e can be generated by a
context-free grammar in which all productions are in CNF.

More Related Content

What's hot

What's hot (20)

5 csp
5 csp5 csp
5 csp
 
push down automata
push down automatapush down automata
push down automata
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
1.2. introduction to automata theory
1.2. introduction to automata theory1.2. introduction to automata theory
1.2. introduction to automata theory
 
4.6 halting problem
4.6 halting problem4.6 halting problem
4.6 halting problem
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Informed search
Informed searchInformed search
Informed search
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Np hard
Np hardNp hard
Np hard
 
Planning
PlanningPlanning
Planning
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 

Viewers also liked

Viewers also liked (14)

Cs419 lec7 cfg
Cs419 lec7   cfgCs419 lec7   cfg
Cs419 lec7 cfg
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
L3 cfg
L3 cfgL3 cfg
L3 cfg
 
Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7Theory of Computation - Lectures 6 & 7
Theory of Computation - Lectures 6 & 7
 
Payroll Management System
Payroll Management SystemPayroll Management System
Payroll Management System
 
Data Flow Diagram
Data Flow DiagramData Flow Diagram
Data Flow Diagram
 
Payroll Management System SRS
Payroll Management System SRSPayroll Management System SRS
Payroll Management System SRS
 
Dfd final
Dfd finalDfd final
Dfd final
 
Dfd and flowchart
Dfd and flowchartDfd and flowchart
Dfd and flowchart
 
Example of dfd with answer
Example of dfd with answerExample of dfd with answer
Example of dfd with answer
 
Data flow diagrams (2)
Data flow diagrams (2)Data flow diagrams (2)
Data flow diagrams (2)
 
Data flow diagram
Data flow diagram Data flow diagram
Data flow diagram
 
Dfd examples
Dfd examplesDfd examples
Dfd examples
 

Similar to Pda to cfg h2

Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Srimatre K
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptxAkhilJoseph63
 
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
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal formsAkila Krishnamoorthy
 
ContextFreeGrammars.pptx
ContextFreeGrammars.pptxContextFreeGrammars.pptx
ContextFreeGrammars.pptxPEzhumalai
 
ContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptxContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptxviswanath kani
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataeugenesri
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataparmeet834
 
PushdownAutomata.ppt
PushdownAutomata.pptPushdownAutomata.ppt
PushdownAutomata.pptRSRS39
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaRushabh2428
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauagesdanhumble
 
Conversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxConversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxRishikesh990460
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cflSampath Kumar S
 
Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...appasami
 
Unicode Cjk Compatible Variations
Unicode Cjk Compatible VariationsUnicode Cjk Compatible Variations
Unicode Cjk Compatible VariationsJoe Jiang
 

Similar to Pda to cfg h2 (20)

Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptx
 
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
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Ch4a
Ch4aCh4a
Ch4a
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
ContextFreeGrammars.pptx
ContextFreeGrammars.pptxContextFreeGrammars.pptx
ContextFreeGrammars.pptx
 
ContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptxContextFreeGrammars (1).pptx
ContextFreeGrammars (1).pptx
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
PushdownAutomata.ppt
PushdownAutomata.pptPushdownAutomata.ppt
PushdownAutomata.ppt
 
Pda
PdaPda
Pda
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauages
 
Conversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptxConversion of CFG to CNF.pptx
Conversion of CFG to CNF.pptx
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 
Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...
 
Unicode Cjk Compatible Variations
Unicode Cjk Compatible VariationsUnicode Cjk Compatible Variations
Unicode Cjk Compatible Variations
 
Ch03
Ch03Ch03
Ch03
 

More from Rajendran

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower boundsRajendran
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsRajendran
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower boundsRajendran
 
Red black tree
Red black treeRed black tree
Red black treeRajendran
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theoremRajendran
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theoremRajendran
 
Master method
Master method Master method
Master method Rajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisRajendran
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisRajendran
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of QuicksortRajendran
 
Np completeness
Np completenessNp completeness
Np completenessRajendran
 
computer languages
computer languagescomputer languages
computer languagesRajendran
 

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Red black tree
Red black treeRed black tree
Red black tree
 
Hash table
Hash tableHash table
Hash table
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Master method
Master method Master method
Master method
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lower bound
Lower boundLower bound
Lower bound
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
 
Np completeness
Np completenessNp completeness
Np completeness
 
computer languages
computer languagescomputer languages
computer languages
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 

Pda to cfg h2

  • 1. Convert PDA to CFG • Given a PDA M = (Q, €, F, 6, qO, ZO, {}), we construct a CFG G = (V, €, P, S) – V = {[q, A, p] | q, p are in Q, A is in F+{S}} – P is a set of productions constructed as follows: • S c [qO, ZO, q] for all q in Q • for each (p, s) in 6(q, a, A), where a is in € + {s}, we define production: [q, A, p] c a € + {s} and B are in • for each (p, B1B2…Bm) in 6(q, a, A), where a is in F [q, A, qm+1] -> a [q1, B1, q2] [q2, B2, q3] …[qm, Bm, qm+1] for all q, q1, q2, …, qm+1 in Q
  • 2. Deterministic PDA’s • A PDA is deterministic if there is at most one move for any input symbol, any top stack symbol, and at any state. • A no move or move without advancing input string are possible in a deterministic PDA. • A move without advancing input string implies that no other move exists. • The pushdown automaton for wcwR is deterministic.
  • 3. Deterministic PDA’s • The set of languages accepted by deterministic PDD’s is only a subset of the languages accepted by nondeterministic PDA’s. • A regular language is language accepted by a DPDA. • Not all languages accepted by DPAD are regular. • All languages accepted by DPAD have an unambiguous CFG. • Not all unambiguous languages are accepted by DPAD.
  • 4. Grammatical Format • Eliminate useless symbols – derivable from S – can derive a string of terminals • Eliminate s-productions – A -> s is an s-production. • Eliminate unit productions – A -> B is a unit production if both A and B are variables. • For any CFG G and s is not in L(G), there exists an equivalent context -free grammar with no useless symbol, s-production, and unit production.
  • 5. Eliminating Useless Symbols • Given a CFG G = (V, T, P, S), withL(G ) is not empty, we can effectively find an equivalent CFG G’ = (V’, T, P’, S) such that for each A in V’ there is some w in T* for which A=>*w. • Given a CFG G = (V, T, P, S), we can effectively find an equivalent CFG G’ = (V’, T’, P’, S) such that for each X in (V’+T’) there exist a and þ in (V’+T’)* for which S =>* aXþ.
  • 6. Eliminatingssss-productions • If s is not in L(G), we can eliminate all s-productions. • A variable is nullable if A =>* s. • For A -> X1X2…Xn, add the following productions A -> Y1Y2…Yn – If Xi is not nullable, then Yi = Xi. – If Xi is nullable, then Yi = Xi or Yi = s. – If Xi is nullable for (i = 1, …, n), don’t add A => s.
  • 7. Eliminating Unit Productions • If A=>*B and for all nonunit production B->X, add – A->X • Eliminate all unit productions.
  • 8. Eliminating Useless Symbols and sss and Unit Productions 1. Eliminate s-productions 2. Eliminate unit productions 3. Eliminate useless symbols.
  • 9. Chomsky Normal Form (CNF) • If aCFG has only productions of the form, it is called Chomsky Normal Form (CNF) – A -> BC, or – A -> a where A, B, and C are variables and a is a terminal. • Any context-free language with e can be generated by a context-free grammar in which all productions are in CNF.
  • 10. Chomsky Normal Form (CNF) • If aCFG has only productions of the form, it is called Chomsky Normal Form (CNF) – A -> BC, or – A -> a where A, B, and C are variables and a is a terminal. • Any context-free language with e can be generated by a context-free grammar in which all productions are in CNF.