Mathematics for Computer Science:
Logic and Discrete Structures 2013-14
Dr Konrad Dabrowski
Methods of Proof
1. Mathematical proofs. 2
2. Direct proofs. 4
3. Proof by contraposition. 6
4. Proof by contradiction. 10
5. Proof of equivalence. 15
6. Proof by cases. 17
7. Existence proofs. 19
8. Proof by counter-example. 21
9. Applications. 22
10.Induction. 29
Mathematical proofs
• A mathematical proof is a valid argument that establishes the truth of a
mathematical statement.
• A proof is generally constructed using:
– the hypotheses of the theorem (that is, the things assumed to be true in the
theorem that is to be proved)
– axioms known to be true
– previously proved theorems
– rules of inference (that is, allowable rules that can be used to infer new
mathematical statements from existing ones).
• Up until now, we have been considering formal proofs (in logics).
• Now we focus on informal proofs, as applied by humans.
Mathematical Proofs: Slide 2 of 36
Mathematical Proofs: Slide 3 of 36
Theorems
• Theorems are usually stated using an informal version of first-order
logic and often have one of the following structures:
– “Every such-and-such is a such-and-such.”
– “There is a such-and-such that is not a such-and-such.”
– “If something is a such-and-such then it is a such-and-such.”
• Consequently, in order to prove many theorems we utilize our
knowledge of first-order logic.
• Different proof methods are available to us, often depending upon the
structure of the theorem to be proved.
Mathematical Proofs: Slide 4 of 36
Direct proofs
• A direct proof is used to prove theorems of the form:
– “If such-and-such then such-and-such.”
• More generally, theorems of the form:
∀x(P(x) ⇒ Q(x)).
• Essentially, a direct proof is a list of statements starting from P(x) and
ending at Q(x), and where every statement in the list is:
– an axiom
– a previously proved theorem
– an inference of such using a rule of inference.
• Direct proofs, once stated, tend to be easy to check, but often some
insight is required to devise the proof in the first place.
• (Compare this with Resolution, for example, where often there is a
short sequence of resolutions yielding the required result but where it
is not obvious as which resolutions to apply!)
Here is a direct proof of the following theorem:
– “If n is an odd integer then so is n2
.”
Proof Suppose that n is an odd integer.
So, n = 2k + 1, for some integer k.
Thus, n2
= (2k + 1)2
= (2k + 1)(2k + 1) = 4k2
+ 4k + 1.
When we divide n2
by 2 we get 2k2
+ 2k remainder 1.
Thus, n2
is odd. □
Here is a direct proof of the following theorem:
– “If m and n are perfect squares then so is mn.”
Proof Suppose that m and n are perfect squares; so, m = a2
, for
some integer a, and n = b2
, for some integer b.
Thus mn = a2
b2
= (ab)2
, and so mn is a perfect square. □
Mathematical Proofs: Slide 5 of 36
Examples of direct proofs
Mathematical Proofs: Slide 6 of 36
Proof by contraposition
• Proofs by contraposition are generally used to prove theorems of the
form:
∀x(P(x) ⇒ Q(x)).
• The key to a proof by contraposition is the following argument from
first-order logic:
– M is a model of ∀x(P(x) ⇒ Q(x))
iff for every x, M is a model of P(x) ⇒ Q(x)
iff for every x, M is a model of ¬Q(x) ⇒ ¬P(x)
iff M is a model of ∀x(¬Q(x) ⇒ ¬P(x)).
• Thus, if we wish to prove that ∀x(P(x) ⇒ Q(x)) is a theorem then it
suffices to prove that for any value of x, ¬Q(x) ⇒ ¬P(x).
Mathematical Proofs: Slide 7 of 36
Examples of proofs by contraposition
Here is a proof by contraposition of the following theorem:
– “If n is an integer and 3n + 2 is odd then n is odd.”
Proof Assume the negation of what we want to prove; that is,
assume that n is even.
So, n = 2k, for some integer k.
Thus, 3n + 2 = 6k + 2 is even.
Hence, if n is even then 3n + 2 is even; that is, if 3n + 2 is odd then
n is odd. □
• Let’s try and prove the result above with a direct proof.
Suppose that 3n + 2 is odd; so, 3n + 2 = 2k + 1, for some integer k.
So, 3n = 2k – 1 is odd.
Its not so clear as to how to proceed now, as we appear to be back
where we started except we have that 3n is odd as opposed to 3n + 2.
Here is a proof by contraposition of the following theorem:
– “If m and n are integers and mn is even then m is even or n is even.”
Proof Assume that m is odd and n is odd; so, m = 2k + 1, for some
integer k, and n = 2p + 1, for some integer p.
Thus, mn = (2k + 1)(2p + 1) = 4kp + 2k + 2p + 1 = 2(2kp + k + p) + 1
which is odd. □
Here is a proof by contraposition of the following theorem:
– “If n is an integer and n3
+ 5 is odd then n is even.”
Proof Assume that n is odd; so, n = 2k + 1, for some integer k.
Thus, n3
+ 5 = (2k + 1)3
+ 5 = (2k + 1)(4k2
+ 4k + 1) + 5
= 8k3
+ 12k2
+ 6k + 6 = 2(4k3
+ 6k2
+ 3k + 3) which is even. □
Mathematical Proofs: Slide 8 of 36
Examples of proofs by contraposition
• The previous examples show that using one proof method can be
easier than using another; but how do we decide which proof method
to use?
• There is no canonical answer: probably the best approach is to try a
direct proof and if you struggle then try a proof by contraposition!
Consider the following theorem:
– “The sum of two rational numbers is rational.”
Proof Try a direct proof. Let x and y be rational numbers; so, let
x = a/b and let y = c/d, where a, b, c, and d are integers.
Thus, x + y = a/b + c/d = ad/bd + bc/bd = (ad + bc)/bd, which is
rational, and so the direct proof works.
If we tried a proof by contraposition then we would start by considering
the irrational sum of two numbers x + y.
This would not be of very much help! □
Mathematical Proofs: Slide 9 of 36
Which is the easiest method to use?
Mathematical Proofs: Slide 10 of 36
Proof by contradiction
• Suppose that we wish to prove that something, p say, is true.
Suppose also that we know
– something else, q say, to be false
¬p ⇒ q to be true.
The only way that ¬p ⇒ q can be true when q is false is for p to be
true.
The above state of affairs results in a proof by contradiction.
• Look more closely at a proof by contradiction.
It proves that p is true but it does it non-constructively; that is, it does it
not by building a proof that p is true but by showing that if p were false
then we would be able to prove that something known to be false is
true!
Mathematical Proofs: Slide 11 of 36
Examples of proofs by contradiction
Here is a proof by contradiction of the following theorem:
– “√2 is irrational.”
Proof Suppose that √2 is rational; that is, suppose that √2 = a/b,
where a and b are integers and where no integer apart from 1 divides
both a and b.
So, 2 = a2
/b2
, with a2
= 2b2
and a2
even.
Lemma: If a2
is even then a is even.
Proof of lemma [Proof by contraposition] Suppose that a is odd; that
is, a = 2k + 1, for some integer k.
Thus, a2
= (2k + 1)2
= 4k2
+ 4k + 1 = 2(2k2
+ 2k) + 1; consequently, a2
is
odd. □
Now let us continue with our main proof.
Mathematical Proofs: Slide 12 of 36
Examples of proofs by contradiction
Recall, we have that a2
= 2b2
and a2
is even.
So, by our lemma, we have that a is even; that is, a = 2p, for some
integer p.
Hence, 4p2
= 2b2
with b2
= 2p2
; in particular, b2
is even.
Applying our lemma again yields that b is even; so, b = 2q, for some
integer q.
Thus, 2 divides a and 2 divides b, which yields a contradiction.
Hence, our original assumption that √2 is rational cannot be correct;
that is, √2 is irrational. □
• Note: we have not actually constructed a description of the actual
irrational number √2: we have simply shown that it cannot be rational
and therefore must be irrational!
Consider the following theorem:
– “If n is a positive integer and n is odd then 5n + 6 is odd.”
Proof [Direct proof] Let n be odd; so, n = 2k + 1, for some integer k.
Thus, 5n + 6 = 5(2k + 1) + 6 = 10k + 11 = 2(5k + 5) + 1, which is odd.
[Proof by contraposition] Suppose that 5n + 6 is even; so, 5n + 6 = 2k,
for some integer k.
Thus, n + 4n = 2k – 6 and n = 2k – 6 – 4n = 2(k – 3 – 2n), which is
even.
[Proof by contradiction] Let n be odd; that is, n = 2k + 1, for some
integer k.
Suppose that 5n + 6 is even; that is, 5n + 6 = 2p, for some integer p.
Thus, 5(2k + 1) + 6 = 2p; that is, 10k + 5 + 6 = 2p; that is,
11 = 2(p – 5k).
Hence, 11 is even which yields a contradiction; thus, 5n + 6 is odd. □
Mathematical Proofs: Slide 13 of 36
More examples
Mathematical Proofs: Slide 14 of 36
More examples
• Note the structure of our proof by contradiction in the previous
example:
– we wanted to prove p ⇒ q, so we rewrote this as ¬p ∨ q and assumed its
negation, namely p ∧ ¬q, to obtain our contradiction.
Here is a proof by contradiction of the following theorem:
– “There is no rational number r for which r3
+ r + 1 = 0.”
Proof Suppose that r = a/b is rational, where a and b are integers
having no common factor different from 1.
So, a3
/b3
+ a/b + 1 = 0 with a3
+ ab2
+ b3
= 0.
As 0 is even, a3
+ ab2
+ b3
is even.
If a and b are odd then a3
+ ab2
+ b3
is odd – contradiction.
If a is odd and b is even then a3
+ ab2
+ b3
is odd – contradiction.
If a is even and b is odd then a3
+ ab2
+ b3
is odd – contradiction.
So, a and b are even and have a common factor 2 – contradiction. □
Mathematical Proofs: Slide 15 of 36
Proof of equivalence
• Proofs of equivalence have the form p ⇔ q and are usually structured
into two parts:
– p ⇒ q and q ⇒ p.
Consider the following theorem:
– “For any integer n, n is odd if, and only if, n2
is odd.”
Proof [Direct proof] If n is odd then n = 2k + 1, for some integer k.
So, n2
= (2k + 1)2
= 4k2
+ 4k + 1 = 2(2k2
+ 2k) + 1 is odd.
[Proof by contraposition] Conversely, now we wish to prove that if n2
is odd then n is odd.
Suppose n is even; that is, n = 2k, for some integer k.
Thus, n2
= (2k)2
= 2(2k2
) is even. □
Mathematical Proofs: Slide 16 of 36
Examples of proofs by equivalence
Consider the following theorem:
– “If x is a real number then the following are equivalent:
i. x is rational
ii. x/2 is rational
iii. 3x – 1 is rational.”
Proof Suppose that i. holds; so, x = a/b is rational and x/2 = a/2b is
rational. So, ii. holds.
Suppose that ii. holds; so, x/2 = a/b is rational and x = 2a/b is rational.
So, i. holds.
Suppose that i. holds; so, x = a/b is rational and 3x – 1 = 3a/b – 1
= (3a – b)/b is rational. So, iii. holds.
Suppose that iii. holds; so, 3x – 1 = a/b is rational and x = (a + b)/3b is
rational. So, i. holds.
Thus, i. ⇔ ii. and i. ⇔ iii.
Hence, ii. ⇒ i. and i. ⇒ iii.; and iii. ⇒ i. and i. ⇒ ii. So, ii. ⇔ iii. □
Mathematical Proofs: Slide 17 of 36
Proof by cases
• Sometimes the proof of a theorem can be split up into the separate
proofs of a small number of different cases.
Consider the following theorem:
– “For integers a, b, and c, min{a, min{b, c}} = min{min{a, b}, c}, where
min{x, y} is the minimum of x and y.”
Proof [Proof by cases]
Case i. a ≤ b, c.
min{a, min{b, c}} = a and min{min{a, b}, c} = min{a, c} = a. Thus,
min{a, min{b, c}} = min{min{a, b}, c}.
Case ii. b ≤ a, c.
min{a, min{b, c}} = min{a, b} = b and min{min{a, b}, c} = min{b, c} = b.
Thus, min{a, min{b, c}} = min{min{a, b}, c}.
Case iii. c ≤ a, b.
min{a, min{b, c}} = min{a, c} = c and min{min{a, b}, c} = c. Thus,
min{a, min{b, c}} = min{min{a, b}, c}. □
Mathematical Proofs: Slide 18 of 36
Exhaustive checks
• Sometimes a proof by cases is nothing other than an exhaustive
check.
Consider the following theorem:
– “There are no positive cubes less than 1000 that are the sum of the cubes
of two distinct positive integers.”
Proof [Proof by contradiction] Suppose that the theorem is false; so,
a cube x3
involved in the sum must be such that x3
< 1000.
Thus, x < 10 (as 103
= 1000) and the cubes involved in the sum come
from the set {1, 8, 27, 64, 125, 216, 343, 512, 729}.
But no pair of numbers from this set are such that their sum is equal
to another cube from this set – contradiction. □
Mathematical Proofs: Slide 19 of 36
Existence proofs
• Existence proofs tend to be proofs of theorems of the form ∃xP(x).
• In order to prove a theorem of the form ∃xP(x) we can either construct
an actual x such that P(x) holds or we can show that such an x must
exist without actually constructing it.
• The former are called constructive proofs; the latter non-constructive
proofs.
For example, in order to prove the theorem:
– “There is a positive integer that is the sum of all positive integers
less than it.”
we simply write 3 = 1 + 2 to constructively prove this.
On the other hand, consider the following theorem:
– “There exist irrational numbers x and y such that xy
is rational.”
Proof [Non-constructive existence proof] √2 is irrational (we proved
this earlier).
Define z = √2√2
.
Suppose that z is irrational.
So, z√2
= (√2√2
)√2
= (√2)√2√2
= (√2)2
= 2 is rational.
Hence:
– if z is irrational then z√2
is rational
– if z is rational then √2√2
is rational.
Either way, we have our result. □
• Of course, we haven’t actually constructed x and y as in the statement
of the theorem; we’ve just shown that they exist!
Mathematical Proofs: Slide 20 of 36
Non-constructive existence proofs
Mathematical Proofs: Slide 21 of 36
Proof by counter-example.
• Consider a statement of the form ∀xP(x).
• In order to prove it, we need to prove that for every x, P(x) holds.
• In order to disprove it, we need to find some x such that ¬P(x) holds
(or, at least, show that such an x exists); that is, find (the existence of)
a counter-example.
For example, consider the statement:
– “If a and b are rational numbers then ab
is rational.”
Refutation Put a = 2 and b = ½. Then ab
= √2 is irrational. □
Hence, the statement is not a theorem as we have found a counter-
example.
Mathematical Proofs: Slide 22 of 36
Applying our proof techniques
• A tiling of a chess-board (of an as yet
undefined shape) is a placement of black-
and-white dominoes so that every domino
straddles two squares and so that the
board is covered.
• Pictured are two tilings of an 8 × 8 chess-
board and a 10 × 10 chess-board.
• It is trivial to prove that any x × x chess-
board, where x is even, can be tiled (how
might you do this?).
• However, suppose that we have an x × x
chess-board with x odd: can it be tiled?
No; as such a chess-board has an odd
number of squares and any number of
dominoes covers an even number of
squares [proof by contradiction].
Mathematical Proofs: Slide 23 of 36
Applying our proof techniques
• Suppose that our chess-board is a
mutilated 4 × 4 chess-board with a
pair of opposite squares removed.
• Can such a chess-board be tiled?
• We shall try and prove that the
answer is “no”, and we shall try and
obtain a proof by contradiction.
• First, we may assume, without loss of
generality, that it is the top-left and
bottom-right pair of squares that has
been removed.
• Suppose otherwise.
• A simple rotation reduces us to the
situation where it is the top-left and
bottom-right squares that have been
removed.
Mathematical Proofs: Slide 24 of 36
Applying our proof techniques
• [Proof by contradiction] Suppose that a tiling
of our chess-board exists.
• [Proof by cases]
• Case i. A domino covers squares 2 and 3.
This forces the remaining dominoes to be
placed deterministically.
So, squares 13 and 15 cannot be tiled.
• Case ii. A domino covers squares 2 and 6.
This forces the remaining dominoes to be
placed deterministically.
So, square 15 cannot be tiled.
This rules out all possibilities.
Hence, by splitting the proof into 2 cases
and obtaining contradictions, we establish
that the mutilated chess-board cannot be
tiled. □
2 3 4
6 7 8
13 14 15
10 11 12
5
9
Mathematical Proofs: Slide 25 of 36
Another proof
• We can obtain another proof that our
mutilated chessboard cannot by tiled
with dominoes.
• [Proof by contradiction]
• Note that in any tiling of a chessboard
(mutilated or otherwise), every domino
covers a black and a white square.
Thus, if a tiling exists then the number of
white squares must be equal to the
number of black squares.
In our mutilated chessboard this is not
the case; hence, we obtain a
contradiction.
• If there are black squares and white
squares missing then this argument
doesn’t suffice.
2 3 4
6 7 8
13 14 15
10 11 12
5
9
Mathematical Proofs: Slide 26 of 36
Applying our proof techniques
• Let’s try and prove something about tilings of bigger chess-boards.
• Consider the following statement:
– “When a black square and a white square are removed from an 8 × 8
chess-board, the remaining chess-board can always be tiled.”
Here, we are allowing the removal of any black square and any white
square.
• We shall prove that this statement is true.
The statement is of the form ∃xP(x), where x ranges over all possible
placement of tiles (of any back-white-square-mutilated chessboard)
and P(x) holds if, and only if, x is a tiling of the chess-board.
We shall provide a constructive existence proof.
Mathematical Proofs: Slide 27 of 36
Applying our proof techniques
• Number the squares as
shown and note that we
can lie dominoes nose-to-
tail along the path shown
(assuming all squares are
present).
• Note also that squares on
the chess-board alternate
between white and black
along this path.
2 3 4
131415
1 6 7 8
91112
5
1064
181716 2019 2163 22
272829 2526 2462 23
323130 3433 3561 36
414243 3940 3860 37
464544 4847 4959 50
555657 5354 5258 51
Mathematical Proofs: Slide 28 of 36
20
57
Applying our proof techniques
• Remove any black square
b and any white square w.
• Note that the number of
squares between b and w
along the path is even.
Also, the number of
squares along the path
from w to b is even too.
• Thus we can lay dominoes
nose-to-tail and cover all
the squares of the
mutilated chess-board.
• The result follows. □
• How would you generalize
the proof to an x × x chess-
board, where x is even?
2 3 4
131415
1 6 7 8
91112
5
1064
181716 19 2163 22
272829 2526 2462 23
323130 3433 3561 36
414243 3940 3860 37
464544 4847 4959 50
5556 5354 5258 51
Mathematical Proofs: Slide 29 of 36
Induction
• Possibly the most important proof technique in Computer Science is
induction.
• Induction is a technique which allows us to prove statements of the
form ∀nP(n), where n is a positive integer and P is some predicate
depending upon n.
• Induction allows us to make the following inference:
– “If we can prove:
• P(1)
∀ ∀n(P(n) ⇒ P(n + 1))
then we can infer ∀nP(n).”
• It is important to remember that induction is a proof technique and not
a technique for inferring theorems in some logical proof system.
Mathematical Proofs: Slide 30 of 36
Induction
• Proofs by induction come in two parts:
– the base case, that is, P(1)
– the inductive step, that is, proving that if P(n) holds then P(n + 1) holds,
where n is an arbitrary integer.
• The crucial point about the inductive step is that the chosen n is an
arbitrary integer; that is, it can be any integer at all.
• Induction can be thought of as climbing an infinite ladder:
– the base case equates to “I can stand on the bottom rung.”
– the inductive step equates to “whenever I am standing on some rung of the
ladder then I can climb to the next rung.”
If both these statements are true then induction tells us we can climb
the infinite ladder!
Mathematical Proofs: Slide 31 of 36
Examples of proofs by induction
• When tackling proofs by induction, perhaps the most important and
difficult thing to do is to formulate the induction hypothesis; that is,
P(n).
Consider the following theorem:
– “For any positive integer n, 1 + 2 + … + n = n(n + 1)/2.”
Proof [Proof by induction]
Our induction hypothesis, P(n), is:
– “1 + 2 + … + n = n(n + 1)/2”.
Note that as to whether P(n) holds might depend upon the value of n.
Base case: put n = 1 in the inductive hypothesis and see whether it
holds:
– left-hand side is 1
– right-hand side is 1(1 + 1)/2 = 1.
So, P(1) holds.
Mathematical Proofs: Slide 32 of 36
Examples of proofs by induction
Inductive step: suppose that P(n) holds; that is,
– 1 + 2 + … + n = n(n + 1)/2.
Consider P(n + 1).
In order to decide what P(n + 1) states, simply replace the symbol n in
P(n) with n + 1; so, we obtain:
– 1 + 2 + … + (n + 1) = (n + 1)((n + 1) + 1)/2.
We need to show that P(n + 1) holds if P(n) holds.
Take the left-hand side of P(n + 1), namely:
– 1 + 2 + … + (n + 1) = 1 + 2 + … + n + (n + 1)
= n(n + 1)/2 + (n + 1) (since P(n) holds)
= (n + 1)(n + 2)/2.
But this is identical to the right-hand side of P(n + 1), and so P(n + 1)
holds if P(n) does.
Thus, by induction, P(n) holds for every positive integer n. □
Mathematical Proofs: Slide 33 of 36
Examples of proofs by induction
• We shall prove the following theorem using induction:
– “Any rectangular chess-board with an even number of squares can be tiled
with dominoes.”
Proof Let our induction hypothesis P(n) be:
– “For every m < n, either m is odd, or m is even and any rectangular chess-
board with m squares can be tiled with dominoes.”
Base case: P(1) states:
– “for every m < 1, either m is odd, or m is even and any rectangular chess-
board with m squares can be tiled with dominoes”.
But this is vacuously true as there is no m < 1 making the statement
false.
(Note: it is quite often the case that base cases of inductions are
trivial.)
Mathematical Proofs: Slide 34 of 36
Examples of proofs by induction
Inductive step: So, let us suppose that P(n) holds, for some n; that is:
– “For every m < n, either m is odd, or m is even and any rectangular chess-
board with m squares can be tiled with dominoes.”
Consider P(n + 1).
If n + 1 is even then n is odd and so combined with P(n), above, we
must have that:
– “For every m < n + 1, either m is odd, or m is even and any rectangular
chess-board with m squares can be tiled with dominoes.”
So, the interesting situation is when n + 1 is odd, i.e., when n is even.
Consider some rectangular chess-board with n squares. If we can
prove that it can be tiled with dominoes then we are done.
As our rectangular chess-board has an even number n of squares then
either the number of rows is even or the number of columns is even.
Without loss of generality, suppose that the number of rows r is even.
Mathematical Proofs: Slide 35 of 36
Examples of proofs by induction
Consider the chess-board with the squares in the first column
removed.
As the number of rows r is even, the amended chess-board has
n – r < n squares, which is even.
By the induction hypothesis, this amended chess-board can be tiled.
However, this tiling can be extended to the original chess-board by
placing a column of dominoes in the first column of the chess-board.
The result follows by induction. □
amended
chess-
board, tiled
by induction
tiled
first
column
Mathematical Proofs: Slide 36 of 36
Summary
• Much of mathematical reasoning is based upon propositional logic and
first-order logic.
• In day-to-day life we use reasoning based upon these logics all the
time without even realising it.
• The ability to reason is crucial and fundamental to Computer Science,
especially the capacity to automate (mathematical) reasoning.
• Of particular relevance to Computer Science is the constructive nature
of reasoning, for in Computer Science much of our activity is taken up
with building things (such as programs or proofs or data structures or
arguments or …).
• Perhaps the most striking relationship between proofs and programs is
the intimate relationship between induction and recursion, which share
the same intuition: build larger artifacts out of previously-built smaller
ones.

