# Solutions to First Midterm Exam

### Directions:

• Answer the problems on the exam pages.
• There are four problems for 100 total points plus 10 extra credit. Actual scale was A = 85, B = 70, C = 55.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• In case of a numerical answer, an arithmetic expression like "32× 26 + 13 × 41" need not be reduced to a single integer.

```  Q1: 20 points
Q2: 15 points
Q3: 35 points
Q4: 30+10 points
Total: 100+10 points
```

Question text is in black, solution text in blue

• Several questions concern a group of dogs ( Ace, Biscuit, Cardie, and Duncan, denoted by the constants a, b, c, and d respectively) and a scientist's observations of their behavior. If u and v are dogs, the predicate X(u, v) means "u is dominant over v" or equivalently "v is dominated by u". Do not assume anything about this predicate unless you are explicitly given that assumption as a premise to a problem. In fact, some questions do not assume that you are working with those particular four dogs, but with any set of dogs and any binary relation X on them.

• Question 1 (20): Translate the following seven statements as indicated:

• (a) Statement I (to English): [X(c, d) ∨ X(d, c)] → [X(a, b) ∧ ¬X(a, b)]

If either Cardie dominates Duncan or Duncan dominates Cardie, then Ace both does and does not dominate Biscuit.

• (b) Statement II (to symbols): If Ace is not dominant over Cardie, then either Cardie is dominant over Duncan, or Duncan is dominant over Ace, but not both.

¬X(a, c) → (X(c, d) ⊕ X(d, a))

• (c) Statement III (to English): [¬X(b, d) → X(c, a)] ∧ [¬X(c, a) → ¬X(b, d)]

If Biscuit does not dominate Duncan, then Cardie dominates Ace, and if Cardie does not dominate Ace, then Biscuit does not dominate Duncan.

• (d) Statement IV (to symbols): For some dog, given any dog other than it, one of those two dogs is dominant over the other.

∃u: ∀v: (u ≠ v) → (X(u, v) ∨ X(v, u))

It was important to get the "other than it" for full credit. Note that "(u ≠ v) ∧ ..." is wrong, as "u ≠ v" is not true for all pairs.

• (e) Statement V (to English): ∀u:∀v:(¬X(u, v)) ∨ (¬X(v, u))

For any two dogs, either the first does not dominate the second or the second does not dominate the first.

Note that this statement allows u and v to be the same dog, which will be useful later.

• (f) Statement VI (to symbols): Given any dog, there are a second and a third dog (neither equal to the first dog nor equal to each other), such that neither the first dog nor the second is dominant over the other, and the third dog is dominant over both the first and the second.

∀u: ∃v: ∃w: (u ≠ v) ∧ (u ≠ w) ∧ (v ≠ w) ∧ ¬X(u, v) ∧ ¬ X(v, u) ∧ X(w, u) ∧ X(w, v)

Note that "u ≠ v ≠ w" does not state that "u ≠ w". Here we can use ∧ to include the not-equal conditions as we are saying that v and w exist that satisfy the not-equal conditions and make the rest true as well.

• (g) Statement VII (to symbols): There is a dog who neither dominates nor is dominated by any other dog.

∃u: ∀v: (u ≠ v) → (¬X(u, v) ∧ ¬X(v, u))

• Question 2 (15): Assuming that Statements I, II, III, V, and VII are true, determine all sixteen values of X(u, v) where u and v are taken from the set {Ace, Biscuit, Cardie, Duncan). (You may find it useful to do Question 3(a) first.)

First look at Statement 1, which says that if either X(c, d) or X(d, c) is true, then X(a, b) is both true and false. So X(c, d) ∨ X(d, c) leads to a contradiction, meaning that X(c, d) and X(d, c) are both false.

Next, Statement III is two implications, which we can combine by Hypothetical Syllogism to get ¬X(c, a) → X(c, a), which is only possible if X(c, a) is true.

Specializing Statement V to c and a, and using X(c, a), we get ¬X(a, c). Turning to Statement II, we know that the premise of this implication is true and so its conclusion is true. Since X(c, d) is false, X(d, a) must be true.

In Question 3a we prove ∀u: ¬X(u, u) from Statement V, telling us that X(a, a), X(b, b), X(c, c), and X(d, d) are all false.

Specializing Statement V to d and a, we find that X(a, d) is false.

