Meet the five Trail Guides

  • Lemmi
    What’s a proof?

    A proof gives reasons why a math claim must be true.

  • Tacto
    What’s Lean 4?

    Lean is a language for writing math. It checks each proof.

  • Goalie
    How does it help?

    After each step, Lean shows what’s left to prove.

  • Typo
    What if I get stuck?

    Read what Lean expected. Use that clue to try another step.

  • Indy
    Where do I start?

    Begin with numbers you know. Build up to bigger proofs.

Learn Lean 4, one checkpoint at a time

How do you know it’s true?

A proof is a reason that works every single time. Lean 4 is a tool that checks those reasons, step by step. Warm up at base camp, then climb from your first calculation to a proof that a program works.

The Proof Hike trail Checkpoint 1: Lean as a calculator, steps 1–5 1 Checkpoint 2: Your first proofs, steps 6–10 2 Checkpoint 3: Logic, part one, steps 11–15 3 Checkpoint 4: Logic, part two, steps 16–20 4 Checkpoint 5: Numbers & induction, steps 21–25 5 Checkpoint 6: Algebra with Mathlib, steps 26–30 6 Checkpoint 7: Data & functions, steps 31–35 7 Checkpoint 8: Real mathematics, steps 36–40 8 Checkpoint 9: Logic puzzles, steps 41–45 9 Checkpoint 10: Prove your programs work, steps 46–50 10
Your trail map10 checkpoints · 5 lessons each

How the hike works

  1. Step 0Base Camp GymWhat a proof is, a short history, where Lean came from, and how to read it.
  2. Steps 1–50The trail: 10 checkpointsEach lesson is one small, checked step: an idea, a Lean proof, a common slip, and your turn.
  3. The summitProve a program worksFinish by proving facts about real code, checked by Lean, not just tested.

Big idea 1

What is a math proof?

A proof is an argument that shows a claim must be true, in every case, with no exceptions. Not “probably”. Not “it worked when I tried it”. Every case.

The claimAdd two even numbers and the answer is always even.

Way 1 · Try examplesTesting examplesFour sums of even numbers, each checked and even. Below them the rows fade out, with infinitely many more cases still unchecked.2 + 4 = 6even8 + 10 = 18even24 + 36 = 60even100 + 2 = 102even? + ? = ?? + ? = ?? + ? = ?…and infinitely many more

Good evidence, not a proof. There are infinitely many even numbers. You can never finish checking them.

Way 2 · Find the reasonTwo even numbers make an even numberSix dots arranged as three vertical pairs, plus ten dots arranged as five pairs, combine into sixteen dots arranged as eight pairs. Every dot still has a partner.6 = 3 pairs+10 = 5 pairs16 = 8 pairsEvery dot still has a partner. Nothing is left over.

A proof. “Even” means the dots split into pairs. Join two piles of pairs and you still have only pairs. That reason never mentions 6 or 10, so it works for every size.

The same idea in algebra: if a = 2r and b = 2s, then a + b = 2r + 2s = 2(r + s), which is twice a whole number. You will check exactly this proof with Lean at Step 36.

Big idea 2

What is Lean?

Lean is a programming language that can also check proofs. You write a claim and the steps of your argument. Lean checks every step against the rules of logic. It never gets tired, never skips a line, and never says “looks fine to me” when it isn’t.

How Lean checks a proofYou write a claim and proof steps. Lean checks every step. If every step follows, Lean says no goals and the proof is accepted. If a step does not follow, Lean points to that step and explains what it expected.You writea claim + stepsLeanchecks every stepAcceptedno goalsNothing left to prove.Not yetPoints to the stepand says why.How Lean checks a proofYou writea claim + stepsLeanchecksevery stepAcceptedno goalsNothing left.Not yetPoints to thestep and sayswhy.
Think of Lean as a referee who checks every move. When it rejects a step, it shows exactly what it still needed. That message is a clue, not a punishment.

Three tiny examples

These lines come straight from the course’s checked Lean files. The grey boxes show what Lean actually printed.

  1. 1

    Lean as a calculator

    #eval 2 + 3 * 4Lean says14

    #eval means “work this out”. Lean multiplies first, just like you would: 3 × 4 = 12, then 2 + 12 = 14. Step 1

  2. 2

    A claim with a proof

    example : 2 + 2 = 4 := by rflLean saysno goals

    “No goals” means nothing is left to prove. The proof is complete and checked. Step 6

  3. 3

    A false claim gets caught

    example : 2 + 2 = 5 := by rflLean saysTactic `rfl` failed: The left-hand side 2 + 2 is not definitionally equal to the right-hand side 5 ⊢ 2 + 2 = 5

    Lean works out 2 + 2 and gets 4, which is not 5. You can’t sneak a false claim past it.

How to read example 2

example : 2 + 2 = 4 := byrfl1234
  1. example “Here comes a claim.” (A named claim uses theorem instead; see Step 8.)
  2. : 2 + 2 = 4 The claim itself. Read the colon as “the statement is”.
  3. := by “…and here is why.” The word by means “I’ll prove it step by step, with tactics.”
  4. rfl A tactic: one proof move. rfl means “both sides work out to the same thing”.
Every Lean proof in this course has this shape: a claim, then := by, then tactics. The tactics change as the hike goes on.

Step 0 · Before the hike

Warm up in the Base Camp Gym

Good hikers stretch before they climb. Spend about 20 minutes on six short stations. You will know what a proof is, where proofs and Lean came from, and how to read every line of a Lean proof. No setup needed.

  1. Station 1Where math came fromFrom tally marks to Euclid in two minutes.
  2. Station 2What a proof really isStepping stones of reasons, and why examples are not enough.
  3. Station 3Why we want a checkerFamous proofs that fooled experts for years.
  4. Station 4Where Lean came fromFrom 2013 to Lean 4, the version you will use.
  5. Station 5How to read Lean 4Claims, tactics, goals, types and the ⊢ symbol.
  6. Station 6Warm-up checkThree quick questions before you start the hike.

Steps 1–50 · The hike

Then climb the ten checkpoints

Follow the numbers on the map. Each checkpoint has five short lessons and earns one item for its Trail Guide.

  1. Lean as a calculatorSteps 1–5 · Lemmi
  2. Your first proofsSteps 6–10 · Tacto
  3. Logic, part oneSteps 11–15 · Goalie
  4. Logic, part twoSteps 16–20 · Typo
  5. Numbers & inductionSteps 21–25 · Indy
  6. Algebra with MathlibSteps 26–30 · Tacto
  7. Data & functionsSteps 31–35 · Lemmi
  8. Real mathematicsSteps 36–40 · Indy
  9. Logic puzzlesSteps 41–45 · Goalie
  10. Prove your programs workSteps 46–50 · Typo