You are on page 1of 14
jo =-|3 atruhubleshows 17. 3)6 W)S 0) 6 > cany = 21. x) +87 23. Suppose it wee with weights @ and b ‘hen here woud be areal number T such hat xa +6 T for (1,0) and (0,1), but with xa + yb = for (00) 30d (1) Hence,a > T,b>T,0 a > T, a contac: CHAPTER 12 Section 12.1 1.8) sentence > noun phrase intranive ver phrase ale adjective noun inranlve verb phrase > arile adjective noun intransitive yrb ter’ step). > th hay are as. Sean aon pre” are ver pene SS rtte adjective noun Intrale verb phrase tle sectve noun intranlve verb, aver. (ar dae) te eepy ore ans ue ‘Sentence > noun phrase tansive verb phrase oun phrase artle “noun transi ver phrase town phrase» arte noun tranite verb noun phrase» article noun "tansive yeh article oun» sts). the rte pases the hare 4 sentence > noun phrase transive verb phrase foun phrase article adjective noun. transite verb phrase_noun phrase article adjective noun tranive ver noun phrase = ate adjectve noun ramsne verb article adjective sou Safer tp) >the sleepy har pases th apy Anoers to O84 Numbered Exercises $77 3. The only way to get noun, suchas sortie athe ends to havea noun phrase at th end which an be achieved only via ‘he production sentence > moun phrase transitive yer phrase noun phrase. However, transitive verb phrase > transitive verb passes, and this sentence dos not sonia passes. S.a) 5.6 14. 10B->101A-> 10108 > 10101 b) Because ofthe productions in hs grammar, every 1 must be followed bya Dunlesitoceursattheend ofthe sting. e) All rngs consisting of 20 ra I followed by one or more repetitions fo 4 $9051 00811 0005111 + 000111 8a) So: 08 00S 0081-» 00S11->O0S111- 0051111» OLLI) S=»08-005 = 0014-00114 001114 + GOIN "11.5 505A 00SABAR-+00ABAR 00 AABB > OOIABB = OOLLBS -» 001128 - 001122 850,851,511 W)S 15,892 QSr0Al, A> 1A, AOA, Aa S04, AS UAA 1 1S) 005,554 S104, ASWAASA SAAS.» BBS,AB—> BA. BA» AB,S—>,A~»0,— 1 )S-» 06000000004, AS0AA-} | @)S>AS,S—> ABS, SA, AB BABA AB,A+0,8-> 1 S-» ABS,S > 2 AB > BABA» AB,A->0,B 1 g)S > ABS, STS UT > ATT > AU + BU.U > 8 AB BA,BA™ AB.A~>0,B-1 17.8) 05. S72 WSS AAS IAA gS 0005, S$) 19.4) Type2, not pe} b) Type} Type 0, rot ype 1 @) Type 2, not spe 36) Type 2, not pe 3 ‘Type O, not ype |g) Type 3h) Type O, not type ‘)Type2, not ype3 jp Type 2. notype 32 Let Sand be the stat symbols of G; and G, respectively. Let S be 2 ew stat symbol a) Add apd productions > Sy and S— Ss. D)AGE Sand production S— 5:5.) Add S and production § > hand $= S,6. 2a) senegce eu piers rb pra JIN. are sijecve ian itanstie er teary ee S.78 Answers to Odd Numbered Exercises sm LN 204 EIN the seepy tie a wily te ernie pases the re ° eo tranve eb phrase nwnphese ARAN ide adjective Soon tramiveverd ate ajeine non a 28.8) Yes B)No Yes No 29.2) $— (igi tneger Sng ier positive eg) 2. Silincer (sen) > + (sign) > = integer) (aii Aieger > {integer igi ” lait) 4:5,6.7.8,9.0 (paste neger) “> (eer noner dig) (past ineger) > (nore di nteger) 1k ‘bese (paste ineger) > Uneer nonzero dig) limeser / \ (postive ter) > (nce digit Unanzero digi)» = 1, 2,3.4,5,6,7.8,9 1 am ince 1) (signed decimal mamber) = sign inege | ‘sgn integer) positive iteger (sgn) = 41= Aitger) = digit | top gin . sige (aig == 01112131415] 6171819 12/314) 516171819 (positive ner = (integer nonzero digit | (nonzero dig integer | (eg) (nonzero integer nee | nonzero digi) | (nonzero dig) 3 Answers to O38 Numbered Exercies $79 3Mea) deer eter) ) ideniter) fa ble|--lz leer eene leer) | (eee leer lletr enter | Uelener leer lene llr leet | (leer let cee lee lle eer) Mller) = @ | Je |o-=2 ©) lidentor| = (ueleter | (ult Lener | (ule ter eter | (uel ltr eter eter} | (cetera lene ler | uclner ltr leer eter ete eter) ser) = let | (ueleter) Melee) s= |e |= 2 (Wolter) = A |B|C |---| 2 denier = (let igor alphanumeri\lphanumeric (alphanumeric) | Uoleter gor alphanumeric alphanumeric alphanuneri\ alphanumeric) (digtorus = (igi) | (alphanumeric) = (ete | igi) eter) = llr | uleter} Meter) = 0 |e |v |2 (ucleer) = ABYC |---| 2 (digi) = 0) 112-219 23. identifier) = (leterors | denier symbol) Ueaerors) = (eter | (apmbon = (tras | gt) (leer) := lene) | acener) (let) = a | Je +2 (ueleter) = A BAC || (aig) := 01112) 19 3S.rumeral = sign? noncerodigit digits decimal | sgn? 0 decimal? sent |— noncerodigit== 1|2| I norzerdigit aigite STeidetfer = leterru symbole = leter|- Tetras digit eter |uleter a|Dle|-|2 [BIC lolz HZ }19 S.80 Answers Od Numbered Exercises ss 38.8) espresion) wer) (erm addOperaton) {Yactr factor actor mulOperatoraddOperator) (dentin denier identifier Operator (addOpertr) abet 1) Not generated ©) (expression, em actor ctor mal Opertory {expression factor mal Opertor) {term} term ad4Operator factor mulOperator) {factor factor addOpertor actor Operator) denier deter add Operator identi malOpertor rym & (expresion) tir) ‘actor actor malOpertor, {actor expres ad Operton {actor term malOpertor) {Yctor factor actor mulOperatonrlOperator {Yactor actor expression malOperator| mulOperator) {actor ctor term) erm addOpeatrlOperatar ad Operator) {actor factor factor aco (addOpertr (mut OperatrmlOperator) {enter denier identifier dente add Operator mal OperatarmalOpertor) wxyz—+/ © (exsion) (term) actor factor malOpeaton) actor egression malOperator) aco em) erm add Operator ulOperator actor actor aco (addOperator imal Operator) denier denier dei Opera per 1-3) Not generated 1) (epresion) (term) (addOperaon (erm) {factor mlOperao factor ad4Opeator factor mulOperatr actor nie ate efter enema deter ajb ef 9 amon lier {Yair mulOperator factor) {factor muiOperaer expression) {actor mutOperaor ter) add Operator ter) {factor mulOperator factor (addOpertr factor) {identifier ad Operator identifier addOpertor identifier) meet) sal Answers Odd Numbered Exercises $81 Not generated © (expression) (ier) (actor (malOperaor factor) (expression) imulOperator expression) {term (addOperatr term imulOperaor term) (addOperatr| ter) (Waco addOperto) factor) mal Operator factor addOpertorfacto)) (denier addOperator identifier ymOperator deer (addOperator identifier) oe, 3.201010 01000 «) 1101 $a) 1100 byooL10110 @ HHL S-2Anowere 0 Odd Numbered Exercises sa 1B (5.1028). open Vapors {lad pues 1S. Lets be the start state and lets be the sae representing sucessful call From input 02, 3,4, 5,6, 7,088 send ‘the machine back tos with output of an error message forthe ‘er, From san inp of sends the machine to sate, with ‘the output being that the Os Seat tothe nctwork. Fro an input of9 send the machin o sates with ao ouput ror there an input of I sends the machine to tat 5 with 0 ou ut from there an input of | sends the machin o sta with ‘he output being ta the 911s sent the network. Al ober inputs while states rs send th mache back oy with ‘utpt of an eror message fer the wer. From san input of sends the mache to tat with no ouput rm 2 input ‘of sends the machine to state wih no outpt and this path continues ina smile manner tothe 911 path, looking ext for, then2, then any seven digi, at which pont the machine oes osu withthe output being hate ten-igit input Issentothe network Any incorrect” input while in tats ors (tats, anything except aI while ins or 2 while in) Sends the machine back tip with out of an eror message forthe see Similars rom. anit of fllowed by appro- rate successors rive vs eventually to but nappropriae ‘uiats drive wsback oy withan error message. Also, inputs ‘whl in sates oer than 2 or 8 send the machine back to ‘Sates wth ouput ofan eror message forthe se, ss Answers to Odd Numbered Exercises $3 a F aay iit 1000000 Tapa se | 0 «© 100011001100, s S44 Ansners to O8t-Numbered Exercises Section 12.3 1.3) (00,001, 1100,1101) —__b) {000,0011, 010,011) (00,011,110, 111] (000000, o001, 000100, ‘000101,010000, 010001, 010100, 010101) 3. A= (1, 10), (011,000; A= (10.111, 1010, t000,10111 10100), fal; A= (4,10), B= (10,111, 1000) or A= (a, 10,111, 1010, 1000, 10111, 101000) $.a)The set of stings consisting of zeo or more consecutive bit ais 10) The st of stings consisting ofall I such that the number of Is is divisible by 3, including the nll string {) The st of strings i which every 1 i immediately pre ‘eded by a0) The sot of sings that begin and end With T and have atleast two Is between every pai of Os 7A suing isin A* if and only if tis a concatena- tion of an aitary number of stings in A. Because each Sting in Ais also in By i follows that sing 0. A" is also a concatenation of strings in B. Hence, AY CB" B.ayYes b)Yes No @No Yes Yes 11a) Yes _B)No_e)Yes No 13. a) Yes_b) Yes No @No No DNo- 15 We use stuctual ie ‘ection onthe input stingy. The basis step considers y = 2, and forthe inductive sep we write y = wa, where w € 7° and {2 I. For the basis sep, we ave xy =x, s0 we mist show that fsx) = fL/(,2).3)- Bu par (ofthe definition of the extended rns function sas th this itr, We then assume the inductive hypothesis tha the equation holds for and prove that fs, wa) = f{Jl6, 3), wa). By pat) ‘ofthe defiiton, the lechand side ofthis equation equals FF l.xw).a). By the indctve hypothesis, f(s, 2») HL 6-2),0)50 f(M16.20).2) = fUU.2).¥ a) The Fightand side of our desied equality is, by par (u) of the definition, aso equal 1 f(JJ1s, 2), wa, 8 deste. 175(0,10,11)(,17" 18, (0°1" jm = Oandn > 1) 21} UfOHEN 0} U(10.1N(0.1)*4(0}1}*(01}0, PU {o)(1/{00(0)(1}0,1}* 23. Lets be the only ia state, and put transits from > iselfon eter input. Pat tras sition from the tart state sf on input, abd a trasition fom 515 on input I. Crete state 8, and have the other transitions from sy ands (aswell as bth ranstons from) lead ts, 28 Start sates only fal state; tanstions fom sf0 59 on 0, fom toon from sy Yo 52 01 0, fom sto 5, om, fom 3105) on 0, fom 105) on I, ffom 5 055 on0, from) 105) on | 27. Have five sates, with only final For? =O, 1, 2,3, wantin fam 510 islf fon input | and 0s, on iat 0: Both transitions fom x axe 19 itself 28. Have four sats, with oly 4) final For {= 0,1, 2,tansiton fom 5151 on input | but back 55 ‘om input 0. Both transition from 5 ae to itselE sw 233 Stat state only fn state 5 ransiions fom sy 19 ‘on from 5 090, om sf 5; on I; from 05 080 38 sat 237, Suppose that such a machine exists, with stat state 5p and orber sate sy. Because the empty sting is not inthe Junguage but some sings ae accepted, we must have §; 2s the only inal stat, witha least one tansiton frm So to 5, Beem the sting 0 is not inthe language, the tran sition fom Son input O must be 1 itself 0 the tans tion fom 5 on input I must be fos. But this contadiets the fact tat 1 i notin the language. 39. Change each f til tate to nonnal state and vce vrs, 41, Same ma chine as in Exercise 25, bu with, 5, and 2 8 the final states 48.(00111) 48. (,0/U(0°I" |m> In > I] $7.(10" [n> O}U(10"I0" | asm > 0} $8. The union ofthe set fall stings that start with a0 and these ofall stings that have no 0s sh sas 53, Add a nonfal states wih tanstions 3) fom s) on input, fom som inp 1, a from on input Oo | oF 57, Suppose that M isa fitestatesutmaton that accepts the set of bit sings containing an equal numberof Or and Is. Suppose M has m states. Consider the string "1". By the pigeonhole principle, as M processes this sting, it mst encounter the same state more than once a it reads the rst. 110s; 50 ets be asta it bits at eas tvice. Then On the input takes Mf fom stats back to ise for some poitne integer. But hen M ends up exactly atthe same place afer reading O°" ait will alr reading 0°17. There: fore, because M accepts "+111 talon acoptsr*1, ‘which sa contradicoon. $9. We know frm Exercise $84 thatthe equivalence classes of Rate & refinement of the cguivalence classes of Ry fo eth positive integer The ‘auivalence classes are finite sets, and finite sets cannot be refined indefinitely (the mos refined they cn be is foreach Answers to O36 Numbered Eeeries S88 08, A 18,8» 08,818 17.8 0C,8-> 14,8» A> 1A, AW 0C,A— 1,B-> 0B, B > 1B,B-> 0,8 > LC» OC, 1B, C > 1. 19. Tie follows because inp tit leads oa final state inthe automaton coresponds uniquely to's derivation inthe gmat 21-The “only i parts clear Because 1 is init. For the “if” pat let the tates be SoS Spon Sy Where Wm I). Beeause n> |), some state repeated bythe pigeonhole principle. Let ybe the part of ht causes the loo, sth x= uy andy sends to 5, for some j. Then uy © L(A for all. Hence, L(M) isinfinte. 23. Suppose that L = 01") were regu, Let S be the set of states ofa finite-state machine recognizing this set Let = OI" where 3n > |S). Then by the pump- ing lemma, = 01" = ww, If) = Landuv'w e (01 | ‘3 0), Obviously v cannot contain both and I, because v? ‘would then contain 10. So sal Os oral Is and hence, sun contains 0 many 0s F190 aay I, iL notin ‘his contadstion shows that Lis pot epulr 25. Suppose ‘hat the set of palindromes aver (01) were regular. Let 8 be the set of states of finite-state machine recognizing this set Lets = 0°10", where n > |S. Apply the pumping lnm to get uv € forall nonnegative integers where (0) > 1, and lus) = |S], and 2= 0710" =uvw, Then » must be 3 sting of s(ecsue [n> |S) so ww is nota palindrome “Hence, the set of palindromes isnot ela. 27- Let then 111 gL but 101 € L011 and 10 ae dsinguishable For the second question, the oaly way for Iz to bein Lis for zt end with O, and that is also the only way for 11: to bein L,50 and 11 ae indisingishable. 2. This follows ‘immediately fom Exercise 28, because then distinguishable stings mast ve the machine fromthe starsat to different states. 3. Any two distin strings ofthe same length are Aistinguishable with respect othe language P of all alte romes, because if and y are dsc sngs of length, then xx € P bat yx# ¢ P. Beease there ae 2 diferent stings of length», Exercise 29 lls us that ay deterministic finite-state automaton fr recognizing palindromes must have Meas 2 tates, Because mi abitary, this is impossible Section 12.5 1. a) The nonblank portion ofthe tape contains the string LI when the machine halts b) The nnblank potion of the tape contains the sting 011 when the machine bal ‘The nonblank portion ofthe tage contains he sting 0001 ‘whenthemachinehals. 4) Thenonblankporonaf hetape contains te sting 00 whea the machine alts. 3a) The ‘machine als (and accepts) atte blank elowing the input, having changed the tape ffom II to 01. b) The machine changes every oer occurrence of a 1, if any, staring with te fis, to 20, and otherwise leaves the Sng unchanged; ital (and accep’) when it comes tothe end ofthe sting. $a Halts with O1 onthe tape, and does not accept B) The ‘Ansversto Odd Numbered Exercises S87 frst (fan) is hanged to a and the others re eft lone, The input isnot accepted, 7.640.511, RS 1,1, R) 969,056 0, Ro 4.05, 0,8)(64,8,0.8) He (6,081.0, 8), 9.0.8), (60.54, 05 8) (yh 0.R). (6). Bas 550,500, Raa 1s, 1 Ras. 0-5, 0, 2), (o Bist BR) SF he input string is "ano tts wih the machine ats in noni ae. Otherwise the inal Os changed to an M and the machine Skips asl the intervening Os and Is unit ether comes to the en ofthe input sig or else comes oan M. Athi pont, itbacks up one sguae and enters stat, Betause the accep able strings must have a1 atthe riht fr each Oat the le, ‘here mstbea I ere ifthe string saccepable. Therefore, the ‘only tansion out of curs when this square contains | Ifitdoes the machine epacesitwithan M and makes ay back to he lef if it doesnt, the machine hal in non state mits way back, ity ins as ong itses Is hen stay ny as longa it ses Os. Eventually either tencoters 4 T while in sat wich pont it als without accepting or ese itweaches the rightmost M that had boon writen vera Ost ‘he start ofthe string, ei sy when this bapens, hen there reno mor Os inthe sting, soit had beter be the ease ‘hat there are no more I ithe, his is accomplished bythe transitions 6, M$, M, R) and 5, Ma. R) and inal state Oerwisethe machin hls in noni tate, itis in sg when this Mis encountered things start allover gin, excep now the string will have had its leftmost remain: ing O and its rightmost remaining 1 replaced by Ms. So the ‘machine moves, staying in sate 10 the lefost remaining (and goes hack into sate to repeat the proces 195, By, By (6, 0,81.0,E) (6, By $3, Ey R (65. ML, MS, 0850, R)65,0,85, 0,8), (yy, APR), 150 MR) oe bse LR (Ge Mas, MR), 60.2.55.M,R) 65 255.2. R Bb BD sn ML 2,2 8, 0,570, Dlr esp 1 Lol 2087.2. Dp (nau oinon BB. b, (or E.5y BL) where Mf and Fare markers, with E marking the le end of the inp 19.069 1s By R), Gr, 15. Bs Rs 15.8, Ry (5514, Ry By be Roa Base, Ry (8, Bop 1.51 B.A) 1,52. B. Rls B86 By R), (62 ess. BR), (2. B86, B, R)y (5 Tes BR), (65.856, BR) (41085 By R), (4, By sy B Ry (64, Bes TR), (65 1st, By). C65 Bye. Ry (69. Bysy by Ril Bods 1 Rs Bosne WK) BBG Toso 1 Raine Basi B,D) sh 18.0.0), (630,520, L). 6 19,0, R) 5. BB, Ry, (630.510, (9.108), 18) (5, B 86 1 Ry (64, B85 LD) 181 1) (05,03, 0,0) (650.56 1, Tod, 1 Rs Bese BR) 3855.0, 5,0, yo 686 By Ry 9.88.81, (65.0653 0.1) 65, LoL), B. 0, B. By, S88 Answers Odd Numbered Execs ss a io 27. Suppose tat sy ste only halt tate fo the Turing ma- chine in Exercise 2, where m isthe largest tat number, and suppose that we have designed that machine so that when the ‘machine hls the tape head is reading the leftmost I ofthe answer Renumber each sats in the machine for Exercise 18 by adding m to cach subscript, and ake the union of the two set of ive-upes, B.ANo bYes Ves Yes H1.60.B, 54.1.0), (Go. 1o8i 1 Rs B80. ER) Supplementary Exercises 1.4) 005111, 5+ i )S-» AABS, AB —> BA, BA ABA 0,B—>1,S-—% > BT,T OFA,T + 1FB,T + 4,04 AD, 1A AL, 0B “> B0, 18> BI, EA-> E0,E8 + ELE) ‘f i { i YN | /\ | J, MN ¢ | » J \ | ¢ 1 » AOA AK 7 \ fA A i ~ Ys “A, ‘A, /\S LS | | 7.No, take A= (1,10) and B = (0,00), —9,No,take A = (G0, 000, 0000} and = 00,000). Thay BL 92 3 92 94 sao 23. Const the deterministic finite automaton for A with Stes Sandia sates F, For Ase the same atomaton but With al sates S~ F. 27 Suppose tat L = (V | pis prime} is regular, and let § Set of sates ina finite-state automaton recogniing L, Lat z= IF where p isa prime with p > [S| (Sich @ prime exis because there ae inintly many primes). By the pumping lemma it must be posible to write z = with (uy) = [5], He) > 1, and forall nonnegative iae- 420 lw €L, Because 2 is a sting ofall I, = 1%, and w = IF, where a+b +e= p,a+b= a, and ‘his means that aw’ w= 16110 = YosbeH Now take i= p+. Then wviw = 1 eat Oand y> 0, then + > O, By the mulptcatve company ay, he commutative nd Theorem 8, wehave =) > 0 15. Fit ot that <0 then ~: > O(add~z tbh sides ofthe hypothesis), Now gien x > y and ~2 > 0, we have -(-2)>y- (2) By the mulipicaive compatibility law ‘Bur by Exercise 3 ths is equivalent to —(e"2) > ~-2). ‘Then add x2 and y= to bh sides and apply the varius lays in the obvious waysto yield r-2 < y-2. 17. Thea 1. 21, We must show tht if 2) ~ (37) and(),2)~ O/.2aen(w + yn 2)~ (Wty 42) and tht (w-y3-2.3-y tw -2)~ (Wy bX Za + we) Thus we arse hatw 2" = + w and that y42 22+ sand we want oskow that + yt" 2 Sept 'ey and tat wey bere y bw e Soy woz tw sy" 2 Forte fistohe desired con cTusions adhe wo given equations, For the second ree thegvenequtionsasw — = "=x andy 2 = y"— 2, mull them, and do the alga Appendix 2 La? 2 92 Aa2y W239 Oy a Appendix 3 1. Aer the ist Bock i execute a has been assigned the criginalvalue of b and b has bsn assigned the original value lof, wherea after the socond block i exected, is assigned the orginal value ofc anda the orignal vale of a well £3. The folowing while constrction does the same thing.

You might also like