Statement VII says that one of the dogs neither dominates nor is dominated by any other dog. Since X(c, a) and X(d, a) are true, this dog cannot be Ace, Cardie, or Duncan and thus must be Biscuit. Thus X(b, a), X(b, c), X(b, d), X(a, b), X(c, b), and X(d, b) are all false. We have now established all sixteen truth values -- the only two that are true are X(c, a) and X(d, a).

• Question 3 (35): Here are some more questions about the relation X. Here you are not necessarily assuming the truth of all of the statements you used in Question 2 -- use only the statements you are given in each part.

• (a, 5) A relation R is defined to be antireflexive if ∀u: ¬R(u, u). Prove that if X is any relation that makes Statement V true, then X is antireflexive.

Let u be an arbitrary dog. Specializing Statement V to make both dogs u, we get ¬X(u, u) ∨ ¬X(u, u), which implies ¬X(u, u). Since u was arbitrary, we have proved ∀u: ¬X(u, u).

• (b, 10) A dominance chain is a sequence of dogs u1, u2,..., uk (where k is any positive natural) such that X(ui, ui+1) is true for any i in the range from 1 through k-1. Let Y(u, v) be defined to mean "there exists a dominance chain with u1 = u and uk = v". Explain in English why Y must be a transitive relation for any X. Is Y guaranteed to be antisymmetric if X is? Justify your answer.

This was the most disappointing set of answers on the test. Most of you never addressed the transitivity of Y, instead asserting the transitivity of X with no justification (except some sort of inference from the meaning of the English word "dominate"). Here is the correct answer:

We want to prove ∀u: ∀ v: ∀ w: (Y(u, v) ∧ Y(v, w)) → Y(u, w). So we let u, v, and w be arbitrary dogs and assume both Y(u, v) and Y(v, w). By the definition of Y, there exist two dominance chains, one with first element u and last element v, and one with first element v and last element w. We can create a single dominance chain by letting ui,..., uk be the first chain (so that u1 = u and uk = v, then letting uk+1 be the second element of the other chain, uk+2 be the third element, and so on, including all the elements of the second chain until the last one, which is w. This new chain establishes that Y(u, w) is true. It is valid because X(ui, ui+1) for every i in the new chain is given by the conditions for one or the other of the original chains.

For the second question, Y is not guaranteed to be antisymmetric even if X is. (Almost no one got this right, as most of you didn't recognize any difference between X and Y.) To show that there is no general rule, we just need one counterexample. Suppose that X(a, b), X(b, c), and X(c, a) are true, and that X is false for all other pairs. This relation is antisymmetric because we never have both X(u, v) and X(v, u) true at all, much less when u ≠ v. But Y(a, b) is true (by a chain of one link) and Y(b, a) is also true (by a chain of two links from b to c to a). Since a ≠ b, Y is not antisymmetric.

• (c, 10) Define the relation Z so that Z(u, v) means "(u = v) ∨ Y(u, v)". Prove carefully that if Y is antisymmetric, then Z is a partial order. Draw the Hasse diagram for the Z created from the X given in Question 2.

Again, while most of you recognized that you had to prove Z to be reflexive, symmetric, and transitive, few of you had valid proofs of these facts. Many of you assumed that if Y had these properties, Z must as well, which is true but requires proof. Many of you didn't even recognize any difference between Y and Z, just asserting that Y had the desired properties.

Z is reflexive because if u is an arbitrary dog, Z(u, u) is defined to be "(u = u) ∨ Y(u, u)", and this is true whether Y(u, u) is true or not. (A fair number of you had valid proofs for this.)

To prove that Z is antisymmetric, we let u and v be arbitrary dogs and assume that Z(u, v) and Z(v, u) are both true. We have the assumption that Y is antisymmetric, and we want to prove that u = v. Z(u, v) is defined as "(u = v) ∨ Y(u, v)". If u = v is true, we are done because that is our goal. If u ≠ v is true, then Y(u, v) must be true. Similarly, since Z(v, u) is true, if u ≠ v then Y(v, u) is true. By the antisymmetry of Y, Y(u, v) and Y(v, u) together imply u = v. So our assumptions give us u = v in either case, and we have proved the antisymmetry of Z.

To prove that Z is transitive, we let u, v, and w be arbitrary dogs and assume both Z(u, v) and Z(v, w). We want to prove Z(u, w), and part (b) of this problem tells us that Y is transitive. We have several cases based on whether u = v and whether v = w. Case 1 (u = v): in this case Z(u, w) follows from Z(v, w) by substitution. Case 2 (v = w): now Z(u, w) follows from Z(u, v) by substitution. Case 3 (u ≠ v ∧ v ≠ w): Now Z(u, v) can only be true because of Y(u, v), and Z(v, w) can only be true because of Y(v, w). So by transitivity of Y, Y(u, w) is true and by definition of Z this makes Z(u, w) true. Since we have proved our conclusion in each case and at least one of the three cases must be true, we have proved that Z is transitive.

The Hasse diagram for the dog set of Question 2 has four points, one each for a, b, c, and d. There is an inverted V shape including a, c, and d, with a above c and d (since c and d each have a path upward to a). The point for b has no edges to any other points, and can be put anywhere.

• (d, 10) Prove that Statements IV, V, and VI cannot all hold at the same time for the same relation X, by deriving a contradiction from the three of them.

• Question 4 (30+10): My dog Duncan needs a new case of canned food every 24 days and a new bag of dry food every 35 days.

• (a,5) Using the Euclidean Algorithm, show that 24 and 35 are relatively prime.

• 35 % 24 = 11
• 24 % 11 = 2
• 11 % 2 = 1
• Since the algorithm reaches 1, the two original numbers are relatively prime.

• (b,10) Find integers x and y such that 24x + 35y = 1.

• 35 = 0(24) + 1(35)
• 24 = 1(24) + 0(35)
• 11 = -1(24) + 1(35)
• 2 = 3(24) - 2(70) [The second row minus twice the third.]
• 1 = -16(24) + 11(35) [The third row minus five times the fourth.]

• (c,5) Quoting results from the course, determine how often I run out of canned food and dry food on the same day. (An arithmetic expression is enough -- you don't have to evaluate it.)

The Chinese Remainder Theorem says that when two periodic processes have relatively prime periods x and y, the combined process has a period of xy. In this case, the two processes synchronize every 24(35) = 840 days.

• (d,10) If I started a new case of canned food 6 days ago, and started a new bag of dry food 13 days ago, how many days will it be until I next run out of both kinds of food on the same day?

I will next run out of canned food in 24 - 6 = 18 days, and I will next run out of dry food in 35 - 13 = 22 days. The number x of days until I next run out of both satisfies the two congruences x ≡ 18 (mod 24) and x ≡ 22 (mod 35). The Chinese Remainder Theorem says that this pair of congruences is equivalent to the single congruence x ≡ (18)(11)(35) + (22)(-16)(24) (mod 840), using the coefficients found in part (b). This evaluates to 6930 - 8448 = -1518. To get the actual number of days we need to find the first positive natural that is congruent to this number mod 840. Adding 840's we get -678, then 162, which is the answer.

Several people got the correct answer by computing the days on which I run out of canned food (18, 42, 66, 90, 114, 138, 162, 186,...) and the days on which I run out of dry food (22, 57, 92, 127, 162, 197,...) and noting that 162 is the first number on both lists. This was an effective method if you were able to carry out about ten two-digit or three-digit additions all correctly. Of course you were luck the common solution came up early in the progress toward 840 -- it could have come anywhere in that interval.

• (e,10XC) Let S be the set of numbers {0, 1, 2,..., 34} and let the function f from S to S be defined by f(n) = (24n + 9) % 35, where "%" is the Java modular division operator. Explain carefully why we know that f is a bijection (both one-to-one and onto) and determine the inverse function for f.

We have argued that multiplying by z, modulo m, is a bijection if z and m are relatively prime. (This is the reason that a hash function that jumps z entries for every collision will eventually try all entries.) So if g(n) = 24n % 35, then g is a bijection. Our function f is the composition of this g with another function h(n) = n + 9, so that f(n) = h(g(n)). The function h is also a bijection because it has an inverse -- the function h-1(n) = n - 9 undoes h. (The fact that 9 is relatively prime to 35 is irrelevant -- the functions n + 7 and n - 7 are also inverses of each other.) So we are done because the composition of two bijections is a bijection.

We can also prove f to be a bijection just by computing its inverse, because only bijections can have inverses. If we let n be arbitrary and let y = f(n) = (24n + 9) % 35, we can get the inverse of f by solving for n in terms of y. We have that y - 9 ≡ 24n (mod 35), and we computed in part (b) that -16 is a multiplicative inverse of 24, modulo 35. So we have that -16(y - 9) ≡ -16(24n) ≡ n (mod 35). Letting g(y) be the function -16(y - 9), we have that g(f(n)) = -16(24n + 9 - 9) ≡ n (mod 35) and that f(g(y)) = 24(-16(y - 9)) + 9 ≡ y - 9 + 9 ≡ y (mod 35). So f and g are inverses, and f must be a bijection.