← Step 0: Base Camp Gym

Step 0 · Extra station

Six proofs worth knowing

Before you meet Lean, see what a proof feels like. These six are famous for a reason: each one is short, each one is convincing, and each one shows a different trick that mathematicians use again and again.

You only need school algebra. Read slowly, look at the pictures, and try the small question at the end of each proof.

What to look for in every proof

  1. A clear claim. Exactly what is being said, and about which things.
  2. Starting facts. Definitions, axioms or theorems we already accept.
  3. Small steps, each with a reason. No step is “obvious, trust me”.
  4. Every case is covered. Not just the examples we happened to try.
1

Direct proof · Easy trail

A triangle’s angles add to 180°

Claim. In every triangle, the three angles add up to 180°.

You could measure a thousand triangles with a protractor. You would get “about 180°” every time, but measuring is never exact, and you cannot measure every triangle. A proof settles it for all of them at once.

Starting facts. (a) Angles that sit side by side along a straight line add up to 180°. (b) When a line crosses two parallel lines, it makes equal angles on opposite sides, the “Z-angles”. Fact (b) comes from Euclid’s parallel postulate, one of his axioms.

▶ Watch it step by step

Step by step: a triangle’s angles add to 180 degreesAn animation in thirteen steps. A full turn is 360 degrees and a straight line is 180. Two parallel lines are crossed by a third line; sliding and spinning angle a shows that Z-angles are equal. Then a triangle ABC gets a line through C parallel to AB, its angles alpha and beta move to C, and together with gamma they fill a straight line: 180 degrees.full turn = 360°straight line = half a turn = 180°180°50°130°50° + 130° = 180°parallelparallelabaaαβγABCαβα + γ + β = 180°

Swipe sideways to see the whole picture.

  1. A full turn is 360°. Why 360? The Babylonians counted in sixties, and a popular explanation is that a year has roughly 360 days. 360 is also handy: it divides evenly by 2, 3, 4, 5, 6, 8, 9, 10, 12 and many more.
  2. A straight line is half a turn: 180°. Stand on the line facing right and turn until you face left. You have turned exactly halfway round.
  3. Angles side by side on a straight line add to 180°. Split the half turn with a ray, and the two parts still make the whole half turn: here 50° + 130° = 180°.
  4. Two parallel lines. They point in exactly the same direction, so they never meet. The little arrows mark them as parallel.
  5. A third line crosses both. At the top crossing, call the angle above the line on the right a.
  6. Slide the top crossing down the third line. The two lines point the same way, so it lands exactly on the bottom crossing, and angle a fits perfectly. These “corresponding angles” are equal. This is the step that relies on Euclid’s parallel postulate.
  7. Spin a half a turn around the top crossing. It lands on the opposite angle. They are equal because a + b = 180° (along the top line) and b + the opposite angle = 180° (along the third line).
  8. So the two angles inside the Z are equal. Both are a. These are called alternate angles, or “Z-angles”. This is the one fact the triangle proof needs.
  9. Now take any triangle. Call its angles α at A, β at B and γ at C. We want to show α + β + γ = 180°.
  10. Draw a line through C, parallel to AB. Now we have two parallel lines again.
  11. Side CA crosses both parallel lines, making a Z. So the Z-angle at C equals α. Watch α turn and land at C.
  12. Side CB crosses them too, making a backwards Z. So the angle on the other side of C equals β.
  13. At C, the angles α, γ and β fill a straight line, so α + γ + β = 180°. We never used the triangle’s size or shape, so this is true for every triangle. ∎
Why a triangle’s angles add to 180 degreesTriangle ABC with angles alpha at A, beta at B and gamma at C. A line through C runs parallel to AB. Beside gamma, the angle between this line and side CA equals alpha, and the angle between the line and side CB equals beta. The three angles at C sit side by side on a straight line, so alpha plus gamma plus beta is 180 degrees.αβγαβABCnew line through C, parallel to ABsame arrows = parallelAt C: α + γ + β make a straight line, so they add to 180°

