Learn Lean by writing code and proofs.
Start with a calculation you can prove. Work up to logic, induction and verified programs through 130 short lessons. Write your own Lean code, check it, and learn from the result.
- 38 lessons free
- 130 exercises
- Lean 4.30 compiler
- Browser based no setup
Try it here. A test can reverse a few lists twice and compare. Lean can show it holds for every list, including ones nobody has written yet. Type simp in the editor and press Check.
The goal: for any list of numbers xs, reversing it twice gives xs back.
The course, in order
13 courses in 5 stages. Each one builds on the one before it. The first 3 are free; if you already know the early material, start wherever you need. See every lesson on one page →
- 1
Start here
Lean as a language, the first proof tactics, and propositional logic.
- Lean foundationsValues, types and functions, your own data types, and the first proofs about them.FreeStart
- Your first Lean proofsRead a goal, take a proof step, and let Lean check your reasoning.FreeStart
- Propositional logicAnd, or, not and if-and-only-if, then excluded middle and proof by contradiction.FreeStart
- 2
Proof techniques
Quantifiers, rewriting, simp, omega and calc, and proofs written as terms.
- QuantifiersStatements about every number and about some number.PassView
- Rewriting and automationrw, simp, decide, omega and calc.PassView
- Proof terms and Curry–HowardProofs are programs. Write them directly as terms.PassView
- 3
Programs and induction
Recursive programs, induction on numbers, lists and trees, and specifications you prove.
- Functional programmingFunctions as values, structured data, recursion, termination, and type classes.PassView
- Induction on numbers and listsProve facts about every natural number and every list.PassView
- Programs with proofsWrite a specification, then prove the program meets it.PassView
- Inductive types and case analysisModel your own data, then reason about every shape it can take.PassView
- 4
Natural Number Lab
Arithmetic built from zero and successor, through order and divisibility.
- The Natural Number LabAddition, multiplication, powers, order and divisibility, proved from zero and successor.PassView
- 5
Advanced proofs and effects
Proof-carrying data, length-indexed vectors, monads and their laws.
- Advanced functional proofsLaws for map, filter and fold, evidence carried in data, and lengths checked by the type.PassView
- Monads and effectsOption, Except, state and IO, the Monad class, and proofs of the monad laws.PassView
Questions
Do I need to install Lean?
No. The course editor runs in the browser and sends checks to Lean 4.30. You can install Lean locally later without changing the language or tactics you learned here.
Is this Mathlib?
The exercises use Lean’s core library so that they run fast and teach the language itself. Every tactic covered (rw, simp, omega, induction, obtain, calc …) is the same one you will use with Mathlib.
When is an exercise complete?
The proof must compile without errors or sorry. Completion is then saved to your account.
What happened to the previous Lean 4 course?
Its material now belongs to the Academy sequence. Lean foundations contains the free introduction; Functional programming contains the later programming, recursion and type-class lessons.