Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Proof and Logic

How mathematics establishes that something is true: the logic of statements and quantifiers, the standard methods of proof, and the sets, functions and relations every later course is written in.

Why prove anything

A pattern that holds in every case anyone has checked feels like a fact, and in mathematics it can still be false.

This lesson starts with three such patterns, each of which survived far longer than anyone would need to be convinced, and each of which failed. They are the reason mathematics settles its claims by proof rather than by evidence. The second half of the lesson says what a proof is, why it starts from definitions, and writes the first few out in full. It assumes school algebra and nothing else.

Forty primes, then a square

In 1772 Euler noticed that the expression n2+n+41 produces primes with remarkable persistence. At n=0 it gives 41, then 43, 47, 53, 61, 71, and every value up to n=39, where it gives 1601, is prime. Forty consecutive successes is more than most people would ask before believing a rule.

At n=40 the value is 1681, and 1681=412. Once it has happened it is easy to see why. Write the expression at n=40 with the first two terms grouped: 402+40=40(40+1)=40×41, so the whole thing is 40×41+41=41×41.

The same thought shows that n=41 fails too: every term of 412+41+41 is a multiple of 41, and the value is 1763=41×43. The structure that breaks the pattern was visible in the formula from the start. The forty checks established forty facts and said nothing about the forty-first, because nothing in them said why the values were prime. A check tells you what happened, not what must happen.

Doubling that stops at thirty-one

Place points on a circle and join every pair with a straight chord, taking care that no three chords pass through the same interior point. Count the regions the chords cut the disc into. One point makes no chord, so there is 1 region. Two points give one chord and 2 regions. Three points give a triangle and 4 regions, four points give 8, and five give 16.

The sequence 1,2,4,8,16 is as clean a pattern as mathematics offers, and the obvious guess is that six points give 32. They give 31, and no arrangement of six points does better. (If the six points are the corners of a regular hexagon, the three long diagonals meet at the centre, which breaks the rule about three chords, and the count drops to 30.)

Here too the failure makes sense once the right quantity is counted. Add the chords one at a time. A new chord that crosses k chords already drawn passes through k+1 existing regions and splits each of them in two, so it adds k+1 regions. Summing over all the chords, the total is 1 for the starting disc, plus 1 for each chord, plus 1 for each crossing point. With n points there are (n2) chords (one per pair of points, so n(n-1)/2), and every choice of four points produces exactly one crossing (where the diagonals of their quadrilateral meet), so there are (n4) crossings. For six points that is 1+15+15=31, and for seven it is 1+21+35=57, nowhere near 64.

The powers of two were a coincidence of small numbers: 2n-1 and 1+(n2)+(n4) agree up to five points and then part company. The argument rests on the sentence "every choice of four points produces exactly one crossing", and a careful reader should want that sentence justified. Justifying sentences like it is what this course is about.

Nine hundred million confirmations

Perhaps people should simply check more. The third pattern answers that. Count the prime factors of a whole number with repeats, so that 12=2×2×3 has three and 9=3×3 has two, and give 1 zero. Among the numbers from 1 to 10, five (2, 3, 5, 7 and 8) have an odd number of prime factors, and up to 100 it is fifty-one.

In 1919 George Pólya conjectured that this always happens: for every n greater than 1, at least half of the numbers from 1 to n have an odd number of prime factors. It was checked by hand and later by machine over enormous ranges, and it held for every n anyone tested.

In 1958 Brian Haselgrove proved that it fails somewhere, by an argument that showed a counterexample exists without producing one. In 1980 Minoru Tanaka found the first one by computer. It is 906,150,257. Up to that number, 453,075,128 have an odd number of prime factors and 453,075,129 have an even number, so the odd ones are outnumbered by one. Every n from 2 to 906,150,256 obeys the conjecture.

A claim about every natural number is a claim about infinitely many cases, and any finite collection of checks, however large, leaves infinitely many unchecked. Nine hundred million confirmations are exactly as far from infinity as forty. Evidence, which is how the empirical sciences rightly work, cannot establish a mathematical claim of this kind. It can refute one: a single failure, such as 1681 or Tanaka's number, disposes of a claim about every case completely.

What a proof is

A proof is a finite chain of statements, each of which is justified by one of three things: a definition, an axiom (a statement taken as a starting point and not argued for), or a result that has already been proved. The last statement in the chain is the claim. Because every link is justified, the claim cannot fail in any case the chain covers, and one chain can cover infinitely many cases.

A proof is not an argument that makes the claim plausible, and it is not a picture: the chords on a circle suggested 32 and delivered 31. What a proof offers is checkability. A reader can take each line, ask what justifies it, and find the answer in a definition, an axiom or an earlier theorem. If every line survives that question, the reader has no choice but to accept the conclusion, without needing to trust the writer.

This is the trade mathematics makes. Its conclusions hold only under the stated assumptions, and within them they are permanent. Euclid's proof that there are infinitely many primes, written around 300 BCE, is as correct now as it was then, which no measurement from that century can claim.

Proofs in this course are written in sentences. Symbols appear where they are clearer, but words such as "suppose", "since" and "so" carry the argument, because they say which statement follows from which. A column of bare equations often hides exactly the step that needed justifying.

Definitions do the work

A proof starts from definitions. This is the habit that most separates proof from school mathematics: a word such as "even" stops being something you recognise and becomes an exact statement you can use.

An integer n is even if there is an integer k with n=2k. An integer n is odd if there is an integer k with n=2k+1. Everything this lesson proves about parity comes from those two sentences and the ordinary rules of algebra for integers, such as the fact that sums and products of integers are integers and that multiplication distributes over addition.

The definition settles questions that recognition leaves vague. Is 0 even? Yes, since 0=2×0. Is -3 odd? Yes, since -3=2×(-2)+1. The school test "the last digit is 0, 2, 4, 6 or 8" agrees, but it is a fact about base-ten notation and would need its own proof before it could be used.

Notice also what the definitions do not say. Nothing in them states that every integer is even or odd, or that no integer is both. Both are true, but both need proofs of their own, which rest on division with remainder, and a proof that quietly relies on them before they are proved is incomplete.

The word "some" in the definitions matters too. To show a number is even you must produce the k, or show that one exists. To use the fact that a number is even you may name its k and work with it. That is the whole mechanism of the proofs below.

A first proof

The sum 3+5=8 is even, and so is 7+11=18, but those are evidence. The goal is an argument that covers every pair at once.

Example. Prove that the sum of two odd integers is even.

Let a and b be odd integers. By the definition of odd, there is an integer k with a=2k+1, and there is an integer m with b=2m+1. Then a+b=(2k+1)+(2m+1)=2k+2m+2=2(k+m+1). Since k and m are integers, k+m+1 is an integer. So a+b is twice an integer, and by the definition of even, a+b is even.

Three details are worth copying. It names arbitrary odd integers, so nothing is assumed about them except that they are odd. It uses two different letters, k and m, because a and b need not be equal; one letter would have proved the claim only for a number added to itself. And its last sentence names the definition it has satisfied, so the reader sees the chain close.

Now you. Prove that the sum of an even integer and an odd integer is odd.

Answer

Let a be an even integer and b an odd integer. By the definitions, there is an integer k with a=2k and an integer m with b=2m+1. Then a+b=2k+2m+1=2(k+m)+1. Since k+m is an integer, a+b has the form twice an integer plus one, so by the definition of odd, a+b is odd.

Example. Prove that the product of two odd integers is odd.

Let a and b be odd integers, so that a=2k+1 and b=2m+1 for some integers k and m. Then ab=(2k+1)(2m+1)=4km+2k+2m+1=2(2km+k+m)+1. Since k and m are integers, so is 2km+k+m. Therefore ab is twice an integer plus one, and by the definition of odd, ab is odd.

Now you. Prove that if a is an even integer and b is any integer, then ab is even.

Answer

Let a be an even integer and b any integer. By the definition of even, there is an integer k with a=2k. Then ab=2kb=2(kb). Since k and b are integers, kb is an integer, so ab is twice an integer and, by the definition of even, ab is even.

Proving that a pattern fails

Proof can also show that a pattern fails, and why, far beyond a single counterexample. For this the definitions needed are those of prime and composite: an integer greater than 1 is prime if its only positive divisors are 1 and itself, and composite if it is the product of two integers each greater than 1.

Example. Prove that n2+n+41 is composite whenever n is a positive multiple of 41.

Let n be a positive multiple of 41, so that n=41m for some integer m≥1. Then n2+n+41=412m2+41m+41=41(41m2+m+1). The first factor, 41, is greater than 1. Since m≥1, the second factor is at least 41+1+1=43, so it is greater than 1 as well. Therefore n2+n+41 is a product of two integers each greater than 1, and by definition it is composite.

No amount of checking could do this: the proof shows Euler's expression fails at n=41, 82, 123 and infinitely many other values, and why.

Now you. Prove that n2+n+41 is composite whenever n=41m+40 for some integer m≥0. (At m=0 this is the failure at n=40.)

Answer

Let n=41m+40 with m≥0 an integer. Expanding, n2=1681m2+3280m+1600, so n2+n+41=1681m2+3321m+1681=41(41m2+81m+41). The factor 41 is greater than 1, and since m≥0 the second factor is at least 41, so it is greater than 1 too. So n2+n+41 is a product of two integers each greater than 1, and is composite.

What the proofs needed

Every proof in this lesson began by working out what its claim actually asserted. "The sum of two odd integers is even" turned out to mean: for any integers a and b, if a is odd and b is odd, then a+b is even. Hidden in that ordinary sentence are an "if ... then" and a "for any", and the proof's shape came from them: take arbitrary a and b, assume they are odd, and reach the conclusion. Refuting Pólya's conjecture needed the same precision in reverse: knowing that one n with fewer than half is enough means knowing exactly what the negation of "for every n" says.

So statements have to be read exactly: "and", "or", "not" and "if ... then" do not always mean in mathematics what they mean in conversation. The next lesson fixes those meanings, and the conditional, the "if ... then" that every theorem is written in, turns out to mean something that surprises almost everyone the first time.

Statements and connectives

The words that build mathematical claims, "not", "and", "or", "if ... then", mean something slightly different in conversation every time they are used, and a proof cannot rest on a word whose meaning moves.

The previous lesson unpacked "the sum of two odd integers is even" into a claim with an "if ... then" inside it, and its proofs worked only because it was clear what that claim asserted. This lesson makes that clarity routine. It says which sentences can be true or false, fixes the meaning of each connective with a truth table, and spends most of its time on the conditional, the connective every theorem is written in. It assumes school algebra and the definitions of even and odd: an integer is even when it equals 2k for some integer k, and odd when it equals 2k+1.

Statements

A statement is a sentence that is either true or false. "91 is prime" is a statement, and a false one, since 91=7×13. "210>1000" is a true one, since 210=1024. What matters is that the sentence has a truth value, not that anyone knows it. "Every even integer greater than 2 is the sum of two primes" is Goldbach's conjecture, proposed in a letter to Euler in 1742 and checked by computer for every even number up to 4×1018. Nobody knows whether it is true, but it is certainly one or the other, so it is a statement.

Plenty of mathematical sentences are not statements. "Is 91 prime?" is a question and "Let n=91" is an instruction. The subtler case is a sentence with a free variable, such as "x>3", which is true when x=5, false when x=1, and has no truth value until x is pinned down. Such a sentence is an open sentence. Turning open sentences into statements is the job of the next lesson; this one works with statements, or with open sentences read for one value of the variable at a time.

Statements are written with capital letters, P, Q, R, so that the structure of a claim can be seen apart from its content. The rules below depend only on whether each part is true or false, never on what it says.

Not, and, or

Each connective is defined by saying, for every combination of truth values of its parts, whether the compound is true. With two parts there are four combinations, and a truth table lists them, one per row.

Negation, written ¬P and read "not P", is true exactly when P is false. Conjunction, P∧Q, read "P and Q", is true exactly when both parts are true. Disjunction, P∨Q, read "P or Q", is true when at least one part is true, including when both are.

PQ¬PP∧QP∨Q
TTFTT
TFFFT
FTTFT
FFTFF

The last column is the one that departs from conversation. "Soup or salad" on a menu usually means one but not both. In mathematics "or" is always inclusive, and the sentences mathematicians write show why. The rule "if ab=0 then a=0 or b=0" must not exclude a=b=0, and "n is divisible by 2 or by 3" is true of 6. When the exclusive sense is wanted it is spelt out: "P or Q but not both", which is (P∨Q)∧¬(P∧Q).

The negation of a statement is whatever is true in exactly the cases where the statement is false, and ordinary language often reaches for an opposite instead. The negation of "x>3" is "x≤3", not "x<3": at x=3 both "x>3" and "x<3" are false, so the second cannot be the negation of the first. And "x≤3" is itself a disjunction, "x<3 or x=3".

Negating a compound statement

Two compound statements are equivalent when they have the same truth value in every row of their truth table. Since the table lists every case, checking the rows is a complete proof. Note that ¬(P∧Q), which denies the whole conjunction, is a different thing from ¬P∧Q, where ¬ applies only to P.

The most useful equivalences say how to negate an "and" or an "or". To deny that two things both hold is to say that at least one fails, and to deny that at least one holds is to say that both fail. These are De Morgan's laws, after Augustus De Morgan, who stated them in 1847, and they are what a proof needs whenever it must say what the failure of a condition looks like.

Example. Show that ¬(P∧Q) and ¬P∨¬Q are equivalent, and use this to negate "x>0 and x<5".

Compute both columns in each of the four rows.

PQP∧Q¬(P∧Q)¬P¬Q¬P∨¬Q
TTTFFFF
TFFTFTT
FTFTTFT
FFFTTTT

The fourth and seventh columns agree in every row, so the two statements are equivalent. Now let P be "x>0" and Q be "x<5". The negation of P∧Q is ¬P∨¬Q, and the negations of the parts are "x≤0" and "x≥5". So the negation of "x>0 and x<5" is "x≤0 or x≥5".

Now you. Show that ¬(P∨Q) and ¬P∧¬Q are equivalent, and use this to negate "x<0 or x>1".

Answer

P∨Q is false only in the row where P and Q are both false, so ¬(P∨Q) is true in that row and false in the other three. ¬P∧¬Q is true only when ¬P and ¬Q are both true, which is the same row. The columns agree in all four rows, so the statements are equivalent. The negation of "x<0 or x>1" is therefore "x≥0 and x≤1", that is, 0≤x≤1.

The common error is to negate the parts and leave the connective alone. "Not (x>0 and x<5)" is not "x≤0 and x≥5", which no number satisfies. Negating a compound always turns "and" into "or" or the reverse.

The conditional

The fourth connective is the conditional, P⇒Q, read "if P then Q" or "P implies Q". P is the hypothesis and Q the conclusion. The fifth is the biconditional, P⟺Q, read "P if and only if Q", which is true when P and Q have the same truth value.

PQP⇒QP⟺Q
TTTT
TFFF
FTTF
FFTT

The first two rows of the conditional need no defence. "If n is divisible by 4, then n is even" is kept by a number divisible by 4 that is even, and would be broken by one divisible by 4 that is odd: a true hypothesis with a false conclusion is exactly what it means for an implication to fail.

The last two rows are the ones that surprise. Whenever the hypothesis is false, the conditional is true, whatever the conclusion, so "if 2+2=5, then 7 is even" is a true statement. A conditional true because its hypothesis is false is called vacuously true. It looks like a convention, and slightly at odds with sense, but no other choice would let mathematics state its theorems.

Why a false hypothesis gives a true conditional

Take a theorem nobody doubts: for every integer n, if n is divisible by 4, then n is even. It claims something about every integer, so it is true only if each instance, one conditional per integer, is true. At n=8 the instance has a true hypothesis and a true conclusion. At n=6 the hypothesis is false and the conclusion true. At n=7 both are false. If either of the last two instances counted as false, this theorem would be false, and so would nearly every theorem of the form "if ... then", since nearly any hypothesis fails for some values. Those rows have to be true for mathematics to be sayable at all.

Nothing else could go in them either. Making both rows false turns P⇒Q into P∧Q, so the theorem would assert that n is divisible by 4. Making only the false-true row false turns it into P⟺Q, so the theorem would claim every even number is divisible by 4, which 6 refutes. Making only the false-false row false gives a column identical to Q, and the hypothesis would do nothing.

The conditional asserts no connection between its parts: "if 2+2=5, then 7 is even" is true though its halves are unrelated. In mathematics that costs nothing, because the connection is what the proof supplies. The table also tells a proof where to look. A conditional can fail only in the row where P is true, so to prove P⇒Q it is enough to assume P and show that Q follows, which is what the previous lesson did when it began "let a and b be odd".

That same row gives the negation. Since P⇒Q is false only when P is true and Q false, its negation is P∧¬Q. The negation of an implication is not another implication: it says the hypothesis holds and the conclusion fails, which is what a counterexample exhibits.

Example. Negate "if n is prime, then n is odd", decide whether the conditional is true for n=2, n=9 and n=7, and say what this shows.

The negation is "n is prime and n is even", since ¬(P⇒Q) is P∧¬Q. For n=2 the hypothesis is true and the conclusion false, so the conditional is false, and its negation is true: 2 is prime and even. For n=9 the hypothesis is false, since 9=3×3, so the conditional is vacuously true. For n=7 both parts are true and so is the conditional. The claim "every prime is odd" is therefore false, and n=2 is the counterexample: an integer at which the negation holds.

