Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
Advertisements

Lecture 9,10 Theory of AUTOMATA
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
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.
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CS21 Decidability and Tractability
Introduction to Computability Theory
1 Lecture 22 Myhill-Nerode Theorem –distinguishability –equivalence classes of strings –designing FSA’s –proving a language L is not regular.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Regular Expression (EXTRA)
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Homework 4 Solutions.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
1 Non-regular languages. 2 Regular languages Non-regular languages.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Module 24 Myhill-Nerode Theorem –distinguishability –equivalence classes of strings –designing FSA’s –proving a language L is not regular.
Extra on Regular Languages and Non-Regular Languages
Proofs 1/25/12.
MYHILL NERODE THEOREM By Anusha Tilkam. Myhill Nerode Theorem: The following three statements are equivalent 1.The set L є ∑* is accepted by a FSA 2.L.
Introduction to CS Theory
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 Recap lecture 28 Examples of Myhill Nerode theorem, Quotient of a language, examples, Pseudo theorem: Quotient of a language is regular, prefixes of.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 105 theory of computation
Complexity and Computability Theory I
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PROPERTIES OF REGULAR LANGUAGES
CSE 3813 Introduction to Formal Languages and Automata
Pumping Lemma for Regular Languages some languages are not regular!
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
Non-regular languages
Chapter 4 Properties of Regular Languages
Are all Languages Regular
CS21 Decidability and Tractability
Recap lecture 26 Example of nonregular language, pumping lemma version I, proof, examples,
Chapter 1 Regular Language - 02
Instructor: Aaron Roth
Instructor: Aaron Roth
Recap lecture 18 NFA corresponding to union of FAs,example, NFA corresponding to concatenation of FAs,examples, NFA corresponding to closure of an FA,examples.
CHAPTER 1 Regular Languages
Presentation transcript:

Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University

Automata and Formal Languages Tim Sheard 2 Lecture 8 Importance of loops Consider this DFA. The input string gets accepted after an execution that goes through the state sequence s  p  q  p  q  r. This path contains a loop (corresponding to the substring 01 ) that starts and ends at p. There are two simple ways of modifying this path without changing its beginning and ending states: sp q r

Automata and Formal Languages Tim Sheard 3 Lecture 8 (1)delete the loop from the path; (2)instead of going around the loop once, do it several times. As a consequence, we see that all strings of the form 0(10) i 11 (where i  0) are accepted. sp q r

Automata and Formal Languages Tim Sheard 4 Lecture 8 Long paths must contain a loop Suppose n is the number of states of a DFA. Then every path of length n or more visits at least n+1 states, and therefore must visit some state twice. Thus, every path of length n or longer must contain a loop.

Automata and Formal Languages Tim Sheard 5 Lecture 8 The pumping lemma Suppose L is a regular language, w is a string in L, and u is a non-empty substring of w. Thus, w=xuy, for some strings x, y. We say that u is a pump in w if all strings xu i y (that is, xy, xuy, xuuy, xuuuy, …) belong to L. Pumping Lemma. Let L be a regular language. Then there exists a number n, such that for all w  L such that |w|  n, there exists a prefix of w whose length is less than n which contains a pump. Formally: If w  L and |w|  n then w = xyz such that 1.y   y is the pump  2.|xy|  n ( xy is the prefix) 3.xy i z  L Definition. The number n associated to the regular language L as described in the Pumping Lemma is called the pumping constant of L.

Automata and Formal Languages Tim Sheard 6 Lecture 8 Proof w  L, |w|  n, w = xyz such that 1. y   |xy|  n 3. xy i z  L Let the DFA have m states. Let |w|  m. Consider the path from the start state s to the (accepting) state  (s, w ). Just following the first m arcs, we make m+1 total visits to states, so there must be a loop formed by some of these arcs. We can write w=opqr, where p corresponds to that loop, and |opq| = m (the prefix of size m). Thus let n=|op|, x=o, y = p, and z = qr. 1) Since every loop has at least one arc, we know |p| >0, thus y   2) |xy|  n because xy = op and n = |op| 3) xy i z  L because If p is a loop, its starts at state s i and  (s i, p ) = s i, and we know that  (s i, qr ) = s final.. Thus  (s start, x ) = s i, Thus for each i  (s i, y i ) = s i, and were done.

Automata and Formal Languages Tim Sheard 7 Lecture 8 start qiqi final x = p y = q z = rs m steps r | s

