Documentation overview
This page is intended to contain a complete overview of all documentation helpful for users of Mathlib and of Lean in general. We organize the documentation according to the Divio documentation system into four quadrants:
Tutorials are lessons that take you by the hand through a series of steps to complete a project of some kind.
How-to guides take you through the steps required to solve a real-world problem.
Reference guides are complete technical descriptions of the machinery and how to operate it.
Explanations clarify and illuminate a particular topic.
If you have some documentation and it is missing from the list, you can add it to documentation.yaml in the website repository. If you are missing documentation, you can request it on Zulip.
Filter by all tags:
Tutorials
- Natural Numbers Game
-
by Kevin Buzzard, Jon Eugster, Mohammad Pedramfar, Alexander Bentkamp, Patrick Massot
An online tutorial for everyone who wants to try out Lean. Proving elementary properties on natural numbers.
- elementary
- nonmathlib
- Glimpse of Lean
-
by Patrick Massot
An introduction to theorem proving in Lean for the impatient. Get a feel for proving real theorems in Lean in a few hours.
- analysis
- category theory
- elementary
- logic
- measure theory
- probability
- ring theory
- Mathematics in Lean
-
by Jeremy Avigad, Patrick Massot
The standard textbook on getting started with formalizing maths in Lean.
- analysis
- classes
- elementary
- group theory
- linear algebra
- measure theory
- ring theory
- topology
- Mechanics of Proof
-
by Heather Macbeth
Textbook on writing careful, rigorous mathematical proof. Aimed at readers with less mathematical experience than Mathematics in Lean.
- elementary
- nonmathlib
- Theorem Proving in Lean 4
-
by Jeremy Avigad, Leonardo de Moura, Soonho Kong, Sebastian Ullrich
Introductory textbook for Lean, more focussed on the foundations of type theory.
- classes
- elementary
- logic
- Logic and Proof
-
by Jeremy Avigad, Joseph Hua, Robert Y. Lewis, Floris van Doorn
Textbook on mathematical logic using Lean and natural deduction.
- elementary
- logic
- The equation compiler and WellFoundedRelation
-
by the Mathlib community
A walkthrough on the use of well-founded recursion to show termination of the
gcdalgorithm.- declarations
- tactics
How-to guides
- Mathlib Manual: Guides: Shared Mathlib installation
-
by Jon Eugster
A trick to not download different Mathlib installations for each of your Lean projects.
- development
- Mathlib Manual: Guides: Follow Stable Dependencies
-
by Jon Eugster
A trick to specify only stable releases of your dependencies in the Lakefile.
- development
- Mathlib Manual: Guides: Using local dev version of a dependency
-
by Jon Eugster
A trick to use local copies of a repository for development.
- development
- How to use calc
-
by the Mathlib community
A guide to writing computational proofs using the
calcenvironment.- tactics
- How to speed up a Mathlib file
-
by the Mathlib community
Tips and tricks to fix a file that compiles slowly.
- declarations
- tactics
- How to contribute to Mathlib
-
by the Mathlib community
How-to guide for contributors to Mathlib.
- development
- Git Guide for Mathlib4 Contributors
-
by the Mathlib community
How-to guide for making effective use of Git, focussed on contributing to Mathlib.
- development
- Pull Request Review Guide
-
by the Mathlib community
How to write a good review for pull requests to Mathlib. For everyone, not just members of the maintainer team.
- development
- library note [custom simps projection]
-
by the Mathlib community
How to register projections for the
@[simps]attribute.- tactics
- Setting up linting and testing for your Lean project
-
by the Mathlib community
How to add a linting and testing framework to a math project in Lean.
- development
- linters
- Formalizing mathematics: How to format your code well
-
by Bhavik Mehta
Guide to writing well-formatted Lean code according to the Mathlib style guidelines.
- development
Reference guides
- Lean 4 tactic cheatsheet
-
by the Mathlib community
Cheatsheet for the most common tactics.
- tactics
- incomplete
- Mathlib API documentation
-
by the Mathlib community
A complete listing of all definitions and theorems included with Mathlib.
- declarations
- Loogle
-
by Joachim Breitner
Search tool for Lean/Mathlib declarations.
- declarations
- Foundational types
-
by the Mathlib community
Documents the types built into the foundations of Lean.
- logic
- Lean Glossary
-
by the Mathlib community
Explanations of terminology one might encounter in the Lean community.
- classes
- declarations
- development
- linters
- logic
- tactics
- Mathlib Manual: Tactics
-
by the Mathlib community
Documentation on tactics included with Mathlib, including a complete index.
- tactics
- A mathlib overview
-
by the Mathlib community
A index of Mathlib organized by mathematical topic.
- declarations
- Undergraduate mathematics in Mathlib
-
by the Mathlib community
An index of undergraduate mathematical topics available in Mathlib.
- declarations
- 100 theorems
-
by the Mathlib community
Indexes which of Freek Wiedijk's 100 classical theorems have been formalized in Mathlib.
- declarations
- 1000+ theorems
-
by the Mathlib community
Indexes further famous theorems with formalization in Mathlib.
- declarations
- Maths in Lean: the natural numbers
-
by the Mathlib community
Overview of the theory of natural numbers in Lean and Mathlib.
- elementary
- Maths in Lean: linear algebra
-
by the Mathlib community
Overview of the theory of linear algebra in Mathlib.
- linear algebra
- Maths in Lean: Sets and set-like objects
-
by the Mathlib community
Overview of the theory of sets, lists and more in Mathlib.
- elementary
- Maths in Lean: Topological, uniform and metric spaces
-
by the Mathlib community
Overview of the theory of topology in Mathlib.
- topology
- Maths in Lean: category theory
-
by the Mathlib community
Overview of category theory in Mathlib.
- category theory
- Mathlib naming conventions
-
by the Mathlib community
Defines how Mathlib names declarations in a systematic way.
- declarations
- normative
- Library style guidelines
-
by the Mathlib community
Defines how to format code to contribute to Mathlib.
- development
- normative
- Documentation style guidelines
-
by the Mathlib community
Defines how to write documentation for your contributions to Mathlib.
- development
- normative
- Pull request title and description conventions
-
by the Mathlib community
Defines the writing style of text in a pull request for contributions to Mathlib.
- development
- normative
- The Lean Github ecosystem
-
by the Mathlib community
Overview of the development flow for branches in the Lean ecosystem.
- development
- Formalizing mathematics: Tactics
-
by Bhavik Mehta
Overview of the most important tactics made available by Mathlib.
- tactics
Explanations
- Tips and suggestions for teaching with Lean
-
by the Mathlib community
Strategies and approaches for teaching with Lean
- teaching
- The conversion tactic mode
-
by the Mathlib community
A guide to writing calculation proofs using the
convenvironment.- tactics
- Simplifier
-
by the Mathlib community
Basic usage and pitfalls for the
simpanddsimptactics.- tactics
- Common Lean Pitfalls
-
by the Mathlib community
How to avoid mistakes commonly made by Lean users.
- declarations
- tactics
- What is a quotient?
-
by Kevin Buzzard
How quotients work in Lean, compared to quotients in (naïve) set theory.
- elementary
- Division by zero in type theory: a FAQ
-
by Kevin Buzzard
Explains why Lean chooses to define that
1 / 0 = 0.- elementary
- library note [the algebraic hierarchy]
-
by the Mathlib community
Explains the structure of the algebraic hierarchy and how to add new elements to it.
- classes
- library note [reducible non-instances]
-
by the Mathlib community
Definitions that cannot be instances should be made reducible.
- classes
- library note [implicit instance arguments]
-
by the Mathlib community
Some places prefer implicit
{}brackets for typeclass arguments instead of typical instance[]brackets.- classes
- library note [lower instance priority]
-
by the Mathlib community
When creating an instance that always applies, give it a lower priority.
- classes
- library note [instance argument order]
-
by the Mathlib community
A trick to speed up typeclass instance synthesis by putting more specific goals first.
- classes
- library note [SetLike Aesop ruleset]
-
by the Mathlib community
How to add rules about
SetLikemembership to Aesop.- elementary
- tactics
- library note [no_index around OfNat.ofNat]
-
by the Mathlib community
Write
ofNat(n)in lemmas instead ofOfNat.ofNat n.- elementary
- library note [coercion into rings]
-
by the Mathlib community
How to set up coercions from a concrete structure like
ℕto an arbitrary ringR.- ring theory
- library note [RCLike instance]
-
by the Mathlib community
An instance creating a goal
[RCLike ?m]is okay since there are only two choices,ℝorℂ.- analysis
- classes
- library note [fact non-instances]
-
by the Mathlib community
We do not declare any global instances of the
Facttypeclass.- classes
- library note [decidable namespace]
-
by the Mathlib community
The
Decidablenamespace contains theorems that avoid the use of the Law of Excluded Middle by usingDecidableinstances instead.- declarations
- library note [decidable arguments]
-
by the Mathlib community
If a
Decidablehypothesis is not needed for the type signature of a theorem or lemma, useclassicalinstead.- declarations
- library note [slow-failing instance priority]
-
by the Mathlib community
Instances that would be slow to fail to apply should have a lower priority.
- classes
- library note [foundational algebra order theory]
-
by the Mathlib community
Batteries sets up the algebraic and order theoretic properties of
NatandInt; Mathlib replaces this with a typeclass-based system.- elementary
- library note [continuity lemma statement]
-
by the Mathlib community
How to write more useful continuity lemmas.
- topology
- library note [comp_of_eq lemmas]
-
by the Mathlib community
How to avoid elaboration problems when writing the continuity of a composition.
- topology
- library note [IMO geometry formalization conventions]
-
by the Mathlib community
Conventions for formalizing geometry problems from the IMO as part of Mathlib's Archive.
- euclidean geometry
- library note [change elaboration strategy with `by apply`]
-
by the Mathlib community
A trick to elaborate a term and its type in a different order.
- tactics
- library note [pointwise nat action]
-
by the Mathlib community
The action of natural numbers or integers on sets takes precedence over pointwise actions.
- elementary
- library note [Design choices about smooth algebraic structures]
-
by the Mathlib community
Mathlib's design choices about smooth algebraic structures
- differential geometry
- library note [Manifold type tags]
-
by the Mathlib community
Explains why
ModelProdandModelPiexist.- differential geometry
- library note [non-Archimedean non-instances]
-
by the Mathlib community
Why non-Archimedean subgroup basis lemmas cannot be instances.
- topology
- library note [range copy pattern]
-
by the Mathlib community
The image of a morphism
fis defined usingSet.rangeif possible, notmap ⊤ f.- group theory
- linear algebra
- ring theory
- library note [continuous functional calculus]
-
by the Mathlib community
Design overview of the ontinuous functional calculus in Mathlib.
- analysis
- library note [specialised high priority simp lemma]
-
by the Mathlib community
When not to un-
@[simp]a lemma in favour of a more powerful version.- tactics
- library note [out-param inheritance]
-
by the Mathlib community
Limitations on the interaction of typeclass inheritance and
outParams.- classes
- library note [lower cancel priority]
-
by the Mathlib community
Inheritance from cancellative algebraic structures gets a lower priority.
- classes
- library note [forgetful inheritance]
-
by the Mathlib community
Design pattern for typeclass inheritance where we include all fields, even if they can be inferred.
- classes
- library note [hom simp lemma priority]
-
by the Mathlib community
Widely applicable
@[simp]lemmas should receivemidpriority.- classes
- tactics
- library note [CategoryTheory universes]
-
by the Mathlib community
Design patterns for ordering the universe levels in category theory declarations.
- category theory
- declarations
- library note [operator precedence of big operators]
-
by the Mathlib community
The choice of operator precedence for
∏and∑operators in Mathlib.- group theory
- library note [bundled maps over different rings]
-
by the Mathlib community
A design trick for when bundled maps have stronger properties if certain typeclass assumptions are satisfied.
- group theory
- linear algebra
- Computation models for polynomials and finitely supported functions
-
by the Mathlib community
An overview of potential (re)implementations for computable polynomials in Mathlib.
- logic
- ring theory
- Tradeoffs of concrete types defined as subobjects
-
by the Mathlib community
Reasons to prefer defining something as a custom structure, a coercion to
Type, or a subobject.- declarations
- classes
- Formalizing mathematics: Types and terms
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- logic
- Formalizing mathematics: Equality
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- logic
- Formalizing mathematics: The three kinds of types
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- logic
- Formalizing mathematics: Brackets in function inputs
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- declarations
- Formalizing mathematics: Notation and precedence
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- declarations
- Formalizing mathematics: Structures
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- declarations
- Formalizing mathematics: Classes
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- classes
- Formalizing mathematics: Dot notation
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- declarations
- Formalizing mathematics: Coercions
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- declarations
- Formalizing mathematics: The axiom of choice
-
by Bhavik Mehta
Lecture notes for a course on formalizing mathematics, focussing more on the design choices made when formalizing.
- logic