Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.

Slides:



Advertisements
Similar presentations
Context-Free and Noncontext-Free Languages
Advertisements

Lecture 10: Context-Free Languages Contextually David Evans
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 13: Turing Machines.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CS 3240: Languages and Computation Properties of Context-Free Languages.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Turing machines Sipser 2.3 and 3.1 (pages )
Turing machines Sipser 2.3 and 3.1 (pages )
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
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.
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
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.
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Cs3102: Theory of Computation Class 10: DFAs in Practice Spring 2010 University of Virginia David Evans.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
Pushdown Automata (PDAs)
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.
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
Context-Free and Noncontext-Free Languages Chapter 13 1.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
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.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
Context-Free and Noncontext-Free Languages Chapter 13.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
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 2670 Introduction to Theory of Computing October 13, 2005.
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.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
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 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:
Bottom-up parsing Pumping Theorem for CFLs MA/CSSE 474 Theory of Computation.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Context-Free and Noncontext-Free Languages Chapter 13.
Lecture 17 Oct 25, 2011 Section 2.1 (push-down automata)
Context-Free Grammars
فصل دوم Context-Free Languages
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Intro to Theory of Computation
Presentation transcript:

cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans

Menu Computing Model for CFGs Non-CFLs: languages that cannot be recognized by NDPDA or CFG

s All Languages Regular Languages Can be recognized by some DFA Finite Languages Context-Free Languages

Computing Model for CFG There can be multiple rules for one variable: S  0S0 S  1S1 S  ε

Computing Model for CFG There can be multiple rules for one variable: Can we define an extended transition function for a CFG?

CFG Extended Transition Function Should we have really called this  *? Unlike the other  * functions we have defined, this one cannot (typically) actually be calculated!

Acceptance Rule for CFG

s All Languages Regular Languages Can be recognized by some DFA Finite Languages Context-Free Languages What can’t a CFG/NPDA do?

Recall: Non-Regular Languages q0q0 qzqz x y z qiqi Finite number of configurations (only the state). If string is long enough, some state must repeat If configuration repeats, can repeat any number of times. Does this work for NPDAs?

How many PDA configurations? For a nondeterministic PDA how many different machine configurations are possible? q2q2 ε, ε  +

Are NPDAs/CFGs all powerful!?

Limits of NPDA/CFGs Pushdown Automata Finite number of states and stack symbols Can only read top symbol on stack Context-Free Grammar Finite number of variables and rules Left side of rule is a single variable Pumping Lemma for Context-Free Languages: we will prove it for CFGs Because we proved L(NPDA) = L(CFG), this pumping lemma applies to NPDAs also – but its much tougher to see why. A convincing proof of the CFL pumping lemma that does not use CFG- equivalence is worth a challenge bonus (exemption from Exam 1).

Pumping Lemma for CFLs S  AbcD A  Sab … G has a finite number of variables and rules. If A is a CFL, there exists some CFG G that generates A. b = maximum number of symbols on right side of any rule What is the longest string G could produce in h replacement steps?

S  SSSS S  0 S SSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS … b b0b0 b1b1 b2b2 h For parse tree height h, maximum length string is  b h.

CFG Repetition If A is a CFL, there exists some CFG G that generates A where b is the maximum number of symbols on the right side of a rule. There is some string s  A with length How do we know such a string exists? Because of the maximum length property, we know it takes at least |V| steps to derive s.

S   X Because of the maximum length property, we know it takes at least |V| steps to derive s : for some X  V, X must be on the left side of a chosen rule more than once! X   s = u v x y z

S   X X   u v x y z G is context-free. Wherever variable A appears, it can be replaced the same way. X   yv s’ = uvvxyyz

A more powerful language class needs a more powerful pumping lemma!

Pumping Lemma for CFLs Player 1: picks h (maximum number of variables) and b (maximum number of symbols on right side of rule). Let p = b h+1. Player 2: picks s  A, |s|  p Player 1: picks u,v,x,y,z such that s = uvxyz and |vy| > 0 and |vxy|  p. Player 2: picks i  0. Player 2 wins if uv i xy i z  A. If Player 2 can always win, A is not context free! Player 2 wins if uv i xy i z  A. If Player 2 can always win, A is not context free!

Pumping Lemma for CFLs Player 1: picks h (maximum number of variables) and b (maximum number of symbols on right side of rule). Let p = b h+1. Player 2: picks s  A, |s|  p Player 1: picks u,v,x,y,z such that s = uvxyz and |vy| > 0 and |vxy|  p. Player 2: picks i  0. Player 2 wins if uv i xy i z  A. If Player 2 can always win, A is not context free! Player 2 wins if uv i xy i z  A. If Player 2 can always win, A is not context free! Simple way to prove non-context-free languages are non-regular: Pick u = ε, v = ε and we have the PL for regular languages!

Example:

Charge PS3: only one week (but shorter than PS2) Exam 1: March 2 (two weeks from today) Thursday – Closure properties for CFLs – DFAs, CFGs, and Compilers