Now you. Negate "if x>2, then x2>4", and decide whether the conditional is true for x=3, x=-3 and x=1.

Answer

The negation is "x>2 and x2≤4". At x=3 both x>2 and x2=9>4 hold, so the conditional is true. At x=-3 the hypothesis fails, so the conditional is vacuously true, even though x2=9>4. At x=1 the hypothesis and the conclusion both fail, and again the conditional is vacuously true. None of the three makes the negation true.

Converse, inverse and contrapositive

Swapping and negating the parts of P⇒Q gives three new conditionals: the converse Q⇒P, the inverse ¬P⇒¬Q, and the contrapositive ¬Q⇒¬P. Their tables settle which say the same thing as the original.

PQP⇒Q¬Q⇒¬PQ⇒P¬P⇒¬Q
TTTTTT
TFFFTT
FTTTFF
FFTTTT

The contrapositive agrees with the original in every row, so the two are equivalent. The converse and inverse agree with each other and differ from the original in the middle two rows. So a proof of ¬Q⇒¬P is a proof of P⇒Q, which a later lesson turns into a method, while a proof of P⇒Q says nothing about Q⇒P. Treating it as if it did is the commonest logical error in student proofs.

Example. Write the converse, inverse and contrapositive of "if n is divisible by 6, then n is divisible by 3", and decide which are true for every integer n.

The statement is true: if n=6k for an integer k, then n=3(2k), and 2k is an integer. The converse is "if n is divisible by 3, then n is divisible by 6", which is false, since n=3 is divisible by 3 and not by 6. The inverse is "if n is not divisible by 6, then n is not divisible by 3", and n=3 refutes it too, as it must, being equivalent to the converse. The contrapositive is "if n is not divisible by 3, then n is not divisible by 6", which is true because it is equivalent to the original.

Now you. For real numbers x, write the converse, inverse and contrapositive of "if x>3, then x2>9", and decide which are true.

Answer

The statement is true: if x>3 then x is positive, so x2=x⋅x>3x>3⋅3=9. The converse, "if x2>9 then x>3", is false, since x=-4 gives x2=16>9 with x<3. The inverse, "if x≤3 then x2≤9", is false by the same x=-4. The contrapositive, "if x2≤9 then x≤3", is true, being equivalent to the original.

Necessary, sufficient and only if

When P⇒Q holds, P is a sufficient condition for Q: having P guarantees Q. And Q is a necessary condition for P: without Q there is no P, which is the contrapositive read aloud. Divisibility by 6 is sufficient for divisibility by 3, and divisibility by 3 is necessary for divisibility by 6. These are one fact seen from its two ends.

"P only if Q" also means P⇒Q. "Only" marks the necessary condition, which is the conclusion: "n is divisible by 4 only if n is even" says divisibility by 4 cannot happen without evenness. By contrast "P if Q" means Q⇒P. The two are opposite, so together they make "if and only if": P⟺Q is the same as (P⇒Q)∧(Q⇒P), a condition both necessary and sufficient. That is why proving an "if and only if" takes two proofs, one per direction.

One convention catches every newcomer. Definitions are written with "if", as in "an integer n is even if n=2k for some integer k", but a definition is always read as "if and only if". The previous lesson used its definitions in both directions, producing a k from an even number and concluding evenness from a k, and was right to.

What connectives cannot say

The five connectives are now fixed, and the negation of each compound can be written down mechanically. Yet the argument for the conditional's table used something no connective contains. "For every integer n, if n is divisible by 4, then n is even" is not a conditional between two statements, since "n is divisible by 4" is an open sentence; the phrase "for every integer n" is what made the whole a true statement. Refuting "every prime is odd" needed the opposite phrase: there is a prime that is even. Nearly every theorem is about all numbers or some number, and neither "all" nor "some" can be built from the five connectives. The next lesson adds them, with rules for negating them that turn "not every" into "some fails".

Quantifiers

Nearly every theorem is a claim about all numbers of some kind or about at least one of them, and the connectives of the previous lesson have no way to say either.

That lesson fixed the meaning of "not", "and", "or", "implies" and "if and only if", and closed on a sentence they could not build: "for every integer n, if n is divisible by 4, then n is even". This lesson adds "for every" and "there exists", gives the rules for negating them, and shows that their order changes what is said. It ends with the definition of a limit, negated symbol by symbol.

Open sentences and the two quantifiers

A sentence such as "x2>4" has no truth value until x is fixed: it is true when x=3 and false when x=1. Such an open sentence is written P(x), so that P(3) is a true statement and P(1) a false one.

Two quantifiers turn an open sentence into a statement. The universal quantifier ∀x, read "for all x", makes ∀xP(x), which is true when P(x) is true for every value of x. The existential quantifier ∃x, read "there exists an x", makes ∃xP(x), which is true when P(x) is true for at least one value.

"At least one" is the exact reading of ∃. It does not mean exactly one, and it does not hint that not all: "there is an even integer" is true, though there are infinitely many. As with inclusive "or", the weaker reading is the default.

Often the quantifier is not written at all. "If n is divisible by 4, then n is even" is printed as a theorem with no "for all", and every reader supplies "for every integer n". A proof has to put it back, because "every n" and "some n" call for different proofs.

The domain is part of the claim

"For all x" always means all x in some collection, the domain, and changing the domain changes the claim. Take "x2≥x for every x". Over the integers it is true: if x≤0 then x2≥0≥x, and if x≥1 then multiplying x≥1 by the positive number x gives x2≥x. Over the reals it is false, since x=12 gives x2=14. Likewise "there is an x with x2=2" is true over the reals and false over the rationals, which a later lesson proves.

So mathematicians write the domain into the quantifier: ∀x∈ℤ, ∃x∈ℝ, with ℕ, ℤ, ℚ and ℝ for the natural numbers, integers, rationals and reals. This course takes ℕ to start at 1.

A claim often concerns part of a domain, as in "every prime greater than 2 is odd", and the two quantifiers restrict in different ways. A restricted universal uses a conditional: ∀n(nis prime∧n>2⇒nis odd). A value that fails the restriction makes the conditional vacuously true, so it is let through. A restricted existential uses a conjunction: "some prime is even" is ∃n(nis prime∧nis even), which needs one value with both properties.

Swapping the connectives destroys the claim. ∀n(nis prime∧nis odd) says every integer is an odd prime, which 4 refutes. ∃n(nis prime⇒nis even) is made true by n=4, which is not prime, so it says nothing about primes at all. The shorthands ∀x>0 and ∃n≥N abbreviate exactly these patterns: ∀x>0P(x) means ∀x(x>0⇒P(x)), and ∃n≥NP(n) means ∃n(n≥N∧P(n)).

Negating a quantified statement

To deny that every x has a property is to say that some x lacks it, and to deny that some x has it is to say that every x lacks it:

¬∀xP(x)≡∃x¬P(x)¬∃xP(x)≡∀x¬P(x)

These are the previous lesson's De Morgan laws, stretched. Over a domain of three objects a, b and c, ∀xP(x) is P(a)∧P(b)∧P(c), and De Morgan turns its negation into ¬P(a)∨¬P(b)∨¬P(c), which is ∃x¬P(x). The quantifier laws say the same holds when the domain is infinite.

Negation is therefore mechanical: move the ¬ inwards, and every quantifier it passes changes kind. When it reaches the open sentence at the end, the previous lesson's rules apply: "and" becomes "or", and ¬(P⇒Q) becomes P∧¬Q. The domain and the restrictions do not change. The negation of ∀x>0P(x) is ∃x¬(x>0⇒P(x)), which is ∃x(x>0∧¬P(x)), or ∃x>0¬P(x): the ">0" rides along untouched.

The mistake this prevents is turning "not every" into "none". "Not every prime is odd" is true, because of 2. "No prime is odd" is false, because of 3.

Example. Symbolise "every positive real number x satisfies x2≥x", negate it, and decide which of the two is true.

Over the reals, the claim is ∀x(x>0⇒x2≥x). Passing the negation through the quantifier gives ∃x¬(x>0⇒x2≥x), and negating the conditional gives ∃x(x>0∧x2<x): some positive real number has a square smaller than itself. The negation is true, because x=12 is positive and x2=14<12. So the original claim is false.

Now you. Symbolise "every real number x with x2=x satisfies x=1", negate it, and decide which of the two is true.

Answer

The claim is ∀x(x2=x⇒x=1). Its negation is ∃x¬(x2=x⇒x=1), which is ∃x(x2=x∧x≠1): some real number equals its own square without being 1. The negation is true, because 02=0 and 0≠1. So the original claim is false.

Counterexamples

The negation of ∀xP(x) is ∃x¬P(x), and an existential statement is proved by producing one value. So one value at which P fails, a counterexample, refutes a universal claim however many other values it holds for. For a restricted claim ∀x(P(x)⇒Q(x)), a counterexample must satisfy the hypothesis and fail the conclusion; a value that fails the hypothesis refutes nothing.

In 1640 Pierre de Fermat wrote that every number 22n+1 is prime. The cases n=0 to 4 give 3, 5, 17, 257 and 65537, all prime. In 1732 Euler showed that the next, 232+1=4294967297, equals 641×6700417, and that one line settles the matter.

The other direction has no such shortcut. No number of examples proves a universal claim over an infinite domain: n2+n+41 is prime for every n from 0 to 39 and equals 412 at n=40, and Pólya's conjecture about prime factors held for every number below 906,150,257. Existential claims are the mirror image. One example proves "some prime is one more than a square", namely 5=22+1, while refuting an existential claim needs a proof about every value. Knowing which kind of statement is in hand says in advance whether an example will be enough.

The order of quantifiers

An open sentence in two variables, like "y>x", needs two quantifiers. Two of the same kind can come in either order; when they are mixed, the order is part of the meaning.

Over the integers, "every integer has a larger one" is ∀x∃y(y>x), and "some integer is larger than all of them" is ∃y∀x(y>x). The first is true and the second false, and the symbols differ only in order. In ∀x∃y the y is found after x is known, so it may depend on x: for 7 take 8, for 1000 take 1001. In ∃y∀x the y is fixed first and must then work against every x at once.

It helps to read quantifiers as a game: a sceptic picks the values under ∀ and a prover those under ∃, in the order written, and the statement is true when the prover can always win. Committing early is a handicap, so ∃y∀xP(x,y) implies ∀x∃yP(x,y): one y that beats every x answers each x in turn. The integers show the converse fails. Negation still works one quantifier at a time, so ¬∀x∃yP(x,y) is ∃x∀y¬P(x,y).

Example. Over the integers, decide whether ∀x∃y(y>x) and ∃y∀x(y>x) are true, and prove each answer.

The first is true. Let x be any integer and take y=x+1. Then y is an integer and y-x=1>0, so y>x. As x was arbitrary, the statement holds.

The second is false, so prove its negation, ∀y∃x(y≤x). Let y be any integer and take x=y. Then y≤x. As y was arbitrary, no integer is larger than all integers, not even than itself.

Now you. Over the integers, decide whether ∀x∃y(x+y=0) and ∃y∀x(x+y=0) are true, and prove each answer. Does the first stay true over ℕ?

Answer

The first is true: for any integer x, the integer y=-x gives x+y=0.

The second is false. Suppose some integer y had x+y=0 for every integer x. Then x=0 gives y=0 and x=1 gives y=-1, a contradiction.

Over ℕ the first is false: x=1 would need y=-1, which is not a natural number.

The limit of a sequence

Quantifier order is the whole content of the definition calculus rests on. A sequence a1,a2,a3,… converges to a real number L when

∀ε>0∃N∈ℕ∀n≥N(|an-L|<ε)

As a game: the sceptic names a tolerance ε, the prover answers with a position N, the sceptic picks any term from position N on, and the prover wins if it lies within ε of L. Since ∃N follows ∀ε, the position may depend on the tolerance, and it must. For an=1n and L=0, the tolerance 0.01 is met from N=101, since 1101<0.01 while 1100 is not, and 0.001 needs N=1001. Swap the first two quantifiers and one N must serve every ε at once. Then each |an-L| with n≥N is below every positive number, so it is 0, and the sequence equals L exactly from N on. Under that reading 1n would not converge to 0.

To negate the definition, move the ¬ in one symbol at a time. ∀ε>0 becomes ∃ε>0, keeping its restriction. ∃N∈ℕ becomes ∀N∈ℕ. ∀n≥N becomes ∃n≥N. Finally |an-L|<ε becomes |an-L|≥ε. So an does not converge to L when

∃ε>0∀N∈ℕ∃n≥N(|an-L|≥ε)

that is, some tolerance is broken by a term beyond every starting point. A disproof must therefore supply one ε, and a way to answer every N with a suitable n.

Example. Prove that an=(-1)n does not converge to 1.

Prove the negation with L=1. Take ε=1. Let N be any natural number and take n=2N+1. Then n≥N and n is odd, so an=-1 and |an-1|=2≥1. Since N was arbitrary, the negation holds.

Now you. Prove that an=1n does not converge to 1.

Answer

Prove the negation with L=1. Take ε=12. Let N be any natural number and take n=N+1. Then n≥N and n≥2, so |an-1|=1-1n≥1-12=12. Since N was arbitrary, the negation holds.

From what a claim says to how to prove it

Any statement in this course can now be written with quantifiers over a stated domain, and its negation computed rather than guessed.

The proofs above had shapes dictated by their quantifiers: a "for all" was met by letting the variable be arbitrary, a "there exists" by naming a value. But each step was a line of arithmetic. Knowing exactly what "the square of every odd integer is one more than a multiple of 8" claims does not say how to establish it. The next lesson turns those shapes into a method, the direct proof.

Direct proof and proof by cases

Knowing exactly what a statement claims does not tell you how to establish it, and most statements worth proving are conditionals about every number of some kind.

The previous lesson gave the language: "for all", "there exists", and the rules for negating them. It closed on a claim it could state but not prove, that the square of every odd integer is one more than a multiple of 8. This lesson supplies the method, the direct proof, and proves that claim along the way. It works with two definitions, divisibility and parity, then splits proofs into cases, and proves that things exist, both by producing them and without saying what they are.

Assume the hypothesis, reach the conclusion

A conditional P⇒Q is false in exactly one situation: P true and Q false. So to prove it, there is only one situation to rule out. Assume P, and derive Q from it, using definitions, axioms and results already proved. If P happens to be false, the conditional is true anyway, which is why a proof never has to say anything about that case. This is a direct proof: it starts at the hypothesis and walks forward to the conclusion.

Most theorems are also universal. "If an integer is divisible by 4, it is even" means ∀n∈ℤ(4dividesn⇒nis even), and no list of cases can cover every n. The move that does is to let n be arbitrary: name an integer n, assume nothing about it except the hypothesis, and reason about it. Whatever follows then follows for every integer, because nothing in the argument depended on which one was named. The proofs in the previous lesson that ended "as x was arbitrary, the statement holds" used exactly this.

Together these fix the opening and closing lines of almost every proof in this course. The first sentence names the arbitrary object and states the hypothesis: "Let n be an integer divisible by 4." The last sentence states the conclusion and says which definition it satisfies: "so n is even." Everything in between is the work, and each line of it must be justified by what came before.

Once n is named, the proof may not quietly assume it is positive, or prime, or small, unless the hypothesis says so. Checking n=4, 8 and 12 is not a proof about an arbitrary n; it is three examples.

Finding a proof usually runs the other way. On scrap paper, write the conclusion out by its definition, so that "n is even" becomes "n=2× (some integer)", and ask what would produce that expression. Then write the argument forwards, from hypothesis to conclusion, for the reader. The scrap paper is how you found the route; the proof is the route.

Divisibility

For integers a and b, a divides b, written a∣b, if there is an integer k with b=ak. So 3∣12 because 12=3×4, and -4∣12 because 12=(-4)(-3). Every integer divides 0, since 0=a×0, and 1 divides every integer. On the other hand 0∣b only when b=0, since 0×k is always 0.

Two points about the notation catch almost everyone once. First, a∣b is a statement, true or false, while ba is a number: "3∣12" is true, and writing "3∣12=4" mixes a sentence with a calculation. Second, the order matters: 3∣12 is true and 12∣3 is false, because no integer k gives 3=12k.

The definition has the same shape as the definitions of even and odd from the first lesson of this course, a "there is an integer k", and it is used in the same two ways. To use a∣b, name the k and write b=ak. To prove a∣b, produce an integer k with b=ak. Parity is a special case: an integer n is even exactly when 2∣n.

Example. Prove that for all integers a, b and c, if a∣b and b∣c, then a∣c.

Let a, b and c be integers with a∣b and b∣c. By the definition of divisibility, there is an integer k with b=ak, and there is an integer m with c=bm. Substituting the first equation into the second gives c=(ak)m=a(km). Since k and m are integers, km is an integer. So c is a times an integer, and by the definition of divisibility, a∣c.

The two quotients get different letters, k and m, because nothing says they are equal. The scrap-paper route was short: the goal asked for c in terms of a, and the hypotheses chain c to b and b to a. This property, transitivity, lets divisibility pass along a chain: from 3∣12 and 12∣60, without any division, 3∣60.

Now you. Prove that for all integers a, b and c, if a∣b and a∣c, then a∣(bx+cy) for all integers x and y.

Answer

Let a, b and c be integers with a∣b and a∣c, and let x and y be any integers. By the definition of divisibility, there are integers k and m with b=ak and c=am. Then bx+cy=akx+amy=a(kx+my). Since k, m, x and y are integers, kx+my is an integer, so by the definition of divisibility, a∣(bx+cy). Taking x=y=1 gives a∣(b+c), and taking x=1, y=-1 gives a∣(b-c).