Swipe sideways to see the whole picture.

The new line through C copies angle α and angle β up to the top corner, right next to γ.
  1. Take any triangle ABC. Call its angles α at A, β at B and γ at C.
  2. Draw a line through C, parallel to the side AB.
  3. The side CA crosses both parallel lines, so the angle between CA and the new line equals α (fact b).
  4. In the same way, side CB makes an angle equal to β on the other side.
  5. At C, the angles α, γ and β fill the straight line, so α + γ + β = 180° (fact a). ∎

Why it covers every case: we never used a particular size or shape. The same steps work for a tiny triangle, a huge one, a thin one or a wide one.

Try it: what is each angle of an equilateral triangle?

Its three angles are equal and add to 180°, so each one is 180° ÷ 3 = 60°. Notice that you just used the theorem as a fact in a new proof.

2

Same area, two ways · Easy trail

Pythagoras’ theorem

Claim. In a right triangle with short sides a and b and longest side c, we have a² + b² = c².

Babylonian scribes were already listing right triangles like this around 1800 BCE. Euclid’s Elements, written about 300 BCE, contains a proof, and hundreds of different proofs are known today. Here is one you can see.

▶ Watch it step by step

Step by step: Pythagoras’ theoremAn animation in ten steps. A right triangle has short sides a and b and longest side c, and squares are drawn on its three sides. Then four copies of the triangle sit in the corners of a square with side a plus b, leaving a tilted hole of side c. Angles on the straight edge show the hole’s corners are right angles, so its area is c squared. The triangles then slide, without turning, into two rectangles, leaving a square of side a and a square of side b. The same big square minus the same four triangles leaves the same area, so c squared equals a squared plus b squared. A final step checks this with algebra.a²b²c²abcThe claima² + b² = c²small square + small square= big square?a²b²1234c²ccccabbaaba + bαβ?Along the straight top edge:β + hole’s angle + α = 180°In the triangle (Proof 1):α + β + 90° = 180°so α + β = 90°hole’s angle = 90°First count: the big square is4 triangles + c²Second count: the big square is4 triangles + a² + b²c² = a² + b²(a + b)² = a² + 2ab + b²counted as pieces:(a + b)² = 4 × ½ab + c²= 2ab + c²take 2ab from both sides:

Swipe sideways to see the whole picture.

  1. A right triangle. Its two shorter sides are a and b, and the longest side (opposite the right angle) is c. The claim: a² + b² = c².
  2. Read a² as an area. a² is the area of a square with side a. So the claim says: the two small squares together have exactly the same area as the big square on c.
  3. Build one big square with side a + b. Put four copies of the triangle, numbered 1 to 4, in its corners. Along each edge, one triangle gives a and its neighbour gives b. The tilted hole in the middle has four sides of length c.
  4. Is the hole really a square? Look at its top corner. Call the triangle’s two small angles α and β. Here β, the hole’s angle and α sit side by side along the straight top edge, so together they make 180°.
  5. Yes, its corners are right angles. By Proof 1 the triangle’s angles add to 180°, and one of them is 90°, so α + β = 90°. That leaves 180° − 90° = 90° for the hole. The same happens at all four corners, so the hole is a square with area c².
  6. Count the area once. The big square is made of four triangles plus the hole: big square = 4 triangles + c².
  7. Now slide the triangles. No turning, only sliding: 1 moves down, 3 moves left, 4 moves up and right, 2 stays put. They pair up into two rectangles: 1 with 3, and 2 with 4.
  8. Count the area again. The holes are now a square of side a and a square of side b. So big square = 4 triangles + a² + b².
  9. Compare the two counts. Same big square, same four triangles, so what is left over must be equal: c² = a² + b². We never used particular lengths, so this holds for every right triangle. ∎
  10. Check it with algebra. The big square’s area is (a + b)² = a² + 2ab + b². Counted as pieces it is 4 × ½ab + c² = 2ab + c². Take 2ab from both sides and you get a² + b² = c² again.