Mcs lecture19.methods ofproof(1)

  • 1.
    Mathematics for ComputerScience: Logic and Discrete Structures 2013-14 Dr Konrad Dabrowski Methods of Proof 1. Mathematical proofs. 2 2. Direct proofs. 4 3. Proof by contraposition. 6 4. Proof by contradiction. 10 5. Proof of equivalence. 15 6. Proof by cases. 17 7. Existence proofs. 19 8. Proof by counter-example. 21 9. Applications. 22 10.Induction. 29
  • 2.
    Mathematical proofs • Amathematical proof is a valid argument that establishes the truth of a mathematical statement. • A proof is generally constructed using: – the hypotheses of the theorem (that is, the things assumed to be true in the theorem that is to be proved) – axioms known to be true – previously proved theorems – rules of inference (that is, allowable rules that can be used to infer new mathematical statements from existing ones). • Up until now, we have been considering formal proofs (in logics). • Now we focus on informal proofs, as applied by humans. Mathematical Proofs: Slide 2 of 36
  • 3.
    Mathematical Proofs: Slide3 of 36 Theorems • Theorems are usually stated using an informal version of first-order logic and often have one of the following structures: – “Every such-and-such is a such-and-such.” – “There is a such-and-such that is not a such-and-such.” – “If something is a such-and-such then it is a such-and-such.” • Consequently, in order to prove many theorems we utilize our knowledge of first-order logic. • Different proof methods are available to us, often depending upon the structure of the theorem to be proved.
  • 4.
    Mathematical Proofs: Slide4 of 36 Direct proofs • A direct proof is used to prove theorems of the form: – “If such-and-such then such-and-such.” • More generally, theorems of the form: ∀x(P(x) ⇒ Q(x)). • Essentially, a direct proof is a list of statements starting from P(x) and ending at Q(x), and where every statement in the list is: – an axiom – a previously proved theorem – an inference of such using a rule of inference. • Direct proofs, once stated, tend to be easy to check, but often some insight is required to devise the proof in the first place. • (Compare this with Resolution, for example, where often there is a short sequence of resolutions yielding the required result but where it is not obvious as which resolutions to apply!)
  • 5.
    Here is adirect proof of the following theorem: – “If n is an odd integer then so is n2 .” Proof Suppose that n is an odd integer. So, n = 2k + 1, for some integer k. Thus, n2 = (2k + 1)2 = (2k + 1)(2k + 1) = 4k2 + 4k + 1. When we divide n2 by 2 we get 2k2 + 2k remainder 1. Thus, n2 is odd. □ Here is a direct proof of the following theorem: – “If m and n are perfect squares then so is mn.” Proof Suppose that m and n are perfect squares; so, m = a2 , for some integer a, and n = b2 , for some integer b. Thus mn = a2 b2 = (ab)2 , and so mn is a perfect square. □ Mathematical Proofs: Slide 5 of 36 Examples of direct proofs
  • 6.
    Mathematical Proofs: Slide6 of 36 Proof by contraposition • Proofs by contraposition are generally used to prove theorems of the form: ∀x(P(x) ⇒ Q(x)). • The key to a proof by contraposition is the following argument from first-order logic: – M is a model of ∀x(P(x) ⇒ Q(x)) iff for every x, M is a model of P(x) ⇒ Q(x) iff for every x, M is a model of ¬Q(x) ⇒ ¬P(x) iff M is a model of ∀x(¬Q(x) ⇒ ¬P(x)). • Thus, if we wish to prove that ∀x(P(x) ⇒ Q(x)) is a theorem then it suffices to prove that for any value of x, ¬Q(x) ⇒ ¬P(x).
  • 7.
    Mathematical Proofs: Slide7 of 36 Examples of proofs by contraposition Here is a proof by contraposition of the following theorem: – “If n is an integer and 3n + 2 is odd then n is odd.” Proof Assume the negation of what we want to prove; that is, assume that n is even. So, n = 2k, for some integer k. Thus, 3n + 2 = 6k + 2 is even. Hence, if n is even then 3n + 2 is even; that is, if 3n + 2 is odd then n is odd. □ • Let’s try and prove the result above with a direct proof. Suppose that 3n + 2 is odd; so, 3n + 2 = 2k + 1, for some integer k. So, 3n = 2k – 1 is odd. Its not so clear as to how to proceed now, as we appear to be back where we started except we have that 3n is odd as opposed to 3n + 2.
  • 8.
    Here is aproof by contraposition of the following theorem: – “If m and n are integers and mn is even then m is even or n is even.” Proof Assume that m is odd and n is odd; so, m = 2k + 1, for some integer k, and n = 2p + 1, for some integer p. Thus, mn = (2k + 1)(2p + 1) = 4kp + 2k + 2p + 1 = 2(2kp + k + p) + 1 which is odd. □ Here is a proof by contraposition of the following theorem: – “If n is an integer and n3 + 5 is odd then n is even.” Proof Assume that n is odd; so, n = 2k + 1, for some integer k. Thus, n3 + 5 = (2k + 1)3 + 5 = (2k + 1)(4k2 + 4k + 1) + 5 = 8k3 + 12k2 + 6k + 6 = 2(4k3 + 6k2 + 3k + 3) which is even. □ Mathematical Proofs: Slide 8 of 36 Examples of proofs by contraposition
  • 9.
    • The previousexamples show that using one proof method can be easier than using another; but how do we decide which proof method to use? • There is no canonical answer: probably the best approach is to try a direct proof and if you struggle then try a proof by contraposition! Consider the following theorem: – “The sum of two rational numbers is rational.” Proof Try a direct proof. Let x and y be rational numbers; so, let x = a/b and let y = c/d, where a, b, c, and d are integers. Thus, x + y = a/b + c/d = ad/bd + bc/bd = (ad + bc)/bd, which is rational, and so the direct proof works. If we tried a proof by contraposition then we would start by considering the irrational sum of two numbers x + y. This would not be of very much help! □ Mathematical Proofs: Slide 9 of 36 Which is the easiest method to use?
  • 10.
    Mathematical Proofs: Slide10 of 36 Proof by contradiction • Suppose that we wish to prove that something, p say, is true. Suppose also that we know – something else, q say, to be false ¬p ⇒ q to be true. The only way that ¬p ⇒ q can be true when q is false is for p to be true. The above state of affairs results in a proof by contradiction. • Look more closely at a proof by contradiction. It proves that p is true but it does it non-constructively; that is, it does it not by building a proof that p is true but by showing that if p were false then we would be able to prove that something known to be false is true!
  • 11.
    Mathematical Proofs: Slide11 of 36 Examples of proofs by contradiction Here is a proof by contradiction of the following theorem: – “√2 is irrational.” Proof Suppose that √2 is rational; that is, suppose that √2 = a/b, where a and b are integers and where no integer apart from 1 divides both a and b. So, 2 = a2 /b2 , with a2 = 2b2 and a2 even. Lemma: If a2 is even then a is even. Proof of lemma [Proof by contraposition] Suppose that a is odd; that is, a = 2k + 1, for some integer k. Thus, a2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1; consequently, a2 is odd. □ Now let us continue with our main proof.
  • 12.
    Mathematical Proofs: Slide12 of 36 Examples of proofs by contradiction Recall, we have that a2 = 2b2 and a2 is even. So, by our lemma, we have that a is even; that is, a = 2p, for some integer p. Hence, 4p2 = 2b2 with b2 = 2p2 ; in particular, b2 is even. Applying our lemma again yields that b is even; so, b = 2q, for some integer q. Thus, 2 divides a and 2 divides b, which yields a contradiction. Hence, our original assumption that √2 is rational cannot be correct; that is, √2 is irrational. □ • Note: we have not actually constructed a description of the actual irrational number √2: we have simply shown that it cannot be rational and therefore must be irrational!
  • 13.
    Consider the followingtheorem: – “If n is a positive integer and n is odd then 5n + 6 is odd.” Proof [Direct proof] Let n be odd; so, n = 2k + 1, for some integer k. Thus, 5n + 6 = 5(2k + 1) + 6 = 10k + 11 = 2(5k + 5) + 1, which is odd. [Proof by contraposition] Suppose that 5n + 6 is even; so, 5n + 6 = 2k, for some integer k. Thus, n + 4n = 2k – 6 and n = 2k – 6 – 4n = 2(k – 3 – 2n), which is even. [Proof by contradiction] Let n be odd; that is, n = 2k + 1, for some integer k. Suppose that 5n + 6 is even; that is, 5n + 6 = 2p, for some integer p. Thus, 5(2k + 1) + 6 = 2p; that is, 10k + 5 + 6 = 2p; that is, 11 = 2(p – 5k). Hence, 11 is even which yields a contradiction; thus, 5n + 6 is odd. □ Mathematical Proofs: Slide 13 of 36 More examples
  • 14.
    Mathematical Proofs: Slide14 of 36 More examples • Note the structure of our proof by contradiction in the previous example: – we wanted to prove p ⇒ q, so we rewrote this as ¬p ∨ q and assumed its negation, namely p ∧ ¬q, to obtain our contradiction. Here is a proof by contradiction of the following theorem: – “There is no rational number r for which r3 + r + 1 = 0.” Proof Suppose that r = a/b is rational, where a and b are integers having no common factor different from 1. So, a3 /b3 + a/b + 1 = 0 with a3 + ab2 + b3 = 0. As 0 is even, a3 + ab2 + b3 is even. If a and b are odd then a3 + ab2 + b3 is odd – contradiction. If a is odd and b is even then a3 + ab2 + b3 is odd – contradiction. If a is even and b is odd then a3 + ab2 + b3 is odd – contradiction. So, a and b are even and have a common factor 2 – contradiction. □
  • 15.
    Mathematical Proofs: Slide15 of 36 Proof of equivalence • Proofs of equivalence have the form p ⇔ q and are usually structured into two parts: – p ⇒ q and q ⇒ p. Consider the following theorem: – “For any integer n, n is odd if, and only if, n2 is odd.” Proof [Direct proof] If n is odd then n = 2k + 1, for some integer k. So, n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1 is odd. [Proof by contraposition] Conversely, now we wish to prove that if n2 is odd then n is odd. Suppose n is even; that is, n = 2k, for some integer k. Thus, n2 = (2k)2 = 2(2k2 ) is even. □
  • 16.
    Mathematical Proofs: Slide16 of 36 Examples of proofs by equivalence Consider the following theorem: – “If x is a real number then the following are equivalent: i. x is rational ii. x/2 is rational iii. 3x – 1 is rational.” Proof Suppose that i. holds; so, x = a/b is rational and x/2 = a/2b is rational. So, ii. holds. Suppose that ii. holds; so, x/2 = a/b is rational and x = 2a/b is rational. So, i. holds. Suppose that i. holds; so, x = a/b is rational and 3x – 1 = 3a/b – 1 = (3a – b)/b is rational. So, iii. holds. Suppose that iii. holds; so, 3x – 1 = a/b is rational and x = (a + b)/3b is rational. So, i. holds. Thus, i. ⇔ ii. and i. ⇔ iii. Hence, ii. ⇒ i. and i. ⇒ iii.; and iii. ⇒ i. and i. ⇒ ii. So, ii. ⇔ iii. □
  • 17.
    Mathematical Proofs: Slide17 of 36 Proof by cases • Sometimes the proof of a theorem can be split up into the separate proofs of a small number of different cases. Consider the following theorem: – “For integers a, b, and c, min{a, min{b, c}} = min{min{a, b}, c}, where min{x, y} is the minimum of x and y.” Proof [Proof by cases] Case i. a ≤ b, c. min{a, min{b, c}} = a and min{min{a, b}, c} = min{a, c} = a. Thus, min{a, min{b, c}} = min{min{a, b}, c}. Case ii. b ≤ a, c. min{a, min{b, c}} = min{a, b} = b and min{min{a, b}, c} = min{b, c} = b. Thus, min{a, min{b, c}} = min{min{a, b}, c}. Case iii. c ≤ a, b. min{a, min{b, c}} = min{a, c} = c and min{min{a, b}, c} = c. Thus, min{a, min{b, c}} = min{min{a, b}, c}. □
  • 18.
    Mathematical Proofs: Slide18 of 36 Exhaustive checks • Sometimes a proof by cases is nothing other than an exhaustive check. Consider the following theorem: – “There are no positive cubes less than 1000 that are the sum of the cubes of two distinct positive integers.” Proof [Proof by contradiction] Suppose that the theorem is false; so, a cube x3 involved in the sum must be such that x3 < 1000. Thus, x < 10 (as 103 = 1000) and the cubes involved in the sum come from the set {1, 8, 27, 64, 125, 216, 343, 512, 729}. But no pair of numbers from this set are such that their sum is equal to another cube from this set – contradiction. □
  • 19.
    Mathematical Proofs: Slide19 of 36 Existence proofs • Existence proofs tend to be proofs of theorems of the form ∃xP(x). • In order to prove a theorem of the form ∃xP(x) we can either construct an actual x such that P(x) holds or we can show that such an x must exist without actually constructing it. • The former are called constructive proofs; the latter non-constructive proofs. For example, in order to prove the theorem: – “There is a positive integer that is the sum of all positive integers less than it.” we simply write 3 = 1 + 2 to constructively prove this.
  • 20.
    On the otherhand, consider the following theorem: – “There exist irrational numbers x and y such that xy is rational.” Proof [Non-constructive existence proof] √2 is irrational (we proved this earlier). Define z = √2√2 . Suppose that z is irrational. So, z√2 = (√2√2 )√2 = (√2)√2√2 = (√2)2 = 2 is rational. Hence: – if z is irrational then z√2 is rational – if z is rational then √2√2 is rational. Either way, we have our result. □ • Of course, we haven’t actually constructed x and y as in the statement of the theorem; we’ve just shown that they exist! Mathematical Proofs: Slide 20 of 36 Non-constructive existence proofs
  • 21.
    Mathematical Proofs: Slide21 of 36 Proof by counter-example. • Consider a statement of the form ∀xP(x). • In order to prove it, we need to prove that for every x, P(x) holds. • In order to disprove it, we need to find some x such that ¬P(x) holds (or, at least, show that such an x exists); that is, find (the existence of) a counter-example. For example, consider the statement: – “If a and b are rational numbers then ab is rational.” Refutation Put a = 2 and b = ½. Then ab = √2 is irrational. □ Hence, the statement is not a theorem as we have found a counter- example.
  • 22.
    Mathematical Proofs: Slide22 of 36 Applying our proof techniques • A tiling of a chess-board (of an as yet undefined shape) is a placement of black- and-white dominoes so that every domino straddles two squares and so that the board is covered. • Pictured are two tilings of an 8 × 8 chess- board and a 10 × 10 chess-board. • It is trivial to prove that any x × x chess- board, where x is even, can be tiled (how might you do this?). • However, suppose that we have an x × x chess-board with x odd: can it be tiled? No; as such a chess-board has an odd number of squares and any number of dominoes covers an even number of squares [proof by contradiction].
  • 23.
    Mathematical Proofs: Slide23 of 36 Applying our proof techniques • Suppose that our chess-board is a mutilated 4 × 4 chess-board with a pair of opposite squares removed. • Can such a chess-board be tiled? • We shall try and prove that the answer is “no”, and we shall try and obtain a proof by contradiction. • First, we may assume, without loss of generality, that it is the top-left and bottom-right pair of squares that has been removed. • Suppose otherwise. • A simple rotation reduces us to the situation where it is the top-left and bottom-right squares that have been removed.
  • 24.
    Mathematical Proofs: Slide24 of 36 Applying our proof techniques • [Proof by contradiction] Suppose that a tiling of our chess-board exists. • [Proof by cases] • Case i. A domino covers squares 2 and 3. This forces the remaining dominoes to be placed deterministically. So, squares 13 and 15 cannot be tiled. • Case ii. A domino covers squares 2 and 6. This forces the remaining dominoes to be placed deterministically. So, square 15 cannot be tiled. This rules out all possibilities. Hence, by splitting the proof into 2 cases and obtaining contradictions, we establish that the mutilated chess-board cannot be tiled. □ 2 3 4 6 7 8 13 14 15 10 11 12 5 9
  • 25.
    Mathematical Proofs: Slide25 of 36 Another proof • We can obtain another proof that our mutilated chessboard cannot by tiled with dominoes. • [Proof by contradiction] • Note that in any tiling of a chessboard (mutilated or otherwise), every domino covers a black and a white square. Thus, if a tiling exists then the number of white squares must be equal to the number of black squares. In our mutilated chessboard this is not the case; hence, we obtain a contradiction. • If there are black squares and white squares missing then this argument doesn’t suffice. 2 3 4 6 7 8 13 14 15 10 11 12 5 9
  • 26.
    Mathematical Proofs: Slide26 of 36 Applying our proof techniques • Let’s try and prove something about tilings of bigger chess-boards. • Consider the following statement: – “When a black square and a white square are removed from an 8 × 8 chess-board, the remaining chess-board can always be tiled.” Here, we are allowing the removal of any black square and any white square. • We shall prove that this statement is true. The statement is of the form ∃xP(x), where x ranges over all possible placement of tiles (of any back-white-square-mutilated chessboard) and P(x) holds if, and only if, x is a tiling of the chess-board. We shall provide a constructive existence proof.
  • 27.
    Mathematical Proofs: Slide27 of 36 Applying our proof techniques • Number the squares as shown and note that we can lie dominoes nose-to- tail along the path shown (assuming all squares are present). • Note also that squares on the chess-board alternate between white and black along this path. 2 3 4 131415 1 6 7 8 91112 5 1064 181716 2019 2163 22 272829 2526 2462 23 323130 3433 3561 36 414243 3940 3860 37 464544 4847 4959 50 555657 5354 5258 51
  • 28.
    Mathematical Proofs: Slide28 of 36 20 57 Applying our proof techniques • Remove any black square b and any white square w. • Note that the number of squares between b and w along the path is even. Also, the number of squares along the path from w to b is even too. • Thus we can lay dominoes nose-to-tail and cover all the squares of the mutilated chess-board. • The result follows. □ • How would you generalize the proof to an x × x chess- board, where x is even? 2 3 4 131415 1 6 7 8 91112 5 1064 181716 19 2163 22 272829 2526 2462 23 323130 3433 3561 36 414243 3940 3860 37 464544 4847 4959 50 5556 5354 5258 51
  • 29.
    Mathematical Proofs: Slide29 of 36 Induction • Possibly the most important proof technique in Computer Science is induction. • Induction is a technique which allows us to prove statements of the form ∀nP(n), where n is a positive integer and P is some predicate depending upon n. • Induction allows us to make the following inference: – “If we can prove: • P(1) ∀ ∀n(P(n) ⇒ P(n + 1)) then we can infer ∀nP(n).” • It is important to remember that induction is a proof technique and not a technique for inferring theorems in some logical proof system.
  • 30.
    Mathematical Proofs: Slide30 of 36 Induction • Proofs by induction come in two parts: – the base case, that is, P(1) – the inductive step, that is, proving that if P(n) holds then P(n + 1) holds, where n is an arbitrary integer. • The crucial point about the inductive step is that the chosen n is an arbitrary integer; that is, it can be any integer at all. • Induction can be thought of as climbing an infinite ladder: – the base case equates to “I can stand on the bottom rung.” – the inductive step equates to “whenever I am standing on some rung of the ladder then I can climb to the next rung.” If both these statements are true then induction tells us we can climb the infinite ladder!
  • 31.
    Mathematical Proofs: Slide31 of 36 Examples of proofs by induction • When tackling proofs by induction, perhaps the most important and difficult thing to do is to formulate the induction hypothesis; that is, P(n). Consider the following theorem: – “For any positive integer n, 1 + 2 + … + n = n(n + 1)/2.” Proof [Proof by induction] Our induction hypothesis, P(n), is: – “1 + 2 + … + n = n(n + 1)/2”. Note that as to whether P(n) holds might depend upon the value of n. Base case: put n = 1 in the inductive hypothesis and see whether it holds: – left-hand side is 1 – right-hand side is 1(1 + 1)/2 = 1. So, P(1) holds.
  • 32.
    Mathematical Proofs: Slide32 of 36 Examples of proofs by induction Inductive step: suppose that P(n) holds; that is, – 1 + 2 + … + n = n(n + 1)/2. Consider P(n + 1). In order to decide what P(n + 1) states, simply replace the symbol n in P(n) with n + 1; so, we obtain: – 1 + 2 + … + (n + 1) = (n + 1)((n + 1) + 1)/2. We need to show that P(n + 1) holds if P(n) holds. Take the left-hand side of P(n + 1), namely: – 1 + 2 + … + (n + 1) = 1 + 2 + … + n + (n + 1) = n(n + 1)/2 + (n + 1) (since P(n) holds) = (n + 1)(n + 2)/2. But this is identical to the right-hand side of P(n + 1), and so P(n + 1) holds if P(n) does. Thus, by induction, P(n) holds for every positive integer n. □
  • 33.
    Mathematical Proofs: Slide33 of 36 Examples of proofs by induction • We shall prove the following theorem using induction: – “Any rectangular chess-board with an even number of squares can be tiled with dominoes.” Proof Let our induction hypothesis P(n) be: – “For every m < n, either m is odd, or m is even and any rectangular chess- board with m squares can be tiled with dominoes.” Base case: P(1) states: – “for every m < 1, either m is odd, or m is even and any rectangular chess- board with m squares can be tiled with dominoes”. But this is vacuously true as there is no m < 1 making the statement false. (Note: it is quite often the case that base cases of inductions are trivial.)
  • 34.
    Mathematical Proofs: Slide34 of 36 Examples of proofs by induction Inductive step: So, let us suppose that P(n) holds, for some n; that is: – “For every m < n, either m is odd, or m is even and any rectangular chess- board with m squares can be tiled with dominoes.” Consider P(n + 1). If n + 1 is even then n is odd and so combined with P(n), above, we must have that: – “For every m < n + 1, either m is odd, or m is even and any rectangular chess-board with m squares can be tiled with dominoes.” So, the interesting situation is when n + 1 is odd, i.e., when n is even. Consider some rectangular chess-board with n squares. If we can prove that it can be tiled with dominoes then we are done. As our rectangular chess-board has an even number n of squares then either the number of rows is even or the number of columns is even. Without loss of generality, suppose that the number of rows r is even.
  • 35.
    Mathematical Proofs: Slide35 of 36 Examples of proofs by induction Consider the chess-board with the squares in the first column removed. As the number of rows r is even, the amended chess-board has n – r < n squares, which is even. By the induction hypothesis, this amended chess-board can be tiled. However, this tiling can be extended to the original chess-board by placing a column of dominoes in the first column of the chess-board. The result follows by induction. □ amended chess- board, tiled by induction tiled first column
  • 36.
    Mathematical Proofs: Slide36 of 36 Summary • Much of mathematical reasoning is based upon propositional logic and first-order logic. • In day-to-day life we use reasoning based upon these logics all the time without even realising it. • The ability to reason is crucial and fundamental to Computer Science, especially the capacity to automate (mathematical) reasoning. • Of particular relevance to Computer Science is the constructive nature of reasoning, for in Computer Science much of our activity is taken up with building things (such as programs or proofs or data structures or arguments or …). • Perhaps the most striking relationship between proofs and programs is the intimate relationship between induction and recursion, which share the same intuition: build larger artifacts out of previously-built smaller ones.