Proof by cases

Sometimes no single argument covers every value, but a few arguments do, each covering part. A proof by cases splits the hypothesis into possibilities that together exhaust it, and gives a direct proof in each. Its logic is the rule for "or": if P1∨P2 holds, and P1⇒Q and P2⇒Q both hold, then Q holds.

The commonest split is by parity, which rests on a fact taken as known here: every integer is even or odd, and none is both. (That fact comes from division with remainder, not from the definitions alone.) Take the claim that n2+n is even for every integer n.

Let n be an integer. If n is even, then n=2k for some integer k, and n2+n=4k2+2k=2(2k2+k), which is even. If n is odd, then n=2k+1 for some integer k, and n2+n=(4k2+4k+1)+(2k+1)=2(2k2+3k+1), which is even. Since n is even or odd, n2+n is even in every case.

A result once proved becomes a tool. Here is the previous lesson's open claim. Let n be an odd integer, so n=2k+1 for some integer k. Then n2=4k2+4k+1=4(k2+k)+1. By the result just proved, applied to the integer k, there is an integer m with k2+k=2m. So n2=8m+1, and 8∣(n2-1). For n=7 that is 49=8×6+1, and for n=11 it is 121=8×15+1. No case split was needed in this proof; the one inside the lemma did the work.

The triangle inequality

The absolute value of a real number is itself defined by cases: |x|=x if x≥0, and |x|=-x if x<0. So any claim about absolute values invites a proof by cases on signs, because in each case the bars can be replaced by something plain.

Example. Prove that |x+y|≤|x|+|y| for all real numbers x and y.

Let x and y be real numbers. There are three cases, according to their signs.

If x≥0 and y≥0, then x+y≥0, so |x+y|=x+y=|x|+|y|.

If x<0 and y<0, then x+y<0, so |x+y|=-(x+y)=(-x)+(-y)=|x|+|y|.

If one is non-negative and the other negative, the claim is symmetric in x and y, so we may suppose x≥0>y. Then |x|=x and |y|=-y. Now |x+y| is either x+y or -(x+y). In the first event, x+y<x≤x-y=|x|+|y|, since y<0. In the second, -(x+y)=-x-y≤-y≤x-y=|x|+|y|, since x≥0.

The three cases exhaust all pairs of real numbers, and the inequality holds in each, so it holds for all x and y.

Two things make a case split sound. The cases must between them cover everything, which is why "one non-negative and one negative" had to be there; checking only the first two cases would prove nothing about x=3, y=-5. And "we may suppose" is honest only when the omitted case is the same argument with the letters swapped. The cases may overlap harmlessly, but none may be missing.

Now you. Prove that |xy|=|x||y| for all real numbers x and y.

Answer

Let x and y be real numbers. If x≥0 and y≥0, then xy≥0, so |xy|=xy=|x||y|. If x<0 and y<0, then xy>0, so |xy|=xy=(-x)(-y)=|x||y|. Otherwise one is non-negative and one negative; the claim is symmetric, so suppose x≥0>y. Then xy≤0, so |xy|=-xy=x(-y)=|x||y| (when xy=0 both readings of |xy| give 0). The cases cover every pair, so the equation always holds.

Proving that something exists

A claim ∃xP(x) is proved most plainly by producing an x and checking P(x). Such a proof is constructive. When the claim is ∀k∃n, the n may depend on k, so the proof must give a recipe.

Take the claim that for every natural number k there are k consecutive natural numbers, none of them prime. Let k be a natural number and write N=(k+1)!, the product 1×2×⋯×(k+1). Consider the k numbers N+2,N+3,…,N+(k+1). Each has the form N+j with 2≤j≤k+1. Then j∣N, since j is one of the factors of N, and j∣j, so j∣(N+j) by the Now you on divisibility. As 2≤j<N+j, the number N+j has a divisor other than 1 and itself, so it is not prime.

For k=5 the recipe gives N=720 and the run 722 to 726. It is far from the first such run, which is 24 to 28. A constructive proof must produce a witness, not the best one.

Existence without a witness

Some existence proofs never say which object works. Here is the classic, which assumes that 2 is irrational (the next lesson proves it).

Example. Prove that there are irrational numbers a and b with ab rational.

Consider the real number 22. It is either rational or irrational. If it is rational, take a=b=2: both are irrational and ab=22 is rational. If it is irrational, take a=22 and b=2, both irrational, and then ab=(22)2=22⋅2=22=2, which is rational. In either case a suitable pair exists.

This is a proof by cases in which the cases are never resolved. It establishes that one of two pairs works without saying which, so it is non-constructive. The answer is known from outside the proof: Aleksandr Gelfond and Theodor Schneider showed, independently in the 1930s, that 22 is irrational, so the second pair is the one. Some mathematicians, the constructivists, reject such proofs, because they rest on the claim that every statement is true or false even when nobody can say which.

Now you. Given that 2 and log29 are irrational, give a constructive proof of the same claim.

Answer

Take a=2 and b=log29, both irrational. Since 2=212, we get ab=212log29=2log23=3, using 12log29=log2912=log23. So ab is rational, and this time the pair is named.

Where the direct route stalls

Every proof above ran forwards: unpack the hypothesis by its definition, then rearrange until the conclusion's definition appears. Try the same on "for every integer n, if n2 is even then n is even". Let n be an integer with n2 even, so n2=2k for some integer k. The goal is n=2× (an integer), and all the hypothesis offers is n=±2k, which is not visibly twice anything.

The hypothesis is about n2 and the conclusion is about n, and information does not flow backwards through squaring. Cases on the parity of n only help by ruling the odd case out, which is a different method in disguise. The statement is true, and the next lesson proves it by turning the conditional round, the same move that proves 2 irrational.

Contrapositive and contradiction

Some true statements give a direct proof nothing to work with, because the hypothesis says nothing usable about the thing the conclusion is about.

The previous lesson proved conditionals by assuming the hypothesis and walking forward from definitions, and it ended on a claim that walk cannot finish: for every integer n, if n2 is even then n is even. It also used, without proof, the fact that 2 is irrational. This lesson pays both debts with two indirect methods, proof by contrapositive and proof by contradiction, proves Euclid's theorem that there are infinitely many primes, and says how to choose a method. It assumes the definitions of even, odd and divisibility: n is even when n=2k for some integer k, odd when n=2k+1, and a∣b when b=ak for some integer k.

Turning the conditional round

The contrapositive of P⇒Q is ¬Q⇒¬P, and a truth table shows the two are true in exactly the same rows. So a proof of the contrapositive is a proof of the original, not an approximation to one. A proof by contrapositive is a direct proof aimed at that equivalent statement: assume ¬Q, and reach ¬P.

What makes the swap worth doing is that negation can turn a useless hypothesis into a useful one. "n2 is even" gives n2=2k, and there is no way back through the square to n. Its partner in the contrapositive is "n is not even", which, because every integer is even or odd and none is both, means "n is odd", and that gives n=2k+1, a formula for n itself. Squaring a formula is easy. Unsquaring a fact is not.

Example. Prove that for every integer n, if n2 is even then n is even.

We prove the contrapositive: for every integer n, if n is not even then n2 is not even. Let n be an integer that is not even. Since every integer is even or odd, n is odd, so n=2k+1 for some integer k. Then n2=4k2+4k+1=2(2k2+2k)+1. Since 2k2+2k is an integer, n2 is odd, and since no integer is both odd and even, n2 is not even. This proves the contrapositive, and therefore the original statement.

The first sentence is not decoration. Without it, the proof looks like a proof of the converse, and a careful reader will wonder whether the writer has confused the two.

Now you. Prove that for every integer n, if 3∣n2 then 3∣n. (Use the fact that every integer is of the form 3k, 3k+1 or 3k+2 for some integer k.)

Answer

We prove the contrapositive: if 3 does not divide n then 3 does not divide n2. Let n be an integer not divisible by 3. Then n=3k+1 or n=3k+2 for some integer k. In the first case n2=9k2+6k+1=3(3k2+2k)+1, and in the second n2=9k2+12k+4=3(3k2+4k+1)+1. Either way n2 leaves remainder 1 on division by 3, so 3 does not divide n2. This proves the contrapositive, and so the claim.

Assuming the opposite

A proof by contradiction proves a statement Q by assuming ¬Q and deriving something impossible: a statement together with its negation. The justification is one row of a truth table. The conditional ¬Q⇒(R∧¬R) has a conclusion that is false in every row, so if the conditional has been proved, its hypothesis must be false too. And ¬Q false means Q true.

For a conditional P⇒Q, the thing to assume is its negation, which is P∧¬Q. So the proof starts with two assumptions rather than one: everything the direct proof had, plus the negated conclusion as a further fact to use.

The method is old. Aristotle, in the Prior Analytics of the fourth century BCE, gives as his standard example of reasoning "to the impossible" the proof that the diagonal of a square cannot be measured by its side, since otherwise odd numbers would equal even ones: the next proof in this lesson.

The contrapositive is a special case: if the argument uses ¬Q to reach ¬P, that contradicts the assumed P. The difference is the destination. A contrapositive proof has a fixed target, ¬P, while a proof by contradiction may end at any impossibility at all.

The square root of two

A real number is rational if it equals ab for some integers a and b with b≠0, and irrational otherwise. "Irrational" is a negative: no pair of integers, out of infinitely many, has a certain property. Contradiction assumes one pair exists and extracts an impossibility from it, a single argument about a single, arbitrary pair.

Approximations show why checking cannot settle it. The fraction 9970 gives 992=9801 against 2×702=9800, and 577408 gives 5772=332929 against 2×4082=332928. The gap is one each time, and no amount of searching can show that it never closes.

Example. Prove that 2 is irrational.

Suppose, for contradiction, that 2 is rational, so 2=ab for some integers a and b with b≠0. If a and b are both even, cancel a factor of 2 from each; the denominator shrinks in size each time, so this must stop, and we may assume that a and b are not both even. Squaring 2=ab and multiplying by b2 gives a2=2b2, so a2 is even. By the result proved above, a is even, so a=2c for some integer c. Substituting, 4c2=2b2, so b2=2c2, and b2 is even. By the same result, b is even. So a and b are both even, which contradicts the choice of a and b. Hence 2 is not rational.

A proof that proves too much is wrong, so why does it not show 4 irrational? Run it with 4: from a2=4b2 the next step would need "if 4∣a2 then 4∣a", and that is false, since 4∣36 while 4 does not divide 6. The proof for 2 works because 2 is prime, and it breaks exactly where it should.

Now you. Prove that 3 is irrational, using the result from the first Now you: if 3∣n2 then 3∣n.

Answer

Suppose, for contradiction, that 3=ab for integers a and b with b≠0. Cancelling factors of 3 from both as long as both are divisible by 3, which must stop because the denominator shrinks in size, we may assume a and b are not both divisible by 3. Squaring gives a2=3b2, so 3∣a2, and therefore 3∣a. Write a=3c. Then 9c2=3b2, so b2=3c2 and 3∣b2, hence 3∣b. So 3 divides both a and b, contradicting the choice of a and b. Hence 3 is irrational.

The primes never run out

An integer p>1 is prime if its only positive divisors are 1 and p. The primes thin out, from a quarter of the numbers up to 100 to about one in thirteen of those up to a million, so whether they stop is a real question. Around 300 BCE Euclid answered it in Book IX of the Elements, Proposition 20. The proof needs one preliminary fact.

Every integer N>1 has a prime divisor. Among the divisors of N that are greater than 1 there is at least one, N itself, and there are only finitely many candidates between 2 and N, so there is a smallest; call it d. Suppose, for contradiction, that d is not prime. Then d=rs for some integers with 1<r<d. Now r∣d and d∣N, so r∣N by the transitivity of divisibility from the previous lesson. That makes r a divisor of N greater than 1 and smaller than d, contradicting the choice of d. So d is prime.

Example. Prove that there are infinitely many primes.

Suppose, for contradiction, that there are only finitely many, and list all of them as p1,p2,…,pk. Let N=p1p2⋯pk+1. Then N>1, so by the preliminary fact N has a prime divisor p. Since the list contains every prime, p is one of p1,…,pk, and so p divides the product p1p2⋯pk. It also divides N. A number dividing two integers divides their difference (from the previous lesson), so p∣N-p1p2⋯pk, that is, p∣1. But p>1, and no integer greater than 1 divides 1. This contradiction shows the primes are not finite in number.

Now you. Prove directly that for every positive integer n there is a prime greater than n. (Consider a prime divisor of n!+1.)

Answer

Let n be a positive integer. Since n!+1>1, it has a prime divisor p. If p≤n, then p is one of the factors 1,2,…,n of n!, so p∣n!; as also p∣n!+1, it would follow that p∣1, which is impossible. So p>n. For n=6, 6!+1=721=7×103, and both prime factors exceed 6. The proof uses a small contradiction to locate p, but it never assumes the primes are finite: it produces a larger prime from any n.

What Euclid's proof does not say

A common retelling runs: multiply the primes together, add one, and the result is a new prime. The proof says something weaker, that N has a prime divisor not on the list, and the retelling is false. The first cases make it look right: 2+1=3, 2×3+1=7, then 31, 211 and 2311, all prime. The sixth breaks it:

2×3×5×7×11×13+1=30031=59×509

Neither 59 nor 509 is among the primes from 2 to 13, exactly as the proof promises. The new prime is a divisor of N, not N itself.

Nor did Euclid assume the primes were finite. His proposition reads "prime numbers are more than any assigned multitude of prime numbers": given any finite collection of primes, their product plus one either is prime or has a prime divisor, and the divisibility argument shows that divisor is not in the collection. That proves more than the textbook version, since it turns any finite list into a new prime.

Choosing a method

Try the direct route first. When it stalls, look at the shape of the statement. If it is a conditional whose hypothesis gives nothing to manipulate while the negation of its conclusion gives a formula, as "n2 is even" against "n is odd", use the contrapositive. If the statement is a negative with no hypothesis to start from, "is irrational", "there is no largest", "there are infinitely many", use contradiction, since assuming the positive version hands the proof an object to work on.

The claim that log23 is irrational shows the second shape. Suppose log23=pq with p and q positive integers (positive because log23>0). Then 2pq=3, so 2p=3q. The left side is even and the right side is a product of odd numbers, hence odd, and no integer is both.

Prefer the contrapositive when both methods work. Its target, ¬P, is fixed in advance, so a mistake usually shows as a failure to arrive. A proof by contradiction accepts any impossibility, including one produced by an algebra slip, so a wrong one can look exactly like a right one.

Contradictions in disguise

Many proofs by contradiction are something else wearing its opening sentence. The test is to delete "suppose, for contradiction" and ask whether the assumption was ever used. Consider: "Suppose, for contradiction, that the sum of odd integers a and b is odd. Write a=2k+1 and b=2m+1. Then a+b=2(k+m+1), which is even, a contradiction." The assumed oddness of a+b did nothing until the last word. Strip the wrapper and what remains is a direct proof that a+b is even.

The second disguise hides a contrapositive. "Suppose n2 is even and n is odd. Then n=2k+1, so n2 is odd, contradicting n2 even." The hypothesis appears only in the final clash; the work ran from ¬Q to ¬P. Writing it as a contrapositive says the same thing with fewer assumptions in the air.

The textbook proof of Euclid's theorem is the third: its argument works on any finite list, so the assumption that the list held every prime was never needed. Removing a disguise improves a proof. Every line becomes true, rather than true only in an impossible world about to collapse, and a stronger or constructive result often appears.

What none of these methods can do

Every proof in this lesson and the previous one handled infinitely many integers by one argument about an arbitrary integer. Some claims do not yield to that. Take "every integer n≥2 is a product of primes". For an arbitrary n, either n is prime, or n=ab with a and b smaller than n; to finish, the proof needs a and b to be products of primes already, which is the claim for smaller numbers. The argument for each n leans on the cases below it, and checking them one by one never ends. The next lesson supplies the method that follows such a chain all the way up: induction.

Induction

A claim about every natural number is infinitely many claims, and checking them one at a time never finishes.

The previous lesson, on proof by contrapositive and contradiction, ended on a claim neither method finishes: every integer n≥2 is a product of primes, where the argument for n needs the claim for smaller numbers first. This lesson gives the method for such chains and proves it valid. Throughout, the natural numbers are ℕ={1,2,3,…}, starting at 1, and the definitions are the usual ones: n is even when n=2k for some integer k, odd when n=2k+1, and a∣b when b=ak for some integer k.

The principle

For each natural number n let P(n) be a statement, such as "1+2+⋯+n=n(n+1)2". The principle of induction says: if P(1) is true, and if for every natural number n the conditional P(n)⇒P(n+1) is true, then P(n) is true for every natural number n.

The two hypotheses have names. Proving P(1) is the base case. Proving P(n)⇒P(n+1) for every n is the inductive step, and inside it the assumption P(n) is the inductive hypothesis. The step is an ordinary conditional, proved directly: take an arbitrary n, assume P(n), derive P(n+1). This is not assuming what is to be proved, since the step never claims P(n) is true, only that if it is, so is the next. The picture is a line of dominoes: the base case knocks over the first, and the step makes each falling domino knock over the next.

A claim can pass one check and fail the other. Let P(n) be "n2+n is odd". The step holds: if n2+n is odd, then (n+1)2+(n+1)=(n2+n)+2(n+1) is an odd number plus an even one, hence odd. But P(1) says 2 is odd, which is false, and in fact n2+n=n(n+1) is even for every n. A proof by induction that skips the base case can prove something false.

