There are six questions for 100 total points. Questions are in black, solutions in blue.

Question 5 (a) as corrected on 26 Oct 2004.

**Question 1 (10):**
Prove ∃a:∀b:(b≥a)→[∃c:(b<3c)∧(3c<2b)].
This can be done without mathematical induction.

Let a be 4. (Why? Because 3 doesn't work, as there is no multiple of 3 between 3 and 6.) Let b be arbitrary, and assume that b ≥ a. One of the three numbers b+1, b+2, or b+3 must be a multiple of 3. Let c be the natural such that this number is 3c. Clearly b < 3c, and since b ≥ 4 it is also true that 3c < 2b. So we found a c that satisfies the conditions, and we have proved the statement in square brackets. Since b was arbitrary, we have proved the implication. Since we found a value of a that works, we have proved the entire statement.

**Question 2 (10):**
Prove *by induction* that for all naturals n, (n+1)/2≤n. Here the
"/" is the Java integer division operator.

We use ordinary induction on n. Let P(n) be the statement "(n+1)/2 ≤ n". For the base case, P(0) is the statement "(0+1)/2 ≤ 0", which is true because 1/2 = 0 with Java integer division.

For the inductive case, assume that (n+1)/2 ≤ n. We want to prove that (n+2)/2 ≤ n+1. By adding 1 to both sides of the inductive hypothesis we get (n+1)/2 + 1 ≤ n+1. Since (n+1)/2 + 1 = (n+3)/2, we know that (n+2)/2 ≤ (n+3)/2 ≤ n+1, which is what we wanted to prove. We have completed the inductive case and thus completed the proof.

**Question 3 (20):**
This problem concerns the three naturals 64, 77, and 91.

- (a,10) Run the Euclidean Algorithm on 77 and 64, on 91 and 64, and on 91 and 77.
Which pairs are relatively prime?
77 = 1(64) + 13

64 = 4(13) + 12

13 = 1(12) + 1

12 = 12(1) + 0, 77 and 64 are relatively prime.

91 = 1(64) + 27

64 = 2(27) + 10

27 = 2(10) + 7

10 = 1(7) + 3

7 = 2(3) + 1

3 = 3(1) + 0, 91 and 64 are relatively prime.

91 = 1(77) + 14

77 = 5(70) + 7

14 = 2(7) + 0, 91 and 77 are not relatively prime.

- (b,5) Are these three numbers pairwise relatively prime? Explain your answer.
Since one pair of numbers, 91 and 77, are not relatively prime to each other, the three numbers are not pairwise relatively prime.

- (c,5) Pick one of the pairs that are relatively prime and find integers x and y
such that x times one number plus y times the other number equals 1.
Since we compute this using the steps from the Euclidean Algorithm, it will be easier to do it for 77 and 64:

77 = 1(77) + 0(64)

64 = 0(77) + 1(64)

13 = 1(77) - 1(64)

12 = -4(77) + 5(64) by subtracting four copies of the 13 line from the 64 line

1 = 5(77) - 6(64)

**Question 4 (20):**
Prove ∀a:∀b:(b>0)→[∃q∃r:(a=qb+r)∧(r<b)].
(Hint: Let b be arbitrary, assume b>0, and use strong induction on a, with P(a)
being the predicate in square brackets.)

We can let b be arbitrary to start, since we can switch the order of the two ∀ quantifiers at the beginning. So let b be arbitrary, assume b > 0, and use strong induction on a. For the base case, P(0) says that there exist q and r such that qb+r = 0. This is true because we may take q=0 and r=0. So now for the strong inductive case assume that any a with a ≤ n can be written as qb+r for some q and r with r < b. We need to show that n+1 can be written as sb+t for some naturals s and t, with t < b. There are several ways to prove this, but I find it easier to divide it into two cases. If n+1 < b, we may let s=0 and t = n+1, and we have n+1 = sb+t and t < b. On the other hand, if n+1 ≥ b, then n+1-b is a natural that is ≤ n. So the strong inductive hypothesis tells us that n+1-b = qb+r for some naturals q and r with r < b. Now we can let s = q+1 and t = r, and we have n+1 = sb+t and t < b. This completes the strong inductive case and thus completes the proof.

**Question 5 (20):**
Define the function f from strings in {a,b}^{*} to strings in {0,1}^{*}
by the following rules:

- f(λ)=λ
- For any string u in {a,b}
^{*}, f(ua) = f(u)0 and f(ub) = f(u)01

Prove the following, where u is in {a,b}^{*} and w is in {0,1}^{*}:

- (a,10) ∀u:|u|≤|f(u)|≤
2|u| (Statement corrected
26 Oct 2004.)
We use string induction on u, where P(u) is the statement "|u|≤|f(u)≤2|u|". The base case is P(λ), which is "|λ|≤|f(λ)|≤|λ|". This is true because |λ| and |f(λ)| are both 0.

So now assume P(u), so that |f(u)| is between |u| and 2|u|, inclusive. We need to prove both P(ua) and P(ub). We can calculate |f(ua)| = |f(u)0| = |f(u)| + 1 and |f(ub)| = |f(u)01| = |f(u)| + 2. Also |ua| and |ub| are each equal to |u| + 1. So |f(ua)| and |f(ub)| are both at least at great as |f(u)| + 1 which is at least as great as |u| + 1. And both |f(ua)| and |f(ub)| are no bigger than |f(u)| + 2, which is no bigger than 2|u| + 2 = 2(|u| + 1). So both P(ua) and P(ub) are true.

- (b,10) ∀w: w∈(0+01)
^{*}→∃u:f(u)=w (Hint: Remember that (0+01)^{*}has an inductive definition on which you can do inductive proofs.)Letting P(w) be "∃u:f(u)=w", we can prove P(w) for all w in the given language by proving P(λ), ∀w:P(w)→P(w0), and ∀w:P(w)→P(w01). P(λ) says "∃u:f(u)=λ", which is true because we can take u to be λ. So let w be arbitrary and assume P(w) -- we must now prove P(w0) and P(w01). P(w) says that f(u)=w for some string u. But then from the definition of f, f(ua) = w0 and f(ub) = w01. So strings exist that are mapped to w0 and w01 by f, and both P(w0) and P(w01) are true. We have finished the inductive cases and thus proved P(w) for all strings in the language (0+01)

^{*}.

**Question 6:(20)**
Define a **directed ternary tree (DTT)** by the following rules:

- A single node is a DTT, and the node is its root.
- If S, T, and U are DTT's, and x is a new node, then the graph made from x, S, T, and U by adding arcs from x to the roots of S, T, and U is a DTT, and x is its root.
- Nothing else is a DTT.

Recall that a **leaf** is a node with no arcs out of it. Prove that in any DTT,
the number of leaves is twice the number of non-leaves, plus one.

We proceed by induction on all DTT's. For any DTT R, let N(R) be the that the number of non-leaves in R, let L(R) be the number of leaves in R, and let P(R) be the statement "L(R) = 2N(R) + 1". The base case is P(B), where B is the DTT given by the base case of the definition, with one node that is a leaf. Since N(B) = 0 and L(B) = 1, P(B) is true.

For the inductive case, assume that S, T, and U are all DTT's such that P(S), P(T), and P(U) are all true. Let R be the tree constructed from S, T, U, and a new node x according to the inductive case of the definition. To prove P(R), we must calculate N(R) and L(R). Since x is not a leaf and is the only new node, and the leaves and non-leaves of S, T, and U remain leaves and non-leaves respectively in R, we have that N(R) = 1 + N(S) + N(T) + N(U) and that L(R) = L(S) + L(T) + L(U). By the inductive hypothesis applied to S, T, and U, L(R) is also equal to (2N(S) + 1) + (2N(T) + 1) + (2N(U) + 1) = 2(N(S) + N(T) + N(U)) + 3 = 2(N(S) + N(T) + N(U) + 1) + 1, so P(R) is true and the induction is complete.

Last modified 26 October 2004