# 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. 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.

Correction in orange made 23 February 2016.

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

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))

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

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

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

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

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

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

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

• 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)

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

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

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

• (e) The relation SB is antisymmetric.

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

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

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

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

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

• 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.

• 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.

• 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.

• 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.

• (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.)

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

• (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.

• (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?