Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Chapter 5 Pushdown Automata
Fall 2004COMP 3351 Simplifications of Context-Free Grammars.
Prof. Busch - LSU1 Properties of Context-Free languages.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Positive Properties of Context-Free languages.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Costas Buch - RPI1 Simplifications of Context-Free Grammars.
1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Costas Busch - RPI1 Positive Properties of Context-Free languages.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
Fall 2003Costas Busch - RPI1 Decidable Problems of Regular Languages.
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule substitute B equivalent grammar.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule Substitute Equivalent grammar.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Prof. Busch - RPI1 Decidable Problems of Regular Languages.
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
1 A Non Context-Free Language (We will prove it at the next class)
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata (PDAs)
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Costas Busch - LSU1 Properties of Context-Free languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Formal Languages, Automata and Models of Computation
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1.Draw a parse tree for the following derivation: S  C A C  C A b b  b b A b b  b b B b b  b b a A a a b b  b b a b a a b b 2. Show on your parse.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
G. Pullaiah College of Engineering and Technology
Simplifications of Context-Free Grammars
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
Chapter 7 PUSHDOWN AUTOMATA.
NPDAs Accept Context-Free Languages
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Decidable Problems of Regular Languages
Chapter 2 Context-Free Language - 01
… NPDAs continued.
Applications of Regular Closure
Normal Forms for Context-free Grammars
Presentation transcript:

Grammar Set of variables Set of terminal symbols Start variable Set of Production rules

Example Grammar :

Definition: Context-Free Grammars Grammar Productions of the form: String of variables and terminals VariablesTerminal symbols Start variable Variable

Leftmost derivation: Rightmost derivation:

Derivation Tree

yield Derivation Tree

Simplifications of Context-Free Grammars

Example

Normal Forms for Context-free Grammars

Chomsky Normal Form Each productions has form: variable or terminal

Introduce variables for terminals:

Introduce intermediate variable:

Final grammar in Chomsky Normal Form: Initial grammar

Then, for every symbol : In productions: replace with Add production New variable:

Replace any production with New intermediate variables:

Greinbach Normal Form All productions have form: symbolvariables

Pushdown Automata PDAs

Pushdown Automaton -- PDA Input String Stack States

The States Input symbol Pop symbol Push symbol

top input stack Replace

Push top input stack

Pop top input stack

No Change top input stack

Pop top input stack Empty Stack empty The automaton HALTS No possible transition after

Pop top input stack A Possible Transition

Non-Determinism PDAs are non-deterministic Allowed non-deterministic transitions

Formalities for PDAs

Transition function:

Formal Definition Pushdown Automaton (PDA) States Input alphabet Stack alphabet Transition function Final states Stack start symbol Initial state

Instantaneous Description Current state Remaining input Current stack contents

A computation:

Deterministic PDAs - DPDAs

Deterministic PDA: DPDA Allowed transitions: (deterministic choices)

Allowed transitions: (deterministic choices)

Not allowed: (non deterministic choices)

PDAs Have More Power than DPDAs

Positive Properties of Context-Free languages

Context-free languages are closed under: Union is context free is context-free Union

Context-free languages are closed under: Concatenation is context free is context-free Concatenation

Context-free languages are closed under: Star-operation is context freeis context-free Star Operation

Negative Properties of Context-Free Languages

Context-free languages are not closed under: intersection is context free not necessarily context-free Intersection

Context-free languages are not closed under: complement is context freenot necessarily context-free Complement

Intersection of Context-free languages and Regular Languages

The intersection of a context-free language and a regular language is a context-free language context free regular context-free

An Application of Regular Closure Prove that: is context-free

Decidable Properties of Context-Free Languages

Membership Question: for context-free grammar find if string Membership Algorithms: Parsers Exhaustive search parser CYK parsing algorithm

Empty Language Question: for context-free grammar find if Algorithm: 1.Remove useless variables 2.Check if start variable is useless

Infinite Language Question: for context-free grammar find if is infinite Algorithm: 1. Remove useless variables 3. Create dependency graph for variables 4. If there is a loop in the dependency graph then the language is infinite 2. Remove unit and productions