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.

Slides:



Advertisements
Similar presentations
Properties of Regular Sets
Advertisements

6.2 Closure Properties of CFL's
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
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.
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 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
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.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
1 Lecture 5 Topics –Closure Properties for REC Proofs –2 examples Applications.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
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.
1 Module 31 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union, concatenation.
Courtesy Costas Busch - RPI1 Non-regular languages.
Normal forms for Context-Free Grammars
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.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
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.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Design contex-free grammars that generate: L 1 = { u v : u ∈ {a,b}*, v ∈ {a, c}*, and |u| ≤ |v| ≤ 3 |u| }. L 2 = { a p b q c p a r b 2r : p, q, r ≥ 0 }
1 State SymbolRead- Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
1 Problem of the Day: Factor (ab) k as xyz in all ways such that y ≠ ε.
1 Module 31 Closure Properties for CFL’s –Kleene Closure –Union –Concatenation CFL’s versus regular languages –regular languages subset of CFL.
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.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
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.
CS 203: Introduction to Formal Languages and Automata
Costas Busch - LSU1 Properties of Context-Free languages.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Critique this PDA for L= { u u R v v R : u ∈ {0,1}* and v ∈ {0,1}+ } u0εu0 u1εu1 uεεvε v00vε v11vε vεεfε sεεtε t0εt0 t1εt1 t00tε t11tε tεεuε After you.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
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.
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 Create a NDFA which accepts the language generated by this context-free grammar. Start symbol: S S → aa S S → ε S → M M → bbb M → ab M M → b S M → E.
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
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.
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Properties of Regular Languages 1.Closure 2.Union 3.Concatenation 4.Complement(Negation)
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.
Properties of Regular Languages
Formal Language & Automata Theory
PDAs Accept Context-Free Languages
Single Final State for NFA
DPDA Deterministic PDA
CSE322 PROPERTIES OF REGULAR LANGUAGES
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Properties of Context-Free Languages
Closure Properties of Regular Languages
Properties of Context-Free languages
DPDA Deterministic PDA
Convert to a DFA: Start state: Final States: State Symbol Read- Q E(Q)
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
NFAs accept the Regular Languages
Presentation transcript:

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 last class to design a PDA that accepts L.

2 No class or tutorial on Tuesday July 3: reading break is July 2-3 for May to August classes. During reading break: try doing problems on old midterm and final exams. Our final exam is fast approaching.

3 The worst question on the midterm was Question #4. These were on previous midterms. Make sure you know how to work all the questions on the old final exams and ask about them at the final exam tutorial if you are unsure of the answers. Results for Question #4: Number Correct Number of students

4

5 To organize your cases for the pumping lemma question, group according to first/last symbol of y: What happens if there is some c’s in x or in y?

6

7 Closure Properties of Context-free Languages Intersecting a context-free language and a regular language gives a context-free language. Context-free languages are closed under union, concatenation and Kleene star. Context-free languages are not closed under intersection or complement. Thought question: are they closed under difference/exclusive or?

8 Theorem: If L 1 is context-free and L 2 is regular then L 1 ⋂ L 2 is context-free. Proof: By construction. This proof is similar to the one on the assignment proving closure of regular languages under intersection.

9 L= { w c w R : w  {a, b}* } ⋂ a* c a* StateInputPopNext state Push saεsA sbεsB scεtε taAtε tbBtε Start state: s, Final State: {t}

10 Theorem: Context-free languages are closed under union, concatenation and Kleene star. Proof: By construction. Let G 1 = (V 1, Σ, R 1, S 1 ) and let G 2 = (V 2, Σ, R 2, S 2 ). We show how to construct a grammar G= (V, Σ, R S) for L(G 1 ) ⋃ L(G 2 ), L(G 1 ) ۰ L(G 2 ), and L(G 1 )*.

11 L 1 = { a n b 2n : n ≥ 0} S 1 → a S 1 bb S 1 → ε L 2 = { u u R v : u, v in {a, b} + } S 2 → U 2 V 2 U 2 → a U 2 a U 2 → b U 2 b U 2 → aa U 2 → bb V 2 → a V 2 V 2 → b V 2 V 2 → a V 2 → b

12 L 1 = { a n b 2n : n ≥ 0} S 1 → a S 1 bb S 1 → ε L 2 = { u u R v : u, v in {a, b} + } S 2 → U 2 V 2 U 2 → a U 2 a U 2 → b U 2 b U 2 → aa U 2 → bb V 2 → a V 2 V 2 → b V 2 V 2 → a V 2 → b UNION: Start symbol S S → S 1 S → S 2

13 L 1 = { a n b 2n : n ≥ 0} S 1 → a S 1 bb S 1 → ε L 2 = { u u R v : u, v in {a, b} + } S 2 → U 2 V 2 U 2 → a U 2 a U 2 → b U 2 b U 2 → aa U 2 → bb V 2 → a V 2 V 2 → b V 2 V 2 → a V 2 → b CONCATENATION: Start symbol S S → S 1 S 2

14 L 1 = { a n b 2n : n ≥ 0} S 1 → a S 1 bb S 1 → ε KLEENE STAR: Start symbol S S → S 1 S S → ε

15 L 2 = { u u R v : u, v in {a, b} + } S 2 → U 2 V 2 U 2 → a U 2 a U 2 → b U 2 b U 2 → aa U 2 → bb V 2 → a V 2 V 2 → b V 2 V 2 → a V 2 → b KLEENE STAR: Start symbol S S → S 2 S S → ε

16 Theorem: L = { a n b n c n : n ≥ 0} is not context-free. Proof: Next class using the pumping theorem for context-free languages. Today: assume it is true.

17 L 1 = { a p b q c r : p = q } Design a context-free grammar for L 1. L 2 = { a p b q c r : p = r } Design a PDA for L 2. This proves L 1 and L 2 are context-free. L 1 ⋂ L 2 = { a n b n c n : n ≥ 0}. Therefore, context-free languages are not closed under intersection.

18 L = { a n b n c n : n ≥ 0} L 1 = { a p b q c r : p ≠ q } L 2 = { a p b q c r : p ≠ r } L 3 = { a p b q c r : q ≠ r } The complement of L is NOT equal to L 1 ⋃ L 2 ⋃ L 3. Which strings are in the complement of L but not in L 1 ⋃ L 2 ⋃ L 3 ?

19 L = { a n b n c n : n ≥ 0} L 1 = { a p b q c r : p ≠ q } L 2 = { a p b q c r : p ≠ r } L 3 = { a p b q c r : q ≠ r } L 4 = { w  {a, b, c}* : w ∉ a* b* c*} L 1 ⋃ L 2 ⋃ L 3 ⋃ L 4 is context-free and is the complement of L. Therefore, context-free languages are not closed under complement.