Exam 1 Solutions Q 1-3

advertisement
Computer Science 290, Spring, 2009
Exam 1
Name________________________________
(20 points) Question 1: short answer
Consider the relation x | y (x divides y) on Z+, the positive integers.
(x | y means there is a q in Z+ such that y = xq, and you should use this in your proofs.)
(6) a) Prove or give a counter-example for the statement | is reflexive.
For any x in Z+, x = 1*x, so x | x. Therefore, for all x in Z+, x | x. | is reflexive.
(7) b) Is | symmetric, antisymmetric or asymmetric? Prove it.
.
Antisymmetric: Consider any x, y in Z+ such that x | y and y | x. The y = k * x for some integer k and x = n*y
for some integer y. Consequently, x = n*(k*x) (substitution), so x = (n*k) * x (multiplication associative). But
then n*k = 1. Since n and k are both integers, they must both be 1 (no integer other than 1 has a multiplicative
inverse). Substituting into the first equation for k, we have y = x.
Thus, we have shown that for all x, y in Z+, if x | y and y | x, then x = y. So | is antisymmetric.
Computer Science 290, Spring, 2009
Exam 1
Question 1:
Name________________________________
(7) c) ) Prove or give a counter-example for the statement: | is transitive.
Consider any x, y, z in Z+ such that x | y and y | z. Then by definition, there are integers k and n so that
y = k*x and z = n*y. By substitution, z = n * (k*x), so z = (n*k) * x (multiplication associative). But n*k is an
integer, so x | z.
We have shown that for all x, y, z in Z+, if x | y and y | z, then x | z. Thus, | is transitive.
Computer Science 290, Spring, 2009
Exam 1
(30 pts) Question 2:
Name________________________________
Let M be a subset of AxA, where A = {1, 2, 3, 4, 5, 6} (see example below). Define R on M as follows:
(r1, c1) R (r2, c2) if and only if r1 = r2 and (c1 = c2 or c1 = c2+1 or c1 = c2-1),
or c1 = c2 and (r1 = r2+1 or r1 = r2-1).
In other words if p1 = (r1, c1) and p2 = (r2, c2), then p1 R p2 if they describe positions in the grid with 6 rows
and columns that are adjacent horizontally or vertically, or are the same.
1 2 3 4 5 6
1
2
3
4
5
6
In the diagram the black cells in the grid indicate positions in the set M.
M = {(1,1),(1,4),(2,1),(2,2),(2,4),(2,5),(3,2),(3,4),(3,6),(4,2),(4,4),(4,6),(5,1),(5,3),(5,6),(6,3),(6,6)}
Then, for example, (2,1) R (2,2) and (3,4) R (2,4).
(3) a) Prove that R is reflexive.
Let x = (r, c) in M, since r = r and c = c, xRx. So for all x in M, xRx and R is reflexive.
Computer Science 290, Spring, 2009
Exam 1
Name________________________________
Question 2:
(8) b) Prove that R is symmetric.
Let x = (p, q) and y = (s, t) so that xRy. Then one of the following is true:
p = s and q = t, in which case s = p and t = q, so yRx
p = s and q = t + 1, in which case s = p and t = q – 1, so yRx
p = s and q = t – 1, in which case s = p and t = q + 1, so yRx
q = t and p = s + 1, in which case t = q and s = p – 1, so yRx
q = t and p = s – 1, in which case t = q and s = p + 1, so yRx
Since in every case, we see that yRx, we can conclude that for all x, y in M, if xRy then yRx, so
R is symmetric.
(7) c) Prove that R is not transitive.
Consider (1,1), (2,1), and (2,2), all in M. (1,1)R(2,1) and (2,1)R(2,2), but not (1,1)R(2,2). So R is not transitive.
Computer Science 290, Spring, 2009
Exam 1
Question 2:
(4) d) Describe the transitive closure, T, of R.
Name________________________________
xTy if there is a sequence of x = w1, w2, … , wk = y and wi is adjacent to wj either horizontally or vertically.
(1,1)T(1,1); (1,1)T((2,1); (1,1)T(2,2); (1,1)T(3,2); (1,1)T(4,2); (2,1)T(1,1); (2,1)T(2,1); (2,1)T(2,2);
(2,1)T(3,2); (2,1)T(4,2); (2,2)T(1,1); (2,2)T((2,1); (2,2)T(2,2); (2,2)T(3,2); (2,2)T(4,2);
(3,2)T(1,1); (3,2)T((2,1); (3,2)T(2,2); (3,2)T(3,2); (3,2)T(4,2); (4,2)T(1,1); (4,2)T((2,1); (4,2)T(2,2);
(4,2)T(3,2); (4,2)T(4,2);
(5,1)T(5,1);
(5,3)T(5,3); (5,3)T(6,3); (6,3)T(5,3); (6,3)T(6,3);
(1,4)T(1,4); (1,4)T(2,4); (1,4)T(2,5); (1,4)T(3,4); (1,4)T(4,4); (2,4)T(1,4); (2,4)T(2,4); (2,4)T(2,5); (2,4)T(3,4);
(2,4)T(4,4); (2,5)T(1,4); (2,5)T(2,4); (2,5)T(2,5); (2,5)T(3,4); (2,5)T(4,4); (3,4)T(1,4); (3,4)T(2,4);
(3,4)T(2,5); (3,4)T(3,4); (3,4)T(4,4); (4,4)T(1,4); (4,4)T(2,4); (4,4)T(2,5); (4,4)T(3,4); (4,4)T(4,4);
(3,6)T(3,6); (3,6)T(4,6); (3,6)T(5,6); (3,6)T(6,6); (4,6)T(3,6); (4,6)T(4,6); (4,6)T(5,6); (4,6)T(6,6);
(5,6)T(3,6); (5,6)T(4,6); (5,6)T(5,6); (5,6)T(6,6); (6,6)T(3,6); (6,6)T(4,6); (6,6)T(5,6); (6,6)T(6,6);
(8) e) Describe M / T, either in words or in terms of the diagram.
M/T comprises the six blocks of M that are not connected horizontally or vertically.
M/T = { {(1,1), (2,1), (2,2), (3,2), (4,2)}, {(5,1)}, {(5,3), (6,3)}, {(1,4), (2,4), (2,5), (3,4), (4,4)},
{(3,6), (4,6), (5,6), (6,6)} }
Computer Science 290, Spring, 2009
Exam 1
(25 pts) Question 3:
Name________________________________
Define R on Z+0 (non-negative integers)as follows: a R b if and only if a mod 7 = b mod 7. (Recall that r = a
mod b if there is a q such that a = b*q + r and 0 <= r < b.)
(15) a) Prove that R is an equivalence relation.
For all x in Z+0 x = x (mod 7) since the remainder when dividing x by seven is the same as the remainder when
dividing x by 7. So R is reflexive.
For some x, y in Z+0, assume xRy. Then there is an r, 0 <= r < 7, and p, q >= 0 so that x = 7*p + r and
y = 7*q + r.
So yRx. Therefore, for all x, y in Z+0, if xRy then yRx – R is symmetric.
Assume for some x, y, z in Z+0 that xRy and yRz. Since xRy, there is an r, 0 <= r < 7, and p, q >= 0 so that
x = 7*p + r and y = 7*q + r. Since yRz, there must be a t such that z = 7*t + r. Thus xRz. So
for all x,y,z in Z+0, if xRy and yRz, then xRz – R is transitive.
Since R is reflexive, symmetric, and transitive, it is an equivalence relation.
Computer Science 290, Spring, 2009
Exam 1
Name________________________________
Question 3:
(10) b) Describe or write out Z / R.
{ {0, 7, 14, … 7k …}, {1, 8, 15, … 7k+1…}, {2, 9, 16, … 7k+2…}, {3, 10, 17, … 7k+3…},
{4, 11, 18, … 7k+4…}, {5, 12, 19, … 7k+5…}, {6, 13, 20,… 7k+6…} }
Download