Pumping Theorem Examples

Slides:



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

CSCI 3130: Formal languages and automata theory Tutorial 5
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
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.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
What you need to know about this class A powerpoint syllabus.
Here’s your first homework Section Assignment: (use this format in all your assignments) Wrong = Missing = Name and assignment Problem group description.
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 }
Context-free Languages Chapter 2. Ambiguity.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
Context-Free and Noncontext-Free Languages Chapter 13 1.
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.
Introduction to Management
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 and Noncontext-Free Languages Chapter 13.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
We’ll be spending a few minutes talking about Quiz 2 on Sections that you’ll be taking the next class session, before you work on Practice Quiz.
WELCOME TO MICRO ECONOMICS AB 224 Discussion of Syllabus and Expectations in the Class.
WELCOME TO MANAGERIAL ECONOMICS MT 445 Discussion of Syllabus and Expectations in the Class.
Bottom-up parsing Pumping Theorem for CFLs MA/CSSE 474 Theory of Computation.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
Context-Free and Noncontext-Free Languages Chapter 13.
MATH/COMP 340: Numerical Analysis I
Fall 2016 MATH 250: Calculus III.
CSE 105 theory of computation
More on showing L non-regular
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Helping our children to achieve in maths
Pushdown Automata.
Theory of Computation Lecture #27-28.
Push-down Automata.
Lecture 17 Oct 25, 2011 Section 2.1 (push-down automata)
Pushdown Automata.
Geometry 15 Jan 2013 Warm up: Check your homework. For EACH PROBLEM: √ if correct. X if incorrect. Work with your group mates to find and correct any.
MA/CSSE 474 Decision Problems about Regular Languages
We’ll be spending minutes talking about Quiz 1 that you’ll be taking at the next class session before you take the Gateway Quiz today.
We’ll be spending a few minutes talking about Quiz 2 on Sections that you’ll be taking the next class session, before you work on Practice Quiz.
Intro to Theory of Computation
Non-Context-Free Languages
Welcome to College English 1!
Context-Free Grammars
فصل دوم Context-Free Languages
COSC 3340: Introduction to Theory of Computation
Bottom-up parsing Pumping Theorem for CFLs
PHYS 202 Intro Physics II Catalog description: A continuation of PHYS 201 covering the topics of electricity and magnetism, light, and modern physics.
Welcome to College English 2!
MA/CSSE 474 Theory of Computation
COSC 3340: Introduction to Theory of Computation
CS21 Decidability and Tractability
Welcome to College English 2!
MA/CSSE 474 Theory of Computation
CS21 Decidability and Tractability
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
More on showing L non-regular
Presentation and project
Welcome to College English 1!
Pumping Theorem for CFLs
Presentation and project
MA/CSSE 474 Theory of Computation
More About Nondeterminism
MA/CSSE 474 Theory of Computation
Tuesday January 31st, 2017 Learning Target;
DAY 3 – LOTS OF TIME TO LEARN TOOLS
Intro to Theory of Computation
Welcome to College English 2!
Presentation transcript:

Pumping Theorem Examples MA/CSSE 474 Theory of Computation Pumping Theorem Examples Closure Decisions Exam next Friday!

Your Questions? Previous class days' material Reading Assignments HW 12 problems Anything else

Anonymous feedback question A student wrote (yesterday, I presume): Could homework 12 be postponed until Friday? There already seems to be some confusion, and I feel unprepared to answer all the questions within the next day. It seems we have to use the PT for CFL, multiple times, yet we just began talking about it in Tuesday's lecture. In class examples and more practice/discussion would be helpful. The assumption about the problems is incorrect. There are no PT questions in HW 12. Those are in HW 13. We covered all of the HW 12 material by the end of Monday's class. Because my Piazza post could have caused confusion, I will let everyone do a late submission (until Friday at 11:55 PM) without using a late day. "Early" still means "by the end of Wednesday", and Friday is still the last day to submit for credit. Beware: HW 12 is "normal" length; HW 13 is longer and harder. So the shorter time for HW 12 and longer time for HW 13 is appropriate. If you don't finish HW 12 today, try to do it early enough tomorrow so you can get started on HW 13 before the weekend.

Anonymous feedback comment A student wrote: I think that you take a little bit too long explaining the announcements at the beginning of class. Because we occasionally go overtime, I think on days we have to cover a lot of material you should try to make announcements Thank you for pointing this out. The Announcements have often taken too long. In the past couple of weeks I have worked hard to reduce this time; I will continue to do so. Today they will be a little bit long because of responding to these questions.

