# Solutions to First Midterm Exam Spring 2020

### Directions:

• Answer the problems on the exam pages.
• There are four problems, each with multiple parts, for 100 total points plus 5 extra credit. Actual scale A = 93, C = 63.
• 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+5 points
Total: 100+5 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.

Question 2 deals with the following scenario. Every day, Duncan monitors all visitors to the house and evaluates which ones (in his judgment) pose a threat. One day there were exactly five visitors, arriving at five distinct times. In alphabetical order, they were an Amazon driver (ad), the house cleaner (hc), the mail person (mp). a political canvasser (pc), and a UPS driver (ud).

Let V be the set {ad, hc, mp, pc, ud}. Let PT and DA be two unary relations on V, such that PT(x) means "visitor x posed a threat" and DA(x) means "visitor x was driven away by Duncan". Let AB be a binary relation on V, such that AB(x, y) means "visitor x arrived before visitor y", or equivalently "visitor y arrived after visitor x". We assume that AB is a strict total order, so that it is antireflexive, antisymmetric, transitive, and total.

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

The operator "%" on naturals, as in Java, refers to integer division, so that "x % y" is the remainder on dividing x by y.

• Question 1 (20): Translate each statement as indicated, using the set of visitors V = {ad, hc, mp, pc, ud} defined above and the predicates PT(x), DA(x), and AB(x, y) defined above to mean "visitor x posed a threat", "visitor x was driven away by Duncan", and "visitor x arrived before visitor y" respectively. All variables should be of type "visitor". The predicate AB is assumed to be a strict total order (antireflexive, antisymmetric, transitive, and total).

• (a, 3) (to English) (Statement I) (PT(pc) ↔ AB(hc, pc)) ∧ (PT(hc) → (PT(pc) ∧ AB(hc, pc)))

The political canvasser posed a threat if and only if they arrived after the house cleaner, and if the house cleaner posed a threat, then the political canvasser also posed a threat and the house cleaner arrived before the political canvasser. These were mostly right.

• (b, 3) (to symbols) (Statement II) If both the political canvasser and the house cleaner posed a threat, then the house cleaner arrived before the political canvasser. These were nearly all right.

(PT(pc) ∧ PT(hc)) → AB(hc, pc)

• (c, 3) (to English) (Statement III) (PT(pc) ∨ PT(hc) ∨ AB(hc, pc)) ∧ ¬(AB(hc, pc) ∧ PT(hc) ∧ PT(pc))

Either the canvasser or the house cleaner posed a threat, or the house cleaner arrived before the canvasser, and it was not the case that the house cleaner arrived before the canvasser and that the canvasser and the house cleaner both posed threats. These were pretty good -- some people messed up the DeMorgan Law on the second half.

• (d, 4) (to symbols) (Statement IV) Every visitor who was not driven away by Duncan did not arrive after the house cleaner.

∀x:(¬DA(x)) → (¬AB(hc, x)) Here lots of people translated "not after" as "before", which is wrong in the case that x = hc.

• (e, 4) (to English) (Statement V) ∃y:∀z:DA(y)∧ (AB(z, hc) ↔ (y=z))

There was a visitor that was driven away by Duncan, and every visitor arrived before the house cleaner if and only if they were that visitor. Alternatively: There was exactly one visitor who arrived before the house cleaner, and they were driven away by Duncan. Here a lot of people misstated the condition on z, saying for example that "all visitors after hc were driven away". It's important that your statement makes clear that there was exactly one visitor before the house cleaner. :

• (f, 3) (to symbols) (Statement VI) Every visitor who posed a threat was driven away by Duncan. The main mistakes here were syntactic, like "and" instead of an implication.

∀x:PT(x) → DA(x)

• Question 2 (30): These questions use the definitions, predicates, and premises above.

• (a, 10) Given only that Statements I, II, and III are true, determine the truth values of the three propositions q = PT(hc), r = PT(pc), and s = AB(hc, pc). You may use a truth table or a deductive sequence proof.

Using the abbreviations q, r, and s, Statement I becomes "(r ↔ s) ∧ (q → (r ∧ s))". Statement II becomes "(r ∧ q) → s", and Statement III becomes "(r ∨ q ∨ s) ∧ ¬(s ∧ q ∧ r)".

If q were true, r and s would also be true by I, and this contradicts III. So q is false. This makes II vacuously true, so we can ignore it. I says that r and s are equivalent, and if they were both false all three would be false, contradicting III. So r and s are both true, the right half of I is satisfied vacuously, and III is also satisfied. We got about an equal number of truth table and deductive sequence proofs, most of them pretty good. I took off 2 out of 10 if you just gave the value of the three statements in each case, without showing your reasoning. I also insisted that your arguement show that your solution was the only one. A complete truth table does this as a matter of course.

• (b, 20) Asssuming that Statements I-V are all true, and assuming that the relation AB is a strict total order (antireflexive, antisymmetric, transitive, and total) prove that Statement VI is also true. You may use either English or symbols, but make it clear each time you use a quantifier proof rule.

Let x be an arbitrary visitor. If x = hc, we know that PT(x) is false from part (a), and thus PT(x) → DA(x) is satisfied vacuously. By Instantiation on V, let y be the visitor such that DA(y) and ∀z:AB(z, hc)↔ (y=z). If AB(x, hc), specify this last statement to x to get AB(x, hc) ↔ (x=y), which tells us that x = y and thus also that DA(x) is true. This satisfies PT(x) → DA(x) trivially. By the totality of the relation AB, the only remaining case is AB(hc, x). By Specification of IV to x, we have (¬DA(x)) → (¬ AB(hc, x)), which by Contrapositive gives us AB(hc, x) → DA(x). Now Modus Ponens gives us DA(x), so again PT(x) → DA(x) is satisfied trivially. Since x was arbitrary and we have covered all cases, we have proved ∀x:PT(x) → DA(x) by Generalization, and this is Statement VI.