A debt from the first lesson

The first lesson of this course defined even and odd, noted that nothing in the definitions says every integer is one or the other, and left that claim open, although every proof since has leaned on it. Induction pays the debt.

Example. Prove that every natural number is even or odd.

Let P(n) be the statement "n is even or n is odd". For the base case, 1=2×0+1, so 1 is odd and P(1) holds. For the inductive step, let n be a natural number and assume P(n). If n is even, then n=2k for some integer k, so n+1=2k+1 is odd. If n is odd, then n=2k+1 for some integer k, so n+1=2k+2=2(k+1) is even. In either case n+1 is even or odd, so P(n+1) holds. By induction, P(n) holds for every natural number n.

The claim for all integers follows in a sentence: 0=2×0 is even, and for a natural number n, if n=2k then -n=2(-k), while if n=2k+1 then -n=2(-k-1)+1. The companion fact, that no integer is both, is a short contradiction: 2k=2m+1 would give k-m=12, and a difference of integers is an integer.

Now you. Prove by induction that n2+n is even for every natural number n.

Answer

Let P(n) be "n2+n is even". For the base case, 12+1=2=2×1, so P(1) holds. For the step, let n be a natural number with n2+n=2k for some integer k. Then (n+1)2+(n+1)=n2+3n+2=(n2+n)+2(n+1)=2k+2(n+1)=2(k+n+1), and k+n+1 is an integer, so (n+1)2+(n+1) is even and P(n+1) holds. By induction, n2+n is even for every natural number n.

Why the principle holds

The principle rests on a property of ℕ called the well-ordering principle: every nonempty collection of natural numbers has a least element. It fails for the integers, which have no least element. Well-ordering is taken as a basic property of ℕ.

Theorem. The principle of induction holds.

Suppose, for contradiction, that P(1) and the step both hold but P(n) is false for some natural number n. Then the collection of natural numbers n for which P(n) is false is nonempty, so by well-ordering it has a least element; call it m. Since P(1) is true, m≠1, so m≥2 and m-1 is a natural number. Since m-1<m and m is the least failure, P(m-1) is true. The inductive step with n=m-1 then gives P(m), contradicting the choice of m. So P(n) holds for every n.

A first failure would need a predecessor that succeeds, and the step forbids that. The same shape gives another way to write any induction, the smallest counterexample argument: take the least n where the claim fails and find a smaller failure.

Sums

Adding 1+2+⋯+100 in pairs from the outside in, 1+100, 2+99 and so on, gives fifty pairs of 101, so 5050. The same pairing suggests 1+2+⋯+n=n(n+1)2 in general, and induction proves it.

Example. Prove that 1+2+⋯+n=n(n+1)2 for every natural number n.

Let P(n) be the statement 1+2+⋯+n=n(n+1)2. For the base case, the left side is 1 and the right side is 1×22=1, so P(1) holds. For the step, let n be a natural number and assume 1+2+⋯+n=n(n+1)2. Adding n+1 to both sides,

1+2+⋯+n+(n+1)=n(n+1)2+(n+1)=n(n+1)+2(n+1)2=(n+1)(n+2)2.

The right side is the formula with n+1 in place of n, a target worth writing down before the algebra starts, so P(n+1) holds. By induction, the formula is true for every natural number n.

Induction checks a formula; it does not find one. The usual route is a guess from small cases: 1, 1+3=4, 1+3+5=9 and 1+3+5+7=16 suggest 1+3+⋯+(2n-1)=n2, and the step is one line, n2+(2n+1)=(n+1)2.

Now you. Prove that 12+22+⋯+n2=n(n+1)(2n+1)6 for every natural number n.

Answer

Let P(n) be the formula. For the base case, both sides equal 1, since 1×2×36=1. For the step, assume P(n) for a natural number n and add (n+1)2 to both sides. The right side becomes

n(n+1)(2n+1)+6(n+1)26=(n+1)(2n2+7n+6)6=(n+1)(n+2)(2n+3)6,

which is the formula with n+1 in place of n, since 2(n+1)+1=2n+3. So P(n+1) holds, and by induction the formula holds for every n.

Other starting points, and divisibility

Nothing forces the base case to be 1. If P(n0) holds and P(n)⇒P(n+1) for every n≥n0, then P(n) holds for every n≥n0; this is the ordinary principle applied to Q(k)=P(n0+k-1). A later start is what inequalities often need. Compare 2n with n2 for n=1,2,3,4: 2>1, then 4=4, 8<9 and 16=16. From n=5, where 32>25, the power of two stays ahead.

Claim. 2n>n2 for every integer n≥5. For the base case, 25=32>25=52. For the step, let n≥5 and assume 2n>n2. Then 2n+1=2×2n>2n2, and it remains to show 2n2≥(n+1)2, that is, n2≥2n+1. Since n≥5, n2≥5n=2n+3n>2n+1. So 2n+1>(n+1)2, and by induction the claim holds for every n≥5.

The step in fact works for every n≥3, yet the claim is false at 3 and 4: a true conditional says nothing when its hypothesis is false, so the chain starts only where a base case is verified. For divisibility, the step shows that the new expression is the old one plus a multiple of the divisor.

Claim. 3∣n3-n for every natural number n. For the base case, 13-1=0=3×0. For the step, assume n3-n=3k for some integer k. Expanding, (n+1)3-(n+1)=n3+3n2+3n+1-n-1=(n3-n)+3(n2+n)=3(k+n2+n), which is a multiple of 3. By induction, the claim holds for every n.

Writing n3-n=(n-1)n(n+1), three consecutive integers, gives a shorter proof. Induction's merit is that it needs no such insight, only the algebra of one step.

Strong induction

Some steps need more than the case just before. Strong induction lets the step assume every earlier case: if P(1) is true, and for every natural number n the truth of P(1),P(2),…,P(n) together implies P(n+1), then P(n) holds for every n. It is no stronger than ordinary induction. Apply the ordinary principle to Q(n), "P(1) through P(n) are all true": Q(1) is P(1), and the strong step turns Q(n) into P(n+1) and hence Q(n+1). As before, the base can start at any n0.

Example. Prove that every integer n≥2 is a product of primes, where a single prime counts as a product of one prime.

We use strong induction starting at 2. For the base case, 2 is prime, so it is a product of one prime. For the step, let n≥2 and assume that every integer k with 2≤k≤n is a product of primes. Consider n+1. If n+1 is prime, it is a product of one prime. Otherwise n+1=ab for integers a and b that are both greater than 1 and less than n+1, so both lie between 2 and n. By the inductive hypothesis each is a product of primes, and writing those two products side by side expresses n+1=ab as a product of primes. By strong induction, every integer n≥2 is a product of primes.

Ordinary induction could not do this: that 59 factorises says nothing about 60, whose proof uses 6 and 10 instead, giving 60=(2×3)(2×5). Uniqueness of the factorisation, apart from order, is a separate and harder theorem.

Now you. The Fibonacci numbers are F1=F2=1 and Fn+1=Fn+Fn-1 for n≥2, giving 1,1,2,3,5,8,13,…. Prove that Fn<2n for every natural number n.

Answer

We use strong induction with two base cases, because the step reaches back two places. F1=1<2 and F2=1<4. For the step, let n≥2 and assume Fk<2k for every k≤n. Then Fn+1=Fn+Fn-1<2n+2n-1<2n+2n=2n+1. So the bound holds for n+1, and by strong induction for every n. The step starts at n=2 because n=1 would call on the undefined F0, so F2 must be checked by hand. The bound is generous, since F30=832040 against 230=1073741824.

All horses are one colour

Here is a proof by induction of something false. Let P(n) be "in any group of n horses, all the horses are the same colour". For the base case, a group of one horse is one colour. For the step, assume P(n) and take a group of n+1 horses, lined up. Remove the last horse: the first n form a group of n, so by hypothesis they share a colour. Remove the first horse instead: the last n share a colour too. The horses in the middle belong to both groups, so the two colours are the same, and all n+1 horses are one colour. By induction, all horses everywhere are the same colour.

The base case is fine, so the step must fail for some n. Try n=1, going from one horse to two, A and B. Removing the last leaves {A}, removing the first leaves {B}, and each is trivially one colour. The middle horses, in both groups, number n-1, which here is none. Nothing links A's colour to B's, and the step from P(1) to P(2) is invalid.

For every n≥2 the groups overlap in n-1≥1 horses and the step is correct. It fails at exactly one link, the first, and that is enough: P(2) is false, so the chain never gets going. A written step often assumes something silent about n, and the remedy is to run it by hand at the smallest value it must cover.

What the proofs are about

Induction completes the toolkit: direct proof, cases, contrapositive, contradiction, and, for claims indexed by the natural numbers, two finite checks. The objects those proofs talk about, though, have stayed informal. The proof of the principle took "the collection of natural numbers where P fails" and asked for its least element, without saying what a collection is or when two collections are the same. The horses came in "groups" and were removed from them. Mathematics needs those words to mean something exact, and the next lesson makes them precise: sets, and how to prove that two of them are equal.

Sets

Every proof so far has spoken of "the even integers" or "the primes" as collections, and none has said what a collection is, when two of them are the same, or how to build new ones from old.

The previous lesson completed the stock of proof methods with induction, but the objects the proofs talk about have been informal, and this lesson makes them precise. It assumes the connectives, including the rule that a conditional with a false hypothesis is vacuously true, the quantifiers ∀ and ∃, and induction.

Membership and set builder notation

A set is a collection of objects, its elements, and it is determined by nothing except which objects those are. "x is an element of A" is written x∈A, and its negation x∉A. So 3∈ℕ and -3∉ℕ, with ℕ, ℤ, ℚ and ℝ standing as before for the natural numbers (starting at 1), the integers, the rationals and the reals.

A small set can be listed between braces: {2,3,5,7} is the set of primes below 10. A large one is described by a property, in set builder notation:

{x∈A:P(x)}

read "the set of x in A such that P(x)". Here A is a set already known and P(x) an open sentence, and the result is the set of elements of A that make P true. So {n∈ℤ:n2<10}={-3,-2,-1,0,1,2,3}, since 32=9 is below 10 and 42=16 is not. A second form puts an expression first: {2k:k∈ℤ} is the even integers.

The notation comes with one rule, and proofs use it constantly: y belongs to {x∈A:P(x)} exactly when y∈A and P(y) is true. The insistence on a surrounding set A looks like pedantry, and the last section shows that it is not.

Subsets and equality

A is a subset of B, written A⊆B, when every element of A is an element of B:

A⊆Bmeans∀x(x∈A⇒x∈B)

To prove this universal conditional, let x be an arbitrary element of A and show, using only what membership in A means, that x∈B. One element of A outside B disproves it.

Two sets are equal when they have the same elements. So {1,2,2}={2,1}: each element of either side, 1 or 2, lies in the other. Order is not an element, and writing 2 twice names the same element twice. The definition also gives the method this lesson is built round: A=B exactly when A⊆B and B⊆A, so a proof that two sets are equal is two subset proofs, called a proof by double inclusion.

Keep ∈ and ⊆ apart: 1∈{1,2} and {1}⊆{1,2}, but {1}∉{1,2}, since the set {1} is not one of the numbers 1 and 2. Yet {1}∈{{1},2}.

Example. Prove that {n∈ℤ:2∣nand3∣n}={n∈ℤ:6∣n}.

Call the sides L and R. First, L⊆R. Let n∈L. Then n is an even integer and n=3b for some integer b. If b were odd, 3b would be a product of odd numbers and so odd, contradicting n even; hence b=2c for some integer c, and n=6c. So 6∣n, and n∈R. Second, R⊆L. Let n∈R, so n=6c for some integer c. Then n=2(3c) and n=3(2c), so 2∣n and 3∣n, and n∈L. Each set is a subset of the other, so L=R.

Now you. Prove that {x∈ℝ:x2-3x+2<0}=(1,2).

Answer

Call the left side S; note x2-3x+2=(x-1)(x-2). First, S⊆(1,2). Let x∈S, so (x-1)(x-2)<0. A product of two reals is negative only when one factor is positive and the other negative, and since x-1>x-2, the positive one is x-1. So x>1 and x<2, and x∈(1,2). Second, (1,2)⊆S. Let 1<x<2. Then x-1>0 and x-2<0, so their product is negative and x∈S. Hence S=(1,2).

Union, intersection, difference and complement

Four operations build new sets from old, each a connective in disguise. x is in the union A∪B when x∈A or x∈B, with the inclusive "or"; in the intersection A∩B when x∈A and x∈B; and in the difference A∖B when x∈A and x∉B. With A={1,2,3,4} and B={3,4,5} these are {1,2,3,4,5}, {3,4} and {1,2}.

The complement of A is everything not in A, and "everything" needs a limit: a universe U, fixed in advance and containing every set under discussion, with Ac=U∖A. The universe is part of the meaning: the complement of the even integers is the odd integers when U=ℤ, but also contains 12 and π when U=ℝ.

The intersection of {1,2} and {3} has no elements at all. It is the empty set ∅, and it is a subset of every set A. The claim ∅⊆A means ∀x(x∈∅⇒x∈A). The hypothesis x∈∅ is false for every x, so the conditional is vacuously true. The same argument shows there is only one empty set, since two sets with no elements are each a subset of the other. But {∅} is not empty: it has one element.

Proving an identity by double inclusion

An identity between sets claims that two sets are equal for every choice of A, B and C. A drawing of overlapping circles shows one arrangement; double inclusion covers them all, one arbitrary element at a time.

Example. Prove that for all sets A, B and C, A∩(B∪C)=(A∩B)∪(A∩C).

First, left in right. Let x∈A∩(B∪C). Then x∈A, and x∈B or x∈C. If x∈B, then x∈A∩B; if x∈C, then x∈A∩C. Either way x is in the right side. Second, right in left. Let x∈(A∩B)∪(A∩C). If x∈A∩B, then x∈A and x∈B, so x∈A∩(B∪C); the case x∈A∩C is the same with C for B. Each side contains the other, so they are equal.

An "or" in the hypothesis became a proof by cases, and an "or" in the conclusion needed only one of its parts. That is the pattern of most identity proofs.

Now you. Prove that for all sets A, B and C, A∪(B∩C)=(A∪B)∩(A∪C).

Answer

First, left in right. Let x∈A∪(B∩C). If x∈A, or if x is in both B and C, then x is in A∪B and in A∪C, so in the right side. Second, right in left. Let x∈(A∪B)∩(A∪C). If x∈A, it is in the left side. If not, then x∈A∪B forces x∈B and x∈A∪C forces x∈C, so x∈B∩C, and again x is in the left side. The sets are equal.

De Morgan's laws for sets

Augustus De Morgan's laws for statements, from 1847, say that ¬(P∨Q) is equivalent to ¬P∧¬Q, and ¬(P∧Q) to ¬P∨¬Q. Since union is "or", intersection "and" and complement "not", the same laws hold for subsets of a universe U:

(A∪B)c=Ac∩Bc(A∩B)c=Ac∪Bc

Example. Prove that (A∪B)c=Ac∩Bc for all subsets A and B of U.

First, left in right. Let x∈(A∪B)c, so x∈U and x∉A∪B. If x were in A, it would be in A∪B, so x∉A; likewise x∉B. Hence x∈Ac and x∈Bc, so x∈Ac∩Bc. Second, right in left. Let x∈Ac∩Bc, so x∈U, x∉A and x∉B. Then "x∈A or x∈B" is false, so x∉A∪B and x∈(A∪B)c. The sets are equal.

The middle of each half is De Morgan's law for statements, applied to x∈A and x∈B. Every identity here is an equivalence of statements with "x∈" written in front.

Now you. Prove that (A∩B)c=Ac∪Bc for all subsets A and B of U.

Answer

First, left in right. Let x∈(A∩B)c, so x∈U and x∉A∩B. Then "x∈A and x∈B" is false, so x∉A or x∉B, that is, x∈Ac or x∈Bc, and x∈Ac∪Bc. Second, right in left. Let x∈Ac∪Bc. If x∈Ac, then x∉A, so x∉A∩B; if x∈Bc, the same holds with B. Either way x∈(A∩B)c. The sets are equal.

Power sets and products

The power set P(A) is the set of all subsets of A. For A={1,2,3} it has eight elements: ∅, three one-element sets, three pairs, and A itself. Writing |A| for the number of elements of a finite set, the pattern is general: if |A|=n, then |P(A)|=2n.

The proof is by induction on n≥0. When n=0, A=∅, whose only subset is ∅, and 1=20. Suppose every set of n elements has 2n subsets, and let |A|=n+1. Choose a∈A and let A′=A∖{a}, which has n elements. A subset of A either omits a, and is then a subset of A′, or contains a, and is then S∪{a} for exactly one subset S of A′. There are 2n of each kind and none of both, so A has 2n+2n=2n+1 subsets.

An ordered pair (a,b) differs from the set {a,b}: (a,b)=(c,d) exactly when a=c and b=d. The Cartesian product A×B is the set of all pairs (a,b) with a∈A and b∈B, named after Descartes because ℝ×ℝ is the coordinate plane. For finite sets |A×B|=|A||B|: sort the pairs by first coordinate, and each of the |A| choices of a gives a row of exactly |B| pairs, with no pair in two rows. So {1,2,3}×{x,y} has 3×2=6 elements.

Unions and intersections of many sets

