# Solutions to First Midterm Exam

#### 24 February 2005

Questions are in black, solutions in blue.

• Question 1 (20): I have ordered a pizza which might or might not have anchovies, might or might not have broccoli, and might or might not have calimari. Part (a) of the problem contains three statements about which ingredients I might have ordered. In part (b) you are asked to figure out which ones I did order.

• (a,5) Translate the following three statements as indicated, using "a" to represent "the pizza has anchovies", "b" for "the pizza has broccoli", and "c" for "the pizza has calimari":
• (to symbols) If the pizza has either anchovies or broccoli, or both, then it does not have calimari.

(a∨b)→¬c

• (to English) (b∧¬c) → a

If the pizza has broccoli and does not have calimari, then it has anchovies.

• (to symbols) Unless the pizza has both calimari and anchovies, it has broccoli.

¬(c∧a) → b

• (b,15) Do the three statements in (a) determine exactly which ingredients are on the pizza? If so, find the set of ingredients and show that it is the only one consistent with the statements. If not, either find two or more distince sets of ingredients that are consistent, or show that no set of ingredients is consistent. You may use either a truth table or a propositional proof (the latter would probably be faster).

There is exactly one possible solution, with anchovies and broccoli but not calimari. Here is one of several possible propositional proofs:

1. Assume a.
2. a &or b (right joining)
3. ¬c (modus ponens, first statement)
4. ¬c∨not;a (right joining)
5. ¬(c∧a) (DeMorgan)
6. b (modus ponens, third statement)
7. a∧b∧¬c (conjunction, lines 1, 3, and 6)
8. a → (a∧b∧¬c) (direct proof, lines 1-7)
9. Assume ¬a
10. ¬(b∧¬c) (modus tollens, second statement)
11. ¬b∨c (DeMorgan)
12. ¬c&or¬a (left joining, line 9)
13. ¬(c∧a) (DeMorgan)
14. b (modus ponens, third statement)
15. c (tertium non datur, lines 10 and 14)
16. a∨b (left joining, line 14)
17. ¬c (modus ponens, third statement)
18. c∧¬c (conjunction, lines 15 and 17)
19. 0 (excluded middle)
20. ¬a → 0 (direct proof, lines 9-19)
22. a∧b∧¬c (modus ponens, lines 8 and 21)

This solution satisfies all three rules trivially, and the proof above shows that no other solution is possible. A truth table would also work.

• Question 2 (20): This question involves the children's game rock-paper-scissors. (No prior familiarity with the game is necessary to answer the question.) Let M = {r,p,s} be the set of the three possible moves in the game, and let B be the binary relation on M defined so that B(x,y) means "move x either wins or ties against move y". That is, B is the relation {(r,r), (r,s), (p,r), (p,p), (s,p), (s,s)}.

• Is B a partial order on M? For each of the three defining properties of a partial order, prove either that B has this property or that it does not. (Remember that a universal statement may be proved false with a single counterexample.)

B is reflexive, because for all three possible values of x, B(x,x) is true.

B is antisymmetric, because there is no case where B(x,y) and B(y,x) are both true and x ≠ y. (There are three possible choices of a set {x,y} with x ≠ y, and in each of them one of B(x,y) and B(y,x) is false.)

B is not transitive -- we can show this with a single counterexample to the transitivity rule: B(r,s) and B(s,p) are true but B(r,p) is false.

Since B does not satisfy all three properties, it is not a partial order.

• Question 3 (35): Let N = {0,1,2,3,...} be the set of all naturals. This question deals with the following four functions from N to N:
• f(n) = n/2 (this is Java integer division, so that f(6) and f(7) each equal 3)
• h(n) = 2n
• t(n) = f(h(n)) (so that t = f ° h)
• s(n) = h(f(n)) (so that s = h ° f)

• (a,10) Explain what it means for a function to be a surjection, also called an onto function. Which of the four functions above, if any, are surjections? Justify your answers.

