FunctorialAcademySign in

Functorial Academy · Start here

Lean 4 for Programmers

From your first definition to specifications an AI can prove.

Lean 4 is a programming language whose type checker can also check proofs. You will learn it the way you learned your last language: by writing small functions and reading what the compiler says. Then you will learn the part that matters most now that an AI can write proofs: stating exactly what a function must do. You write the specification. The AI proves it or finds a counterexample. Lean checks both.

Start freeEnter your email and we send you a six-digit code. No password. A new address gets a new account.
  • 9 units
  • 105 exercises
  • Checked by real Lean 4
  • Free

The path

For working programmers. You know a mainstream language. You need no Lean and no experience with proofs.

  1. Terms and types. Everything in Lean is a term with a type. Ask Lean what things are, and run some code.
  2. Data and recursion. Functions by cases, recursion that Lean can see will stop, and types you define yourself.
  3. Propositions are types. A statement is a type and a proof is a program of that type. Tests run at compile time, and one test is not a specification.
  4. Tactics for logic. And, or, not, for all, there exists: how to prove each one and how to use each one.
  5. Rewriting and automation. Replace equals with equals, then let Lean's automation do the routine steps.
  6. Induction. A recursive function gets a proof by induction. On numbers first, then on lists.
  7. Types that carry proofs. Put the precondition in the type and the bug can't be written. Subtypes, bounded indices, and functions that provably stop.
  8. Specifying functions. A specification is a proposition about an implementation. Write one tight enough that the right function satisfies it and no wrong one does.
  9. Specs you can hand off. Sorting, searching, round trips and preconditions. You write the statement, the AI writes the proof, Lean checks it.
Start freeEnter your email and we send you a six-digit code. No password. A new address gets a new account.