Pythagoras’ theorem by rearranging four trianglesTwo equal squares with side a plus b. The left one holds four copies of a right triangle in its corners, leaving a tilted square of side c in the middle. The right one holds the same four triangles paired into two rectangles, leaving a square of side a and a square of side b. Taking the same triangles away from the same square leaves the same area, so c squared equals a squared plus b squared.1234c²c1234a²b²abbaabab4 triangles + c²4 triangles + a² + b²=Same square, same four triangles, so what is left over matches: c² = a² + b²

Swipe sideways to see both squares.

The four numbered triangles are the same in both squares. Only their places change.
  1. Make four copies of the right triangle.
  2. Put them in the corners of a big square with side a + b, as on the left. The hole in the middle has four sides of length c.
  3. The hole is really a square: at each of its corners, the hole’s angle and the triangle’s two small angles fill a straight line. Those two small angles add to 90° (by Proof 1, since the third angle is 90°), so the hole’s angle is 180° − 90° = 90°. Its area is c².
  4. Now slide the same four triangles into two rectangles, as on the right. The holes are a square of side a and a square of side b, with area a² + b².
  5. Both big squares are the same, and we took away the same four triangles. So what is left has the same area: c² = a² + b². ∎

The same thing with algebra: the big square’s area is (a + b)² = a² + 2ab + b². It is also four triangles plus the hole: 4 × ½ab + c² = 2ab + c². Set them equal and take 2ab from both sides: a² + b² = c². Expanding (a + b)² is exactly what Lean’s ring does in Step 26.

Try it: a right triangle has short sides 6 and 8. How long is the longest side?

6² + 8² = 36 + 64 = 100, and 100 = 10², so the longest side is 10.

3

Counting boxes · Steady climb

The pigeonhole principle

Principle. If you put more things into boxes than there are boxes, some box gets at least two things.

It sounds too simple to be useful. The skill is in choosing the boxes.

▶ Watch it step by step

Step by step: the pigeonhole principleAn animation in nine steps. Twelve boxes, one per month, receive twelve people, one each. A thirteenth person has to land in a box that is already taken, April, because twelve boxes with at most one person each hold at most twelve people. Then the numbers 1 to 10 move into five boxes of pairs that add to 11: 1 and 10, 2 and 9, 3 and 8, 4 and 7, 5 and 6. Picking 1, 9, 3, 4 and 6 fills one box each; the sixth pick, 8, joins 3, and 3 plus 8 is 11. Finally 1, 2, 3, 4, 5 show that five picks are not enough: they sit in five different boxes and no two add to 11.Claim: any 13 people include two with the same birth monthJFMAMJJASONDApril: two people12 boxes, one per month. Each person goes in their month’s box.12 people, one per box: every box is now taken.Person 13 has to share a box with someone.If every box held at most 1 person:12 boxes × at most 1 = at most 12 people.But there are 13. So some box holds two. ∎More things than boxes ⇒ some box gets at least twoClaim: any 6 different numbers from 1–10 include two that add to 11Ten numbers. Choose any six of them.Can you avoid two that add to 11?1 + 10 = 112 + 9 = 113 + 8 = 114 + 7 = 115 + 6 = 1112345678910Each box is a pair that adds to 11. Every number is in exactly one box.Picks so far: 1, 9, 3, 4, 6one in each box, so no two add to 11 yetSixth pick: 8. Its box already holds 3.3 + 8 = 11Only five picks? 1, 2, 3, 4, 5 use five different boxes,and no two of them add to 11. Five is not enough.

