* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Solutions - CMU Math
Survey
Document related concepts
Infinitesimal wikipedia , lookup
Law of large numbers wikipedia , lookup
List of first-order theories wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Mathematics of radio engineering wikipedia , lookup
Real number wikipedia , lookup
Hyperreal number wikipedia , lookup
Quadratic reciprocity wikipedia , lookup
Collatz conjecture wikipedia , lookup
Halting problem wikipedia , lookup
Elementary mathematics wikipedia , lookup
Non-standard calculus wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Transcript
CONCEPTS OF MATHEMATICS, SUMMER 1 2014 ASSIGNMENT 10 Problem 1 (20 points) A secretive three letter government agency decides to question all its employees with a lie detector. We assume that there is a 0.001 probability that the lie detector thinks you are lying when you are really telling the truth (this is called a false positive). Otherwise, we assume that the lie detector always detects when somebody is lying. Assume the agency has 100 000 employees and knows for sure that exactly 10 of them are dishonest. An employee takes the test and makes the lie detector beep. What is the probability that the employee is really lying? Solution. Let B denote the event that the lie detector beeps and T the event that the employee is telling the truth. We are given that P (B|T ) = 0.001 = 10−3 and P (B|T c ) = 1. We also know that P (T c ) = 10/100000 = 10−4 . By conditioning, P (B) = P (B|T )P (T ) + P (B|T c )P (T c ) = 10−3 (1 − 10−4 ) + 1 · 10−4 . By Bayes’ theorem: P (B|T )P (T ) 10−3 (1 − 10−4 ) = −3 ≈ 0.9 P (B) 10 (1 − 10−4 ) + 10−4 Thus the probability that the employee is lying is approximately 1 − 0.9 = 0.1. P (T |B) = Problem 2 (40 points) Assume we are working in a finite probability space S with probability function P . Assume A and B are events. Prove or disprove: (1) If A ⊆ B, then P (A) ≤ P (B). (2) If P (B) 6= 0 and P (A|B) = P (A), then A and B are independent. (3) If A and B are independent, then Ac and B c are independent. (4) If P (A) > 1/2 and P (B) > 1/2, then P (A ∩ B) > 0. Solution. (1) This is true: We can write B = A ∪ (B\A) and the two sets in this union are disjoint, so by axiom (P2 ) of probability P (B) = P (A ∪ (B\A)) = P (A) + P (B\A). Since P (B\A) ≥ 0 (axiom (P0 ) of probability), P (B) ≥ P (A). (2) This is true: by definition of conditional probability, P (A ∩ B) = P (B) · P (A|B) which by assumption is P (B) · P (A), which means (by definition of being independent) that A and B are independent. (3) This is true: By De Morgan’s law, P (Ac ∩ B c ) = P ((A ∪ B)c ) = 1 − P (A ∪ B) = 1 − P (A) − P (B) + P (A ∩ B) Since A and B are independent, P (A ∩ B) = P (A)P (B), so the above is equal to: 1 − P (A) − P (B) + P (A)P (B) = (1 − P (A))(1 − P (B)) = P (Ac )P (B c ) Date: June 26, 2014. 1 2 ASSIGNMENT 10 (4) This is true: P (A ∪ B) = P (A) + P (B) − P (A ∩ B), so P (A ∩ B) = P (A) + P (B) − P (A ∪ B) > 21 + 12 − P (A ∪ B) = 1 − P (A ∪ B). Now P (A ∪ B) ≤ 1, so we get that P (A ∩ B) > 1 − P (A ∪ B) ≥ 1 − 1 = 0, as needed. Problem 3 (40 points) We toss n coins one after the other (where n is a positive natural number). Assume that for each coin, the probability that it falls on head is p, 0 ≤ p ≤ 1. (1) Give a finite probability space modeling this experiment. Don’t forget to define the probability function P . (2) Assume k is a natural number. What is the probability of obtaining exactly k heads? Solution. (1) Let S be the set of functions from [n] to {0, 1}, where we see head as 1 and tail as 0. For s ∈ S, we define P ({s}) = pk (1 − p)n−k , where k is the number of ones in s. This makes sense since we are tossing the coins independently. We can then extend P to the whole of P(S) using the axioms of probability. (2) If k > n, this is 0 so assume k ≤ n. Each sequence with exactly k heads has probability pk (1 − p)n−k of happening. There are nk such sequences (we have to choose the position of the heads and this corresponds to a k-element subset of [n]). Therefore the probability to obtain exactly k heads is nk pk (1 − p)n−k (this is also valid if k > n). Problem 4 (40 points) Assume p0 , p1 , ..., pn are distinct primes. Let S be the set of all natural numbers of the form pk00 pk11 . . . pknn , where each ki is a natural number, 0 ≤ ki ≤ 42. For k ≤ 42 a natural number, what is the probability that a randomly chosen element of S is a product of exactly k (not necessarily distinct) primes? Solution. By uniqueness of prime factorization, an element of S which is the product of exactly k primes is of the form pk00 pk11 . . . pknn with k0 + k1 + . . . + kn = k. Since k ≤ 42, this means any natural number solution , k1, . . . , kn ) to this equation must have each (k0k+n k+n+1−1 ki ≤ 42, so there are exactly n+1−1 = n elements of S which are the products of exactly k primes (this also works if k = 0: 1 is the only such number). In total, there are 43n+1 ways of choosing the ki s, and each determines a unique number (by uniqueness of prime factorization) so |S| = 43n+1 . Therefore the desired probability is: k+n n 43n+1 Problem 5 (40 points) (1) Assume S is a finite probability space with probability function P . Assume A0 , A1 , ..., An are events P and n is a natural number. Prove the union bound: P (A0 ∪ A1 ∪ . . . ∪ An ) ≤ ni=0 P (Ai ). [n] (2) Assume m and n are natural √ numbers and S is the set [m] of functions from [n] to [m]. Assume that n ≤ m. Show that if we choose a function f ∈ S uniformly at random, the probability S that f is injective is at least 1/2. Hint: write the event that f is not injective as i<j Ai,j where Ai,j is the event that a randomly selected f is such that f (i) = f (j). ASSIGNMENT 10 3 Solution. (1) We work by induction on n. If n = 0, this is clear and if n = 1, P (A0 ∪ A1 ) P (A0 ) + P (A1 ) − P (A0 ∩ A1 ) ≤ P (A0 ) + P (A1 ), as P (A0 ∩ A1 ) ≥ 0. For the inductive step, assume it is true for n. Then P (A0 ∪A1 ∪. . .∪An+1 ) = P ((A0 ∪A1 ∪. . .∪An )∪An+1 ). We have already proven the result for two sets, so this is ≤ P (AP 0 ∪ A1 ∪ . . . ∪ An ) + P (An+1 ). By the induction hypothesis, the first term is ≤ ni=0 P (Ai ), so P P P (A0 ∪ . . . ∪ An+1 ) ≤ ( ni=0 P (Ai )) + P (An+1 ) = n+1 i=0 P (Ai ). (2) For i < j in [n], let Ai,j be the event that a randomly selected f in S is such that f (i) = S f (j). Let A be the event that a randomly selected f is not injective. Then A = i<j Ai,j : a function f is not injective exactly if there exists i < j such that 1 f (i) = f (j). We have that P (Ai,j ) = m . One way to see this is to observe that 2 there are m ways to choose f (i) and f (j) and m of them lead to the event Ai,j . Also, there are n2 many pairs (i, j) in [n] with i < j. By the union bound, X X 1 n 1 P (A) ≤ P (Ai,j ) = = m 2 m i<j i<j By a simple calculation, n2 = n(n−1) (even if n ≤ 1), so we get that P (A) ≤ 2 √ n(n−1) n2 1 ≤ 2m ≤ 2 (where we used that n ≤ m in the last step). 2m Extra credit (40 points): Infinite probability spaces In this exercise, you will show why infinite probability spaces are tricky to define right! Assume S is an infinite set and P : P(S) → R is a function satisfying the following properties: • If A ⊆ S, 0 ≤ P (A) ≤ 1. • P (S) = 1. • If A and B are disjoint subsets of S, then P (A ∪ B) = P (A) + P (B). • For any a and b in S, P ({a}) = P ({b}). Notice that if S were finite, we would just have a uniform finite probability space. (1) Show that for any positive real number x, there is a positive natural number n such that n1 < x. Hint: Use Fact 9.32 from the notes. (2) Show that for any a ∈ S, P ({a}) = 0. Now assume that S = [0, 1]. For a set A ⊆ R and a real number x, define A + x := {y ∈ R | y = a + x for some a ∈ A}. Assume the function P satisfies the following additional properties: • If A0 , A1 , A2 , ... S is a countable family of events such that P (An ) = 0 for each n ∈ N, then P ( n∈N An ) = 0. (So a “small” union of very unlikely event is still very unlikely.) • If A is an event, x is a real number and A + x ⊆ S, then P (A + x) = P (A) (So a “translate” of A has the same probability as A.) You should think of these axioms as trying to express the process of choosing elements of [0, 1] uniformly at random. However, you will now show that there cannot exist a function P satisfying those very reasonable axioms! Recall from a assignment that the relation E on [0, 1] defined by xEy if and only if x − y is rational is an equivalence relation. We now build a set X ⊆ [0, 1/2] such that for each x, y ∈ X, if [x]E = [y]E , then x = y, and for any y ∈ R, there is x ∈ X such that xEy (you may take it for granted that such a set exists. Intuitively, we just look at the set [0, 1]/E of all equivalence classes, pick exactly one element out of each class, and put it in X). 4 ASSIGNMENT 10 We will show that X cannot be assigned any probability, which will contradict our list of axioms. Recall that by assumption, P ([0, 1]) = P (S) = 1. (3) Show that for distinct rational numbers r and r0 , (X + r) ∩ (X + r0 ) = ∅. (4) Show that [0, 1] is the union of all sets of the form (X + r) ∩ [0, 1] for r a rational number. Conclude that X is uncountable. (5) Show that if P (X) > 0, then P ([0, 1]) > 1. (6) Show that if P (X) = 0, then P ([0, 1]) = 0. Solution. (1) By Fact 9.32, there is a positive natural number n such that x1 < n. By a fact about the real numbers, this implies that 11 > n1 , i.e. x > n1 . x (2) Assume for a contradiction x := P ({a}) > 0 for some a ∈ S. Then by the fourth property this must be true for all a ∈ S. Pick a positive natural number n such that n1 < x. Since S is infinite, we can pick a set A of size n in S. We then have that P (A) = nx > 1, a contradiction to the first property. (3) Assume r and r0 are rationals. If y ∈ (X + r) ∩ (X + r0 ), then by definition y = x + r and y = x0 + r0 for some x, x0 ∈ X. Thus x − x0 = r0 − r ∈ Q, so xEx0 , so x = x0 by definition of X. Thus r = r0 . (4) Call this union Y . Since for each rational r, (X + r) ∩ [0, 1] ⊆ [0, 1], Y ⊆ [0, 1]. Conversely if y ∈ [0, 1], by the defining property of X, there is x ∈ X such that xEy, i.e. for some rational r, y = x + r, i.e. y ∈ X + r, so y ∈ Y . Therefore Y ⊆ [0, 1] and so Y = [0, 1]. It follows that X is uncountable: if X were at most countable, then X + r (which is in bijection with X via the function x 7→ x + r) must be at most countable for every rational r, and there are only countably many rationals so [0, 1] would be a countable union of at most countable sets, so at most countable. However, we know that [0, 1] is uncountable (this is a byproduct of the proof of uncountability of the reals seenSin class. We could also prove it from uncountability of R by observing that R = n∈Z ([0, 1] + n)). (5) Assume P (X) > 0. Let p := P (X). As before, pick a positive natural number n such that n1 < p. Pick a set R of n distinct rational numbers in (0, 1/2) (possible as the set Q ∩ (0, 1/2) is infinite. We have that since X ⊆ [0, 1/2], for each r ∈ R, X + r ⊆ [0, 1], so by the invariance of probability under translate, P (X + r) = P (X) = p for every r ∈ R.SBy (3), for distinct r and r0 in R, X + r and X + r0 are disjoint, so P ([0, 1]) ≥ P ( r∈R X + r) = np > 1, which is absurd. (6) Assume P (X) = 0. Then P ((X + r) ∩ [0, 1]) = 0 for every rational number r (by S invariance under translation and monotonicity of probability). By (4), [0, 1] = r∈Q (X +r)∩[0, 1] and this is a countable union, so by the fifth axiom, P ([0, 1]) = 0, which is absurd. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 1 Problem 1 Recall that π is defined to be the ratio of a circle’s circumference to its diameter (you may take it for granted that this ratio is always constant). A well known theorem of Archimedes says that the area of a circle of radius r is given by πr2 (this is actually not that easy to prove). Show that π 6= 4. You are allowed to use basic geometric facts and constructions, but not any results (except the ones just mentioned) about π itself. If you draw a picture, explain precisely how it is drawn. If you want to claim a quantity is greater than another, make sure you justify why without relying too much on a (possibly imperfect) drawing. You are not expected to achieve the same level of preciseness as for the other problems, but try to justify each step as well as you can. Solution. Start with a circle of radius 1 centered at the point O. By Archimedes’ formula, this circle has area π. Inscribe this circle inside a square of side 2. Let A denote the upper right corner of this square. The square has area 2 · 2 = 4. We will admit that the area of the circle is ≤ the area of the square, but we want to argue the inequality is strict (keeping in mind that our picture could be misleading). Draw a line segment from O √ to A. By the Pythagorean theorem, this line has √ length 12 + 12 = 2. Let C the point at which the segment touches the circle. Since we are assuming√ the circle has radius 1, OC has length 1, and therefore AC has length 2 − 1. Let B be a point above C on the square such that BC is perpendicular to AB. Similarly take a point on the square D on the right of C such that CD is perpendicular √ to AC. Then ABCD forms √ a square, √ whose diagonal AC has length 2 − 1. Since 1 < 2, 1 = 1 < 2, so √ 2 − 1 > 0. Therefore the square ABCD has nonzero area a which does not contribute to the area of the circle, i.e. the area π of the circle and the area a of ABCD together are less than or equal to the area of the square (which is 4). It follows that π ≤ 4 − a < 4, so π 6= 4, as needed. A picture of the construction is below. Date: May 7, 2014. 1 2 SOLUTION TO ASSIGNMENT 1 A B D C O Problem 2 (1) What is wrong with the following “proof” that 0 = 1? Assume x, y are real numbers such that x = y. x=y (by assumption) x−y =0 (Subtracting y from both sides) (x − y)(x − y)−1 = 0(x − y)−1 (Multiplying both sides by (x − y)−1 ) 1 = 0(x − y)−1 (1 = (x − y)(x − y)−1 by definition of the reciprocal) 1=0 (Any number multiplied by zero is zero (F0 )) Solution. We have that x − y = 0, so it does not have a reciprocal, i.e. (x − y)−1 does not make sense. In other words, we are trying to divide by zero. (2) What is wrong with the following “proof” that all nonzero real numbers are positive? For x a nonzero real number, 0 < x · x (by F15 ). Multiply both sides of the inequality by x−1 to obtain 0 · x−1 < x · x · x−1 . Since any number multiplied by zero is zero (F0 ), 0 < x · x · x−1 . By definition of the reciprocal, x · x−1 = 1, so 0 < x · 1. Since one is the multiplicative identity (M2 ), 0 < x. SOLUTION TO ASSIGNMENT 1 3 Solution. In order to be able to multiply both sides of the inequality by x−1 and keep the direction of the inequality, we have to make sure that x−1 > 0. (3) Notice that the wrong proof of the first part does not by itself disprove that 0 = 1 (one can always give wrong proofs of true facts). Using only the axioms and facts about real numbers from the lecture notes, prove that 0 6= 1. Hint: This should be very easy. Solution. This is part of axiom (R0 ). (4) Show that not all nonzero real numbers are positive by giving an explicit example of a negative real number. Of course, you should prove (using only the axioms and facts of real numbers from the lecture notes, as usual) that your example is indeed negative. Solution. We claim that −1 < 0. To see this, start with (F10 ): 0 < 1. Now use (O3 ) to add −1 to both sides of the inequality and obtain 0 + (−1) < 1 + (−1). Since −1 is the reciprocal of 1, 1 + (−1) = 0. By (A2 ), 0 + (−1) = −1, so we get −1 < 0, as needed. Problem 3 Assume x, y are real numbers with x < y. Find a real number z such that x < z < y (of course, you should prove that your z has this property). Solution. We claim that z := x+y does the job. To see this, first add x 2 to both sides of x < y to obtain x + x < x + y. Multiply both sides by 1 (a positive number, since 21 = 1 · 2−1 = 2−1 , and since 2 = 1 + 1 > 0, 2 (F16 ) tells us 2−1 > 0.) to obtain x+x < x+y . Now 2 2 x+x 1·x+1·x (1 + 1)x = = =x 2 2 2 So x < x+y . 2 We also have to see that x+y < y. The proof of this is similar: we 2 add y to both sides of x < y to obtain x + y < y + y. Then we divide < y+y = y, as needed. by 2 to get x+y 2 2 Problem 4 (1) Using only the axioms of real numbers, prove (F0 ): For any real number x, x · 0 = 0. Hint: Write 0 as 0 + 0. 4 SOLUTION TO ASSIGNMENT 1 Solution. Since 0 is the additive identity, 0 + 0 = 0. Thus: x · 0 = x · (0 + 0) =x·0+x·0 (By distributivity) Now add −(x · 0) to both sides of this equation to obtain x · 0 + (−(x · 0)) = x · 0 + x · 0 + (−(x · 0)). By definition of the negative, x · 0 + (−(x · 0)) = 0, and since 0 is the additive identity, we get that 0 = x · 0, as desired. (2) Using only the axioms of real numbers, prove (F4 ): For all real numbers x, y, if xy = 0, then x = 0 or y = 0. Solution. If x = 0, we are done, so assume x 6= 0. Then we can multiply both sides of the equation xy = 0 by x−1 and obtain x−1 xy = x−1 · 0. By definition of the reciprocal, x−1 x = 1, and we have shown in the previous part that x−1 · 0 = 0, thus we get y = 0, as desired. (3) Using only the axioms of real numbers, prove that (−1)(−1) = 1. Hint: Show that (−1)(−1) + (−1) = 0. Solution. By distributivity, (−1)(−1)+(−1) = (−1)((−1)+1), and by definition of (−1), 1 + (−1) = 0, so by the first part, (−1)(−1) + (−1) = (−1) · 0 = 0. Adding 1 to both sides of this equation, we get (−1)(−1) = 1. (4) Using only the axioms of real numbers, prove (F10 ): 0 < 1. Solution. By trichotomy (O0 ), we must have exactly one of 0 < 1, 0 = 1, or 1 < 0. We will show the last two cases cannot happen. We do not have 0 = 1, since axiom (R0 ) tells us 0 6= 1. To rule out 1 < 0, we assume it holds and derive that 0 < 1, which contradicts trichotomy. 1<0 0 < −1 (By assumption) (By adding −1 to both sides (O3 )) 0 < (−1)(−1) (By the previous equation −1 is positive, so we use (O2 )) 0<1 (By the previous part, (−1)(−1) = 1) Extra credit 2: A paradox What is wrong with the following argument? SOLUTION TO ASSIGNMENT 1 5 By “characters”, we mean letters from the roman alphabet: a, ..., z, A, ..., Z, digits: 0, 1, ..., 9, spaces, dots, quotation marks: “,”, brackets: (,), or commas. Some real numbers can be defined using relatively few characters. For example, a definition of “pi” would be “the ratio of a circle’s circumference to its diameter”. However, there are only finitely many characters, so one can form only finitely many sentences of at most 42000 characters. Therefore only finitely many real numbers can be defined using sentences of at most 42000 characters. It follows that there must be a largest real number x definable in this way. Let y be this number plus one. The previous paragraph gives a definition of y of less than 42000 characters, yet y cannot be bigger than x by definition of x, a contradiction. Solution. The problem lies in the meaning of the word “definable”. We haven’t said exactly what it meant for a real number to be definable in a given number of words. This paradox shows that sometimes plain English is just too ambiguous to be trusted. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 2 Problem 1 (1) Prove Theorem 3.20 from the notes: For all real numbers x and y: (a) (xy)2 = x2 y 2 . √ √ √ (b) If x and y are non-negative, xy = x y. Solution. (a) (xy)2 = (x · y)2 = x · y · x · y (by definition). Using commutativity, this is the same as x · x · y · y which is by definition the same as x2 · y 2 . √ (b) We know that xy is non-negative, so xy makes sense. In √ √ addition, x and y are both non-negative by definition, √ √ so x y is also non-negative. The definition of the square √ root tells us that xy is the unique non-negative z such √ √ 2 that z 2 = xy. Thus it is enough to check that x y = √ √ 2 √ √ x y = ( x)2 ( y)2 = xy. For this, we use the previous part: xy, as needed. (2) Prove Theorem 3.22 from the notes: For all real numbers x and y: 2 (a) x2 = |x| √ . (b) |x| = x2 . (c) x ≤ |x|. (d) |xy| = |x||y|. Solution. (a) There are two cases. If x ≥ 0, |x| = x, and so |x|2 = x2 . If x < 0, |x| = −x, and so |x|2 = (−x)2 = (−x)(−x) = x2 , where the last step used property (F3 ) of the real numbers. √ 2 (b) Recall that by definition x is the unique non-negative z such that z 2 = x2 . We √ consider two cases. If x ≥ 0, then z = x, and hence x2 = x = |x|. If x < 0, then 2 2 −x > 0 (by property (F √12 ) of the reals), and (−x) = x (by property (F3 )), so x2 = −x = |x|. Date: May 26, 2014. 1 2 SOLUTION TO ASSIGNMENT 2 (c) We again consider two cases. If x ≥ 0, then x = |x|. If x < 0, then we argued in the previous part that 0 < −x, hence x < 0 < −x = |x|. (d) We could do this by cases again, but we will instead use the previous results: |xy| = p (xy)2 = p √ p x2 y 2 = x2 y 2 = |x||y| Where the first equality uses (2)(b), the second uses (1)(a), the third uses (1)(b), and the last uses (2)(b) again. Problem 2 Say whether each of the following statement is true or false. If it is true, prove it. If it is false, give a counterexample. √ √ √ (1) For all non-negative real numbers x and y, x + y = x + y. Solution. √ This is false: take x = y = 1. Then the left hand side is 2, the right hand side is 1 + 1 = 2. Since 2 <√4 = 2 + 2, we √ can take the square root on both sides to obtain 2 < 2, so 2 6= 2. √ √ √ (2) For all non-negative real numbers x and y, x + y ≤ x + y. Solution. This√is true: for non-negative √ √ real numbers x and y, √ we have that ( x + y)2 = x + 2 x y + y. Thus x + y = √ √ √ √ ( x)2 + ( y)2 ≤ ( x + y)2 . Taking the square root on both sides of this inequality√and observing that all the quantities are √ √ non-negative, we get x + y ≤ x + y, as desired. √ √ √ (3) For all non-negative real numbers x and y, x + y ≥ x + y. Solution. We have already given an example √ This is√ false: √ where x + y < x + y. p √ (4) For all non-negative real numbers x and y, 2(x + y) ≥ x + √ y. √ √ Solution. This is true: By the AGM inequality, 2 x y = √ 2 xy ≤ x + y. Add x + y to both sides of this inequality to √ √ √ √ obtain x+2 x y+y ≤ 2(x+y). Observe that x+2 x y+y = √ √ √ √ ( x + y)2 , so we have ( x + y)2 ≤ 2(x + y). Take square roots on both sides to conclude. Problem 3 Assume p, q, r are propositions. (1) Prove that p → q ≡ ¬q → ¬p. The statement ¬q → ¬p is called the contrapositive of p → q. SOLUTION TO ASSIGNMENT 2 3 Solution. We simply observe that the truth table of these propositions are the same: p q ¬p ¬q p → q ¬q → ¬p F F T T T T F T T F T T T F F T F F T T F F T T (2) Prove the following distributive law: r∧(p∨q) ≡ (r∧p)∨(r∧q). Solution. This is again proven by a truth table: p F F F F T T T T q F F T T F F T T r p ∨ q r ∧ (p ∨ q) r ∧ p r ∧ q (r ∧ p) ∨ (r ∧ q) F F F F F F T F F F F F F T F F F F T T T F T T F T F F F F T T T T F T F T F F F F T T T T T T (3) Find a proposition involving p, q that is true precisely when exactly one of p and q are true. Solution. It is enough to find a proposition that is true exactly when p is true and q is false, or p is false and q is true. We claim (p ∧ ¬q) ∨ (¬p ∧ q) does the job. Let’s check with a truth table: p F F T T q ¬p ¬q p ∧ ¬q ¬p ∧ q (p ∧ ¬q) ∨ (¬p ∧ q) F T T F F F T T F F T T F F T T F T T F F F F F We see that our proposition has the required property: it is true only in two cases: p is false, q is true and p is true, q is false. (4) Write a proposition logically equivalent to the negation of p → q that does not contain “outer” negations, i.e. your proposition can only include brackets, ∧, ∨, →, ↔, T , F , p, q, ¬p, or ¬q (so ¬(p → q) does not have the right form). Solution. We know that p → q is equivalent to ¬p ∨ q. Thus we want to find ¬(¬p ∨ q). Using De Morgan’s law, this is equivalent to ¬¬p ∧ ¬q. It is easily verified using a truth table that ¬¬p ≡ p, and hence ¬(p → q) ≡ p ∧ ¬q. Intuitively, this 4 SOLUTION TO ASSIGNMENT 2 says that to disprove a proposition of the form p → q, we must show both that p is true and that q is false. Problem 4 Assume p and q are propositions. Define the logical operator NAND by the following truth table: p q p NAND q F F T F T T T F T T T F You should convince yourself that p NAND q is logically equivalent to ¬(p ∧ q). Show that F, T, ¬p,p∨q, p∧q, p → q, and p ↔ q can all be expressed using only NAND, p, and q. Solution. First, it is straightforward to check using a truth table that p ∧ p ≡ p, and hence that ¬p ≡ ¬(p ∧ p). Thus ¬p ≡ p NAND p. We could have replaced p by any other proposition in the previous argument, so we can now assume we have NAND and ¬ at our disposal and need to express the rest. We have that p ∧ q ≡ ¬¬(p ∧ q) ≡ ¬(p NAND q) so ∧ can also be expressed in terms of the previous operators, and we can add it to our belt. We are now able to get ∨ from De Morgan’s law: ¬(¬p ∧ ¬q) ≡ ¬¬p ∨ ¬¬q ≡ p ∨ q. Finally, it is very easy to obtain the rest using ¬, ∧, and ∨: • F ≡ p ∧ ¬p (you should check this using a truth table). • T ≡ p ∨ ¬p (you should check this using a truth table). • p → q ≡ ¬p ∨ q (see lecture notes). • p ↔ q ≡ (p → q) ∧ (q → p) (see lecture notes). CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 3 Problem 1 (20 points) Assume x and y are real numbers, and assume we know that y is greater than or equal to every real number less than x. (1) One can see this second assumption as a propositional function with variables x and y and domain of discourse the real numbers. Write this propositional function in symbols. (2) Show that x ≤ y. Solution. (1) The second assumption is really saying that for any number z that is less than x, z is also ≥ y. In symbols: ∀z(z < x → z ≤ y). (2) Assume for a contradiction that it is false that x ≤ y. Then y < x. By problem 3 of assignment 1, we know there is a real number z such that y < z < x. Since z < x, we must have that also z ≤ y by the assumption of the problem statement. But just defined z so that y < z, a contradiction. Problem 2 (20 points) Assume n and m are integers. Complete the proof of Theorem 5.5 in the notes, namely show: (1) If n is even, then nm is even. (2) If n and m are odd, then nm is odd. Solution. (1) Assume n is even. Fix an integer k such that n = 2k. Then nm = 2km = 2(km), so since the product of two integer is also an integer, nm is even. (2) Assume n and m are both odd, and fix integers k and k 0 such that n = 2k + 1, m = 2k 0 + 1. Compute: nm = (2k + 1)(2k 0 + 1) = 4kk 0 + 2k + 2k 0 + 1 = 2(2kk 0 + k + k 0 ) + 1 Since 2kk 0 + k + k 0 is an integer, this shows nm is odd. Date: June 2, 2014. 1 2 SOLUTION TO ASSIGNMENT 3 Problem 3 (20 points) For each of the statement below, say whether it is a proposition or only a propositional function, and write it in symbols using the integers as domain of discourse. (1) x is an even integer. (2) x is an odd integer. (3) Any integer is either even or odd. (4) Any even integer is not odd. Solution. The first two statements are propositional functions (they depend on a variable x). The last two are propositions. (1) ∃k(x = 2k) (By definition, x is even exactly if there exists an integer k such that x = 2k). (2) ∃k(x = 2k + 1) (By definition, x is odd exactly if there exists an integer k such that x = 2k + 1). (3) ∀x((∃k(x = 2k)) ∨ (∃l(x = 2l + 1))) (where we have used the above propositional functions to say that an integer is odd or even). (4) ∀x((∃k(x = 2k)) → (¬∃l(x = 2l + 1))) (i.e. for any integer x, if x is even, then it is not odd). Problem 4 (20 points) Write the negation of the following propositions in symbols and without outer negations, namely “¬∃”, “¬∀”, and “¬(” cannot appear in your final answer. Also determine the truth value of those propositions (and justify). Use the real numbers as domain of discourse. (1) ∃x(0 = 1 → (x = 3 ∧ x = 2)) (2) ∀x (x ≥ 0 → (x 6= 2 → (0 = 1 ∨ x 6= 3))) (3) ∀x∃y∃z(z ≥ 0 ∧ (y = −1 ∨ y = 1) ∧ x = yz) (4) ∃y∃z∀x(z ≥ 0 ∧ (y = −1 ∨ y = 1) ∧ x = yz) Solution. Recall from the notes and previous problems the following rules to take negations: • De Morgan’s laws for logical operators: ¬(p ∧ q) ≡ ¬p ∨ ¬q, ¬(p ∨ q) ≡ ¬p ∧ ¬q. • De Morgan’s laws for quantifiers: ¬∀xp(x) ≡ ∃x¬p(x), ¬∃xp(x) ≡ ∀x¬p(x). • Negation of an implication (problem 3.4 of assignment 2): ¬(p → q) ≡ p ∧ ¬q. • The negation of x < y is x ≥ y (follows from fact (F6 ) about the reals), and the negation of x = y is x 6= y (by definition). SOLUTION TO ASSIGNMENT 3 3 We simply use those rules repeatedly and obtain the following negations: (1) (2) (3) (4) ∀x(0 = 1 ∧ (x 6= 3 ∨ x 6= 2)). ∃x(x ≥ 0 ∧ (x 6= 2 ∧ (0 6= 1 ∧ x = 3))). ∃x∀y∀z(z < 0 ∨ (y 6= −1 ∧ y 6= 1) ∨ x 6= yz). ∀y∀z∃x(z < 0 ∨ (y 6= −1 ∧ y 6= 1) ∨ x 6= yz). As for the truth values of the original proposition, we have: (1) This is true: we have to prove an existential statement, so we take x = 0 (or any other real number). We want to see that 0 = 1 → (0 = 3 ∧ 0 = 2). This is true, since 0 = 1 is false, and false implies anything. (2) This is false: we prove the negation is true. The negation is an existential statement, so we take x = 3. Then 3 ≥ 0, 3 6= 2, 0 6= 1, and 3 = 3, as needed. (3) This is true: It is a universal statement, so we let x be an arbitrary real number. We have to find y and z so that z ≥ 0, y = −1 or y = 1, and x = yz. Let y be −1 if x is negative, and 1 otherwise. Let z be |x|. If x is non-negative, then x = 1 · x = 1 · |x| = yz. If x is negative, |x| = −x, so x = −|x| = yz. Since x is either negative or non-negative, we have covered all the cases, and we conclude that y and z are as desired. (4) This is false: we prove the negation is true. Let y and z be arbitrary real numbers. We now have to exhibit an x that satisfies the required properties. Simply take x := yz + 1. Then x 6= yz, and so z < 0 ∨ (y 6= −1 ∧ y 6= 1) ∨ x 6= yz is true, as required. Problem 5 (20 points) CMU students celebrate the end of the semester at a party. We assume any two students either know or do not know each other, and that knowledge is a symmetric and transitive relation: if x knows y, then y also knows x, and if x knows y and y knows z, then x knows z. (1) Write the above assumptions in symbols, as a proposition over the domain of discourse of students attending the party. Use xKy to say that student x knows student y. (2) Show that if at least five students come to the party, there will exist three (distinct) students such that either the three all know each other, or the three all do not know each other. Is this still true if we replace five by four? 4 SOLUTION TO ASSIGNMENT 3 Solution. (1) ∀x∀y(xKy → yKx) ∧ ∀x∀y∀z((xKy ∧ yKz) → xKz). The first part says that knowledge is symmetric, the second that it is transitive. (2) Assume students A, B, C, D, and E are at the party. We proceed by cases. • Case 1: A, B, C all do not know each other. Then, we are already done. • Case 2: At least two students among A, B and C know each other. By renaming the students if necessary, we can assume that A and B know each other. – Subcase 1: B and C know each other. Then by the transitivity of knowledge, A and C also know each other, and so A, B, C, all know each other. – Subcase 2: A and C know each other. Proceed as in subcase 1. – Subcase 3: B and C do not know each other, and A and C do not know each other. ∗ Subsubcase 1: D knows A. Then by transitivity D knows B, and A, B, D all know each other. ∗ Subsubcase 2: D knows B: proceed as in subsubcase 1. ∗ Subsubcase 3: D does not know any of A, B, C: Then B, C, D do not know each other, so we are done. ∗ Subsubcase 4: D does not know A and B, but D knows C. Then either E knows nobody, in which case A, C, and E do not know each other, or E knows someone: if it is A or B, then by transitivity A, B, E all know each other. If it is C or D, then similarly C, D, E also all know each other. All cases have been exhausted, and in each case we obtained the required result. If there are only four students A, B, C, D, then the last subsubcase witnesses the result is not true anymore: namely it could be that A and B know each other, C and D know each other, and no other knowledge relation holds. In that case, no three students all know each other, and no three students all do not know each other. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 4 Problem 1 (20 points) (1) Write the following sets using set-builder notation. This means your answer should be of the form {x ∈ A | p(x)} for A a set and p a propositional function (that need not be written in symbols). For example, the set of non-negative real numbers is {x ∈ R | x is non-negative} or alternatively {x ∈ R | x ≥ 0}. (a) The set of nonzero real numbers. (b) The set of irrational numbers. (c) The set of real numbers that are the square root of a natural number. (d) The set of subsets of reals that do not contain 0 but contain 1. (2) (a) Compute P({4, 9, 13}). (b) Explain why ∅ = 6 P(∅). (c) Compute P(P(P(∅))). (d) Assume A and B are sets. Show that A ⊆ B if and only if P(A) ⊆ P(B). Solution. (1) (a) {x ∈ R | x is nonzero}, or if you like symbols {x ∈ R | x 6= 0} (b) {x ∈ R | x is irrational}, or if you like symbols {x ∈ R | x ∈ / Q}. (c) {x ∈ R | x is the square root of a natural number}, or if you √ like symbols {x ∈ R | there exists y ∈ N, x = y}. (d) {x ∈ P(R) | x does not contain 0 but contains 1}, or if you like symbols {x ∈ P(R) | 0 ∈ / x ∧ 1 ∈ x}. (2) (a) P({4, 9, 13}) = {∅, {4}, {9}, {13}, {4, 9}, {4, 13}, {9, 13}, {4, 9, 13}} (b) We have that P(∅) = {∅} (the only subset of ∅ is ∅ itself), so ∅ ∈ P(∅), but ∅ ∈ / ∅ (the empty set contains no elements). Thus ∅ and P(∅) do not share the same elements, so they cannot be equal (equal objects must share the same properties). (c) We do it step by step: P(P(P(∅))) = P(P({∅})) = P({∅, {∅}}) = {∅, {∅}, {{∅}}, {∅, {∅}}} Date: June 2, 2014. 1 2 SOLUTION TO ASSIGNMENT 4 In the first step, we simply observe that the only subset of ∅ is ∅ itself (recall ∅ ⊆ ∅). In the second, we use that ∅ ⊆ {∅}, and {∅} ⊆ {∅}, and those are the only subsets. of {∅}. Finally, we again list all the subsets of {∅, {∅}}: they consist of the empty set, the full set, the singleton consisting of the first element of the set, and the singleton consisting of the second element of the set. (d) Assume first that A ⊆ B. To see that P(A) ⊆ P(B), we take an arbitrary element C in P(A), and show it is also in P(B). By definition of the power set, C ⊆ A. Since A ⊆ B, this implies that C ⊆ B (proof: let x ∈ C. As C ⊆ A, x ∈ A. As A ⊆ B, x ∈ B. Since x was arbitrary, C ⊆ B). Therefore by definition of the power set again, C ∈ P(B), as needed. For the converse, assume that P(A) ⊆ P(B). We show A ⊆ B by taking an arbitrary element a ∈ A and showing it is in B. Since a ∈ A, {a} ⊆ A. Thus {a} ∈ P(A), so {a} ∈ P(B), i.e. {a} ⊆ B, so (just by definition of being a subset) a ∈ B. This finishes the proof. Problem 2 (20 points) For sets A and B, we define the difference A\B (read “A minus B”, or “A without B”) to be the set {x ∈ A | x ∈ / B}. The symmetric difference A∆B is the set (A\B) ∪ (B\A). Given a fixed set U (often called the universe), the complement Ac of a set A ⊆ U is defined to be U \A. (1) Prove De Morgan’s laws for sets: for a universe set U , and A, B ⊆ U , (A ∩ B)c = Ac ∪ B c , and (A ∪ B)c = Ac ∩ B c . (2) Show that A∆B = (A ∪ B)\(A ∩ B). For a and b real numbers, we write (a, b) for the set {x ∈ R | a < x < b} and [a, b] for {x ∈ R | a ≤ x ≤ b}. We similarly define (a, b] and [a, b). Note that if a > b, then [a, b] = ∅, and if a ≥ b, then (a, b) = ∅. (3) Compute the intersection of all sets of the form (0, b), for b a positive real number. (4) Compute the union of all sets of the form [a, 1], for a a positive real number. Solution. (1) We prove that (A∩B)c = Ac ∪B c . The proof of the second equality is completely analogous. As usual, to prove that two sets are equal, we show that each is a subset of the other. To see (A∩B)c ⊆ Ac ∪B c , let x ∈ (A ∩ B)c be arbitrary. By definition of the complement, x ∈ U and x is not in A ∩ B. This means that it is not true that both x ∈ A and x ∈ B holds. By De Morgan’s laws for logical operators, this is the same as saying that x is not in A or x is not in B. Thus x ∈ Ac ∪ B c , as needed. SOLUTION TO ASSIGNMENT 4 3 To see Ac ∪ B c ⊆ (A ∩ B)c , we let x ∈ Ac ∪ B c . Then either x is in U and not in A, or x is in U and not in B. In the first case, x is also not a member of A ∩ B (it is a smaller set: A ∩ B ⊆ A). Thus x ∈ (A ∩ B)c . In the second case, we similarly use that A ∩ B ⊆ B and also get that x is not in A ∩ B, so x ∈ (A ∩ B)c . (2) Again, we show double inclusion: Let’s first see A∆B ⊆ (A∪B)\(A∩ B). Let x ∈ A∆B. By definition, this means x ∈ (A\B) ∪ (B\A). So either x ∈ A\B, or x ∈ B\A. In the first case, x is in A, but not in B. Since A ⊆ A ∪ B, x is in A ∪ B. Since A ∩ B ⊆ B, x is not in A ∩ B. Therefore x ∈ (A ∪ B)\(A ∩ B). The case where x ∈ B\A is dealt with similarly. Now let’s see (A ∪ B)\(A ∩ B) ⊆ A∆B. Let x ∈ (A ∪ B)\(A ∩ B). This means x is in A ∪ B but x is not in A ∩ B. Since x is in A ∪ B, it is in A or in B. Assume first x is in A. If x were also in B, that would mean x is in A ∩ B, but we know that this is not possible. Therefore x is not in B, so x is in A\B, and so x is in (A\B) ∪ (B\A) = A∆B. In case x ∈ B, we show x ∈ / A and conclude similarly. (3) We claim this is exactly ∅. Indeed, if x is an element of the intersection, then x is in particular a member of (0, 1), so 0 < x. Since x is an element of the intersection, x is a member of (0, x), so x < x, which is impossible. Thus the intersection has no elements, and so must be the empty set. (4) Call this union A. We claim A = (0, 1]. To see A ⊆ (0, 1], let x ∈ A. Then x ∈ [a, 1] for some positive a, and so 0 < a ≤ x ≤ 1, so x ∈ (0, 1]. Conversely, let’s see (0, 1] ⊆ A. Let x ∈ (0, 1]. Then x is a positive real number and is in [x, 1]. Therefore x is in A, as needed. Problem 3 (20 points) Prove that for all natural numbers m and n, m + n is a natural number. (This is part of Fact 3.6. One can do a similar proof for multiplication, and with some work replace “natural numbers” by “integers”). Hint: Fix m and use induction on n. Solution. Following the hint, we fix an integer m, and use the principle of mathematical induction on the propositional function p(x) saying “m + x is a natural number”. For the base case, p(0) says that m + 0 = m is a natural number. This is true by the assumption on m. For the inductive step, assume p(n) holds, i.e. m + n is a natural number. We want to see that p(n + 1) holds, i.e. m + n + 1 is a natural number. This holds because the natural numbers are an inductive set: m + n ∈ N implies (m + n) + 1 ∈ N. By the principle of mathematical induction, we conclude p(n) holds for all natural numbers n, i.e. for any natural number n, m+n is a natural number. 4 SOLUTION TO ASSIGNMENT 4 Problem 4 (20 points) (1) For each of the set of real numbers below, say whether it is inductive and prove your claim: (a) Z. (b) R\Q. (c) (R\Q) ∪ N. (d) R\{ 12 }. (2) Using the definition of the natural numbers as the intersection of all inductive sets, show that if x is a real number such that 0 < x < 1, then x ∈ / N. Hint: Consider the set {y ∈ R | y > x} ∪ {0}. Solution. (1) (a) Z is inductive: 0 is an integer, and if x is an integer, then x + 1 is an integer (Fact 3.6). (b) R\Q is not inductive, as it does not contain any rational number, so does not contain 0. (c) The set X = (R\Q) ∪ N is inductive. It contains 0, since 0 is a natural number. For the other condition, let x ∈ X. We show x + 1 ∈ X. X is a union of two sets, so either x ∈ R\Q or x ∈ N. If x ∈ N, then as N is an inductive set, x + 1 ∈ N, so x + 1 ∈ X. If x ∈ R\Q, then x is a real that is not rational (i.e. x is irrational), so x + 1 is also irrational (suppose not. Then x + 1 = n/m for some integers n and m with m nonzero, and so x = n/m − 1 which is rational, a contradiction). Thus x + 1 ∈ R\Q, so x + 1 ∈ X, as needed. (d) R\{ 12 } is not inductive, as − 12 is in this set, but − 21 + 1 = 12 is not. (2) The set X := {y ∈ R | y > x} ∪ {0} is an inductive set: 0 ∈ X, and if z ∈ X, then either z = 0, in which case z + 1 = 1 is in X, as 1 > x, or z > x, in which case also z + 1 > x, so z + 1 ∈ X. Moreover, x∈ / X (we assumed x 6= 0, and x cannot be larger than itself). Thus N ⊆ X (N is contained in any inductive set), and so if we had x ∈ N, we would have x ∈ X, leading to a contradiction. Therefore x ∈ / N. Problem 5 (20 points) (1) Fix a real number r 6= 1. Show that for any natural number n, Pn i 1−rn+1 i=0 r = 1−r . (2) Explain why we assumed r 6= 1 in (1), and give a simple formula to compute the sum in case r = 1. You can assume the following basic fact: for real numbers a, b, c, d with b and d nonzero, ab + dc = ad+bc bd . Solution. P x+1 (1) We prove it by induction, with p(x) standing for xi=0 ri = 1−r . 1−r P0 i 0 For the base case, we have that on the one hand i=0 r = r = 1, SOLUTION TO ASSIGNMENT 4 5 0+1 1−r and on the other hand 1−r 1−r = 1−r = 1, thus p(0) holds. For the inductive step, assume p(n) holds. We compute: n+1 X ri = rn+1 + i=0 n X ri i=0 1 − rn+1 1−r rn+1 (1 − r) + 1 − rn+1 = 1−r n+2 1−r = 1−r = rn+1 + This is as desired. By the principle of mathematical induction, p(n) is true for all natural numbers n. (2) We assumed r 6= 1 to avoid dividing by zero in the formula on the right hand side. The sum on the left hand side P defined, and P still stays it is not hard to show (by induction) that ni=0 1i = ni=0 1 = n + 1. Extra credit: Russel’s paradox (20 points) Show that there is not set of all sets, i.e. there is no set A such that B ∈ A exactly if B is a set. Hint: Suppose that such an A exists and derive a contradiction as follows: consider the family S of sets in A that are not members of themselves and ask whether S is a member of itself1. Solution. Assume for a contradiction there is a set A containing exactly all the sets. By the axiom of specification, we can form the set S := {B ∈ A | B∈ / B} of sets that are not members of themselves. By basic logic, we have that either S ∈ S or S ∈ / S. Let’s look at each case separately. Assume S ∈ S. Then by definition of S, S ∈ / S (just replace B by S in “B ∈ / B” in the set-builder definition of S). Thus in case S ∈ S, we get a contradiction. Assume now S ∈ / S. Since A contains all sets, we have in particular that S ∈ A. Since we also have that S ∈ / S, we must have that S ∈ S = {B ∈ A | B∈ / B}. This is a contradiction again. In both cases, we got a contradiction, so the original assumption that there was a set of all sets is invalid. Closer to the real world, there cannot be a book listing all non-selfreferential books: if it lists itself, then it must be non-self-referential, but we know it is, since it lists itself. If it does not list itself, it is non-self-referential, but then the list inside the book is missing the book itself. 1Closer to the real world, think about why there cannot be a book listing all non-self- referential books. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 5 Problem 1 (10 points): Dividing Assume n, m, and k are integers. Prove or disprove: (1) If k divides n, then [k divides m if and only if k divides n + m]. (2) If k divides n + m, then [k divides n or k divides m]. (3) If k divides n, then k divides n · m. (4) If k divides n · m, then [k divides n or k divides m]. (5) If m and n are coprime, then m and m − n are coprime. Solution. (1) This is true. Fix n0 ∈ Z such that n = kn0 . If k divides m, then m = km0 for some m0 ∈ Z, and so n + m = km0 + kn0 = k(m0 + n0 ), so k divides m + n. Conversely, if k divides n + m, then n + m = kr for some r ∈ Z, so m = (n + m) − n = kr − kn0 = k(r − n0 ) so k divides m. (2) This is false: 2 divides 1+1 = 2·1, but 2 does not divide 1 (otherwise we would have 1 ≥ 2, which is false). (3) This is true: fix n0 such that n = kn0 . Then nm = kn0 m = k(n0 m) so k divides n · m. (4) This is false: 4 divides 2 · 2, but 4 does not divide 2. (5) This is true: assume m and n are coprime but m and m − n are not. Then there exists a prime p dividing m and m − n. By (4), p divides −(m − n). By (1), p divides m − (m − n) = n. Thus p divides m and n and so m and n are not coprime, contradiction. Problem 2 (20 points): The well ordering property Recall that a is a minimal element of X ⊆ R if a ∈ X and for any b ∈ X, a ≤ b. Show that any non-empty subset of N has a minimal element. Hint: Prove by strong induction on n that any subset of N which contains n has a minimal element. Solution. We prove by strong induction the proposition p(x) saying “every subset of N containing x has a minimal element”. For the base case, if S is a subset of N containing 0, then 0 is a minimal element of S as 0 is the smallest natural number. For the inductive step, assume n ≥ 1 and p(m) holds for all m < n. Let S be a subset of N containing n. If S does not contain any m < n, then n is a minimal element of S. If S contains some m < n, then we can apply the induction hypothesis to deduce that S has Date: June 6, 2014. 1 2 SOLUTION TO ASSIGNMENT 5 a minimal element. By the principle of strong induction we conclude that p(n) is true for all natural numbers n. Since any non-empty subset S of N containg some n ∈ N, we are done. Problem 3 (20 points) Show that for every nonzero integer n there exists a unique natural number m and a unique odd integer k such that n = 2m k. Solution. We first show by strong induction the proposition p(x) saying that if x is a positive natural number, x can be written as 2m k for some natural number m and odd natural number k. We start our induction at 1: for the base case, 1 = 20 · 1. For the inductive step, assume n ≥ 1 is given and p(n0 ) holds for every n0 < n. If n is odd, we take m = 0 and k = n. If n is even, we have n = 2n0 for some positive natural number n0 . By the 0 0 induction hypothesis, n0 can be written as n0 = 2m k, so n = 2n0 = 2m +1 k, so m := m0 + 1 does the job. By the principle of strong induction, p(n) is true for all positive natural numbers n. To finish the proof of existence, let n be an arbitrary nonzero integer. If n > 0, we are already done as we know p(n). If n < 0, we apply p(−n) to obtain an odd natural number k 0 and a natural number m such that −n = 2m k 0 . Letting k := −k 0 , we get that n = 2m k, as desired. 0 To see uniqueness, assume 2m k = 2m k 0 for m, m0 natural numbers and k, k 0 odd integers numbers. Without loss of generality, m ≤ m0 . Then 0 2m−m k = k 0 , and if we had m < m0 , the left hand side would be even but the right hand side would be odd, which cannot happen. Thus we must have m = m0 , and so k = k 0 . Problem 4 (20 points): Coding ordered pairs with sets (1) For objects a and b, define (a, b) to be the set {{a}, {a, b}}. Show that for any objects a, b, c, d, if (a, b) = (c, d), then a = c and b = d. (2) Prove or disprove: (a) For all sets A, B, C, D: (A × B) ∪ (C × D) = (A ∪ C) × (B ∪ D). (b) For all sets A, B, C, D: (A × B) ∩ (C × D) = (A ∩ C) × (B ∩ D). Solution. (1) We first prove that for any objects x, y, z, {x, y} = {x, z} implies y = z. To see this, we consider two cases: if x = z, then {x, z} = {x}, and so {x, y} = {x}, i.e. y = x, and therefore y = z. If x 6= z, then it must be that y = z, and the result follows. Now assume (a, b) = (c, d), i.e. {{a}, {a, b}} = {{c}, {c, d}}. Then since sets are determined by their elements, we must have that either {a} = {c}, or {a} = {c, d}. In both cases, {c} ⊆ {a}, so c ∈ {a}, and hence c = a. Therefore we know that {{a}, {a, b}} = {{a}, {a, d}}. Appealing to the first paragraph, {a, b} = {a, d}, and appealing to it again, b = d. SOLUTION TO ASSIGNMENT 5 3 (2) (a) This is false: Take A = B = {1}, C = D = {2}. Then (1, 2) ∈ (A∪C)×(B ∪D) but (1, 2) ∈ / (A×B)∪(C ×D) = {(1, 1), (2, 2)}. (b) This is true: If (x, y) is in (A×B)∩(C×D), then since (x, y) is in both A×B and C ×D, x ∈ A and x ∈ C, and y ∈ B and y ∈ D. Thus x ∈ A ∩ C and y ∈ B ∩ D, so (x, y) ∈ (A ∩ C) × (B ∩ D). Conversely if (x, y) ∈ (A ∩ C) × (B ∩ D), x ∈ A and x ∈ C and y ∈ B and y ∈ D, so (x, y) ∈ A × B and (x, y) ∈ C × D, so (x, y) ∈ (A × B) ∩ (C × D). Problem 5 (20 points) (1) Give an example of a set A and a relation on A which is reflexive, symmetric, but not transitive. (2) Show that the relation E on the set R defined by xEy if and only if x − y is rational is an equivalence relation. Is this still true if we replace “rational” by “irrational”? (3) Given an equivalence relation E on a set A and a ∈ A, the equivalence class [a]E of a is defined to be the set {b ∈ A | bEa}. Write A/E for the set of equivalence classes of E. Show that for any a and b in A: (a) a ∈ [a]E . (b) If aEb, then [a]E = [b]E , and if ¬(aEb), then [a]E ∩ [b]E = ∅. (c) A is the union of all sets of the form [a]E for a ∈ A. (4) Given an equivalence relation E on a set A, show that there exists a set B and a function f : A → B such that for all a, b ∈ A, aEb if and only if f (a) = f (b). Hint: take B = A/E. Solution. (1) Take A = {0, 1, 2}, R = (A × A)\{(0, 2), (2, 0)}. Then it is easy to check reflexivity and symmetry, but transitivity fails: 0R1 and 1R2, but not 0R2. (2) We check E is reflexive, symmetric, and transitive. Let x, y, z be real numbers. We have that xEx since x − x = 0 is rational. Thus E is reflexive. If xEy, then x − y is rational, and so y − x = −(x − y) is rational. Therefore E is symmetric. If xEy and yEz, then x − y is rational and y − z is rational. Therefore x − z = x − y + y − z is also rational. This is no longer true if we replace rational by irrational: reflexivity fails as 0 − 0 is not irrational. (3) (a) By reflexivity, aEa, so a ∈ [a]E . (b) Assume aEb. We show that [a]E ⊆ [b]E . Using symmetry, bEa and so the same proof will give us [b]E ⊆ [a]E . Let c ∈ [a]E . Then cEa and aEb, so cEb by transitivity. Therefore c ∈ [b]E , as needed. Now assume ¬(aEb), and assume for a contradiction c ∈ [a]E ∩ [b]E . Then cEa and cEb. By symmetry, aEc. By transitivity, aEb, a contradiction. (c) Let B be the union of all sets of the form [a]E for a ∈ A. If a ∈ A, then by the previous part, a ∈ [a]E , so a ∈ B. Conversely, if 4 SOLUTION TO ASSIGNMENT 5 b ∈ B, then by definition of the union, b ∈ [a]E for some a ∈ A, and so in particular b ∈ A. This shows A, B are subsets of each other and so A = B. (4) Take B = A/E, and let f (a) := [a]E . If aEb, then f (a) = [a]E = [b]E = f (b) by the previous part. Conversely, if [a]E = f (a) = f (b) = [b]E , then by the previous part, a ∈ [a]E = [b]E , so aEb by definition of an equivalence class. Extra credit (20 points): The Fibonacci sequence For n a natural number, define the nth Fibonacci number an inductively by: • a0 = 0. • a1 = 1. • an = an−1 + an−2 if n ≥ 2. (1) Compute explicitly a0 , a1 , a2 , ..., a8 . √ √ n n 1+ 5 1− 5 , where φ = and ψ = (2) Show that an = φ √−ψ 2 2 . Hint: First 5 2 2 show that φ = φ + 1 and ψ = ψ + 1. Solution. (1) a0 = 0, a1 = 1, a2 = 0 + 1, a3 = 1 + 1 = 2, a4 = 3, a5 = 5, a6 = 8, a7 = 13, a8 = 21. (2) After some boring but easy computations, we see that φ2 = φ + 1 and ψ 2 = ψ + 1. It follows that for any natural number n ≥ 2, φn = φn−2 φ2 = φn−2 (φ + 1) = φn−1 + φn−2 , and similarly for ψ. n n . We Now we prove by strong induction on n that an = φ √−ψ 5 check the cases n = 0 and n = 1 separately. For n = 0, an = 0 = √ √5 5 1−1 √ , 5 √ = = 1 = a1 . Now we assume n ≥ 2 and the and for n = 1, φ−ψ 5 formula holds for all m < n. Then: 1 1 an = an−1 + an−2 = √ φn−1 + ψ n−1 + φn−2 + ψ n−2 = √ (φn + ψ n ) 5 5 Where the first equality is by the induction hypothesis, and the second is by the computation carried out in the first paragraph above. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 6 Problem 1 (20 points) Assume f : A → B and g : B → C are functions. (1) Assume f and g are injective. Show that g ◦ f is injective. (2) Assume f and g are surjective. Show that g ◦ f is surjective. (3) Assume g ◦ f is a bijection. Is f injective? Is g injective? (4) Assume g ◦ f is a bijection. Is f surjective? Is g surjective? Solution. (1) Let a, a0 ∈ A and assume (g ◦ f )(a) = (g ◦ f )(a0 ), i.e. g(f (a)) = g(f (a0 )). Since g is injective, f (a) = f (a0 ). Since f is injective, a = a0 , as desired. (2) Let c ∈ C. We have to find a ∈ A such that (g ◦ f )(a) = g(f (a)) = c. Since g is surjective, there is b ∈ B such that g(b) = c. Since f is surjective, there is a ∈ A such that f (a) = b. Then g(f (a)) = g(b) = c, as needed. (3) f is injective: Let a, a0 ∈ A and assume f (a) = f (a0 ). Then g(f (a)) = g(f (a0 )), and so (g◦f )(a) = (g◦f )(a0 ), hence by injectivity of g ◦ f , a = a0 . g need not be injective: for a counterexample, take A = {1, 2}, B = {1, 2, 3} and C = {1, 2}. Let f (x) = x, g(1) = 1, g(2) = g(3) = 2. The last definition witnesses that g is not injective but (g ◦f )(1) = 1, (g ◦f )(2) = 2, so it is easy to see g ◦f is a bijection from A to B. (4) g is surjective: Given c ∈ C, we know there is a ∈ A such that g(f (a)) = c. Let b := f (a). Then g(b) = c, therefore g is surjective. f need not be surjective: Consider the same example as before. Then f is not surjective as there is no a ∈ A such that f (a) = 3, yet g ◦ f is a bijection. Problem 2 (20 points) (1) Assume f : A → B is a bijection. Prove that f −1 is a bijection. (2) Assume f : A → B is an injection. Show that for any set C ⊆ A, C is equipotent to its image f [C]. (3) Assume U is a set. Show that the relation E on P(U ) defined by AEB if and only if A is equipotent to B is an equivalence relation. (4) Show that if A is a set and n and m are natural numbers such that A is equipotent to both [n] and [m], then n = m. Date: June 16, 2014. 1 2 SOLUTION TO ASSIGNMENT 6 Solution. (1) We first show that f −1 is injective. Assume b, b0 ∈ B are such that a := f −1 (b) = f −1 (b0 ). By definition of the inverse, this means that f (a) = b and f (a) = b0 , so b = b0 . Thus f −1 is injective. To see surjectivity, assume a ∈ A. We want to find b ∈ B such that f −1 (b) = a. Let b := f (a). By definition, f −1 (b) is the unique a0 such that f (a0 ) = b, so by this uniqueness we must have a = a0 , and hence f −1 (b) = a, as needed. Therefore f −1 is surjective, and so f −1 is a bijection. (2) The map g : C → f [C] defined by g(c) = f (c) is a bijection: it is injective because f is injective, and it is surjective by definition of f [C]. (3) It is reflexive: For A ⊆ U , the function f : A → A defined by f (a) = a is a bijection witnessing that A is equipotent to A. It is symmetric: if A is equipotent to B, then pick f : A → B a bijection. By the previous part f −1 : B → A is also a bijection, and hence B is equipotent to A. It is transitive: Assume A is equipotent to B and B is equipotent to C. Then we have f : A → B and g : B → C bijections. By the previous problem, g ◦ f : A → C is injective and surjective, and hence a bijection. Therefore A is equipotent to C. (4) Assume A is equipotent to [n] and [m]. Since being equipotent is an equivalence relation by the previous part (with e.g. U := A ∪ [n] ∪ [m]), we can use symmetry of equipotence to get that [n] is equipotent to A, and so by transitivity, [n] is equipotent to [m]. By Theorem 8.30 in the notes, this implies that n = m. Problem 3 (20 points) Show that: (1) If n is a natural number and A ⊆ [n]. Then A is finite and |A| ≤ n with equality if and only if A = [n]. Hint: use induction on n. (2) For natural numbers n and m, if f : [n] → [m] is an injection, then n ≤ m. (3) If f : A → B is an injection and B is finite, then A is finite. Conclude that if A ⊆ B and B is finite, then A is finite, and if A ⊆ B and A is infinite, then B is infinite. Hint: use (1). (4) If A and B are countable, then A × B is countable. Solution. (1) We use induction on the propositional function p(x) which says “For any set A ⊆ [x], A is finite, |A| ≤ n, and (|A| = n if and only if A = [n])”. For the base case, let A ⊆ [0] = ∅. Then A = ∅. Therefore by reflexivity of equipotence, A is equipotent to ∅ = [0], and so |A| = 0 by definition of cardinality. This takes care of all three things to prove. SOLUTION TO ASSIGNMENT 6 3 For the inductive step, we assume that n is a natural number and for any set B ⊆ [n], B is finite, |B| ≤ n, and (|B| = n if and only if B = [n])”. We want to show the same statement with n replaced by n + 1. Let A be an arbitrary subset of [n + 1]. Consider the set B := A\{n + 1}. • We first show that A is finite with |A| ≤ n + 1. B is a subset of [n], so by the induction hypothesis, B is finite with m := |B| ≤ n. By definition of cardinality there is a bijection f : B → [m]. If B = A, m = |A| ≤ n ≤ n + 1, so we are done. Otherwise, n + 1 ∈ A, and A = B ∪ {n + 1}. Let g : A → [m + 1] be defined by g(k) = f (k) if k 6= n + 1, and g(n + 1) = m + 1. Then it is easy to check g is a bijection and it follows that A is finite and |A| = m + 1 ≤ n + 1. • Now, if A = [n + 1], then by reflexivity of equipotence and definition of cardinality, |A| = n + 1. Conversely, if |A| = n + 1, then we must have that n + 1 ∈ A (otherwise, B = A and by the induction hypothesis, |A| = |B| = n < n + 1). Thus A = B ∪ {n + 1}, and by the argument above |B| = n. By the induction hypothesis, B = [n], so A = B ∪ {n + 1} = [n + 1]. (2) Assume we have an injection f : [n] → [m]. The image A := f [[n]] is a subset of [m], so by the previous part, has cardinality m0 ≤ m. Since [n] is equipotent to A, it follows [n] also has cardinality m0 , i.e. [n] is equipotent to [m0 ], so by Theorem 8.30, n = m0 ≤ m, as desired. (3) Assume f : A → B is an injection and B is finite. By definition, this means there exists a bijection g : B → [n] for some natural number n. Thus by problem 1, the composition h := g ◦ f is an injection from A to [n]. Now, h[A] is a subset of [n], so must be finite by (1). By problem 2, A is equipotent to h[A], so A is also finite. If we have A ⊆ B and B is finite, the inclusion map f : A → B defined by f (a) = a is an injection, and thus applying the previous paragraph, A is finite. If A ⊆ B and A is infinite, then if B were finite, A would be finite by the previous sentence, so B is infinite. (4) Fix f : A → N and g : B → N bijections. Define the bijection h : A × B → N × N by h((a, b)) := (f (a), g(b)). It is very easy to check it is a bijection and one knows (Theorem 8.41) that N × N is countable. By transitivity of countability, A × B is also countable. Problem 4 (20 points): Size of the power set (1) Fix a natural number n. Formally, a binary n-tuple s is a function from [n] to {0, 1}. You can see s as a list s(1), s(2), . . . , s(n) of n zeroes or ones. Show that there is a bijection from P([n]) to the set of binary n-tuples (that is, one can “code” subsets of [n] using n-tuples of zeroes and ones). Hint: let the ith element of the tuple 4 SOLUTION TO ASSIGNMENT 6 be 1 if i is in the set and 0 otherwise. Use this result to explain informally why |P([n])| = 2n . (2) For the rest of this problem, assume A is a set. Show that there is an injection f : A → P(A). (3) Write A {0, 1} for the set of functions from A to {0, 1}. Generalize (1) by showing that there is a bijection from P(A) to A {0, 1}. (4) Write A A for the set of functions from A to A and assume A has at least two elements. Show that there is an injection from P(A) to A A. Is this still true if A has one element? What about no elements? Solution. (1) Let S be the set of binary n-tuples. We send the set A ⊆ [n] to the binary tuple (a1 , a2 , ..., an ) with ai = 1 if i ∈ A and ai = 0 otherwise. Let f : P([n]) → S be this map. This is an injection, as if f (A) = (a1 , a2 , ..., an ) = f (A0 ), then i ∈ A if and only if ai = 1 if and only if i ∈ A0 , so since sets are determined by their elements, A = A0 . This is a surjection, as given a tuple a := (a1 , ..., an ), we can let A ⊆ [n] be such that i ∈ A if and only if ai = 1. Then f (A) = a. Note that this also works if n = 0, as the only 0-tuple is the empty tuple (), and the only subset of ∅ is ∅, so f (∅) = () is also a bijection. There are 2n many binary n-tuples, since there are 2 choices for the first component, and for each choice there are two choices for the second component, and so on, so as there are n components there are 2 · 2 · ... · 2 (n times), or 2n binary n-tuples. Since |S| = 2n and P([n]) is equipotent to S, we must also have |P([n])| = 2n (by definition of cardinality). (2) Define f : A → P(A) by f (a) = {a}. If f (a) = f (a0 ), then {a} = {a0 }, and so a = a0 , so f is an injection. (3) Define a bijection from P(A) to A {0, 1} sending a subset S of A to the function g : A → {0, 1} defined by g(a) = 1 if a ∈ S and g(a) = 0 if a ∈ / S. As before, since sets are determined by their elements, it is very easy to check it is a bijection. (4) Pick two distinct elements a0 and a1 in A. Now do the same thing as before with a0 replacing 0 and a1 replacing 1: namely send each set S ⊆ A to the function g : A → A defined by g(a) = a1 if a ∈ S and g(a) = a0 if a ∈ / S. As before, this is an injection (not necessarily a surjection anymore, as there might be other elements than a0 and a1 in A). If A has one element, |P(A)| = |{∅, A}| = 2, but there is only one function from A to A, so there cannot be an injection from P(A) to A by problem 3. If A has zero elements, |P(A)| = 1, and there is also one function from A to A (the empty function), so one can simply map the only element of P(A) to the empty function, obtaining a bijection. SOLUTION TO ASSIGNMENT 6 5 Problem 5 (20 points) (1) For each of the following four conditions, give an example of a function from N to N which satisfies it: bijective and not the identity, injective and not surjective, surjective and not injective, not surjective and not injective. (2) We say s is a bit string if it is a binary n-tuple for some natural number n. Show that the set of all bit strings is countable. (3) Show that the set of all finite binary tuples √ is countable. (4) Show that the set {x ∈ R | x = a + b 42 for some a, b ∈ Q} is countable. (5) Show that the set of irrational numbers is uncountable. Solution. (1) A bijective function f1 : N → N that is not the identity is defined by f1 (0) = 1, f1 (1) = 0, and f1 (n) = n for n ≥ 2. An injective but not surjective function is f2 : N → N defined by f2 (n) = n + 1: 0 is not in the range of f2 as 0 − 1 = −1 is not a natural number, but f2 is still injective: if f2 (n) = f2 (n0 ), then n + 1 = n0 + 1, so n = n0 . A surjective but not injective function is given by f3 (n) = the smallest natural number ≤ n2 (for example, f3 (0) = 0/2 = 0, f3 (1) = 0, f3 (2) = 1, . . .). It is not injective as f3 (0) = f3 (1), but it is surjective as given b ∈ N, f3 (2b) = b. A function that is not injective and not surjective is given by the function which is 0 no matter what the input is. (2) Let An be the set of all binary n-tuples. We argued in part (1) that |An | = 2n , so each An is finite and hence atSmost countable. The set of finite binary tuples is simply the union ∞ n=0 An of the An s. This is a countable union, so by Fact 8.44, it must be at most countable. It is also an infinite set, since the map sending n ∈ N to the n-tuple with n zeroes is an injection (by Example 8.34.2, N is infinite, so if N injects into another set B, B must be infinite: otherwise this would contradict problem 3.3). Thus by definition of “at most countable”, it is countable. √ (3) The map f (a, b) := a + b 42 is a surjection from Q × Q to X. We know that Q is countable (Theorem 8.43) and hence by Problem 3.4 that Q × Q is countable. X is also infinite since it contains the rational numbers: just set b = 0 in the definition. Applying Fact 8.40 from the notes, we obtain that X is countable. Note that we did not even need to prove that f is an injection (although it is actually true). (4) Assume not. Then we have that the set of irrational numbers is at most countable, and R is the union of the set of rational numbers and the irrational numbers, both of which at most countable. Therefore by Fact 8.44, R is at most countable, which we know is not true (Theorem 8.46). 6 SOLUTION TO ASSIGNMENT 6 Extra credit (20 points): Cantor’s theorem and uncomputability (1) Prove Cantor’s theorem: given a set A, there is no surjection from A to P(A) (so in this sense, the cardinality of P(A) is strictly larger than that of A). Hint: Assume for a contradiction there is such a surjection F : A → P(A), and consider the set {a ∈ A | a ∈ / F (a)}. (2) At the bottom, computers deal with bit strings: finite strings of 0s and 1s (i.e. binary n-tuple for some n). We think of a computer program simply as a bit string and assume that each computer program P computes a function fP that takes as input a bit string and outputs another bit string. For example, one can write a (very rudimentary) calculator program P for which fP would take as input a bit string coding two natural number n and m and output a bit string coding n+m. Show that there is a function from the set of bit strings to the set of bit strings that no computer program can compute. Hint: How many programs are there? How many functions are there? Solution. (1) We follow the hint and let X := {a ∈ A | a ∈ / F (a)}. Since F is surjective, and X ∈ P(A), there is a ∈ A such that F (a) = X. Now either a ∈ X or a ∈ / X. If a ∈ X, then by definition, a ∈ / F (a) = X, a contradiction. If a ∈ / X = F (a), then by definition of X, we must have a ∈ X, a contradiction again. Therefore F could not have existed in the first place. (2) As shown in problem 5, the set S of all bit strings is countable, so there are only countably many programs. By problem 4, P(S) injects into the set X of functions from S to S. By Cantor’s theorem, P(S) is uncountable, so X is also uncountable. As there are only countably many programs, this means that there must be f ∈ X such that f 6= fP for all programs P , i.e. f cannot be computed by any program. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 7 Problem 1 (20 points) (1) Prove the rule of sum for two sets: For any disjoint finite sets A and B, |A ∪ B| = |A| + |B|. Hint: Assume A has size n, B has size m, and show A ∪ B and [n + m] are equipotent. (2) Prove the inclusion-exclusion principle: For any finite sets A and B, |A ∪ B| = |A| + |B| − |A ∩ B|. Hint: Decompose the union into disjoint sets and use the rule of sum. Solution. (1) Let A and B be disjoint finite sets. Let n := |A| and m := |B|. Fix bijections f : [n] → A and g : [m] → B witnessing this. Define h : [n + m] → A ∪ B by h(i) = f (i) if i ≤ n, and h(i) = g(i − n) if i > n. We claim it is also a bijection, and from this it will follow that [n+m] and A∪B are equipotent, proving that |A∪B| = n+m. First, let’s see h is an injection. Assume h(i) = h(i0 ) for i, i0 ∈ [n + m]. Assume without loss of generality that i ≤ i0 . There are three cases: in the first case, i, i0 ≤ n, and so h(i) = f (i), h(i0 ) = f (i0 ), and so since f is an injection, i = i0 . In the second case, i, i0 > n, and so h(i) = g(i−n), h(i0 ) = g(i0 −n). Since g is an injection, i−n = i0 −n, so i = i0 . In the third and last case, i ≤ n but i0 > n (we cannot have i > n and i0 ≤ n since we assumed i ≤ i0 ). Then h(i) = f (i) and h(i0 ) = g(i − n), so a := f (i) = g(i − n). However, f (i) ∈ A and g(i − n) ∈ B, so a is in both A and B, so a ∈ A ∩ B, so A and B are not disjoint. This shows that the third case cannot happen, and concludes the proof that h is an injection. Next, let’s see that h is a surjection. Let c ∈ A ∪ B be arbitrary. We have to find i ∈ [n + m] such that h(i) = c. We consider two cases: In the first case, c ∈ A. Since f is a surjection, there is i ∈ [n] such that f (i) = c. Therefore h(i) = f (i) = c. In the second case, c ∈ B. Since g is a surjection, there is i0 ∈ [m] such that g(i) = c. Let i := i0 +n. Then i > n and i ∈ [n+m], so h(i) = g(i−n) = g(i0 ) = c, as desired. (2) We first observe that A = (A\B) ∪ (A ∩ B) (by the distributive law for logical operators, x ∈ A if and only if ((x ∈ A and x ∈ / B) or (x ∈ A and x ∈ B))). Moreover, the sets A\B and A∩B are disjoint, and are subsets of A which is finite, so also finite. Thus by the rule Date: June 18, 2014. 1 2 SOLUTION TO ASSIGNMENT 7 of sum |A| = |A\B| + |A ∩ B|. Interverting the role of A and B, we also have that |B| = |B\A| + |A ∩ B|. Similarly, it is easy to check that A∪B = (A\B)∪(B\A)∪(A∩B) and all sets in this union are disjoint. Therefore by the rule of sum and the previous paragraph: |A∪B| = |A\B|+|B\A|+|A∩B| = (|A|−|A∩B|)+(|B|−|A∩B|)+|A∩B| = |A|+|B|−|A∩B| Problem 2 (20 points) Assume n, m, and k are natural numbers. Give a combinatorial proof of the following identities by “counting in two ways”. P (1) 2n = ni=0 ni (also explain how this follows from the binomial theorem). P (2) For n ≥ 1, ni=0 i ni = n2n−1 . n Pk m m+n . (3) i=0 i k−i = k Give an algebraic proof that for any natural numbers n and k: Pn i n+1 (4) i=0 k = k+1 Solution. (1) On the one hand, the number of ways to choose a subset of [n] is 2n (as has been computed in class and also in a previous assignment). On the other hand, to choose a subset of [n], we can first pick a size i between 0 and n for that set, and then choose it among the n i possiblities. Since each set has exactly one size, the rule of sum tells Pn usnthat the number of ways to choose a subset of [n] is also i=0 i . The result also follows from plugging x = y = 1 in the binomial theorem. (2) We consider the process of choosing a subset of [n], and then choosing a distinguished element inside that subset. On the one hand, one can first choose the distinguished element among the n possibilities, and then choose a set among the 2n−1 subsets of [n] that contain the distinguished element (this is where we use n ≥ 1). By the rule of product, this gives us that there are n2n−1 ways of making such a selection. On the other hand, we can first pick a size for the set, and for each possible size i choose among the ni subsets, and then pick a distinguished elements among the ipossibilities. By the rule of products, for a fixed size i, there are ni i ways of doing this, and by the rule of sum, we obtain the left hand side of the identity. (3) We consider the process of choosing a subset of [m + n] with k elements. By definition, there are m+n many such sets, so this k gives us the right hand side. To pick such a set, we can first decide how many elements of the set are going to be in [m], and how many are going to be in the remaining n elements of [m + n]. For each choice i of the number of elements in [m], we have mi possible SOLUTION TO ASSIGNMENT 7 3 subsets of [m] to pick, and then have to complete this with one of n subset of [m + n]\[m]. By the rule of product, this gives us k−i n m k−i choices. Since the possibilities are disjoint for each i, the i rule of sum gives us the left hand side. 1 (4) We prove it by induction on n. For n = 0, we get k0 = k+1 . If k = 0, both are 1, and if k > 0, both are 0, so this takes care of the base case. For the inductive step, assume it is true for n, and let’s prove it for n + 1: n+1 X i=0 i k X n n+1 i n+1 n+1 n+2 = + = + = k k k k+1 k+1 i=0 This is as required. The equality before last used the induction hypothesis, and the last equality is by Pascal’s formula. Problem 3 (20 points) For this problem and the next, an answer given as some expression involving binomial coefficients and factorials (like 123! 42 21 ) is fine, no need to compute a final number. Also recall that poker hands are considered to be unordered. (1) How many poker hands are there that contain two pairs and only two suits? (2) How many poker hands are there that contain either exactly three jacks or exactly two spades (or both)? (3) How many poker hands are there that contain a two, a three, and three other cards of different ranks? (4) How many poker hands are there that contain at most two different suits and five distinct ranks? Solution. (1) There are 42 possible suits to choose from and 13 2 possible ranks for the two pairs. One these have been determined, we have only to choose the suit (two possibilities) and the rank (11 possibilities, since the two others of a suitable suit are of the remaining taken) card. By the rule of product, there are 42 · 13 ·2·11 possible hands. 2 (2) Let’s first compute the number a of hands containing exactly three jacks. We have 4 ways of selecting the three jacks (a triple of jacks is determined by the missing suit), and the two remaining cards can be anything that is not the last jack, so there are 49−1 possibilities. 2 In total, there are a := 4 · 48 hands containing exactly three jacks. 2 Now, let’s compute the number b of hands containing exactly two ways of picking the ranks for those spades. spades. There are 13 2 Then we have three cards left to choose from and we cannot pick a spade. There are 13−2 = 11 spades left in the deck, so we can choose 4 SOLUTION TO ASSIGNMENT 7 39 the rest in (52−2)−11 ways. In total, b = 13 3 2 · 3 . Now we use the principle of inclusion-exclusion to compute the number of hands containing exactly three jacks or exactly two spades. For this, we have to compute the number c of hands containing both exactly three jacks and two spades. There are two mutually disjoint possibilities: either one of the jack is a spade, or none of the jacks are spades but 3 the two other cards are. In the first case, we have 2 ways of picking the remaining jacks, 13 − 1 = 12 ways of choosing the next spade, and (52 − 3) − 11 = 38 ways of choosing the last card. In the second 12 case, we have exactly one choice for the jacks and 2 choices for the rank of the two spades. Putting things together, c = 32 ·12·38+ 12 2 . Therefore the number of hands containing 13either 39 exactly three jacks 3 12 or exactly two spades is a+b−c = 4· 48 + · −( 2 2 3 2 ·12·38+ 2 ). (3) There are 4ways of choosing the two, 4 ways of choosing the three, of choosing the three remaining cards. In and 43 · 11 3 many ways 11 5 total, there are 4 · 3 many ways. (4) We separately count this number for exactly one suit, and exactly two suits. For one suit, this is simply the number of flushes: 4 · 13 5 (pick a suit, then pick the five ranks). With two different suits, there are 42 ways of picking the suits, and then 13 5 ways of picking the ranks. Say the suits are spade and diamond. We can either have four of the cards in spade and one in diamond (5possibilities), three of the cards in spade and two in diamond ( 52 possibilities), two in spade and three in diamond ( 53 = 52 possibilities), or one in spade and four in diamond (5 possibilities). This is also 25 − 2: we have two choices for the suit of each card, but we have to remove the hands that are all spades or all diamonds. In 5total, we have 4 13 5 13 4 13 4 · 13 + (2 · (5 + )) = 4 · + 5 2 5 2 5 2 5 (2 − 2) possible ways. Problem 4 (20 points) (1) How many different arrangements can one make with the letters of INFINITY? (for example, FINITYIN would be one such arrangement). (2) (a) How many strictly positive natural number solutions does the equation x1 +x2 +x3 +x4 +x5 = 123 have? Hint: Do a change of variables to reduce this back to counting the number of natural number solutions. (b) How many natural number solutions does the equation x1 +x2 + x3 + x4 + x5 ≤ 123 have? Hint: Add a variable. (3) Assume m and n are natural numbers, and we are given m different objects and n different boxes. In how many different ways can we put objects into boxes (without restrictions)? In how many different ways can we put objects into boxes so that two distinct objects are SOLUTION TO ASSIGNMENT 7 5 never in the same box? We assume that both boxes and objects are distinguishable so for example if n = m = 2, putting object 1 in box 1 and object 2 in box 2 is not the same as putting object 1 in box 2 and object 2 in box 1. (4) For n ≥ 7 a natural number, how many binary n-tuples are there that either begin with 01, end with 1110, or have an even number of 1s? Warning: as always in mathematics, “or” is not the same as “exclusive or”. Solution. (1) Call the number of arrangements we are looking for m. INFINITY contains 8 letters. The letter I is repeated three times, and the letter N is repeated two times. If we first assume that all the letters are different, then there are 8! permutations. However, for each such permutation, we can permute the letter I and the letter N in 3! · 2! 8! . ways. Thus m · 3! · 2! = 8!, or m = 3!2! (2) (a) Let yi := xi − 1 (so xi = yi + 1). xi is a positive natural number if and only if yi is a natural number, hence counting the number of positive solutions to the equation x1 + x2 + x3 + x4 + x5 = 123 is the same as counting the number of non-negative solutions to the equation (y1 +1)+(y2 +1)+(y3 +1)+(y4 +1)+(y5 +1) = 123, = i.e. y1 + . . . + y5 = 118. As seen in class, there are 5+118−1 5−1 122 solutions. 4 (b) x1 +. . .+x5 ≤ 123 if and only if for some unique natural number x6 , x1 +. . .+x5 +x6 = 123. Thus the number of natural number solutions to x1 + . . . + x5 ≤ 123 is exactly the number of natural number solutions to x1 + . . . + x6 = 123. As seen in class, there 128 are 6+123−1 = solutions. 6−1 5 (3) Assume the objects are the members of [m], and the boxes the members of [n]. Without restrictions, there are n possible boxes the 1 can be sent to, n possible boxes 2 can be sent to, and so on, so in total there are nm possible choices. This is also the number of functions from [m] to [n]. If we want that each box contains at most one element, then we are counting the number of injections from [m] to [n]. This is zero if m > n (this was shown in assignment 6, and is also a consequence of the pigeonhole principle), so assume m ≤ n. In this case, 1 can be sent to n possible boxes, but once that is done, there are only n − 1 boxes for 2, n − 2 boxes for 3 and so on. Thus n! possibilities. there are n · (n − 1) · . . . (n − m + 1) = (n−m)! (4) Let A be the set of binary n-tuples that begin with 01, B the set of binary n-tuples that end with 1110, and C the set of binary n-tuples that have an even number of 1s. We first compute the size of each set separately. We tacitly use n ≥ 7 in what follows: • n-tuples beginning with 01 are determined by what comes next, and there are 2n−2 possible choices, so |A| = 2n−2 . 6 SOLUTION TO ASSIGNMENT 7 • Similarly, |B| = 2n−4 . • We claim that for n ≥ 1, there are 2n−1 many tuples with an even number of ones. We prove it by induction on n. Note that since there are 2n tuples in total, the number of tuples with an odd number of ones must be 2n − 2n−1 = 2n−1 (2 − 1) = 2n−1 as well. If n = 1, 0 is the only tuple with an even number of ones, and 2n−1 = 20 = 1. Now assume it is true for n. A binary (n + 1)-tuples with an even number of 1 either begins with 1 followed by an n-tuple with an odd number of ones, or begins with 0 followed by an n-tuple with an even number of ones. Thus by the rule of sum the number of binary (n + 1)-tuples with an even number of ones is 2n−1 + 2n−1 = 2n , and similarly for the number of binary (n + 1)-tuples with an odd number of ones. We now compute the size of A0 := A ∪ B. For this, we need to compute the size of A ∩ B. Since n ≥ 6, this is just 2n−6 (a tuple is determined by the remaining n − 6 bits). Therefore, |A0 | = |A| + |B| − |A ∩ B| = 2n−2 + 2n−4 − 2n−6 . Finally, we have to compute A0 ∪ C, and hence need the size of A0 ∩ C = (A ∩ C) ∪ (B ∩ C). There are 2n−2 tuples beginning with 01, and so 2n−3 many with an even number of ones. Similarly, there are 2n−5 tuples with an even number of ones beginning with 1110. Finally, there are 2n−7 tuples with an even number of ones beginning with 10 and ending with 1110 (this uses again n ≥ 7). Thus |A0 ∩C| = |(A∩C)∪(B∩C)| = |A∩C|+|B∩C|−|A∩B∩C| = 2n−3 +2n−5 −2n−7 Putting everything together: |A∪B∪C| = |A0 ∪C| = |A0 |+|C|−|A0 ∩C| = 2n−2 +2n−4 −2n−6 +2n−1 −(2n−3 +2n−5 −2n−7 ) Problem 5 (20 points) (1) We arrange the natural numbers from 1 to 10 on a circle in some arbitrary order. Show that as we go around the circle clockwise, there must be three consecutive numbers whose sum is at least 17. (2) Show that at a party with n ≥ 2 students, there are two students who know the same number of people (we assume knowledge is symmetric). Solution. (1) Say x1 , x2 , . . . , x10 is the clockwise enumeration of the numbers. We P also let x11 := x1 , x12 := x2 . We consider the sum r := 10 i=1 (xi + xi+1 + xi+2 ). Each xi appears exactly three times in this sum, so SOLUTION TO ASSIGNMENT 7 r =3· 10 X i=1 xi = 3 10 X i=1 i= 7 3 · 10 · 11 = 165 2 Where the second equality is simply by rearranging the numbers, and the third equality is by a formula seen in class. Now assume for a contradiction that for any i ≤ 10, xi + xi+1 + xi+2 ≤ 16. Then 165 = r ≤ 10 · 16 = 160, which is absurd. (2) We consider two cases: • If there is a student who knows nobody, then since knowledge is symmetric, any student knows at most n − 2 other students. There are n students and n − 1 possible number of people they can know (0, 1, . . . , n − 2) so by the pigeonhole principle two students know the same number of people. • If every student knows somebody, then again any student knows at least 1 other students, so again there are only n − 1 possible number of people they can know (1, 2, . . . , n − 1). By the pigeonhole principle, the result follows as in the previous case. Extra credit (20 points): Infinity crashes the party Show that in an infinite party with countably many students, there exists a countable set S of students such that either all students in S know each other, or all students in S do not know each other. We make the standard assumption that knowledge is symmetric. Hint: First prove a suitable infinite version of the pigeonhole principle. Then given a student x0 , argue that it either knows countably many other students, or does not know countably many other students. Pick x1 among those students, and continue in this way to build a sequence x0 , x1 , x2 , ... Such that for each i, xi either knows all the students in xi+1 , xi+2 , . . ., or does not know any of them. Conclude by using the (infinite) pigeonhole principle one last time. Solution. This is known as the infinite Ramsey theorem. First we claim that if A is countable, and f : A → {0, 1}, then either f −1 [{0}] is countable, or f −1 [{1}] is countable. Indeed if not, then both are finite, and so A = f −1 [{0}] ∪ f −1 [{1}] is finite (that a union of two finite sets is finite follows from e.g. the rule of sum). Said another way, if we put put countably many objects into two boxes, one box must contain countably many objects. Now we build inductively a sequence of distinct students x0 , x1 , . . . such that for each i, xi either knows all the students in xi+1 , xi+2 , . . . or does not know any of them. To build such a sequence, we first pick any student x0 , and use our version of the pigeonhole principle to deduce that either x0 knows countably many different other students, or it does not know countably many students. In the first case, we set b0 = 1. In the second, we set b0 = 0. If b0 = 1, we let X0 be the set of students x0 knows (countable by assumption). If b0 = 0, we let X0 be the set of students x0 does not know. 8 SOLUTION TO ASSIGNMENT 7 Next, we pick x1 in X0 and use the pigeonhole principle again: either x1 knows countably many students in X0 , or it does not know countably many students in X0 . In the first case, we set b1 = 1, in the second we set b1 = 0, and then set X1 to be the set of students in X0 that x1 knows if b1 = 1, or does not know if b1 = 0. We continue in this way to get a sequence of bits b0 , b1 , b2 , . . . and a nested sequence of countable sets X0 ⊇ X1 ⊇ X2 ⊇ . . .. Now by the pigeonhole principle again, there exists a countable T ⊆ N such that either for any n ∈ T , bn = 0, or for any n ∈ T , bn = 1. Let b be the value of bn for n ∈ T . The set of all xn with n ∈ T is the desired set of students: For example, if b = 1, we have that by definition, for n ∈ T , bn = b = 1, so bn knows all the students in Xn , and hence knows xm for m ∈ T and m ≥ n. Since this works for any n ∈ T and knowledge is symmetric, we have that for any n and m in T , xn knows xm . Similarly, if b = 0, none of the xn with n ∈ T know each other. CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 8 Problem 1 (20 points) Prove Theorem 10.11 in the lecture notes: For any integers m, n, and k: (1) gcd(n, m) = gcd(m, n). (2) gcd(n, m) = gcd(±n, ±m) (i.e. equality holds regardless of the choice of sign). (3) gcd(n, m) = gcd(n, m + kn). (4) gcd(n, m) = 1 if and only if n and m are coprime. (5) gcd(n, m) = 0 if and only if n = m = 0. (6) If n divides m, gcd(n, m) = |n|. In particular, gcd(n, 0) = |n|. (7) If n = ka, m = kb, and a and b are coprime, then gcd(n, m) = |k|. Solution. We will use freely the basic results on dividing discussed so far (Theorem 7.14 and Theorem 10.1). (1) The definition of the gcd does not depend on the order of m and n. (2) Because an integer r divides n if and only if r divides ±n using the definition of dividing), and similarly for m. (3) This is true if n = 0, as in this case m + kn = m, so assume n 6= 0. Assume r is an integer dividing both n and m. Then r divides kn, so r divides m + kn. Conversely, if r divides both n and m + kn, then r divides kn, so r divides m = (m + kn) − kn. We have shown that the common divisors of n and m are the same as the common divisors of n and m + kn. Thus their gcd must be equal. (4) Assume gcd(n, m) = 1. If there were a prime p dividing both n and m, then p ≥ 2, so gcd(n, m) ≥ 2, contradiction. Conversely, if n and m are coprime and k is a common divisor, then any prime dividing k must also be a divisor, so no prime can divide k, i.e. k is ±1. We cannot have n = m = 0, so as 1 is a common divisor of both n and m, gcd(n, m) = 1. (5) If n = m = 0, the gcd is defined to be zero. If gcd(n, m) = 0, then since 1 divides anything, we must be in the special case where n = m = 0 and the gcd is just defined to be zero. (6) Assume n divides m. If m = 0, then n = 0 and the result holds. If m 6= 0, then since divisibility is insensible to change of signs and 0 divides only zero, we can assume that m and n are positive. Observe that n is a common divisor of both n and m. To show it is the largest one, we take an arbitrary integer r and assume r divides both n and m. Then as n 6= 0, Theorem 7.14.8 implies that r ≤ n. Since r was arbitrary, this means that n is indeed the maximal common divisor. (7) If k = 0, then n = m = 0 and the gcd is 0, as desired. Now assume k 6= 0. Changing the signs if necessary, we can assume k > 0. Since a and b are coprime, at least one of them must be nonzero so the gcd cannot be zero. Observe first that k divides both ka and kb, so k is a common divisor. To see it is the largest one, let r be an arbitrary common divisor of ka and kb. We claim that r divides k. To see this, either reason using the uniqueness of prime factorization (several cases depending on whether r is negative, |r| ≤ 1, etc.), or use Bézout’s lemma: since a and b are coprime, there exists integers m and n such that ma + nb = 1. Multiplying this Date: June 23, 2014. 1 2 SOLUTION 8 equation by k, we get that mak + nbk = k. By assumption, r divides both terms, so r must divide the sum: k. Now by Theorem 7.14.8, |r| ≤ |k| = k. Since r was arbitrary, this shows k is the largest common divisor, as needed. Another argument: Let r := gcd(n, m). By problem 2 (which was proven without relying on this part), there exists integers a0 and b0 such that a0 ka + b0 kb = r. This shows that k divides r. Fix an integer c such that kc = r. Now, if k = 0, then n = m = 0 so r = k = 0, so assume k 6= 0. This implies that r 6= 0. Since r divides n = ka, kc divides ka. Fix c0 such that kcc0 = ka. Then cc0 = a, so c divides a. Similarly, c divides b. Since a and b are coprime, gcd(a, b) = 1, and hence |c| ≤ 1. Since r is nonzero, |c| = 1, so r = kc = |k|. Problem 2 (20 points) Prove Theorem 10.15 in the lecture notes: For integers m, n, and k, the following are equivalent (i.e. (A) holds if and only if (B) holds): • (A) gcd(n, m) divides k. • (B) There exists integers a and b such that k = am + bn. Solution. We first prove that if k = gcd(n, m), then there exists integers a and b such that k = am + bn. This is true if k = 0 (take a = b = 0), so assume k > 0. Consider m0 := m k and n0 := nk . These are integers since k is a common divisor of m and n. Moreover, gcd(m0 , n0 ) = 1: since one of n or m is nonzero, one of m0 , n0 is nonzero, so the gcd must be nonzero and if a natural number r divides both m0 and n0 , then kr divides m = km0 and n = kn0 , so by definition of the gcd we must have r ≤ 1. By the previous problem, m0 and n0 are coprime and so by Bézout’s lemma, there exists integers a0 and b0 so that a0 m0 + b0 n0 = 1. Multiplying this equation by k, we get the result. Now let’s solve the actual problem. Assume first that (A) holds. Fix an integer c such that c · gcd(n, m) = k. By the previous paragraphs, there exists integers a0 and b0 such that a0 m + b0 n = gcd(n, m). Multiply this equation by c to get (B). Conversely, assume (B). Let r := gcd(n, m). Then r divides m and r divides n, so r divides am + bn = k. Problem 3 (20 points) Assume p is a prime number. (1) Show that p divides kp for all natural numbers k with 1 ≤ k ≤ p − 1. (2) Show that for any natural number n, p divides np − n. Hint: induction. Solution. p! . Observe that p does not divide (p−k)!k!: if (1) Let c := kp . We have that c = (p−k)!k! it does, then by Euclid’s lemma it must divide one of the factors, i.e. p divides i for some positive natural number i < p which is impossible (we are using 1 ≤ k ≤ p − 1 here). Now, p certainly divides p(p − 1)! = p! = c(p − k)!k!, so by Euclid’s lemma p divides either c or (p − k)!k!. We have already seen it does not divide the latter so it must divide the former. (2) By induction on n. If n = 0, this is true because any number divides 0p − 0 = 0. Now assume it is true for n. By the binomial theorem: SOLUTION 8 3 p X p k n (n + 1) − (n + 1) = −n − 1 + k p k=0 p−1 X p k n = −n + 1 − 1 + n + k k=1 p−1 X p nk = np − n + k p k=1 Where the second equality holds simply by taking out the k = 0 and k = n terms out of the sum. Now by the induction hypothesis,Pp divides np − n. By the previous part, p also p−1 p k p divides k for 1 ≤ k ≤ p − 1, so p divides k=1 k n , and therefore the entire expression above. Problem 4 (20 points) Use the Euclidean algorithm to find gcd(123, 321), as well as two integers a and b such that 123a + 321b = gcd(123, 321). Show all your work. Solution. g := gcd(123, 321) = 3 and the coefficients are a = 47, b = −18. We give the details: We have that 321 = 2 · 123 + 75, so g = gcd(123, 75). We have that 123 = 1 · 75 + 48 so g = gcd(75, 48). We have that 75 = 1 · 48 + 27 so g = gcd(48, 27). We have that 48 = 1 · 27 + 21 so g = gcd(27, 21). We have that 27 = 1 · 21 + 6 so g = gcd(21, 6). We have 21 = 6 · 3 + 3 so g = gcd(6, 3). Finally, 6 = 2 · 3 + 0 so g = gcd(3, 0) = 3. To get the coefficients a and b, we backtrack our steps. As in the notes, we use boldface to write the numbers that were plugged into the gcd function. From the step before last above, we have that 3 = 21 − 3 · 6 Thus 3 = 21 − 3 · (27 − 21) = 4 · 21 − 3 · 27 Continuing in this way: 3 = 4 · (48 − 27) − 3 · 27 = 4 · 48 − 7 · 27 3 = 4 · 48 − 7 · (75 − 48) = 11 · 48 − 7 · 75 3 = 11 · (123 − 75) − 7 · 75 = 11 · 123 − 18 · 75 3 = 11 · 123 − 18 · (321 − 2 · 123) = 47 · 123 − 18 · 321 So a = 47, b = −18. Problem 5 (20 points) Assume n is a natural number. Show that there exists a natural number m such that none of m, m + 1, . . . , m + n are prime. Hint: Find m such that m is a multiple of 2, m + 1 is a multiple of 3, m + 2 a multiple of 4, etc. 4 SOLUTION 8 Solution. Take m := (n + 2)! + 2. We have that m is a multiple of 2: 2 divides (n + 2)! = 2 · 3 · . . . (n + 2) and 2 divides 2, so 2 divides m = (n + 2)! + 2. In fact, for any natural number k ≤ n, k + 2 divides m + k: indeed, k + 2 divides (n + 2)! (as k ≤ n), and k + 2 also divides k + 2, so k + 2 divides m + k = (n + 2)! + k + 2. We also have that 1 < k + 2 < m + k: the first inequality is clear and the second is because 2 < m ((n + 2)! + 2 ≥ 2! + 2 = 4). Therefore m + k is not prime for any natural number k ≤ n. Extra credit (20 points): Perfect numbers We start with a couple of definitions and fun facts. A natural number n is called perfect if it is equal to the sum of its proper (i.e. not equal to n) natural number divisors. For example, 6 is perfect: the natural number divisors of 6 are 1, 2, and 3, and 6 = 1 + 2 + 3. 28 = 1+2+4+7+14 is also perfect (it is unknown whether there are infinitely many perfect numbers, or whether there are any odd perfect numbers at all). A Mersenne prime is a prime of the form 2n −1 for n a natural number. For example, 3 = 22 −1 and 7 = 23 −1 are Mersenne primes (It is also unknown whether there are infinitely many Mersenne prime. The largest known Mersenne prime is 257885161 − 1, found by a distributed effort over the internet). Show that if 2n − 1 is a Mersenne prime, then 2n−1 (2n − 1) is perfect. Solution. Let p := 2n − 1. Note that we must have n ≥ 2. The proper divisors of 2n−1 p are of the form 2k for k ≤ n − 1 a natural number, and 2k p for k ≤ n − 2 a natural number. Thus their sum is: n−1 X k=0 2k + n−2 X 2k p = 2n − 1 + p(2n−1 − 1) k=0 = 2n − 1 + (2n − 1)(2n−1 − 1) = (2n − 1)(1 + 2n−1 − 1) = 2n−1 (2n − 1) Where the first equality used the formula for geometric series derived in a previous Pn 1−rn+1 k for r 6= 1. This shows 2n−1 (2n − 1) is perfect. assignment: k=0 r = 1−r CONCEPTS OF MATHEMATICS, SUMMER 1 2014 SOLUTION TO ASSIGNMENT 9 Problem 1 (20 points) Assume a, b, and n are integers. In this exercise, you will study the integer solutions of the equation ax ≡ b mod n. (1) Show that the equation has an integer solution if and only if gcd(a, n) divides b. (2) Show further that the integer solution is unique modulo n if and only if a and n are coprime. Hint: first show that a has an inverse modulo n if and only if a and n are coprime. Solution. (1) ax ≡ b mod n is the same as saying that there exists an integer k such that ax+nk = b. Thus we need to figure out when there exists integers x and k so that ax+nk = b. By problem 2 of assignment 8, this is equivalent to saying that gcd(a, n) divides b. Thus the equation has a solution if and only if gcd(a, n) divides b. (2) We have seen in class that if a and n are coprime, then a has an inverse. Conversely, assume a has an inverse and assume for a contradiction a and n share a common prime factor p. Let n0 := np . Then an0 ≡ 0 mod n, so if a had an inverse, we would have n0 ≡ 0 mod n, which is not true if n 6= 0. If n = 0, recall that congruence modulo 0 is just equality so in order for a to have an inverse, we must have |a| = 1, i.e. a and 0 are coprime. Now assume a has an inverse. If x and x0 are integer solutions, then ax ≡ ax0 mod n. Multiplying the equation by this inverse gets us x ≡ x0 mod n. Conversely, assume that a does not have an inverse, i.e. a and n are not coprime. We exhibit distinct solutions modulo n. Let g := gcd(a, n). If a = n = 0, any integer x is a solution and so it is clearly not unique. Now assume g > 1. If g = n, then n divides a so a ≡ 0 mod n, so 0 and 1 are distinct solutions modulo n. Otherwise, 1 < g < n. Let m := ng . Then 1 < m < n and am ≡ 0 mod n. Thus if x is a solution, x + m also is: a(x + m) ≡ ax + am ≡ ax mod n, and x and x + m are distinct modulo n. Problem 2 (20 points) (1) Soldiers in an army are ordered to line up in rows of 5. Once this is done, three soldiers remain. Next, the soldiers are ordered to line up in rows of 7. Three soldiers remain once again. Finally, the soldiers are ordered to line up in rows of 11 and four soldiers remain. Given that the army has less than 500 soldiers, compute its size. (2) Alice sends Bob the cyphertext c = 36. Assume c was encrypted using (the toy version of) the RSA cryptosystem seen in class. Bob’s public key is n = 51 and e = 3. (a) Demonstrate that this public key is too small by finding the corresponding private key. (b) Find the secret number m that Alice encrypted as c. Date: June 25, 2014. 1 2 SOLUTION 9 Show all your work! Solution. (1) We use the proof of the Chinese remainder theorem to solve the system of congruence equations x ≡ 3 mod 5, x ≡ 3 mod 7, x ≡ 4 mod 11. Using the notation from the proof in the notes, we have that m0 = 3, n0 = 5, m1 = 3, n1 = 7, m2 = 4, n2 := 11. We first compute a0 := 7 · 11 = 77, a1 := 5 · 11 = 55, a2 := 5 · 7 = 35. We also let a := 5 · 7 · 11 = 385. Next, we find an inverse ci of ai modulo ni for each i. We first want to find an inverse of 77 ≡ 2 mod 5. We could of course use the Euclidean algorithm but by inspection c0 = 3 works. Next, we find an inverse of 55 ≡ −1 mod 7, so c1 = −1 is an inverse. Finally, 35 ≡ 2 mod 11, and c2 = 6 is an inverse. We now let bi := ai ci . So b0 = 77 · 3 = 231, b1 = 55 · −1 = −55, b2 = 35 · 6 = 210. Take x := m0 b0 + m1 b1 + m2 b2 = 3 · 231 + 3 · (−55) + 4 · 210 ≡ 213 mod 385. Since the army has less than 500 soldiers, it cannot have 213 + 385 or more soldiers, so the number of soldiers must be 213. (2) (a) By bruteforce, we find that n = 3 · 17. Thus Bob’s private key is p = 3, q = 17, n0 = (p − 1)(q − 1) = 32. (b) We first compute an inverse d of e modulo n0 . For this, we find a and b such that ae + bn0 = 1. We could use the Euclidean algorithm for this but here we see by inspection that b = 2, a = −21 will work. Thus d ≡ −21 ≡ 11 mod 32. We then compute cd = 3611 modulo n using repeated squaring. 362 ≡ (−15)2 ≡ 225 ≡ 21 mod 51 364 ≡ (21)2 ≡ 441 ≡ 33 ≡ (−18) mod 51 368 ≡ (−18)2 ≡ 324 ≡ 18 mod 51 363 ≡ (−15)3 ≡ 21 · (−15) ≡ −315 ≡ −9 mod 51 3611 ≡ 18 · (−9) ≡ −162 ≡ −9 ≡ 42 mod 51 Since we always assume 2 ≤ m < n, the secret number is m = 42. Problem 3 (20 points) (1) Prove that the number: 1111111111222222222233333333334444444444555555555566666666667777777777 888888888899999999995071 is divisible by 11 (the number consists of ten consecutive 1s, followed by ten consecutive 2s, ..., followed by ten consecutive 9s, followed by 5071). (2) Show that in any month (including February, even in leap years), exactly one Tuesday must fall on a day that is a multiple of four (for example, this assignment is due on Tuesday June 24 = 6 · 4 and the other Tuesdays fall on the 3, 10, or 17 which are not divisible by 4). SOLUTION 9 3 Solution. (1) We first demonstrate a way to deduce from representation of a number Pmthe decimal i . Then since 10 ≡ −1 mod 11, a 10 whether it is divisible by 11. Say n = i=0 i Pm i n ≡ i=0 ai (−1) mod 11. In other words, n is divisible by 11 if and only if a0 − a1 + a2 − . . . + (−1)m am is divisible by 11. This is the case here: 1 − 7 + 0 − 5 = −11 ≡ 0 mod 11, and the other digits cancel each other out. (2) Number the days of the week as follows: Monday is 0, Tuesday is 1, Wednesday is 2, and so on: Sunday is 6. Assume the first day of the month falls on day of the week k. Then the nth day of the month will fall on a day of the week that is congruent to k + n − 1 modulo 7. We are looking for a day x that satisfies the congruence equations x ≡ 0 mod 4 and k + x − 1 ≡ 1 mod 7, i.e. x ≡ 2 − k mod 7. Since 4 and 7 are coprime, the Chinese remainder theorem guarantees a unique solution to this system of equations modulo 7·4 = 28. Pick such a solution x. Now, if x ≡ 0 mod 28, there is no zeroth day of the month, but we also have x ≡ 28 mod 28, so the 28th day of the month will be the desired Tuesday. If x 6≡ 0 mod 28, then we can just take the solution 1 ≤ y < 28 so that x ≡ y mod 28, and the yth day of the month will be as desired. This is the only day of the month with that property: clearly, y ≥ 4 so y + 28 ≥ 32 and there are no months with 32 days or more. Since the Chinese remainder theorem guarantees uniqueness of y modulo 28, we are done. Problem 4 (20 points) Assume p is a prime, and let m be a natural number not divisible by p. For k an integer, write r(k, p) for the remainder of the division of k by p. Using only Euclid’s lemma (and without using the result seen in class on existence of inverse modulo p), prove that the function f : {0, 1, . . . , p − 1} → {0, 1, . . . , p − 1} given by f (x) = r(mx, p) is a bijection. Use this to give another proof that m has an inverse modulo p. Hint: First explain why it is enough to show f is an injection. Solution. It is enough to see f is an injection. Then by a previous assignment f must be equipotent to its range, so the range of f must have size p. Since the range is a subset of the codomain, and the codomain also has size p, a previous assignment tells us the range must be the whole of the codomain, i.e. f is also a surjection. So assume f (x) = f (y). Then mx ≡ my mod p, and we want to conlude that x ≡ y mod p. By definition, p divides mx − my = m(x − y), so by Euclid’s lemma must divide one of the factors. Since m is not divisible by p, p divides x − y. Assume without loss of generality that y ≤ x. Since 0 ≤ x, y < p, we must have that 0 ≤ y − x < p, and so the only possibility is that y − x = 0. Since f is a bijection, it is a surjection, so there must exist x ∈ {0, . . . , p − 1} such that f (x) = 1 i.e. mx ≡ 1 mod p. Problem 5 (20 points): Wilson’s theorem (1) Assume that p is a prime. Show that if a is its own inverse modulo p, then either a ≡ 1 mod p, or a ≡ −1 mod p. (2) Assume p is a natural number and p ≥ 2. Show that p is prime if and only if (p − 1)! ≡ −1 mod p. Hint: To go from left to right, use that each factor in (p − 1)! must have an inverse which is also a factor in (p − 1)!. Solution. (1) If a is its own inverse modulo p, then a2 ≡ 1 mod p, so a2 − 1 ≡ 0 mod p, so (a − 1)(a + 1) ≡ 0 mod p. If a 6≡ 1 mod p, then a − 1 6≡ 0 mod p, so we can multiply by the inverse of a − 1 to get a + 1 ≡ 0 mod p, i.e. a ≡ −1 mod p. 4 SOLUTION 9 (2) First assume p is not prime. Then there exists 1 < m ≤ n < p such that mn = p. Thus m divides (p − 1)! and so (p − 1)!n ≡ 0 mod p. Thus if we had (p − 1)! ≡ (−1) mod p, then we would get (p − 1)!n ≡ (−n) 6≡ 0 mod p, a contradiction. Now assume p is prime. By the previous part, each i with 1 < i < p − 1 cannot be its own inverse modulo p. Thus for each such i, there exists ai different from i with 1 < ai < p − 1 and iai ≡ 1 mod p. Moreover, by uniqueness of inverses modulo p, ai 6≡ aj mod p for i 6= j. Thus by successively canceling out1 pairs (i, ai ) from the product 2 · 3 · . . . · (p − 2), we get that 2 · 3 · . . . · (p − 2) ≡ 1 mod p, and so: (p − 1)! ≡ 1 · (p − 1) · 2 · 3 · . . . · (p − 2) mod p ≡ −1 mod p Extra credit (20 points): Euler’s totient function For n a natural number, define: Φn := {m ∈ [n] | m and n are coprime} Euler’s totient function ϕ : N → N is defined by ϕ(n) := |Φn |. For example, ϕ(6) = 2, as Φ6 = {1, 5}: 1 and 5 are the only numbers in [6] coprime to 6. A larger example is ϕ(28) = 12: you should convince yourself that 1, 3, 5, 9, 11, 13, 15, 17, 19, 23, 25, and 27 are all the numbers in [28] that are coprime to 28. (1) Show that for a prime p, ϕ(p) = p − 1. (2) Show more generally that for a prime p and a natural number k ≥ 1, ϕ(pk ) = pk−1 (p − 1). (3) Show that for coprime natural numbers m and n, ϕ(mn) = ϕ(m)ϕ(n). Hint: Use the Chinese remainder theorem to see that there is a bijection between Φmn and Φm × Φn . (4) For a natural number n ≥ 2, give a formula for ϕ(n) in terms of the prime factorization of n. (5) Assume you have found a very efficient method to compute ϕ(n). Explain how you can break the RSA cryptosystem. Solution. (1) All the natural numbers between 1 and p − 1 are coprime to p by definition of a prime number. (2) The only natural numbers below pk that are not coprime to pk are of the form ap for some 1 ≤ a ≤ pk−1 . There are pk−1 such as, so ϕ(pk ) = pk − pk−1 = pk−1 (p − 1). (3) Since ϕ(0) = 0, the result is true if one of m or n is 0, and since ϕ(1) = 1, the result is true if one of them is 1, so assume m, n ≥ 2. By the Chinese remainder theorem, every 1 ≤ x ≤ mn can be uniquely decomposed into x1 and x2 where 1 ≤ x1 ≤ m, 1 ≤ x2 ≤ n and x ≡ x1 mod m, x ≡ x2 mod n. Conversely, any such equation has a unique solution in [mn]. Now since m and n are coprime, x and mn are coprime if and only if both x1 and m and x2 and n are coprime. To see this, assume first that x and mn are coprime. If x1 and m share a prime factor, then since x = x1 + km, x and m also share a prime factor and so x and mn are not coprime. Similarly, x2 and m cannot share a prime factor. Conversely, if x1 and m are coprime, then by the argument above x 1This could be made precise using induction. SOLUTION 9 5 and m must be coprime. Similarly, if x2 and n are coprime, then x and n must be coprime. Since m and n are coprime, we must have that x and mn are coprime. This tells us that there is a bijection between the numbers in [mn] that are coprime to mn and the pairs (x1 , x2 ) of numbers in [m] × [n] so that x1 is coprime to m and x2 is coprime to n. By the rule of product, ϕ(mn) = ϕ(m)ϕ(n). (4) Assume n = pk00 pk11 . . . pkr r , where the ki s are positive natural numbers, and the pi s are distinct primes. Then by the previous parts, ϕ(n) = pk00 −1 (p0 − 1)pk11 −1 (p1 − 1) . . . pkr r −1 (pr − 1) (5) All we need to break the RSA cryptosystem is a fast way to compute the modular inverse d of e modulo n0 = (p − 1)(q − 1) (where p, q are distinct primes and the public key is given by n = pq and e). Now, by the previous part, n0 = ϕ(n), so if we could compute n0 quickly from only n, then we could compute d very quickly using the Euclidean algorithm and decrypt any message sent to the public key.