Mathematics for Computer Science Exercises from Week 4 Silvio Capobianco Last update: 26 September 2018 Problems from Section 4.1 Problem 4.3. Set Formulas and Propositional Formulas. (a) Verify that the propositional formula (P and Q) or (P and Q) is equivalent to P. (b) Prove that for all sets A, B, by showing A = (A B) (A B) x A iff x (A B) (A B) for all elements x using the equivalence of part (a) in a chain of iff s. Solution. (a) By using distributivity: (P and Q) or (P and Q) iff P and (Q or Q) iff (b) Let P ::= x A and Q ::= x B: then, iff P. P and T x A iff (x A and not(x B)) or (x A and x B) iff (x A B) or (x A B) iff x (A B) (A B). 1
Problem 4.4. Prove Theorem (Distributivity of union over intersection). A (B C) = (A B) (A C) (1) for all sets A, B, C, by using a chain of iff s to show that x A (B C) iff x (A B) (A C) for all elements x. You may assume the corresponding propositional equivalence 3.10. Solution. Let P ::= x A, Q ::= x B, and R ::= x C: we plan to use the distributive law for disjunction P or (Q and R) iff (P or Q) and (P or R), expressed by 3.10 in the textbook. So: x A (B C) iff x A or (x B and x C) where the second iff exploits 3.10. iff (x A or x B) and (x A or x C) iff (x A B) and (x A C) iff x (A B) (A C), Problem 4.6(a) Let A and B be sets. Prove that pow(a B) = pow(a) pow(b). Solution. Let S be a set. We must prove: S A B iff S A and S B (2) Suppose the left-hand side of (2) holds. Let x be an arbitrary element: then, x S implies x A B implies x A 2
because A B A; similarly, x S implies x B. We have thus proved that, if S A B, then S A and S B: that is, pow(a B) pow(a) pow(b). Suppose now that the right-hand side of (2) holds. Recall that such intersection is never empty, because the empty set is a subset of every set, thus an element of every power set. Let S A and S B: if S is empty, then S A B for sure; if S is not empty, then every element of S belongs to both A and B, thus to A B, and this shows S A B. We have thus proved that, if S A and S B, then S A B: that is, pow(a) pow(b) pow(a B). Double inclusion means equality. Problem 4.7 Subset take-away 1 is a two player game played with a finite set A of numbers. Players alternately choose nonempty subsets of A with the conditions that a player may not choose the whole set A, or any set containing a set that was named earlier. The first player who is unable to move loses the game. For example, if the size of A is one, then there are no legal moves and the second player wins. If A has exactly two elements, then the only legal moves are the two one-element subsets of A. Each is a good reply to the other, and so once again the second player wins. The first interesting case is when A has three elements. This time, if the first player picks a subset with one element, the second player picks the subset with the other two elements. If the first player picks a subset with two elements, the second player picks the subset whose sole member is the third element. In both cases, these moves lead to a situation that is the same as the start of a game on a set with two elements, and thus leads to a win for the second player. Verify that when A has four elements, the second player still has a winning strategy. 2 1 From Christensen & Tilford, David Gale s Subset Takeaway Game, American Mathematical Monthly, Oct. 1997 2 David Gale worked out some of the properties of this game and conjectured that the second player wins the game for any set A. This has been disproved in 2017 by Brouwer & Christensen. See arxiv:1702.03018 3
Solution. The first player can only take one, two, or three elements of A. Let us proceed by cases: 1. If the first player takes a one-element set, call that element a, and call b, c, and d the three remaining. If the second player takes {b}, she reduces the initial game to a game on the set {c, d}, which she wins. Alternatively, she can take {b, c, d}, and reduce the initial game to a game on that set, which she also wins. 2. If the first player takes a three-element set, call those elements a, b, and c, and call d the remaining element. If the second player takes {d}, she reduces the initial game to a game on the set {a, b, c}, which she wins. 3. The third and last case is the most interesting. If the first player takes a two-elements set, call those elements a and b, and call c and d the two remaining elements. The moves {a, b, c} and {a, b, d} are not legal anymore, but the moves {a, c, d} and {b, c, d} are. If the second player takes {c, d}, then {a, c, d} and {b, c, d} also become illegal, and every new move must be either a subset of {a, b}, or a subset of {c, d}, or another set with two elements. In the first two cases, the game will turn into two games, each on a two-element set, which the second player can win in sequence; as soon as one of the games is won, the four two-elements subsets which have not been chosen become illegal moves. In the third case, the second player can still act by complementation (e.g., if the first player chooses {a, d}, then the second player chooses {b, c}) because a set with four elements has six two-elements subset. After either two, four, or six two-elements subsets have been chosen, the game will turn into two two-objects games as before. Problems for Section 4.2 Problem 4.13. Prove that for any sets A, B, C and D, if the Cartesian products A B and C D are disjoint, then either A and C are disjoint or B and D are disjoint. 4
Solution. Recall that two sets are disjoint if they have no common elements. Let s prove the contrapositive: if A and C are not disjoint and B and D are not disjoint, then A B and C D are not disjoint. And this is easy to see: if x A C and y B D, then (x, y) (A B) (C D). Problem 4.14(a). Give a simple example where the following result fails, and briefly explain why: False Theorem. For sets A, B, C and D, let Then L = R. L ::= (A B) (C D), R ::= (A C) (B D). Solution. Suppose A = {1}, B = {2}, C = {3}, D = {4}: then (2, 3) is an element of L, but not of R. More nastily: if B and C are empty, but A and D are not, then L is not empty and R is. There is no such thing as a pair without a second element, or without a first element. The problem here is that the choices for the left and right component are independent in L, but not in R. In L, if we have chosen the first component from A, then we still have the option of choosing the second component from either C or D: but in R, we are forced to choose it from C. Problems for Section 4.4 We open this section with some definitions. If A is a set, then the identity relation Id A is the relation from A to A with graph {(a, a) a A}: that is, a is in relation Id A with b if and only if a = b. If R : A B and S : B C are relations, the composition of S with R (in this order) is the relation S R : A C defined by: a(s R)c iff b B. (arb and bsc). (3) 5
Problem 4.15. The inverse R 1 of a binary relation R from A to B is the relation from B to A defined by: br 1 A iff arb In other words, you get the diagram for R 1 from R by reversing the arrows in the diagram describing R. Now many of the relational properties of R correspond to different properties of R 1. For example, R is iff R 1 is. Fill in the remaining entries in this table: R is iff R 1 is Hint: Explain what s going on in terms of arrows from A to B in the diagram for R. Solution. We preliminarily observe that (R 1 ) 1 = R, as: Then we can immediately fill: a (R 1 ) 1 b iff b R 1 a iff a R b R is iff R 1 is To fill the rest of the table, we observe that the relation diagram of R 1 is obtained from that of R by first reflecting it along a vertical line which cuts the arrows in half, then reversing the direction of each arrow. This leads to the following important observation: R has the n in property if and only if R 1 has the n out property 6
where is either,, or =. As the inverse of the inverse relation is the original relation, the observation above also holds with the roles of R and R 1 swapped. We can now go on: R is iff R has the 1 out property iff R 1 has the 1 in property iff R 1 is To conclude, we recall that is a function which is both injective and surjective: in this case, R 1 is a surjective and injective relation which is both and, so it is also. And vice versa. The final table is thus: Problem 4.20. R is iff R 1 is Give an example of a relation R that is a injective function from a set A to itself but is not. Solution. Let A = N and xry iff y = x + 1: 1. R is. However given x, we always have x R (x + 1). 2. R is injective. If x + 1 = y + 1, then x = y. 3. R is. If xry and xrz, then y = x + 1 = z. 4. R is not, because it is not surjective. There is no natural number x such that x + 1 = 0. 7