Swipe sideways to see the whole picture.

  1. Twelve boxes, one for each month. The claim: in any group of 13 people, two of them were born in the same month. Put each person in the box for their birth month.
  2. The best we can do is spread them out. Twelve people can all have different birth months, one per box. But now every box is taken.
  3. So the 13th person has to share a box (here, April). Obvious? Yes, on purpose. This warm-up shows the rule in a case you can check at a glance. The skill, as the puzzle coming up shows, is choosing what the boxes are.
  4. As a proof, it is one line. At most one person per box would mean at most 12 people. We have 13, so some box holds two. ∎ This is the pigeonhole principle: more things than boxes means some box gets at least two.
  5. Now a real puzzle. Here are the numbers 1 to 10. The claim: pick any 6 different ones, and two of them will add up to 11. Can you dodge it?
  6. The clever part is choosing the boxes. Pair up the numbers that add to 11: {1, 10}, {2, 9}, {3, 8}, {4, 7} and {5, 6}. Every number from 1 to 10 sits in exactly one box.
  7. Pick numbers one at a time. Try 1, 9, 3, 4 and 6. Each lands in a different box, so no two of them add to 11 yet. But now all five boxes hold a pick.
  8. The sixth pick has nowhere new to go. Six numbers, five boxes: some box gets two. Here 8 lands in the box that already holds 3, and 3 + 8 = 11. Whichever six you pick, the same thing happens. ∎
  9. Notice: we never said which two numbers. The proof shows the pair exists without finding it. And six really is needed: 1, 2, 3, 4, 5 sit in five different boxes and no two add to 11. That is a counterexample for five picks.
The pigeonhole principleTop: twelve boxes, one for each month. Thirteen people are placed, one per box, and the thirteenth has to go into a box that already has someone, here April. Bottom: five boxes holding the pairs 1 and 10, 2 and 9, 3 and 8, 4 and 7, 5 and 6, each pair adding to 11. The six chosen numbers 1, 3, 4, 6, 8 and 9 go into their boxes, and the box for 3 and 8 receives two of them: 3 plus 8 is 11.13 people, 12 months: some month must get twoJFMAMJJASOND13th personAny 6 numbers from 1–10, 5 boxes of pairs that add to 1111 + 1092 + 9383 + 844 + 765 + 63 + 8 = 11

Swipe sideways to see all the boxes.

Top: months are the boxes. Bottom: the clever choice of boxes is pairs that add to 11.

Warm-up: any 13 people include two with the same birth month

  1. Make 12 boxes, one for each month, and put each person in the box for their birth month.
  2. If every box held at most one person, there would be at most 12 people.
  3. There are 13, so some box holds at least two: two people share a month. ∎

The real trick: pick any 6 different numbers from 1 to 10. Two of them add up to 11.

  1. Make five boxes: {1, 10}, {2, 9}, {3, 8}, {4, 7} and {5, 6}. The two numbers in each box add to 11.
  2. Every number from 1 to 10 belongs to exactly one box.
  3. Six numbers, five boxes: some box receives two of your numbers.
  4. Those two numbers add to 11. ∎

Notice: the proof does not tell you which two numbers. It proves that they exist without finding them. Mathematicians call this an existence proof.

Try it: is it still true if you pick only 5 numbers?

No. Pick 1, 2, 3, 4, 5: no two of them add to 11. That is a counterexample. With five numbers, each one can sit in its own box, so the argument has nothing to push against.

4

Find an invariant · Steady climb

The broken chessboard

Claim. Cut two opposite corner squares off a chessboard. The 62 squares left cannot be covered by 31 dominoes, where each domino covers two squares side by side.

Trying every way to place 31 dominoes would take far too long, and failing a million times proves nothing. One clever idea settles it in four lines.

▶ Watch it step by step