A family of sets A1,A2,A3,…, one for each n∈ℕ, has a union and an intersection defined by the quantifiers:

x∈A1∪A2∪⋯⟺∃n(x∈An)x∈A1∩A2∩⋯⟺∀n(x∈An)

Take An=(0,1n). The intersection of A1 to AN is (0,1N), never empty, yet the intersection over all n∈ℕ is ∅. Suppose x lies in every An. Then x>0, so some natural number n exceeds 1x (a property of the reals proved in a later lesson), and for it 1n<x, so x∉An, a contradiction. What holds at every finite stage can fail for the whole family.

Russell's paradox

Georg Cantor, who founded the theory, defined a set in 1895 as any collection of definite, distinct objects into a whole. Read literally, that allows {x:P(x)} for any property P, with no surrounding set. In 1901 Bertrand Russell took the property x∉x and formed

R={x:x∉x}

By the membership rule, R∈R exactly when R∉R, and no statement can be equivalent to its own negation. Russell's letter of June 1902 reached Gottlob Frege as the second volume of his foundations of arithmetic, built on exactly this kind of set, went to press.

The repair, due to Ernst Zermelo in 1908, is the rule this lesson has used throughout: a property may only carve a subset out of a set already known, as {x∈A:P(x)}. Run Russell's argument on RA={x∈A:x∉x}. If RA were in A, then RA∈RA exactly when RA∉RA, so RA∉A. The paradox becomes a theorem: no set contains every set, which is why a complement needs a universe.

Sets now have a precise language and a method of proof, but a set on its own does nothing. Mathematics is mostly about processes that turn one thing into another, a number into its square or a point into its reflection, and the next lesson makes those processes precise as functions.

Functions

Squaring a number, reflecting a point and seating each guest at a table are all processes that turn one thing into another, and a proof about any of them needs to know exactly what such a process is and when it can be undone.

The previous lesson made collections precise as sets, with subsets, the Cartesian product A×B of ordered pairs, and the habit of proving two sets equal by showing each contains the other. A set on its own does nothing, though. This lesson builds processes out of sets, assuming only that lesson, the quantifiers, and the direct and contrapositive proofs before it. As throughout the course, ℕ={1,2,3,…} starts at 1.

What a function is

Let A and B be sets. A function f:A→B is a rule that assigns to each element a of A exactly one element of B, written f(a) and called the value of f at a. The set A is the domain and B is the codomain. A rule given by a formula is often written with a barred arrow, as in x↦x2, read "x goes to x2".

"Rule" is informal, and the previous lesson supplies the formal version in one sentence: a function from A to B is the sets A and B together with a subset f of A×B such that for every a∈A there is exactly one b∈B with (a,b)∈f, and f(a) names that b. Nothing here asks for a formula, so a seating plan is as much a function as 3x+7 is.

"Exactly one" makes two demands: every element of the domain receives a value, and none receives two. The rule "send x to a real number whose square is x" fails both as a function from ℝ to ℝ: at x=-1 there is no such number, and at x=4 there are two. The square root repairs both by shrinking the domain to [0,∞) and choosing the non-negative root, a convention rather than a discovery.

Two functions are equal when they have the same domain, the same codomain, and the same value at every element of the domain. So x↦(x+1)2 and x↦x2+2x+1 on ℝ are one function written two ways.

Why the codomain is part of the function

Take the rule x↦x2 with two codomains: s:ℝ→ℝ and t:ℝ→[0,∞), with s(x)=t(x)=x2. They have the same set of pairs, yet they answer one question differently: is every element of the codomain a value? For t it is, since each y≥0 equals t(y). For s it is not, since no real number squares to -1.

That question decides, later in this lesson, whether a function can be undone: an inverse of s would have to send -1 somewhere, and there is nowhere to send it. That is why the codomain is recorded as part of the function, why s and t count as different, and why "x↦x2 is surjective" is neither true nor false until the codomain is named.

The values a function actually takes form its range, {f(a):a∈A}, a subset of the codomain. For s and t alike it is [0,∞). The codomain is where values may land; the range is where they do.

Image and preimage

For f:A→B and S⊆A, the image of S is f(S)={f(x):x∈S}, the values taken on S. For T⊆B, the preimage of T is f-1(T)={x∈A:f(x)∈T}, the inputs that land in T. The notation is a trap: f-1(T) is a set, and it exists for every function, whether or not f has an inverse.

With s(x)=x2 on ℝ, the image of [-1,2] is [0,4]: squares of numbers in [-1,2] lie between 0 and 4, and each y in [0,4] is the square of y∈[0,2]. The preimage of [1,4] is [-2,-1]∪[1,2], since negative inputs count too, and the preimage of [-4,-1] is ∅.

Two copies of the graph of y = x². On the left, the inputs from −1 to 2 on the x axis map onto the image from 0 to 4 on the y axis. On the right, the outputs from 1 to 4 pull back to a preimage in two pieces, from −2 to −1 and from 1 to 2, because a number and its negative have the same square.
Two copies of the graph of y = x². On the left, the inputs from −1 to 2 on the x axis map onto the image from 0 to 4 on the y axis. On the right, the outputs from 1 to 4 pull back to a preimage in two pieces, from −2 to −1 and from 1 to 2, because a number and its negative have the same square.

A round trip need not return where it started: the preimage of T=[-4,4] is [-2,2], whose image is [0,4], strictly smaller than T. One inclusion always holds, though.

Example. Let f:A→B and T⊆B. Prove that f(f-1(T))⊆T.

Let y∈f(f-1(T)). By the definition of image, y=f(x) for some x∈f-1(T). By the definition of preimage, x∈f-1(T) means f(x)∈T. So y=f(x)∈T, and since y was arbitrary, the inclusion holds.

The reverse fails for s because -4∈T is not a value at all. In general f(f-1(T)) is exactly the part of T that f reaches, so equality holds for every T precisely when every element of B is a value.

Now you. Let f:A→B and S⊆A. Prove that S⊆f-1(f(S)), and find a set S for which the inclusion is strict when f=s.

Answer

Let x∈S. Then f(x) is the value of f at an element of S, so f(x)∈f(S) by the definition of image. By the definition of preimage, an element of A whose value lies in f(S) belongs to f-1(f(S)), so x∈f-1(f(S)). Hence S⊆f-1(f(S)). For strictness take S=[0,1]: then s(S)=[0,1] and s-1([0,1])=[-1,1], which contains -1∉S. The round trip collects every input that shares a value with something in S.

Injective, surjective and bijective

A function f:A→B is injective, or one-to-one, when distinct inputs give distinct outputs. The useful form is the contrapositive: for all a,a′∈A, if f(a)=f(a′) then a=a′. The proof template is "Let a,a′∈A with f(a)=f(a′)", then algebra, then "so a=a′". To disprove it, one pair suffices: s(2)=s(-2).

It is surjective, or onto, when every element of the codomain is a value: for every b∈B there exists a∈A with f(a)=b. The template follows the quantifiers: "Let b∈B. Put a=…", then check that a∈A and f(a)=b. The formula for a comes from scratch work solving f(a)=b, which is not part of the proof; the check that a lies in the domain is, and it is the step most often forgotten. To disprove it, name one b and prove that f(a)=b has no solution in A.

It is bijective, a bijection, when it is both, so that each b∈B is the value of exactly one a∈A. The two properties are independent. The map d:ℕ→ℕ, d(n)=2n, is injective, since 2m=2n gives m=n, but not surjective, since 2n=1 forces n=12∉ℕ. With the even natural numbers as codomain, the same rule is a bijection. The function t is surjective and not injective.

Example. Prove that f:ℝ→ℝ, f(x)=3x+7, is a bijection.

Injective: let a,a′∈ℝ with f(a)=f(a′). Then 3a+7=3a′+7, so 3a=3a′, and dividing by 3 gives a=a′. Surjective: let b∈ℝ and put a=b-73. This is a real number, and f(a)=3⋅b-73+7=b. So f is injective and surjective, hence a bijection.

On the integers the same rule, n↦3n+7 from ℤ to ℤ, is injective by the same argument but not surjective: 3n+7=0 needs n=-73, not an integer. The membership check is exactly where the two cases part.

Now you. Let h:ℝ∖{1}→ℝ∖{2} be given by h(x)=2xx-1. Show that h never takes the value 2, so that it is a function into ℝ∖{2}, and prove that it is a bijection.

Answer

Values: 2xx-1=2 would give 2x=2x-2, which is false. Injective: let a,a′≠1 with 2aa-1=2a′a′-1. Clearing denominators, 2aa′-2a=2aa′-2a′, so a=a′. Surjective: let b≠2 and put a=bb-2, defined since b≠2. It is not 1, since bb-2=1 would give b=b-2. And h(a)=2b/(b-2)b/(b-2)-1=2b/(b-2)2/(b-2)=b. So h is a bijection. Both excluded points were forced: 1 because the formula fails there, 2 because it is never reached.

Composition

Given f:A→B and g:B→C, the composite g∘f:A→C is (g∘f)(a)=g(f(a)), read "g after f": f runs first. Order matters: with f(x)=x+1 and g(x)=x2 on ℝ, (g∘f)(1)=4 while (f∘g)(1)=2. Composition is associative, since h∘(g∘f) and (h∘g)∘f both send a to h(g(f(a))), so brackets can be dropped.

Example. Prove that if f:A→B and g:B→C are injective, then g∘f is injective.

Let a,a′∈A with g(f(a))=g(f(a′)). The elements f(a) and f(a′) of B have the same value under g, and g is injective, so f(a)=f(a′). Since f is injective, a=a′. So g∘f is injective.

The proof peels the functions off from the outside in. A partial converse holds: if g∘f is injective then so is f, since f(a)=f(a′) gives g(f(a))=g(f(a′)) and so a=a′. But g need not be: with f:[0,∞)→ℝ, f(x)=x, the composite s∘f is injective while s is not.

Now you. Prove that if f:A→B and g:B→C are surjective, then g∘f is surjective.

Answer

Let c∈C. Since g is surjective, there is b∈B with g(b)=c. Since f is surjective, there is a∈A with f(a)=b. Then (g∘f)(a)=g(f(a))=g(b)=c, so g∘f is surjective. Again the proof works from the outside in, finding b before a.

Together the two results say that a composite of bijections is a bijection.

Inverses

The identity on A is idA:A→A, idA(a)=a. A function g:B→A is an inverse of f:A→B when g∘f=idA and f∘g=idB.

Theorem. A function f:A→B has an inverse if and only if it is a bijection.

Suppose first that g is an inverse. For injectivity, let f(a)=f(a′); applying g gives a=g(f(a))=g(f(a′))=a′. For surjectivity, let b∈B and put a=g(b); then f(a)=f(g(b))=b. Conversely, suppose f is a bijection. For each b∈B, surjectivity gives some a with f(a)=b and injectivity says there is only one, so letting g(b) be that a assigns exactly one element of A to each b, and g:B→A is a function. By construction f(g(b))=b. For a∈A, g(f(a)) is the unique element sent to f(a), and a is such an element, so g(f(a))=a. Hence g is an inverse.

Each half of the definition did one job: g∘f=idA forced injectivity and f∘g=idB surjectivity. Neither alone is enough. For d(n)=2n, the map e sending an even m to m2 and an odd m to 1 satisfies e∘d=idℕ, yet d(e(1))=2. An inverse is also unique: if g and h are both inverses, then g=g∘(f∘h)=(g∘f)∘h=h by associativity. So it earns the name f-1. For f(x)=3x+7 it is f-1(y)=y-73, the formula the surjectivity proof already found.

Counting functions between finite sets

Let |A|=m and |B|=n, and list A as a1,…,am. A function f:A→B is a free choice of f(a1), then f(a2), and so on, each from B: an ordered list of m elements of B. By the product rule of the previous lesson, extended to m factors by induction, there are nm functions from A to B.

For an injection each choice must avoid the earlier ones: n options for f(a1), n-1 for f(a2), down to n-m+1 for f(am). So there are n(n-1)⋯(n-m+1) injections, a falling factorial. When m>n some factor is 0 and there are none, which is the pigeonhole principle. When m=n, an injection takes n distinct values in a set of n elements, so it hits all of B, and there are n! bijections.

A computer listing every function on small sets agrees. From a 3-element set to a 4-element set there are 43=64 functions, of which 4⋅3⋅2=24 are injective. From a 4-element set to itself there are 256, and exactly 24=4! are injective, the same 24 that are surjective. The falling factorial also settles the birthday problem: of the 36523 ways to give 23 people birthdays, the injective fraction is 365⋅364⋯34336523≈0.493, so a shared birthday is more likely than not.

For finite sets of equal size, then, injective and surjective coincide. The map d on ℕ, injective and not surjective, shows that this fails for infinite sets, a first sign that counting the infinite needs a different idea.

When one output is not enough

A function relates each input to exactly one output, and that restriction is what made composition and inverses work. Many relations mathematics cares about break it. "Divides" on the positive integers links 3 to 6, 9, 12 and every other multiple. The equation x2+y2=1 links 0 to both 1 and -1 and links 2 to nothing, so the circle is not the graph of a function from ℝ to ℝ. "Leaves the same remainder on division by 5" links 3 to 8, 13 and -2.

Each is still a set of ordered pairs, a subset of a product, with the "exactly one" condition dropped. The next lesson takes such relations up, beginning with the ones that declare two things to be the same for present purposes.

Equivalence relations

A function pairs each input with exactly one output, but "divides", "has the same birthday as" and "leaves the same remainder on division by 5 as" pair things far more freely, and they need a language of their own.

The previous lesson closed on the observation that many useful relations are not functions at all. This lesson defines relations, picks out the ones that say two things are "the same for present purposes", and shows that each of them cuts its set into pieces, which is how modular arithmetic and the fractions are built. It assumes sets, the Cartesian product A×B of all ordered pairs (a,b) with a∈A and b∈B, the quantifiers, and divisibility: a∣b when b=ak for some integer k.

Relations as sets of pairs

A relation on a set A is a subset of A×A. When the pair (a,b) belongs to it we say a is related to b and write a∼b. A relation is exactly the set of pairs it holds between, so two relations are equal when they contain the same pairs, however differently they were described.

Take A={1,2,3,4} and let a∼b mean a∣b. As a set of pairs this is

{(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)}

eight of the sixteen pairs in A×A. Order matters, since (2,4) is in the set and (4,2) is not. A relation on A can be any subset of A×A, and a set of n elements has n2 ordered pairs, so it carries 2n2 relations: for A={1,2,3}, 29=512.

A function from A to B fits the same mould. Its graph, {(a,f(a)):a∈A}, is a set of pairs in which every a∈A appears as a first coordinate exactly once, so functions are the relations with that property. On ℝ, x∼y when y=x2 is a function. The relation x∼y when x=y2 is not, and it fails both ways: 4 is related to 2 and to -2, and -1 is related to nothing. Divisibility above is not one either, since 1 is related to four elements.

Reflexive, symmetric and transitive

Three properties of a relation ∼ on A matter here, each a universal statement:

reflexive:∀a∈A(a∼a)
symmetric:∀a,b∈A(a∼b⇒b∼a)
transitive:∀a,b,c∈A((a∼b∧b∼c)⇒a∼c)

A relation with all three is an equivalence relation. Equality is the model, and "has the same birthday as" is another: everyone shares a birthday with themselves, sharing is mutual, and two people who share with a third share with each other.

Being universal, each property is broken by a single counterexample, and three relations on ℝ show that any two can hold without the third. The order x≤y is reflexive and transitive but not symmetric, since 1≤2 and not 2≤1. "Close to", meaning |x-y|≤1, is reflexive and symmetric but not transitive: 0 is close to 1 and 1 to 2, but 0 is not close to 2. And x∼y when xy>0 is symmetric and transitive (if xy>0 and yz>0, then x and z both have the sign of y) but not reflexive, since 0⋅0=0.

That last example refutes a tempting proof: "if a∼b then b∼a, so a∼a by transitivity". Each step is valid, but the argument needs some b with a∼b to start from, and for a=0 there is none. Reflexivity asks about every a, including those related to nothing.

Proving a relation is an equivalence

Such a proof is three short proofs, one per property, each a universal conditional: take arbitrary elements, assume the hypothesis, and reach the conclusion from the definition of the relation.

Example. On ℝ, let x∼y when x-y∈ℤ. Prove that ∼ is an equivalence relation.

Reflexive: let x∈ℝ. Then x-x=0, an integer, so x∼x. Symmetric: let x∼y, so x-y=k for some integer k. Then y-x=-k, also an integer, so y∼x. Transitive: let x∼y and y∼z, so x-y=k and y-z=m for integers k and m. Adding, x-z=k+m, an integer, so x∼z. All three hold, so ∼ is an equivalence relation.

Here 2.7∼0.7∼-3.3: two reals are related when they have the same fractional part. The three steps used that the integers contain 0 and are closed under negation and addition.

Now you. On the nonzero reals, let x∼y when xy∈ℚ. Prove that ∼ is an equivalence relation.

Answer

Reflexive: for x≠0, xx=1, which is rational, so x∼x. Symmetric: let xy=q with q rational. Since x≠0, q≠0, so yx=1q is rational and y∼x. Transitive: let xy=q and yz=r with q and r rational. Then xz=xy⋅yz=qr, which is rational, so x∼z. Hence ∼ is an equivalence relation.

Equivalence classes partition the set

Given an equivalence relation ∼ on A and a∈A, the equivalence class of a is everything related to it:

[a]={x∈A:x∼a}

