# First Midterm Exam Solutions

#### 30 September 2004

• Note for Questions 1-4: These questions deal with a set of dogs D = {Chinook, Ebony, Hadley}, a set of breeds B = {Husky, Labrador, Poodle}, and a binary predicate M defined so that M(d,b) means "dog d is a member of breed b''.

• Question 1 (15): Translate each of the following English statements into symbolic notation:

• (a,5) If Hadley is a Labrador, then Chinook is not a Husky.

• (b,5) Hadley is either a Labrador or a Poodle, but not both, and if Chinook is either a Husky or a Poodle, but not both, then Hadley is not a Poodle.

• (c,5) Every dog is a member of some breed.

∀d:∃b:M (d, b)

• Question 2 (15): Translate each of the following symbolic statements into English. (The type of variables b, b1, and b2 is "breed", and the type of d, d1, and d2 is "dog".)

"If Chinook is a Husky, then Hadley is a Labrador, and if Hadley is a Labrador, then Chinook is a Husky." Equivalently, "Chinook is a Husky if and only if Hadley is a Labrador."

• (e,5) ∀ d1:∀ d2: ∀ b: [M(d1,b)∧ M(d2,b)∧ (d1≠d2)]→ (b = Labrador)

"If two different dogs are members of a breed, then that breed is Labrador."

• (f,5) ∀ b1:¬∃ d:∃ b2: M(d,b2)∧ (b1≠b2)∧ M(d,b1).

"For any breed, there do not exist a dog and a different breed such that the dog is a member of both breeds."

• Question 3 (15): Assume that statements (a) through (f) from Questions 1 and 2 are true, and further assume that Ebony is a Labrador. You may find it useful to solve parts of Question 4 first, or otherwise determine the breeds of the various dogs.

• (g,5) Prove, using the definition of a function, that the relation M is a function from the given set of dogs to the given set of breeds.

A function must be total and well-defined. Statement (c) says exactly that M is total. Statement (f) is almost exactly the statement that M is well-defined. If we use the negation-of-quantifier rule twice, and use commutativity of ∀ quantifiers, we can transform (f) into the equivalent statement ∀d:∀b1:∀b2:[M (d, b1) ∧ M (d, b2)] → (b1 = b2). This latter statement is exactly the definition of "M is well-defined".

• (h,5) Is M a one-to-one function? Prove your answer using the given assumptions.

M is not one-to-one because we will show in Question 4 that Chinook is neither a Husky nor a Poodle, and so Chinook is a Labrador by (c). We are given that Ebony is also a Labrador, and a one-to-one function could not have two different dogs with the same breed.

• (i,5) Is M an onto function? Prove your answer using the given assumptions.

M is not onto, because none of the given dogs is a Husky and an onto function would have to have at least one dog of each breed. We will show below that Hadley is a Poodle.

• Question 4 (20): This question deals with some of the propositions obtained by substituting specific values into M.

• (j,5) Using a truth table, determine the truth value of M (Chinook, Husky) and M (Hadley, Labrador) from statements (a) and (d) only.

Call the two booleans in question CH and HL. Statement (a) says HL → ¬ CH, and statement (d) says CH ⊕ HL. We make a two-variable truth table:

```          (HL  --> not  CH) and (CH  --> HL) and (HL --> CH)
0    1   1    0   1    0   1   0  |1|  0   1   0
0    1   0    1   1    1   0   0  |0|  0   1   1
1    1   1    0   1    0   1   1  |0|  1   0   0
1    0   0    1   0    1   1   1  |0|  1   1   1
```

The truth table shows that the premises can only be satisfied if HL and CH are both false.

• (k,10) Using only information about the propositions M (Chinook, Husky), M (Chinook, Poodle), M (Hadley, Labrador), and M (Hadley, Poodle) from statements (a), (b), (d), and (e), determine the value of these four propositions and prove your answer from the statements using propositional proof rules. If you are sure that a rule is valid but can't remember its name, just state it and use it.

We know ¬HL and ¬CH from statements (a) and (d), and these give us no further information about the other two propositions, CP and HP. Statement (b) says (HL ⊕ HP) ∧ ((CH ⊕ CP) → ¬HP). Statement (e) affects our situation because it says that no two different dogs can be Poodles, so we get ¬(CP ∧ HP).

