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 patterns that survived far longer than anyone would need to be convinced, and then failed. They are the reason mathematics settles its claims by proof rather than by evidence. The rest of the lesson says what a proof is, names the parts of the structure that proofs build (axioms, definitions, theorems, lemmas, conjectures), writes the first proofs out in full from the definitions of even and odd, and then turns to the two skills every later lesson relies on: reading a proof actively, and writing one that a reader can check. It closes on the question of how much detail a proof needs, and on what the word "obvious" can hide. It assumes school algebra, the material of Mathematical Foundations, 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.

It is worth being exact about what the forty checks did establish. Each one is a small proof: "n2+n+41 is prime when n=17" is settled by computing 172+17+41=347 and confirming that no integer from 2 to 18 divides it. What no check can do is reach the claim "for every n", because that claim has infinitely many instances and each check settles one. Later in this lesson a proof will settle infinitely many instances in the other direction, showing that the expression is composite for every positive multiple of 41.

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. The number of regions is therefore

R(n)=1+(n2)+(n4)

For six points that is 1+15+15=31, and for seven it is 1+21+35=57, nowhere near 64. Eight points give 99 against 128, and the gap only widens: R(n) is a polynomial in n of degree 4, while 2n−1 doubles at every step.

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. (Problem 14 shows that the agreement is not an accident of arithmetic but has a reason, and that the reason expires at five.) 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.

Why does every choice of four points give exactly one crossing?

Two chords with a common endpoint meet only at that endpoint, on the circle, so every interior crossing comes from two chords with four different endpoints. The question is which pairs of such chords cross.

A chord AB cuts the disc into two pieces, one on each side of the line through A and B, and it cuts the circle into two arcs, one in each piece. Take another chord CD with C and D different from A and B. If C and D lie on the same arc, the whole segment CD lies in one piece, because each piece is the part of the disc on one side of a line, and the part of a disc on one side of a line contains every segment between two of its points. So CD does not cross AB. If C and D lie on different arcs, they are on opposite sides of the line AB, so the segment CD meets that line, and it meets it inside the disc, which is where CD lies. So the chords cross. In short: two chords cross exactly when their endpoints alternate around the circle.

Now label four points in the order they sit around the circle as P1,P2,P3,P4. They can be split into two pairs in three ways: {P1P2,P3P4}, {P1P4,P2P3} and {P1P3,P2P4}. In the first two the endpoints do not alternate, and in the third they do. So exactly one of the three pairs of chords crosses, at the point where the diagonals of the quadrilateral P1P2P3P4 meet. Different sets of four points give different crossing points, because a crossing lies on exactly two chords (no three chords pass through one interior point) and those two chords determine their four endpoints. That proves there are exactly (n4) crossings.

The claim that a new chord crossing k old ones adds k+1 regions needs a similar check. The k crossing points are distinct, so they cut the new chord into k+1 segments. Each segment runs through the interior of a single existing region from one side of it to the other, and so divides that region into two.

One more coincidence is waiting further out. With ten points the formula gives 1+45+210=256=28, a power of two again, though not the one the pattern predicted (29=512). A pattern that has failed can still throw up numbers that look like it, which is one more reason not to trust patterns.

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 906150257. Up to that number, 453075128 have an odd number of prime factors and 453075129 have an even number, so the odd ones are outnumbered by one. Every n from 2 to 906150256 obeys the conjecture.

A second conjecture of the same family has a stranger history. For each whole number k, let μ(k) be 0 if some prime divides k twice, and otherwise 1 or −1 according as k has an even or an odd number of prime factors. So μ(1)=1, μ(2)=μ(3)=−1, μ(4)=0, μ(6)=1. Add these up to n and call the total M(n): the first values are M(1)=1, M(2)=0, M(3)=−1, M(4)=−1, M(5)=−2. The running total wanders up and down, and in 1897 Franz Mertens conjectured that it always stays small: |M(n)|<n for every n>1. The conjecture mattered, because it would have implied the Riemann hypothesis, one of the most famous open problems in mathematics. It has been checked by computer far beyond 1014, and no value of n that breaks it has ever been found.

It is false. In 1985 Andrew Odlyzko and Herman te Riele proved that |M(n)| exceeds n for some n, and to this day nobody knows a single such n. The first one is believed to be so large that no search by computer will ever reach it. Here the evidence was not merely insufficient: it may never be possible to see the conjecture fail, however long anyone checks.

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.

How can anyone know a counterexample exists without finding it?

By proving that the claim, if true, would lead to something false. Haselgrove, and later Odlyzko and te Riele, did not search for a bad n. They showed that if the conjecture held for every n, then certain quantities built from the zeros of Riemann's zeta function would have to behave in a particular way, and then computed enough of those zeros, to high precision, to see that they do not. So the conjecture cannot hold for every n, and some n breaks it. The argument never needs to know which.

The same thing had happened before. For every x that anyone could compute, the number of primes up to x is smaller than a standard estimate for it, the logarithmic integral. In 1914 J. E. Littlewood proved that the difference changes sign infinitely often, so the inequality fails for some enormous x. More than a century later no such x has been exhibited, though the first one is known to be below 10317.

This kind of proof, which shows that something exists without producing it, is called non-constructive, and it is entirely legitimate. It rests on two ideas this course develops properly later: that the negation of "for every n, P(n)" is "for some n, not P(n)" (in the quantifiers lesson), and that a statement which leads to a falsehood must itself be false (proof by contradiction, in the lesson on contrapositive and contradiction). The lesson on direct proof has a short example of an existence proof that never names its witness.

For the working mathematician the moral cuts both ways. Numerical evidence can be overwhelming and still wrong; and a conjecture can be settled, completely and permanently, while its counterexamples stay out of reach.

When one case is the whole proof

The asymmetry between confirming and refuting has a practical side. To refute a claim about every case, one case is enough, and checking that one case is a complete proof that the claim is false. The check has to be exact and has to be shown, but nothing more is required.

Euler supplies the next example against himself. Fermat had claimed that no cube is a sum of two positive cubes and no fourth power a sum of two fourth powers, and in 1769 Euler conjectured a generalisation: for every k≥3, a sum of fewer than k positive kth powers is never a kth power. So three fourth powers never add to a fourth power, four fifth powers never add to a fifth power, and so on. The conjecture stood for almost two hundred years. In 1966 L. J. Lander and T. R. Parkin, searching by computer, found

275+845+1105+1335=1445

and published it in a paper of two sentences. Nothing more was needed: anyone can check that both sides equal 61917364224, and once they have, the conjecture is dead for k=5. In 1988 Noam Elkies found three fourth powers with a fourth-power sum, and Roger Frye then found the smallest such example by computer, 958004+2175194+4145604=4224814.

A good counterexample often does more than refute: examined closely, it can show why the claim fails. The next Example gives one of the most famous counterexamples in number theory, verified twice, once by brute force and once by an argument that shows where the factor comes from.

Example. The numbers Fn=22n+1 are called Fermat numbers. The first five are F0=3, F1=5, F2=17, F3=257 and F4=65537, all prime, and in 1640 Fermat stated his belief that every Fn is prime. Prove that F5=232+1 is not.

The claim "every Fn is prime" is refuted by exhibiting one Fn with a factor strictly between 1 and itself. Euler found such a factor in 1732: 641. The first proof is a multiplication. We have 232=4294967296, so F5=4294967297, and long multiplication gives

641×6700417=4294967297

Both factors are greater than 1, so F5 is composite. That is a complete proof, and it would satisfy any referee.

The second proof avoids large numbers and shows where 641 comes from. Notice that 641=5×27+1 and also 641=54+24. The second fact gives 24=641−54, so

232=24×228=(641−54)×228=641×228−(5×27)4

The first fact gives 5×27=641−1. Expanding (641−1)4 by the binomial theorem, every term except the last contains the factor 641, and the last is (−1)4=1, so (641−1)4=641m+1 for the integer m=6413−4×6412+6×641−4. Putting these together,

F5=232+1=641×228−(641m+1)+1=641(228−m)

and since F5>641, the second factor 228−m is an integer greater than 1. It is in fact 6700417, so the two proofs reach the same factorisation by different routes.

Now you. Multiply the first few primes together and add 1: 2+1=3, 2×3+1=7, 2×3×5+1=31, 2×3×5×7+1=211 and 2×3×5×7×11+1=2311 are all prime. Prove that the pattern fails at the next step.

Answer

The next number is 2×3×5×7×11×13+1=30031, and

59×509=30031

Both factors are greater than 1, so 30031 is composite, and the claim that every such number is prime is false. The multiplication is the whole proof. Finding the factor is another matter: it takes trial division by the primes up to 30031≈173.3, and the first to divide is 59.

Notice that 59 and 509 are both larger than 13. That is no accident: none of the primes 2 to 13 can divide a number that is one more than a multiple of it (Problem 11 proves this). The same observation is the heart of Euclid's proof that there are infinitely many primes, which the lesson on contrapositive and contradiction gives in full. Euclid's argument never claims that these numbers are prime, only that their prime factors are new.

What a proof is

A proof is a finite chain of statements, each of which is justified by one of a few things: a definition, an axiom (a statement taken as a starting point and not argued for), a result that has already been proved, an assumption the proof has openly made (such as the hypothesis of the claim, "suppose a is odd"), or a rule of logic applied to earlier lines. 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, an earlier theorem or the rules of logic. If every line survives that question, the reader has no choice but to accept the conclusion, without needing to trust the writer.

Two things follow from that description. First, a proof is relative to its starting points. It shows that the claim follows from the definitions and axioms used, and if those change, the proof may fail. The claim "the angles of a triangle add up to 180 degrees" is a theorem of Euclid's geometry and false on the surface of a sphere, where a triangle with a vertex at the North Pole and two on the equator can have three right angles. Second, a proof is judged line by line, not as a whole. An argument that is persuasive overall but has one unjustified step is not a proof, however likely its conclusion. Many false "proofs" in the history of mathematics were wrong in exactly one sentence.

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.

Who decides whether a proof is correct?

In principle, anyone who reads it carefully: that is the point of checkability. In practice, a new proof is read by experts, most formally by the referees of the journal it is sent to, and it is accepted when the people best placed to find an error have tried and failed. The system works well but not perfectly, and its failures are instructive.

In 1879 Alfred Kempe published a proof of the four colour theorem, that every map in the plane can be coloured with four colours so that neighbouring regions differ. It was accepted for eleven years. In 1890 Percy Heawood found the flaw: one step in Kempe's argument, a case in which two recolourings are done at once, can fail. Kempe's method still proved that five colours suffice, and the four colour theorem waited until 1976. In 1993 Andrew Wiles announced a proof of Fermat's Last Theorem; a gap was found while the paper was being checked, and Wiles, working with Richard Taylor, repaired it the following year. In both cases the error was found by exactly the kind of line-by-line reading this lesson describes.

What never decides the question is the reputation of the author, the number of people who believe the result, or the amount of evidence for it. A proof by an unknown student is as good as one by a famous professor, and Euler's name did not save his conjecture on sums of powers. Since the 1990s a further check has become available: proof assistants, programs that verify every logical step of a proof written in a formal language. The lesson on direct proof describes how they settled doubts about two proofs too long for any person to check by hand.

Axioms, definitions, theorems and conjectures

Mathematics organises what it knows with a small vocabulary, and every textbook uses it. The words say what role a statement plays, which is also what a reader may do with it.

An axiom is a statement accepted without proof, as a starting point. Every chain of proofs has to start somewhere, and the axioms are where. Euclid began his geometry with five postulates, such as "a straight line can be drawn between any two points"; this course takes as axioms the ordinary rules of arithmetic for the integers and the real numbers, listed later in this lesson, and a few more facts introduced when they are needed, such as the well-ordering of the natural numbers in the lesson on direct proof.

A definition gives a new word an exact meaning in terms of words already understood. "An integer n is even if n=2k for some integer k" introduces "even" and asserts nothing, so it cannot be false. It can only be useful or useless, well chosen or badly chosen. Definitions are written with "if" but always meant as "if and only if": an integer that is not twice an integer is not even.

A theorem is a statement that has been proved, usually one important enough to be remembered. Lesser results go by other names, and the choice is a matter of emphasis, not of logic.

  • A proposition is a proved statement of moderate interest.
  • A lemma is a proved statement whose main purpose is to help prove something else. Long proofs are broken into lemmas the way long programs are broken into functions. Some lemmas outgrew their purpose and kept the name, such as Euclid's lemma about primes.
  • A corollary is a statement that follows from a theorem just proved with little extra work.
  • A conjecture is a statement that someone believes and nobody has proved. Goldbach's conjecture, that every even number greater than 2 is a sum of two primes, has been open since 1742. The twin prime conjecture says there are infinitely many pairs of primes that differ by 2, such as 11 and 13 or 101 and 103.

A conjecture that is proved becomes a theorem, whatever it is still called: "Fermat's Last Theorem" was a conjecture from the 1630s until Andrew Wiles proved it in the 1990s, and the Poincaré conjecture, proved by Grigori Perelman in 2003, kept its name. A conjecture that is refuted becomes a false statement, and the object that refutes it is a counterexample, as n=40 is for Euler's expression.

Most theorems have the shape "if these conditions hold, then this conclusion follows". The conditions are the hypotheses of the theorem and what follows is its conclusion. A theorem says nothing about situations where its hypotheses fail, so every application must first check that they hold. Much of reading mathematics well is keeping track of which hypotheses a result needs.

If axioms are not proved, how do we know they are true?

For most of history the answer was that axioms are self-evident truths about the world, and Euclid's geometry was the model. But one of his postulates, the parallel postulate, never looked as self-evident as the others. In one common form it says that through a point not on a given line there is exactly one line that never meets the given one. For two thousand years mathematicians tried to prove it from the other four, and failed.

Around 1830 János Bolyai and Nikolai Lobachevsky, independently (and Gauss privately, before them), showed why. They developed a geometry in which the other axioms hold and the parallel postulate fails, with infinitely many parallels through the point, and found it perfectly coherent. Its theorems differ from Euclid's: the angles of a triangle add up to less than 180 degrees. Later in the century Eugenio Beltrami built a model of the new geometry inside ordinary Euclidean geometry, which showed that if Euclid's geometry is free of contradictions, so is this one. So the parallel postulate cannot be proved from the others; it is a genuine choice.

The modern view grew from this. Axioms are not claims about the world, but a description of a structure: a proof shows that whatever satisfies the axioms also satisfies the theorem. The structure may model something physical, and whether it does is a question for physics. David Hilbert, who rebuilt Euclid's geometry on complete axioms around 1899, is reported to have said that one must be able to say "tables, chairs and beer mugs" in place of "points, lines and planes", since a proof may use only what the axioms say.

That leaves two demands on a system of axioms. It should be free of contradictions, since from a contradiction anything can be derived (the next lesson shows why), and it should say enough to decide the questions one cares about. In 1931 Kurt Gödel showed that for arithmetic the second demand cannot be fully met: for any consistent list of axioms about the whole numbers that a computer could print out, some statements about the whole numbers can be neither proved nor refuted from it. Mathematicians choose axioms that are consistent as far as anyone can tell, and rich enough for the mathematics they want to do.

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. Is −10 even? Yes, since −10=2×(−5), and the definition never asked for k to be positive. 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 direct proof lesson proves them, from a theorem about division that itself needs an axiom about the natural numbers. Until then, this lesson's proofs about parity may assume only what their hypotheses say.

The word "some" in the definitions matters too, and it gives every definition of this shape two uses. To show a number is even you must produce the k, or show that one exists: 14 is even because 14=2×7. To use the fact that a number is even you may name its k and work with it: if a is even, write a=2k for an integer k, and from then on k is available. Producing and naming are the whole mechanism of the proofs below. The first half of a typical proof names, the second half produces.

Definitions are choices, made to make the theorems come out cleanly. A prime is defined as an integer greater than 1 whose only positive divisors are 1 and itself, and the "greater than 1" is deliberate. If 1 counted as prime, the theorem that every integer greater than 1 factors into primes in only one way would be false, since 6=2×3=1×2×3. Rather than add "apart from factors of 1" to every such theorem, mathematicians exclude 1 once, in the definition.

First proofs

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.

The proof also has the shape the vocabulary above predicts. The claim, spelled out, is "for all integers a and b, if a is odd and b is odd, then a+b is even". The first sentence of the proof takes arbitrary a and b and assumes the hypotheses; the last states the conclusion. Everything between is justified by a definition or by arithmetic.

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.

The algebra here is chosen with the goal in view. Expanding (2k+1)(2m+1) gives four terms, and the target is the form 2×(integer)+1, so the three terms with a factor of 2 are grouped together and the 1 is left outside. Writing the conclusion's definition down first, and then steering the algebra towards it, is how nearly every proof in the first half of this course is found.

A proved result becomes a tool. Taking b=a gives a corollary at once: the square of an odd integer is odd. Applying the result twice shows that a3=(a×a)×a is odd when a is, and so on for every power, though "and so on" is itself a claim about infinitely many cases, which the induction lesson will turn into a proof.

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.

Nothing was assumed about b, not even its parity, and none was needed. That matters here, because this lesson has not yet proved that b must be even or odd.

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. The integer 1 is neither.

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. Notice the check that the second factor exceeds 1. Without it the proof would be incomplete, since a number such as 41=41×1 is a product with a factor of 41 and is prime. The hypothesis m≥1 is used exactly there.

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.

The same idea disposes of every polynomial of this kind. For any integers b and c with c>1, the value of n2+bn+c at n=c is c2+bc+c=c(c+b+1), which is composite as soon as c+b+1>1. Euler's expression was never going to produce primes for ever, and neither is any other polynomial with integer coefficients that is not constant, a fact known since the eighteenth century.

Reading a proof actively

A proof is not read like a story, from start to finish at an even pace. It is read with a pencil, and the reader's job is to be convinced line by line, which means doing a share of the work. Five habits turn passive reading into active reading.

  1. State the claim exactly before reading the proof. Say what is assumed and what is to be shown, with every "for all" and "if" made explicit. A proof of a claim you have not pinned down cannot be checked.
  2. Try the claim on examples. Small cases show what the claim says and often show why it is true. They also give test values for each line of the proof.
  3. Ask of every line what justifies it. The answer should be a definition, an axiom, an earlier result, an assumption made openly, or the rules of algebra and logic. If you cannot find the justification, you have found either a gap in your understanding or a gap in the proof, and both are worth finding.
  4. Find where each hypothesis is used. A hypothesis that is never used is suspicious: either the theorem is stronger than stated, or the proof has a mistake. Then drop the hypothesis and see what goes wrong, which shows why it is there.
  5. Ask what the proof gives beyond the claim. Often the argument proves more than it states, or suggests a stronger result, or fails in a way that points to one.

Example. Read the following proof actively.

Claim. If m and n are odd integers, then m2−n2 is divisible by 4.

Proof. Write m=2k+1 and n=2j+1 with k and j integers. Then m2−n2=(4k2+4k+1)−(4j2+4j+1)=4(k2+k−j2−j), which is 4 times an integer. □

The claim. For all integers m and n: if m is odd and n is odd, then there is an integer t with m2−n2=4t. "Divisible by 4" has been unpacked into its definition, which is what the proof must produce.

Examples. 52−32=16, 72−12=48, 32−72=−40, 52−52=0. All are divisible by 4, including the negative one and the zero.

Line by line. "Write m=2k+1 and n=2j+1" is justified by the definition of odd and the hypotheses; the letters differ because m and n need not be equal. The expansion is algebra, (2k+1)2=4k2+4k+1. The final grouping is the distributive law. That k2+k−j2−j is an integer follows because k and j are integers, and the proof leaves that step to the reader, which is acceptable at this level.

Hypotheses. Both are used, in the first line. Drop one: with m=2 and n=1, m2−n2=3, not divisible by 4. So the claim is false without it.

Beyond the claim. Every example was divisible by 8, not just 4: 16, 48, −40, 0. The proof suggests why. The expression k2+k−j2−j is (k2+k)−(j2+j), and k2+k=k(k+1) is a product of consecutive integers, which is always even. Proving "always even" needs the fact that every integer is even or odd, so the stronger result, that m2−n2 is divisible by 8, must wait for the lesson on direct proof, where it follows from the fact that every odd square is one more than a multiple of 8.

Now you. Read this argument actively, using the five habits, and find the step it takes for granted.

Claim. The product of two consecutive integers is even.

Proof. Let n be an integer. One of n and n+1 is even. An even integer times any integer is even, so n(n+1) is even. □

Answer

The claim. For every integer n, the integer n(n+1) is even, that is, n(n+1)=2t for some integer t.

Examples. 3×4=12, 0×1=0, (−5)×(−4)=20, 10×11=110. All even.

Line by line. The first line introduces an arbitrary integer, which is right for a claim about every integer. The last line uses the second Now you in the section on first proofs, that an even integer times any integer is even, together with the fact that n(n+1)=(n+1)n if the even one is n+1. The middle line, "one of n and n+1 is even", has no justification. It needs two facts: that n is even or odd, and that if n is odd then n+1 is even. The second is easy: if n=2k+1 then n+1=2(k+1). The first is the statement that every integer is even or odd, which the definitions do not give and this lesson has not proved.

Hypotheses. There are none beyond "n is an integer", and it is used: for n=12 the product is 34, which is not an even integer.

So the argument is correct but incomplete at this point in the course, and it becomes a complete proof once the lesson on direct proof proves that every integer is even or odd. The step is the kind that feels too obvious to state. Active reading is how such steps get noticed.

Writing a proof

A proof is written for a reader, and its job is to let that reader check every step without having to reconstruct the writer's thinking. A handful of conventions, followed by almost every mathematician, do most of the work.

Introduce every letter before using it, and say what it is. "Let n be an integer" or "let a and b be odd integers" at the start; "there is an integer k with a=2k" when a new letter arrives from a definition. A letter that appears from nowhere cannot be checked, because the reader cannot know what may be assumed about it.

Use the connecting words precisely. The words carry the logic, and each has a job.

  • "Let" introduces an arbitrary object: "let x be a real number". The proof must then work for every x of that kind.
  • "Suppose" or "assume" introduces a hypothesis to be used for the rest of the argument, or for one case of it.
  • "Since", "because" and "by" give a justification: "since k and m are integers", "by the definition of odd".
  • "So", "therefore", "hence" and "thus" announce a conclusion drawn from what came before.
  • "We must show" or "it suffices to show" announces the goal, which helps the reader in a long proof.

Write in sentences. Every line of a proof, even one that is mostly symbols, should read aloud as an English sentence with a verb. "a+b=2(k+m+1)" is a sentence whose verb is "equals". Do not start a sentence with a symbol ("n is even" is better as "The integer n is even"), and do not use arrows such as ⇒ as shorthand for "so" in a written proof: ⇒ is a connective with a precise meaning, fixed in the next lesson, and "A⇒B" does not say that A is true.

Make chains of equations honest. In a+b=(2k+1)+(2m+1)=2k+2m+2=2(k+m+1) each = joins two expressions that are equal, so the chain proves that the first equals the last. Never write a chain in which some link is not an equation between neighbours, and never start from the equation you are trying to prove.

Justify what a reader could doubt, and nothing more. Routine algebra such as expanding brackets needs no comment. Every use of a definition, of a hypothesis and of an earlier result should be visible. The test is a classmate who knows the definitions but not the proof: any step they could reasonably question needs its reason stated.

Say when you are done. End with the conclusion in words that echo the claim, and then a marker such as □, or the older "Q.E.D." (from the Latin quod erat demonstrandum, "which was to be shown").

Here is the same proof written badly and then well. The bad version:

a=2k+1, b=2k+1, a+b=4k+2=2(2k+1) ⇒ even.

It never says what a and b are or what is being proved. It uses one letter k for both numbers, so it proves the claim only for a=b. It uses ⇒ for "so". And it never says which definition "even" refers to. The good version is the first Example in the section on first proofs: every letter introduced, every step justified, the conclusion tied to the definition. It is longer, and every extra word is doing work.

A proof is also not the record of how it was found. The search for a proof is full of false starts, guesses and working backwards from the goal, and none of that belongs in the final text. The finished proof runs forwards from what is known to what is claimed, as if the route had been obvious all along. The lesson on direct proof shows why working backwards, handed in as a proof, can "prove" false things.

Levels of rigour, and what "obvious" hides

Every proof leaves some steps to the reader. The first Example did not prove that k+m+1 is an integer from any axiom; it said "since k and m are integers", and trusted the reader to accept that sums of integers are integers. How much may be left out is a question of level, and there are roughly three.

An informal argument explains why something is true and skips whatever the speaker considers routine. It is how mathematicians talk to each other at a blackboard, and how the regions on a circle were counted above. A written proof, the kind this course teaches and every textbook and journal uses, justifies every step that a competent reader could doubt, from definitions, axioms and earlier results, and leaves only routine algebra and routine logic unstated. A formal proof leaves nothing out: every step is an application of a stated rule to earlier lines, and a computer can check it. Formal proofs of even simple facts are long, which is why people rarely write them by hand.

The level is a choice about audience, not about truth. A written proof is expected to be convertible into a formal one by a patient reader, and the unstated steps are the ones where that conversion is routine. The danger lies in steps that feel routine and are not. The word "obvious" is where such steps hide, and there are three ways it goes wrong: the obvious fact is false, the obvious fact is true but hard, or the obvious fact is true and easy but has not yet been proved at the point where it is used.

The third kind is the commonest in a first course. "Every integer is even or odd" is true and not hard, but it does not follow from the definitions without a theorem about division, and the Now you on reading actively showed how easily it slips into a proof unannounced. Another example is the ordinary rules of algebra. This course takes as axioms the following facts about the integers (the real numbers obey the same ones). Sums and products of integers are integers, and for all integers a, b and c:

  1. a+b=b+a and ab=ba;
  2. (a+b)+c=a+(b+c) and (ab)c=a(bc);
  3. a(b+c)=ab+ac;
  4. a+0=a and a×1=a;
  5. there is an integer −a with a+(−a)=0.

Subtraction is defined by b−a=b+(−a). Everything else in school algebra, including rules that feel as basic as these, can be proved from them. That is what makes them a good choice of axioms: a short list, from which the rest follows.

Example. Prove from the axioms that a×0=0 for every integer a.

The rule is obvious, and that is the point: the proof shows that it is not an extra assumption but a consequence of the five. The only facts about 0 available are axiom 4, a+0=a, and axiom 5, which involves 0 as the result of adding −a. The trick is to use 0+0=0.

Let a be an integer. By axiom 4, 0+0=0, so

a×0=a×(0+0)=a×0+a×0

by axiom 3. Write x=a×0, so this says x=x+x. By axiom 5 there is an integer −x with x+(−x)=0. Adding −x to both sides of x=x+x gives x+(−x)=(x+x)+(−x). The left side is 0. By axiom 2 the right side is x+(x+(−x))=x+0, which is x by axiom 4. So 0=x, that is, a×0=0. By axiom 1, also 0×a=0. □

The step "add −x to both sides" is a rule of logic rather than an axiom of arithmetic: if two expressions name the same number, adding the same thing to each gives the same result.

Now you. Prove from the axioms, in this order: (i) if a+x=0 then x=−a, so each integer has only one negative; (ii) (−1)×a=−a; (iii) (−a)(−b)=ab. The last is the school rule "a negative times a negative is a positive".

Answer

(i) Let a and x be integers with a+x=0. Then

x=x+0=x+(a+(−a))=(x+a)+(−a)=(a+x)+(−a)=0+(−a)=−a

using, in order, axiom 4, axiom 5, axiom 2, axiom 1, the hypothesis, and axioms 1 and 4 (since 0+(−a)=(−a)+0=−a).

(ii) Let a be an integer. Then

a+(−1)×a=1×a+(−1)×a=(1+(−1))×a=0×a=0

using axiom 4 (with axiom 1 to write a=1×a), axiom 3 (with axiom 1 to put the common factor on the left), axiom 5, and the Example. So (−1)×a is an integer that gives 0 when added to a, and by (i) it equals −a.

(iii) First, (−1)×(−1)=1. By (ii) with a=−1, (−1)×(−1)=−(−1). And (−1)+1=1+(−1)=0 by axioms 1 and 5, so by (i), applied to the integer −1, the negative of −1 is 1. Now let a and b be integers. By (ii), −a=(−1)a and −b=(−1)b, so

(−a)(−b)=((−1)a)((−1)b)=((−1)(−1))(ab)=1×(ab)=ab

where the middle step rearranges a product of four factors using axioms 1 and 2 several times.

The rule that puzzles schoolchildren is therefore forced: any number system with the five properties must have (−a)(−b)=ab. That is a better answer to "why?" than any story about debts.

The second way "obvious" goes wrong is that the fact is true but hard. A closed curve drawn in the plane without crossing itself divides the plane into an inside and an outside. Nobody doubts it, and it is the Jordan curve theorem, stated by Camille Jordan in 1887; his proof was long thought inadequate, and the first proof generally accepted as complete was given by Oswald Veblen in 1905. The difficulty is that "curve" includes shapes far wilder than anything one draws.

The first way is the worst: the obvious fact is false. For most of the nineteenth century mathematicians took it for granted that a continuous function, one whose graph can be drawn without lifting the pen, must have a slope at most points. In 1872 Karl Weierstrass presented a continuous function that has a slope at no point at all. Intuition is formed by the examples one has seen, and the theorems are about all examples, including the ones nobody has drawn.

Does anyone really prove that 1+1=2?

Yes, and the place where it happens shows what a fully formal proof costs. Alfred North Whitehead and Bertrand Russell set out in Principia Mathematica, published in three volumes between 1910 and 1913, to derive mathematics from logic alone. The proposition from which 1+1=2 follows, numbered 54.43, appears several hundred pages into the first volume, and the authors remark that it will follow once arithmetical addition has been defined. The length is not because 1+1=2 is deep. It is because every notion involved, "one", "two", "plus", "equals", had to be built from logic first, and every step recorded.

Most of mathematics does not work that way. The natural numbers are usually given by axioms of their own (Giuseppe Peano's, from 1889, are the standard ones), and from those, 1+1=2 takes a few lines: 2 is defined as the number after 1, and addition is defined so that adding 1 to a number gives the number after it.

The modern descendant of Principia is the proof assistant. Systems such as Lean and Coq check formal proofs by computer, and large libraries of mathematics have been formalised in them. Their users report the same experience Whitehead and Russell had: the steps a written proof calls obvious are where most of the effort goes, and occasionally where an error is found.

This course works at the level of written proofs throughout. Its standard for "obvious" is practical: a step may go unstated only if the reader could supply its proof from the definitions and earlier results in a line or two. The rules of algebra listed in this section meet that standard, having been proved or assumed here. "Every integer is even or odd" does not, until the lesson on direct proof.

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.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution. Unless a problem says otherwise, do not assume that every integer is even or odd.

Warm-up

1. Using only the definitions, show that: (a) −7 is odd; (b) 6n+4 is even for every integer n; (c) 2n2+2n+1 is odd for every integer n; (d) 10n−3 is odd for every integer n.

Solution

(a) We have −7=2×(−4)+1, and −4 is an integer, so −7 is odd.

(b) Let n be an integer. Then 6n+4=2(3n+2), and 3n+2 is an integer, so 6n+4 is even.

(c) Let n be an integer. Then 2n2+2n+1=2(n2+n)+1, and n2+n is an integer, so 2n2+2n+1 is odd.

(d) Let n be an integer. Then 10n−3=10n−4+1=2(5n−2)+1, and 5n−2 is an integer, so 10n−3 is odd. The only step that needs thought is rewriting −3 as −4+1, so that the constant term has the form the definition asks for.

2. In the setting of this lesson, say whether each statement is an axiom, a definition, a theorem or a conjecture, and whether it is known to be true. (a) For all integers a and b, a+b=b+a. (b) An integer n is odd if n=2k+1 for some integer k. (c) The product of two odd integers is odd. (d) Every even integer greater than 2 is a sum of two primes. (e) The number n2+n+41 is prime for every natural number n.

Solution

(a) An axiom (axiom 1 of the list in the section on levels of rigour). It is accepted without proof.

(b) A definition. It introduces the word "odd" and asserts nothing, so it is neither true nor false.

(c) A theorem, proved in the section on first proofs. It is true.

(d) Goldbach's conjecture. Nobody knows whether it is true.

(e) A conjecture that has been refuted, so a false statement: n=40 is a counterexample, since 402+40+41=1681=41×41.

3. It was once believed that 2p−1 is prime whenever p is prime. Check the claim for p=2, 3, 5 and 7, and then show that p=11 is a counterexample.

Solution

The values are 22−1=3, 23−1=7, 25−1=31 and 27−1=127. The first three are clearly prime, and 127 is prime because none of 2, 3, 5, 7, 11 divides it (a factorisation 127=rs with 1<r≤s would need r≤127<12, and every integer from 2 to 11 that is not prime is a multiple of a smaller prime on the list).

For p=11, which is prime, 211−1=2047, and 23×89=2047. Both factors are greater than 1, so 2047 is composite and the claim is false. Primes of the form 2p−1 are called Mersenne primes, after Marin Mersenne; Problem 12 proves the true statement in the other direction.

4. Prove that for all integers a and b: (a) if a is even and b is odd, then a−b is odd; (b) if a and b are both odd, then a−b is even.

Solution

(a) Let a be even and b odd, so a=2k and b=2m+1 for some integers k and m. Then a−b=2k−2m−1=2(k−m−1)+1. Since k−m−1 is an integer, a−b is odd.

(b) Let a and b be odd, so a=2k+1 and b=2m+1 for some integers k and m. Then a−b=2k−2m=2(k−m), and k−m is an integer, so a−b is even.

In (a) the constant −1 had to be rewritten as −2+1 to reach the form 2×(integer)+1.

Core

5. Prove that if a and b are odd integers, then a2+b2 is even but not a multiple of 4.

Hint

Write a2+b2=4s+2 for an integer s. To show it is not 4t for any integer t, look at the difference 4t−(4s+2) and show it can never be 0.

Solution

Let a and b be odd, so a=2k+1 and b=2m+1 for some integers k and m. Then

a2+b2=(4k2+4k+1)+(4m2+4m+1)=4s+2

where s=k2+k+m2+m is an integer. Since 4s+2=2(2s+1) and 2s+1 is an integer, a2+b2 is even.

Now let t be any integer. Then 4t−(a2+b2)=4t−4s−2=2(2u−1), where u=t−s is an integer. If u≥1 then 2u−1≥1, and if u≤0 then 2u−1≤−1; every integer is at least 1 or at most 0, so 2u−1≠0 in either case. Hence 4t−(a2+b2)≠0, that is, a2+b2≠4t. Since t was arbitrary, a2+b2 is not a multiple of 4.

For example, 1+9=10, 9+25=34 and 49+1=50 are all even and none is a multiple of 4.

6. Prove or disprove each claim. (a) The sum of three odd integers is odd. (b) The product of an even integer and an odd integer is odd. (c) The number n2+n+17 is prime for every natural number n. (d) For all integers a and b, if a+b is even, then a and b are both even.

Hint

Two are false. For each false one, a single well-chosen example settles it, but you must verify that the example really fails the conclusion, which may need a line of argument (for instance, that a certain number is not odd). For (c), try the n that makes every term a multiple of 17, or the one just below it.

Solution

(a) True. Let a, b and c be odd, so a=2k+1, b=2m+1 and c=2j+1 for some integers k, m and j. Then a+b+c=2(k+m+j+1)+1, and k+m+j+1 is an integer, so a+b+c is odd.

(b) False. Take 2, which is even, and 1, which is odd (1=2×0+1). Their product is 2. If 2 were odd we would have 2=2k+1 for an integer k, so 2k=1; but 2k≤0 when k≤0 and 2k≥2 when k≥1. So 2 is not odd, and the claim fails. (In fact the product of an even integer and any integer is even, by the second Now you on first proofs.)

(c) False. At n=16, 162+16+17=256+16+17=289=17×17, which is composite. The reason is the one that broke Euler's expression: 162+16=16×17, so the value is 16×17+17=172. The value at n=17, 172+17+17=17×19, is composite too.

(d) False. Take a=b=1. Then a+b=2=2×1 is even, but a is not even: 1=2k would need 2k=1, which fails for every integer k by the argument in (b). The correct statement is that a+b is even exactly when a and b have the same parity, which follows from a result in the lesson on direct proof.

7. Find the flaw in this proof. Is the claim true?

Claim. For every integer n, if n2 is even, then n is even.

Proof. Let n be an even integer, so n=2k for some integer k. Then n2=4k2=2(2k2), and 2k2 is an integer, so n2 is even. □

Hint

Compare what the proof assumes in its first line with what the claim assumes.

Solution

The claim has hypothesis "n2 is even" and conclusion "n is even". The proof assumes "n is even" and concludes "n2 is even". So it proves the converse, "if n is even then n2 is even", which is a different statement. Every line of the proof is correct; it is a correct proof of the wrong claim.

A proof of an "if ... then" statement must begin by assuming the hypothesis of that statement. The error is easy to make here because both statements are true and look alike, and the next lesson shows that a conditional and its converse are, in general, logically independent: either can be true while the other is false. (For example, "if n is divisible by 4 then n is even" is true, and its converse is false at n=2.)

The claim itself is true. A direct attempt stalls, because from n2=2j there is no evident way to write n as twice an integer. The lesson on contrapositive and contradiction proves it by proving the equivalent statement "if n is not even then n2 is not even", and then uses it to show that 2 is irrational.

8. Find the flaw in this argument.

−1=(−1)1=(−1)22=((−1)2)12=112=1
Hint

Every step uses either arithmetic or a law of exponents. For which bases is the law xpq=(xp)q valid when q is a fraction?

Solution

The first two equalities are true, since 22=1. The last two are true, since (−1)2=1 and 112=1=1. The false step is (−1)22=((−1)2)12, which applies the law xpq=(xp)q with x=−1, p=2 and q=12.

That law is proved for real exponents only when the base x is positive. For negative bases, fractional powers are not even defined in the real numbers in general ((−1)12 would be a real number whose square is −1, and there is none), and the law fails: here it would equate (−1)1=−1 with (1)12=1. The same slip lies behind the familiar error x2=x, which fails for every negative x; the correct statement is x2=|x|.

The lesson is about hypotheses. A rule of algebra is a theorem, and like every theorem it has hypotheses, often left unspoken in school. Applying it outside them can "prove" anything.

9. Prove that if n is an odd integer, then n2+4n+7 is a multiple of 4. Is it always a multiple of 8?

Hint

Substitute n=2k+1 and collect terms. For the second question, try the smallest odd positive n.

Solution

Let n be odd, so n=2k+1 for some integer k. Then

n2+4n+7=(4k2+4k+1)+(8k+4)+7=4k2+12k+12=4(k2+3k+3)

and k2+3k+3 is an integer, so n2+4n+7 is a multiple of 4.

It is not always a multiple of 8. At n=1 the value is 12. If 12=8u for an integer u, then u≤1 gives 8u≤8<12 and u≥2 gives 8u≥16>12, so there is no such u. One counterexample settles the question.

10. Using only the five axioms in the section on levels of rigour, the Example there and the results of its Now you, prove that for all integers a, b and c: (a) if a+b=a+c then b=c; (b) −(−a)=a; (c) −(a+b)=(−a)+(−b).

Hint

For (a), add −a to both sides and regroup. For (b) and (c), use part (i) of the Now you: to show that some integer x is the negative of y, it is enough to show y+x=0.

Solution

Two consequences of axioms 1, 4 and 5 are used throughout: 0+x=x+0=x, and (−x)+x=x+(−x)=0, for every integer x.

(a) Let a, b, c be integers with a+b=a+c. Then

b=0+b=((−a)+a)+b=(−a)+(a+b)=(−a)+(a+c)=((−a)+a)+c=0+c=c

using the two consequences above, axiom 2 twice, and the hypothesis in the middle step.

(b) Let a be an integer. By axiom 5 and axiom 1, (−a)+a=0. So a is an integer that gives 0 when added to −a, and by part (i) of the Now you, applied to the integer −a, it is the negative of −a: a=−(−a).

(c) Let a and b be integers. Using axioms 1 and 2 to rearrange the four terms,

(a+b)+((−a)+(−b))=(a+(−a))+(b+(−b))=0+0=0

by axioms 5 and 4. So (−a)+(−b) gives 0 when added to a+b, and by part (i) of the Now you it is −(a+b).

Part (a) is the cancellation law for addition. The corresponding law for multiplication, "if ab=ac and a≠0 then b=c", does not follow from these five axioms; it needs a further one, and the lesson on direct proof shows what happens when its condition a≠0 is forgotten.

11. Let d≥2 be an integer and let M be a multiple of d. Prove that M+1 is not a multiple of d. Deduce that none of the primes 2,3,5,7,11,13 divides 30031.

Hint

Write M=dk. For an arbitrary integer t, show that (M+1)−dt cannot be 0 by splitting into the cases k−t≥0 and k−t≤−1.

Solution

Since M is a multiple of d, M=dk for some integer k. Let t be any integer and put u=k−t, an integer. Then

(M+1)−dt=dk−dt+1=du+1

If u≥0, then du≥0 because d>0, so du+1≥1. If u≤−1, then du≤−d≤−2, so du+1≤−1. Every integer satisfies u≥0 or u≤−1, so in either case du+1≠0, that is, M+1≠dt. Since t was arbitrary, M+1 is not a multiple of d.

Now let M=2×3×5×7×11×13=30030. For each prime p in the list, M is p times the product of the other five, so M is a multiple of p, and p≥2. By the first part, M+1=30031 is not a multiple of p.

So every prime factor of 30031 is larger than 13, which is why the Now you in the section on counterexamples found the factors 59 and 509. The same reasoning, applied to the product of any finite list of primes, shows that no finite list contains every prime.

12. Prove that if n=ab for integers a≥2 and b≥2, then 2n−1 is composite. Illustrate with n=6.

Hint

First prove the identity xb−1=(x−1)(xb−1+xb−2+⋯+x+1) by expanding the right-hand side. Then put x=2a.

Solution

The identity. Let x be a number and b≥1 an integer. Multiplying out,

(x−1)(xb−1+xb−2+⋯+x+1)=(xb+xb−1+⋯+x2+x)−(xb−1+xb−2+⋯+x+1)

Every power x1,…,xb−1 appears once with each sign and cancels, leaving xb−1.

The claim. Let n=ab with a≥2 and b≥2 integers, and put x=2a. Then 2n=(2a)b=xb, so by the identity

2n−1=(2a−1)(2a(b−1)+2a(b−2)+⋯+2a+1)

Both factors are integers. The first is at least 22−1=3, since a≥2. The second is a sum of b≥2 positive terms, including 2a and 1, so it is at least 2a+1≥5. So 2n−1 is a product of two integers each greater than 1, and is composite.

For n=6=2×3: 26−1=63=(22−1)(24+22+1)=3×21. Taking a=3, b=2 instead gives 63=7×9.

So if 2n−1 is prime, then n cannot be composite, and since 21−1=1 is not prime, n must be prime. (Passing from "composite n gives composite 2n−1" to this is the contrapositive, which the next lesson shows is equivalent.) Problem 3 shows that the converse fails.

Challenge

13. Prove that if a positive integer n has an odd divisor m>1, then 2n+1 is composite. Check the result for n=6, and explain why it shows that 2n+1 can be prime only when n is a power of 2.

Hint

For odd m, replace x by −x in the identity of Problem 12 to get a factorisation of xm+1. Then write n=mt and put x=2t. To show the second factor exceeds 1, compare 2n+1 with 2t+1.

Solution

A factorisation. Let m≥1 be odd. The identity of Problem 12 with b=m, applied to the number −x, gives

(−x)m−1=(−x−1)((−x)m−1+(−x)m−2+⋯+(−x)+1)

Since m is odd, (−x)m=−xm, so the left side is −(xm+1), and the first factor on the right is −(x+1). Multiplying both sides by −1,

xm+1=(x+1)S(x),S(x)=xm−1−xm−2+xm−3−⋯−x+1

where the signs alternate, since (−x)j=xj for even j and −xj for odd j, and m−1 is even.

The claim. Let n be a positive integer with an odd divisor m>1, and write n=mt for a positive integer t. Put x=2t, so 2n=xm. Then

2n+1=(2t+1)×S(2t)

The number S(2t) is an integer, since it is a sum and difference of powers of 2. The first factor satisfies 2t+1≥3. Since m≥3 and t≥1, n=mt>t, so 2n+1>2t+1>0. The product of 2t+1 and S(2t) is 2n+1, which is larger than 2t+1; since 2t+1 is positive, this forces S(2t)>1. So 2n+1 is a product of two integers each greater than 1, and is composite.

Check. For n=6, take m=3 and t=2: 26+1=65, and (22+1)(24−22+1)=5×13=65.

Powers of 2. Every positive integer can be written as 2s×m with s≥0 and m odd: divide out factors of 2 until none remain (the prime factorisation proved in the lesson on induction makes this precise). If 2n+1 is prime, then by what was just proved n has no odd divisor greater than 1, so its odd part m is 1 and n=2s. So a prime of the form 2n+1 is a Fermat number Fs=22s+1. The Example on Fermat numbers shows the converse fails at s=5.

14. For integers a≥0 and k≥0, let (ak) be the number of k-element subsets of a set with a elements, so (ak)=0 when k>a. The section on the circle problem found R(n)=1+(n2)+(n4) regions for n points. Prove that

R(n)=(n−10)+(n−11)+(n−12)+(n−13)+(n−14)

for every n≥1, and deduce that R(n)=2n−1 exactly when n≤5.

Hint

First prove Pascal's rule, (nk)=(n−1k−1)+(n−1k) for n≥1 and k≥1, by fixing one element of an n-element set and sorting the k-element subsets by whether they contain it. For the second part, count all the subsets of a set with n−1 elements.

Solution

Pascal's rule. Let n≥1 and k≥1, and let X be a set with n elements. Fix one element x of X. A k-element subset of X either contains x or does not. Those that contain x correspond exactly to the (k−1)-element subsets of X without x (remove x, or put it back), and there are (n−1k−1) of them. Those that do not contain x are exactly the k-element subsets of X without x, and there are (n−1k). Every k-element subset is in exactly one group, so (nk)=(n−1k−1)+(n−1k). The rule holds even when k>n or k−1>n−1, since both sides then count subsets that do not exist.

The identity. Let n≥1. By Pascal's rule with k=2 and k=4,

(n2)=(n−11)+(n−12),(n4)=(n−13)+(n−14)

and 1=(n−10), since a set has exactly one subset with no elements. Adding these three equations gives the identity.

Comparison with 2n−1. Let Y be a set with m=n−1 elements. A subset of Y is fixed by deciding, for each of the m elements, whether it is in or out, so Y has 2m subsets in all. Sorting them by size, 2m is the sum of (mk) over all k from 0 to m. By the identity, R(n) counts only the subsets of size at most 4. So

2n−1−R(n)=the number of subsets of Y with at least 5 elements

If n≤5, then m≤4, no subset has 5 or more elements, and R(n)=2n−1. If n≥6, then m≥5, and Y itself, or any 5 of its elements, gives at least one subset of size at least 5, so R(n)<2n−1.

For n=6 the only such subset is Y itself, and R(6)=32−1=31. For n=10 the missing subsets number 126+84+36+9+1=256, so R(10)=512−256=256, which explains the coincidence with a power of two noted earlier: a 9-element set has exactly as many subsets of size at least 5 as of size at most 4, since taking complements swaps the two kinds.

So the pattern 1,2,4,8,16 was not a coincidence of arithmetic after all. It was the count of all subsets of a set too small to have any subset of size 5, and it stopped the moment such subsets appeared.

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 a good part of its time on the conditional, the connective every theorem is written in. It then treats logic as algebra: which compound statements always say the same thing, which are true whatever their parts, and how to rewrite one into another by a small set of laws. It ends with two results about the connectives themselves: every truth table can be written with "not", "and" and "or" alone, and in fact with a single connective. 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, or proposition, 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. A statement with no connectives inside it, such as "91 is prime", is called atomic; one built from others with connectives is compound.

Is "this sentence is false" a statement?

No, and the reason matters. Suppose it were true. Then what it says holds, so it is false. Suppose it were false. Then what it says fails, so it is not false, that is, it is true. Either truth value leads to the other, so the sentence cannot consistently have one, and it fails the definition of a statement. This is the liar paradox, known since antiquity in the form of Epimenides the Cretan saying that all Cretans are liars.

The paradox is not a curiosity. It arises from a sentence that talks about its own truth, and the same pattern of self-reference drives some of the deepest results of modern logic. Bertrand Russell's paradox of 1901 considers the set of all sets that are not members of themselves and asks whether it is a member of itself; it has the liar's shape exactly, and it forced mathematicians to lay down axioms saying which sets exist, as the lesson on sets explains. Kurt Gödel's incompleteness theorem of 1931 builds a sentence of arithmetic that says, in effect, "this sentence cannot be proved". Unlike the liar, that sentence is a genuine statement: it cannot be false (if it were, it could be proved, and a proof of a false statement cannot exist in a sound system), so it is true and unprovable.

For this course the lesson is modest. The logic that follows assumes that every statement is exactly one of true and false, and the sentences it applies to are ordinary mathematical ones that talk about numbers, sets and functions, not about their own truth.

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). This is the exclusive or, sometimes written P⊕Q, and it is true in the middle two rows only.

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". Likewise the negation of "n is even" is "n is not even", which becomes "n is odd" only once it is known that every integer is one or the other, a fact the lesson on direct proof proves.

English uses many words for ∧. "But", "although", "whereas" and "yet" all mean "and" to a logician, whatever contrast they suggest: "7 is prime but 9 is not" is P∧¬Q. Mathematical writing also hides conjunctions in chains: "0<x<1" is "0<x and x<1", and "a=b=c" is "a=b and b=c".

Compound statements need brackets, just as in arithmetic, since ¬P∧Q could mean (¬P)∧Q or ¬(P∧Q), and these differ. The convention is that ¬ applies to the smallest thing after it, so ¬P∧Q means (¬P)∧Q. For the other connectives this course uses brackets whenever there could be doubt.

The conditional

The fourth connective is the conditional, P⇒Q, read "if P then Q" or "P implies Q". P is the hypothesis (or antecedent) and Q the conclusion (or consequent).

PQP⇒Q
TTT
TFF
FTT
FFT

The first two rows 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, as the next section shows.

Vacuous truth turns up constantly in mathematics, usually without comment. "Every element of the empty set is even" is true, because it says "for every x, if x is in the empty set then x is even", and the hypothesis is false for every x. "All the prime factors of 1 are greater than 100" is true for the same reason. A definition that says "a set of numbers is bounded below by 5 if every element is at least 5" makes the empty set bounded below by 5, and by every other number too. These are not tricks; they are what the definitions say, and results about empty sets and edge cases come out right only because of them.

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 the biconditional of the next section, 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 not odd", 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 not odd. 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, and indeed nothing can: if x>2 then x is positive and x2=x⋅x>2x>4.

Isn't "if the Moon is made of cheese, then 2+2=4" nonsense rather than true?

In conversation, yes, because an English "if ... then" usually promises a connection: the conclusion is supposed to follow because of the hypothesis. The conditional of this lesson, often called the material conditional, promises only that the hypothesis is not true while the conclusion is false. It is the weakest statement that still does the one job theorems need, which is to rule out a true hypothesis with a false conclusion.

The debate is old. Logicians in ancient Greece argued over what makes a conditional true, and Philo of Megara, around 300 BCE, gave the answer used here: a conditional is false only when it leads from a truth to a falsehood. Others demanded a real connection, and philosophers still study "relevance logics" and theories of counterfactuals ("if the match had been struck, it would have lit") in which the connection matters. Mathematics chose Philo's version because it is the one that makes the rules of proof work: with it, P and P⇒Q together always give Q, a conditional is equivalent to its contrapositive, and a universal "if ... then" theorem is true exactly when it has no counterexample.

People reason badly with conditionals even when the stakes are clear. In 1966 the psychologist Peter Wason showed subjects four cards, each with a letter on one side and a number on the other, showing E, K, 4 and 7, and asked which cards must be turned over to test the rule "if a card has a vowel on one side, then it has an even number on the other". Most people choose E, or E and 4. The right answer is E and 7. The rule can fail only on a card with a vowel and an odd number, so the E must be checked for an odd number and the 7 for a vowel; the 4 cannot break the rule whatever is on its back, since a conditional with a true conclusion is true. The truth table is not an arbitrary convention that conflicts with good sense. Used carefully, it is good sense.

The biconditional

The fifth connective is the biconditional, P⟺Q, read "P if and only if Q" and often abbreviated "P iff Q". It is true when P and Q have the same truth value, and false when they differ.

PQP⇒QQ⇒P(P⇒Q)∧(Q⇒P)P⟺Q
TTTTTT
TFFTFF
FTTFFF
FFTTTT

The fifth and sixth columns agree in every row, so a biconditional says exactly that each part implies the other. That is why proving an "if and only if" takes two proofs, one for each direction, and why the lesson on direct proof labels them (⇒) and (⇐). The biconditional is also the negation of the exclusive or: P⟺Q is true where P⊕Q is false, and the reverse.

A true biconditional says that two conditions are interchangeable. "An integer n is divisible by 6 if and only if it is divisible by both 2 and 3" means that, for each integer, the two sides are both true or both false, so one may be replaced by the other anywhere. Mathematicians spend a great deal of effort finding such equivalences, because each one gives two ways to think about the same thing.

The biconditional is not the same as equality of statements, but it behaves like it. For every P, P⟺P is true; if P⟺Q then Q⟺P; and if P⟺Q and Q⟺R, then P⟺R. The last fact justifies chains such as "x2−5x+6=0 if and only if (x−2)(x−3)=0 if and only if x=2 or x=3", where each link is a separate equivalence and the chain concludes that the first and last are equivalent.

Tautologies, contradictions and valid arguments

A truth table can be built for any compound statement, one column per piece, working outwards from the atomic statements. With two atomic statements there are 4 rows; with three there are 8; with n there are 2n, since each atomic statement independently takes one of two values. By convention the rows are listed systematically: the first variable is T in the top half and F in the bottom half, the second alternates in blocks half as long, and so on down to the last, which alternates every row.

Some compound statements come out true in every row, whatever their parts say. Such a statement is a tautology. One that is false in every row is a contradiction, and one that is neither is contingent. Three tautologies are basic enough to have names.

  • The law of excluded middle, P∨¬P: every statement is true or its negation is.
  • The law of non-contradiction, ¬(P∧¬P): no statement is true together with its negation.
  • The law of identity, P⇒P.

Their tables have two rows each and are immediate. A tautology stays a tautology when its atomic statements are replaced by any statements at all, however complicated, since the table never looked at what they said. So (x>3)∨¬(x>3) is true for every x, and so is (P∧Q)∨¬(P∧Q).

One tautology explains a remark in the previous lesson, that a system of axioms must be free of contradictions. The statement (P∧¬P)⇒Q is a tautology: its hypothesis is false in every row, so the conditional is vacuously true in every row, whatever Q is. So from a contradiction, every statement follows. This is the principle of explosion, and it means that a single contradiction among the axioms would make every statement a theorem, including every false one. The lesson on contrapositive and contradiction turns the same fact into a method: if an assumption leads to a contradiction, the assumption is false.

Tautologies of the form "if these premises, then this conclusion" are the valid patterns of reasoning. An argument with premises P1,…,Pk and conclusion C is valid when (P1∧⋯∧Pk)⇒C is a tautology, which means: in no row are all the premises true and the conclusion false. Validity is about form, not truth. A valid argument with a false premise may have a false conclusion; what it cannot do is lead from true premises to a false conclusion. The patterns used most often in proofs are these.

  • Modus ponens: from P and P⇒Q, conclude Q. Every application of a theorem is one: the theorem is P⇒Q, and checking its hypothesis gives P.
  • Modus tollens: from P⇒Q and ¬Q, conclude ¬P.
  • Hypothetical syllogism: from P⇒Q and Q⇒R, conclude P⇒R. This is how results chain together.
  • Disjunctive syllogism: from P∨Q and ¬P, conclude Q.
  • Proof by cases: from P∨Q, P⇒R and Q⇒R, conclude R.

Two invalid patterns are common enough to have names too. Affirming the consequent argues from P⇒Q and Q to P: "if n is divisible by 4 then n is even; n is even; so n is divisible by 4", which fails at n=6. Denying the antecedent argues from P⇒Q and ¬P to ¬Q: "if n is divisible by 4 then n is even; n is not divisible by 4; so n is not even", which fails at n=6 too.

Example. Show that hypothetical syllogism is valid: ((P⇒Q)∧(Q⇒R))⇒(P⇒R) is a tautology.

With three atomic statements there are eight rows. Write H for the hypothesis (P⇒Q)∧(Q⇒R).

PQRP⇒QQ⇒RHP⇒RH⇒(P⇒R)
TTTTTTTT
TTFTFFFT
TFTFTFTT
TFFFTFFT
FTTTTTTT
FTFTFFTT
FFTTTTTT
FFFTTTTT

The last column is T in every row, so the statement is a tautology.

There is a faster way, and it scales better. A conditional is false only when its hypothesis is true and its conclusion false, so look for such a row and see whether one can exist. For the conclusion P⇒R to be false, P must be T and R must be F. For the hypothesis to be true, both P⇒Q and Q⇒R must be T. With P true, P⇒Q forces Q true; with R false, Q⇒R forces Q false. Q cannot be both, so no falsifying row exists, and the statement is a tautology. This is the same search as in the table, organised by working backwards from the one row that could do damage.

Now you. Show that modus tollens is valid, that is, ((P⇒Q)∧¬Q)⇒¬P is a tautology, and that affirming the consequent is not, by finding a row in which ((P⇒Q)∧Q)⇒P is false. Give an instance of the second with real numbers.

Answer

Modus tollens. For the conditional to be false, its conclusion ¬P must be F, so P is T, and its hypothesis must be T, so P⇒Q is T and ¬Q is T, which makes Q false. But then P⇒Q has a true hypothesis and a false conclusion, so it is F, not T. No row makes the whole statement false, so it is a tautology.

Affirming the consequent. Take P false and Q true. Then P⇒Q is T (vacuously) and Q is T, so the hypothesis (P⇒Q)∧Q is T, while the conclusion P is F. In that row the conditional is false, so it is not a tautology, and the argument pattern is invalid.

An instance. "If x>2 then x2>4. We have x2>4. So x>2." The premises are true for x=−3, since the conditional holds for every real number and (−3)2=9>4, but the conclusion −3>2 is false. That is the row P false, Q true.

Is there a faster way than writing out all 2n rows?

Sometimes, as the backwards search in the Example shows. But in general nobody knows one, and this is one of the great open problems of mathematics and computer science.

The question "is there a row that makes this compound statement true?" is called the Boolean satisfiability problem, or SAT. A statement is a tautology exactly when its negation has no satisfying row, so deciding tautologies and solving SAT are the same problem in two guises. The truth table settles it, but with n atomic statements it has 2n rows: 30 statements give over a billion rows, and 300 give more rows than there are atoms in the observable universe. Checking a proposed row, on the other hand, is quick. The question is whether finding a row can always be made nearly as quick as checking one.

In 1971 Stephen Cook proved that SAT is as hard as any problem whose solutions can be checked quickly: a fast method for SAT would give a fast method for all of them, including scheduling, route planning and breaking many codes. Whether such a method exists is the P versus NP problem, one of the seven Millennium Prize Problems announced by the Clay Mathematics Institute in 2000, with a prize of a million dollars. Most experts believe no such method exists.

In practice, modern SAT solvers use clever searches to handle statements with millions of atomic parts, provided they have useful structure, and they have been used to prove theorems. In 2016 Marijn Heule, Oliver Kullmann and Victor Marek used one to settle the Boolean Pythagorean triples problem, showing that the numbers 1 to 7825 cannot be split into two groups neither of which contains a Pythagorean triple a2+b2=c2, while 1 to 7824 can. The proof the computer produced was about 200 terabytes long: a truth table argument on an industrial scale.

Logical equivalence and its laws

Two compound statements are logically equivalent when they have the same truth value in every row of their truth table. Equivalently, A and B are equivalent when A⟺B is a tautology. Since the table lists every case, checking the rows is a complete proof. Equivalent statements say the same thing in different words, and a proof may replace either by the other at any point. 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.

De Morgan's laws are two entries in a short list of standard equivalences, each checked by a truth table of at most eight rows. In the list, T stands for any tautology and F for any contradiction.

NameStatementEquivalent to
Double negation¬¬PP
Commutative lawsP∧Q and P∨QQ∧P and Q∨P
Associative laws(P∧Q)∧R and (P∨Q)∨RP∧(Q∧R) and P∨(Q∨R)
Distributive lawsP∧(Q∨R)(P∧Q)∨(P∧R)
P∨(Q∧R)(P∨Q)∧(P∨R)
De Morgan's laws¬(P∧Q) and ¬(P∨Q)¬P∨¬Q and ¬P∧¬Q
Idempotent lawsP∧P and P∨PP
Absorption lawsP∧(P∨Q) and P∨(P∧Q)P
Identity lawsP∧T and P∨FP
Domination lawsP∨T and P∧FT and F
Complement lawsP∨¬P and P∧¬PT and F
Material implicationP⇒Q¬P∨Q
ContrapositiveP⇒Q¬Q⇒¬P
BiconditionalP⟺Q(P⇒Q)∧(Q⇒P)

Two of these deserve comment. Material implication says that "if P then Q" is the same as "not P, or Q": the conditional is false only when P is true and Q false, which is exactly when ¬P∨Q is false. It is the bridge that lets conditionals be handled with the laws for ∧, ∨ and ¬. The distributive laws come in two forms, and the second, with ∨ distributing over ∧, has no counterpart in arithmetic, where a+bc is not (a+b)(a+c). Logic is more symmetric than arithmetic: every law in the list stays a law when ∧ and ∨ are exchanged and T and F are exchanged, a fact called duality.

The laws turn logic into algebra. Because the truth value of a compound depends only on the truth values of its parts, replacing any part by an equivalent part gives an equivalent whole. So an equivalence can be proved by a chain of rewritings, each justified by a law, in place of a truth table. For three or four atomic statements the chain is usually shorter than the table, and it often shows why the equivalence holds. It gives, for instance, a two-line derivation of the negation of a conditional: ¬(P⇒Q) is equivalent to ¬(¬P∨Q) by material implication, which is equivalent to ¬¬P∧¬Q by De Morgan, and so to P∧¬Q by double negation.

Example. Prove, using the laws, that (P⇒Q)∧(P⇒R) is equivalent to P⇒(Q∧R), and say what the equivalence means for proofs.

StepStatementReason
1(P⇒Q)∧(P⇒R)given
2(¬P∨Q)∧(¬P∨R)material implication, twice
3¬P∨(Q∧R)distributive law, read from right to left
4P⇒(Q∧R)material implication

Each line is equivalent to the one before, so the first is equivalent to the last. For proofs, it says that to prove "if P then both Q and R" it is enough to prove "if P then Q" and "if P then R" separately, and conversely. The proof that 6∣n gives both 2∣n and 3∣n in the lesson on direct proof is of this shape.

Now you. Prove, using the laws, that (P⇒R)∧(Q⇒R) is equivalent to (P∨Q)⇒R, and say what it means for proofs.

Answer
StepStatementReason
1(P⇒R)∧(Q⇒R)given
2(¬P∨R)∧(¬Q∨R)material implication, twice
3(R∨¬P)∧(R∨¬Q)commutative law, twice
4R∨(¬P∧¬Q)distributive law, read from right to left
5R∨¬(P∨Q)De Morgan's law
6¬(P∨Q)∨Rcommutative law
7(P∨Q)⇒Rmaterial implication

For proofs, it is the justification of proof by cases: to show that R follows from "P or Q", show that it follows from P and that it follows from Q. Compare the Example: a conjunction in the conclusion splits into two conditionals joined by "and", and so does a disjunction in the hypothesis. A conjunction in the hypothesis behaves differently: (P∧Q)⇒R is equivalent to (P⇒R)∨(Q⇒R), which is weaker than either conditional alone.

Why do the laws of logic look so much like the laws of algebra?

Because they are the laws of an algebra, and the first person to see this was George Boole. In The Mathematical Analysis of Logic (1847) and The Laws of Thought (1854), Boole wrote statements as letters, "and" as multiplication and "not x" as 1−x, with 1 for true and 0 for false. In his system x2=x for every x, since "P and P" says no more than P, and this equation, which holds for the numbers 0 and 1 and no others, singles out the two truth values. The algebra now called Boolean algebra grew from his work.

The same algebra appears in two other places in this course and beyond. Replace statements by sets, "and" by intersection, "or" by union and "not" by complement, and every law in the table becomes a law of sets: De Morgan's laws for sets, the distributive laws, absorption, all of them. The reason is that "x belongs to A∩B" means "x belongs to A and x belongs to B", so each law of sets is a law of logic applied to membership. The lesson on sets proves them this way.

The second place is electronics. In his 1937 master's thesis at MIT, Claude Shannon showed that circuits of switches obey Boolean algebra: two switches in series pass current exactly when both are closed, which is "and", and two in parallel pass it when at least one is closed, which is "or". So designing a circuit is writing a compound statement, and simplifying the circuit is simplifying the statement by the laws. Every digital computer is built on this correspondence, and the section on functional completeness below explains why engineers can build all of it from one kind of component.

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 (the inverse is the contrapositive of the converse) and differ from the original in the middle two rows. So a proof of ¬Q⇒¬P is a proof of P⇒Q, which the lesson on contrapositive and contradiction 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.

The equivalence with the contrapositive also follows from the laws, without a table: P⇒Q is equivalent to ¬P∨Q by material implication, to Q∨¬P by commutativity, to ¬¬Q∨¬P by double negation, and so to ¬Q⇒¬P by material implication again.

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.

A conditional and its converse are independent: all four combinations of truth values occur. Both can be true ("if n is even then n+1 is odd" and its converse), the statement can be true and its converse false (the Example), the reverse can happen (swap the parts of the Example), and both can be false ("if n is prime then n is odd", refuted by 2, and its converse, refuted by 9). When both are true, the statement and its converse together make a biconditional.

Necessary, sufficient, only if, unless

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. A condition that is necessary and sufficient for Q is one equivalent to it: "a necessary and sufficient condition for n to be divisible by 6 is that it be divisible by 2 and by 3."

"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.

"P unless Q" means that if Q fails, then P holds: ¬Q⇒P, which by material implication and double negation is Q∨P. So "unless" is, for a logician, just "or". "The equation has a real solution unless its discriminant is negative" says: if the discriminant is not negative, there is a real solution. It makes no claim about what happens when the discriminant is negative; in conversation "unless" often suggests the converse too, and in mathematics it does not.

Several other phrases are common, and each has a fixed translation.

EnglishSymbols
P implies Q; if P then Q; Q if P; Q whenever PP⇒Q
P only if Q; P is sufficient for Q; Q is necessary for PP⇒Q
Q provided that P; Q follows from PP⇒Q
P unless Q¬Q⇒P, that is, P∨Q
P if and only if Q; P is necessary and sufficient for Q; P exactly when QP⟺Q
neither P nor Q¬P∧¬Q

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. Theorems get no such licence: in a theorem, "if" means only "if".

Normal forms

Every compound statement, however tangled, can be rewritten in one of two standard shapes, and the rewriting can be read straight off the truth table.

A literal is an atomic statement or the negation of one, such as P or ¬Q. A statement is in disjunctive normal form (DNF) if it is a disjunction of terms, each of which is a conjunction of literals, as in (P∧¬Q)∨(¬P∧Q∧R). It is in conjunctive normal form (CNF) if it is a conjunction of clauses, each of which is a disjunction of literals, as in (P∨Q)∧(¬P∨R). The names say which connective is on the outside: DNF is an "or" of "and"s, CNF an "and" of "or"s. A single literal, or a single term, counts as a (short) disjunction or conjunction.

The key observation is that each row of a truth table can be described by a conjunction of literals that is true in that row and in no other. For the row in which P is T, Q is F and R is T, the conjunction is P∧¬Q∧R: it is true exactly when P is true, Q is false and R is true. Now take any truth table. Write down the conjunction for each row in which the statement is T, and join them with ∨. The result is true in a row exactly when one of its terms is true there, which happens exactly when that row is one of the T rows. So it has the given truth table, and it is in disjunctive normal form.

Conjunctive normal form comes from the F rows in the same way. For each row in which the statement is F, write the disjunction of literals that is false in that row and in no other: for the row P T, Q F, R T it is ¬P∨Q∨¬R, which fails only when every literal fails. Join these clauses with ∧. The result is false in a row exactly when one of its clauses is false there, that is, exactly in the F rows.

Example. The majority statement M of P, Q and R is true exactly when at least two of the three are true. Find a DNF and a CNF for M, and simplify them.

PQRMrow conjunctionrow disjunction
TTTTP∧Q∧R
TTFTP∧Q∧¬R
TFTTP∧¬Q∧R
TFFF¬P∨Q∨R
FTTT¬P∧Q∧R
FTFFP∨¬Q∨R
FFTFP∨Q∨¬R
FFFFP∨Q∨R

The DNF is the disjunction of the four row conjunctions of the T rows:

(P∧Q∧R)∨(P∧Q∧¬R)∨(P∧¬Q∧R)∨(¬P∧Q∧R)

and the CNF is the conjunction of the four row disjunctions of the F rows:

(¬P∨Q∨R)∧(P∨¬Q∨R)∧(P∨Q∨¬R)∧(P∨Q∨R)

Both are correct and both are clumsy. The laws shorten them. The first two terms of the DNF share P∧Q, and by the distributive law their disjunction is (P∧Q)∧(R∨¬R), which is P∧Q by the complement and identity laws. More directly, (P∧Q)∨(P∧R)∨(Q∧R) is true exactly when some two of the three are true, which is exactly when at least two are true, so it is a shorter DNF for M. The same reasoning applied to the CNF gives (P∨Q)∧(P∨R)∧(Q∨R): this is true exactly when every pair contains a true statement, that is, when at most one of the three is false. The two short forms are duals of each other, as the duality principle predicts.

Now you. Find a CNF and a DNF for (P⇒Q)⇒R from its truth table, and check them against a short form obtained with the laws.

Answer

The statement is false exactly when P⇒Q is true and R is false. With R false, P⇒Q is true in the rows $(P, Q) = $ (T, T), (F, T) and (F, F). So the F rows are TTF, FTF and FFF, and the other five rows are T.

The CNF, one clause per F row, is

(¬P∨¬Q∨R)∧(P∨¬Q∨R)∧(P∨Q∨R)

The DNF, one term per T row (TTT, TFT, TFF, FTT, FFT), is

(P∧Q∧R)∨(P∧¬Q∧R)∨(P∧¬Q∧¬R)∨(¬P∧Q∧R)∨(¬P∧¬Q∧R)

With the laws: (P⇒Q)⇒R is equivalent to ¬(P⇒Q)∨R by material implication, and ¬(P⇒Q) is equivalent to P∧¬Q, so the statement is equivalent to (P∧¬Q)∨R. That is a DNF with two terms. It is true when R is true (four rows) or when P is T, Q is F and R is F (one more row), five rows in all, matching the table. Distributing gives the CNF (P∨R)∧(¬Q∨R), which is false exactly when R is false and either P is false or Q is true, which are the three F rows found above.

Normal forms give every statement a standard shape. Two statements in the same atomic statements are equivalent exactly when their full DNFs (one term per T row) have the same terms, and SAT solvers take their input in CNF. The Logic course's lesson on normal forms treats them from a logician's side. The construction also proves something stronger, which is the subject of the next section.

Functional completeness

A truth function of n variables is any rule that assigns T or F to each of the 2n rows of a truth table. Each connective is one: ∧ is the truth function of two variables with a T in the first row only. Since each of the 2n rows may independently get T or F, there are 22n truth functions of n variables. For two variables that is 24=16, and the five connectives of this lesson are just the most useful of the sixteen. The question is whether they, or fewer, are enough to express the others. A set of connectives is functionally complete if every truth function, of any number of variables, is the truth table of some statement built from atomic statements using only those connectives.

Theorem. The set {¬,∧,∨} is functionally complete.

Proof. Let a truth function of n variables P1,…,Pn be given. If it is F in every row, it is the truth table of P1∧¬P1, which uses only ¬ and ∧. Otherwise it has at least one T row, and the construction of the previous section produces a statement in disjunctive normal form, built from ¬, ∧ and ∨ alone, that is true in exactly the T rows. Its truth table is therefore the given one. □

Fewer connectives suffice. By De Morgan's law and double negation, P∨Q is equivalent to ¬(¬P∧¬Q), so every ∨ in a statement can be replaced by ¬ and ∧ without changing its truth table.

Corollary. The sets {¬,∧}, {¬,∨} and {¬,⇒} are functionally complete.

Proof. The first was just shown. For the second, P∧Q is equivalent to ¬(¬P∨¬Q), so ∧ can be removed in favour of ¬ and ∨. For the third, P∨Q is equivalent to ¬P⇒Q by material implication (and double negation), so ∨ can be removed from {¬,∨} in favour of ¬ and ⇒. In each case every statement in the complete set {¬,∧,∨} can be rewritten, one connective at a time, into an equivalent statement using only the smaller set. □

Remarkably, a single connective is enough. The NAND ("not and") connective, P↑Q, is defined to be equivalent to ¬(P∧Q): it is false only when both parts are true.

Theorem. The set {↑} is functionally complete.

Proof. Since {¬,∧} is complete, it is enough to express ¬ and ∧ using ↑ alone. First, P↑P is equivalent to ¬(P∧P), which is ¬P by the idempotent law. Second, P∧Q is equivalent to ¬¬(P∧Q), which is ¬(P↑Q), and by the first part that is (P↑Q)↑(P↑Q). So every statement built with ¬ and ∧ can be rewritten with ↑ alone. □

Henry Sheffer published this in 1913, and NAND is often called the Sheffer stroke; Charles Sanders Peirce had noticed it around 1880 but did not publish. The same is true of NOR, P↓Q, equivalent to ¬(P∨Q), which Problem 11 asks you to prove.

Not every set of connectives is complete, and proving that one is not needs a different kind of argument: some property that all the statements built from the set share, and some truth function that lacks it.

Theorem. The set {∧,∨} is not functionally complete. In particular, ¬P cannot be expressed using ∧ and ∨ alone.

Proof. Consider the row in which every atomic statement is true. Every atomic statement is true in that row. If two statements A and B are both true in that row, then so are A∧B and A∨B. Every statement built from atomic statements with ∧ and ∨ is made by finitely many such steps, starting from atomic statements, and each step keeps the property, so every such statement is true in the all-true row. But ¬P is false in the row where P is true. So no statement built with ∧ and ∨ has the truth table of ¬P. □

The argument, "the building blocks have the property, and each way of combining them preserves it", is an instance of structural induction, which the lesson on induction makes precise. It proves more than the theorem states: adding ⇒ and ⟺ to the set does not help, since A⇒B and A⟺B are also true whenever A and B are. Every complete set must contain some connective that can turn truth into falsehood.

Why does it matter that one connective is enough?

Because computers are built from it. A logic gate is a small circuit whose output voltage, high or low, is a truth function of its input voltages. In the transistor technology used in almost every chip since the 1980s, NAND and NOR gates are the simplest gates to build, each needing four transistors, while an AND gate is typically built as a NAND followed by a NOT. Functional completeness guarantees that any circuit, from an adder to a whole processor, can be built from NAND gates alone. Chip designers do not literally do that, but the standard libraries of components they work from are built around NAND and NOR, and the "NAND flash" memory in phones and memory sticks takes its name from the way its cells are wired, in series, like the transistors in a NAND gate.

An early example of single-gate design flew to the Moon. The Apollo Guidance Computer, which navigated the Apollo spacecraft, was built from integrated circuits that each contained NOR gates and nothing else. Using one type of chip simplified manufacturing and testing at a time when integrated circuits were new and unreliable, and functional completeness made it possible.

The counting fact 22n also has a consequence. The number of truth functions grows so fast that most of them need enormous statements: in 1949 Claude Shannon showed, by counting, that for large n almost every truth function of n variables needs a circuit of size exponential in n. Yet nobody can point to a specific, explicitly described truth function and prove that it needs a large circuit. That gap is closely tied to the P versus NP problem from the section on tautologies.

What connectives cannot say

The five connectives are now fixed, the negation of each compound can be written down mechanically, and every truth table can be expressed with them. 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 not odd. 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".

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Which of these are statements? For each statement, give its truth value. (a) 7 is a factor of 91. (b) x2≥0. (c) Factorise x2−1. (d) Every prime greater than 2 is odd. (e) 2100+1 is prime.

Solution

(a) A statement, and true: 91=7×13.

(b) Not a statement: it is an open sentence with the free variable x. It becomes a statement once x is fixed, or once a quantifier is added, as in "for every real number x, x2≥0", which is true.

(c) Not a statement: it is an instruction.

(d) A statement, and true. (A prime p>2 is not divisible by 2, since its only positive divisors are 1 and p; that it is then odd uses the fact, proved in the lesson on direct proof, that every integer is even or odd.)

(e) A statement, and false. Since 100=25×4 has the odd divisor 25, Problem 13 of the previous lesson shows that 2100+1 is composite: it is divisible by 24+1=17. Whether or not one knows the answer, the sentence has a truth value, which is what makes it a statement.

2. Write out the truth tables of ¬P∨(P∧Q) and of P⇒Q, and decide whether they are equivalent. Then show the same thing using the laws.

Solution
PQ¬PP∧Q¬P∨(P∧Q)P⇒Q
TTFTTT
TFFFFF
FTTFTT
FFTFTT

The last two columns agree in every row, so the statements are equivalent.

With the laws: by the distributive law, ¬P∨(P∧Q) is equivalent to (¬P∨P)∧(¬P∨Q). The first part is a tautology by the complement law (and commutativity), so by the identity law the whole is equivalent to ¬P∨Q, which is P⇒Q by material implication.

3. A triangle is isosceles if at least two of its sides are equal, and equilateral if all three are. For the statement "if a triangle is equilateral, then it is isosceles", write the converse, the inverse, the contrapositive and the negation, and say which are true for every triangle.

Solution

The statement is true: if all three sides are equal, then in particular two are.

The converse, "if a triangle is isosceles, then it is equilateral", is false: a triangle with sides 2, 2 and 3 is isosceles and not equilateral (these lengths do form a triangle, since 2+2>3).

The inverse, "if a triangle is not equilateral, then it is not isosceles", is false, by the same triangle. It is equivalent to the converse.

The contrapositive, "if a triangle is not isosceles, then it is not equilateral", is true, being equivalent to the statement.

The negation of a statement about every triangle is, for a particular triangle, "the triangle is equilateral and not isosceles". No triangle satisfies it, as it must be, since the statement is true for every triangle.

4. Let P be "n is prime", Q be "n is odd" and R be "n>2", for a positive integer n. Translate each sentence into symbols. (a) n is prime only if n is odd. (b) n>2 is sufficient for n to be odd. (c) Being odd is necessary for n to be prime, provided n>2. (d) n is not prime unless it is odd. (e) n is odd if it is prime and greater than 2.

Solution

(a) P⇒Q. "Only if" introduces the necessary condition, which is the conclusion. It is false for n=2.

(b) R⇒Q. False for n=4.

(c) R⇒(P⇒Q). "Being odd is necessary for being prime" is P⇒Q, and the proviso makes it conditional on R. It is true for every positive integer n.

(d) "A unless B" is ¬B⇒A. Here A is ¬P and B is Q, so the translation is ¬Q⇒¬P, the contrapositive of (a) and equivalent to it.

(e) (P∧R)⇒Q. It is equivalent to (c): by the laws, R⇒(P⇒Q) is ¬R∨¬P∨Q, and so is (P∧R)⇒Q, since ¬(P∧R) is ¬P∨¬R.

Core

5. Prove the distributive law "P∧(Q∨R) is equivalent to (P∧Q)∨(P∧R)" by a truth table. Then deduce the other distributive law, "P∨(Q∧R) is equivalent to (P∨Q)∧(P∨R)", without a table.

Hint

For the second part, apply the first law to the statements ¬P, ¬Q and ¬R, and negate both sides.

Solution
PQRQ∨RP∧(Q∨R)P∧QP∧R(P∧Q)∨(P∧R)
TTTTTTTT
TTFTTTFT
TFTTTFTT
TFFFFFFF
FTTTFFFF
FTFTFFFF
FFTTFFFF
FFFFFFFF

The fifth and eighth columns agree in all eight rows, which proves the first law.

For the second, a tautology remains one when its atomic statements are replaced by any statements, so the first law holds with ¬P, ¬Q, ¬R in place of P, Q, R: the statement ¬P∧(¬Q∨¬R) is equivalent to (¬P∧¬Q)∨(¬P∧¬R). Equivalent statements have equivalent negations, so

¬(¬P∧(¬Q∨¬R))is equivalent to¬((¬P∧¬Q)∨(¬P∧¬R))

Apply De Morgan's laws and double negation to each side. The left side becomes ¬¬P∨¬(¬Q∨¬R), then P∨(¬¬Q∧¬¬R), then P∨(Q∧R). The right side becomes ¬(¬P∧¬Q)∧¬(¬P∧¬R), then (P∨Q)∧(P∨R). So P∨(Q∧R) is equivalent to (P∨Q)∧(P∨R).

The same argument proves the duality principle in general: negating both sides of any law and pushing the negations inwards exchanges ∧ with ∨.

6. Prove or disprove each claim. (a) (P⇒Q)⇒R is equivalent to P⇒(Q⇒R). (b) P⇒(Q⇒R) is equivalent to (P∧Q)⇒R. (c) (P⇒Q)∨(Q⇒P) is a tautology. (d) (P⟺Q)⟺R is equivalent to P⟺(Q⟺R).

Hint

Exactly one is false. For it, look for a row with P false. For (d), find a simple description of the rows in which each side is true.

Solution

(a) False. Take P false and R false, with Q either value. Then P⇒Q is true (vacuously), so (P⇒Q)⇒R has a true hypothesis and a false conclusion, and is false. But P⇒(Q⇒R) has a false hypothesis, so it is true. The two differ in this row, so they are not equivalent. The conditional is not associative, which is why brackets around it are never omitted.

(b) True. By material implication twice, P⇒(Q⇒R) is equivalent to ¬P∨(¬Q∨R), which by associativity is (¬P∨¬Q)∨R. By De Morgan's law this is ¬(P∧Q)∨R, and by material implication that is (P∧Q)⇒R. In words: "if P, then if Q then R" says the same as "if P and Q, then R". This is why a theorem with two hypotheses can be proved by assuming both at once.

(c) True. By material implication, the statement is equivalent to (¬P∨Q)∨(¬Q∨P), which by the commutative and associative laws is (P∨¬P)∨(Q∨¬Q). Each bracket is a tautology, so the whole is. It sounds absurd ("for any two statements, one implies the other"), and it is a reminder that the material conditional asserts no connection: if Q is true then P⇒Q holds, and if Q is false then Q⇒P holds.

(d) True. A biconditional A⟺B is true exactly when A and B are both true or both false. Claim: (P⟺Q)⟺R is true exactly when an odd number of P, Q, R are true. Check by cases on R. If R is true, the whole is true exactly when P⟺Q is true, that is, when P and Q are both true or both false, that is, when an even number of P, Q are true, which together with the true R makes an odd number in all. If R is false, the whole is true exactly when P⟺Q is false, that is, when exactly one of P, Q is true, again an odd number in all. The same argument, splitting on P in place of R, shows that P⟺(Q⟺R) is true exactly when an odd number of the three are true. The two descriptions coincide, so the statements are equivalent.

7. Find the flaw. A student writes: "To negate a conditional, negate both of its parts. So the negation of P⇒Q is ¬P⇒¬Q, and the negation of 'if n is divisible by 4, then n is even' is 'if n is not divisible by 4, then n is not even'."

Hint

A statement and its negation must have opposite truth values in every row. Check the row with P false and Q false.

Solution

In the row where P and Q are both false, P⇒Q is true (vacuously), and ¬P⇒¬Q is true too, since both its parts are true. A statement and its negation cannot both be true, so ¬P⇒¬Q is not the negation of P⇒Q. What the student wrote is the inverse, which is equivalent to the converse and has nothing to do with the negation.

The correct negation is P∧¬Q: the hypothesis holds and the conclusion fails. For the example, the negation of "if n is divisible by 4, then n is even" is "n is divisible by 4 and n is not even", which no integer satisfies, as it should, since the original holds for every integer. The student's version is false for n=6, which is not divisible by 4 and is even.

The underlying error is treating ¬ as if it distributed over connectives. It does not distribute over ∧ or ∨ either (De Morgan's laws say what happens instead), and over ⇒ it produces a conjunction.

8. On an island, every inhabitant is either a knight, who always tells the truth, or a knave, who always lies. (a) Inhabitant A says: "At least one of us two is a knave." What are A and B? (b) On another occasion, C says "D is a knight", and D says "C and I are of opposite types". What are C and D? In each part, write the information as statements with connectives and solve.

Hint

Let A be the statement "A is a knight". Whatever A says is true exactly when A is a knight, so if A says S, then A⟺S holds.

Solution

Write A for "A is a knight", and similarly for the others. A knave is then someone for whom the statement is false. If a person X says S, then S is true exactly when X is a knight, so X⟺S holds.

(a) A says ¬A∨¬B, so A⟺(¬A∨¬B) holds. If A were false, the right side would have to be false too, so ¬A∨¬B would be false; but ¬A is true, so it is true. That is impossible, so A is true. Then the right side is true: ¬A∨¬B holds, and since ¬A is false, ¬B is true. So A is a knight and B is a knave. Check: A, a knight, says truly that at least one of them (B) is a knave.

(b) C says D, so C⟺D. D says that exactly one of C and D is a knight, which is C⊕D, so D⟺(C⊕D). From the first, C and D have the same truth value, so C⊕D is false. Then the second says D⟺F, so D is false, and by the first C is false. Both are knaves. Check: C, a knave, says falsely that D is a knight; D, a knave, says falsely that they are of opposite types.

Puzzles of this kind were popularised by Raymond Smullyan in the 1970s. Each is a small satisfiability problem: find the rows in which all the biconditionals are true.

9. Using the laws of the section on logical equivalence, and no truth tables, prove: (a) ¬(P∨(¬P∧Q)) is equivalent to ¬P∧¬Q; (b) (P∧Q)∨(P∧¬Q) is equivalent to P; (c) P⇒(Q⇒P) is a tautology.

Hint

In (a), push the negation inwards with De Morgan's laws first, then distribute. In (c), remove the arrows with material implication and regroup.

Solution

(a) By De Morgan's law, ¬(P∨(¬P∧Q)) is equivalent to ¬P∧¬(¬P∧Q). By De Morgan's law and double negation, ¬(¬P∧Q) is equivalent to P∨¬Q, so the whole is ¬P∧(P∨¬Q). By the distributive law this is (¬P∧P)∨(¬P∧¬Q). The first part is a contradiction by the complement law (with commutativity), so by the identity law (A∨F is A, after commuting) the whole is equivalent to ¬P∧¬Q.

(b) By the distributive law, (P∧Q)∨(P∧¬Q) is equivalent to P∧(Q∨¬Q). By the complement law Q∨¬Q is a tautology, and by the identity law P∧T is P.

(c) By material implication twice, P⇒(Q⇒P) is equivalent to ¬P∨(¬Q∨P). By the commutative and associative laws this is (¬P∨P)∨¬Q. The bracket is a tautology by the complement law, and by the domination law T∨¬Q is a tautology. So the statement is equivalent to a tautology, and is one. In words: if P is true, then it follows from anything.

10. Let E be the statement "exactly one of P, Q, R is true". Write E in disjunctive normal form. Then prove that

(P∨Q∨R)∧(¬P∨¬Q)∧(¬P∨¬R)∧(¬Q∨¬R)

is a conjunctive normal form for E, that is, that it has the same truth table.

Hint

For the CNF, read each clause in words. The first says something about "at least", and each of the other three forbids something.

Solution

DNF. E is true in exactly three rows: TFF, FTF and FFT. One term per row gives

(P∧¬Q∧¬R)∨(¬P∧Q∧¬R)∨(¬P∧¬Q∧R)

CNF. Call the displayed statement C. Its first clause, P∨Q∨R, is true exactly when at least one of the three is true. The clause ¬P∨¬Q is equivalent to ¬(P∧Q) by De Morgan's law, so it is true exactly when P and Q are not both true; likewise the other two clauses say that P and R are not both true, and that Q and R are not both true. So the last three clauses together are true exactly when no two of the three are true, that is, when at most one is true. Hence C is true exactly when at least one and at most one is true, which is exactly when E is true. The two have the same truth table.

This CNF is shorter than the one read off the five F rows, and it is the standard way to say "exactly one" to a SAT solver: one clause for "at least one", and one clause for each pair to say "not both".

11. The NOR connective P↓Q is defined to be equivalent to ¬(P∨Q). Prove that {↓} is functionally complete, and write P∧Q and P⇒Q using ↓ alone.

Hint

Since {¬,∨} is complete, it is enough to express ¬ and ∨. Compare with the proof for NAND.

Solution

First, P↓P is equivalent to ¬(P∨P), which is ¬P by the idempotent law. Second, P∨Q is equivalent to ¬¬(P∨Q) by double negation, which is ¬(P↓Q), and by the first part that is (P↓Q)↓(P↓Q). So ¬ and ∨ can both be expressed with ↓ alone. Since {¬,∨} is functionally complete (the corollary in the section on functional completeness), every truth function can be expressed by first writing it with ¬ and ∨ and then replacing each occurrence of these by its expression in ↓. Hence {↓} is functionally complete.

For ∧: by De Morgan's law and double negation, P∧Q is equivalent to ¬(¬P∨¬Q), which is ¬P↓¬Q, that is, (P↓P)↓(Q↓Q).

For ⇒: P⇒Q is equivalent to ¬P∨Q, which by the second part is (¬P↓Q)↓(¬P↓Q), that is,

((P↓P)↓Q)↓((P↓P)↓Q)

A check in one row: with P true and Q false, P↓P is F, then F↓F is T, and T↓T is F, matching P⇒Q in that row.

12. Prove that {⇒} is not functionally complete, but that {⇒,F} is, where F is a constant statement that is false in every row.

Hint

For the first part, adapt the proof that {∧,∨} is not complete. For the second, express ¬P.

Solution

Not complete. Consider the row in which every atomic statement is true. Atomic statements are true in that row, and if A and B are true in that row, then so is A⇒B, since its conclusion is true. Every statement built from atomic statements with ⇒ alone is made by finitely many such steps, each of which keeps the property, so every such statement is true in the all-true row. But ¬P is false in any row where P is true. So ¬P cannot be expressed with ⇒ alone, and {⇒} is not functionally complete.

Complete with F. The statement P⇒F is true exactly when P is false, since its conclusion is always false; so it is equivalent to ¬P. Thus both ¬ and ⇒ can be expressed with {⇒,F}, and since {¬,⇒} is functionally complete (the corollary in the section on functional completeness), so is {⇒,F}.

Adding F breaks the argument of the first part exactly where it must: F is not true in the all-true row. Reading P⇒F as "not P" is the idea behind proof by contradiction: to show ¬P, show that P leads to something false.

Challenge

13. A binary connective ∘ is Sheffer if {∘} is functionally complete by itself. Prove that NAND and NOR are the only Sheffer connectives among the sixteen binary connectives.

Hint

First show that a Sheffer connective must make T∘T false and F∘F true, using the argument of Problem 12 and its mirror image with the all-false row. That leaves four candidates. Two are NAND and NOR. For the other two, show that every statement built with them is equivalent to an atomic statement or its negation.

Solution

Let ∘ be a Sheffer connective.

Step 1: T∘T is F. Suppose instead that T∘T is T. Then, as in Problem 12, every statement built with ∘ alone is true in the row where all atomic statements are true: atomic statements are, and if A and B are true in that row then so is A∘B. So ¬P could not be expressed, contradicting completeness.

Step 2: F∘F is T. Suppose instead that F∘F is F. Then in the row where all atomic statements are false, every statement built with ∘ is false, by the same argument. But ¬P is true in that row, so it could not be expressed, again contradicting completeness.

Step 3: the four candidates. With T∘T false and F∘F true, the connective is fixed by its values in the two middle rows, T∘F and F∘T.

  • Both T: the table is F, T, T, T, which is NAND.
  • Both F: the table is F, F, F, T, which is NOR.
  • T∘F is T and F∘T is F: the table is F, T, F, T, which is the table of ¬Q. So P∘Q is equivalent to ¬Q.
  • T∘F is F and F∘T is T: the table is F, F, T, T, so P∘Q is equivalent to ¬P.

Step 4: the last two are not Sheffer. Take the third, where A∘B is equivalent to ¬B. Claim: every statement built from atomic statements with ∘ alone is equivalent to X or to ¬X for a single atomic statement X. Atomic statements have this form. If A and B have it, say B is equivalent to X or ¬X, then A∘B is equivalent to ¬B, which is equivalent to ¬X or to X (by double negation), so it has the form too. Every statement is built by finitely many such steps, so every one has the form. But P∧Q is not equivalent to any of P, ¬P, Q, ¬Q: it differs from P when P is T and Q is F, from ¬P and from ¬Q when both are T, and from Q when P is F and Q is T. (A statement involving some other atomic statement X has a truth value that changes with X, so it cannot have the table of P∧Q either.) So ∧ cannot be expressed, and this connective is not Sheffer. The fourth candidate is the same with the roles of A and B exchanged.

Conclusion. A Sheffer connective must be NAND or NOR, and both are Sheffer, by the theorem in the lesson and Problem 11.

14. Prove that no statement built from P and Q using only ¬ and ⟺ is equivalent to P∧Q. Deduce that {¬,⟺} is not functionally complete.

Hint

Count the T's in the four-row truth table. Show that every statement built from P and Q with ¬ and ⟺ has an even number of them.

Solution

For a statement A built from P and Q, let t(A) be the number of rows, out of the four, in which A is true. Claim: t(A) is even for every statement built from P and Q with ¬ and ⟺.

Atomic statements. P is true in two rows and so is Q, so t(P)=t(Q)=2.

Negation. ¬A is true exactly in the rows where A is false, so t(¬A)=4−t(A), which is even if t(A) is.

Biconditional. Let A and B be statements with t(A)=a and t(B)=b even, and let c be the number of rows in which both are true. The rows in which A is true or B is true number a+b−c (the c rows where both are true would otherwise be counted twice), so the rows in which both are false number 4−a−b+c. Now A⟺B is true exactly in the rows where both are true or both are false, so

t(A⟺B)=c+(4−a−b+c)=4−a−b+2c

which is even, since a and b are even.

Every statement built from P and Q with ¬ and ⟺ is made from P and Q by finitely many such steps, each of which keeps the number of T rows even, so every such statement has t even. But P∧Q is true in exactly one row, and 1 is odd. So no such statement is equivalent to P∧Q.

Hence the truth function of ∧ cannot be expressed with ¬ and ⟺, and {¬,⟺} is not functionally complete. The same count shows that ∨ and ⇒, each true in three rows, cannot be expressed either. The set {¬,⟺} can express exactly the eight truth functions of P and Q with 0, 2 or 4 true rows; they are the truth functions that computer scientists call linear, and in Boole's algebra with 1 for T they are the sums of P, Q and 1 with arithmetic done modulo 2.

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 the two missing words, "for every" and "there exists". It fixes what they mean, shows that the collection a variable ranges over is part of every claim, gives mechanical rules for negating any quantified statement, and shows that the order of two quantifiers can be the whole difference between a true statement and a false one. It then covers "there is exactly one", the translation of mathematical English into symbols and back, and the quantifiers hidden in ordinary sentences. It ends where the subject earns its keep: the definitions of a limit and of continuity, each a string of three alternating quantifiers, read, used and 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, also called a predicate, is written P(x), so that P(3) is a true statement and P(1) a false one. Open sentences can have several variables. "x<y" is a predicate P(x,y) in two variables, true for the pair (2,5) and false for (5,2), and "a divides b" is another. The set of values that make P(x) true is its truth set: over the real numbers the truth set of x2>4 is everything below −2 together with everything above 2.

Two quantifiers turn an open sentence into a statement.

Definition. The universal quantifier ∀ is read "for all" or "for every". The statement ∀xP(x) is true when P(x) is true for every value of x in the domain, and false when at least one value makes P(x) false.

Definition. The existential quantifier ∃ is read "there exists" or "for some". The statement ∃xP(x) is true when P(x) is true for at least one value of x in the domain, and false when every value makes P(x) false.

"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, and "some real number satisfies x2≥0" is true, though every real number does. As with inclusive "or", the weaker reading is the default, and a stronger one is always spelt out.

When the domain is finite the quantifiers are nothing new. Over the domain {1,2,3}, ∀xP(x) says the same as P(1)∧P(2)∧P(3), and ∃xP(x) says the same as P(1)∨P(2)∨P(3). So "for all" is a long "and", and "there exists" is a long "or". What the quantifiers add is the ability to take that "and" or "or" over infinitely many cases, which no finite formula built from connectives can do.

A variable governed by a quantifier is bound, and one that is not is free. In ∀x(x2≥0) the x is bound, and the statement is about no particular x: renaming it gives ∀t(t2≥0), the same statement. The bound variable is a placeholder, like k in ∑k=110k2 or t in ∫01tdt. A sentence with a free variable is still an open sentence. Over the integers, ∃k(n=2k) has k bound and n free, so it is not a statement but a predicate of n: it says "n is even". That is how definitions are made. Each definition in this course is an open sentence in the thing being defined, with the other variables bound inside it.

A quantifier governs the formula written directly after it, and brackets say how far that reaches. In ∀x(P(x)∧Q(x)) the quantifier covers both parts. In ∀xP(x)∧Q(x) it covers only P(x), and the x in Q(x) is free, so the whole is an open sentence. When in doubt, bracket.

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.

What if the domain is empty?

Then every universal statement is true and every existential statement is false. ∃xP(x) needs a value of x with P(x), and there are none. ∀xP(x) is false only if some value makes P(x) false, and there are none of those either. So over an empty domain "every x satisfies P" is true whatever P is, including P(x) and ¬P(x) at once.

This is the vacuous truth of the previous lesson in another form. A universal statement restricted to a set, such as "every element of A is positive", is ∀x(x∈A⇒x>0), and when A is empty every instance has a false hypothesis. "Every real number x with x2<0 is equal to 17" is true, and so is "every such x is not equal to 17".

The convention is forced, not chosen for convenience. The negation law of the section below says ¬∀xP(x) is the same as ∃x¬P(x). Over an empty domain the right-hand side is false, so ∀xP(x) must be true. Any other choice would break that law, and with it the rule that a universal claim is refuted exactly by a counterexample.

One familiar inference does fail. Over a non-empty domain, ∀xP(x) implies ∃xP(x): pick any element, and it satisfies P. Over an empty domain the first is true and the second false. Formal logic usually requires domains to be non-empty so that this inference holds, and in mathematics the issue surfaces when a statement about "every element of A" is used to produce an element of A. A proof that does so has quietly assumed that A is not empty, and should say so.

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: the lesson on contrapositive and contradiction proves the second, and the lesson on the real numbers the first. And "there is an x with 2x=1" is false over the integers and true over the rationals.

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, so ℕ={1,2,3,…}. When the domain is clear from the context, as in "over the integers" at the head of an argument, it is left out of each quantifier.

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 rule to remember: ∀ goes with ⇒, and ∃ goes with ∧.

The shorthands ∀x>0, ∃n≥N and ∀x∈A abbreviate exactly these patterns. They are called restricted or bounded quantifiers:

∀x>0P(x)means∀x(x>0⇒P(x))∃n≥NP(n)means∃n(n≥N∧P(n))

With them, definitions become short formulas. Over the integers, "a divides b" is ∃k(b=ak), and "n is a perfect square" is ∃m(n=m2). "n is prime" says n>1 and the only positive divisors of n are 1 and n:

n>1∧∀d∈ℕ(d∣n⇒d=1∨d=n)

A positive divisor of a positive integer n is at most n, so the quantifier could equally be written ∀d≤n, with d running over 1,2,…,n. A quantifier bounded by a number in this way ranges over finitely many values, and a statement all of whose quantifiers are bounded like this can be settled by checking. "1009 is prime" is a finite claim, and a computer confirms it by trying every d up to 1009 (or, with a little more thought, up to 31, since a factorisation n=de with 1<d≤e has d2≤n).

Why does it matter whether every quantifier is bounded?

Because it marks the line between what can be settled by a finite computation and what cannot. A statement in which every quantifier ranges over a finite, explicitly given set is a finite conjunction or disjunction in disguise, and a patient enough computer decides it. "Every even number from 4 to 4×1018 is a sum of two primes" is such a statement, and a distributed computation led by Tomás Oliveira e Silva verified it, with the results published in 2014.

Goldbach's conjecture itself is ∀n(neven∧n>2⇒∃p≤n∃q≤n(pprime∧qprime∧n=p+q)). Everything inside the first quantifier is bounded, so each instance can be checked, but the first quantifier is not bounded. That shape has a consequence. If the conjecture is false, a search through the even numbers will eventually find a counterexample and stop. If it is true, the search runs for ever, and no amount of running tells you which case you are in. A statement of the form "for all n, (a checkable property of n)" can be refuted by computation but never confirmed by it.

Logicians sort statements by how their unbounded quantifiers alternate, a classification called the arithmetical hierarchy. Goldbach's conjecture has one unbounded ∀ in front of a checkable property. The twin prime conjecture, that there are infinitely many primes p with p+2 also prime, reads ∀n∃p(p>n∧pandp+2are prime), with an unbounded ∀ followed by an unbounded ∃, and neither a proof nor a disproof of it can come from searching alone: no finite amount of data about primes settles it either way. The definition of a limit, later in this lesson, alternates three times. The more alternations, the further a statement is from anything a computer can check, and the more the proof has to do.

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.

Theorem (negation of quantifiers). For every predicate P(x) over any domain,

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

Proof. For the first, ¬∀xP(x) is true exactly when ∀xP(x) is false. By the definition of ∀, that happens exactly when at least one value of x makes P(x) false, that is, makes ¬P(x) true, and by the definition of ∃ that is exactly when ∃x¬P(x) is true. For the second, ¬∃xP(x) is true exactly when no value of x makes P(x) true, that is, when every value makes ¬P(x) true, which is the meaning of ∀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 theorem says the same holds when the domain is infinite, where there is no finite formula to apply De Morgan to.

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 take over: ¬(P∧Q) is ¬P∨¬Q, ¬(P∨Q) is ¬P∧¬Q, and ¬(P⇒Q) is P∧¬Q. A negated inequality flips completely: ¬(x<y) is x≥y, not x>y.

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. In the other direction, ¬∃n≥NP(n) is ∀n¬(n≥N∧P(n)), which is ∀n(n≥N⇒¬P(n)), or ∀n≥N¬P(n). The restriction says which objects the claim is about, and denying the claim does not change the subject. So the negation of "every positive real has a square root" is "some positive real has no square root", never "some non-positive real ...".

With several quantifiers the rule is applied once per quantifier, from the outside in:

¬∀x∃y∀zP(x,y,z)≡∃x¬∃y∀zP≡∃x∀y¬∀zP≡∃x∀y∃z¬P(x,y,z)

The pattern of the result is easy to remember: every quantifier flips, their order stays, and the ¬ lands on the innermost sentence.

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. The negation of a universal claim is an existential one, which asks for a single exception, not a universal claim of the opposite.

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.

The work was in two steps: first get the symbols right, then negate by rule, and only then think about the mathematics. The rule is reliable, and intuition about what "the opposite" of a sentence should be is not.

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.

Is the negation law really safe for infinite domains?

In the mathematics of this course, yes: the proof above used nothing but the definitions of ∀ and ∃, and nothing in it depended on the domain being finite. But one half of it carries more weight than it seems to, and some mathematicians refuse it.

The half that nobody doubts is ∃x¬P(x)⇒¬∀xP(x). If you hold a particular x at which P fails, then plainly not every x satisfies P. The same goes for both directions of the second law, ¬∃xP(x)⟺∀x¬P(x).

The other half is ¬∀xP(x)⇒∃x¬P(x). Suppose you have shown that "every x satisfies P" leads to a contradiction. Have you shown that some particular x fails P? Classically, yes: each x either satisfies P or does not, by the law of excluded middle, and if every one satisfied it you would have ∀xP(x). But the argument never tells you which x fails. The constructive mathematicians, following L. E. J. Brouwer (the next lesson says more about them), read "there exists" as "we can find", and for them this half of the law fails over infinite domains.

A standard example shows what is at stake. Let P(n) say "the nth digit after the decimal point of π is not the start of a run of a hundred consecutive 7s". Over a finite range of n you can check. Over all of ℕ, suppose someone proved ¬∀nP(n) by an indirect argument. Classically that proves such a run exists; constructively it proves only that the absence of such a run is impossible, and the run's position may be beyond anyone's reach.

For this course the classical law holds without reservation. The point of the story is where the weight sits: a proof of "some x fails" that does not produce an x has used excluded middle, and in constructive settings, such as some proof assistants, that step has to be flagged.

What each kind of claim needs

The shape of a statement says in advance what a proof of it must do and what a disproof must do. For a single quantifier there are four cases.

StatementTo prove itTo disprove it
∀xP(x)Let x be arbitrary and show P(x)Exhibit one x with ¬P(x)
∃xP(x)Exhibit one x with P(x)Let x be arbitrary and show ¬P(x)

The table is two facts and their negations. An existential statement is proved by producing a value, called a witness, and checking it. So one value at which P fails, a counterexample, refutes a universal claim however many other values it holds for, because the negation of ∀xP(x) is the existential statement ∃x¬P(x). 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. Nobody has since found another prime of this form.

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. A universal claim needs an argument about an arbitrary element: name an x, assume nothing about it beyond membership of the domain (and the hypothesis, if the claim is a conditional), and derive P(x). Because nothing was assumed about the named x, the argument works for each one. The next lesson turns this into a method and explains exactly why it is valid.

Existential claims are the mirror image. One example proves "some prime is one more than a square", namely 5=22+1, and one example proves "some rational x has x2−3x+2<0", namely x=32, which gives 94−92+2=−14. Refuting an existential claim needs a proof about every value: "no integer x satisfies 2x=1" is ∀x(2x≠1), and it is proved by noting that for an integer x the number 2x is even while 1 is odd, and no integer is both (a fact the next lesson proves).

When the statement has two quantifiers the table is applied twice, from the outside in. A proof of ∀x∃yP(x,y) lets x be arbitrary and then exhibits a y that works for that x, so its y is typically a formula in x. A proof of ∃y∀xP(x,y) exhibits one y first and then shows it works for an arbitrary x, so its y cannot mention x at all. Knowing which kind of statement is in hand says in advance whether an example will be enough, and what shape of argument is needed when it is not.

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: ∀x∀yP(x,y) and ∀y∀xP(x,y) both say that P holds for every pair, and ∃x∃y and ∃y∃x both say that it holds for at least one pair. When the kinds 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 between two players. A sceptic picks the values under ∀ and a prover picks those under ∃, in the order written, each seeing the choices already made. The statement is true when the prover has a strategy that wins however the sceptic plays. In ∀x∃y(y>x) the sceptic names x and the prover answers x+1, and wins every time. In ∃y∀x(y>x) the prover must commit to y first, and the sceptic answers y itself, or anything larger, and wins every time. Every proof in this course of a statement with several quantifiers is a winning strategy for the prover, written down.

Committing early is a handicap, never an advantage, and that makes one direction of the order a theorem.

Theorem. For every predicate P(x,y), ∃y∀xP(x,y) implies ∀x∃yP(x,y).

Proof. Suppose ∃y∀xP(x,y), and let y0 be a value with ∀xP(x,y0). Let x be arbitrary. Then P(x,y0) holds, so y0 is a value of y with P(x,y), and ∃yP(x,y) is true. Since x was arbitrary, ∀x∃yP(x,y). □

In the game, the prover who can win by committing first can win by committing second: play the same y0 whatever x turns out to be. The converse is false, and the integers with y>x show it. A counterexample to a claim about all predicates is one predicate on one domain, and y>x over ℤ makes ∀x∃y true and ∃y∀x false.

Negation still works one quantifier at a time, so ¬∀x∃yP(x,y) is ∃x∀y¬P(x,y). The negation of "every integer has a larger one" is "some integer has no larger one", that is, "some integer is at least as large as every integer", and the negation of "some integer is larger than every integer" is "every integer is at most as large as some integer", a clumsy but true sentence.

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.

In both proofs the witness is a formula in the variable chosen before it: y=x+1 in the first, x=y in the second. That is what the order ∀∃ permits, and it is why the proof of the negation could be so short. The sceptic's value came first.

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. Let x be any integer and take y=−x, which is an integer. Then x+y=0. As x was arbitrary, the statement holds.

The second is false, so prove its negation, ∀y∃x(x+y≠0). Let y be any integer. If y≠0, take x=0, so x+y=y≠0. If y=0, take x=1, so x+y=1≠0. Either way the required x exists, and as y was arbitrary, the negation holds. (A single choice also works: x=1−y gives x+y=1.)

Over ℕ the first is false. Its negation is ∃x∈ℕ∀y∈ℕ(x+y≠0), and x=1 is a witness: for every natural number y, 1+y≥2, so 1+y≠0.

If the y depends on the x, is there a function hiding in ∀x∃y?

Yes, and making it explicit is a standard tool. Suppose ∀x∃yP(x,y) is true. For each x there is at least one suitable y; pick one and call it f(x). Then f is a function on the domain with ∀xP(x,f(x)). Conversely, if some function f has ∀xP(x,f(x)), then ∀x∃yP(x,y), with y=f(x) as the witness. So

∀x∃yP(x,y)is equivalent to∃f∀xP(x,f(x))

and the right-hand side makes the dependence visible: the prover's strategy is the function f. Logicians call f a Skolem function, after the Norwegian logician Thoralf Skolem, who used this move to replace existential quantifiers by function symbols. In the Examples above the Skolem functions were f(x)=x+1 and f(x)=−x.

The equivalence also explains the theorem that ∃y∀x implies ∀x∃y: the first says there is a constant function that works, and a constant function is a function.

Proofs of ∀∃ statements are, in practice, constructions of such functions, and much of analysis is the study of how good the function can be made. In the definition of a limit, below, the Skolem function sends each tolerance ε to a starting point N, and a proof of convergence usually gives it by a formula such as "take N greater than 1ε". In continuity, the function sends a point and a tolerance to a δ, and whether it can be chosen without looking at the point is exactly the difference between continuity and uniform continuity.

There is a subtlety in "pick one". When the domain is finite, or when a rule such as "the least suitable y" is available, the choice is unproblematic. Making infinitely many arbitrary choices at once, with no rule, is the content of the axiom of choice, which the lesson on order relations meets again through Zorn's lemma. For the statements in this course a rule is always at hand.

Exactly one

The existential quantifier means "at least one", and many theorems claim more: there is exactly one such object. The quotient and remainder on dividing one integer by another, the positive square root of a positive number, the limit of a convergent sequence, each is unique, and each word "the" in those phrases depends on it.

Definition. ∃!xP(x), read "there is a unique x with P(x)" or "there is exactly one x with P(x)", means

∃x(P(x)∧∀y(P(y)⇒y=x))

In words: some x has the property, and every object with the property is that x. The same claim splits into two independent halves,

∃xP(x)∧∀x∀y(P(x)∧P(y)⇒x=y)

existence, that at least one object has the property, and uniqueness, that at most one does. The second half on its own is how "there is at most one" is written. It asserts nothing about existence: over the integers, "at most one x satisfies x2=−1" is true because none does.

The two forms say the same thing. If x witnesses the first form, then ∃xP(x) holds, and whenever P(u) and P(v), both u=x and v=x, so u=v. Conversely, if both halves hold, take x with P(x); any y with P(y) then has y=x by uniqueness, which is the first form.

The split is also the plan of every proof of unique existence: two separate arguments. Existence is proved like any existential claim, by a witness. Uniqueness is a universal claim, proved by letting two objects with the property be arbitrary and showing they are equal. Finding one object and failing to think of another proves existence only.

Uniqueness shows up hidden in counting. Two variables may take the same value, so ∃x∃y(P(x)∧P(y)) is true whenever one object has P, and "at least two objects have P" needs the inequality written in:

∃x∃y(x≠y∧P(x)∧P(y))

Negating ∃!xP(x) by rule, from the second form, gives ¬∃xP(x)∨∃x∃y(P(x)∧P(y)∧x≠y): either nothing has the property, or at least two things do. A claim of unique existence fails in two quite different ways, and a disproof must say which.

Example. Prove that there is a unique natural number n with n2−2n−3=0. Is there a unique integer with that property?

Existence. Take n=3. Then n2−2n−3=9−6−3=0, and 3∈ℕ.

Uniqueness. Let n be a natural number with n2−2n−3=0. Factorising, (n−3)(n+1)=0, so n−3=0 or n+1=0. Since n≥1, the number n+1 is at least 2 and so is not 0. Hence n−3=0, and n=3. So every natural number with the property equals 3.

Over the integers the answer changes: −1 also works, since 1+2−3=0. So there are at least two integers with the property, 3 and −1, and by the negation above, ∃!n∈ℤ is false. The uniqueness argument shows where the domain entered: "n+1≠0" was the only step that used n≥1.

The uniqueness proof here showed that every solution equals the one already found. The other pattern, taking two arbitrary solutions and showing they are equal, is often cleaner when the solution has no formula, as in the next exercise.

Now you. Prove that there is a unique real number x with x3+x=10.

Answer

Existence. Take x=2: then x3+x=8+2=10.

Uniqueness. Let x and y be real numbers with x3+x=10 and y3+y=10. Subtracting, x3−y3+x−y=0, and since x3−y3=(x−y)(x2+xy+y2), this is

(x−y)(x2+xy+y2+1)=0

The second factor is positive: x2+xy+y2=(x+y2)2+3y24≥0, so x2+xy+y2+1≥1. A product of two real numbers is 0 only if one of them is, so x−y=0, and x=y.

The uniqueness half never needed to know the solution: it would work unchanged for x3+x=c with any real c. Existence for other values of c, where no neat witness can be guessed, needs the intermediate value theorem, a consequence of the completeness of the real numbers.

Does ∃!x∃!yP(x,y) say there is exactly one pair?

No, and the failure is a good test of reading symbols literally. Unwrap the outer quantifier: ∃!xQ(x), where Q(x) is "∃!yP(x,y)", that is, "exactly one y goes with this x". So the statement says: exactly one x has exactly one partner. Other values of x may have no partner, or several.

A small example makes it concrete. Take the domain {1,2} and let P(x,y) be true for the pairs (1,1), (2,1) and (2,2), and false for (1,2). The value x=1 has exactly one partner, y=1. The value x=2 has two, so it fails "∃!y". Hence exactly one x, namely 1, has exactly one partner, and ∃!x∃!yP(x,y) is true. Yet three pairs satisfy P.

The implication does hold the other way. If exactly one pair (a,b) satisfies P, then x=a has exactly one partner, b, and every other x has none, so ∃!x∃!yP(x,y) is true. So "exactly one pair" is strictly stronger, and its correct symbolisation treats the pair as a single object:

∃x∃y(P(x,y)∧∀u∀v(P(u,v)⇒u=x∧v=y))

Mixed stacks need the same care. "∀x∃!y" says that every x has exactly one partner, which is what it means for P to define a function. "∃!y∀x" says something else: exactly one y is a partner of every x at once. Unique existence does not even commute with itself: on the domain {1,2,3}, with P true for exactly the pairs (1,2), (1,3) and (2,1), only x=2 has exactly one partner, so ∃!x∃!yP(x,y) is true, while each of y=1, 2, 3 has exactly one partner, so ∃!y∃!xP(x,y) is false. So the only safe way to read a stack of quantifiers is from the outside in, one at a time. The Logic course treats identity and counting quantifiers formally in its lesson on identity and number.

Translating mathematical English

Mathematics is written in English with symbols mixed in, and most of its quantifiers are words. Translating into symbols is how you find out exactly what a sentence claims, and translating back is how you say it to a reader. The common words are these.

  • "for every", "for all", "for each", "for any", "whenever", "always", and the indefinite article in a general claim ("a square is never negative") are universal.
  • "there is", "there exists", "for some", "at least one", "can be" ("6 can be written as a sum of two primes") and the indefinite article in an existence claim ("x2=2 has a real solution") are existential.
  • "no", "none", "never" are ∀¬, which is the same as ¬∃: "no square is negative" is ∀x(x2≥0).
  • "only" marks the conclusion of a conditional: "only even numbers are divisible by 4" is ∀n(4∣n⇒nis even).

The word "any" is the dangerous one, because it is universal in some positions and existential in others. "Any square is non-negative" means every square. "If any integer is a counterexample, the conjecture is false" means if some integer is, and "there is not any solution" means no solution. When "any" appears, rewrite with "every" or "some" and check that the meaning survived.

Several phrases in analysis and number theory package two quantifiers at once, and they come in pairs that differ only in order. For a property P(n) of natural numbers:

  • "P(n) holds for all sufficiently large n", or "eventually", means ∃N∀n≥NP(n): from some point on, always.
  • "P(n) holds for infinitely many n", or "frequently", means ∀N∃n≥NP(n): beyond every point, at least once more.

The negation of "eventually P" is ∀N∃n≥N¬P(n), "infinitely often not P", and the negation of "infinitely often P" is "eventually not P". Over ℕ, "arbitrarily large" means the same as "infinitely many": "there are arbitrarily large primes" is ∀N∃p(p>N∧pis prime), which says the primes never stop.

Example. Symbolise "between any two distinct real numbers there is a rational number". Then negate the symbolic form, and translate the negation back into English.

The claim is universal in the two numbers and existential in the rational. "Distinct" can be replaced by "x<y", since of two distinct reals one is smaller and the sentence does not care which is named first. So the claim is

∀x∈ℝ∀y∈ℝ(x<y⇒∃q∈ℚ(x<q∧q<y))

To negate, flip each quantifier and push the ¬ inwards, using ¬(A⇒B)≡A∧¬B and De Morgan on the final conjunction:

∃x∈ℝ∃y∈ℝ(x<y∧∀q∈ℚ(q≤x∨q≥y))

In English: there are real numbers x<y such that every rational number lies at or below x or at or above y, that is, no rational lies strictly between them. The original is the true one: it is the density of the rationals, which the lesson on the real numbers proves from the completeness axiom.

Now you. A function f:ℝ→ℝ is bounded if some number M is at least |f(x)| for every real x. Symbolise "f is bounded", write the negation "f is unbounded" in symbols and in English, and prove that f(x)=x2 is unbounded.

Answer

"f is bounded" is ∃M∈ℝ∀x∈ℝ(|f(x)|≤M). Its negation is ∀M∈ℝ∃x∈ℝ(|f(x)|>M): whatever bound is proposed, some value of f exceeds it in size.

To prove x2 unbounded, let M be any real number and take x=|M|+1. Then x≥1, so x2=x⋅x≥x=|M|+1>|M|≥M, and |f(x)|=x2>M. Since M was arbitrary, f is unbounded. The witness x depended on M, as the order ∀M∃x allows.

By contrast sin is bounded, with M=1 as the witness, since |sinx|≤1 for every x. Here one M is fixed first and must serve every x, as the order ∃M∀x requires.

Hidden quantifiers

Most quantifiers in real writing are not written as quantifiers at all, and a large share of confusion, in mathematics and outside it, comes from supplying the wrong one.

In algebra the sign "=" carries a hidden quantifier that changes with the sentence. "(x+1)2=x2+2x+1" is an identity, a claim about every real x. "x2=2x" is an equation, an open sentence, and "solve it" means find its truth set, here {0,2}. "x2=2x has a solution" is an existential claim. The three look alike on the page, and a proof needs to know which it is holding, because an identity may be used for any value while an equation may be used only for the values that satisfy it.

Properties of functions are quantified statements in the same way. For a function f:ℝ→ℝ:

  • f is increasing when ∀x∀y(x<y⇒f(x)≤f(y)), and strictly increasing with f(x)<f(y) at the end;
  • f is constant when ∃c∀x(f(x)=c), or equivalently ∀x∀y(f(x)=f(y));
  • f is periodic when ∃p>0∀x(f(x+p)=f(x));
  • f has a maximum when ∃a∀x(f(x)≤f(a)).

Each negation is then a matter of rule. "f is not increasing" is ∃x∃y(x<y∧f(x)>f(y)): one pair of points where the function goes down. It is not "f is decreasing", which is a universal claim of its own, and most functions, x2 among them, are neither.

The words "let" and "suppose" in a proof also carry quantifiers. "Let n be an integer" introduces an arbitrary object, the first move of a proof of a ∀. "Choose k with n=2k" introduces a particular one, supplied by an ∃ in a hypothesis. The next lesson makes the difference precise, because confusing the two is behind many invalid proofs.

Everyday English is looser still. "All that glisters is not gold", from The Merchant of Venice, literally says ∀x(glisters(x)⇒¬gold(x)): nothing that glisters is gold. It means ¬∀x(glisters(x)⇒gold(x)): not everything that glisters is gold. "Everybody loves somebody" is usually ∀x∃y, each person has someone, but can be heard as ∃y∀x, one person whom everybody loves. A statistic such as "a pedestrian is injured in this city every hour" is ∀ hour ∃ pedestrian; the old joke replies "that poor pedestrian", reading it as ∃ pedestrian ∀ hour. None of this is a defect of English, which leans on context. Mathematics cannot, so when a sentence could be read two ways it is rewritten until it cannot.

The limit of a sequence

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

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

Read aloud: for every tolerance ε>0 there is a position N such that every term from position N on lies within ε of L. Here |an−L| is the distance from an to L, so |an−L|<ε says L−ε<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 the definition collapses.

Proposition. If ∃N∈ℕ∀ε>0∀n≥N(|an−L|<ε), then an=L for every n≥N.

Proof. Take such an N, and let n≥N. Then |an−L|<ε for every ε>0. Suppose |an−L|>0. Then ε=|an−L| is a positive tolerance, and the hypothesis gives |an−L|<|an−L|, which is impossible. So |an−L|=0, and an=L. □

So under the swapped reading a sequence would converge only if it were eventually equal to its limit, and 1n, which never reaches 0, would not converge to 0. The order ∀ε∃N is what lets a sequence approach a value without arriving.

Proving that a limit is correct means winning the game for every ε at once, so the proof must give N as a rule in terms of ε. Finding the rule is scrap work: write |an−L|, simplify it, and see how large n must be to make it less than ε. The proof then needs a natural number beyond any given real number, which is the Archimedean property of the reals: for every real number x there is a natural number N with N>x. It is used here as a known fact about ℝ, and the lesson on the real numbers derives it from the completeness axiom.

Example. Prove that nn+1→1.

Scrap work: |nn+1−1|=|−1n+1|=1n+1, and 1n+1<ε exactly when n+1>1ε. So any N beyond 1ε will do.

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

|nn+1−1|=1n+1<ε

Since ε>0 was arbitrary, nn+1→1. □

The proof follows the quantifiers exactly. "Let ε>0" answers ∀ε, "there is N" answers ∃N, "let n≥N" answers ∀n≥N, and the displayed line is the sentence at the end. For ε=0.01 the rule gives any N>100, say 101, and then 1n+1≤1102<0.01 for every n≥101. The rule need not give the smallest N that works, only one that does.

Now you. Prove that 3nn+2→3.

Answer

Scrap work: |3nn+2−3|=|3n−3n−6n+2|=6n+2. Solving 6n+2<ε exactly is possible, but it is simpler to bound first: 6n+2<6n, and 6n≤ε once n≥6ε.

Proof. Let ε>0. By the Archimedean property there is a natural number N with N>6ε. Let n≥N. Then n>6ε, so 6n<ε, and

|3nn+2−3|=6n+2<6n<ε

Since ε>0 was arbitrary, 3nn+2→3. □

Bounding 6n+2 by something simpler before solving is the standard move: the proof needs some N that works, and a cruder estimate that is easy to invert is worth more than an exact one that is not.

To show that a sequence does not converge to L, negate the definition, 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. In the language of the section on mathematical English: for some ε, infinitely many terms lie at distance at least ε from L. 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 the roles have changed. The prover of the negation chooses ε and n, the sceptic chooses N, and the prover's n is allowed to depend on N, as 2N+1 does.

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.

A sequence that converges to no real number at all is said to diverge, and that is one more quantifier in front: ∀L∈ℝ∃ε>0∀N∈ℕ∃n≥N(|an−L|≥ε). Showing that (−1)n diverges means defeating every candidate L, not just 1 and −1, and it is one of the problems at the end. The lesson on limits builds the theory on this definition: that a sequence has at most one limit, that a convergent sequence is bounded, and the rules for limits of sums and products.

Continuity, pointwise and uniform

The definition of continuity has the same three quantifiers, with a fourth that can stand in two places, and its two positions give two different notions.

Definition. A function f:ℝ→ℝ is continuous at the point a when

∀ε>0∃δ>0∀x∈ℝ(|x−a|<δ⇒|f(x)−f(a)|<ε)

It is continuous when it is continuous at every point, ∀a∀ε>0∃δ>0∀x(…), and uniformly continuous when

∀ε>0∃δ>0∀a∈ℝ∀x∈ℝ(|x−a|<δ⇒|f(x)−f(a)|<ε)

In the game for continuity at a, the sceptic names a tolerance ε for the output, the prover answers with a tolerance δ for the input, and the sceptic may then pick any x within δ of a; the prover wins if f(x) is within ε of f(a). It says that f(x) can be made as close as you like to f(a) by taking x close enough to a. The definitions of continuity and uniform continuity differ only in where ∀a stands. In continuity it comes before ∃δ, so δ may depend on the point a as well as on ε. In uniform continuity it comes after, so one δ must serve every point at once. By the theorem on quantifier order, moving an ∃ later can only weaken a statement, so every uniformly continuous function is continuous. The converse fails, and the standard example shows why.

A linear function is uniformly continuous. For f(x)=2x+1, |f(x)−f(a)|=|2x−2a|=2|x−a|, so given ε>0 take δ=ε2: whenever |x−a|<δ, |f(x)−f(a)|=2|x−a|<ε. The δ mentions only ε, so it serves every a at once. (The calculation uses |uv|=|u||v| and the other school facts about absolute value, which the next lesson proves.)

The squaring function is continuous, but its δ has to shrink as a grows. Since x2−a2=(x−a)(x+a), the output error is the input error multiplied by |x+a|, which is about 2|a| when x is near a.

Proposition. The function f(x)=x2 is continuous at every real number a.

Proof. Let a be a real number and let ε>0. Take δ to be the smaller of 1 and ε2|a|+1, which is positive. Let x be a real number with |x−a|<δ. Since δ≤1, we have a−1<x<a+1, so 2a−1<x+a<2a+1, and as 2a+1≤2|a|+1 and 2a−1≥−(2|a|+1), this gives |x+a|<2|a|+1. Therefore

|x2−a2|=|x−a||x+a|≤|x−a|(2|a|+1)<δ(2|a|+1)≤ε

where the strict step uses |x−a|<δ and 2|a|+1>0, and the last step uses δ≤ε2|a|+1. □

The δ depends on a through the factor 2|a|+1. That is not a weakness of this proof. No choice of δ free of a can work, as the negation of uniform continuity shows. By rule, f is not uniformly continuous when

∃ε>0∀δ>0∃a∃x(|x−a|<δ∧|f(x)−f(a)|≥ε)

Proposition. The function f(x)=x2 is not uniformly continuous on ℝ.

Proof. Take ε=1. Let δ>0, and take a=1δ and x=a+δ2. Then |x−a|=δ2<δ, and

x2−a2=(x−a)(x+a)=δ2(2δ+δ2)=1+δ24≥1

So |f(x)−f(a)|≥1=ε. Since δ>0 was arbitrary, f is not uniformly continuous. □

However small the proposed δ, the sceptic goes far enough out along the parabola, to a=1δ, that the curve is steep enough to turn an input step of δ2 into an output jump of more than 1. Both propositions are about the same function, and the only difference between the statements they settle is the position of ∀a.

If every uniformly continuous function is continuous anyway, why does anyone care about the difference?

Because many arguments need one δ for a whole interval, and pointwise continuity supplies only one δ per point. The clearest case is integration. To show that a continuous function on [0,1] has an integral, one cuts the interval into pieces of width δ and needs the function to vary by less than ε across every piece at once, which is uniform continuity. The same need appears whenever a limit must be taken uniformly across a range: approximating functions by polynomials, exchanging a limit with an integral, solving differential equations by successive approximation.

The rescue is a theorem named after Eduard Heine and Georg Cantor: a function continuous at every point of a closed bounded interval [p,q] is uniformly continuous there. For x2 this can be seen directly. On [0,1], if x and a both lie in the interval then |x+a|≤2, so |x2−a2|≤2|x−a|, and δ=ε2 works at every point. The trouble in the proposition above came entirely from letting a run off to infinity.

Both conditions of the theorem matter. On the unbounded set ℝ, x2 fails. On the bounded but open interval between 0 and 1, excluding the ends, the function 1x is continuous at every point and not uniformly continuous, because near 0 it is as steep as you please; one of the challenge problems below proves this. The general proof of the theorem needs the completeness of the real numbers, through the theorem of Bolzano and Weierstrass on convergent subsequences, and it is a staple of a first course in analysis.

The same distinction, between a quantity that may depend on a point and one that may not, runs through the rest of analysis: uniform convergence of sequences of functions against pointwise convergence is the next instance, and it decides whether a limit of continuous functions is continuous.

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 shape of the symbols dictates the shape of the proof: a ∀ is met by letting the variable be arbitrary, an ∃ by naming a value, which may depend on every variable chosen before it, and a disproof is a proof of the negation, with every quantifier flipped.

Take the claim that the square of every odd integer is one more than a multiple of 8. In symbols it is

∀n∈ℤ(nis odd⇒∃m∈ℤ(n2=8m+1))

and the symbols say what a proof must do: let n be an arbitrary odd integer, and produce an integer m, depending on n, with n2=8m+1. The examples agree: 1=8×0+1, 9=8×1+1, 25=8×3+1, 49=8×6+1, 81=8×10+1, and (−3)2=9 as well. But they are examples, and the claim is universal over an infinite domain. The quantifiers say what a proof must deliver, not how to find the m. The next lesson supplies the method, the direct proof, and proves this claim with it.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Decide whether each statement is true over ℕ, over ℤ and over ℝ, twelve verdicts in all, and justify each. (a) ∀x(x2>0). (b) ∃x(2x=1). (c) ∀x∃y(x=2y). (d) ∃x∀y(x≤y).

Solution

(a) Over ℕ, true: every natural number x is at least 1, so x2≥1>0. Over ℤ and over ℝ, false: x=0 is a counterexample, since 02=0.

(b) Over ℕ and ℤ, false: for an integer x, 2x is even and 1 is odd, and no integer is both (a fact the next lesson proves), so 2x≠1. Over ℝ, true, with witness x=12.

(c) Over ℕ, false: for x=1 we would need a natural number y with 2y=1, and by (b) there is none. Over ℤ, false for the same reason, with the same counterexample x=1. Over ℝ, true: for any real x, y=x2 gives 2y=x.

(d) Over ℕ, true, with witness x=1: every natural number y has 1≤y. Over ℤ, false. Its negation is ∀x∃y(y<x), and for any integer x the integer y=x−1 is smaller. Over ℝ, false by the same argument with y=x−1.

2. Negate each statement, moving ¬ inwards until it applies to nothing but an equation or inequality, and then remove it by rewriting that equation or inequality. Say whether the original or the negation is true. (a) ∀x∈ℝ(x>0⇒∃y∈ℝ(y2=x)). (b) ∃n∈ℕ∀m∈ℕ(m≤n). (c) ∀x∈ℝ∀y∈ℝ(x<y⇒∃z∈ℝ(x<z∧z<y)).

Solution

(a) ∃x∈ℝ(x>0∧∀y∈ℝ(y2≠x)): some positive real number is not the square of any real number. The original is true, since every positive real has a real square root, as the lesson on the real numbers proves.

(b) ∀n∈ℕ∃m∈ℕ(m>n): every natural number is exceeded by some natural number. The negation is true, with m=n+1, so the original, "some natural number is at least every natural number", is false.

(c) ∃x∈ℝ∃y∈ℝ(x<y∧∀z∈ℝ(z≤x∨z≥y)): some two reals x<y have no real strictly between them. The original is true: for x<y, the midpoint z=x+y2 satisfies x<z<y, because z−x=y−x2>0 and y−z=y−x2>0.

3. Over the integers, write each of these as a formula using only quantifiers, connectives, +, ×, =, < and ∣. (a) n is odd. (b) n is a sum of two squares. (c) a and b have a common divisor greater than 1. (d) n has exactly two positive divisors.

Solution

(a) ∃k(n=2k+1).

(b) ∃x∃y(n=x×x+y×y). The two variables may take the same value, which is right: 8=22+22 counts.

(c) ∃d(1<d∧d∣a∧d∣b).

(d) ∃u∃v(0<u∧0<v∧u≠v∧u∣n∧v∣n∧∀d(0<d∧d∣n⇒d=u∨d=v)). The clause u≠v makes "at least two", and the final universal makes "at most these two". Here u≠v abbreviates ¬(u=v). For positive n this says that n is prime, since the two divisors must be 1 and n with 1≠n; it is a second definition of primality, equivalent to the one in the lesson.

4. Decide which of these are true, and justify each answer. (a) ∃!x∈ℤ(x2=4). (b) ∃!x∈ℕ(x2=4). (c) ∃!x∈ℝ(x3=−8). (d) ∃!x∈ℝ(x2<0).

Solution

(a) False: 2 and −2 are two different integers whose squares are 4, so uniqueness fails.

(b) True. Existence: 2∈ℕ and 22=4. Uniqueness: if x∈ℕ and x2=4, then (x−2)(x+2)=0, and x+2≥3 is not 0, so x=2.

(c) True. Existence: (−2)3=−8. Uniqueness: if x3=y3=−8, then 0=x3−y3=(x−y)(x2+xy+y2). So x=y or x2+xy+y2=0. In the second case, x2+xy+y2=(x+y2)2+3y24 is a sum of two non-negative terms, so both are 0, giving y=0 and then x=0; so x=y in this case too.

(d) False, for the other reason: no real number has a negative square, so existence fails.

Core

5. Over ℝ, decide which statements are true, and prove each answer. (a) ∀x∃y(xy=1). (b) ∃y∀x(xy=0). (c) ∀x∃y(y2=x). (d) ∃x∀y(x≤y2). (e) ∀x∃y∀z(z>y⇒z2>x).

Hint

Play the game. For a true statement, give the prover's choices, each as a formula in the variables chosen earlier. For a false one, prove the negation, which means giving the sceptic's choices.

Solution

(a) False. The negation is ∃x∀y(xy≠1), with witness x=0: for every real y, 0×y=0≠1.

(b) True, with witness y=0: for every real x, x×0=0.

(c) False. The negation is ∃x∀y(y2≠x), with witness x=−1: every real y has y2≥0>−1.

(d) True, with witness x=0: for every real y, 0≤y2.

(e) True. Let x be any real number and take y=|x|+1. Let z be any real number with z>y. Then z>1, and multiplying z>1 by the positive number z gives z2>z. So z2>z>y=|x|+1>|x|≥x. The conditional therefore holds for every z, and since x was arbitrary, the statement holds. It says that however large x is, the squares of all sufficiently large numbers exceed it, and the y had to depend on x.

6. Find the flaw in this proof, and show that the claim is false.

Claim. There is a natural number M such that n≤M for every natural number n.

Proof. Let n be a natural number. Take M=n. Then M is a natural number and n≤M. Since n was arbitrary, such an M exists.

Hint

Write the claim in symbols, and write in symbols what the proof actually establishes. Compare the order of the quantifiers.

Solution

The claim is ∃M∈ℕ∀n∈ℕ(n≤M). The proof chose n first and then M in terms of n, so what it proves is ∀n∈ℕ∃M∈ℕ(n≤M): every natural number is at most some natural number. That statement is true and has just been proved, but it is not the claim. In the claim, M must be fixed before n is chosen and must then work for every n, so it may not depend on n. The phrase "since n was arbitrary, such an M exists" hides the swap: the M found was a different number for each n.

The claim is false. Its negation is ∀M∈ℕ∃n∈ℕ(n>M). Let M be any natural number and take n=M+1. Then n is a natural number and n>M. Since M was arbitrary, the negation holds.

7. Over ℝ, prove or disprove each statement. (a) ∃!x∀y(xy=x). (b) ∃!y∀x(xy=x). (c) ∀x∃!y(xy=x).

Hint

Each "exists exactly one" needs an existence argument and a uniqueness argument. For uniqueness, the ∀ inside lets you substitute any convenient value.

Solution

(a) True. Existence: x=0 gives 0×y=0=x for every y. Uniqueness: suppose x satisfies xy=x for every real y. Taking y=2 gives 2x=x, so x=0. So every such x is 0.

(b) True. Existence: y=1 gives x×1=x for every x. Uniqueness: suppose y satisfies xy=x for every real x. Taking x=1 gives y=1.

(c) False. Its negation is ∃x¬∃!y(xy=x), and x=0 is a witness: 0×y=0 for every real y, so both y=1 and y=2 satisfy 0×y=0, and the y is not unique. (For every x≠0 there is exactly one such y, namely 1, since xy=x gives x(y−1)=0 and x≠0. So the statement fails at a single point.)

Parts (a) and (b) say that 0 is the unique number that absorbs every product, and 1 the unique number that leaves every product unchanged.

8. Let P(x) and Q(x) be predicates over a domain D. (a) Prove that ∀x(P(x)∧Q(x)) is equivalent to ∀xP(x)∧∀xQ(x), and that ∃x(P(x)∨Q(x)) is equivalent to ∃xP(x)∨∃xQ(x). (b) Prove that ∀xP(x)∨∀xQ(x) implies ∀x(P(x)∨Q(x)), and disprove the converse. (c) Prove that ∃x(P(x)∧Q(x)) implies ∃xP(x)∧∃xQ(x), and disprove the converse.

Hint

For the disproofs, one domain and one pair of predicates is enough: try the integers with "even" and "odd".

Solution

(a) Suppose ∀x(P(x)∧Q(x)). Let x be arbitrary; then P(x)∧Q(x), so P(x). As x was arbitrary, ∀xP(x), and in the same way ∀xQ(x). Conversely, suppose ∀xP(x) and ∀xQ(x), and let x be arbitrary. Then P(x) and Q(x), so P(x)∧Q(x), and as x was arbitrary, ∀x(P(x)∧Q(x)).

For the second equivalence, negate both sides of the first with ¬P and ¬Q in place of P and Q. The first equivalence gives ∀x(¬P(x)∧¬Q(x))≡∀x¬P(x)∧∀x¬Q(x). The negation of the left side is ∃x¬(¬P(x)∧¬Q(x)), which is ∃x(P(x)∨Q(x)). The negation of the right side is ¬∀x¬P(x)∨¬∀x¬Q(x), which is ∃xP(x)∨∃xQ(x). Equivalent statements have equivalent negations, so these two are equivalent.

(b) Suppose ∀xP(x)∨∀xQ(x), and let x be arbitrary. If ∀xP(x) holds, then P(x), so P(x)∨Q(x). Otherwise ∀xQ(x) holds, so Q(x) and again P(x)∨Q(x). As x was arbitrary, ∀x(P(x)∨Q(x)).

The converse fails. Over ℤ, let P(x) be "x is even" and Q(x) be "x is odd". Every integer is even or odd (the next lesson proves this, and that no integer is both), so ∀x(P(x)∨Q(x)) is true. But ∀xP(x) is false, since 1 is not even, and ∀xQ(x) is false, since 0 is not odd, so ∀xP(x)∨∀xQ(x) is false.

(c) Suppose ∃x(P(x)∧Q(x)), and let a be a witness, so P(a) and Q(a). Then a witnesses ∃xP(x) and also ∃xQ(x).

The converse fails, with the same predicates. ∃xP(x) is true (take 0) and ∃xQ(x) is true (take 1), but ∃x(P(x)∧Q(x)) is false, since no integer is both even and odd. The two witnesses were different objects, and nothing forces one object to serve both.

So ∀ distributes over ∧ and ∃ over ∨, as a long "and" and a long "or" should, and neither distributes over the other connective.

9. Write each statement in symbols, then write its negation in symbols and in plain English without the word "not" at the front. Here (an) is a sequence of real numbers and f:ℝ→ℝ. (a) The sequence (an) is bounded. (b) an=0 for infinitely many n. (c) Every real number is a value of f. (d) f is periodic.

Hint

Decide first which quantifier each phrase hides, and in what order. "Infinitely many" over ℕ was translated in the section on mathematical English.

Solution

(a) ∃M∈ℝ∀n∈ℕ(|an|≤M). Negation: ∀M∈ℝ∃n∈ℕ(|an|>M). In English: whatever bound is proposed, some term exceeds it in size; the sequence is unbounded.

(b) ∀N∈ℕ∃n≥N(an=0). Negation: ∃N∈ℕ∀n≥N(an≠0). In English: from some point on, no term is 0; there are only finitely many zero terms.

(c) ∀y∈ℝ∃x∈ℝ(f(x)=y). Negation: ∃y∈ℝ∀x∈ℝ(f(x)≠y). In English: some real number is missed by f altogether. (A function with property (c) is called surjective onto ℝ; the lesson on functions studies it.)

(d) ∃p>0∀x∈ℝ(f(x+p)=f(x)). Negation: ∀p>0∃x∈ℝ(f(x+p)≠f(x)). In English: for every proposed positive period, some point is not repeated one period later.

In each case the restrictions (n≥N, p>0) survive the negation unchanged, and each quantifier flips.

10. (a) Prove that (−1)nn→0. (b) For ε=0.1, find the smallest N that works in the definition of convergence for this sequence.

Hint

Compute |an−0|, and ask how large n must be to make it less than ε. You will need a natural number larger than a given real number.

Solution

(a) For every n∈ℕ, |an−0|=|(−1)n|n=1n. Let ε>0. By the Archimedean property there is a natural number N with N>1ε2. Let n≥N. Then n>1ε2, and since both sides are positive and taking square roots preserves order between positive numbers, n>1ε. Hence 1n<ε, that is, |an−0|<ε. Since ε>0 was arbitrary, an→0.

(b) We need 1n<0.1 for every n≥N. For positive n, 1n<0.1 holds exactly when n>10, that is, when n>100. So N=101 works, since every n≥101 has n>100. And no smaller N works: if N≤100, then n=100 satisfies n≥N and |a100|=110, which is not less than 0.1. So the smallest N is 101.

11. Prove that the sequence an=(−1)n does not converge to any real number.

Hint

Write down the statement to prove: ∀L∃ε>0∀N∃n≥N(|an−L|≥ε). One ε can work for every L, but the choice of n must depend on whether L is closer to 1 or to −1.

Solution

We prove ∀L∈ℝ∃ε>0∀N∈ℕ∃n≥N(|an−L|≥ε).

Let L be any real number, and take ε=1. Let N be any natural number. There are two cases.

If L≥0, take n=2N+1. Then n≥N and n is odd, so an=−1, and |an−L|=|−1−L|=1+L≥1, since 1+L is positive.

If L<0, take n=2N. Then n≥N and n is even, so an=1, and |an−L|=|1−L|=1−L>1, since 1−L is positive.

In both cases n≥N and |an−L|≥1=ε. Since N was arbitrary, an does not converge to L, and since L was arbitrary, it converges to no real number.

The order of choices matches the order of quantifiers: ε was chosen after L (though it happened not to depend on it), and n after both L and N, depending on each.

12. Let H:ℝ→ℝ be the step function with H(x)=1 for x≥0 and H(x)=0 for x<0. Prove that H is continuous at every a≠0 and is not continuous at 0.

Hint

At a point a≠0, choose δ small enough that every x within δ of a has the same sign as a. At 0, write out the negation of continuity at 0 and look to the left of 0.

Solution

Continuity at a≠0. Let ε>0 and take δ=|a|, which is positive. Let x be a real number with |x−a|<|a|, so a−|a|<x<a+|a|.

If a>0, the left inequality reads 0<x, so H(x)=1=H(a). If a<0, then |a|=−a and the right inequality reads x<0, so H(x)=0=H(a). In both cases |H(x)−H(a)|=0<ε. Since ε was arbitrary, H is continuous at a. Notice that δ depended on a and not on ε.

No continuity at 0. We prove ∃ε>0∀δ>0∃x(|x−0|<δ∧|H(x)−H(0)|≥ε). Take ε=12. Let δ>0, and take x=−δ2. Then |x|=δ2<δ, and x<0, so |H(x)−H(0)|=|0−1|=1≥12. Since δ was arbitrary, H is not continuous at 0.

Any ε up to 1 would do in the second part. For ε>1 the sceptic cannot win, since H never varies by more than 1, which is why the negation only asks for one ε.

Challenge

13. Let P(x,y) be a predicate over a non-empty domain. Up to the fact that quantifiers of the same kind commute, there are six statements obtained by putting one quantifier on each variable:

∀x∀yP,∃y∀xP,∃x∀yP,∀x∃yP,∀y∃xP,∃x∃yP

Determine exactly which of these statements imply which others for every predicate P on every non-empty domain. Prove each implication that holds, and give a counterexample for each one that does not.

Hint

Arrange the six in a diamond with ∀∀ at the top and ∃∃ at the bottom. For the non-implications, four small predicates on the domain {1,2} suffice: try x=y, x=1, y=1, and "x=1 and y=1".

Solution

Write the statements as A=∀x∀yP, B=∃y∀xP, C=∃x∀yP, D=∀x∃yP, E=∀y∃xP and F=∃x∃yP. The claim is that the implications that hold are exactly these, together with each statement implying itself:

A⇒B⇒D⇒FA⇒C⇒E⇒F

and the ones they give by chaining: A⇒D, A⇒E, A⇒F, B⇒F and C⇒F. That is eleven implications between distinct statements, out of thirty ordered pairs.

The implications. Since implication is transitive, it suffices to prove the six arrows displayed.

A⇒B: suppose A. The domain is non-empty, so pick an element b. For every x, P(x,b) holds by A, so b witnesses ∃y∀xP(x,y).

B⇒D is the theorem on quantifier order proved in the lesson.

D⇒F: suppose D. Pick an element a of the domain. By D there is a y with P(a,y), and the pair a, y witnesses F.

A⇒C, C⇒E and E⇒F are the same three arguments with the roles of x and y exchanged: C⇒E is the theorem on quantifier order applied with x and y swapped.

The non-implications. Take the domain {1,2} and four predicates.

Model 1, P(x,y) is "x=y". Then D and E are true (each element is paired with itself) and F is true, while A is false (P(1,2) fails), B is false (no y equals both 1 and 2) and so is C.

Model 2, P(x,y) is "x=1". Then C is true (x=1 works for every y), so E and F are true. But A is false, B is false (for any y, P(2,y) fails), and D is false (for x=2 no y works).

Model 3, P(x,y) is "y=1". This is Model 2 with the roles exchanged: B, D, F true, and A, C, E false.

Model 4, P(x,y) is "x=1 and y=1". Only the pair (1,1) satisfies P. Then F is true, and A, B, C, D, E are all false (D fails at x=2, E at y=2, and B, C because they imply D, E).

A model in which X is true and Y false refutes "X⇒Y". Going through the nineteen remaining ordered pairs:

  • From B (true in Model 3): B⇏A, B⇏C, B⇏E, all by Model 3.
  • From C (true in Model 2): C⇏A, C⇏B, C⇏D, all by Model 2.
  • From D: D⇏A, D⇏B, D⇏C by Model 1, and D⇏E by Model 3.
  • From E: E⇏A, E⇏B, E⇏C by Model 1, and E⇏D by Model 2.
  • From F: F implies none of A, B, C, D, E, by Model 4.

That is 3+3+4+4+5=19 non-implications, and with the eleven implications it accounts for all thirty ordered pairs. The picture is a diamond: the two "∃∀" statements sit side by side and are independent of each other, as are the two "∀∃" statements, and each "∃∀" statement implies, of the two "∀∃" statements, only the one obtained by swapping its two quantifiers.

14. Let f(x)=1x on the open interval of real numbers x with 0<x<1. Prove that f is continuous at every point of this interval, but not uniformly continuous on it. (Quantifiers over x and a now range over the interval.)

Hint

For continuity at a, first make δ≤a2 so that x stays above a2, and then bound |1x−1a|=|x−a|xa. For the failure of uniform continuity, take ε=1 and put both points very close to 0.

Solution

Write I for the interval.

Continuity at each point. Let a∈I and ε>0. Take δ to be the smaller of a2 and εa22, which is positive. Let x∈I with |x−a|<δ. Then x>a−δ≥a−a2=a2, so xa>a22>0. Therefore

|1x−1a|=|a−x|xa<δa2/2=2δa2≤ε

where the strict inequality uses |a−x|<δ together with xa>a22, and the last step uses δ≤εa22. Since ε was arbitrary, f is continuous at a, and since a was arbitrary, at every point of I.

Not uniformly continuous. We prove ∃ε>0∀δ>0∃a∈I∃x∈I(|x−a|<δ∧|f(x)−f(a)|≥ε). Take ε=1. Let δ>0, and let t be the smaller of δ and 12. Take a=t and x=t2. Both lie in I, since 0<t2<t≤12. Then |x−a|=t2<t≤δ, and

|f(x)−f(a)|=2t−1t=1t≥2≥1

because t≤12. Since δ was arbitrary, f is not uniformly continuous on I.

The δ in the first part shrinks like a2 as a approaches 0, and the second part shows this is unavoidable. The interval is bounded, so the failure comes from the missing endpoint 0, where the function is unbounded; this is why the theorem of Heine and Cantor needs a closed interval.

15. Let (an) be a sequence and L a real number. Prove that each of the following is equivalent to an→L. (a) ∀ε>0∃N∈ℕ∀n≥N(|an−L|≤ε). (b) ∀k∈ℕ∃N∈ℕ∀n≥N(|an−L|<1k). (c) ∀ε>0∃N∈ℕ∀n≥N(|an−L|<Cε), where C>0 is a fixed real number. Then show that the condition ∀ε>0∀N∈ℕ∃n≥N(|an−L|<ε) is not equivalent to an→L.

Hint

Each proof in one direction is immediate. In the other, feed the given condition a different tolerance from the one you were given: ε2, or 1k for a suitable k, or εC. For the last part, look at (−1)n.

Solution

Write (D) for the definition, ∀ε>0∃N∀n≥N(|an−L|<ε).

(a) Suppose (D), and let ε>0. By (D) there is N with |an−L|<ε for all n≥N, and then |an−L|≤ε for those n. So (a) holds. Conversely, suppose (a), and let ε>0. Apply (a) with the tolerance ε2>0: there is N with |an−L|≤ε2<ε for all n≥N. So (D) holds.

(b) Suppose (D), and let k∈ℕ. Apply (D) with ε=1k>0 to get the required N. Conversely, suppose (b), and let ε>0. By the Archimedean property there is a natural number k with k>1ε, so 1k<ε. By (b) there is N with |an−L|<1k<ε for all n≥N. So (D) holds.

(c) Suppose (D), and let ε>0. Apply (D) with the tolerance Cε>0 to get N with |an−L|<Cε for all n≥N. Conversely, suppose (c), and let ε>0. Apply (c) with the tolerance εC>0: there is N with |an−L|<C⋅εC=ε for all n≥N.

The last condition is weaker. Every convergent sequence satisfies it: given ε and N, (D) gives some N′, and n equal to the larger of N and N′ is at least N and has |an−L|<ε. But an=(−1)n with L=1 also satisfies it: given ε>0 and N, take n=2N, which is even, so |an−1|=0<ε. And (−1)n does not converge to 1, as the lesson proved. So the condition does not imply convergence. It says that terms come within ε of L infinitely often, rather than eventually for good; a number with this property is called a cluster point of the sequence, and (−1)n has two, 1 and −1.

Parts (a) to (c) are used constantly. They let a proof aim at |an−L|≤ε, or at |an−L|<3ε, and still conclude convergence, and they show that the definition does not depend on the choice between < and ≤ or on the exact scale of the tolerance.

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. Along the way it proves the division algorithm, which settles a question the first lesson left open (every integer is even or odd, and none is both), and it covers proofs by cases, inequalities, "if and only if", existence with and without a witness, and disproof by counterexample. It assumes the definitions of parity from the first lesson: an integer n is even when n=2k for some integer k, and odd when n=2k+1 for some integer k.

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.

Why does an argument about one n prove the claim for every n?

Because the argument is a template. Take any particular integer, say 12, and substitute it for n in every line of the proof. Each line stays justified, since each justification appealed only to the hypothesis and to rules of algebra that hold for all integers. So the written proof stands for infinitely many proofs, one for each integer, and writing it once with a letter is how a finite text covers an infinite domain.

Logicians call the final step universal generalisation: from a proof of P(n) for an arbitrary n, conclude ∀nP(n). The rule carries a restriction, and every misuse of it breaks the restriction. The name must be genuinely arbitrary: nothing may be assumed about it beyond what the statement's hypothesis grants.

Here is the first way to break it. "Let n be an even integer, so n=2k for some integer k. Then n2=4k2, a multiple of 4. Since n was arbitrary, the square of every integer is a multiple of 4." The n was an arbitrary even integer, not an arbitrary integer, so the conclusion is only that the square of every even integer is a multiple of 4, which is true. The claim about every integer is false: 32=9.

The second way is subtler. "There is a prime; call it p. Then p≥2. Since p was arbitrary, every integer is at least 2." Here p was never arbitrary. It came from an existential statement, so it names one particular object that happens to be unknown to us, and a fact about it is a fact about that one object. The wording marks the difference: "let n be an integer" introduces an arbitrary object, while "there is an integer k with n=2k" introduces a fixed one. In the game of the previous lesson, the sceptic chooses the arbitrary objects, and the proof must win whatever they are.

The Logic course states this rule and its restriction formally, in its lesson on proof with quantifiers, where the restriction becomes a checkable condition on where a name may appear.

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. In outline, a proof of ∀x(P(x)⇒Q(x)) reads: let x be arbitrary and suppose P(x); then a chain of justified steps; therefore Q(x); since x was arbitrary, the statement holds for every x.

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. Nor may two objects share a letter they have not earned. If a and b are both even, then a=2k and b=2m for some integers k and m; writing a=2k and b=2k would prove the claim only for a=b.

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. A later section shows what goes wrong when the scrap paper is handed in as the proof.

Divisibility

For integers a and b, a divides b, written a∣b, if there is an integer k with b=ak. Equivalent phrasings are "a is a divisor (or factor) of b" and "b is a multiple of a". 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 avoids division on purpose: it uses only multiplication of integers, so it makes sense even for a=0.

The definition has the same shape as the definitions of even and odd, 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).

An expression bx+cy with integer x and y is called an integer linear combination of b and c, and the Now you says that a common divisor of two numbers divides every such combination. It is the most used fact about divisibility. Here it is at work: if d divides both n and n+1, then d divides (n+1)−n=1, so d is 1 or −1. Two consecutive integers share no factor greater than 1.

Divisibility also controls size. The next two facts are used constantly, and the second needs a small case split.

Proposition. Let a and b be integers.

(i) If a∣b and b≠0, then |a|≤|b|.

(ii) If a∣b and b∣a, then a=b or a=−b.

Proof. (i) Suppose a∣b and b≠0, so b=ak for some integer k. If k were 0 then b would be 0, so k≠0, and a non-zero integer has |k|≥1. Therefore |b|=|a||k|≥|a|. (The rule |ak|=|a||k| is proved in the section on absolute value below.)

(ii) Suppose a∣b and b∣a. If a=0, then b∣0 tells us nothing, but a∣b says b=0×k=0, so a=b. If a≠0, then b≠0 as well, since 0∣a would force a=0. Now (i) applies both ways: |a|≤|b| and |b|≤|a|, so |a|=|b|, which means a=b or a=−b. □

Part (i) is the reason no integer greater than 1 divides 1, a fact the next lesson leans on in Euclid's proof that the primes never run out. Part (ii) shows why the sign needs care: 3∣−3 and −3∣3, and 3≠−3.

Three things divisibility does not do are worth knowing before they are needed. It does not cancel freely: 4∣2×6 does not give 4∣6. It does not distribute over sums in reverse: a∣b+c does not give a∣b. And "a∣b" is not "a≤b": 5∣−10 and 5∣0 although 5 exceeds both.

Working backwards, writing forwards

Inequalities show the gap between finding a proof and writing one most sharply. Take the claim that x2+y2≥2xy for all real numbers x and y. The natural scrap work starts from the goal: x2+y2≥2xy, so x2−2xy+y2≥0, so (x−y)2≥0, which is true because squares are never negative. Every line is correct algebra and the claim is true. But as written, the argument runs from the claim to a known fact, so what it proves is the conditional "if x2+y2≥2xy, then (x−y)2≥0", which is the wrong way round.

To see that an argument of this shape proves nothing, run it on a false claim. "Claim: −2=2. Proof: squaring both sides gives 4=4, which is true." The algebra is flawless and the claim is false. The truth table of the conditional explains it: P⇒Q is true when P is false and Q is true, so a false statement can imply a true one. Truth travels forwards along an implication, from hypothesis to conclusion, and never backwards. Reaching a true statement from the claim says nothing about the claim.

The repair is to run the scrap work in reverse. Let x and y be real numbers. The square of a real number is non-negative, so (x−y)2≥0. Expanding, x2−2xy+y2≥0, and adding 2xy to both sides gives x2+y2≥2xy. Now each line follows from the one before, and the chain starts at a known fact. The reversal worked because every step of the scrap work could be undone; if one of them cannot, the scrap work has found no proof at all.

Example. Prove that for all non-negative real numbers x and y, xy≤x+y2, with equality exactly when x=y.

The two sides are the geometric mean and the arithmetic mean of x and y. On scrap paper: the goal is 2xy≤x+y, that is, 0≤x−2xy+y. Since x and y are non-negative, x=(x)2, y=(y)2 and xy=xy, so the right-hand side is (x−y)2. That suggests where the written proof should start.

Let x and y be non-negative real numbers. Then x and y are real numbers with (x)2=x, (y)2=y and xy=xy (that square roots exist is proved in the lesson on the real numbers). The square of the real number x−y is non-negative, so

0≤(x−y)2=x−2xy+y

Adding 2xy to both sides and dividing by 2 gives xy≤x+y2. Equality holds exactly when (x−y)2=0, that is, when x=y, and since the square root of a non-negative number determines the number, that is exactly when x=y.

The hypothesis earned its place: for x=y=−1 the left side is 1=1 and the right side is −1. Geometrically, a rectangle with sides x and y has area xy, and the square with the same perimeter has side x+y2, so the inequality says that the square encloses at least as much.

Now you. Prove that x+1x≥2 for every positive real number x, and find when equality holds. Where does the proof use that x is positive?

Answer

Scrap work: multiplying the goal by x gives x2+1≥2x, which is (x−1)2≥0. Written forwards:

Let x be a positive real number. Then (x−1)2≥0, so x2−2x+1≥0, and so x2+1≥2x. Dividing both sides by the positive number x keeps the direction of the inequality, and gives x+1x≥2. Equality holds exactly when (x−1)2=0, that is, when x=1.

Positivity was used in the division. It cannot be dropped: at x=−1, x+1x=−2. Another route is the Example with y=1x: then xy=1, and 1≤12(x+1x).

Is it ever safe to argue from the conclusion?

Yes, when every step is reversible and the proof says so. A chain P⟺P1⟺P2⟺⋯⟺Pn in which Pn is known to be true does prove P, because read from right to left it is a chain of implications ending at P. A proof in this style writes "⟺", or "which holds if and only if", at each step, and the reader must check each step in both directions. That doubles the checking, which is why the forward version is usually preferred.

Some operations can always be undone. Adding the same number to both sides of an equation or inequality is reversed by subtracting it. Multiplying both sides of an equation by a non-zero number is reversed by dividing. Multiplying both sides of an inequality by a positive number is reversed the same way. Squaring is reversible for non-negative quantities: if a≥0 and b≥0, then a≤b exactly when a2≤b2. To see this, write b2−a2=(b−a)(b+a). If a+b>0, the product has the same sign as b−a; if a+b=0, both are 0 and both inequalities hold.

Other operations cannot be undone. Squaring numbers whose signs are unknown loses information, as (−2)2=22 showed. Multiplying by something that might be 0 turns any equation into 0=0. Multiplying an inequality by something that might be negative can reverse its direction.

School algebra meets the same issue under another name. Solve x+2=x by squaring: x+2=x2, so (x−2)(x+1)=0 and x=2 or x=−1. The first works, since 4=2. The second does not, since 1=1≠−1. The "extraneous root" is exactly the backward direction failing: squaring showed that every solution is among 2 and −1, not that both are solutions. Whenever a step is not reversible, the argument proves only one direction, and the other must be checked separately.

Division with remainder

Dividing 17 by 5 gives quotient 3 and remainder 2, since 17=5×3+2. School arithmetic takes for granted that such a pair always exists and that there is only one. Both halves need proof, and both are needed here: existence gives every integer a remainder, and uniqueness makes the remainder a label that can be relied on.

The existence proof rests on one property of the natural numbers, which this course takes as basic.

The well-ordering principle. Every non-empty set of natural numbers has a least element.

It is not true of every number system. The integers have no least element, and neither do the positive rationals, since half of any positive rational is a smaller one. The principle holds equally for sets of non-negative integers: add 1 to every member of such a set, take the least element of the resulting set of natural numbers, and subtract 1 again. The induction lesson shows that well-ordering and the principle of induction are two forms of the same fact about ℕ.

Theorem (the division algorithm). Let a and b be integers with b>0. There are unique integers q and r with a=bq+r and 0≤r<b.

The number q is the quotient and r the remainder on dividing a by b, and the remainder is written amodb. Despite its traditional name, the result is a theorem, not a procedure, and its two parts, existence and uniqueness, get separate proofs.

Proof of existence. Let S be the set of all non-negative integers of the form a−bk, where k is an integer. First, S is not empty. Take k=−|a|. Then a−bk=a+b|a|≥a+|a|≥0, using b≥1 for the first inequality and |a|≥−a for the second. So by the well-ordering principle, S has a least element r, and since r is in S, r=a−bq for some integer q. Then a=bq+r and r≥0.

It remains to show r<b. Consider r−b=a−b(q+1). It has the form a−bk, and it is smaller than r because b>0. Since r is the least element of S, the number r−b is not in S, and a number of the form a−bk can be missing from S only by being negative. So r−b<0, that is, r<b.

Proof of uniqueness. Suppose a=bq+r and a=bq′+r′, where q, q′, r, r′ are integers with 0≤r<b and 0≤r′<b. The two representations play identical roles, so we may name them so that r≤r′. Then 0≤r′−r<b, since r′<b and r≥0. Subtracting the two equations gives r′−r=b(q−q′), so 0≤b(q−q′)<b, and dividing by the positive number b gives 0≤q−q′<1. The only integer in that range is 0, so q=q′, and then r=a−bq=a−bq′=r′. □

Why does the existence proof need the well-ordering principle?

The informal argument is: subtract b from a over and over (or add it, if a is negative) until the result lands in the range 0 to b−1. It lands there because the values move in steps of exactly b, the width of the target, so they cannot jump over it. The question a proof must answer is why the process stops, and "the values a, a−b, a−2b, and so on decrease, and a decreasing sequence of non-negative integers cannot go on for ever" is the well-ordering principle in other words. The formal proof goes straight to where the process ends: the least non-negative value of a−bk.

The property is special to the integers. Among the positive rationals there is no least element at all, which is why "divide 12 by 13 with remainder" needs the quotient to be declared an integer before it means anything. With the quotient an integer, the theorem does extend to real a and b, but then the existence proof needs a new ingredient, the fact that the integers are not bounded above inside ℝ, which is part of what makes the real numbers the real numbers.

The theorem is the start of number theory. Applied repeatedly, it gives Euclid's algorithm for the greatest common divisor, the subject of the Discrete Mathematics lesson on divisibility, and arithmetic that keeps only remainders is modular arithmetic. It also generalises. Polynomials with real coefficients can be divided with remainder, with degree playing the part of size: for polynomials f and g with g not the zero polynomial, there are unique polynomials q and r with f=gq+r and either r=0 or r of smaller degree than g. The existence proof is this one again, taking an r of least degree. Number systems with such a division are called Euclidean domains, and most of the theory of the integers carries over to them.

The condition 0≤r<b decides what happens for negative a: −17=5×(−4)+3, so −17mod5=3. The pair q=−3, r=−2 also satisfies −17=5q+r, but r is out of range, and uniqueness says 3 is the only remainder in range.

Uniqueness gives a test for divisibility: b∣a exactly when amodb=0. If the remainder is 0, then a=bq. Conversely, if a=bk for some integer k, then a=bk+0 is a representation with remainder in range, so by uniqueness the remainder is 0.

It also pays the debt from the first lesson.

Corollary. Every integer is even or odd, and no integer is both.

Proof. Let n be an integer. Dividing by 2 gives n=2q+r with 0≤r<2, so r=0 or r=1. If r=0 then n=2q is even, and if r=1 then n=2q+1 is odd. Now suppose n=2k and n=2m+1 for integers k and m. These are two representations n=2q+r with remainders 0 and 1, both in range, so uniqueness would make 0=1. Hence no integer is both. □

The same argument with b=3 shows that every integer has exactly one of the forms 3k, 3k+1, 3k+2, and in general, for b>0, every integer has exactly one of the forms bk, bk+1, and so on up to bk+(b−1). That splits the integers into b classes, and a proof about all integers can take them one at a time.

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 the corollary above has now made legitimate. 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 every integer 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.

Two things make a case split sound. The cases must between them cover everything: a proof about all integers that treats n=3k and n=3k+1 has proved nothing about 5. And each case must be proved using only what that case supplies, plus what was assumed for all of them. The cases may overlap harmlessly, for instance "x≥0" and "x≤0" share x=0, but none may be missing.

Parity is division by 2, and the division algorithm allows division by anything. Splitting by the remainder on division by 4, or 3, or 10, is how most facts about squares and powers are proved.

Example. Prove that no integer of the form 4k+3 is a sum of two squares of integers.

The claim says a certain thing does not exist, and the previous lesson turned such a claim into a universal one: ¬∃ is ∀¬. So the claim is that for all integers x and y, the sum x2+y2 does not leave remainder 3 on division by 4, and that has a direct proof. First a lemma about single squares.

Lemma. The square of every integer has the form 4m or 4m+1 for some integer m. Let n be an integer. If n is even, n=2k, and n2=4k2, which has the form 4m with m=k2. If n is odd, n=2k+1, and n2=4k2+4k+1=4(k2+k)+1, which has the form 4m+1.

Now let x and y be integers. By the lemma, x2=4s+e and y2=4t+f for some integers s and t, where each of e and f is 0 or 1. Then x2+y2=4(s+t)+(e+f), and e+f is 0, 1 or 2. In every case this writes x2+y2=4q+r with 0≤r<4 and r≠3. By the uniqueness of the remainder, the remainder of x2+y2 on division by 4 is not 3, so x2+y2 is not of the form 4k+3.

So 3, 7, 11, 15, 19 and every fourth number after them are never sums of two squares, a fact about infinitely many numbers and all pairs of integers, settled by four small cases. The converse fails: 21=4×5+1 is not a sum of two squares, since none of 21−0, 21−1, 21−4, 21−9, 21−16 is a square. Remainders give a necessary condition, not a sufficient one. For primes the full answer is a famous theorem: Fermat claimed in a letter to Marin Mersenne on Christmas Day 1640 that an odd prime is a sum of two squares exactly when it has the form 4k+1, as 5=1+4, 13=4+9 and 29=4+25 do. The Example is the easy half; Euler proved the hard half more than a century later.

Now you. Prove that the square of every integer has the form 3m or 3m+1, and deduce that no integer of the form 3k+2 is a perfect square.

Answer

Let n be an integer. By the division algorithm, n has exactly one of the forms 3k, 3k+1, 3k+2 for some integer k.

If n=3k, then n2=9k2=3(3k2). If n=3k+1, then n2=9k2+6k+1=3(3k2+2k)+1. If n=3k+2, then n2=9k2+12k+4=3(3k2+4k+1)+1. In each case n2 has the form 3m or 3m+1 with m an integer.

So the remainder of any square on division by 3 is 0 or 1, and by uniqueness of the remainder it is never 2. Hence no integer of the form 3k+2 is a square. For instance 2, 5, 8, 11 and 1000000001=3×333333333+2 are not squares. Notice that the third case lands on remainder 1 only because 4=3+1: the remainder of the square depends only on the remainder of the number.

How many cases can a proof have?

As many as can be checked. Logic puts no limit on the number: a proof by cases, or proof by exhaustion, is valid when the cases provably cover everything and each is proved. What separates it from checking examples is that first requirement. Checking n=1 to a million covers a million cases out of infinitely many, while the four cases above cover every integer because the division algorithm says so.

In 1976 Kenneth Appel and Wolfgang Haken proved the four colour theorem, that every map drawn in the plane can be coloured with four colours so that regions sharing a border differ, by reducing it to nearly two thousand configurations and checking each by computer, over some twelve hundred hours of machine time. The proof was controversial, since no person could read all of it. In 1996 Neil Robertson, Daniel Sanders, Paul Seymour and Robin Thomas gave a cleaner proof with 633 configurations, still checked by machine, and in 2005 Georges Gonthier verified the whole argument in the Coq proof assistant, software that checks every logical step. Thomas Hales's proof of the Kepler conjecture (that no packing of equal spheres is denser than the greengrocer's stack of oranges), announced in 1998, went the same way: the referees reported being "99% certain" of the computer case analysis, and a formal verification by Hales's Flyspeck project was completed in 2014.

These are proofs by cases in exactly this lesson's sense. The computer changes who checks the cases, not what makes the argument valid, and the doubts they raised were answered by making every step checkable by a program far smaller than the proof.

Absolute value and 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 |5|=5 and |−5|=−(−5)=5. Geometrically, |x| is the distance from x to 0 on the number line, and |x−y| is the distance between x and y. Any claim about absolute values invites a proof by cases on signs, because in each case the bars can be replaced by something plain. The basic facts come first.

Lemma. For all real numbers x, y and a:

(i) |x|≥0, with |x|=0 only when x=0;

(ii) |−x|=|x| and |xy|=|x||y|;

(iii) −|x|≤x≤|x|;

(iv) |x|≤a if and only if −a≤x≤a.

Proof. (i) If x≥0, then |x|=x≥0, and |x|=0 means x=0. If x<0, then |x|=−x>0.

(ii) For |xy|=|x||y|, split on signs. 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|. If x≥0 and y<0, then xy≤0, so |xy|=−xy=x(−y)=|x||y|; here, when xy=0, both readings of |xy| give 0, so the formula |xy|=−xy is still right. The case x<0≤y is the same with x and y exchanged. Taking y=−1 gives |−x|=|x||−1|=|x|.

(iii) If x≥0, then x=|x|, and −|x|=−x≤0≤x. If x<0, then |x|=−x, so −|x|=x, and x<0<|x|.

(iv) Suppose |x|≤a. By (iii), x≤|x|≤a and −a≤−|x|≤x. Conversely, suppose −a≤x≤a. If x≥0, then |x|=x≤a. If x<0, then |x|=−x≤a, because −a≤x. □

Part (iv) says that |x|≤a means "x lies within a of 0", and it is how inequalities with absolute values are unpacked in practice. The same proof with strict inequalities shows that |x|<a exactly when −a<x<a.

Theorem (the triangle inequality). For all real numbers x and y, |x+y|≤|x|+|y|.

First proof, by cases. 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. □

Checking only the first two cases would prove nothing about x=3, y=−5, and that is where the inequality is strict: |3+(−5)|=2, while |3|+|−5|=8.

Second proof, from the lemma. Let x and y be real numbers. By (iii), −|x|≤x≤|x| and −|y|≤y≤|y|. Adding these inequalities gives −(|x|+|y|)≤x+y≤|x|+|y|, and by (iv), with a=|x|+|y|, this says |x+y|≤|x|+|y|. □

The second proof is shorter because the cases were paid for once, in the lemma, and then reused. That is the usual pattern: a case split belongs at the lowest level where it is needed, inside a lemma that is proved once, rather than repeated in every theorem that uses it.

The name comes from geometry. Replace x by x−y and y by y−z, and the inequality becomes

|x−z|≤|x−y|+|y−z|

for all real x, y and z: the distance from x to z is at most the distance travelled by going through y. In the plane, it says that one side of a triangle is no longer than the other two together. Rearranged, it also gives a lower bound.

Corollary (the reverse triangle inequality). For all real numbers x and y, ||x|−|y||≤|x−y|.

Proof. Let x and y be real. Since x=(x−y)+y, the triangle inequality gives |x|≤|x−y|+|y|, so |x|−|y|≤|x−y|. Exchanging the roles of x and y gives |y|−|x|≤|y−x|, and |y−x|=|x−y| by (ii), so −|x−y|≤|x|−|y|. Together, −|x−y|≤|x|−|y|≤|x−y|, and by (iv) this says ||x|−|y||≤|x−y|. □

These two inequalities are the everyday tools of analysis. The lesson on limits uses the triangle inequality to prove that a sequence cannot converge to two different limits and that the limit of a sum is the sum of the limits, and the reverse form shows that if an→L then |an|→|L|.

Without loss of generality

The first proof of the triangle inequality treated the case x≥0>y and skipped the case y≥0>x. That was honest because the statement is symmetric in x and y: exchanging the two letters turns |x+y|≤|x|+|y| into |y+x|≤|y|+|x|, which says the same thing. So the written argument for x≥0>y, with the letters exchanged throughout, is an argument for y≥0>x, and writing it out again would add nothing. The phrase for this move is without loss of generality, often shortened to WLOG: "without loss of generality, x≥0>y". The uniqueness half of the division algorithm used it too, when it named the two remainders so that r≤r′.

The phrase is a promise that the omitted cases follow from the treated one by a symmetry, and a reader is entitled to ask which symmetry. The test is mechanical: apply the symmetry to the whole statement, hypotheses included, and check that the same statement comes back. Good writing names it: "the statement is symmetric in x and y, so we may assume x≤y."

Here is what failing the test looks like. "Claim: for all real numbers x and y, y−x≥0. Proof: without loss of generality x≤y, and then y−x≥0." Exchanging x and y turns the claim into x−y≥0, a different statement, so the case x>y was lost, not saved; the claim fails at x=1, y=0. Hypotheses must survive the exchange too. In "let a be even and b odd; without loss of generality a≤b", the exchange would make b the even one, so the assumption is not free.

Used properly, the move saves a great deal. A statement symmetric in three variables allows "without loss of generality x≤y≤z", one ordering in place of six, and a statement unchanged when n is replaced by −n allows "without loss of generality n≥0". When the symmetry is not obvious, write the second case out.

If and only if

A biconditional P⟺Q is the conjunction of two conditionals, P⇒Q and Q⇒P, so a proof of it is two proofs. Label them, so the reader knows which is which: the forward direction (⇒) assumes P and reaches Q, and the backward direction (⇐) assumes Q and reaches P. The two may need quite different arguments, and either may be proved by any method, including a contrapositive, which proves Q⇒P in the form ¬P⇒¬Q.

The classic mistake is to prove one direction and believe both are done, usually because the easy direction was proved and the other looked like "the same thing backwards". Take "an integer n is even if and only if n2 is even". The forward direction is one line: n=2k gives n2=2(2k2). The backward direction is the claim this lesson cannot yet prove, as its last section explains.

A convention to know: definitions are written with "if" but mean "if and only if". "An integer is even if it is twice an integer" also means that an integer that is not twice an integer is not even. Theorems do not get this licence; in a theorem, "if" means only "if".

Example. Prove that for every integer n, 6∣n if and only if 2∣n and 3∣n.

Let n be an integer.

(⇒) Suppose 6∣n, so n=6k for some integer k. Then n=2(3k) and n=3(2k), and 3k and 2k are integers, so 2∣n and 3∣n.

(⇐) Suppose 2∣n and 3∣n, so n=2k and n=3m for some integers k and m. The goal is a factor of 6, and 6 appears if each expression for n is multiplied by the other divisor. Since n=3n−2n,

n=3(2k)−2(3m)=6k−6m=6(k−m)

and k−m is an integer, so 6∣n.

The backward direction is not a formality, and it does not hold for every pair of divisors: 2∣4 and 4∣4, but 8 does not divide 4. It worked because 3×1−2×1=1, an integer combination of 2 and 3 equal to 1. The same trick shows that whenever ax+by=1 for some integers x and y, a number divisible by both a and b is divisible by ab. For 2 and 4 no such combination exists, since 2x+4y is always even.

Now you. Prove that for all integers a and b, a−b is even if and only if a and b have the same parity (both even or both odd).

Answer

Let a and b be integers.

(⇒) Suppose a−b is even, so a−b=2k for some integer k, and a=b+2k. By the corollary to the division algorithm, b is even or odd. If b is even, b=2m, and a=2(m+k) is even, so both are even. If b is odd, b=2m+1, and a=2(m+k)+1 is odd, so both are odd. Either way a and b have the same parity.

(⇐) If both are even, a=2k and b=2m, so a−b=2(k−m). If both are odd, a=2k+1 and b=2m+1, so a−b=2(k−m). Either way a−b is even.

Each direction was a proof by cases, split on different things: the forward direction on the parity of b, the backward direction on which kind of "same parity" was assumed.

Longer lists of equivalent statements are proved in a cycle. To show that P, Q and R are all equivalent, it is enough to prove P⇒Q, Q⇒R and R⇒P: three proofs instead of six, since any one of the statements leads round the cycle to each of the others. Textbooks announce this as "the following are equivalent", and the order of the cycle is chosen to make each step easy.

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 that turns each k into a suitable n.

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) because a common divisor divides a sum. 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. The result also says something that sounds like the opposite of the next lesson's theorem that the primes never run out: there are gaps between consecutive primes as long as you like.

Many theorems claim more than existence: there is exactly one such object. That is two claims, and each needs its own proof. Existence is proved as above. Uniqueness is a universal claim, "any two objects with the property are equal", and is proved by letting two such objects be arbitrary and showing they coincide, as the division algorithm did with (q,r) and (q′,r′). Showing that one candidate works and that no other one comes to mind proves existence only.

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 argument was published by Dov Jarden in 1953. The answer is known from outside the proof: a theorem proved independently by Aleksandr Gelfond and Theodor Schneider in 1934 implies that 22 is irrational (indeed not the root of any polynomial with integer coefficients), so the second pair is the one.

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. (That log29=2log23 is irrational follows from the irrationality of log23, which the next lesson proves.)

Some mathematicians, the constructivists, reject non-constructive proofs, because they rest on the claim that every statement is true or false even when nobody can say which.

Is a proof that names no witness really a proof?

In the mathematics taught in this course, yes. The Example uses one principle beyond the definitions, the law of excluded middle: for every statement P, either P or ¬P. Applied to "22 is rational", it licenses the case split, and each case is then proved. Accept the law, and the proof is complete.

Not everyone accepts it. Early in the twentieth century the Dutch mathematician L. E. J. Brouwer argued that, for statements about infinite collections, asserting "P or not P" claims knowledge nobody has, and that to prove something exists is to show how to find it. His intuitionism, and the constructive mathematics that grew from it, rejects the law of excluded middle, and with it the Example. David Hilbert answered in 1927 that taking the law of excluded middle from the mathematician would be like denying the telescope to the astronomer or the use of his fists to the boxer. Mainstream mathematics sided with Hilbert, but the constructive view never went away, and it returned with computers: in constructive logic, a proof of ∀x∃yP(x,y) contains a program computing y from x, and some proof assistants are built on this idea.

Non-constructive proofs can say surprising things. Chomp, a game popularised by David Gale in 1974, is played on a rectangular bar of chocolate whose bottom-left square is poisoned; players alternately choose a square and eat it together with every square above and to the right of it, and whoever must eat the poisoned square loses. The game always ends and cannot be drawn, and in such a game one of the two players has a winning strategy. On any rectangle larger than one square it is the first player. For suppose the second player could always win, and let the first player open by eating only the top-right square. The second player has a winning reply to that. But every move eats the top-right square along with the rest, so the first player could have made that same reply as the opening move, reaching the same position, and then won by following the second player's strategy. So the second player cannot always win. The argument proves a winning first move exists without naming it, and for most rectangles nobody knows what it is.

Examples, counterexamples and finite checks

A universal claim over an infinite domain is proved only by an argument about an arbitrary element, and no number of examples will do. It is disproved by a single counterexample: one value that satisfies the hypothesis and fails the conclusion. A disproof should state the counterexample and verify it, since a value that fails the hypothesis refutes nothing.

Many exercises, and most real questions, say "prove or disprove", and the first job is to decide which. Try examples first, and choose them to be awkward: 0, 1 and −1, negative numbers, equal values, the smallest case the hypothesis allows. If a counterexample appears, the question is settled. If none does, attempt a proof and watch where it strains: a step that fails usually points to the values where the claim fails.

Example. Prove or disprove each claim. (a) The sum of any three consecutive integers is divisible by 3. (b) The sum of any four consecutive integers is divisible by 4.

(a) Examples: 1+2+3=6, 4+5+6=15, −1+0+1=0, all divisible by 3. So attempt a proof. Let n be an integer; the three consecutive integers starting at n are n, n+1 and n+2, and their sum is 3n+3=3(n+1). Since n+1 is an integer, 3 divides the sum. The claim is true.

(b) The first example, 1+2+3+4=10, already fails: 10=4×2+2, so 4 does not divide it. The claim is false, and this one counterexample disproves it. The attempted proof shows more. The sum n+(n+1)+(n+2)+(n+3)=4n+6=4(n+1)+2 always leaves remainder 2, so the sum of four consecutive integers is never divisible by 4. A counterexample settles the question; the algebra explains it.

Now you. Prove or disprove each claim, for all integers a, b and c. (a) If a∣b+c and a∣b−c, then a∣2b. (b) If a∣b+c and a∣b−c, then a∣b.

Answer

(a) True. Let a, b and c be integers with a∣b+c and a∣b−c. A common divisor of two integers divides their sum, and (b+c)+(b−c)=2b, so a∣2b.

(b) False. Take a=2 and b=c=1. Then b+c=2 and b−c=0, both divisible by 2, but 2 does not divide 1.

Part (a) suggests the repair. The claim in (b) becomes true when a is odd: writing a=2t+1, we have b=ab−t(2b), and a divides both ab and 2b, hence divides b. This is the combination trick from the section on "if and only if", with a×1−2×t=1.

Checking examples is a proof in one situation: when the domain is finite, and every element is checked. The division algorithm can make an infinite domain finite. Take the claim that the last digit of every perfect square is 0, 1, 4, 5, 6 or 9. Let n be an integer, and divide by 10: n=10q+r with 0≤r≤9. Then

n2=100q2+20qr+r2=10(10q2+2qr)+r2

so n2 and r2 leave the same remainder on division by 10 (write r2=10t+s with 0≤s≤9 and apply uniqueness), and the remainder of a non-negative integer on division by 10 is its last digit. So the last digit of n2 is the last digit of one of 0,1,4,9,16,25,36,49,64,81, which is one of 0,1,4,9,6,5,6,9,4,1. That is ten checks, and they settle every integer, because the division algorithm proves that the ten remainders are all there are. So 1234567 is not a square, and no search was needed to see it.

Where the direct route stalls

Every proof above ran forwards: unpack the hypothesis by its definition, then rearrange, split into cases or construct, 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.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Using only the definition of divisibility, decide which of these are true: −6∣42, 42∣−6, 0∣0, 0∣5, 11∣0.

Solution

−6∣42 is true, since 42=(−6)(−7) and −7 is an integer.

42∣−6 is false: by part (i) of the proposition on divisibility and size, it would give 42≤|−6|=6.

0∣0 is true, since 0=0×1. The statement is true even though 00 is undefined, which is one more reason to keep "a∣b" (a statement) apart from "ba" (a number).

0∣5 is false, since 0×k=0≠5 for every integer k.

11∣0 is true, since 0=11×0.

2. For each pair, find the integers q and r given by the division algorithm, so that a=bq+r and 0≤r<b: (a) a=100, b=7; (b) a=−100, b=7; (c) a=5, b=12; (d) a=−1, b=12.

Solution

(a) 100=7×14+2, so q=14 and r=2.

(b) −100=7×(−15)+5, since 7×(−15)=−105. So q=−15 and r=5. The tempting answer q=−14 gives −100=−98−2, with remainder −2, which is out of range.

(c) 5=12×0+5, so q=0 and r=5. When 0≤a<b, the quotient is 0 and the remainder is a itself.

(d) −1=12×(−1)+11, so q=−1 and r=11.

In each case 0≤r<b holds, so by uniqueness these are the only answers.

3. Prove that for all integers a, b and c: (a) if a∣b then a∣bc; (b) if a∣b then a2∣b2; (c) if a∣b then −a∣b and a∣−b.

Solution

Let a, b and c be integers with a∣b, so b=ak for some integer k.

(a) Then bc=(ak)c=a(kc), and kc is an integer, so a∣bc.

(b) Then b2=a2k2=a2(k2), and k2 is an integer, so a2∣b2.

(c) Then b=(−a)(−k) and −b=a(−k), and −k is an integer, so −a∣b and a∣−b.

4. Prove that for all real numbers x and a, |x−3|<a if and only if 3−a<x<3+a. Use this to find all real x with |2x−6|<1.

Solution

Let x and a be real numbers. By the strict form of part (iv) of the lemma on absolute value, applied to the number x−3, we have |x−3|<a if and only if −a<x−3<a. Adding 3 to each part is reversible (subtract 3 to undo it), so this holds if and only if 3−a<x<3+a.

For the second part, |2x−6|=|2(x−3)|=|2||x−3|=2|x−3| by part (ii) of the lemma. So |2x−6|<1 if and only if |x−3|<12, which by the first part holds if and only if 52<x<72. These are exactly the real numbers within 12 of 3.

Core

5. Prove that for every odd integer n, the number n4−1 is divisible by 16. Show by an example that 16 cannot be replaced by 32.

Hint

Factor n4−1 as a difference of two squares, and use the fact proved in the lesson that the square of an odd integer has the form 8m+1.

Solution

Let n be an odd integer. By the result proved in the section on proof by cases, n2=8m+1 for some integer m. Then

n4−1=(n2−1)(n2+1)=(8m)(8m+2)=16m(4m+1)

and m(4m+1) is an integer, so 16∣n4−1.

For n=3, n4−1=80=16×5, and 32 does not divide 80, since 80=32×2+16 has remainder 16. So the claim with 32 in place of 16 is false, and n=3 is a counterexample.

6. Prove or disprove each claim, for all integers a, b and c. (a) If ab∣c then a∣c. (b) If a∣c and b∣c then ab∣c. (c) If a2∣b then a∣b. (d) If a∣b2 then a∣b.

Hint

Two are true and have one-line proofs. For the other two, try small values, including a=b in (b) and a perfect square for a in (d).

Solution

(a) True. Let a, b, c be integers with ab∣c, so c=abk for some integer k. Then c=a(bk), and bk is an integer, so a∣c.

(b) False. Take a=b=c=2. Then a∣c and b∣c, but ab=4 does not divide 2 (by part (i) of the proposition, a divisor of 2 has size at most 2). The claim does hold when a and b have an integer combination equal to 1, by the argument in the section on "if and only if", and 2 and 2 do not.

(c) True. Let a, b be integers with a2∣b, so b=a2k for some integer k. Then b=a(ak), and ak is an integer, so a∣b.

(d) False. Take a=9 and b=3. Then b2=9 and 9∣9, but 9 does not divide 3, since a divisor of 3 has size at most 3.

7. Find the flaw in this proof, show that the claim is false, and state and prove a correct claim about the sum of an even and an odd integer.

Claim. The sum of an even integer and an odd integer is one more than a multiple of 4.

Proof. Let m be even and n odd. Then m=2k and n=2k+1 for some integer k. So m+n=4k+1, which is one more than a multiple of 4.

Hint

Ask what the proof has assumed about how m and n are related.

Solution

The definitions give m=2k for some integer k and n=2j+1 for some integer j, and nothing says j=k. By using one letter for both, the proof assumed n=m+1, so it proved the claim only for an even integer and the odd integer immediately after it. For those it is correct: m+(m+1)=4k+1.

The claim itself is false. Take m=2 and n=5: then m+n=7=4×1+3, which by uniqueness of the remainder is not of the form 4q+1.

A correct claim is that the sum of an even integer and an odd integer is odd. Let m be even and n odd, so m=2k and n=2j+1 for some integers k and j. Then m+n=2(k+j)+1, and k+j is an integer, so m+n is odd.

8. Find the flaw in this argument.

Let a and b be real numbers with a=b and b≠0. Multiplying both sides by a gives a2=ab. Subtracting b2 gives a2−b2=ab−b2. Factorising, (a+b)(a−b)=b(a−b). Dividing by a−b gives a+b=b. Since a=b, this says 2b=b, and dividing by b gives 2=1.

Hint

Each step but one is valid algebra. Which operation is only allowed under a condition, and does the condition hold here?

Solution

The flaw is the division by a−b. Since a=b, the number a−b is 0, and division by 0 is not defined. The rule being used is cancellation: if xz=yz and z≠0, then x=y. Without the condition z≠0 the rule is false, since 3×0=5×0 while 3≠5.

Every line up to and including (a+b)(a−b)=b(a−b) is true: with a=b both sides are 0. The line a+b=b does not follow from it, and it is false, because a=b≠0 gives a+b=2b≠b. The final division by b is legitimate, because the hypothesis says b≠0.

9. For real numbers x and y, let max(x,y) be x if x≥y and y otherwise, and let min(x,y) be y if x≥y and x otherwise. Prove that for all real x and y,

max(x,y)=x+y+|x−y|2min(x,y)=x+y−|x−y|2
Hint

Check that both sides of each equation are unchanged when x and y are exchanged. Then one case is enough.

Solution

First, the statement is symmetric in x and y. Exchanging them leaves max(x,y) and min(x,y) unchanged: if x≠y both are defined by which of the two is larger, and if x=y every expression involved equals x. It also leaves the right-hand sides unchanged, since y+x=x+y and |y−x|=|−(x−y)|=|x−y| by part (ii) of the lemma on absolute value. So the pair of equations for (y,x) is the same pair as for (x,y), and without loss of generality x≥y.

Let x≥y. Then x−y≥0, so |x−y|=x−y, and by definition max(x,y)=x and min(x,y)=y. Now

x+y+(x−y)2=2x2=xx+y−(x−y)2=2y2=y

which are max(x,y) and min(x,y), as required. The case x<y follows by exchanging the letters.

10. Prove that |x−1|+|x−3|≥2 for every real number x, and that equality holds if and only if 1≤x≤3.

Hint

The signs of x−1 and x−3 change at 1 and 3, which suggests three cases. For the inequality alone, there is also a one-line proof by the triangle inequality.

Solution

Let x be a real number, and write f(x)=|x−1|+|x−3|. The three cases below cover every real number.

If x<1, then x−1<0 and x−3<0, so f(x)=(1−x)+(3−x)=4−2x. Since x<1, 2x<2, so f(x)>2.

If 1≤x≤3, then x−1≥0 and x−3≤0, so |x−1|=x−1 and |x−3|=3−x (when x=3 both readings give 0). So f(x)=(x−1)+(3−x)=2.

If x>3, then x−1>0 and x−3>0, so f(x)=(x−1)+(x−3)=2x−4. Since x>3, 2x>6, so f(x)>2.

In every case f(x)≥2. For the equality: if 1≤x≤3 then f(x)=2 by the middle case; conversely, if f(x)=2, then x is not in the first or third case, where f(x)>2, so 1≤x≤3.

The inequality alone also follows from the triangle inequality: |x−1|+|x−3|=|x−1|+|3−x|≥|(x−1)+(3−x)|=2. Geometrically, the sum of the distances from x to 1 and to 3 is at least the distance between 1 and 3.

11. Let a and b be integers with b>0. Prove that there are unique integers q and r with a=bq+r and −b2<r≤b2. Find q and r for a=18, b=5 and for a=−18, b=5.

Hint

For existence, start from the division algorithm and move the remainder down by b when it is too big. For uniqueness, follow the uniqueness proof in the lesson: the two remainders now lie in a range of width b that includes one end and not the other.

Solution

Existence. By the division algorithm, a=bq0+r0 for integers q0 and r0 with 0≤r0<b. If r0≤b2, take q=q0 and r=r0; then −b2<0≤r≤b2. If r0>b2, take q=q0+1 and r=r0−b. Then bq+r=bq0+b+r0−b=a. Also r<0≤b2, because r0<b, and r>b2−b=−b2, because r0>b2. So in both cases the pair has the required properties.

Uniqueness. Suppose a=bq+r=bq′+r′ with q, q′, r, r′ integers and both r and r′ in the range −b2<r≤b2. The two representations play identical roles, so without loss of generality r≤r′. Then r′−r≥0, and r′−r<b2+b2=b, because r′≤b2 and −r<b2. Subtracting the equations gives r′−r=b(q−q′), so 0≤b(q−q′)<b, and dividing by b>0 gives 0≤q−q′<1. Hence q−q′=0, so q=q′ and r=a−bq=r′.

For a=18, b=5: the division algorithm gives 18=5×3+3, and 3>52, so q=4 and r=−2, that is, 18=5×4−2. For a=−18: −18=5×(−4)+2, and 2≤52, so q=−4 and r=2.

12. Prove that an integer n can be written as a2−b2 for some integers a and b if and only if n does not have the form 4k+2 for any integer k.

Hint

For the backward direction, compute (k+1)2−k2 and (k+1)2−(k−1)2. For the forward direction, use the lemma that every square has the form 4m or 4m+1.

Solution

Let n be an integer.

(⇐) Suppose n is not of the form 4k+2. By the division algorithm, n has one of the forms 4k, 4k+1, 4k+3 for some integer k. If n=4k+1=2(2k)+1 or n=4k+3=2(2k+1)+1, then n is odd, say n=2j+1 for an integer j, and (j+1)2−j2=2j+1=n. If n=4k, then

(k+1)2−(k−1)2=(k2+2k+1)−(k2−2k+1)=4k=n

In every case n is a difference of two squares of integers.

(⇒) Suppose n=a2−b2 for integers a and b. By the lemma in the section on proof by cases, a2=4s+e and b2=4t+f for some integers s and t, with each of e and f equal to 0 or 1. Then n=4(s−t)+(e−f), and e−f is −1, 0 or 1. If e−f is 0 or 1, then n leaves remainder 0 or 1 on division by 4. If e−f=−1, then n=4(s−t−1)+3 leaves remainder 3. In no case is the remainder 2, so by uniqueness of the remainder, n is not of the form 4k+2.

For example, 7=42−32 and 12=42−22, while 2, 6 and 10 are not differences of two squares.

Challenge

13. Prove that n=1 is the only natural number for which n4+4 is prime.

Hint

Add and subtract 4n2: then n4+4 is a difference of two squares.

Solution

Let n be a natural number. Then

n4+4=(n4+4n2+4)−4n2=(n2+2)2−(2n)2=(n2+2n+2)(n2−2n+2)

For n=1, n4+4=5, which is prime.

Now let n≥2. The second factor is n2−2n+2=(n−1)2+1≥1+1=2, since n−1≥1. The first factor is n2+2n+2=(n2−2n+2)+4n, which exceeds the second, so it is greater than 2 as well. So n4+4 is the product of two integers each greater than 1, which by definition makes it composite, and hence not prime. For instance 34+4=85=17×5, and the factors are 9+6+2 and 9−6+2.

So n4+4 is prime for n=1 and for no other natural number. The factorisation is a case of an identity named after Sophie Germain: a4+4b4=(a2+2ab+2b2)(a2−2ab+2b2). Finding it is the whole difficulty.

14. Prove that n5−n is divisible by 30 for every integer n.

Hint

Factor n5−n completely over the integers. Show separately that 2, 3 and 5 divide it, using cases on remainders, and then combine the three facts with the trick from the Example in the section on "if and only if".

Solution

Let n be an integer and write N=n5−n. Factoring,

N=n(n4−1)=n(n2−1)(n2+1)=(n−1)n(n+1)(n2+1)

Throughout, if an integer d divides one factor of a product, it divides the product (Problem 3(a)).

Divisibility by 2. The product n(n+1)=n2+n is even, as proved in the lesson, and it is a factor of N, so 2∣N.

Divisibility by 3. By the division algorithm, n=3k, 3k+1 or 3k+2 for some integer k. In the first case 3∣n; in the second n−1=3k; in the third n+1=3(k+1). In each case 3 divides a factor of N, so 3∣N.

Divisibility by 5. Write n=5k+r with 0≤r≤4. If r=0, 5∣n. If r=1, n−1=5k. If r=4, n+1=5(k+1). If r=2, then n2+1=25k2+20k+5=5(5k2+4k+1). If r=3, then n2+1=25k2+30k+10=5(5k2+6k+2). In each case 5 divides a factor of N, so 5∣N.

Combining. Since 2∣N and 3∣N, the Example in the section on "if and only if" gives 6∣N. Now 6∣N and 5∣N, say N=6u and N=5v for integers u and v. Since N=6N−5N,

N=6(5v)−5(6u)=30v−30u=30(v−u)

and v−u is an integer, so 30∣N.

As a check, n=2 gives 30 and n=3 gives 240=30×8. Each of the three facts is a case of Fermat's little theorem, that p∣np−n for every prime p, which needs new ideas to prove for all primes at once.

15. Prove that for all real numbers x and y,

|x+y|1+|x+y|≤|x|1+|x|+|y|1+|y|
Hint

First prove that s1+s≤t1+t whenever 0≤s≤t. Then apply it with s=|x+y| and t=|x|+|y|, split the resulting fraction in two, and compare each half with the right-hand side.

Solution

All the denominators are at least 1, so every fraction is defined.

Step 1. Let s and t be real numbers with 0≤s≤t. Then

t1+t−s1+s=t(1+s)−s(1+t)(1+t)(1+s)=t−s(1+t)(1+s)≥0

because t−s≥0 and the denominator is positive. So s1+s≤t1+t.

Step 2. Let x and y be real numbers. By the triangle inequality, 0≤|x+y|≤|x|+|y|, so Step 1 with s=|x+y| and t=|x|+|y| gives

|x+y|1+|x+y|≤|x|+|y|1+|x|+|y|=|x|1+|x|+|y|+|y|1+|x|+|y|

Step 3. Since |y|≥0, we have 1+|x|+|y|≥1+|x|>0, and a non-negative numerator over a larger positive denominator gives a smaller or equal fraction, so |x|1+|x|+|y|≤|x|1+|x|. In the same way |y|1+|x|+|y|≤|y|1+|y|. Adding these to the inequality of Step 2 proves the claim.

Applied to x−y and y−z, the result says that d(x,y)=|x−y|1+|x−y|, a measure of distance that never exceeds 1, still satisfies the triangle inequality.

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. With them it proves that p is irrational for every prime p, and so is log23; it proves Euclid's lemma, the fact about primes on which the uniqueness of prime factorisation rests; it proves Euclid's theorem that there are infinitely many primes, and that infinitely many of them have the form 4k+3. It then states and proves the pigeonhole principle, a counting fact whose proof is a one-line contradiction and whose uses run through all of combinatorics. It ends with how to choose a method and how to recognise a proof by contradiction that is really something else.

Throughout, the definitions are those of the previous lessons: 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 lesson also uses what the lesson on direct proof proved from the division algorithm: every integer is even or odd and none is both, and for b>0 every integer has exactly one of the forms bk,bk+1,…,bk+(b−1).

Turning the conditional round

The contrapositive of P⇒Q is ¬Q⇒¬P. The two are logically equivalent: each is false in exactly one row of its truth table, the row with P true and Q false, since ¬Q⇒¬P fails exactly when ¬Q is true and ¬P is false. 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.

With a universal quantifier in front nothing changes. "For every x, if P(x) then Q(x)" is equivalent to "for every x, if not Q(x) then not P(x)", because the two conditionals are equivalent for each x separately. A proof lets x be arbitrary, assumes ¬Q(x), and derives ¬P(x).

The contrapositive must not be confused with the converse, Q⇒P, which is a different statement and may be false when the original is true. "If n is divisible by 4 then n is even" is true, its converse "if n is even then n is divisible by 4" is false at n=2, and its contrapositive "if n is odd then n is not divisible by 4" is true, as it must be.

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. Both facts about parity from the previous lesson were used, one at each end: "even or odd" turned "not even" into "odd" at the start, and "not both" turned "odd" into "not even" at the finish.

Combined with the direct proof that the square of an even number is even, the Example gives a biconditional: n is even if and only if n2 is even. The two directions were proved by different methods, which is common.

Now you. Prove that for every integer n, if n2−6n+5 is even then n is odd.

Answer

We prove the contrapositive: if n is not odd then n2−6n+5 is not even. Let n be an integer that is not odd. Then n is even, so n=2k for some integer k. Then

n2−6n+5=4k2−12k+5=2(2k2−6k+2)+1

and 2k2−6k+2 is an integer, so n2−6n+5 is odd, and hence not even. This proves the contrapositive, and so the claim.

A direct attempt starts from n2−6n+5=2m and has to extract the parity of n from a quadratic; the contrapositive starts from a formula for n and only has to expand. (Another route: n2−6n+5=(n−1)(n−5), and a product of two integers is odd exactly when both are odd, but proving that last fact is itself a contrapositive argument.)

Assuming the opposite

A proof by contradiction proves a statement Q by assuming ¬Q and deriving something impossible: a statement together with its negation, R∧¬R. 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.

The contradiction can be with anything known to be true: with the assumption itself, with another hypothesis, with a definition, or with a theorem proved earlier. "1=0", "p∣1 although p>1", "n is both even and odd" and "b is a smaller positive element than the least one" are all typical endings.

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. For a universal statement ∀xQ(x), the negation is ∃x¬Q(x): assume that one counterexample exists, name it, and derive an impossibility. The assumption must be the exact negation, computed by the rules of the lesson on quantifiers. Assuming too much ("every x fails", when the negation only says "some x fails") proves nothing, a mistake examined in the section on disguises below.

A proof by contradiction announces itself in its first line, "Suppose, for contradiction, that ...", names the impossibility when it arrives, and ends by saying what has been proved. The reader should never have to guess which statements are established facts and which are the doomed assumption.

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 section's proof, in geometric dress.

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.

Here is the shape at its simplest. Claim: there is no smallest positive rational number. Suppose, for contradiction, that q is a smallest positive rational. Then q2 is rational, since q=ab gives q2=a2b, and it is positive, and q2<q because q>0. So q2 is a positive rational smaller than the smallest one, which is impossible. Hence there is no smallest positive rational. The claim is a negative ("there is no ..."), with no hypothesis to start from, and assuming the positive version handed the proof an object, q, to work on. That is the typical reason for choosing contradiction.

Example. Prove that the sum of a rational number and an irrational number is irrational.

Recall that a real number is rational if it equals ab for some integers a and b with b≠0, and irrational otherwise. Let r be rational and x irrational, and suppose, for contradiction, that r+x is rational. Write r=ab and r+x=cd with a, b, c, d integers and b, d non-zero. Then

x=(r+x)−r=cd−ab=bc−adbd

and bc−ad and bd are integers with bd≠0. So x is rational, contradicting the hypothesis that x is irrational. Hence r+x is irrational.

"Irrational" is a negative, "not equal to any fraction", and it gives a direct proof nothing to hold. Assuming the sum rational turns it into an equation with integers in it, and equations can be rearranged.

Now you. Prove that the product of a non-zero rational number and an irrational number is irrational. Where does the proof use that the rational number is non-zero?

Answer

Let r be a non-zero rational and x irrational, and suppose, for contradiction, that rx is rational. Write r=ab and rx=cd with a, b, c, d integers and b, d non-zero. Since r≠0, also a≠0, so we may divide by r:

x=rxr=cd⋅ba=bcad

with bc and ad integers and ad≠0 (a product of non-zero integers). So x is rational, a contradiction. Hence rx is irrational.

The hypothesis r≠0 was used to divide by r, and it cannot be dropped: 0×x=0 is rational for every x.

Is proof by contradiction as safe as a direct proof?

In classical mathematics, which is the mathematics of this course and of almost all working mathematicians, yes. Its justification is the truth table, and truth tables rest on the principle that every statement is true or false. But there are two kinds of proof by contradiction, and only one of them depends on that principle.

The first kind proves a negative statement, ¬P, by assuming P and deriving an impossibility. That is simply what "not P" means: P leads to absurdity. The irrationality of 2 is of this kind, since "irrational" means "not rational", and the proof assumes 2 rational and derives an absurdity. So is the claim that there is no smallest positive rational.

The second kind proves a positive statement, P, by assuming ¬P and deriving an impossibility. That shows ¬¬P, "it is not the case that P fails", and passing from ¬¬P to P is the law of double negation, equivalent to the law of excluded middle. Constructive mathematicians, following L. E. J. Brouwer, accept the first kind and reject the second in general, because a proof that "there is no way for an object to fail to exist" does not show how to find the object. For them "there exists" means "we can construct".

The theorem below that there are infinitely many primes is of the first kind too, since "infinite" means "not finite", and constructivists accept it. Even so, the way it is usually written hides information. Recast as a direct argument, it shows how to produce a new prime from any finite list of primes, which is more than the bare claim. That is the practical lesson for classical mathematicians as well: a proof by contradiction is valid, but when a direct version exists it often carries a construction that the contradiction concealed.

The square root of two

"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.

The proof needs a fraction for 2 that cannot be simplified, and the cleanest way to get one is the well-ordering principle from the previous lesson: every non-empty set of natural numbers has a least element.

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. Replacing a and b by −a and −b if necessary, we may take b>0. So the set of natural numbers b for which 2=ab with some integer a is not empty, and by the well-ordering principle it has a least element. Let b be that least element and a the matching integer.

Squaring 2=ab and multiplying by b2 gives a2=2b2, so a2 is even. By the Example of the previous section, 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, say b=2d with d an integer, and d is a natural number because b is. Then 2=ab=2c2d=cd with 0<d<b, which contradicts the choice of b as the least possible denominator. Hence 2 is not rational.

The contradiction is with the minimality of b, and the minimality is where "lowest terms" comes from. Textbooks often say "write 2=ab in lowest terms", which assumes that every fraction can be reduced to lowest terms; the well-ordering principle is the reason it can.

A proof that proves too much is wrong, so why does the argument 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 of a special property of 2, and it breaks exactly where it should. The next section identifies the property: 2 is prime.

Now you. Prove that 3 is irrational. You may use the result of the previous lesson that if 3 does not divide n, then n=3k+1 or n=3k+2 for some integer k, and in both cases n2 has the form 3m+1.

Answer

First, if 3∣n2 then 3∣n. We prove the contrapositive: if 3 does not divide n, then n2=3m+1 for some integer m, and by the uniqueness of the remainder, n2 leaves remainder 1 and not 0 on division by 3, so 3 does not divide n2.

Now suppose, for contradiction, that 3=ab with a an integer and b a natural number, and choose b as small as possible by the well-ordering principle. 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; write b=3d with d a natural number. Then 3=cd with d<b, contradicting the choice of b. Hence 3 is irrational.

The proof is the proof for 2 with 3 in place of 2, and the one new ingredient was "if 3∣n2 then 3∣n", proved, like its analogue for 2, by contrapositive.

The same method proves a claim of a different look, which the previous lesson used and promised to prove.

Theorem. log23 is irrational.

Proof. Since 3>1=20 and 2x increases with x, log23>0. Suppose, for contradiction, that log23=pq with p and q integers, which we may take to be positive. Then 2pq=3, and raising both sides to the power q gives 2p=3q. Since p≥1, the left side is 2×2p−1, which is even. The right side is a product of q odd numbers, and a product of odd numbers is odd, since (2s+1)(2t+1)=2(2st+s+t)+1. So 2p=3q is both even and odd, which no integer is. Hence log23 is irrational. □

It follows that log29=2log23 is irrational too, by the Now you of the previous section with the rational number 2, which completes the constructive example of the previous lesson: 2log29=3 is an irrational number raised to an irrational power with a rational result, and both numbers are named. The argument also shows why log23 matters outside mathematics. In music, a perfect fifth has frequency ratio 3:2 and an octave 2:1, and a stack of fifths never lands exactly on a stack of octaves, because (32)q=2m would give 3q=2m+q. The nearest miss, twelve fifths against seven octaves, is off by the ratio 312219=531441524288, a little over 1.0136, and every tuning system has to hide this gap somewhere.

Euclid's lemma

An integer p>1 is prime if its only positive divisors are 1 and p. An integer n>1 that is not prime is composite: it has a positive divisor other than 1 and n, and so can be written n=rs with 1<r<n and 1<s<n. The number 1 is neither.

What made 2 and 3 work in the last section was the step "if p∣a2 then p∣a". For prime p it always holds, and the reason is the most important single fact about primes.

Theorem (Euclid's lemma). Let p be a prime and a, b integers. If p∣ab, then p∣a or p∣b.

It appears as Proposition 30 of Book VII of Euclid's Elements. It is not obvious, and it fails for composite numbers: 6∣4×9, although 6 divides neither 4 nor 9. The proof goes through a lemma about integer combinations, proved by the well-ordering principle and two small contradictions.

Lemma. Let p be a prime and a an integer that p does not divide. Then there are integers x and y with px+ay=1.

Proof. Let S be the set of positive integers of the form px+ay with x and y integers. It is not empty, since p=p×1+a×0 is in it, so by the well-ordering principle it has a least element d=px0+ay0.

First, d∣p. By the division algorithm, p=dq+r with 0≤r<d. Then

r=p−dq=p−(px0+ay0)q=p(1−x0q)+a(−y0q)

is of the form px+ay. If r were positive it would be an element of S smaller than d, contradicting the choice of d. So r=0, and d∣p.

Second, d∣a, by the same argument: a=dq′+r′ with 0≤r′<d, and r′=a−dq′=p(−x0q′)+a(1−y0q′) is of the form px+ay, so r′=0 by the minimality of d.

Since d is a positive divisor of the prime p, either d=1 or d=p. If d=p, then p=d∣a, contrary to the hypothesis. So d=1, and 1=px0+ay0. □

Proof of Euclid's lemma. Suppose p∣ab. If p∣a there is nothing more to prove, so suppose p does not divide a; we show p∣b. By the lemma, px+ay=1 for some integers x and y. Multiplying by b gives

b=p(bx)+(ab)y

Now p divides p(bx), and p divides ab and hence (ab)y. A common divisor of two integers divides their sum, so p∣b. □

The first line of the proof is a technique worth naming. To prove "A or B", assume that A fails and prove B. It is valid because ¬A⇒B is equivalent to A∨B (the previous lessons' rule that P⇒Q is equivalent to ¬P∨Q), and it converts an "or", which gives a proof little to hold, into a hypothesis, ¬A, that the proof can use.

Applied with b=a, Euclid's lemma gives what the irrationality proofs need: if p∣a2, then p∣a. Applied repeatedly, it shows that a prime dividing a product of several integers divides at least one of them. And with that, the proof for 2 goes through for every prime.

Theorem. For every prime p, p is irrational.

Proof. Let p be prime, and suppose, for contradiction, that p=ab with a an integer and b a natural number, where b is the least natural number for which such an a exists. Then a2=pb2, so p∣a2, and by Euclid's lemma p∣a. Write a=pc. Then p2c2=pb2, so b2=pc2, and p∣b2, so p∣b by Euclid's lemma again. Write b=pd, where d is a natural number and d<b because p>1. Then p=pcpd=cd, contradicting the minimality of b. □

Euclid's lemma is also what makes prime factorisation unique: if a number had two different factorisations into primes, a prime from one would divide the product of the other, hence divide one of its factors, hence equal it, and cancelling it would give a smaller counterexample. That argument, and the fundamental theorem of arithmetic it proves, are in the Discrete Mathematics lesson on primes. With unique factorisation the irrationality results extend at once: n is irrational for every natural number n that is not a perfect square, since in a2=nb2 every prime appears to an even power on the left, and some prime appears to an odd power on the right.

The primes never run out

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, itself proved by contradiction.

Lemma. Every integer N>1 has a prime divisor.

Proof. The set of divisors of N that are greater than 1 is a non-empty set of natural numbers, since it contains N, so by the well-ordering principle it has a least element 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. That makes r a divisor of N greater than 1 and smaller than d, contradicting the choice of d. So d is prime. □

The least divisor greater than 1 is always prime: for N=91 it is 7, and for N=30031 it is 59. The argument is another instance of a pattern that the next lesson turns into a method: take the smallest thing that goes wrong, and show that a smaller one would too.

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 lemma 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, so p∣N−p1p2⋯pk, that is, p∣1. But p>1, and no integer greater than 1 divides 1, since a divisor of a non-zero integer is at most its size. This contradiction shows the primes are not finite in number.

The ingredients were all proved earlier: the lemma above, the fact that a common divisor divides a difference, and the size bound for divisors from the previous lesson.

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 by the lemma. 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 for p>1. 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 in number: from any n it produces a prime beyond it, and it is a proof of ∀n∃p(p>n∧pprime), the quantifier form of "infinitely many".

A common retelling of Euclid's proof 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 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, and it needs no contradiction about all the primes at once.

Are there other proofs that the primes never run out?

Many, and several open whole subjects. Here is one that uses only divisibility. The Fermat numbers are Fn=22n+1, so F0=3, F1=5, F2=17, F3=257. Their product satisfies

F0F1⋯Fn−1=Fn−2

because (220−1)F0F1⋯Fn−1 collapses from the left by (x−1)(x+1)=x2−1: (2−1)(2+1)=22−1, then (22−1)(22+1)=24−1, and so on up to 22n−1=Fn−2, while the first factor 220−1 is 1.

Now take m<n and let d be a positive common divisor of Fm and Fn. Then d divides the product F0⋯Fn−1, which contains Fm, and d divides Fn, so d divides their difference, 2. Every Fermat number is odd, so d=1. Two different Fermat numbers therefore share no prime divisor. Each has a prime divisor, so choosing one for each Fermat number gives infinitely many different primes. This argument is usually credited to Christian Goldbach, in correspondence with Euler. It is direct and constructive, and it shows more than Euclid's: there are at least n primes up to Fn−1.

Euler found a proof of a different kind, which showed more still: the sum of the reciprocals of the primes, 12+13+15+17+⋯, grows without bound. A finite set of primes would make that sum finite. His method, which connects primes to the infinite product ∏p(1−1ps)−1, was developed by Dirichlet and Riemann into analytic number theory, and it culminated in the prime number theorem of 1896, proved independently by Jacques Hadamard and Charles de la Vallée Poussin: the number of primes up to x is approximately xlnx. In 1955 Hillel Furstenberg published a proof that uses the language of topology, a curiosity rather than a tool, but a reminder that a theorem this basic can be reached from almost anywhere.

Primes of the form 4k + 3

Every odd prime leaves remainder 1 or 3 on division by 4, and both kinds occur: 5, 13, 17, 29 have the form 4k+1, and 3, 7, 11, 19 have the form 4k+3. Euclid's idea, adapted, shows that the second kind never runs out. The adaptation needs one fact about remainders and one lemma.

The fact: a product of integers of the form 4k+1 has the form 4k+1, since (4s+1)(4t+1)=4(4st+s+t)+1, and a product of several such numbers can be multiplied two at a time.

Lemma. Every positive integer of the form 4k+3 has a prime divisor of the form 4k+3.

Proof. Suppose, for contradiction, that some positive integer of the form 4k+3 has no prime divisor of that form. By the well-ordering principle there is a least such integer; call it m. Then m is not prime, since otherwise it would be its own prime divisor of the form 4k+3. And m≥3, so m=rs with 1<r<m and 1<s<m. Since m is odd, r and s are odd (if either were even, so would be m), so each has the form 4k+1 or 4k+3. They cannot both have the form 4k+1, since then m would too, and by the uniqueness of the remainder m cannot have both forms. So one of them, say r, has the form 4k+3. As r<m, the minimality of m gives r a prime divisor q of the form 4k+3. Then q∣r and r∣m, so q∣m, contradicting the choice of m. □

Theorem. There are infinitely many primes of the form 4k+3.

Proof. Suppose, for contradiction, that there are only finitely many, and list them all as p1,p2,…,pk; the list is not empty, since 3 is on it. Let

N=4p1p2⋯pk−1=4(p1p2⋯pk−1)+3

so N is a positive integer of the form 4k+3. By the lemma, N has a prime divisor q of the form 4k+3. By assumption, q is one of p1,…,pk, so q divides 4p1p2⋯pk. Since q also divides N, it divides the difference 4p1p2⋯pk−N=1, which is impossible for a prime. Hence there are infinitely many primes of the form 4k+3. □

The choice of N is careful. The factor 4 and the −1 make N of the form 4k+3, which is what calls the lemma into play. The more obvious N=p1p2⋯pk+1 might be of either form. With p1=3 and p2=7 the proof builds N=83, which is itself a prime of the form 4k+3. Adding 11 to the list gives N=923=13×71, and 71=4×17+3 is the new prime, as promised, while 13 has the form 4k+1.

Now you. Prove that there are infinitely many primes of the form 6k+5.

Answer

Facts about remainders. By the division algorithm every integer has one of the forms 6k,6k+1,…,6k+5. An integer of the form 6k, 6k+2 or 6k+4 is even, and one of the form 6k+3 is divisible by 3. A product of numbers of the form 6k+1 has that form, since (6s+1)(6t+1)=6(6st+s+t)+1.

Lemma: every positive integer of the form 6k+5 has a prime divisor of that form. Suppose not, and let m be the least positive integer of the form 6k+5 with no prime divisor of that form. Then m is not prime, so m=rs with 1<r,s<m. Now m=2(3k+2)+1 is odd and m=3(2k+1)+2 is not divisible by 3, so neither r nor s is even or divisible by 3 (either would pass to m). Hence each of r and s has the form 6k+1 or 6k+5. They are not both of the form 6k+1, or m would be. So one, say r, has the form 6k+5 and is smaller than m, and it has a prime divisor of that form, which then divides m. This contradicts the choice of m.

Theorem. Suppose there are only finitely many primes of the form 6k+5, listed as p1,…,pk (the list contains 5). Let N=6p1⋯pk−1=6(p1⋯pk−1)+5. By the lemma, N has a prime divisor q of the form 6k+5, which must be some pi and so divides 6p1⋯pk. Then q divides 6p1⋯pk−N=1, which is impossible. So there are infinitely many primes of the form 6k+5.

Why does the same argument fail for primes of the form 4k+1?

Try it. Suppose p1,…,pk are all the primes of the form 4k+1, and let N=4p1⋯pk+1, of the form 4k+1. The argument needs N to have a prime divisor of the form 4k+1, and that is where it breaks: a product of two numbers of the form 4k+3 has the form 4k+1, since (4s+3)(4t+3)=4(4st+3s+3t+2)+1. So a number of the form 4k+1 can have only prime divisors of the other kind. The very first case shows it: with the list {5}, N=21=3×7, and neither factor has the form 4k+1. The lemma has no analogue, and the argument proves nothing.

The theorem is still true, and a different choice of N proves it: take N=(2p1⋯pk)2+1. The missing ingredient is that every odd prime dividing a number of the form x2+1 has the form 4k+1, which follows from Fermat's little theorem (the Discrete Mathematics course proves it in its lesson on Fermat, Euler and RSA). Granting that, a prime divisor of N has the form 4k+1 and is not on the list, since it does not divide N−1.

These are the first cases of a much larger theorem, proved by Peter Gustav Lejeune Dirichlet in 1837: if a and d are positive integers with no common divisor greater than 1, the progression a,a+d,a+2d,… contains infinitely many primes. Euclid-style arguments work only for a few progressions, and Dirichlet's proof needed new tools from analysis, in the tradition that Euler's proof of the infinitude of primes began. It is often counted as the birth of analytic number theory.

The pigeonhole principle

Some existence proofs need no construction at all, only counting. If thirteen people are in a room, two of them were born in the same month. Nobody can say which two without asking, but the claim is certain, because twelve months cannot give thirteen people a month each.

Theorem (the pigeonhole principle). If more than k objects are placed in k boxes, some box contains at least two objects.

Proof. Let n>k objects be placed in k boxes, and suppose, for contradiction, that every box contains at most one. Then the total number of objects is at most 1+1+⋯+1=k, so n≤k, contradicting n>k. □

The proof is really a contrapositive: "if every box holds at most one object, there are at most k objects" is obvious, and the principle is its contrapositive. Stated in the language of the lesson on functions, it says that a function from a set of n elements to a set of k elements, with n>k, cannot be injective: two elements of the first set have the same value.

The principle itself is trivial. The skill lies in choosing the objects and the boxes so that "two objects in one box" says something useful. The proof then names no particular pair, so the argument is non-constructive in the sense of the previous lesson.

Example. Prove that among any five different integers chosen from 1,2,…,8, there are two whose sum is 9.

Make four boxes, one for each pair of numbers summing to 9: {1,8}, {2,7}, {3,6}, {4,5}. Every number from 1 to 8 belongs to exactly one box. Put each of the five chosen numbers in its box. Five numbers in four boxes means, by the pigeonhole principle, that some box receives two of them, and since the chosen numbers are different, they are the two different members of that box. Their sum is 9.

Five is the least number that works: the four numbers 1,2,3,4 contain no two summing to 9. A pigeonhole argument is sharp exactly when the objects can be spread one per box, and checking that is how to tell whether the bound can be improved.

Now you. Let n be a natural number. Prove that among any n+1 integers there are two whose difference is divisible by n.

Answer

By the division algorithm each integer has a remainder on division by n, one of the n values 0,1,…,n−1. Use these remainders as boxes. The n+1 integers go into n boxes, so by the pigeonhole principle two of them, say a and b, have the same remainder r: a=nq+r and b=nq′+r for integers q and q′. Then a−b=n(q−q′), and q−q′ is an integer, so n∣a−b.

The integers need not be different: if two of them are equal, their difference 0 is divisible by n anyway. And n+1 is sharp, since 0,1,…,n−1 are n integers whose differences are all strictly between −n and n and non-zero, so none is divisible by n.

When there are many more objects than boxes, the conclusion strengthens. Write ⌈x⌉ for the ceiling of x, the least integer greater than or equal to x, so ⌈2.1⌉=3 and ⌈3⌉=3.

Theorem (generalised pigeonhole principle). If n objects are placed in k boxes, some box contains at least ⌈nk⌉ objects.

Proof. Suppose, for contradiction, that every box contains at most ⌈nk⌉−1 objects. By the definition of the ceiling, ⌈nk⌉−1<nk, since otherwise ⌈nk⌉−1 would be an integer at least nk and smaller than the least one. So the total number of objects is at most k(⌈nk⌉−1)<k⋅nk=n, contradicting that there are n objects. □

In words: some box holds at least the average number of objects. A hundred people include at least ⌈10012⌉=9 born in the same month. No human head has a million hairs, so the possible numbers of hairs are 0 to 999999, a million boxes, and London has more than eight million inhabitants; so at least ⌈80000011000000⌉=9 Londoners have exactly the same number of hairs on their heads.

The generalised principle proves a result that sounds like it must need a search.

Theorem. In any group of six people, where each pair either know each other or do not, there are three who all know one another or three who are all strangers to one another.

Proof. Pick one person, A. The other five fall into two boxes: those who know A and those who do not. By the generalised principle one box contains at least ⌈52⌉=3 people.

Suppose three people B, C, D all know A. If any two of B, C, D know each other, those two together with A are three people who all know one another. If no two of them know each other, then B, C, D are three mutual strangers. Either way the claim holds.

If instead three people B, C, D are all strangers to A, the same argument with "know" and "do not know" exchanged applies: if two of them are strangers, they and A are three mutual strangers, and otherwise B, C, D all know one another. □

Six is the least number that works. Five people seated at a round table, each knowing exactly their two neighbours, contain no three mutual acquaintances (among any three at a table of five, two are not neighbours) and no three mutual strangers (among any three, two are neighbours). The theorem is the first case of Ramsey theory, named after Frank Ramsey, whose 1930 paper proved that such structure is unavoidable in every large enough system: complete disorder is impossible.

Does the pigeonhole principle hold for infinite sets?

Not in the same form, and the failure is instructive. Put the natural numbers, as objects, into the boxes labelled 2,3,4,… by sending n to box n+1. Every box receives exactly one object, although there are, in the naive sense, more objects than boxes, since the objects include 1 and the boxes do not. So "more objects than boxes forces a shared box" is false for infinite collections, and the reason is that "more" has lost its meaning.

Galileo noticed a version of this in 1638, in his Two New Sciences: the perfect squares 1,4,9,16,… are a small part of the natural numbers, yet they can be paired off with all of them, n with n2. He concluded that "equal", "greater" and "less" do not apply to infinite quantities. Richard Dedekind in 1888 turned the paradox into a definition: a set is infinite exactly when it can be matched one to one with a part of itself. For finite sets the pigeonhole principle says this never happens, and that is the precise sense in which the principle is a fact about finiteness.

One form does survive. If infinitely many objects are placed in finitely many boxes, some box contains infinitely many. Suppose, for contradiction, that every one of the k boxes held only finitely many, say at most m1,…,mk objects. Then there would be at most m1+⋯+mk objects in all, a finite number. This infinite pigeonhole principle is a workhorse of analysis. Applied to a sequence whose terms take only finitely many values, it gives a value taken infinitely often, and so a constant subsequence; refined by repeatedly halving an interval, it proves the theorem of Bolzano and Weierstrass that every bounded sequence of reals has a convergent subsequence.

How to compare the sizes of infinite sets correctly, by matching rather than counting, is the subject of the lesson on countable and uncountable sets, which shows that some infinite sets are genuinely larger than others.

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, such as "is irrational", "there is no largest", "has no solution" or "there are infinitely many", use contradiction, since assuming the positive version hands the proof an object to work on.
  • If the conclusion is an "or", assume that one part fails and prove the other, as in Euclid's lemma.
  • If the claim is that two things must coincide, or that some part must be large, and no particular one is named, look for boxes and count.

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. A proof by contradiction also keeps an assumption in the air that will turn out false, and every line written under it is true only in an impossible world. A reader checking the proof has to keep track of which lines are established facts and which depend on the doomed assumption, and the more lines there are, the harder that becomes.

Methods also combine. A biconditional may have one direction proved directly and the other by contrapositive, as with "n is even if and only if n2 is even". A proof by contradiction may use a contrapositive inside it, as the proof for 3 did. And a proof by cases may use a different method in each case.

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. This is the fake contradiction: a direct proof with a false assumption bolted to the front and a clash with it bolted to the end.

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, as it did with Euclid.

Worse than a disguise is an assumption that is not the negation at all. A proof by contradiction of Q must assume exactly ¬Q, and if it assumes something stronger, the contradiction may come from the extra strength and prove nothing. Here is the pattern at its plainest.

Claim. For every integer n, n2+n is even.

Proof. Suppose, for contradiction, that n2+n is odd for every integer n. Taking n=1 gives 1+1=2 odd, a contradiction.

The claim is true, but this is not a proof of it. The negation of ∀n(n2+nis even) is ∃n(n2+nis odd): one integer where it fails, which the proof must name as an arbitrary unknown, not a universal failure that can be tested at any convenient value. The same "proof" would establish that every integer is prime: suppose every integer is composite; then 2 is composite, a contradiction. The same mistake in words is "suppose a and b are both odd" as the negation of "a and b are both even", when the negation is "at least one of a and b is odd". Before writing "suppose, for contradiction", compute the negation by the rules of the lesson on quantifiers and write it down in full.

The last hazard is the one the previous section warned about: a proof by contradiction that reaches its contradiction by an error. Every false step leads somewhere false, and in a proof by contradiction a false conclusion is the goal, so an algebra slip can look like success. When a contradiction arrives unexpectedly early, or from a line that did not use the assumption, suspect the algebra before celebrating.

What these methods leave open

Several proofs in this lesson ran the same way: take the least natural number with some property, the least denominator for 2, the least divisor greater than 1, the least number of the form 4k+3 without a prime divisor of that form, and show that a smaller one would exist. The engine in each was the well-ordering principle, not the contrapositive or the contradiction around it.

Some claims need that engine and nothing else. 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. A direct argument about an arbitrary n cannot supply that, and neither can the contrapositive or a contradiction on their own: the argument for each n leans on the cases below it, and checking them one by one never ends. The next lesson turns the smallest-counterexample idea into a method of its own, induction, which follows such a chain all the way up, and proves that it and well-ordering are two forms of the same principle.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. For each statement, write its contrapositive (if it is a conditional) and the assumption with which a proof by contradiction would begin. (a) For every integer n, if n2 is odd then n is odd. (b) For all real numbers x and y, if x+y is irrational then x is irrational or y is irrational. (c) There is no largest prime. (d) For every natural number n, if 2n−1 is prime then n is prime.

Solution

(a) Contrapositive: for every integer n, if n is even then n2 is even. Contradiction assumes: there is an integer n with n2 odd and n even.

(b) Contrapositive: for all real x and y, if x and y are both rational then x+y is rational (De Morgan turns "not (x irrational or y irrational)" into "x rational and y rational"). Contradiction assumes: there are real x and y with x+y irrational and both x and y rational.

(c) This is not a conditional, so there is no contrapositive. Contradiction assumes: there is a largest prime, that is, a prime p with q≤p for every prime q.

(d) Contrapositive: for every natural number n, if n is not prime then 2n−1 is not prime. Contradiction assumes: there is a natural number n that is not prime with 2n−1 prime.

In each case the assumption for contradiction is existential: a proof by contradiction of a universal claim assumes one counterexample, not that everything fails.

2. Prove by contrapositive: (a) for every integer n, if 5n+3 is even then n is odd; (b) for all real numbers x and y, if x+y≥2 then x≥1 or y≥1.

Solution

(a) We prove: if n is not odd then 5n+3 is not even. Let n be an integer that is not odd; then n is even, n=2k for some integer k. So 5n+3=10k+3=2(5k+1)+1, which is odd, and hence not even. This proves the contrapositive.

(b) The negation of "x≥1 or y≥1" is "x<1 and y<1", and the negation of "x+y≥2" is "x+y<2". So we prove: if x<1 and y<1 then x+y<2. Let x and y be real numbers with x<1 and y<1. Adding the inequalities gives x+y<2. This proves the contrapositive.

In (b) a direct proof would face an "or" in the conclusion with nothing to decide between its parts; the contrapositive turns it into an "and" in the hypothesis, which can be used at once.

3. (a) A drawer holds 10 black socks and 10 white socks. How many must be taken out in the dark to be sure of a matching pair? To be sure of two black socks? (b) How many people must be in a room to be sure that five of them were born in the same month? (c) Thirty students sit a test marked in whole numbers from 0 to 10. Prove that at least three of them receive the same mark.

Solution

(a) Three socks. With two colours as boxes, three socks put two in one box, which is a matching pair; two socks are not enough, since they may be one of each colour. For two black socks, twelve: in the worst case the first ten drawn are all white, so eleven may contain only one black sock, while twelve socks include at most ten white ones and so at least two black ones.

(b) 49. With twelve months as boxes, 49 people give some month at least ⌈4912⌉=5 people. With 48 people it is possible that exactly four were born in each month, so 48 is not enough.

(c) There are 11 possible marks, 0 to 10. By the generalised pigeonhole principle, some mark is received by at least ⌈3011⌉=3 students, since 3011 lies between 2 and 3.

4. Prove by contradiction: (a) there are no integers m and n with 14m+21n=100; (b) there are no natural numbers x and y with x2−y2=1.

Solution

(a) Suppose, for contradiction, that 14m+21n=100 for some integers m and n. Then 100=7(2m+3n), so 7∣100. But 100=7×14+2, and by the uniqueness of the remainder, the remainder of 100 on division by 7 is 2, not 0. So 7 does not divide 100, a contradiction.

(b) Suppose, for contradiction, that x2−y2=1 for some natural numbers x and y. Then (x−y)(x+y)=1. Here x+y≥2 is a positive integer, so x−y is positive too, since the product is positive; hence x−y≥1, and (x−y)(x+y)≥1×2=2>1, a contradiction.

Core

5. Prove that 6 is irrational, and deduce that 2+3 is irrational.

Hint

For 6, follow the proof for 2, using Euclid's lemma with the prime 2. For the sum, suppose it equals a rational r and square both sides.

Solution

6 is irrational. Suppose, for contradiction, that 6=ab with a an integer and b a natural number, and choose b as small as possible, by the well-ordering principle. Squaring, a2=6b2=2(3b2), so 2∣a2, and by Euclid's lemma 2∣a. Write a=2c. Then 4c2=6b2, so 2c2=3b2. Hence 2∣3b2, and by Euclid's lemma 2∣3 or 2∣b2. The first is false, so 2∣b2, and by Euclid's lemma again 2∣b. Write b=2d with d a natural number smaller than b. Then 6=2c2d=cd, contradicting the minimality of b.

2+3 is irrational. Suppose, for contradiction, that 2+3=r with r rational. Squaring,

r2=2+26+3=5+26

so 6=r2−52. Sums, differences, products and quotients (by non-zero numbers) of rationals are rational, so r2−52 is rational, and therefore 6 is rational, contradicting the first part. Hence 2+3 is irrational.

The sum of two irrationals can be rational (2+(−2)=0), so the second part needed an argument particular to these two numbers; squaring converted it into a statement about 6 alone.

6. Find the flaw in this proof, show that the claim is false, and state and prove a correct claim with the same hypothesis.

Claim. For every integer n, if 4∣n2 then 4∣n.

Proof. We prove the contrapositive. Suppose 4 does not divide n. By the division algorithm, n=4k+r with r equal to 1, 2 or 3. Then n2=16k2+8kr+r2=4(4k2+2kr)+r2, and r2 is 1, 4 or 9, which is not divisible by 4. So n2 is not divisible by 4.

Hint

Check the three values of r2 one at a time.

Solution

The flaw is the claim that none of 1, 4, 9 is divisible by 4: the value r=2 gives r2=4, which is. In that case n2=4(4k2+4k+1) is divisible by 4, and the contrapositive fails. The case split was correct and complete; one case was simply checked wrongly.

The claim is false, and n=2 is a counterexample: 4∣4=22, but 4 does not divide 2. (This is the step that stopped the irrationality proof from "proving" 4 irrational.)

A correct claim: for every integer n, if 4∣n2 then n is even. We prove the contrapositive: if n is not even then 4 does not divide n2. Let n be odd, n=2k+1. Then n2=4k2+4k+1=4(k2+k)+1, so by the uniqueness of the remainder, n2 leaves remainder 1 on division by 4, and 4 does not divide it.

7. Prove or disprove each statement. (a) If p is a prime other than 3, then p2+2 is not prime. (b) Every positive integer of the form 4k+1 has a prime divisor of the form 4k+1.

Hint

For (a), divide by 3. For (b), look back at why the lesson's argument for primes of the form 4k+3 could not be copied.

Solution

(a) True. Let p be a prime with p≠3. Then 3 does not divide p, since the only positive divisors of p are 1 and p, and neither is 3. So p=3k+1 or p=3k+2 for some integer k. In the first case p2+2=9k2+6k+3=3(3k2+2k+1), and in the second p2+2=9k2+12k+6=3(3k2+4k+2). Either way 3∣p2+2. Since p≥2, p2+2≥6>3, so 3 is a divisor of p2+2 strictly between 1 and p2+2, and p2+2 is not prime.

Equivalently, by contrapositive: if p and p2+2 are both prime, then p=3. And p=3 does give a prime, 11.

(b) False. The number 21=4×5+1 has the form 4k+1, and its only prime divisors are 3 and 7, both of the form 4k+3. (The number 1=4×0+1 is an even simpler counterexample, having no prime divisor at all, but 21 shows that the failure is not just a matter of 1.) The reason is that (4s+3)(4t+3) has the form 4k+1.

8. Prove that for every natural number n, if 2n−1 is prime then n is prime. Show that the converse is false.

Hint

Prove the contrapositive. If n=ab, put x=2a and factor xb−1.

Solution

We prove the contrapositive: if n is not prime, then 2n−1 is not prime.

Let n be a natural number that is not prime. If n=1, then 2n−1=1, which is not prime. Otherwise n is composite, so n=ab with 1<a<n and 1<b<n. Put x=2a. Then 2n−1=xb−1, and

xb−1=(x−1)(xb−1+xb−2+⋯+x+1)

since multiplying out the right side, every power xj with 1≤j≤b−1 appears once with each sign and cancels, leaving xb−1. So x−1=2a−1 divides 2n−1. Since a≥2, 2a−1≥3>1, and since a<n, 2a−1<2n−1. So 2n−1 has a divisor strictly between 1 and itself, and is not prime.

The converse, "if n is prime then 2n−1 is prime", is false: 11 is prime, but 211−1=2047=23×89. Primes of the form 2n−1 are called Mersenne primes, after Marin Mersenne, and the problem shows that searching for them only needs to consider prime exponents.

9. Prove that in any group of n≥2 people, where friendship is mutual and nobody counts as their own friend, two people have the same number of friends within the group.

Hint

The possible numbers of friends are 0,1,…,n−1, which is n boxes for n people: one too many. Show that two of these boxes cannot both be occupied.

Solution

Each person has between 0 and n−1 friends in the group. The values 0 and n−1 cannot both occur. For suppose some person A has n−1 friends; then A is a friend of every other person, and since friendship is mutual, every other person has at least one friend, A. So nobody has 0 friends. (And A has n−1≥1 friends, so A does not have 0 either.)

So either every person has between 0 and n−2 friends, or every person has between 1 and n−1 friends. In either case the numbers of friends take at most n−1 values. The n people are placed in at most n−1 boxes by their number of friends, so by the pigeonhole principle two of them are in the same box: they have the same number of friends.

10. Prove that for every natural number n there is a positive multiple of n whose decimal digits are all 0 or 1.

Hint

Consider the n+1 numbers 1,11,111,…, the last with n+1 ones, and their remainders on division by n.

Solution

For j=1,2,…,n+1, let Rj be the number whose decimal representation consists of j ones, so R1=1, R2=11, R3=111. There are n+1 of these numbers and only n possible remainders on division by n, so by the pigeonhole principle two of them, Ri and Rj with i<j, have the same remainder. As in the Now you on the pigeonhole principle, n divides Rj−Ri.

Now Rj−Ri is the number made of j−i ones followed by i zeros: for instance R5−R2=11111−11=11100. In general Rj=Rj−i×10i+Ri, since the first j−i digits of Rj are ones followed by the last i, which form Ri; so Rj−Ri=Rj−i×10i. This is positive, a multiple of n, and every digit is 0 or 1.

For example, with n=7, the remainders of 1,11,111,1111,11111,111111 are 1,4,6,5,2,0, so 111111=7×15873 already works. The proof does not find the multiple, but it guarantees one with at most n+1 digits.

11. Five points are placed in a square of side 2 (inside or on the boundary). Prove that two of them are at distance at most 2 from each other. Show that 2 cannot be replaced by any smaller number.

Hint

Cut the square into four squares of side 1.

Solution

Place the square with corners (0,0) and (2,2), and cut it by the lines x=1 and y=1 into four closed squares of side 1. Every point of the big square lies in at least one small square; assign each of the five points to one small square containing it. Five points in four squares means, by the pigeonhole principle, that two points, (x1,y1) and (x2,y2), are assigned to the same small square.

Both lie in a square of side 1, so |x1−x2|≤1 and |y1−y2|≤1. Their distance is

(x1−x2)2+(y1−y2)2≤1+1=2

To see that 2 is best possible, place the points at the four corners and the centre (1,1). Two corners are at distance at least 2, and the centre is at distance exactly 2 from each corner, so the smallest distance between two of the five points is 2. No smaller number can replace it.

12. Let a, b and c be odd integers. Prove that the equation ax2+bx+c=0 has no rational solution.

Hint

Suppose x=pq with q as small as possible, so that p and q are not both even. Clear denominators and look at the parity of each term.

Solution

Suppose, for contradiction, that x=pq is a solution, with p an integer and q a natural number chosen as small as possible by the well-ordering principle. Then p and q are not both even: if they were, pq=p/2q/2 with the natural number q2 smaller than q.

Multiplying ap2q2+bpq+c=0 by q2 gives

ap2+bpq+cq2=0

There are three cases, using that a product of integers is odd exactly when every factor is odd, and that a sum of three integers is odd when one or three of them are odd.

If p and q are both odd, then ap2, bpq and cq2 are all odd, and their sum is odd.

If p is even and q odd, then ap2 and bpq are even and cq2 is odd, so the sum is odd.

If p is odd and q even, then ap2 is odd and bpq and cq2 are even, so the sum is odd.

In every case ap2+bpq+cq2 is odd, but it equals 0, which is even, and no integer is both. This contradiction shows that no rational number is a solution.

The discriminant gives a check in an example: x2+x+1=0 has no real solution at all, but x2+3x+1=0 has the real solutions −3±52, and the problem shows, without computing them, that they are irrational.

Challenge

13. Prove that for every natural number n≥2, the number 1+12+13+⋯+1n is not an integer.

Hint

Let 2k be the largest power of 2 that is at most n. Show that 2k is the only number from 1 to n divisible by 2k. Then multiply the sum by 2k−1 times the product of the odd numbers up to n, and look at which terms become integers.

Solution

Let n≥2 and write H=1+12+⋯+1n. Let 2k be the largest power of 2 with 2k≤n; then k≥1, since 2≤n, and 2k+1>n.

Step 1: among 1,2,…,n, only 2k is divisible by 2k. Every i from 1 to n can be written i=2jo with j≥0 and o odd (divide out factors of 2 until an odd number remains; the process stops because the numbers decrease). If j≥k+1, then i≥2k+1>n, which is impossible, so j≤k. If j=k and o≥3, then i≥3×2k>2k+1>n, again impossible. So j=k only for i=2k, and every other i≤n has j≤k−1.

Step 2: clear most denominators. Let m be the product of all the odd numbers from 1 to n, which is odd, and let M=2k−1m, an integer since k≥1. For each i≤n with i≠2k, write i=2jo as above, with j≤k−1. The odd number o is at most n, so it is one of the factors of m, and

Mi=2k−1−j⋅mo

is an integer. For i=2k, however, M2k=m2, which is not an integer, because m is odd.

Step 3: the contradiction. Suppose, for contradiction, that H is an integer. Then MH is an integer. But

MH=∑i≠2kMi+m2

where the sum is an integer, say S, by Step 2. So m2=MH−S is an integer, and m is even, contradicting that m is a product of odd numbers. Hence H is not an integer.

For example, with n=6, k=2, m=1×3×5=15 and M=30, and 30H=30+15+10+7.5+6+5=73.5: every term is an integer except the one from 14.

14. Prove that every sequence of n2+1 different real numbers contains an increasing subsequence of length n+1 or a decreasing subsequence of length n+1. Show that n2+1 cannot be replaced by n2.

Hint

Label each term with a pair of numbers: the length of the longest increasing subsequence that starts at that term, and the length of the longest decreasing one. If the claim failed, how many different labels would there be?

Solution

Let a1,a2,…,an2+1 be different real numbers. A subsequence is a choice of terms ai1,ai2,…,air with i1<i2<⋯<ir, kept in order; it is increasing if ai1<ai2<⋯<air and decreasing if the inequalities are reversed. For each position i, let ui be the length of the longest increasing subsequence that starts with ai, and di the length of the longest decreasing subsequence that starts with ai. Both are at least 1, since ai alone is such a subsequence.

Suppose, for contradiction, that there is no increasing and no decreasing subsequence of length n+1. Then 1≤ui≤n and 1≤di≤n for every i, so each pair (ui,di) is one of the n2 pairs of numbers from 1 to n. There are n2+1 positions, so by the pigeonhole principle two positions i<j have the same pair: ui=uj and di=dj.

Since the terms are different, ai<aj or ai>aj. If ai<aj, put ai in front of a longest increasing subsequence starting with aj. Since i<j and ai<aj, the result is an increasing subsequence starting with ai, of length uj+1, so ui≥uj+1>uj, contradicting ui=uj. If ai>aj, the same argument with a longest decreasing subsequence starting at aj gives di≥dj+1, contradicting di=dj. Either way we have a contradiction, which proves the claim.

For the sharpness, arrange 1,2,…,n2 in n blocks, each block decreasing and each block entirely above the one before:

n,n−1,…,1,2n,2n−1,…,n+1,…,n2,n2−1,…,n2−n+1

An increasing subsequence can take at most one term from each block, since each block decreases, so it has length at most n. A decreasing subsequence cannot use two blocks, since every term of a later block is larger than every term of an earlier one, so it has length at most n. For n=2 this is the sequence 2,1,4,3.

The theorem was proved by Paul Erdős and George Szekeres in 1935. It is a typical pigeonhole argument in that the boxes are not visible in the problem: the labels (ui,di) had to be invented.

15. Prove that any set of ten different two-digit numbers (integers from 10 to 99) contains two disjoint non-empty subsets with the same sum.

Hint

Count the non-empty subsets, and count the possible sums. Then make two subsets with equal sums disjoint without changing the fact that their sums are equal.

Solution

Let X be a set of ten different two-digit numbers. A set of ten elements has 210=1024 subsets, of which 1023 are non-empty. The sum of a non-empty subset is at least 10 and at most the sum of all ten elements, which is less than 10×100=1000. So the sums of the non-empty subsets lie among the integers from 10 to 999, which are 990 values. Since 1023>990, the pigeonhole principle gives two different non-empty subsets A and B of X with the same sum.

Now remove their common elements: let A′=A∖B and B′=B∖A, the elements of A not in B and the elements of B not in A. They are disjoint, and removing the same elements, those of A∩B, from both subsets reduces both sums by the same amount, so A′ and B′ still have equal sums.

It remains to check that neither is empty. Suppose, for contradiction, that A′ is empty. Then every element of A is in B, and since A≠B, B has some element not in A. Every element of X is positive, so the sum of B exceeds the sum of A, contradicting that the sums are equal. So A′ is not empty, and by the same argument with A and B exchanged neither is B′.

This was Problem 1 of the International Mathematical Olympiad of 1972. The count shows that the argument has room to spare; it works for any ten positive integers below 100, and the actual sums are never found.

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 that neither method finishes: 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, and to finish, the argument needs the claim for a and b first. This lesson gives the method for such chains and proves it valid. It then puts the method to work on sums, inequalities and divisibility, on sequences defined by recursion, on claims that only yield once they are strengthened, and finally on objects that are not numbers at all. Throughout, ℕ={1,2,3,…} starts 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 of induction

For each natural number n let P(n) be a statement, such as "1+2+⋯+n=n(n+1)2". In the language of the lesson on quantifiers, P is an open sentence with domain ℕ, and the goal is ∀n∈ℕP(n).

The principle of induction. Let P(n) be a statement for each natural number n. If P(1) is true, and P(n)⇒P(n+1) is true for every natural number n, then P(n) is true for every natural number n.

The two hypotheses have names. Proving P(1) is the base case. Proving ∀n∈ℕ(P(n)⇒P(n+1)) is the inductive step, and inside it the assumption P(n) is the inductive hypothesis. The step is an ordinary universal conditional, and it is proved the way the lesson on direct proof proved every such statement: let n be an arbitrary natural number, assume P(n), and derive P(n+1).

Why should the two together reach every n? The base case gives P(1). The step with n=1 gives P(1)⇒P(2), so P(2). The step with n=2 gives P(3), and so on. For any one number, say 1000, a chain of 999 applications of the step reaches it, and the chain is finite. What no finite chain can do is reach every n at once, and that is what the principle adds. The usual picture is a line of dominoes: the base case knocks over the first, the step guarantees that each falling domino knocks over the next, and so every domino falls, however long the line.

A first reaction to the step is that it assumes what it is meant to prove. It does not. The goal is the universal statement "P(n) for every n". The step assumes P(n) for one arbitrary n, as the hypothesis of a conditional, and shows only that P(n+1) would follow. It never claims that P(n) is true. Someone with no idea whether P(5) holds can still prove "if P(5) then P(6)". Assuming P(n) for a single arbitrary n is legitimate; assuming P(n) for every n would be circular, and the difference between those two is the difference between an induction and a fraud.

A written proof by induction has a standard shape, and it pays to keep to it until the method is second nature. State P(n) in full. Prove the base case P(1), usually by computing both sides. For the step, write "let n be a natural number and suppose P(n)", then write out P(n+1) explicitly as the target, and derive it, marking the line where the inductive hypothesis is used. Finish with "by induction, P(n) holds for every natural number n".

Both halves are needed, and a claim can pass one 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 that 2 is odd, which is false, and in fact n2+n=n(n+1) is even for every n. The step was a true conditional whose hypothesis never holds. In the other direction, a base case with no step is a single example, and the first lesson showed where examples lead: n2+n+41 is prime for n=0,1,…,39 and not for n=40.

Sums

Sums are where induction is first met, and the notation for them is worth fixing. For numbers a1,a2,…,an,

∑k=1nak=a1+a2+⋯+an

read "the sum of ak for k from 1 to n". The letter k is a dummy: ∑k=1nk2 and ∑j=1nj2 are the same number. The one property of the notation an induction uses is

∑k=1n+1ak=∑k=1nak+an+1

which says that the sum up to n+1 is the sum up to n with one more term added. A later section makes this the definition.

A story told of Carl Friedrich Gauss as a schoolboy has him adding 1+2+⋯+100 in pairs from the outside in: 1+100, 2+99, and so on, fifty pairs of 101, so 5050. The same pairing suggests a formula for every n, and induction proves it.

Example. Prove that ∑k=1nk=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 of P(1) is 1 and the right side is 1×22=1, so P(1) holds.

For the step, let n be a natural number and suppose 1+2+⋯+n=n(n+1)2. The target is P(n+1), which reads 1+2+⋯+(n+1)=(n+1)(n+2)2. Adding n+1 to both sides of the inductive hypothesis,

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

which is the target, so P(n+1) holds. By induction, the formula holds for every natural number n.

Writing the target before the algebra is what made the last step obvious: once (n+1)(n+2)2 was on the page, the factor n+1 was the thing to pull out. Without a target, a step of this kind tends to expand everything and then struggle to recognise the result.

Now you. Prove that ∑k=1nk2=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, let n be a natural number and suppose P(n). The target is ∑k=1n+1k2=(n+1)(n+2)(2n+3)6, since 2(n+1)+1=2n+3. Adding (n+1)2 to both sides of the inductive hypothesis, the right side becomes

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

which is the target. So P(n+1) holds, and by induction the formula holds for every n. As a check, n=3 gives 1+4+9=14 and 3×4×76=14.

Induction checks a formula; it does not find one. The usual route is a guess from small cases. The sums 1, 1+3=4, 1+3+5=9 and 1+3+5+7=16 suggest that the first n odd numbers add up to n2, and then the step is one line, n2+(2n+1)=(n+1)2. The guess has to be exact before induction can touch it. "The sum of the first n odd numbers is a perfect square" is true, but as an inductive hypothesis it is useless, since knowing that some sum is some square says nothing about which square, and so nothing about the next sum. The sharper claim, that the square is n2, is the one that carries itself from n to n+1. That observation returns, in a stronger form, later in the lesson.

How is a formula like the sum of squares found in the first place?

One way is to make the sum collapse. For any numbers b1,b2,…,bn+1,

∑k=1n(bk+1−bk)=bn+1−b1

because each bk in the middle is added once and subtracted once. (A careful proof of this "telescoping" is itself a one-line induction.) So a sum can be evaluated whenever its terms can be written as differences. Take bk=k3. Then (k+1)3−k3=3k2+3k+1, and summing from k=1 to n gives

(n+1)3−1=3∑k=1nk2+3⋅n(n+1)2+n

using the formula for ∑k already proved. Solve for the unknown sum:

3∑k=1nk2=(n+1)3−(n+1)−3n(n+1)2=(n+1)(n2+2n−3n2)=n(n+1)(2n+1)2

and dividing by 3 gives the formula of the Now you. This is a derivation, not a guess, so strictly it needs no separate induction; but the telescoping identity it rests on is an induction, so induction is there either way.

A second way uses the shape of the answer. Summing a polynomial of degree d gives a polynomial of degree d+1 (the same telescoping argument, with bk=kd+1, shows this by induction on d). So ∑k=1nk2 is an3+bn2+cn+e for some constants, and the four values 0, 1, 5, 14 at n=0,1,2,3 determine them. Solving gives a=13, b=12, c=16, e=0, which is the formula again.

Repeating the first method with bk=k4, k5 and so on gives ∑k3, ∑k4, one after another. Jakob Bernoulli found the general pattern, published in his Ars Conjectandi in 1713, and the coefficients that appear in it are still called the Bernoulli numbers.

Why induction works

The lesson on direct proof took one property of ℕ as basic and used it to prove the division algorithm.

The well-ordering principle. Every non-empty set of natural numbers has a least element.

It fails for the integers, which have no least element, and for the positive rationals, since half of any positive rational is a smaller one. It is a fact about how ℕ is built, and induction follows from it.

Theorem. The well-ordering principle implies the principle of induction.

Proof. Suppose P(1) is true and P(n)⇒P(n+1) for every natural number n, and suppose, for contradiction, that P(n) is false for some natural number n. Then the set F of natural numbers n for which P(n) is false is non-empty, so by well-ordering it has a least element 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 element of F, the number m−1 is not in F, so P(m−1) is true. The inductive step with n=m−1 then gives P(m), contradicting m∈F. So F is empty, and P(n) holds for every n. □

The shape of this proof is worth keeping. A first failure would need a predecessor that succeeds, and the step forbids exactly that. The same shape gives another way to write any induction, the smallest counterexample argument: suppose the claim fails somewhere, take the least n where it fails, and derive a contradiction, usually by finding a smaller failure. Here it is on a fact the previous lesson proved in just this way, for Euclid's proof that the primes never run out.

Proposition. Every integer n≥2 has a prime divisor.

Proof. Suppose not, and let m be the least integer m≥2 with no prime divisor; it exists by well-ordering. Then m is not prime, since a prime divides itself. So m=ab for integers a and b with 1<a<m. As 2≤a<m and m is the least counterexample, a has a prime divisor p. Then p∣a and a∣m, so p∣m by transitivity of divisibility, and m has a prime divisor after all. This contradiction proves the proposition. □

Well-ordering was stated for sets of natural numbers, and the proof applied it to a set of integers that are at least 2. That is harmless: such a set is a set of natural numbers. More generally, a non-empty set of integers that are all at least some fixed integer n0 has a least element, by shifting every member by 1−n0, taking the least element of the resulting set of natural numbers, and shifting back.

Is induction a theorem or an axiom?

The theorem above derived induction from well-ordering, and a later section derives well-ordering from induction. Neither derivation starts from nothing: each assumes the other, or something equivalent. So one of them has to be taken as a basic truth about ℕ, and which one is a matter of taste. This course took well-ordering; most axiomatic treatments take induction.

The standard axioms are due to Richard Dedekind, in his 1888 essay Was sind und was sollen die Zahlen? ("What are numbers and what should they be?"), and Giuseppe Peano, whose 1889 Arithmetices principia set them out in the form now called the Peano axioms. In modern dress they say: 1 is a natural number; every natural number n has a successor n+1, which is a natural number; 1 is not the successor of anything; different numbers have different successors; and any set that contains 1 and contains the successor of each of its members contains every natural number. The last axiom is the principle of induction, stated for sets instead of statements (take the set of n for which P(n) holds).

The first four axioms do not imply the fifth. They are all true of a structure made of ℕ together with a second, separate chain …,c−1,c0,c1,… in which the successor of ci is ci+1: every element has exactly one successor, different elements have different successors, and 1 is still no one's successor. But the set ℕ itself contains 1 and is closed under successors, and it leaves out every ci. The induction axiom is precisely what rules such extra chains out. It says that the natural numbers are the things reachable from 1 by adding 1 finitely many times, and nothing else.

That is also why induction is not a law of logic. Logic alone, from P(1) and ∀n(P(n)⇒P(n+1)), derives P(2), P(3) and each particular P(n) in finitely many steps, but never ∀nP(n), because the structure with the extra chain satisfies the premises and not the conclusion. The Logic course makes this point formally in its lesson on proof technique. The name "mathematical induction", for the method as a whole, was given by Augustus De Morgan in 1838.

Other starting points, and inequalities

Nothing forces the base case to be 1.

Induction from n0. Let n0 be an integer and let P(n) be a statement for each integer n≥n0. If P(n0) is true, and P(n)⇒P(n+1) for every integer n≥n0, then P(n) is true for every integer n≥n0.

Proof. Apply the ordinary principle to Q(k)=P(n0+k−1) for k∈ℕ. Then Q(1) is P(n0), and Q(k)⇒Q(k+1) is the step for n=n0+k−1≥n0. So Q(k) holds for every natural number k, which says P(n) holds for every integer n≥n0. □

A start at n0=0 is common, for sums that begin at k=0 and for statements about sets with n elements, where the empty set is the natural first case. A later start is what many inequalities need. Compare 2n with n2: for n=1,2,3,4 the values are 2>1, 4=4, 8<9 and 16=16. From n=5, where 32>25, the power of two pulls ahead and stays there.

Claim. 2n>n2 for every integer n≥5.

Proof. For the base case, 25=32>25=52. For the step, let n≥5 and suppose 2n>n2. The target is 2n+1>(n+1)2. By the hypothesis, 2n+1=2×2n>2n2, so it is enough 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 used n≥5 only to get n2>2n+1, which holds for every n≥3. So the step is valid from n=3 on, and yet the claim is false at n=3 and n=4. There is no contradiction: a true conditional says nothing when its hypothesis is false, and P(3) is false, so P(3)⇒P(4) is true and useless. The chain starts only where a base case has been checked.

Inequality steps have a common pattern, visible above. The hypothesis gives a bound for the new quantity (here 2n+1>2n2), and what remains is to compare that bound with the target (here 2n2≥(n+1)2). That leftover comparison usually involves no induction at all, and it is where the condition on n gets used. Finding it is most of the work.

Example. Prove Bernoulli's inequality: for every real number x≥−1 and every natural number n, (1+x)n≥1+nx.

There are two variables, and the induction is on n alone. Fix a real number x≥−1, and let P(n) be the statement (1+x)n≥1+nx.

For the base case, (1+x)1=1+x=1+1⋅x, so P(1) holds with equality.

For the step, let n be a natural number and suppose (1+x)n≥1+nx. The target is (1+x)n+1≥1+(n+1)x. Since x≥−1, the number 1+x is non-negative, and multiplying both sides of an inequality by a non-negative number keeps its direction. So

(1+x)n+1=(1+x)n(1+x)≥(1+nx)(1+x)=1+(n+1)x+nx2≥1+(n+1)x

where the last step uses nx2≥0. So P(n+1) holds. By induction, P(n) holds for every n, and since x≥−1 was arbitrary, the inequality holds for all such x.

The hypothesis x≥−1 was used exactly once, to multiply through by 1+x, and it cannot be dropped: at x=−4 and n=3, the left side is (−3)3=−27 and the right side is 1−12=−11. The inequality is crude but strong enough for a striking conclusion. With x=0.01 it gives 1.01n≥1+n100, so 1.01100000≥1001, and in general a growth factor above 1, however slightly above, eventually exceeds any bound. That fact returns in the lesson on limits.

Now you. Prove that n!>2n for every integer n≥4, where n!=1×2×⋯×n. Check that the claim is false for n=1,2,3, and say for which n the step is valid.

Answer

Let P(n) be n!>2n. For the base case, 4!=24>16=24.

For the step, let n≥4 and suppose n!>2n. The target is (n+1)!>2n+1. Now (n+1)!=(n+1)⋅n!>(n+1)⋅2n, using the hypothesis and n+1>0. Since n+1≥2, (n+1)⋅2n≥2⋅2n=2n+1. So (n+1)!>2n+1, and by induction the claim holds for every n≥4.

For small n: 1!=1<2, 2!=2<4 and 3!=6<8, so the claim is false at 1, 2 and 3. The step used only n+1≥2, so it is valid for every n≥1. As with 2n>n2, the base case, not the step, decides where the claim starts.

Divisibility

For a claim of the form d∣f(n), the step has a characteristic move: write f(n+1) as a multiple of f(n) plus something visibly divisible by d. Then the hypothesis takes care of the first part and algebra takes care of the second.

Claim. 3∣n3−n for every natural number n.

Proof. For the base case, 13−1=0=3×0. For the step, suppose 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), a product of three consecutive integers, one of which is a multiple of 3 by the division algorithm, gives a shorter proof, and one that covers negative n as well. The merit of induction is that it needs no such insight, only the algebra of one step. When the expression has a power with n in the exponent, the useful split is usually different: factor out the base of the power.

Example. Prove that 9∣4n+6n−1 for every natural number n.

Let P(n) be the statement 9∣4n+6n−1. For the base case, 4+6−1=9, which is divisible by 9.

For the step, let n be a natural number and suppose 4n+6n−1=9k for some integer k. The target is 9∣4n+1+6(n+1)−1. The term 4n+1 is 4×4n, so aim to produce 4 copies of the old expression:

4n+1+6n+5=4(4n+6n−1)−24n+4+6n+5=4(4n+6n−1)−18n+9

The right side is 4×9k−9(2n−1)=9(4k−2n+1), and 4k−2n+1 is an integer, so P(n+1) holds. By induction, 9∣4n+6n−1 for every natural number n.

The bookkeeping line is the only idea: after writing 4n+1=4×4n, add and subtract whatever makes 4 times the old expression appear, and check that what is left over is divisible by 9. For n=2 and n=3 the numbers are 16+12−1=27 and 64+18−1=81.

Now you. Prove that 64∣9n−8n−1 for every natural number n.

Answer

Let P(n) be the statement. For the base case, 9−8−1=0=64×0.

For the step, let n be a natural number and suppose 9n−8n−1=64k for some integer k. Then

9n+1−8(n+1)−1=9(9n−8n−1)+72n+9−8n−9=9×64k+64n=64(9k+n)

and 9k+n is an integer, so P(n+1) holds. By induction, 64∣9n−8n−1 for every natural number n. For n=2 the number is 81−17=64, and for n=3 it is 729−25=704=64×11.

Induction also gives a second proof of a fact that the lesson on direct proof derived from the division algorithm: every integer is even or odd. Let P(n) be "n is even or n is odd". The base case holds since 1=2×0+1 is odd. For the step, if n=2k then n+1=2k+1 is odd, and if n=2k+1 then n+1=2(k+1) is even, so P(n+1) holds in either case. That covers ℕ. For the other integers, 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. This proof needs only the definitions and induction, where the division algorithm needed well-ordering, and a later section shows that those two are one principle in different forms.

All horses are one colour

Here is a proof by induction of something false. It is worth taking apart slowly, because the error in it is the most common error in real inductions.

Claim. In any group of n horses, all the horses are the same colour.

Proof. Let P(n) be the claim for groups of n horses. For the base case, a group of one horse is one colour. For the step, suppose 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 the inductive 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, every group of horses is one colour.

The base case is fine, so the step must fail for some n. The step claims to prove P(n)⇒P(n+1) for every n≥1, so try the smallest, n=1, going from one horse to two, A and B. Removing the last horse leaves {A} and removing the first leaves {B}, and each is trivially one colour. The horses "in the middle", 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 two groups overlap in n−1≥1 horses, and the step is correct: P(2)⇒P(3) is a true conditional, and so are all the later links. The chain fails at exactly one link, the first, and that is enough, because P(2) is false and every later domino waits on it. The argument hid an assumption about n, that there is at least one horse in the middle, and the remedy is mechanical: run the step by hand at the smallest value it must cover. A step that is valid only for n≥2 needs base cases up to 2, and here P(2) cannot be proved, because it is false.

Two other failures are worth knowing by sight. The first is a step of the wrong size. From P(1) and P(n)⇒P(n+2) follow P(3), P(5), P(7) and so on, and nothing at all about even n. A step that jumps by more than 1 needs as many base cases as the size of the jump, one to start each chain; the section on strong induction does exactly this.

The second is building up instead of cutting down. A step should start from an arbitrary object of size n+1 and reduce it to objects of size n, as the horse argument (correctly, in this respect) did. The tempting alternative starts from an object of size n, for which P(n) holds, and enlarges it by one; but that proves the claim only for those objects of size n+1 that arise by enlarging, and there may be others. In graph theory, where objects are grown one vertex or edge at a time, this "build-up error" produces convincing false proofs, and the cure is always the same: begin the step with an arbitrary object of the larger size.

Strong induction

Some steps need more than the case just before. To show that 60 is a product of primes, knowing that 59 is one is no help at all; what helps is that 60=6×10 and that 6 and 10 are products of primes. Strong induction lets the step assume every earlier case, not only the last.

The principle of strong induction. Let P(n) be a statement for each natural number n. If P(1) is true, and for every natural number n the truth of all of P(1),P(2),…,P(n) implies P(n+1), then P(n) is true for every natural number n.

Despite the name, it is no stronger than ordinary induction.

Theorem. The principle of induction implies the principle of strong induction.

Proof. Suppose P(1) holds and the strong step holds. Let Q(n) be the statement "P(1),P(2),…,P(n) are all true", and apply ordinary induction to Q. The base case Q(1) is P(1), which is true. For the step, suppose Q(n). Then P(1) to P(n) are all true, so the strong step gives P(n+1), and together these say Q(n+1). By induction, Q(n) holds for every n, and in particular P(n) holds for every n. □

As with ordinary induction, the start can be any integer n0: the step for n+1 may then assume P(k) for every k with n0≤k≤n.

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. Let P(n) be "n is a product of primes".

For the base case, 2 is prime, so it is a product of one prime.

For the step, let n≥2 and suppose 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, since n+1≥2 and is not prime, n+1=ab for integers a and b with 1<a<n+1 and 1<b<n+1. So 2≤a≤n and 2≤b≤n, and by the inductive hypothesis each of a and b is a product of primes. Writing the two products side by side expresses n+1=ab as a product of primes. So P(n+1) holds, and by strong induction every integer n≥2 is a product of primes.

This is the existence half of the fundamental theorem of arithmetic. The other half, that the factorisation is unique apart from the order of the factors, is a separate and harder theorem: it needs Euclid's lemma from the previous lesson, that a prime dividing a product divides one of the factors, and it is proved in the Discrete Mathematics lesson on primes. That lesson also shows a number system, the even numbers, in which the existence proof above goes through word for word and uniqueness fails, which is the best evidence that uniqueness is not a formality.

Now you. Prove that every integer n≥8 can be written as 3a+5b with a and b non-negative integers. (Think of paying n pence exactly with 3p and 5p stamps.) Show that 7 cannot be written this way.

Answer

Let P(n) be "n=3a+5b for some non-negative integers a and b". We use strong induction starting at 8, with three base cases, because the step reaches back three places.

Base cases: 8=3+5, 9=3+3+3 and 10=5+5, so P(8), P(9) and P(10) hold.

Step: let n≥10 and suppose P(k) for every k with 8≤k≤n. Then n+1≥11, so k=n−2 satisfies 8≤k≤n, and by the hypothesis n−2=3a+5b with a,b≥0. So n+1=3(a+1)+5b, with a+1 and b non-negative, and P(n+1) holds. By strong induction, P(n) holds for every n≥8.

The step starts at n=10, not 8, because for n+1=9 or 10 the number n−2 would be 7 or 8, and 7 is below the start. That is why 9 and 10 had to be base cases.

For 7: if 7=3a+5b with a,b≥0, then b≤1. If b=0 then 3a=7, and if b=1 then 3a=2, and neither has an integer solution. So 7 cannot be written, and the start at 8 cannot be lowered.

The number of base cases is set by the step, not by taste. Count how far back the step reaches (here 3 places), and check by hand every case the step cannot produce from an earlier one. In the Now you, those were 8, 9 and 10. The answer's 7 is not an accident: for stamps of a and b pence with no common factor greater than 1, the largest amount that cannot be paid exactly is ab−a−b, here 15−3−5=7, a result usually credited to James Joseph Sylvester.

Ordinary induction could have done the stamps, with a less natural step: go from n to n+1 by trading a 5p stamp for two 3p stamps when there is one, and three 3p stamps for two 5p stamps otherwise (possible since n≥8 forces at least three 3p stamps when there is no 5p stamp). Strong induction is not more powerful, as the theorem showed, but it lets the step reach for whichever earlier case is useful, and that is often the difference between an easy proof and a clever one.

Recursive definitions and the Fibonacci numbers

Induction proves statements about every natural number. Its partner, recursion, defines objects for every natural number, in the same two parts: a starting value, and a rule that gives each next value from the earlier ones. Many familiar objects are defined this way, even when school presented them otherwise.

For a real number a, the powers are defined by a0=1 and an+1=an⋅a for every integer n≥0. Factorials are defined by 0!=1 and (n+1)!=(n+1)⋅n!, which gives 1!=1, 2!=2, 3!=6, 4!=24. Sums are defined by ∑k=11ak=a1 and ∑k=1n+1ak=∑k=1nak+an+1, which is why "add the next term to both sides" was the natural move in every sum above. The dots in a1+a2+⋯+an are an informal abbreviation of this definition.

A property of a recursively defined object is proved by induction, and the proof's step follows the definition's step. Here is a law of exponents, the kind of rule school takes for granted.

Proposition. For every real number a and all integers m,n≥0, am+n=aman.

Proof. Fix a and m, and induct on n from n0=0. For n=0, am+0=am=am⋅1=ama0. For the step, suppose am+n=aman. Then, using the definition twice and the hypothesis once,

am+(n+1)=a(m+n)+1=am+n⋅a=aman⋅a=aman+1

So the law holds for n+1, and by induction for every n≥0. □

Why does a recursive definition define anything?

The definition of n! says what 0! is and how to get (n+1)! from n!. It is tempting to say "so n! is defined for every n, by induction", but induction proves statements about objects that already exist, and here the object is what is in question. The precise result is the recursion theorem, proved by Dedekind in his 1888 essay: given a set X, an element c of X, and a rule g that gives an element g(n,x) of X for each natural number n and each x in X, there is exactly one sequence a1,a2,a3,… of elements of X with a1=c and an+1=g(n,an) for every n.

Uniqueness is an ordinary induction. If a and b are two such sequences, then a1=c=b1, and if an=bn then an+1=g(n,an)=g(n,bn)=bn+1. So an=bn for every n. Existence takes more care: one proves by induction that for each n there is exactly one finite list a1,…,an obeying the rules up to n, checks that these lists agree wherever they overlap, and glues them into one infinite sequence. Doing that rigorously needs a sequence to be an object, a function from ℕ to X in the sense of the lesson on functions.

The theorem needs the rule to run from earlier values to later ones, and a "definition" that does not can fail in both possible ways. The condition f(n)=f(n+1) for every n is satisfied by every constant sequence, so it defines nothing in particular. The condition f(n)=f(n+1)+1 for every n, with values in ℕ, is satisfied by nothing: it would make f(1)>f(2)>f(3)>⋯, and the set of these values would have no least element, against well-ordering.

And sometimes nobody knows. Let T(1)=0, and for n>1 let T(n)=1+T(n2) when n is even and T(n)=1+T(3n+1) when n is odd. Then T(n) counts the steps the process "halve if even, otherwise triple and add one" takes to reach 1. From 3 the process runs 3,10,5,16,8,4,2,1, so T(3)=7, and from 27 it takes 111 steps, climbing as high as 9232 on the way. Whether T(n) is defined for every n, that is, whether every starting number eventually reaches 1, is the Collatz conjecture, posed by Lothar Collatz in 1937 and still open. The rule for odd n calls on the larger number 3n+1, so the recursion theorem does not apply, and no substitute for it has been found.

The most famous recursive sequence has a two-step rule. The Fibonacci numbers are defined by

F1=1,F2=1,Fn+2=Fn+1+Fnfor every n≥1

so the sequence runs 1,1,2,3,5,8,13,21,34,55,89,144,…, each term the sum of the two before. They are named after Leonardo of Pisa, called Fibonacci, whose Liber Abaci of 1202 counted pairs of breeding rabbits with them. Because the rule reaches back two places, proofs about them are typically strong inductions with two base cases.

For instance, Fn<2n for every n. The base cases are F1=1<2 and F2=1<4. For the step, let n≥2 and suppose Fk<2k for every k≤n. Then Fn+1=Fn+Fn−1<2n+2n−1<2n+2n=2n+1. The step starts at n=2 because at n=1 it would call on F0, which the definition does not provide, so F2 has to be checked by hand.

The bound is generous: F30=832040 against 230=1073741824. The true growth rate comes from the number φ=1+52≈1.618, which satisfies φ2=φ+1. The same two-base induction shows φn−2≤Fn≤φn−1 for every n: the bases are φ−1≤1≤1 and 1≤1≤φ, and for the step, φn−2+φn−3=φn−3(φ+1)=φn−1, and in the same way φn−1+φn−2=φn. So the Fibonacci numbers grow like powers of φ, and the Discrete Mathematics lesson on linear recurrences derives the exact formula, Fn=φn−ψn5 with ψ=1−52.

Identities between Fibonacci numbers are a good training ground, because the recursion is the only tool and the step has to be found in it.

Example. Prove that F1+F2+⋯+Fn=Fn+2−1 for every natural number n.

Let P(n) be the statement ∑k=1nFk=Fn+2−1. For the base case, the left side is F1=1 and the right side is F3−1=2−1=1.

For the step, let n be a natural number and suppose ∑k=1nFk=Fn+2−1. The target is ∑k=1n+1Fk=Fn+3−1. By the definition of the sum, the hypothesis, and then the Fibonacci rule,

∑k=1n+1Fk=∑k=1nFk+Fn+1=Fn+2−1+Fn+1=Fn+3−1

So P(n+1) holds, and by induction the identity holds for every n. As a check, 1+1+2+3+5=12=F7−1=13−1.

Only one earlier case was needed, so this was an ordinary induction; the two-place reach of the Fibonacci rule was absorbed by the two Fibonacci numbers already present in the hypothesis.

Now you. Prove that F12+F22+⋯+Fn2=FnFn+1 for every natural number n.

Answer

Let P(n) be the statement ∑k=1nFk2=FnFn+1. For the base case, F12=1=F1F2.

For the step, let n be a natural number and suppose ∑k=1nFk2=FnFn+1. The target is ∑k=1n+1Fk2=Fn+1Fn+2. Now

∑k=1n+1Fk2=FnFn+1+Fn+12=Fn+1(Fn+Fn+1)=Fn+1Fn+2

using the hypothesis, then factoring out Fn+1, then the Fibonacci rule. So P(n+1) holds, and by induction the identity holds for every n.

The identity has a picture. Squares of sides 1,1,2,3,5,…,Fn, each placed against the long side of the rectangle formed by the ones before, fill an Fn by Fn+1 rectangle exactly; for n=5, the areas 1+1+4+9+25=40=5×8.

Loading the induction

Sometimes a true statement cannot be proved by induction as it stands, and a stronger statement can. This sounds backwards, since a stronger statement says more and should be harder to prove. But in an induction the statement plays two parts: it is the conclusion of the step, and it is also the hypothesis. Strengthening it makes the target harder, and it also makes the hypothesis more useful, and the second effect often wins. George Pólya, in How to Solve It (1945), called this the inventor's paradox: the more ambitious plan may have the better chance of success. Strengthening the statement to be proved is also called loading the induction.

Example. Prove that ∑k=1n1k2<2 for every natural number n.

First try the claim as it stands. The base case is 1<2. For the step, suppose ∑k=1n1k2<2; then

∑k=1n+11k2=∑k=1n1k2+1(n+1)2<2+1(n+1)2

and that is not less than 2. The step fails, and it has to: the hypothesis "less than 2" allows the sum to be 1.9999, and then adding a term of 14 would break the bound. The hypothesis does not say how much room is left below 2, and the step needs exactly that information.

So put the room into the statement. Let P(n) be the statement

∑k=1n1k2≤2−1n

This implies the original claim, since 2−1n<2. For the base case, both sides are 1. For the step, let n be a natural number and suppose P(n). The target is ∑k=1n+11k2≤2−1n+1. By the hypothesis,

∑k=1n+11k2≤2−1n+1(n+1)2

so it is enough to show −1n+1(n+1)2≤−1n+1, that is, 1(n+1)2≤1n−1n+1. The right side is (n+1)−nn(n+1)=1n(n+1), and n(n+1)<(n+1)2, so 1(n+1)2<1n(n+1). Hence P(n+1) holds, and by induction P(n) holds for every n. In particular every sum ∑k=1n1k2 is less than 2.

Where did 2−1n come from? From asking what the step needs. A bound of the form 2−g(n) carries itself forward when g(n)−g(n+1)≥1(n+1)2: the room lost in one step must cover the new term. The choice g(n)=1n loses 1n(n+1) per step, which is just enough, and g(1)=1 makes the base case work. That calculation, done on scrap paper, is how loaded statements are found. The sums themselves approach π26≈1.645, a value found by Leonhard Euler in the 1730s, but no bound of that precision is needed to prove that they stay below 2.

Now you. Prove that ∑k=1n1k3<32 for every natural number n, by proving the stronger statement ∑k=1n1k3≤32−12n2.

Answer

Let P(n) be ∑k=1n1k3≤32−12n2. Since 12n2>0, P(n) implies the claim.

For the base case, the left side is 1 and the right side is 32−12=1.

For the step, let n be a natural number and suppose P(n). By the hypothesis,

∑k=1n+11k3≤32−12n2+1(n+1)3

and the target is 32−12(n+1)2. So it is enough to show

1(n+1)3+12(n+1)2≤12n2

Multiplying both sides by the positive number 2n2(n+1)3, a reversible step, this is 2n2+n2(n+1)≤(n+1)3, that is, n3+3n2≤n3+3n2+3n+1, which is true because 3n+1>0. So P(n+1) holds, and by induction P(n) holds for every n.

The unloaded claim fails in the step for the same reason as in the Example: "less than 32" says nothing about how much room is left. The sums approach about 1.202.

Loading is not only for inequalities. The sum of the first n odd numbers, earlier in the lesson, was a loaded statement: "is a perfect square" could not carry itself forward, and "is n2" could. The Fibonacci bounds were another: to show only that Fn is positive would be easy, but to learn how fast it grows, the statement had to carry a precise bound. A useful rule of thumb follows. When an inductive step fails because the hypothesis is too vague, do not give up on induction; ask what extra information the step would need, and put it into the statement.

Three forms of one principle

The lesson has now met three principles about ℕ: well-ordering, ordinary induction and strong induction. They are not three facts but one fact in three forms.

Theorem. The well-ordering principle, the principle of induction and the principle of strong induction are equivalent: each implies the other two.

Proof. It is enough to prove three implications in a cycle, as the lesson on direct proof explained for lists of equivalent statements. Well-ordering implies induction by the theorem in the section on why induction works, and induction implies strong induction by the theorem in the section on strong induction. It remains to show that strong induction implies well-ordering.

Assume the principle of strong induction, and let A be a set of natural numbers with no least element. We show that A is empty; this is the contrapositive of well-ordering. Let P(n) be the statement "n∉A".

Base case: if 1 were in A, it would be the least element of A, since 1≤m for every natural number m. As A has no least element, 1∉A, so P(1) holds.

Step: let n be a natural number and suppose P(1),…,P(n), that is, none of 1,2,…,n is in A. If n+1 were in A, then every element m of A would satisfy m≥n+1, since a natural number less than n+1 is one of 1,…,n. So n+1 would be the least element of A, which does not exist. Hence n+1∉A, and P(n+1) holds.

By strong induction, n∉A for every natural number n, so A is empty. Thus every non-empty set of natural numbers has a least element. □

The proofs in the cycle used a few basic facts about ℕ besides the three principles: 1 is the least natural number, every natural number other than 1 is m+1 for some natural number m, and no natural number lies strictly between n and n+1. With those facts taken as known, each principle can stand in for the others, and which to use is a question of convenience.

Use ordinary induction when case n+1 follows from case n, as for sums, most inequalities and most divisibility claims. Use strong induction when case n+1 depends on some earlier case whose position is not fixed, as for factorisations, or on a fixed number of earlier cases, as for the Fibonacci numbers and the stamps. Use the smallest counterexample when the natural argument is "a failure would force a smaller failure". A classic of the last kind is Pierre de Fermat's method of infinite descent, which shows that something cannot exist by showing that any example would produce a smaller one.

Here is descent applied to 2, a proof quite different from the previous lesson's. Suppose 2 is rational. Then the set of natural numbers b such that b2 is an integer is non-empty, so it has a least element b; let a=b2, a natural number. Since 1<2<2, we have b<a<2b, so a−b is a natural number less than b. Now

(a−b)2=a2−b2=2b−a

since a2=b2⋅2=2b and b2=a. So (a−b)2 is an integer. Then a−b is a smaller natural number with the same property, contradicting the choice of b. So 2 is irrational. The proof never mentions parity; it uses only the ordering of ℕ.

How can three true statements be "equivalent"?

In ordinary logic, any two true statements are equivalent, since P⟺Q is true whenever both are true, so "well-ordering is equivalent to induction" cannot mean only that. What it means is: from the basic facts listed after the proof, well-ordering can be derived from induction and induction from well-ordering. So in any structure where the basic facts hold, the three principles stand or fall together.

A structure where they fall together makes this concrete. Take ℕ followed by a copy of the integers: the numbers 1,2,3,…, and after all of them, further elements …,c−1,c0,c1,…, with every ci counted larger than every natural number, ci<cj when i<j, and "x+1" meaning the next element, so ci+1=ci+1. Every basic fact still holds. The first element is 1; every other element has a predecessor, since ci=ci−1+1; and nothing lies strictly between x and x+1. But all three principles fail. The set {…,c−1,c0,c1,…} is non-empty and has no least element, so well-ordering fails. The statement "x is one of 1,2,3,…" holds at 1 and passes from x to x+1, but fails at c0, so induction fails. And strong induction fails for the same statement.

Structures like this are not idle inventions. Thoralf Skolem showed in 1934 that the first-order axioms of arithmetic, which can state induction only one formula at a time, cannot rule out such extra elements: there are "non-standard models" of arithmetic whose order begins with a copy of ℕ and continues with blocks like the one above. Inside ordinary mathematics, the second-order induction axiom, about all sets of natural numbers, is what excludes them, and it is the version this course uses.

Structural induction, a first look

Induction is not really about numbers. It is about things built up in stages from starting pieces by fixed rules, and the natural numbers are the simplest such things: one starting piece, 1, and one rule, "add 1". Other objects are built the same way, and they have their own induction.

The formulas of propositional logic, from the lesson on statements and connectives, are the standard example. They are defined recursively, by rules for building them. Each variable p, q, r, and so on, is a formula. If φ is a formula, so is ¬φ. If φ and ψ are formulas, so are (φ∧ψ) and (φ∨ψ). And nothing is a formula unless it is produced by these rules.

So ((p∧q)∨¬r) is a formula: p, q and r are formulas, hence (p∧q) and ¬r are, hence the whole. The string p∧∨q is not, since no rule produces it.

The principle of structural induction. To prove that every formula has a property, prove that every variable has it (the base case), and prove that the rules preserve it: if φ and ψ have the property, then so do ¬φ, (φ∧ψ) and (φ∨ψ) (the inductive steps, one per rule).

Proposition. Every formula contains as many left brackets as right brackets.

Proof. By structural induction. For a formula φ write L(φ) and R(φ) for its numbers of left and right brackets. A variable has no brackets, so L=R=0. If L(φ)=R(φ), then ¬φ has the same brackets as φ, so L(¬φ)=R(¬φ). If L(φ)=R(φ) and L(ψ)=R(ψ), then

L((φ∧ψ))=L(φ)+L(ψ)+1=R(φ)+R(ψ)+1=R((φ∧ψ))

and the same holds for (φ∨ψ). So every rule preserves the property, and every formula has it. □

The same method shows that in every formula the number of occurrences of variables is one more than the number of occurrences of ∧ and ∨ together. A variable has 1 and 0. The rule for ¬ changes neither count. And if φ and ψ have b+1 and b′+1 variable occurrences against b and b′ binary connectives, then (φ∧ψ) has b+b′+2 variable occurrences against b+b′+1 connectives. So ((p∧q)∨¬r), with three variables, has two binary connectives, as it does.

These look like small facts, and they are the first steps of real theorems. The bracket count, sharpened a little, proves that every formula can be read in only one way, which is what allows the truth value of a formula to be defined recursively from the truth values of its parts. Structural induction is also the everyday tool of computer science, where lists, trees, expressions and programs are all built by rules like these, and where a function defined by recursion on such an object is proved correct by induction on the same structure.

Is structural induction a new principle, or ordinary induction in disguise?

For formulas it is strong induction on length. Let Q be a property that holds for every variable and is preserved by the three rules, and let P(n) be the statement "every formula with exactly n symbols has Q", counting variables, connectives and brackets as symbols. By the last clause of the definition, every formula is a variable or is produced by a rule from shorter formulas. A formula with n symbols is therefore a variable (and then n=1), or ¬φ with φ of n−1 symbols, or (φ∧ψ) or (φ∨ψ) with φ and ψ together of n−3 symbols. In every case the parts have fewer than n symbols. So if P(k) holds for every k<n, the parts have Q, the rule preserves it, and the formula has Q. That is a strong inductive step, and the case n=1 is the base case, so P(n) holds for every n and every formula has Q.

The last clause, "nothing else is a formula", is what makes this work. Without it, some object could count as a formula without being built from shorter ones, and the induction would never reach it. It plays the same part as the Peano axiom that nothing is a natural number except what can be reached from 1.

The general form of the idea is well-founded induction. Suppose objects are compared by a relation "is simpler than" under which there is no infinite chain, each object simpler than the one before. Then any property that holds for an object whenever it holds for all simpler objects holds for every object. Ordinary induction is the case of ℕ with its usual order, structural induction is the case of formulas ordered by "is a part of", and the smallest counterexample argument is the same idea viewed from the other side: a counterexample would have to have a simplest counterexample, and the argument shows it cannot. The lesson on order relations returns to orders with no infinite descending chains.

Every proof in this lesson used collections without saying what they are. The proof that induction works took "the set of natural numbers where P fails" and asked for its least element. The horses came in groups, and were removed from them. The formulas were a collection defined by rules. The next lesson makes those words exact: sets, how to build them, and how to prove that two of them are equal.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Prove that ∑k=1nk(k+1)=n(n+1)(n+2)3 for every natural number n.

Solution

Let P(n) be the formula. For the base case, the left side is 1×2=2 and the right side is 1×2×33=2.

For the step, let n be a natural number and suppose P(n). The target is ∑k=1n+1k(k+1)=(n+1)(n+2)(n+3)3. By the hypothesis,

∑k=1n+1k(k+1)=n(n+1)(n+2)3+(n+1)(n+2)=(n+1)(n+2)(n+3)3

taking out the common factor (n+1)(n+2)3. So P(n+1) holds, and by induction P(n) holds for every natural number n.

2. Prove that ∑k=1n1k(k+1)=nn+1 for every natural number n.

Solution

Let P(n) be the formula. For the base case, both sides equal 12.

For the step, let n be a natural number and suppose P(n). By the hypothesis,

∑k=1n+11k(k+1)=nn+1+1(n+1)(n+2)=n(n+2)+1(n+1)(n+2)=(n+1)2(n+1)(n+2)=n+1n+2

which is P(n+1). By induction, P(n) holds for every natural number n. (Since 1k(k+1)=1k−1k+1, the sum also telescopes to 1−1n+1.)

3. Prove that 7∣32n+1+2n+2 for every natural number n.

Solution

Let P(n) be the statement. For the base case, 33+23=27+8=35=7×5.

For the step, let n be a natural number and suppose 32n+1+2n+2=7k for some integer k. Then

32n+3+2n+3=9⋅32n+1+2⋅2n+2=9(32n+1+2n+2)−7⋅2n+2=7(9k−2n+2)

and 9k−2n+2 is an integer, so P(n+1) holds. By induction, P(n) holds for every natural number n.

4. A sequence is defined by a1=1 and an+1=2an+1 for n≥1. Compute a1 to a5, guess a formula for an, and prove it.

Solution

The first terms are a1=1, a2=3, a3=7, a4=15, a5=31, each one less than a power of 2. The guess is an=2n−1.

Let P(n) be an=2n−1. For the base case, a1=1=21−1. For the step, let n be a natural number and suppose an=2n−1. By the recursive definition and the hypothesis, an+1=2an+1=2(2n−1)+1=2n+1−1, which is P(n+1). By induction, an=2n−1 for every natural number n.

This is the number of moves needed for the Tower of Hanoi with n discs, which satisfies the same recursion.

Core

5. Prove that 13+23+⋯+n3=n2(n+1)24 for every natural number n, and deduce that 13+23+⋯+n3=(1+2+⋯+n)2.

Hint

In the step, both the old right side and the new term contain the factor (n+1)2. Take it out before expanding anything.

Solution

Let P(n) be the statement ∑k=1nk3=n2(n+1)24. For the base case, both sides equal 1, since 1×44=1.

For the step, let n be a natural number and suppose P(n). The target is ∑k=1n+1k3=(n+1)2(n+2)24. By the hypothesis,

∑k=1n+1k3=n2(n+1)24+(n+1)3=(n+1)2(n2+4n+4)4=(n+1)2(n+2)24

which is the target. By induction, P(n) holds for every natural number n.

For the deduction, the Example in the section on sums gives 1+2+⋯+n=n(n+1)2, whose square is n2(n+1)24. So the sum of the first n cubes is the square of the sum of the first n numbers; for n=4, 1+8+27+64=100=102.

6. Find the flaw in this proof.

Claim. For every non-zero real number a and every integer n≥0, an=1.

Proof. By strong induction on n, starting at 0. For the base case, a0=1 by definition. For the step, let n≥0 and suppose ak=1 for every integer k with 0≤k≤n. Then

an+1=an⋅anan−1=1×11=1

so the claim holds for n+1. By strong induction, an=1 for every n≥0.

Hint

Run the step by hand at the smallest value of n it has to cover, and ask which cases it calls on.

Solution

The claim is false: 21=2. The base case is correct, so the step must fail somewhere.

The step for n uses the inductive hypothesis at k=n and at k=n−1. For n≥1 both lie in the range 0≤k≤n, and the step is valid there: from an=1 and an−1=1 it correctly deduces an+1=1. But the step must also cover n=0, the passage from a0 to a1, and there it uses a−1=1. The case k=−1 is not in the range 0≤k≤0, so the hypothesis says nothing about it, and indeed a−1=1a is not 1 unless a=1. The algebraic identity an+1=ananan−1 is true for n=0; the failure is in replacing a−1 by 1.

So the chain breaks at its first link, exactly as in the horses: P(0)⇒P(1) is not established, and every later link waits on P(1). A step that reaches back two places needs two base cases, here n=0 and n=1, and P(1), which says a=1, cannot be proved.

7. Prove or disprove each claim. (a) 2n≥n3 for every integer n≥10. (b) 2n≥n3 for every integer n≥9.

Hint

Check the base cases first. For the step in (a), reduce the target to an inequality between polynomials in n and use n≥10 to compare their leading terms.

Solution

(b) is false: 29=512 and 93=729, so n=9 is a counterexample.

(a) is true. Let P(n) be 2n≥n3. For the base case, 210=1024≥1000=103.

For the step, let n≥10 and suppose 2n≥n3. Then 2n+1=2⋅2n≥2n3, so it is enough to show 2n3≥(n+1)3=n3+3n2+3n+1, that is, n3≥3n2+3n+1. Since n≥10,

n3≥10n2=3n2+7n2≥3n2+70n>3n2+3n+1

using n2≥10n and 70n>3n+1. So 2n+1≥(n+1)3, and by induction P(n) holds for every n≥10.

The two parts together show that the base case, not the step, fixes where the claim starts: n=10 is the least n from which the inequality holds for good. (It also holds at n=1, where 2≥1, and fails for n=2 to 9.)

8. Prove that every natural number can be written as a sum of distinct powers of 2 (the powers 20=1, 21=2, 22=4, and so on, each used at most once), and that this can be done in only one way, apart from the order of the terms.

Hint

For existence, use strong induction: subtract the largest power of 2 that does not exceed n. For uniqueness, first show that distinct powers of 2 that are all less than 2m add up to less than 2m.

Solution

Existence. Let P(n) be "n is a sum of distinct powers of 2". We use strong induction. For the base case, 1=20.

For the step, let n be a natural number, suppose P(k) for every k≤n, and consider n+1. The powers of 2 that do not exceed n+1 include 20, and there are finitely many of them, since 2j>j≥n+1 once j≥n+1 (an easy induction shows 2j>j for all j). Let 2m be the largest, so 2m≤n+1<2m+1. If n+1=2m, we are done. Otherwise let r=n+1−2m. Then 1≤r, and r<2m+1−2m=2m, and r≤n since 2m≥1. By the hypothesis, r is a sum of distinct powers of 2, each at most r and therefore less than 2m. Adding 2m to that sum gives n+1 as a sum of distinct powers of 2, since 2m is not among the others. By strong induction, P(n) holds for every n.

A lemma. For every integer m≥0, 20+21+⋯+2m−1=2m−1 (for m=0 the sum is empty and both sides are 0). This is an induction on m: if the sum up to 2m−1 is 2m−1, adding 2m gives 2m+1−1. So any collection of distinct powers of 2 all less than 2m has sum at most 2m−1, which is less than 2m.

Uniqueness. Suppose some natural number is the sum of the powers in a set S and also of the powers in a different set T. Remove from both the powers they have in common. The two sums stay equal, the remaining sets S′ and T′ have no power in common, and they are not both empty, since S≠T. Let 2m be the largest power in S′∪T′, and without loss of generality say it lies in S′ (the situation is symmetric in S and T). Every power in T′ is then different from 2m and at most 2m, so less than 2m, and by the lemma the sum of T′ is less than 2m, which is at most the sum of S′. That contradicts the equality of the sums. So the representation is unique.

This is the binary representation of n: for example 13=8+4+1, written 1101 in base 2.

9. Let pn=12⋅34⋅56⋯2n−12n. Prove that pn<13n for every natural number n.

Hint

First try the claim as it stands, and see that the step fails. Then prove the stronger statement pn≤13n+1. Squaring is reversible for positive quantities.

Solution

A direct induction fails. From pn<13n the step would need 13n⋅2n+12n+2≤13n+3, which after squaring and clearing denominators is (2n+1)2(3n+3)≤3n(2n+2)2, that is, 12n3+24n2+15n+3≤12n3+24n2+12n, which is false for every n. So load the induction.

Let P(n) be pn≤13n+1. For the base case, p1=12=14.

For the step, let n be a natural number and suppose P(n). Since pn+1=pn⋅2n+12n+2 and the factor is positive,

pn+1≤13n+1⋅2n+12n+2

and it is enough to show that the right side is at most 13n+4. Both are positive, so this is equivalent to the inequality between their squares, and clearing the positive denominators, to

(2n+1)2(3n+4)≤(2n+2)2(3n+1)

The left side expands to 12n3+28n2+19n+4 and the right side to 12n3+28n2+20n+4, so the inequality says 19n≤20n, which is true. Hence P(n+1) holds, and by induction P(n) holds for every natural number n.

Finally, 3n+1>3n gives 13n+1<13n, so pn<13n for every n.

The margin in the step, n out of about 12n3, is tiny, which is why the unloaded version failed. The true size of pn is close to 1πn, and since π>3, that is consistent with the bound.

10. Prove Cassini's identity: Fn+1Fn−1−Fn2=(−1)n for every integer n≥2, where Fn are the Fibonacci numbers.

Hint

In the step, use the Fibonacci rule to replace Fn+2 by Fn+1+Fn, and later to replace Fn+1−Fn by Fn−1.

Solution

Let P(n) be Fn+1Fn−1−Fn2=(−1)n. For the base case n=2, F3F1−F22=2×1−1=1=(−1)2.

For the step, let n≥2 and suppose P(n). The target is Fn+2Fn−Fn+12=(−1)n+1. Using Fn+2=Fn+1+Fn, and then Fn+1−Fn=Fn−1 (the Fibonacci rule again, valid since n≥2),

Fn+2Fn−Fn+12=Fn+1Fn+Fn2−Fn+12=Fn2−Fn+1(Fn+1−Fn)=Fn2−Fn+1Fn−1

By the hypothesis this is −(−1)n=(−1)n+1. So P(n+1) holds, and by induction P(n) holds for every n≥2.

At n=6 the identity reads 13×5−82=1, and it is behind a well-known puzzle: an 8 by 8 square, cut into four pieces along lines through Fibonacci lengths, seems to reassemble into a 5 by 13 rectangle of area 65. The missing unit of area hides in a thin gap along the diagonal.

11. Call a formula positive if it is built from variables using only ∧ and ∨, with the formation rules from the section on structural induction but without the rule for ¬. Prove that every positive formula is true when all of its variables are true. Deduce that ¬p is not logically equivalent to any positive formula, so ∧ and ∨ alone are not enough to express every truth table (this makes precise the argument by which the lesson on statements and connectives proved the same result).

Hint

Use structural induction over the rules for positive formulas. For the deduction, compare a positive formula with ¬p under the assignment that makes every variable true.

Solution

Fix the truth assignment v that makes every variable true. We prove by structural induction that every positive formula is true under v. The positive formulas are the variables, together with (φ∧ψ) and (φ∨ψ) for positive φ and ψ, and nothing else.

Base case: a variable is true under v by the choice of v.

Steps: suppose φ and ψ are positive formulas that are both true under v. Then (φ∧ψ) is true under v, since both its parts are, and (φ∨ψ) is true under v, since at least one of its parts is.

So every positive formula is true under v.

Now suppose some positive formula χ were logically equivalent to ¬p, that is, had the same truth value as ¬p under every assignment of truth values to the variables occurring in either. Take the assignment making every variable true, p included. Then ¬p is false, while χ is true by what was just proved, so they differ there, and they are not equivalent. Hence no positive formula is equivalent to ¬p, and some truth table, the one for "not", cannot be built from ∧ and ∨ alone. With ¬ added, every truth table can be built.

Challenge

12. An L-tromino is the shape formed by three unit squares of a 2 by 2 square, the fourth removed. Prove that for every natural number n, a 2n by 2n board of unit squares with any one square removed can be covered exactly by L-trominoes, without overlaps.

Hint

Split the board of side 2n+1 into four quarters of side 2n. One quarter contains the removed square. Place a single tromino at the centre of the board so that each of the other three quarters also has exactly one square that is unavailable.

Solution

Let P(n) be the statement that every 2n by 2n board with one square removed can be tiled by L-trominoes.

For the base case, a 2 by 2 board with one square removed is itself an L-tromino.

For the step, let n be a natural number and suppose P(n). Take a 2n+1 by 2n+1 board with one square removed. The two lines through the centre of the board, parallel to its sides, divide it into four quarters, each a 2n by 2n board, and the removed square lies in exactly one of them. Each quarter has one corner square at the centre of the big board, and the three such squares belonging to the other three quarters form an L-tromino; place a tromino on them.

Now each quarter is a 2n by 2n board with exactly one square unavailable: the removed square in its quarter, and the square covered by the central tromino in each of the other three. By the inductive hypothesis each quarter, with its one unavailable square, can be tiled by L-trominoes. These four tilings together with the central tromino cover the whole board except the removed square, with no overlaps, since the quarters are disjoint and the central tromino lies on squares excluded from the quarters' tilings. So P(n+1) holds, and by induction P(n) holds for every n.

A count is consistent with this: the board has 4n−1 squares left, and 3∣4n−1 because 4n−1=(4−1)(4n−1+⋯+1). The result appears in Solomon Golomb's 1954 paper on polyominoes.

13. The inequality between the arithmetic and geometric means says that for every natural number n and all non-negative real numbers x1,…,xn,

x1x2⋯xn≤(x1+x2+⋯+xnn)n

Call this statement A(n). The lesson on direct proof proved A(2) (in the form xy≤x+y2). Prove A(n) for every n by the following route. (a) Prove A(2k) for every natural number k, by induction on k. (b) Prove that A(n) implies A(n−1) for every n≥2. (c) Conclude that A(n) holds for every n.

Hint

For (a), split 2k+1 numbers into two halves of 2k, apply A(2k) to each half and then A(2) to the two averages. For (b), given n−1 numbers with average a, add a itself as an nth number.

Solution

Two facts about non-negative reals are used throughout: if 0≤u≤u′ and 0≤w≤w′ then uw≤u′w′ (since uw≤u′w≤u′w′), and consequently, if 0≤u≤u′ then um≤um′ for every natural number m (by induction on m). Also A(1) says x1≤x1, which is true.

(a) Induction on k. The base case A(2) says xy≤(x+y2)2 for non-negative x and y; it holds because (x+y2)2−xy=(x−y)24≥0.

For the step, suppose A(m) where m=2k, and let x1,…,x2m be non-negative reals. Let a be the average of x1,…,xm and b the average of xm+1,…,x2m; both are non-negative, and the average of all 2m numbers is a+b2. By A(m) applied to each half, 0≤x1⋯xm≤am and 0≤xm+1⋯x2m≤bm, so multiplying, x1⋯x2m≤ambm=(ab)m. By A(2), 0≤ab≤(a+b2)2, so (ab)m≤(a+b2)2m. Hence x1⋯x2m≤(a+b2)2m, which is A(2m)=A(2k+1). By induction, A(2k) holds for every k.

(b) Let n≥2 and suppose A(n). Let x1,…,xn−1 be non-negative reals with average a=x1+⋯+xn−1n−1≥0, and put xn=a. The average of x1,…,xn is (n−1)a+an=a, so A(n) gives x1⋯xn−1⋅a≤an. If a>0, dividing by a gives x1⋯xn−1≤an−1, which is A(n−1) for these numbers. If a=0, then all the xi are 0, since they are non-negative with sum 0, and A(n−1) reads 0≤0. So A(n−1) holds.

(c) Let n be a natural number. Since 2n>n, there is a power of 2 at least n; let N=2n. For 0≤j≤N−n let Q(j) be the statement A(N−j). Then Q(0) is A(2n), true by (a). If Q(j) holds and j<N−n, then N−j≥n+1≥2, so (b) turns A(N−j) into A(N−j−1), which is Q(j+1). By induction on j (a finite run of steps), Q(N−n) holds, and that is A(n).

This "forward and backward" induction is due to Augustin-Louis Cauchy, in his Cours d'analyse of 1821. The ordinary step from A(n) to A(n+1) is awkward, and the detour through powers of 2 avoids it: jumping up far and then stepping down one at a time still reaches every n.

14. Prove Zeckendorf's theorem (existence part): every natural number is a sum of distinct Fibonacci numbers, taken from F2,F3,F4,…, no two of which are consecutive in the sequence. For example, 100=89+8+3=F11+F6+F4.

Hint

Use strong induction. Subtract the largest Fibonacci number Fk≤n and show that what is left is less than Fk−1, so the representation of the remainder cannot use Fk−1.

Solution

Call a representation of n as Fi1+Fi2+⋯+Fir admissible when i1>i2>⋯>ir≥2 and ij−ij+1≥2 for each j. Since F2=1<F3=2 and Fj+1=Fj+Fj−1>Fj for j≥3, the numbers F2,F3,F4,… are strictly increasing, so Fj≥j−1 for j≥2 (induction on j).

Let P(n) be "n has an admissible representation". We use strong induction. For the base case, 1=F2.

For the step, let n be a natural number, suppose P(k) for every k≤n, and consider n+1≥2. The indices j≥2 with Fj≤n+1 include 2 and are all less than n+3, since Fn+3≥n+2. Let k be the largest. Then Fk≤n+1<Fk+1, and k≥3 because F3=2≤n+1.

If n+1=Fk, that is an admissible representation. Otherwise let r=n+1−Fk. Then 1≤r≤n, and

r<Fk+1−Fk=Fk−1

By the hypothesis, r has an admissible representation Fi1+⋯+Fis. Its largest term satisfies Fi1≤r<Fk−1, and since the Fj with j≥2 are increasing and k−1≥2, this forces i1<k−1, that is, i1≤k−2. So n+1=Fk+Fi1+⋯+Fis with k−i1≥2, which is admissible. By strong induction, every natural number has an admissible representation.

For 100, the largest Fibonacci number not exceeding it is 89, leaving 11; the largest not exceeding 11 is 8, leaving 3=F4. The representation is also unique, a fact proved by a similar induction and named after Édouard Zeckendorf.

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, and it leaned on collections throughout: the set of natural numbers where a statement fails, groups of horses, the collection of all formulas. This lesson makes those words exact. It sets up the language of sets that the rest of the course, and most of mathematics, is written in: how to describe a set, how to prove that one set lies inside another and that two sets are equal, the operations that build new sets from old and the laws they obey, power sets and Cartesian products, and unions and intersections of infinitely many sets at once. It ends with the paradox that showed the naive idea of a set to be contradictory, and with the axioms that repaired it. The lesson assumes the connectives, including the rule that a conditional with a false hypothesis is vacuously true, the quantifiers ∀ and ∃, and induction. As before, ℕ={1,2,3,…} starts at 1.

Sets and membership

A set is a collection of objects, called its elements or members, 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, the integers, the rationals and the reals.

This is not a definition in the strict sense, since "collection" is only another word for "set". Like "point" in geometry, "set" and "is an element of" are taken as basic, and what matters is the rules they obey. The first and most important rule says what it means for two sets to be the same.

Axiom of extensionality. Two sets are equal exactly when they have the same elements: A=B means ∀x(x∈A⟺x∈B).

A small set can be written by listing its elements between braces, in roster notation: {2,3,5,7} is the set of primes below 10. By extensionality, order and repetition in a list make no difference. {1,2,2}={2,1}, since each side has exactly the elements 1 and 2; writing 2 twice names the same element twice. Longer sets are sometimes listed with dots, as in {1,2,…,100} or {2,4,6,…}, when the pattern cannot be mistaken.

Elements can be anything, including other sets. The set {1,{1,2}} has exactly two elements, the number 1 and the set {1,2}; the number 2 is not one of them, since it is an element of an element, not an element. A set with no elements at all is the empty set, written ∅. By extensionality there is only one: two sets with no elements have the same elements. And {∅} is not empty. It has one element, which happens to be the empty set, in the way that a box containing an empty box is not an empty box.

Subsets of the real line have their own notation. For real numbers a<b, the open interval (a,b) is the set of reals x with a<x<b, and the closed interval [a,b] is the set with a≤x≤b. Mixed ones such as [a,b) include one end and not the other, and (a,∞) is the set of all reals greater than a. The notation (a,b) also means an ordered pair, met later in the lesson, and context decides which is meant.

Set builder notation

Most sets are too large to list, and are described by a property instead, 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, in the sense of the lesson on quantifiers, and the result is the set of those 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. Some books write a vertical bar for the colon, {x∈A∣P(x)}; the meaning is the same.

The notation comes with one rule, and every proof about such a set uses it.

The membership rule. An object y belongs to {x∈A:P(x)} exactly when y∈A and P(y) is true.

The letter x is a dummy, like the k in a sum: {x∈ℝ:x2=2} and {t∈ℝ:t2=2} are the same set, {2,−2}. The surrounding set matters: {x∈ℚ:x2=2} is empty, because the previous lesson's descent argument, or the lesson on contradiction, shows that no rational squares to 2.

A second form puts an expression first. For a set A and an expression f(x),

{f(x):x∈A}

is the set of all values f(x) as x runs through A. So {2k:k∈ℤ} is the set of even integers, and {k2:k∈ℤ}={0,1,4,9,…} is the set of perfect squares. Its membership rule has a hidden quantifier: y∈{f(x):x∈A} exactly when ∃x∈A(y=f(x)). To show that 10 is in the first set, name the witness, k=5. To show that 7 is not, show that no witness exists: 7=2k would make 7 even. Several variables are allowed, and then each gets its own quantifier: y∈{3a+5b:a,b∈ℤ} means that there are integers a and b with y=3a+5b.

The insistence on a surrounding set A in the first form looks like pedantry, since "{x:P(x)}, the set of all x with property P" seems just as clear. A later section shows that it is not pedantry: without the surrounding set, the notation produces a contradiction.

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)

So ℕ⊆ℤ⊆ℚ⊆ℝ, and {2,3}⊆{1,2,3}. A is a proper subset of B when A⊆B and A≠B, that is, when B has at least one element that A lacks. Notation for this varies between books, so this course writes it out in words.

The definition is a universal conditional, and it fixes the method of proof. To prove A⊆B, let x be an arbitrary element of A, unpack what membership of A says about x, and show from that alone that x satisfies the condition for membership of B. This is called element chasing, and it is the direct proof of the lesson on direct proof, applied to the statement "x∈A⇒x∈B". To disprove A⊆B, the negation ∃x(x∈A∧x∉B) says what is needed: one element of A that is not in B.

For example, {n∈ℤ:4∣n}⊆{n∈ℤ:2∣n}. Let n be an element of the left side. By the membership rule, n is an integer and 4∣n, so n=4k for some integer k. Then n=2(2k) with 2k an integer, so 2∣n, and n belongs to the right side. The reverse inclusion fails, and 2 shows it: 2 is an even integer and 4 does not divide 2.

Keep ∈ and ⊆ apart. The first relates an object to a set that contains it; the second relates two sets. So 1∈{1,2} and {1}⊆{1,2}, but {1}∉{1,2}, since the set {1} is neither of the numbers 1 and 2. Yet {1}∈{{1},2}, and there {1}⊈{{1},2}, since the element 1 of {1} is not an element of {{1},2}. Whether a set is an element or a subset of another depends on the other set, and each claim is checked against its own definition.

The empty set is a subset of every set A. The claim ∅⊆A means ∀x(x∈∅⇒x∈A). The hypothesis x∈∅ is false for every x, so each instance of the conditional is vacuously true, and so is the universal statement. A disproof would need an element of ∅ outside A, and there is no element of ∅ at all.

Three properties of ⊆ are used constantly. For all sets A, B and C: A⊆A; if A⊆B and B⊆C then A⊆C; and if A⊆B and B⊆A then A=B. The first holds because x∈A⇒x∈A is always true. For the second, let x∈A; then x∈B because A⊆B, and then x∈C because B⊆C. The third is extensionality: together, the two inclusions say x∈A⟺x∈B for every x. The lesson on order relations names these three properties reflexivity, transitivity and antisymmetry.

The third property is the method this lesson is built round. To prove that two sets are equal, prove two subset statements, A⊆B and B⊆A, each by element chasing. This is a proof by double inclusion. Checking a few elements of each set is not a proof of equality, for the same reason that checking examples is not a proof of a universal statement: each inclusion is a claim about every element.

Example. Prove that {12a+18b:a,b∈ℤ}={6c:c∈ℤ}.

Call the two sides L and R.

First, L⊆R. Let y∈L. By the membership rule there are integers a and b with y=12a+18b. Then y=6(2a+3b), and 2a+3b is an integer, so y has the form 6c with c=2a+3b, and y∈R.

Second, R⊆L. Let y∈R, so y=6c for some integer c. The task is to find integers a and b with 12a+18b=6c, and it is enough to write 6 itself in the form 12a+18b: since 18−12=6, take a=−c and b=c. Then 12a+18b=−12c+18c=6c=y, so y∈L.

Each side is a subset of the other, so L=R.

The two halves were different in kind. The first unpacked an existential hypothesis ("there are a and b") and needed only algebra. The second had an existential goal, and needed a witness to be constructed. The same shape recurs whenever a set is described by a formula: showing that the formula's values lie in a set is usually routine, and showing that it reaches every element of the set is where the work is. The equation {ma+nb:a,b∈ℤ}={dc:c∈ℤ}, where d is the greatest common divisor of m and n, is Bézout's identity from the Discrete Mathematics course, and 12, 18 and 6 are its simplest instance.

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

Answer

Call the left side S, and note that x2−3x+2=(x−1)(x−2) for every real x.

First, S⊆(1,2). Let x∈S, so (x−1)(x−2)<0. A product of two real numbers is negative only when one factor is positive and the other negative. Since x−1>x−2, the positive factor must be x−1 and the negative one x−2. 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.

Each set contains the other, so S=(1,2). This is the same as "solving the inequality", but written as two inclusions it is clear that both directions were checked: every solution lies in (1,2), and every point of (1,2) is a solution.

Union, intersection, difference and complement

Four operations build new sets from old, and each is a connective in disguise. For sets A and B:

x∈A∪B⟺x∈A∨x∈Bx∈A∩B⟺x∈A∧x∈Bx∈A∖B⟺x∈A∧x∉B

The union A∪B collects everything in either set, with the inclusive "or", so an element of both belongs to it. The intersection A∩B keeps what the two sets share. The difference A∖B, read "A minus B", keeps what is in A and not in B. With A={1,2,3,4} and B={3,4,5} these are {1,2,3,4,5}, {3,4} and {1,2}, and B∖A={5}, so difference, unlike union and intersection, depends on the order. Two sets are disjoint when A∩B=∅, that is, when they have no element in common.

The complement of A is everything not in A, and "everything" needs a limit. Fix a universe U, a set containing every set under discussion, and define the complement of a subset A of U as Ac=U∖A. The universe is part of the meaning: the complement of the even integers is the odd integers when U=ℤ, but it also contains 12 and π when U=ℝ. When no universe has been fixed, write the difference U∖A and name the universe.

A fifth operation is less familiar but just as natural. The symmetric difference A△B is the set of elements in exactly one of A and B:

x∈A△B⟺(x∈A)⊕(x∈B)

where ⊕ is exclusive "or". With the sets above, A△B={1,2,5}. A later section studies it.

These operations are pictured by Venn diagrams, with each set drawn as a region inside a rectangle standing for U: the union is the area covered by either region, the intersection the overlap, the complement everything outside. The pictures are the best way to guess an identity. Whether they can prove one is a fair question.

Can a Venn diagram prove a set identity?

For identities built from ∪, ∩, ∖ and complement, a complete diagram can, and the reason is the same as the reason truth tables work. Whether an element x belongs to a set built from A, B and C by these operations depends only on the three answers to "is x in A?", "in B?", "in C?". There are 23=8 patterns of answers, and the eight regions of the standard three-circle diagram are exactly the eight patterns, including the region outside all three circles. So two expressions give the same set, for all choices of A, B and C, exactly when they contain the same regions of the diagram. Checking regions is checking a finite list of cases that provably covers everything, which is a proof by cases in the sense of the lesson on direct proof.

Written as a table rather than a picture, this is a membership table: one column per set, one row per pattern of ∈ and ∉, and a column for each expression. It is literally a truth table, with "x∈A" in place of a propositional variable, and an identity between sets holds exactly when the matching statement of logic is a tautology. That is why De Morgan's laws, the distributive laws and the rest hold for sets: each is a logical equivalence with "x∈" written in front.

The method has limits. A picture that leaves out a region, for instance by drawing B inside A, checks only the special case where that region is empty, and a claim can hold there and fail in general. With four sets there are 16 patterns, and four circles cannot show them all, since four circles in the plane make at most 14 regions; John Venn, who introduced the diagrams in 1880, used ellipses for four sets. And the method does not reach statements about unions of infinitely many sets, or claims mixing sets with arithmetic, where element chasing is the only general tool. So this course proves identities by double inclusion, and uses diagrams and tables to find and check them.

For finite sets, size interacts with these operations in a simple way. Write |A| for the number of elements of a finite set A. If A and B are disjoint, then |A∪B|=|A|+|B|, since counting the union counts each element once and the two sets share none. In general the elements of A∩B are counted twice in |A|+|B|, which gives

|A∪B|=|A|+|B|−|A∩B|

To prove it from the disjoint case, split A∪B into the disjoint sets A and B∖A, and split B into the disjoint sets B∖A and A∩B. Then |A∪B|=|A|+|B∖A| and |B|=|B∖A|+|A∩B|, and subtracting gives the formula. Of 100 students, if 60 study French, 45 study German and 20 study both, then 60+45−20=85 study at least one, and 15 study neither. The formula for three or more sets, with its alternating signs, is the subject of the Discrete Mathematics lesson on inclusion and exclusion.

The laws of set algebra

Because each operation is a connective in disguise, each law of logic from the lesson on statements and connectives becomes a law of sets. For all subsets A, B and C of a universe U:

A∪B=B∪A,A∩B=B∩A(commutative)(A∪B)∪C=A∪(B∪C),(A∩B)∩C=A∩(B∩C)(associative)A∩(B∪C)=(A∩B)∪(A∩C),A∪(B∩C)=(A∪B)∩(A∪C)(distributive)A∪∅=A,A∩U=A,A∪U=U,A∩∅=∅(identity and domination)A∪Ac=U,A∩Ac=∅,(Ac)c=A(complement)A∪A=A,A∩A=A(idempotent)A∪(A∩B)=A,A∩(A∪B)=A(absorption)

together with De Morgan's laws, which get a section of their own below. The associative laws make brackets unnecessary in A∪B∪C and A∩B∩C. Each law is proved by double inclusion, and each proof is the matching law of logic applied to the statements x∈A, x∈B and x∈C. One example shows the pattern.

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

First, the left side is contained in the right. Let x∈A∩(B∪C). Then x∈A, and x∈B∪C, so x∈B or x∈C. If x∈B, then x∈A and x∈B, so x∈A∩B. If x∈C, then in the same way x∈A∩C. In either case x belongs to (A∩B)∪(A∩C).

Second, the right side is contained in the left. Let x∈(A∩B)∪(A∩C). If x∈A∩B, then x∈A and x∈B; since x∈B, also x∈B∪C, so x∈A∩(B∪C). If x∈A∩C, the same argument with C in place of B gives x∈A∩(B∪C).

Each side contains the other, so they are equal.

An "or" in the hypothesis became a proof by cases, while an "or" in the conclusion needed only one of its parts to be established. That is the pattern of most identity proofs, and knowing it in advance makes them quick to write.

Now you. Prove the other distributive law: 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, then x∈A∪B and x∈A∪C, so x is in the right side. If x∈B∩C, then x∈B, so x∈A∪B, and x∈C, so x∈A∪C; again x is in the right side.

Second, right in left. Let x∈(A∪B)∩(A∪C). Either x∈A or x∉A. If x∈A, then x∈A∪(B∩C). If x∉A, then x∈A∪B forces x∈B, and x∈A∪C forces x∈C, so x∈B∩C, and again x∈A∪(B∩C).

The sets are equal. The second half split on whether x∈A, a case split that the hypothesis did not offer directly; the law of excluded middle supplies it.

Once the laws are proved, they can be used like the rules of algebra, and identities can be derived without chasing elements. The useful link between difference and complement is A∖B=A∩Bc (for subsets of U), which follows at once from the membership conditions. Then, for example,

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

using, in turn, the link twice, De Morgan's law with (Bc)c=B, the distributive law, a complement law and an identity law. Both styles are proofs. Element chasing is more robust, since it needs no list of laws and works for operations not on the list; algebra is shorter once the laws are available.

The subset relation can itself be expressed through the operations, and the result is a list of equivalent conditions.

Theorem. For all sets A and B, the following are equivalent: (i) A⊆B; (ii) A∪B=B; (iii) A∩B=A.

Proof. We prove (i) ⇒ (ii) ⇒ (iii) ⇒ (i), a cycle of three implications, as the lesson on direct proof recommends for such lists.

(i) ⇒ (ii). Suppose A⊆B. Always B⊆A∪B. Conversely, let x∈A∪B; if x∈A then x∈B because A⊆B, and if x∈B there is nothing to show. So A∪B⊆B, and A∪B=B.

(ii) ⇒ (iii). Suppose A∪B=B. Always A∩B⊆A. Conversely, let x∈A. Then x∈A∪B=B, so x∈A and x∈B, that is, x∈A∩B. So A∩B=A.

(iii) ⇒ (i). Suppose A∩B=A, and let x∈A. Then x∈A∩B, so x∈B. Hence A⊆B. □

Set algebra looks like the algebra of numbers, with ∪ as addition and ∩ as multiplication, and the resemblance misleads in one respect: there is no cancellation. From A∪C=B∪C nothing follows about A and B: take C=U, and the equation holds for every A and B. The same goes for A∩C=B∩C, with C=∅. Problem 6 shows what does allow cancellation.

De Morgan's laws

Augustus De Morgan stated his laws for statements in his Formal Logic of 1847: ¬(P∨Q) is equivalent to ¬P∧¬Q, and ¬(P∧Q) to ¬P∨¬Q. They are proved by truth table in the lesson on statements and connectives. Since union is "or", intersection "and" and complement "not", the same laws hold for subsets A and B of a universe U:

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

In words: what lies outside the union lies outside both sets, and what lies outside the intersection lies outside at least one of them.

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; in the same way 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".

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 by De Morgan's law for statements, x∉A or x∉B. In the first case x∈Ac and in the second x∈Bc, so either way x∈Ac∪Bc.

Second, right in left. Let x∈Ac∪Bc. If x∈Ac, then x∈U and x∉A, so x∉A∩B, since every element of A∩B is in A. If x∈Bc, the same holds with B. Either way x∈(A∩B)c.

The sets are equal. Alternatively, the second law follows from the first by algebra: apply the first law to Ac and Bc to get (Ac∪Bc)c=A∩B, then take complements of both sides.

The laws hold with any set in place of the universe, since complement is only difference from U: for all sets A, B and C,

A∖(B∪C)=(A∖B)∩(A∖C)A∖(B∩C)=(A∖B)∪(A∖C)

by the same proofs with "x∈A" in place of "x∈U".

Symmetric difference

The symmetric difference A△B, the set of elements in exactly one of A and B, is the set-theoretic "exclusive or". It can be built from the other operations in two standard ways.

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

First, left in right. Let x∈A△B, so x is in exactly one of A and B. Then x∈A∪B. And x is not in both, so x∉A∩B. Hence x∈(A∪B)∖(A∩B).

Second, right in left. Let x∈(A∪B)∖(A∩B). Then x is in at least one of A and B, and not in both, so in exactly one, and x∈A△B.

For the second description: x is in exactly one of the two sets when either x∈A and x∉B, or x∈B and x∉A, and those two conditions say x∈A∖B and x∈B∖A. So A△B=(A∖B)∪(B∖A), and the two sets in this union are disjoint.

Now you. Prove that intersection distributes over symmetric difference: for all sets A, B and C, A∩(B△C)=(A∩B)△(A∩C).

Answer

First, left in right. Let x∈A∩(B△C). Then x∈A, and x is in exactly one of B and C. If x∈B and x∉C, then x∈A∩B and x∉A∩C, so x is in exactly one of A∩B and A∩C. If x∈C and x∉B, the same holds with the roles exchanged. Either way x∈(A∩B)△(A∩C).

Second, right in left. Let x be in exactly one of A∩B and A∩C. Either way x∈A. If x∈A∩B and x∉A∩C, then, since x∈A, it must be that x∉C; so x∈B and x∉C, and x∈B△C. The other case is the same with B and C exchanged. So x∈A∩(B△C).

The sets are equal. Union does not distribute over symmetric difference: with A=B=C={1}, the left side A∪(B△C) is {1}∪∅={1}, while (A∪B)△(A∪C)={1}△{1}=∅.

Symmetric difference has the algebra of addition with remainders mod 2, and the reason is a counting fact.

Proposition. For all sets A, B and C, an object x belongs to (A△B)△C exactly when it belongs to an odd number of the sets A, B, C. Consequently (A△B)△C=A△(B△C).

Proof. Let x be any object, and let k be the number of the sets A and B containing x, so k is 0, 1 or 2. By definition, x∈A△B exactly when k=1, that is, exactly when k is odd. Now x∈(A△B)△C exactly when x is in exactly one of A△B and C. If x∉C, that means x∈A△B, that is, k is odd, and then the number of sets among A, B, C containing x is k, which is odd. If x∈C, it means x∉A△B, that is, k is even, and then the number of the three sets containing x is k+1, which is odd. In each case, x∈(A△B)△C exactly when x lies in an odd number of the three sets.

For associativity, note that △ is commutative, straight from its definition, so A△(B△C)=(B△C)△A. By what was just proved, applied to B, C and A in that order, this set consists of the objects lying in an odd number of B, C, A. That is the same condition as before, since it does not depend on the order of the three sets. So the two sets have the same elements. □

With associativity in hand, symmetric difference behaves like addition. The empty set is a zero, A△∅=A, and every set is its own negative, A△A=∅. So equations can be solved: if A△X=B, then applying A△ to both sides gives A△(A△X)=A△B, and the left side is (A△A)△X=∅△X=X. So X=A△B is the only solution, and it is one, by the same computation read backwards. This is the cancellation that union and intersection lacked. In the language of algebra, the subsets of U form a group under △, and with ∩ as multiplication they form a ring in which every element is its own square; this is the setting in which Boole's algebra of logic is studied today.

Power sets

The power set of a set A, written P(A), is the set of all subsets of A. Its membership rule is: X∈P(A) exactly when X⊆A. For A={1,2,3} it has eight elements,

P({1,2,3})={∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}

namely the empty set, three sets of one element, three of two, and A itself. The elements of a power set are sets, which is where the distinction between ∈ and ⊆ earns its keep: {1}∈P(A), while {{1}}⊆P(A). The smallest cases are worth doing once by hand. The empty set has exactly one subset, itself, so P(∅)={∅}, a set with one element. Then P({∅})={∅,{∅}} has two.

Theorem. If a finite set A has n elements, then P(A) has 2n elements.

Proof. By induction on n, starting at n=0, as the induction lesson allows. Let P(n) be the statement that every set with n elements has exactly 2n subsets. For n=0 the set is ∅, whose only subset is ∅, and 20=1.

For the step, suppose every set with n elements has 2n subsets, and let A have n+1 elements. Choose an element a∈A and let A′=A∖{a}, a set with n elements. Every subset X of A either omits a or contains it, and not both. If it omits a, then X is a subset of A′, and every subset of A′ arises this way. If it contains a, then X=S∪{a} where S=X∖{a} is a subset of A′, and different subsets S of A′ give different sets S∪{a}, since S can be recovered by removing a. So there are 2n subsets of each kind by the inductive hypothesis, and A has 2n+2n=2n+1 subsets. By induction the theorem holds for every n≥0. □

A second proof counts choices: a subset of {a1,…,an} is determined by deciding, for each ai in turn, whether to include it, and n independent yes or no choices can be made in 2n ways. The two proofs are the same argument; the induction is what makes "and so on for each ai" precise. Either way, the power set of a set of 10 elements has 1024 elements, and its elements are themselves sets.

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

Here the elements are sets, so let X stand for one.

First, left in right. Let X∈P(A)∩P(B). Then X∈P(A) and X∈P(B), that is, X⊆A and X⊆B. To show X⊆A∩B, let x∈X; then x∈A and x∈B, so x∈A∩B. Hence X∈P(A∩B).

Second, right in left. Let X∈P(A∩B), so X⊆A∩B. Since A∩B⊆A, transitivity of ⊆ gives X⊆A, and likewise X⊆B. So X∈P(A) and X∈P(B), and X∈P(A)∩P(B).

The sets are equal. The proof chased elements at two levels: the outer chase was over subsets X, and inside it a second, ordinary chase over elements x proved a subset statement.

Now you. Prove that P(A)∪P(B)⊆P(A∪B) for all sets A and B, and show by an example that the two sets need not be equal.

Answer

Let X∈P(A)∪P(B). If X∈P(A), then X⊆A⊆A∪B, so X⊆A∪B by transitivity. If X∈P(B), then in the same way X⊆A∪B. Either way X∈P(A∪B).

For the example, take A={1} and B={2}. Then {1,2}⊆A∪B, so {1,2}∈P(A∪B). But {1,2} is a subset of neither A nor B, so it is not in P(A)∪P(B). Counting confirms the gap: P(A)∪P(B)={∅,{1},{2}} has 3 elements, while P(A∪B) has 4.

A subset of A∪B may take some elements from A and some from B, and that is exactly what P(A)∪P(B) misses. Equality holds precisely when one of A and B contains the other.

For infinite sets the question "how many subsets?" has a startling answer. Georg Cantor proved in 1891 that no set, finite or infinite, can be matched one to one with its power set, so P(ℕ) is a larger infinity than ℕ, and there is an endless ladder of larger ones. The lesson on countable and uncountable sets proves it, and the section on Russell's paradox below shows how closely the two arguments are related.

Cartesian products

In a set, order does not matter: {a,b}={b,a}. Coordinates need order, and so does most of mathematics. An ordered pair (a,b) is an object with a first coordinate a and a second coordinate b, governed by one rule:

(a,b)=(c,d)exactly whena=c and b=d

So (1,2)≠(2,1), and (1,1) is a perfectly good pair, while {1,1}={1}. Ordered pairs can be defined from sets alone, and the lesson on functions gives the standard definition; for now the rule is all that is needed.

The Cartesian product of sets A and B is the set of all ordered pairs with first coordinate in A and second in B:

A×B={(a,b):a∈A,b∈B}

It is named after René Descartes, because ℝ×ℝ, written ℝ2, is the coordinate plane of his La Géométrie (1637). With A={1,2,3} and B={x,y},

A×B={(1,x),(1,y),(2,x),(2,y),(3,x),(3,y)}

and B×A consists of the pairs the other way round, so A×B≠B×A here: the product is not commutative. Products of three or more sets are formed from ordered triples (a,b,c) and so on. In the same way An is the set of ordered n-tuples of elements of A. For any set A, A×∅=∅, since there is no second coordinate to choose.

Proposition. If A and B are finite, then |A×B|=|A|⋅|B|.

Proof. Let |A|=m and |B|=n, and list A as a1,…,am. Sort the pairs by first coordinate: for each i, the pairs with first coordinate ai are (ai,b) for b∈B, which are n different pairs, since pairs with different second coordinates differ. These m rows are disjoint, since pairs with different first coordinates differ, and together they make up A×B. So |A×B|=n+n+⋯+n with m terms, which is mn. (The step "adding m disjoint rows gives the sum of their sizes" is the disjoint case of the union formula, extended to m sets by induction on m.) □

This is the product rule of counting, and repeated, it gives |An|=|A|n. The lesson on functions uses it to count the functions between two finite sets.

The product interacts with the other operations in the expected way on one side. For all sets A, B and C,

A×(B∪C)=(A×B)∪(A×C)

To prove it: a pair (a,x) lies in the left side exactly when a∈A and (x∈B or x∈C), and in the right side exactly when (a∈A and x∈B) or (a∈A and x∈C), and these conditions are equivalent by the distributive law of logic. Every element of either side is a pair, so the sets are equal. The same argument works with ∩ or ∖ in place of ∪. The analogous claim for unions in both coordinates at once is false, and Problem 8 shows why.

Unions and intersections of families

Two sets have a union and an intersection, and by associativity so do any finite number. Analysis and probability need more: the union of infinitely many sets at once. The tool is an indexed family of sets, a set Ai for each i in some index set I. Its union and intersection are defined by the quantifiers, as the two-set versions were defined by the connectives:

x∈⋃i∈IAi⟺∃i∈I(x∈Ai)x∈⋂i∈IAi⟺∀i∈I(x∈Ai)

So the union collects everything that lies in at least one Ai, and the intersection keeps what lies in every Ai. When I={1,2} these are A1∪A2 and A1∩A2, since "there is an i among 1 and 2" is an "or", and "for every i among 1 and 2" is an "and". When I=ℕ one also writes ⋃n=1∞An and ⋂n=1∞An. The symbol ∞ there is notation only; there is no set A∞.

Proofs about families are element chasing with a quantifier in the membership condition. To show x is in a union, produce an index i with x∈Ai. To show x is in an intersection, let i be an arbitrary index and show x∈Ai. To show x is not in an intersection, produce one index i with x∉Ai. Arguments about intervals of reals often need one fact about ℝ, the Archimedean property: for every real number t there is a natural number n with n>t. It is proved from the completeness of ℝ in the lesson on the real numbers, and used here freely.

Example. Prove that ⋃n∈ℕ[1n,2−1n]=(0,2).

Write An=[1n,2−1n], so A1=[1,1]={1}, A2=[12,32], A3=[13,53], and the intervals grow towards both ends of (0,2).

First, the union is contained in (0,2). Let x be in the union. Then x∈An for some natural number n, so 1n≤x≤2−1n. Since 1n>0, this gives 0<x<2.

Second, (0,2) is contained in the union. Let 0<x<2. The task is to produce one n with 1n≤x and 1n≤2−x, and since x and 2−x are both positive, it is enough to take n at least as large as 1x and as 12−x. By the Archimedean property there is a natural number n greater than the larger of these two numbers. Then 1n<x and 1n<2−x, so x∈An, and x is in the union.

The sets are equal. Each An contains its end points, while the union contains neither 0 nor 2. So a union of infinitely many closed intervals need not be a closed interval, a first sign that infinite operations behave differently from finite ones.

Now you. Prove that ⋂n∈ℕ(−1n,1n)={0}.

Answer

First, {0} is contained in the intersection. For every natural number n, −1n<0<1n, so 0∈(−1n,1n). As n was arbitrary, 0 lies in the intersection.

Second, the intersection is contained in {0}. We prove the contrapositive: if x≠0, then x is not in the intersection. Let x≠0, so |x|>0. By the Archimedean property there is a natural number n>1|x|, and then 1n<|x|. So x∉(−1n,1n), since the members of that interval have absolute value less than 1n. One index where x fails is enough to keep x out of the intersection.

The sets are equal. Each interval in the family is open, and the intersection is the closed interval [0,0]={0}: the mirror image of the Example.

The same technique shows that ⋂n∈ℕ(0,1n)=∅: a real x in every interval would satisfy x>0, and then some n>1x gives 1n<x, so x∉(0,1n). Yet the intersection of any finite number of these intervals is the smallest of them, (0,1N) for the largest index N present, which is not empty. What holds at every finite stage can fail for the whole family, and this is the reason the lesson on the real numbers needs closed intervals in its nested interval theorem.

De Morgan's laws extend to families, with the quantifier rules of the lesson on quantifiers doing the work that De Morgan's laws for "and" and "or" did before. For subsets Ai of a universe U,

(⋃i∈IAi)c=⋂i∈IAic(⋂i∈IAi)c=⋃i∈IAic

For the first: an element x of U is outside the union exactly when ¬∃i(x∈Ai), which is equivalent to ∀i(x∉Ai), that is, x∈Aic for every i, which is membership of the intersection of the complements. Each step is an equivalence, so both inclusions are proved at once. The second law is the same argument with ¬∀ turned into ∃¬. The distributive laws extend too: B∩⋃i∈IAi=⋃i∈I(B∩Ai), since "x∈B and there is an i with x∈Ai" says the same as "there is an i with x∈B and x∈Ai".

Russell's paradox

Georg Cantor, who created the theory of sets, described a set in 1895 as any collection into a whole of definite, distinct objects of our intuition or thought. Read literally, that allows a set {x:P(x)} for every property P, with no surrounding set: the collection of all objects with the property. Gottlob Frege built his logical foundation of arithmetic, the Grundgesetze der Arithmetik, on a principle of exactly this kind. In 1901 Bertrand Russell found that it is contradictory.

Take the property "x∉x", "x is not an element of itself". Most sets have it: the set of even integers is not an even integer, and ∅ is not an element of ∅. If every property defines a set, then there is a set

R={x:x∉x}

and its membership rule says that for every object y, y∈R exactly when y∉y. Now ask whether R is an element of itself, by taking y=R:

R∈R⟺R∉R

No statement can be equivalent to its own negation. If R∈R, the rule gives R∉R; if R∉R, the rule gives R∈R. Either way there is a contradiction, and there is no third case. So the assumption that every property defines a set is false.

Russell wrote to Frege on 16 June 1902, as the second volume of the Grundgesetze was going to press. Frege added an appendix to that volume, published in 1903, acknowledging that the paradox struck at the foundation of his system. The episode is one of the turning points in the history of mathematics: it showed that intuition about collections, however clear it feels, can be inconsistent, and that the rules for forming sets have to be stated explicitly.

The popular version is the village barber who shaves exactly those villagers who do not shave themselves: does he shave himself? The same reasoning shows he does if and only if he does not, and the resolution is simply that no such barber exists. That is the right reading of Russell's argument too. It is a proof, by contradiction, that no set R has the property ∀y(y∈R⟺y∉y).

The repair used in this lesson from the start is to form sets by a property only inside a set already known, as {x∈A:P(x)}. Run Russell's argument on

RA={x∈A:x∉x}

for an arbitrary set A. Its membership rule is: y∈RA exactly when y∈A and y∉y. Suppose RA∈A. Then taking y=RA gives RA∈RA⟺RA∉RA, the same contradiction. So RA∉A. Nothing is contradictory any more: the argument has become a proof.

Theorem. For every set A there is a set not belonging to A. In particular, there is no set of all sets.

Proof. Let A be a set. By the argument just given, the set RA={x∈A:x∉x} is not an element of A. If there were a set V containing every set, then RV would be a set not in V, a contradiction. □

This is why a complement needs a universe. The "set of everything" that would make Ac meaningful without a universe does not exist.

What does Russell's paradox have to do with Cantor's theorem?

They are the same argument. Cantor's theorem, proved in the lesson on countable and uncountable sets, says that for every set A there is no function f that assigns to each element a of A a subset f(a) of A in such a way that every subset is assigned to some element. The proof builds the subset

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

and shows that no element d has f(d)=D: if it did, then d∈D would hold exactly when d∉f(d)=D, which is impossible. The set D differs from each f(a) at the element a, like a diagonal.

Russell arrived at his paradox, by his own account, by thinking about this proof. If there were a set V of all sets, then every subset of V would itself be a set, hence an element of V, so P(V)⊆V. In pure set theory every object is a set, so every element x of V is also a subset of V, and the rule f(x)=x assigns to each element of V a subset of V; every subset of V is assigned to something, namely to itself. Cantor's theorem says that cannot happen, and his set D becomes {x∈V:x∉x}, which is Russell's R. Cantor's contradiction has become Russell's paradox. In Cantor's hands the argument proves that power sets are bigger; in Russell's, that some collections are too big to be sets.

The same diagonal shape appears again and again in logic. Kurt Gödel's first incompleteness theorem (1931) builds a sentence that says of itself that it is not provable, and Alan Turing's proof (1936) that no program can decide whether every program halts builds a program that does the opposite of what the supposed decider predicts about it. Each time, an object is defined by disagreeing with the entry on the diagonal of a table that was supposed to be complete.

The axioms of set theory

Russell's paradox showed that sets cannot be formed by any property whatever. Some other rule for forming sets is needed, strong enough to build everything mathematics uses and restrained enough to avoid contradiction. Ernst Zermelo proposed the first such list of axioms in 1908. Abraham Fraenkel and Thoralf Skolem each added an axiom of replacement in 1922, and John von Neumann proposed the axiom of foundation in the 1920s. The result, called Zermelo and Fraenkel set theory, or ZF, and ZFC when the axiom of choice is included, is the standard foundation of mathematics today. Informally, its axioms say:

Extensionality. Sets with the same elements are equal.

Empty set. There is a set with no elements.

Pairing. For any objects a and b there is a set {a,b}. With a=b this gives {a}.

Union. For any set F whose elements are sets, there is a set whose elements are exactly the elements of the elements of F. With F={A,B} this is A∪B, and with F={Ai:i∈I} it is ⋃i∈IAi.

Power set. For any set A there is a set P(A) of all its subsets.

Separation. For any set A and any property P expressible in the language of sets, there is a set {x∈A:P(x)}.

Replacement. For any set A and any rule assigning an object f(x) to each x∈A, there is a set {f(x):x∈A}.

Infinity. There is a set that contains ∅ and, with each element x, also contains x∪{x}.

Foundation. Every non-empty set A has an element x with x∩A=∅. One consequence is that no set is an element of itself.

Choice. For every family of non-empty sets there is a way of choosing one element from each.

Every construction in this lesson comes from these axioms. Intersection and difference come from separation, as A∩B={x∈A:x∈B} and A∖B={x∈A:x∉B}, and so does a complement inside a universe. Union needs an axiom of its own, since there is no larger set given in advance to carve it out of; so does the power set. Russell's set is forbidden because separation only ever carves a subset from a set already available, which is exactly the repair of the previous section. The Cartesian product A×B comes from separation inside P(P(A∪B)), once ordered pairs are defined as sets, as the lesson on functions does. And the axiom of infinity supplies the natural numbers, as the first deeper explanation below describes.

What the axioms cannot do is prove themselves consistent. Gödel's second incompleteness theorem, of 1931, shows that a consistent system of this strength cannot prove its own consistency, so the evidence for ZF is of another kind: the axioms describe a clear picture, in which sets are built up in stages from the empty set, and more than a century of intensive use has produced no contradiction. In practice mathematicians rarely cite the axioms. They form sets as this lesson has, by separation, unions, power sets and products, confident that each step could be justified from the list if anyone asked.

How can numbers be built out of sets?

If sets are the foundation of mathematics, the natural numbers must be sets too. John von Neumann's definition of 1923 is the one used today. It starts at 0 and builds each number as the set of all the numbers before it:

0=∅,1={0}={∅},2={0,1}={∅,{∅}},3={0,1,2}

and in general the successor of n is n∪{n}. Each number n is then a set with exactly n elements, and m<n means simply m∈n, which also gives m⊆n. The axiom of infinity says precisely that some set contains 0 and is closed under x↦x∪{x}, and the intersection of all subsets of that set with this property is the smallest such set: the set ω={0,1,2,…} of all natural numbers.

Now induction, which the previous lesson derived from the well-ordering principle, a property of ℕ this course takes as basic, becomes a theorem about sets. Let S be a subset of ω that contains 0 and contains n∪{n} whenever it contains n. Then S is one of the sets whose intersection defined ω, so ω⊆S, and hence S=ω. That is the induction axiom of Peano, derived from the axioms of sets.

The rest of the number system follows. Integers are built from pairs of natural numbers, with (a,b) standing for a−b and two pairs identified when they stand for the same difference; rationals are built from pairs of integers in the same way, which is the construction in the lesson on equivalence relations; and real numbers are built from sets of rationals. So every object in this course, from 2 to a function on ℝ, can be modelled as a set built from ∅ in stages. Nobody thinks of 3 as {∅,{∅},{∅,{∅}}} when adding, and nobody needs to; the point is that the foundation holds.

(This course starts ℕ at 1, the convention of number theory and analysis; set theory starts it at 0. Nothing of substance depends on the choice.)

What is the axiom of choice, and why was it controversial?

For a finite family of non-empty sets, choosing one element from each needs no axiom: pick an element of the first set, then of the second, and so on, which is an induction on the number of sets. For infinite families, no finite process makes all the choices, and the axiom asserts that a choice function exists anyway. Russell's illustration: from infinitely many pairs of shoes one can choose a shoe from each pair without the axiom, by the rule "take the left one", but from infinitely many pairs of socks, where the two members of a pair are indistinguishable, no rule is available, and only the axiom supplies a choice.

Zermelo stated the axiom in 1904, to prove that every set can be well ordered, that is, given an order in which every non-empty subset has a least element, as ℕ has. The proof was controversial, because the axiom asserts that something exists without saying what it is, the objection the constructivists raised against non-constructive proofs in the lesson on direct proof. It also has strange consequences. Stefan Banach and Alfred Tarski showed in 1924, using choice, that a solid ball can be cut into finitely many pieces that can be moved rigidly and reassembled into two balls of the same size as the first; the pieces are so irregular that they have no volume at all.

The question was settled as far as it can be. Kurt Gödel showed in 1938 that if ZF is consistent, it stays consistent when choice is added, and Paul Cohen showed in 1963 that it also stays consistent when the negation of choice is added. So choice can be neither proved nor refuted from the other axioms. Most mathematicians accept it, because much of mathematics depends on it: that every vector space has a basis, and many results in analysis and algebra, are equivalent to it or need it. Its most used form in practice is Zorn's lemma, stated in the lesson on order relations.

Sets now have a precise language, a method of proof and a foundation. A set on its own does nothing, though. 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, built, like everything else, out of sets.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. In the universe U={1,2,…,8}, let A={1,2,3,4} and B={3,4,5,6}. List the elements of A∪B, A∩B, A∖B, B∖A, A△B, Ac, (A∪B)c and Ac∩Bc.

Solution

A∪B={1,2,3,4,5,6}, A∩B={3,4}, A∖B={1,2}, B∖A={5,6}, and A△B={1,2,5,6}, the elements in exactly one of the two sets.

Ac={5,6,7,8}. (A∪B)c={7,8}. Since Bc={1,2,7,8}, Ac∩Bc={7,8}, the same set, as De Morgan's law requires.

2. Decide which statements are true: (a) ∅∈∅; (b) ∅⊆∅; (c) ∅∈{∅}; (d) {∅}⊆{∅}; (e) {1}∈{1,{1}}; (f) {1}⊆{1,{1}}; (g) {{1}}⊆{1,{1}}; (h) {{1}}∈{1,{1}}.

Solution

(a) False: ∅ has no elements at all. (b) True: the empty set is a subset of every set. (c) True: ∅ is the one element of {∅}. (d) True: every set is a subset of itself.

(e) True: {1} is one of the two elements, 1 and {1}. (f) True: the only element of {1} is 1, which is an element of {1,{1}}. (g) True: the only element of {{1}} is {1}, which is an element of {1,{1}}. (h) False: the elements of {1,{1}} are 1 and {1}, and {{1}} is neither, since its only element is {1} while the only element of {1} is 1, and {1}≠1.

3. Write out P({a,b}), P(∅) and P(P(∅)) in full, and find the number of elements of P(P({1,2})).

Solution

P({a,b})={∅,{a},{b},{a,b}}, with 22=4 elements.

P(∅)={∅}, with 20=1 element.

P(P(∅))=P({∅})={∅,{∅}}, with 21=2 elements.

P({1,2}) has 22=4 elements, so by the theorem on power sets P(P({1,2})) has 24=16 elements.

4. List the elements of each set: (a) {n∈ℤ:n2≤5}; (b) {2k+1:k∈ℤ,−2≤k≤2}; (c) {x∈ℝ:x2=−1}; (d) {(x,y)∈ℤ×ℤ:x2+y2=1}; (e) {1,2}×{1,2}.

Solution

(a) {−2,−1,0,1,2}, since 22=4≤5 and 32=9>5.

(b) The values of 2k+1 for k=−2,−1,0,1,2 are −3,−1,1,3,5, so the set is {−3,−1,1,3,5}.

(c) ∅, since the square of a real number is never negative.

(d) If x2+y2=1 with integers x and y, then one square is 1 and the other 0. So the set is {(1,0),(−1,0),(0,1),(0,−1)}, four pairs.

(e) {(1,1),(1,2),(2,1),(2,2)}, four pairs, as |{1,2}|2=4 requires; (1,2) and (2,1) are different.

Core

5. Let A, B and C be sets. (a) Prove that (A∖B)∖C=A∖(B∪C). (b) Prove or disprove that A∖(B∖C)=(A∖B)∖C. (c) Prove that A∖(B∖C)=(A∖B)∪(A∩C).

Hint

Write each membership condition with "and", "or" and "not", and simplify with the laws of logic. For (b), try sets with a single element.

Solution

(a) For every object x: x∈(A∖B)∖C exactly when x∈A, x∉B and x∉C. And x∈A∖(B∪C) exactly when x∈A and x∉B∪C, that is, x∈A and not (x∈B or x∈C), which by De Morgan's law for statements is x∈A, x∉B and x∉C. The conditions are the same, so each set is contained in the other and they are equal.

(b) False. Take A=B=C={1}. Then B∖C=∅, so A∖(B∖C)={1}, while A∖B=∅, so (A∖B)∖C=∅. Difference is not associative.

(c) For every object x, x∈A∖(B∖C) exactly when x∈A and not (x∈B and x∉C). By De Morgan's law for statements, the second part is (x∉B or x∈C). So the condition is: x∈A, and x∉B or x∈C. By the distributive law of logic this is: (x∈A and x∉B) or (x∈A and x∈C), which says x∈(A∖B)∪(A∩C). Each step is an equivalence, so the sets are equal. With the sets of (b), the right side is ∅∪{1}={1}, as it should be.

6. Let A, B and C be sets. (a) Show that A∪C=B∪C does not imply A=B. (b) Prove that if A∪C=B∪C and A∩C=B∩C, then A=B. (c) Prove that if A△C=B△C, then A=B.

Hint

For (b), take x∈A and split into the cases x∈C and x∉C; each case uses one of the two hypotheses. For (c), use the algebra of symmetric difference from the lesson.

Solution

(a) Take A={1}, B=∅ and C={1}. Then A∪C={1}=B∪C, but A≠B.

(b) Suppose A∪C=B∪C and A∩C=B∩C. We show A⊆B. Let x∈A. If x∈C, then x∈A∩C=B∩C, so x∈B. If x∉C, then x∈A∪C=B∪C, so x∈B or x∈C, and since x∉C, x∈B. In both cases x∈B, so A⊆B. The hypotheses are unchanged when A and B are exchanged, so the same argument gives B⊆A, and A=B.

(c) Suppose A△C=B△C, and take the symmetric difference of both sides with C. Using associativity, C△C=∅ and X△∅=X,

A=A△(C△C)=(A△C)△C=(B△C)△C=B△(C△C)=B

So A=B. Symmetric difference cancels where union and intersection alone do not, and (b) shows that union and intersection together do.

7. Find the flaw in this proof, and show that the claim is false.

Claim. For all sets A, B and C, if A⊆B∪C, then A⊆B or A⊆C.

Proof. Suppose A⊆B∪C, and let x∈A. Then x∈B∪C, so x∈B or x∈C. If x∈B, then since x was an arbitrary element of A, A⊆B. If x∈C, then in the same way A⊆C. So A⊆B or A⊆C.

Hint

Which of B and C contains x depends on x. Compare "for every x, x∈B or x∈C" with "every x is in B, or every x is in C".

Solution

The claim is false. Take A={1,2}, B={1} and C={2}. Then A⊆B∪C={1,2}, but A⊈B because 2∉B, and A⊈C because 1∉C.

The flaw is in the case split. Once the proof splits into cases according to whether x∈B, the element x is no longer arbitrary: in the first case it is an element of A that happens to lie in B. Concluding "A⊆B" from that case generalises from a restricted x, the misuse of "arbitrary" discussed in the lesson on direct proof. What the argument actually proves is ∀x∈A(x∈B∨x∈C), which is just the hypothesis again. The claim needs (∀x∈Ax∈B)∨(∀x∈Ax∈C), and a universal quantifier does not distribute over "or", as the lesson on quantifiers showed.

The correct statement in the other direction is true: if A⊆B or A⊆C, then A⊆B∪C, since B and C are both subsets of B∪C.

8. Let A, B, C and D be sets. (a) Prove that (A×B)∩(C×D)=(A∩C)×(B∩D). (b) Prove that (A×B)∪(C×D)⊆(A∪C)×(B∪D), and show by an example that equality can fail.

Hint

Every element of each side is an ordered pair, so let (x,y) be an arbitrary pair and compare the conditions on x and y. For the example, draw the sets as rectangles in the plane.

Solution

(a) Every element of either side is an ordered pair, so it is enough to compare the conditions for a pair (x,y) to belong. The pair is in (A×B)∩(C×D) exactly when (x∈A and y∈B) and (x∈C and y∈D). Rearranging the "and"s, this is (x∈A and x∈C) and (y∈B and y∈D), that is, x∈A∩C and y∈B∩D, which is the condition for (x,y)∈(A∩C)×(B∩D). So the sets are equal.

(b) Let (x,y)∈(A×B)∪(C×D). If (x,y)∈A×B, then x∈A⊆A∪C and y∈B⊆B∪D, so (x,y)∈(A∪C)×(B∪D). If (x,y)∈C×D, the same argument applies with C and D. So the inclusion holds.

For the example, take A=B={1} and C=D={2}. Then (A×B)∪(C×D)={(1,1),(2,2)}, while (A∪C)×(B∪D)={1,2}×{1,2} also contains (1,2) and (2,1). In pictures, the union of two squares on a diagonal is smaller than the square that spans both.

9. Prove that for all sets A and B, P(A)⊆P(B) if and only if A⊆B. Deduce that P(A)=P(B) if and only if A=B.

Hint

For the forward direction, find an element of P(A) that tells you about A itself.

Solution

(⇒) Suppose P(A)⊆P(B). Since A⊆A, we have A∈P(A), so A∈P(B), which means A⊆B.

(⇐) Suppose A⊆B, and let X∈P(A), so X⊆A. By transitivity of ⊆, X⊆B, so X∈P(B). Hence P(A)⊆P(B).

For the deduction: P(A)=P(B) holds exactly when P(A)⊆P(B) and P(B)⊆P(A). By the first part this holds exactly when A⊆B and B⊆A, which by double inclusion is A=B.

10. Prove that ⋂n∈ℕ[0,1+1n)=[0,1] and that ⋃n∈ℕ[0,1−1n]=[0,1).

Hint

Each needs the Archimedean property in exactly one of the two inclusions. For a real number that is supposed to be kept out, find one index that excludes it; for a real number that is supposed to be let in, find one index that includes it.

Solution

The intersection. First, [0,1] is contained in it. Let 0≤x≤1 and let n be any natural number. Then x≤1<1+1n, so x∈[0,1+1n). As n was arbitrary, x is in the intersection.

Second, the intersection is contained in [0,1]. Let x be in every [0,1+1n). Taking n=1 gives x≥0. Suppose, for contradiction, that x>1. Then x−1>0, and by the Archimedean property there is a natural number n>1x−1, so 1n<x−1, that is, x>1+1n. Then x∉[0,1+1n), a contradiction. So 0≤x≤1.

The union. First, it is contained in [0,1). If x∈[0,1−1n] for some n, then 0≤x≤1−1n<1.

Second, [0,1) is contained in it. Let 0≤x<1. Then 1−x>0, and by the Archimedean property there is a natural number n>11−x, so 1n<1−x, that is, x<1−1n. Hence x∈[0,1−1n], and x is in the union.

So an intersection of half-open intervals can be closed, and a union of closed intervals can be half-open.

11. Using only the formula |X∪Y|=|X|+|Y|−|X∩Y| for finite sets and the laws of set algebra, prove that for all finite sets A, B and C,

|A∪B∪C|=|A|+|B|+|C|−|A∩B|−|A∩C|−|B∩C|+|A∩B∩C|

Use it to count the integers from 1 to 100 that are divisible by at least one of 2, 3 and 5.

Hint

Apply the two-set formula with X=A∪B and Y=C, then use the distributive law on (A∪B)∩C and apply the two-set formula again.

Solution

By the two-set formula with X=A∪B and Y=C,

|A∪B∪C|=|A∪B|+|C|−|(A∪B)∩C|

The first term is |A|+|B|−|A∩B|, by the two-set formula again. For the last term, the distributive law gives (A∪B)∩C=(A∩C)∪(B∩C), and the intersection of these two sets is (A∩C)∩(B∩C)=A∩B∩C, by the associative, commutative and idempotent laws. So, by the two-set formula once more,

|(A∪B)∩C|=|A∩C|+|B∩C|−|A∩B∩C|

Substituting both into the first display gives the formula.

For the count, let A, B and C be the multiples of 2, 3 and 5 in {1,…,100}. A number is a multiple of both 2 and 3 exactly when it is a multiple of 6 (proved in the lesson on direct proof), and similarly for the other pairs and for all three, since 2, 3 and 5 are distinct primes. The number of multiples of d from 1 to 100 is the quotient of 100 by d. So |A|=50, |B|=33, |C|=20, |A∩B|=16, |A∩C|=10, |B∩C|=6, |A∩B∩C|=3, and

|A∪B∪C|=50+33+20−16−10−6+3=74

So 74 of the numbers are divisible by at least one of 2, 3 and 5, and 26 by none of them.

Challenge

12. Prove that there is no set A with P(A)⊆A. Deduce again that there is no set of all sets.

Hint

Russell's set, carved out of A, is a subset of A.

Solution

Suppose, for contradiction, that A is a set with P(A)⊆A. By separation there is a set

R={x∈A:x∉x}

and R⊆A, so R∈P(A), and therefore R∈A. Now apply the membership rule to R itself. Since R∈A, the rule says R∈R exactly when R∉R. If R∈R, then R∉R; if R∉R, then R∈R. Either way there is a contradiction, so no such A exists.

If V were a set containing every set, then every subset of V, being a set, would be an element of V, so P(V)⊆V, which has just been shown impossible. So there is no set of all sets.

For finite sets the result is also a matter of counting, since a set with n elements has 2n>n subsets. The argument above works for every set, finite or infinite, and it is a special case of Cantor's theorem that P(A) is always strictly larger than A.

13. Let A, B and C be subsets of a universe U. Call a subset of U generated if it can be built from A, B and C by finitely many applications of ∪, ∩ and complement. For each of the 8 choices of X∈{A,Ac}, Y∈{B,Bc} and Z∈{C,Cc}, call X∩Y∩Z an atom. (a) Prove that the atoms are pairwise disjoint and that their union is U. (b) Prove that every generated set is a union of some collection of atoms. (c) Deduce that there are at most 256 generated sets, and exactly 256 when every atom is non-empty.

Hint

For (b), use structural induction on how a generated set is built. The union of the atoms in a collection S, the union of those in T, and the intersection of the two, correspond to S∪T and S∩T; by (a), the complement corresponds to the atoms not in S.

Solution

(a) Let x∈U. Exactly one of x∈A, x∈Ac holds, and likewise for B and C. So x lies in exactly one atom, namely the one whose factors are the sets containing x. Every element of U is in some atom, so the union of the atoms is U; no element is in two atoms, so the atoms are pairwise disjoint.

(b) For a collection S of atoms, write ⋃S for the union of the atoms in S (with ⋃S=∅ when S is empty). By (a), for every x∈U, x∈⋃S exactly when the unique atom containing x belongs to S. We prove by structural induction that every generated set has the form ⋃S.

Base cases: A is the union of the four atoms whose first factor is A, since an element of A lies in one of them and each of them lies inside A. Likewise for B and C.

Steps: suppose X=⋃S and Y=⋃T. For x∈U, let ax be the atom containing x. Then x∈X∪Y exactly when ax∈S or ax∈T, that is, ax∈S∪T, so X∪Y=⋃(S∪T). In the same way X∩Y=⋃(S∩T), and x∈Xc exactly when ax∉S, so Xc=⋃S′, where S′ is the collection of atoms not in S. So every rule preserves the property, and every generated set is a union of atoms.

(c) There are 8 atoms, hence 28=256 collections of atoms by the theorem on power sets, and by (b) each generated set is ⋃S for one of them. So there are at most 256 generated sets.

Conversely, every ⋃S is generated: each atom is generated, as an intersection of generated sets; unions of generated sets are generated; and ∅=A∩Ac is generated. If every atom is non-empty, then different collections give different sets: if S≠T, some atom lies in one and not the other, say in S and not in T, and an element of that atom is in ⋃S but, by (a), not in ⋃T. So there are exactly 256 generated sets in that case.

The count matches the 223=256 truth tables in three variables, and (b) is the set version of the fact from the lesson on statements and connectives that every formula is equivalent to a disjunction of conjunctions, its disjunctive normal form.

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 the lesson on sets, the quantifiers, and the direct, contrapositive and inductive 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, or the image of a. The set A is the domain of f and B is its codomain. The words map and mapping mean the same as function. A rule given by a formula is often written with a barred arrow, as in x↦x2, read "x goes to x2", and the whole function as "f:ℝ→ℝ, x↦x2".

"Rule" is informal: it suggests a formula or a procedure, and neither is needed. The previous lesson supplies the formal version.

Definition. A function from A to B consists of the sets A and B together with a subset G of A×B with the property that for every a∈A there is exactly one b∈B with (a,b)∈G. The set G is the graph of the function, and f(a) names the unique b with (a,b)∈G.

So a function is its table of values, nothing more: a list of pairs (input, output) in which every input appears exactly once. A seating plan that puts each of five guests at one of two tables is a function from the set of guests to the set of tables, as much as x↦3x+7 is a function from ℝ to ℝ, and neither is "more" of a function for having a formula. Written out, the condition on G is the conjunction of two quantified statements:

∀a∈A∃b∈B((a,b)∈G)∀a∈A∀b,b′∈B(((a,b)∈G∧(a,b′)∈G)⇒b=b′)

The first says every element of the domain receives a value; the second says none receives two. A proposed function can fail either, and checking that a rule defines a function means checking both. The second is often called checking that f is well defined, a phrase the next lesson meets again in a sharper form.

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. A rule can also fail the second condition in disguise. "Send the fraction ab to a" looks like a function from ℚ to ℤ, but 12=24, and the rule sends that one rational number to 1 through one name and to 2 through the other. Whenever an input can be named in more than one way and the rule reads the name, the second condition needs a proof.

Two functions are equal when they have the same domain, the same codomain, and the same value at every element of the domain; equivalently, the same domain, codomain and graph. So x↦(x+1)2 and x↦x2+2x+1 on ℝ are one function written two ways, and to prove two functions f,g:A→B equal, let a∈A be arbitrary and show f(a)=g(a).

A few functions appear so often that they have names. The identity on a set A is idA:A→A, idA(a)=a, whose graph is the diagonal {(a,a):a∈A}. If S⊆A, the inclusion ι:S→A is ι(s)=s; it has the same graph as idS but a different codomain, and the next section explains why that makes it a different function. A constant function A→B sends every element to one fixed b∈B. The projections A×B→A, (a,b)↦a, and A×B→B, (a,b)↦b, pick out a coordinate.

Two more are functions in disguise. A sequence of real numbers is a function ℕ→ℝ, with an written for its value at n, and the sequences of the course's last lesson, on limits, are functions in exactly this sense. For S⊆A, the characteristic function χS:A→{0,1} is 1 on S and 0 off it. It records the subset S as a function, and Problem 10 shows that subsets of A and functions A→{0,1} correspond exactly.

Functions of several variables need no new definition. Addition of real numbers is a function ℝ×ℝ→ℝ, (x,y)↦x+y, whose domain happens to be a product, and f(x,y) is shorthand for f((x,y)).

Is a function really just a set of pairs?

It took mathematics about a century to say yes. For Leonhard Euler, in his Introductio in analysin infinitorum of 1748, a function of a variable was an analytic expression built from the variable and constants: a formula. That view came under strain from Fourier series. Joseph Fourier claimed in the early nineteenth century that quite arbitrary functions, including ones given by different formulas on different intervals, could be written as sums of sines and cosines, and mathematicians had to decide whether such a sum, or a curve drawn freehand, was "one function".

Peter Gustav Lejeune Dirichlet settled the matter in the direction this lesson takes. In a paper of 1837 on Fourier series he said, in substance, that y is a function of x when to each x in an interval there corresponds a definite y, whether or not a single law connects them. His famous example, from 1829, is the function on ℝ that is 1 at every rational number and 0 at every irrational one: it has no graph anyone can draw and no formula of the kind Euler meant, and it is a perfectly good function. The fully set-theoretic version, a function as a set of ordered pairs with the "exactly one" condition, became standard in the twentieth century along with the set theory of the previous lesson.

There is one wrinkle, and it is why the definition above says "the sets A and B together with" a graph rather than "a graph". The graph determines the domain, which is the set of first coordinates, but it does not determine the codomain: the graph of x↦x2 on ℝ is the same set of pairs whether the codomain is ℝ or [0,∞). Some books define a function to be its graph alone and treat the codomain as extra information; most modern ones, and this course, make the codomain part of the function, because the property of being surjective depends on it. The two conventions describe the same mathematics and differ only in bookkeeping.

The ordered pair itself can be defined from sets. Kazimierz Kuratowski's definition of 1921, (a,b)={{a},{a,b}}, has the one property pairs need, that (a,b)=(c,d) exactly when a=c and b=d. With it, functions, relations and products are all sets, and set theory can serve as the foundation for the whole of mathematics.

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) (square roots exist, as the lesson on the real numbers proves). 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. Many books call the range the image of f and write it f(A), a notation the next section explains. Beware that some older books use "range" for the codomain; when a text's usage matters, check its definition.

The codomain can always be shrunk to the range, or to any set containing it, and the codomain can always be enlarged: if f:A→B and B⊆C, the same graph defines a function A→C. Shrinking the codomain of s to [0,∞) produced t. Enlarging a codomain can destroy surjectivity but never create it, and it never changes whether the function is injective (both notions are defined below).

The domain is less flexible. A formula such as 1x does not come with a domain, and "the function 1x" is incomplete until one is chosen. Calculus usually takes the largest set of reals on which the formula makes sense, here ℝ∖{0}, and calls it the natural domain, but that is a convention, and a proof must say which domain it means. A statement as simple as "1x is decreasing" is false on ℝ∖{0} (since −1<1 and 1−1<11) and true on (0,∞).

Image and preimage

A function acts on elements, and through them on sets of elements. For f:A→B and S⊆A, the image of S is

f(S)={f(x):x∈S}={y∈B:y=f(x) for some x∈S}

the set of values taken on S. For T⊆B, the preimage (or inverse image) of T is

f−1(T)={x∈A:f(x)∈T}

the set of inputs that land in T. The range is the image of the whole domain, f(A). The notation carries two traps. First, f(S) uses the same brackets as f(a) with a set in place of an element: f({2})={f(2)} is a set with one element, not the element f(2). Second, f−1(T) is a set, and it exists for every function, whether or not f has an inverse. The preimage of a single element is written f−1(b) for f−1({b}) and is called the fibre of f over b; it may be empty, or have one element, or many.

Membership in each is a statement with a quantifier, and proofs use it in that form. For the image the quantifier is existential: y∈f(S) exactly when there is x∈S with f(x)=y. For the preimage there is none: x∈f−1(T) exactly when x∈A and f(x)∈T. That difference, an "exists" hidden in one definition and absent from the other, explains almost everything in the next section.

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], so both inclusions hold. 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.

Computing an image is a small existence proof, and it is easy to get half of it. The claim s([−1,2])=[0,4] is an equality of sets, so it needs double inclusion: that every value on [−1,2] lies in [0,4], and that every element of [0,4] is actually reached. The first half alone would equally "prove" s([−1,2])=[0,100]. A preimage computation is an "if and only if": x∈s−1([1,4]) exactly when 1≤x2≤4, exactly when 1≤|x|≤2.

A round trip need not return where it started: the preimage of T=[−4,4] under s 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))=T∩f(A), exactly the part of T that f reaches, so equality holds for every T precisely when every element of B is a value (Problem 6).

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.

Images, preimages and the set operations

Unions, intersections and complements are the tools of the previous lesson, and a first question about any new operation on sets is which of them it respects. For preimages the answer is all of them. For images it is only some, and knowing which is part of knowing what a function is.

Theorem. Let f:A→B, let S1,S2⊆A and let T,T1,T2⊆B. Then:

(i) f−1(T1∪T2)=f−1(T1)∪f−1(T2);

(ii) f−1(T1∩T2)=f−1(T1)∩f−1(T2);

(iii) f−1(B∖T)=A∖f−1(T);

(iv) f(S1∪S2)=f(S1)∪f(S2);

(v) f(S1∩S2)⊆f(S1)∩f(S2), and the inclusion can be strict.

Proof. Parts (i) to (iii) are chains of equivalences, each step reversible, so each gives both inclusions at once. For (i), for every x∈A:

x∈f−1(T1∪T2)⟺f(x)∈T1∪T2⟺f(x)∈T1∨f(x)∈T2⟺x∈f−1(T1)∪f−1(T2)

using the definition of preimage, then of union, then of preimage and union again. Part (ii) is the same chain with ∧ and ∩ in place of ∨ and ∪. For (iii), for every x∈A, x∈f−1(B∖T) if and only if f(x)∈B∖T, if and only if f(x)∉T (since f(x)∈B automatically), if and only if x∉f−1(T), which for x∈A means x∈A∖f−1(T).

For (iv), double inclusion. Let y∈f(S1∪S2), so y=f(x) for some x∈S1∪S2. If x∈S1 then y∈f(S1), and if x∈S2 then y∈f(S2); either way y∈f(S1)∪f(S2). Conversely, let y∈f(S1)∪f(S2). If y∈f(S1), then y=f(x) for some x∈S1, and x∈S1∪S2, so y∈f(S1∪S2); the case y∈f(S2) is the same with the indices exchanged.

Part (v) is the Example below. □

The proofs of (i) to (iii) never needed cases: "x∈f−1(…)" translates directly into "f(x)∈…", and the set operation passes straight through. The same argument works for any family of sets, finite or not. If Ti⊆B for each i in an index set I, then

f−1(⋃i∈ITi)=⋃i∈If−1(Ti)f−1(⋂i∈ITi)=⋂i∈If−1(Ti)

and likewise the image of a union of any family is the union of the images. Both images and preimages also respect inclusion: if S1⊆S2 then f(S1)⊆f(S2), and if T1⊆T2 then f−1(T1)⊆f−1(T2). The proofs are one line each.

Example. Let f:A→B and S1,S2⊆A. Prove that f(S1∩S2)⊆f(S1)∩f(S2), and show that equality can fail.

Let y∈f(S1∩S2). Then y=f(x) for some x∈S1∩S2. Since x∈S1, y=f(x)∈f(S1), and since x∈S2, y∈f(S2). So y∈f(S1)∩f(S2), and as y was arbitrary the inclusion holds.

For the failure, take s(x)=x2 on ℝ, S1={−1} and S2={1}. Then S1∩S2=∅, so s(S1∩S2)=∅, while s(S1)=s(S2)={1} and s(S1)∩s(S2)={1}.

The attempted proof of the reverse inclusion shows exactly where it breaks. Let y∈f(S1)∩f(S2). Then y=f(x1) for some x1∈S1, and y=f(x2) for some x2∈S2. To finish we need one element of S1∩S2 with value y, and all we have is two elements, one in each set, with the same value. If f never sends two different elements to the same value, then x1=x2 and the proof goes through; that property is injectivity, defined in the next section, and Problem 5 proves that it is exactly what equality in (v) for all S1 and S2 requires.

Now you. Let f:A→B and S1,S2⊆A. Prove that f(S1)∖f(S2)⊆f(S1∖S2), and give an example where the inclusion is strict.

Answer

Let y∈f(S1)∖f(S2). Then y∈f(S1), so y=f(x) for some x∈S1, and y∉f(S2). If x were in S2, then y=f(x) would lie in f(S2), which it does not; so x∉S2. Hence x∈S1∖S2 and y=f(x)∈f(S1∖S2).

For strictness take s(x)=x2 on ℝ, S1={−1,1} and S2={1}. Then S1∖S2={−1} and s(S1∖S2)={1}, while s(S1)∖s(S2)={1}∖{1}=∅. The element −1 survives the difference, but its value is shared with the removed element 1.

Taking S1=A in the Now you, and writing S for S2, gives f(A)∖f(S)⊆f(A∖S): the image of a complement contains the part of the range outside f(S), and that is all that can be said in general. The image of a complement need not be inside the complement of the image either. With s and S=[0,∞), the image of ℝ∖S=(−∞,0) is (0,∞), while ℝ∖s(S)=(−∞,0), and these two sets are disjoint.

Why does the preimage respect every set operation when the image does not?

Look at the two definitions side by side. Membership in a preimage, x∈f−1(T), is the statement f(x)∈T, with no quantifier. Membership in an image, y∈f(S), is the statement ∃x(x∈S∧f(x)=y), with an existential quantifier. Every set operation is a connective in disguise (union is "or", intersection is "and", complement is "not"), so the question is which connectives pass through each definition.

With no quantifier in the way, all of them pass through the preimage: "f(x)∈T1∩T2" is literally "f(x)∈T1 and f(x)∈T2". The image has to move the connective past "there exists", and the lesson on quantifiers showed which moves are allowed. The existential quantifier distributes over "or": ∃x(P(x)∨Q(x)) is equivalent to ∃xP(x)∨∃xQ(x), and that is part (iv). It does not distribute over "and": ∃x(P(x)∧Q(x)) implies ∃xP(x)∧∃xQ(x), but not conversely, since the two witnesses on the right may be different objects. That is part (v), and the counterexample with −1 and 1 is exactly two different witnesses. Negation fails worst of all, because "not exists" is "for all not", a different kind of statement.

This is more than bookkeeping. The preimage turns f:A→B into a function P(B)→P(A), T↦f−1(T), which runs backwards and preserves unions, intersections and complements: in the language of algebra it is a homomorphism of Boolean algebras. Much of later mathematics is built on it. In topology a function between spaces is defined to be continuous when the preimage of every open set is open, and in measure theory a function is measurable when preimages of measurable sets are measurable. Both definitions use preimages rather than images for the reason given here: conditions stated through preimages are automatically compatible with unions, intersections and complements, so they combine well. For functions on ℝ, the preimage definition of continuity turns out to be equivalent to the ε, δ definition met in the course's last lesson.

Injective, surjective and bijective

A function f:A→B is injective, or one-to-one, when distinct inputs give distinct outputs: for all a,a′∈A, if a≠a′ then f(a)≠f(a′). 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) and 2≠−2.

A classic slip is to prove the converse, "if a=a′ then f(a)=f(a′)". That is true of every function, since it is the "none receives two values" half of the definition, so a proof of it says nothing about injectivity.

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. Equivalently, the range f(A) is all of 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 or a one-to-one correspondence, when it is both, so that each b∈B is the value of exactly one a∈A. The three properties have a compact description through fibres. For each b∈B, the fibre f−1(b) is the set of inputs with value b. Then f is injective when every fibre has at most one element, surjective when every fibre has at least one, and bijective when every fibre has exactly one. For a function on ℝ drawn as a graph, the fibre over b is where the horizontal line at height b meets the graph, which is the "horizontal line test" of school.

The 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:ℝ→[0,∞), x↦x2, is surjective and not injective, and s is neither. The identity on any set is a bijection.

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)=2bb−2bb−2−1=2bb−22b−2=b

So h is a bijection. Both excluded points were forced: 1 because the formula fails there, 2 because it is never reached.

For functions between sets of real numbers, one sufficient condition for injectivity is used constantly. A function f:A→ℝ with A⊆ℝ is strictly increasing if x<y implies f(x)<f(y) for all x,y∈A, and strictly decreasing if x<y implies f(x)>f(y).

Proposition. A strictly increasing or strictly decreasing function on a set of real numbers is injective.

Proof. Let f be strictly increasing, and let x≠y be in its domain. The statement is symmetric in x and y, so without loss of generality x<y. Then f(x)<f(y), so f(x)≠f(y). The decreasing case is the same with the inequality reversed. □

So x↦x3 is injective on ℝ: if x<y then y3−x3=(y−x)(y2+xy+x2), and the second factor is (y+x2)2+3x24, which is positive unless x=y=0, which cannot happen when x<y. The converse of the proposition fails: x↦1x on ℝ∖{0} is injective, since 1x=1y gives x=y, but it is neither increasing nor decreasing, as the section on the codomain showed. Proving that x↦x3 is also surjective on ℝ, that every real number has a real cube root, needs the completeness of the real numbers, which the lesson on the real numbers uses to prove that 2 exists; the argument for cube roots is the same.

Composition

Given f:A→B and g:B→C, the composite g∘f:A→C is defined by (g∘f)(a)=g(f(a)), read "g after f": f runs first. The composite exists only when the codomain of f is the domain of g (or, more loosely, when the range of f lies inside the domain of g), so that every value of f is something g can act on.

Order matters. With f(x)=x+1 and g(x)=x2 on ℝ, (g∘f)(x)=(x+1)2 and (f∘g)(x)=x2+1, so (g∘f)(1)=4 while (f∘g)(1)=2. When the sets differ, one composite may exist and the other not: with f:ℕ→ℤ and g:ℤ→{0,1}, g∘f makes sense and f∘g does not.

Proposition. Let f:A→B, g:B→C and h:C→D. Then

(i) h∘(g∘f)=(h∘g)∘f;

(ii) f∘idA=f and idB∘f=f.

Proof. Both sides of (i) are functions from A to D, so it is enough to compare values. For a∈A, (h∘(g∘f))(a)=h((g∘f)(a))=h(g(f(a))), and ((h∘g)∘f)(a)=(h∘g)(f(a))=h(g(f(a))). For (ii), (f∘idA)(a)=f(a) and (idB∘f)(a)=f(a) for every a∈A. □

Associativity means brackets can be dropped, and h∘g∘f has one meaning: apply f, then g, then h. Composition behaves like a multiplication with identities but without commutativity, which is how it reappears in algebra, where matrices multiply because the linear maps they represent compose.

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.

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. The converses hold only in part, and each half is worth knowing exactly.

Proposition. Let f:A→B and g:B→C.

(i) If g∘f is injective, then f is injective.

(ii) If g∘f is surjective, then g is surjective.

Proof. (i) Let a,a′∈A with f(a)=f(a′). Applying g gives g(f(a))=g(f(a′)), and since g∘f is injective, a=a′.

(ii) Let c∈C. Since g∘f is surjective, there is a∈A with g(f(a))=c. Put b=f(a), an element of B. Then g(b)=c. □

The other halves fail. Let f:[0,∞)→ℝ be the inclusion, f(x)=x, and g=s, squaring on ℝ. Then g∘f is x↦x2 on [0,∞), which is injective (it is strictly increasing there), yet g is not injective. The fault is that g is only ever applied to values of f, and the values where g misbehaves, the negative numbers, are never reached. Similarly, with f:ℝ→ℝ, f(x)=x2, and g:ℝ→[0,∞), g(x)=|x|, the composite x↦x2 from ℝ to [0,∞) is surjective, while f is not. So if g∘f is a bijection, all that follows is that f is injective and g is surjective; Problem 8 shows that nothing more follows without further hypotheses.

Inverses

To undo f:A→B is to have a function going back that cancels it from both sides. A function g:B→A is an inverse of f when

g∘f=idAandf∘g=idB

that is, g(f(a))=a for every a∈A and f(g(b))=b for every b∈B. A function with an inverse is called invertible. The two conditions do different jobs, and the theorem that says which functions have inverses shows exactly how.

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

Proof. (⇒) Suppose g:B→A is an inverse of f. For injectivity, let a,a′∈A with 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), an element of A. Then f(a)=f(g(b))=b. So f is a bijection.

(⇐) Suppose f is a bijection. For each b∈B, surjectivity gives some a∈A with f(a)=b, and injectivity says there is only one. Let g(b) be that a. This assigns exactly one element of A to each b∈B, so g:B→A is a function; in terms of graphs, the graph of g is {(b,a):(a,b)∈G}, the graph of f with each pair reversed, and bijectivity is precisely what makes this reversed set satisfy the "exactly one" condition. By construction f(g(b))=b for every b∈B. For a∈A, g(f(a)) is the unique element of A with value f(a), and a is such an element, so g(f(a))=a. Hence g is an inverse of f. □

In the forward direction, g∘f=idA forced injectivity and f∘g=idB forced surjectivity. Neither alone is enough, as the next section shows.

Proposition. Let f:A→B.

(i) If f has an inverse, it has only one.

(ii) If g is the inverse of f, then g is a bijection and f is the inverse of g.

(iii) If f:A→B and h:B→C are bijections, then h∘f is a bijection, and its inverse is f−1∘h−1.

Proof. (i) Let g and k both be inverses of f. Using associativity and both halves of the definition,

g=g∘idB=g∘(f∘k)=(g∘f)∘k=idA∘k=k

(ii) The two equations g∘f=idA and f∘g=idB, read with the roles of f and g exchanged, say that f is an inverse of g. By the theorem, g is then a bijection.

(iii) By the associativity of composition,

(f−1∘h−1)∘(h∘f)=f−1∘(h−1∘h)∘f=f−1∘idB∘f=f−1∘f=idA

and in the same way (h∘f)∘(f−1∘h−1)=h∘idB∘h−1=idC. So f−1∘h−1 is an inverse of h∘f, which is therefore a bijection by the theorem. □

By (i) the inverse earns a name, f−1. For f(x)=3x+7 on ℝ it is f−1(y)=y−73, the formula the surjectivity proof already found. The order reversal in (iii) is the rule of socks and shoes: socks go on first and shoes second, so to undo the process the shoes come off first.

The symbol f−1 now has two meanings, the preimage of a set under any function and the inverse function of a bijection, and they agree wherever both make sense. If f is a bijection and T⊆B, then x∈f−1(T) (preimage) means f(x)∈T, which, applying the inverse, means x=f−1(y) for some y∈T, that is, x lies in the image of T under the function f−1. So the clash is harmless, as long as the preimage is never mistaken for evidence that an inverse exists.

A bijection from a set to itself is also called a permutation of the set. The permutations of a set A are closed under composition and inverses and include idA, which makes them the first example of a group; for a set of n elements there are n! of them, as the section on counting shows.

Left and right inverses

Splitting the definition of an inverse in two gives two weaker notions. Let f:A→B. A function g:B→A is a left inverse of f if g∘f=idA, and a right inverse of f if f∘g=idB. (The names follow the side on which g is written in the composite.) A left inverse undoes f: apply f, then g, and you are back where you started. A right inverse is undone by f: g picks, for each b, an input that f sends back to b.

Theorem. Let f:A→B.

(i) If A is not empty, then f is injective if and only if it has a left inverse.

(ii) f is surjective if and only if it has a right inverse.

(iii) If f has a left inverse g and a right inverse h, then g=h, and f is a bijection with inverse g.

Proof. (i) (⇐) If g∘f=idA and f(a)=f(a′), then a=g(f(a))=g(f(a′))=a′, as in the proof of the previous theorem. (⇒) Suppose f is injective. Since A is not empty, fix an element a0∈A. Define g:B→A by cases. If b lies in the range f(A), there is an a∈A with f(a)=b, and by injectivity only one, so let g(b) be that a. If b∉f(A), let g(b)=a0. Every b∈B falls in exactly one case and receives exactly one value, so g is a function. For a∈A, the element f(a) lies in the range, and a is the unique element with value f(a), so g(f(a))=a. Hence g∘f=idA.

(ii) (⇐) If f∘g=idB and b∈B, put a=g(b); then f(a)=f(g(b))=b. (⇒) Suppose f is surjective. For each b∈B the fibre f−1(b) is not empty; choose an element of it and call it g(b). Then g:B→A is a function, and f(g(b))=b for every b, because g(b) lies in the fibre over b. Hence f∘g=idB.

(iii) Using associativity, g=g∘idB=g∘(f∘h)=(g∘f)∘h=idA∘h=h. So g satisfies both g∘f=idA and f∘g=idB, and it is an inverse of f; by the previous theorem f is a bijection. □

The hypothesis in (i) is needed only for a technical reason, and the reason is instructive. The empty function ∅→B is injective, because the condition "if f(a)=f(a′) then a=a′" has no instances to fail. A left inverse would be a function B→∅, and if B has an element there is nowhere to send it. So the empty function into a non-empty set is injective with no left inverse, and the theorem has to exclude it.

Left and right inverses, unlike two-sided ones, are usually far from unique, and the Example shows how many there can be.

Example. Let d:ℕ→ℕ, d(n)=2n, as before. Describe all left inverses of d, and show that none of them is a right inverse.

A function e:ℕ→ℕ is a left inverse exactly when e(d(n))=n for every n, that is, when e(2n)=n for every natural number n. This fixes e on the even numbers, where it must halve, and says nothing about the odd ones. So the left inverses of d are exactly the functions

e(m)={m2if m is evenφ(m)if m is odd

where φ is any function from the odd natural numbers to ℕ. For instance φ(m)=1 and φ(m)=m give two different left inverses. None of them is a right inverse: for every left inverse e, the value d(e(1))=2e(1) is even, so it is not 1, and d∘e≠idℕ. That agrees with the theorem, since d is injective and not surjective.

Now you. Let q:ℤ→ℤ send n to its quotient on division by 2, so that n=2q(n)+r with r∈{0,1}. Show that q is surjective, find two different right inverses of q, and show that q has no left inverse.

Answer

By the division algorithm, q is a function: each integer has exactly one quotient. The fibre over m∈ℤ is q−1(m)={2m,2m+1}, because 2m=2m+0 and 2m+1=2m+1 are divisions with remainder in range, so both have quotient m, and any n with quotient m equals 2m+r with r∈{0,1}. Every fibre is non-empty, so q is surjective.

A right inverse must choose one element of each fibre. Let g1(m)=2m and g2(m)=2m+1. Then q(g1(m))=m and q(g2(m))=m for every m, so both are right inverses, and they differ, for instance g1(0)=0≠1=g2(0). Mixing the choices, say 2m for even m and 2m+1 for odd m, gives infinitely many more.

A left inverse would make q injective, by part (i) of the theorem. But q(0)=q(1)=0 with 0≠1, so q is not injective and has no left inverse.

What does "choose an element of each fibre" rely on?

In the Now you nothing was really chosen: the fibres were written down, and "take the smaller element" is a rule. The same works for any surjection whose domain is ℕ, since the well-ordering principle gives every non-empty fibre a least element, and "send b to the least element of its fibre" defines a right inverse outright. The proof of part (ii) of the theorem, though, said "choose an element of each fibre" for an arbitrary surjection, possibly with infinitely many fibres and no rule to pick from any of them. That is an infinite number of arbitrary choices made at once, and none of the principles used so far licenses it.

The principle that does is the axiom of choice: for every family of non-empty sets, there is a function picking one element from each. Ernst Zermelo stated it explicitly in 1904, to prove that every set can be well-ordered, and it was controversial at once, precisely because it asserts that a function exists without describing it. Bertrand Russell's illustration is well known: from infinitely many pairs of shoes one can choose one shoe from each pair by a rule ("take the left one"), but from infinitely many pairs of socks, where the two members of a pair cannot be told apart, no rule is available, and the axiom is needed to say that a choice exists at all.

The statement "every surjection has a right inverse" is not merely a consequence of the axiom of choice; it is equivalent to it. Given a family of non-empty sets Xi, the function sending each pair (i,x) with x∈Xi to its index i is a surjection onto the index set, and a right inverse picks, for each i, a pair (i,x) with x∈Xi, which is exactly a choice of one element from each set. So part (ii) of the theorem cannot be proved without the axiom.

Kurt Gödel showed in 1938 that adding the axiom of choice to the other axioms of set theory cannot produce a contradiction unless they already contain one, and Paul Cohen showed in 1963 that the same is true of adding its negation. So the axiom is independent of the others: they neither prove nor refute it. Almost all of mainstream mathematics accepts it, and much of analysis and algebra uses it, often in the form of Zorn's lemma, which the lesson on order states. The left-inverse half of the theorem needs no such axiom: there the only choice is the single element a0, and choosing one element from one non-empty set is ordinary logic.

Restriction

Many useful functions are not injective, and most of them become injective once part of the domain is discarded. Let f:A→B and S⊆A. The restriction of f to S is the function f|S:S→B given by f|S(x)=f(x) for x∈S. Its graph is the part of the graph of f lying over S, and in terms of composition f|S=f∘ι, where ι:S→A is the inclusion. Conversely, when g=f|S we call f an extension of g to A.

Restriction keeps some properties and changes others. The range of f|S is f(S), the image of S, which is how images and restrictions are tied together. If f is injective, so is every restriction, since a pair of inputs in S with the same value is a pair in A with the same value; formally, f∘ι is a composite of injections. Surjectivity is usually lost, and injectivity is often gained: s(x)=x2 is not injective on ℝ, but s|[0,∞) is, because x2 is strictly increasing on [0,∞).

Restricting the domain and shrinking the codomain to the range together turn a function into a bijection whenever the restriction is injective. If f:A→B is injective, then the same rule, viewed as a function A→f(A), is surjective by the definition of the range and injective because f is, so it is a bijection. This is how the classical inverse functions are made. The square root is the inverse of x↦x2 restricted to [0,∞) with codomain [0,∞). The function arcsin is the inverse of sin restricted to [−π2,π2], with codomain [−1,1]; other intervals would have done, and the choice of that one is a convention, like the choice of the non-negative square root.

Example. Let p:ℝ→ℝ, p(x)=x2−4x+1. Show that p is not injective, and prove that its restriction to [2,∞), with codomain [−3,∞), is a bijection. Find its inverse.

Completing the square, p(x)=(x−2)2−3. So p(0)=1=p(4), and p is not injective on ℝ: the graph is symmetric about the line x=2.

Let P:[2,∞)→[−3,∞) be the restriction, with the smaller codomain. It is a function into [−3,∞), since (x−2)2≥0 gives P(x)≥−3. Injective: let a,a′≥2 with P(a)=P(a′). Then (a−2)2=(a′−2)2, and both a−2 and a′−2 are non-negative. Two non-negative numbers with the same square are equal (if u,v≥0 and u2=v2, then (u−v)(u+v)=0, so u=v, or u+v=0, which forces u=v=0). So a−2=a′−2 and a=a′. Surjective: let y≥−3 and put a=2+y+3, defined because y+3≥0. Then a≥2, so a is in the domain, and P(a)=(y+3)2−3=y. So P is a bijection, and the element with value y is 2+y+3, which gives P−1(y)=2+y+3.

The restriction to (−∞,2] would have worked as well, with inverse y↦2−y+3. Each half of the parabola carries its own inverse.

Now you. Let f:ℝ→ℝ, f(x)=x2+2x. Prove that the restriction of f to (−∞,−1], with codomain [−1,∞), is a bijection, and find its inverse.

Answer

Completing the square, f(x)=(x+1)2−1, so every value is at least −1 and the restriction F:(−∞,−1]→[−1,∞) is a function.

Injective: let a,a′≤−1 with F(a)=F(a′). Then (a+1)2=(a′+1)2. Here a+1≤0 and a′+1≤0, so −(a+1) and −(a′+1) are non-negative numbers with the same square, hence equal, and a=a′.

Surjective: let y≥−1 and put a=−1−y+1, defined because y+1≥0. Then a≤−1, so a is in the domain, and F(a)=(−y+1)2−1=y.

So F is a bijection with inverse F−1(y)=−1−y+1. The minus sign in front of the root is forced by the choice of the left half of the parabola; the plus sign would give a number outside the domain whenever y>−1.

Going the other way, a function can be built on a set piece by piece and then glued. Suppose A=S∪T, and g:S→B and h:T→B agree on the overlap, meaning g(x)=h(x) for every x∈S∩T. Then there is exactly one function f:A→B with f|S=g and f|T=h: its graph is the union of the graphs of g and h. Each x∈A lies in S or T, so it receives a value; if it lies in both, the two values agree, so it receives only one. This is what justifies a definition by cases, such as |x|=x for x≥0 and |x|=−x for x≤0: the pieces overlap at 0, and there they agree. Where pieces overlap and disagree, as in "f(x)=1 for x≥0 and f(x)=2 for x≤0", no function has been defined.

Counting functions between finite sets

For finite sets the three properties can be counted, and the counts explain a good deal. Write |A| for the number of elements of a finite set A.

Theorem. Let |A|=m and |B|=n.

(i) There are nm functions from A to B.

(ii) There are n(n−1)(n−2)⋯(n−m+1) injections from A to B, a product of m factors; in particular there are none when m>n.

(iii) There are n! bijections from A to B when m=n, and none otherwise.

Proof. (i) By induction on m. When m=0, A=∅, and there is exactly one function from ∅ to B, since its graph must be a subset of ∅×B=∅, and the empty graph satisfies the "exactly one" condition vacuously; and n0=1. Suppose the count is right for sets of m elements, and let |A|=m+1. Fix a∈A and put A′=A∖{a}, with m elements. A function f:A→B is determined by the pair (f|A′,f(a)), and every pair (g,b) with g:A′→B and b∈B arises from exactly one f, by the gluing principle of the previous section. So the functions A→B correspond exactly to the elements of the product of the set of functions A′→B with B, which by the product rule of the previous lesson has nm⋅n=nm+1 elements.

(ii) The same induction, with one change. An injection f:A→B is determined by the pair (f|A′,f(a)), where f|A′ is an injection and f(a) must avoid its m values: n−m choices for each of the n(n−1)⋯(n−m+1) injections A′→B. That gives n(n−1)⋯(n−m+1)(n−m), the formula for m+1. When m>n, the factor n−n=0 appears in the product, so the count is 0.

(iii) If m=n, the theorem below shows that the bijections are exactly the injections, and there are n(n−1)⋯1=n! of them. If m≠n, a bijection A→B would make the two sets the same size, which the counts of values forbid: an injection needs m≤n by (ii), and a surjection needs m≥n, since m inputs take at most m values. □

The product n(n−1)⋯(n−m+1) is a falling factorial, and it counts ordered selections without repetition, the subject of the Discrete Mathematics lesson on arrangements. The statement that there is no injection from a set of m elements into a set of n<m elements is the pigeonhole principle: put more than n letters into n pigeonholes and some pigeonhole receives two. The lesson on contrapositive and contradiction uses it as a tool; here it has appeared as a count.

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, ignoring 29 February, the injective fraction is 365⋅364⋯34336523≈0.493, so a shared birthday is more likely than not.

Counting surjections is harder, since there is no single running choice to count, and it needs inclusion and exclusion. For small sets it can be done by hand: a surjection from a 4-element set onto a 3-element set must send exactly two elements to one value and one element to each of the other two, and Problem 11 counts them.

What is a function from the empty set?

Exactly one, for every set B, including B=∅: its graph is the empty set, and the condition on graphs holds vacuously, since there is no element of ∅ for it to fail at. It is called the empty function.

A function from a non-empty set A to ∅ is another matter: an element a∈A needs a value in ∅, and there is none. So there are no functions from a non-empty set to the empty set.

These are exactly the values of nm that the counting formula needs. The number of functions ∅→B with |B|=n is n0=1, and the number of functions A→∅ with |A|=m≥1 is 0m=0. The single case m=n=0 gives one function, the empty function from ∅ to itself, and this is one of the reasons mathematicians working with finite sets take 00=1. Likewise 0!=1 counts the one bijection from ∅ to itself.

The empty function is injective, since there is no pair of inputs to collide, and surjective only onto ∅; it is why part (i) of the theorem on left inverses needs A to be non-empty. Cases like this look like pedantry, but they are what let formulas such as nm and 2n hold without exceptions.

For sets of the same finite size, the counts show that injective and surjective come together, and there is a direct proof.

Theorem. Let A and B be finite sets with |A|=|B|, and let f:A→B. Then f is injective if and only if it is surjective, and so if and only if it is a bijection.

Proof. Let |A|=|B|=n.

(⇒) Suppose f is injective. Its n values at the n elements of A are all different, so the range f(A) has n elements. It is a subset of B, and the elements of B outside it number n−n=0. So f(A)=B, and f is surjective.

(⇐) Suppose f is surjective but not injective. The fibres f−1(b), for b∈B, are disjoint, since each element of A has one value, and their union is A, so their sizes add up to n. Each of the n fibres has at least one element, by surjectivity, and some fibre has at least two, since two different elements share a value. Then the sizes add up to at least (n−1)+2=n+1, a contradiction. So f is injective. □

The theorem is used constantly in a practical form: to show that a map between finite sets of the same size is a bijection, prove only one of the two properties, whichever is easier. It fails without both hypotheses. It needs the sizes equal, as the inclusion of {1} in {1,2} shows, and it needs finiteness.

What goes wrong for infinite sets?

The map d:ℕ→ℕ, d(n)=2n, is injective and not surjective, and the map n↦⌈n2⌉ on ℕ is surjective and not injective, since 1 and 2 both go to 1. So for maps from an infinite set to itself, the two properties separate completely, and the theorem above is special to finite sets. The proof shows where finiteness entered: it subtracted and added numbers of elements, and for infinite sets there are no such numbers to compare.

Galileo noticed the phenomenon in his Two New Sciences of 1638. The squares 1,4,9,16,… are a small part of the natural numbers, becoming rarer the further one goes, yet n↦n2 pairs the natural numbers one to one with the squares. He concluded that "equal", "greater" and "less" do not apply to infinite quantities. Richard Dedekind turned the paradox into a definition in 1888: he called a set infinite when it can be put in bijection with a proper subset of itself, as ℕ can with the even numbers or the squares. By the theorem above, no finite set has this property, since a bijection from a finite set A onto a proper subset S, composed with the inclusion of S in A, would be an injection A→A that is not surjective.

Georg Cantor took the other way out of Galileo's paradox. Rather than give up comparing infinite sets, define two sets to have the same size when there is a bijection between them, and accept that a set can have the same size as a part of itself. The lesson on counting the infinite develops this, with bijections and injections doing all the work, and finds that infinite sets come in more than one size.

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. Functions themselves produce such relations: every f:A→B gives the relation "has the same value under f as" on A, which links a to a′ when f(a)=f(a′), and whose linked groups are exactly the non-empty fibres. The next lesson takes such relations up, beginning with the ones that declare two things to be the same for present purposes, and shows that every one of them arises from a function in this way.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Let A={1,2,3} and B={x,y}. Which of these subsets of A×B are graphs of functions A→B? For each one that is, give its range and say whether it is injective and whether it is surjective. (a) {(1,x),(2,x),(3,x)}; (b) {(1,x),(2,y)}; (c) {(1,x),(1,y),(2,x),(3,y)}; (d) {(1,y),(2,x),(3,y)}.

Solution

(a) A function: each of 1, 2, 3 appears exactly once as a first coordinate. It is the constant function with value x, its range is {x}, it is not injective (1 and 2 share the value x) and not surjective (y is not a value).

(b) Not a function: 3 does not appear as a first coordinate, so it receives no value.

(c) Not a function: 1 appears twice, with values x and y.

(d) A function with range {x,y}=B, so it is surjective. It is not injective, since 1 and 3 both have value y. No function from a set of three elements to a set of two can be injective, by the pigeonhole principle.

2. Let f:ℝ→ℝ, f(x)=|x|. Find f([−3,1]), f−1([1,2]), f−1([−2,−1]), f−1(f([1,2])) and f(f−1([−1,4])), justifying the first by double inclusion.

Solution

f([−3,1])=[0,3]. If −3≤x≤1, then 0≤|x|≤3, so every value on [−3,1] lies in [0,3]. Conversely, if 0≤y≤3, then −y∈[−3,0]⊆[−3,1] and f(−y)=y, so y is a value on [−3,1].

f−1([1,2])=[−2,−1]∪[1,2], since 1≤|x|≤2 exactly when 1≤x≤2 or −2≤x≤−1.

f−1([−2,−1])=∅, since |x|≥0 for every x.

f([1,2])=[1,2], as f is the identity on non-negative numbers, so f−1(f([1,2]))=f−1([1,2])=[−2,−1]∪[1,2], strictly larger than [1,2].

f−1([−1,4])=[−4,4], since |x|≥0>−1 always and |x|≤4 exactly when −4≤x≤4. Then f([−4,4])=[0,4], strictly smaller than [−1,4]. This is [−1,4]∩f(ℝ)=[−1,4]∩[0,∞), as Problem 6 predicts.

3. Decide whether each function is injective and whether it is surjective, with proofs. (a) ℤ→ℤ, n↦n+3. (b) ℤ→ℤ, n↦3n. (c) ℤ→{0,1,2,…}, n↦|n|. (d) ℝ×ℝ→ℝ, (x,y)↦x+y.

Solution

(a) Injective: if n+3=m+3 then n=m. Surjective: let b∈ℤ and put n=b−3, an integer, with n+3=b. So it is a bijection.

(b) Injective: if 3n=3m then n=m. Not surjective: if 3n=1 for an integer n, then 3∣1, but a divisor of 1 has absolute value at most 1. So 1 is not a value.

(c) Surjective: let m≥0 be an integer; then m∈ℤ and |m|=m. Not injective: |1|=|−1| and 1≠−1.

(d) Surjective: let b∈ℝ; then (b,0)∈ℝ×ℝ and b+0=b. Not injective: (1,0) and (0,1) are different pairs with the same value 1. In fact every fibre is a whole line, {(x,b−x):x∈ℝ}.

4. Let f,g:ℝ→ℝ be given by f(x)=2x+1 and g(x)=x2+1. Find formulas for g∘f and f∘g and show that they are different functions. Find f−1 and check both of the equations that make it an inverse.

Solution

(g∘f)(x)=g(2x+1)=(2x+1)2+1=4x2+4x+2, and (f∘g)(x)=f(x2+1)=2x2+3. At x=0 the first is 2 and the second is 3, so g∘f≠f∘g.

Solving 2x+1=y for x suggests f−1(y)=y−12. Check: for every real x, f−1(f(x))=(2x+1)−12=x, and for every real y, f(f−1(y))=2⋅y−12+1=y. So both f−1∘f and f∘f−1 are the identity on ℝ.

Core

5. Let f:A→B. Prove that f is injective if and only if f(S1∩S2)=f(S1)∩f(S2) for all subsets S1 and S2 of A.

Hint

For the forward direction one inclusion is the Example in the lesson; the other is where the lesson's failed attempt got stuck. For the backward direction, use the contrapositive with one-element sets.

Solution

(⇒) Suppose f is injective, and let S1,S2⊆A. The inclusion f(S1∩S2)⊆f(S1)∩f(S2) holds for every function, by the Example in the section on set operations. For the reverse, let y∈f(S1)∩f(S2). Then y=f(x1) for some x1∈S1 and y=f(x2) for some x2∈S2. So f(x1)=f(x2), and by injectivity x1=x2. This element lies in both S1 and S2, so y=f(x1)∈f(S1∩S2).

(⇐) We prove the contrapositive. Suppose f is not injective, so there are a≠a′ in A with f(a)=f(a′). Take S1={a} and S2={a′}. Then S1∩S2=∅, so f(S1∩S2)=∅, while f(S1)∩f(S2)={f(a)}∩{f(a′)}={f(a)}, which is not empty. So the equality fails for this pair of subsets.

6. Let f:A→B.

(a) Prove that f(f−1(T))=T∩f(A) for every T⊆B, and deduce that f is surjective if and only if f(f−1(T))=T for every T⊆B.

(b) Prove that f is injective if and only if f−1(f(S))=S for every S⊆A.

Hint

Each "if and only if" has one direction that needs a single well-chosen set: T=B in (a), and a one-element set in (b).

Solution

(a) Let T⊆B. By the Example in the section on image and preimage, f(f−1(T))⊆T, and every element of f(f−1(T)) is a value of f, so lies in f(A); hence f(f−1(T))⊆T∩f(A). Conversely, let y∈T∩f(A). Then y=f(x) for some x∈A, and f(x)=y∈T, so x∈f−1(T) and y=f(x)∈f(f−1(T)).

If f is surjective, then f(A)=B, and T∩B=T for every T⊆B, so f(f−1(T))=T. Conversely, if f(f−1(T))=T for every T, take T=B: since f−1(B)=A, this says f(A)=B, so f is surjective.

(b) (⇒) Suppose f is injective and let S⊆A. The inclusion S⊆f−1(f(S)) holds for every function (the Now you in the section on image and preimage). For the reverse, let x∈f−1(f(S)). Then f(x)∈f(S), so f(x)=f(x′) for some x′∈S, and by injectivity x=x′∈S.

(⇐) Suppose f−1(f(S))=S for every S⊆A, and let a,a′∈A with f(a)=f(a′). Take S={a′}. Then f(a)=f(a′)∈f(S), so a∈f−1(f(S))={a′}, which gives a=a′. So f is injective.

7. Find the flaw in this proof, and show that the claim is false.

Claim. Let f:A→B and g:B→C. If g∘f is injective, then g is injective.

Proof. Let b,b′∈B with g(b)=g(b′). Write b=f(a) and b′=f(a′) with a,a′∈A. Then g(f(a))=g(f(a′)), and since g∘f is injective, a=a′. Hence b=f(a)=f(a′)=b′, so g is injective.

Hint

The second sentence asserts that something exists. What property of f would guarantee it?

Solution

The flaw is the second sentence. It assumes that b and b′ are values of f, which holds for all b,b′∈B only when f is surjective, and nothing in the hypothesis says so. The argument never considers elements of B outside the range of f, and those are exactly where g may fail to be injective.

A counterexample: let A={1}, B={1,2}, C={1}, with f(1)=1 and g(1)=g(2)=1. Then g∘f:{1}→{1} is injective, since its domain has only one element, but g is not, since g(1)=g(2) and 1≠2.

The argument does prove a correct statement: if g∘f is injective and f is surjective, then g is injective. Then the second sentence is justified by surjectivity, and the rest goes through unchanged.

8. Let f:A→B and g:B→C. Prove or disprove each claim. (a) If g∘f is a bijection, then f is surjective. (b) If g∘f is surjective and g is injective, then f is surjective. (c) If f and g∘f are bijections, then g is a bijection. (d) If g∘f is injective and g is surjective, then f is surjective.

Hint

Two are true. For the false ones, the smallest sets you can think of will do: the counterexample in Problem 7 is a good place to start. For (c), write g as a composite.

Solution

(a) False. Take A={1}, B={1,2}, C={1}, f(1)=1 and g(1)=g(2)=1. Then g∘f:{1}→{1} is a bijection, but f is not surjective, since 2 is not a value. Nor is g injective, so a bijective composite says nothing about f being surjective or g being injective.

(b) True. Let b∈B. Then g(b)∈C, and g∘f is surjective, so there is a∈A with g(f(a))=g(b). Since g is injective, f(a)=b. So every b∈B is a value of f.

(c) True. Since f is a bijection it has an inverse f−1:B→A, and (g∘f)∘f−1=g∘(f∘f−1)=g∘idB=g by associativity. So g is a composite of the bijections f−1 and g∘f, and a composite of bijections is a bijection.

(d) False. The example in (a) works again: g∘f is injective, g:{1,2}→{1} is surjective, and f is not surjective.

9. Prove that f:ℝ→(−1,1), f(x)=x1+|x|, is a bijection, and find a formula for f−1.

Hint

First check that the values lie in (−1,1) and that f(x) has the same sign as x. Then split injectivity and surjectivity into the cases of non-negative and negative inputs, where the absolute value can be removed.

Solution

Values. For every real x, 1+|x|>|x|≥0, so |f(x)|=|x|1+|x|<1 and f(x)∈(−1,1). So f is a function into (−1,1). Since the denominator is positive, f(x)>0 when x>0, f(x)=0 when x=0, and f(x)<0 when x<0.

Injective. Let a,a′∈ℝ with f(a)=f(a′). By the sign observation, a and a′ are both non-negative or both negative. If both are non-negative, then a1+a=a′1+a′, so a+aa′=a′+aa′ and a=a′. If both are negative, then |a|=−a and |a′|=−a′, so a1−a=a′1−a′, which gives a−aa′=a′−aa′ and a=a′.

Surjective. Let y∈(−1,1). If 0≤y<1, put x=y1−y, a real number since y≠1, and non-negative. Then 1+|x|=1+y1−y=11−y, so f(x)=y1−y⋅(1−y)=y. If −1<y<0, put x=y1+y, a real number since y≠−1, and negative since y<0<1+y. Then |x|=−y1+y and 1+|x|=11+y, so f(x)=y1+y⋅(1+y)=y.

So f is a bijection. The two cases of the surjectivity proof combine into one formula, since 1−|y| is 1−y for y≥0 and 1+y for y<0:

f−1(y)=y1−|y|for −1<y<1

A bijection between ℝ and a bounded interval may be surprising. It shows that, in the sense of the lesson on counting the infinite, the whole line and a short piece of it have the same size.

10. Let A be a set, and let F be the set of all functions from A to {0,1}. For S⊆A, let χS be the characteristic function of S.

(a) Prove that Φ:P(A)→F, Φ(S)=χS, is a bijection, by showing that Ψ:F→P(A), Ψ(g)=g−1({1}), is its inverse.

(b) Prove that χS∩T=χS⋅χT and χA∖S=1−χS for all S,T⊆A, where the operations on the right are taken value by value.

(c) Deduce that a set of n elements has 2n subsets.

Hint

For (a), check Ψ∘Φ=idP(A) and Φ∘Ψ=idF; the second is an equality of functions, proved by comparing values at an arbitrary a∈A, in two cases. For (c), use the counting theorem.

Solution

(a) For S⊆A, Ψ(Φ(S))=χS−1({1})={a∈A:χS(a)=1}=S, by the definition of χS. So Ψ∘Φ=idP(A).

For g∈F, let S=g−1({1}); we show χS=g by comparing values. Let a∈A. If g(a)=1, then a∈S, so χS(a)=1=g(a). If g(a)=0, then a∉S, so χS(a)=0=g(a). These cases are exhaustive, since g takes values in {0,1}. So Φ(Ψ(g))=g, and Φ∘Ψ=idF. Hence Ψ is an inverse of Φ, and Φ is a bijection.

(b) Let a∈A. If a∈S∩T, both sides of the first equation are 1 at a, since 1⋅1=1. If a∉S∩T, then a∉S or a∉T, so one of χS(a) and χT(a) is 0 and the product is 0=χS∩T(a). For the second, if a∈S then χA∖S(a)=0=1−1, and if a∉S then χA∖S(a)=1=1−0.

(c) Let |A|=n. By the counting theorem, there are 2n functions from A to the 2-element set {0,1}, so |F|=2n. Since Φ is a bijection from P(A) to F, and a bijection between finite sets exists only when they have the same number of elements (the same theorem, part (iii)), |P(A)|=2n. This is the count the previous lesson proved by induction, now obtained by translating subsets into functions. Part (b) shows the translation also turns set operations into arithmetic, which is how computers store and combine sets, as strings of bits.

11. How many surjections are there from a set of 4 elements onto a set of 3 elements? Check your answer by counting the functions that are not surjective and adding.

Hint

The fibres of a surjection partition the domain into non-empty pieces, one for each element of the codomain. What sizes can they have?

Solution

Let A={1,2,3,4} and B={x,y,z}. The three fibres of a surjection f:A→B are non-empty, disjoint, and together make up A, so their sizes are positive integers adding to 4: one fibre has 2 elements and the others 1 each.

A surjection is therefore determined by three choices: which element b of B has the fibre of size 2 (3 ways); which two elements of A form that fibre (6 ways: {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}); and how the remaining two elements of A are sent to the remaining two elements of B, one each (2 ways). Different choices give different functions, and every surjection arises from one set of choices, namely its own. So there are 3×6×2=36 surjections.

Check. A function that is not surjective has range of size 1 or 2. Range of size 1: a constant function, 3 of them. Range of size 2: choose the two values (3 ways), then a function from A onto that 2-element set; there are 24=16 functions from A to a 2-element set, of which 2 are constant, so 14 are onto, giving 3×14=42. In total 36+42+3=81=34, the number of all functions from A to B.

Challenge

12. Let f:A→B.

(a) Prove that f is injective if and only if, for every set C and all functions h,k:C→A, f∘h=f∘k implies h=k.

(b) Prove that f is surjective if and only if, for every set C and all functions h,k:B→C, h∘f=k∘f implies h=k.

Hint

The forward directions compare values. For the backward directions argue by contrapositive and build h and k on very small sets: a one-element C in (a), and C={0,1} in (b), with a characteristic function.

Solution

(a) (⇒) Suppose f is injective, and let h,k:C→A with f∘h=f∘k. For every c∈C, f(h(c))=f(k(c)), so h(c)=k(c) by injectivity. The functions h and k have the same domain, codomain and values, so h=k.

(⇐) Suppose the cancellation property holds, and let a,a′∈A with f(a)=f(a′). Let C={0}, and define h,k:C→A by h(0)=a and k(0)=a′. Then (f∘h)(0)=f(a)=f(a′)=(f∘k)(0), so f∘h=f∘k, and the property gives h=k. Hence a=h(0)=k(0)=a′, and f is injective.

(b) (⇒) Suppose f is surjective, and let h,k:B→C with h∘f=k∘f. Let b∈B. There is a∈A with f(a)=b, and then h(b)=h(f(a))=k(f(a))=k(b). So h=k.

(⇐) We prove the contrapositive. Suppose f is not surjective, and choose b0∈B outside the range of f. Let C={0,1}, let h:B→C be the constant function 0, and let k=χ{b0}, which is 1 at b0 and 0 elsewhere. For every a∈A, f(a)≠b0, so k(f(a))=0=h(f(a)), and h∘f=k∘f. But h(b0)=0≠1=k(b0), so h≠k, and the cancellation property fails.

The two properties describe injectivity and surjectivity purely by how f composes with other functions, without mentioning elements. That is how category theory, which studies mathematical structures through the maps between them, defines its general notions of monomorphism and epimorphism. Note that no choice was needed in (b), unlike the right inverse of the lesson: cancellation is a weaker property than having a right inverse, and is available for every surjection outright.

13. Prove that there is no function f:ℤ→ℤ with f(f(n))=n+1 for every integer n.

Hint

Compute f(f(f(n))) in two ways: as f applied to f(f(n)), and as f∘f applied to f(n). That determines f up to one constant.

Solution

Suppose, for a contradiction, that f:ℤ→ℤ satisfies f(f(n))=n+1 for every integer n. Let n∈ℤ. Applying the hypothesis to the integer f(n) gives f(f(f(n)))=f(n)+1. Applying f to both sides of f(f(n))=n+1 gives f(f(f(n)))=f(n+1). Hence

f(n+1)=f(n)+1for every integer n

Let c=f(0). We show f(n)=n+c for every integer n. For n≥0 this is an induction on n: it holds at n=0, and if f(n)=n+c then f(n+1)=f(n)+1=(n+1)+c. For negative integers, rewrite the displayed equation as f(n)=f(n+1)−1 and induct on k≥0 for the statement f(−k)=−k+c: it holds at k=0, and if f(−k)=−k+c, then f(−k−1)=f(−k)−1=(−k−1)+c.

Now apply the hypothesis at n=0: 1=f(f(0))=f(c)=c+c=2c. But 2c is even and 1 is odd, and no integer is both. This contradiction shows that no such f exists.

The obstruction is arithmetic, not logical. On ℝ the function x↦x+12 satisfies f(f(x))=x+1, and on ℤ the equation f(f(n))=n+2 is satisfied by n↦n+1; the proof shows that on ℤ every solution of f(f(n))=n+m is a translation by m2, which exists exactly when m is even.

14. A function f:A→A is idempotent if f∘f=f.

(a) Prove that f is idempotent if and only if f(y)=y for every y in the range f(A).

(b) Prove that an idempotent function that is injective, or surjective, is the identity.

(c) How many idempotent functions are there from {1,2,3,4} to itself?

Hint

For (c), use (a): an idempotent function is determined by its range R and by where it sends the elements outside R. Count by the size of R.

Solution

(a) (⇒) Let f be idempotent and y∈f(A), say y=f(x). Then f(y)=f(f(x))=f(x)=y. (⇐) Suppose f fixes every element of its range, and let x∈A. Then f(x) is in the range, so f(f(x))=f(x). Hence f∘f=f.

(b) Let f be idempotent. If f is injective, then for each x∈A the equation f(f(x))=f(x) says that f(x) and x have the same value, so f(x)=x. If f is surjective, its range is A, and by (a) it fixes every element of A. In both cases f=idA.

(c) Let A={1,2,3,4}. By (a), an idempotent f fixes each element of its range R=f(A), which is non-empty because A is, and sends each element of A∖R into R. So f determines a pair (R,g), where R is a non-empty subset of A and g=f|A∖R is a function A∖R→R.

Conversely, every such pair comes from exactly one idempotent. Given a non-empty R⊆A and g:A∖R→R, define f to be the identity on R and g on A∖R. Its range contains R, since f fixes R, and is contained in R, since every value lies in R; so the range is R, f fixes its range, and f is idempotent by (a). Its pair is (R,g) again, and different pairs give different functions. So the idempotents correspond exactly to the pairs.

For |R|=k there are k4−k functions A∖R→R, by the counting theorem. Summing over the subsets R by size: 4 subsets of size 1, each giving 13=1; 6 of size 2, each giving 22=4; 4 of size 3, each giving 31=3; and 1 of size 4, giving 40=1. The total is 4+24+12+1=41.

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, functions with their images and preimages, the quantifiers, and divisibility: a∣b when b=ak for some integer k. It also uses the division algorithm from the lesson on direct proof: for integers a and n with n>0 there are unique integers q and r with a=qn+r and 0≤r<n.

Relations as sets of pairs

A relation from a set A to a set B is a subset R of A×B, and a relation on A is a relation from A to A, a subset of A×A. When the pair (a,b) belongs to R we say a is related to b and write aRb, or a∼b when the relation has a symbol of its own. 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 small relation on a finite set can be drawn. Put a dot for each element and an arrow from a to b whenever a∼b, with a loop at a when a∼a. The drawing, a directed graph, carries exactly the information of the set of pairs, and each property defined below becomes a visible feature of it: a loop at every dot, arrows that always come in opposite pairs, a short cut for every path of two arrows.

A function from A to B fits the same mould. Its graph, {(a,f(a)):a∈A}, is a relation from A to B in which every a∈A appears as a first coordinate exactly once, so functions are the relations with that property, as the previous lesson defined them. 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.

Every relation R from A to B has an inverse (or converse) relation R−1={(b,a):(a,b)∈R} from B to A, obtained by reversing every pair. The inverse of "divides" is "is a multiple of". The inverse of the graph of a function is again a relation, and it is the graph of a function exactly when the function is a bijection, which is the theorem on inverses from the previous lesson in this language.

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)

Definition. A relation on A that is reflexive, symmetric and transitive is an equivalence relation on A.

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. An equivalence relation is a way of saying "these two are the same, for present purposes": same birthday, same remainder, same fractional part, same value. The three properties are the minimum any notion of sameness must have.

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. The argument does prove something: in a symmetric and transitive relation, every element related to anything is related to itself.

"Close to" deserves a second look, because it is the commonest way to go wrong outside mathematics. Two measurements that agree within a tolerance are "the same" for practical purposes, but the tolerance does not chain: 0.0 and 0.9 agree within 1, as do 0.9 and 1.8, while 0.0 and 1.8 do not. A chain of a thousand indistinguishable steps can join two very different things, which is the old paradox of the heap in modern dress. A relation that must be an equivalence cannot be defined by a tolerance.

Two further properties belong to the next lesson but are worth naming now so that they are not confused with these. A relation is irreflexive when no element is related to itself, as with <, which is stronger than failing to be reflexive: the relation xy>0 above is neither reflexive nor irreflexive, since 1∼1 holds and 0∼0 does not. And it is antisymmetric when a∼b and b∼a together force a=b, as with ≤. Symmetric and antisymmetric are not opposites: equality is both.

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. Label the three parts, and in each state what is assumed and what is to be shown.

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, and the same proof works with ℤ replaced by any set of reals with those three properties, such as ℚ or the multiples of 5.

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. This time the proof used that the nonzero rationals contain 1 and are closed under reciprocals and products: the multiplicative version of the Example.

Equivalence classes

An equivalence relation says which elements are "the same". Gathering each element together with everything the same as it gives the central object of this lesson.

Definition. Let ∼ be an equivalence relation on A and a∈A. The equivalence class of a is the set of everything related to it:

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

Any element of a class is a representative of it. The set of all equivalence classes is the quotient of A by ∼, written A/∼ and read "A modulo ∼", and the function π:A→A/∼, π(a)=[a], is the quotient map.

Under the fractional part relation of the Example above, [0.7]={…,−1.3,−0.3,0.7,1.7,2.7,…}, and [0.7]=[2.7]: one class, two names. Each class contains exactly one number in [0,1), the common fractional part, so the classes correspond to the points of [0,1). Under "has the same birthday as", the class of a person is everyone born on the same day of the year, and there are at most 366 classes.

The quotient is a set whose elements are sets, and the notation hides a trap. The class [a] is named after one of its elements, but it does not remember which name was used: [0.7] and [2.7] are the same set, as much as 12 and 24 are the same number. Everything that follows turns on one fact, that a class is the same whichever representative names it.

Lemma. Let ∼ be an equivalence relation on A, and let a,b∈A. The following are equivalent:

(i) a∼b;

(ii) [a]=[b];

(iii) [a]∩[b]≠∅.

Proof. We prove (i) ⇒ (ii) ⇒ (iii) ⇒ (i).

(i) ⇒ (ii). Suppose a∼b. We show [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].

(ii) ⇒ (iii). By reflexivity a∼a, so a∈[a]. If [a]=[b], then a lies in both, and the intersection is not empty.

(iii) ⇒ (i). Suppose c∈[a]∩[b], so c∼a and c∼b. Symmetry gives a∼c, and transitivity applied to a∼c and c∼b gives a∼b. □

Each property of an equivalence relation did a visible job. Reflexivity put every element in its own class, symmetry let the relation be read in either direction, and transitivity carried membership from one class to another. The lemma says two classes are either equal or disjoint, never partly overlapping, and that is the content of the partition theorem below.

Example. On ℝ2=ℝ×ℝ, let (x,y)∼(x′,y′) when y−x2=y′−x2′. Prove that ∼ is an equivalence relation, describe its classes, and find a set containing exactly one representative of each class.

Reflexive: y−x2=y−x2. Symmetric: an equation read from right to left is the same equation. Transitive: if y−x2=y′−x2′ and y′−x2′=y′′−x2′′, then y−x2=y′′−x2′′. So ∼ is an equivalence relation, and all three properties came straight from the corresponding properties of equality, because the relation compares the value of one quantity, y−x2, at two points.

The class of (x0,y0) is the set of points (x,y) with y−x2=c, where c=y0−x02: the parabola y=x2+c. So the classes are the parabolas y=x2+c, one for each real c, stacked vertically and filling the plane without overlapping. The parabola y=x2+c crosses the y axis exactly once, at (0,c), so the y axis {(0,c):c∈ℝ} contains exactly one representative of each class.

Now you. On ℝ2, let (x,y)∼(x′,y′) when x2+y2=x2′+y2′. Prove that ∼ is an equivalence relation, describe its classes, and find a set containing exactly one representative of each class.

Answer

Reflexive, symmetric and transitive follow from the same properties of equality, applied to the values of x2+y2, exactly as in the Example. So ∼ is an equivalence relation.

The class of (x0,y0) is the set of points (x,y) with x2+y2=r2, where r=x02+y02≥0. For r>0 this is the circle of radius r centred at the origin, and for r=0 it is the single point (0,0), since x2+y2=0 forces x=y=0. So the classes are the circles centred at the origin together with the origin itself.

The ray {(r,0):r≥0} contains exactly one representative of each class: the class of radius r meets the x axis at (r,0) and (−r,0), and only the first has a non-negative first coordinate (for r=0 the two coincide). Leaving out the origin would miss a class, and taking the whole x axis would count every circle twice.

A set containing exactly one element of each class, like the y axis in the Example or the ray in the Now you, is called a set of representatives or a transversal. For congruence modulo n, later in the lesson, the remainders 0,1,…,n−1 are the standard one.

Classes and partitions

A partition of a set A is a collection of non-empty subsets of A, its blocks, such that every element of A lies in exactly one block. The even and odd integers partition ℤ; the positive reals, the negative reals and {0} partition ℝ; birthdays partition a room. The sets {1,2} and {2,3} do not partition {1,2,3}, because 2 lies in both, and neither do {1} and {2}, because 3 lies in neither.

Theorem (the partition theorem). Let A be a set.

(i) If ∼ is an equivalence relation on A, then its equivalence classes form a partition of A.

(ii) If Q is a partition of A, then the relation "a∼b when a and b lie in the same block" is an equivalence relation on A, whose equivalence classes are exactly the blocks of Q.

(iii) These two constructions are inverse to each other: starting from an equivalence relation, forming its partition into classes, and then the relation "in the same class" returns the original relation; starting from a partition, forming the relation "in the same block", and then its classes returns the original partition.

Proof. (i) Each class is non-empty, since a∈[a] by reflexivity, and every element of A lies in at least one class, its own. If a lies in two classes [b] and [c], then [b]∩[c]≠∅, so [b]=[c] by the lemma. So every element lies in exactly one class.

(ii) Reflexive: every a lies in some block, and a is in the same block as itself. Symmetric: "a and b lie in the same block" does not depend on the order in which they are named. Transitive: suppose a and b share a block S, and b and c share a block T. Then b lies in both S and T, and since it lies in exactly one block, S=T; so a and c share the block S. For the classes, let a∈A and let S be the block containing a. Then x∈[a] exactly when x lies in the same block as a, which is exactly when x∈S. So [a]=S, and every block is a class, because every block is non-empty and so is the class of any of its elements.

(iii) Starting from ∼, two elements lie in the same class exactly when [a]=[b], which by the lemma is exactly when a∼b, so the relation "in the same class" is ∼ again. Starting from a partition, part (ii) showed that the classes of "in the same block" are the blocks. □

So equivalence relations on A and partitions of A are one idea described two ways, and the theorem gives a bijection between the set of equivalence relations on A and the set of partitions of A. Either description can be used, whichever is easier: a relation is often easier to define, and a partition easier to see. 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.

How many equivalence relations does a finite set carry?

By the partition theorem, as many as it has partitions. Write Bn for the number of partitions of a set of n elements. Counting by hand gives B1=1, B2=2 and B3=5, and it is natural to take B0=1, since the empty set has exactly one partition, the empty collection of blocks (every element of ∅ lies in exactly one block, vacuously).

There is a recurrence. Take a set of n+1 elements and fix one of them, z. A partition is determined by two things: the set K of elements not in the same block as z, which can be any subset of the other n elements, and a partition of K into the remaining blocks. If K has k elements, there are (nk) ways to choose K and Bk ways to partition it, so

Bn+1=∑k=0n(nk)Bk

From B0=B1=1 and B2=2 this gives B3=1+2⋅1+1⋅2=5, then B4=1+3+6+5=15, B5=1+4+12+20+15=52 and B6=203. These are the Bell numbers, named after Eric Temple Bell, who wrote about them in the 1930s. They grow much faster than 2n but much slower than the 2n2 relations: on a set of 4 elements, 15 of the 65536 relations are equivalence relations.

The number 52 was known long before. In the Japanese incense game genjikō, played from the Edo period, five packets of incense are burned and the players must say which of them were the same; the 52 possible answers, the partitions of a set of five, were drawn as small diagrams of vertical and horizontal bars and each named after a chapter of The Tale of Genji. Refining the count by the number of blocks gives the Stirling numbers of the second kind, and Problem 14 finds two of them.

Congruence modulo n

The most important equivalence relation in elementary mathematics compares integers by their remainders. 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), since 17−2=15, and −7≡2(mod3), since −7−2=−9. 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.

This is the fractional part Example over again, with the multiples of n in place of the integers: the proof used only that the multiples of n contain 0 and are closed under negation and addition.

The classes are the congruence classes (or residue classes) modulo n, and the class of a is

[a]={b∈ℤ:b≡a(modn)}={a+kn:k∈ℤ}

the integers reached from a by adding or subtracting n any number of times. When the modulus needs saying, write [a]n.

Theorem. Let n be a positive integer. Then a≡b(modn) exactly when a and b leave the same remainder on division by n. Consequently there are exactly n congruence classes modulo n, namely [0],[1],…,[n−1], and they are all different.

Proof. Divide both numbers by n: a=qn+r and b=q′n+r′ with 0≤r,r′<n. If r=r′, then a−b=(q−q′)n, so a≡b(modn). Conversely, suppose a−b=kn. Then a=b+kn=(q′+k)n+r′ with 0≤r′<n, which is a division of a by n with remainder in range, so by the uniqueness half of the division algorithm r=r′.

So every integer a is congruent to its remainder r, and lies in the class [r], one of [0],[1],…,[n−1]. These n classes are different, because two distinct numbers r and s in the range 0 to n−1 are their own remainders, which differ, so they are not congruent, and by the lemma on classes [r]≠[s]. □

For n=3:

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

and these three sets partition ℤ. For n=2 the two classes are the even and the odd integers, so the corollary of the division algorithm that every integer is even or odd, and not both, is the partition theorem for congruence modulo 2. For n=1 there is a single class, ℤ itself, since 1 divides everything.

The set of congruence classes modulo n is written ℤ/nℤ, read "ℤ mod nℤ", where nℤ={nk:k∈ℤ} is the set of multiples of n; some books write ℤn. So

ℤ/nℤ={[0],[1],…,[n−1]}

is a set of n elements, each of which is an infinite set of integers. The remainders 0 to n−1 form a set of representatives, and there are others: {−1,0,1} also contains one element of each class modulo 3.

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

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 3∣a+2b exactly when 3∣a−b: this is congruence modulo 3 in disguise, and its classes are [0], [1] and [2] modulo 3. Spotting the disguise first would have given all three properties at once from the Example.

Why not just work with the remainders 0 to n−1?

For integers, one could. Define an arithmetic on the set {0,1,…,n−1} by "add or multiply as usual, then take the remainder", and nothing in this lesson would be lost. Many programming languages do exactly that, and the Discrete Mathematics course computes with remainders all the time.

The classes earn their place in three ways. First, they need no choice of representative. The remainders are one set of representatives among many, and statements such as [a]+[b]=[a+b], proved below, hold for every representative at once, which is what makes computations such as [−1]100=[1] legitimate without first converting −1 to n−1. Second, the construction works where no convenient representatives exist. In the fractional-part relation on ℝ the interval [0,1) does the job, but for the fractions built at the end of this lesson, "the representative in lowest terms" needs the theory of greatest common divisors to even define, while the classes need nothing. Third, the same construction applies far beyond the integers. The notation ℤ/nℤ records that the classes are the sets a+nℤ, translates of the set of multiples of n. Group theory takes any group G and any suitable subgroup H and forms G/H from the translates of H in exactly this way; linear algebra forms quotient spaces V/W of a vector space by a subspace; topology glues spaces together by declaring points equivalent. In each case there is usually no preferred representative, and the classes are the only way to proceed.

The price is the obligation that the next section is about: any operation defined through representatives must be shown to be independent of them.

Well defined operations

Clock arithmetic adds hours: nine o'clock plus five hours is two o'clock. In the language of classes, that is the rule

[a]+[b]=[a+b][a]⋅[b]=[ab]

on ℤ/nℤ, with n=12. The rule is stated through representatives: to add two classes, pick an element of each, add the elements, and take the class of the result. A class has infinitely many representatives, and nothing yet guarantees that different choices give the same answer. If they did not, the rule would assign several values to one pair of classes, and it would not be a function at all.

Definition. Let ∼ be an equivalence relation on A, and let F be a rule that assigns to each element of A an element of a set C. The rule "[a]↦F(a)" is well defined on A/∼ when

a∼a′⇒F(a)=F(a′)for all a,a′∈A

that is, when F takes the same value on all representatives of a class. For a rule in two variables, such as addition, the condition is that a∼a′ and b∼b′ together imply F(a,b)=F(a′,b′).

In the language of the previous lesson, the rule proposes the set of pairs {([a],F(a)):a∈A} as the graph of a function on A/∼. Every class appears as a first coordinate, since every class has a representative, so the first half of the definition of a function is automatic. The second half, that no class appears with two different values, is exactly the condition above. A proof that a rule is well defined is therefore a proof that it defines a function, and it must always be given.

Here is one that fails. "Send the class of a modulo 3 to the class of a modulo 6", [a]3↦[a]6, looks innocent. But [0]3=[3]3, and the rule sends this one class to [0]6 through one name and to [3]6 through the other, and [0]6≠[3]6 because 6∤3. So there is no such function. The rule [a]↦a from ℤ/nℤ to ℤ fails for the same reason whenever n>1: [0]=[n] but 0≠n.

Addition modulo n, on the other hand, is well defined. Let a≡a′(modn) and b≡b′(modn), say a−a′=nk and b−b′=nm. Then

(a+b)−(a′+b′)=(a−a′)+(b−b′)=n(k+m)

so a+b≡a′+b′(modn), and [a+b]=[a′+b′]. Clock arithmetic works whether nine o'clock is represented by 9, 21 or −3.

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

Let a≡a′(modn) and b≡b′(modn), so a−a′=nk and b−b′=nm for integers k and m. The goal is n∣ab−a′b′, and the trick is to change one factor at a time, adding and subtracting the mixed product ab′:

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

Since am+b′k is an integer, ab≡a′b′(modn), so [ab]=[a′b′] and the product class does not depend on the representatives.

Because both operations are well defined, congruences can be added and multiplied like equations: from a≡a′ and b≡b′ follow a+b≡a′+b′ and ab≡a′b′, and by induction ak≡ak′ for every natural number k. That is how large remainders are found without large numbers. For example, 10≡1(mod9), so 10k≡1k=1(mod9) for every k, and a number with decimal digits dk…d1d0 satisfies

d0+10d1+102d2+⋯+10kdk≡d0+d1+⋯+dk(mod9)

so a number and the sum of its digits leave the same remainder on division by 9: the old rule of "casting out nines". Similarly 210=1024≡1(mod11), since 1024=11×93+1, so 21000=(210)100≡1100=1(mod11).

With the operations in hand, ℤ/nℤ is a number system with n elements. It obeys the familiar laws, commutativity, associativity and distributivity, because each law holds for representatives and the operations are computed from representatives: for instance [a]([b]+[c])=[a(b+c)]=[ab+ac]=[a][b]+[a][c]. It also behaves in unfamiliar ways. In ℤ/6ℤ, [2][3]=[6]=[0], a product of two non-zero classes that is zero. In ℤ/5ℤ that never happens, and every non-zero class has a multiplicative inverse: [1][1]=[2][3]=[4][4]=[1]. Which n behave like 5 and which like 6, and why, is the subject of the Discrete Mathematics lesson on modular arithmetic, which builds on the definitions here.

Now you. Show that the rule [a]12↦[a]4, from ℤ/12ℤ to ℤ/4ℤ, is well defined, and that the rule [a]4↦[a]12 is not. Interpret the first on a clock face.

Answer

Well defined: suppose [a]12=[a′]12, so a−a′=12k for some integer k. Then a−a′=4(3k), so a≡a′(mod4) and [a]4=[a′]4. The value does not depend on the representative.

Not well defined: [0]4=[4]4, since 4∣4−0, but [0]12≠[4]12, since 12∤4. The rule gives two different values for one class.

On a clock face, the first rule sorts the twelve hours into four classes by their remainder on division by 4: 1, 5 and 9 o'clock all go to [1]4, and 4, 8 and 12 o'clock to [0]4. It is well defined because 4∣12, so a full turn of the clock is a whole number of cycles of 4. The same argument shows that [a]n↦[a]m is well defined whenever m∣n.

Can congruence classes be raised to powers?

A power with a class as the base is fine: [a]k=[ak] for a natural number k is repeated multiplication, and it is well defined because multiplication is. The trouble is a class in the exponent. The rule [a][b]=[ab] on ℤ/nℤ, with b restricted to non-negative representatives, is not well defined. Modulo 3, [1]=[4], but 21=2 and 24=16≡1(mod3), so [2][1] would be both [2] and [1]. The base respects congruence modulo n, and the exponent does not.

The exponent does respect a different congruence. Pierre de Fermat stated in a letter of 1640 what is now called Fermat's little theorem: if p is prime and p∤a, then ap−1≡1(modp). Granting it, if b≡b′(modp−1) with b,b′≥0, say b=b′+(p−1)t with t≥0, then ab=ab′(ap−1)t≡ab′(modp). So for a base not divisible by p, the exponent may be reduced modulo p−1: modulo 3, exponents live modulo 2, and indeed 21≡2 and 24≡1 differ because 1 and 4 are not congruent modulo 2. Leonhard Euler generalised this to any modulus, and the result is the arithmetic behind RSA encryption, where a message is raised to one power to encrypt it and to another, chosen through the exponent's own modulus, to decrypt it. The Discrete Mathematics lesson on Fermat, Euler and RSA proves both theorems.

The lesson for well-definedness is that an operation can respect the relation in one argument and not in another, so each argument must be checked.

Kernels and quotient maps

Several equivalence relations in this lesson had the same shape: two points of the plane were related when y−x2, or x2+y2, took the same value at both. Every function produces a relation of this kind, and every equivalence relation arises this way.

Definition. Let f:A→B. The kernel of f is the relation on A given by a∼fa′ when f(a)=f(a′).

The name is borrowed from algebra, where the kernel of a homomorphism is the set of elements sent to the identity, and the relation defined here is its general form. (Some books call it the equivalence kernel, or the relation "induced by" f.)

Theorem. Let f:A→B.

(i) The kernel ∼f is an equivalence relation on A, and its classes are the non-empty fibres f−1(b), for b in the range f(A).

(ii) The rule f‾:A/∼f→f(A), f‾([a])=f(a), is well defined and is a bijection.

(iii) f=ι∘f‾∘π, where π:A→A/∼f is the quotient map and ι:f(A)→B is the inclusion.

(iv) Every equivalence relation ∼ on a set A is the kernel of its own quotient map π:A→A/∼.

Proof. (i) Reflexivity, symmetry and transitivity of ∼f are those of equality, applied to the values of f: f(a)=f(a); if f(a)=f(a′) then f(a′)=f(a); if f(a)=f(a′) and f(a′)=f(a′′) then f(a)=f(a′′). The class of a is {x∈A:f(x)=f(a)}, which is the fibre f−1(f(a)). Conversely each fibre over an element b=f(a) of the range is the class of a.

(ii) Well defined: if [a]=[a′], then a∼fa′, which means f(a)=f(a′). Surjective: every element of f(A) is f(a)=f‾([a]) for some a. Injective: if f‾([a])=f‾([a′]), then f(a)=f(a′), so a∼fa′ and [a]=[a′] by the lemma on classes.

(iii) For a∈A, (ι∘f‾∘π)(a)=ι(f‾([a]))=f(a).

(iv) For a,a′∈A, π(a)=π(a′) means [a]=[a′], which by the lemma on classes means a∼a′. So the kernel of π is ∼. □

Part (iii) says that every function is a surjection, then a bijection, then an injection: first collapse each fibre to a single point, then match the collapsed points one to one with the values, then include the values in the codomain. Part (iv) says that "equivalence relation" and "kernel of a function" are the same notion. Together they give a practical method. To prove a relation is an equivalence, it is enough to find a function whose equal values define it, and then the classes are the fibres and can be counted by counting the values.

In the proof of (ii), well-definedness and injectivity were the same argument read in opposite directions: "a∼fa′ implies f(a)=f(a′)" and "f(a)=f(a′) implies a∼fa′". That is typical. A rule on classes is well defined when it does not distinguish elements that the relation identifies, and injective when it distinguishes all the elements that the relation does not identify.

Example. On ℤ, let a∼b when a2≡b2(mod5). Show that ∼ is an equivalence relation, and find its classes.

The relation is the kernel of f:ℤ→ℤ/5ℤ, f(a)=[a2], since a2≡b2(mod5) says exactly [a2]=[b2]. So it is an equivalence relation by part (i) of the theorem, and its classes are the non-empty fibres of f.

To find the fibres, note that f(a)=[a]2 depends only on the class of a modulo 5, because multiplication of classes is well defined. So it is enough to square the five classes: [0]2=[0], [1]2=[1], [2]2=[4], [3]2=[9]=[4] and [4]2=[16]=[1]. The range of f is {[0],[1],[4]}, and the fibres are

f−1([0])=[0]5f−1([1])=[1]5∪[4]5f−1([4])=[2]5∪[3]5

So there are three classes: the multiples of 5, the integers congruent to 1 or −1 modulo 5, and those congruent to 2 or −2. The classes [2] and [3] are not squares modulo 5, so their fibres are empty and contribute no class. As a check, 32=9 and 72=49 are congruent modulo 5, and indeed 3≡−2 and 7≡2 lie in the same class.

Now you. On ℤ, let a∼b when a3≡b3(mod7). Show that ∼ is an equivalence relation, and find its classes.

Answer

It is the kernel of f:ℤ→ℤ/7ℤ, f(a)=[a3]=[a]3, so it is an equivalence relation, with the non-empty fibres of f as its classes. Since f(a) depends only on [a]7, cube the seven classes: 03=0; 13=1; 23=8≡1; 33=27≡6; 43=64≡1; 53=125≡6; 63=216≡6. (For instance 125=7×17+6 and 216=7×30+6.)

The range is {[0],[1],[6]}, and the three classes are [0]7, then [1]7∪[2]7∪[4]7, then [3]7∪[5]7∪[6]7. So 2∼4∼8∼9 and 3∼5∼−1, while 1 and 3 are in different classes.

What else is built by identifying things?

Much of geometry and topology. Take the fractional-part relation on ℝ from the start of the lesson, x∼y when x−y∈ℤ, and form the quotient ℝ/∼, usually written ℝ/ℤ. Each class has exactly one representative in [0,1), but the quotient is better pictured as a circle than as an interval. Numbers just below 1, such as 0.99, are close to numbers just above 0, such as 0.01, once 1 and 0 are identified, so walking right along ℝ goes round and round the quotient. The kernel theorem makes this exact: the function x↦(cos2πx,sin2πx) from ℝ to the unit circle is surjective, and its kernel is exactly ∼, because the cosine and sine of two angles both agree exactly when the angles differ by a whole number of turns. So ℝ/ℤ is in bijection with the circle. Angles, times of day and the phase of any periodic process live naturally in this quotient.

The same idea in two dimensions: on ℝ2, let (x,y)∼(x′,y′) when both x−x′ and y−y′ are integers. Each class has one representative in the unit square [0,1)×[0,1), and passing to the quotient glues the left edge of the square to the right edge and the bottom edge to the top. The result is a torus, the surface of a ring doughnut, and it is the world of old arcade games in which a ship leaving the screen on one side reappears on the other. Gluing the edges of a strip with a half twist gives a Möbius band; identifying each point of a sphere with the opposite point gives the projective plane, the setting of projective geometry.

In algebra the same move builds new number systems. The complex numbers can be constructed as a quotient of the polynomials with real coefficients, by declaring two polynomials equivalent when their difference is a multiple of x2+1, so that the class of x becomes a square root of −1. The arithmetic of ℤ/nℤ is the simplest instance of all these constructions, and the requirement met in this lesson, that the operations be well defined, is exactly what each of them has to check.

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).

Proof. 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, and it fails exactly at the step that cancelled d.

Definition. A rational number is an equivalence class [(a,b)] of pairs in P, written ab, and ℚ=P/∼ is the set of these classes.

So 12 is the set {(1,2),(2,4),(−3,−6),(5,10),…}, and the familiar facts about fractions become facts about classes. "ab=cd exactly when ad=bc" is the lemma on classes. "Every fraction can be written with a positive denominator" says that each class contains a pair with b>0, since (a,b)∼(−a,−b). "Every fraction can be written in lowest terms" says that each class contains a pair with b>0 and no common factor greater than 1, and that such a pair is unique, which is a real theorem about integers rather than a fact about notation.

The integers sit inside ℚ through the map j:ℤ→ℚ, j(n)=[(n,1)]. It is injective: if [(n,1)]=[(m,1)] then n⋅1=1⋅m, so n=m. It is not surjective, since [(1,2)] is not [(n,1)] for any integer n (1⋅1=2n has no integer solution). Identifying each integer n with j(n) is how "ℤ⊆ℚ" is meant.

Arithmetic comes next, through representatives, and it carries the obligation of the section on well defined operations. The school rules

ab+cd=ad+bcbdab⋅cd=acbd

compute with a chosen pair from each class, and they define operations on ℚ only if the answer is independent of the choice. A school favourite shows that this can fail: "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. So ⊕ is not an operation on ℚ at all.

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 (ad+bc,bd) lies in P and the result is a rational number. 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, grouping, and substituting the two hypotheses,

(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.

Now you. Prove that multiplication of rationals, [(a,b)]⋅[(c,d)]=[(ac,bd)], is well defined, and check that on integers it agrees with ordinary multiplication: j(m)⋅j(n)=j(mn).

Answer

Since b≠0 and d≠0, bd≠0, so (ac,bd)∈P. Let (a,b)∼(a′,b′) and (c,d)∼(c′,d′), so ab′=ba′ and cd′=dc′. We must show (ac)(b′d′)=(bd)(a′c′). Rearranging and substituting,

(ac)(b′d′)=(ab′)(cd′)=(ba′)(dc′)=(bd)(a′c′)

so the product class does not depend on the representatives. On integers, j(m)⋅j(n)=[(m,1)]⋅[(n,1)]=[(mn,1)]=j(mn). The same check for addition gives [(m⋅1+1⋅n,1)]=j(m+n), so the new arithmetic extends the old.

With both operations defined, the laws of arithmetic on ℚ are proved from those on ℤ one representative at a time, as for ℤ/nℤ. The new feature is division: a non-zero rational [(a,b)] has a≠0, so (b,a)∈P, and [(a,b)]⋅[(b,a)]=[(ab,ba)]=[(1,1)]=j(1), since ab⋅1=ba⋅1. Every non-zero rational has a multiplicative inverse, which no integer other than 1 and −1 has in ℤ. The division that could not be assumed has been built.

Is a fraction really an infinite set of pairs?

It is one way to make "fraction" precise, and the point of the construction is not that anyone should think of 12 as an infinite set while doing arithmetic. The point is that the construction exists. It shows that the rational numbers, with all their laws, can be built from the integers using nothing but sets, so that any contradiction in the theory of ℚ would already be a contradiction in the theory of ℤ. After the construction, what matters is how the rationals behave, and any other construction that produced a system with the same behaviour would serve equally well.

The same method goes further down and further up. The integers can be built from the natural numbers: declare pairs (a,b) of natural numbers equivalent when a+d=b+c, thinking of (a,b) as "a−b", which avoids assuming the subtraction it creates. Problem 12 carries this out. The natural numbers themselves can be built from sets alone: in the standard construction, due to John von Neumann, the number 0 is the empty set and each later whole number is the set of those before it, so that 1={0}, 2={0,1}, and so on.

Going up, the real numbers cannot be built from ℚ by an equivalence relation on pairs, because there are "more" reals than pairs of rationals, a fact made precise later in the course. Both classical constructions were published in 1872. Richard Dedekind defined a real number as a "cut", a way of splitting the rationals into a lower and an upper part, and 2 as the cut between the rationals whose square is below 2 (together with all negative rationals) and the rest. Georg Cantor used sequences of rationals whose terms get closer and closer together, with two such sequences declared equivalent when their difference tends to 0: an equivalence relation again, on sequences rather than pairs, and a real number is a class of them. So each step of the ladder ℕ, ℤ, ℚ, ℝ above the first is built by the method of this lesson or a close relative.

Grouping and ranking

Equivalence relations group things. They say when two objects are the same for present purposes, cut a set into classes, and let the classes become objects in their own right, with operations of their own once those are shown to be well defined. Every equivalence relation is the kernel of a function, and every function is, up to a bijection, the quotient map of its kernel followed by an inclusion.

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: indeed they are antisymmetric, as two things each ranked below the other are the same thing. The lesson on order takes up these relations, and meets equivalence relations again at once: a relation that is merely reflexive and transitive, such as "divides" on all of ℤ, where 3∣−3 and −3∣3, becomes an order only after the elements it cannot tell apart are identified.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. For each relation on {1,2,3}, decide whether it is reflexive, symmetric and transitive, giving a failing instance for each property that fails. (a) R1={(1,1),(2,2),(3,3),(1,2),(2,1)}. (b) R2={(1,2),(2,3),(1,3)}. (c) R3={(1,1),(2,2)}. (d) R4=∅.

Solution

(a) Reflexive, since (1,1), (2,2), (3,3) are all present. Symmetric: the only pairs with different entries are (1,2) and (2,1), and each has its reverse. Transitive: in a chain a∼b∼c in which one step is a loop, the conclusion a∼c is the other step, which is present; the only other chains are 1∼2∼1 and 2∼1∼2, whose conclusions (1,1) and (2,2) are present. So R1 is an equivalence relation, with classes {1,2} and {3}.

(b) Not reflexive: (1,1)∉R2. Not symmetric: (1,2)∈R2 but (2,1)∉R2. Transitive: the only chain of two pairs is 1∼2∼3, and (1,3)∈R2.

(c) Not reflexive: (3,3)∉R3. Symmetric, since each pair is its own reverse. Transitive: the only chains are 1∼1∼1 and 2∼2∼2, whose conclusions are present. This is a symmetric, transitive relation that is not reflexive, and it fails at 3, the element related to nothing.

(d) Not reflexive: (1,1)∉R4. Symmetric and transitive vacuously, since there are no pairs for the conditions to fail at.

2. Which of these are partitions of ℤ? (a) The even integers and the odd integers. (b) The positive integers and the negative integers. (c) The sets {3k,3k+1,3k+2}, one for each integer k. (d) The multiples of 2, the multiples of 3, and the integers divisible by neither. For each partition, describe the corresponding equivalence relation.

Solution

(a) A partition: both sets are non-empty, and every integer is even or odd and not both. The relation is "a−b is even", congruence modulo 2.

(b) Not a partition: 0 is in neither set.

(c) A partition. Each set has three elements, so is non-empty. Every integer n lies in the set with k equal to its quotient on division by 3, since n=3k+r with 0≤r≤2, and in no other, by uniqueness of the quotient. The relation is "a and b have the same quotient on division by 3", the kernel of the function sending each integer to its quotient; for example 3∼5, both having quotient 1, while 5 and 6 are not related.

(d) Not a partition: 6 is a multiple of both 2 and 3, so it lies in two blocks.

3. In ℤ/4ℤ, find the classes containing 2026, −7 and 103, and compute [3]+[3], [3]⋅[3] and [2]⋅[2]. In ℤ/7ℤ, find all classes x with [3]x=[1], and in ℤ/8ℤ all classes x with [2]x=[0].

Solution

2026=4×506+2, so 2026∈[2]. −7=4×(−2)+1, so −7∈[1]. 103=4×25+3, so 103∈[3].

[3]+[3]=[6]=[2], [3]⋅[3]=[9]=[1] and [2]⋅[2]=[4]=[0].

In ℤ/7ℤ there are seven classes to try, and [3][x] for x=0,1,…,6 is [0],[3],[6],[2],[5],[1],[4] (for instance 3⋅5=15=2×7+1). So x=[5] is the only solution.

In ℤ/8ℤ, [2][x]=[2x] is [0] exactly when 8∣2x, and trying x=0,…,7 gives 2x=0,2,4,6,8,10,12,14, of which 0 and 8 are multiples of 8. So x=[0] or x=[4]: two solutions, and a non-zero product that is zero.

4. Write out, as a set of ordered pairs, the equivalence relation on {1,2,3,4,5,6} whose classes are {1,2,3}, {4,5} and {6}. How many pairs does it contain? In general, how many pairs does an equivalence relation on a finite set contain, in terms of the sizes of its classes?

Solution

Two elements are related exactly when they lie in the same class, so the relation is the union of C×C over the classes C:

{1,2,3}×{1,2,3}∪{4,5}×{4,5}∪{(6,6)}

that is, the nine pairs (a,b) with a,b∈{1,2,3}, the four pairs (4,4),(4,5),(5,4),(5,5), and (6,6): 9+4+1=14 pairs.

In general, if the classes have sizes c1,c2,…,ck, the relation is the union of the disjoint sets Ci×Ci, so it has c12+c22+⋯+ck2 pairs. The two extremes are equality, with n classes of size 1 and n pairs, and the relation that relates everything, with one class and n2 pairs.

Core

5. On the set ℝ2∖{(0,0)} of non-zero points of the plane, let (x,y)∼(x′,y′) when (x′,y′)=(λx,λy) for some non-zero real number λ. Prove that ∼ is an equivalence relation, describe its classes geometrically, and prove that {(1,m):m∈ℝ}∪{(0,1)} contains exactly one representative of each class.

Hint

For the three properties, find the λ that works in each case: 1, then 1λ, then a product. For the representatives, split on whether the first coordinate is zero.

Solution

Reflexive: (x,y)=(1⋅x,1⋅y). Symmetric: if (x′,y′)=(λx,λy) with λ≠0, then (x,y)=(1λx′,1λy′) with 1λ≠0. Transitive: if (x′,y′)=(λx,λy) and (x′′,y′′)=(μx′,μy′) with λ,μ≠0, then (x′′,y′′)=(μλx,μλy) with μλ≠0. So ∼ is an equivalence relation.

The class of (x,y) is {(λx,λy):λ≠0}, the line through the origin and (x,y) with the origin removed. So the classes are the lines through the origin, each with the origin deleted.

Representatives. Let (x,y) be a non-zero point. If x≠0, take λ=1x: then (1,yx) is in the class, and it has the form (1,m). If x=0, then y≠0, and λ=1y gives (0,1) in the class. So every class contains at least one point of the set.

It contains only one. If (1,m)∼(1,m′), then (1,m′)=(λ,λm), so λ=1 and m′=m. And (0,1) is not related to any (1,m), since every point related to (0,1) has the form (0,λ), with first coordinate 0. So distinct points of the set lie in distinct classes.

The quotient is the projective line: the set of directions through the origin, each line counted once. The representatives (1,m) are labelled by the slope m, and (0,1) is the vertical line, the one direction with no slope.

6. Find the flaw in this proof, and show that the claim is false.

Claim. The rule f([a]6)=[a]4 defines a function from ℤ/6ℤ to ℤ/4ℤ.

Proof. We must check that f is well defined. Suppose [a]6=[b]6. Then f([a]6)=[a]4 and f([b]6)=[b]4. Since [a]6=[b]6, we have a=b, and so [a]4=[b]4. Hence f is well defined.

Hint

What does [a]6=[b]6 actually tell you about a and b?

Solution

The flaw is the step "since [a]6=[b]6, we have a=b". Equal classes do not have equal representatives; by the lemma on classes, [a]6=[b]6 means only that a≡b(mod6), that is, 6∣a−b. The whole point of checking well-definedness is to handle two different representatives of one class, and the proof assumed the difficulty away.

The claim is false. Take a=0 and b=6. Then [0]6=[6]6, but the rule sends this class to [0]4 through the first name and to [6]4=[2]4 through the second, and [0]4≠[2]4 since 4∤2. So the rule does not define a function. By the argument of the Now you on well defined operations, [a]n↦[a]m is well defined when m∣n, and here 4∤6.

7. For which positive integers n does the rule [a]n↦(−1)a define a function from ℤ/nℤ to {1,−1}? Prove your answer.

Hint

Try n=2 and n=3. The value (−1)a depends only on the parity of a.

Solution

Exactly when n is even.

Suppose n is even, say n=2m, and let [a]n=[a′]n, so a−a′=nk=2(mk) for some integer k. Then a−a′ is even, so a and a′ have the same parity (lesson on direct proof), and (−1)a=(−1)a′, since (−1)a is 1 for even a and −1 for odd a. So the rule is well defined.

Suppose n is odd. Then [0]n=[n]n, since n∣n−0, but (−1)0=1 and (−1)n=−1 because n is odd. So one class receives two values, and the rule does not define a function.

(The exponent a may be negative; (−1)a still makes sense, since (−1)−k=1(−1)k=(−1)k.)

8. Equivalence relations on a set A are subsets of A×A, so they can be intersected and united.

(a) Prove that if R and S are equivalence relations on A, then R∩S is an equivalence relation on A, and that the class of a under R∩S is the intersection of its classes under R and under S.

(b) Identify the intersection of congruence modulo 2 and congruence modulo 3 on ℤ.

(c) Show that the union of congruence modulo 2 and congruence modulo 3 is not an equivalence relation.

Hint

For (b), use the Example in the lesson on direct proof: 6∣n if and only if 2∣n and 3∣n. For (c), look for a chain that uses one relation for the first step and the other for the second.

Solution

(a) Reflexive: for a∈A, (a,a)∈R and (a,a)∈S, so (a,a)∈R∩S. Symmetric: if (a,b)∈R∩S, then (b,a)∈R and (b,a)∈S by symmetry of each, so (b,a)∈R∩S. Transitive: if (a,b) and (b,c) are in R∩S, then both are in R, so (a,c)∈R, and both are in S, so (a,c)∈S; hence (a,c)∈R∩S. For the classes, x is in the class of a under R∩S exactly when (x,a)∈R and (x,a)∈S, exactly when x lies in both classes of a.

(b) For integers a and b: a and b are related by the intersection exactly when 2∣a−b and 3∣a−b, which by the result quoted in the hint holds exactly when 6∣a−b. So the intersection is congruence modulo 6. Its classes are intersections of classes modulo 2 and modulo 3, for instance [1]6=[1]2∩[1]3.

(c) In the union, 0 is related to 2 (congruent modulo 2) and 2 is related to 5 (congruent modulo 3). But 0 is not related to 5: 5−0=5 is divisible by neither 2 nor 3. So the union is not transitive, and not an equivalence relation. (It is reflexive and symmetric, as a union of reflexive and symmetric relations always is.)

9. Prove or disprove that each relation on ℝ is an equivalence relation. Where it is one, describe the classes. (a) x∼y when x2−y2∈ℤ. (b) x∼y when xy≥0. (c) x∼y when ⌊x⌋=⌊y⌋, where ⌊x⌋ is the greatest integer at most x.

Hint

Two of these are kernels of functions, which settles them at once. For the other, test a chain through 0.

Solution

(a) An equivalence relation. Directly: x2−x2=0∈ℤ; if x2−y2=k∈ℤ then y2−x2=−k∈ℤ; if x2−y2=k and y2−z2=m with k,m∈ℤ, then x2−z2=k+m∈ℤ. (Equivalently, it is the kernel of x↦[x2], the class of x2 under the fractional-part relation.) The class of x is {y:y2=x2+k for some k∈ℤ}, the set of ±x2+k over the integers k≥−x2. For example, the class of 0 is {±k:k=0,1,2,…}.

(b) Not an equivalence relation. It is reflexive, since x2≥0, and symmetric, since xy=yx. It is not transitive: 1⋅0≥0 and 0⋅(−1)≥0, so 1∼0 and 0∼−1, but 1⋅(−1)=−1<0, so 1 and −1 are not related. The number 0 is related to everything and joins the positive and negative numbers into one chain.

(c) An equivalence relation, since it is the kernel of the function x↦⌊x⌋. The classes are its non-empty fibres, one for each integer n: the fibre over n is {x:⌊x⌋=n}=[n,n+1). So the classes are the half-open intervals [n,n+1), n∈ℤ, which partition ℝ.

10. Let ∼ be an equivalence relation on A, with quotient map π:A→A/∼, and let g:A→C be a function. Prove that there is a function h:A/∼→C with h∘π=g if and only if g is constant on each class, that is, a∼a′ implies g(a)=g(a′). Prove that such an h is unique, and that it is injective if and only if g(a)=g(a′) implies a∼a′.

Hint

The equation h∘π=g says h([a])=g(a) for every a, so it leaves no freedom in choosing h. The question is only whether that formula is well defined.

Solution

(⇒) Suppose h∘π=g, and let a∼a′. Then [a]=[a′] by the lemma on classes, so g(a)=h([a])=h([a′])=g(a′).

(⇐) Suppose g is constant on each class. Define h([a])=g(a). This is well defined: if [a]=[a′], then a∼a′, so g(a)=g(a′). Every class has a representative, so h is a function on all of A/∼, and (h∘π)(a)=h([a])=g(a) for every a∈A.

Uniqueness: if h and h′ both satisfy h∘π=g=h′∘π, then for every class [a], h([a])=g(a)=h′([a]). Two functions with the same domain, codomain and values are equal, so h=h′. (Equivalently: π is surjective, and surjections can be cancelled on the right.)

Injectivity: suppose g(a)=g(a′) implies a∼a′, and let h([a])=h([a′]). Then g(a)=g(a′), so a∼a′ and [a]=[a′]. Conversely, suppose h is injective and g(a)=g(a′). Then h([a])=h([a′]), so [a]=[a′], and a∼a′.

Together with the kernel theorem, this says a function out of a quotient is the same thing as a function on A that respects the relation, which is how functions on quotients are defined in practice.

11. Decide whether each rule defines a function, and prove your answer. (a) [(a,b)]↦[(a+b,b)], from ℚ to ℚ. (b) [(a,b)]↦[(a+1,b+1)], from ℚ to ℚ. (c) [(a,b)]↦[(b,a)], from ℚ to ℚ, and from ℚ∖{0} to ℚ. What do the rules in (a) and (c) do to a rational number?

Hint

For each rule, take two related pairs and ask whether their images are related. For (b), try two names of 12; note also that b+1 may be 0.

Solution

(a) Well defined. The pair (a+b,b) lies in P since b≠0. Let (a,b)∼(a′,b′), so ab′=ba′. Then (a+b)b′=ab′+bb′=ba′+bb′=b(a′+b′), so (a+b,b)∼(a′+b′,b′). The rule is x↦x+1, since [(a,b)]+[(1,1)]=[(a⋅1+b⋅1,b⋅1)]=[(a+b,b)].

(b) Not a function. First, it can leave P: [(1,−1)] would be sent to the "class" of (2,0), which is not in P. And even where it stays inside P it is not well defined: (1,2)∼(2,4), but the images are (2,3) and (3,5), and 2⋅5=10≠9=3⋅3, so they name different rationals, 23 and 35.

(c) On ℚ∖{0} it is a well defined function. A non-zero rational [(a,b)] has a≠0 (since [(0,b)]=[(0,1)] is zero, as 0⋅1=b⋅0), so (b,a)∈P. If (a,b)∼(a′,b′), then ab′=ba′, which is the same equation as ba′=ab′, the condition for (b,a)∼(b′,a′). On all of ℚ the rule fails, because [(0,1)] would go to the class of (1,0)∉P. The rule is x↦1x.

Challenge

12. This problem builds the integers from the natural numbers, using only addition and multiplication in ℕ and the cancellation law (if x+z=y+z then x=y). On ℕ×ℕ, let (a,b)∼(c,d) when a+d=b+c. Think of (a,b) as standing for a−b.

(a) Prove that ∼ is an equivalence relation.

(b) Prove that [(a,b)]+[(c,d)]=[(a+c,b+d)] is well defined.

(c) Prove that [(a,b)]⋅[(c,d)]=[(ac+bd,ad+bc)] is well defined.

(d) Prove that every class contains exactly one pair of the form (k+1,1) with k∈ℕ, or (1,1), or (1,k+1) with k∈ℕ, and exactly one of these three forms occurs.

Hint

Subtraction is not available in ℕ, so every step must be an equation between sums. For transitivity, add the two given equations and cancel. For (c), change one argument at a time: first show that replacing (a,b) by a related pair gives a related product, then use the symmetry of the formula for the other argument. For (d), compare a and b.

Solution

(a) Reflexive: a+b=b+a. Symmetric: a+d=b+c is the same equation as c+b=d+a, which says (c,d)∼(a,b). Transitive: suppose a+d=b+c and c+f=d+e. Adding the equations gives a+d+c+f=b+c+d+e, that is, (a+f)+(c+d)=(b+e)+(c+d), and cancelling c+d gives a+f=b+e, so (a,b)∼(e,f).

(b) Let (a,b)∼(a′,b′) and (c,d)∼(c′,d′), so a+b′=b+a′ and c+d′=d+c′. Adding, (a+c)+(b′+d′)=(b+d)+(a′+c′), which says (a+c,b+d)∼(a′+c′,b′+d′).

(c) First change the left argument. Let (a,b)∼(a′,b′), so a+b′=b+a′, and let (c,d) be any pair. We need (ac+bd,ad+bc)∼(a′c+b′d,a′d+b′c), that is,

ac+bd+a′d+b′c=ad+bc+a′c+b′d

Multiplying a+b′=b+a′ by c gives ac+b′c=bc+a′c, and multiplying b+a′=a+b′ by d gives bd+a′d=ad+b′d. Adding these two equations gives exactly the required one.

Now the right argument. The formula is symmetric: swapping the two pairs gives (ca+db,cb+da), which is the same pair as (ac+bd,ad+bc). So replacing (c,d) by a related pair also gives a related product, by the first step with the roles exchanged.

Finally, if (a,b)∼(a′,b′) and (c,d)∼(c′,d′), change one argument and then the other: the product for (a,b),(c,d) is related to that for (a′,b′),(c,d), which is related to that for (a′,b′),(c′,d′), and transitivity finishes it.

(d) Let (a,b)∈ℕ×ℕ. Exactly one of a>b, a=b, a<b holds. If a>b, then a=b+k for a natural number k, and (a,b)∼(k+1,1), since a+1=b+k+1. If a=b, then (a,b)∼(1,1), since a+1=b+1. If a<b, then b=a+k, and (a,b)∼(1,k+1), since a+k+1=b+1.

No two different pairs of these forms are related. Two pairs (k+1,1) and (k′+1,1) are related exactly when k+1+1=1+k′+1, that is, k=k′, and similarly for the third form. A pair (k+1,1) is not related to (1,1), since that would need k+1+1=1+1, that is, k=0, which is not a natural number; similarly for the other combinations, (k+1,1)∼(1,k′+1) would need k+k′+2=2. So each class contains exactly one pair of these forms.

The classes of (k+1,1) play the part of the positive integers k, the class of (1,1) is 0, and the classes of (1,k+1) are the negative integers −k. With [(a,b)] read as a−b, the formulas in (b) and (c) are the rules (a−b)+(c−d)=(a+c)−(b+d) and (a−b)(c−d)=(ac+bd)−(ad+bc).

13. Let R be any relation on a set A.

(a) Prove that the intersection E of all equivalence relations on A that contain R is an equivalence relation containing R, and that it is contained in every equivalence relation containing R. It is called the equivalence relation generated by R.

(b) On ℤ, let R={(n,n+4):n∈ℤ}∪{(n,n+6):n∈ℤ}. Prove that the equivalence relation generated by R is congruence modulo 2.

Hint

For (a), there is at least one equivalence relation containing R to intersect. For (b), show two inclusions: congruence modulo 2 is one of the relations being intersected; and any equivalence relation containing R relates n to n+2, and hence, by induction, n to n+2k.

Solution

(a) The family of equivalence relations containing R is not empty: A×A, which relates everything, is an equivalence relation containing R. Let E be the intersection of the family. It contains R, since every member does. Reflexive: for a∈A, (a,a) lies in every member, so in E. Symmetric: if (a,b)∈E, then (a,b) lies in every member, so (b,a) does too, by symmetry of each member, and (b,a)∈E. Transitive: if (a,b) and (b,c) are in E, they lie in every member, so (a,c) lies in every member, and (a,c)∈E. Finally, an intersection of a family is contained in each member, so E is contained in every equivalence relation containing R. So E is the smallest equivalence relation containing R.

(b) Write ≡ for congruence modulo 2, E for the relation generated by R, and a∼Eb for (a,b)∈E.

E⊆≡: congruence modulo 2 is an equivalence relation, and it contains R, since (n+4)−n=4 and (n+6)−n=6 are even. By (a), E is contained in it.

≡⊆E: first, n∼En+2 for every integer n. Indeed (n+2,n+6)∈R (taking n+2 in place of n in the first set), so n+2∼En+6, and by symmetry n+6∼En+2. Also (n,n+6)∈R, so n∼En+6. By transitivity, n∼En+2.

Next, n∼En+2k for every integer n and every integer k≥0, by induction on k. For k=0 this is reflexivity. If n∼En+2k, then since n+2k∼En+2k+2 by the first step, transitivity gives n∼En+2(k+1).

Now let a≡b(mod2), so b−a=2k for some integer k. If k≥0, then a∼Ea+2k=b. If k<0, then a−b=2(−k) with −k>0, so b∼Ea, and a∼Eb by symmetry. So ≡⊆E, and the two relations are equal.

The same argument shows that the relation generated by the steps 4 and 6 is congruence modulo 2 because 2=6−4 is an integer combination of the steps. In general, steps s and t generate congruence modulo the greatest common divisor of s and t, which is Bézout's theorem in disguise.

14. Let n≥2 and A={1,2,…,n}.

(a) Prove that there are exactly 2n−1−1 equivalence relations on A with exactly two classes.

(b) Prove that there are exactly n(n−1)2 equivalence relations on A with exactly n−1 classes.

Hint

Count partitions instead, by the partition theorem. In (a), a partition into two blocks is determined by the block containing 1. In (b), the class sizes are forced.

Solution

By the partition theorem, equivalence relations on A with k classes correspond one to one with partitions of A into k blocks, so it is enough to count partitions.

(a) Given a partition of A into two blocks, let S be the block containing 1. Then S is a subset of A containing 1, and S≠A, because the other block is non-empty. Conversely, every subset S with 1∈S and S≠A gives the partition {S,A∖S} into two blocks: both are non-empty (S contains 1, and A∖S is non-empty since S≠A), they are disjoint, and they cover A. The block of this partition containing 1 is S, and a partition into two blocks is determined by either block, so the two maps are inverse to each other.

So the count is the number of subsets S of A with 1∈S and S≠A. A subset containing 1 is {1}∪T for exactly one subset T of {2,…,n}, and there are 2n−1 such T. Excluding S=A leaves 2n−1−1.

(b) In a partition of A into n−1 blocks, the block sizes are positive integers adding to n. If every block had one element the total would be n−1, so exactly one block has two elements and the rest are singletons; a block of three or more, or two blocks of two, would push the total above n. So the partition is determined by its one two-element block {a,b}, and every two-element subset of A arises from exactly one such partition (itself together with the singletons of the other elements). The number of two-element subsets of A is n(n−1)2: there are n(n−1) ordered pairs (a,b) with a≠b, and each subset {a,b} arises from exactly two of them.

For n=4: 23−1=7 relations with two classes, 6 with three classes, and with the one relation with one class and the one with four, the total is 7+6+1+1=15, the Bell number B4.

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. It also uses two results from the lesson on direct proof: the well-ordering principle (every non-empty set of natural numbers has a least element) and the division algorithm. As throughout the course, ℕ={1,2,3,…}, and the power set of a set X, the set of all its subsets, is written P(X).

Antisymmetry and partial orders

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. A relation can also be neither: "x divides y" on ℤ relates 2 to 4 and not back, so it is not symmetric, and it relates 2 and −2 both ways, so it is not antisymmetric.

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.

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, written (A,⪯) when the relation needs naming. 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. Every subset of ℝ, such as ℕ, ℤ or ℚ, inherits the order, and more generally a partial order restricted to any subset is still a partial order, since the three properties are universal statements and survive shrinking the domain.

Example. Let X be a set. Prove that ⊆ is a partial order on the power set P(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 ℤ.

Every partial order comes with a twin. If ⪯ is a partial order on A, so is its reverse, defined by a⪰b when b⪯a: each of the three properties, read with the letters exchanged, is the same property again. The reverse of ≤ is ≥, and the reverse of ⊆ is ⊇. This is the duality principle: every definition in this lesson has an upside-down version (least for greatest, lower bound for upper bound), and every theorem proved for one version holds for the other, by applying it to the reverse order. So the lesson proves each fact once.

What if a relation is reflexive and transitive but not antisymmetric?

Then it is a preorder, and preorders are common: divisibility on ℤ; "|x|≤|y|" on ℝ, which relates 3 and −3 both ways; "is at least as tall as" on people; and, in the next lesson, "there is an injection from A into B" on sets. A preorder ranks, but it allows ties between different objects.

A preorder always hides a partial order, and the equivalence relations of the previous lesson are what find it. Let ⊑ be a preorder on A, and say a∼b when a⊑b and b⊑a. This is an equivalence relation: reflexive because a⊑a, symmetric because its definition is, and transitive because a⊑b⊑c and c⊑b⊑a give a⊑c and c⊑a. On the classes, define [a]≤[b] when a⊑b.

The definition uses representatives, so it must be checked to be well defined, as operations on classes were in the lesson on equivalence relations. Suppose a∼a′, b∼b′ and a⊑b. Then a′⊑a⊑b⊑b′, so a′⊑b′ by transitivity. The relation on classes is reflexive and transitive because ⊑ is, and it is antisymmetric: [a]≤[b] and [b]≤[a] mean a⊑b and b⊑a, so a∼b and [a]=[b]. Collapsing the ties produces a partial order.

For divisibility on ℤ, the ties are n and −n, the classes are {0} and the pairs {n,−n}, and choosing the non-negative member of each gives divisibility on {0,1,2,…}, a genuine partial order. For injections between sets, the ties are pairs of sets each injecting into the other, and the question of whether a tie means there is a bijection between them is exactly the Schröder and Bernstein theorem, proved in the next lesson.

Total orders and strict orders

Two elements a and b of a poset are comparable when a⪯b or b⪯a, and incomparable otherwise. 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.

Incomparability is where intuition from numbers misleads. In a total order, "not a≤b" means "b<a". In a partial order it does not: 2 does not divide 3, and 3 does not come before 2 either. A proof that says "a⪯b fails, so b precedes a" has assumed the order is total.

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". The strict versions have their own axioms. A relation ≺ on A is a strict partial order when it is irreflexive (no a has a≺a) and transitive.

Proposition. If ⪯ is a partial order on A, and a≺b means a⪯b and a≠b, then ≺ is a strict partial order. Moreover it is asymmetric: a≺b and b≺a never both hold.

Proof. Irreflexive: a≺a would require a≠a. Transitive: let a≺b and b≺c. Then a⪯b and b⪯c, so a⪯c. If a=c, then a⪯b and b⪯a, so a=b by antisymmetry, contradicting a≺b. So a≠c and a≺c. Asymmetric: if a≺b and b≺a, transitivity gives a≺a, contradicting irreflexivity. □

The converse also holds: from a strict partial order ≺, the relation "a≺b or a=b" is a partial order, and the two constructions undo each other. That is Problem 5. So a partial order and a strict partial order carry the same information, and a text may start from either. In a total order, the strict version satisfies trichotomy: for all a and b, exactly one of a≺b, a=b, b≺a holds. At least one holds by totality, and at most one by irreflexivity and asymmetry.

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, named after the number theorist Helmut Hasse, 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. No arrowheads are needed, since up is the direction of the order.

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 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.

The diagram loses nothing, because in a finite poset the covering pairs determine the whole order.

Proposition. In a finite poset, a≺b if and only if there are elements a=c0≺c1≺⋯≺ck=b with k≥1 in which each ci+1 covers ci.

Proof. (⇐) By transitivity of ≺, applied k−1 times, c0≺ck.

(⇒) Suppose a≺b. Consider all sequences a=c0≺c1≺⋯≺ck=b in which each term is strictly below the next. There is at least one, with k=1. In any such sequence the terms are distinct, since ci≺cj for i<j by transitivity, and ≺ is irreflexive. So k+1 is at most the number of elements of the poset, and among the finitely many possible lengths there is a largest; take a sequence with k as large as possible. If some ci+1 did not cover ci, there would be a c with ci≺c≺ci+1, and inserting it would give a longer sequence. So every step is a covering pair. □

Finiteness was used, and it is needed. In (ℚ,≤) no element covers another at all, since between p<q lies p+q2; a Hasse diagram of ℚ would be dots and no lines.

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. The precise word for "the same poset under different names" is this. An order isomorphism from (A,⪯) to (B,⊑) is a bijection f:A→B with a⪯a′ if and only if f(a)⊑f(a′), for all a,a′∈A; the two posets are then isomorphic. The map sending each divisor of 30 to its set of prime factors, 1↦∅, 6↦{2,3}, 30↦{2,3,5} and so on, is an order isomorphism onto (P({2,3,5}),⊆), and isomorphic posets have the same Hasse diagram. The "if and only if" matters: the identity map from ({1,2,3},∣) to ({1,2,3},≤) is a bijection that preserves order (a∣b gives a≤b), but 2≤3 while 2 does not divide 3, so it is not an isomorphism.

The divisors of 12 are 2i3j with 0≤i≤2 and 0≤j≤1, and 2i3j∣2i′3j′ exactly when i≤i′ and j≤j′. The product order on A×B, for posets A and B, sets (a,b)⪯(a′,b′) when a⪯a′ in A and b⪯b′ in B. So the divisors of 12 are isomorphic to {0,1,2}×{0,1} in the product order, a three by two grid, which is the two squares of the figure. The product order is a partial order, checked coordinate by coordinate, but it is rarely total: in ℝ×ℝ, the points (1,0) and (0,1) are incomparable.

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. By duality, an element ℓ is least when ℓ⪯a for every a∈A, and minimal when no a∈A has a≺ℓ.

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, and the minimal ones the points with no line going down.

Greatest is a statement about every element; maximal is a statement about none. Written out with quantifiers,

ggreatest:∀a∈A(a⪯g)mmaximal:¬∃a∈A(m≺a)

and the difference is the difference between "a⪯m" and "not m≺a", which the previous section showed are the same only in a total order. A maximal element may simply be incomparable with the rest. In a total order every pair is comparable, and the two notions coincide.

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; by duality the least element, minA, is unique too. In a preorder the argument fails at exactly that step, and "greatest" elements can tie.

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. The converse of the Now you, that a unique maximal element must be greatest, is true for finite posets and false for infinite ones; Problem 6 asks for both halves.

Infinite posets can lack maximal and minimal elements altogether: under ≤, ℕ has no maximal element, since n<n+1, and ℤ has neither kind. Finite posets cannot.

Theorem. Every finite non-empty poset has a minimal element and a maximal element.

Proof. Let A be a finite non-empty poset. For each x∈A, let d(x) be the number of elements y∈A with y≺x. The values d(x) form a non-empty set of non-negative integers, so by well-ordering some x∈A has d(x) as small as possible. Suppose, for a contradiction, that some y∈A has y≺x. Every z with z≺y also has z≺x, by transitivity, so the elements strictly below y are among those strictly below x. The element y is itself strictly below x but not strictly below y, since ≺ is irreflexive. So d(y)≤d(x)−1<d(x), contradicting the choice of x. Hence x is minimal. Applying this to the reverse order gives a maximal element. □

Applied to the set {y∈A:y⪯x}, which contains x and so is not empty, the theorem gives more: in a finite poset, every element lies above some minimal element, and dually below some maximal one. The last section of the lesson asks what replaces this theorem when the poset is infinite.

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. A set with a greatest element has that element as its supremum: maxS is an upper bound in S, and every upper bound v of S has maxS⪯v because maxS∈S.

The definition works in any poset. Under divisibility on ℕ the upper bounds of {4,6} are the common multiples, and the section on lattices shows that the least of them in the divisibility order is 12, the least common multiple. Under ⊆, sup{A,B}=A∪B, since A∪B contains both, and 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. (This is (ii) contraposed: "u≤v for every upper bound v" says that every v with v<u fails to be an upper bound, and in a total order "not u≤v" is "v<u".) 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 proved in the lesson on the real numbers. 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. Its infimum is 0, which is its least element.

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

Answer

Supremum. 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.

Infimum. Every x∈(0,1) has x>0, so 0 is a lower bound. Let b>0. If b≥1, the element 12 lies below it. If 0<b<1, then x=b2 satisfies 0<x<b<1, so x∈(0,1) and x<b. So no number above 0 is a lower bound, and inf(0,1)=0.

A supremum can fail to exist in two ways: there may be no upper bounds at all, as for ℕ in ℝ, or there may be upper bounds and no least one. The first failure is familiar; the second is subtler, and the next paragraphs and the section on lattices both show it.

What is the supremum of the empty set?

Condition (i) for S=∅ says "s⪯u for every s∈∅", a universal statement over an empty domain, so it is vacuously true: every element of the poset is an upper bound of ∅. Condition (ii) then asks for an element below every element of the poset. So sup∅ exists exactly when the poset has a least element, and then it is that element. Dually, inf∅ is the greatest element, if there is one.

In (P(X),⊆) that gives sup∅=∅ and inf∅=X. The second looks odd until it is read as an intersection: the intersection of no sets at all is the set of x that belong to every set in an empty family, and every x∈X passes that test vacuously. In ℝ, which has no least element, ∅ has no supremum; that is why the completeness axiom of the lesson on the real numbers speaks only of non-empty sets.

The power set is better behaved than ℝ in every respect: every family of subsets of X, of any size, has a supremum, its union, and an infimum, its intersection. The proof is the one for two sets. The union of a family contains each member, and any set containing each member contains every element of the union. A poset in which every subset has a supremum and an infimum is a complete lattice, and complete lattices have a remarkable property: every order-preserving map from one to itself has a fixed point. Problem 13 proves this for power sets, and the result gives a second proof of the Schröder and Bernstein theorem of the next lesson.

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 non-empty, 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 q>0 and 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 no rational has square 2.

That suggests a fact, stated here and proved in the lesson on the real numbers: T is non-empty 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.

Lattices, and divisibility as one

The suprema of two-element sets deserve names. In a poset, the join of a and b, written a∨b, is sup{a,b}, and their meet, written a∧b, is inf{a,b}, whenever these exist. A lattice is a poset in which every two elements have a join and a meet. (The symbols are the logical "or" and "and", and the resemblance is deliberate: in P(X), x∈A∨B exactly when x∈A or x∈B.)

Three lattices are already in view. In a total order, a∨b=max{a,b} and a∧b=min{a,b}: the two elements are comparable, so one of them is the greatest element of {a,b} and hence its supremum, and dually. In (P(X),⊆), A∨B=A∪B and A∧B=A∩B. The third is divisibility on ℕ, whose meet is the greatest common divisor, and the proof that it exists rests on the well-ordering principle and the division algorithm, as the lemma behind Euclid's lemma did in the lesson on contrapositive and contradiction.

Example. Let a,b∈ℕ. Prove that {a,b} has an infimum in (ℕ,∣), and that it can be written as ax+by for some integers x and y.

Let S be the set of positive integers of the form ax+by with x,y∈ℤ. It is not empty, since a=a⋅1+b⋅0 is in it. By the well-ordering principle it has a least element d, and d=ax0+by0 for some integers x0 and y0.

First, d is a lower bound, that is, d∣a and d∣b. By the division algorithm, a=dq+r with 0≤r<d. Then

r=a−dq=a−(ax0+by0)q=a(1−qx0)+b(−qy0)

has the form ax+by. If r were positive it would belong to S and be smaller than d, contradicting the choice of d. So r=0 and d∣a. The same argument with b in place of a gives d∣b.

Second, d lies above every lower bound. Let c∈ℕ with c∣a and c∣b. A common divisor of two integers divides every integer combination of them, so c∣ax0+by0=d.

So d is a lower bound lying above every lower bound: d=inf{a,b}=a∧b, and d=ax0+by0. For a=12 and b=18, the positive combinations include 12, 18, 18−12=6, and nothing smaller, since every combination 12x+18y=6(2x+3y) is a multiple of 6. So 12∧18=6=12⋅(−1)+18⋅1.

The infimum under divisibility is the greatest common divisor, gcd(a,b), and here "greatest" has two meanings that happen to agree: d is greatest in the divisibility order, and since every common divisor c divides d>0, also c≤d, so d is greatest in size. The representation d=ax0+by0 is Bézout's identity, and the Discrete Mathematics lesson on divisibility computes x0 and y0 with Euclid's algorithm.

Now you. Let a,b∈ℕ, and let m be the least positive common multiple of a and b (it exists because ab is one). Prove that m=sup{a,b} in (ℕ,∣).

Answer

The set of positive common multiples of a and b contains ab, so by well-ordering it has a least element m. Since a∣m and b∣m, m is an upper bound of {a,b}.

Let n∈ℕ be any upper bound, so a∣n and b∣n. By the division algorithm, n=mq+r with 0≤r<m. Since a divides both n and m, it divides r=n−mq, and likewise b∣r. If r were positive, it would be a positive common multiple smaller than m, contradicting the choice of m. So r=0 and m∣n. Hence m lies below every upper bound, and m=sup{a,b}=a∨b, the least common multiple.

So (ℕ,∣) is a lattice, with least element 1 and no greatest element. It becomes more symmetric if 0 is admitted: on {0,1,2,…} divisibility is still a partial order (antisymmetry needs a line for 0, since 0∣b forces b=0), and 0 is its greatest element, because n∣0 for every n. The divisors of a fixed number n form a lattice as well, since the gcd and lcm of two divisors of n are again divisors of n (the lcm because n is a common multiple, and so a multiple of the least one). The cube and the two squares in the figure are lattices of this kind.

A subset of a lattice need not be a lattice, and the join inside a subset can differ from the join outside it. In {1,2,3,4,6} under divisibility, 4 and 6 have no upper bound at all, so there is no join. In {1,2,3,12,18}, the set {2,3} has two upper bounds, 12 and 18, which are incomparable, so it has upper bounds and no least one: the second way a supremum can fail. And {1,2,3,5,30} is a lattice in which 2∨3=30, since 6 is not there; inside ℕ the join is 6. Suprema are taken in a named poset, and changing the poset changes the answer, exactly as T had a supremum in ℝ and none in ℚ. Some laws, on the other hand, hold in every lattice, and Problem 9 proves two of them.

Well-orders

The well-ordering principle says something about (ℕ,≤) that is false for ℤ, for the non-negative rationals and for [0,1]: every non-empty subset has a least element. That property gets its own name. A total order ⪯ on W is a well-order when every non-empty subset of W has a least element, and (W,⪯) is then well-ordered.

So ℕ is well-ordered by ≤, and so is every finite totally ordered set, since by the theorem on finite posets a non-empty finite subset has a minimal element, and in a total order a minimal element is least. The set ℤ is not, and neither is {1n:n∈ℕ} under ≤, which has no least element. Totality is almost free in the definition: if a partial order has a least element in every non-empty subset, then for any a and b the subset {a,b} has a least element, which makes a and b comparable.

Well-orders are exactly the orders along which one cannot descend for ever.

Proposition. In a well-ordered set W there is no infinite sequence x1≻x2≻x3≻⋯ with each term strictly below the one before.

Proof. Suppose there were such a sequence. Its set of values {xn:n∈ℕ} is a non-empty subset of W, so it has a least element, say xk. But xk+1 is also in the set and xk+1≺xk, a contradiction. □

The converse holds for total orders too: if some non-empty S⊆W has no least element, choose x1∈S; it is not least, so, by totality, some x2∈S has x2≺x1; that is not least either, so some x3∈S has x3≺x2; and so on for ever. The argument makes infinitely many choices one after another, a point that returns at the end of the lesson.

The reason to care about well-orders is that induction works along them. Strong induction, from the induction lesson, is the case W=ℕ of this theorem.

Theorem (induction over a well-order). Let (W,⪯) be well-ordered and let P(x) be a statement about elements of W. Suppose that for every x∈W, if P(y) holds for all y≺x, then P(x) holds. Then P(x) holds for every x∈W.

Proof. Suppose not. Then the set of counterexamples {x∈W:P(x)is false} is non-empty, so it has a least element x0. Every y≺x0 is smaller than the least counterexample, so P(y) holds. By the hypothesis, P(x0) holds, a contradiction. □

There is no separate base case, because for the least element of W the condition "P(y) for all y≺x" is vacuous, and the hypothesis must prove P outright there.

The lexicographic order

A dictionary orders words by their first letter, breaks ties by the second, and so on. For totally ordered sets A and B, the lexicographic order on A×B does the same with pairs:

(a,b)≺(a′,b′)⟺a≺a′or(a=a′andb≺b′)

with (a,b)⪯(a′,b′) meaning (a,b)≺(a′,b′) or (a,b)=(a′,b′). On ℕ×ℕ it runs

(1,1)≺(1,2)≺(1,3)≺⋯≺(2,1)≺(2,2)≺⋯≺(3,1)≺⋯

Every pair (1,n) comes before (2,1), so (2,1) has infinitely many predecessors, and the order is not isomorphic to (ℕ,≤), in which every element has finitely many. The lexicographic order is total: given (a,b)≠(a′,b′), either a≠a′, and the pair with the smaller first coordinate comes first, or a=a′ and b≠b′, and the smaller second coordinate decides. That ⪯ is a partial order follows from Problem 5 once the strict relation ≺ is shown to be irreflexive and transitive, which is Problem 1.

Example. Prove that the lexicographic order on ℕ×ℕ is a well-order.

Let S be a non-empty subset of ℕ×ℕ. The set of first coordinates F={a:(a,b)∈Sfor someb} is a non-empty subset of ℕ, so it has a least element a0. The set G={b:(a0,b)∈S} is non-empty, since a0∈F, so it has a least element b0, and (a0,b0)∈S.

We show (a0,b0)⪯(a,b) for every (a,b)∈S. Since a∈F, a0≤a. If a0<a, then (a0,b0)≺(a,b) by the first clause of the definition. If a0=a, then b∈G, so b0≤b, and either b0=b, when the pairs are equal, or b0<b, when (a0,b0)≺(a,b) by the second clause. So (a0,b0) is the least element of S.

The proof used well-ordering twice, once per coordinate, and the same proof shows that the lexicographic product of any two well-orders is a well-order.

Now you. Order ℕ by putting every even number before every odd number, and each parity in its usual order: m⊑n when m and n have the same parity and m≤n, or m is even and n is odd. So 2⊏4⊏6⊏⋯⊏1⊏3⊏⋯. Given that ⊑ is a total order, prove that it is a well-order, and name an element with infinitely many predecessors.

Answer

Let S be a non-empty subset of ℕ. If S contains an even number, let e be the least even element of S in the usual order, which exists by well-ordering of ℕ applied to the even elements of S. For n∈S: if n is odd, e⊑n because evens precede odds; if n is even, e≤n by the choice of e, so e⊑n. So e is least. If S contains no even number, every element is odd, and the least element of S in the usual order, o, satisfies o≤n for every n∈S, all of the same parity, so o⊑n. In both cases S has a least element.

The number 1 has infinitely many predecessors, every even number. As with (2,1) in ℕ×ℕ, that shows the order is not isomorphic to (ℕ,≤).

The lexicographic order on finite words is where intuition fails. Order words in the letters a and b as a dictionary does, with a word placed before its own extensions. Then

b≻ab≻aab≻aaab≻⋯

an infinite descending sequence, so by the Proposition the dictionary order on words is not a well-order, even though it is total. The pairs were safe because they have fixed length. The repair for words is shortlex: compare lengths first, and use the dictionary only between words of the same length. There are finitely many words of each length, so shortlex lists all words in one sequence, a,b,aa,ab,ba,bb,aaa,…, and it is a well-order.

Lexicographic orders are the standard tool for proving that a process stops. If each step of an algorithm replaces a pair of natural numbers by a lexicographically smaller one, the algorithm must halt, since otherwise its pairs form an infinite descending sequence. That remains true when a step may lower the first coordinate and then raise the second coordinate as much as it likes: (3,1) may be followed by (2,1000000), and still the run is finite.

What does a well-order longer than ℕ look like, and why would anyone want one?

The two orders met above, evens before odds and the lexicographic order on ℕ×ℕ, are well-orders that continue past a complete copy of ℕ. Cantor, in his papers of 1883, counted along such orders with ordinal numbers: ω for the order type of ℕ, ω+1 for ℕ followed by one more element, ω+ω=ω⋅2 for evens before odds, and ω⋅ω=ω2 for ℕ×ℕ in lexicographic order, which is ω copies of ω in a row. Every well-ordered set is isomorphic to exactly one ordinal, and the ordinals are themselves well-ordered, so they measure the length of a well-order as the natural numbers measure the size of a finite set.

The practical use is induction and termination beyond the reach of ℕ. Wilhelm Ackermann defined in 1928 a function on pairs of non-negative integers by

A(0,n)=n+1,A(m+1,0)=A(m,1),A(m+1,n+1)=A(m,A(m+1,n))

It is not obvious that this defines anything: the last clause feeds a value of A back into A. Induction over the lexicographic well-order settles it. Suppose A is defined at every pair lexicographically below (m,n). If m=0, the first clause defines A(0,n) outright. The second clause refers to (m−1,1), whose first coordinate is smaller. The third first refers to (m,n−1), which is smaller, so A(m,n−1) is some number k; it then refers to (m−1,k), which is smaller whatever k is, because the first coordinate dropped. So A(m,n) is defined, and by the theorem it is defined everywhere. No induction on a single natural number does this directly, because the second coordinate can jump arbitrarily high. The function grows explosively: A(4,2)=265536−3, a number of 19729 decimal digits.

Chains and antichains

Inside any poset there are two extreme kinds of subset. A chain is a subset in which every two elements are comparable, so that the order restricted to it is total. An antichain is a subset in which no two distinct elements are comparable. In (ℕ,∣) the powers of 3 form a chain, 1∣3∣9∣27∣⋯, and the primes form an antichain, since no prime divides a different prime. In (P(X),⊆) the one-element subsets form an antichain. A single element is both a chain and an antichain, and so is ∅.

For a finite poset, the height is the largest number of elements in a chain and the width the largest number of elements in an antichain. The two interact through one simple fact.

Lemma. A chain and an antichain have at most one element in common.

Proof. If x≠y were both in the chain C and the antichain D, they would be comparable because C is a chain and incomparable because D is an antichain. □

So if a poset is the union of k chains, every antichain has at most k elements: each of its elements lies in one of the chains, and no chain can hold two of them, so the pigeonhole principle allows at most k. Dually, if a poset is the union of k antichains, every chain has at most k elements. Covers of one kind bound sets of the other kind, and when a cover and a set of the same size can both be found, the height or width is settled. The next theorem says that for chains and height, the bound is always attained.

Theorem (Mirsky). Let A be a finite poset whose largest chain has h elements. Then A is the union of h disjoint antichains.

Proof. For x∈A, let ℓ(x) be the largest number of elements in a chain whose greatest element is x. The chain {x} shows ℓ(x)≥1, and ℓ(x)≤h by the choice of h. For 1≤i≤h, let Ai={x∈A:ℓ(x)=i}. Every element lies in exactly one Ai.

Each Ai is an antichain. Suppose x≺y. Take a chain of ℓ(x) elements with greatest element x. Every element of it is ⪯x, hence ≺y, so adding y gives a chain of ℓ(x)+1 elements with greatest element y. Therefore ℓ(y)≥ℓ(x)+1>ℓ(x). So two comparable distinct elements never share a value of ℓ, and no Ai contains two comparable elements. □

Leon Mirsky published the theorem in 1971. By the remark before it, no partition into fewer than h antichains is possible, since the chain of h elements would need h different antichains; so the height equals the least number of antichains that cover the poset. Since each antichain has at most w elements, where w is the width, a finite poset of height h and width w has at most hw elements.

The theorem has a practical reading. If x≺y means that task x must be finished before task y starts, an antichain is a set of tasks that can run at the same time, and the proof schedules the whole project in h rounds, round i being Ai, where h is the length of the longest chain of dependencies. No schedule can use fewer.

Example. Find the height and the width of {1,2,…,12} under divisibility, and a partition into antichains of the least possible number.

Height. The chain 1∣2∣4∣8 has four elements. No chain has five: list a chain's elements in increasing order as c1∣c2∣⋯; each is a proper multiple of the one before, so at least twice it, and five elements would give c5≥24c1≥16>12. So the height is 4.

Mirsky's partition. The value ℓ(n) is the number of elements in the longest divisor chain ending at n. It is 1 for n=1; 2 for the primes 2,3,5,7,11 (only 1 lies below them); 3 for 4,6,9,10 (for instance 1∣3∣9, and nothing longer, since the only divisors of 9 are 1, 3, 9); and 4 for 8 and 12 (as 1∣2∣4∣8 and 1∣2∣4∣12). So the antichains are

{1},{2,3,5,7,11},{4,6,9,10},{8,12}

and a direct check confirms that no number in any of them divides another in the same set.

Width. The six numbers 7,8,9,10,11,12 form an antichain: a proper multiple of any of them is at least 14. And six chains cover the whole poset:

{1,2,4,8},{3,6,12},{5,10},{7},{9},{11}

so by the lemma no antichain has more than six elements. The width is 6, and 4×6=24≥12, as it must be.

Now you. Find the height and width of (P({1,2,3}),⊆), the Mirsky partition into antichains, and a cover by chains that proves the width.

Answer

Height. If S⊆T and S≠T, then T has more elements than S. So the sets in a chain have different sizes, and sizes run from 0 to 3, which allows at most four sets. The chain ∅⊆{1}⊆{1,2}⊆{1,2,3} has four, so the height is 4.

Partition. A longest chain ending at a set S with k elements can include one set of each size from 0 to k (remove the elements of S one at a time), and no more, by the size argument. So ℓ(S)=|S|+1, and the antichains are the sets of each size: {∅}, the three singletons, the three pairs, and {{1,2,3}}.

Width. The three singletons form an antichain. The three chains

{∅,{1},{1,2},{1,2,3}},{{2},{2,3}},{{3},{1,3}}

cover all eight subsets, so no antichain has more than three elements. The width is 3.

Is there a theorem with chains and antichains the other way round?

Yes, and it is harder. Mirsky's theorem covers a poset by as few antichains as its height demands. The dual statement covers it by as few chains as its width demands.

Dilworth's theorem. A finite poset whose largest antichain has w elements is the union of w chains.

Robert Dilworth proved it in 1950, twenty-one years before Mirsky's dual, and the delay reflects the difficulty. The easy half, that at least w chains are needed, is the lemma above. The hard half has no neat labelling like ℓ(x); the standard proofs go by induction on the size of the poset, splitting at a largest antichain, or deduce it from results on matchings in graphs, and they belong to a course in combinatorics.

Both theorems give the bound |A|≤hw, and that bound alone has a famous consequence. Paul Erdős and George Szekeres proved in 1935 that every sequence of more than rs distinct real numbers contains an increasing subsequence of more than r terms or a decreasing one of more than s terms. For instance, any ten distinct numbers in a row contain four in increasing order or four in decreasing order. The proof is a choice of partial order, and it is Problem 12.

For power sets the width is known exactly. Emanuel Sperner proved in 1928 that the largest antichain in P({1,2,…,n}) has (n⌊n/2⌋) elements, the number of subsets of the middle size, so the Now you's answer of 3=(31) is the case n=3.

Linear extensions and Zorn's lemma

A partial order can always be completed to a total one without contradicting it. A linear extension of a partial order ⪯ on A is a total order ≤* on A such that a⪯b implies a≤*b. Listing a degree's modules in an order that respects every prerequisite is finding a linear extension, and so is the "topological sort" a build system performs before compiling files that depend on one another. For the divisors of 12, the usual order of size is one linear extension, and 1,3,2,6,4,12 is another.

Theorem. Every partial order on a finite set has a linear extension.

Proof. By induction on the number n of elements. A set with 0 or 1 elements is already totally ordered. Let n≥1, suppose the claim holds for every set of n elements, and let (A,⪯) be a poset with n+1 elements. By the theorem on finite posets it has a minimal element m. The set A∖{m} has n elements and, with ⪯ restricted to it, is a poset, so by hypothesis it has a linear extension ≤′. Define ≤* on A by putting m first: m≤*x for every x∈A, and for x,y≠m, x≤*y when x≤′y. This is a total order, since it is ≤′ with one new element placed below everything. It extends ⪯: let x⪯y. If x=m, then m≤*y. If y=m, then x⪯m, and x≺m is impossible because m is minimal, so x=m and m≤*m. If neither is m, then x≤′y, so x≤*y. □

For an infinite set, peeling off a minimal element fails: there may be none, and even when there is, the peeling may never reach some elements. A different construction is needed, and it starts with a lemma that orders a single incomparable pair.

Lemma. Let R be a partial order on A, written xRy, and let a and b be incomparable under R. Then

R′=R∪{(x,y):xRaandbRy}

is a partial order on A that contains R and has aR′b.

Proof. Call the pairs of R old and the other pairs of R′ new. The pair (a,b) is new, since aRa and bRb. R′ is reflexive because R is.

Antisymmetric. Let xR′y and yR′x. If both pairs are old, x=y by antisymmetry of R. If (x,y) is old and (y,x) new, then yRa and bRx, so bRxRyRa and, by transitivity, bRa, contradicting incomparability. The case with (x,y) new and (y,x) old is the same with the letters exchanged. If both are new, then xRa and bRx, so bRa, again impossible. So only the first case occurs, and x=y.

Transitive. Let xR′y and yR′z. If both are old, xRz. If (x,y) is old and (y,z) new, then xRyRa and bRz, so (x,z) is new, and in R′. If (x,y) is new and (y,z) old, then xRa and bRyRz, so (x,z) is new. If both are new, then bRy and yRa, so bRa, impossible. In every possible case xR′z. □

The lemma fixes one incomparable pair; an infinite set can have infinitely many, and fixing them one at a time is a process with no last step. What replaces "and so on" is a principle about posets.

Zorn's lemma. Let P be a non-empty poset in which every non-empty chain has an upper bound in P. Then P has a maximal element.

It is not proved in this course. It is equivalent, given the other axioms of set theory, to the axiom of choice, which says that from any family of non-empty sets one element can be chosen from each at once; mathematicians take one of the equivalent forms as an axiom. For a finite poset, Zorn's lemma is the theorem on finite posets proved above, which needs no chain condition at all. For infinite posets the hypothesis is essential: in (ℕ,≤) every element is part of the chain ℕ, which has no upper bound, and there is no maximal element.

Theorem (Szpilrajn). Every partial order on any set has a linear extension.

Proof. Let ⪯ be a partial order on A, and let P be the set of all partial orders on A that contain ⪯, each regarded as a set of pairs, and ordered by ⊆. P is not empty, since ⪯ belongs to it.

Let C be a non-empty chain in P, and let U be the union of its members. We show U∈P; it is then an upper bound of C. U contains ⪯, since every member of C does, and it is reflexive for the same reason. For transitivity, let (x,y) and (y,z) be in U, say (x,y)∈R1 and (y,z)∈R2 with R1,R2∈C. Since C is a chain, one contains the other, say R1⊆R2. Then both pairs are in the partial order R2, so (x,z)∈R2⊆U. Antisymmetry is proved the same way: if (x,y) and (y,x) are in U, both lie in the larger of the two orders containing them, so x=y.

By Zorn's lemma, P has a maximal element R. Suppose R were not total, with a and b incomparable. The Lemma gives a partial order R′ containing R, hence containing ⪯, so R′∈P; and (a,b)∈R′ while (a,b)∉R, so R⊆R′ and R≠R′, which would contradict the maximality of R. Hence R is total, and it is a linear extension of ⪯. □

Edward Szpilrajn published the theorem in 1930. The proof shows the pattern of almost every use of Zorn's lemma. Collect the partial objects, here partial orders extending the given one, and order them by inclusion. Check that the union of a chain of partial objects is again a partial object; the check is usually routine, and it is the step that must not be skipped. Take a maximal partial object, and show that if it were not complete it could be enlarged, usually by a lemma like the one above. The same pattern proves that every vector space has a basis (the partial objects are linearly independent sets, and a maximal one spans), including vector spaces far beyond those of a first linear algebra course, such as ℝ regarded as a vector space over ℚ. It also proves that every connected graph, however infinite, has a spanning tree.

The chain condition is where proofs fail. Let P be the set of finite subsets of ℕ, ordered by ⊆. The chain {1}⊆{1,2}⊆{1,2,3}⊆⋯ has union ℕ, which is not in P, and no finite set contains every member of the chain, so the chain has no upper bound in P. And P has no maximal element: ∅ lies strictly below {1}, and a non-empty finite set F lies strictly below F∪{maxF+1}. Zorn's lemma promises nothing here, and nothing is there.

Why is Zorn's lemma an axiom rather than a theorem?

Because it cannot be proved from the other axioms of set theory, and neither can its negation. Kurt Gödel showed in 1938 that the axiom of choice is consistent with the other axioms of Zermelo and Fraenkel's system, ZF, and Paul Cohen showed in 1963 that its negation is consistent with them too. Since Zorn's lemma and the axiom of choice imply each other over ZF, the same holds for Zorn.

The heuristic argument for Zorn's lemma shows where choice enters. Start anywhere in P. If the current element is not maximal, choose something strictly above it. Continue: after infinitely many steps the elements chosen form a chain, which has an upper bound, so choose one and keep climbing. The climb runs along a well-order that may be far longer than ℕ, but the chosen elements are all different, so it cannot run longer than the size of P allows; it must stop, and it can only stop at a maximal element. Making this rigorous needs the ordinals and a single act of choosing, all at once, a successor for every non-maximal element; the axiom of choice is exactly the licence for that.

Three equivalent forms are usually met together: the axiom of choice, which Ernst Zermelo made explicit in 1904; Zermelo's well-ordering theorem, proved from choice in the same paper, that every set, ℝ included, can be well-ordered; and Zorn's lemma, found by Kazimierz Kuratowski in 1922 and independently by Max Zorn, who published it in 1935. The mathematician Jerry Bona summed up how differently they strike the intuition: the axiom of choice is obviously true, the well-ordering principle obviously false, and who can tell about Zorn's lemma? They are one principle in three costumes.

Choice has strange consequences. Nobody can write down a well-order of ℝ, although one exists if choice is assumed, and the Banach and Tarski paradox of 1924 cuts a solid ball into finitely many pieces that can be moved rigidly and reassembled into two balls the size of the first. Most mathematicians accept choice anyway, because without it much of algebra and analysis breaks, and results proved with it are marked in careful texts when the use is essential.

Zorn's lemma is a statement about infinite sets, and so is the preorder "there is an injection from A into B" met near the start of the lesson. The next lesson takes up that preorder, compares the sizes of infinite sets by functions alone, and asks how many real numbers there are.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Let A and B be totally ordered sets, and let ≺ be the strict lexicographic order on A×B. Prove that ≺ is irreflexive and transitive.

Solution

Write < for the strict orders of A and of B; both are irreflexive and transitive.

Irreflexive. (a,b)≺(a,b) would require a<a, or a=a and b<b. Both are impossible, since < is irreflexive in A and in B.

Transitive. Let (a,b)≺(a′,b′) and (a′,b′)≺(a′′,b′′). There are four cases, according to which clause of the definition gives each relation.

If a<a′ and a′<a′′, then a<a′′ by transitivity in A. If a<a′ and a′=a′′, then a<a′′. If a=a′ and a′<a′′, then a<a′′. In these three cases (a,b)≺(a′′,b′′) by the first clause. If a=a′=a′′ with b<b′ and b′<b′′, then b<b′′ by transitivity in B, and (a,b)≺(a′′,b′′) by the second clause.

By Problem 5, the relation "≺ or =" is therefore a partial order, and the lesson showed it is total.

2. List the covering pairs of the divisors of 36 under divisibility, and say how many lines the Hasse diagram has. Find the height and the width, with proof.

Solution

The divisors are 1,2,3,4,6,9,12,18,36. First, n covers d exactly when nd is prime. If n=dp with p prime and d∣c∣n, then c=dk and n=ck′ for positive integers k and k′ with kk′=p, so k=1 or k′=1, that is, c=d or c=n. If instead nd=uv with 1<u,v, then d≺du≺n, so n does not cover d.

So the covering pairs are those where the larger is 2 or 3 times the smaller:

1≺2, 1≺3, 2≺4, 2≺6, 3≺6, 3≺9, 4≺12, 6≺12, 6≺18, 9≺18, 12≺36, 18≺36.

That is twelve lines. The diagram is a three by three grid standing on a corner, since the divisors are 2i3j with 0≤i,j≤2.

Height. The chain 1∣2∣4∣12∣36 has five elements. Suppose a chain had six, listed upwards as c1∣c2∣⋯∣c6. Each quotient qi=ci+1ci is an integer at least 2, and q1q2q3q4q5=c6c1, which divides 36 because c6 does. If all five quotients are 2, the product is 32, which does not divide 36; if one is at least 3, the product is at least 3×24=48>36. Either way this is impossible. The height is 5.

Width. The set {4,6,9} is an antichain: none divides another. The three chains {1,2,4,12,36}, {3,6,18} and {9} cover all nine divisors, so by the lemma on chains and antichains no antichain has more than three elements. The width is 3.

3. In the poset {2,3,4,…,12} under divisibility, find all minimal and all maximal elements, and decide whether there is a least or a greatest element. Then find, if they exist, sup{2,3}, sup{4,6} and sup{5,7} in this poset.

Solution

An element is minimal when no other element of the set divides it. The numbers 2,3,5,7,11 are prime, so their only divisors in the set are themselves, and they are minimal. Every other element has a prime divisor in the set: 4,6,8,10,12 are divisible by 2 and 9 by 3. So the minimal elements are 2,3,5,7,11.

An element is maximal when no proper multiple of it lies in the set, that is, when its double exceeds 12. So the maximal elements are 7,8,9,10,11,12; the others have 2×2=4, 6, 8, 10 and 12 in the set.

There are five minimal elements, so there is no least element (a least element would be the only minimal one), and six maximal elements, so no greatest one.

The upper bounds of {2,3} in the set are its common multiples there, 6 and 12, and 6∣12, so sup{2,3}=6. The only upper bound of {4,6} is 12, so sup{4,6}=12. The set {5,7} has no upper bound, since 35>12, so it has no supremum.

4. In (P({1,2,3,4}),⊆), find all upper bounds and all lower bounds of S={{1,2},{2,3}}, and supS and infS. In (ℕ,∣), find sup{12,18} and inf{12,18}.

Solution

A set U is an upper bound of S when {1,2}⊆U and {2,3}⊆U, that is, when {1,2,3}⊆U. So the upper bounds are {1,2,3} and {1,2,3,4}, and the least is supS={1,2,3}={1,2}∪{2,3}.

A set L is a lower bound when L⊆{1,2} and L⊆{2,3}, that is, when L⊆{2}. So the lower bounds are ∅ and {2}, and infS={2}={1,2}∩{2,3}.

In (ℕ,∣), the supremum is the least common multiple and the infimum the greatest common divisor, by the Example and the Now you in the section on lattices. The common multiples of 12 and 18 are the multiples of 36 (the least positive one is 36, since 12, 24 are not multiples of 18 and 36 is), so sup{12,18}=36, and inf{12,18}=6, computed in the lesson.

Core

5. Let ≺ be a strict partial order on A (irreflexive and transitive), and define a⪯b to mean a≺b or a=b. Prove that ⪯ is a partial order whose strict version is ≺ again. Prove also that starting from a partial order, passing to its strict version and then back gives the partial order you started with.

Hint

For transitivity of ⪯, split on whether either of the two relations is an equality. For antisymmetry, use the asymmetry argument from the lesson.

Solution

Reflexive. For every a, a=a, so a⪯a.

Transitive. Let a⪯b and b⪯c. If a=b, then a⪯c is the second relation. If b=c, it is the first. Otherwise a≺b and b≺c, so a≺c by transitivity of ≺, and a⪯c.

Antisymmetric. Let a⪯b and b⪯a, and suppose a≠b. Then a≺b and b≺a, so a≺a by transitivity, contradicting irreflexivity. So a=b.

The strict version of ⪯ is ≺. The strict version relates a to b when a⪯b and a≠b, that is, when (a≺b or a=b) and a≠b, which is equivalent to "a≺b and a≠b". Since ≺ is irreflexive, a≺b already implies a≠b, so this is just a≺b.

The other round trip. Start from a partial order ⪯, with strict version a≺b meaning a⪯b and a≠b. The relation "a≺b or a=b" holds when (a⪯b and a≠b) or a=b. If a⪯b, then either a≠b and the first alternative holds, or a=b and the second does. Conversely, each alternative gives a⪯b, the second by reflexivity. So the round trip returns ⪯.

6. Prove or disprove each claim. (a) If a poset has exactly one maximal element, that element is greatest. (b) If a finite poset has exactly one maximal element, that element is greatest.

Hint

For (a), put an element beside a copy of ℤ with nothing relating the two. For (b), use the theorem on finite posets on the set of elements above a given x.

Solution

(a) False. Let A=ℤ∪{m}, where m is a new element that is not an integer, ordered by ≤ on ℤ and with m related only to itself. This is a partial order: reflexivity, antisymmetry and transitivity hold inside ℤ, and any relation involving m is m⪯m. No integer is maximal, since n≺n+1. The element m is maximal, since nothing other than m is related to it. So m is the only maximal element. It is not greatest, since 0⪯m fails.

(b) True. Let A be a finite poset whose only maximal element is m, and let x∈A. The set U={y∈A:x⪯y} is finite and contains x, so by the theorem on finite posets, applied to U with the restricted order, it has an element y maximal in U. This y is maximal in A: if y≺z for some z∈A, then x⪯y≺z, so z∈U, contradicting the maximality of y in U. Since m is the only maximal element of A, y=m, and so x⪯m. As x was arbitrary, m is greatest.

Part (a) shows where finiteness enters: in ℤ∪{m}, the set of elements above 0 has no maximal element, and the argument of (b) breaks at exactly that step.

7. Find the flaw in this argument, show that the claim is false, and prove the claim under the extra hypothesis that every two elements of P have a common upper bound in P.

Claim. Let P be a non-empty poset in which every non-empty chain has an upper bound in P. Then P has a greatest element.

Proof. By Zorn's lemma, P has a maximal element m. Let x∈P. Since m is maximal, it is not the case that m≺x. Therefore x⪯m. As x was arbitrary, m is greatest.

Hint

Which step would be correct in a total order, and only there? For the counterexample, try the smallest poset with two incomparable elements.

Solution

The flaw is the step from "not m≺x" to "x⪯m". In a total order that step is trichotomy, but in a partial order x and m may be incomparable, and then neither m≺x nor x⪯m holds. The argument confuses maximal with greatest.

The claim is false. Let P={a,b} with a and b incomparable (so the order is just equality). The non-empty chains are {a} and {b}, with upper bounds a and b. Both a and b are maximal and neither is greatest.

Corrected claim. Suppose also that every two elements of P have a common upper bound. Let m be maximal, as Zorn's lemma provides, and let x∈P. Let u be a common upper bound of x and m. Then m⪯u, and m≺u is impossible since m is maximal, so u=m. Hence x⪯u=m. As x was arbitrary, m is greatest.

8. Prove that among any n+1 numbers chosen from {1,2,…,2n}, one divides another. Show that the statement fails for n numbers, and deduce the width of {1,2,…,2n} under divisibility.

Hint

Write each number as a power of 2 times an odd number. How many odd numbers are available?

Solution

Every k∈ℕ can be written as k=2iq with i≥0 and q odd: divide k by 2 as long as the result is even, which stops because the values decrease. The odd part q is determined by k. If 2iq=2jr with q and r odd and, say, i<j, then q=2j−ir would be even; so i=j and q=r.

For k≤2n the odd part is one of the n odd numbers 1,3,…,2n−1. Among n+1 chosen numbers, by the pigeonhole principle two different ones, 2iq and 2jq, have the same odd part q. They are different, so i≠j; say i<j. Then 2jq=2j−i⋅2iq, so the first divides the second.

For n numbers the claim fails: take n+1,n+2,…,2n. A proper multiple of any of them is at least twice it, so at least 2n+2, and is not in the set. So no one of them divides another.

In the language of the lesson, the sets Cq={2iq:2iq≤2n} for the n odd numbers q are n chains covering {1,…,2n}, so every antichain has at most n elements, and {n+1,…,2n} is an antichain with exactly n. The width is n. For n=6 this is the width 6 of {1,…,12} found in the lesson, and the chains Cq are the six chains used there.

9. Let L be a lattice. Prove that (a) a⪯b if and only if a∨b=b, and dually a⪯b if and only if a∧b=a; (b) a∧(a∨b)=a and a∨(a∧b)=a, for all a,b∈L. (c) Deduce that gcd(a,lcm(a,b))=a for all a,b∈ℕ.

Hint

For (a), check the two conditions in the definition of supremum. Part (b) then follows from (a) in one line each.

Solution

(a) Suppose a⪯b. Then b is an upper bound of {a,b}, since a⪯b and b⪯b, and every upper bound v of {a,b} has b⪯v. So b is the least upper bound: a∨b=b. Conversely, if a∨b=b, then a⪯a∨b=b, since the join is an upper bound of {a,b}. The second statement is the first applied to the reverse order, in which joins and meets exchange roles.

(b) Since a∨b is an upper bound of {a,b}, a⪯a∨b, and the dual half of (a) gives a∧(a∨b)=a. Since a∧b is a lower bound of {a,b}, a∧b⪯a, and the first half of (a), with a∧b in the role of a and a in the role of b, gives (a∧b)∨a=a. The join of two elements does not depend on their order, since {a∧b,a} and {a,a∧b} are the same set, so a∨(a∧b)=a.

(c) In (ℕ,∣) the meet is the greatest common divisor and the join is the least common multiple, as proved in the lesson. So gcd(a,lcm(a,b))=a∧(a∨b)=a by (b). For instance gcd(4,lcm(4,6))=gcd(4,12)=4.

10. Prove or disprove each claim. (a) The lexicographic order on ℕ×ℤ is a well-order. (b) There is a well-order on ℤ. (c) Every subset of a well-ordered set is well-ordered by the restricted order. (d) If (W,⪯) is well-ordered, so is W with the reverse order.

Hint

For (b), a bijection between ℤ and ℕ lets you borrow the order of ℕ. For (d), try ℕ.

Solution

(a) False. The subset S={(1,z):z∈ℤ} is non-empty and has no least element: for any (1,z)∈S, the element (1,z−1) is in S and (1,z−1)≺(1,z) by the second clause.

(b) True. Define g:ℤ→ℕ by g(z)=2z for z≥1 and g(z)=1−2z for z≤0. The values for z≥1 are even and those for z≤0 are odd and at least 1, so g maps into ℕ, and it is injective: equal values have equal parity, and then 2z=2z′ or 1−2z=1−2z′ gives z=z′. Define m⊑n when g(m)≤g(n). This is reflexive and transitive because ≤ is, antisymmetric because g(m)=g(n) forces m=n, and total because ≤ is. Let S⊆ℤ be non-empty. Then g(S) is a non-empty subset of ℕ, with a least element g(s0) for some s0∈S, and g(s0)≤g(s) for every s∈S, that is, s0⊑s. So ⊑ is a well-order. It lists ℤ as 0,1,−1,2,−2,….

(c) True. Let (W,⪯) be well-ordered and V⊆W. The restricted order is a total order, since the defining properties are universal statements. A non-empty subset of V is a non-empty subset of W, so it has a least element, and that element is in the subset.

(d) False, unless W is finite. (ℕ,≤) is well-ordered, but under the reverse order ≥ a least element of ℕ would be a greatest natural number, and there is none, since n<n+1.

11. Let (A,⪯) be an infinite totally ordered set in which every element has only finitely many predecessors (elements strictly below it). Prove that A is order-isomorphic to (ℕ,≤).

Hint

Send each element to one more than its number of predecessors. Show this map is strictly increasing, and that its image contains n whenever it contains n+1.

Solution

For a∈A, let pred(a)={x∈A:x≺a}, a finite set, and define f(a)=|pred(a)|+1, a natural number.

f is strictly increasing. Let a≺b. Every x≺a has x≺b by transitivity, so pred(a)⊆pred(b). Also a∈pred(b) and a∉pred(a). So pred(b) has at least one more element than pred(a), and f(a)<f(b).

f is injective and reflects order. Let a≠b. By totality, a≺b or b≺a, so f(a)<f(b) or f(b)<f(a); in particular f(a)≠f(b). The same reasoning shows that f(a)≤f(b) implies a⪯b: otherwise b≺a, and then f(b)<f(a). So a⪯b if and only if f(a)≤f(b).

f is surjective. First, the image of f is closed downwards: if f(b)=n+1 with n≥1, then pred(b) is a non-empty finite totally ordered set, so it has a greatest element a (by the theorem on finite posets, since a maximal element of a total order is greatest). The predecessors of a are exactly the predecessors of b other than a: if x≺a then x≺b and x≠a; and if x≺b with x≠a, then x⪯a because a is greatest in pred(b), so x≺a. So f(a)=n. Second, the image is infinite, since f is injective and A is infinite, so for each n∈ℕ some value f(b)≥n. Going down from f(b) one step at a time, each value from f(b) down to 1 is in the image, n among them.

So f is a bijection A→ℕ with a⪯b exactly when f(a)≤f(b), an order isomorphism. The hypothesis on predecessors cannot be dropped: in the evens-first order on ℕ, the element 1 has infinitely many predecessors, and the order is not isomorphic to (ℕ,≤).

Challenge

12. Prove that every sequence x1,x2,…,xN of N>rs distinct real numbers has an increasing subsequence of more than r terms or a decreasing subsequence of more than s terms. Show that rs terms are not enough.

Hint

First prove that a finite poset with more than rs elements has a chain of more than r elements or an antichain of more than s, using Mirsky's theorem. Then find a partial order on the positions 1,…,N whose chains are the increasing subsequences.

Solution

Step 1. Let A be a finite poset with more than rs elements, and suppose every chain has at most r elements, so the height h satisfies h≤r. By Mirsky's theorem, A is the union of h antichains. If each had at most s elements, A would have at most hs≤rs elements, which is false. So some antichain has more than s elements.

Step 2. On the set of positions {1,2,…,N}, define i⊑j when i≤j and xi≤xj. This is a partial order: reflexive since i≤i and xi≤xi; antisymmetric since i≤j and j≤i give i=j; transitive since both conditions are transitive.

A chain is a set of positions i1<i2<⋯<ik any two of which are comparable; since ia<ib, comparability means xia≤xib, and as the values are distinct, xi1<xi2<⋯<xik. So chains are increasing subsequences. An antichain is a set of positions i1<⋯<ik no two of which are comparable; for ia<ib, incomparability means xia≤xib fails, so xia>xib. So antichains are decreasing subsequences.

The poset has N>rs elements, so by Step 1 there is an increasing subsequence of more than r terms or a decreasing one of more than s terms.

Sharpness. Take r blocks of s numbers each. Block t, for t=1,…,r, lists ts,ts−1,…,ts−s+1 in decreasing order, so the blocks are decreasing inside and every number in a later block exceeds every number in an earlier one. For r=3, s=2 this is 2,1,4,3,6,5. An increasing subsequence takes at most one term from each block, since each block is decreasing, so it has at most r terms. A decreasing subsequence stays inside one block, since a term of a later block is larger than every term of an earlier one, so it has at most s terms. This sequence has rs distinct terms and neither kind of long subsequence.

The result is due to Paul Erdős and George Szekeres, 1935. Problem 14 of the lesson on contrapositive and contradiction proved the case r=s by the pigeonhole principle.

13. Let X be a set and let F:P(X)→P(X) be monotone: A⊆B implies F(A)⊆F(B). Prove that F has a fixed point, a set S with F(S)=S.

Hint

Consider all sets A with A⊆F(A), and take their union. Show it is contained in its own image, then apply F once more.

Solution

Call a set A⊆X expanding if A⊆F(A). The empty set is expanding, since ∅⊆F(∅). Let S be the union of all expanding sets, a subset of X.

S⊆F(S). Let x∈S. Then x∈A for some expanding set A. Since A⊆S and F is monotone, F(A)⊆F(S). So x∈A⊆F(A)⊆F(S). As x was arbitrary, S⊆F(S).

F(S)⊆S. Applying F to S⊆F(S), monotonicity gives F(S)⊆F(F(S)). So F(S) is itself expanding, and therefore it is one of the sets in the union that defines S: F(S)⊆S.

By double inclusion, F(S)=S. In the language of the lesson, S is the supremum in (P(X),⊆) of the expanding sets, and it is the greatest fixed point: every fixed point is expanding, so is contained in S.

This is the power-set case of the Knaster and Tarski fixed point theorem, and it proves the Schröder and Bernstein theorem of the next lesson. Given injections f:A→B and g:B→A, the map F(C)=A∖g(B∖f(C)) on P(A) is monotone; for a fixed point C, the function equal to f on C and to the inverse of g on A∖C is a bijection A→B.

14. A box holds finitely many balls, each labelled with a natural number. A move removes one ball, with label n say, and puts into the box any finite number of new balls (possibly none), each with a label smaller than n. So a ball labelled 1 can only be removed. Prove that however the moves are chosen, the box is empty after finitely many moves.

Hint

Suppose some play goes on for ever, and choose one whose starting box has the smallest possible largest label. Follow the balls with that largest label.

Solution

A play that never empties the box is an infinite sequence of moves, each legal in the box left by the one before. Suppose, for a contradiction, that infinite plays exist. Each starts from a non-empty box, which has a largest label; by the well-ordering principle, choose an infinite play whose starting box has the least possible largest label n.

No move ever creates a ball with label n or more, since new labels are smaller than the label removed, which is at most n. So the balls labelled n are those present at the start, say k of them, and at most k moves remove one. Hence there is a stage t after which no move removes a ball labelled n.

If n=1, every move removes a ball and adds none, so the play has at most as many moves as the box has balls, and is finite, a contradiction. So n≥2.

From stage t on, every move removes a ball with label at most n−1 and adds balls with smaller labels, and the balls labelled n are never touched. So deleting the balls labelled n from the box at stage t, and from every later box, leaves an infinite sequence of legal moves, starting from a box whose labels are all at most n−1. That box is not empty, since a move is made from it. This is an infinite play whose starting box has largest label less than n, contradicting the choice of n. So there are no infinite plays.

No bound on the number of moves exists in advance: a single ball labelled 2 may be replaced by a million balls labelled 1, and the play then lasts a million and one moves. That is why no induction on the number of moves or balls works; the argument uses the largest label first and the number of balls carrying it second, which is a lexicographic order in disguise.

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 the elements of a set by order, ended on Zorn's lemma, a principle about infinite sets, and left a prior question: how large is an infinite set, and how many reals are there? This lesson answers it with functions alone, assuming from the lesson on functions injective, surjective and bijective maps, inverses, and the facts that a composite of injections is an injection and a composite of bijections is a bijection. It also uses the well-ordering principle: every non-empty set of natural numbers has a least element. As throughout the course, ℕ={1,2,3,…} starts at 1, and P(A) is the power set of A.

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 are equinumerous, or 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 that |A|≤|B| and not |A|=|B|: an injection exists and a bijection does not.

Proposition. For all sets A, B and C: (i) |A|=|A|; (ii) if |A|=|B| then |B|=|A|; (iii) if |A|=|B| and |B|=|C| then |A|=|C|; (iv) |A|≤|A|, and if |A|≤|B| and |B|≤|C| then |A|≤|C|; (v) if A⊆B then |A|≤|B|.

Proof. (i) The identity idA is a bijection. (ii) A bijection has an inverse, which is a bijection B→A. (iii) If f:A→B and g:B→C are bijections, so is g∘f:A→C. (iv) The identity is an injection, and a composite of injections is an injection. (v) The inclusion map a↦a from A to B is an injection. □

The notation is suggestive, and it is worth being clear about what it does not yet say. No object called |A| has been defined; "|A|=|B|" is a statement about the two sets, and so is "|A|≤|B|". In particular, nothing so far says that |A|≤|B| and |B|≤|A| together give |A|=|B|. For numbers that is antisymmetry, and it is free. For sets it says that injections both ways produce a bijection, which is a real theorem, proved later in this lesson. In the language of the lesson on order, "|A|≤|B|" is a preorder on sets, and the theorem says its ties are exactly the equinumerous pairs.

Nor is "smaller" the same as "subset". The natural numbers are a proper subset of the integers, and the next sections show |ℕ|=|ℤ|. For finite sets a proper subset is always smaller, and that is the first thing to prove.

Finite sets and the pigeonhole principle

For n≥1 write [n]={1,2,…,n}, and let [0]=∅. A set A is finite, with n elements, when |A|=|[n]| for some n≥0; a bijection [n]→A is a way of counting A, naming its elements first, second, and so on up to nth. A set that is not finite is infinite.

For the definition to make sense, a set must not have both m and n elements for different m and n. That is the pigeonhole principle, from the lesson on contradiction, in its sharpest form.

Lemma (pigeonhole). If m>n≥0, there is no injection [m]→[n].

Proof. By induction on n. For n=0: [m] is not empty, since m≥1, and there is no function at all from a non-empty set to ∅.

Suppose the claim holds for n, and suppose for a contradiction that f:[m]→[n+1] is an injection with m>n+1. We build an injection [m−1]→[n]. If no element of [m−1] is sent to n+1, then f restricted to [m−1] is already an injection into [n]. Otherwise f(k)=n+1 for some k≤m−1, and by injectivity k is the only such element, so f(m)≠n+1. Define g on [m−1] by g(k)=f(m) and g(i)=f(i) for i≠k. The values of g are values of f at the distinct points of [m]∖{k}, so they are distinct and none is n+1; g is an injection [m−1]→[n]. Either way, since m−1>n, this contradicts the claim for n. □

Corollary. (a) If |[m]|=|[n]| then m=n, so the number of elements of a finite set is well defined. (b) ℕ is infinite. (c) A finite set is not equinumerous with any proper subset of itself.

Proof. (a) A bijection [m]→[n] is an injection, so m≤n by the lemma; its inverse gives n≤m.

(b) Suppose h:ℕ→[n] were a bijection. Restricted to [n+1]⊆ℕ it is an injection [n+1]→[n], which the lemma forbids.

(c) Let A have n elements, with φ:[n]→A a bijection, and suppose h:A→S is a bijection onto a proper subset S of A. Then g=φ−1∘h∘φ is an injection [n]→[n] whose image misses some k, namely φ−1(a) for any a∈A∖S. So n≥1. The map s:[n]∖{k}→[n−1] that fixes numbers below k and lowers numbers above k by one is injective, and s∘g is an injection [n]→[n−1], which the lemma forbids. □

Part (c) is what fails for infinite sets. Richard Dedekind turned it round in 1888 and defined a set to be infinite when it is equinumerous with a proper subset of itself, a definition the next section shows ℕ meets. The same lemma, restated, is the everyday pigeonhole principle: if more than n objects are put into n boxes, some box receives two, because the assignment of boxes cannot be an injection.

Hilbert's hotel and countable sets

David Hilbert gave the infinite case 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 ℕ is infinite in Dedekind's sense. 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 part (c) of the corollary and false for infinite ones.

A set is countably infinite when it is equinumerous with ℕ, countable when it is finite or countably infinite, 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 (aleph null) for the size of ℕ. Starting ℕ at 0 instead changes nothing, since the hotel's shift n↦n+1 is a bijection from {0,1,2,…} to ℕ.

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 non-zero 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,…

Finding an explicit bijection can be fiddly, and the next theorem often removes the need: to show a set is countable, it is enough to inject it into ℕ.

Theorem. Every subset of ℕ is countable. Consequently, a set A is countable if and only if there is an injection A→ℕ, and a non-empty set A is countable if and only if there is a surjection ℕ→A.

Proof. Let S⊆ℕ be infinite; we list it in increasing order. Let s1=minS, and for k≥1 let sk+1=min(S∖{s1,…,sk}). The set on the right is never empty, since otherwise S={s1,…,sk} would be finite, so by well-ordering each sk is defined. The sequence is strictly increasing: sk+1 lies in S∖{s1,…,sk−1}, whose least element is sk, and sk+1≠sk. So k↦sk is injective, and, by induction, sk≥k for every k. It is also surjective. Let t∈S, and suppose t is not among s1,…,st. Then t∈S∖{s1,…,st−1}, so its least element st satisfies st≤t; with st≥t this gives st=t, a contradiction. So k↦sk is a bijection ℕ→S.

For the first consequence: a countable set injects into ℕ, through a bijection with ℕ or with some [n]⊆ℕ. Conversely, an injection h:A→ℕ is a bijection from A onto its image h(A)⊆ℕ, which is countable, so A is countable.

For the second: if A is countable and non-empty, a bijection ℕ→A is a surjection, and if A has n≥1 elements, the bijection [n]→A extended by sending every k>n to the image of 1 is a surjection. Conversely, given a surjection q:ℕ→A, send each a∈A to the least element of {n:q(n)=a}, which exists by well-ordering. This map is injective, since different elements a have disjoint sets of such n, so A is countable by the first consequence. □

So subsets and surjective images of countable sets are countable. A countable set is the smallest kind of infinite set, in a sense made precise in the following question.

Does every infinite set contain a copy of ℕ?

Yes, if one is allowed to choose. Let A be infinite. Then A is not empty, so choose a1∈A. The set A∖{a1} is not empty, since otherwise A would have one element, so choose a2 in it. In general A∖{a1,…,ak} is never empty, since A is not finite, and ak+1 can be chosen from it. The map k↦ak is an injection ℕ→A, since each ak+1 differs from all earlier terms. So |ℕ|≤|A| for every infinite set A: no infinite size is smaller than ℵ0.

The proof makes infinitely many choices, one after another, with no rule saying which element to take. When A is a set of natural numbers, "take the least" is a rule, and the proof of the theorem above did exactly that. For an arbitrary set there may be no rule, and the argument needs a weak form of the axiom of choice, met in the lesson on functions, called countable choice or, more precisely for a sequence of choices each depending on the last, dependent choice.

With it, the two definitions of infinite agree. Given an injection k↦ak from ℕ into A, the hotel's shift moves ak to ak+1 and fixes every other element, a bijection from A onto A∖{a1}. So every infinite set is infinite in Dedekind's sense. Without any form of choice this can fail: set theorists have built models of the other axioms containing infinite sets with no countably infinite subset, sets that are infinite and yet equinumerous with none of their proper subsets.

Pairs and the rationals

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),…

The position of (m,n) in this list is a formula. Write T(k)=k(k+1)2=1+2+⋯+k, with T(0)=0. With s=m+n, the earlier diagonals hold 1+2+⋯+(s−2)=T(s−2) pairs, and (m,n) is in place m on its own, so its position is

p(m,n)=T(m+n−2)+m=(m+n−2)(m+n−1)2+m

This is the Cantor pairing function, shifted so that ℕ starts at 1. It gives p(1,1)=1, p(1,2)=2, p(2,1)=3 and p(3,5)=T(6)+3=24.

Theorem. The function p is a bijection ℕ×ℕ→ℕ. In particular ℕ×ℕ is countable.

Proof. Fix s≥2. The pairs with m+n=s are those with 1≤m≤s−1, and p sends them to T(s−2)+1,T(s−2)+2,…,T(s−2)+(s−1)=T(s−1). So p maps diagonal s injectively onto the block Bs={N∈ℕ:T(s−2)<N≤T(s−1)}.

The blocks B2,B3,B4,… are disjoint and cover ℕ. They are disjoint because T is increasing, so the ranges (T(s−2),T(s−1)] do not overlap. They cover ℕ because, given N∈ℕ, the set of s≥2 with T(s−1)≥N is not empty (T(N)≥N), so it has a least element s; then T(s−1)≥N, and T(s−2)<N, either because s=2 and T(0)=0 or by the minimality of s. So N∈Bs.

Now p is injective: two pairs on the same diagonal have different images, and two pairs on different diagonals land in different blocks. And p is surjective: each N lies in some block Bs, which is the image of diagonal s. □

As a check, the 1770 pairs with m+n≤60 (diagonals 2 to 60, holding 1+2+⋯+59=1770 pairs) are sent to exactly 1 to 1770, since the last block ends at T(59)=1770. A second, shorter bijection, (m,n)↦2m−1(2n−1), is Problem 5.

Since ℕ×ℕ is countable, so is A×B for any countable sets A and B: injections a:A→ℕ and b:B→ℕ give the injection (x,y)↦p(a(x),b(y)) from A×B to ℕ. By induction on k, then, ℤk=ℤk−1×ℤ is countable for every k≥1.

Between two rationals lies their average, so ℚ cannot be listed in increasing order. It can be listed in another.

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 by the theorem of the previous section ℚ is countable. It is infinite, since it contains ℕ, so |ℚ|=|ℕ|.

For instance −34 goes to (7,4) and then to p(7,4)=T(9)+7=52. Position p(4,2)=14 is not used, since (4,2) would stand for 22, which is not in lowest terms. The injection is not a bijection, and the theorem on subsets of ℕ closes the gap: listing the image of p∘h in increasing order and sending each rational to the rank of its code in that list is an explicit bijection ℚ→ℕ. Problem 12 gives a more elegant list of the positive rationals, in which each appears exactly once and no gaps need closing.

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)=T(5)+3=18.

Countable unions

A countable set of countable sets has a countable union. This is the most used closure property of countable sets, and it follows from the pairing function.

Theorem. Let A1,A2,A3,… be countable sets. Then A1∪A2∪A3∪⋯ is countable. The same holds for finitely many countable sets.

Proof. Let U be the union. If every An is empty, so is U. Otherwise, discard the empty sets; what remains is a finite or infinite sequence of non-empty countable sets with the same union, and repeating one of them if necessary makes it an infinite sequence A1,A2,… of non-empty countable sets. By the theorem on countable sets, for each n there is a surjection gn:ℕ→An; choose one for each n. Define G:ℕ×ℕ→U by G(n,k)=gn(k). It is surjective: an element of U lies in some An, and is gn(k) for some k. Then G∘p−1:ℕ→U is a surjection, and U is countable. □

For example, ℚ is the union over b∈ℕ of the sets {ab:a∈ℤ}, each countable as the image of ℤ, which gives a second proof that ℚ is countable.

Where does the proof "choose one for each n", and does it matter?

It chose a surjection gn:ℕ→An for every n at once. Each An is countable, so for each n surjections exist, often many of them, but the hypothesis supplies no rule for picking one. Making infinitely many such choices simultaneously is an application of the axiom of choice, met in the lesson on functions, in its countable form.

Usually the sets come with lists already attached, and then nothing is chosen: in the second proof for ℚ, the list of {ab:a∈ℤ} is k↦f(k)b, one formula for every b. The same is true in the Example below and in almost every application. When the lists are given, the theorem holds in set theory without choice.

When they are not, choice cannot be avoided. Solomon Feferman and Azriel Lévy showed in 1963 that it is consistent with the axioms of set theory other than choice that ℝ is a countable union of countable sets. Since ℝ is uncountable (proved below without any choice), in such a world the theorem fails. This does not make the theorem doubtful in ordinary mathematics, which accepts choice; it shows exactly which assumption carries the weight.

Example. Prove that the set ℤ[x] of polynomials with integer coefficients is countable.

For n≥0, let Pn be the set of polynomials c0+c1x+⋯+cnxn with every ci∈ℤ, that is, the polynomials of degree at most n (together with the zero polynomial). Such a polynomial is determined by its list of coefficients, and every list gives a polynomial, so (c0,…,cn)↦c0+c1x+⋯+cnxn is a bijection ℤn+1→Pn. Since ℤn+1 is countable, so is Pn, and this bijection is an explicit list of it (composed with a list of ℤn+1), so no choice is involved. Every polynomial has some degree n, so ℤ[x]=P0∪P1∪P2∪⋯, a countable union of countable sets, and ℤ[x] is countable.

Now you. Prove that the set of all finite subsets of ℕ is countable.

Answer

For n≥0, let Fn be the set of subsets of [n]. It is finite, with 2n elements, so countable, and it can be listed explicitly, for instance by the rule below. Every finite subset S of ℕ is a subset of [n] for some n (take n=0 if S is empty, and n=maxS otherwise), so the set of finite subsets of ℕ is F0∪F1∪F2∪⋯, a countable union of countable sets, and is countable.

An explicit bijection also exists. Send a finite set S⊆ℕ to β(S)=∑k∈S2k−1, with β(∅)=0. Every non-negative integer has exactly one binary expansion, and the binary expansion of β(S) has a 1 in exactly the places k−1 for k∈S. So β is a bijection from the finite subsets of ℕ onto {0,1,2,…}; for instance β({1,3})=1+4=5, which is 101 in binary.

The same pattern shows that the set of all finite sequences of natural numbers is countable (the union over k of the countable sets ℕk), and so is the set of all finite strings over a finite or countable alphabet. Every book, proof or computer program is such a string, so there are only countably many of each.

Intervals and the real line

Before asking whether ℝ is countable, it helps to see that its size does not depend on which piece of the line is taken. The lesson on functions proved that x↦x1+|x| is a bijection ℝ→(−1,1), and x↦x+12 is a bijection (−1,1)→(0,1), with inverse y↦2y−1. Composing, |ℝ|=|(0,1)|: the whole line has as many points as a short open piece of it. The same stretching shows that any two open intervals (a,b) and (c,d) with a<b and c<d are equinumerous, through x↦c+(x−a)(d−c)b−a.

Endpoints look harder, since no continuous bijection turns [0,1) into (0,1). But bijections need not be continuous, and the hotel's trick absorbs a point.

Example. Give an explicit bijection h:[0,1)→(0,1).

The point 0 needs a room in (0,1). Pick a sequence of distinct points inside (0,1), say 12,13,14,…, and shift along it, as the hotel shifts its guests: send 0 to 12, each 1n with n≥2 to 1n+1, and every other point to itself.

h(x)={12x=01n+1x=1nfor some integern≥2xotherwise

Let Q={1n:n≥2}. Then h maps {0}∪Q into Q, and [0,1)∖({0}∪Q) into itself by the identity, so its values lie in (0,1). Injective: two points in the third case have different images since h is the identity there, and their images are not in Q, while images in the first two cases are in Q; within {0}∪Q, the images 12 (of 0) and 1n+1 (of 1n) are all different, since n↦n+1 is injective and n+1≥3. Surjective: let y∈(0,1). If y∉Q, then h(y)=y. If y=12, then h(0)=y. If y=1m with m≥3, then h(1m−1)=y, as m−1≥2. So h is a bijection.

Now you. Give an explicit bijection [0,1]→(0,1).

Answer

Now two points need rooms. Use the same sequence and shift by two: send 0 to 12, 1 to 13, each 1n with n≥2 to 1n+2, and every other point to itself.

With Q={1n:n≥2}, the map sends {0,1}∪Q into Q and fixes everything else in [0,1], so all values lie in (0,1). Injective: points outside {0,1}∪Q are fixed and their images are outside Q; inside {0,1}∪Q the images 12, 13 and 1n+2 for n≥2 are all different. Surjective: y∉Q is its own image; 12 is the image of 0; 13 is the image of 1; and 1m with m≥4 is the image of 1m−2, where m−2≥2.

So every interval with more than one point, open, closed or half open, bounded or not, has the same size as ℝ. The Schröder and Bernstein theorem, later in the lesson, will make results like this one line long, at the price of not exhibiting the bijection.

Cantor's diagonal argument

Georg Cantor proved 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.

This lesson takes two facts about decimals from school, and the lesson on the real numbers proves them from its definitions: every real number in (0,1) has a decimal expansion 0.d1d2d3…, and every such expansion names a real number in [0,1]. 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) is uncountable: it is not empty, and no surjection from ℕ reaches all of it. Hence ℝ is uncountable too, since |ℝ|=|(0,1)|, and so is every interval with more than one point. 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.

Two consequences follow at once. The irrational numbers are uncountable, since otherwise ℝ=ℚ∪(ℝ∖ℚ) would be a union of two countable sets. And |ℕ|<|ℝ|: the inclusion is an injection, and no bijection exists. So there are at least two infinite sizes.

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.

Why doesn't the same argument prove that ℚ is uncountable?

Run it on a list of the rationals in (0,1), which exists because ℚ is countable. The construction produces a number y with digits 4 and 5 that differs from every rational on the list. There is no contradiction, because nothing says y is rational. It is not: a real number is rational exactly when its decimal expansion is eventually periodic (Problem 13 of the lesson on the real numbers proves this), and if y were rational it would be on the list, which the construction has just shown it is not. So the argument, applied to a complete list of the rationals, proves that a certain explicit real number is irrational, and nothing more.

The general lesson is that the diagonal argument needs the new object to belong to the set being listed. For binary sequences and for real numbers in (0,1) that is automatic, since any sequence of digits 4 and 5 names such a number. For the rationals, or for the algebraic numbers of the next section, or for any countable set of reals, the diagonal number escapes the set.

The same point sinks a tempting "proof" that ℕ is uncountable, written out in Problem 7. There the diagonal construction produces an infinite string of non-zero digits, which is not a natural number at all, so it escapes the list without contradicting anything.

A second view shows what really separates ℚ from ℝ. Cantor's first proof, of 1874, avoided decimals: given any sequence of reals, it built nested closed intervals avoiding one more term at each stage, and a point common to all the intervals was missed by the sequence. For a list of the rationals the intervals still shrink, but the point they close in on is irrational, so inside ℚ they have nothing in common. What the reals have and the rationals lack is the existence of that common point, the completeness that the next lesson makes into an axiom.

Algebraic and transcendental numbers

A real number is algebraic when it is a root of some non-zero polynomial with integer coefficients, and transcendental otherwise. Every rational ab is algebraic, as a root of bx−a. So is 2, a root of x2−2, and so is 2+3: if x=2+3 then x2=5+26, so (x2−5)2=24, and x is a root of x4−10x2+1. Sums and products of algebraic numbers are again algebraic (a theorem of algebra, not needed here), and for a long time nobody knew whether any real number is not.

Theorem (Cantor, 1874). The set of real algebraic numbers is countable. Consequently transcendental numbers exist, and the set of them is uncountable.

Proof. A non-zero polynomial of degree n has at most n real roots, as Mathematical Foundations shows (each root contributes a linear factor). So for each non-zero q∈ℤ[x], the set Z(q) of its real roots is finite. The algebraic numbers are the union of the sets Z(q) over all non-zero q∈ℤ[x], and ℤ[x] is countable by the Example of the previous section, so this is a countable union of finite sets, which is countable by the theorem on countable unions. No choice is involved: each Z(q) is listed in increasing order, and ℤ[x] has the explicit list built above.

If the transcendental numbers formed a countable set, then ℝ, the union of the algebraic and the transcendental numbers, would be a union of two countable sets, and countable. It is not, so the transcendental numbers are uncountable, and in particular there is at least one. □

The proof is a strange one. It shows that almost every real number is transcendental, in the sense that the transcendental ones are uncountable and the algebraic ones only countable, without identifying a single one. Joseph Liouville had exhibited the first explicit transcendental numbers in 1844, by a quite different argument about how closely algebraic numbers can be approximated by rationals. Charles Hermite proved that e is transcendental in 1873, and Ferdinand von Lindemann did the same for π in 1882, which settled the ancient problem of squaring the circle with ruler and compasses: it cannot be done. Cantor's argument, published in 1874, gave existence with no example at all, a non-constructive proof in the sense of the lesson on direct proof.

The count also puts a limit on description. Every number that can be defined by a finite text, in any fixed language, corresponds to at least one finite string of symbols, and there are only countably many such strings. So only countably many real numbers can be defined at all, and almost all real numbers can never be individually named.

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.

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

Proof. The map a↦{a} is an injection A→P(A), since {a}={a′} forces a=a′. So |A|≤|P(A)|. It remains to show that no F:A→P(A) is surjective, and then in particular none is a bijection. 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 D is not a value of F, and F is not surjective. □

For a finite set with n elements this is n<2n. For ℕ the diagonal is visible: with F(n) as row n of a table whose columns are 1,2,3,… and whose entries say whether each number is in F(n), the question "is n∈F(n)?" reads down the diagonal, and D answers each one the other way. The subsets of ℕ correspond exactly to the 0 and 1 sequences of the last Now you (a set S corresponds to the sequence with 1 in the places belonging to S), and the two proofs are the same proof.

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, concerns 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.

Is there a largest set, the set of all sets?

No, and Cantor's theorem is one proof. Suppose V were a set containing every set. Every subset of V is a set, so it is an element of V, and P(V)⊆V. Then the inclusion is an injection P(V)→V, so |P(V)|≤|V|, while Cantor's theorem gives |V|<|P(V)|. Together these would make |V|=|P(V)| by the theorem of the next section, contradicting Cantor's theorem. (Without that theorem, the contradiction can be reached directly: an injection P(V)→V yields a surjection V→P(V), by sending each image back where it came from and everything else to ∅, and Cantor's proof shows no such surjection exists.)

Cantor noticed this in the late 1890s, and it is sometimes called Cantor's paradox. It is a cousin of Russell's paradox and of the Burali-Forti paradox about the set of all ordinals, and all three were read the same way: some collections are too big to be sets. Zermelo's axioms of 1908, from which the modern system ZF grew, avoid them by never allowing a set to be formed from an unrestricted property, only by carving a subset out of a set already known, by pairing, union and power set, and by a few other operations. None of these builds a set of all sets. The collection of all sets still makes sense as something mathematicians talk about, but it is called a class, and classes are not members of anything.

The ladder above also answers a quieter question. Is there some set that is at least as big as every set? If B were one, then |P(B)|≤|B|, and the same argument gives a contradiction. So every set is outranked by another, and there are infinitely many infinite sizes.

The Schröder and Bernstein theorem

For finite sets, injections both ways give equal numbers of elements by the pigeonhole lemma. For infinite sets the corresponding statement is a genuine theorem, and the most useful tool for proving that two sets have the same size.

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

The difficulty is that neither f nor g need be surjective, and no simple combination of them obviously is. The idea is to use f on part of A and the inverse of g on the rest, and to find the right split. Elements of A outside the image g(B) cannot be handled by g−1, so they must use f. Then so must anything of the form g(f(x)) for such x, because otherwise g−1 would send it to f(x), which f already hits. Following this requirement round and round gives the set on which f is used.

Proof. Define subsets of A by

C0=A∖g(B),Cn+1=g(f(Cn))forn≥0

and let C=C0∪C1∪C2∪⋯. If x∈A∖C, then x∉C0, so x∈g(B), and since g is injective there is exactly one y∈B with g(y)=x; write it g−1(x). Define h:A→B by

h(x)={f(x)x∈Cg−1(x)x∉C

h is injective. Let h(x)=h(x′) with x≠x′. If both are in C, then f(x)=f(x′), contradicting injectivity of f. If neither is, then g−1(x)=g−1(x′), and applying g gives x=x′. If x∈C and x′∉C, then f(x)=g−1(x′), so x′=g(f(x)). Now x∈Cn for some n, so x′∈g(f(Cn))=Cn+1⊆C, a contradiction. The remaining case is the same with x and x′ exchanged.

h is surjective. Let y∈B. If g(y)∉C, then h(g(y))=g−1(g(y))=y. If g(y)∈C, then g(y)∈Cn for some n, and n≠0 because g(y)∈g(B). So g(y)∈Cn=g(f(Cn−1)), that is, g(y)=g(f(x)) for some x∈Cn−1. Since g is injective, y=f(x), and since x∈C, h(x)=f(x)=y. □

Cantor stated the theorem without a proof he was satisfied with. Richard Dedekind proved it in 1887 but did not publish; Felix Bernstein, a nineteen-year-old in Cantor's seminar, proved it in 1897; and Ernst Schröder published a proof at about the same time that was later found to contain a gap. The proof uses no choice at all: every step is determined by f and g. Problem 13 of the lesson on order gives a second proof, from a fixed point theorem for power sets.

With the theorem, a bijection no longer has to be built. For the Now you of the section on intervals, the inclusion (0,1)→[0,1] and the map x↦x+13, which sends [0,1] into [13,23]⊆(0,1), are injections both ways, so |[0,1]|=|(0,1)| in one line.

Example. Prove that |ℝ|=|P(ℕ)|.

An injection P(ℕ)→ℝ. Send a set S⊆ℕ to the number 0.d1d2d3… with dn=1 if n∈S and dn=0 if n∉S. Different sets give digit strings that differ in some place, and neither string contains a 9. Two different expansions of the same number must have one ending in 9s, so these strings name different numbers, and the map is injective.

An injection ℝ→P(ℕ). Send x∈ℝ to the set L(x)={q∈ℚ:q<x}. If x<y, there is a rational q with x<q<y (the rationals are dense, as the lesson on the real numbers proves), and q∈L(y) while q∉L(x). So x↦L(x) is an injection ℝ→P(ℚ). Let φ:ℚ→ℕ be a bijection. Then T↦φ(T)={φ(q):q∈T} is a bijection P(ℚ)→P(ℕ), with inverse U↦φ−1(U). Composing gives an injection ℝ→P(ℕ).

By the Schröder and Bernstein theorem, |ℝ|=|P(ℕ)|. So the size of the real line is the second rung of Cantor's ladder, and ℝ has the same size as the set of 0 and 1 sequences. This size is called the continuum. Since |ℕ|<|P(ℕ)| by Cantor's theorem, this gives a proof that ℝ is uncountable which uses decimals only for the injection P(ℕ)→ℝ, where no digit 9 ever appears.

Now you. Prove that |ℝ×ℝ|=|ℝ|: the plane has no more points than the line.

Answer

An injection ℝ→ℝ×ℝ is x↦(x,0).

An injection ℝ×ℝ→ℝ. Since |ℝ|=|(0,1)|, there is a bijection b:ℝ→(0,1), and (x,y)↦(b(x),b(y)) is a bijection ℝ×ℝ→(0,1)×(0,1). So it is enough to inject (0,1)×(0,1) into ℝ. Write u=0.u1u2u3… and v=0.v1v2v3… using the expansions that do not end in 9s, and send (u,v) to the number with the interleaved expansion 0.u1v1u2v2u3v3…. The interleaved string does not end in 9s, since that would force both u and v to end in 9s. Different pairs give different strings, since the pair can be read back from the odd and even places, and two different strings neither of which ends in 9s name different numbers. So the map is injective.

By the Schröder and Bernstein theorem, |ℝ×ℝ|=|ℝ|. By induction, |ℝn|=|ℝ| for every n∈ℕ. Cantor found this in 1877 and wrote to Dedekind that he saw it but did not believe it. It shows that dimension is not a matter of how many points a space has; what distinguishes the line from the plane is how the points are arranged, and a continuous bijection between them is impossible.

The continuum hypothesis

Two infinite sizes are now in hand: that of ℕ, shared by ℤ, ℕ×ℕ, ℚ and the algebraic numbers, and the strictly larger size of ℝ, shared by every interval, by the plane and by P(ℕ). Every infinite set of reals met so far has one of these two sizes. In 1878 Cantor asked whether that is always so.

The continuum hypothesis. Every infinite subset of ℝ is either countable or equinumerous with ℝ.

Equivalently, assuming the axiom of choice, there is no set A with |ℕ|<|A|<|ℝ|. Cantor believed the hypothesis and spent years trying to prove it. It was the first of the twenty-three problems David Hilbert set out in Paris in 1900 as the challenges for the new century.

What does it mean that the continuum hypothesis cannot be settled?

Kurt Gödel showed in 1940 that the continuum hypothesis cannot be disproved from the usual axioms of set theory, ZF together with the axiom of choice, provided those axioms are consistent. He built, inside any model of the axioms, a smaller model, the constructible universe, in which every set is built in a precisely controlled way, and in which the hypothesis is true. Paul Cohen showed in 1963 that it cannot be proved from them either, by inventing forcing, a method of enlarging a model by adding new sets, and using it to add many new subsets of ℕ, so that the continuum becomes much larger than the first size beyond ℵ0. Cohen received the Fields Medal in 1966 for this work.

So the hypothesis is independent of the axioms: both it and its negation are consistent with them. This is not a statement that the question is meaningless or that the answer is unknown for lack of effort. It is a theorem about what the axioms that ground the rest of mathematics can prove, in the same way that Euclid's parallel postulate was eventually shown to be independent of his other axioms.

What remains is a question of which further axioms to adopt. The hypothesis does hold for the well-behaved sets that analysis usually meets: Cantor and Ivar Bendixson showed in the 1880s that every closed set of reals is countable or has the size of ℝ, and later work extended this to much larger families of sets. Whether set theory should be extended by axioms that decide the hypothesis for all sets, and which way, is an open debate among set theorists.

The count settles 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.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.

Warm-up

1. Give an explicit bijection from ℕ to each set, and prove that it is one: (a) the even natural numbers; (b) {n∈ℤ:n≥−5}; (c) ℕ×{1,2}.

Solution

(a) Let E={2,4,6,…} and a(n)=2n. Its values are even natural numbers. It is injective, since 2m=2n gives m=n, and surjective, since an even natural number k is 2m with m=k2∈ℕ, and a(m)=k.

(b) Let b(n)=n−6. For n≥1, b(n)≥−5, so the values lie in the set. It is injective, since m−6=n−6 gives m=n. It is surjective: given an integer k≥−5, the number n=k+6 is at least 1, and b(n)=k. So b lists the set as −5,−4,−3,….

(c) Let c(n)=(⌈n2⌉,2−(nmod2)), so that odd n=2j−1 goes to (j,1) and even n=2j goes to (j,2). Its inverse is (j,1)↦2j−1 and (j,2)↦2j: composing either way gives the identity, since every natural number is exactly one of 2j−1 or 2j for a unique j∈ℕ (by the division algorithm). A function with an inverse is a bijection.

2. Using p(m,n)=T(m+n−2)+m with T(k)=k(k+1)2, and the bijection f:ℕ→ℤ from the lesson: (a) compute p(5,3); (b) find the pair (m,n) with p(m,n)=20; (c) find f−1(−6) and f(10).

Solution

(a) p(5,3)=T(6)+5=21+5=26.

(b) The blocks are Bs={N:T(s−2)<N≤T(s−1)}. Since T(5)=15<20≤21=T(6), the number 20 lies in B7, so m+n=7 and m=20−T(5)=5, giving (m,n)=(5,2). Check: p(5,2)=T(5)+5=20.

(c) For k≤0, f−1(k)=1−2k, so f−1(−6)=13. For even n, f(n)=n2, so f(10)=5.

3. Say whether each set is countable or uncountable, with a reason: (a) the set of all finite words in the letters a to z; (b) ℚ×ℚ; (c) the set of infinite 0 and 1 sequences with only finitely many 1s; (d) the set of all infinite 0 and 1 sequences; (e) the set of irrational numbers in (0,1); (f) the set of circles in the plane whose centre has rational coordinates and whose radius is rational.

Solution

(a) Countable. For each k≥0 there are 26k words of length k, a finite set, and the set of all words is the union of these countably many finite sets.

(b) Countable, as a product of two countable sets.

(c) Countable. Sending such a sequence to the set of places where it has a 1 is a bijection onto the finite subsets of ℕ, which are countable by the Now you of the section on countable unions.

(d) Uncountable, by the Now you of the section on the diagonal argument.

(e) Uncountable. If it were countable, then (0,1) would be the union of the countable set ℚ∩(0,1) and a countable set, hence countable, which the diagonal argument forbids.

(f) Countable. A circle is determined by its centre (a,b) and radius r, so sending the circle to (a,b,r) is an injection into ℚ×ℚ×ℚ, which is countable.

4. Prove: (a) if B is countable and f:A→B is an injection, then A is countable; (b) if A is countable and g:A→B is a surjection, then B is countable.

Solution

(a) Since B is countable, there is an injection b:B→ℕ, by the theorem on countable sets. Then b∘f:A→ℕ is a composite of injections, hence an injection, and by the same theorem A is countable.

(b) If B is empty, it is finite and so countable. Otherwise A is non-empty too, since g is onto B, so there is a surjection a:ℕ→A by the theorem. Then g∘a:ℕ→B is a surjection (every y∈B is g(x) for some x, and x=a(n) for some n), and by the theorem B is countable.

Core

5. Prove that F(m,n)=2m−1(2n−1) is a bijection ℕ×ℕ→ℕ.

Hint

Show that every natural number k can be written as 2iq with i≥0 and q odd in exactly one way.

Solution

Every k∈ℕ is 2iq with i≥0 and q odd. Let I={i≥0:2i∣k}. It contains 0, and it is bounded, since 2i∣k gives 2i≤k<2k, so i<k. So I has a greatest element i, and k=2iq for some q∈ℕ. If q were even, 2i+1 would divide k, contradicting the choice of i. So q is odd.

The form is unique. Suppose 2iq=2jr with q, r odd, and suppose i<j. Then q=2j−ir is even, a contradiction. So i=j by symmetry, and then q=r.

F is a bijection. F(m,n)=2m−1(2n−1) has i=m−1≥0 and q=2n−1 odd. Injective: if F(m,n)=F(m′,n′), uniqueness of the form gives m−1=m′−1 and 2n−1=2n′−1, so (m,n)=(m′,n′). Surjective: given k, write k=2iq with q odd; then m=i+1∈ℕ and n=q+12∈ℕ satisfy F(m,n)=k. For instance F(3,2)=4×3=12, and 40=23×5 is F(4,3).

6. Let A be a set with a countably infinite subset, and let B be countable. Prove that |A∪B|=|A|. Deduce that the set of irrational numbers has the same size as ℝ.

Hint

Replace B by B∖A. Then use the hotel: a countably infinite part of A can absorb a countable set of extra guests.

Solution

Let B′=B∖A, a subset of a countable set and so countable, with A∪B=A∪B′ and A∩B′=∅. Let K⊆A be countably infinite. Then K∪B′ is countable, as a union of two countable sets, and infinite, since it contains K, so it is countably infinite. Two countably infinite sets are equinumerous, both being equinumerous with ℕ, so there is a bijection φ:K∪B′→K.

Define h:A∪B′→A by h(x)=φ(x) for x∈K∪B′, and h(x)=x for x∈A∖K. The domain splits into the disjoint pieces K∪B′ and A∖K (disjoint because B′∩A=∅), and the codomain into the disjoint pieces K and A∖K. On the first piece h is the bijection φ onto K, and on the second it is the identity onto A∖K. So h is injective (images from different pieces lie in different pieces) and surjective, and |A∪B|=|A|.

For the irrationals, let A=ℝ∖ℚ and B=ℚ. The set K={2+n:n∈ℕ} is a countably infinite subset of A, since 2+n rational would make 2 rational. So |ℝ|=|A∪B|=|A|: there are exactly as many irrational numbers as real numbers.

7. Find the flaw in this argument.

Claim. ℕ is uncountable.

Proof. Let g:ℕ→ℕ be any function. Write each g(n) in decimal as an infinite string of digits running leftwards, …dn,3dn,2dn,1, padded with 0s, so that dn,k is the kth digit from the right. Let ck=4 if dk,k=5 and ck=5 otherwise, and let c be the number …c3c2c1. Then c differs from g(n) in the nth digit from the right, so c≠g(n) for every n, and g is not surjective.

Hint

Is c a natural number?

Solution

Every digit ck is 4 or 5, so the string …c3c2c1 has infinitely many non-zero digits. A natural number has only finitely many non-zero digits: if 10j−1≤N<10j, every digit beyond the jth from the right is 0. So the string names no natural number, and c∉ℕ. The argument shows only that a certain infinite string is not among the values of g, which is true and harmless, and it does not show that some natural number is missed.

This is the requirement from the discussion of ℚ after the diagonal argument: the diagonal object must belong to the set being listed. For (0,1) it does, since an infinite string of digits after a decimal point names a real number; for ℕ it does not. Indeed the claim is false, since the identity is a bijection ℕ→ℕ.

8. Prove or disprove each claim. (a) The set of infinite subsets of ℕ is countable. (b) The set of sequences (a1,a2,…) of non-negative integers with only finitely many non-zero terms is countable. (c) If A is uncountable and B⊆A is countable, then A∖B is uncountable. (d) Every uncountable subset of ℝ contains an interval (a,b) with a<b.

Hint

For (a) and (c), write a known uncountable set as a union. For (d), think of a set that meets no interval completely.

Solution

(a) False. P(ℕ) is the union of the set of finite subsets of ℕ, which is countable, and the set of infinite subsets. If the latter were countable, P(ℕ) would be a union of two countable sets and countable, contradicting Cantor's theorem.

(b) True. For n≥0 let En be the set of such sequences with ak=0 for all k>n. The map (a1,a2,…)↦(a1,…,an) is a bijection from En to the set of n-tuples of non-negative integers, which is countable as a finite product of countable sets (E0 has one element). Every such sequence lies in En for n its last non-zero place, or n=0, so the set is E0∪E1∪⋯, a countable union of countable sets with explicit lists, hence countable.

(c) True. A=B∪(A∖B). If A∖B were countable, A would be a union of two countable sets, hence countable.

(d) False. The irrationals are uncountable (as shown after the diagonal argument), but contain no interval (a,b) with a<b, since every such interval contains a rational number.

9. Consider a family of open intervals (a,b), each with a<b, no two of which overlap. Prove that the family is countable.

Hint

Every interval of positive length contains a rational number. Fix a list of the rationals, and use it to name one rational in each interval without choosing.

Solution

Fix a bijection k↦qk from ℕ to ℚ. Every interval I=(a,b) with a<b contains a rational number (by density of ℚ, proved in the lesson on the real numbers), so the set {k∈ℕ:qk∈I} is not empty, and by well-ordering it has a least element r(I). This defines a function r on the family, with no choice involved.

The function r is injective. If r(I)=r(J)=k, then qk lies in both I and J, so they overlap, and since no two different intervals of the family overlap, I=J. So the family injects into ℕ and is countable.

The same argument shows that a function φ:ℝ→ℝ that is increasing can have only countably many jumps: at each jump there is a gap between the left and right limits, and the gaps at different jumps are disjoint open intervals.

10. Let ℕℕ be the set of all sequences (a1,a2,…) of natural numbers. Prove that |ℕℕ|=|P(ℕ)|, and hence |ℕℕ|=|ℝ|.

Hint

Use the Schröder and Bernstein theorem. For one injection, encode a set by a sequence of 1s and 2s. For the other, send a sequence to its graph, a subset of ℕ×ℕ.

Solution

An injection P(ℕ)→ℕℕ. Send S⊆ℕ to the sequence with an=2 if n∈S and an=1 otherwise. Different sets differ at some n, where the sequences differ, so the map is injective.

An injection ℕℕ→P(ℕ). Send a sequence a to its graph Γ(a)={(n,an):n∈ℕ}⊆ℕ×ℕ. If a≠a′, they differ at some n, and then (n,an)∈Γ(a) but (n,an)∉Γ(a′), since the only pair in Γ(a′) with first coordinate n is (n,an′). So Γ is an injection ℕℕ→P(ℕ×ℕ). The pairing bijection p:ℕ×ℕ→ℕ gives a bijection T↦p(T) from P(ℕ×ℕ) to P(ℕ), and the composite is an injection ℕℕ→P(ℕ).

By the Schröder and Bernstein theorem |ℕℕ|=|P(ℕ)|, and |P(ℕ)|=|ℝ| by the Example in that section, so |ℕℕ|=|ℝ|.

11. Prove that no power set is countably infinite: there is no set A with |P(A)|=|ℕ|.

Hint

If P(A) is countable, what does that say about A? Treat finite and infinite A separately.

Solution

Suppose |P(A)|=|ℕ|. The map a↦{a} is an injection A→P(A), and P(A) is countable, so A is countable by Problem 4(a).

If A is finite with n elements, then P(A) has 2n elements, as the lesson on sets proved by induction, so P(A) is finite and not equinumerous with ℕ (part (b) of the corollary on finite sets, together with the fact that equinumerosity is symmetric and transitive).

If A is countably infinite, let φ:A→ℕ be a bijection. Then S↦φ(S) is a bijection P(A)→P(ℕ), with inverse T↦φ−1(T). So |P(ℕ)|=|P(A)|=|ℕ|, contradicting Cantor's theorem.

Either way there is a contradiction. So a power set is finite (of size 2n) or uncountable, and never of size ℵ0.

Challenge

12. Build a tree of fractions: the root is 11, and each node ab has a left child aa+b and a right child a+bb. Prove that every positive rational number appears in the tree exactly once, and in lowest terms. Deduce an explicit list of the positive rationals in which each appears exactly once.

Hint

Left children are less than 1 and right children greater than 1. For existence and uniqueness, use strong induction on a+b for ab in lowest terms, and ask which node could be the parent of ab.

Solution

Write every node as the pair (a,b) of positive integers that the construction produces, so the root is (1,1) and the children of (a,b) are (a,a+b) and (a+b,b).

Every node is in lowest terms. The root is. If gcd(a,b)=1, then a common divisor d of a and a+b divides (a+b)−a=b, so d divides both a and b, and d=±1; the same holds for a+b and b. By induction on the depth of a node, every node (a,b) has gcd(a,b)=1.

Left, right and root. A left child (a,a+b) has value aa+b<1, a right child (a+b,b) has value greater than 1, and the root has value 1.

Existence. We prove by strong induction on a+b that every pair (a,b) of positive integers with gcd(a,b)=1 is a node. If a=b, then gcd(a,b)=a=1, and (1,1) is the root. If a<b, then (a,b−a) is a pair of positive integers with gcd(a,b−a)=1 (a common divisor of a and b−a divides their sum b), and a+(b−a)=b<a+b, so by hypothesis (a,b−a) is a node, and its left child is (a,b). If a>b, then in the same way (a−b,b) is a node, and its right child is (a,b).

Uniqueness. We prove by strong induction on a+b that (a,b) is at most one node. If a=b, a node equal to (a,b) is in lowest terms, so a=b=1, and every node other than the root is a left or right child, with value different from 1, so only the root is (1,1). If a<b: a node equal to (a,b) is not the root and not a right child, so it is the left child of some node (a′,b′) with (a′,a′+b′)=(a,b), which forces (a′,b′)=(a,b−a). By hypothesis, (a,b−a) is a single node, and it has a single left child. So (a,b) occurs once. The case a>b is the same with right children.

Since every positive rational has exactly one representation ab with a,b∈ℕ and gcd(a,b)=1, every positive rational occurs at exactly one node.

The list. Level k of the tree (the nodes at distance k from the root) has 2k nodes. Listing level 0, then level 1 from left to right, then level 2, and so on, reaches every node after finitely many steps, and each once. So it is a bijection from ℕ to the nodes, and hence, by what was proved, to the positive rationals:

1,12,2,13,32,23,3,14,43,35,52,25,53,34,4,…

This is the Calkin and Wilf enumeration, published by Neil Calkin and Herbert Wilf in 2000. Unlike the injection in the lesson, it skips nothing.

13. Prove that the set of all bijections ℕ→ℕ has the same size as ℝ.

Hint

For an injection from the 0 and 1 sequences, let a sequence decide which of the pairs {1,2}, {3,4}, {5,6}, and so on are swapped. For the other direction, use Problem 10.

Solution

Let Σ be the set of bijections ℕ→ℕ, and S the set of infinite 0 and 1 sequences. Recall |S|=|P(ℕ)|=|ℝ|: a set corresponds to the sequence with 1s exactly at its members, and the Example of the section on Schröder and Bernstein gives |P(ℕ)|=|ℝ|.

An injection S→Σ. For t=(t1,t2,…)∈S, let σt swap 2k−1 and 2k when tk=1 and fix both when tk=0, for each k∈ℕ. Every natural number is 2k−1 or 2k for exactly one k, so σt is defined on all of ℕ, and σt∘σt is the identity, so σt is its own inverse and a bijection. If t≠t′, they differ at some k, and then one of σt(2k−1), σt′(2k−1) is 2k and the other is 2k−1, so σt≠σt′.

An injection Σ→ℕℕ. Every bijection ℕ→ℕ is in particular a sequence of natural numbers, (σ(1),σ(2),…), so the inclusion Σ⊆ℕℕ is an injection. By Problem 10, |ℕℕ|=|ℝ|=|S|, so there is an injection Σ→S.

By the Schröder and Bernstein theorem, |Σ|=|S|=|ℝ|. In particular the set of permutations of ℕ is uncountable, while the set of permutations of ℕ that move only finitely many numbers is countable (each is determined by a finite list of values), which shows how much the infinite permutations add.

14. Let (A,⪯) be a countable totally ordered set. Prove that there is an injection f:A→ℚ with a≺b implying f(a)<f(b): every countable total order is a suborder of the rationals.

Hint

List A as a1,a2,a3,… and define f(an) one step at a time. At step n, the earlier values split into those that must lie below f(an) and those that must lie above it; the rationals always have room in between, and beyond either end.

Solution

If A is empty there is nothing to do. Otherwise list A without repetitions as a1,a2,…, finite or infinite. We define f(an) by recursion on n so that, at every stage, f is strictly increasing on {a1,…,an}.

Let f(a1)=0. Suppose f(a1),…,f(an−1) are defined with f strictly increasing on {a1,…,an−1}, where n≥2. Let L={i<n:ai≺an} and U={i<n:an≺ai}; since the order is total and the ai are distinct, every i<n lies in exactly one of them. Every element indexed by L is below every element indexed by U, since ai≺an≺aj; so, as f is increasing on the earlier elements, f(ai)<f(aj) for all i∈L and j∈U. Put λ=max{f(ai):i∈L} and μ=min{f(aj):j∈U} when these sets are non-empty, and define

f(an)={λ+μ2L≠∅andU≠∅λ+1U=∅μ−1L=∅

(At least one of L and U is non-empty, since n≥2.) In each case f(an) is rational, greater than every f(ai) with i∈L, and less than every f(aj) with j∈U, because λ<λ+μ2<μ when λ<μ. So f is strictly increasing on {a1,…,an}.

Now let a≺b in A, say a=ai and b=aj. At stage max(i,j), both values are defined and f is strictly increasing on the elements defined so far, so f(a)<f(b). Values are never changed after they are defined, so this holds for f itself. Finally f is injective: if a≠b, then a≺b or b≺a by totality, and f(a)≠f(b).

The construction used only that ℚ has no greatest or least element and that between two rationals lies a third. Cantor proved in 1895 that these properties characterise the rationals: any two countable totally ordered sets that are dense in this sense and have no greatest or least element are order-isomorphic. The standard proof runs the construction above alternately from each side, and is known as the back and forth method.

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 quantifiers, 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; that some real number has square 2, claimed in the lesson on quantifiers; and that a decimal expansion names a real number, which the diagonal argument took for granted. It assumes upper bounds and the supremum from the lesson on order: u=supA when u is an upper bound of A lying below every other upper bound. As throughout the course, ℕ={1,2,3,…}.

The plan is the one a first analysis course follows. First, write down exactly what is assumed about ℝ: the arithmetic and order rules it shares with ℚ, and the one axiom it does not share. Then derive everything else from that list, including facts so familiar that they seem not to need proof, because several of them turn out to be false in number systems that obey every rule of school algebra.

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 lesson on order watched the decimals 1.4, 1.41, 1.414 climb inside T while 1.5, 1.42, 1.415 came down from above, and claimed 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=0.043.8=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, just above 2. Both h and k are built from u by the four operations, 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 the lesson on contradiction proved, no rational has square 2, so u2≠2, and 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 ℚ.

The structure is worth seeing. Trichotomy splits the candidate into three cases; algebra kills two of them; irrationality kills the third. Nothing is left, so no candidate exists.

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. It is rational and positive, and less than 1 because 3−u2≤2<3≤2u+1. Then h2<h, so (u+h)2<u2+h(2u+1)=3, and u+h is in the set and exceeds u, a contradiction. If u2>3, let k=u2−32u>0. Then u−k=u2+32u>0 and (u−k)2>u2−2uk=3. Any element q of the set with q≥u−k would have q2≥(u−k)2>3, so u−k is an upper bound smaller than u, 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.

A field is a set F with two operations, + and ⋅, and two distinguished elements 0 and 1, such that for all x, y, z in F:

  • (A1) x+(y+z)=(x+y)+z and (A2) x+y=y+x;
  • (A3) x+0=x, and (A4) there is an element −x with x+(−x)=0;
  • (M1) x(yz)=(xy)z and (M2) xy=yx;
  • (M3) x⋅1=x, where 1≠0, and (M4) if x≠0, there is an element x−1 with xx−1=1;
  • (D) x(y+z)=xy+xz.

Subtraction and division are abbreviations: x−y means x+(−y), and xy means xy−1 for y≠0. An ordered field is a field with a total order ≤ (reflexive, antisymmetric, transitive, and any two elements comparable, as in the lesson on order) that respects the arithmetic:

  • (O1) if x≤y, then x+z≤y+z;
  • (O2) if 0≤x and 0≤y, then 0≤xy.

As usual x<y means x≤y and x≠y, and x is positive when 0<x. Totality gives trichotomy: for any x and y, exactly one of x<y, x=y, y<x holds.

Eleven axioms look like very little, but every rule of school algebra and every rule for manipulating inequalities follows from them. Here are the ones used constantly, with proofs, to show how the derivations go; parts (i) to (iii) repeat, for every ordered field, what the first lesson proved for the integers.

Lemma. In any ordered field, for all x, y, z:

(i) negatives are unique: if x+y=0 and x+y′=0, then y=y′;

(ii) 0⋅x=0;

(iii) (−1)x=−x, and (−x)(−y)=xy;

(iv) if xy=0, then x=0 or y=0;

(v) x≤y if and only if 0≤y−x; in particular x≤0 if and only if 0≤−x;

(vi) if x<y and 0<z, then xz<yz; if x<y and z<0, then yz<xz.

Proof. (i) y=y+0=y+(x+y′)=(y+x)+y′=0+y′=y′, using (A3), (A1) and (A2).

(ii) 0⋅x=(0+0)x=0⋅x+0⋅x by (A3) and (D). Adding −(0⋅x) to both sides and using (A1), (A4), (A3) leaves 0=0⋅x.

(iii) x+(−1)x=1⋅x+(−1)x=(1+(−1))x=0⋅x=0, so (−1)x is a negative of x, and by (i) it is −x. Then (−x)(−y)=(−1)(−1)xy, and (−1)(−1)=−(−1)=1, because −1+1=0 makes 1 the negative of −1.

(iv) Suppose xy=0 and x≠0. Then y=(x−1x)y=x−1(xy)=x−1⋅0=0.

(v) If x≤y, add −x to both sides by (O1): 0≤y−x. If 0≤y−x, add x: x≤y. Taking y=0 gives the second statement.

(vi) Suppose x<y and 0<z. By (v), 0≤y−x, and y−x≠0. By (O2), 0≤(y−x)z=yz−xz, and by (iv) the product is not 0, since neither factor is. So 0<yz−xz, and by (v), xz<yz. If z<0, then 0<−z by (v), and the first part gives x(−z)<y(−z), that is, −xz<−yz; adding xz+yz to both sides gives yz<xz. □

Part (vi) is the rule "multiplying by a negative number reverses an inequality", and it is a theorem, not a convention. The same style of argument shows that inequalities can be added: if a≤b and c≤d then a+c≤b+c≤b+d.

Example. Prove that in any ordered field, x2≥0 for every x, and deduce that 0<1.

Let x be an element of the field. By totality, 0≤x or x≤0. If 0≤x, then (O2) with both factors equal to x gives 0≤x⋅x=x2. If x≤0, then 0≤−x by part (v) of the lemma, and (O2) gives 0≤(−x)(−x), which equals x2 by part (iii). So x2≥0 in both cases.

Now 1=1⋅1=12≥0, and 1≠0 by (M3), so 0<1.

The fact looks too obvious to prove, and yet it has content: nothing in the order axioms says directly that 1 is on the positive side. It then follows that 1+1>1>0, and by induction that 1+1+⋯+1 (n terms) is positive for every n∈ℕ. So in an ordered field the elements 1, 1+1, 1+1+1, and so on are all different and all positive, and they form a copy of ℕ inside the field. Negatives and quotients of these give copies of ℤ and ℚ. When this lesson writes ℕ⊆ℝ, that copy is what is meant.

Now you. Prove that in any ordered field, if 0<a, then 0<a−1, and if 0<a<b, then 0<b−1<a−1.

Answer

Let 0<a. Then a≠0, so a−1 exists, and a−1≠0 because aa−1=1≠0 (by part (ii) of the lemma, a⋅0=0). Suppose, for contradiction, that a−1<0. Multiplying the inequality 0<a by the negative element a−1 reverses it, by part (vi): a⋅a−1<0⋅a−1, that is, 1<0. That contradicts the Example, so by trichotomy 0<a−1.

Now let 0<a<b. Then b>0, so a−1>0 and b−1>0 by the first part, and their product a−1b−1 is positive by (O2) and part (iv) of the lemma. Multiplying a<b by this positive element keeps the direction, by part (vi): a⋅a−1b−1<b⋅a−1b−1, which simplifies to b−1<a−1.

Why can the complex numbers not be put in order?

They can be put in some total order, just not one that respects the arithmetic. The Example says that in every ordered field, every square is non-negative and 1 is positive, so −1 is negative (by part (v) of the lemma, since 0<1 gives −1<0). In ℂ, −1=i2 is a square. So an order on ℂ satisfying (O1) and (O2) would make −1 both non-negative and negative, which trichotomy forbids. No ordered field contains a square root of −1.

The comment after the Example rules out another family. In the field ℤ/5ℤ of remainders modulo 5, from the lesson on equivalence relations, 1+1+1+1+1=0. In an ordered field, a sum of n copies of 1 is positive, never 0. So no finite field can be ordered, and every ordered field is infinite and contains a copy of ℚ, as the Example showed. In that sense ℚ is the smallest ordered field, sitting inside all of them.

Neither argument uses completeness. They show how much the eleven axioms already decide: the sign of 1, the sign of every square, which fields can be ordered at all. What they cannot decide is whether a given element, such as a square root of 2, exists, and that is the next section's point.

What the rationals lack

The trouble is that ℚ satisfies every one of these axioms. So no argument from the ordered field axioms alone can produce a number whose square is 2, since the same argument would work in ℚ, where there is none. This is a common pattern for proving that something does not follow from a list of axioms: exhibit one structure satisfying all of them in which the conclusion fails. Here ℚ is that structure.

The gap at 2 is not a single blemish. The same algebra, with 3, 5 or any non-square in place of 2, shows that the rationals below 3, 5 and so on have no rational least upper bound either, and the previous lesson showed that the rationals are countable while the reals are not, so all but a countable part of the real line is missing from ℚ. The rationals are full of holes, and a single additional axiom fills all of them.

The completeness axiom

The missing property concerns least upper bounds, exactly where the rationals failed.

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. Every other property of ℝ used from here on is proved from the eleven ordered field axioms and this one. The rationals are an ordered field that is not complete: 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. The set ℕ, as the section on the Archimedean property proves, has no upper bound at all. And the supremum, when it exists, is unique: if u and u′ are both least upper bounds of A, each is an upper bound lying below every upper bound, so u≤u′ and u′≤u, and antisymmetry gives u=u′. That is why the notation supA is allowed.

A supremum need not belong to the set. When it does, it is the maximum maxA, the greatest element; sup[0,1]=max[0,1]=1, while sup[0,1)=1 and [0,1) has no maximum. The axiom is exactly what guarantees a supremum when there is no maximum to fall back on. Every nonempty finite set has a maximum, so completeness says nothing new about finite sets; it is a statement about infinite ones.

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.

Where do the real numbers come from, if they are only described by axioms?

An axiom list describes what is wanted; it does not show that anything fits the description. Dedekind's construction does, using nothing but ℚ and sets.

A cut is a subset α of ℚ that is nonempty, is not all of ℚ, is closed downwards (if q∈α and p<q then p∈α), and has no greatest element. The rationals below 12 form a cut, and so does T together with all negative rationals, that is, {q∈ℚ:q<0orq2<2}. The first cut is "the number 12"; the second has no rational at its top and is "the number 2". Dedekind defines the reals to be the cuts. Order is inclusion: α≤β means α⊆β. Addition is α+β={p+q:p∈α,q∈β}, and multiplication is defined first for positive cuts, then extended by signs.

The hard work is checking the eleven ordered field axioms, which is long and unilluminating. Completeness, the axiom ℚ lacked, is the easy one. If A is a nonempty set of cuts bounded above by a cut β, its union ⋃A is again a cut (nonempty, contained in β so not all of ℚ, closed downwards, and with no greatest element since no member of A has one), it contains every member of A, and it is contained in every upper bound. So supA=⋃A. Taking suprema, which is what fails in ℚ, becomes taking unions, which always works.

Cantor's construction goes through equivalence classes, in the manner of the lesson on equivalence relations, where ℚ was built from pairs of integers. A real number is a class of sequences of rationals whose terms eventually stay as close together as you like, two sequences being equivalent when their difference tends to 0.

The two constructions give the same answer. Any two complete ordered fields are isomorphic: there is a bijection between them that preserves addition, multiplication and order, and it is unique. So the axioms describe exactly one structure, up to renaming the elements, and it no longer matters whether a real number "is" a cut, a class of sequences, or an infinite decimal. This is why a course may start from the axioms, as this one does, and never look at a construction again.

Working with the supremum

The definition of supA quantifies over every upper bound, which is awkward to check directly. Proofs usually want a form that tests only numbers just below the candidate. The lesson on order stated this form for ℝ; here it is with a proof.

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 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−ε.

(⇐) 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 next lesson, on limits, makes over and over. The characterisation also has a sequential flavour: taking ε=1,12,13,… produces elements a1,a2,a3,… of A with s−1n<an≤s, a sequence in A that closes in on its supremum.

A classic pitfall sits here. Strict inequalities do not survive taking suprema. Every element of [0,1) is less than 1, and yet sup[0,1)=1, not something less than 1. What does survive is the weak version: if every a∈A satisfies a≤c, then c is an upper bound, so supA≤c. A proof that concludes "supA<c" from "a<c for all a" has made this mistake, and the decimal 0.999… at the end of the lesson is its most famous victim.

Lower bounds need no second axiom.

Proposition. Every nonempty set of real numbers that is bounded below has a greatest lower bound, infA=−sup(−A), where −A={−a:a∈A}.

Proof. Let A be nonempty with a lower bound m. Then −A is nonempty, and −m is an upper bound of it: every element is −a with a≥m, so −a≤−m by part (v) of the lemma. By completeness, −A has a supremum s. Put t=−s. For every a∈A, −a≤s, so a≥−s=t, and t is a lower bound of A. If m′ is any lower bound of A, then −m′ is an upper bound of −A by the same reasoning, so s≤−m′, that is, m′≤t. So t is the greatest lower bound. □

The infimum infA is the greatest lower bound, and the minimum minA is a least element when one exists. Negation turns upper bounds into lower bounds and back, so every fact about suprema has a mirror image about infima, proved by applying the fact to −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+ε.

(⇐) Suppose t is a lower bound with this property, and let m be any lower bound. If m>t, take ε=m−t>0: 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 quantifiers, on sets and on order used, without proof, that ℕ has no upper bound in ℝ. It sounds like something no proof could make clearer. It is not a consequence of the ordered field axioms, though: the deeper explanation below describes an ordered field containing an element larger than every natural number. In ℝ it follows from completeness.

Theorem (the Archimedean property). For every real number x there is a natural number n with n>x.

Proof. 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 of the supremum with ε=1, some n∈ℕ has n>s−1. Then n+1>s, and n+1∈ℕ, contradicting that s is an upper bound of ℕ. □

The proof is short because completeness did the work. It also shows the pattern of many completeness arguments: assume the bad thing, take a supremum that the bad thing makes available, and use the characterisation to push past it.

Three consequences are used constantly, and each is one line.

Corollary. (i) For every ε>0 there is n∈ℕ with 1n<ε. (ii) For every x>0 and every real y there is n∈ℕ with nx>y. (iii) For every real x there are integers m and m′ with m<x<m′.

Proof. (i) Take n>1ε and multiply both sides by the positive number εn, which gives ε>1n. (ii) Take n>yx and multiply by the positive number x. (iii) Take m′∈ℕ with m′>x, and k∈ℕ with k>−x; then m=−k satisfies m<x. □

Part (i) is the form earlier lessons used: for ε=0.03, the condition n>10.03=33.3… is first met at n=34, and 134≈0.0294. Part (ii) is the form Archimedes and Euclid had in mind: however small a length x and however large a length y, enough copies of x laid end to end exceed y. The fourth definition of Book V of Euclid's Elements says that two magnitudes have a ratio when each, multiplied, can exceed the other, and Archimedes used the property as an explicit assumption in the third century BC.

Part (iii) leads to the integer part of a real number.

Proposition (the floor). For every real number x there is exactly one integer m with m≤x<m+1. It is written ⌊x⌋.

Proof. Existence. By part (iii) of the corollary there are integers k and m′ with k<x<m′. Let S be the set of integers greater than x. It contains m′, so it is nonempty, and every element exceeds k. Subtracting k from each element of S gives a nonempty set of natural numbers, which by the well-ordering principle has a least element; adding k back, S has a least element j. Then j>x, and j−1∉S, so j−1≤x. Put m=j−1: then m≤x<m+1.

Uniqueness. If m≤x<m+1 and m′≤x<m′+1 for integers m and m′, then m<m′+1 and m′<m+1, so −1<m−m′<1. The only integer strictly between −1 and 1 is 0, so m=m′. □

So ⌊3.7⌋=3, ⌊5⌋=5 and ⌊−2.5⌋=−3, not −2, since −3≤−2.5<−2. The floor is the real-number version of the quotient in the division algorithm of the lesson on direct proof, whose deeper explanation noted that dividing reals with remainder needs "the fact that the integers are not bounded above inside ℝ". This is that fact at work.

Example. Prove that inf{1n:n∈ℕ}=0, and that the infimum is not a minimum.

Every 1n is positive (the reciprocal of a positive element is positive), so 0 is a lower bound. Let ε>0. By part (i) of the corollary some n∈ℕ has 1n<ε=0+ε. By the characterisation of the infimum, inf{1n:n∈ℕ}=0. It is not a minimum because 0 is not in the set: 1n=0 would give 1=n⋅0=0.

This is the whole content of the statement 1n→0, which the next lesson turns into its first proved limit. Without the Archimedean property, the set {1n} could have a positive lower bound.

Now you. Prove that for every x>0 there is n∈ℕ with 12n<x, and deduce that inf{12n:n∈ℕ}=0.

Answer

First, 2n>n for every n∈ℕ, by induction: 21=2>1, and if 2n>n then 2n+1=2⋅2n>2n≥n+1. Now let x>0. By the Archimedean property there is n∈ℕ with n>1x, so 2n>n>1x, and taking reciprocals of positive numbers reverses the inequality: 12n<x.

Every 12n is positive, so 0 is a lower bound of the set. For ε>0, the first part with x=ε gives an element 12n<0+ε. By the characterisation, the infimum is 0. Repeated halving shrinks below every positive number, which is what makes bisection work.

Are there ordered fields in which ℕ is bounded?

Yes, and the simplest is built from polynomials. Let F be the set of quotients p(t)q(t) of polynomials in a letter t with real coefficients, q not the zero polynomial, added and multiplied as algebraic fractions. It is a field, for the same reasons that ℚ is a field built from ℤ. Order it by declaring a nonzero element p(t)q(t) positive when the leading coefficients of p and q (the coefficients of their highest powers of t) have the same sign, and write f<g when g−f is positive. One can check that this is a total order satisfying (O1) and (O2). Informally, f is positive when f(t) is positive for all sufficiently large real t.

In this field, t−n has leading coefficient 1 for every natural number n, so t−n is positive and t>n. The element t is an upper bound for ℕ, and F is an ordered field in which the Archimedean property fails. Its reciprocal 1t is positive and smaller than every 1n, since 1n−1t=t−nnt has leading coefficients 1 and n. Such an element is an infinitesimal: positive, yet smaller than every positive rational. By the theorem above, F cannot be complete, and indeed ℕ is bounded in F with no least upper bound (if s were one, the proof of the theorem would find n∈ℕ with n>s−1, and then n+1>s).

This matters for two reasons. It shows that the Archimedean property genuinely depends on completeness, so the proof above is not proving something that was already assumed. And it answers the old worry about infinitesimals. Leibniz built calculus on quantities infinitely small yet not zero, and his critics, most sharply George Berkeley in The Analyst (1734), asked how such things could exist. The ε definitions of the next lesson were the nineteenth century's answer: in ℝ there are no infinitesimals, and none are needed. In the 1960s Abraham Robinson showed that Leibniz's approach can also be made rigorous, by working in a larger ordered field with infinitesimals, which he called non-standard analysis. Fields like F are the simplest glimpse of such worlds.

Computing suprema and infima

The working method has two stages. First, guess: list some elements, and see where they pile up. Then verify, using the characterisations: show the guess is a bound, and show that nothing closer is. If the guess belongs to the set, the second stage is automatic, because a bound that belongs to the set is a maximum or minimum, and any upper bound must be at least as large as an element of the set.

Example. Find the supremum and infimum of A={(−1)n+1n:n∈ℕ}, and decide whether each is a maximum or minimum.

The first elements, at n=1,2,3,4,5,6, are 0, 32, −23, 54, −45, 76. The even terms come down towards 1 from 32; the odd terms come down towards −1. The guess is supA=32 and infA=−1.

The supremum. If n is even, then n≥2, so 1n≤12 and the element is 1+1n≤32. If n is odd, the element is −1+1n≤−1+1=0<32. So 32 is an upper bound. It is the element at n=2, so any upper bound is at least 32. Hence supA=maxA=32.

The infimum. Every element exceeds −1: for even n it is 1+1n>1, and for odd n it is −1+1n>−1. So −1 is a lower bound. Let ε>0. By the Archimedean property there is n∈ℕ with n>1ε; if n is even, replace it by n+1, which is odd and still exceeds 1ε. For this odd n, the element −1+1n lies in A and is less than −1+ε. By the characterisation of the infimum, infA=−1. It is not a minimum, since every element is strictly greater than −1.

Notice where the Archimedean property entered: only in the part that was not attained. That is typical. Suprema and infima that belong to the set need only algebra; those that do not need a way to get arbitrarily close, and in ℝ that way almost always runs through 1n→0.

Now you. Find the supremum and infimum of B={1n−1m:n,m∈ℕ}, and decide whether each is attained.

Answer

Guess supB=1 and infB=−1.

The supremum. For all n,m∈ℕ, 1n−1m<1n≤1, since 1m>0 and n≥1. So 1 is an upper bound, and it is never attained, since every element is strictly less than 1. Let ε>0, and choose m∈ℕ with 1m<ε, by the Archimedean property. With n=1, the element 1−1m lies in B and exceeds 1−ε. By the characterisation, supB=1.

The infimum. Exchanging n and m turns the element 1n−1m into its negative, so −B=B. By the proposition on infima, infB=−sup(−B)=−supB=−1, and it is not attained, because −1=1n−1m would mean 1m−1n=1, which the first part ruled out.

Two general facts save work in such computations, and both follow from the definitions in a line or two. If A⊆B, both nonempty and B bounded above, then supA≤supB, since supB is an upper bound of B and hence of A. And if A and B are nonempty and every element of A is at most every element of B, then supA≤infB, since each b∈B is an upper bound of A, so supA≤b, and then supA is a lower bound of B. The sheet at the end proves more, such as sup(A+B)=supA+supB.

Square roots exist

The lesson on quantifiers said that "some x has x2=2" is false over the rationals and true over the reals. The rational half was the irrationality of 2. The real half needs completeness, and the proof is the argument of the first section run again, with a supremum now available to run it on. It costs nothing extra to do every positive number at once.

Theorem. For every real a>0 there is exactly one real s>0 with s2=a.

Proof. Let S={x∈ℝ:x≥0andx2<a}. It is nonempty, since 0∈S. It is bounded above by 1+a: if x>1+a, then x>1, so x2=x⋅x>x>1+a>a, and x∉S. By completeness, S has a supremum s, and s≥0 because 0∈S. By trichotomy, s2<a, s2=a or s2>a. We rule out the first and the last.

Suppose s2<a. Let h be the smaller of 12 and a−s22s+1. Then 0<h<1, so h2<h, and h(2s+1)≤a−s2. Hence

(s+h)2=s2+2sh+h2<s2+h(2s+1)≤a

so s+h∈S. But s+h>s, contradicting that s is an upper bound of S.

Suppose s2>a. Then s>0 (as s=0 would give s2=0<a). Let k=s2−a2s>0. Then s−k=s2+a2s>0, and

(s−k)2=s2−2sk+k2>s2−2sk=a

If some x∈S had x≥s−k, then, both being non-negative, x2≥(s−k)2>a, contradicting x∈S. So s−k is an upper bound of S, smaller than s, contradicting that s is the least.

Hence s2=a, and s>0 since a>0. For uniqueness, suppose t>0 and t2=a. Then (s−t)(s+t)=s2−t2=0, and s+t>0, so by part (iv) of the lemma, s−t=0. □

The positive square root of a is written a. For a=2, the proof is the first section's argument with one change. Over ℚ, algebra ruled out both inequalities, irrationality ruled out equality, and no candidate was left. Over ℝ, completeness supplies the candidate, 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 same method gives nth roots: for every a>0 and n∈ℕ there is a unique s>0 with sn=a. Only the algebra for pushing a candidate up or down changes, and the problem sheet does the case n=3. In particular ℝ contains irrational numbers, which the ordered field axioms alone could never have produced.

The rationals and irrationals are dense

For all their gaps, the rationals are everywhere: no interval of the real line, however short, avoids them. A set D⊆ℝ is dense in ℝ when every open interval (a,b) with a<b contains an element of D.

Theorem (density of the rationals). For all real a<b there is a rational q with a<q<b.

Proof. Since b−a>0, the Archimedean property gives n∈ℕ with 1n<b−a, that is, nb−na>1. Let m=⌊na⌋+1. By the definition of the floor, m−1≤na<m, so

na<m≤na+1<nb

Dividing by the positive number n gives a<mn<b, and mn is rational. □

The idea is a ruler. Marks spaced 1n apart, with 1n smaller than the gap b−a, cannot all jump over the interval, and the floor finds the first mark past a. Between 0.3 and 0.31 the gap is 0.01, so the proof takes n=101; then na=30.3, m=31, and 31101≈0.3069 lies between them.

Applying the theorem again to (a,q) and to (q,b), and so on, gives as many rationals in (a,b) as you like, so every interval contains infinitely many. The irrationals, which the previous lesson showed are far more numerous than the rationals, are dense too.

Example. Prove that for all real a<b there is an irrational x with a<x<b.

Let a<b. Then a−2<b−2, so by the density of the rationals there is a rational q with a−2<q<b−2. Put x=q+2; adding 2 throughout gives a<x<b. Suppose x were rational. Then 2=x−q would be a difference of rationals, hence rational, which it is not. So x is irrational.

The proof shifts the whole problem by one known irrational, solves it with a rational, and shifts back. It needed the existence of 2 as a real number, from the previous section, and its irrationality, from the lesson on contradiction. Between 0.3 and 0.31 it finds q between 0.3−1.41421… and 0.31−1.41421…, for instance q=−1.11, and the irrational 2−1.11=0.30421….

Now you. Prove that every real number x is the supremum of the rationals below it: x=sup{q∈ℚ:q<x}.

Answer

Let x be real and Qx={q∈ℚ:q<x}. By the density of the rationals there is a rational between x−1 and x, so Qx is nonempty, and it is bounded above by x by its definition. So its supremum exists, and x is an upper bound. Let ε>0. By density there is a rational q with x−ε<q<x; then q∈Qx and q>x−ε. By the characterisation of the supremum, supQx=x.

This says every real number is pinned down by the rationals below it, which is exactly the idea behind Dedekind's construction: the set Qx is the cut that represents x.

Density settles the last claim of the lesson on order, that T={q∈ℚ:q2<2} has supremum 2 in ℝ. Every q∈T has q<2, since a rational q≥2 would be positive, and squaring preserves order on positive numbers, so it would have q2≥2. And for any b<2, density gives a rational q strictly between the larger of b and 0 and 2, which lies in T and exceeds b. So the set that had no supremum in ℚ has one in ℝ, and it is the number the rationals were missing.

Density is a strange property to hold alongside countability. The rationals are dense, so every interval contains infinitely many, and yet they can be listed, so they are, in the sense of the previous lesson, a vanishingly small part of the line. Both facts are true at once, and neither contradicts the other.

Nested intervals

Completeness has several equivalent forms, and one of them is geometric. Picture a sequence of closed intervals, each inside the one before, shrinking down. In ℝ something is always left.

Theorem (nested intervals). Let [a1,b1]⊇[a2,b2]⊇[a3,b3]⊇⋯ be closed bounded intervals, with an≤bn for every n. Then there is a real number c lying in every one of them. If, in addition, for every ε>0 some n has bn−an<ε, then there is exactly one such c.

Proof. Nesting means a1≤a2≤a3≤⋯ and b1≥b2≥b3≥⋯. First, am≤bn for all m and n. If m≤n, then am≤an≤bn. If m>n, then am≤bm≤bn.

So the set A={am:m∈ℕ} is nonempty and every bn is an upper bound of it. By completeness it has a supremum c. Since c is an upper bound of A, an≤c for every n; since c is the least upper bound and bn is an upper bound, c≤bn for every n. Hence c∈[an,bn] for every n.

For uniqueness, suppose c and d both lie in every interval, and suppose c≠d. Let ε=|c−d|>0, and choose n with bn−an<ε. Both c and d lie in [an,bn], so |c−d|≤bn−an<ε=|c−d|, which is impossible. So c=d. □

Each hypothesis is needed, and the counterexamples are worth knowing.

  • Closed. The open intervals (0,1n) are nested, but their intersection is empty, as the lesson on sets showed: a positive x in all of them would satisfy x<1n for every n, against the Archimedean property.
  • Bounded. The closed intervals [n,∞) are nested with empty intersection, since a real in all of them would be at least every natural number.
  • In ℝ. In ℚ, take an to be 2 truncated after n decimal places and bn=an+10−n: the intervals [1.4,1.5]⊇[1.41,1.42]⊇[1.414,1.415]⊇⋯ have rational endpoints, and in ℝ their only common point is 2. So the rational intervals {q∈ℚ:an≤q≤bn} are nested, nonempty and shrinking, and share no rational at all.

The theorem is the rigorous form of bisection. To locate a number with some property, start with an interval that contains it, halve the interval, keep the half where the property still holds, and repeat. The lengths b1−a12n−1 shrink below any ε, since 2n−1≥n, so the theorem pins down exactly one point. The intermediate value theorem, that a continuous function negative at one end of an interval and positive at the other has a zero between, is proved this way, and the Calculus lesson on continuity uses the same halving to find roots numerically.

Is there a proof that ℝ is uncountable that avoids decimals?

Yes, and it is older than the diagonal argument. Let x1,x2,x3,… be any sequence of real numbers. We find a real number that is not in the list.

Start with I0=[0,1]. Suppose a closed interval In−1=[a,b] with a<b has been chosen. Cut it into three closed thirds, [a,a+L3], [a+L3,a+2L3] and [a+2L3,b], where L=b−a. The first and third thirds do not meet, so the number xn lies in at most two of the three. Let In be a third that does not contain xn (the leftmost such, to make the choice definite). This defines closed intervals I1⊇I2⊇I3⊇⋯, each of positive length, with xn∉In.

By the nested intervals theorem some c lies in every In. If c=xn for some n, then xn=c∈In, contradicting the choice of In. So c differs from every xn, and no sequence lists every real number in [0,1]. Hence [0,1], and with it ℝ, is uncountable.

Cantor's first proof that the reals are uncountable, published in 1874, seventeen years before the diagonal argument, was built on nested intervals in this spirit. The argument shows where uncountability comes from. Run it in ℚ, with a list of all the rationals (which exists, by the previous lesson), and every step works except the last: the nested intervals close in on a point, but the point is irrational, so the rational intervals have nothing in common. Countability of ℚ and uncountability of ℝ are two faces of the same fact, completeness.

Decimal expansions, and 0.999…=1

The lesson on countability treated real numbers as infinite decimals and used, without proof, that every number in (0,1) has a decimal expansion and that 0.4999…=0.5. Both claims need a definition before they can be proved, because an infinite decimal is an infinite sum, and "add infinitely many numbers" has so far been given no meaning. Completeness gives it one.

Definition. For digits d1,d2,d3,… in {0,1,…,9}, the decimal 0.d1d2d3… denotes the real number

sup{tn:n∈ℕ},wheretn=d110+d2102+⋯+dn10n

The finite decimal tn is the truncation after n places. The supremum exists: the set is nonempty, and every tn≤910+⋯+910n=1−110n<1, the finite geometric sum being checked by induction. So every infinite decimal names a real number in [0,1].

Theorem. 0.999…=1.

Proof. Here tn=1−110n. Every tn<1, so 1 is an upper bound. Let ε>0. By the Archimedean property there is n with 1n<ε, and 10n≥n (by induction), so 110n≤1n<ε and tn>1−ε. By the characterisation of the supremum, sup{tn}=1. □

The same computation gives 0.4999…=0.5: the truncations 0.4, 0.49, 0.499, and so on, are tn=12−110n, all below 12 and eventually above 12−ε for every ε>0.

Existence runs the other way: every number is the value of some decimal, and the floor function produces the digits.

Theorem. Every real x with 0≤x<1 is the value of a decimal 0.d1d2d3…, whose digits are given by dn=⌊10nx⌋−10⌊10n−1x⌋.

Proof. Write Nn=⌊10nx⌋ for n≥0, so N0=0 because 0≤x<1. From Nn−1≤10n−1x<Nn−1+1, multiplying by 10,

10Nn−1≤10nx<10Nn−1+10

Since 10Nn−1 is an integer at most 10nx, and Nn is the greatest such integer, Nn≥10Nn−1; and Nn≤10nx<10Nn−1+10 gives Nn≤10Nn−1+9. So dn=Nn−10Nn−1 is one of 0,1,…,9. Dividing dk=Nk−10Nk−1 by 10k and adding from k=1 to n, the sum telescopes:

tn=∑k=1ndk10k=∑k=1n(Nk10k−Nk−110k−1)=Nn10n−N0=Nn10n

By the definition of the floor, Nn≤10nx<Nn+1, so tn≤x<tn+110n. The first inequality makes x an upper bound of the truncations. For ε>0, choose n with 110n<ε, as in the previous proof; then tn>x−110n>x−ε. By the characterisation, x=sup{tn}=0.d1d2d3…. □

For x=37: N1=⌊307⌋=4, N2=⌊3007⌋=42, N3=⌊30007⌋=428, so the digits begin 4,2,8, and 37=0.428…, as long division says. The floor formula never produces a tail of 9s: its truncations satisfy x<tn+110n strictly, which fails for the expansion 0.4999… of 0.5 at every n, since there tn+110n=12 exactly. So the expansion it gives is the one that the diagonal argument chose, the one not ending in 9s.

Is 0.999… not always just short of 1?

The feeling comes from picturing 0.999… as a process: nines being written one after another, the number creeping towards 1 and never arriving. Every truncation is indeed short of 1, by exactly 110n. But the decimal does not name any truncation, or a process. By definition it names one number, the least number that is at least every truncation, and the proof shows that number is 1.

Suppose someone insists that 0.999… is a number y strictly less than 1. Then 1−y is positive, and the Archimedean property gives an n with 110n<1−y, so the truncation tn=1−110n exceeds y. Then y is not even an upper bound of the truncations. The only way for a number to sit strictly between every truncation and 1 is to be less than 1 by an infinitesimal amount, and in ℝ there are no infinitesimals. In a non-Archimedean field such as the one described earlier, the argument breaks down, which is the precise sense in which the intuition "just short of 1" is about a different number system.

Two popular arguments deserve a word. "13=0.333…, and three times that is 0.999…, so 0.999…=1" is correct in its conclusion, but as a proof it assumes that infinite decimals can be multiplied digit by digit, which needs its own justification from the definition. "Let y=0.999…; then 10y=9.999…, and subtracting, 9y=9" assumes that multiplying by 10 shifts digits and that infinite decimals can be subtracted term by term. Both steps are true, and both follow from the supremum definition (the problem sheet proves the first kind of fact), but they are theorems, not rules of notation. The supremum proof above needs only the definition and the Archimedean property.

Two expansions for one number is not a defect peculiar to base ten. In every base b≥2, a number with a terminating expansion also has one ending in an endless run of the digit b−1; in binary, 0.0111…=0.1. It is the price of describing a complete line with a countable string of digits.

Where completeness is needed next

The Archimedean property, the floor, density, square roots, nested intervals and decimal expansions are facts calculus uses without comment, and each came from one axiom. The rest of analysis leans on it too. The next lesson writes convergence of a sequence with ε and N and proves the monotone convergence theorem: in ℝ, every bounded increasing sequence converges, to the supremum of its terms. That is the theorem Dedekind could not prove in 1858, and the decimal truncations of 2, rational, increasing, bounded by 2 and with no rational limit, show that in ℚ it is false.

In any ordered field, three properties are equivalent: the least upper bound property; the monotone convergence theorem; and the nested intervals theorem together with the Archimedean property. So a course may take any of them as its axiom; this one took the least upper bound, because it is the easiest to state and the one the rationals most visibly lack. The problem sheet proves one of the equivalences.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution. Throughout, "the characterisation" means the ε form of the supremum or infimum proved in the lesson.

Warm-up

1. Find the supremum and infimum of each set, and say whether each is a maximum or minimum: (a) [−2,3); (b) {x∈ℝ:x2≤5}; (c) {nn+1:n∈ℕ}.

Solution

(a) Every x in the set satisfies −2≤x, and −2 is in the set, so inf=min=−2. Every x satisfies x<3, so 3 is an upper bound. Let ε>0, and let x be the larger of 0 and 3−ε2. Then 0≤x<3, so x is in the set, and x≥3−ε2>3−ε. By the characterisation, sup=3. It is not a maximum, since 3 is not in the set.

(b) For x≥0, squaring preserves order on non-negative numbers, so x2≤5 exactly when x≤5. For x<0, x2=(−x)2, so x2≤5 exactly when −x≤5, that is, x≥−5. So the set is [−5,5], with sup=max=5 and inf=min=−5. (Both exist as real numbers by the theorem on square roots.)

(c) Write nn+1=1−1n+1. For n≥1, 1n+1≤12, so every element is at least 12, the element at n=1. So inf=min=12. Every element is less than 1, so 1 is an upper bound, and it is not attained. Let ε>0 and choose n∈ℕ with 1n<ε. Then 1n+1<1n<ε, so the element 1−1n+1 exceeds 1−ε. By the characterisation, sup=1, not a maximum.

2. Using the ordered field axioms and the lemma in the lesson, prove that for all x and y in an ordered field: (a) if x<y then x+z<y+z for every z; (b) if x<y then −y<−x; (c) if x<y then x<x+y2<y.

Solution

(a) Let x<y and let z be any element. By (O1), x+z≤y+z. If x+z=y+z, adding −z to both sides gives x=y, which is false. So x+z<y+z.

(b) By (a), adding −x−y to both sides of x<y gives −y<−x.

(c) By (a), adding x to both sides of x<y gives 2x<x+y, and adding y gives x+y<2y, where 2=1+1. Now 2>0, since 1>0 (the Example) and 1+1>0+1=1>0 by (a). So 12>0 by the Now you after the Example. Multiplying 2x<x+y<2y by the positive element 12 keeps both inequalities, by part (vi) of the lemma, and gives x<x+y2<y.

Part (c) shows that between two elements of an ordered field there is always a third, so no ordered field has "next" elements. Density of ℚ in ℝ says more: the element in between can be chosen rational.

3. Let A be a nonempty bounded set of real numbers. Prove that infA≤supA, with equality if and only if A has exactly one element.

Solution

Since A is nonempty, choose a∈A. Then infA≤a, because the infimum is a lower bound, and a≤supA, because the supremum is an upper bound. So infA≤supA.

If A={a}, then a is both the maximum and the minimum, so infA=a=supA. Conversely, suppose infA=supA=c. Every a∈A satisfies c≤a≤c, so a=c by antisymmetry. So every element of A equals c, and since A is nonempty, A={c}.

4. (a) Find ⌊−3.5⌋, ⌊−3⌋ and ⌊227⌋. (b) Use the formula dn=⌊10nx⌋−10⌊10n−1x⌋ to find the first four decimal digits of 57.

Solution

(a) ⌊−3.5⌋=−4, since −4≤−3.5<−3. ⌊−3⌋=−3, since −3≤−3<−2. ⌊227⌋=3, since 21≤22<28 gives 3≤227<4.

(b) Write Nn=⌊10n⋅57⌋. Since 7×7=49≤50<56, N1=7. Since 7×71=497≤500<504, N2=71. Since 7×714=4998≤5000<5005, N3=714. Since 7×7142=49994≤50000<50001, N4=7142. With N0=0, the digits are d1=7, d2=71−70=1, d3=714−710=4, d4=7142−7140=2. So 57=0.7142…

Core

5. Let A and B be nonempty sets of reals, both bounded above, and let A+B={a+b:a∈A,b∈B}. Prove that sup(A+B)=supA+supB.

Hint

Use the characterisation, and split the tolerance: find a within ε2 of supA and b within ε2 of supB.

Solution

Let s=supA and t=supB. The set A+B is nonempty, since A and B are.

Upper bound. Every element of A+B is a+b with a∈A and b∈B. Then a≤s and b≤t, and adding these inequalities gives a+b≤s+t. So s+t is an upper bound of A+B.

Nothing smaller. Let ε>0. By the characterisation applied to A with tolerance ε2, some a∈A has a>s−ε2, and likewise some b∈B has b>t−ε2. Then a+b∈A+B and a+b>s+t−ε.

By the characterisation, sup(A+B)=s+t. Taking B={c} gives the special case sup(A+c)=supA+c, where A+c={a+c:a∈A}.

6. Let A be a nonempty bounded set of reals, c a real number, and cA={ca:a∈A}. Prove that if c>0 then sup(cA)=csupA, and that if c<0 then sup(cA)=cinfA.

Hint

Multiplying by a positive number keeps inequalities and multiplying by a negative one reverses them. For c<0, a lower bound of A turns into an upper bound of cA.

Solution

Case c>0. Let s=supA. For every a∈A, a≤s, so ca≤cs; thus cs is an upper bound of cA, which is nonempty. Let ε>0. Then εc>0, so some a∈A has a>s−εc, and multiplying by c>0 gives ca>cs−ε. By the characterisation, sup(cA)=cs.

Case c<0. Let t=infA, which exists because A is nonempty and bounded below. For every a∈A, a≥t, and multiplying by the negative number c reverses this: ca≤ct. So ct is an upper bound of cA. Let ε>0. Then −c>0, so ε−c>0, and by the characterisation of the infimum some a∈A has a<t+ε−c. Multiplying by c<0 reverses the inequality: ca>ct+c⋅ε−c=ct−ε. By the characterisation, sup(cA)=ct.

With c=−1 the second case says sup(−A)=−infA, the proposition on infima read backwards.

7. Find the flaw in this proof, show that the claim is false, and state and prove the correct version.

Claim. Let A and B be nonempty sets of reals such that a<b for every a∈A and every b∈B. Then supA<infB.

Proof. Both exist, since A is bounded above by any element of B and B is bounded below by any element of A. Since a<b for all a and b, taking the supremum over a∈A and then the infimum over b∈B gives supA<infB.

Hint

The first sentence is fine. Look at A=(0,1) and B=(1,2).

Solution

The flaw is in the last step: strict inequalities are not preserved by taking suprema or infima. From "a<b for every a∈A" it follows only that b is an upper bound of A, so supA≤b, with ≤ and not <. The set [0,1) has every element below 1 and supremum equal to 1.

The claim is false. Take A=(0,1) and B=(1,2). Every element of A is less than 1, and every element of B is greater than 1, so a<b for all a∈A and b∈B. But supA=1 and infB=1 (the first as in the lesson on order; the second by the mirror argument: 1 is a lower bound, and for ε>0 the smaller of 1+ε2 and 32 lies in B and is less than 1+ε). So supA=infB, and supA<infB fails.

Correct claim. If A and B are nonempty and a≤b for every a∈A and b∈B (in particular if a<b), then supA≤infB.

Proof. Let b∈B. Every a∈A satisfies a≤b, so b is an upper bound of A, and A has a supremum with supA≤b. This holds for every b∈B, so supA is a lower bound of B, and B has an infimum with supA≤infB, because the infimum is the greatest lower bound. □

8. Prove or disprove each claim. (a) If x is rational and y is irrational, then x+y is irrational. (b) If x and y are irrational, then x+y is irrational. (c) If x is a nonzero rational and y is irrational, then xy is irrational. (d) If x and y are irrational, then xy is irrational. (e) If x2 is irrational, then x is irrational.

Hint

Two are false, with counterexamples built from 2. The true ones go by contradiction or contrapositive, using that ℚ is closed under the four operations.

Solution

(a) True; this and (c) were proved in the lesson on contradiction. Suppose x is rational, y irrational, and x+y=r is rational. Then y=r−x is a difference of rationals, hence rational, a contradiction.

(b) False. 2 is irrational, and so is −2 by (c) with x=−1. Their sum is 0, which is rational.

(c) True. Suppose x≠0 is rational, y irrational, and xy=r is rational. Then y=rx is a quotient of rationals with nonzero denominator, hence rational, a contradiction.

(d) False. 2⋅2=2, which is rational.

(e) True, by the contrapositive: if x is rational, x=pq, then x2=p2q2 is rational. The converse fails: 2 is irrational and its square is rational.

9. Prove that there is exactly one positive real number s with s3=2.

Hint

Follow the proof for square roots with S={x≥0:x3<2}. To push up: for 0<h<1, (s+h)3<s3+h(3s2+3s+1). To push down: try k=s3−23s2.

Solution

First a fact used twice: for 0≤x<y, x3<y3. Indeed y3−x3=(y−x)(y2+xy+x2), with y−x>0 and y2+xy+x2≥y2>0.

Let S={x∈ℝ:x≥0andx3<2}. It contains 1, so it is nonempty. It is bounded above by 2: if x≥2 then x3≥8>2 by the fact. By completeness it has a supremum s, and s≥1.

Suppose s3<2. Let h be the smaller of 12 and 2−s33s2+3s+1. Then 0<h<1, so h2<h and h3<h, and since s>0,

(s+h)3=s3+3s2h+3sh2+h3<s3+3s2h+3sh+h=s3+h(3s2+3s+1)≤2

So s+h∈S and s+h>s, contradicting that s is an upper bound.

Suppose s3>2. Let k=s3−23s2>0. Then s−k=2s3+23s2>0, so 0<k<s. Now

(s−k)3=s3−3s2k+3sk2−k3=s3−3s2k+k2(3s−k)>s3−3s2k=2

because k2>0 and 3s−k>2s>0. If some x∈S had x≥s−k, the fact would give x3≥(s−k)3>2, contradicting x∈S. So s−k is an upper bound smaller than s, contradicting that s is the least.

By trichotomy s3=2, and s>0. For uniqueness, if t>0 and t≠s, then either t<s or s<t, and the fact gives t3<2 or t3>2. So s is the only positive cube root of 2.

10. (a) Prove that if a and b are real numbers with a≤b+ε for every ε>0, then a≤b. (b) Prove that if x≥0 and x≤1n for every n∈ℕ, then x=0. (c) Deduce that if |x−y|<1n for every n∈ℕ, then x=y.

Hint

For (a), argue by contradiction and choose ε to fit. For (b), which property of ℝ is being used?

Solution

(a) Suppose a>b. Take ε=a−b2>0. By hypothesis a≤b+a−b2=a+b2, which gives 2a≤a+b, so a≤b, a contradiction. Hence a≤b.

(b) Let x≥0 with x≤1n for all n. Suppose x>0. By the Archimedean property there is n∈ℕ with 1n<x, contradicting the hypothesis. So x=0. This is exactly where the Archimedean property is used; in an ordered field with infinitesimals, a positive infinitesimal would satisfy the hypothesis.

(c) Let x and y satisfy the hypothesis. Then |x−y|≥0 and |x−y|<1n for every n, so by (b), |x−y|=0, and x=y.

Part (a) is the standard way analysts prove an inequality: show that it holds up to an arbitrary positive error. Part (c) is the same idea for equality, and the next lesson's proof that a limit is unique runs on it.

Challenge

11. Let F be an ordered field with the Archimedean property (for every x∈F some n∈ℕ has n>x), in which the nested intervals theorem holds. Prove that F is complete: every nonempty subset of F that is bounded above has a least upper bound.

Hint

Bisect. Start with an element a1 that is not an upper bound and an element b1 that is. At each step look at the midpoint, and keep the half whose left end is not an upper bound and whose right end is. The common point of the intervals is the candidate.

Solution

Let A⊆F be nonempty and bounded above. Choose a∈A and put a1=a−1, which is not an upper bound of A since a>a1, and let b1 be any upper bound. Then a1<b1.

Given an<bn with an not an upper bound and bn an upper bound, let m=an+bn2, so an<m<bn (Problem 2). If m is an upper bound of A, put an+1=an and bn+1=m; otherwise put an+1=m and bn+1=bn. Either way [an+1,bn+1]⊆[an,bn], an+1 is not an upper bound, bn+1 is one, and bn+1−an+1=bn−an2. By induction, bn−an=L2n−1 with L=b1−a1>0.

The lengths become small: given ε>0, the Archimedean property gives n with n>Lε, and 2n−1≥n (by induction), so bn−an=L2n−1≤Ln<ε. By the nested intervals theorem, there is c with an≤c≤bn for every n.

c is an upper bound of A. Suppose some x∈A has x>c. Choose n with bn−an<x−c. Then bn<an+(x−c)≤c+(x−c)=x, so bn is not an upper bound of A, a contradiction.

No upper bound is smaller than c. Suppose v is an upper bound with v<c. Choose n with bn−an<c−v. Then an>bn−(c−v)≥c−(c−v)=v. Any element above an upper bound is an upper bound, so an is an upper bound of A, a contradiction.

Hence c=supA, and F is complete. The Archimedean hypothesis cannot be dropped: there are non-Archimedean ordered fields in which every nested sequence of closed intervals has a common point, and they are not complete, since by the lesson every complete ordered field is Archimedean. (The larger fields of Robinson's non-standard analysis are examples.)

12. Prove that the set {m+n2:m,n∈ℤ} is dense in ℝ: every interval (a,b) with a<b contains an element of it.

Hint

First find an element z of the set with 0<z<b−a. For that, look at the fractional parts k2−⌊k2⌋ for k=0,1,…,N, and use the pigeonhole principle on N subintervals of [0,1). Then use the multiples of z as a ruler, as in the density of the rationals.

Solution

Write G={m+n2:m,n∈ℤ}. It is closed under addition, subtraction and multiplication by integers.

Step 1: small positive elements. Let N∈ℕ. For k=0,1,…,N, let fk=k2−⌊k2⌋, the fractional part, so 0≤fk<1 and fk∈G. Split [0,1) into the N intervals [jN,j+1N) for j=0,…,N−1. There are N+1 numbers fk and N intervals, so by the pigeonhole principle two of them, fk and fl with k<l, lie in the same interval, and |fl−fk|<1N. Now fl−fk=(l−k)2−(⌊l2⌋−⌊k2⌋) is in G, and it is not 0: otherwise 2=⌊l2⌋−⌊k2⌋l−k would be rational. So z=|fl−fk| (which is fl−fk or its negative, both in G) is an element of G with 0<z<1N.

Step 2: the ruler. Let a<b. Choose N with 1N<b−a, and z∈G with 0<z<1N by Step 1. Let j=⌊az⌋+1, an integer. Then j−1≤az<j, and multiplying by z>0 gives jz−z≤a<jz. Hence a<jz≤a+z<a+(b−a)=b. And jz∈G, being an integer multiple of an element of G. So (a,b) contains the element jz of G.

The same argument works with any irrational in place of 2. For a rational pq it fails, since then every m+npq is a multiple of 1q and the set has gaps of length 1q. Step 1 is a form of Dirichlet's approximation theorem: for every irrational α and every N there are integers l>0 and m with |lα−m|<1N and l≤N.

13. Call a decimal 0.d1d2d3… eventually periodic if there are k≥0 and p≥1 with dn+p=dn for every n>k. Prove that a real number x∈[0,1) is rational if and only if the decimal expansion given by the floor formula is eventually periodic.

Hint

(⇐) First prove that 10m⋅0.d1d2…=D+0.dm+1dm+2… where D is the integer with digits d1…dm, using Problems 5 and 6. Then compare 10k+px and 10kx. (⇒) For x=ab, the remainders rn=10na−bNn, with Nn=⌊10nx⌋, lie in {0,…,b−1}, and each determines the next digit and the next remainder.

Solution

(⇐) A shifting lemma. Let y=0.d1d2d3… with truncations tn, let m≥0, let D=∑j=1mdj10m−j (an integer), and let y′=0.dm+1dm+2… with truncations tn′. We claim 10my=D+y′. The truncations increase, t1≤t2≤⋯, so every tn with n≤m is at most tm+1, and y=sup{tn:n>m}. For n>m, multiplying out gives 10mtn=D+tn−m′. By Problem 6 with c=10m, and Problem 5 with B={D},

10my=sup{10mtn:n>m}=sup{D+tj′:j∈ℕ}=D+sup{tj′}=D+y′

Periodic implies rational. Suppose x=0.d1d2… with dn+p=dn for all n>k. The tails 0.dk+1dk+2… and 0.dk+p+1dk+p+2… have the same digits in every place, so they are the same number y′. By the lemma, 10kx=D1+y′ and 10k+px=D2+y′ for integers D1 and D2. Subtracting, (10k+p−10k)x=D2−D1, and 10k+p−10k>0, so x=D2−D110k(10p−1) is rational.

(⇒) Let x=ab with integers 0≤a<b. Let Nn=⌊10nx⌋ and rn=10na−bNn, an integer. From Nn≤10nab<Nn+1, multiplying by b>0 gives 0≤rn<b. The digits are dn=Nn−10Nn−1, and

10rn−1=10na−10bNn−1=b(Nn−10Nn−1)+(10na−bNn)=bdn+rn

with 0≤rn<b. By the uniqueness in the division algorithm, dn and rn are the quotient and remainder of 10rn−1 on division by b, so both are determined by rn−1 alone.

The b+1 remainders r0,r1,…,rb take at most b values, so by the pigeonhole principle rk=rk+p for some k≥0 and p≥1. Then dk+1=dk+p+1 and rk+1=rk+p+1, and by induction dn=dn+p and rn=rn+p for every n>k. So the expansion is eventually periodic.

For 37, the remainders are r0=3, then 30=7×4+2, 20=7×2+6, 60=7×8+4, 40=7×5+5, 50=7×7+1, 10=7×1+3, back to 3. So 37=0.428571428571…, with period 6. The proof also shows the period is at most b, and in fact at most b−1 when no remainder is 0.

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 the general theorems that let limits be computed without returning to the definition every time, and reaches several theorems that are true in ℝ and false in ℚ, which is exactly what completeness buys. It ends by carrying the same ideas from sequences to functions, with the ε and δ definitions of limit and continuity that calculus is built on. Along the way it separates two activities that textbooks tend to blur: finding a proof and writing one.

The tools come from every earlier lesson: quantifiers for the definition, negation for divergence, the triangle inequality and its reverse form from the lesson on direct proof, contradiction for uniqueness, induction for recursive sequences, and the supremum for everything that needs completeness.

The definition, read closely

A sequence of real numbers is a function a:ℕ→ℝ, written a1,a2,a3,… or (an), with ℕ={1,2,3,…} as throughout the course. The sequence converges to the real number L when

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

and then we write an→L, or limn→∞an=L, and call L a limit of the sequence. A sequence that converges to some real number is convergent; one that converges to none is divergent.

The lesson on quantifiers read the definition 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.

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, adding or deleting finitely many terms never changes whether a sequence converges, or to what.

There is a geometric reading too. The inequality |an−L|<ε says L−ε<an<L+ε: the term lies in the open interval of radius ε about L. So an→L says that every open interval around L, however narrow, contains all the terms from some point on, and only finitely many terms lie outside it. A phrase for "for all n from some point on" is eventually: an→L when, for every ε>0, eventually |an−L|<ε.

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 lesson on the real numbers derived from completeness, and which fails in ordered fields that contain infinitesimals: positive elements smaller than every 1n. In such a field the sceptic names an infinitesimal as ε and wins. The most basic limit in analysis is already a fact about the reals, not about algebra.

Why not simply define convergence as "the terms get closer and closer to L"?

Because that phrase is true of limits that are wrong. The terms of 1n get closer and closer to −1: each term is nearer to −1 than the one before, since 1n+1 decreases. They also get closer and closer to −5 and to −1000. "Closer and closer" says the distance decreases, not that it becomes small, and a decreasing distance can level off at any positive value.

A second attempt, "the terms get arbitrarily close to L", fails the other way. The sequence 0,1,0,1,0,1,… has terms arbitrarily close to 0 (in fact equal to it) infinitely often, and it should not converge to 0. What is missing is the word "eventually": every tolerance must be met not by some terms but by all terms from some point on. Each of the three quantifiers in the definition blocks a specific wrong answer, and removing any one of them lets one through.

The definition took a long time to reach this form. Newton and Leibniz worked with limits and infinitesimals without a definition that could settle disputes, and the criticism they drew was fair. Bernard Bolzano in 1817 and Augustin-Louis Cauchy in his Cours d'analyse of 1821 put limits at the centre and described them in terms of quantities that become and remain smaller than any given quantity, which is the idea of the modern definition in words. Karl Weierstrass, lecturing in Berlin from the late 1850s onwards, gave it the fully symbolic form with ε and its companions, in which "becomes and remains" is replaced by an explicit order of quantifiers. That form is the one used today, because it can be checked mechanically, which is what a definition is for.

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. This is the pattern the lesson on direct proof called working backwards and writing forwards.

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.

The step that made the scratch work easy was replacing 5n+2 by the larger, simpler 5n. That is the central skill: to show a quantity is small, bound it above by something simpler that is visibly small. A fraction gets larger when its numerator is made larger or its denominator smaller (keeping it positive), so the usual moves are to drop negative terms from the numerator and positive terms from the denominator, or to replace a denominator by a fixed fraction of its leading term. For n2+12n3−n, for instance, n2+1≤2n2 and 2n3−n≥n3 for n≥1, so the expression is at most 2n2n3=2n.

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. □

A proof is written for a reader who does not trust its writer, and a few habits make it checkable. 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. Justify each step by a definition or an earlier result, by name. Then 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.

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. □

Problem 11 of the lesson on quantifiers proved this by splitting on the sign of L; the triangle inequality avoids the cases. The proof never says which of the two terms misses, only that one does, and an existential claim needs no more. The tolerance ε=1 is half the distance between the two values the sequence keeps returning to, and that is what makes it work: no open interval of radius 1 contains both 1 and −1. A tolerance of 2 would fail, since for L=0 every term lies within 2 of L.

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. □

The sequence n diverges in a particular way: it grows beyond every bound. A sequence tends to infinity, written an→∞, when

∀M∈ℝ∃N∈ℕ∀n≥N(an>M)

The shape is the same as convergence, with "within ε of L" replaced by "above M", and the proofs have the same shape too. For an=n: let M be real, choose N∈ℕ with N>M2, and let n≥N; then n≥N>M2=|M|≥M, using that square roots preserve order on non-negative numbers. Tending to infinity is a kind of divergence, not a kind of convergence: ∞ is not a real number, and "liman=∞" is a shorthand for the displayed statement, not a limit in the sense of the definition. And not every divergent sequence tends to infinity, as (−1)n shows.

Uniqueness, and bounded sequences

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 picture is two intervals of radius |L−M|2 around L and around M. They do not overlap, and a convergent sequence would have to be eventually inside both. Two features of the proof recur throughout the lesson. Each hypothesis "an→L" was used with a tolerance chosen by the prover, since a convergence hypothesis may be applied to any ε>0 we like. And the two guarantees, which start at different positions N1 and N2, were made to hold together by going past both.

A sequence is bounded when some real B has |an|≤B for every n; equivalently, the set of its terms is bounded above and below.

Theorem. Every convergent sequence is bounded.

Proof. Let an→L. The definition with ε=1 gives N with |an−L|<1 for all n≥N, and then, by the triangle inequality, |an|≤|an−L|+|L|<|L|+1 for n≥N. Only the finitely many terms before position N are left. Let B be the largest of the numbers |a1|,|a2|,…,|aN−1| and |L|+1. Then |an|≤B for every n. □

The finitely many early terms can be anything, and they are handled by taking a maximum, which a finite set always has. The contrapositive is a quick test for divergence: an unbounded sequence, such as n or (−2)n, cannot converge. The converse of the theorem fails, as the bounded divergent sequence (−1)n shows. Much of the rest of the lesson is about what can be added to "bounded" to rescue it.

The algebra of limits

Proving every limit from the definition would be exhausting. The theorems of this section let limits be computed from limits already known, and each is proved once, from the definition. The basic tool is the idea of spending the tolerance in parts.

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. □

The total error is a sum of two errors, so each was given half the budget. Nothing is special about halves. A proof that ends with |(an+bn)−(L+M)|<2ε is also acceptable, once it is observed that 2ε is an arbitrary positive number as ε is; the ε2 version simply arranges in advance for the final line to read ε.

Now you. Prove that if an→L, then |an|→|L|. Is the converse true?

Answer

Let ε>0. There is N with |an−L|<ε for all n≥N. Let n≥N. By the reverse triangle inequality, ||an|−|L||≤|an−L|<ε. Since ε was arbitrary, |an|→|L|. □

The converse is false: |(−1)n|=1→1=|1|, but (−1)n does not converge to 1, or to anything. It does hold when L=0, since |an−0|=||an|−0|, so an→0 exactly when |an|→0.

Products need one more idea, because the error in anbn involves the sizes of the terms, not just their distances from the limits.

Theorem (the algebra of limits). Suppose an→L and bn→M, and let c be a real number. Then

(i) can→cL;

(ii) anbn→LM;

(iii) if M≠0, then bn≠0 for all n from some point on, and 1bn→1M;

(iv) if M≠0, then anbn→LM.

Proof. (i) If c=0 every term is 0 and the claim is clear. Otherwise let ε>0, and choose N with |an−L|<ε|c| for n≥N. Then |can−cL|=|c||an−L|<ε for n≥N.

(ii) The trick is to add and subtract a mixed term:

anbn−LM=an(bn−M)+M(an−L)

Convergent sequences are bounded, so there is B>0 with |an|≤B for every n. Let ε>0. Choose N1 with |bn−M|<ε2B for n≥N1, and N2 with |an−L|<ε2(|M|+1) for n≥N2. For n at least the larger of N1 and N2,

|anbn−LM|≤|an||bn−M|+|M||an−L|<B⋅ε2B+|M|⋅ε2(|M|+1)<ε2+ε2=ε

(The +1 in the second tolerance keeps the denominator positive when M=0.)

(iii) Since |bn|→|M| and |M|>0, the definition with tolerance |M|2 gives N1 with |bn|>|M|−|M|2=|M|2 for n≥N1; in particular bn≠0 there. Let ε>0, and choose N2 with |bn−M|<|M|2ε2 for n≥N2. For n at least the larger of N1 and N2,

|1bn−1M|=|M−bn||bn||M|<|M|2ε/2(|M|/2)|M|=ε

(iv) Write anbn=an⋅1bn and apply (ii) and (iii). □

Part (iii) contains the point everyone forgets: bn→M≠0 does not say bn≠0 for every n, and the sequence 1bn may not exist at the start. It exists eventually, and since early terms do not affect limits, that is enough. The lower bound |bn|>|M|2, keeping the terms away from 0, is what controls the denominator.

With these rules most limits reduce to 1n→0 and constants. Take an=2n2−n+35n2+4. Dividing top and bottom by n2 gives

an=2−1n+3⋅1n⋅1n5+4⋅1n⋅1n

The numerator tends to 2−0+3⋅0⋅0=2 by the rules for sums, constant multiples and products, and the denominator to 5≠0, so an→25 by the rule for quotients. Each step cites a theorem, and the theorems were proved from the definition, so this is a proof.

The hypotheses matter. The rules say that if the parts converge, the combination converges to the combination of the limits. They say nothing when the parts diverge: an=n and bn=−n both diverge while an+bn=0 converges, and (−1)n⋅(−1)n=1 converges although neither factor does. Writing "lim(an+bn)=liman+limbn" before knowing that the limits on the right exist is the commonest misuse. And the quotient rule needs M≠0: the quotient of 1n by 1n2 is n, which diverges, though both parts tend to 0.

Limits also respect weak inequalities.

Theorem (limits preserve order). If an→L, bn→M and an≤bn for every n, then L≤M.

Proof. By the algebra of limits, bn−an→M−L. Suppose, for contradiction, that M−L<0, and take ε=L−M>0. For n large enough, |(bn−an)−(M−L)|<L−M, which gives bn−an<(M−L)+(L−M)=0, contradicting an≤bn. □

Strict inequalities are not preserved: 1n>0 for every n, and the limit is 0, not something positive. This is the same pitfall as for suprema in the previous lesson, and for the same reason.

The squeeze theorem

Some sequences are too awkward to handle directly but can be trapped between two simpler ones.

Theorem (the squeeze theorem). Suppose that an≤bn≤cn for every n≥N0, and that an→L and cn→L. Then bn→L.

Proof. Let ε>0. There are N1 with |an−L|<ε for n≥N1, and N2 with |cn−L|<ε for n≥N2. Let N be the largest of N0, N1, N2, and let n≥N. Then

L−ε<an≤bn≤cn<L+ε

so |bn−L|<ε. Since ε was arbitrary, bn→L. □

Both outer sequences must tend to the same limit. Knowing 0≤bn≤1 says nothing about whether bn converges. The commonest use has an=0 or an=−cn: if |bn−L|≤cn and cn→0, then bn→L.

Example. Prove that rn→0 for every real r with |r|<1.

If r=0 every term is 0. Suppose first that 0<r<1. Then 1r>1, so 1r=1+h for some h>0. By Bernoulli's inequality, proved in the lesson on induction, (1+h)n≥1+nh>nh for every n∈ℕ. Taking reciprocals of positive numbers reverses the inequality, so

0<rn=1(1+h)n<1nh=1h⋅1n

The right-hand side tends to 1h⋅0=0 by the rule for constant multiples, and the left-hand side is the constant 0. By the squeeze theorem, rn→0.

For general r with 0<|r|<1, the first case gives |rn|=|r|n→0, and a sequence tends to 0 exactly when its absolute values do. So rn→0.

The proof turned an unknown, rn, into a known, 1n, at the cost of a constant, and that is the typical shape. For r=0.9, h=19, and the bound says 0.9n<9n; at n=100 it gives 0.9100<0.09, while the truth is about 0.0000266. The bound is crude, and crude bounds are enough. For |r|≥1 the sequence rn does not tend to 0: its terms have |rn|≥1.

Now you. Prove that n2n→0. (First show by induction that 2n≥n2 for n≥4.)

Answer

The inequality. For n=4, 24=16=42. Suppose 2n≥n2 for some n≥4. Then 2n+1=2⋅2n≥2n2, and 2n2≥(n+1)2 because 2n2−(n+1)2=n2−2n−1=(n−1)2−2≥9−2>0 for n≥4. So 2n+1≥(n+1)2, and by induction 2n≥n2 for all n≥4.

The limit. For n≥4, 0<n2n≤nn2=1n. Since 0→0 and 1n→0, the squeeze theorem (with N0=4) gives n2n→0. □

Monotone sequences and what completeness buys

A sequence is increasing when an≤an+1 for every n, and decreasing when an≥an+1 for every n; it is monotone if it is one or the other. By induction, an increasing sequence has an≤am whenever n≤m. Boundedness alone did not force convergence, but boundedness with monotonicity does, and this is the first theorem of the lesson that needs completeness.

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

Proof. Let (an) be increasing and bounded. 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 characterisation of the supremum), 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.

If (an) is decreasing and bounded, then (−an) is increasing and bounded, so −an→sup{−an}=−inf{an}, and by the rule for constant multiples an→inf{an}. □

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 by the squeeze theorem they converge to 2. 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. This is the theorem Dedekind could not prove in 1858, and the reason he went looking for a definition of the real numbers.

The theorem proves that a limit exists without saying what it is. For sequences defined by a rule that produces each term from the previous one, the value can often be found afterwards.

Example. Let a1=2 and an+1=12(an+2an). Prove that an→2.

The first terms are 2, 32, 1712, 577408, and 577408≈1.4142157 already agrees with 2≈1.4142136 to five decimal places. The plan is to show the sequence is decreasing and bounded below, conclude that it converges, and then identify the limit.

Positivity. By induction, every an>0: a1=2, and if an>0 then an+1 is half a sum of two positive numbers.

Squares at least 2. For every n, writing an+1=an2+22an,

an+12−2=(an2+2)2−8an24an2=(an2−2)24an2≥0

and a12=4≥2. Since an>0, this gives an≥2 for every n.

Decreasing. an−an+1=an−an2+22an=an2−22an≥0.

Convergence. The sequence is decreasing and bounded below by 2, so by the monotone convergence theorem it converges to some L, and L≥2 because limits preserve order. In particular L≠0.

The limit. The shifted sequence bn=an+1 also converges to L: given ε, the N that works for (an) works for (bn), since n≥N gives n+1≥N. On the other hand, by the algebra of limits, an+1=an2+22an→L2+22L, using 2L≠0. By uniqueness of limits, L=L2+22L, so 2L2=L2+2 and L2=2. As L>0, L=2. □

This is Newton's method applied to x2−2=0, and the rule is older than Newton: it is the Babylonian method for square roots. Notice that every term is rational, so in ℚ the sequence is decreasing, bounded below, and has no limit. Every step of the proof works in ℚ except the one that invoked monotone convergence.

The order of the steps matters. Solving L=f(L) only identifies the limit once convergence is known. With a1=1 and an+1=2an, the same manipulation gives L=2L, so "L=0", but the sequence is 2n−1, which tends to infinity. The equation found the only possible limit; it did not show there is one.

Why does this sequence close in on 2 so quickly?

Because the error squares at every step. Write en=an−2≥0. Then

an+1−2=an2+2−22an2an=(an−2)22an

so en+1=en22an≤en222<en22. Once the error is below 10−k, the next error is below 12⋅10−2k: the number of correct decimal places roughly doubles with each step. From e3=1712−2≈0.0025 it gives e4<0.0000032, and indeed e4≈0.0000021; the next term, 665857470832, is correct to eleven decimal places.

This is called quadratic convergence, and it is why Newton's method is used inside calculators and computer libraries to compute square roots. Compare the decimal truncations, where each step adds one correct digit, or bisection, where each step adds about a third of a digit (one binary digit). All three sequences converge to 2, and the definition of convergence does not distinguish them; speed is a separate question, and numerical analysis is largely about it.

Now you. Let a1=0 and an+1=an2+12. Prove that (an) converges and find its limit.

Answer

Increasing. an+1−an=an2−2an+12=(an−1)22≥0.

Bounded. By induction, 0≤an≤1 for every n: a1=0, and if 0≤an≤1 then 0≤an2≤1, so 12≤an+1≤1.

Limit. By monotone convergence, an→L for some L. The shifted sequence an+1 also tends to L, and by the algebra of limits an+1=an2+12→L2+12. By uniqueness, L=L2+12, so (L−1)2=0 and L=1.

The first terms are 0, 0.5, 0.625, 0.6953, 0.7417, and the convergence is slow: the error shrinks roughly like 2n.

Subsequences and the theorem of Bolzano and Weierstrass

A bounded sequence need not converge, but it cannot avoid converging entirely: part of it always does. To say which part, pick out infinitely many of its terms in order. If n1<n2<n3<⋯ are natural numbers, the sequence an1,an2,an3,… is a subsequence of (an), and its kth term is ank. The even-numbered terms a2,a4,a6,… form a subsequence with nk=2k; so do the terms at prime positions. The terms must be taken in their original order and without repetition, so a2,a1,a3,… and a1,a1,a2,… are not subsequences.

Since n1≥1 and each nk+1≥nk+1, induction gives nk≥k for every k: the kth term of a subsequence sits at position k or later in the original sequence.

Theorem. If an→L, then every subsequence of (an) also converges to L.

Proof. Let (ank) be a subsequence and let ε>0. There is N with |an−L|<ε for all n≥N. Let k≥N. Then nk≥k≥N, so |ank−L|<ε. □

The contrapositive is the most efficient divergence test there is: a sequence with two subsequences converging to different limits, or with one divergent subsequence, diverges. For (−1)n, the even-numbered terms are all 1 and the odd-numbered terms all −1, so the sequence diverges, in one line. The same test disposes of an=(−1)nnn+1: the even terms 2k2k+1 tend to 1 and the odd terms tend to −1.

The positive result needs one lemma, which has nothing to do with limits.

Lemma. Every sequence of real numbers has a monotone subsequence.

Proof. Call a position m a peak if am≥an for every n>m: the term at m is at least as large as every later term.

Suppose there are infinitely many peaks, at positions m1<m2<m3<⋯. Each mk+1 comes after the peak mk, so amk≥amk+1, and (amk) is a decreasing subsequence.

Suppose instead there are finitely many peaks (perhaps none). Choose a position n1 after all of them. Since n1 is not a peak, some later position n2>n1 has an2>an1. Since n2 is also after every peak, it is not a peak, so some n3>n2 has an3>an2. Continuing in this way (formally, by a recursive definition) gives positions n1<n2<n3<⋯ with (ank) increasing. □

Theorem (Bolzano and Weierstrass). Every bounded sequence of real numbers has a convergent subsequence.

Proof. By the lemma, a bounded sequence has a monotone subsequence. The subsequence is bounded, since its terms are among those of the original, so by the monotone convergence theorem it converges. □

Bolzano used the idea in 1817, and Weierstrass made it a cornerstone of his Berlin lectures half a century later, hence the double name. The theorem is again a fact about ℝ and not about ℚ: the bounded sequence of decimal truncations of 2 has no subsequence converging to a rational, since every subsequence converges in ℝ to 2. It is the tool analysis uses whenever something must be found and no formula is available. A continuous function on a closed interval [a,b] attains a greatest value, for instance, because a sequence of points at which the values approach their least upper bound has, by this theorem, a subsequence of points converging to some point of [a,b], and continuity makes the value there the maximum (the same theorem first shows that the values are bounded, so that the least upper bound exists). The Calculus lesson on continuity states this extreme value theorem and builds on it.

Can a sequence be shown to converge without knowing its limit?

Yes, by looking only at how its terms relate to each other. A sequence is a Cauchy sequence if

∀ε>0∃N∈ℕ∀m,n≥N(|am−an|<ε)

that is, its terms eventually all lie within ε of each other. No limit appears in the definition.

Every convergent sequence is Cauchy. If an→L, choose N with |an−L|<ε2 for n≥N; then for m,n≥N, |am−an|≤|am−L|+|L−an|<ε.

In ℝ the converse holds, and its proof uses everything in this section. Let (an) be Cauchy. It is bounded: with ε=1, every term from position N on lies within 1 of aN, and finitely many earlier terms are bounded by their maximum. By Bolzano and Weierstrass, some subsequence ank converges to a limit L. Now let ε>0. Choose N with |am−an|<ε2 for m,n≥N, and then choose k≥N with |ank−L|<ε2 (possible since the subsequence converges and the positions k can be taken as large as we like). For n≥N, as nk≥k≥N,

|an−L|≤|an−ank|+|ank−L|<ε2+ε2=ε

So a sequence of reals converges exactly when it is Cauchy. This is the Cauchy criterion, and it is how most convergence proofs in analysis go, because most limits worth studying, such as the sums of infinite series, have no closed form to guess.

In ℚ the criterion fails: the Newton sequence for 2 is Cauchy (it converges in ℝ, so it is Cauchy in ℝ, and the condition mentions only its rational terms) but has no rational limit. This is the gap Cantor's construction of the reals fills: a real number is a Cauchy sequence of rationals, with two sequences identified when their difference tends to 0. In the language of the previous lesson, "every Cauchy sequence converges" is yet another equivalent form of completeness, for Archimedean ordered fields.

Limits of functions and continuity

The same game can be played with a function instead of a sequence. Where a sequence is watched as n grows, a function is watched as x approaches a point a, and the position N is replaced by a distance δ.

Let f be a real function whose domain D contains every x with 0<|x−a|<r, for some r>0: the function is defined near a, though perhaps not at a itself. Then f(x) tends to L as x tends to a, written limx→af(x)=L or f(x)→L as x→a, when

∀ε>0∃δ>0∀x∈D(0<|x−a|<δ⇒|f(x)−L|<ε)

The sceptic names a tolerance ε on the output. The prover answers with a tolerance δ on the input. The sceptic picks any x in the domain within δ of a other than a itself, and the prover wins if f(x) is within ε of L. As before, δ may depend on ε, a working δ may be replaced by any smaller positive one, and a proof has the shape: let ε>0; choose δ; let x satisfy 0<|x−a|<δ; show |f(x)−L|<ε.

Why does the definition exclude x=a?

Because the limit is meant to describe what f does near a, not at a, and the most important limits in calculus concern functions that are not defined at the point at all. The derivative of x2 at 3 is the limit as x→3 of x2−9x−3, a quotient that is 00, and so undefined, at x=3. For x≠3 it equals x+3, and the limit is 6. A definition that tested x=3 could not even be applied.

Excluding a also makes the value there irrelevant when it does exist. The function equal to x2 for x≠2 and to 100 at x=2 has limx→2f(x)=4, exactly as x2 does; the one wrong value is simply not examined. Whether the limit agrees with the value is a separate question, and it is precisely the question of continuity, which is defined next with the condition 0<|x−a| dropped.

The Calculus lesson on limits takes this definition as its starting point and uses it for exactly these difference quotients, where the whole content of differentiation lives.

The central technique is new. In a sequence proof, the distance |an−L| was bounded by something depending on n alone. Here |f(x)−L| usually factors as |x−a| times something else, and the something else must be kept under control by first insisting that x stay reasonably near a.

Example. Prove that limx→2x2=4.

Scratch work. |x2−4|=|x−2||x+2|. The first factor is what δ controls. The second is not small, but it is bounded if x stays near 2: if |x−2|<1, then 1<x<3, so |x+2|<5. Then |x2−4|<5|x−2|, which is below ε once |x−2|<ε5. Both restrictions are wanted, so take δ to be the smaller of 1 and ε5.

Proof. Let ε>0, and let δ be the smaller of 1 and ε5, so δ>0. Let x satisfy 0<|x−2|<δ. Since |x−2|<1, we have 1<x<3, so 0<x+2<5. Since |x−2|<ε5,

|x2−4|=|x−2||x+2|<ε5⋅5=ε

Since ε was arbitrary, limx→2x2=4. □

The first restriction, δ≤1, is arbitrary: δ≤12 would bound |x+2| by 4.5 and work as well. What matters is that some fixed restriction comes first, so that the bound on the other factor does not depend on δ itself. Choosing "δ=ε|x+2|" is the classic error: δ must be chosen before x, so it cannot depend on x.

Now you. Prove that limx→3(x2−x)=6.

Answer

Scratch work. x2−x−6=(x−3)(x+2). If |x−3|<1, then 2<x<4, so |x+2|<6. So take δ to be the smaller of 1 and ε6.

Proof. Let ε>0, and let δ be the smaller of 1 and ε6. Let 0<|x−3|<δ. Then 2<x<4, so 0<x+2<6, and

|(x2−x)−6|=|x−3||x+2|<ε6⋅6=ε

Since ε was arbitrary, the limit is 6. □

A function f with domain D is continuous at a point a∈D when

∀ε>0∃δ>0∀x∈D(|x−a|<δ⇒|f(x)−f(a)|<ε)

and continuous when it is continuous at every point of its domain. The condition 0<|x−a| has gone, since at x=a the inequality holds automatically, and the limit L has become the value f(a). So when f is defined near a, continuity at a says exactly that limx→af(x)=f(a): the function's value is what its nearby values predict. The Example shows that x2 is continuous at 2.

Proving continuity function by function would be as tiring as proving limits sequence by sequence. The link between the two kinds of limit makes the algebra of limits available.

Theorem (sequential continuity). If f is continuous at a, and (xn) is a sequence in the domain with xn→a, then f(xn)→f(a).

Proof. Let ε>0. By continuity there is δ>0 such that |f(x)−f(a)|<ε whenever x is in the domain and |x−a|<δ. Since xn→a, applying the definition of convergence with tolerance δ, there is N with |xn−a|<δ for all n≥N. For such n, |f(xn)−f(a)|<ε. So f(xn)→f(a). □

The converse is true as well, and the problem sheet proves it: if f(xn)→f(a) for every sequence xn→a in the domain, then f is continuous at a. With both directions, continuity becomes a statement about sequences, and the algebra of limits transfers. If f and g are continuous at a and xn→a, then f(xn)→f(a) and g(xn)→g(a), so f(xn)+g(xn)→f(a)+g(a), and the same for products, and for quotients when g(a)≠0. So sums, products and quotients of continuous functions are continuous. The constant functions and x itself are plainly continuous (take δ=ε for x), so every polynomial is continuous everywhere, and every rational function wherever its denominator is not zero.

Here are two functions that are not continuous, and how to prove it. The negation of continuity at a reads: there is ε>0 such that for every δ>0 some x in the domain has |x−a|<δ and |f(x)−f(a)|≥ε.

A jump. Let H(x)=0 for x<0 and H(x)=1 for x≥0, the step function of Problem 12 of the lesson on quantifiers. Take ε=12. For any δ>0, the point x=−δ2 has |x−0|<δ and |H(x)−H(0)|=|0−1|=1≥12. So H is not continuous at 0. The sequential form says the same more briefly: −1n→0, but H(−1n)=0 does not tend to H(0)=1. At every other point H is continuous, since it is constant on an interval around the point.

Discontinuous everywhere. Let g(x)=1 if x is rational and g(x)=0 if x is irrational, a function Dirichlet described in 1829. Let a be any real number and take ε=12. For any δ>0, the interval (a−δ,a+δ) contains a rational q and an irrational s, by the density theorems of the previous lesson. Since g(q)=1 and g(s)=0 differ by 1, at least one of them differs from g(a) by at least 12 (if both were within 12 of g(a), the triangle inequality would put them within 1 of each other, strictly). So g is continuous nowhere. No picture of a graph could show this; only the definition can.

What is continuity good for?

For theorems that say something exists. The first is the intermediate value theorem: if f is continuous on [a,b] and f(a)<0<f(b), then f(c)=0 for some c in [a,b]. Here is a proof from completeness.

Let S={x∈[a,b]:f(x)<0}. It contains a and is bounded above by b, so it has a supremum c, and a≤c≤b. We show f(c)=0 by ruling out the other two cases.

Suppose f(c)<0. Then c≠b, since f(b)>0. By continuity at c with ε=−f(c)>0, there is δ>0 with f(x)<f(c)+ε=0 for every x in [a,b] with |x−c|<δ. Some such x is larger than c: take the smaller of c+δ2 and b. It lies in S and exceeds c, contradicting that c is an upper bound of S.

Suppose f(c)>0. Then c≠a, since f(a)<0. By continuity with ε=f(c), there is δ>0 with f(x)>f(c)−ε=0 for every x in [a,b] with |x−c|<δ. So no point of (c−δ,c] lies in S, and every element of S, being at most c, is at most c−δ. Then c−δ is an upper bound of S smaller than c, contradicting that c is the least.

So f(c)=0. The theorem fails over ℚ: the function x2−2 is continuous on the rationals in [0,2], negative at 0 and positive at 2, and never zero at a rational. The proof broke where it took a supremum, as monotone convergence did. So completeness is what makes the graph of a continuous function unable to cross the axis without meeting it, the property that the word "continuous" was chosen to describe.

The second existence theorem is the extreme value theorem mentioned above, whose proof runs through Bolzano and Weierstrass. Between them, these two carry most of the weight in a first course in calculus: the mean value theorem, and through it everything a derivative says about a function, rests on them.

What has been built

The course began with patterns that held for forty cases, or for every number below 906150257, 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, the triangle inequality for uniqueness and the algebra of limits, induction for recursive sequences, contradiction for order and uniqueness, density for the Dirichlet function, and the supremum for monotone convergence, for Bolzano and Weierstrass, and for the intermediate value theorem.

A first course in real analysis continues directly from here, with the same ε arguments applied to series, derivatives and integrals. Calculus uses these limits as its foundation: its limit laws are the algebra of limits for functions, and its existence theorems are the ones sketched above. Calculus II carries the definitions into several variables, where the lesson on limits and continuity replaces |x−a| by the distance between points in the plane and finds that a limit can depend on the direction of approach. Each of these 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.

Problems

Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution. Results proved in the lesson (the algebra of limits, the squeeze theorem, monotone convergence) may be quoted.

Warm-up

1. (a) Prove from the definition that 5n→0. (b) For an=1n2, find the smallest N such that |an|<0.001 for every n≥N.

Solution

(a) Scratch work: 5n<ε exactly when n>5ε, that is, n>25ε2.

Proof. Let ε>0. By the Archimedean property there is N∈ℕ with N>25ε2. Let n≥N. Then n>25ε2, and since square roots preserve order on positive numbers, n>5ε, so |5n−0|=5n<ε. Since ε was arbitrary, 5n→0.

(b) 1n2<0.001 exactly when n2>1000. Since 312=961 and 322=1024, this holds exactly when n≥32. The terms decrease, so every n≥32 works, and n=31 does not. The smallest N is 32.

2. Prove from the definition that an=1+1n does not converge to 0.

Solution

The negation of an→0 requires one ε>0 such that every N is followed by some n≥N with |an−0|≥ε. Take ε=1. Let N∈ℕ and take n=N. Then |an−0|=1+1n>1, so |an|≥1. Since N was arbitrary, an does not converge to 0.

In fact every term misses by more than 1. By the algebra of limits the sequence converges to 1+0=1, and uniqueness gives the result again.

3. Find each limit, justifying every step by a result from the lesson. (a) limn3−2n4n3+n2+1. (b) lim3n+(−1)nn+1.

Solution

(a) Divide top and bottom by n3: the nth term is 1−2⋅1n⋅1n4+1n+1n⋅1n⋅1n. Since 1n→0, the rules for products, constant multiples and sums give numerator →1 and denominator →4≠0, and the rule for quotients gives the limit 14.

(b) Divide by n: the term is 3+(−1)nn1+1n. Now −1n≤(−1)nn≤1n, and both outer sequences tend to 0, so (−1)nn→0 by the squeeze theorem. So the numerator tends to 3 and the denominator to 1, and the limit is 3. The divergent sequence (−1)n appears in the formula, but only inside a combination that converges, so the algebra of limits was applied to (−1)nn, never to (−1)n itself.

4. Prove from the definition that f(x)=3x−1 is continuous at every real a. For a=2 and ε=0.3, what is the largest δ that works?

Solution

Let a be real and ε>0, and let δ=ε3. If |x−a|<δ, then |f(x)−f(a)|=|3x−3a|=3|x−a|<3δ=ε. So f is continuous at a, and a was arbitrary.

For ε=0.3, δ=0.1 works. No larger δ does: if δ>0.1, some x with 0.1<|x−2|<δ exists, for instance x=2+0.1+δ2, and then |f(x)−f(2)|=3|x−2|>0.3. So the largest is δ=0.1.

Core

5. Let an≥0 for every n, and an→L. Prove that L≥0 and that an→L.

Hint

For L>0, multiply and divide an−L by an+L. For L=0, work from the definition directly.

Solution

Since 0≤an for every n and limits preserve order, 0≤L.

Case L>0. For every n,

|an−L|=|an−L|an+L≤|an−L|L

since an≥0. Let ε>0, and choose N with |an−L|<Lε for n≥N. Then |an−L|<ε for n≥N.

Case L=0. Let ε>0, and choose N with |an|<ε2 for n≥N. Then 0≤an<ε2, and since square roots preserve order on non-negative numbers, an<ε for n≥N. So an→0.

The first case fails for L=0 because the bound divides by L; the second case repairs it with a different choice of tolerance. Continuity of the square root function follows, by the converse of sequential continuity (Problem 9).

6. Find the flaw in this proof, show that the claim is false, and say which extra hypothesis would make the argument correct.

Claim. Every bounded sequence of real numbers converges.

Proof. Let (an) be bounded. The set of its terms is nonempty and bounded above, so it has a supremum s. Let ε>0. Since s−ε is not an upper bound, some term has aN>s−ε. For n≥N we then have s−ε<aN≤an≤s, so |an−s|<ε. Hence an→s.

Hint

Compare the argument line by line with the proof of the monotone convergence theorem, and test it on (−1)n.

Solution

The flaw is the step aN≤an for n≥N. Nothing in the hypotheses says later terms are at least as large as earlier ones; that is exactly the statement that the sequence is increasing, and it was never assumed.

The claim is false: (−1)n is bounded, since |(−1)n|=1, and the lesson proved it diverges. Following the argument on it: s=1, and for ε=1 the term a2=1 exceeds s−ε=0, but the later term a3=−1 is not at least a2, and |a3−s|=2.

With the extra hypothesis that (an) is increasing, the argument is correct word for word: it is the proof of the monotone convergence theorem. Without monotonicity, the correct conclusion from boundedness is weaker: by Bolzano and Weierstrass, some subsequence converges.

7. Prove or disprove each claim, for sequences of real numbers. (a) If an→L, then an2→L2. (b) If an2→L2, then an→L. (c) If an→L and (bn) diverges, then (an+bn) diverges. (d) If (an) and (bn) both diverge, then (anbn) diverges. (e) If an→0 and (bn) is bounded, then anbn→0.

Hint

Two are false, and (−1)n disproves both. For (c), argue by contradiction with the algebra of limits. For (e), the algebra of limits does not apply, because (bn) need not converge; go back to the definition.

Solution

(a) True, by the rule for products applied with bn=an.

(b) False. Let an=(−1)n and L=1. Then an2=1→1=L2, but (an) does not converge to 1 (or to anything).

(c) True. Suppose, for contradiction, that an+bn→M for some M. Then bn=(an+bn)−an→M−L by the algebra of limits (the rule for sums, with the constant multiple −1), contradicting that (bn) diverges.

(d) False. Let an=bn=(−1)n. Both diverge, and anbn=1 for every n, which converges.

(e) True. Let B>0 with |bn|≤B for every n, and let ε>0. Choose N with |an|<εB for n≥N. Then |anbn−0|=|an||bn|<εB⋅B=ε for n≥N. So anbn→0. For example (−1)nn→0 again, with an=1n and bn=(−1)n.

8. Let x be a real number. Prove that ⌊nx⌋n→x.

Hint

Use the defining inequality of the floor, ⌊y⌋≤y<⌊y⌋+1, with y=nx, and squeeze.

Solution

Let n∈ℕ. By the definition of the floor, ⌊nx⌋≤nx<⌊nx⌋+1, so nx−1<⌊nx⌋≤nx. Dividing by the positive number n,

x−1n<⌊nx⌋n≤x

The left-hand side tends to x−0=x by the algebra of limits, and the right-hand side is the constant x. By the squeeze theorem, ⌊nx⌋n→x.

Each term ⌊nx⌋n is rational, so this gives an explicit sequence of rationals converging to any real number, the sequential form of the density of ℚ. For x=2 and n=10k it is the sequence of decimal truncations.

9. Let f have domain D and let a∈D. Prove that if f(xn)→f(a) for every sequence (xn) in D with xn→a, then f is continuous at a.

Hint

Prove the contrapositive. If f is not continuous at a, the negation of the definition hands you an ε that defeats every δ. Try δ=1n for each n in turn.

Solution

We prove the contrapositive: if f is not continuous at a, then some sequence xn→a in D has f(xn) not tending to f(a).

Suppose f is not continuous at a. By the negation of the definition, there is ε>0 such that for every δ>0 some x∈D has |x−a|<δ and |f(x)−f(a)|≥ε. For each n∈ℕ, apply this with δ=1n, and let xn be such a point: xn∈D, |xn−a|<1n and |f(xn)−f(a)|≥ε.

Then −1n<xn−a<1n, so xn→a by the squeeze theorem. But every term of f(xn) lies at least ε from f(a), so for this ε no N works, and f(xn) does not tend to f(a). □

Together with the theorem on sequential continuity, this shows that f is continuous at a exactly when f carries every sequence converging to a to a sequence converging to f(a). (Choosing one xn for each n at once is a use of the axiom of choice for countably many choices, a principle this course, like most of mathematics, takes for granted.)

10. Prove from the definition that f(x)=1x, with domain the positive reals, is continuous at every a>0.

Hint

|1x−1a|=|x−a|xa. Keep x away from 0 by insisting first that |x−a|<a2.

Solution

Scratch work. |1x−1a|=|a−x|xa. If |x−a|<a2, then x>a2, so xa>a22 and the expression is less than 2|x−a|a2. That is below ε when |x−a|<a2ε2.

Proof. Let a>0 and ε>0, and let δ be the smaller of a2 and a2ε2, which is positive. Let x>0 with |x−a|<δ. Then x>a−a2=a2, so xa>a22>0, and

|1x−1a|=|x−a|xa<a2ε/2a2/2=ε

So f is continuous at a, and a>0 was arbitrary. □

The δ depends on a as well as on ε, and it must: near 0 the graph is steep, and a fixed ε needs ever smaller δ as a decreases. When one δ serves every point of the domain at once, the function is called uniformly continuous; 1x on the positive reals is not.

11. Let g(x)=x if x is rational and g(x)=0 if x is irrational. Prove that g is continuous at 0 and at no other point.

Hint

At 0, note that |g(x)|≤|x| always. At a≠0, use the density of the rationals and of the irrationals, with ε=|a|2.

Solution

At 0. Here g(0)=0, since 0 is rational. For every x, |g(x)−g(0)|=|g(x)| is |x| or 0, so |g(x)|≤|x|. Let ε>0 and δ=ε. If |x|<δ, then |g(x)−g(0)|≤|x|<ε. So g is continuous at 0.

At a≠0. Take ε=|a|2>0 and let δ>0. We find x with |x−a|<δ and |g(x)−g(a)|≥ε. Let δ′ be the smaller of δ and |a|2.

If a is rational, g(a)=a. By the density of the irrationals there is an irrational x with |x−a|<δ, and then |g(x)−g(a)|=|0−a|=|a|≥ε.

If a is irrational, g(a)=0. By the density of the rationals there is a rational x with |x−a|<δ′. Then |x|≥|a|−|x−a|>|a|−|a|2=|a|2 by the reverse triangle inequality, so |g(x)−g(a)|=|x|>ε.

In both cases δ fails, and since δ was arbitrary, g is not continuous at a. □

So a function can be continuous at exactly one point. Continuity is a property of a function at a point, defined by the ε and δ game, and pictures of unbroken curves describe only the most familiar cases.

Challenge

12. Prove that n1/n→1, where n1/n is the positive nth root of n.

Hint

Write n1/n=1+hn with hn≥0. By the binomial theorem, (1+h)n≥n(n−1)2h2 for h≥0 and n≥2. Then use Problem 5.

Solution

The positive nth root exists and is unique, by the lesson on the real numbers.

Step 1: n1/n≥1. If 0<s<1, then sn<1≤n, so s is not the nth root of n. So hn=n1/n−1≥0.

Step 2: a bound on hn. Let n≥2. By the binomial theorem,

n=(1+hn)n=∑k=0n(nk)hnk≥(n2)hn2=n(n−1)2hn2

since every term of the sum is non-negative. Dividing by n(n−1)2>0 gives hn2≤2n−1, and since square roots preserve order on non-negative numbers, 0≤hn≤2n−1.

Step 3: squeeze. The sequence cn=2n−1 (for n≥2) tends to 0: it is 2⋅1m with m=n−1, and shifting the index does not change a limit. By Problem 5, cn→0=0. By the squeeze theorem, hn→0, so n1/n=1+hn→1. □

The terms are not monotone: 11/1=1, 21/2≈1.414, 31/3≈1.442, 41/4≈1.414, and from n=3 on they decrease. Monotone convergence could also be used from n=3, but it would not identify the limit without an argument like this one.

13. Prove that if an→L, then the averages σn=a1+a2+⋯+ann also converge to L. Show by an example that (σn) can converge when (an) does not.

Hint

First reduce to L=0 by considering an−L. Then split the sum at a position N beyond which |an| is small: the early terms contribute a fixed amount divided by n, and the late terms contribute an average of small numbers.

Solution

Reduction. Let bn=an−L, so bn→0, and the averages of (bn) are (a1−L)+⋯+(an−L)n=σn−L. So it is enough to prove: if bn→0, then τn=b1+⋯+bnn→0.

Main step. Let ε>0. Choose N with |bn|<ε2 for all n≥N. Let C=|b1|+|b2|+⋯+|bN−1|, a fixed number (zero if N=1). By the Archimedean property choose N′≥N with N′>2Cε. Let n≥N′. By the triangle inequality,

|τn|≤|b1|+⋯+|bN−1|n+|bN|+⋯+|bn|n<Cn+(n−N+1)n⋅ε2≤CN′+ε2<ε2+ε2=ε

using n−N+1≤n. Since ε was arbitrary, τn→0, and so σn→L. □

The converse fails. Let an=(−1)n, which diverges. The partial sums a1+⋯+an are −1,0,−1,0,…, so |σn|≤1n, and σn→0 by the squeeze theorem.

The averages are called Cesàro means, after Ernesto Cesàro. Averaging smooths out oscillation, which is why it can create convergence, and the theorem says it never destroys it.

14. Let en=(1+1n)n. Prove that (en) is increasing and bounded above by 3, and deduce that it converges.

Hint

Expand by the binomial theorem and write the kth term as 1k!(1−1n)(1−2n)⋯(1−k−1n). Compare term by term with en+1. For the bound, use k!≥2k−1.

Solution

The expansion. By the binomial theorem,

en=∑k=0n(nk)1nk,(nk)1nk=n(n−1)⋯(n−k+1)k!nk=1k!∏j=0k−1(1−jn)

where for k=0 the empty product is 1. Write Tk(n) for this kth term.

Increasing. For 0≤j<n, 1−jn≤1−jn+1, and both are non-negative, so each factor of Tk(n) is at most the corresponding factor of Tk(n+1), and therefore Tk(n)≤Tk(n+1) for 0≤k≤n. Also en+1 has one more term, Tn+1(n+1)≥0. Hence

en=∑k=0nTk(n)≤∑k=0nTk(n+1)≤∑k=0n+1Tk(n+1)=en+1

Bounded. Each factor 1−jn lies in [0,1], so Tk(n)≤1k!. And k!≥2k−1 for k≥1, by induction: 1!=1=20, and (k+1)!=(k+1)k!≥2⋅2k−1=2k. So

en≤1+∑k=1n12k−1=1+2(1−12n)<3

using the finite geometric sum ∑k=1n12k−1=2−12n−1.

Convergence. The sequence is increasing and bounded above, so by the monotone convergence theorem it converges, to a number between e1=2 and 3. That number is e=2.71828…, the base of the natural logarithm. Its first terms show how slowly the sequence approaches it: e1=2, e2=2.25, e10≈2.5937, e100≈2.7048. The theorem produced the number e with no formula for it, which is what completeness is for.

Proof and Logic, from libre.university