This is a course on the Lean proof assistant that I am giving at Dalhousie University in Fall 2026. The course focuses on using Lean for mathematics. We start from the foundations — dependent type theory, propositions as types, and inductive types, developed from scratch — before moving on to tactics, Mathlib, and proofs of real theorems. Daniel Teixeira is the teaching assistant for this course, and he helped develop many of the materials, including the homeworks and projects.
If a “+” sign appears after a lecture below, you can click on it to see a list of Lean topics covered in the lecture, with links to the relevant documentation.
This is the public website for the course. For students taking the course, grades, assignments, and announcements stay on Brightspace.
Textbooks
We are using two online textbooks, both free.
-
Theorem Proving in Lean 4
— Avigad, de Moura, Kong, and Ullrich -
Mathematics in Lean
— Avigad and Massot
Lecture Notes
These files use the Unicode character set and are UTF-8 encoded. If your browser does not display them correctly, download the files instead — Lean Web or VS Code will know what to do with them.
- Sep 8 pdf Lean design and first steps
- Sep 8 lean First steps
- Lean as a calculator:
#eval - Definitions with
def - Every expression has a type:
#check,Nat,Bool - A first look at namespaces
- Lean as a calculator:
- Sep 10 lean Name spaces, simple types, products, functions
- Namespaces:
namespace,end,open - Types as objects
- Cartesian products
A × B, pairs,.1and.fst - Typing Unicode symbols:
\x,\r,\all,\ex,\a - Functions and lambda abstraction:
fun x => x + 5 - Definitions with a type:
def f : A → B := …; curried vs. uncurried functions
- Namespaces:
- Sep 15 lean Polymorphism, implicit arguments, dependent function types
set_optionand#print- Polymorphic functions: types as arguments
- Wildcards
_and implicit arguments{A : Type} - Dependent function types
(a : A) → B a - Lists:
List α,[],List.length; metavariables - Types that depend on values:
if…then…else
- Sep 17 pdf First steps in logic
- Sep 17 lean Variable declarations, universes, first steps in logic
variabledeclarations andsection- Universes:
Type,Type 1, … - Propositions:
Prop,∧,∨,¬,→ - Postulating the rules of logic with
axiom; the BHK interpretation - Reading the goal: hypotheses,
⊢, and the expected type
- Sep 22 pdf Propositions as types
- Sep 22 lean Propositions as types
sorryas a placeholder;noncomputablePropas a universe: the Curry–Howard correspondencetheoremvs.def- Conjunction:
And.intro,And.left,And.right - Disjunction:
Or.inl,Or.inr,Or.elim
- Sep 24 lean More on propositional logic
- Dot notation
h.left,h.1, and anonymous constructors⟨x, y⟩ haveandshowin term mode- True and False:
False.elim,trivial;example - Negation:
¬pmeansp → False;absurd - Classical logic:
Classical.em,#print axioms - If and only if:
↔,Iff.intro
- Dot notation
- Sep 29 pdf Topological interpretation of propositional intuitionistic logic, and the BHK interpretation of quantifiers
- Sep 29 lean Quantifiers
- The universal quantifier
∀ x : A, P xas a dependent function type - The existential quantifier:
Exists.introand witnesses - The BHK interpretation of the quantifiers
- The universal quantifier
- Oct 1 lean Equality and inductive types
- Equality:
Eq.refl,rfl,Eq.symm,Eq.trans - Leibniz’s law:
Eq.subst, themotive, and▸ - Chains of equations with
calc - Inductive types: defining our own natural numbers with
inductive - Recursive functions and definitional equality
- Equality:
- Oct 6 lean Inductive types, continued
congrArg- The recursor
N.rec: recursion and induction in one - Parameterized inductive types: our own lists
L α - Proofs by induction about
appendandlength - Notations:
notation,infix,infixl,infixr,prefix,postfix
- Oct 8 lean Parameters and indices, inductive predicates
- Parameters vs. indices
- Inductive predicates:
Even n - Pattern matching on proofs with
match; impossible cases withnomatch - Logical connectives as inductive types:
Prod,And,Or
- Oct 13 lean Structures
FalseandExistsas inductive types- Structures:
structure, constructors, projections - Creating and updating structure values:
⟨…⟩,where,{ p with … } - Destructuring with
let ⟨x, y⟩ := p - Groups as (bundled) structures;
Group : Type 1
- Oct 15 lean Type classes
- Unbundled structures
- Inheritance with
extends - Type classes:
classandinstance - Chaining instances, e.g., for products
- Mathematical structures as type classes: monoids
- Oct 20 lean Introduction to tactics
- What is a tactic? Entering tactic mode with
by - Basic tactics:
exact,assumption,intro,intros,apply - Searching for a lemma:
apply? - Conjunction:
constructor,obtain, and the focusing dot· - Disjunction:
left,right,rcases - Equality:
rfl,rw, rewriting right-to-left with←
- What is a tactic? Entering tactic mode with
- Oct 22 lean Tactics, decidability
- The existential quantifier:
exact ⟨n, h⟩,obtain, and Mathlib’suse contradiction- Rewriting with library lemmas;
rw … at h - Decidability: the
decidetactic, theDecidabletype class, and defining our own instances #reduce; finding class instances with#synth
- The existential quantifier:
- Oct 27 lean More tactics
import Mathlib- The simplifier:
simp,simp?,simp only - Decision procedures:
omega,decide - Induction and case analysis:
induction,cases - Structuring proofs:
have,show,calc - Combinators:
<;>,repeat,try,first,all_goals - More tactics:
rintro,refine,specialize - Classical reasoning:
by_cases,by_contra,push Not - Automation:
norm_num,linarith,nlinarith
- Oct 29 lean Tactic examples, Mathlib naming conventions
- Which automation to use when:
rfl,decide,omega,norm_num,simp,exact? - Algebra:
ring,linarith,nlinarith,field_simp,positivity - Mathlib, the community library
- Mathlib naming conventions:
add_comm,sub_nonneg,_of_, …
- Which automation to use when:
- Nov 3 lean Finding things in Mathlib, some real theorems
- Guessing the name of a lemma
- Letting Lean search:
exact?,apply?,rw?,simp?,hint - Searching by shape: Loogle
- Searching by words: LeanSearch
- Reading the source: the Mathlib documentation and “go to definition”
- Examples: a theorem in group theory; sums with
Finset.sum_range_succ
- Nov 5 lean Convergent sequences, AI demo
- Stating theorems well
- Convergence of sequences:
s : ℕ → ℝ,ConvergesTo s a useandcongr- Using AI to fill in the
sorrys of a proof outline
Reading Assignments
The reading assignments are from Theorem Proving in Lean 4 (TPIL) and Mathematics in Lean (MIL).
- Sep 10 TPIL Chapters 1+2
- Sep 15 TPIL Chapter 3
- Oct 1 TPIL Chapters 4+7
- Oct 15 TPIL Chapters 5, 8-10
- Nov 2 MIL Chapters 1-3
Homework
Projects
Project 1 due Oct 29
Choose one of three options:
Project 2 due Dec 1
Choose one of four options:
Installing VS Code and Lean
Quick links:
- Lean Web — run Lean and Mathlib right in your browser, no install required (needs an internet connection)
- Download VS Code
Step-by-step videos: