SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 PROBLEM 1 What are the converse and contrapositive statements of the statement If it is sunny, then I will go swimming? (The answer needs not to be justified.) SOLUTION: Converse is If I (will) go swimming, then it is sunny. Contrapositive is If I do not/will not go swimming, then it is not sunny. PROBLEM 2 Show that (p q) and q p are logically equivalent by (a) using a truth table; (b) using logical equivalences. SOLUTION: (a) Truth table: p q q p q (p q) p q p T T F T F F F T F T T F F F F T F F T T T F F T T F T F Since the fifth and seventh columns agree, we conclude that (p q) and q p are logically equivalent by definition. (b) We have (p q) (1) p q (2) p q (3) q p, where we have used De Morgan s law (1), the doble negation law (2) and the commutative law (3). (c) Prove or disprove that (p q) r and p (q r) are equivalent. SOLUTION: They are not equivalent, because there exist truth values for the three propositions p, q, r making (p q) r false but p (q r) true. To see this, take p to be false, q true and r false. Then (p q) r is false, since its premise (p q) is true and its conclusion r is false. On the other hand p (q r) is true since its premise p is false. (d) Prove that ( q (p q)) p is a tautology. SOLUTION ALTERNATIVE 1: This can be done with a truth table: p q p q p q q (p q) ( q (p q)) p T T F F T F T T F F T F F T F T T F T F T F F T T T T T 1
2 SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 Since the truth value of ( q (p q)) p is always T, no matter what the values of p and q are, it follows that ( q (p q)) p is a tautology by definition. SOLUTION ALTERNATIVE 2: using logical equivalences we get q (p q)) p ( q (p q)) p q (p q)) p De Morgan and double negation q ( p q)) p q (p q)) p De Morgan and double negation ((q p) (q q)) p Distributive law ((q p) T) p Negation law q p p Associative law and Negation law q T Identity law T Domination law so that ( q (p q)) p is logically equivalent to a proposition that is always true, which means it is a tautology. PROBLEM 3 Let P (m, n) be m is greater than n, where the domain (universe of discourse) is the set of negative integers. Decide the truth value of the following propositions: (a) x yp (x, y), (b) x yp (y, x), (c) x yp (x, y), (d) x yp (y, x), SOLUTION: (a) is FALSE since it claims that there exists a negative integer x such that x > y for all negative integers y. In particular, we would have to have x > 1, which is impossible. (b) is FALSE since it claims that there exists a negative integer x such that y > x for all negative integers y. Indeed, if such an x existed, we would have to have x > x, which is impossible. (c) is TRUE since it claims that for any negative integer x, we can find a negative integer y such that x > y. For instance, we can take y = x 1. (d) is FALSE since it claims that for any negative integer x, we can find a negative integer y such that y > x. But such a y cannot exist if x = 1. PROBLEM 4 (a) Formalize the following argument and determine whether it is valid: She is a bachelor student in mathematics or in computer science. If she doesn t know discrete math, she is not a bachelor student in computer science. If she knows discrete math, she is smart. She is not a bachelor student in mathematics. Therefore, she is smart.
SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 3 SOLUTION: Let us name the different propositions with the following letters: m c d s She is a bachelor student in mathematics She is a bachelor student in computer science She knows discrete math She is smart Then the formal argument is: m c d c d s m s This is VALID and we prove it by using the following rules of inference: 1. d c Premise 2. c d Contraposition on 1. and Doble negation 3. d s Premise 4. c s Hypothetical syllogism on 2. and 3. 5. m c Premise 6. m Premise 7. c Disjunctive syllogism on 5. and 6. 8. s Modus ponens on 4. and 7. (b) Determine whether the following argument is valid: p r q r (p q) r SOLUTION: The argument is not valid because the truth values p false, q false and r true, make the three premises true and the conclusion false. PROBLEM 5 A stamp collector wants to include in her collection exactly one stamp from each country of Africa. If I(s) means that she has stamp s in her collection, F (s, c) means that stamp s was issued by country c, the domain for s is all stamps, and the domain for c is all countries of Africa, express the statement that her collection satisfies her requirement. Do not use the! symbol. SOLUTION: The simplest formula is ( ) c s x (I(x) F (x, c)) x = s. PROBLEM 6 Prove or disprove the following statements about sets:
4 SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 (a) A (B C) = (A B) (A C) for all sets A, B, C. (b) A (B C) = (A B) (A C) for all sets A, B, C. SOLUTION: (a) is FALSE. For a counterexample, take A = {1, 2}, B = {1} and C = {2}. Then we have A (B C) = {1, 2} = {1, 2} and (A B) (A C) = {2} {1} =. (b) is TRUE, since A (B C) (1) = A B C (2) = A (B C) (3) = (A B) (A C) (4) = (A B) (A C), where we have used the definition of difference between sets (1 and 4), De Morgan s law (2) and the distributive law (3). PROBLEM 7 Find the power set of the set {{a, b}, c}. SOLUTION: {, {{a, b}}, {c}, {{a, b}, c}} PROBLEM 8 Consider the functions f, g : Z Z defined by f(n) = 2n + 1 and g(n) = 2 n 2. (a) What is the range of each of the functions f, g, f g and g f, respectively? Which of the functions f, g, f g and g f are surjective? (b) Which of the functions f, g, f g and g f are injective? SOLUTION: (a) The range of f is the set of all odd integers and the range of g the set of all even integers. We have f g : Z Z defined by f g(n) = f(g(n)) = 4 n 2 + 1, so the range is the set {n Z (k Z)(n = 4k + 1)}. We have g f : Z Z defined by g f(n) = g(f(n)) = 2 2n+1 2 = 2 n + 1 2 = 2n, so the range is the set of all even integers. It follows that none of the functions are surjective, since all these sets are proper subsets of Z. (b) g and f g are not injective, since for instance g(0) = g(1) and f g(0) = f g(1). f is injective since Likewise, g f is injective. f(n 1 ) = f(n 2 ) 2n 1 + 1 = 2n 2 + 1 2n 1 = 2n 2 n 1 = n 2. PROBLEM 9 (a) Show that the set of odd positive integers greater than 3 is countable. SOLUTION: The function f(n) = 2n+3 is a bijection between the set of positive integers to the set of positive integers greater than 3. Hence the latter set is countable. (b) Let A and B be countable sets. Prove that A B is countable.
SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 5 SOLUTION: The fact that A is countable means that we can arrange the elements of A is a sequence labelled by the set of positive integers, possibly ending: Likewise, we can write A = {a 1, a 2, a 3,...}. B = {b 1, b 2, b 3,...}. All elements of A B are then of the form (a i, b j ) for some i, j N +. We then order all elements in the following way (a 1, b 1 ) (a 1, b 2 ) (a 1, b 3 ) (a 1, b 4 ) (a 1, b 5 )... (a 2, b 1 ) (a 2, b 2 ) (a 2, b 3 ) (a 2, b 4 ) (a 2, b 5 )... (a 3, b 1 ) (a 3, b 2 ) (a 3, b 3 ) (a 3, b 4 ) (a 3, b 5 )... (a 4, b 1 ) (a 4, b 2 ) (a 4, b 3 ) (a 4, b 4 ) (a 4, b 5 )... (a 5, b 1 ) (a 5, b 2 ) (a 5, b 3 ) (a 5, b 4 ) (a 5, b 5 )..................... and we then order the elements using the same diagonal-chaising-pattern as in the proof of the countability of Q +. and PROBLEM 10 (a) Find 100 j=1 (2j + 5) and 100 j=5 3j. SOLUTION: We have (2j + 5) = 2 j + 5 = 2 j=1 j=1 3 j = 3 j j=5 j=0 j=0 j=1 (b) Decide whether 175 22 (mod 17). 100 101 2 + 100 5 = 10600 4 3 j = 3101 3 1 35 3 1 = 3101 3 5. 2 SOLUTION: We have 175 22 = 153 and 17 153, since 153 = 17 9. 22 (mod 17). hence 175 (c) Find the prime factorization of 45617. SOLUTION: We check that neither 2, 3, 5 nor 7 divide 45617. Dividing by 11 we obtain 4147. Repeating the procedure, we again find that the smallest prime dividing this number is 11, and dividing yields 377. We find that this number is not divisible by any of 2, 3, 5, 7, 11, but dividing by 13 yields 29, a prime number. Hence the factorization is 45617 = 11 2 13 29. (d) Find gcd(70, 84) and lcm(70, 84). SOLUTION: We find the prime factorizations 70 = 2 5 7 and 84 = 2 2 3 7, whence gcd(70, 84) = 2 7 = 14.
6 SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 Similarly, lcm(70, 84) = 2 2 3 5 7 = 420. PROBLEM 11 Find the mistake in the following proof of the following theorem and give a correct proof. Theorem If a b and b c, then a c. Proof. Since a b, we have b = ka for k Z. Likewise, since b c, we have c = kb. Therefore, c = bk = (ak)k = ak 2. It follows that a c. QED SOLUTION: The proof is incorrect since there is no guarantee that the multiple k will be the same in both cases. Correct proof: Since a b, we have b = ka for some k Z. Likewise, since b c, we have c = lb for some l Z. Therefore, c = lb = l(ka) = (lk)a. It follows that a c. QED PROBLEM 12 (a) A message has been encrypted using the function f(x) = (x + 5) mod 26. If the message in coded form is JCF HY, decode the message. SOLUTION: The decoded message is EXACT. To see this, we first replace the letters in the coded form by numbers corresponding to their position in the English alphabet, yielding 10 3 6 8 25. Then we apply the inverse of f, namely f 1 (x) = (x 5) mod 26, to these numbers, obtaining 5 24 1 3 20, which correspond to the letters E X A C T. (b) Explain why g(x) = (2x + 3) mod 26 would not be a good coding function. SOLUTION: The function g is not bijective, since for instance g(0) = g(13). Hence there exists no inverse function, so we would not be able to decode the message. PROBLEM 13 Prove that if n is an integer that is not a multiple of 3, then n 2 1 (mod 3). SOLUTION-ALTERNATIVE 1: We do a proof by cases: If n is an integer that is not a multiple of 3, then n = 3k + 1 or n = 3k + 2 for some integer k. (In fact, k is the quotient and 1 respectively 2 the remainder, obtained when dividing n by 3.) If n = 3k + 1, then n 2 = 9k 2 + 6k + 1 = 3(3k 2 + 2k) + 1, whence n 2 1 (mod 3). If n = 3k + 2, then n 2 = 9k 2 + 12k + 4 = 3(3k 2 + 4k + 1) + 1, whence n 2 1 (mod 3). SOLUTION-ALTERNATIVE 2: The product of three consecutive integers must be divisible by 3. In particular, 3 (n 1)n(n + 1) for any integer n. If n is not divisible by 3, then 3 must divide (n 1)(n + 1), by the unique factorization of (n 1)n(n + 1). But (n 1)(n + 1) = n 2 1, so that 3 (n 2 1), which means that n 2 1 0 (mod 3), or, equivalently, n 2 1 (mod 3).
SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 7 Let A = 1 0 1 1 1 0 and B = PROBLEM 14 0 1 0 1 0 0 be two zero-one matrices. Find the join, meet and Boolean product of these two matrices. SOLUTION: The join of A and B is A B = 1 0 1 0 1 0 1 1 0 1 0 0 = 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 = 1 1 1 1 1 0. The meet of A and B is A B = 1 0 1 0 1 0 = 1 0 0 1 1 0 0 0 1 1 1 1 = 0 0 0 1 1 0 1 0 0 1 1 1 0 0 0 1 0 0. The Boolean product of A and B is A B = 1 0 1 0 1 0 1 1 0 1 0 0 = = = (1 0) (0 0) (1 1) (1 1) (0 1) (1 0) (1 0) (0 1) (1 0) (0 0) (1 0) (1 1) (0 1) (1 1) (1 0) (0 0) (1 1) (1 0) (1 0) (1 0) (0 1) (1 1) (1 1) (0 0) (1 0) (1 1) (0 0) 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 1 PROBLEM 15 An ISBN number is a 10-digit number s 1 s 10 such that 10 i=1 is i 0 (mod 11). Prove that if we exchange two different digits of an ISBN number, then the new number we get will not be a valid ISBN number. SOLUTION: When we exchange the places of two distinct digits, say s i and s j with s i s j, the difference in the control sum of the new and the old number is (is j + js i ) (is i + js j ) (mod 11). If the new number is still an ISBN number, then this must be zero, so that we must have (i j)(s j s i ) 0 (mod 11), that is, (i j)(s j s i ) = 11k, for some integer k. But i j { 10, 9,..., 9, 10}, since i, jj {0,..., 10} and s j s i { 9, 8,..., 8, 9}, since s i, s j {0,..., 9}. Therefore, neither i j nor s i s j contains 11 as a prime factor, so we must have k = 0, proving that s i = s j, a contradiction.
8 SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 PROBLEM 16 In this problem we use the fact that the Norwegian coin system is built on the following values: 1000, 500, 200, 100, 50, 20, 10, 5, 1 and 0, 50 NOK (Norwegian kroner). We will disregard the last value (0, 50) and work only with integer values of amounts. (a) Suppose that the cashier in a mall has to make change to a customer for the value of 2677 NOK. Assume that he has enough bills and coins of all values. What will he give the customer if he uses the greedy algorithm. SOLUTION: We have 2677 = 2 1000 + 1 500 + 1 100 + 1 50 + 1 20 + 1 5 + 2 1. Therefore, the customer will receive two 1000 bills and one 500, one 100 and one 50 bill, one 20 and one 5 coin, and two 1 coins. (b) Prove that the greedy algorithm applied to NOK always produces change using the fewest bills and coins possible. SOLUTION: We argue as in Lemma 1 and Theorem 1 in 3.1 in the book. Let n be a positive integer, which corresponds to a change. Assume that the change using the fewest bills and coins possible is given by n = 1000a 1 + 500a 2 + 200a 3 + 100a 4 + 50a 5 + 20a 6 + 10a 7 + 5a 8 + a 9, where all a i N. (That is, the change consists of a 1 1000 NOK bills, a 2 500 NOK bills and so on.) Then one can easily show, as in Lemma 1, that as well as Now assume that a 2 1, a 3 2, a 4 1, a 5 1, a 6 2, a 7 1, a 8 1, a 9 4, a 3 + a 4 2, a 6 + a 7 2. n = 1000b 1 + 500b 2 + 200b 3 + 100b 4 + 50b 5 + 20b 6 + 10b 7 + 5b 8 + b 9, where all b i N, is the change using the greedy algorithm. We prove that all b i = a i, which will prove that greedy algorithm applied always produces change using the fewest bills and coins possible. Obviously b 1 a 1, since the greedy algorithm by definistion uses the largest ampount of 1000 bills possible. If b 1 > a 1, we must have 500a 2 + 200a 3 + 100a 4 + 50a 5 + 20a 6 + 10a 7 + 5a 8 + a 9 1000, but this is not possibile by the inequlaities we found. Thus b 1 = a 1. Continuing this way, we obtain that all b i = a i. (I skip the details.)
SOLUTIONS TO TAKE HOME EXAM 1 MNF130, SPRING 2010 9 GENERELLE KOMMENTARER Veldig viktig: Man må huske å begrunne svarene med mindre det eksplisitt står at det holder å skrive ned svaret. F.eks. er det null poengs utteling for bare å skrive ned svarene på matriseoperasjonene i Oppgave 14. Også veldig viktig: Husk å forklare (kort) hva man har vist/gjort. F.eks.: ikke bare skriv ned en sannhetstabell uten kommentarer. Gjelder diverse oppgaver: Husk at for å motbevise noe, dvs. vise at noe ikke er sant, holder det å finne et moteksempel. Dette er et viktig poeng som mange ikke har fått med seg. F.eks. var det mange som omformet mengdene i 6(a) og forsøkte å forklare masse uten å egentlig komme i mål. Husk å bruke parenteser i logiske uttrykk og bruk dem riktig! Litt mange slurvet med dette. Angående logikkoppgaver: ikke argumenter med ord. Bruk logiske symboler og ekvivalenser! Oppgave 6:(b) det var litt rart at nesten ingen har brukt mengdelære og operasjoner på mengder. Omtrent halvparten har brukt Venndiagrammer, som er noe upresist. Den andre halvparten skrev om mengdene til logikk, som i Eksempel 11 i 2.2 i boken. Dette er selvfølgelig helt riktig, men det aller enkleste er jo å bruke mengdeoperasjoner som i løsningsforslaget og Eksempel 14 i 2.2. Oppgave 13: Her var det en del rar føring med mod. Noen skriver f.eks. meningsløse ting som mod 3... Andreas Leopold Knutsen