Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.

Similar presentations


Presentation on theme: "Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages."— Presentation transcript:

1 Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages

2 Theorem 4.1: Pumping lemma for regular languages Let L be a regular language. Then there is a constant n (which depends on L) such that for every string w in L such that |w|  n, we can break w into three strings, w = xyz, such that y  , |xy|  n, and for all i  0, xy i z is also in L.

3 qqlql f

4 Proof: Let m be the number of states in the smallest FA accepting L, and let w = a 1 a 2 …a n where n  m. If w is in L, then we have  (q, a 1 a 2 …a j ) = q l,  (q l, a j+1..a k ) = q l, and  (q l, a k+1 …a n ) = f. choose x = a 1 a 2 …a j y = a j+1..a k z = a k+1 …a n It is obvious that  (q l, v i ) = q l for i  0. So, if the FA accepts w = xyz, it also accepts zy i z.

5 Applications of the pumping lemma: Useful to prove a language L is not a regular set Method select an arbitrary ‘n’ choose a string w in L where |w|  n for any partition of w = xyz such that |xy|  n and |y|  1, show a contradiction; i.e. show that there is a string xy k z not in L; k will depend on n, x, y, and z

6 Example L = {0 i 1 i | k > 0} given arbitrary n, choose w = 0 n 1 n for any partition of w as xyz, y is one of 0 j, 1 j, or 0 j 1 l in all cases xy 2 z is not in L So, L is not a regular set

7 Example: L = { w in (a+b) * | # a’s = # b’s}

8 Example: L = {w | w = a p where p is a prime}

9 Definition of concatenation Let u, v   *. The concatenation of u and v, written as uv, is a binary operation on the strings of  * defined as follows: 1. Basis: If lenghth(v) = 0, then v =  and uv = u 2. Recursive step: Let v be a string of length n > 0 and v = wa where a   and lenghth(w) = n-1. Then uv = (uw)a. Definition of u R (reversal of u) 1.Basis: length(u) = 0, then u =  and  =  R 2.Recursive step: If length(u) = n > 0, then u = wa for some string w such that length(w) = n-1 and some a  , and u R = aw R.

10 u is a substring of v if v = xuy u is a prefix of v if v = ux u is a suffix of v if v = xu Theorem 1: (uv)w = u(vw). Concatenation is associative. Theorem 2: (uv) R = v R u R

11 A language L such that no string in L is a proper prefix (suffix) of any other string L is said to have the prefix(suffix) property. Example: {a} * does not have prefix property {a i b| i  0} does have the prefix property Definition of homomorphism: Let  1 and  2 be alphabets. A homomorphism is a mapping h:  1   2 *. It is extended to  1 * as follows: h:  1 *   2 * is defined as h(  ) =  and h(xa) = h(x)h(a) for all x  1 * and a  1.

12 Homomorphism applied to a language Let L be a language and h be a homomorphism. h(L) = {h(w) | w is in L} Definition of inverse homomorphism: If h:  1   2 * is a homomorphism, then the relation h -1 :  2 *   (  1 * ), called an inverse homomorphism and is defined as follows: If y  2 * then h -1 (y) = {x | h(x) = y} h -1 (L) =  h -1 (y) = {x | y = h(x)  L}

13 Examples: Let  1 = {0, 1},  2 = {a, b}, L = {0 n 1 n | n > 0}. Let h(0) = a, h(1) = bb Then, h(L) = {a n b 2n | n > 0} h -1 (abb) = {01} Let h(0) = ab and h(1) =  Then, h(L) = (ab) n h -1 (ab) = {1 n 01 n }

14 Closure Properties of Regular Languages The class of regular sets is closed under –Union –Intersection –Complement –Difference –Reversal –Closure (*) –Concatenation –Homomorphism –Inverse homomorphism

15 Theorem (4.5): If L is a regular language over an alphabet , then L =  * – L is also regular Proof: Let L = L(A) for some DFA A = (Q, , , q 0, F). Let B be the DFA B = (Q, , , q 0, Q – F). Then L(B) = L. Therefore L is regular. Corollary: If L and M are regular languages, then L  M is regular.

16 Theorem (4.11): If L is a regular language, so is L R. Proof: (Use structural induction on the size of the regular expression E representing L.) Claim: E R represents L R Basis: If L is , {  } or {a} then claim is true Induction step: 1)If E = E 1 + E 2, then E R = E 1 R + E 2 R 2)If E = E 1 + E 2, then E R = E 2 R E 1 R 3)If E = E 1 *, then E R = (E 1 R ) *

17 Theorem (4.14): If L is a regular language over an alphabet , and h is a homomorphism on , then h(L) is also regular. Proof: Let r be a regular expression, representing L, and s be a regular expression obtained from r by replacing every symbol a of  by h(a), then s represents h(L) (use structural induction to prove this). s is a regular expression. So, h(L) is regular language.

18 Theorem (4.16): if h is a homomorphism from an alphabet  to  * and L   *, then h -1 (L) is also a regular set. Proof: Let M=(Q, , , q 0, F) be such that L = L(M). Let M 1 = (Q, ,  1, q 0, F) where  (q, a) in M 1 =  (q, h(a)) in M. Then L(M 1 ) = h -1 (L).

19 Example: Show that {a n ba n | n  1} is not regular.

20 Example: Show that {0,1} * - {0 n 1 n | n > 0} is not regular

21 Note: The Class of Regular sets included in  * is a Boolean algebra of sets for any alphabet .


Download ppt "Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages."

Similar presentations


Ads by Google