Automata and Formal Languages Tim Sheard 8 Lecture 8 Proving non-regularity To prove that a given language is not regular, we use the Pumping Lemma as follows. Assuming L is regular (we are arguing by contradiction!), let n be the pumping constant of L. Making no other assumptions about n (we don't know what it is exactly), we need to produce a string w  L of length  n that does not contain a pump in its n- prefix. This w depends on n; we need to give w for any value of n. There are many substrings of the n-prefix of our chosen w and we must demonstrate that none of them is a pump. Typically, we do this by writing w=xuy, a decomposition of w into three substrings about which we can only assume that u  and |xu|  n. Then we must show that for some concrete i (zero or greater) the string xu i y does not belong to L.

Automata and Formal Languages Tim Sheard 9 Lecture 8 Skill required Notice the game-like structure of the proof. Somebody gives us n. Then we give w of length  n. Then our opponent gives us a non-empty substring u of the n-prefix of w (and with it the factorization w =xuy of w). Finally, we choose i such that xu i y  L. Our first move often requires ingenuity: We must find w so that we can successfully respond to whatever our opponent plays next.

Automata and Formal Languages Tim Sheard 10 Lecture 8 Example 1 We show that L={0 k 1 k | k=0,1,2, …} is not regular. Assuming the Pumping Lemma constant of L is n, we take w=0 n 1 n. We need to show that there are no pumps in the n-prefix of w, which is 0 n. If u is a pump contained in 0 n then 0 n = xuz, and xuuz must also be in the language. But since |u| > 0, if |xuz| = n then |xuuz| = m where m > n. So we obtain a string 0 m 1 n with m>n, which is obviously not in L, so a contradiction is obtained, and are assumption that 0 K 1 K is regular must be false. Note. The same choice of w and i works to show that the language: L={w  {0,1}* | w contains equal number of 0s and 1s} is not regular either.

Automata and Formal Languages Tim Sheard 11 Lecture 8 Example 2 We show that L = { uu | u  {a,b} * } is not regular. Let n be the pumping constant. Then we choose w=a n ba n b which clearly has length greater than n. The initial string a n must contain the pump, u. So w = xuyba n b, and xuyb = a n b. But pumping u 0 times it must be the case that xyba n b is in L too. But since u is not , we see that xyb  a n b, since it must have fewer a’s. Which leads to a contradiction. Thus our original assumption that L was regular must be false. Question. If in response to the given n we play w=a n a n, the opponent has a chance to win. How?

Automata and Formal Languages Tim Sheard 12 Lecture 8 Example 3 The language L = { w  {a,b,c} * | the length of w is a perfect square} is not regular. In response to n, we play any string w of length n 2 (which clearly has length greater than n). The opponent picks a pump u such that w = xuy; let k=|u| and we have |xu i y| = |xuy| + (i-1) |u| = n 2 + (i-1)k. If we can find i such that n 2 +(i-1)k is not a perfect square, then we are led to a contradiction. A good choice is i=kn In that case n 2 +(i-1)k = n 2 +(kn 2 +1 –1)k = n 2 +k 2 n 2 = n 2 (k 2 +1), which is not a perfect square.

Automata and Formal Languages Tim Sheard 13 Lecture 8 Distinguishability

Automata and Formal Languages Tim Sheard 14 Lecture 8 Myhill Nerode The Myhill Nerode theorem is another characterization of the regular languages It uses a language to carve up the set of all strings into equivalence classes Intuitively these equivalence classes will correspond to states in a minimal DFA

Automata and Formal Languages Tim Sheard 15 Lecture 8 Definition x and y are distinguishable with respect to L if there is a z such that either xz is in L and yz is not in L or xz is not in L and yz is in L in other words x and y are indistinguishable wrt L if for all z, xz in L iff yz in L

Automata and Formal Languages Tim Sheard 16 Lecture 8 Example A = {a,b} a and b are indistinguishable epsilon is distinguishable from all other strings all strings other than epsilon, a and b are indistinguishable In other words, there are three equivalence classes for A: [epsilon], [a], [aa]. The number of equivalence classes induced by a language is called the index of the language (A is of index 3)

Automata and Formal Languages Tim Sheard 17 Lecture 8 Homework In homework you will show: indistinguishable by L is an equivalence relation if L is recognized by a DFA with k states then L has index at most k If L has finite index k, then it is recognized by a DFA with k states L is regular iff it has finite index. The index is the size of the smallest DFA recognizing L

Automata and Formal Languages Tim Sheard 18 Lecture 8 Examples What is the index of a n b n ? What are the equivalence classes of a*b*? What is the index of a*b*?