Volume P1 · Proof, induction and invariants
Solutions
Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.
Contents
- Solutions to Chapter 1: Logic and quantifiers
- Solutions to Chapter 2: Sets, functions and finite counting
- Solutions to Chapter 3: Methods of proof
- Solutions to Chapter 4: Mathematical induction
- Solutions to Chapter 5: Strong induction and well ordering
- Solutions to Chapter 6: Recursion and structural induction
- Solutions to Chapter 7: Relations and orders
Solutions to Chapter 1: Logic and quantifiers
Section 1.1: Statements and connectives
Exercise 1.1-1. The form is T only in the row with = T and = F. The form is T only in the row with = F and = F. In the rows TT, TF, FT, FF the first column is F, T, F, F and the second is F, F, F, T.
Exercise 1.1-2. (a) The hypothesis " is even" is F, so the implication is T. (b) The hypothesis is T and the conclusion " is odd" is T, so the implication is T. (c) The part is T, so the "or" is T. (d) Both sides are F, since and , so the "if and only if" is T.
Exercise 1.1-3. The converse is "if is odd, then is prime and ". It is false: is odd and not prime. The contrapositive is "if is even, then is not prime or ". It is true for all , since an even that is prime is . The denial is " is prime, and is even". It is false for every , since the only even prime is . So the original and its contrapositive are true, and the converse and the denial are false.
Exercise 1.1-4. The columns of in the rows TT, TF, FT, FF are T, F, F, T, the same as . The column of is F, T, T, F. The form is , and its column is F, T, T, F. The columns agree.
Exercise 1.1-5. The four rows have one minterm each: TT gives , TF gives , FT gives and FF gives . Each of these is T in its own row and F in the other three. A connective that is T in exactly one row equals the minterm of that row. A connective that is T in several rows is the disjunction of the minterms of those rows. The connective that is F in all rows is . So all sixteen come from , and .
Exercise 1.1-6. is , which is . Since , the form is , that is . For the disjunction use De Morgan: , and , so . Check at = T, = F: = F, = T, and F T = (F T) = T, which is the value of .
Exercise 1.1-7. Write as . Write as : if is T, then is F and the whole is T. If is F, then is T, and the whole has the value of . Write as : the inner form is F exactly when is T and is T, so its negation is .
Exercise 1.1-8. Let , , be T when , , tell the truth. The sentences give , and . Try the two values of . If is F, then is T. The third sentence gives , so is F. The first sentence needs , that is F T, which is F: a contradiction. If is T, then is F, and the third sentence gives , so is T. The first sentence gives T (F T), which is T. So and tell the truth, and lies. A table of the eight rows confirms that this row is the only one.
Exercise 1.1-9. If is T, then has a T conclusion and is T. If is F, then is T, so is T F, which is F. So the form is T exactly when is T. For equal to a false statement, it says that "if (if then false) then ", that is "if is false then ", is the same as . This is the pattern of a proof by contradiction: to prove , assume and reach or a false statement, and then is T.
Section 1.2: Logical equivalence and the laws of logic
Exercise 1.2-1. , by the rule for the implication, the second De Morgan law and double negation. Then , by the first De Morgan law, double negation and the rule for the implication.
Exercise 1.2-2. (a) or . (b) is not prime and is not a square. (c) and .
Exercise 1.2-3. The implication is T in the rows TT, FT, FF, so its DNF is . The form is T in the rows TT and FF, so its DNF is .
Exercise 1.2-4. If is F, the form has an F conjunction as its hypothesis and is T. If is T, the hypothesis is T (), which has the value of , and so the whole is , which is T. In one line: when holds and holds, holds.
Exercise 1.2-5. For : when the hypothesis is T, is T so is F, and is T so is T. For : when the hypothesis is T, is F. If were T, then would be F. So is F and is T.
Exercise 1.2-6. Second De Morgan law from the first: the first law applied to and gives . Negate both sides and use double negation: . First distributive law from the second and from the De Morgan laws: . The second distributive law turns the inside into . The first De Morgan law gives , and the second De Morgan law with double negation gives .
Exercise 1.2-7. . The second distributive law, read from right to left, gives . The second De Morgan law gives , which is . Example: with equal to "", equal to "" and equal to "", the statements "if then " and "if then " together say the same as "if or , then ".
Exercise 1.2-8. The eight rows give with the values T, F, F, T, F, T, T, F in the order TTT, TTF, TFT, TFF, FTT, FTF, FFT, FFF. The form gives T, F, F, T, F, T, T, F in the same order. The columns agree, so is associative. The form is T in four of the eight rows, in the rows TTT, TFF, FTF, FFT, which are the rows with an odd number of T values.
Exercise 1.2-9. There are four: , , and . Let be the column of a form in the rows TT, TF, FT, FF. Every such form is T in the row TT and F in the row FF: the variables and have this property, and and keep it, which is proved by induction on the size of the form. So only the two rows TF and FT are free, and there are at most four columns. The four forms above have the columns (T,F,F,F), (T,T,F,F), (T,F,T,F) and (T,T,T,F) in the order TT, TF, FT, FF with the roles as written, and they are different, so there are exactly four.
Section 1.3: Predicates and quantifiers
Exercise 1.3-1. (a) True: take . (b) False: for each , the value gives . (c) False: has no integer with . (d) True: gives for all .
Exercise 1.3-2. The denial is "there is an even integer that is not the sum of two primes". In symbols, . A counterexample is an even with no such pair. No one has found one, and it is open whether one exists.
Exercise 1.3-3. (a) . (b) , with and positive integers.
Exercise 1.3-4. Suppose . For each , holds and holds. So and hold. Conversely, suppose both hold, and let be any element. Then holds and holds, so holds. As is arbitrary, the left side holds.
Exercise 1.3-5. Suppose and suppose with witness . Then holds, and holds, so holds. Conversely suppose and let be any element with . Then holds, so holds. If is free in the rule fails. Take equal to "" and equal to "" over the integers. For every integer the statement "" is true, so the left side is true as a statement with bound in the first part. The right side has the free variable : its hypothesis is T, and the conclusion is F at . So the two sides differ in meaning.
Exercise 1.3-6. For the empty domain, is T and is F, whatever is. Then is T and is F. The denial laws: is F and is F, so they agree. Also is T and is T, so they agree.
Exercise 1.3-7. is . The first conjunct gives for some , so follows. For over : for given the number lies in and satisfies the predicate. If also satisfies it, then . So is unique.
Exercise 1.3-8. Each of the four rows of must have at least one T, and a row has such choices, so holds for predicates. For some column must be full. By inclusion and exclusion over the set of full columns the count is . A computer count over the predicates gives the same two numbers.
Exercise 1.3-9. "The sequence has no limit" is , obtained from the denial rule applied to . For take . Given , the numbers and add to at least , by the triangle inequality, so one of them is at least . If it is , then for each choose an even , and if it is choose an odd . In each case .
Exercise 1.3-10. Let say that the algorithm has stopped after at most steps. The statement is . Its denial is : for some inputs the algorithm never stops. The bounded statement is , which has in front. It is stronger, and it is false for Algorithm 1.1E: with and , the Fibonacci numbers, the division step runs times for (for : , gives four runs), and so no single works.
Solutions to Chapter 2: Sets, functions and finite counting
Section 2.1: Sets and their operations
Exercise 2.1-1. The first set is . The power set is . The product is .
Exercise 2.1-2. (a) True: is the one element of . (b) True: the empty set is a subset of every set. (c) False: the elements of are and , and is neither. (d) True: . (e) True: , so it is an element of the power set.
Exercise 2.1-3. For any in the universe: iff iff (first law of De Morgan) iff iff .
Exercise 2.1-4. iff . The second distributive law of logic turns this into , which says .
Exercise 2.1-5. Show . Suppose . Always . Also , since an element of is in and an element of is in . So . Suppose . Then : always , and if then , so . Suppose . Then each is in , so , and .
Exercise 2.1-6. Let . Then or . In both cases . The inclusion is proper for and : the set is a subset of , and it is a subset of neither nor .
Exercise 2.1-7. iff and iff and iff . For the second claim take . If , then iff iff , since and means . If , then iff iff . In both cases the condition is .
Exercise 2.1-8. The point lies in iff , , and . This holds iff and , which says . For the union, take and . The left side is and the right side is , with four elements.
Exercise 2.1-9. Suppose is a set. Then iff , by the definition of applied to . A statement cannot be equivalent to its own denial, so no such set exists.
Section 2.2: Functions
Exercise 2.2-1. is injective and surjective: its inverse is . is neither: and is not a square. is injective and not surjective, since odd numbers are not values. is surjective, since , and not injective, since and both give .
Exercise 2.2-2. , since all three numbers have remainder . .
Exercise 2.2-3. and . For they are and , so the functions differ.
Exercise 2.2-4. Let and be surjective, and . There is with and with , so . Two bijections are injective and surjective, and the composition is injective (the theorem of Section 2.2, rule 1) and surjective, so it is bijective. The function is a two-sided inverse of : , and in the other order the same. By the uniqueness of the inverse, it is .
Exercise 2.2-5. Let . Then , so since is injective. For an example with not injective, take , , , , .
Exercise 2.2-6. Suppose is not injective. There are with . Take and . Then , so , but . So equality for all and fails. By contraposition, equality for all pairs implies that is injective.
Exercise 2.2-7. For : iff iff iff iff . The step from is clear, since every is in .
Exercise 2.2-8. From get . Since , multiplication by undoes multiplication by , so . The inverse is . Check: and . For general : if the function is constant and is not injective. If , then has an inverse modulo : the pairs are , , , , , , with the product in each case. Then is an inverse function, so is bijective. The list is .
Exercise 2.2-9. Let , a subset of . Suppose for some . Then iff by the definition of , and , so iff . This is a contradiction. So is not a value of , and is not surjective.
Section 2.3: Finite sets and counting
Exercise 2.3-1. There are subsets. The subsets with at most one element are the empty set and the singletons, so . The map of subsets to bit strings is a bijection, so bit strings of length have at most one .
Exercise 2.3-2. There are multiples of , multiples of and multiples of . By inclusion and exclusion are multiples of or . The other are multiples of neither.
Exercise 2.3-3. There are ways to choose three different letters in order, and choices of digits. The product rule gives .
Exercise 2.3-4. The sets and are disjoint and their union is . By the sum rule .
Exercise 2.3-5. The union has students. So take none of the three.
Exercise 2.3-6. Use the four boxes , , and . Five chosen numbers are mapped to four boxes. Two of them are in one box, and they are different numbers, so they are the two numbers of the box, with sum .
Exercise 2.3-7. Map each integer to its remainder modulo . There are integers and remainders, so two integers have the same remainder, and their difference is a multiple of . For the second claim, form six classes of remainders modulo : , , , , and . Seven integers go to six classes, so two share a class. If their remainders are equal, the difference is a multiple of . If they are and , the sum is a multiple of .
Exercise 2.3-8. Cut the square into nine unit squares. Ten points go to nine squares, so two points lie in the same unit square. Two points of a closed unit square are at distance at most its diagonal, .
Exercise 2.3-9. A function onto a -set is a function that is not constant. There are functions and constant ones, so surjections (for ). For a -set, the functions that miss a given element number , those that miss two given elements number , and those that miss all three number for . Inclusion and exclusion gives . For this is , which is , the number of bijections from a -set onto a -set. Every surjection between sets of equal size is a bijection by Exercise 10.
Exercise 2.3-10. Let . If is injective, then is a bijection from onto , so . The sets and are disjoint with union , so and . Conversely let be surjective and suppose with . Then still maps onto , since the value is also the value . Choose for each one element with . The function is injective, since is the identity. But , which contradicts the pigeonhole principle. On , the function is injective and not surjective, and is surjective and not injective.
Solutions to Chapter 3: Methods of proof
Section 3.1: Direct proof
Exercise 3.1-1. Let be even and be odd. Then , which is odd.
Exercise 3.1-2. Let and . Then , so . Also , so .
Exercise 3.1-3. If , then . If , then . Both are even.
Exercise 3.1-4. If , then and , so the right side is . If , then and , so the right side is .
Exercise 3.1-5. If then has remainder . If then has remainder . A sum has remainder , or , never . The number has remainder (since ), so it is not a sum of two squares.
Exercise 3.1-6. Of three consecutive integers , , , at least one is even, since the parities alternate. Exactly one is a multiple of , since the remainders mod of consecutive integers are three different values in a cycle. So the product has the factors and . As and have no common factor, divides the product: if and , write ; then , so , and .
Exercise 3.1-7. . For apply this to and : .
Exercise 3.1-8. Let and with positive integers and . Then , so since . Positive integers with product are both , so .
Exercise 3.1-9. For the numbers are prime (a computer check). For the value is . A proof by the method of the section must give an argument for every . A finite list of cases is not such an argument, and it is the form of a direct proof that rules out this use.
Exercise 3.1-10. If , then . If , then . If , then . In each case one of the factors of is a multiple of . The product of three consecutive integers is divisible by (Exercise 3.1-6), so is divisible by .
Section 3.2: Indirect proof
Exercise 3.2-1. Suppose is odd, . Then is odd. This is the contrapositive.
Exercise 3.2-2. Suppose is the largest integer. Then is an integer and , which contradicts the choice of .
Exercise 3.2-3. If , then or , and or , with remainder in both cases. So implies . Suppose in lowest terms. Then , so , , and gives , so . Both are multiples of , a contradiction.
Exercise 3.2-4. Suppose is rational, . Since with , is rational. This contradicts the choice of .
Exercise 3.2-5. Suppose . Then with and of the same parity, because their difference is . If both are odd, the product is odd. If both are even, the product is a multiple of . Neither gives . The same argument shows that has no solution for any : the product is more than a multiple of , so it is even but not a multiple of .
Exercise 3.2-6. Suppose with positive integers and (the number is positive). Then , that is, . If , divide by to get . The left side is odd and larger than , so is needed for oddness, and then , which is false for . If , divide by to get , which is false since the left side is larger than .
Exercise 3.2-7. Let , and let be its smallest divisor larger than . The number is a prime. Suppose . Then and , so , which is false. So .
Exercise 3.2-8. Let and . Then .
Exercise 3.2-9. Suppose in lowest terms. Then , so is even and is even, . Then and . If were odd, would be odd, but is even. So is even, which contradicts the lowest terms. For the sum, suppose is rational. Then , so is rational. This contradicts the first part.
Exercise 3.2-10. Suppose and are both odd. Then and have remainder mod , so has remainder . A square has remainder or mod (Exercise 3.1-5), so . This is a contradiction. So at least one of and is even.
Section 3.3: Writing proofs and common errors
Exercise 3.3-1. If then . If then . For the product, if then and . If then , so . The case is the same by symmetry. If then and .
Exercise 3.3-2. If then . If then and is even. For one of the three factors is a multiple of : the remainders of , , mod are three consecutive values of a cycle, and one of them is .
Exercise 3.3-3. The error is the step "divide by ", since . A false proof of : let . Then , and "dividing by " gives . The same error is in another form.
Exercise 3.3-4. The claim is unchanged by the exchange of and , so wlog . Then and , so .
Exercise 3.3-5. (a) , , : , but and . (b) : , but . (c) , : and .
Exercise 3.3-6. (i) implies (iii): if then . (iii) implies (ii): a multiple of is a multiple of . (ii) implies (i): if is odd then is odd (parity theorem), which is the contrapositive. The cycle proves all three equivalent.
Exercise 3.3-7. The step divides by , and may be . The claim is false: satisfies and . The correct statement is or , by .
Exercise 3.3-8. For the value is , and for the value is prime, as a computer check shows, so is the smallest. The values with a composite value are , which is values.
Exercise 3.3-9. If and are both even, , , then . If both are odd, , , then . If one is even and one is odd, the sum is odd (Exercise 3.1-1). The three cases cover all pairs. So is even iff and have the same parity.
Exercise 3.3-10. In the integers, the first sentence is true () and the second is false (there is no largest integer). In the interval of the reals, both are false: for there is no in the interval, and for each the element gives false. The error is a swap of the quantifiers: the of the first sentence depends on , and the second needs one for all .
Solutions to Chapter 4: Mathematical induction
Section 4.1: The principle of induction
Exercise 4.1-1. Base: . Step: . For the sum is .
Exercise 4.1-2. Base: . Step: .
Exercise 4.1-3. Base: . Step: if , then . For : , and if then .
Exercise 4.1-4. Base: . Step: . A complete binary tree with levels to has nodes.
Exercise 4.1-5. Base: . Step: . For the factorial, base . Step: , since .
Exercise 4.1-6. Base: . Step: , which is the formula for .
Exercise 4.1-7. Base: . Step: .
Exercise 4.1-8. Base: . Step: , a sum of two multiples of . For : gives . Step: . The product is even, so is a multiple of , and is a multiple of by the hypothesis.
Exercise 4.1-9. The proof is in the text: , where the first step multiplies the hypothesis by . For and : . The step fails because reverses the inequality when it is multiplied.
Exercise 4.1-10. The step claims that . This is , which is false for every . So the step is wrong. The claim holds for (, , ) and fails at , where .
Section 4.2: Stronger claims and recurrences
Exercise 4.2-1. and . Also , and .
Exercise 4.2-2. Base: . Step: . For the sum is .
Exercise 4.2-3. Base: . Step: , which is the formula for .
Exercise 4.2-4. Base: . Step: , and is the new term .
Exercise 4.2-5. Base cases: and . Step: assume the bound for and . Then , and . So .
Exercise 4.2-6. The values are , which suggest . Base: and . Step: .
Exercise 4.2-7. The proof of the identity is in the text. If divides and , then divides , so (for ).
Exercise 4.2-8. Fix and induct on with two base cases. For : . For : . Step: assume the identity for and for . Add the two equations and to get , the identity for .
Exercise 4.2-9. The claim and proof are in the text. The claim "the sum is less than " does not go by induction: from the hypothesis that the sum up to is less than one gets only that the sum up to is less than , and the step does not give a bound by . The stronger claim gives the room that the new term needs.
Exercise 4.2-10. The proof for is in the text. For the identity: . With : . By induction on , : the base is , and if then both terms are multiples of .
Section 4.3: Induction on other quantities
Exercise 4.3-1. The proof is in the text. The subsets of with an even number of elements correspond one-to-one with those with an odd number, by adding or removing the element . So half of the subsets are even: .
Exercise 4.3-2. The pairs: the count follows from the handshake example with people. For a convex polygon with sides, each pair of vertices is a side or a diagonal, and there are sides, so the diagonals number . For this is .
Exercise 4.3-3. After the passes to the pairs are , , , , .
Exercise 4.3-4. Base: . Step: becomes . The body gives , so it is the same statement.
Exercise 4.3-5. The proof is in the text. For lines the greatest number of regions is .
Exercise 4.3-6. Base: for the integers are , and . Step: each integer of digits is an integer of digits followed by a digit to , and the correspondence is one-to-one. So the count is .
Exercise 4.3-7. The proof is in the text. The number has the digit sum , a multiple of . The number has the digit sum , and , so the remainder is . This agrees with and .
Exercise 4.3-8. Base: with one player there are matches. Step: let there be players. Play one match. The loser leaves, and players remain. By the hypothesis the rest of the tournament has matches, so the total is .
Exercise 4.3-9. A board of side has cells and a board of side has cells after the removal, and neither number is a multiple of . Pieces of three cells cannot cover them. For the side , number the rows and columns to and remove the cell . The center piece covers , and . The four quadrants are each a square minus one cell, and each is one piece: , , and . The count is .
Exercise 4.3-10. The step fails for , going from one person to two. The two groups of person that are obtained by removing one person each share no person, so the argument that the groups share a person does not hold. The step is valid for , and the base does not lead to .
Solutions to Chapter 5: Strong induction and well ordering
Section 5.1: Strong induction
Exercise 5.1-1. Base cases: , , , . Step: for the amount is payable by the hypothesis, and one more stamp of pays . The amounts cannot be paid, and a check of the amounts up to shows no others.
Exercise 5.1-2. Base cases: , , . Step: for the amount is payable, and a stamp of pays . The amounts that cannot be paid are .
Exercise 5.1-3. The proof is in the text. For the largest power is , then with the largest power , then . So .
Exercise 5.1-4. The proof is in the text. The least prime divisor of is , since and , , do not divide it. The least prime divisor of is , since and no smaller prime divides it.
Exercise 5.1-5. The proof is in the text. and , ten factors of .
Exercise 5.1-6. The proof is in the text. For , , so and . As a check, the sequence has ten terms.
Exercise 5.1-7. The proof is in the text. For the largest Fibonacci number at most is , then has the largest , then . So .
Exercise 5.1-8. Let be a product of primes. Each , so (an induction on : the case is , and multiplying by one more factor of at least doubles the bound). So . For , and the bound is attained.
Exercise 5.1-9. For strong from weak, let say that holds for all , with true and empty. A step is the strong hypothesis for , so weak induction proves for all and hence for . For weak from strong, suppose and for . Let and assume for all . If , then is the base. If , then holds, and the step gives .
Exercise 5.1-10. The step writes as , and it uses the hypothesis for , which needs , that is, . For the number is not in the range of the claim, and for the number is not in the range. So the cases and fail, and is a counterexample to the claim.
Section 5.2: Well ordering
Exercise 5.2-1. The set of integers has no least element, since . The set of rational numbers has none, for the same reason. The set of positive rationals is bounded below by and has no least element, since .
Exercise 5.2-2. . , since . . . So the pairs are , , and .
Exercise 5.2-3. Suppose the claim is false, and let be the least with . Since , . The number is smaller than , so , which gives . Then , contrary to .
Exercise 5.2-4. Let with . Then and . A multiple of of absolute value below is , so and . If only is required, then gives two pairs.
Exercise 5.2-5. Let be a set of natural numbers with no least element, and let be "". Let be a natural number and assume for all . If , then would be a least element of , since no smaller number is in . So . By strong induction no number is in , so is empty. Hence a nonempty set has a least element.
Exercise 5.2-6. Suppose some integer has . The set of such integers is nonempty and has a least element . Then , since , so is an integer with and . This contradicts the choice of .
Exercise 5.2-7. Suppose is rational. Then the set of positive integers with an integer is nonempty. Let be its least element and . Since , . Let , so . Then is an integer, so , which contradicts the choice of .
Exercise 5.2-8. Let be nonempty with for all . The set is a nonempty set of natural numbers. Let be its least element. For , gives . So is the greatest element of .
Exercise 5.2-9. Let , and , with and . The remainders decrease since . Now . If , then . If , then with , so the remainder is . In both cases . So the number of divisions is at most about .
Exercise 5.2-10. Suppose some natural number is not in . The set of such numbers is nonempty, so it has a least element . Since , . All of are in by the choice of , so by the property of . This is a contradiction.
Section 5.3: The greatest common divisor and Euclid's algorithm
Exercise 5.3-1. For : , , , . The answer is in four divisions. For : , , , , . The answer is in five divisions.
Exercise 5.3-2. , , , , . The gcd is . Going back: . So and . Check: .
Exercise 5.3-3. Let . A common divisor of and divides , so it is a common divisor of and . A common divisor of and divides . The two sets of common divisors are equal, so their greatest elements are equal.
Exercise 5.3-4. From the inverse of modulo is . For modulo : , so the inverse is .
Exercise 5.3-5. By the proof of Bezout's identity, is the least positive number of the form . The least positive number of the form is times that. So .
Exercise 5.3-6. This is the first part of Euclid's lemma. Let . Then , and divides both terms, since . So .
Exercise 5.3-7. Let and . Multiplying, . So is a combination of and , and every common divisor of and divides . Hence .
Exercise 5.3-8. By the key lemma, . For the divisions, induct on . For : , one division, . Step: for the pair with , with , so the first division gives remainder , and the algorithm continues on , which takes divisions. The total is .
Exercise 5.3-9. Claim: if with all and prime, then and after a reordering . Strong induction on . The prime divides . By Euclid's lemma (applied times, by induction on the number of factors) for some , and then since is prime and . Reorder so that and cancel: . If , both products are empty and . Otherwise is at least and the hypothesis gives and the same primes after a reordering.
Exercise 5.3-10. The first part is the corollary of the text. For : divides , so there are solutions. Dividing by , . A solution is , , since . If is any solution, then , so , and by Euclid's lemma. So and for an integer , and these are solutions for each . Check with : .
Solutions to Chapter 6: Recursion and structural induction
Section 6.1: Recursive definitions
Exercise 6.1-1. The factorials for are . The powers are , each twice the one before.
Exercise 6.1-2. and . Base: . Step: .
Exercise 6.1-3. for and for . Then , and by the same chain through .
Exercise 6.1-4. Let for and for . Strong induction on : for , . For write with and . By the hypothesis , and , since . For the digit sum is .
Exercise 6.1-5. The values are , so . Base: . Step: .
Exercise 6.1-6. The proof is in the text. For the number of calls is .
Exercise 6.1-7. Both give and . At the first gives and the second gives . So they differ first at . The first defines and the second .
Exercise 6.1-8. Let and satisfy the rules. Claim: for all . By strong induction. For and both are given. For , , using the hypothesis for and .
Exercise 6.1-9. For the remainder is in , so the second argument of the call is smaller than . A decreasing chain of natural numbers is finite (well ordering), so the recursion ends at . For : .
Exercise 6.1-10. and , so by induction. and , so by induction.
Section 6.2: Lists and trees
Exercise 6.2-1. , and .
Exercise 6.2-2. The proof is in the text: structural induction on , with and .
Exercise 6.2-3. For both sides are . For the left side is and the right side is . They agree by the hypothesis for .
Exercise 6.2-4. For : . For : . For the reverse: , by induction: , and by the law just shown and the hypothesis.
Exercise 6.2-5. The nodes are , and gives . A tree with leaves has internal nodes and nodes in all.
Exercise 6.2-6. The proofs of laws 4 and 5 are in the text. They use law 1 () and law 2 (associativity). As a check, with and : and .
Exercise 6.2-7. The leaves are at most by the theorem of the text. The nodes are , since the nodes are .
Exercise 6.2-8. Claim: for all lists , by induction on (the hypothesis is for all ). For : . For : by the hypothesis applied to the list . On the other side, by law 2. Then by law 1.
Exercise 6.2-9. The five trees with internal nodes, all with leaves, are of height ; of height ; of height ; of height ; of height . The number of trees is the Catalan number .
Exercise 6.2-10. Structural induction on the definition of . The empty string has brackets of each kind and no nonempty initial segment. For with and in , the numbers of left and right brackets are and , equal by the hypothesis. An initial segment of is the empty string, or followed by an initial segment of (the excess of left brackets is plus that of , so at least ), or followed by an initial segment of (the excess is plus that of , so at least ). In all cases the left brackets are at least as many as the right ones.
Section 6.3: Recursive algorithms
Exercise 6.3-1. , , , , . The values going back are , with multiplications, and .
Exercise 6.3-2. The moves from (from, to) for are . The first three move two disks to , the fourth moves the largest to , and the last three move the two disks onto it.
Exercise 6.3-3. and give : base , step . For the number is . At one move per second this is about years, nearly billion years.
Exercise 6.3-4. Let be the number of ways. The last step is of (before it steps) or of (before it steps), so for , with . These are and with the same recurrence, so by strong induction. For the count is .
Exercise 6.3-5. At the start . In a pass, if is even, . If is odd, and . So the invariant holds after each pass. For and the values after the passes are , , , , and .
Exercise 6.3-6. The proof of the formula is in the text. For the greatest count is , at ( and ). No other gives .
Exercise 6.3-7. The proof is in the text: with . If with , then , so by the hypothesis (and for the array has one key and one comparison). So .
Exercise 6.3-8. Claim: if and are sorted, then is sorted and has the same elements as (counted with multiplicity). Induction on . If or is , the result is the other list. Otherwise let . The result is and and are sorted with smaller total length, so is sorted with the elements of and . The element is at most every element of (since is sorted) and at most every element of (since each of them). So is sorted, and its elements are those of and . The case is symmetric.
Exercise 6.3-9. By strong induction on . For , . For , with , which by the hypothesis is by the key lemma of Section 5.3. For the calls, let be the greatest number of calls with second argument . Then and with , and the claim follows by induction. For the calls are on , which is calls, far below .
Exercise 6.3-10. Let a solution have moves, and let the largest disk move times. Before the first move of the largest disk the other disks are on the third peg, which takes at least moves. After the last move they are on the third peg again (the one that is not the source or the target of that move) and must be moved onto the largest disk at the target, which takes at least moves. So . If then , so the largest disk moves exactly once, and the moves before and after are shortest solutions for disks. By induction on these are unique, so the shortest solution is unique.
Solutions to Chapter 7: Relations and orders
Section 7.1: Relations and equivalence relations
Exercise 7.1-1. The relation "" on the positive integers is reflexive, antisymmetric and transitive, and it is not symmetric ( but ). On the nonzero integers it is reflexive and transitive. It is not symmetric, and it is not antisymmetric either, since and while . The relation on the reals is transitive. It is not reflexive, not symmetric, and it is antisymmetric only in the empty sense: and never hold together, so the condition of antisymmetry has no case to check.
Exercise 7.1-2. The pairs are for (six pairs), (three), (two), and , , (three). The total is .
Exercise 7.1-3. Reflexive: . Symmetric: if then . Transitive: if and , then divides the sum . For the classes are , , and .
Exercise 7.1-4. A relation on is a subset of the pairs. A reflexive one contains the pairs , and each of the other pairs is free, so there are . A symmetric one is fixed by its choice on the diagonal pairs and on the unordered pairs with , so there are . A reflexive and symmetric one has the diagonal fixed, so there are .
Exercise 7.1-5. By the definition of the text, . Let be transitive and let . Then for some , so and . Conversely let , and let and . Then .
Exercise 7.1-6. An equivalence relation on a set is the same as a partition of it. The partitions of are ; ; ; ; and . There are , the Bell number .
Exercise 7.1-7. The relation contains (paths of length ). It is transitive: a path from to followed by a path from to is a path from to . Let be transitive with . By induction on the length of a path , the pair is in : for it is in , and for the pair is in by the hypothesis and , so by transitivity. So . For the given , the element reaches (by ). Each of reaches by the cycle . So has pairs: and for .
Exercise 7.1-8. Reflexive: . Symmetric: . Transitive: . The class of is . Each class has exactly one element in the interval , namely the fractional part of , so the classes correspond to the points of .
Exercise 7.1-9. Let and . Then is a multiple of , so and the rule does not depend on the choice of the representatives. The table for , with the row for and the column for , is
Exercise 7.1-10. The relation is reflexive since is, and symmetric by its definition. If and , then and , so by transitivity of . On the classes define iff . This does not depend on the representatives: if , and , then , so . It is reflexive and transitive as is. It is antisymmetric: and mean and , that is , so .
Section 7.2: Partial orders and total orders
Exercise 7.2-1. Divisibility on the positive integers is a partial order and not total ( and are not comparable). The relation on the reals is a total order. Inclusion on the subsets of is a partial order and not total, since and are not comparable. The relation on the integers is not a partial order, since it is not reflexive. It is a strict order.
Exercise 7.2-2. The covering pairs of the divisors of are , , , , , and . In the set the minimal elements are and , since no other element of the set divides them. The maximal elements are and , since is not in the set and no element of the set is a proper multiple of them.
Exercise 7.2-3. The usual order is a linear extension, since implies . Another is , in which each number comes after its divisors.
Exercise 7.2-4. Let be least in . If for some , then by leastness and , so by antisymmetry, which contradicts . So is minimal. If is also least, then and , so . In under divisibility, is minimal and not least, since .
Exercise 7.2-5. Let be nonempty and finite. Take . If is not maximal, there is with , and so on. By transitivity for , so the are all different, and the process stops in a finite set. The last element is maximal.
Exercise 7.2-6. The constraints are , , , , and . Only is minimal, so the list starts with . The elements must appear in an order where and come before and before , which gives the two base orders and . The element goes anywhere after . In there are places after , and in there are . The total is orders: , , , , , and .
Exercise 7.2-7. Let and . If or , then (using with one step strict, by transitivity and antisymmetry), so the first pair is below the third. Otherwise , and gives .
Exercise 7.2-8. For each element let be the number of elements in a longest chain that has as its largest element. Then . If , a longest chain that ends at extends by , so . So two elements with the same value of are not comparable, and each set is an antichain. The elements fall into at most sets , so by the pigeonhole principle one of them has at least elements.
Exercise 7.2-9. Let be irreflexive and transitive. A cycle gives by transitivity, contrary to irreflexivity, so there is no cycle. Such a relation is also asymmetric (if and then ), and so together with equality is a partial order. For the second claim, let be the relation "must precede" on a finite set. If has a total order that extends it, a cycle would give , so there is no cycle. Conversely, let have no cycle. Then is transitive and irreflexive (a pair is a cycle). The relation " or " is reflexive and transitive, and antisymmetric, since and would give . So it is a partial order, and by the linear extension theorem it extends to a total order, which also extends .
Exercise 7.2-10. The constraints are , , . A computer count gives orders: , , , , . The check by hand: if is first then is next (the elements need ), and then in either order, which gives . If is first, the remaining with have orders (, , ), so orders. The total is . For elements with no relations every list is allowed, so there are linear extensions.
Section 7.3: Well-founded relations and termination
Exercise 7.3-1. A relation is well-founded iff it has no infinite descending chain. For "" on , a chain cannot be infinite, so it is well-founded. For "" on a descending chain is a sequence with , such as , so it is not well-founded. For "" on the non-negative reals it is not well-founded, because of . The relation "proper divisor" is well-founded, since a proper divisor of a positive integer is smaller, so a chain is a descending chain of .
Exercise 7.3-2. Let with the relation restricted to . An infinite descending chain in is an infinite descending chain in , which does not exist.
Exercise 7.3-3. The loop is: while , replace by or by . The measure is . In a pass , and the new value is at most , so of the new value is at most . A sequence of passes would be an infinite descending chain in , which does not exist. So the loop ends.
Exercise 7.3-4. and , so , which is . For with , so , which is .
Exercise 7.3-5. First, , and , so by induction . Next, , and , so by induction .
Exercise 7.3-6. If is a proper prefix of , then . A descending chain would give an infinite descending chain of lengths in , so there is none. The same holds for proper suffixes. (In general, if a map into a well-founded set has , then is well-founded.)
Exercise 7.3-7. Write as . The lexicographic order on is well-founded by the theorem for two sets, applied to the well-founded sets (by the same theorem) and . It agrees with the lexicographic order on triples: is below iff is lexicographically below , or the pairs are equal and , which is the condition on triples.
Exercise 7.3-8. For : , and . For the bound , use induction on the pair in the lexicographic order, which is well-founded. If , . If and , by the hypothesis on . If and , let . By the hypothesis on , , so . By the hypothesis on , .
Exercise 7.3-9. A step from goes to or to , and both are smaller than in the lexicographic order on , which is well-founded. So every run is finite. From the only step is to for a that the step chooses, and then more steps follow. A run of the length exists for each natural , so no bound that depends on the start alone exists.
Exercise 7.3-10. If is well-founded, induction holds by the theorem of the text. Conversely, suppose that induction holds for every property. Let say that no infinite descending chain starts at . Let be such that holds for all . An infinite descending chain would have with a chain that starts at , which contradicts . So holds. By induction holds for all , so there is no infinite descending chain, and is well-founded.
This chapter has a full solution of each exercise of the volume, one file per chapter. Exercise - is the exercise number of Section of Chapter . Try an exercise for some time before reading its solution. A solution gives the steps that a reader at the level of the rating needs, and many solutions end with a check on small cases.
The source of this page. Something is wrong? Report it.