Under the fractional part relation above, [0.7]={…,-1.3,-0.3,0.7,1.7,…}, and [0.7]=[2.7]: one class, two names. Any element of a class is a representative of it. A partition of A is a collection of nonempty subsets of A, its blocks, such that every element of A lies in exactly one block. Birthdays cut a room into at most 366 blocks, and that always happens.

Theorem. If ∼ is an equivalence relation on A, its equivalence classes form a partition of A.

First, every element is in its own class: a∼a by reflexivity, so a∈[a]. Hence every class is nonempty and every element lies in at least one class.

Second, if a∼b then [a]=[b], by double inclusion. Let x∈[a], so x∼a; with a∼b, transitivity gives x∼b, so x∈[b]. Conversely let x∈[b], so x∼b; symmetry turns a∼b into b∼a, and transitivity gives x∼a, so x∈[a].

Third, two classes are equal or disjoint. Suppose [a] and [b] share an element c, so c∼a and c∼b. Symmetry gives a∼c, transitivity gives a∼b, and the second step gives [a]=[b]. So no element lies in two different classes, and each lies in exactly one.

The converse holds too. Given a partition of A, let a∼b when a and b lie in the same block. This is reflexive because every element lies in some block, and symmetric because "the same block" ignores order. For transitivity, let a and b share a block S, and b and c a block T. Then b lies in both, and since it lies in exactly one block, S=T, so a and c share a block. The classes of this relation are the blocks, so equivalence relations on A and partitions of A are one idea described two ways. On {1,2,3} there are five partitions (all together, all apart, or a pair beside a singleton, in three ways), so only five of the 512 relations on that set are equivalence relations.

Congruence modulo n

Fix a positive integer n. Integers a and b are congruent modulo n, written a≡b(modn), when n∣a-b. So 17≡2(mod5) and -7≡2(mod3). The notation is Carl Friedrich Gauss's, from his Disquisitiones Arithmeticae of 1801, and a clock uses it daily: five hours after nine o'clock is two o'clock because 14≡2(mod12).

Example. Prove that congruence modulo n is an equivalence relation on ℤ.

Reflexive: for a∈ℤ, a-a=0=n⋅0, so a≡a(modn). Symmetric: let a≡b(modn), so a-b=nk for some integer k. Then b-a=n(-k), so b≡a(modn). Transitive: let a-b=nk and b-c=nm for integers k and m. Adding, a-c=n(k+m), so a≡c(modn). Congruence modulo n is therefore an equivalence relation.

Its classes, the congruence classes, number exactly n. Division with remainder writes every integer uniquely as a=qn+r with 0≤r<n, and then a-r=qn, so a∈[r]: every integer lies in one of [0],[1],…,[n-1]. These are different, because if 0≤r<s<n then s-r lies strictly between 0 and n, and no multiple of n does. For n=3:

[0]={…,-3,0,3,6,…}[1]={…,-2,1,4,7,…}[2]={…,-1,2,5,8,…}

So a≡b(modn) says exactly that a and b leave the same remainder on division by n.

Now you. On ℤ, let a∼b when 3∣a+2b. Prove that ∼ is an equivalence relation.

Answer

Reflexive: a+2a=3a, so a∼a. Symmetric: let a+2b=3k. Then b+2a=3(a+b)-(a+2b)=3(a+b-k), so b∼a. Transitive: let a+2b=3k and b+2c=3m. Then a+2c=(a+2b)+(b+2c)-3b=3(k+m-b), so a∼c. In fact a+2b=(a-b)+3b, so this is congruence modulo 3 in disguise, with three classes.

The fractions as classes of pairs

A fraction is written as a pair of integers, but different pairs name the same number: 12, 24 and -3-6 are one rational number written three ways. An equivalence relation makes this precise, and builds ℚ from ℤ without assuming the division it is meant to create.

Let P={(a,b)∈ℤ×ℤ:b≠0}, and for pairs in P let (a,b)∼(c,d) when ad=bc, the cross multiplication test stated with multiplication alone. It is reflexive, since ab=ba, and symmetric, since ad=bc is the same equation as cb=da. Transitivity is the real work.

Claim. If (a,b)∼(c,d) and (c,d)∼(e,f), then (a,b)∼(e,f).

We are given ad=bc and cf=de, and must show af=be. Multiplying the first equation by f gives adf=bcf, and by the second bcf=bde. Hence adf=bde, that is, d(af-be)=0. The pair (c,d) lies in P, so d≠0, and a product of integers is zero only when a factor is; so af=be.

The condition d≠0 is not a formality. Allow (0,0) and it is related to everything, since a⋅0=b⋅0. Then (1,2)∼(0,0) and (0,0)∼(3,5), but (1,2) is not related to (3,5), because 1⋅5=5 and 2⋅3=6. Transitivity would fail.

A rational number is now defined to be a class [(a,b)], written ab, and ℚ is the set of these classes. So 12 is the set {(1,2),(2,4),(-3,-6),…}, and the integer n reappears as the class of (n,1).

Well defined operations

Arithmetic on classes is defined through representatives, and that creates an obligation. A rule that picks a representative of a class and computes with it defines something only if every representative gives the same answer. Such a rule is well defined, and until that is proved it is not yet a function.

Here is one that fails. "Send [(a,b)] to a" looks like a function from ℚ to ℤ. But [(1,2)]=[(2,4)], and the rule sends this one class to 1 through one name and to 2 through the other. A school favourite fails the same way: "add the tops and add the bottoms" gives 12⊕13=25, yet with 24 for 12 it gives 37, and 25≠37 because 2⋅7=14 and 5⋅3=15.

Example. Prove that addition of rationals, [(a,b)]+[(c,d)]=[(ad+bc,bd)], is well defined.

First, bd≠0 because b≠0 and d≠0, so the result is a class of pairs in P. Now let (a,b)∼(a′,b′) and (c,d)∼(c′,d′), that is, ab′=ba′ and cd′=dc′. We must show (ad+bc,bd)∼(a′d′+b′c′,b′d′), that is, (ad+bc)b′d′=bd(a′d′+b′c′). Expanding and substituting,

(ad+bc)b′d′=(ab′)dd′+(cd′)bb′=(ba′)dd′+(dc′)bb′=bd(a′d′+b′c′)

So the sum depends only on the classes, and addition of rationals is well defined.

Congruence classes behave as well. Define [a]+[b]=[a+b] modulo n. If a≡a′(modn) and b≡b′(modn), then (a+b)-(a′+b′)=(a-a′)+(b-b′) is a sum of multiples of n, so a+b≡a′+b′(modn). Clock arithmetic is arithmetic on the twelve classes modulo 12, whether nine o'clock is represented by 9, 21 or -3.

Now you. Prove that multiplication of congruence classes modulo n, [a][b]=[ab], is well defined.

Answer

Let a-a′=nk and b-b′=nm for integers k and m. Then

ab-a′b′=a(b-b′)+b′(a-a′)=n(am+b′k)

so ab≡a′b′(modn), and the product class does not depend on the representatives. For example, 10≡1(mod9) gives 10k≡1(mod9) for every k, which is why a number and the sum of its digits leave the same remainder on division by 9.

Equivalence relations group things: they say when two objects are the same for present purposes, and cut a set into classes that become objects in their own right. The other great kind of relation ranks things instead. The order ≤ on the numbers, ⊆ on sets and divisibility on the positive integers are reflexive and transitive but far from symmetric, and the next lesson takes up these orders.

Order

The relations ≤ on the numbers, ⊆ on sets and "divides" on the positive integers do not sort things into groups of equals; they rank them, and ranking needs its own definitions of what comes first, what sits on top, and when a collection has a top at all.

The previous lesson picked out the equivalence relations, those that are reflexive (every element is related to itself), symmetric (a relation one way gives it the other way) and transitive (related along a chain means related end to end), and showed that they group things. This lesson turns to the relations that rank. It assumes relations as sets of pairs, power sets, the quantifiers, and divisibility: a∣b when b=ak for some integer k. As throughout the course, ℕ={1,2,3,…}.

Antisymmetry

An order cannot be symmetric: if x≤y forced y≤x, then 1≤2 would give 2≤1. What an order has instead is that two things each ranked below the other are the same thing. A relation ⪯ on a set A is antisymmetric when

∀a,b∈A((a⪯b∧b⪯a)⇒a=b)

The symbol ⪯ stands for an abstract relation of this kind, read "precedes or equals"; ≤ is kept for numbers.

Antisymmetric is not the negation of symmetric. Equality is both, since whenever a=b and b=a, certainly a=b. And "x+y is even" on ℤ is symmetric without being antisymmetric, since it relates 1 and 3 both ways.

To prove antisymmetry, take arbitrary a and b, assume both a⪯b and b⪯a, and deduce a=b. To refute it, exhibit two different elements related both ways.

Partial orders

A relation on A that is reflexive, antisymmetric and transitive is a partial order, and A with it is a partially ordered set, or poset. Three examples carry the lesson.

The first is ≤ on ℝ, with the ordering facts of school algebra taken as known. Reflexivity is x≤x. For antisymmetry, suppose x≤y and y≤x; if x≠y then x<y and y<x, and adding gives x+y<y+x, which is false, so x=y. For transitivity, x≤y and y≤z mean y-x≥0 and z-y≥0, and adding gives z-x≥0.

Example. Let X be a set. Prove that ⊆ is a partial order on the power set P(X), the set of all subsets of X.

Reflexive: for every A∈P(X), every element of A is an element of A, so A⊆A. Antisymmetric: let A⊆B and B⊆A. Each set is a subset of the other, which is exactly the double inclusion that proves two sets equal, so A=B. Transitive: let A⊆B and B⊆C, and let x∈A. Since A⊆B, x∈B, and since B⊆C, x∈C. As x was arbitrary, A⊆C. All three properties hold, so ⊆ is a partial order on P(X).

Now you. Prove that divisibility is a partial order on ℕ.

Answer

Reflexive: a=a⋅1, so a∣a. Transitive: let a∣b and b∣c, say b=ak and c=bm with k,m integers. Then c=a(km) and km is an integer, so a∣c. Antisymmetric: let a∣b and b∣a, say b=ak and a=bm. Then a=akm, and since a≠0, km=1. Because a and b are positive, so are k and m, and two positive integers with product 1 are both 1. So b=a⋅1=a.

The positivity is doing real work. On ℤ, divisibility is still reflexive and transitive, but 2∣-2 since -2=2⋅(-1), and -2∣2 since 2=(-2)(-1), while 2≠-2. The broken step is the last: km=1 also has the integer solution k=m=-1. So divisibility is not a partial order on ℤ.

Total orders and strict orders

Two elements a and b of a poset are comparable when a⪯b or b⪯a. A partial order in which every pair is comparable is a total order, or linear order, because its elements line up in a single row. The order ≤ on ℝ is total: for any two reals, either x≤y or y≤x.

The other two examples are not. Neither of 2 and 3 divides the other, so they are incomparable under divisibility, and so are 4 and 6. In P({1,2}) the sets {1} and {2} are incomparable, since neither is a subset of the other. This is what "partial" means: the order ranks some pairs and is silent about others.

Each partial order has a strict version: a≺b means a⪯b and a≠b, which turns ≤ into <, ⊆ into "is a proper subset of", and divisibility into "divides and is different from".

Hasse diagrams

A finite poset can be drawn economically, leaving reflexivity and transitivity for the reader to fill in. Say that b covers a when a≺b and there is no c with a≺c≺b. The Hasse diagram puts each element as a point, places b higher on the page than a whenever a≺b, and draws a line only for covering pairs. Then a⪯b exactly when a=b or a path climbs from a to b.

Take the eight divisors of 30, namely 1,2,3,5,6,10,15,30, under divisibility. The number 1 is covered by the primes 2, 3 and 5. Then 2 is covered by 6 and 10, 3 by 6 and 15, and 5 by 10 and 15. Finally 6, 10 and 15 are each covered by 30. That is twelve lines, drawn as the edges of a cube standing on the corner 1, with 30 at the opposite corner. The poset has nineteen strict pairs in all (for instance 2≺30), but the other seven follow by climbing.

The cube is no accident. A divisor of 30 is a product of some of the primes 2, 3 and 5, and a∣b exactly when the primes of a are among those of b. So the divisors of 30 under divisibility have the same diagram as P({2,3,5}) under ⊆.

The divisors of 12 give a different shape. They are 1,2,3,4,6,12. Here 1 is covered by 2 and 3; 2 is covered by 4 and 6; 3 by 6; and 4 and 6 are covered by 12. Note that 12 does not cover 2, because 4 and 6 lie between. Those seven lines draw two squares sharing an edge, from 2 to 6, rather than a cube.

Hasse diagrams under divisibility. The eight divisors of 30 form a cube with 1 at the bottom, 30 at the top and twelve covering lines. The six divisors of 12 form two squares sharing the edge from 2 to 6 (highlighted), with seven covering lines.
Hasse diagrams under divisibility. The eight divisors of 30 form a cube with 1 at the bottom, 30 at the top and twelve covering lines. The six divisors of 12 form two squares sharing the edge from 2 to 6 (highlighted), with seven covering lines.

Maximal against greatest

"Top" has two meanings in a poset, and they come apart as soon as the order is not total. An element g of A is greatest when everything lies below it: a⪯g for every a∈A. An element m is maximal when nothing lies strictly above it: there is no a∈A with m≺a. Least and minimal are the same definitions turned upside down.

Take the divisors of 12 other than 12, the set {1,2,3,4,6} under divisibility. Nothing in it is a proper multiple of 4 or of 6, so both are maximal. Neither is greatest, since neither divides the other, and nothing else could be, since a greatest element would be a multiple of both. So there are two maximal elements and no greatest. At the bottom, 1 divides everything and is least. In a Hasse diagram the maximal elements are the points with no line going up.

Greatest is a statement about every element; maximal is a statement about none. That is why a greatest element is always maximal (anything above it would also be below it, and antisymmetry makes the two equal), while a maximal element may simply be incomparable with the rest. In a total order every pair is comparable, and the two notions coincide.

Infinite posets can lack both: under ≤, ℕ has no maximal element, since n<n+1.

Example. Prove that a poset has at most one greatest element.

Let g and g′ both be greatest elements of A. Since g is greatest and g′∈A, we have g′⪯g. Since g′ is greatest and g∈A, we have g⪯g′. By antisymmetry, g=g′.

Antisymmetry supplies the equality, and it is why one may speak of "the greatest element", written maxA when it exists.

Now you. Prove that if a poset A has a greatest element g, then g is the only maximal element of A.

Answer

First, g is maximal. Suppose g≺a for some a∈A, so g⪯a and g≠a. Since g is greatest, a⪯g, and antisymmetry gives a=g, a contradiction. Second, let m be any maximal element. Since g is greatest, m⪯g. If m≠g then m≺g, contradicting maximality of m. So m=g.

The poset {1,2,3,4,6} is the contrapositive at work: it has two maximal elements, so it cannot have a greatest one.

Upper bounds and the least upper bound

Maximal and greatest look inside a set. Bounds look at it from outside, within a larger poset. Let S be a subset of a poset A. An element u∈A is an upper bound of S when s⪯u for every s∈S, and S is bounded above when it has one. Lower bounds are defined the other way up. An upper bound need not belong to S: in ℝ, the upper bounds of [0,1) are exactly the numbers u≥1, and none of them is in the set.

Among the upper bounds, the one that matters is the lowest. An element u is the least upper bound, or supremum, of S, written supS, when two conditions hold:

(i)s⪯ufor everys∈S,(ii)u⪯vfor every upper boundvofS

Condition (i) says u is an upper bound; condition (ii) says it lies below every other one. Together they say u is the least element of the set of upper bounds, so by the upside-down version of the Example above there is at most one, and "the" is earned. The greatest lower bound, or infimum, infS, is defined the other way up.

The definition works in any poset. Under divisibility on ℕ the upper bounds of {4,6} are the common multiples, and each is a multiple of 12 (if n=6b and 4∣6b, then 3b is even, so b is even). So sup{4,6}=12, the least common multiple. Under ⊆, sup{A,B}=A∪B, since any set containing A and B contains their union.

In ℝ, where ≤ is total, condition (ii) has a working form: no number below u is an upper bound, that is, for every b<u some s∈S has s>b. If supS belongs to S, it is the greatest element: sup[0,1]=1=max[0,1]. But it need not belong.

Example. Prove that S={1-1n:n∈ℕ} has supS=1, and that 1∉S.

The set is {0,12,23,34,…}. For (i), each element satisfies 1-1n<1 because 1n>0, so 1 is an upper bound. For (ii), let b<1; we show b is not an upper bound. Since 1-b>0, choose a natural number n>11-b, which exists because ℕ has no upper bound in ℝ, a fact a later lesson proves. Then 1n<1-b, so 1-1n>b, and an element of S lies above b. Every upper bound is therefore at least 1, and supS=1. Finally 1-1n=1 would force 1n=0, which no n allows, so 1∉S, and S has a supremum but no greatest element.

Now you. Prove that sup(0,1)=1 without using any fact about ℕ.

Answer

For (i), every x∈(0,1) satisfies x<1, so 1 is an upper bound. For (ii), let b<1 and find an element of (0,1) above it. If b≤0, the element 12 will do. If 0<b<1, take the midpoint x=b+12: then b<x<1 and x>0, so x∈(0,1) and x>b. So no number below 1 is an upper bound, and sup(0,1)=1, which is not in the interval.

