Free course · Beginner

Lean 4: Proofs a Computer Can Check

Write Lean 4 code and proofs that a computer checks, starting from zero.

  • 5 modules
  • 16 lessons
  • About 64 min of reading
  • Beginner
  • A coding problem in every lesson
  • Quizzes, final exam and certificate

What you will be able to do

Write small Lean 4 programs, prove statements about numbers and lists step by step while watching the goal view, find lemmas in Mathlib, and read a real theorem statement well enough to check it against a paper. Here is the kind of proof you will write by lesson 10, with the goal Lean shows after each step:

theorem and_swap_tac (p q : Prop) : p ∧ q → q ∧ p := by
  intro h        -- h : p ∧ q    ⊢ q ∧ p
  constructor    -- two goals: ⊢ q  and  ⊢ p
  · exact h.2   -- first goal closed
  · exact h.1   -- No goals

Every code block in the course was compiled with Lean 4, and the examples that show an error were checked to fail with that error. You can follow along in the online playground without installing anything.

What you will learn

  • What a proof assistant is, how to install Lean, and how types work.
  • Write functions, define your own types, and use recursion that Lean accepts.
  • See how a proof is just a value, and prove and, or, for all and exists statements.
  • Prove things step by step with tactics, rewriting and induction.
  • Find lemmas in Mathlib, read real theorem statements, and check one against a paper.

Curriculum

5 modules, 16 lessons. Each lesson is a short article, a hands-on problem you solve in the browser, and a 3-question quiz. See the day-by-day study plan.

1Why Lean3 lessons · 10 min

What a proof assistant is, how to install Lean, and how types work.

  1. 1Why Mathematicians Let a Computer Check Their Proofs: Meet LeanLesson 1 · 4 min read · Easy problem · quiz
  2. 2Set Up Lean 4 and Talk to It With #eval and #checkLesson 2 · 3 min read · Easy problem · quiz
  3. 3Every Lean Expression Has a Type, and Type Errors Are Your FriendLesson 3 · 3 min read · Easy problem · quiz
Module 1 practice test →
2Programming in Lean3 lessons · 10 min

Write functions, define your own types, and use recursion that Lean accepts.

  1. 4Writing Functions in Lean: def, fun, Curly Braces and matchLesson 4 · 4 min read · Easy problem · quiz
  2. 5Build Your Own Nat: How Inductive Types Define Data in LeanLesson 5 · 4 min read · Medium problem · quiz
  3. 6Why Lean Refuses a Function That Might Never StopLesson 6 · 2 min read · Medium problem · quiz
Module 2 practice test →
3Propositions as Types3 lessons · 12 min

See how a proof is just a value, and prove and, or, for all and exists statements.

  1. 7A Proof Is Just a Value: Propositions as Types in LeanLesson 7 · 4 min read · Easy problem · quiz
  2. 8And, Or, Implies: Building Proofs Like Data in LeanLesson 8 · 4 min read · Medium problem · quiz
  3. 9For All, There Exists, and Equals: Lean's Three Workhorse StatementsLesson 9 · 4 min read · Medium problem · quiz
Module 3 practice test →
4Tactic Proofs4 lessons · 16 min

Prove things step by step with tactics, rewriting and induction.

  1. 10Tactic Mode in Lean 4: Proving Step by Step With the Goal ViewLesson 10 · 4 min read · Easy problem · quiz
  2. 11rw vs simp in Lean 4: Rewriting Goals Without Losing TrackLesson 11 · 4 min read · Medium problem · quiz
  3. 12Why Lean Accepts n + 0 = n but Not 0 + n = n: Induction on NatLesson 12 · 4 min read · Medium problem · quiz
  4. 13Proving Facts About Lists in Lean 4: Append, Length and Reverse TwiceLesson 13 · 4 min read · Medium problem · quiz
Module 4 practice test →
5Reading Real Lean3 lessons · 16 min

Find lemmas in Mathlib, read real theorem statements, and check one against a paper.

  1. 14Finding the Lemma You Need in Mathlib: Names, exact? and LoogleLesson 14 · 5 min read · Easy problem · quiz
  2. 15Lean Accepted It. Is It True? How to Read a Theorem StatementLesson 15 · 5 min read · Medium problem · quiz
  3. 16Lean Proved It. Did It Prove What the Paper Says?Lesson 16 · 6 min read · Hard problem · quiz
Module 5 practice test →

Finish the course

Pass the lesson quizzes, then take the final exam and submit the capstone project. Your Certificate of Completion is issued once you pass both.

The Certificate of Completion is issued by BlogLLM. It is not an accredited qualification and it is not affiliated with any university or vendor.