# Solutions to First Midterm Exam Spring 2018

### Directions:

• Answer the problems on the exam pages.
• There are four problems, each with multiple parts, for 110 total points. Actual scale A = 95, C = 65.
• 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: 30 points
Q3: 30 points
Q4: 20+10 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 S be a finite set of dogs consisting of exactly the six distinct dogs Cardie (c), Duncan (d), Guinness (g), Maya (m), Nina (n), and Rio (c).

Let B be a finite set of breeds consisting of exactly the six breeds Collie (C), Mastiff (M), Poodle (P), Retriever (R), Terrier (T), and Weimeraner (W).

Let NL be the binary relation on S defined so that NL(x, y) means "dog x is no larger than dog y". We will also sometimes translate NL(x, y) as "dog y is no smaller than dog x". Although I didn't say this on the actual test, I should have encouraged you to translate ¬NL(x, y) as "dog x is larger than dog y" or "dog y is smaller than dog x".

Let f be the function from S to B defined so that "f(x) = b" means "the breed of dog x is b".

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

If a, b, and m are naturals, with m > 0, the notation "a ≡ b (mod m)" means "a is congruent to b, modulo m".

• Question 1 (20): Translate each statement as indicated, using the set of dogs S = {c, d, g, m, n, r}, the set of breeds B = {C, M, P, R, T, W}, the predicate NL(x, y) meaning "dog x is no larger than dog y" or "dog y is no smaller than dog x", and the function f from S to B defined so that f(x) is the breen of dog x. Note that variables and constants in small letters are of type "dog", and those in capital letters are of type "breed".

• (a, 2) (to symbols) (Statement I) It is not the case that if Duncan is no larger than Rio, then either Maya is no larger than Nina or Guinness is no larger than Cardie.

¬(NL(d, r) → (NL(m, n) ∨ NL(g, c))). The outer pair of parentheses is important because the English says "it is not the case that if" and not "if it is not the case".

• (b, 2) (to English) (Statement II) ¬(NL(m, n) ∨ ¬(¬NL(g, c) ∧ NL(d, r)))

The most literal translation would be "It is not the case that either Maya is no larger than Nina or that it is not the case that Guinness is not no larger than Cardie and Duncan is no larger than Rio". I should have encouraged you to say "larger" for "not no larger", and many of you did this anyway. Many of you also applied some equivalence rules to get a simpler symbolic sentence before translating, doing part of the work of Question 2a here.

