Homework 4 Solutions ECS 20 (Fall 14) Patrice Koehl koehl@cs.ucdavis.edu November 1, 2017 Exercise 1 Let n be an integer. Give a direct proof, an indirect proof, and a proof by contradiction of the statement if n is odd, then n + 7 is even. Let n be an integer. Let p be the proposition: n is odd, and q be the proposition n + 7 is even. Direct proof: We show directly p q. Hypothesis: p is true, i.e. n is odd. As n is odd, there exists an integer k such that n = 2k + 1, Then, n + 7 = 2k + 8 = 2(k + 4). As k + 4 is an integer, n + 7 is even, i.e. q is true. We conclude that p q. Indirect proof: We show that q p. Hypothesis: q is true, i.e. n+7 is odd. Then there exists an integer k such that n+7 = 2k+1. Then n = 2k 6 = 2(k 3), i.e. n is even since k 3 is an integer. p is true. We have shown that q p; by contrapositive, we conclude p q. Contradiction: Hypothesis: We suppose that the proposition p q is false, i.e. that p is true and q is false. Since p is true, n is odd, therefore there exists an integer k such that n = 2k + 1, Then, n + 7 = 2k + 8 = 2(k + 4). Since k + 4 is an integer, n + 7 is even; but the hypothesis states n + 7 is odd: we reach a contradiction. The hypothesis is wrong, therefore the statement p q is true. Exercise 2 Let A = {1, 2} and B = {2, 3}. Define P(A B), P(A), and P(A B), where P(C) indicates the power set of the set C. Since A = {1, 2} and B = {2, 3}, we have: a) A B = {2} b) A B = {1, 2, 3} Therefore, 1
a) P(A) = {, {1}, {2}, {1, 2}} b) P(A B) = {, {2}} c) P(A B) = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} Exercise 3 Let A, and B be two sets in a universe U. Using set identities (no truth table or membership table!), show the following implications: There are at least two methods to show set identities. I will use both, namely a direct proof based on set theory identity and a proof based on logic, using a membership table. a) (A B) (A B) = (A B) (B A) Let us define LHS = (A B) (A B) and = (A B) (B A). LHS = (A B) (A B) (A B) ( A B ) ( De Morgan s law ) ( ) ( (A B) A (A B) B) distributivity ) ( ) ( (A A) (B A) (A B) (B B) distributivity ) ( ) ( (B A) (A B) absorption law ) ( ) B A A B absorption law (B A) (A B) Property of minus (A B) (B A) Symmetry Method 2: Membership table A B A B A B A B LHS (A B) (B A) 1 1 1 1 0 0 0 0 0 1 0 1 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 Since column 6 and 9 are equal, the two sets are equal b) (A B) (C B) = (A C) B Let LHS = (A B) (C B) and = (A C) B. LHS = (A B) (C B) ( A B ) ( C B ) property of minus (A C) B distributivity (A C) B Property of minus 2
Method 2: Membership table A B C A B C B LHS (A C) B 1 1 1 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 Since column 6 and 9 are equal, the two sets are equal c) (A B) (A C) = (A C) B Let LHS = (A B) (A C) and = (A C) B. LHS = (A B) (A C) ( ) ( ) ( A B A C property of minus ) ( A B (A C) demorgan s law ) ( ) A B A A B C distributivity ( A C B ) Absorption law (A C) B property of minus Method 2: Membership table A B C A B A C LHS (A C) B 1 1 1 0 0 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Since column 6 and 9 are equal, the two sets are equal 3
d) (A B) C = (A C) (B C) Let LHS = (A B) C and = (A C) (B C). = (A C) (B C) ( ) ( ) ( A C B C property of minus ) ( A C (B C) demorgan s law ) ( ) ( A C B A C C distributivity ) A B C Absorption law (A B) C property of minus LHS Method 2: Membership table A B C A B LHS A C B C 1 1 1 0 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Exercise 4 Since column 5 and 8 are equal, the two sets are equal Let A, and B be two sets in a universe U. Using set identities (no truth table or membership table!), show the following implications: a) if A B = A, then B ( B A ) = A We use a direct proof. Let p be the proposition A B = A and let q be the proposition B ( B A ) = A. Our hypothesis is that p is true. Then: B ( B A ) = B (B A) De Morgan s law (B B) (B A) Distributivity (A B) Absorption law A Absorption law and hypothesis Therefore q is true. According to the method of direct proof, p q is true. 4
b) if A B = B, then A B = A We use a direct proof. Let p be the proposition A B = B and let q be the proposition A B = A. Our hypothesis is that p is true. Then: A B = A (A B) Hypothesis: B = A B (A A) (A B) Distributivity A (A B) Absorption law A A B A Therefore q is true. According to the method of direct proof, p q is true. Exercise 5 Let A, and B be two sets in a universe U. The symmetric difference of A and B, denoted A B, is the set containing those elements in either A or B, but not in both A and B. This definition can be rewritten as: A B = (A B) (A B). Show that: a) (A B) B = A I use a membership table: Since column 1 and column 4 are equal, (A B) B = A. A B A B (A B) B 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 b) A B = (A B) (B A) Again, I use a membership table: A B A B B A (A B) (B A) A B 1 1 0 0 0 0 1 0 1 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 Since column 5 and 6 are equal, A B = (A B) (B A). 5
Exercise 6 Let A, and B be two sets in a universe U. Show that A B = U A B + A B. Let us define C = A B. A complement law tells us that C C = U where U is the domain. Also, C C =. Using the inclusion-exclusion principle, we find: U = C + C We know that C = A B = A + B A B, and, based on DeMorgan s law, C = A B. Replacing in the equation above, after rearrangement, we obtain: Exercise 7 A B = U A B + A B a) Let A, B, and C be three sets in a universe U. Show that A B C = A + B + C A B A C B C + A B C. From the inclusion-exclusion principle, we know that: A B = A + B A B Let us consider the three sets A, B and C. We observe that: Then: A B C = (A B) C A B C = A B + C (A B) C = A + B + C A B (A B) C = A + B + C A B (A C) (B C) = A + B + C A B ( A C + B C (A C) (B C) ) = A + B + C A B A C B C + (A C) (B C) = A + B + C A B A C B C + A B C b) In a fruit feast among 200 students, 88 chose to eat durians, 73 ate mangoes, and 46 ate litchis. 34 of them had eaten both durians and mangoes, 16 had eaten durians and litchis, and 12 had eaten mangoes and litchis, while 5 had eaten all 3 fruits. How many of the 200 students ate none of the 3 fruits, and how many ate only mangoes? Let U be the domain, namely the set of all students. U = 200. Let D be the set of students that eat durians; D = 88. Let M be the set of students that ate mangoes, M = 73. Let L be the set of students that ate litchis, L = 46. We are also told that D M = 34, D L = 16, M L = 12, and D M L = 5. Let C the set of students that eat at least one (type) of fruits: C = D M L. Based on part b), we find C = 150. Therefore C = 200 150 = 50: there are 50 students that ate none of the 3 fruits. Let DM be the set of students that ate mangoes and durians, LM the set of students that ate mangoes and litchis, and M M those students that only ate mangoes. We note that M = DM LM MM. Also, M = 73, DM = 34, LM = 12, DM LM = 5, and DM MM = LM MM = DM LM MM = 0. Using part a), we get MM = 32. 6
Extra Credit Let A, B, and C be three sets in a universe U. Using set identities (no truth table or membership table!), show the following identity, (A B) (B C) (C A) = (A B) (B C) (C A) Let LHS = (A B) (B C) (C A) and = (A B) (B C) (C A). Then: LHS = (A B) (B C) (C A) (B A) (B C) (C A) symmetry of union (B (A C)) (C A) distributivity (B (C A)) (A C) (C A)) distributivity ((B C) (B A)) ((A C) (A C)) Absorption law (B C) (B A) (A C) Absorption law 7