Closure Properties of Context-Free languages

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Fall 2003Costas Busch - RPI1 Properties of Context-Free languages.
The Pumping Lemma for CFL’s
Properties of Regular Languages
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Prof. Busch - LSU1 Properties of Context-Free languages.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Regular Expressions.
Courtesy Costas Busch - RPI1 Positive Properties of Context-Free languages.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
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 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
1 Languages and Finite Automata or how to talk to machines...
Costas Busch - RPI1 Positive Properties of Context-Free languages.
Fall 2003Costas Busch - RPI1 Decidable Problems of Regular Languages.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Fall 2006Costas Busch - RPI1 Properties of Regular Languages.
Prof. Busch - RPI1 Decidable Problems of Regular Languages.
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 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
1 A Non Context-Free Language (We will prove it at the next class)
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Costas Busch - LSU1 Properties of Context-Free languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
Lecture 16 Cocke-Younger-Kasimi Parsing Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE.
Formal Languages, Automata and Models of Computation
Languages.
Standard Representations of Regular Languages
Properties of Context-Free Languages
PDAs Accept Context-Free Languages
Properties of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Linear Bounded Automata LBAs
7. Properties of Context-Free Languages
NPDAs Accept Context-Free Languages
Simplifications of Context-Free Grammars
Formal Language & Automata Theory
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
Single Final State for NFA
CSE 105 theory of computation
Decision Properties of Regular Languages
CSE322 PROPERTIES OF REGULAR LANGUAGES
Properties of Regular Languages
COSC 3340: Introduction to Theory of Computation
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
4. Properties of Regular Languages
7. Properties of Context-Free Languages
Deterministic PDAs - DPDAs
Decidable Problems of Regular Languages
The Pumping Lemma for CFL’s
Properties of Context-Free languages
… NPDAs continued.
Applications of Regular Closure
CSE 105 theory of computation
NFAs accept the Regular Languages
Normal Forms for Context-free Grammars
CSE 105 theory of computation
Presentation transcript:

Closure Properties of Context-Free languages Summer 2004 COMP 335

Union Context-free languages are closed under: Union is context free Summer 2004 COMP 335

Example Language Grammar Union Summer 2004 COMP 335

For context-free languages with context-free grammars In general: For context-free languages with context-free grammars and start variables The grammar of the union has new start variable and additional production Summer 2004 COMP 335

Concatenation Context-free languages are closed under: Concatenation is context free is context free is context-free Summer 2004 COMP 335

Example Language Grammar Concatenation Summer 2004 COMP 335

For context-free languages with context-free grammars In general: For context-free languages with context-free grammars and start variables The grammar of the concatenation has new start variable and additional production Summer 2004 COMP 335

Star Operation Context-free languages are closed under: Star-operation is context free is context-free Summer 2004 COMP 335

Example Language Grammar Star Operation Summer 2004 COMP 335

For context-free language with context-free grammar and start variable In general: For context-free language with context-free grammar and start variable The grammar of the star operation has new start variable and additional production Summer 2004 COMP 335

Negative Properties of Context-Free Languages Summer 2004 COMP 335

Intersection Context-free languages are not closed under: intersection is context free is context free not necessarily context-free Summer 2004 COMP 335

Example Context-free: Context-free: Intersection NOT context-free Summer 2004 COMP 335

Complement Context-free languages are not closed under: complement is context free not necessarily context-free Summer 2004 COMP 335

Example Context-free: Context-free: Complement NOT context-free Summer 2004 COMP 335

Intersection of Context-free languages and Regular Languages Summer 2004 COMP 335

a context-free language and a regular language The intersection of a context-free language and a regular language is a context-free language context free regular context-free Summer 2004 COMP 335

Construct a new NPDA machine that accepts DFA for NPDA for regular context-free Construct a new NPDA machine that accepts simulates in parallel and Summer 2004 COMP 335

NPDA DFA transition transition NPDA transition Summer 2004 COMP 335

NPDA DFA transition NPDA transition Summer 2004 COMP 335

NPDA DFA initial state initial state NPDA Initial state Summer 2004 COMP 335

NPDA DFA final state final states NPDA final states Summer 2004 COMP 335

Example: context-free NPDA Summer 2004 COMP 335

regular DFA Summer 2004 COMP 335

context-free Automaton for: NPDA Summer 2004 COMP 335

simulates in parallel and In General: simulates in parallel and accepts string if and only if accepts string and accepts string Summer 2004 COMP 335

Therefore: is NPDA is context-free is context-free Summer 2004 COMP 335

Applications of Regular Closure Summer 2004 COMP 335

a context-free language and a regular language The intersection of a context-free language and a regular language is a context-free language Regular Closure context free regular context-free Summer 2004 COMP 335

An Application of Regular Closure Prove that: is context-free Summer 2004 COMP 335

We know: is context-free Summer 2004 COMP 335

We also know: is regular is regular Summer 2004 COMP 335

context-free regular context-free is context-free (regular closure) Summer 2004 COMP 335

Another Application of Regular Closure Prove that: is not context-free Summer 2004 COMP 335

Impossible!!! If is context-free Then context-free regular (regular closure) Then context-free regular context-free Impossible!!! Therefore, is not context free Summer 2004 COMP 335

Decidable Properties of Context-Free Languages Summer 2004 COMP 335

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

Empty Language Question: for context-free grammar find if Algorithm: Remove useless variables Check if start variable is useless Summer 2004 COMP 335

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

Example: Infinite language Dependency graph Summer 2004 COMP 335

Summer 2004 COMP 335