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.

Slides:



Advertisements
Similar presentations
Pumping Lemma Problem: Solution:
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
CSCI 3130: Formal languages and automata theory Tutorial 5
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
CS 3240: Languages and Computation Properties of Context-Free Languages.
CS21 Decidability and Tractability
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.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
1 Module 33 Non-context free languages –Intuition and Examples CFL Pumping Lemma –Comparison to regular language pumping lemma –What it means –Proof overview.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
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 Module 36 Non context-free languages –Examples and Intuition Pumping lemma for CFL’s –Pumping condition –No proof of pumping lemma –Applying pumping.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
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.
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.
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.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
1 Computer Language Theory Chapter 2: Context-Free Languages.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
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.
CS 461 – Oct. 7 Applications of CFLs: Compiling Scanning vs. parsing Expression grammars –Associativity –Precedence Programming language (handout)
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 Chapter 2. Ambiguity.
CS 461 – Sept. 19 Last word on finite automata… –Scanning tokens in a compiler –How do we implement a “state” ? Chapter 2 introduces the 2 nd model of.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
Complexity, etc. Homework. Comparison to computability. Big Oh notation. Sorting. Classwork/Homework: prepare presentation on specific sorts. Presentation.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
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.
Context Free Pumping Lemma. CFL Pumping Lemma A CFL pump consists of two non-overlapping substrings that can be pumped simultaneously while staying in.
Non-Context-Free Languages Section 2.3 CSC 4170 Theory of Computation.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
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.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Limitations.
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.
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 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 44 – Jan. 28 Pumping lemma #2 Applications to 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.
Context-Free Languages
Non-Context-Free Languages Sections: 2.3 page 123 October 17, 2008
Jaya Krishna, M.Tech, Assistant Professor
Context-Free Grammars
فصل دوم Context-Free Languages
CS 461 – Sept. 16 Review Pumping lemma Applications of FA:
Midterm #2 — Review problems
CS21 Decidability and Tractability
Chapter 2 Context-Free Language - 02
CS21 Decidability and Tractability
Limitations of pushdown automata
Intro to Theory of Computation
Presentation transcript:

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

Pumping lemma L is a CFL implies: There is a p, such that for any string s, |s| >= p We can break up s into 5 parts uvxyz: | v y | >= 1 | v x y | <= p and uv i xy i z  L. How does this differ from the first pumping lemma?

In other words If L is a CFL, then for practically any word w in L, we should be able to find 2 substrings within w located near each other that you can simultaneously pump in order to create more words in L. Contrapositive: If w is a word in L, and we can always create a word not in L by simultaneously pumping any two substrings in w that are near each other, then L is not a CFL.

Gist A string can grow in 2 places. –When we write recursive rules, we can add symbols to left or right of a variable. Ex.S  #A# A  ε | 1A2 Look at derivation of: #111…222# Even a complex rule like S  S1S1S2 can be “simplified”, and still only need 2 places to grow the string. –This is because any CFG can be written in such a way that there are no more than 2 symbols on the right side of .

Example L = { 1 n 2 n } should satisfy the pumping lemma. Let p = 2. Strings in L of length >= 2 are: { 12, 1122, , … }. All these words have both a 1 and a 2, which we can pump. Just make sure the 2 places to pump are within p symbols of each other. So let’s say they are in the middle. u v x y z 11111…1 1 ε ….2 Could p = 1 work?

Example 2 { w # w R }. Think about where we can grow. Let p = 3. All strings of length 3 or more look like w # w R where | w | >= 1. As a technicality, would other values of p work?

Non-CFLs It’s possible for a language to be non-CFL! Typically this will be a language that must simultaneously pump in 3+ places. Ex. How could we design a PDA for { 1 n 2 n 3 n }?

Adversary’s Revenge In Game #1, how did we win? Ex. { 0 n 1 n }. –Adversary chose p. –We chose s. –Adversary broke up s = xyz subject to constraints. –We were always able to pump and find words outside L. Game #2 strategy –Adversary’s constraints looser. The middle 3 parts have to be within p of each other. Can be anywhere in the string, not just in first p symbols of word.

{ 1 n 2 n 3 n } Let p be any number. Choose s = 1 p 2 p 3 p. Let s = uvxyz such that |vxy| = 1. Where can v and y be? –All 1’s –All 2’s –All 3’s –Straddling 1’s and 2’s –Straddling 2’s and 3’s In every case, can we find a word not in L?

More examples { 1 i 2 j 3 k : i < j < k } –What should we chose as s? –How can the word be split up? { w w } –Let s = 0 p 1 p 0 p 1 p. Where can v & y be? –Same section of 0’s and 1’s. –In neighboring sections –Either v or y straddles a border.