A supremum can also fail to exist. The empty set has every real as an upper bound and so no least one, and ℕ has no upper bound in ℝ at all.

A gap in the rationals

Whether a least upper bound exists depends on the poset the bounds are drawn from, just as surjectivity depended on the codomain. Work in ℚ under ≤, and let

T={q∈ℚ:q2<2}

The set is nonempty, since 1∈T, and bounded above in ℚ by 2, since a rational q>2 has q2>4. In fact any positive rational u with u2>2 is an upper bound: if some q∈T had q>u, then q2>u2>2, contradicting q∈T.

So the rational upper bounds can be pushed down, and the elements of T pushed up. The decimals 1.5, 1.42, 1.415 and 1.4143 have squares 2.25, 2.0164, 2.002225 and 2.00024449, all above 2, so each is an upper bound. The decimals 1.4, 1.41, 1.414 and 1.4142 have squares 1.96, 1.9881, 1.999396 and 1.99996164, all below 2, so each is in T. The two sides close in on a number whose square is 2, and an earlier lesson proved that no rational has square 2.

That suggests a fact, stated here and proved in a later lesson: T is nonempty and bounded above in ℚ, yet has no least upper bound in ℚ, because below every rational upper bound lies a smaller one. Inside ℝ the same set has supremum 2. The rationals are totally ordered, as the reals are, yet something the reals have is missing from them, and least upper bounds are where the absence shows.

Whether every nonempty set of reals bounded above has a least upper bound is a question about what sets of real numbers look like, and it is where the course is heading. A prior question comes first: how many real numbers are there? Both ℚ and ℝ are infinite, and it is not yet clear that one infinity can be larger than another. The next lesson settles it by comparing the sizes of infinite sets.

Counting the infinite

Asking how many real numbers there are invites the answer "infinitely many", and that answer says nothing until "how many" has a meaning that works for infinite sets.

The previous lesson ranked sets of numbers by order, closed on the least upper bound, and left a prior question: how many reals are there? This lesson answers it with functions alone, assuming injective, surjective and bijective maps, inverses, and the fact that composites of injections (or bijections) are injections (or bijections). As throughout the course, ℕ={1,2,3,…} starts at 1.

Same size without counting

Someone who cannot count can still tell whether there are as many cups as saucers: put one cup on each saucer and see whether anything is left over. That pairing is a bijection, and it is the definition. Sets A and B have the same size, written |A|=|B|, when there is a bijection A→B. And |A|≤|B| means there is an injection A→B, which seats every element of A in its own place in B, perhaps with places to spare. Finally |A|<|B| means an injection exists and a bijection does not. Identities, inverses and composites make "same size" reflexive, symmetric and transitive.

For finite sets the definition agrees with counting. A set has n elements when it is in bijection with {1,2,…,n}. The lesson on functions counted the injections from an m-element set to an n-element set as n(n-1)⋯(n-m+1), which is 0 when m>n. That is the pigeonhole principle: more than n pigeons in n holes put two in some hole. So no set has both m and n elements with m<n, since one bijection followed by the inverse of the other would inject {1,…,n} into {1,…,m}. Two finite sets have the same size exactly when they have the same number of elements.

It also shows that a finite set is never the same size as a proper subset of itself, which has at most n-1 elements when the set has n. Richard Dedekind turned this round in 1888 and defined an infinite set as one that is the same size as a proper subset of itself.

Hilbert's hotel

David Hilbert gave the idea its best known picture in a Göttingen lecture of 1924, and George Gamow made it famous in his 1947 book One Two Three... Infinity. A hotel has a room for every natural number, all taken, when a new guest arrives. The manager asks the guest in room n to move to room n+1. Everyone still has a room, nobody shares, and room 1 is free.

The move is s:ℕ→ℕ∖{1}, s(n)=n+1, and it is a bijection. It is injective, since m+1=n+1 gives m=n. It is surjective, since each k in ℕ∖{1} has k≥2, so k-1∈ℕ and s(k-1)=k. So |ℕ∖{1}|=|ℕ|, and by Dedekind's definition ℕ is infinite.

When a coach brings a guest for every natural number, moving each guest from room n to room 2n frees the odd rooms for them, so ℕ is the same size as two copies of itself. "The whole is greater than the part" is Euclid's fifth common notion, true for finite collections by the pigeonhole principle and false for infinite ones.

Countable sets

A set is countable when it is finite or the same size as ℕ, and uncountable otherwise. A bijection g:ℕ→A is a list of A, g(1) first, g(2) second, in which every element appears exactly once and is reached after finitely many steps. Cantor wrote ℵ0 for the size of ℕ. Starting ℕ at 0 instead changes nothing, since the hotel's shift is a bijection between the two versions.

The integers run off in both directions, so listing them in their usual order has no first term. Alternating works: 0,1,-1,2,-2,…

Example. Prove that f:ℕ→ℤ, given by f(n)=n2 for even n and f(n)=1-n2 for odd n, is a bijection, so that ℤ is countable.

The values are integers (1-n is even when n is odd), beginning f(1)=0, f(2)=1, f(3)=-1, f(4)=2. Injective: for even n, f(n)=n2≥1, while for odd n, f(n)=1-n2≤0 because n≥1. So if f(m)=f(n), then m and n have the same parity, and either m2=n2 or 1-m2=1-n2; both give m=n. Surjective: let k∈ℤ. If k≥1, put n=2k, an even natural number, and f(n)=k. If k≤0, put n=1-2k, which is odd and at least 1, so n∈ℕ, and f(n)=1-(1-2k)2=k. Hence f is a bijection and |ℤ|=|ℕ|.

The surjectivity step also found the inverse: f-1(k)=2k for k≥1 and f-1(k)=1-2k for k≤0. So -3 sits at position 7 in the list.

Now you. Prove that g:ℕ→ℤ∖{0}, given by g(n)=n2 for even n and g(n)=-n+12 for odd n, is a bijection.

Answer

For even n, g(n)=n2≥1, and for odd n, g(n)=-n+12≤-1, a nonzero integer. Injective: g(m)=g(n) forces equal parity, since only even inputs give positive values, and then m2=n2 or -m+12=-n+12 gives m=n. Surjective: let k≠0. If k≥1, then n=2k is even and g(n)=k. If k≤-1, then n=-2k-1 is odd and at least 1, and g(n)=--2k-1+12=k. So g is a bijection, listing -1,1,-2,2,…

Pairs of natural numbers

The set ℕ×ℕ is an infinite grid, with (m,n) in row m and column n. Listing row 1 first never reaches row 2. The way out is to list by diagonals. There are exactly s-1 pairs with m+n=s, from (1,s-1) to (s-1,1), so list the diagonal with sum 2, then sum 3, and so on, each by increasing first coordinate:

(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),…

Each pair lies on exactly one diagonal, and each diagonal is finite, so every pair appears once and is reached after finitely many steps.

The position of (m,n) is a formula. With s=m+n, the earlier diagonals hold 1+2+⋯+(s-2)=(s-2)(s-1)2 pairs, and (m,n) is in place m on its own, so its position is

p(m,n)=(m+n-2)(m+n-1)2+m

This is the Cantor pairing function, shifted so that ℕ starts at 1: a polynomial that is a bijection ℕ×ℕ→ℕ, because the list visits every pair once and fills every position. It gives p(1,1)=1, p(1,2)=2, p(2,1)=3 and p(3,5)=6⋅72+3=24, and on the 1770 pairs with m+n≤60 it returns 1 to 1770, each once. So ℕ×ℕ is countable.

The rationals

Between two rationals lies their average, so ℚ cannot be listed in increasing order. It can be listed in another, and the quickest proof uses a theorem that turns two injections into a bijection.

Theorem (Schröder and Bernstein). If there are injections A→B and B→A, then there is a bijection A→B.

So |A|≤|B| and |B|≤|A| give |A|=|B|. Cantor stated the theorem in 1887 and Felix Bernstein, a student in his seminar, proved it in 1897. The proof is left to a later course.

Example. Prove that ℚ is countable.

Every rational has exactly one form ab in lowest terms with a∈ℤ and b∈ℕ. With f the bijection ℕ→ℤ above, define h:ℚ→ℕ×ℕ by h(ab)=(f-1(a),b), using that form; its uniqueness is what makes h a function. If h(ab)=h(cd), then f-1(a)=f-1(c), so a=c on applying f, and b=d, so the rationals are equal and h is injective. Then p∘h:ℚ→ℕ is a composite of injections, hence an injection, and n↦n injects ℕ into ℚ. By Schröder and Bernstein, |ℚ|=|ℕ|.

For instance -34 goes to (7,4) and then to p(7,4)=9⋅102+7=52. Position p(4,2)=14 is skipped, since (4,2) would stand for 22, which is not in lowest terms; that is why the theorem is needed.

Now you. Prove that F(a,b)=p(f-1(a),f-1(b)) is a bijection ℤ×ℤ→ℕ, and compute F(-1,2).

Answer

Let G(a,b)=(f-1(a),f-1(b)) from ℤ×ℤ to ℕ×ℕ, and H(m,n)=(f(m),f(n)). Since f and f-1 undo each other in each coordinate, H∘G and G∘H are identities, so G has an inverse and is a bijection. Then F=p∘G is a composite of bijections, hence a bijection, and ℤ×ℤ is countable. With f-1(-1)=3 and f-1(2)=4, F(-1,2)=p(3,4)=5⋅62+3=18.

Cantor's diagonal argument

Georg Cantor showed in 1874 that the reals are not countable, and in 1891 gave the proof now called the diagonal argument. It uses decimal expansions of numbers in (0,1), and has one trap.

Some numbers have two expansions: 0.4999…=0.5, since the tail 0.0999… is a geometric series with sum 9100⋅109=110. This is the only way it happens. Two different expansions first disagree at some place k, and the later digits can make up at most one unit in place k, which they do only when one tail is all 9s and the other all 0s. So an expansion with no 0 and no 9 is the only expansion of its number. For numbers with two, use the one that does not end in 9s.

Here is the start of a list of numbers in (0,1), with the nth digit of the nth number in bold:

nxnexpansionnth digitnew digit
1π-30.1415926...15
2e-20.7182818...15
32-10.4142135...45
4120.5000000...05
53-10.7320508...54
6ln20.6931471...75

The new digit is 5, unless the diagonal digit is 5, when it is 4. The number 0.555545… built from them differs from every xn in place n.

Example. Prove that there is no surjection ℕ→(0,1).

Let g:ℕ→(0,1) be any function, and let dn,k be the kth digit of g(n), using the expansion chosen above. Put cn=4 if dn,n=5 and cn=5 otherwise, and let y=0.c1c2c3…. Every digit of y is 4 or 5, so 49=0.444…≤y≤0.555…=59, and y∈(0,1). Suppose y=g(n) for some n. The expansion of y has no 0 or 9, so it is the only one y has, and the chosen expansion of g(n) must be it. Then dn,n=cn, contradicting the choice of cn. So y is not a value of g, and g is not surjective.

So (0,1), which is plainly not finite, is uncountable. So is ℝ: a bijection ℝ→ℕ would inject (0,1) into ℕ, while n↦1n+1 injects ℕ into (0,1), and Schröder and Bernstein would make (0,1) countable. The care over 0s and 9s is needed. With the rule "replace each diagonal digit d by 9-d", a list that starts with 0.5000… and has every later diagonal digit 0 produces 0.4999…, which is the first number again.

Now you. Let S be the set of infinite sequences (t1,t2,…) with every term 0 or 1. Prove that there is no surjection ℕ→S.

Answer

Let g:ℕ→S be any function, with g(n)=(tn,1,tn,2,…). Define u by un=1-tn,n, so each un is 0 or 1 and u∈S. For every n, un≠tn,n, so u and g(n) differ in term n and u≠g(n). Hence u is not a value of g, and g is not surjective. No trap arises here, because two sequences are equal only when every term agrees.

Cantor's theorem

The diagonal idea, build an object that disagrees with the nth item at the nth place, is not about decimals. It works for any set A and its power set P(A), the set of all subsets of A.

Theorem (Cantor). For every set A, |A|<|P(A)|.

The map a↦{a} is an injection A→P(A), since {a}={a′} forces a=a′. It remains to show that no F:A→P(A) is surjective. Each F(a) is a subset of A, which may or may not contain a. Collect the elements not in their own image:

D={a∈A:a∉F(a)}

This is a subset of A. Suppose D=F(d) for some d∈A. If d∈D, the definition of D gives d∉F(d)=D. If d∉D, then d∉F(d), which is exactly the condition for d∈D. Either way there is a contradiction, so F is not surjective, there is no bijection, and |A|<|P(A)|.

For a finite set this is n<2n. For ℕ the diagonal is visible: with F(n) as row n, the question "is n∈F(n)?" reads down the diagonal, and D answers each one the other way. Applied repeatedly, the theorem gives an unending ladder, so there is no largest infinity:

|ℕ|<|P(ℕ)|<|P(P(ℕ))|<⋯

The set D should look familiar. Russell's paradox, from the lesson on sets, is the set of all sets that are not members of themselves, and Russell reached it in 1901 by studying this proof: run it on a supposed set of all sets with F(x)=x, and D becomes {x:x∉x}. Inside a genuine set A, the same self-reference yields a theorem rather than a paradox.

The continuum hypothesis

Two infinite sizes are now in hand: that of ℕ, shared by ℤ, ℕ×ℕ and ℚ, and the strictly larger size of ℝ. In 1878 Cantor asked whether anything lies between: is every infinite set of reals either countable or the same size as ℝ? He believed so, and the claim is the continuum hypothesis, first on Hilbert's list of problems in 1900. Kurt Gödel showed in 1940 that it cannot be disproved from the usual axioms of set theory, and Paul Cohen showed in 1963 that it cannot be proved from them either. The axioms the rest of mathematics runs on do not decide it.

The count does settle a difference between two number systems that look alike. The rationals and the reals are both ordered and closed under the four operations, and between any two rationals lies another. Yet the rationals can be listed and the reals cannot, so something about the reals is missing from the rationals. Nothing so far has said what: counting shows the difference exists without locating it. The next lesson names it, as a property of least upper bounds called completeness.

The real numbers

The rationals and the reals obey the same rules of arithmetic and the same rules for inequalities, yet the rationals can be listed and the reals cannot, so something separates them that no rule of algebra mentions.

The previous lesson found that split by comparing infinite sets through bijections, and left open what the reals have that the rationals lack. This lesson names it, the completeness axiom, and uses it to pay debts that earlier lessons deferred to "a later lesson": that ℕ has no upper bound in ℝ, used without proof in the lessons on sets and on order; that the rationals with square less than 2 have no least upper bound among the rationals, stated in the lesson on order; and that some real number has square 2, claimed in the lesson on quantifiers. It assumes upper bounds and the supremum: u=supA when u is an upper bound of A lying below every other upper bound. As throughout the course, ℕ={1,2,3,…}.

The gap where 2 should be

Work inside ℚ and let T={q∈ℚ:q2<2}. It is nonempty, since 1∈T, and any positive u with u2>2 is an upper bound, because an element q>u would have q2>u2>2. The claim deferred by the lesson on order is that no rational is the least upper bound. The proof rests on two pieces of algebra that push a candidate up or down.

The first says a number whose square is below 2 is never the top of T. Let u≥1 with u2<2, and set h=2-u22u+1. Then h>0, and h<1 because 2-u2≤1<3≤2u+1. Since 0<h<1 gives h2<h,

(u+h)2=u2+2uh+h2<u2+h(2u+1)=2

So u+h is larger than u with square still below 2. From u=1.4 it gives h=195, and (1.4+195)2≈1.9896.

The second says a number whose square is above 2 is never the least upper bound. Let u>0 with u2>2, and set k=u2-22u>0. Then u-k=u2+22u is positive, and

(u-k)2=u2-2uk+k2>u2-2uk=2

So u-k is a smaller upper bound. From u=32 it gives 1712, with square 289144. Both h and k are built from u by arithmetic, so if u is rational, so are they.

Example. Prove that T={q∈ℚ:q2<2} has no least upper bound in ℚ.

Suppose, for contradiction, that u∈ℚ is the least upper bound of T. Since 1∈T, u≥1. Since 2 is irrational, as an earlier lesson proved, u2≠2, so either u2<2 or u2>2. If u2<2, the rational u+h above lies in T and exceeds u, contradicting that u is an upper bound. If u2>2, the rational u-k is an upper bound of T smaller than u, contradicting that u is the least. Both cases are impossible, so T has no least upper bound in ℚ.

Now you. Prove that {q∈ℚ:q2<3} has no least upper bound in ℚ, using the irrationality of 3.

Answer

Suppose u∈ℚ is the least upper bound. Since 1 is in the set, u≥1, and since 3 is irrational, u2≠3. If u2<3, let h=3-u22u+1, rational, positive, and less than 1 because 3-u2≤2<3≤2u+1. Then (u+h)2<u2+h(2u+1)=3, so u+h is in the set and exceeds u, a contradiction. If u2>3, let k=u2-32u. Then u-k=u2+32u>0 and (u-k)2>u2-2uk=3, so u-k is a smaller upper bound, a contradiction.

The ordered field axioms

That proof used only arithmetic, order and the irrationality of 2. To say what the reals have in addition, their familiar properties must be written down as a list, so that it is clear which ones the rationals share.

