Whenever you have a tautology of the form A-> B, then you have a rule of inference. Given a proposition A, you can infer B.
Proofs are often shown using a multi-column format, where one column is propositions and the next two columns are the rule of inference (or its name, if it is famous enough to have one) and the line number of the propositions it is applied to. If the proposition is given initially, then one writes “Given” or “Hypothesis” as its justification.
Suppose you are given Foo and Foo->Baz and are asked to prove Foo^Baz. Here is the proof:
Line |
Proposition |
Justification |
Applied to |
|
1 |
Foo |
Given |
|
|
2 |
Foo -> Baz |
Given |
|
|
3 |
Baz |
[P^(P->Q)] -> Q Modeus Ponens |
1,2 |
|
4 |
Foo ^ Baz |
P^Q -> P^Q
Conjunction |
1,3 |
You can work forwards from the givens or backwards from the to-be-proved proposition.
Example: Given
Prove
Let
|
|
Proposition |
Justification |
Applied to |
|
1 |
P |
Given |
|
|
? |
|
|
|
Given
Prove
Let
|
|
Proposition |
Justification |
Applied to |
|
1 |
P |
Assume |
|
|
? |
|
|
|
Redo example above
This proof uses a special technique, called proof by cases, which decomposes a proposition of the form AVB into cases A and B, and proves the same conclusion in both cases, then recombines them.
Example: Given
· If I ate spicy food, I will have strange dreams
· If it thunders while I sleep, I will have strange dreams
Prove
· If I do not have strange dreams, then I didn’t eat spicy food and it didn’t thunder last night.
Let
· P=I ate spicy food
· R=it thundered last night
· Q=?
|
|
Proposition |
Justification |
Applied to |
|
1 |
~(~P^~R) |
Assumed |
|
|
2 |
P vR |
Demorgans & double negation |
|
|
3 |
P |
First case |
2 |
|
4 |
P->Q |
Given |
|
|
5 |
Q |
Modeus ponens |
3,4 |
|
6 |
R |
Second case |
2 |
|
7 |
? |
? |
|
|
8 |
? |
? |
? |
|
9 |
Q |
Proof by cases |
2, 5, 8 |
Computer scientists usually do not write the quantifiers explicitly when writing a proof. Nor do they use multiple columns. However, if the proof is done correctly, we can add these details.
Example: Prove that “If n is odd, then n^2 is odd.”
|
|
Proposition |
Justification |
Applied to |
Informal proof |
|
1 |
"n (n is odd) |
Assume |
|
“Suppose that n is odd.” |
|
2 |
"n $k (n = 2k+1) ^ k is integer |
Definition of “odd” |
1 |
“Then n = 2k+1, where k is an integer” |
|
3 |
"n $k (n^2 = (2k+1)^2) |
If x=y, then x^2=y^2 |
2 |
“It follows that n^2=(2k+1)^2…” |
|
4 |
? |
Algebraic manipulation |
? |
“…= 4k^2+k4+1…” |
|
5 |
? |
? |
? |
“…= 2(2k^2+2k)+1.” |
|
6 |
? |
Definition of “odd” |
? |
“therefore, n^2 is odd (it is 1 more than twice an integer).” |
Proof by contradiction can be done with any proposition, P. One assumes ~P and shows that this leads to a contradiction.
For example, prove “If n is an integer and n^3+5 is odd, then n is even” We negate the proposition, obtaining the first line below.
|
|
Proposition |
Justification |
Applied to |
|
1 |
~(if n^3+5 is odd, then n is even) |
Assume |
|
|
2 |
n^3+5 is odd, and ~(n is even) |
~(P->Q) ó P^~Q |
1 |
|
3 |
n is odd |
An integer is either even or odd |
2 |
|
4 |
n^2 is odd |
An earlier theorem: if n is odd, then n^2 is odd |
3 |
|
5 |
n*n^2 is odd |
An earlier theorem: if a and b are odd, then ab is odd |
4 |
|
6 |
n^3 is odd |
Algebraic manipulation |
5 |
|
7 |
(n^3+5) – n^3 is even |
Thm: if a and b are odd, then a-b is even |
6 |
|
8 |
5 is even |
Algebraic manipulation |
7 |
|
9 |
5 is odd |
Fact |
|
|
10 |
Contradiction |
|
8, 9 |
|
11 |
if n^3+5 is odd, then n is even |
Proof by contradiction |
1, 10 |
If the proposition to be proved has an existential quantifier in it, then its proof is called an existence proof. One way to prove such a proposition is to construct a constant that satisfies the proposition when it is substituted for the existentially quantified variable.
Example: Prove “For every n, there is an integer divisible by more than n different prime numbers.” That is, "n $k (k is divisible by more than n different prime numbers)
|
|
Proposition |
Justification |
Applied to |
|
1 |
Let {3, 5, 7, …, pn+1) be the first n+1 prime numbers. |
There are infinitely many prime numbers |
|
|
2 |
Let k = 3*5*…*pn+1 |
You can multiply any number of numbers together |
1 |
|
3 |
k is divisible by pi for all i between 1 and n+1 |
Because pi is a factor of k |
2 |
|
4 |
k is divisible by n+1 different prime numbers |
counting |
3 |
If an existence proof does not actually construct the constant that makes the proposition true, then the proof is called a non-constructive existence proof.