# Solutions to First Midterm Exam

### Directions:

• Answer the problems on the exam pages.
• There are six problems, some with multiple parts, for 100 total points plus 10 extra credit. Estimated scale A = 93, C = 69, but may be adjusted.
• Some useful definitions precede the questions below.
• No books, notes, calculators, or collaboration.
• In case of a numerical answer, an arithmetic expression like "217 - 4" need not be reduced to a single integer.

```  Q1: 15 points
Q2: 15 points
Q3: 15 points
Q4: 15 points
Q5: 10 points
Q6: 30+10 points
Total: 100+10 points
```

Question text is in black, solutions in blue.

Correction in orange made 25 February 2014.

• Question 1 (15): Translate each statement as indicated, using the set of dogs {Cardie, Duncan, Nala} (denoted by c, d, and n, with no two equal to one another), and the two predicates R(x, y) meaning "dog x is equal to or faster than dog y" and G(x, y) meaning "dog x's favorite dog is dog y".

• (a, 3) (to English) (Statement I) ∀x: R(n, x)

Nala is equal to or faster than every dog.

• (b, 3) (to symbols) (Statement II) There is a dog that Nala is equal to or faster than, and that dog is Nala's favorite dog.

∃x:R(n, x) ∧ G(n, x)

• (c, 3) (to symbols) (Statement III) Given any two dogs, if the second dog is not Cardie, then the first dog is equal to or faster than the second dog if and only if the first dog's favorite dog is not the second dog.

∀x:∀y:(y ≠ c) → [R(x, y) ↔ ¬G(x, y)]

• (d, 3) (to English) (Statement IV) ¬∃u:∃v:∃w:G(u, v) ∧ G(u, v) ∧ (v ≠ w)

No dog has two distinct favorite dogs. Or alternatively, the mapping from dogs to their favorite dogs is well-defined.

• (e, 3) (to symbols) (Statement V) It is not the case that if Cardie's favorite dog is Nala, then Duncan is equal to or faster than Nala.

¬[G(c, n) → R(d, n)]

• Question 2 (15): This question uses the definitions premises, and predicates from Question 1.

Prove from the premises that Nala's favorite dog is not Duncan. Use only the premises, not any inferences from the English meaning of the predicates. (Hint: This can be done by using Specification on Statements I and III, then just propositional logic.)

Specification from Statement I to x = d gives R(n, d).

Specification from Statement III to x = n and y = d gives (d ≠ c) → [R(n, d) ↔ ¬G(n, d)], which, since "d ≠ c" is true, implies R(n, d) ↔ ¬G(n, d). So ¬G(n, d) is true because R(n, d) is, and this is the desired statement.

• Question 3 (15): This question also uses the definitions, predicates, and premises from Question 1. Again, do not make any inferences from the English meaning of the predicates.

Prove from the premises that the relation G is a function from S to S.

A function must be total and well-defined. Statement IV is exactly the statement that G is well-defined. So it remains to prove only that G is total, meaning ∀x:∃y:G(x, y). We prove this by generalization, letting x be an arbitrary dog and breaking into three cases for the three possible values of x.

If x = n, Statement II tells us that R(n, z) ∧ G(n, z), and thus G(n, z) itself, is true for some dog z. So we are done with this case -- it turns out that z must equal c, but that doesn't matter for the proof.

If x = c, Statement V tells us that [G(c, n) → R(d, n)] is false, meaning that G(c, n) is true and R(d, n) is false. G(c, n) satisfies this case.

If x = d, we have ¬R(d, n) from Statement V as in the previous case. We also can specify x = d and y = n in Statement III to get (n ≠ c) → [R(d, n) ↔ ¬G(d, n)]. Since (n ≠ c) is true, we have R(d, n) ↔ ¬G(d, n) from which we can derive G(d, n) and finish this case. We have determined that Cardie and Duncan each have Nala as favorite dog, and that Nala has a favorite dog.

• Question 4 (15): This question uses the definitions from Question 1, but not the premises. For this question only, you may use the normal English meaning of "equal to or faster than". In addition, you may assume that given any two different dogs, one is faster than the other.

Yes, any dog is equal to itself and so R(x, x) is true for any x.

No, if we let x and y be any two different dogs, we are told that one is faster than the other, so say that R(x, y) is true by renaming if necessary. Given the English meaning of "faster", y cannot be faster than x, and R(y, x) is false. But symmetry would say that these two statements are both true or both false.

Yes, we are told above that of any two different dogs, one must be faster. As in (b), if R(x, y) is true R(y, x) must be false.

Yes, by the English meaning of "faster", if R(x, y) and R(y, z) are both true, then dog x is faster than or equal to dog y who is faster than or equal to dog z. If all three are equal, x = z. If any two are equal and the third different, one is x and one is z, and x is faster than z. If all three are different, x is clearly faster than z.

No, because it is not symmetric.

Yes, because it is reflexive, antisymmetric, and transitive.

• Question 5 (10): This question uses the definitions, predicates, and premises of Question 1. Do not use any inferences from the English meaning of the predicates. Assume the result of Question 3, so that G is a function. Given what you can determine from the premises:

• (a, 5) Is G a one-to-one function (an injection)? Explain your answer.

We showed in the answer to Question 3 that G(c, n) and G(d, n) are both true, which is a counterexample to the claim that G is one-to-one.

• (b, 5) Is G an onto function (a surjection)? Explain your answer.

Since the domain and range of G are the same size (since both are the same set S), G is one-to-one if and only it is onto, and it is not one-to-one, so it is not onto. Further examination shows that Duncan is not the favorite dog of any of the dogs in S.

• Question 6 (30+10): These four questions involve the natural numbers 24 and 35, which are unfortunately the same pair of numbers I chose for the Spring 2012 exam.

• (a, 10) Use the Euclidean Algorithm to show that 24 and 35 are relatively prime.

35 = 1*24 + 11

24 = 2*11 + 2

11 = 5*2 = 1

2 = 2*1 + 0

Since 1 is the last number appearing before 0, it is the gcd and these two numbers are relatively prime.

• (b, 10) Find integers x and y so such that 24x + 35y = 1. Once you have found those integers, give a multiplicative inverse of 24 (modulo 35) and a multiplicative inverse of 35 (modulo 24).

35 = 1*35 + 0*24

24 = 0*35 + 1*24

11 = 1*35 - 1*24

2 = -2*35 + 3*24

1 = 11*35 - 16*24

The inverse of 24 is -16 (or 19), modulo 35.

The inverse of 35 is 11, modulo 24. (Since 35 ≡ 11, this means that 11 is its own inverse modulo 24.)

• (c, 10) Suppose that I know, for some integer x, that x ≡ 2 (mod 35) and that x ≡ 3 (mod 24). State clearly what the Simple Form of the Chinese Remainder Theorem tells us about x.

The Simple Form says that there is some number c such that both congruences are satisfied if and only if x ≡ c (mod 35*24). Thus we know that this x must be congruent to that particular c, modulo 35*24 = 840.

• (d, 10XC) Find an integer x such that x ≡ 2 (mod 35) and that x ≡ 3 (mod 24). (Hint: Your answer to part (b) should be useful, though if you have time you might be able to find the number by trial and error.

We found in part (b) that 11*35 - 16*24 = 1. If we take 3*11*35 - 2*16*24, we find that this number is congruent to 3*1 + 0, modulo 24, since 11*35 ≡ 1 (mod 24). This same number is congruent to 0 + 2*1, modulo 35, since -16*24 ≡ 1 (mod 35). It wasn't necessary for full credit, but we can calculate this number as 1155 - 768 = 387. We thus know that x ≡ 387 (mod 840).