# Solutions to First Midterm Exam

#### 25 February 2015

Question text is in black, solutions in blue.

### 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 = 93, 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: 20 points
Q3: 10 points
Q4: 15 points
Q5: 15 points
Q6: 20+10 points
Total: 100+10 points
```

Correction in orange made 23 February 2016.

Here are definitions of sets, predicates, and statements used in Questions 1-5 on this exam.

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

Last week my young neighbor Marisol invited a set D of six dogs to a Pet Competition. The dogs were Arlie (a), Cardie (c), my Duncan (d), another Duncan (d'), Honey (h), and Whistle (w).

Let Σ be the alphabet {a, b, c,..., z} and recall that Σ* is the set of all strings with letters in Σ.

The relation N ⊆ D × Σ* is {(x, y): the name of dog x is string y}. The names of the six dogs are thus "arlie", "cardie", "duncan", "duncan", "honey", and "whistle".

The relation R ⊆ D × D is {(x, y): either dogs x and y have the same name or x's name comes before y in alphabetical order}.

The relation S ⊆ D × D is {(x, y): x and y are dogs and R(x, y) and R(y, x) are both true}.

The relation GT ⊆ D is {x: x is a dog and x got a treat}.

Let B be the set of breeds {p, r, s, t} or {Poodle, Retriever, Setter, Terrier}. Let the relation IB ⊆ D × B be {(x, y): dog x is of breed y}. Assume that this relation is a function from D to B. (Hence every dog is of exactly one breed.)

The relation SB ⊆ D × D is {(x, y): ∃b: IB(x, b) ∧ IB(y, b)}.

The Pet Competition had three events: Best Dressed (BD), Cleverest Trick (CT), and Fastest Dog (FD). Let E be the set {BD, CT, FD}.

The relation WB ⊆ E × D is {(y, z): event y was won by dog z}. Assume that this relation is a function from E to D, so that every event was won by exactly one dog.

• Question 1 (20): Translate each statement as indicated, using the set of dogs D, the set of breeds B, the set of events E, and the various predicates defined above. GT(x) means "x got a treat", IB(x, y) means "dog x is of breed y", SB(x, y) means "dog x and dog y are of the same breed", and WB(y, z) means "event y was won by dog z".

• (a, 2) (to English) (Statement I) ¬(IB(d, t) → ¬IB(d', s))

It is not the case that if my Duncan is a terrier, then the other Duncan is not a setter.

The most common error here was to miss the parentheses and apply the ¬ operator only to the first IB(d, t).

• (b, 3) (to symbols) (Statement II) Arlie, who is a setter, won the Cleverest Trick event.

IB(a, s) ∧ WB(CT, a)

• (c, 2) (to English) (Statement III) IB(c, p) → (¬IB(d, t) ∧ IB(d', s))

If Cardie is a poodle, then my Duncan is not a terrier and the other Duncan is a setter.

• (d, 3) (to symbols) (Statement IV) No retriever or terrier won any event.

∀x: ∀y: (IB(x, r) ∨ IB(x, t)) → ¬WB(y, x)

• (e, 2) (to English) (Statement V) ∀x: ∃y: IB(y, x)

For every breed, there is a dog of that breed.

Some people got this backward, or said only "For every breed there is a dog" which I took off a point.

• (f, 3) (to symbols) (Statement VI) If either Cardie or Whistle is not a retriever, then Arlie is a terrier.

(¬IB(c, r) ∨ ¬IB(w, r)) → IB(a, t)

• (g, 2) (to English) (Statement VII) ∀x:[∃y: ∃z: ¬SB(x, y) ∧ WB(z, y)] → GT(x)

Given any dog, if there is dog of a different breed from it that won an event, then the first dog got a treat.

Many bad translations put the "if" of the → in the wrong place.

• (h, 3) (to symbols) (Statement VIII) Some dog who is not a setter won more than one event.

∃x: ¬IB(x, s) ∧ ∃y: ∃z: (y ≠ z) ∧ WB(y, x) ∧ WB(z, x)

Many people left off the condition that the two events won by the dog in question were not the same event -- I took off one point for this. Some correct answers used facts from other statements and said that this dog won events BD and FD, since CT was won by a setter, or gave an OR of all the possible combinations of two or more events that this dog could have won.

• 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. Some may depend as well on the statements I through VIII given in Question 1.

• (a) The function IB is one-to-one (an injection)

FALSE. IB maps both Arlie and the other Duncan to "setter". With six dogs and four breeds, no possible function from D to B could be one-to-one.

• (b) The functions WB and IB may be composed to make a function from E to B.

TRUE. The result would be {(x, z): The dog that won event x was of breed z}.

• (c) The relation R is not a partial order.

TRUE. It is reflexive and transitive but not antisymmetric, since R(d, d') and R(d', d) are both true but d ≠ d'.

• (d) The relation S is an equivalence relation.

TRUE. It could also be expressed as {(x, y): dogs x and y have the same name}, since the alphabetical order on strings is itself antisymmetric. And this is clearly reflexive, symmetric, and transitive.

• (e) The relation SB is antisymmetric.

FALSE. SB(a, d') and SB(d', a) are both true, but a ≠ d'. Even without that specific example, with six dogs and four breeds we know there must be two distinct dogs with the same breed.

• (f) The function IB is not onto (not a surjection).

FALSE. It is onto because every breed in B is the breed of at least one dog in D: Statement V says so.

• (g) The relation N from D to Σ* has the "well-defined" property.

TRUE. That property says that no dog has more than one name, and this is assumed above when the six names are given for the six dogs.

• (h) The relation N is not a one-to-one function from D to Σ* (not an injection).

TRUE. There are two distinct dogs mapped to the same string.

• (i) The relation GT is not a binary relation on the set D.

TRUE. A binary relation would take two arguments from D. This is a unary relation because it takes only one.

• (j) The function WB is not onto (not a surjection).

TRUE. If it were, every dog would be the winner of some event. But with three events won by one dog each, it's not possible for all six dogs to be winners.

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

(Note: The point values of Questions 3 and 5 were reversed on the test paper, though they were correct on page 2.)

Determine exactly which truth values of the propositions IB(c, p), IB(d, t), and IB(d', s) are consistent with statements I and III from Question 1. (There may be none, one, or more than one setting of those three truth values that is consistent with both.) Justify your answer with a truth table or a deductive argument.

Statement I converts to IB(d, t) ∧ IB(d', s) by the Definition of Implication and DeMorgan rules, thus resolving the truth value of two of the three propositions. IB(c, p) must be false, since if it were true we could derive ¬IB(d, t) which contradicts the transformed Statement I. And if IB(c, p) is false, Statement III is true vacuously. So this setting ¬IB(c, p) ∧ IB(d, t) ∧ IB(d', s) is consistent with I and III, and is the only setting that is consistent with I and III.

I won't put the truth table here but it would be another perfectly good way to show that the setting above is the only consistent one. Statement I is true for two of the eight settings and Statement III for V. The biggest source of error here was misreadings of Statement I.

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

Determine, using any or all of Statements I through VIII, the breed of each of the six dogs in D. Explain your reasoning.

We know that my Duncan is a terrier and that the other Duncan is a setter from Question III.

Clearly Arlie is a setter by Separation on Statement II.

Since Arlie is not a terrier, the consequent of Statement VI is false and thus its premise is false by Modus Tollens, so we know that Cardie and Whistle are both retrievers.

We now have shown that five of the six dogs are not poodles, but there are two good reasons why there must be a poodle in the set. Specifying Statement V to x = p tells us ∃y:IB(y, p). And Statement VIII tells us that some non-setter won an event, and this dog could not have been a retriever or terrier by Statement IV. So Honey must be the poodle required to exist by these arguments.

• Question 5 (15): 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 VIII, that every dog in the set D got a treat. Make your use of the quantifier proof rules clear.

Let q be an arbitrary dog, and specify Statement VII to q to get [∃y: ∃z: ¬SB(q, y) ∧ WB(z, y)] → GT(q). We use Proof by Cases.

Assume q is not a setter. Then because ¬SB(q, a) and WB(CT, a) are both true, we can use Existence twice to get the premise of the implication from VII and prove GT(q).

Assume q is a setter. By instantiation from VIII let m be a dog who is not a setter and won more than one event. Let u be an event that dog m won. Then we have ¬SB(q, m) and WB(m, u) and again we can use Existence twice to get the premise of the implication from VII and again prove GT(q).

Since we have proven GT(q) in both cases is is true for the arbitrary q and we may conclude ∀x: GT(x) by Generalization.

Many people assumed that their arbitrary dog was not a poodle, and thus failed to prove that Honey got her treat.

• Question 6 (20+10): These number theory questions all deal with the number 42 and with arithmetic modulo 42.

• (a, 5) Give the prime factorizations of the numbers 13, 14, 15, 16, and 42.

13 is prime, 14 = 2 × 7, 15 = 3 × 5, 16 = 2 × 2 × 2 × 2, and 42 = 2 × 3 × 7.

• (b, 5) Of the five numbers in part (a), which have inverses modulo 42 and which do not? How do you know this? (You may or may not want to use the Euclidean Algorithm.)

Each of 14, 15, 16, and 42 have a 2, 3, or 7 in their factorization and are thus not relatively prime to 42 and have no inverses mod 42. But 13 is prime and thus cannot have a common factor with 42 unless it divides it, which is doesn't. So it is relatively prime to 42 and does have an inverse, which we will find in part (c).

If we use the EA then 42 and 13 go to 3 and 1 (relatively prime), 42 and 14 go to 0 (not), 42 and 15 go to 12 and 3 (not), 42 and 16 go to 10, then 6, then 4, then 2 (not), and 42 and 42 go to 0 (not). I took off a point if you justified your claim by the EA and then didn't run the EA on 42 and itself.

• (c, 10) For one of the numbers in part (a) that does have an inverse modulo 42, calculate that inverse.

In the EA we find that 42 = 3(13) + 3, 13 = 4(3) + 1, and 3 = 3(1) + 0. So 42 = 1(42) + 0(13), 13 = 0(42) + 1(13), 3 = 1(42) - 3(13), 1 = -4(42) + 13(13), and we find that 13 is its own inverse mod 42. If we cared, we have also found that -4 is the inverse of 42, mod 13.

• (d, 5XC) For any two numbers x and y in the set {0, 1, 2,..., 41}, define the function fx so that fx(y) is the remainder when xy is divided by 42. (That is, in Java notation, fx(y) = xy % 42.) It turns out that there are exactly four values of x such that the function fx is its own inverse. Find these four values, justifying your claim in each case.

For the function fx to be its own inverse, multiplying by x twice must have the same effect as multiplying by 1, that is, no effect at all. So we are looking for x such that x2 is congruent to 1, modulo 42. We should be able to notice that 1 and -1 (also known as 41) have this property. In (c) we found that 13 does as well, and the fourth number with this property is -13, also known as 29. If we got (c) wrong and started a brute force search, we could restrict it to the 12 numbers found in (e) to be relatively prime to 42, since if x and 42 have a common factor that factor will divide x2 which then can't equal 1.

• (e, 5XC) Exactly how many numbers in the set {0, 1, 2,..., 41} are relatively prime to 42? Of those numbers, exactly how many are prime?

As in the Sieve of Eratosthenes, all our candidates must be congruent to either 1 or 5, modulo 6, since otherwise they would have a factor of 2 or 3 in common with 42. There are 14 such numbers in the range: 1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, and 41. Of these 7 and 35 are not relatively prime to 42 because they share 7 as a common factor with 42. That leaves 12 relatively prime numbers, of which 10 are prime -- the other two are 1 and 25.

Many didn't realize that 1 is relatively prime to any positive integer x, because clearly 1 is a common factor and no larger positive integer divides 1.