Applications of Regular Closure

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

The Pumping Lemma for CFL’s
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
Fall 2004COMP 3351 Simplifications of Context-Free Grammars.
CS 3240: Languages and Computation Properties of Context-Free Languages.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
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.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
Costas Buch - RPI1 Simplifications of Context-Free Grammars.
Fall 2003Costas Busch - RPI1 Decidable Problems of Regular Languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule Substitute Equivalent grammar.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
1 More Applications of The Pumping Lemma. 2 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Prof. Busch - RPI1 Decidable Problems of Regular Languages.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-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 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch1 More Applications of The Pumping Lemma.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1 L= { w c w R : w  {a, b}* } is accepted by the PDA below. Use a construction like the one for intersection for regular languages to design a PDA that.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Properties of Context-Free Languages
PROPERTIES OF REGULAR LANGUAGES
7. Properties of Context-Free Languages
NPDAs Accept Context-Free Languages
Simplifications of Context-Free Grammars
Simplifications of Context-Free Grammars
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Definition: Let G = (V, T, P, S) be a CFL
7. Properties of Context-Free Languages
COSC 3340: Introduction to Theory of Computation
Deterministic PDAs - DPDAs
Pumping Lemma for Context-free Languages
Closure Properties of Context-Free languages
Elementary Questions about Regular Languages
Non-regular languages
Properties of Context-Free Languages
Decidable Problems of Regular Languages
More Applications of the Pumping Lemma
COSC 3340: Introduction to Theory of Computation
Chapter 2 Context-Free Language - 02
DPDA Deterministic PDA
More Applications of The Pumping Lemma
Normal Forms for Context-free Grammars
Presentation transcript:

Applications of Regular Closure

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

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

We know: is context-free

We also know: is regular is regular

context-free regular (regular closure) is context-free is context-free

Another Application of Regular Closure Prove that: is not context-free

Impossible!!! If is context-free Then context-free regular (regular closure) Then context-free regular context-free Impossible!!! Therefore, is not 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: Remove useless variables Check if start variable is useless

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

Example: Infinite language Dependency graph

The Pumping Lemma for Context-Free Languages

Take an infinite context-free language Generates an infinite number of different strings Example:

Variables are repeated A derivation:

Derivation tree string

Derivation tree string repeated

Repeated Part

Another possible derivation

Therefore, the string is also generated by the grammar

We know: We also know this string is generated:

We know: Therefore, this string is also generated:

We know: Therefore, this string is also generated:

We know: Therefore, this string is also generated:

Therefore, knowing that is generated by grammar , we also know that is generated by

In general: We are given an infinite context-free grammar Assume has no unit-productions no -productions

> Take a string with length bigger than (Number of productions) x (Largest right side of a production) Consequence: Some variable must be repeated in the derivation of

String Last repeated variable repeated

Possible derivations:

We know: This string is also generated:

We know: This string is also generated: The original

We know: This string is also generated:

We know: This string is also generated:

We know: This string is also generated:

Therefore, any string of the form is generated by the grammar

Therefore, knowing that we also know that

Observation: Since is the last repeated variable

Observation: Since there are no unit or productions

The Pumping Lemma: For infinite context-free language there exists an integer such that for any string we can write with lengths and it must be:

Applications of The Pumping Lemma

Non-context free languages

Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Pumping Lemma gives a magic number such that: Pick any string with length We pick:

We can write: with lengths and

Pumping Lemma says: for all

We examine all the possible locations of string in

Case 1: is within

Case 1: and consist from only

Case 1: Repeating and

Case 1: From Pumping Lemma:

Case 1: From Pumping Lemma: However: Contradiction!!!

Case 2: is within

Case 2: Similar analysis with case 1

Case 3: is within

Case 3: Similar analysis with case 1

Case 4: overlaps and

Case 4: Possibility 1: contains only contains only

Case 4: Possibility 1: contains only contains only

Case 4: From Pumping Lemma:

Case 4: From Pumping Lemma: However: Contradiction!!!

Case 4: Possibility 2: contains and contains only

Case 4: Possibility 2: contains and contains only

Case 4: From Pumping Lemma:

Case 4: From Pumping Lemma: However: Contradiction!!!

Case 4: Possibility 3: contains only contains and

Case 4: Possibility 3: contains only contains and Similar analysis with Possibility 2

Case 5: overlaps and

Case 5: Similar analysis with case 4

There are no other cases to consider (since , string cannot overlap , and at the same time)

In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion: is not context-free