You are on page 1of 12
B 5. Vests)” VneZ, nx antixa™ Ler ale integers, 1% Poo , ned Proof. > n»5 | Bosis Sep We wat +o Show PCS) is true. Posy, gta » gh =32 ard ee Aine 2S< 32 4 pis) tree. (ndurckt on Step : Ge eth shew trak 1F PCK) fs true, POD Vewst len true, Pla), Kee 2 ae Rey, KEN < get We wid ate Us Tn athe Cee Ss = CeCe = Ko ale (the and Beale) owe 2 Gd beh Oury gk 2* a 2 voide Ay PCKHDS Cindacton bart) PKs. Also, ak aXaa K(4n= ans 2” So (K+ 2% ke gk eagpet verin So, by ‘the gremitily ees of ineqyaali 1 cety x aXe Iohick vo what We vows wasting to Show: 5.5 Defining Sequences Recursively sequence can be defined in a variety of different ways. One informal way is to write the first few terms with the expectation that the general pattern will be obvious. ‘We might say, for instance, “consider the sequence 3,5,7,....” Unfortunately, misunderstandings can occur when this approach is used. The next term of the sequence could be 9 if we mean a sequence of odd integers, or it could be 11 if we mean the sequence of odd prime numbers, { The second way to define a sequence is to give an explicit formula for its nth term. For example, a sequence ao, ai, a2... . can be specified by writing: a, = for all integers, n > 0. mT The advantage of defining a sequence by such an explicit formula is that each term of the sequence is uniquely determined and can be computed in a fixed, finite number of steps, by substitution. The third way to define a sequence is to use recursion. This requires giving both an equation, called a recurrence relation, that defines each later term in the sequence by reference to earlier terms and also one or more initial values for the sequence. Tun A recurrence rel n for a sequence dp, a), d2, ... i$ a formula that relates each term ag to certain of its predecessors a1. dx... di. Where i is an integer with k —i > 0. The initial conditions for such a recurrence relation specify the values Of oy di. 2, .. + it. if is a fixed integer, of ao, a), ..., dn where m is an integer with m > 0, iff depends on k. 2, Find the first four terms of the recursively defined sequence. by-1 + 3k, for all integers, k > 2 (ke2) by = b, +3@) 214 654% (k=3) bas b+ 8B) =7449= lb (x4) bye by +34) = lot 12 = ae (K=8) bg = by + 3 (5) = ASHIS = 43 Examples of Recursively Defined Sequences Recursion is one of the central ideas of computer science. To solve a problem recursively means to find a way to break it down into smaller subproblems each having the same form as the original problem—and to do this in such a way that when the process is repeated many times, the last of the subproblems are small and easy to solve and the solutions of the subproblems can be woven together to form a solution to the original problem. Example 5 The Tower of Hanoi In 1883 a French mathematician, Edouard Lucas, invented a puzzle that he called The Tower of Hanoi (La Tour D’Hanoi) The puzzle consisted of eight disks of wood with holes in their centers, which were piled in order of decreasing size on one pole in a row of three. Those who played the game were supposed to move all the disks one by one from one pole to another, never placing a larger disk ‘on top of a smaller one. ‘The puzzle offered a prize of ten thousand francs (about $34,000 US today) to anyone who could move a tower of 64 disks by hand while following the rules of the game. (See Figure 5.5.2) Assuming that you transferred the disks as efficiently as possible, how many moves would be required to win the prize? 4 golden Solution: An alagant and efficient way tpsohyetbisaealem tothink recursively. Suppose that you, somehow or other, hat ind the most efficient way possible to transfer ‘tower of k— 1 disks one by one from one pole to another, obeying the restriction that you never place a larger disk on top of a smaller one. What is the most efficient way to transfer a tower of k disks from one pole to another? ‘The answer is sketched in Figure 5.5.3, where pole A is the initial pole and pole Cis the target pole, and is described as follows: Toner of Tynerof =| /aisss 4 2 c A 2 c Initial Position Position after Transferring k — 1 Disks from AtoB Step 1: Transfer the top k— 1 disks from pole A to pole B. If k> 2, execution of this step will require a number of moves of individual disks among the three poles. But the point of thinking recursively is, not to get caught up in imagining the details of how those moves will occur. ‘Step 2: Move the bottom disk from pole A to pole C. Step 3: Transfer the top k~ 1 disks from pole B to pole C. (Again, if k> 2, execution of this step will require more than one move.) To see that this sequence of moves is most efficient, observe that to move the bottom disk of a stack of k disks from one pole to another, you must first transfer the top k~ 1 disks to a third pole to get them out of the way. ‘Thus transferring the stack of k disks from pole A to pole C requires at least two transfers of the top k—1 disks: ‘one to transfer them off the bottom disk to free the bottom disk so that it can be moved and another to transfer them back on top of the bottom disk after the bottom disk has been moved to pole C. If the bottom disk were not moved directly from pole A to pole C but were moved to pole B first, at least two additional transfers of the top k — 1 disks would be necessary: ‘one to move them from pole A to pole C so that the bottom disk could be moved from pole A to. pole B and another to move them off pole C so that the bottom disk could be moved onto pole c ‘This would increase the total number of moves and result in a less efficient transfer. Thus the minimum sequence of moves must include going from the initial position (a) to Position (b) to position (c) to position (d). It follows that the minimum =) [the minimum ‘The minimum the minimum ‘number of moves ‘number of number of ‘number of needed to transfer _| movesneeded |, | movesneeded | , | movesneeded | << | a tower of k disks to go from to go from to go from from pole A to position (a) position (b) position (c) pole C {0 position (b) to position (c) | | to position (@) For each integer n 2 1, let the minimum number of moves needed to transfer " a tower of n disks from one pole to another Note that the numbers m, are independent of the labeling of the poles; it takes the same minimum number of moves to transfer n disks from pole A to pole Cas to transfer n disks from pole A to pole 8, for example. Also the values of m, are independent of the number of larger disks that may lie below the top 1, provided these remain stationary while the top n are moved. Because the disks on the bottom are all larger than the ones on the top, the top disks can be moved from pole to pole as though the bottom disks were not present. Going from position (a) to position (b) requires rm-1 moves, going from position (b) to position {c) requires just one move, and going from position (c) to position (d) requires ms-1 moves. By substitution into equation (5.5.1), therefore, my = my +1 + my-1 = my +1 for all integers k > 2. Ma The ini condition, or base, of this recursion is found by using the definition of the sequence. Because just one move is needed to move one disk from one pole to another, m =| te minimum number of moves needed to move | _ '= | a tower of one disk from one pole to another Hence the complete recursive specification of the sequence ms, ma, ms,.. .1s as follows: For all integers k 2, (1) ry = 2mg_1 +1 recurrence relation Q) m=l initial conditions We can compute the next four terms of the sequence: 5S N2e Oy = Loy, t! 4 Wels a* = fy ay2t*' ePay t+ 24) = Payan+2t+2t) Touts fy Namoo moves Going back to the legend, suppose the priests work rapidly and move one disk every second. Then the time from the beginning of creation to the end of the world would be mss seconds. We can compute mss on a calculator. ‘The approximate result is 1.844674 x 10'? seconds = 5.84542 x 10!! years = 584.5 billion years, 6.1 Set Theory: Definitions and the Element Method of Proof ‘The words Set and elemient are undefined terms of set theory just as sentence, true, and false ‘are undefined terms of logic. ‘Subsets: Proof and Disproof ‘We begin by rewriting what it means for a set A to be a subset of a set B as a formal universal conditional statement: se _slereivetteR conditional feted p——$ pea cry xo, \ ACB Vx. ifxe Athenve B | (Select ‘The negation is, therefore, existential: sci | age » umamarcaminee | O° OE POMg ‘A proper subset of a set is a subset that is not equal to its containing set. Thus Example: Let A= {5, vZ5, {(5}} and B = (5, {5}, (5}}} a) How many elements does Ahave? 2, since S= VPS. : e8 b) IBASB? Yes, since an S 454eB ( AC am c) IsBSA? Ne, 115%% ts in By but not an elemout 4 A, ) Is either a proper subset of the other? A toa propa Subset AB, Because we define what it means for one set to another by means of conditional statement, we can use the method establish a subset relationship. ‘Such a proof is called an element argument and is the fundamental proof technique of set theory. m= 60742) Vv A-{meZ) m=brti2, re Zh ©. Disprove that B SA. Be 2nEZ | n=Bs, for gone SE LZ [We must find an element of B, that is not an element of A.) Rea x €B) but x fA. = and JEL. oem, eau het x > Oye) Loar abouk Pr? ao ac lrti2z 2 b= es Z re 4e S$ 4. Let A = {n € Z| n= 5r for some integer r} and B = {m < Z| m= 20s for some integers}. So , 2eB, a.IsACB? Explain, No! : oan tr YEA, Hun for Some intemr 7) . x=5r. Say x=10 =9@) > \e=20s , whee seZ is lo AB? bur \S se ’ s-ig-4 , EP Z , so tawa b.IsB SA? Explain. Contre diction, Yes £ xe By Hun xX = 205 Ler some seZ, > Ke 2nos=5(4s) , 45€7 ema He prdul OF miegen 1S an Integer, Hur X= Slivdeqers) and x € A. By the axiom of extension, sets A and B are equal if, and only if, they have exactly the same ‘elements (p. 7). We talked about this in 1.2...the order of the elements doesn't matter or whether or not an element is listed more than once. Som Given wety A and B. A equals B, written A= B. i/,andonly if, every element of 4 Band every clement of B isin A Symbolically: Venn Diagrams If sets A and B are represented as regions in the plane, relationships between A and B can be represented by pictues, called Venn diagrams, that were introduced by the British mathematician John Venn in 1881. For instance, the relationship A & B can be pictured in one of two ways, as shown in Figure 6.1.4. Figure 6.1.1 The relationship A ¢ B can be represented in three different ways with Venn diagrams, as shown in Figure 6.1.2. © % disjowk seks Figure 6.1.2 Example 4: Relations Between Sets of Numbers Sine denote the sets ae ee respectively, Zisa sub because every integer is rational (any integer n can the form n/1). Qis a subset of R because every rational number is real (any rational number can be represented as a length on the number line). Z is a proper subset of Q because there are rational numbers that are not integers (for example, 1/2). — ie= (Z © ee) ZeQeR LS Ln pAWOr1,2,- % Operations on Sets ‘Most mathematical discussions are carried on within some context. For example, in a certain situation all sets being considered might be sets of real numbers. In such a situation, the set of real numbers would be called auniversal Set or a universe of discourse for the discussion. Sn Let Aand B he subsets of a universal set © 1. Theititiotfot A and B. ented NY Bs is the set of all elements that are in at least one of Aor B. of 2 Te tae 4 a8 B, denoxclMATNIR, is the set of all elements that are comenan te bot Rane 4. The difference of Bilis A (or telative complement of in 8). denoted REAGEs the set of al el 4. The pee OE AY denoted AR is the set of all elemer that aot ia A. Symboticalys AUB atx cU|xe Aorye Rh ANB =(xeU |e Andre B} B-A=(xeU|xe Bands ¢ Al, Am [reU|e gat ‘Venn diagram representations for union, intersection, difference, and complement are shown in Figure 6.1.4. '8. Write in words how to read each of the following out loud. Then write the shorthand notation for each set. a.{xeU]xeAand xB) The set 4) abs ReneS Ke a Universe _ Sok UL suck HU K Is an eine hae ay Rank xis an abu HS, + intersect bjeUlxeAorxeB} = AUB @.(xeUlxeAandxé B} = A-B d.feeUlxea} = AW 2 8 em 12, Let the universal set be the set R of all real numbers and let A= {x RI-3.x <0}, 1/ B=(KeRb1

You might also like