Homework 3

CSE 311: Foundations of Computing I
Homework 3 (due Monday, April 17)
Directions: Write up carefully argued solutions to the following problems. Your solution should be clear enough
that it should explain to someone who does not already understand the answer why it works. You may use results
from lecture, the theorems handout, and previous homeworks without proof.
Formal Proofs
0. Spoofclusions [Written] (15 points)
Theorem: Given (p ∧ r) → (q ∧ r), ¬s → (r ∧ q), and s → (p ∧ q), prove q.
“Spoof:”
1.
(p ∧ r) → (q ∧ r)
[Given]
2.
¬s → (r ∧ q)
[Given]
3.
s → (p ∧ q)
[Given]
4.
¬s → q
[Elim ∧: 2]
5.
p → (q ∧ r)
[Elim ∧: 1]
[Assumption]
6.1.
s
6.2.
p ∧ q [MP: 6.1, 3]
6.3.
p
6.4.
q ∧ r [MP: 6.3, 5]
6.5.
q
[Elim ∧: 6.2]
[Elim ∧: 6.4]
6.
s→q
[Direct Proof Rule]
7.
(s → q) ∧ (¬s → q)
[Intro ∧: 4, 6]
8.
(¬s ∨ q) ∧ (¬¬s ∨ q)
[Law of Implication]
9.
(q ∨ ¬s) ∧ (q ∨ ¬¬s)
[Commutativity]
10.
q ∧ (¬s ∨ ¬¬s)
[Distributivity]
11.
q∧T
[Law of Negation]
12.
q
[Domination]
(a) [5 Points] Is the conclusion of the “spoof” correct? Explain why or why not.
(b) [10 Points] The “spoof” makes a critical error in at least one step. Explain which step(s) are faulty and
why.
1. Infer That! [Online] (10 points)
Using the logical inference rules and equivalences we have given, write a formal proof that you can infer r → ¬q
from (p ∨ r) → (q → s), t, and (r ∧ t) → ¬s.
You can submit and check your answers to this question using
https://grinch.cs.washington.edu/cse311/formal-proofs.
1
2. Mind Your P ’s and Q’s [Online] (10 points)
Using the logical inference rules and equivalences we have given, write a formal proof that given ∀x (Q(x) →
¬P (x)), ∀x ((P (x) ∧ ¬Q(x)) → R(x)), and ∃x P (x), you can conclude that ∃x R(x).
You can submit and check your answers to this question using
https://grinch.cs.washington.edu/cse311/formal-proofs.
English Proofs
3. Even Odds Are Irrational [Written] (20 points)
For this question, let the domain of discourse be the real numbers.
A real number, x, is rational if and only if there exist integers p and q 6= 0 such that x = p/q. Formally, we have
p
Rational(x) ::= ∃p∃q x = ∧ Integer(p) ∧ Integer(q) ∧ q 6= 0
q
For this question (and ideally from here on out), you should use only English proofs.
(a) [10 Points] Prove that for all x and y, if x and y are rational, then x + y is rational.
(b) [10 Points] We say a number is irrational if it is not rational. Prove that it is not the case that all even
numbers x are irrational.
4. ∀ problems, ∃ a reason [Written] (20 points)
Prove or disprove each of the following statements using English proofs.
(a) [10 Points] Let SidesOf(x, y) be “the number of sides of x is y”, Number(x) be “x is a number, and
Shape(y) be “y is a shape.” For this part, let the domain consist of the numbers 0 and 1, and the shapes
triangle and square.
∀x (Number(x) → (∃y (Shape(y) → (SidesOf(y, x + 4) ↔ (Shape(x) ∨ Number(x))))))
Hint: Do not think about what this statement actually means as a whole. Blindly apply the proof strategies
we’ve learned to prove the statement.
(b) [10 Points] For this part, let the domain of discourse be non-negative integers.
∃x ∀y ((y > 0) → (2x < y))
5. Oddly Even, again [Written] (10 points)
Prove or disprove (using an English proof ): For every integer n, if 5n + 3 is odd, then n is even.
As always, use the definitions from class as much as possible. You may also assume that every number is either
even or odd.
2
6. The Object of My Heart [Written] (15 points)
N.B. This question is designed to force you to blindly apply proof rules without trying to “understand” the objects
that you are working with. Your job in this question is to use the facts you get to assume to prove another fact,
all the while only using the provided definitions.
Let the domain of discourse be natural numbers (that is, 0, 1, 2, . . . ).
We say F is an object iff ∀n ∃m JF ♥ n, mK.
We also define the sum of f and g is S iff ∀n ∀a ∀b (Jf ♥ n, aK ∧ Jg ♥ n, bK) → JS ♥ n, a + bK. Prove
that for all objects f and g, the sum of f and g is also an object.
Here is a game-plan for this question:
• Declare all the variables that you need to begin. (There will be at least three.)
• Figure out the actual (logical) statement that you are trying to prove.
• Proceed by removing the quantifiers in the standard way.
• At some point, you will need to use the definitions you are allowed to assume to “find” a number that
“works” for the existential.
• Eventually, you will be able to conclude the answer via a definition.
• We expect you to write an English Proof for this question. You should not be referencing any inference
rules by name in this question!
• We expect you to look at this problem and be confused; that’s okay!! It’s not really supposed to make
sense. You can solve it anyway! If you need help, we will be extra helpful in giving starting hints at office
hours for this one.
7. EXTRA CREDIT: Harmonic Numbers (-NoValue- points)
We say that Hn is the “nth harmonic number.” It is defined as follows:
Hn =
n
X
1
i=1
i
i
We define h2k
k−1 X
2
X
1
=1+
.
i+1
2
i=0 j=1
(a) Find a way of writing H2k that is similar in structure to how we defined h2k . Namely, use a double
summation to group terms after the first into groups whose sizes are successive powers of two.
We recommend that you plug in several values of k to get a feel for what h2k looks like.
(b) Prove that H2k ≤ 2h2k .
(c) Find a closed form for h2k . (In this case, closed form means that there shouldn’t be any summations.)
(d) Use all the previous parts to prove that H2k ≤ c log2 (n) for some constant c.
Remark. You’ve just shown that the harmonic numbers are bounded above by a constant factor of log2 (n).
This may not seem important, but it’s incredibly useful to the runtime analysis of many algorithms that you will
see in future courses.
3