The Stacks Project, formalized in Lean

The Stacks Project is an open-source textbook and reference work on algebraic geometry, about 7,500 pages written collaboratively over two decades. Every definition, lemma and theorem in it carries a permanent tag: Nakayama’s lemma is 00DV.

Here the whole project is formalized in Lean on top of Mathlib, as one library built with reusability in mind. Our formalizations of the Weil conjectures, Faltings’ theorem and the minimal model program are built on it. The blog post tells the full story.

Lean files
—
Declarations
—
Lines of Lean
—

Dependency graph

TheoremPropositionOther
Dependency edge colours Both
?

The Stacks Project

The Weil conjectures, Faltings’ theorem and the minimal model program

Projects built on Stacks, standing beside the book. Choose one in the project menu to zoom on it. Each Lean declaration that carries a blueprint label is one square, grouped by the repository’s folders. Choose a folder in the menu next to it to zoom in. Click a declaration to see it in the middle, with the declarations it depends on, in the project or in Stacks, to its left and the ones that depend on it to its right.

Library

?

Every tag of the Stacks Project, listed by chapter and section. Select one to read the Stacks statement beside the Lean code that proves it.

Green tags were already in Mathlib and red tags were judged not to apply to Lean. The rest are formalized here, or partly formalized where the library says so.

When several Lean declarations carry one tag, each proves a part of it and has its own tab above the code.

Select a tag to view its Lean source and dependencies.

Built with Stacks

Lean projects that use the Stacks library.

The Weil conjectures

All four Weil conjectures, including Deligne’s Riemann hypothesis, following Freitag and Kiehl’s Étale Cohomology and the Weil Conjecture.

About 213,000 lines of Lean, drawing on 730 modules of the Stacks library.

Faltings’ theorem

The Mordell conjecture for curves of genus at least two over number fields, following Bombieri’s The Mordell conjecture revisited.

About 124,000 lines of Lean, drawing on 336 modules of the Stacks library.

The minimal model program

The minimal model program for log canonical pairs in dimension at most four, following OpenAI’s Termination for projective log canonical fourfolds with rational boundary, Kollár and Mori’s Birational Geometry of Algebraic Varieties, and Kollár et al.’s Flips and Abundance for Algebraic Threefolds.

About 2,054,000 lines of Lean, drawing on 1,536 modules of the Stacks library.

Contributing

We welcome contributions from anyone interested in formalizing the Stacks Project. The goal is for people to review, polish, build upon, use and adapt this code, and eventually to upstream as much of it as is reasonable to Mathlib.

How to contribute

The library, Stacks, has two parts. StacksCore is code that a person has checked against the Stacks Project and brought up to Mathlib standards. StacksFrontier is code written by AI agents that has not had that review yet. Lean checks every proof in both.

You can help in five ways:

  1. Formalize an open exercise, example or remark from the list below.
  2. Review code in StacksFrontier and move it into StacksCore.
  3. Formalize a result directly for StacksCore.
  4. Take on one of the projects below.
  5. Improve an existing proof.

Claim new formalizations and reviews before you start, so that two people do not do the same thing.

  1. ClaimCheck the open claims, then open a claim with a blueprint: the exact statement, the Lean statement you intend to prove, the declarations in this library or in Mathlib that you will use or extend, and a proof outline. The task board pre-fills it for you.
  2. Get it approvedA maintainer reviews the blueprint. When it is approved, the issue is labelled blueprint-approved and assigned to you: that is your claim.
  3. FormalizeWrite the Lean code with @[stacks TAG] on the declaration, and open a pull request that closes the issue.

Improvements to existing proofs and small fixes (typos, broken proofs, documentation) need no claim: open a pull request directly. Every pull request, to either tier, is reviewed by the maintainers: Kenny Lau, Brian Nugent, Ashvin A. Swaminathan and Yunzhou Xie.

Formalization tasks

Loading tasks…

Propose a task

Check open issues before submitting.

Open on GitHub

Cite this work