Step by step: the broken chessboard cannot be coveredAn animation in ten steps. An eight by eight board has 32 dark and 32 light squares, and 32 dominoes cover it easily. Two opposite corners, both dark, are cut off, leaving 62 squares. An attempt with 30 dominoes gets stuck with two light squares left that are not side by side. Counting colors gives 30 dark and 32 light squares. One domino moves around the board and always covers one dark and one light square, so 31 dominoes would need 31 dark squares, but only 30 are left: impossible. This never-changing fact is an invariant.8 × 8 boardtwo opposite corners removed??THE BOARD8 × 8 = 64 squares32 dark32 lighta domino covers2 squares side by sidefull board:32 dominoes, easyCUT OFF TWO CORNERS64 − 2 = 62 squares leftClaim: 31 dominoescan never cover them.TRY IT30 dominoes placed?2 squares left, notside by side: stuck!Failing a few timesproves nothing.A cleverer way?COUNT THE COLORSdark squares: 32 − 2 = 30light squares: 32every domino covers1 dark + 1 lightwherever it goes31 dominoes would need31 dark + 31 lightOnly 30 dark: impossible! ∎The never-changing fact is an invariant.

Swipe sideways to see the whole picture.

  1. A chessboard has 8 × 8 = 64 squares: 32 dark and 32 light. A domino is a tile that covers exactly two squares side by side.
  2. A full board is easy to cover. Four dominoes fill each row, so 32 dominoes cover all 64 squares with nothing left over.
  3. Now cut off two opposite corners. That leaves 62 squares. The claim: you can never cover them with 31 dominoes, however you arrange them.
  4. Try it. Lay dominoes down row by row. After 30 dominoes we are stuck: two squares are left, and they are not side by side, so no domino fits. Failing a few times proves nothing, though. Maybe a cleverer arrangement exists?
  5. Clear the board and count colors instead. Opposite corners always have the same color, so we removed two dark squares. That leaves 32 − 2 = 30 dark squares and 32 light ones.
  6. Key fact: a domino always covers one dark and one light square. Squares side by side always have different colors, because the colors alternate along every row and every column.
  7. Turn it upright and move it: still one dark and one light. Going down a column the colors alternate too.
  8. Wherever it goes, it is the same: 1 dark + 1 light. There is no place on the board where a domino covers two squares of the same color.
  9. So 31 dominoes would cover exactly 31 dark and 31 light squares, one of each color per domino.
  10. But only 30 dark squares are left, so it is impossible. ∎ No arrangement can ever work, and we never had to try them all. The idea is called an invariant: something that never changes, whatever you do.
The chessboard with two corners removedAn eight by eight board with the top-left and bottom-right corners crossed out. Both removed corners are dark squares. Two dominoes are drawn on the board, and each covers one dark and one light square. Beside the board: 30 dark squares are left and 32 light ones. 31 dominoes would cover 31 dark and 31 light squares, but there are only 30 dark squares, so it is impossible.two opposite corners removedCOUNT THE COLORSdark squares left: 32 − 2 = 30light squares left: 32every domino covers1 dark + 1 light, wherever it goes31 dominoes would need31 dark + 31 lightOnly 30 dark squares: impossible!

Swipe sideways to see the count.

Wherever a domino lands, it covers one dark and one light square.
  1. Color the board in the usual chessboard pattern. Opposite corners always have the same color, so we removed two dark squares. That leaves 30 dark and 32 light.
  2. Two squares side by side always have different colors, so every domino covers one dark and one light square.
  3. So 31 dominoes would cover exactly 31 dark and 31 light squares.
  4. There are only 30 dark squares. No covering is possible. ∎

The trick: find something that never changes, whatever you do. Here, “each domino covers one of each color” is that unchanging fact, called an invariant.

Try it: what if you remove one dark and one light square instead?

Then 31 dark and 31 light squares are left, so the color argument no longer rules it out. In fact a covering always exists then, a result proved by Ralph Gomory. The same argument can prove “impossible” in one case and say nothing in another, so read every step.

5

Proof by contradiction · Steeper

√2 is not a fraction

Claim. There are no whole numbers p and q with √2 = p / q.

