CS 173, Spring 2011, Midterm 1 Solutions
Notice that there were several versions of the exam, involving 2-3 versions of each problem.
Problem 1: Multiple choice (12 points)
Check the appropriate box for each statement. (One box per statement.) If you change your answer, make it very clear when you’ve meant to uncheck a box.
For any sets A and B,
|A ∪ B| = |A| + |B|. True False √
For any sets A and B,
|A × B| = |A||B|. True √
False
−15 ≡ 7 (mod 8) True False √
−15 ≡ 7 (mod 11) True √
False
For any set A, ∅ ∈ A. True False √
For any set A, ∅ ⊆ A. True √
False
For any sets A and B,
if x∈ A ∩ B, then x ∈ A. True √
False
{5, 6, 7} ∩ {1, 2, 8} = {∅} True False √
If a relation is not symmetric, it is
antisymmetric. True False √
For any real number x,
⌊x⌋ ≤ x ≤ ⌈x⌉. True √
False
7| 0 True √
False
Problem 2: Calculation (10 points)
Calculate the values of the following expressions, showing your work. When the value is a non- empty set, explicitly list its contents. For calculations in Zk, express your final answer as [x], where 0≤ x < k.
(a) In Z12, ([7] + [11])2 = [18]2 = [6]2 = [36] = [0]
(b) In Z10, ([7] + [11])2 = [18]2 = [8]2 = [64] = [4]
(c) In Z13, ([7] + [11])2 = [18]2 = [5]2 = [25] = [12]
(d) {a, b} × {5, 6, 7} = {(a, 5), (a, 6), (a, 7), (b, 5), (b, 6), (b, 7)}
(e) {a, b} × {(5, 6), 7} = {(a, (5, 6)), (a, 7), (b, (5, 6)), (b, 7)}
(f) {5, 6, 7} ∩ {(5, 6), 8} = ∅ (g) gcd(221, 1224) = 17 (h) gcd(391, 1150) = 23 (i) gcd(221, 1495) = 13
(j) {p + q2 | 0 ≤ p ≤ 2 and 0 ≤ q ≤ 2} = {0, 1, 2, 3, 4, 5, 6}
(k) {(p, q) | p ∈ Z and q ∈ Z and 1 ≤ pq ≤ 2} = {(1, 1), (−1, −1), (1, 2), (−1, −2), (2, 1), (−2, −1)}
(l) Xk+1
i=0
2−i = 2− 1 2k+1
Problem 3: Short answer (12 points)
(a) (5 points) Check all boxes that correctly characterize this relation:
A
B
C
D F
E Reflexive: Irreflexive: √
Symmetric: Antisymmetric:
Transitive:
A
B
C
D F
E Reflexive: Irreflexive:
Symmetric: Antisymmetric: √
Transitive: √
A
B
C
D F
E Reflexive: Irreflexive: √
Symmetric: Antisymmetric: √
Transitive:
(b) (3 points) Recall that Z2 is the set of all pairs of integers. Let’s define the equivalence relation
∼ on Z2 as follows: (x, y) ∼ (p, q) if and only |x| + |y| = |p| + |q|. List three members of [(2, 3)].
Solution: Members of [(2, 3)] include (2, 3), (3, 2), (−2, −3), (−2, 3), (1, 4), (−4, 1), (0, 5), etc. (You only needed to supply three pairs.)
(c) (3 points) Recall that N2is the set of all pairs of natural numbers. Let’s define the equivalence relation∼ on N2 as follows: (x, y)∼ (p, q) if and only xy = pq. List three members of [(5, 6)].
Solution: Members of [(5, 6)] include (5, 6), (6, 5), (10, 3), (3, 10), (1, 30), etc. (You only needed to supply three pairs.) Notice that both numbers in the pair must be positive.
(d) (2 points) State the negation of the following claim:
Claim: For all real numbers x and y, if x is irrational and y is irrational, then x + y is irrational.
Solution: There are some real numbers x and y such that x is irrational, y is irrational, but x+ y is rational.
Claim: For all real numbers p and q, if p is irrational and q is irrational, then pq +1 is irrational.
Solution: There are some real numbers p and q such that p is irrational, q is irrational, but pq+ 1 is rational.
(e) (2 points) Disprove the claim from part (c) using a concrete counter-example. Briefly explain why your counter-example works.
Solution: (First version of the claim:) Let x = √
2 and y =−√
2. Then both x and y are irrational. But x + y =√
2 + (−√
2) = 0 which is rational.
(Second version of the claim:) Let p = q = √
2. Then both p and q are irrational. However pq+ 1 = (√
2)(√
2) + 1 = 2 + 1 = 3 which is rational.
Problem 4: Writing a proof (8 points)
Recall the following definitions, for any integers x and y and any positive integer k:
x≡ y (mod k) if and only if k|(x − y).
x|y if and only if there is an integer m such that y = xm.
Working directly from these definitions (e.g. not using facts you may know about congruence or divisibility) and in your best mathematical style, prove the following claim.
Version 1: For all integers a, b, p, and q and all positive integers k, if a≡ p (mod 2k) and b≡ q (mod k), then a(b + 1) ≡ p(q + 1) (mod k).
Solution: Let a, b, p, and q be integers and k be a positive integer. Suppose that a≡ p (mod 2k) and b ≡ q (mod k). Then 2k|a − p and k|b − q (definition of congruence). So a − p = 2kn and b− q = km, where n and m are integer (definition of divides). So a = p + 2kn and b = q + km.
So then
a(b + 1) = (p + 2km)(q + km + 1) = p(q + 1) + p(km) + 2km(q + km + 1) = p(q + 1) + ks where s = pk + 2m(q + km + 1).
So a(b + 1)− p(q + 1) = ks. Since s must be an integer by closure, this means that k|a(b + 1) − p(q + 1). So a(b + 1)≡ p(q + 1) (mod k).
Version 2: For all integers a, b, p, and q and all positive integers k, if a≡ b (mod k) and p≡ q (mod 5k), then a(p + 2) ≡ b(q + 2) (mod k).
Solution: Let a, b, p, and q be integers and k be a positive integer. Suppose that a≡ b (mod k) and p ≡ q (mod 5k), Then k|a − b and 5k|p − q (definition of congruence. So a − b = kn and p− q = 5km, where n and m are integer (definition of divides). So a = b + kn and p = q + 5km.
So then
a(p + 2) = (b + kn)(q + 5km + 2) = b(q + 2) + b(5km) + kn(q + 5km + 2) = b(q + 2) + ks where s = 5bm + n(q + 5km + 2).
Problem 5: Proof by contrapositive (8 points)
Prove the following claim using proof by contrapositive.
Version 1: For all real numbers p and q, if (p + 1)q≤ 10 then p ≤ 3 or q ≤ 4.
Solution: The contrapositive of the claim is: for all real numbers p and q, if p > 3 and q > 4, then (p + 1)q > 10.
So, let p and q be real numbers and suppose that p > 3 and q > 4. Then p + 1 > 4. So (p + 1)q > 16. But 16 > 10. So (p + 1)q > 10, which is what we needed to show.
Version 2: For all real numbers p and q, if pq≤ 15 then p − 10 <= 0 or q <= 2.
Solution: The contrapositive of the claim is: for all real numbers p and q, if p− 10 > 0 and q >2, then pq > 15.
So, let p and q be real numbers and suppose that if p− 10 > 0 and q > 2. Then p > 10. So pq >20. But 20 > 15. So pq > 15, which is what we needed to show.