CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl. 1 2 No unions necessry, so eliminte stte 1. 2 Perform union on loops of stte 2. 2 Eliminte stte 2. No finl unions necessry. ( ) 1
(), 1 2 Add new strt stte nd finl stte. Mke originl finl sttes non-finl. 1 2, Perform union on edge from stte 1 to stte 2. 1 2 Eliminte stte 1. 2 ( ) Perform unions on edges from stte to stte 2 nd from stte to the finl stte. 2
2 ( ) Eliminte stte 2. ( ) (( ) ) No unions necessry, so eliminte stte. ( ) ((( ) ) ) ( ) Perform union on remining edges. ( ) ((( ) ) ) ( ) 2. Textook, Pge 88, Exercise 1.29. () A 1 = {0 n 1 n 2 n n 0} Condensed proof:
Proof. uppose A 1 is regulr. Let p e the pumping length given y the pumping lemm. Choose s = 0 p 1 p 2 p. By the lemm, xy p nd y > 0 therefore p 0 so s A 1. Clerly, s p thus s = xyz for some x, y nd z. ince xy p, xy cnnot extend eyond the first p symols of s, mening xy =0 k where 1 k p. Let us write x = 0, y = 0, z = 0 c 1 p 2 p. The numer of 0 s, 1 s nd 2 s in s re given y + + c = p. Leti =0suchthts = xy i z = xz. Thenumerof1 s in s is p wheres the numer of 0 s in s is + c. ors A, thenumerof0 s in s must equl the numer of 1 s in s,nmely + c = p. ustituting for p, wehve + c = + + c with equlity holding when = 0. Becuse y > 0nd y =, >0, thus s / A, contrdiction. Therefore A 1 is non-regulr. Detiled proof: Proof. We wnt to prove the lnguge A 1 is non-regulr. In order to use the pumping lemm, we must ssume A 1 is regulr, since the lemm only pplies to regulr lnguges. The gol is to show our ssumption leds to contrdiction, mening the ssumption is flse nd therefore the opposite must e true. ince our ssumption is tht A 1 is regulr, the opposite of this ssumption is A 1 is non-regulr, which is precisely wht we wnt to show. Once we ssume A 1 is regulr, the lemm provides us with the pumping length, p. We re now free to choose word s which elongs to A 1 nd hs length p. If we choose s ppropritely, we should e le to pump up the size of s in the mnner descried y the pumping lemm nd show the resulting word, s,does not elong to A 1. ince the lemm sttes ll such words should lso elong to the lnguge, this would e contrdiction, leding us to our conclusion tht A 1 is non-regulr. or s to e word in A 1, it must follow the form given y the definition ove. Due to the mnner in which A 1 is defined, to otin unique word, we must fix vlue for n. Given some creful thought, we cn gretly reduce the numer of cses we need to consider sed on the vlue we choose for n. To understnd the ville choices, let us oserve the effects pumping will hve on the word s. If we select s to e lrge enough word from the lnguge, the pumping lemm sttes s cn e divided into three prts s = xyz. rom this division, the lemm descries n infinite set of words of the form s = xy i z where s must lso elong to the lnguge for ny i 0. Depending on the size of y nd likewise where y flls within the word s, we will hve one of the following representtive forms for y (where 1 k p): 4
y = 0 k y = 1 k y = 2 k y = 0 k 1 k y = 1 k 2 k y = 0 k 1 n 2 k This mens we hve t lest six different cses to consider if we llow the size nd position of y to e ritrry (with the exception y > 0). However, we re not forced to llow this much vrition in the structure of y. In fct, using the third condition of the pumping lemm, xy p, we effectively limit oth the size nd position of y within the word s. urthermore, depending on the word we choose for s (the vlue we choose for n), we cn lso limit the symols which my pper in y nd hence the relevnce of ech form of y in the ove list. Given the form of the words in A 1, setting n llows us to control the numer of 0 s in the prefix of s. Ifwesetn p, the entire string xy must consist entirely of 0 s since xy consists of no more thn the first p symols of s, ll of which re now 0. Hence, y tkes on single form, nmely y = 0 k where 1 k p. o,yusing condition three nd choosing n ppropritely (specificlly, we will let n = p), we hve nrrowed the numer of cses we need to consider to single cse! Once we select the word s = 0 p 1 p 2 p, for the word to e useful in the context ofthelemm,itmusteevidentthts A 1 nd s p. We hve nerly proved tht s A 1. Wht remins to e shown is n 0. This follows from the conditions y > 0nd xy p. We hve n = p xy y > 0, thus n>0 nd, trivilly, n 0. Lstly, it is esy to show tht s p. ince s =p>p, s p. Now tht it is cler s A 1 nd s p, the lemm llows us to divide s into s = xyz for some x, y nd z. We cn write the representtive forms of x, y nd z s follows: x = 0 y = 0 z = 0 c 1 p 2 p We hve lredy indicted tht x nd y consist entirely of 0 s. As for the form of z, since xy p nd there re p leding 0 s in s, if xy <pthere will e some leftover 0 s which crry over into z, hence the 0 c.(therestofz is just the reminder of s.) urthermore, since the 0 s distriuted cross x, y nd z re from the p leding 0 s of s, + + c must sum to p. At this point, we focus our ttention on the new word, s = xy i z,sprovidedy the lemm. The difference etween s nd s is the numer of times the sustring y 5
is llowed to repet. or s, y simply ppers once ut for s, y is llowed to repet ny numer of times. A prticulr instnce of s cn e chosen y fixing the vlue for i. Preferly, we would like vlue for i other thn 1, s i =1wouldmke s = s nd we re trying to construct word which is not in A 1 (recll s needed to e word in A 1 ). The simplest vlue we cn choose for i is i =0. Inthiscse, s = xz. We must now show xz / A 1 in order to form contrdiction with the pumping lemm. (The first condition of the lemm sttes xy i z A 1 for ll i 0.) Recll the representtive forms of x nd z. x = 0 nd z = 0 c 1 p 2 p. One wy to show xz / A 1 is y showing the numer of 0 s in xz does not equl the numer of 1 s in xz since the definition of A 1 requires these quntities to e equl. By the forms of x nd z, it is pprent the numer of 0 s in xz is given y + c nd the numer of 1 s is given y p. Rememering tht + + c = p, we cn determine when the two quntities re equl. + c = p + c = + + c 0= If we cn show tht cnnot possily e 0, then our proof is complete. ortuntely, we cn demonstrte this fct using the condition y > 0. Replcing y with its representtive form, we otin 0 > 0. More or less y definition, 0 = nd therefore >0. o, it follows cnnot e 0, mening the numer of 0 s in xz cnnot equl the numer of 1 s. Thus, xz / A 1 nd since this forms contrdiction with the clims of the pumping lemm, our supposition tht A 1 is regulr must e incorrect. Hence, we conclude A 1 is non-regulr. () A 2 = {www w {, } } Proof. uppose A 2 is regulr. Let p e the pumping length given y the pumping lemm. Choose s = www where w = p. Clerly, s A 2 nd s p, thuss = xyz for some x, y nd z. ince xy p, xy cnnot extend eyond the first p symols of s, mening xy = k where 1 k p. Letuswritex =, y =, z = c p p. The numer of s in ech w is given y ++c = p. Leti =0nds = xy i z = xz. or reference, let xz = w 1 w 2 w where w 1 = c nd w 2 = w = p.thenumer of s in w 2 nd w re ech p wheres the numer of s in w 1 is + c. or s A, thenumerof s in w 1 must equl the numer of s in w 2 nd w,nmely + c = p. ustituting for p, wehve + c = + + c with equlity holding when = 0. Becuse y > 0nd y =, >0, thus s / A, contrdiction. Therefore A 2 is non-regulr. 6
(c) A = { 2n n 0} NOTE: n is ssumed to e n integer. Proof. uppose A is regulr. Let p e the pumping length given y the pumping lemm. Choose s = 2n. By the lemm, xy p nd y > 0 therefore p 0nd s A. Clerly, s =2 p p, thuss = xyz for some x, y nd z. Let us write x =, y =, z = c. The numer of s in s is + + c =2 p. Let i =2nd s = xy i z = xyyz. Thenumerof s in s, denoted # (s ), is +2 + c =2 p +. ince y > 0nd y =, >0. rom 2 p = + + c<+2 + c, we conclude 2 p < # (s ). ustituting for on the right-hnd side of +2 + c =2 p +, we find +2 + c =2 p +2 p c. ince xy p, c = xyz xy 2 p p>0, we hve +2 + c<2 p+1,thus# (s ) < 2 p+1. Becuse 2 p < # (s ) < 2 p+1,# (s )isnot n even power of 2 nd s / A, contrdiction. Therefore A is non-regulr. 7