Homework #7 Solutions. #1. Use the pumping lemma for CFL’s to show L = {a i b j a i b j | i, j > 0} is not a CFL. Proof by contradiction using the Pumping.

Slides:



Advertisements
Similar presentations
Pumping Lemma Problem: Solution:
Advertisements

4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory VII.
CS 3240: Languages and Computation Properties of Context-Free Languages.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Turing machines Sipser 2.3 and 3.1 (pages )
Turing machines Sipser 2.3 and 3.1 (pages )
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
CS5371 Theory of Computation
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
1 CSC 3130: Automata theory and formal languages Tutorial 4 KN Hung Office: SHB 1026 Department of Computer Science & Engineering.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
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 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.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.3: Non-Context-Free Languages) David Martin With.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
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.
Prof. Busch - LSU1 Pumping Lemma for Context-free 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.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Chapter 12: Context-Free Languages and Pushdown Automata
1 Computer Language Theory Chapter 2: Context-Free Languages.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
1 Homework #7 (Models of Computation, Spring, 2001) Due: Section 1; April 16 (Monday) Section 2; April 17 (Tuesday) 2. Covert the following context-free.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
Context-Free Grammars – Chomsky Normal Form Lecture 16 Section 2.1 Wed, Sep 26, 2007.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
1 Properties of Context-Free Languages Is a certain language context-free? Is the family of CFLs closed under a certain operation?
Context-free Languages
Context-free Languages Chapter 2. Ambiguity.
Section 12.4 Context-Free Language Topics
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
Test # 2 Friday, November 2 nd Covers all of Chapter 2 Test # 2 will be 20% of final score (same as Test #1) Final Exam will be 40% of the final score.
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.
Non-Context-Free Languages Section 2.3 CSC 4170 Theory of Computation.
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.
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,
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Transparency No. 1 Formal Language and Automata Theory Homework 5.
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:
CS 461 – Oct. 5 Pumping lemma #2 –Understanding –Use to show a language is not a CFL Next: Applications of CFLs –Expression grammars and Compiling.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
7. Properties of Context-Free Languages
Jaya Krishna, M.Tech, Assistant Professor
7. Properties of Context-Free Languages
فصل دوم Context-Free Languages
Pumping Lemma for Context-free Languages
Key Answers for Homework #7
Applications of Regular Closure
Presentation transcript:

Homework #7 Solutions

#1. Use the pumping lemma for CFL’s to show L = {a i b j a i b j | i, j > 0} is not a CFL. Proof by contradiction using the Pumping Lemma. Assume L is context-free. L is obviously infinite, since i, j > 0. Pick a string w in L with length |w| > m, for example, w = a m b m a m b m, j > 0. Then w = uvxyz with |vxy| 1 and uv i xy i z is also in L for all i > 0 The analyses to the right show that this language cannot be context-free because uv 2 xy 2 z is not in L. Case 7) vxy overlaps 2 nd a m and 2 nd b m : Same as #3 Case 6) vxy is within 2 nd b m : Same as #2 Case 5) vxy is within 2 nd a m : Same as #1 Case 4) vxy overlaps first b m and second a m : Similar logic to #3 3c) v is all a’s, y is all b’s: uv 2 xy 2 z = a m+|v| b m+|y| a m b m  L because either m+|v|  m, or m+|y|  m 3b) y itself straddles a’s and b’s: similar to #3a 3a) v itself straddles a’s and b’s: pumping v would produce strings of the form a…a(ab) i b…ba m b m which are not in L Case 3) vxy overlaps first a m and first b m uv 2 xy 2 z = a m b m+|v|+|y| a m b m  L … similar to #1 Case 2) vxy is within first b m uv 2 xy 2 z = a m+|v|+|y| b m a m b m  L because m+|v|+|y|  m because |vy| > 0 Case 1) vxy is within first a m

a)Show that each of these languages is context- free. G 1 S  AC|  A  aAbb|  C  cC|  L 1 : |b’s| = 2  |a’s| L 2 : |c’s| = 2  |b’s| So L 1  L 2 = { a n b 2n c 4n | n  0 } #2. Consider the following 2 languages: G 2 S  AB|  A  Aa|  B  bBcc| 

2b) Is L1∩ L2 context-free? Justify your answer. L 1 : |b’s| = 2  |a’s| L 2 : |c’s| = 2  |b’s| So L 1  L 2 = { a n b 2n c 4n | n  0 } Not context-free (easy use of pumping lemma.) Pick z = a m b 2m c 4m

#3. Convert the following grammar to Chomsky Normal Form S  A | A B a | A b A A  A a |  B  B b | BC C  C B | C A | b B 1. Eliminate  -productions: S  A | A B a | A b A | B a | b A | A b |  A  A a | a B  B b | BC C  C B | C A | b B | C

#3 cont. 2. Remove unit productions S  A a | a | A B a | A b A | B a | b A | A b |  A  A a | a B  B b | BC C  C B | C A | b B 3. a) Eliminate useless (non-generating) symbols and all productions involving one or more of those symbols. S  A a | a | A b A | b A | A b A  A a | a b) Eliminate unreachable symbols: None 4. Convert to CNF: S   A A 1 | A B |B 1 A | A B 1 A 1  a B  B 1 A B 1  b A  A A 1 | a

#4. Let G be a grammar in Chomsky Normal Form. Fill in the following table.  log n  + 1 n2n-1na1a2a3…ana1a2a3…an 4595 a1a2a3a4a5a1a2a3a4a a1a2a3a4a1a2a3a a1a2a3a1a2a a1a2a1a a1a  min depth(tree) max depth (tree) Length (derivation) |w| w