The diagonal of a 1 × 1 square has length √2. A calculator shows 1.41421356…, and the digits never settle into a repeating pattern, but a screen can only show finitely many digits. Legend says this discovery upset the followers of Pythagoras, who believed that every length was a ratio of whole numbers.

The idea of a proof by contradiction: suppose the opposite is true, then follow the steps until something impossible happens. If a supposition leads to nonsense, it must be false.

▶ Watch it step by step

Step by step: the square root of 2 is not a fractionAn animation in nine steps. A 1 by 1 square gets a diagonal; Pythagoras gives 1 squared plus 1 squared equals d squared, so d is the square root of 2. A calculator shows 1.41421356 and more digits. Then we suppose root 2 equals p over q in lowest terms, so p and q are not both even. Squaring gives p squared equals 2 q squared, so p squared is even. A table of n and n squared for n from 1 to 6 shows that only even numbers have even squares, so p is even: p equals 2k. Substituting gives 4 k squared equals 2 q squared, so q squared equals 2 k squared, and q is even too. A red link joins "p and q are both even" to the supposition, which flashes red. So the supposition was false and root 2 is not a fraction: a proof by contradiction.11d√2How long is the diagonal?Pythagoras (Proof 2):1² + 1² = d²d² = 2d = √2√2 on a calculator:1.41421356…The digits never repeat in a pattern …Could √2 = p / q ?Suppose √2 = p / q, in lowest termsso p and q are not both even✗ falseHalve top and bottom while both are even:12/8 = 6/4 = 3/23 and 2 are not both even: lowest terms.Square both sides2 = p² / q²× q² on both sidesp² = 2q²So p² is even(it is 2 × q²)Which n² are even?nn²123456149162536odd × odd = oddSo p is even:p = 2kPut in p = 2k(2k)² = 2q²4k² = 2q²q² = 2k²So q² is even,so q is even toop and q are both even!That clashes with the supposition: not both even.So √2 is not a fraction. ∎This is a proof by contradiction.

Swipe sideways to see the whole picture.

  1. Draw a 1 × 1 square and its diagonal. How long is the diagonal? Call its length d.
  2. Pythagoras (Proof 2 on this page) answers it. The diagonal cuts the square into two right triangles with legs 1 and 1, so 1² + 1² = d². That gives d² = 2, so d = √2.
  3. A calculator says √2 = 1.41421356… The digits never settle into a repeating pattern, but no screen can show all of them, so looking can’t settle the question. Could √2 still be a fraction p / q of whole numbers?
  4. Suppose it is: √2 = p / q, in lowest terms. Here “lowest terms” means p and q are not both even. That costs nothing: any fraction can be halved top and bottom until they are not both even, like 12/8 = 6/4 = 3/2.
  5. Square both sides. That gives 2 = p² / q², and multiplying both sides by q² gives p² = 2q². So p² is 2 times a whole number: p² is even.
  6. Even squares come from even numbers. In the table, only the even values of n give an even n². The reason: odd × odd is odd, so if p were odd, p² would be odd too. So p is even, and we can write p = 2k for some whole number k.
  7. Put p = 2k into p² = 2q². We get (2k)² = 2q², so 4k² = 2q². Halve both sides: q² = 2k². So q² is even, and for the same reason as before, q is even too.
  8. Clash! We have shown that p and q are both even. But we supposed they are not both even. Both can’t be true.
  9. So the supposition was false: √2 is not a fraction. ∎ This method is called proof by contradiction: suppose the opposite, follow it until something impossible happens, and conclude that the opposite was wrong.
Why the square root of 2 is not a fractionOn the left, a 1 by 1 square whose diagonal has length the square root of 2. On the right, six linked steps. Suppose root 2 equals p over q in lowest terms. Squaring gives p squared equals 2 q squared. So p squared is even, so p is even: p equals 2k. Then 4 k squared equals 2 q squared, so q squared equals 2 k squared. So q squared is even and q is even too. Then p and q are both even, so the fraction was not in lowest terms: a contradiction.11√2the diagonal ofa 1 × 1 squareSuppose √2 = p / q,in lowest terms1Square both sides:p² = 2q²2p² is even, so p is even.Write p = 2k3Then 4k² = 2q²,so q² = 2k²4q² is even,so q is even too5p and q both even:not lowest terms!6The supposition led to a clash, so it must be false.

