Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007) Problem 1: Specify two different predicates P (x) and Q(x) over the set of positive integers so that the proposition x (P (x) Q(x)) is false while x (P (x) Q(x)) is true. Your answer should contain a clear definition of the predicates P (x) and Q(x) and an explanation of why, for your choice of predicates, x (P (x) Q(x)) is false and x (P (x) Q(x)) is true. Let P (x) denote the predicate x is divisible by 3 and let Q(x) denote the predicate x is divisible by 7. The universe for both the predicates is the set of positive integers. Here, the proposition x (P (x) Q(x)) is false. The reason is that an integer x need not be divisible by both 3 and 7. (For example, 3 is not divisible by 7.) However, the proposition x (P (x) Q(x)) is true since we can choose x = 21 which is divisible by both 3 and 7. Problem 2: Suppose p, q and r are propositions such that p q, ( p) r and r (p q) are all true. Show that q is true. We will use a proof by contradiction. So, suppose q is false. (1) Note that p q is true; that is, p q is true. Since q is false, we must conclude that p is true; that is, p is false. (2) Since p is true (from (1)) and ( p) r is true (given), r is true (by modus ponens). (3) Since r is true (from (2)) and r (p q) is true (given), p q is true (by modus ponens). (4) However, p is false (from (1)) and q is false by our assumption. So, p q is false. This contradicts the conclusion in (3) that p q is true. Thus, q must be true. Problem 3: Recall that a binary propositional operator is associative if for all propositions a, b and c, the propositional forms a (b c) and (a b) c have the same truth value. Also recall that the NAND operator ( ) is defined by a b (a b). Is the NAND operator associative? Justify your answer. The NAND operator is not associative. To see this, consider the case where a = b = 1 and c = 0. The truth values of a (b c) and (a b) c are computed below. (i) a (b c) 1 (1 0) 1 1 0. (ii) (a b) c (1 1) 0 0 0 1. Thus, a (b c) and (a b) c have different truth values. So, NAND is not associative. 1
Problem 4: Suppose A and B are sets such that A = 6, B = 2 and A B = 1. Calculate P(A B). (Recall that for a set X, P(X) denotes the powerset of X.) By the inclusion-exclusion formula, A B = A + B A B = 6 + 2 1 = 7. Recall that for any finite set X, P(X) = 2 X. Therefore, P(A B) = 2 7 = 128. Problem 5: Let A = {1, 2, 3, 4} and B = {a, b, c, d, e}. How many functions from A to B are either one-to-one or map the element 1 to c? (You need not simplify your answer.) Let S 1 denote the set of functions from A to B which are one-to-one and let S 2 denote the set of functions from A to B which map the element 1 to c. The required answer to the problem is S 1 S 2. We will compute this number using the inclusion-exclusion formula: S 1 S 2 = S 1 + S 2 S 1 S 2. (a) S 1 is the number of one-to-one functions from A to B. In constructing such a function, there are 5 choices for the element 1, 4 choices for the element 2, 3 choices for the element 3 and 2 choices for the element 4. So, S 1 = 5 4 3 2 = 120. (b) S 2 is the number of functions from A to B that map the element 1 to c. In constructing such a function, there is only one choice for the element 1 but there are 5 choices for each of the three remaining elements of A. So, S 2 = 5 5 5 = 5 3 = 125. (c) S 1 S 2 is the number of functions from A to B which are one-to-one and which map the element 1 to c. In constructing such a function, there are is only one choice for the element 1, 4 choices for the element 2, 3 choices for the element 3 and 2 choices for the element 4. So, S 1 S 2 = 4 3 2 = 24. Thus, using the inclusion-exclusion formula, the required answer is 120 + 125 24 = 221. Problem 6: Let X = {a, b, c, d, e}. Let us call a binary relation R on X special if it satisfies all of the following conditions: (i) R is reflexive, (ii) R is symmetric and (iii) R contains the pair (a, b). Find the number of special binary relations on X. You need not simplify your answer. Every binary relation on X can be represented by a 5 5 Boolean matrix. There are 25 entries in this matrix, with 5 entries along the main diagonal, 10 entries above the diagonal and 10 entries below the diagonal. Since the relation is required to be reflexive, there is only one choice (namely, the value 1) for each entry along the diagonal. Since the relation is required to be symmetric, once we choose a 0 or 1 value for each of the 10 entries above the diagonal, the 10 entries below the diagonal are determined; that is, there is only one choice for each of those entries. Of the 10 entries above the diagonal, one entry corresponding to (a, b) must be 1 (since the relation must contain that pair). Thus, only 9 entries in the Boolean matrix have two choices each. All other entries have only one choice. So, the number of special relations = 2 9. (This expression can be simplified to 512.) 2
Problem 7: Let Y = {1, 2, 3, 4}. Consider the binary relation R on Y defined by Find the transitive closure of R. R = {(1, 2), (2, 1), (2, 3), (2, 4), (4, 3), (4, 4)}. The directed graph of the binary relation R is shown below. 1 2 3 4 Recall that the transitive closure of R contains each pair (x, y) such that there is a directed path of length 1 from x to y in the above graph. Thus, the transitive closure of R is given by {(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (4, 3), (4, 4)}. Problem 8: Let N + denote the set of positive integers (i.e., integers that are strictly greater than 0). Consider the function f from N + to N + defined as follows: f(x) = 1+ the number of 9 s in the decimal representation of x. For example, f(1) = 1, f(293) = 2, f(1929) = 3. 1. Is f one-to-one? Justify your answer. 2. Is f onto? Justify your answer. Part (a): f is not one-to-one. To see this, notice that f(1) = f(2) = 1; that is, two different elements of N + are mapped by f to the same element of N +. So, f is not one-to-one. Part (b): f is onto. To prove this statement, we must show that for any integer y N +, there is an integer x N + such that f(x) = y. There are two cases. Case 1: y = 1. For this case, let x = 1. From the definition of f, we have f(x) = f(1) = 1 = y. Case 2: y 2. For this case, let x be the decimal integer that consists of y 1 occurrences of the digit 9. (For example, if y = 3, we let x = 99.) Since y 2, this integer is well defined; it has at least one 9. Again, by the definition of f, f(x) = 1 + y 1 = y. Thus, for any integer y N +, there is an integer x N + such that f(x) = y. In other words, f is onto. 3
Problem 9: Let R denote the set of real numbers. Consider the function f from R R to R R defined by f(x, y) = (x + y, x y). Find f 1. (You may assume without proof that f is a bijection.) For any (a, b) R R, let f 1 (a, b) = (x, y). Thus, to specify f 1, we need to do the following: given a and b, find the values of x and y. By the definition of inverse, we have f(x, y) = (a, b). However, by the definition of f, we have f(x, y) = (x + y, x y). Therefore, we have two linear equations x + y = a and x y = b for the variables x and y. Solving the two linear equations, we get In other words, f 1 is defined by x = (a + b)/2 and y = (a b)/2. f 1 (a, b) = ( (a + b)/2, (a b)/2 ). Problem 10: Find the number of solutions to the equation x 1 + x 2 + x 3 + x 4 + x 5 = 37, where x 1, x 2, x 3, x 4 and x 5 are non-negative integers, x 2 8, x 3 7, x 4 2 and x 5 < 4. (You may leave the answer as an expression consisting of binomial coefficients.) To solve this problem, we will use the fact that the number of solutions to the equation z 1 + z 2 +... + z r = q where z 1, z 2,..., z r and q are all non-negative integers, is = C(q + r 1, r 1). To handle the constraints on x 2, x 3 and x 4, first define new variables y 2 = x 2 8, y 3 = x 3 7 and y 4 = x 4 2. Since x 2 8, x 3 7 and x 4 2, we have y 2 0, y 3 0 and y 4 0. Substituting for x 2, x 3 and x 4 in terms of y 2, y 3 and y 4 respectively in the given equation, we get x 1 + y 2 + y 3 + y 4 + x 5 = 37 8 7 2 = 20 (1) Let N 1 denote the number of solutions to Equation (1) where each of the variables is a non-negative integer. Using the formula mentioned above, N 1 = C(20 + 5 1, 5 1) = C(24, 4). In some of these solutions, x 5 satisfies the condition x 5 < 4 while in others, x 5 4. So, if we find the number of solutions, say N 2, where x 5 4, then the required solution to the problem is N 1 N 2. To find N 2, we proceed in a manner similar to that of N 1. Define a new variable y 5 = x 5 4. Thus, when x 5 4, y 5 0. We substitute for x 5 in terms of y 5 in Equation (1) to get the equation x 1 + y 2 + y 3 + y 4 + y 5 = 20 4 = 16 (2) The number of solutions N 2 to Equation (2) where each variable is a non-negative integer is = C(16 + 5 1, 5 1) = C(20, 4). Therefore, the required answer is N 1 N 2 = C(24, 4) C(20, 4). 4
Problem 11: Recall that a bit string is a string composed of characters 0 and 1. Let us call a bit string s interesting if it satisfies all of the following conditions: (i) s has length 23, (ii) s starts with 1110, (iii) s ends with with 00110 and (iv) s has 0 as its middle bit. Find the number of bit strings that are interesting. (You need not simplify your answer.) There are 23 positions in the string. Of these, 10 positions (namely, the first 4, the last 5 and the middle bit) have specified values. For each of the remaining 13 positions, we have two choices (namely, 0 or 1). So, the number of interesting bit strings = 2 13. (This expression can be simplified to 8192.) Problem 12: Use induction on n to prove the following for all n 2: If A 1, A 2,..., A n are subsets of a universal set U, then A 1 A 2... A n = A 1 A 2... A n. You can assume without proof that for any two subsets X and Y of the universal set U, X Y = X Y. Proof: Basis: n = 2. For any two sets A 1 and A 2, the problem allows us to assume that A 1 A 2 = A 1 A 2. Thus, the basis holds. Induction Hypothesis: A 1, A 2,..., A k, Assume that for some integer k 2, and any collection of k sets A 1 A 2... A k = A 1 A 2... A k (3) To prove: For any collection of k + 1 sets A 1, A 2,..., A k+1, A 1 A 2... A k A k+1 = A 1 A 2... A k A k+1 (4) Proof: Consider any collection of k + 1 sets A 1, A 2,..., A k+1. Let X = A 1 A 2... A k. Consider the two sets X and A k+1. By the given assumption for two sets, we have X A k+1 = X A k+1 (5) Now, by the definition of X, X = A 1 A 2... A k. Therefore, we can apply the inductive hypothesis (Equation (3)) to X to get X = A 1 A 2... A k (6) Substituting the result of Equation (6) in Equation (5), we get Again, using the definition of X in Equation (7), we get as required. This completes the proof. X A k+1 = A 1 A 2... A k A k+1 (7) A 1 A 2... A k A k+1 = A 1 A 2... A k A k+1 (8) 5