Discrete Structures for Computing
Notes 3
------------------------------------------------------------------------
1.6 Introduction to Proofs
------------------------------------------------------------------------
A PROOF is a valid argument that establishes the proof of a mathematical
statement. We combine the hypotheses of the statement, the axioms of the
system, and previously proven theorems by using the rules of inference
to end up with the desired conclusion.
The last section (on rules of inference) showed how to do FORMAL PROOFS:
every step is the application of just one rule, and the name of the
rule and which steps it is using are explicitly spelled out.
Formal proofs are what automated proof systems give you.
But, especially if they are long, they can be difficult for humans to
follow. Humans typically do better with INFORMAL PROOFS: combine
multiple steps in one step, don't clutter up the presentation with
stating things that are "obvious". (But one person's "obvious" might
be another person's cluelessness.)
In the statements of theorems, there is usual an *implicit* universal
quantifier. I.e.,
"If x > y, where x and y are positive real numbers, then x^2 > y^2."
This means "For all positive real numbers x and y..."
An informal proof typically starts off just talking about x and y,
without explicitly mentioning that Universal Instantiation is being used.
And it usually ends once the property has been shown for x and y,
without explicitly concluding that Universal Generalization gives
the result for ALL x and y.
Many theorems state something of the form p -> q (a conditional).
We'll see three ways to prove a conditional.
Direct Proof
------------
* Assume that p is true.
* Use rules of inference (on p, axioms, previously proven facts)
to deduce additional true statements.
* Eventually deduce q.
Advantages:
* conceptually straightforward
* works well when the sequence of steps needed to derive q is fairly
obvious.
Disadvantages:
* What if it is *not* obvious how to get from p to q?
Example: Prove "If n is odd, then n^2 is odd."
Remember that an integer is odd if it equals 2k + 1 for some
integer k.
* Suppose n is odd. Then n = 2k+1 for some integer k.
* So n^2 = (2k+1)^2 and (2k+1)^2 = 4k^2 + 4k + 1.
* Observe that 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1,
i.e., 2k' + 1.
* So n^2 is also odd.
Proof by Contraposition
-----------------------
Sometimes it is not so clear how to proceed with a direct proof. An
alternative is make use of the fact that p -> q is logically
equivalent to ~q -> ~p (the contrapositive). So if can do a direct
proof of ~q -> ~p, then we've also shown p -> q. Oddly enough,
sometimes it is easier to do a direct proof of the contrapositive than
of the original conditional.
Example: Show "If 3n + 2 is odd, then n is odd."
-------
First try a direct proof.
* Since 3n + 2 is odd, 3n + 2 = 2k + 1 for some integer k.
* Hmm, now what??
Instead let's try a proof by contraposition, i.e., prove
"If n is not odd, then 3n + 2 is not odd."
I.e., "If n is even, then 3n + 2 is even."
* Assume n is even, i.e., n = 2k for some integer k.
* Then 3n + 2 = 3(2k) + 2 = 6k + 2
* Notice that 6k + 2 = 2(3k+1), which is the format for an even number.
Example:
-------
Prove "If n = a*b, where a and b are positive integers, then
a <= sqrt(n) or b <= sqrt(n)."
Hard to know even how to begin with a direct proof.
Let's try proof by contraposition, i.e., prove
"If not(a <= sqrt(n) or b <= sqrt(n)), then n != a*b."
We can rephrase this, using DeMorgan's Law as:
"If a > sqrt(n) and b > sqrt(n)), then n != a*b."
* Assume a > sqrt(n) and b > sqrt(n).
* Then a*b > sqrt(n)*sqrt(n).
* So a*b > n.
* Thus n != a*b.
Vacuous proof:
--------------
Suppose we want to show p -> q, and p is false.
Then by definition of conditional, p -> q is true, so there is
nothing to show.
Trivial proof:
--------------
Suppose we want to show p -> q, and q is true.
Then by definition of conditional, p -> q is true, so there is
nothing to show.
How do you decide whether to try a direct or indirect proof?
Start trying one, if you get stuck, switch to the other.
Proof by Contradiction
----------------------
Let p be the statement we want to prove is true.
If we can prove ~p -> q, where q is a contradiction (always false),
then we have succeeded in proving that p is true.
Why?
* q is false (we chose q to be false)
* ~p -> q is true (we just proved it)
* by the definition of conditional, it must be that ~p is false.
(remember that if a conditional is true and its conclusion is false,
it must be that the hypothesis is false)
* Thus p is true.
I.e., the proof technique is this:
* Assume that the negation of the desired statement is true.
* Derive a contradiction:
- the negation of a known mathematical fact, or
- in the process we are able to derive both r and ~r for some
statement r
Example: Prove that sqrt(2) is irrational (is not equal to a/b where a and b
are integers).
Use contradiction.
* p is the statement "sqrt(2) is irrational."
* Assume ~p, i.e., sqrt(2) is rational.
* So sqrt(2) = a/b for some integers a and b, where a/b is in lowest terms,
i.e., a and b have no factors in common
* In particular, 2 does not divide both a and b. *** (r)
* So 2 = a^2/b^2
* So 2b^2 = a^2.
* So a^2 is even, which implies a is also even (an exercise)
* So a = 2c for some integer c.
* So 2b^2 = (2c)^2 = 4c^2
* So b^2 = 2c^2.
* So b^2 is even, which implies b is also even.
* But now we have derived that 2 divides both a and b. *** (~r)
So we have shown that ~p -> (r /\ ~r), so it must be that p is true.
---
An important special case of proof by contradiction is to use it
to prove a conditional statement of the form p -> q.
The form of this proof is:
* Assume p is true but q is false (i.e., the conditional is false).
* Then derive a contradiction
- could be the negation of p, as well as the other possibilities
Example: Prove "If 3n+2 is odd, then n is odd."
* p is "3n+2 is odd" and q is "n is odd"
* Assume 3n+2 is odd but n is even (i.e., p is true but q is false).
* Since n is even, 3n+2 is even.
* I.e., we just proved ~p. So we have
~q -> (p /\ ~p)
Proofs of Equivalence
---------------------
Suppose we want to prove p <-> q (p if and only if q).
Then we must prove
(1) p -> q and
(2) q -> p
Example: Prove "n is odd iff n^2 is odd" (p <-> q).
First prove that if n is odd then n^2 is odd (p -> q).
* (Done in a previous example.)
Second prove that if n^2 is odd then n is odd (q -> p).
* Assume n^2 is odd.
* So n^2 = 2k + 1 for some integer k.
* So n = sqrt(2k + 1).
* Hmmm, what now?
So let's try an indirect proof, say proof by contraposition.
Proof by contraposition:
Show that if n is even then n^2 is even (~p -> ~q).
* Assume n is even.
* Then n = 2k for some integer k.
* So n^2 = 4k^2 = 2*2k^2 = 2k'.
* So n^2 is even.
Proving several propositions are equivalent:
-------------------------------------------
Suppose we want to show that p_1, p_2, ..., p_n are all equivalent.
We can do this by showing
* p_1 -> p_2
* p_2 -> p_3
* ...
* p_{n-1} -> p_n
* p_n -> p_1 (close the circle)
So by transitivity of ->, they are all equivalent to each other.
In fact, it doesn't matter what order of the propositions you use.
Mistakes in Proofs
------------------
Algebra errors (sometimes hidden).
Example: "Prove" that 1 = 2.
Start with two equal positive integers, and and b.
1. a = b
2. a*a = a*b
3. a*a - b*b = a*b - b*b
4. (a-b)(a+b) = b(a-b)
5. a+b = b
6. b+b = b since a = b
7. 2b = b
8. 2 = 1
The error is in step 5, where we divided both sides by (a-b), which is 0.
Division by 0 is undefined.
Logic errors.
Example: "Prove" that if n is even then n^2 is even.
1. Suppose n^2 is even.
2. Then n^2 = 2k for some integer k.
3. Let n = 2k' for some integer k'.
4. Then n is even.
Error is in step 3, where we assumed the thing we are trying to prove.
This shows you can have a wrong proof of a true statement.
------------------------------------------------------------------------
1.7 Proof Methods and Strategy
------------------------------------------------------------------------
Exhaustive Proof
----------------
Frequently the same argument does not work for all possible cases
appearing in the statement. So we have to consider different cases.
Sometimes, the number of different cases we have to consider is
quite small, and each case consists of just one instance.
Then all we have to do is prove the result for each instance.
Example: Prove that (n+1)^2 >= 3^n if n is a positive integer
with n <= 4.
We only have 4 instances to consider, n = 1, 2, 3, and 4.
Check n = 1: (1+1)^2 >= ? 3^1
4 >= 3
Check n = 2, 3, and 4 similarly.
Humans can (reasonably) do exhaustive proof for relatively small
number of instances. Computerized proof systems can do exhaustive
proof for much larger number of instances, but
* must be a finite number of instances and
* must be possible to enumerate the instances.
Proof by Cases
--------------
The same argument does not work in all situations, so we partition
the instances into cases and handle each case separately.
* Each case might have many (even infinite) number of instances,
so this is more general than exhaustive proof
*** Make sure you have covered all the instances! ***
Example: Prove "if n is an integer then n^2 >= n".
Case 1: n = 0. Since 0^2 = 0, 0^2 >= 0.
Case 2: n >= 1. n >= 1 implies n^2 >= n.
Case 3: n <= -1. Since n is negative, n^2 is positive, so n^2 > n.
Notice that we had a different argument in each of the 3 cases,
and the 3 cases cover all situations.
Also notice that the extra information we have for each individual
case helps us to make progress on the argument.
Example: Prove "|x*y| = |x|*|y| where x and y are real numbers".
Proof: Consider all 4 cases depending on whether or x is negative
and whether or not y is negative.
Case 1: x and y are both nonnegative.
|x*y| = x*y = |x|*|y|
Case 2: x is nonnegative and y is negative.
|x*y| = -(x*y) since x*y is negative but the absolute value is nonneg
= x*(-y)
= |x|*|y| since y is negative
Case 3: x is negative and y is nonnegative.
Similar to Case 2 except switch the roles of x and y.
Case 4: x and y are both negative.
|x*y| = x*y since x*y is positive
= (-x)*(-y) since x and y are negative
= |x|*|y|
Notice our cases encompass all possibilities.
Without Loss of Generality
--------------------------
Notice there was some repetition between Cases 2 and 3 above.
We can shorten the proof by combining them into a single case
"one of x and y is positive and the other is negative".
Then we can say WITHOUT LOSS OF GENERALITY (WLOG) let's assume x is the
negative number
*** Be careful! Have to make sure it really *is* without loss of generality.
Existence Proofs
----------------
Many theorems state that an object with certain properties exists.
I.e., ExP(x) where P is a predicate. A proof of such a theorem is
called an EXISTENCE PROOF. There are two kinds:
* constructive proof - give an explicit example of an object with the
desired property
* nonconstructive proof - somehow prove that such an object must exist
without explicitly demonstrating one. Most common way is to use
proof by contradiction: assume that there is no such object and
get a contradiction. Can be less "satisfying" than a constructive
proof but sometimes this is all that you can do.
Example: Prove "there is a positive integer that can be written as
the sum of cubes in two different ways."
Proof: 1729 = 10^3 + 9^3 = 12^3 + 1^3.
(Can find this after considerable computation, e.g., computer search).
Example: Prove "there exist irrational numbers x and y such that x^y
is rational."
Proof:
* by a previous example we know that sqrt(2) is irrational.
* Case 1: sqrt(2)^sqrt(2) is rational.
Then let x and y both be sqrt(2). (The statement did not say
they had to be *different* irrational numbers.)
* Case 2: sqrt(2)^sqrt(2) is irrational.
Then let x = sqrt(2)^sqrt(2) and y = sqrt(2).
Check that x^y = 2, which is rational.
Notice that the two cases cover all the possibilities.
At the end we know that either Case 1 or Case 2 gives us our desired
x and y, but we don't know which.
Example: The textbook describes a 2-player game called Chomp.
It is not too hard to give a non-constructive proof that there exists
a winning strategy for the game, but that is not very helpful
if you actually want to win. So far, no one has been able to give
a constructive proof of a winning strategy.
Uniqueness Proofs
-----------------
Some theorems state that there is exactly one element with a certain
property. A proof of such a theorem is called a UNIQUENESS PROOF.
Strategy here is
(1) show that an element x with the desired property exists
(2) show that any other y (y != x) does not have the property.
I.e., if x and y both have the property, then x must equal y.
Example: Prove "if a and b are real numbers and a != 0, then there
is a unique real number r such that ar + b = 0."
Proof:
(1) Show such an r exists: Let r = -b/a.
(2) Show that if s satisfies as + b = 0, then it must be that s = r.
* Suppose as + b = 0.
...
[[ probably skip this example - not very motivating ]]
Practical Proof Strategies
--------------------------
* replace terms by their definitions
* analyze what the hypotheses and conclusion mean
* first, try a direct proof
* if that fails, try an indirect proof (e.g., contrapositive)
* if that fails, try proof by contradiction
Whichever method you use, you have a starting point and a goal.
How to get to the goal?
Sometimes it is easier to work backwards from the goal.
Example: Arithmetic mean is (x+y)/2
Geometric mean is sqrt(x*y)
Prove "arithmetic mean is always greater than geometric mean".
Proof: More precisely, we want to show (x+y)/2 > sqrt(x*y) whenever
x and y are distinct positive real numbers.
Let's start with the goal and do some algebra:
(x+y)/2 > sqrt(x*y)
(x+y)^2/4 > x*y
(x+y)^2 > 4xy
x^2 + 2xy + y^2 > 4xy
x^2 - 2xy + y^2 > 0
(x-y)^2 > 0.
So as long as x - y is not 0 (i.e., x and y are distinct), the
final inequality is true.
We can work all these inequalities "backwards" and get a direct proof:
Suppose x and y are distinct real numbers.
1. (x - y)^2 > 0
2. So x^2 - 2xy + y^2 > 0
3. So x^2 - 2xy + y^2 + 4xy > 4xy
4. So x^2 + 2xy + y^2 > 4xy
5. So (x+y)^2 > 4xy
6. So (x+y)^2/4 > xy
7. So (x+y)/2 > sqrt(xy).
In this proof, you look like a genius - how did you know to add 4xy
to both sides in step 3? Etc.
If you are still stuck, try a combination of forward and backward
reasoning: if the goal is to prove p -> q, see if you can find an r
s.t. p -> r -> q. By breaking up the problem this way, you might
get easier subproblems (e.g., prove p -> r and prove r -> q separately).
Adapting Existing Proofs:
------------------------
Stand on the shoulder of giants! Why reinvent the wheel?
See if there are some existing proofs that you can modify (maybe only
a little) to prove what you need to prove.
Looking for Counter-examples
----------------------------
A CONJECTURE is a statement whose truth value is unknown.
Determining whether a conjecture is true or false can be a two-pronged
process. You can alternately try to prove it is correct and to prove
that it is false. When trying to prove it is false, one approach is
to look for a counter-example.
* If your attempt to find a proof that it is true fails, see if there
is anything in your proof attempt that might guide you to find a
counter-example.
* If your attempt to find a counter-example fails, see if there is
anything in your attempt that might guide you to find a proof that
the conjecture is true.