Anonymous feedback comment A student wrote: I think the true false questions on exam are unfair. I understand that you want us to identify our weakness. However, trying very hard but find the wrong answer not only earns me nothing, but also costs half of my credits on another question which I also work very hard to solve. Differently, choosing IDK can earn more credits with much less work. I feel that the balance between credits and the amount of work needs to be re-judged. I suggest that: 2 points for right answer 1 for idk 0 for wrong answer I think it is more fair than it is now. My answer is on the next slide Italicized words above are ones whose spelling I corrected.

Answer to previous comment I think "fair" means treating all students the same. I also think your suggestion of "no risk guessing" leads to inflated scores for those who don't understands the material. If the exam is too hard, I adjust the "bottom line", by dividing scores by a number less than 1 (0.9 for Exam 1, and 0.95 for Exam 2). For Exam 3, I am going to try a new point scheme where the penalty for an incorrect guess is a smaller percentage of the possible points. Instead of (2, -1, 1), I will make it (4, -1 2). Here are the scores students would receive for four questions under the old and new schemes. What do you think? Examples (2, -1, 1) (4, -1, 2) Guess all (2 right, 2 wrong) 2 (25%) 6 (37.5%) Know 2, guess 2 (3 right, 1 wrong) 5 (62.5%) 11 (68.75%) Guess all 4 wrong -4 (-50%) -4 (-25%) IDK for all 4 questions 4 (50%) 8 (50%) 1 right, 3 wrong -1(-25%) 1 (6.25%)

Anonymous feedback comment A student wrote: I'm taking another CSSE course at this point in time that is very out of class and project based. Therefore, I am pleased that this CS class has 80% of the grade being determined by what you do in the classroom. I think that the grade you get in a class like Theory of Computation is a much more accurate representation of your ability in the subject than in a class where 50% (or more) of the grade is based on work that you (and probably others) do outside of the classroom. In my opinion, there are too many variables involved for out of classroom work to be considered for more than 10-15% of the grade for a class, especially a class which keeps its rubric and test cases similar across quarters, which many classes do.

Anonymous feedback comment A student wrote: Just wanted to let you know that while I had a hard time with this class at first, it's become one of the most interesting classes I've taken at rose and I'm really enjoying it right now. The only other anonymous feedback this term was the one about showing rank in the Moodle gradebook. I dealt with that one already.

The Context-Free Pumping Theorem If L is a context-free language, then k  1 ( strings w  L, where |w|  k (u, v, x, y, z ( w = uvxyz, vy  , |vxy|  k, and q  0 (uvqxyqz is in L)))) If k  1 ( a string w  L, where |w|  k ( u, v, x, y, z ( (w = uvxyz, vy  , and |vxy|  k) implies (  q  0 (uvqxyqz is not in L))))), then L is not context-free Write it in contrapositive form Now we want to write it in contrapositive form, so we can use it to show a language is NOT context-free. k  1 ( string w  L, where |w|  k (u, v, x, y, z (w = uvxyz, vy  , |vxy|  k, and q  0 (uvqxyqz is not in L)))).

Regular vs. CF Pumping Theorems Similarities: ● We don't get to choose k. ● We choose w, the string to be pumped, based on k. ● We don't get to choose how w is broken up (into xyz or uvxyz) ● We choose a value for q that shows that w isn’t pumpable. ● We may apply closure theorems before we start. Things that are different in CFL Pumping Theorem: ● Two regions, v and y, must be pumped in tandem. ● We don’t know anything about where in the strings v and y will fall in the string w. All we know is that they are reasonably “close together”, i.e., |vxy|  k. ● Either v or y may be empty, but not both.

An Example of Pumping: AnBnCn AnBnCn = {anbncn, n 0} Choose w = ak bk ck (we don't get to choose the k) 1 | 2 | 3 (the regions: all a's, all b's, all c's) If either v or y spans two regions, then let q = 2 (i.e., pump in once). The resulting string will have letters out of order and thus not be in AnBnCn. If both v and y each contain only one distinct character, set q to 2. Additional copies of at most two different characters are added, leaving the third unchanged. We no longer have equal numbers of the three letters, so the resulting string is not in AnBnCn.

An Example of Pumping: { , n 0} L = { , n  0} The elements of L: n w  1 a1 2 a4 3 a9 4 a16 5 a25 6 a36

