# Solutions to First Midterm Exam Spring 2016

### Directions:

• Answer the problems on the exam pages.
• There are six problems, some with multiple parts, for 100 total points plus 10 extra credit. Actual scale A = 88, C = 58.
• 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: 20 points
Q2: 20 points
Q3: 10 points
Q4: 20 points
Q5: +10 points
Q6: 30 points
Total: 100+10 points
```

Question text is in black, solutions in blue.

Here are definitions of sets, predicates, and statements used on this exam.

Remember that the score of any quantifier is always to the end of the statement it is in.

Let D be a finite set of dogs consisting of exactly the four distinct dogs Cardie (c), Duncan (d), Mia (m), and Scout (s).

Let N be the set of natural numbers {0, 1, 2, 3,...}.

There are three owners O1, O2, and O3.

Let BT(u, n) be the relation from D to N defined so that BT(n, u) means "dog u belongs to owner On".

Let E be the binary relation on D defined so that E(u, v) means "dog u goes out earlier than dog v".

Let Y be the binary relation on D defined so that Y(u, v) means "dog u is younger than dog v". You may assume that no two dogs in D are exactly the same age.

Some of the true/false questions also refer to an arbitrary set D of dogs with predicates T(x) meaning "dog x is a terrier" and S(x, y) meaning "dog x is sillier than dog y".

• Question 1 (20): Translate each statement as indicated, using the set of dogs D = {c, d, m, s}, the set of naturals N, the "belongs to" predicate BY(u, n). the "earlier" predicate E(u, v), and the "younger" predicate Y(u, v). All these are defined above.

• (a, 2) (to English) (Statement I) (E(c, d) ∨ E(d, c)) → Y(m, d)

If either Cardie or Duncan goes out earlier than the other, then Mia is younger than Duncan.

• (b, 3) (to symbols) (Statement II) Mia is younger than Cardie, and if either Cardie or Duncan goes out earlier than the other, then Mia is not younger than Duncan.

Y(m, c) ∧ ((E(c, d) ∨ E(d, c)) → ¬Y(m, d))

Many people misparsed this and made Y(m, c) part of the premise of the if-then. The placement of the word "if" in the English should make it clear that the statement is saying that Y(m, c) is unconditionally true.

• (c, 2) (to English) (Statement III) ¬(Y(m, c) ∧ Y(m, d)) → (E(c, d) ⊕ E(d, c))

If it is not the case that Mia is younger than both Cardie and Duncan, then either Cardie goes out earlier than Duncan or Duncan goes out earlier than Cardie, but not both.

Again, many people placed the "if" incorrectly -- the parentheses make it clear here that the ¬ modifies the premise of the if-then and not the entire if-then. Also, the "but not both" is necessary at the end to represent the ⊕. Given the English meaning of "earlier", it is impossible for both to be true, but we don't take acocunt of English meaning of predicates when we do translations.

• (d, 3) (to symbols) (Statement IV) The relation Y is antireflexive and antisymmetric.

[∀x:¬Y(x, x)] ∧ [∀x:∀z:(Y(x, z) ∧ Y(z, x)) → (x = z)]

Many people correctly reused the quantifier between the two definitions. Many people said "Y(x, z) → ¬Y(z, x)" instead of the given implication -- this is not a correct definition of "antisymmetric" in general, but is correct when the relation is also antireflexive, so I accepted this answer.

• (e, 2) (to English) (Statement V) ∀u:∀v: E(u, v) ↔ [∃i:∃j: BT(u, i) ∧ BT(v, j) ∧ (i < j)]

For any two dogs, one goes out earlier than the other if and only if they each have an owner such that the earlier dog's owner has a smaller number.

Note that the literal translation is "there exists naturals i and j" rather than "there exists owners i and j", though I did not take off for this type error.

• (f, 3) (to symbols) (Statement VI) Every dog has exactly one owner, and O3 owns exactly one dog.

[∀u:&exists;n: BT(u, n)] ∧ [∀u:∀n:∀n': (BT(u, n) ∧ BT(u, n')) → (n = n')] ∧ [∃u: BT(u, 3)] ∧ [∀u:∀v: (BT(u, 3) ∧ BT(v, 3)) → (u = v)]

This was really a pretty difficult translation, since in both clauses you need to say both "at least one" and "at most one" in order to convey the meaning of "exactly one". Many people said only one or the other. It was possible to reuse quantifiers between clauses.

• (g, 2) (to English) (Statement VII) ∀x: (x ≠ s) ↔ (E(s, x) ∧ Y(s, x))

Any dog is different from Scout if and only if Scout both goes out earlier than it and is younger than it. (Equivalently, Scout is the earliest and the youngest dog, with no ties.)

• (h, 3) (to symbols) (Statement VIII) There is a dog u such that for any dog v, v is younger than u if and only if v is Scout. (Equivalently, Scout and only Scout is younger than u.)

∃u:∀v: Y(v, u) ↔ (v = s)

Most people got this right, perhaps because the syntax of the English is closer to the symbolic syntax. Many people had → in place of the ↔.

• Question 2 (20): The following are ten true/false questions, with no explanation needed or wanted, no partial credit for wrong answers, and no penalty for guessing. They use the sets and relations defined above. Many depend as well on the statements I through VIII given in Question 1.

• (a) If we know that p → q is true, and r is any proposition at all, then (p ∨ r) → q must be true.

FALSE. If p and q are false, but r is true, then the first statement is true but the second is false. You cannot use the Rule of Joining inside a statement becuase it is a deductive rule, not an equational rule. In this case it is effectively inside a negation because of the →.

• (b) If we know that p is true, and r is any proposition at all, then p ∨ r must also be true.

TRUE. This is an instance of the Rule of Joining.

• (c) The relation BT is a function from D to N, assuming that Statements I-VIII are all true,

TRUE. Statement VI's first clause says that every dog has one owner, which is exactly what it means for BT to be a function.

• (d) The relation BT from D to N is neither onto nor one-to-one, assuming that Statements I-VIII are all true.

TRUE. Since BT maps four dogs to three owners, it is clearly not one-to-one. But most people (I conjecture) overlooked the fact that BT is a function not to owners but to naturals, and it is not onto the naturals because no dog is mapped to 0, 4, 5, 6, etc.

• (e) Define the relation Y' by the rule Y'(u, v) ↔ ((u = v) ∨ Y(u, v)). Then Y' is a total order on D, assuming the English meaning of "younger" and that no two dogs are exactly the same age.

TRUE. Y' is clearly reflexive, and it is antisymmetric because Y is. Its transitivity and totality come from the English meaning of "younger" and the fact that no two dogs are the same age.

• (f) Define the relation E' by the rule E' (u, v) ↔ "dog u goes out either earlier than dog v or at the same time". Then E' is a partial order on D, assuming the English meaning of "earlier" and the truth of Statements I-VIII.

FALSE. It is clearly reflexive by the definition, and it is and transitive by the English meaning. But we know from Statements I-III that Cardie and Duncan go out at the same time, so E'(c, d) and E'(d, c) are both true. This violates antisymmetry.

• (g) If u and v are any two binary strings, and u is a prefix of v, then uR is a suffix of vR. (Here uR denotes the reversal of u.)

TRUE. Since u is a prefix of v, v = uw for some string w. By a fact we stated in lecture, vR = wRuR, so uR is a suffix of vR by the definition of suffix.

• (h) Consider the statement ∀x: ¬T(x) → S(x, d), meaning "every non-terrier is sillier than Duncan". If there exists any terrier in the set of dogs, then this implication is true because its premise "∀x: ¬T(x)" is false.

FALSE. It's certainly possible that there exists a terrier and no non-terriers, and in this case the given implication is true. The error comes in misparsing the statement by treating the quantifier as part of the premise, rather than referring to the entire statement. Remember that the scope of a quantifier is always to the end of its statement (which is the end of any parentheses enclosing it).

• (i) If the statements "all terriers like snacks" and "all dogs who are not terriers like snacks" are both true, then the statement "all dogs like snacks" must be true.

TRUE. We can prove this by cases: Let x be an arbitrary dog and specify both premises to x. We then know by cases that x likes snacks whether it is a terrier or not, so by generalization all dogs like snacks.

• (j) If x and y are naturals, and 143 divides the product xy, then 143 must also divide either x or y (or both).

FALSE. Let x be 11 and y be 13. Clearly 143 divides neither of these, but since xy = 143 it does divide xy. If we replaced 143 with a prime number, the implication would be true by the Atomicity Lemma, but that lemma does not apply to composite numbers.

• Question 3 (10): This question uses the sets, definitions, and predicates above, and the statements from Question 1.

(Note: The point value of Questions 3 was given as 15 on the test paper, though it was correct on page 2.)

From Statements I, II, and III, there is only one possible setting of the truth values of the four propositions Y(m, c), Y(m, d), E(c, d), and E(d, c). Determine this setting and show that it is the only setting that works. You may use either a truth table or a deductive argument.

The deductive argument is easier. If we assume (E(c, d) ∨ E(d, c)), we get Y(m, d) by Statement I and ¬Y(m, d) by the second clause of Statement II. This is a contradiction, so (E(c, d) ∨ E(d, c)) must be false, and both E(c, d) and E(d, c) are false.

Y(m, c) is true by the first clause of Statement II, so the only question is that of Y(m, d). Since E(c, d) and E(d, c) are both false, the conclusion of Statement III is false, and so its premise must be false. This makes Y(m, c) and Y(m, d) both true.

The truth table is greatly simplified if you note that Y(m, c) must be true, so you need only eight lines rather than 16.

Many people got the wrong answer because of bad translations, usually winding up with four out of ten points.

• Question 4 (20): This question also uses the sets, definitions, and predicates from above and the statements from Question 1.

Prove, using any or all of Statements I through VII, that Statement VIII is true. Do not assume anything about the English meaning of the predicates, except what you are given in the statements. Make your use of quantifier proof rules clear.

Since the statement to be proved is existential, our last move is going to be Existence. We need to determine, before beginning our proof, which dog is the right choice for u. If Scout were u, she would be required to be younger than herself, which is impossible. If u is any other dog, Scout will be younger than u by Statement VII, which is good. But we also need the other dogs who are not Scout to not be younger than u. So u must be the second-youngest dog in D. We know from Statements I-III that Mia is younger than both Cardie and Duncan, so Mia is the dog we need.

Note: If we were allowed to use the English meaning of "younger", we would know that there must be a second-youngest dog and we could use this for u. But we are explicitly told to use only the statements, which don't (for example) say that Y is transitive.

Once we know that u should be Mia, we can let v be an arbitrary dog and try to prove the statement "Y(v, m) ↔ (v = s)". We do this by cases.

• If v is Scout, then Y(v, m) is true by specificying Statement VII to x = m. This is good because in this case v = s is true.
• If v is Mia, Y(v, m) is false because Y is antireflexive from Statement IV, which is good because Mia is not Scout.
• If v is either Cardie or Duncan, we know Y(m, v) from Statements I-III, which means that Y(v, m) is false because Y is antisymmetric from Statement IV. And this is good because in these cases v = s is false.

We have proved ∀v: Y(v, m) ↔ (v = s), and our desired statement follows by Existence.

The majority of purported proofs for this were very bad, not even beginning to approach the problem correctly. Some people wrote down the conclusion and began deriving consequences of it, which is quite backward. I did give a lot of partial credit for the "there must be a second-yougest dog" argument.

• Question 5 (10XC): This question also uses the sets, definitions, and predicates from above and the statements from Question 1.

Assuming the truth of Statements I-VIII, determine which owner owns which dog, and determine the value of the predicate E(u, v) for all possible pairs of dogs u and v. Make your use of quantifier proof rules clear.

Clearly the key statement is VI, which says that a dog goes out earlier than another if and only if it has an owner with a smaller number. We know that O3 has exactly one dog, that Cardie and Duncan go out at the same time, and that Scout goes out earlier than any dog except herself.

Scout's owner cannot own any other dog because Scout would then not be earlier than that dog. And Scout's owner cannot be O3 because no dog has a larger-numbered owner than that. Scout's owner must be O1 or O2, and if it is O2 there is only one dog (O3's) who goes out after Scout (but there need to be three). So Scout's owner is O1, and since O3 owns one dog we know that O2 owns two. These two must be Cardie and Duncan, since they have the same owner, and so O3 must own Mia.

The instances of E that are correct are E(s, m), E(s, c), E(s, d), E(c, m), and E(d, m). That is, Scout is earlier than all three other dogs, and Cardie and Duncan are earlier than Mia.

Readers of past exams might have been tempted to conclude that Cardie and Duncan have the same owner because those are the names of my two dogs. But such readers may also have noticed that there is more than one dog named Duncan in my neighborhood, and I never said that this Duncan was mine. In any case, Statements I-III legitimately tell you that they have the same owner.

• Question 6 (20+10): Here are some straightforward number theory questions.

• (a, 5) Give prime factorizations of the naturals 14, 16, 21, and 24.

14 = 2*7, 16 = 2*2*2*2, 21 = 3*7, and 24 = 2*2*2*3. I deducted a point if you included 1 as a factor, because 1 is not a prime number.

• (b, 5) Based on your prime factorizations, explain which of the four numbers in part (a), if any, have inverses modulo which of the others.

Numbers have inverses modulo one another if and only if they are relatively prime. Thus 16 and 21 have inverses modulo one another, but every other pair of numbers share at least one prime factor and so are not relatively prime. I deducted two points if you said that 16 had an inverse modulo 21 but neglected to say that 21 has an inverse modulo 16. I did not take off if you used the Euclidean Algorithm rather than the factorizations to get the correct statements about relative primality.

• (c, 10) Find an inversse of 28. modulo 39, and an inverse of 39, modulo 28. Be sure to make clear which is which.

• 39 = 1*39 + 0*28
• 28 = 0*39 + 1*28
• 11 = 1*39 - 1*28
• 6 = -2*39 + 3*28 (subtracting two 11's from 28)
• 5 = 3*39 - 4*28
• 1 = -5*39 + 7*28 (check: -195 + 196)

The inverse of 39, modulo 28, is -5 (or 23).

The inverse of 28, modulo 39, is 7.

• (d, 10XC) Find which naturals x satisfy both the congruences x ≡ 25 (mod 28) and x ≡ 20 (mod 39). You may give an arithmetic expression in your answer without resolving it to an explicit integer.

The Simple Form of the Chinese Remainder Theorem says that this pair of congruences is equivalent to a single congruence of the form x ≡ c (mod 28*39). We established in part (c) that 28 and 39 are relatively prime. I gave four points for simply stating this result, and took off those same four points if your answer was a single number rather than a congruence class.

A naive, but in this case effective, way to find c is to list numbers that are congruent to 25 mod 28: 25, 53, 81, 109, 137, 165,.., and numbers that are congruent to 20 mod 39: 20, 59, 98, 137, 176,..., and notice that 137 is on both lists. The set of x such that x ≡ 137 (mod 28*39) is thus the answer.

The standard way to find c is to take the linear combination -5*39 + 7*28 from part (c), which we know is congruent to 1 both mod 28 and mod 39. By multiplying the first term by 25, we do not change the answer mod 39 but multiply the mod 28 answer by 25. Similarly we get the right answer mod 39 by multiplying the second term by 25. Our expression for c is thus -5*39*25 + 7*28*20. You were not required to evaluate this, but it turns out to be -4875 + 3920 = -955. Since 28*39 = 1092, this is equivalent to -955 + 1092 = 137, the answer we got by our first method. Again, it was important to say "x ≡ c (mod 28*39)" rather than just offering the single number c as your answer. If you got incorrect inverses in (c) but used them in (d) in such a way that you would have been right with the right inverses, I gave you full credit for (d). If you said "I need inverses" but didn't note that you had them in (c), I took off points.