Addition and multiplication are commutative and associative, multiplication distributes over addition, there are elements 0≠1 with x+0=x and x⋅1=x, every x has a negative -x, and every x≠0 has a reciprocal 1x: these make ℝ a field. The order ≤ is total and respects the arithmetic: x≤y implies x+z≤y+z, and 0≤x with 0≤y implies 0≤xy. A field with such an order is an ordered field. Every rule of school algebra, from 0⋅x=0 to "multiplying by a negative number reverses an inequality", follows from these axioms, and here they are taken as given.

The trouble is that ℚ satisfies every one of them. So no argument from these axioms alone can produce a number whose square is 2, since it would work equally well in ℚ, where there is none. Something else must be assumed.

The completeness axiom

It concerns least upper bounds, exactly where the rationals fail.

Completeness axiom. Every nonempty set of real numbers that is bounded above has a least upper bound in ℝ.

The reals are an ordered field satisfying this axiom, a complete ordered field, and that is all this course assumes about them. The rationals are an ordered field that does not: T is nonempty and bounded above, and has no rational least upper bound. Both conditions in the axiom are needed. The empty set has every real as an upper bound and so no least one, and ℕ, as a later section proves, has no upper bound at all.

The idea took its modern form in 1872, in two independent constructions. Richard Dedekind, in Braunschweig, published Stetigkeit und irrationale Zahlen ("Continuity and irrational numbers"), defining a real number as a cut of the rationals into a lower and an upper class; he dated the idea to November 1858, when, teaching calculus in Zurich, he could find no rigorous proof that a bounded increasing quantity approaches a limit. The same year Georg Cantor, in Halle, built the reals from sequences of rationals whose terms eventually cluster together. In both constructions completeness is a theorem, and any two complete ordered fields turn out to be the same up to relabelling, so taking the axiom as a starting point describes ℝ exactly.

Working with the supremum

The definition of supA quantifies over every upper bound. Proofs usually want a form that tests only numbers just below s.

Example. Prove that s=supA if and only if s is an upper bound of A and, for every ε>0, some a∈A satisfies a>s-ε.

Suppose first that s=supA. Then s is an upper bound by definition. Let ε>0. Since s-ε<s and s lies below every upper bound, s-ε is not an upper bound, so some a∈A has a>s-ε.

Conversely, suppose s is an upper bound with the ε property, and let v be any upper bound of A. Suppose, for contradiction, that v<s, and take ε=s-v>0. Some a∈A has a>s-ε=v, contradicting that v is an upper bound. So s≤v for every upper bound v, and s=supA.

The second half chose ε to fit the contradiction. Picking ε after the thing to be defeated is known is the move the final lesson makes over and over.

Lower bounds need no second axiom. If A is nonempty and bounded below by m, then -A={-a:a∈A} is nonempty and bounded above by -m, so it has a supremum, and reversing every inequality shows that -sup(-A) is the greatest lower bound of A. So every nonempty set bounded below has an infimum, infA=-sup(-A).

Now you. Prove that t=infA if and only if t is a lower bound of A and, for every ε>0, some a∈A satisfies a<t+ε.

Answer

Suppose t=infA. It is a lower bound by definition. Let ε>0. Since t+ε>t and t lies above every lower bound, t+ε is not a lower bound, so some a∈A has a<t+ε. Conversely, suppose t is a lower bound with this property, and let m be any lower bound. If m>t, take ε=m-t: some a∈A has a<t+ε=m, contradicting that m is a lower bound. So m≤t for every lower bound m, and t=infA.

The Archimedean property

The lessons on sets and on order promised a proof that ℕ has no upper bound in ℝ. It does not follow from the ordered field axioms: there are ordered fields containing elements larger than every natural number. In ℝ it follows from completeness.

Example. Prove the Archimedean property: for every real x there is a natural number n with n>x.

Suppose, for contradiction, that some real x has n≤x for every n∈ℕ. Then ℕ is nonempty and bounded above, so by completeness it has a supremum s. By the characterisation with ε=1, some n∈ℕ has n>s-1. Then n+1>s, and n+1∈ℕ, contradicting that s is an upper bound of ℕ.

The form the earlier lessons used follows at once: for every ε>0 some n has 1n<ε. Take n>1ε and multiply by the positive number εn. For ε=0.03 the condition is n>33.3, so n=34 is the first that works, with 134≈0.0294.

Now you. Prove that inf{1n:n∈ℕ}=0.

Answer

Every 1n is positive, so 0 is a lower bound. Let ε>0. By the Archimedean property some n∈ℕ has n>1ε, so 1n<ε=0+ε. By the characterisation of the infimum, the infimum is 0, which is not itself in the set.

The square root of two exists

The lesson on quantifiers said that "some x has x2=2" is false over the rationals and true over the reals. The real half needs completeness, and the proof is the rational argument run again.

Let S={x∈ℝ:x2<2}. It is nonempty, since 1∈S, and bounded above by 2, since x≥2 gives x2≥4. By completeness it has a supremum s, and s≥1. The two pieces of algebra from the first section never used rationality, so they apply to s. If s2<2, then s+h lies in S and exceeds s, impossible for an upper bound. If s2>2, then s-k is a smaller upper bound, impossible for the least one. So s2=2. No other positive number qualifies, since t>0 and t2=2 give (s-t)(s+t)=0 with s+t>0. This s is 2.

Over ℚ, the algebra ruled out both inequalities, irrationality ruled out equality, and no supremum was left. Over ℝ, completeness supplies the supremum, the same algebra rules out both inequalities, and equality is what remains. The gap in the rationals is exactly where the reals have a number.

The rationals are dense

For all their gaps, the rationals are everywhere: between any two reals a<b lies a rational. By the Archimedean property choose n with 1n<b-a, so nb-na>1. The integers greater than na form a nonempty set bounded below (the Archimedean property, applied to na and to -na, gives an integer on each side), so by well-ordering it has a least element m. Then m-1≤na<m, so na<m≤na+1<nb, and dividing by n gives a<mn<b. Between 0.3 and 0.31, the proof takes n=101 and m=31, and 31101≈0.3069.

Density settles the last claim of the lesson on order, that T has supremum 2 in ℝ. Every q∈T has q<2, and for any b<2 there is a rational q strictly between max{b,0} and 2, which lies in T and exceeds b. The irrationals are dense too: a rational q between a-2 and b-2 gives the irrational q+2 between a and b.

Where completeness is needed next

The Archimedean property, the density of the rationals and the existence of 2 are facts calculus uses without comment, and each came from one axiom. The first place calculus needs completeness itself is its foundation, the limit of a sequence. The decimal truncations 1, 1.4, 1.41, 1.414, and so on, of 2 form an increasing bounded sequence of rationals with nothing in ℚ to converge to. The final lesson writes convergence with ε and N, proves limits with the methods of the whole course, and shows that in ℝ every bounded increasing sequence converges, the theorem Dedekind found no proof of in 1858.

Limits, proved

Calculus rests on the statement that a sequence converges to a limit, and so far that statement has been written down, read as a game and negated, but never proved for a single sequence.

The previous lesson supplied what was missing: the completeness axiom, that every nonempty set of reals bounded above has a least upper bound, and from it the Archimedean property, that for every real x some natural number exceeds x. This lesson puts the whole course to work on one definition. It proves that particular sequences converge and that others do not, proves general theorems about limits, and ends with a theorem that is true in ℝ and false in ℚ, which is exactly what completeness buys. Along the way it separates two activities that textbooks tend to blur: finding a proof and writing one.

The definition, read closely

A sequence a1,a2,a3,… of real numbers converges to L when

∀ε>0∃N∈ℕ∀n≥N(|an-L|<ε)

with ℕ={1,2,3,…} as throughout the course. The lesson on quantifiers read it as a game. A sceptic names a tolerance ε>0, as small as they like. A prover answers with a position N. The sceptic then picks any term from position N on, and the prover wins if that term lies within ε of L. The sequence converges to L when the prover has a winning answer to every tolerance, and we write an→L.

Because ∃N comes after ∀ε, the position may depend on the tolerance, and for any interesting sequence it must: a smaller ε usually needs a later N. Because the last quantifier is ∀n≥N, it is not enough for one term to land close; every term from N on must, so the sequence stays close rather than visiting. The first N-1 terms are ignored completely, which is why changing finitely many terms never changes a limit.

The quantifiers also dictate the shape of every convergence proof before any arithmetic is done. The universal ∀ε>0 is met by "Let ε>0", assuming nothing about it but positivity. The existential ∃N is met by naming an N, which may be built from ε but from nothing chosen later. The inner universal is met by "Let n≥N". What remains is to show |an-L|<ε using only those facts. An N that works may always be replaced by a larger one, so there is no need to find the smallest; the proof only has to find one.

The first limit: 1n→0

Theorem. The sequence an=1n converges to 0.

Proof. Let ε>0. By the Archimedean property there is a natural number N with N>1ε. Let n≥N. Then

|an-0|=1n≤1N<ε

where the first inequality holds because n≥N>0, and the second follows from N>1ε on multiplying both sides by the positive number εN. Since ε was arbitrary, 1n→0. □

For ε=0.01 the proof asks for N>100, and N=101 is the answer the lesson on quantifiers found by hand. The proof answers every tolerance at once, with a recipe rather than a table.

The one step that is not arithmetic is the existence of N, and it is not a formality. It is the Archimedean property, which the previous lesson derived from completeness. There are ordered fields that obey every rule of school algebra and contain positive elements smaller than every 1n; in such a field the sceptic names one of those as ε and wins. The most basic limit in analysis is already a fact about the reals, not about algebra.

How a proof is found, and how it is written

For most sequences the right N is not obvious, and the finished proof hides how it was found, because the work happens in two passes. The first is scratch work, done on the side and never handed in: start from the goal |an-L|<ε, simplify |an-L|, and work backwards to a condition on n that guarantees it. The second is the proof, which runs forwards: it starts from ε, names the N the scratch work found, and checks that it wins.

Example. Prove that an=3n+1n+2 converges to 3.

Scratch work. Simplify the distance to the limit:

|an-3|=|3n+1-3(n+2)n+2|=5n+2

The goal 5n+2<ε holds exactly when n>5ε-2. That is the sharpest condition, but a cruder one is easier to write with: since 5n+2<5n, it is enough that 5n<ε, which holds once n>5ε. So take N>5ε.

Proof. Let ε>0. By the Archimedean property there is N∈ℕ with N>5ε. Let n≥N. Then

|an-3|=5n+2<5n≤5N<ε

so |an-3|<ε for every n≥N. Since ε was arbitrary, an→3. □

At ε=0.1 the proof asks for N>50, so N=51, while the sharp condition n>48 shows the smallest working position is 49. Both win, and the proof is shorter for not caring which. What the proof never contains is the backwards reasoning: "suppose |an-3|<ε, then..." would be assuming the conclusion, and a reader would rightly object.

Now you. Prove that an=4n-12n+3 converges to 2, showing the scratch work and the proof separately.

Answer

Scratch work. |an-2|=|4n-1-2(2n+3)2n+3|=72n+3, which is less than 72n. That is below ε once n>72ε.

Proof. Let ε>0. By the Archimedean property there is N∈ℕ with N>72ε. Let n≥N. Then |an-2|=72n+3<72n≤72N<ε. Since ε was arbitrary, an→2. □

Proving that a sequence diverges

A sequence diverges when it converges to no real number at all. The lesson on quantifiers negated the definition: an fails to converge to L when

∃ε>0∀N∈ℕ∃n≥N(|an-L|≥ε)

The roles swap. Now the prover picks one tolerance, the sceptic picks any starting position, and the prover must find a term beyond it that misses. To prove divergence, this must be done for every candidate L, so the proof starts "Let L be any real number."

Example. Prove that an=(-1)n diverges.

Let L be any real number, and take ε=1. Let N∈ℕ. The terms at positions 2N and 2N+1 are both beyond N, and they are 1 and -1. If both were within 1 of L, the triangle inequality would give

2=|1-(-1)|≤|1-L|+|L-(-1)|<1+1=2

which is impossible. So one of the two positions gives an n≥N with |an-L|≥1. Since N was arbitrary, an does not converge to L, and since L was arbitrary, it converges to nothing. □

The proof never says which of the two terms misses, only that one does, and an existential claim needs no more.

Now you. Prove that an=n diverges.

Answer

Let L be any real number, and take ε=1. Let N∈ℕ. By the Archimedean property there is a natural number m>L+1; let n be the larger of N and m. Then n≥N and n>L+1, so |an-L|≥n-L>1. Since N and then L were arbitrary, an diverges. □

Uniqueness and the ε2 argument

Writing liman=L presumes a sequence has only one limit, and that needs proof.

Theorem. If an→L and an→M, then L=M.

Proof. Suppose not, so L≠M, and let ε=|L-M|2, which is positive. Since an→L there is N1 with |an-L|<ε for all n≥N1, and since an→M there is N2 with |an-M|<ε for all n≥N2. Let n be the larger of N1 and N2. By the triangle inequality,

|L-M|≤|L-an|+|an-M|<ε+ε=|L-M|

a contradiction. So L=M. □

The idea is to spend the tolerance in halves: two distances each below ε2 sum to less than ε, and taking the later of two positions makes both guarantees hold at once. The same budget proves that limits respect addition.

Example. Prove that if an→L and bn→M, then an+bn→L+M.

Let ε>0. Then ε2>0, so, applying the definition to each sequence with tolerance ε2, there are N1 and N2 with |an-L|<ε2 for n≥N1 and |bn-M|<ε2 for n≥N2. Let N be the larger of N1 and N2, and let n≥N. Then

|(an+bn)-(L+M)|≤|an-L|+|bn-M|<ε2+ε2=ε

Since ε was arbitrary, an+bn→L+M. □

Now you. Prove that if an→L, then an+1-an→0.

Answer

Let ε>0. There is N with |an-L|<ε2 for all n≥N. Let n≥N; then n+1≥N too, so

|an+1-an|≤|an+1-L|+|L-an|<ε2+ε2=ε

Since ε was arbitrary, an+1-an→0. □ For (-1)n the consecutive differences are always ±2, which gives a second proof that it diverges.

Bounded, increasing, and what completeness buys

A sequence is bounded when some B has |an|≤B for every n. Every convergent sequence is. If an→L, the definition with ε=1 gives N with |an-L|<1 for n≥N, and then |an|≤|an-L|+|L|<|L|+1. Only the finitely many terms before position N are left, so B, the largest of |a1|,…,|aN-1| and |L|+1, bounds them all. The converse fails, as the bounded divergent (-1)n shows. But one extra condition rescues it.

A sequence is increasing when an≤an+1 for every n, and then, by induction, an≤am whenever n≤m.

Theorem (monotone convergence). A bounded increasing sequence of reals converges to the supremum of its terms.

Proof. The set A={an:n∈ℕ} is nonempty and bounded above, so by the completeness axiom it has a supremum s. Let ε>0. Since s-ε<s, it is not an upper bound of A (the supremum characterisation from the previous lesson), so some term has aN>s-ε. Let n≥N. Then s-ε<aN≤an≤s, the middle step because the sequence increases and the last because s is an upper bound. So |an-s|<ε, and an→s. □

In ℚ the theorem is false. The decimal truncations of 2, namely 1,1.4,1.41,1.414,1.4142,…, are rational, increasing and bounded above by 2. In ℝ the nth truncation is within 10-(n-1) of 2, and 10-(n-1)≤1n, so they converge to 2, exactly as 1n does. If they also converged to some rational q (a real tolerance can always be shrunk to a rational one, so the definition means the same in either setting), uniqueness would force q=2, which is irrational. So the sequence has no limit in ℚ. The proof breaks at its first line, where a supremum is needed and the rationals do not supply one. That is what completeness buys: sequences that ought to converge, do.

Writing a proof someone else can check

A proof is written for a reader who does not trust its writer, and four habits make it checkable. First, state what is being proved, with the quantifiers put back: "for every ε>0 there is an N" is a claim a reader can hold the proof against, while "an gets close to 3" is not. Second, name every quantity when it is introduced and say where it comes from: "let ε>0" makes it arbitrary, "there is N∈ℕ with N>5ε" makes it chosen, and a reader can then check that N depends on ε and on nothing chosen later. Third, justify each step by a definition or an earlier result, by name: the Archimedean property, the triangle inequality, the completeness axiom.

The fourth habit is to read the finished proof back as the sceptic, hunting for the move that would lose the game. Writing "take N=5ε" loses it, because that is not a natural number for most ε, and the Archimedean property is what repairs it. Writing "let ε=1n" loses it too, because the sceptic chose ε first and n does not yet exist. A proof that survives that reading can be checked by anyone, line by line, without trusting its author.

What has been built

The course began with patterns that held for forty cases, or for every number below 906,150,257, and then failed, and it has built the means to settle such claims instead. Statements and quantifiers say exactly what is claimed and what its negation claims. Direct proof, cases, the contrapositive, contradiction and induction establish it. Sets, functions and relations are the language the claims are written in, bijections measure infinite sets, and completeness says what the real numbers are. This lesson needed nearly all of it: quantifiers for the definition, negation for divergence, contradiction for uniqueness, the supremum for monotone convergence.

Real Analysis continues directly from here, with the same ε arguments applied to products and quotients of sequences, to continuity, derivatives and integrals, and to the question of which sequences converge when no limit is known in advance. Calculus uses these limits informally, as a tolerance game played with functions rather than sequences, and everything proved here stands behind it. Discrete Mathematics takes induction, sets, functions and relations as its daily tools. Each of them assumes a reader who can take a definition, say exactly what it claims, and prove things from it, which is what this course set out to make.

Proof and Logic, from libre.university