Nested and Cross-Serial Dependencies PalEven = {wwR : w  {a, b}*} a a b b a a The dependencies are nested. WcW = {wcw : w  {a, b}*} a a b c a a b Cross-serial dependencies.

WcW = {wcw : w  {a, b}*} Let w = akbkcakbk. aaa … aaabbb … bbbcaaa … aaabbb … bbb | 1 | 2 |3| 4 | 5 | Call the part before c the left side and the part after c the right side. ● If v or y overlaps region 3, set q to 0. The resulting string will no longer contain a c. ● If both v and y occur before region 3 or they both occur after region 3, then set q to 2. One side will be longer than the other. ● If either v or y overlaps region 1, then set q to 2. In order to make the right side match, something would have to be pumped into region 4. Violates |vxy|  k. ● If either v or y overlaps region 2, then set q to 2. In order to make region 5. Violates |vxy|  k.

Work with another student on these {(ab)nanbn : n > 0} {x#y : x, y  {0, 1}* and x  y} Answers are on the next two hidden slides

Hidden: {(ab)nanbn : n > 0} Let w = (ab)kakbk. Divide w into three regions: the ab region, the a region, and the b region. If either v or y crosses the boundary between regions 2 and 3 then pump in once. The resulting string will have characters out of order. We consider the remaining alternatives for where nonempty v and y can occur: (1, 1) If |vy| is odd, pump in once and the resulting string will have characters out of order. If it is even, pump in once. The number of ab’s will no longer match the number of a’s in region 2 or b’s in region 3. (2, 2) Pump in once. More a’s in region 2 than b’s in region 3. (3, 3) Pump in once. More b’s in region 3 than a’s in region 2. v or y crosses the boundary between 1 and 2: Pump in once. Even if v and y are arranged such that the characters are not out of order, there will be more ab pairs than there are b’s in region 3. (1, 3) |vxy| must be less than or equal to k, so this is impossible. Let w = (ab)kakbk. Divide w into three regions: the ab region, the a region, and the b region. If either v or y crosses the boundary between regions 2 and 3 then pump in once. The resulting string will have characters out of order. We consider the remaining alternatives for where nonempty v and y can occur: (1, 1) If |vy| is odd, pump in once and the resulting string will have characters out of order. If it is even, pump in once. The number of ab’s will no longer match the number of a’s in region 2 or b’s in region 3. (2, 2) Pump in once. More a’s in region 2 than b’s in region 3. (3, 3) Pump in once. More b’s in region 3 than a’s in region 2. v or y crosses the boundary between 1 and 2: Pump in once. Even if v and y are arranged such that the characters are not out of order, there will be more ab pairs than there are b’s in region 3. (1, 3) |vxy| must be less than or equal to k.

Hidden: {x#y : x, y  {0, 1}* and x  y} SURPRISINGLY, it is Context-free! We can build a PDA M to accept L. All M has to do is to find one way in which x and y differ. We sketch its construction: M starts by pushing a bottom of stack marker Z onto the stack. Then it nondeterministically chooses to go to state 1 or 2. From state 1, it pushes the characters of x, then after the # starts popping the characters of y. It accepts if the two strings are of different lengths. From state 2, it must accept if two equal-length strings have at least one different character. So M starts pushing a % for each character it sees. It nondeterministically chooses a character on which to stop pushing. It remembers that character in its state (so it branches and there are two similar branches (one for "0" and one for "1" from here on). Next it reads the characters up to the # and does nothing with them. Starting with the first character after the #, it pops one % for each character it reads. When the stack is empty (actually when it contains Z) it checks to see whether the next input character matches the remembered character. If it does not, it accepts. SURPRISINGLY, it is Context-free! We can build a PDA M to accept L. All M has to do is to find one way in which x and y differ. We sketch its construction: M starts by pushing a bottom of stack marker Z onto the stack. Then it nondeterministically chooses to go to state 1 or 2. From state 1, it pushes the characters of x, then after the # starts popping the characters of y. It accepts if the two strings are of different lengths. From state 2, it must accept if two equal-length strings have at least one different character. So M starts pushing a % for each character it sees. It nondeterministically chooses a character on which to stop pushing. It remembers that character in its state (so it branches and there are two similar branches (one for "0" and one for "1" from here on). Next it reads the characters up to the # and does nothing with them. Starting with the first character after the #, it pops one % for each character it reads. When the stack is empty (actually when it contains Z) it checks to see whether the next input character matches the remembered character. If it does not, it accepts.