A surjection is a function where every possible output value is the result of the function on some input value. The function f is a surjection because every natural n is equal to f(2n) and is thus a result. The function h is not a bijection because it never takes on an odd value. The function t is a bijection because any natural n is equal to t(n). The function s is not a surjection because it never takes on an odd value.

• (b,10) Explain what it means for a function to be an injection, also called a one-to-one function. Which of the four functions above, if any, are injections? Justify your answers.

An injection is a function where any two different inputs have different outputs. The function f is not an injection because of the example given, where inputs 6 and 7 have the same output. The function h is an injection because if x ≠ y, then 2x ≠ 2y. The function t is an injection because t(n) = n for all n. The function s is not an injection because, for example, s(6) and s(7) are both equal to h(3), or 6.

• (c,5) Explain what it means for a function to be a bijection. Which of the four functions above, if any, are bijections? Justify your answers.

A bijection is a function that is both a surjection and an injection -- it is also called a one-to-one correspondence because it assigns each input a unique output. Only t is a bijection -- each of the others fails to be one or the other (s is neither).

• (d,10) Prove or disprove the following statement: ∀n:s(s(n))=s(n), where s is the function defined above and the type of n is `natural`.

The statement is true. Let n be an arbitrary natural. Then f(n) is some number k, where either n = 2k (if n is even) or n = 2k+1 (if n is odd). So s(n) = h(f(n)) = h(k) = 2k. Then f(s(n)) = k, and s(s(n)) = h(f(s(n)) = h(k) = 2k. Since s(n) and s(s(n)) are each equal to 2k, they are equal to each other.

• Question 4 (25): This question deals with a set of dogs D and a binary relation P on D. If x and y are dogs, P(x,y) means "x plays nicely with y". You are given that P is an equivalence relation.

• (a,10) Translate each of the following statements as directed:
• (I) (to symbols) There is no dog that plays nicely with all dogs.

¬∃a:∀b:P(a,b)

• (II) (to English) ∃c:∀d:∀e: (¬P(c,d)∧¬P(c,e))→P(d,e)

"There is a dog c such that for any two dogs d and e, if neither d nor e play nicely with c, then d plays nicely with c,", or equivalently "There is a dog such that any two dogs that don't play nicely with it play nicely with each other."

• (b,15) Using statements I and II from part (a) and the fact that P is an equivalence relation, prove that there exist two dogs such that every dog plays nicely with one or the other (that is, ∃x:∃y:∀z:P(z,x)∨P(z,y)). Be clear about your use of the four quantifier proof rules.

1. Let c be the dog given by statement II, so that ∀d:∀e:(¬P(c,d)∧¬P(c,e))→P(d,e).
2. Rewrite I as ∀a∃b:¬P(a,b).
3. Specify line 2 to c, so that ∃b:¬P(c,b).
4. Let b be the dog given in line 3, so that ¬P(c,b).
5. Let z be an arbitrary dog.
6. P(z,c) → (P(z,c)∨P(z,b)) by right joining.
7. Assume ¬P(z,c).
8. Because P is symmetric, we have ¬P(c,z).
9. By conjunction from lines 8 and 3, we have ¬P(c,z)∧¬P(c,b)
10. Specify line 1 to d=z and e=b, so we have (¬P(c,z)∧¬P(c,b))→P(z,b).
11. By modus ponens we have P(z,b).
12. By left joining we have P(z,c)∨P(z,b).
13. Lines 7-12 are a direct proof of ¬P(z,c)→(P(z,c)∨P(z,b)).
14. Lines 6 and 13 are a proof by cases of P(z,c)∨P(z,b).
15. Since z was arbitrary, we have proved ∀z:P(z,c)∨P(z,b) by Generalization.
16. Since we may set y=b and x=c, we have the desired ∃x:∃y:∀z:P(z,x)∨P(z,y) by two uses of the Rule of Existence.