• 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-VI only if explicitly told to. Two points for each correct answer.

• (a) If Statements I-VI are all true, and the relation AB has the specified properties, we do not know whether the mail person posed a threat.

TRUE. We know DA(mp), but we have information about PT only for hc and pc.

• (b) There exists a symmetric binary relation on some non-empty set that is not reflexive. TRUE. The empty relation on any non-empty set is an example.

• (c) If n is any natural with n > 1, then n and n+1 are relatively prime.

TRUE. Run the Euclidean Algorithm on n and n+1 for one step, and you reach 1.

• (d) Let the set S be {2, 4, 8, 26, 32} and define a partial order by the division relation D(a, b), which means that a divides b with no remainder. Then when we construct the Hasse diagram, there are fewer than five edges.

TRUE, there are exactly four edges. This partial order is a linear order.

• (e) If |A| = 4 and |B| = 5, then there is not any surjective (onto) function from A to B.

TRUE. This is a standard result about surjections and size of finite sets.

• (f) Let A and B be any two disjoint nonempty sets (so that A ∩ B = ∅). Let U be any partial order on A and let V be any partial order on B. Then U ∪ V (the set of all ordered pairs that are in either U or V) is a partial order on A ∪ B.

TRUE. The new relation is still reflexive as R(x, x) is true for all x. It is still antisymmetric as we've added no pairs and thus created no new obligations. It is still transitive as R(x, y) and R(y, z) can both be true only if all three are in A or all three are in B. (Here is where we use the fact that A and B are disjoint.)

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

TRUE. A total order is defined to be a partial order that also has the totality property.

• (h) If R is an equivalence relation on a nonempty finite set A, then the equivalence classes of R must each have the same number of elements.

FALSE. Any partition is the set of classes for some equivalence relation.

• (i) The function f: NR, defined by f(n) = √n, is an injection (1-1 function) but not a surjection (onto function).

TRUE. A surjection would hit all real numbers, but this hits only the square roots of naturals. It's an injection because every natural has a different square root.

• (j) The negation of ∀x:DA(x) is ¬∀x:¬DA(x).

FALSE. It is ∃x:¬DA(x).

• (k) If f(x) = 2x2 + 1 and g(x) = 4√x, then (f ○ g)(x) = 4√2x2 + 1.

FALSE. That function is (g ○ f)(x). The other would be 2(4√x)2 + 1.

• (l) Every one-to-one function has an inverse function. FALSE. There are one-to-one functions that are not onto, but this statement is true if the domain and range are finite sets of the same size.

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

TRUE. This is just the rule of Right Joining.

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

FALSE. Without violating p → q, we could have (p ∨ r) be true because of r, and have q be false.

• (o) Let R be a relation defined on the set Z so that R(a, b) if and only if a ≠ b. Then R is symmetric and transitive, but not reflexive.

FALSE. It is not transitive, since R(0, 1) and R(1, 0) are true but R(0, 0) is false. It is symmetric and not reflexive.

• Question 4 (20+5): Here are some straightforward number theory questions. Let X be the set of naturals {0, 1, 2,..., 99}. Define the function g from X to X by the rule g(x) = (77x)%100, where "%" denotes the Java remainder operator.

• (a, 5) Give prime factorizations of the naturals 77 and 100, and explain why these factorizations prove that these numbers are relatively prime to one another.

77 = 7 × 11, and 100 = 2 × 2 ×. 5 × 5. Since no prime occurs in both factorizations, the two numbers are relatively prime to one another.

• (b, 5) Compute integers y and z such that 77y + 100z = 1. You could conceivably do this by brute force, but the Inverse Algorithm from lecture is far easier and more reliable.

Brute force actually works here because 7 × 11 × 13 = 1001, telling us that (77 × 13) - (10 × 100) = 1. But let's do it properly: 100 = 1(100) + 0(77), 77 = 0(100) + 1(77), 23 = 1(100) - 1(77), 8 = -3(100) + 4(77), 7 = 7(100) - 9(77), and 1 = -10(100) + 13(77).

• (c, 10XC) Prove that the function g from X to X, defined above, is a bijection.

This follows from the result of (d) that g has an inverse. But directly, we know that 13 × 77 is congruent to 1, modulo 100. So any x in X is equal to g(13x), making g onto. And if x and y are two different elements of X, g(x) and g(y) are different because g(y) = g(x) + g(y-x), and g(y-x) = 77(y-x) cannot be 0 modulo 100 if y-x ≠ 0, since 77 and 100 have a least common multiple of 7700 and 77(y-x) < 7700.

• (d, 5) Find a function from X to X that is an inverse of g.

The function h(y) = 13y is an inverse of g, because h(g(y)) and g(h(y)) are both congruent to (77 × 13)y modulo 100, and this is congruent to y modulo 100, since 77 × 13 = 1001 is congruent to 1.

• (e, 5XC) For any numbers a and B in X, define the function fa, b from X to X by the rule fa, b(x) = (ax+b)%100. For what values of a and b is fa, b a bijection? Prove your answer.

We know by the Inverse Theorem that a has a multiplicative inverse modulo 100 if and only if it is relatively prime to 100. If a has no such inverse, then fa,b cannot be a bijection for any b because fa,0 fails to be one-to-one, making fa,b not one-to-one. But if a has an inverse c, then fa,b has the inverse fc, -cb, because a(cx-cb) + b = x - b + b = x and c(ax+b) - cb = x + cb - cb = x, both equations being taken modulo 100.