Swipe sideways to follow the chain.

Follow the numbers 1 to 6. The last step contradicts the first.
  1. Suppose √2 = p / q. We may take the fraction in lowest terms, so p and q are not both even. (Any fraction can be simplified until that is true.)
  2. Square both sides: 2 = p² / q², so p² = 2q². That means p² is even.
  3. If p were odd, p² would be odd too. (An odd number times an odd number is odd. You prove a version of this in Lean in Step 37.) So p is even: p = 2k for some whole number k.
  4. Put that in: (2k)² = 2q², so 4k² = 2q², so q² = 2k². Now q² is even.
  5. By the same reason as step 3, q is even.
  6. So p and q are both even. That contradicts step 1. The supposition was false: √2 is not a fraction. ∎

In Lean: this style of proof gets its own step on the trail. See Step 17: Proof by contradiction.

Try it: where exactly did we use “lowest terms”?

Only at the very end. Reaching “p and q are both even” is only a clash because we promised in step 1 that they are not both even. Without that promise there would be no contradiction.

6

Contradiction by construction · Steeper

The primes never run out

Claim. There is no largest prime number. The primes go on forever.

A prime is a whole number bigger than 1 whose only divisors are 1 and itself: 2, 3, 5, 7, 11, 13… This proof is in Euclid’s Elements, more than 2,300 years old, and it is still the one taught today.

Starting fact. Every whole number bigger than 1 has at least one prime factor. (Keep dividing it by a smaller factor until you cannot any more.)

▶ Watch it step by step

Step by step: the primes never run outAn animation in nine steps. The primes up to 30 are marked on a number line. Suppose the only primes are 2, 3 and 5. Then N = 2 × 3 × 5 + 1 = 31 is drawn as 30 dots in 5 rows of 6 plus one extra dot. The 30 dots split exactly into 15 pairs, 10 groups of 3 and 6 groups of 5, and each time the extra dot is left over: remainder 1. So none of 2, 3, 5 divides 31, yet 31 has a prime factor, which is not on the list: a clash. With the list 2, 3, 5, 7, 11, 13, N = 30031 = 59 × 509 is not prime, but 59 and 509 are new primes. The same steps work for any finite list, so the primes never run out.2, 3, 5, 7, 11, 13, 17, 19, 23, 29, …the primes up to 30130Do they ever stop?2357111317192329Suppose these areall the primes:235…and no othersN = 2 × 3 × 5 + 1 = 31+2 × 3 × 5 = 30 dots1 extraleft over15 pairs10 groups of 36 groups of 5Divide 31 by each:31 = 2 × 15 + 131 = 3 × 10 + 131 = 5 × 6 + 1always remainder 1None of 2, 3, 5 divides 31.But every whole number biggerthan 1 has a prime factor.The prime factor of 31 is 31,and 31 is not on the list.31new primeClash!The list was not complete.Suppose these are all the primes:23571113…and no othersN = 2 × 3 × 5 × 7 × 11 × 13 + 1 = 30031remainder 1 when divided by any of them30031 =59×509new primenew prime30031 is not prime, but its prime factors are not on the list.Any finite listof primes:p₁, p₂, …, pₙ…and no others?Build a new number:N = p₁ × p₂ × … × pₙ + 1Divide N by any primeon the list:remainder 1N has a primefactor, and it isnot on the list.Clash!2357111317192329…The primes never run out. ∎

