DISCLAIMER: THESE QUESTIONS DO NOT NECESSARILY REPRESENT WHAT WILL BE ON THE MIDTERM.
(a) p V q (b) (p & q) -> r
not p not r
------ ------------
q not p
SOLUTION: The first is valid and the 2nd is invalid.
| p | q | p V q | not p |
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 |
((p V q) & (not p)) -> q given
not ((p V q) & not p) V q p-> q <=> not p V q
(not (p V q) V not not p ) V q DeMorgan's Law
((not p & not q) V p) V q) DeMorgan's Law
((not p V p) & (not q V p)) V q) Distribution Law
(T_0 & (not q V p)) V q Inverse Law
(not q V p) V q Identity Law
(p V not q ) V q Commutative Law
p V (not q V q) Associative Law
p V T_0 Inverse Law
T_0 Domination Law
(b) This is not a valid rule of inference. It should be intuitively clear.
Modus Tollens would say that if r is false, then (p & q) has to be false. But
by DeMorgan's Law this would give "not p V not q" , not necessarily "not p".
Maybe p could be true and q could be false. Try substituting p = 1, q = 0 and r = 0.
You will see that this is a contradiction.
(a) Duke is a labrador retriever.
All labrador retrievers like to swim.
Therefore Duke likes to swim.
UNIVERSE = dogs
SOLUTION: Let L(x) = "x is a labrador retriever"; S(x) = "x likes to swim".
Given: L(Duke)
for-all x [L(x) -> S(x)]
Therefore S(Duke)
Proof: 1) for-all x [L(x) -> S(x)] given
2) L(Duke) -> S(Duke) 1 and universal specification
3) L(Duke) given
4) S(Duke) 2 and 3 and Modus Ponens
This is too easy. I couldn't think of any better ones this afternoon.
(b) All even numbers that are also greater than 2 are not prime.
2 is an even number.
2 is prime.
Therefore some even numbers are prime.
UNIVERSE = numbers
SOLUTION: Let E(x) = "x is even" and G(x) = "x is greater than 2" and P(x) = "x is prime".
Given: for-all x[(E(x) & G(x)) -> not P(x)]
E(2)
P(2)
Therefore there-exists x [E(x) & P(x)]
Notice the first statement is irrelevant. This was an exercise in not letting irrelevant
facts confuse matters.
Proof:
1) E(2) given
2) P(2) given
3) E(2) & P(2) 1 and 2 and conjunction
4) there-exitsts x [E(x) & P(x)] 3 and existential generalization
(c) If it is hot today or raining today then it is no fun to snow ski today.
It is no fun to snow ski today.
Therefore it is hot today.
UNIVERSE = days.
Let H(x) = "day x is hot"; R(x) = "on day x is raining"; and
F(x) = "on day x it is fun to snow ski".
Given: for-all x [(H(x) V R(x)) -> not F(x)]
not F(today)
Therefore H(today)
This is an invalid argument. We need to show a counterexample. In this case, since
the first statement is a for-all, if we can find can imagine any x (day) that makes
the hypotheses true and the conclusion false, then we have a counter-example.
For example, imagine a day c when H(c) = 0
R(c) = 1
F(c) = 0
Then the first and 2nd lines are true and the third, the conclusion is false. This
is a counter-example. Intuitively, there are lots of other reasons skiing is not
fun besides heat and rain.
(d) It is not fun to snow ski today if it is too warm or raining today.
It is too warm today.
Therefore it is not fun to snow ski today.
UNIVERSE = days.
Use the same predicates as for part (c).
Given:
for-all x [(H(x) V R(x)) -> not F(x)] (notice this was stated as "q if p")
H(today)
therefore not F(today)
This is a valid argument.
Proof: 1) for-all x [H(x) V R(x)) -> not F(x) given
2) H(today) given
3) (H(today) V R(today)) -> not F(today) 1 and universal specification
4) H(today) V R(today) 2 and conjunctive amplification
5) not F(today) 3 and 4 and Modus Ponens
t(n) = t(n-1) + 2n-1 t(1) = 1
n t(n)
1 1
2 4 t(2) = t(1) + 2*2 - 1 = 1 + 4 - 1 = 4
3 9 t(3) = t(2) + 2*3-1 = 4 + 6 - 1 = 9
GUESS: t(n) = n2
t(n+1) = t(n) + 2(n+1) - 1
= 2*n^2 - n + 2(n+1) - 1 by I.H.
= 2*n^2 - n +2n + 2 - 1
= 2*n^2 + n + 1
This doesn't match the claim and there is no way to fix it. Therefore the claim
appears to be false.
Proof (by induction): Basis: For n = 1, by the recursive definition t(1) = 1. By the formula t(1) = 1*1 = 1. Therefore the claim is true for the basis case.
I.H. Assume t(n) = n^2 for some n > 1. Induction Step: Will show that t(n+1) = (n+1)^2. By the recursive definition, t(n+1) = t(n) + 2(n+1) - 1 = n^2 + 2n + 2 - 1 by I.H. = n^2 + 2n + 1 = (n+1)^2. Therefore the claim is true.
Big-O: We know that this sum is n(n+1)/2 so f(n) = (n^2)/2 + 1/2.
We know n^2/2 < n^2/2 and 1/2 < n^2/2. thereofre f(n) < 2*(n^2)/2 = n^2.
Therefore f(n) is O(n^2) for c = 1 and n_0 = 0.
Omega: We know that f(n) = 1/2(n^2 + 1) > 1/2(n^2) so f(n) is Omega(n^2)
Theta: Since f(n) is O(n^2) and Omega(n^2) it is theta(n^2).
Simplify: f(n) = 2*(log n) - 1) + 2 - 2 log n - 2 + 2 = 2 log n. Big-O : Clearly f(n) = 2 log n is O(log n) for c = 2. Omega: Clearly f(n) = 2 log n >= 2 log n so is Omega(log n ) for c = 2. Theta: Since f(n) is O(log n) and Omega(log n) it is also Theta(log n).
Big-O: f(n) <= 3n^2 + 4n^2 for n >= 1.
since 4n <= 4n^2 for n >= 1
and -5 <= 0
Therefore f(n) is O(n^2) for c = 7 and n_0 = 1.
Omega: f(n) >= 3n^2? Solve: 3n^2 + 4n - 5 >= 3n^2
4n - 5 >= 0
4n >= 5
n >= 5/4
So f(n) >= 3n^2 for n >= 5/4
So f(n) is Omega(n^2) or c = 3, n_0 = 5/4
Theta: Since it is O and Omega(n^2), f(n) is theta(n^2).
Big-O: f(n) = n^2 - n <= n^2 whenever n >= 0. Therefer f(n) is O(n^2) for c = 1, n_0 = 0.
Omega: f(n) = n^2 - n >= 1/2 n^2? Notice we can't pick c >= 1. It won't work. It is
ok to pick c a positive fraction. The only restriction
is c has to be positive.
Solve: 1/2 n^2 >= n
1/2 n >= 1
n >= 2.
So f(n) >= 1/2 n^2 for n >= 2
So f(n) is Omega(n^2) for c = 1/2, n_0 = 2.
Theta: since ...... same as above
Big-O: f(n) = 2 n log n - 2n - 3 log n <= 3n log n since 2n + 3 log n >= 0 for n >= 1.
Therefore f(n) is O(n log n) for c = 3, n_0 = 1.
Omega: f(n) >= 2n log n? Solve:
3n log n - 2n - 3 log n >= 2n log n
n log n >= 2n + 3 log n
log n >= 2 + 3logn/n (Equation *)
Now, this is tricky. You can't solve it exactly. You have to replace 3 logn/n by
an upper bound. We know that logn < n for n >= 1. When n = 2 logn/n = 1/2.
When n = 4, logn/n = 1/2. When n = 8, logn/n = 3/8. So for any intger
n >= 1 we are pretty sure that logn/n <= 1/2. Therefore 3logn/n <= 3/2 for
n >= 1.
So Equation * becomes:
logn >= 2 + 3/2 >= 2 + 3logn/n Sine if logn >= 2 +3/2 then since 2 + 3/2 is
greater than 2 + 3logn/n, log n > = 2 + 3logn/n as desired.
So now we want to know for what n is log n >= 7/2?
Well certainly if logn >= 4 then logn >= 7/2 since 4 > 7/2.
So figure out when logn >= 4. This is easy, when n >= 16.
Therefore, when n >= 16 we have logn >= 2 + 3logn/n and, going back,
f(n) >= 2nlogn.
Therefore f(n) is Omega(n log n) for c = 2, n_0 = 16.
Note: This was very involed. I would like you to be able to do this, but do not expect it.
Theta: same as always.