1 / 26

Formal Methods in Computer Science CS1502 Pumping Lemma

2. . What do we know about NFAs and DFAs?Describe the concept of ?closure". What are closure properties of regular languages that we know of?Are all languages regular?. 3. . Is language { 0n10n | n >= 0 } regular? Let's try to find an DFA or NFA recognizing it.What do we need to show to pro

dewei
Download Presentation

Formal Methods in Computer Science CS1502 Pumping Lemma

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. 1 Formal Methods in Computer Science CS1502 Pumping Lemma Patchrawat Uthaisombut University of Pittsburgh

    2. 2 What do we know about NFAs and DFAs? Describe the concept of closure. What are closure properties of regular languages that we know of? Are all languages regular?

    3. 3 Is language { 0n10n | n >= 0 } regular? Lets try to find an DFA or NFA recognizing it. What do we need to show to proof that a language is NOT regular? How?

    4. 4 Using some other property All regular languages share some property Q. ?x (Reg(x) ? Q(x)) (All Ps are Qs) Note, some non-regular languages may also have property Q. If we can show that a language L doesnt have this property, then L cannot be regular. ~Q(L) ? ~Reg(L) What property Q is a good choice to use? All regular languages must have property Q. If a language does not have property Q (and thus not regular), it should be easy to prove this.

    5. 5 Goals Pumping lemma Understanding the Pumping condition Shared by all regular languages. Proof of Pumping lemma (Negation of Pumping condition) (Using pumping lemma to show that a language is not regular.) (Existence of non-regular languages)

    6. 6 Pumping Condition A language L satisfies the pumping condition if there exists an integer p > 0 such that for all strings s in L of length at least p there exist strings x, y, z such that s = xyz and |xy| ? p and |y| > 0 and for all i ? 0, xyiz is in L. ?p (p>0 ? ?s ((s?L ? |s|?p)? ?x ?y ?z ( ( s = xyz ? |xy| ? p ? |y| > 0 ) ? ?i (i ? 0 ? xyiz ?L) ) ) )

    7. 7 Let x = abcdefg be in L. Then there exists a substring y in s such that y can be repeated (pumped) in place any number of times and the resulting string is still in L. xyiz is in L for all i ? 0. Example y = cde xy0z = xz = abfg is in L xy1z = xyz = abcdefg is in L xy2z = xyyz = abcdecdefg is in L xy3z = xyyyz = abcdecdecdefg is in L y can be pumped

    8. 8 What the other parts mean A language L satisfies the pumping condition if there exists an integer p > 0 such that will discuss later for all strings s in L of length at least p s must be in L and have sufficient length there exist strings x, y, z such that s = xyz and |xy| ? n and y occurs in the first p characters of s. |y| > 0 and y is not the empty string. for all i ? 0, xyiz is in L.

    9. 9 Example Let L be the set of even length strings over {a,b}. Consider p = 2 and s = abaa. What are the possibilities for y? abaa, abaa abaa Which one satisfies the pumping condition? abaa Do all strings of L satisfy this?

    10. 10 Example Let L be the set of strings over {a,b} where the number of as mod 3 is 1. Consider p = 3 and s = abbaaa. What are the possibilities for y? abbaaa, abbaaa, abbaaa abbaaa, abbaaa abbaaa Which ones satisfy the pumping condition? abbaaa, abbaaa, abbaaa Do all strings of L satisfy this?

    11. 11 Pumping Lemma A language L satisfies the pumping condition if: there exists an integer p > 0 such that for all strings s in L of length at least p there exist strings x, y, z such that s = xyz and |xy| <= p and |y| >= 1 and for all i >= 0, xyiz is in L Pumping Lemma: All regular languages satisfy the pumping condition.

    12. 12 High Level Outline Let L be an arbitrary regular language. Let M be a DSA such that L(M) = L. M exists by definition of L being regular. Show that L satisfies the pumping condition Use M in this part Pumping Lemma follows.

    13. 13 First step: n+1 prefixes of x Let p be the number of states in M. Let s be any string in L of length at least p. Let si denote the ith character of string s. There are at least p+1 distinct prefixes of s length 0: ? length 1: s1 length 2: s1s2 ... length i: s1s2 si ... length n: s1s2 si sn

    14. 14 Example Let p = 8 Let s = abcdefgh There are 9 distinct prefixes of s. length 0: ? length 1: a length 2: ab ... length 8: abcdefgh

    15. 15 Second step: Pigeon-hole Principle As M processes string s, it processes each prefix of s In particular, each prefix of s must end up in some state of M Situation There are p+1 distinct prefixes of s. There are only p states in M. Conclusion At least two prefixes of s must end up in the same state of M Pigeon-hole principle If there are more birds than holes, then some hole has two or more birds. Name these two prefixes w1 and w2.

    16. 16 Third step: Forming x, y, z Setting: Prefix w1 has length i Prefix w2 has length j > i prefix w1 of length i: s1s2 si prefix w2 of length j: s1s2 si si+1 sj Forming x, y, z Set x = w1 = s1s2 si Set y = si+1 sj Set z = sj+1 s|s| xyz = s1s2 si si+1 sj sj+1 s|s| x y z

    17. 17 Example Let M be a 5-state FSA that accepts all strings over {a,b,c,,z} whose length mod 5 = 3. Consider x = abcdefghijklmnopqr, a string in L. What are the two prefixes w1 and w2? w1 = ? w2 = abcde What are x, y, z? x = ? y = abcde z = fghijklmnopqr xyz = abcdefghijklmnopqr

    18. 18 Fourth step: Showing x, y, z satisfy all the conditions |xy| ? p xy = w2 w2 is one of the first p+1 prefixes of string s |y| ? 1 y consists of the characters in w2 after w1 Since w2 and w1 are distinct prefixes of s, y is not ? For all i ? 0, xyiz in L x=w1 and xy=w2 end up in the same state q of M This is how we defined w1 and w2 Thus for all i ? 0, xyi ends up in state q The string z causes M to go from state q to an accepting state.

    19. 19 Example Let M be a 5-state FSA that accepts all strings over {a,b,c,,z} whose length mod 5 = 3. Consider x = abcdefghijklmnopqr, a string in L. What are x, y, z? x = ? y = abcde z = fghijklmnopqr |xy| = 5 ? p |y| = 5 ? 1 For all i ? 0, xyiz = (abcde)ifghijklmnopqr is in L.

    20. 20 Pumping Lemma A language L satisfies the pumping condition if: there exists an integer p > 0 such that for all strings s in L of length at least p there exist strings x, y, z such that s = xyz and |xy| <= p and |y| >= 1 and for all i >= 0, xyiz is in L Pumping Lemma: All regular languages satisfy the pumping condition.

    21. 21 Rephrasing pumping lemma Pumping Lemma: All regular languages satisfy the pumping condition. ?x ( Reg(L) ? Pump(L) ) A language is regular if and only if it satisfies the pumping condition. Equivalent? ?x ( ~Reg(L) ? ~Pump(L) ) Not Equivalent All non-regular languages do not satisfy the pumping condition. Equivalent? ?x ( ~Reg(L) ? ~Pump(L) ) Not Equivalent All languages that do not satisfy the pumping condition are not regular. Equivalent? ?x ( ~Pump(L) ? ~Reg(L) ) Equivalent

    22. 22 How to use the pumping lemma Contrapositive of Pumping Lemma: All languages that do not satisfy the pumping condition are not regular. ?x ( ~Pump(L) ? ~Reg(L) To prove that a language L is not regular Show that L does NOT satisfy the pumping condition. Cite pumping lemma and conclude that L is not regular.

    23. 23 Pumping Condition A language L satisfies the pumping condition if there exists an integer p > 0 such that for all strings s in L of length at least p there exist strings x, y, z such that s = xyz and |xy| ? p and |y| > 0 and for all i ? 0, xyiz is in L. ?p (p>0 ? ?s ((s?L ? |s|?p)? ?x ?y ?z ( ( s = xyz ? |xy| ? p ? |y| > 0 ) ? ?i (i ? 0 ? xyiz ?L) ) ) )

    24. 24 ??x ( P(x) ? Q(x) ) Not all Ps are Qs ? ?x ?( P(x) ? Q(x) ) ? ?x ?(?P(x) ? Q(x) ) ? ?x ( P(x) ? ?Q(x) ) Some Ps are not Qs ??x ( P(x) ? Q(x) ) No Ps are Qs. ? ?x ?( P(x) ? Q(x) ) ? ?x ( ?P(x) ? ?Q(x) ) ? ?x ( P(x) ? ?Q(x) ) All Ps are not Qs

    25. 25 Negation of Pumping condition ??p (p>0 ? ?s ((s?L ? |s|?p)? ?x ?y ?z ( ( s = xyz ? |xy| ? p ? |y| > 0 ) ? ?i (i ? 0 ? xyiz ?L) ) ) ) ?p ( p > 0 ? ?s ( (s?L ? |s| ? p) ? ?x ?y ?z ( ( s = xyz ? |xy| ? p ? |y| > 0 ) ? ?i (i ? 0 ? xyiz ? L) ) ) )

    26. 26 Negation of Pumping condition A language L does NOT satisfy the pumping condition if: for all integers p > 0 there exists a string s in L of length at least p such that for all strings x, y, z such that s = xyz, |xy| ? p, and |y| > 0, there exists an i ? 0 such that xyiz is not in L ?p ( p > 0 ? ?s ( (s?L ? |s| ? p) ? ?x ?y ?z ( ( s = xyz ? |xy| ? p ? |y| > 0 ) ? ?i (i ? 0 ? xyiz ? L) ) ) )

    27. 27 Pumping condition and its negation A language L satisfies the pumping condition if: there exists an integer p > 0 such that for all strings s in L of length at least p there exist strings x, y, z such that s = xyz, |xy| ? p, and |y| > 0, for all i ? 0, xyiz is in L A language L does not satisfy the pumping condition if: for all integers p > 0 there exists a string s in L of length at least p such that for all strings x, y, z such that s = xyz, |xy| ? p, and |y| > 0, there exists an i ? 0 such that xyiz is not in L

More Related