Swipe sideways to see the whole picture.

  1. Primes are the building blocks of whole numbers. A prime is a whole number bigger than 1 whose only divisors are 1 and itself. Here are the primes up to 30. They get rarer as the numbers grow. Do they ever stop?
  2. Suppose they do stop. Then we could write down the complete list of primes. To keep the picture small, pretend the whole list is just 2, 3 and 5, and there are no others.
  3. Build a new number: multiply all the primes on the list, then add 1. N = 2 × 3 × 5 + 1 = 31. Picture it as 30 dots in 5 rows of 6, plus 1 extra dot set apart.
  4. Divide 31 by 2. The 30 dots pair up exactly: 15 pairs. The extra dot has no partner, so the remainder is 1.
  5. Divide 31 by 3. The 30 dots make 10 groups of 3. Again the extra dot is left over: remainder 1.
  6. Divide 31 by 5. The 30 dots make 6 groups of 5, and once more the extra dot is left over. This is no luck: 30 = 2 × 3 × 5 splits exactly into 2s, 3s or 5s, so the remainder is always that single extra dot.
  7. So none of 2, 3, 5 divides 31. But every whole number bigger than 1 has a prime factor. The prime factor of 31 is 31 itself, and it is not on the list. Clash! The “complete” list was not complete.
  8. Careful: N does not have to be prime. Try the list 2, 3, 5, 7, 11, 13. Then N = 30030 + 1 = 30031 = 59 × 509, which is not prime. But 59 and 509 are primes missing from the list, and that is all the proof needs.
  9. The same steps work for any finite list. Multiply the primes and add 1. Dividing N by any of them leaves remainder 1, so N has a prime factor that is not on the list. No list of primes is ever complete: the primes never run out. ∎
Why the primes never run outSuppose the only primes are 2, 3 and 5. Multiply them and add 1 to get 31. Dividing 31 by 2, 3 or 5 always leaves remainder 1, so none of them divides 31. But 31 has a prime factor, and it cannot be on the list. The list was not complete: a clash.SUPPOSE THESE AREALL THE PRIMES235…and no othersMultiply them,then add 1:2 × 3 × 5 + 1= 31DIVIDE 31 BY EACH ONE31 = 2 × 15 + 131 = 3 × 10 + 131 = 5 × 6 + 1remainder 1 every time31 has a primefactor, and it isnot on the list.Clash!The same steps work for any list of primes, however long.

Swipe sideways to follow the steps.

A short example list. The proof itself works for every list.
  1. Suppose there are only finitely many primes, and write them all in a list: p₁, p₂, …, pₙ.
  2. Build a new number: N = p₁ × p₂ × … × pₙ + 1.
  3. Divide N by any prime on the list. The product part divides exactly, so the remainder is always 1. No prime on the list divides N.
  4. But N is bigger than 1, so it has a prime factor. That prime is not on the list.
  5. So the list did not contain every prime, which contradicts step 1. The primes never run out. ∎

A common slip: the proof does not say N is prime. Try the list 2, 3, 5, 7, 11, 13: N = 30031 = 59 × 509. N is not prime, but its prime factors 59 and 509 are new, which is all the proof needs. In Lean, you use this theorem from Mathlib in Step 39.

Try it: with the list 2, 3, find N and its prime factor.

N = 2 × 3 + 1 = 7. Dividing 7 by 2 or by 3 leaves remainder 1, and 7 itself is a prime that was not on the list.

Five tricks to keep

TrickWhen to reach for itSeen in
Direct proofChain facts you know until you reach the claim.Proof 1
Count it two waysWork out the same area or total in two ways, then set them equal.Proof 2
PigeonholeMore things than boxes? Choose the boxes cleverly.Proof 3
InvariantFind something that never changes, then show the goal would change it.Proof 4
ContradictionSuppose the opposite and follow it until something impossible happens.Proofs 5 and 6

Here is the catch: every one of these proofs is written for humans. A reader has to check each step, and in long proofs readers miss gaps. Lean checks every step for you. Next, see how in the Base Camp Gym.