• (c, 4) (to symbols) (Statement III) The relation NL is a total order. (This should be the AND of four quantified statements, one for each defining property of a total order.

This could be done either by taking the AND or four quantified statements, or using the same quantifiers for all four statements (since all the quantifiers are universal). The latter gives:

∀x:∀y:∀z:NL(x, x) ∧ ((NL(x, y) ∧ NL(y, x)) → (x = y)) ∧ ((NL(x, y) ∧ NL(y, z)) → NL(x, z)) ∧ (NL(x, y) ∨ NL(y, x).

Many of you gave the formula for "total" relations that is part of the definition of a function, but that is not the same as the "total" property that makes a partial order into a total order. Some of you gave the defintion of "symmetric" rather than (or in addition to) the one for "antisymmetric".

• (d, 2) (to English) (Statement IV) ∃x: (f(x) = M) ∧ ∀y: NL(y, x)

"There is a mastiff such that all dogs are no larger than it," or "The largest of the dogs is a mastiff."

• (e, 3) (to symbolx) (Statement V) Duncan is the one and only dog who is both no larger than Rio and no smaller than Nina.

∀x: (NL(x, r) ∧ NL(n, x)) ↔ (x = d). I took off one point for the wrong quantifier and one for not having the ↔ operator. The English says two things, that Duncan has these two properties and that no other dog has both of them. The ↔ is the simplest way to say both, though there are others.

• (f, 3) (to English) (Statement VI) ∀x: (∃y: (f(x) = f(y)) ∧ (x ≠ y)) ↔ ((x = m) ∨ (x = n))

"For any dog, there is a different dog of the same breed if and only if the first dog is Maya or Nina," or "Maya and Nina each share a breed with a different dog, and no other dogs do," or even "Maya and Mina are the same breed, and all the other dogs are the only ones of their breed".

• (g, 4) (to symbols) (Statement VII) Every dog is no smaller than some poodle, and every dog is neither Cardie nor Guinness if and only if it is no larger than some poodle.

∀x: ∃y:(f(y) = P) ∧ (NL(y, x)) ∧ (((x ≠ c) ∧ (x ≠ g)) ↔ ∃z: NL(x, z) ∧ (f(z) = p))

The most common mistake here was to use only a single existential quantifier, making the two "some poodles" in the English statement necessarily the same dog y. But this can't work even if all the dogs are poodles, since by Statement III no dog who isn't y can be both no larger and no smaller than y. There have to be at least two poodles. Other mistakes included saying "NL(P, x)", which is a type error since P is a breed and NL's arguments are both dogs. Some people got it right by writing the entire statement as the AND of two statements, each with its own existential quantifier. That way, even if the two variables are both y, there is no requirement that the two poodles be the same dog.

• Question 2 (30): These questions use the sets, definitions, and predicates above, and the statements from Question 1.

• (a, 10) Prove that Statements I and II are logically equivalent to one another. You may use a truth table, an equational sequence proof, or two deductive sequence proofs. You may find it useful to abbreviate the three propositions involved as p, q, and r.

The truth table shows that each statement is true in only one of the eight situations, the one where NL(d, r) is true and the other two are false.

There were several ways to carry out a short equational sequence proof. The simplest thing is to show that each statement is equivalent to NL(d, r) ∧ ¬NL(g, c) ∧ ¬ NL(n, m) or "p ∧ ¬q: ∧ ¬r".

• Statement I: ¬(p → (q ∨ r))
• (by Definition of Implication) ¬ (¬p ∨ (q ∨ r))
• (by Associativity) ¬(¬p ∨ q ∨ r)
• (by DeMorgan) p ∧ ¬q ∧ ¬r

• Statement II: ¬(r ∨ ¬(¬q ∧ p))
• (by DeMorgan) ¬(r ∨ (q ∨ ¬p))
• (by Associativity) ¬ (r ∨ q ∨ ¬p)
• (by DeMorgan) ¬r ∧ ¬q ∧ p
• (by Commutativity) p ∧ ¬q ∧ ¬r

• (b, 10) Assuming that Statements I-VII are all true, prove that Cardie is neither a Poodle nor a Mastiff. You may use either English or symbols, but make it clear each time you use a quantifier proof rule. Proof by Contradiction is probably the most natural overall strategy to use.

We need to derive a contradiction from "(f(c) = M) ∨ (f(c) = P)". We can use Proof by Cases, first getting a contradiction from the assumption that Cardie is a Mastiff, then starting over and getting one from the assumption that she is a Poodle.

Assume f(c) = M. Applying Instantiation to Statement IV, we get that there is a dog a such that f(a) = M and NL(y, a) is true for every dog y. We do not get that Cardie is this dog from Statement IV alone -- probably a majority of you made this mistake. We can specify Statement VI to Cardie, to get that she is the only dog of her breed (since she is neither Maya nor Nina). Once we have established that she is the dog a from VI, we get a contradiction because Statements I and II imply that NL(g, c) is false, while it would have to be true by Specification if ∀y:NL(y, c) were true.

Now assume that f(c) = P. If we again observe from VI that Cardie must now be the only Poodle, there are lots of contradictions available. But claiming that she is the only Poodle without invoking VI is a mistake. Even without VI, we can specify the second half of VII to Cardie, getting ((c ≠ c) ∧ (c ≠ g)) ↔ ∃z:(f(z) = P) ∧ NL(c, z). Since the first half of the ↔ is false (since Cardie is Cardie), we may conclude the negation of the second half which is ∀z: (f(z) ≠ P) ∨ ¬ NL(c, z), or equivalently ∀z: (f(z) = P) → ¬ NL(c, z). Specifying this statement to Cardie, we get f(c) = P → ¬NL(c, c). But we are assuming that f(c) = P is true, and NL(c, c) is true by Specification on the reflexity clause of Statement III. So we have a contradiction.

• (c, 10) Assuming that Statements I-VII are all true, determine the complete order of the six dogs according to size. (That is, give enough information to determine whether NL(x, y) is true for each x and y in S.) Explain your reasoning clearly, either in English, symbols, or a combination.

I think the best way to start is to look at Statement VII. As we observed above, it says that every dog except Cardie and Guinness is between two Poodles in size, and that every dog is no smaller than some Poodle. Since there are at least two Poodles, we can tell from Statement VI that these must be Maya and Nina, and that in fact there are exactly two Poodles and four other dogs each with different breeds. Since Statements I and II imply that NL(m, n) is false, Nina must be the smaller Poodle and the smallest dog, and Maya must be the larger Poodle and the third-largest dog, smaller only than Cardie and Guinness. Statements I and II also tell us that NL(g, c) is false, so that Guinness must be the largest dog (and the only Mastiff) and Cardie is second-largest. Finally, we know that NL(d, r) is true from I and II, so Rio must be the larger of the two dogs between the Poodles. So from larger to smaller we have Guinness, Cardie, Maya, Rio, Duncan, and Nina.

Note that I didn't use Statement V at all, meaning that it is implied by the other statements. Many of you used it (correctly) in combination with I and II to get that Maya must be larger than Rio, because otherwise she would be a second dog between Nina and Rio in size. So I, II, and IV give "n < d < r < m" and "c < g", but you need to use VII to justify the claim that Maya is smaller than Cardie.

• Question 3 (30): The following are fifteen true/false questions, with no explanation needed or wanted, no partial credit for wrong answers, and no penalty for guessing. Some use the sets, relations, and functions defined above, but you should assume the truth of Statements I-VII only if explicitly told to. Two points for each correct answer.

• (a) Assuming that Statements I-VII are all true, the function f is not one-to-one.

TRUE. As we observed, there are two Poodles and hence each dog is not mapped to a different breed. Statement VI tells us directly that two dogs share a breed, though not which breed.

• (b) Assuming that Statements I-VII are all true, the function f is not onto.

TRUE. Since |S| = |B|, we know that (a) and (b) must have the same answer. Since there are two Poodles, at most five of the six breeds can be represented by a dog. (Statement VI tells us that there are exactly five breeds represented.)

• (c) Assume for this question only that Cardie is a Retriever and that Duncan is a Terrier. Then Statements I-VII determine the breed of each of the other dogs.

FALSE. We know from the analysis in Question 2 that Maya and Nina are Poodles and the Guinness is a Mastiff. But Rio could be either a Collie or a Weimeraner, and the statements give no evidence as to which.

• (d) The staetment "f is one-to-one" means that each dog has exactly one breed.

FALSE. It is the fact that f is a function that implies that each dog has exactly one breed. If f were one-to-one, then each breed would be represented by at most one dog.

• (e) Every total order is also a partial order.

TRUE. A total order is a partial order that also has the totality property ∀x:∀y:R(x, y) ∨ R(y, x).

• (f) The string "ababbabababb" is in the Kleene star of the language {ab, abb}.

TRUE. This string can be written as the concatenation of five strings, each of which are "ab" or "abb".

• (g) Let u and v be nonempty strings over the alphabet {0, 1}. If u is both a prefix and a suffix of v, then it must be equal to v.

FALSE. We could let u = "0" and v = "010".

• (h) Let I be an implication, that is, a statement of the form p → q. If I and its contrapositive are both true, then its converse and inverse must also both be true.

FALSE. I and its contrapositive always have the same truth value. The converse and inverse have the same truth value as one another, but not necessarily the same value as I itself. For example, I could be "0 → 1" which is true, while its converse "1 → 0" is false.

• (i) If I have a statement "∃x: P(x)", then the Rule of Instantiation allos me to conclude "P(a)", where a is any element of the type of x.

FALSE. This is the very error that so many of you made on Question 2 (b), where you went from "There is a Mastiff who is the largest dog" to "Cardie is a Mastiff who is the largest dog". When we use Instantiation to go from an existentially quantified statement to an unquantified statement, the latter is about an unidentified element, about which we know only the type.

• (j) Let A = {1, 2, 3} and let R be an equivalence relation on A. Then R cannot be antisymmetric.

FALSE. The identity relation {(1, 1), (2, 2), (3, 3)} is both an equivalence relation and antisymmetric. The identity relation is the only relation that has all four properties and is thus both an equivalence relation and a partial order.

• (k) Let A = {1, 2, 3} and let R be an equivalence relation on A. Then the number of pairs (x, y) in R must be either three, five, or nine.

TRUE. R must contain (1, 1), (2, 2), and (3, 3) by reflexivity. The other six pairs are paired up by symmetry, so that we have (x, y) in R if and only if we have (y, x). This means that R must have 3, 5, 7, or 9 pairs in it. But 7 is impossible, because if we have two of the pairs (1, 2), (1, 3), and (2, 3), we must have the third by transitivity.

• (l) If x is an odd natural greater than 1, then x can be written as the product of one or more odd primes (if we are allowed to use the same prime more than once).

TRUE. The FTA tells us that there is a factorization of x into primes, which must include at least one prime because x is greater than one. All this primes must be odd because if any of them were 2, x would be even.

• (m) Any positive natural n can be written as a product xyz where the naturals x, y, and z are pairwise relatively prime.

TRUE. We can take x and y each to be 1, and z to be n. Because 1 is relatively prime to any positive natural, these three numbers are pairwise relatively prime. Nothing in the statement forced x, y, and z to be different, or prevented any of them from being 1.

• (n) Let x, y, and z, be positive naturals, with z > 1. If neither x nor y is divisible by z, then neither x + y nor xy is divisible by z.

FALSE. The first claim fails for any z, as we could take x = 1 and y = z - 1. The second is true if z is prime, but not if z is composite. For example, we could have x = 2, y = 3, and z = 6. Any counterexample to either claim makes the entire statement false.

• (o) If x, y, and z are three odd naturals each greater than 1, then the number xyz + 4 is not divisible by any of x, y, or z.

TRUE. The remainder when we divide xyz + 4 by x, y, or z will be the same as the remainder when we divide 4 by that number. But 4's only divisors are 1, 2, and 4, none of which is an odd number greater than 1.

• Question 4 (30): Here are some straightforward number theory questions.

• (a, 5) Explain why every odd natural is relatively prime to 32.

Two naturals are relatively prime if there is no prime that occurs in both of their prime factorizations. Since 32 = 25, the only prime occurring in its factorization is 2. And 2 does not occur in the factorization of any odd natural, by the definition of oddness.

• (b, 5) Is there a composite number strictly between 10 and 20 that is relatively prime to both 32 and 51? Explain your answer.

There is no such number. The even numbers in the range all share 2 as a factor with 32. Of the odd number in the range, 15 and 17 share factors with 51 and the other three (11, 13, and 19) are prime. We can avoid the case breakdown by noting the the smallest composite number that does not include 2 or 3 in its factorization is 25.

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

• Euclidean Algorithm: 51 = 1(32) + 19
• 32 = 1(19) + 13
• 19 = 1(13) + 6
• 13 = 2(6) + 1
• 6 = 6(1) + 0

• Linear combinations:
• 51 = 1(51) + 0(32)
• 32 = 0(51) + 1(32)
• 19 = 1(51) - 1(32)
• 13 = -1(51) + 2(32)
• 6 = 2(51) - 3(32)
• 1 = -5(51) + 8(32) = -255 + 256
• -5 (or 27) is an inverse of 51, modulo 32
• 8 is an inverse of 32, modulo 51

• (d, 10XC) Someone on the internet calling themself "Mr. Rabbit" has agreed to sell me a file of government secrets for \$100. However, Rabbit will accept payment only in two obscure cryptocurrencies: Batcoins (currently worth \$51 each) and Twitcoins (currently worth \$32 each). For technical reasons, Batcoins and Twitcoins cannot be broken up into fractions like Bitcoins -- each coin must be transferred entirely or not at all. Both Rabbit and I have plenty of each kind of coin. How can I pay Rabbit exactly \$100 by transferring integer numbers of Batcoins and/or Twitcoin from me to Rabbit and/or from Rabbit to me?

The key insight here is that we want to express 100 as an integer linear combination of 51 and 32. So we don't neet the CRT as such, just the last equation from the Inverse Algorithm that tells us 1 = -5(51) + 8(32). Multiplying this equation by 100 gives us 100 = -500(51) + 800(32). Thus if I give Rabbit 800 Twitcoins and receive 500 Batcoins in return, his net gain is 25600 - 25500 = 100. (This is why I specified that we each had plenty of coins on hand.)

Some of you simply looked for a smaller solution by brute force, which was a reasonable plan if you could do the arithmetic correctly. Listing multiples of 51 and 32, you might notice that 12(51) = 612 and 16(32) = 512, so that I could pay Rabbit 12 Batcoins and receive 16 Twitcoins in return.

It is possible to use the CRT to get the right answer. A natural CRT question might be to find a number congruent to 100 both modulo 51 and modulo 32. Of course 100 is such a number already, but if you, say, use the CRT to find a number congruent to 49 (mod 51) and to 4 (mod 32) you get (4)(-5)(51) + (49)(8)(32). I could pay Rabbit this number by giving him 392 Twitcoins and getting back 20 Batcoins, but I have now paid him \$100 plus some multiple of (32)(51). If I figure out what multiple that is (which is the integer part of (12544 - 1020)/1632, or 7), I could have Rabbit give me back either 224 Batcoins or 357 Twitcoins and we would be done. This works out to my given him 35 Twitcoins (worth \$1120) and getting back 20 Batcoins (worth \$1020), netting him \$100 as desired.