By left separation on (b) we get HL ⊕ HP, and since we know that HL is false, HP must be true. By right separation from (b) we get an implication, and the contrapositive of this implication is HP → (CH ↔ CP). (Here we use the rule (p ↔ q) ↔ ¬ (p ⊕ q).) Since HP is true, by modus ponens we get CH ↔ CP. Since CP cannot be true by (e) (since HP is already true), CH and CP cannot be both true, so they are both false. Thus we have ¬HL ∧ HP ∧ ¬CH ∧ ¬CP.

We can check that all our premises are satisfied by this truth assignment: (a) is true vacuously, the left half of (b) is satisfied by HP, the right half of (b) is true vacuously, (d) is true since CH and HL are both false, and (e) is true because we have not assigned two Poodles.

• (l,5) Verify that your conclusion is consistent with statement (f).

Statement (f) says that no dog has two different breeds. Our assignment to the four booleans could have violated it by setting both HL and HP true, or both CH and CP true, but it didn't. The entire set of premises is satisfied if Chinook and Ebony are Labradors and Hadley is a Poodle.

• Question 5 (20): The binary relation Pre on strings is defined so that Pre(u,v) means ∃w:uw=v. If this is true we say that u is a prefix of v. Prove carefully that Pre is a partial order on the set of all strings over any alphabet. State the three properties of a partial order, and use the definition of Pre and quantifier proof rules to show that each of the three properties holds. (Hint: You may assume that every string has a length, and that the length of xy is the length of x plus the length of y. You may also assume well-known properties of the naturals.)

A partial order is reflexive, antisymmetric, and transitive.

Pre is reflexive because ∀w:Pre(w,w) is true. To prove this, let w be an arbitrary string. Pre(w,w) means ∃x:wx=w. This is true by the Rule of Existence because we may take x to be λ. Since w was arbitrary, we have proved the reflexive property.

The antisymmetry property is ∀u:∀v:(Pre(u,v)∧Pre(v,u)) → (u=v). To prove this, let u and v be arbitrary strings and assume Pre(u,v) and Pre(v,u). So we know ∃x:ux=v and ∃y:vy=u. Consider the lengths |u| and |v| of u and v respectively. Since |u| + |x| = |v|, we know |u| ≤ |v|, and since |v| + |y| = |u|, we know |v| ≤ |u|. By properties of the naturals, |u| must equal |v|. So x and y each have length 0, and so each must be the empty string and we have that u = v. We have proved the implication by direct proof. Since u and v were arbitrary, we have proved the symmetric property.

The transitive property is ∀u:∀v:∀w:[Pre(u,v) ∧ Pre(v,w)] → Pre(u,w). So let u, v, and w be arbitrary strings and assume Pre(u,v) and Pre(v,w). By the definition of Pre we have that ∃x:ux=v and ∃y:vy=w. Let x and y be specific strings satisfying ux = v and vy = w, by the Rule of Instantiation. Substituting ux for v in the equation vy = w, we find that uxy = w. Letting z by xy, we find that ∃z:uz=w which is the definition of Pre(u,w). We have proved the implication, and since u, v, and w were all arbitary, we have proved the transitive property.

• Question 6 (15): Recall that we may define two naturals a and b to be congruent modulo a natural r if there exists a natural q such that either a=qr+b or b=qr+a. We write this "a≡b (mod r)". Recall also that a natural c divides a natural d (written "D(c,d)") if and only if ∃ e:ce=d. Prove carefully, using exactly these definitions, that: ∀a:∀b:∀c:∀d:[D(a,b)∧ (c ≡ d (mod b))]→ (c ≡ d (mod a))

Let a, b, c, and d be arbitrary naturals and assume D(a,b) and c ≡ d (mod b). By the definition of division we know ∃e:ae=b, so by Instantiation let e be a natural such that ae = b. By the given definition of congruence we know that ∃q:(c=qb+d)∨(d=qb+c). Let q be a natural such that c = qb+d or d = qb+c.

We prove c ≡ d (mod a) by cases. First assume that c = qb+d. Since b = ae, we have that c = qae+d = a(qe)+d. By joining, we have (c=a(qe)+d) ∨ (d=q(ae)+c). Letting z be qe, we have ∃z:(c=az+d) ∨ (d=az+c), which is the definition of c ≡ d (mod a).

For the other case, we assume d = qb + c. Again since b = ae we have d = a(qe) + c, and by joining we get (d = a(qe) + c) ∨ (c = a(qe) + c). Letting z = qe, we get ∃z:(d = az+c) ∨ (c = az+d) by the Rule of Existence, and this is the definition of c ≡ d (mod a). We have completed the proof by cases and thus proved the implication. Since a, b, c, and d were arbitrary we have proved the desired statement.