Download 9-27-2016 - Stanford University

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Foundations of mathematics wikipedia , lookup

Gödel's incompleteness theorems wikipedia , lookup

Turing's proof wikipedia , lookup

Truth-bearer wikipedia , lookup

Law of thought wikipedia , lookup

Theorem wikipedia , lookup

Mathematical proof wikipedia , lookup

Transcript
Writing proofs for MATH 61CM, 61DM
Week 1: basic logic, proof by contradiction, proof by induction
written by Sarah Peluse, revised by Evangelie Zachos and Lisa Sauermann
September 27, 2016
1
Introduction
A proof is a mathematical argument for why a statement is true. In contrast to more
subjective disciplines, concepts in math have rigorous descriptions and deductions must be
100% logically sound. The purpose of writing a proof is to communicate your argument to
others. Therefore, it is important for you to learn how to write clear proofs that other people
can understand. Math involves a lot of writing, and the standards for grammar and clarity
are the same as in any other field. In particular, always write in complete sentences.
Writing proofs is a separate skill from problem solving. When you do not have much
experience writing proofs, many homework-type problems can appear to be much harder
than they actually are. In these proof writing sections, we’ll cover the proof strategies you
will need to know for this class so that this artificial difficulty disappears. The formalisms
you see in proofs are actually there to make your job easier, and with a little practice you
will become fluent in them.
Today we will cover basic logical terms and two general proof techniques: proof by
contradiction and proof by induction. For each topic we’ll present a proof of a simple
result and break down the purpose of each line, except in the section on induction, for
which instead there is an extended explanation and proof template. There will also be a
more proof examples without the breakdown, and a collection of optional exercises. These
optional exercises are meant to be easier than the homework assignment, so that they can
serve as a warm-up if you are getting stuck.
2
Basic logic and notation
This section will introduce some terms from classical logic and the corresponding notation.
The basic mathematical proposition format is “if P, then Q.” For example,
• If n is an integer, then 2n is an integer.
• If n is an integer, then n + 1 is an integer.
• If n is a positive integer, then n + 1 is a positive integer.
1
• * If n is an integer, then n + 1 is a positive integer.
[This is a false statement! Propositions can sometimes be false.]
Sometimes these statements are written slightly differently, as “Q if P”, or even with the the
symbol =⇒ instead. For example:
n is an integer =⇒ 2n is an integer.
Even if a proposition “if P, then Q” is true, that does not mean that the converse “if Q, then
P” is true. For example, using the three true statements above and taking the converse:
• *If 2n is an integer, then n is an integer. [FALSE]
• If n + 1 is an integer, then n is an integer. [TRUE]
• *If n + 1 is a positive integer, then n is a positive integer. [FALSE]
If both the proposition and the converse are true, then the statement “P if and only if Q”
(equivalently “Q if and only if P”) is true. This statement can also be written as “P iff Q”
or “P ⇐⇒ Q”. For example:
n is an integer if and only if n + 1 is an integer.
n is an integer iff n + 1 is an integer.
n is an integer ⇐⇒ n + 1 is an integer.
If you are proving an if and only if statement, or an equivalence, your proof will usually need
to have two parts: one for the if part and one for the only if part.
Although “P =⇒ Q” and “Q =⇒ P” are not equivalent statements, there is a statement
equivalent to “P =⇒ Q” that is often useful when proving things. This statement is called
the contrapositive and goes as follows:
if not Q, then not P.
Examples:
• If 2n is not an integer, then n is not an integer.
• If n + 1 is not an integer, then n is not an integer.
• If n + 1 is not a positive integer, then n is not a positive integer.
Finally, we want to introduce two quantifiers, which you will see more of next week. These
are “for all” and “there exists”. Often choosing the right quantifier can make a statement
true or false, interesting or boring. Here are some examples:
• For all integers n, 2n is an integer. [TRUE]
• There exists an integer n so that 2n is an integer. [TRUE BUT DUMB]
2
• *For all integers n, n/2 is an integer. [FALSE]
• There exists an integer n so that n/2 is an integer. [TRUE]
There are also symbols for these two qualifiers. ∀ means for all and ∃ means there exists.
• ∀ integers n, 2n is an integer.
• ∃ an integer n so that n/2 is an integer.
Finally, there are two abbreviations you might see: (1) i.e. stands for id est and means
“that is” or “in other words”, (2) e.g. stands for exempli gratia and means “for the sake of
example” or “for example”. Here are examples of how to use them:
• 7 is a prime number, i.e. a number divisible only by itself and one.
• We take a prime number, e.g. 5, and . . . .
Note: when in doubt, write things in terms of words instead of symbols or abbreviations.
3
Proving universal statements using definitions
Most mathematical statements that you’ll encounter in your life are universal statements.
These statements say that for all (∀) elements in a particular set, some result holds. For
example:
• The cube of an odd integer is odd.
• If n, m ∈ Z and m is even, then nm is even.
P
2
2
(HW 1, 61CM/DM)
• For n ∈ N, nj=1 j 3 = n (n+1)
4
• For any vectors x, y ∈ Rn , kx − yk2 + kx + yk2 = 2(kxk2 + kyk2 ) (HW 1, 61CM/DM)
are all examples of universal statements. If the set in question is finite, you can prove the
statement by checking each individual element (although you probably do not want to).
However, if the set in question is infinite, then you cannot prove the statement by checking
any number of individual elements. In this case, there are a number of approaches. One is
to prove universal statements using definitions. The best way to start such an approach is
to write down all definitions involved and noodle around until you have a logical proof. Here
are some very simple examples so you can see how this works. (Note: some of the statements
above need techniques in later sections.)
3
3.1
Examples
Proposition. The square of an even integer is a multiple of 4.
Short Proof. Any even integer a can be written as a = 2b for some integer b, and then
a2 = 4b2 . Because b2 is an integer, a2 is a multiple of 4.
Longer Proof. Let a be an even integer. Then a = 2 · b for some integer b. We have
a2 = (2 · b) · (2 · b) = 4 · b2 . Because the product of two integers is an integer and b is an
integer, b2 is an integer. This means that a2 is the product of 4 and an integer, i.e. a2 is a
multiple of 4. Since a was an arbitrary even integer, we conclude that every even integer is
a multiple of four.
We will now break down the longer proof. Which type of proof should you be aiming
for? In general, when writing a proof, you should write every fact that is not completely
obvious to you. Thus your beginning proofs will be a bit longer than proofs that will appear
in class or in books. This tendency is completely fine and is in fact to be encouraged! Short
and clear proofs are a culmination of developed skill, not a starting point.
Let a be an even integer.
Computing 22 , 42 , 62 , and 82 and seeing that they are all multiples of 4 is not a proof,
even though by computing these examples you may see why the proposition should be
true. Our goal is to show that the square of every even integer is a multiple of four, and
to do this we need a “general” even number. Any specific even number will not suffice,
even if we check a million of them. We give our “general” even number the name “a” so
that we can refer to it in our argument.
Then a = 2 · b for some integer b.
This is just a statement of the definition of an even number. Since a is a “general”
even number, the above is really the only information available for us to use. Because
a is a “general” even number, it is the product of 2 and a “general” integer, which we
name “b” so that we can refer to it later.
We have a2 = (2 · b) · (2 · b) = 4 · b2 .
We are interested in what the square of a “general” even number is, so we square our
“general” even number a. The square turns out to be a nice expression, 4 · b2 .
Because the product of two integers is an integer and b is an integer, b2 is an integer.
4
Recall that our goal is to show that a2 is a multiple of 4, since a is our “general” even
integer. We have shown that a2 = 4 · b2 , so we’re done if b2 is an integer, because then a2
has the form of a “general” multiple of 4. You are free to use the fact that the product
of two integers is again an integer without explanation. Because b2 = b · b, b2 is thus an
integer.
This means that a2 is the product of 4 and an integer, i.e. a2 is a multiple of 4.
Putting together the two previous sentences, we see that a2 has the form of a “general”
multiple of 4. Compare and contrast this sentence with the second sentence of the proof.
There we unravel the definition of an even number, and here we “reravel” the definition
of being a multiple of 4.
Since a was an arbitrary even integer, we conclude that every even integer is a multiple
of four.
This line explains and justifies the inclusion of the first sentence of the proof, for we
really have proved that the result holds for any even number. It is also good practice in
to finish a proof by stating the result that you have just proved.
It is nice to include a symbol to indicate the end of a proof. Many books use this box.
Some people instead put Q.E.D., which stands for the Latin quod erat demonstrandum,
meaning “which was to be demonstrated/shown”. This is a translation of the Ancient
Greek phrase, óπρ ´δι δίξαι, originally used by Euclid at the end of his proofs.
Here is a second example of a universal statement and its proof, with a twist.
Proposition. Let n be an integer. If n2 is even, then n is even.
To prove this proposition, we will use a trick from the previous section and prove the contrapositive. Note that this is still an example of a proof of a universal statement using
definitions.
Proof. We will prove the contrapositive: if n is odd, then n2 is odd. If n is odd, then it can be
written as n = 2a+1 where a is an integer. Then n2 = (2a+1)2 = 4a2 +4a+1 = 2(2a2 +2a)+1.
Because 2a2 + 2a is an integer, n2 is an odd integer. Thus any odd number n has an odd
square, and so we conclude by the contrapositive that any even square n2 has an even root
n.
Proposition. The product of two rational numbers is rational.
5
Proof. Let ab , dc ∈ Q. We have
a c
ac
· = .
b d
bd
By definition, a, b, c, d ∈ Z and b, d 6= 0. Since the product of two integers is an integer,
ac, bd ∈ Z. Since neither b nor d is zero, bd 6= 0 as well. This implies that ab · dc = pq , where
p = ac and q = bd are integers and q 6= 0. That is, ab · dc is a rational number. Thus, since
a c
, ∈ Q were arbitrary rational numbers, we conclude that the product of two rational
b d
numbers is rational.
3.2
Exercises
Exercise 1. Prove that the sum of two odd integers is even.
Exercise 2. Prove that the product of two integers which are perfect squares is a perfect
square.
Exercise 3. Prove that the sum of two rational numbers is a rational number.
Exercise 4. If a, b ∈ Z, we say that a divides b if there exists a c ∈ Z such that b = ac. We
use the notation a | b to mean that a divides b. For example, 2 | 4, 3 | −6, and 13 | 143.
• Show that 1 divides any integer.
• Show that any integer divides 0.
• Show that if n is an odd integer, then 4 | n2 − 1.
• Show that if a | b and a | c, then a | (b + c).
• Show that if a | b and b | c, then a | c. That is, the divisibility relation is transitive.
• Show that if d | n and n is odd, then d is odd.
4
Proof by contradiction
Suppose we want to prove some mathematical statement. One strategy is to show that if
the statement weren’t true, then we’d be led to a conclusion that we know to be false. Thus,
statement must be true, for assuming that it is false leads to a contradiction.
4.1
Examples
We start with a simple example to understand this technique.
Proposition. If z ∈ R is irrational, then so is −z.
Proof. Let z ∈ R be irrational. Assume for the sake of contradiction that −z were rational.
. This implies
Then there exist p, q ∈ Z with q 6= 0 such that −z = pq . But then z = − pq = −p
q
that z is rational, which gives a contradiction since we assumed that z was irrational.
6
We will now break down the proof.
Let z ∈ R be irrational.
As in any proof of a universal statement, we take z to be an arbitrary irrational
number.
Assume for the sake of contradiction that −z were rational.
You should signal some way at the beginning of a proof by contradiction that this is
the technique that you are planning to use. After we inform the reader of our strategy,
we state the negation of the result that we are trying to prove. If z were not irrational,
then it would be rational by definition.
Then there exist p, q ∈ Z with q 6= 0 such that −z = pq .
This is the definition of what it means for z to be rational. Since we’re trying to
derive a contradiction from z being rational, we should have to invoke the definition at
some point.
But then z = − pq =
−p
.
q
There is nothing stopping −z from being rational when z ∈ R is arbitrary, but the
proposition we’re trying to prove has us assume that z is irrational. In fact, this is the
only thing we’re assuming, so we must use it some time in the proof. We want to connect
what we know about −z to what we know about z somehow. Since z is just −z times
.
(−1), z must be equal to − pq = −p
q
This implies that z is rational, which gives a contradiction since we assumed that z
was irrational.
The previous line told us that z can be written as the quotient of two integers −p
and q, q 6= 0. So by definition, z is rational. But by hypothesis z is irrational. Since a
number cannot be both rational and irrational, this is a contradiction.
Here are some more substantial examples.
Proposition. There are no integer solutions to the equation x3 + x + 1 = 0.
7
Proof. Assume for the sake of contradiction that x = n is an integer solution of x3 +x+1 = 0.
There are two possibilities. Either n is even or n is odd. If n is even, then n = 2a for some
integer a and then n3 +n+1 = 8a3 +2a+1 = 2(4a3 +a)+1 is odd. If n is odd, then n = 2b+1
for some integer b and then n3 +n+1 = 8b3 +12b2 +6b+1+2b+1+1 = 2(4b3 +6b2 +3b+b+1)+1
is odd. In either case, we have proven that 0 is odd, which gives us a contradiction. Thus
no integer solution to x3 + x + 1 = 0 exists.
Proposition. For every real number x ∈ [0, π/2], sin x + cos x ≥ 1.
Proof. Assume for the sake of contradiction that there exists such an x ∈ [0, π/2] so that
sin x + cos x < 1. By the choice of domain, sin x, cos x ≥ 0 so that sin x + cos x ≥ 0.
Then sin2 x + cos2 x + 2 sin x cos x < 1, and so 2 sin x cos x < 0. This means that either
(sin x) or (cos x) must be less than 0, but that is a contradiction of our choice of x, because
0 ≤ x ≤ π/2. Thus for any x ∈ [0, π/2], sin x + cos x ≥ 1.
4.2
Proofs using the contrapositive vs. proofs by contradiction
See if you can rewrite the proof that for any integer n, n2 is even =⇒ n is even into a
proof by contradiction. In fact any direct proof of the contrapositive can be worked into
a proof by contradiction. Which one you use is a matter of taste. (I prefer proving the
contrapositive generally. It is often shorter.) However, proofs by contradiction are more
general. Let us say you want to prove “if P, then Q.” When proving the contrapositive, you
assume (not Q) and conclude (not P). To rewrite this into a proof by contradiction, you
would assume (P) and (not Q) and derive (not P), which contradicts (P). However, there are
proofs by contradiction which assume (P) and (not Q) but derive a different contradiction.
For example, when we proved that there were no integer solutions to x3 + x + 1 = 0, the
contradiction we derived was not that n was not an integer. Instead, we derived that 0 is an
odd integer. This is an example of a proof that you can not simply rewrite to be a proof of
the contrapositive.
4.3
Exercises
Exercise 5. Prove that there are no rational solutions to the equation x3 + x + 1 = 0.
Exercise 6. Prove that there are no common prime factors of n and n + 1.
√
Exercise 7. Prove that 5 is irrational.
Exercise 8. Let z > 0 be irrational.
√
• Show that z is irrational.
√
• Show that n z is irrational for all integers n ≥ 3 as well.
5
Proof by induction
The second strategy that we’ll cover today is that of proof by induction. If you are interested
in computer science, then this proof strategy will be very important to you in the future.
8
It is easiest to explain the method by presenting an example first. Let’s prove the equality
1 + 2 + · · · + 2n = 2n+1 − 1.
Checking it for the case n = 1 is easy: the left hand side is 1 + 2 = 3, and the right hand
side is 21+1 − 1 = 4 − 1 = 3 as well. Suppose that we have checked it by hand for n up to
10, and have gotten bored of all of the arithmetic. To prove it for the case n = 11, we just
have to note that the left hand side is
(1 + 2 + · · · + 210 ) + 211 ,
and we have already computed 1 + 2 + · · · + 210 : 210+1 − 1 = 211 − 1. Hence,
1 + 2 + · · · + 211 = 211 − 1 + 211 = 2 · 211 − 1 = 212 − 1,
and we have proved the result for n = 11. We can generalize this argument. Suppose that
we have proved the claim for all integers n ≤ k. That is, we have shown that
1 + 2 + · · · + 2n = 2n+1 − 1
for all integers n ≤ k. Then we have all we need to prove the claim for n = k + 1, for
1 + 2 + · · · + 2k+1 = (1 + 2 + · · · + 2k ) + 2k+1 ,
and we know the result for n = k: 1 + 2 + · · · + 2k = 2k+1 − 1. Thus, we can plug it in the
equation above to get
1 + 2 + · · · + 2k+1 = (1 + 2 + · · · + 2k ) + 2k+1 = 2k+1 − 1 + 2k+1 = 2 · 2k+1 − 1 = 2(k+1)+1 − 1,
which gives the claim when n = k + 1.
So we have shown that if the claim holds for n = k, then it also holds for n = k + 1.
We have also shown that it holds for n = 1. Combining these together, we see that it holds
for n = 2. Since it holds for n = 2, it must hold for n = 3. Similarly, since it holds for
n = 3, it must hold for n = 4 as well, and so on. Thus, we have proved the claim for all n ∈ N.
The outline above gives the basic structure of any inductive proof, where you are proving
a statement P(n) with a parameter n. Such a proof needs both a base case, which here
is n = 1, and an inductive step, which proves the desired statement P(k + 1) by assuming
P(k). Often the statement for P(k) is called the inductive hypothesis. Using the inductive
hypothesis to prove P(k + 1) is usually the difficult part. Note that the base case does not
need to be at n = 1. Sometimes it is at n = 0, or n = 2, or n = 10. Whatever base case you
pick, P (n) is true for all n beyond the base case.
What are some examples of statements P(n) that can be proven by induction?
• 1 + 2 + · · · + 2n = 2n+1 − 1
Pn
n(n+1)
.
•
i=0 i =
2
9
• Any positive integer n can be written as a product of prime numbers
• An under-determined system of n linear equations always has a nontrivial solution.
The above explanation is actually a little oversimplified. What do you notice about the
following proof by induction?
Proposition. Every integer n ≥ 2 can be written as a product of prime numbers.
Proof. We prove this statement by induction. The number is 2, so the statement is true
for n = 2. If we assume that the statement is true for all n ≤ k, i.e. that all integers
2 ≤ n ≤ k have a prime factor, we will now prove the same for k + 1. If k + 1 is prime, then
it itself provides a factorization into primes. If k + 1 is not prime, then by definition it equals
k +1 = a×b where both a and b are integers smaller than k +1. By the inductive hypothesis,
both a and b have a factorization into prime numbers. Multiplying these factorizations gives
a factorization of k + 1 into prime numbers, as we wished to show. Thus every integer n ≥ 2
can be written as a product of prime numbers.
First, note that here the base case is n = 2. The statement is false for n = 1, depending
on how you view it. But, more importantly, note that our inductive hypothesis was not
P(k). Instead, it was P(2) and P(3) and P(4) and . . . and P(k). Sometimes this is called
strong induction. It is logically equivalent to the induction presented above, but sometimes
it is much simpler to write!
To help you stay organized, here is a template for writing a proof by induction:
Proof. We proceed by induction on n.
Base case: First we check that P( base case ) is true.
proof of P( base case )
Thus, P( base case ) is true.
Induction step: Suppose that P(n) is true for a general n ≥ base case . We will
show that P(n + 1) is true as well.
proof of P(n + 1)
Thus, P(n + 1) is true. This completes the induction
Can you revise this template to a template for strong induction?
5.1
Examples
Proposition. For x ∈ R and n ∈ Z>0 ,
d n
x
dx
= nxn−1 .
10
Proof. We proceed by induction on n. For the base case we take n = 1. Because x1 = x is
a linear function, its derivative is the constant slope 1 = 1 · x0 . Now, assume the inductive
d n
d n+1
hypothesis that dx
x = nxn−1 . We evaluate dx
x
using the product rule:
d
d
d n+1
x
= xn x + x xn = xn + x(nxn−1 ) = (n + 1)xn
dx
dx
dx
Thus the inductive step is completed, and the statement is proven.
Note that in the next example, the base case is n = 0, instead of n = 1 as above.
Proposition. Let r ∈ R with r 6= 1 and n ∈ Z, n ≥ 0. Then
n
X
ri = 1 + r + r2 + r3 + · · · + rn =
i=0
rn+1 − 1
r−1
Proof. We proceed by induction on n.
P
Base case: First we check the claim when n = 0. We have 0i=0 ri = 1 and
r1 −1
= 1. So indeed
r−1
n
X
rn+1 − 1
i
r =
r−1
i=0
r0+1 −1
r−1
=
holds when n = 0.
Induction step: Suppose that the result holds for a general n ≥ 0. We will now prove
that the result holds for n + 1. We have
!
n+1
n
X
X
ri =
ri + rn+1 .
i=0
By the induction hypothesis,
Pn
i=0
n+1
X
i=0
ri =
rn+1 −1
,
r−1
n
X
ri =
i=0
so
!
ri
+ rn+1
i=0
n+1
−1
+ rn+1
r−1
rn+1 − 1 + (r − 1)rn+1
=
r−1
rn+1 − 1 + rn+2 − rn+1
=
r−1
n+2
r
−1
=
.
r−1
=
r
Thus, the result holds for n + 1. This completes the induction.
11
5.2
Exercises
Exercise 9. Prove by induction that
n
X
i=0
i=
n(n + 1)
.
2
Exercise 10. Prove by induction that
n
X
(2i − 1) = 1 + 3 + · · · + (2n − 1) = n2 .
i=1
That is, the sum of the first n odd numbers equals n2 .
Exercise 11. Prove by induction that for all n ∈ N, 6 | (n3 − n).
6
General tips
These tips will hold in general when you are writing proofs. We’ll remind you of them next
week because they are important! The the purpose of a proof is to communicate an
argument. A common mistake with beginning proof writers is to write down a proof that
is less complete than one they would give verbally. But your writing alone must convey the
argument without you being there to explain what you meant to say. Here are some general
guidelines to follow which will make your proofs clearer and more readable:
• Write in complete, grammatically correct sentences.
• Signal to your reader what you are doing in your proof. That means:
– If you are proving a universal statement about elements in some set (for example,
a vector space), say that you are arguing with a general element of that set. Don’t
just start doing an argument with a vector “v” without saying what v is.
– If you are doing a proof by contradiction, say at the beginning of the proof that
you are doing a proof by contradiction.
– If you are doing a proof by induction, say at the beginning of the proof that you
are doing a proof by induction and clearly label the base case and induction step
somehow.
– If at some point in the proof you want to break the argument up into cases, say
that you are breaking the proof up into cases and label the cases.
– If your proof has multiple parts (for example, an “ ⇐⇒ proof” or showing that
two sets are equal), then before each of these parts state what you are proving.
• If you are handwriting your homework, try to figure out most or all of the proof before
starting to write out your final copy. This technique will make it much easier to signal
effectively.
12