Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

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

CSCI 3130: Formal languages and automata theory Tutorial 5
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR Dr. Cynthia Lee - UCSD - Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
CS 3240: Languages and Computation Properties of Context-Free Languages.
CS21 Decidability and Tractability
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
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.
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.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
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.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
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.
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.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
1 Computer Language Theory Chapter 2: Context-Free Languages.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
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.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
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.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
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.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
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,
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.
Lecture 6: Context-Free Languages
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
CSE 105 theory of computation
CSE 105 theory of computation
Intro to Theory of Computation
Context-Free Grammars
فصل دوم Context-Free Languages
CS21 Decidability and Tractability
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org

CONTEXT-FREE LANGUAGES PDA If a language isn’t regular, it just might be one of the…

Understanding Pushdown Automata The edge from q0 to q1 does what? a)Lets you go to q1 without reading any input (on epsilon) b)Lets you go to q1 on epsilon or ‘$’ c)Lets you go to q1 on ‘$’

Understanding Pushdown Automata In addition to what we said in the last question, the edge from q0 to q1 does what else? a)Pushes one entry onto the stack (epsilon) b)Pushes one entry onto the stack (‘$’) c)Pushes two entries onto the stack (epsilon and ‘$’) d)Pops two entries off the stack (epsilon and ‘$’)

Input “aabb” into this PDA. After “aa” has been read, what is on the stack? Tracing in a Pushdown Automaton a) b) c) d) e) top of stack bottom of stack  bb aa aa0 0aa ϵϵϵ

Which is the best description of the language of the given PDA? a){ w | number of b’s in w >= number of a’s in w} b){w | w = a n b n+1 for some n>=0} c){ w | w = a n b n+2 for some n>=0} d){ w | w = a n b 2n for some n>=0} e){w | w = 0a n b 2n 0 for some n>=0} Language of a Pushdown Automaton

Tracing in a Pushdown Automaton Which string is NOT accepted by this PDA? a) aabb b) abbbc c) abbccc d)aabcc e)None or more than one of the above

Tracing in a Pushdown Automaton Which choice depicts a stack state that occurs at some point during the successful* processing of the string “aaabbbc” on the given PDA? a) b) c) d) e)None of the above * Ignore all nondeterministic paths that end in rejecting/getting stuck. top of stack bottom of stack  aaabbbc #a a# #λ

Why did we push ‘#’ onto the stack? a)We didn’t have to, because we already “counted” the a’s by pushing them on the stack b)It’s something we do because of convention, but it isn’t necessary to correctness c)We did it to make sure that we didn’t cause a crash/error by trying to pop something off an empty stack d)It is necessary to correctness e)None or more than one of the above

THE CLASS OF CONTEXT-FREE LANGUAGES CFLs!

Which Venn diagram best represents the classes of languages we have studied? RLs CFLs RLs CFLs = RLs CFLs RLs (a)(b) (c)(d)(e) None of the above Note: CFLs = Context- Free Languages, RLs = Regular Languages

What methods can we use to prove/disprove each of these? RLs CFLs RLs CFLs = RLs CFLs RLs (a)(b) (c)(d) Note: CFLs = Context- Free Languages, RLs = Regular Languages

Famous People: Noam Chomsky In this class, you know him as the namesake of “Chomsky Normal Form” A linguist who has taught at MIT for 55 years Famous for: Developed theories of conetxt-free grammars for analysis of human language – A mathematical model of language – Discoveries crossed over into Computer Science Perhaps now equally well known for his outspoken criticism of US foreign policy and his radical political views – Anarchist – Vehement war critic, war on drugs critic – Co-wrote Manufacturing Consent, argues that the media in our society is harming democracy and promoting corporations and consumerism

CONTEXT-FREE PUMPING LEMMA Proving that languages that are NOT context-free

Limits of Context-Free Languages What are the limitations of Context-Free languages What are the limitations of PDA? – Stack size has no limit (infinite stack) – ….BUT, there’s only one of them – Stack can only be accessed at the top What does that mean intuitively? When would you need more than one stack? Regular Context-Free Not Context-Free

PDA Language is 0 n 1 2n Can we change this so it is 0 n 1 2n 0 n ?

Classic Not-Context-Free Language a n b n c n for some n>=0 INTUITIVELY, the problem is that a PDA recognizing this language would try to: – Push on the stack to count the ‘a’ section, then – Pop off the stack to match the ‘b’ section, then – You’ve “forgotton” n, now you can’t count the ‘c’ section Aside: what could you do with a second stack? THIS IS NOT A PROOF!! – Maybe there is a completely different way to approach this problem using PDA, which we just didn’t think of yet – But, turns out, there is no way to do this, and we can actually prove that

Aside: Recognizing a n b n c n for some n>=0 using a second stack

CFL Pumping Lemma

Proving {a i b j c k | 0<=i<=j<=k} is not Context-Free s = a p b p c p i = ??? – Can’t solve it with just one i! – For the case analysis in this proof, we need to use i=0 for some cases of how the string is sliced up, and i=2 for other cases of how the string is sliced up – Is that legal??? Yes. The Pumping Lemma Game shows us why…

The REGULAR LANGUAGES Pumping Lemma Game Your Script “I’m giving you a language L that I’m assuming is regular.” “Excellent. I’m giving you this string s that I made using your p. It is in L and |s| >= p. I think you’ll really like it.” “Hm. I followed your directions for xyz, but when I [copy y N times or delete y], the new string is NOT is L! What happened?” Pumping Lemma’s Script “Thanks. For the language L that you’ve given me, I pick this nice pumping length I call p.” “Great string, thanks. I’ve cut s up into parts xyz for you. I won’t tell you what they are exactly, but I will say this: |y| > 0 and |xy| <= p. Also, you can remove y, or copy it as many times as you like, and the new string will still be in L, I promise!” “Well, then L wasn’t a regular language. Thanks for playing.”

The CONTEXT-FREE LANGUAGES Pumping Lemma Game Your Script “I’m giving you a language L that I’m assuming is context-free.” “Excellent. I’m giving you this string s that I made using your p. It is in L and |s| >= p. I think you’ll really like it.” “Hm. I followed your directions for uvxyz, but when I [copy vy N times or delete vy], the new string is NOT is L! What happened?” Pumping Lemma’s Script “Thanks. For the language L that you’ve given me, I pick this nice pumping length I call p.” “Great string, thanks. I’ve cut s up into parts uvxyz for you. I won’t tell you what they are exactly, but I will say this: |vy| > 0 and |vxy| <= p. Also, you can remove v and y, or copy them as many times as you like (as in uv i xy i z), and the new string will still be in L, I promise!” “Well, then L wasn’t a context-free language. Thanks for playing.”

MIDTERM REVIEW Review review review…

From last year’s midterm: 5. To prove a language is not regular, which method can be used? a)Show several DFAs or NFAs that almost, but not quite, recognize the language, and then conclude that no DFA or NFA can recognize the language. b)Use the Pumping Lemma for regular languages. c)Show a CFG that recognizes the language, and then conclude that the language is context-free, not regular. d)(b) and (c) e)None of the above.

(a) TRUE or (b) FALSE The following proof is valid: A = {w | w=a n for n>=0} is a regular language, and B = {w | w=b n for n>=0} is a regular language because we can produce DFA’s M A and M B for A and B, respectively (see drawings). Regular languages are closed under concatenation, therefore language AB = {w | w=a n b n for n>=0} is a regular language. (valid in this case means the flow of logic is sound, even though may not do a great job of stating GIVEN/WANT TO SHOW, etc)