1 Module 31 Closure Properties for CFL’s –Kleene Closure –Union –Concatenation CFL’s versus regular languages –regular languages subset of CFL.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

Properties of Regular Languages
1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
Closure Properties of CFL's
1 Lecture 14 Language class LFSA –Study limits of what can be done with FSA’s –Closure Properties –Comparing to other language classes.
1 Module 19 LNFA subset of LFSA –Theorem 4.1 on page 131 of Martin textbook –Compare with set closure proofs Main idea –A state in FSA represents a set.
1 Module 9 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
1 Module 21 Closure Properties for LFSA using NFA’s –From now on, when I say NFA, I mean any NFA including an NFA- unless I add a specific restriction.
Lecture Note of 12/22 jinnjy. Outline Chomsky Normal Form and CYK Algorithm Pumping Lemma for Context-Free Languages Closure Properties of CFL.
1 Lecture 20 Regular languages are a subset of LFSA –algorithm for converting any regular expression into an equivalent NFA –Builds on existing algorithms.
1 Module 37 Showing CFL’s not closed under set intersection and set complement.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
1 Module 34 CFG --> PDA construction –Shows that for any CFL L, there exists a PDA M such that L(M) = L –The reverse is true as well, but we do not prove.
1 Homework #6 (Models of Computation, Spring, 2001) Due: Section 1; March 29 Section 2; March Let L be the language of the following grammar G 1.
104 Closure Properties of Regular Languages Regular languages are closed under many set operations. Let L 1 and L 2 be regular languages. (1) L 1  L 2.
1 Lecture 5 Topics –Closure Properties for REC Proofs –2 examples Applications.
1 Lecture 18 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference,
1 Lecture 32 CFG --> PDA construction –Shows that for any CFL L, there exists a PDA M such that L(M) = L –The reverse is true as well, but we do not prove.
1 Lecture 36 Attempt to prove that CFL’s are closed under intersection –Review previous constructions –Translate previous constructions to current setting.
1 Module 31 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union, concatenation.
Normal forms for Context-Free Grammars
1 Lecture 19 Closure Properties for LFSA using NFA’s –union second proof –concatenation –Kleene closure.
1 Lecture 20 LNFA subset of LFSA –Theorem 4.1 on page 105 of Martin textbook –Compare with set closure proofs Main idea –A state in FSA represents a set.
CS 3240 – Chapter 8.  Is a n b n c n context-free? CS Properties of Context-Free Languages2.
1 Background Information for the Pumping Lemma for Context-Free Languages Definition: Let G = (V, T, P, S) be a CFL. If every production in P is of the.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
1 Properties of Context-free Languages Reading: Chapter 7.
1 Dr. torng CFG → PDA construction Shows that for any CFL L, there exists a PDA M such that L(M) = L The reverse is true, but we skip the proof Parsing.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
TM Design Universal TM MA/CSSE 474 Theory of Computation.
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
1 Properties of Context-Free Languages Is a certain language context-free? Is the family of CFLs closed under a certain operation?
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
Lecture 10UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Context-Free and Noncontext-Free Languages Chapter 13 1.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Context-Free and Noncontext-Free Languages Chapter 13.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Formal Languages and Grammars
CFL Big Picture. Context Free Languages Conclusion We have studied the class of context free languages (CFL) We saw two different ways to express a CFL.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
1 Module 17 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference,
Transparency No. 1 Formal Language and Automata Theory Homework 5.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Lecture 6: Context-Free Languages
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
Closed book, closed notes
Language Theory Module 03.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Formal Language & Automata Theory
Natural Language Processing - Formal Language -
COP4620 – Programming Language Translators Dr. Manuel E. Bermudez
Definition: Let G = (V, T, P, S) be a CFL
Properties of Context-Free Languages
Closure Properties of Regular Languages
Closure Properties of Regular Languages
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

1 Module 31 Closure Properties for CFL’s –Kleene Closure –Union –Concatenation CFL’s versus regular languages –regular languages subset of CFL

2 Closure Properties for CFL’s Kleene Closure

3 CFL closed under Kleene Closure Let L be an arbitrary CFL Let G 1 be a CFG s.t. L(G 1 ) = L –G 1 exists by definition of L 1 in CFL Construct CFG G 2 from CFG G 1 Argue L(G 2 ) = L * There exists CFG G 2 s.t. L(G 2 ) = L * L * is a CFL

4 Visualization L*L* L CFL CFG’s Let L be an arbitrary CFL Let G 1 be a CFG s.t. L(G 1 ) = L –G 1 exists by definition of L 1 in CFL Construct CFG G 2 from CFG G 1 Argue L(G 2 ) = L * There exists CFG G 2 s.t. L(G 2 ) = L * L * is a CFL G1G1 G2G2

5 Algorithm Specification Input –CFG G 1 Output –CFG G 2 such that L(G 2 ) = CFG G 1 CFG G 2 A

6 Construction Input –CFG G 1 = (V 1, , S 1, P 1 ) Output –CFG G 2 = (V 2, , S 2, P 2 ) V 2 = V 1 union {T} – T is a new symbol not in V 1 or  S 2 = T P 2 = P 1 union ??

7 Closure Properties for CFL’s Kleene Closure Examples

8 Input grammar: –V = {S} –  = {a,b} –S = S –P: S → aa | ab | ba | bb Output grammar –V = –  = {a,b} –Start symbol is –P: Example 1 V 2 = V 1 union {T} T is a new symbol not in V 1 or  S 2 = T P 2 = P 1 union {T → ST | }

9 Input grammar: –V = {S, T} –  = {a,b} –Start symbol is T –P: T → ST | S → aa | ab | ba | bb Output grammar –V = –  = {a,b} –Start symbol is –P: Example 2 V 2 = V 1 union {T} T is a new symbol not in V 1 or  S 2 = T P 2 = P 1 union {T → ST | }

10 Construction for Set Union Input –CFG G 1 = (V 1, , S 1, P 1 ) –CFG G 2 = (V 2, , S 2, P 2 ) Output –CFG G 3 = (V 3, , S 3, P 3 ) V 3 = V 1 union V 2 union {T} –Variable renaming to insure no names shared between V 1 and V 2 – T is a new symbol not in V 1 or V 2 or  S 3 = T P 3 =

11 Construction for Set Concatenation Input –CFG G 1 = (V 1, , S 1, P 1 ) –CFG G 2 = (V 2, , S 2, P 2 ) Output –CFG G 3 = (V 3, , S 3, P 3 ) V 3 = V 1 union V 2 union {T} –Variable renaming to insure no names shared between V 1 and V 2 – T is a new symbol not in V 1 or V 2 or  S 3 = T P 3 =

12 CFL’s and regular languages

13 CFL Closure Properties What have we just proven –CFL’s are closed under Kleene closure –CFL’s are closed under set union –CFL’s are closed under set concatenation What can we conclude from these 3 results? –It follows that regular languages are a subset of CFL’s

14 Regular languages subset of CFL Similar to reg-exp to NFA-λ construction from module 22 –Base Case: {}, { }, {a}, {b} are regular languages over {a,b} P={}, P={S → }, P={S → a}, P={S → b} –Inductive Case: If L 1 and L 2 are are regular languages, then L 1 *, L 1 L 2, L 1 union L 2 are regular languages Use previous constructions to see that these resulting languages are also context-free

15 Other CFL Closure Properties We will show that CFL’s are NOT closed under many other set operations Examples include –set complement –set intersection –set difference

16 Language class hierarchy All languages over alphabet  RE REG H H Equal CFL REC ?