← Back to all reports

Math

The Stacks Project, Formalized

How Swarms of AI Agents Checked a 7,500-Page Math Encyclopedia Without Missing a Single Step

Discover how Axiom Math used coordinated AI agents and the Lean 4 proof checker to turn a 7,500-page tower of modern geometry into 16 million lines of 100% bug-free computer code—and even caught hidden mistakes in the textbook.

1. The Big Idea (In 30 Seconds)

Imagine a math textbook so massive that if you printed it out on standard notebook paper, the stack would be over two feet tall—about 7,500 pages of some of the hardest geometry on Earth. On November 4, 2026, researchers at Axiom Math announced that coordinated swarms of AI agents translated that entire encyclopedia—called The Stacks Project—into 15.75 million lines of computer-checked code in a system called Lean 4, creating the largest bug-free library of advanced mathematics in human history.

2. The Problem: Why Do We Even Need This?

At first, equations and shapes look like two totally different worlds: x2+y2=1x^2 + y^2 = 1 is an algebra puzzle made of numbers and plus signs, while a circle is a round shape you draw with a compass. Over the last century, legendary mathematicians like Emmy Noether and Alexander Grothendieck built a secret dictionary connecting those two worlds—a field called algebraic geometry. That dictionary is how mathematicians proved Fermat’s Last Theorem (a puzzle that stumped humanity for 358 years) and how your phone locks up secret messages using elliptic curve cryptography.

But there was a giant problem: to reach the top of that math tower, you had to climb through thousands of pages of old 1960s French lecture notes and unwritten “math folklore” passed down in whispers from professors to students. So in 2005, Columbia University professor Johan de Jong started The Stacks Project—an open-source online math encyclopedia built like software, where hundreds of mathematicians wrote down every step and gave every single rule a permanent four-character license plate called a tag (like 00DS or 0F2W).

Even with 7,500 pages of careful human writing, though, human brains have a limit. When people write proofs, we skip “obvious” steps, accidentally forget special rules for weird number systems, and can’t possibly read millions of lines of new AI-generated math by hand. Worse, until now, computers couldn’t check new breakthroughs in modern geometry because no computer had the 7,500-page foundation loaded into its brain!

3. How It Works (Step-by-Step)

Think of The Stacks Project as the world’s biggest instruction manual for building a giant LEGO metropolis, where every new skyscraper rests on thousands of smaller LEGO bridges, arches, and baseplates built in earlier chapters.

Here is how Axiom Math turned 7,500 pages of human math into 15,751,904 lines of machine-verified LEGO bricks:

  1. Step 1 — The Unforgiving Referee (Lean 4’s Kernel): If you write a math essay for a human teacher, you can write “It is easy to see that these two pieces fit,” and the teacher might nod along. A computer program called Lean 4 is like a physics engine for LEGOs where pieces either click together 100% or refuse to connect at all. Every single proof must trace all the way down to basic logic rules, with zero “trust me” shortcuts (in Lean, a skipped proof is marked with the word sorry—and this library has zero sorrys across all 62,975 files).
  2. Step 2 — Solving the “Incompatible LEGO Stud” Problem (Coordinated AI Swarms): What happens if you tell 1,000 AI agents to translate 7,500 pages at the same time without talking to each other? Agent A might build a metric-sized LEGO stud for Chapter 10, while Agent B builds an inch-sized stud for Chapter 11. Both pass inspection alone, but when Chapter 12 tries to snap them together, the whole tower crashes! Axiom built a hierarchical swarm of specialized AI agents that searched Lean’s existing community library (Mathlib) first and enforced shared blueprints so all 663,090 math declarations snap together cleanly.
  3. Step 3 — Permanent License Plates (@[stacks TAG]): Every time an agent finished proving a rule in Lean, it stamped the code with the exact four-character tag from Johan de Jong’s textbook (like @[stacks 00DS]). Out of 16,249 formalizable tags, 1,377 were already in Mathlib and 14,872 were newly formalized or refined—connected by 855,576 formal dependency wires (nearly 20 times more connections than the 43,355 citations written in the human book!).
  4. Step 4 — Catching Fake Translations (Multi-Agent Auditing): How do you stop a clever AI from “cheating” by translating a super-hard geometry theorem into 1+1=21 + 1 = 2 (which is true, but useless)? First, separate auditor agents cross-check the computer statement against the English text. Second, the dependency tower itself acts as a lie detector: if Chapter 37 proves the wrong statement, then Chapter 50—which needs Chapter 37’s exact brick to hold up its roof—will immediately fail to compile!
  5. Step 5 — Self-Healing Math (Counterexamples & Repairs): When an AI agent couldn’t prove a statement from the book, it didn’t just give up. It switched into detective mode, built a mathematical counterexample to prove why the book’s sentence broke in an extreme case, figured out the exact missing rule needed to fix it, and found a detour so the rest of the skyscraper could still stand!
  6. Step 6 — The Two-Room Library (StacksCore & StacksFrontier): To keep the library organized for humans, Axiom split it into two rooms: StacksFrontier (the fast-growing room written by AI agents and 100% checked by Lean’s referee) and StacksCore (the polished room where human mathematicians have double-checked every name and style rule to match Mathlib).
flowchart TD
    A["📖 The Stacks Project Textbook<br/>(7,500 pages • 115 chapters • 17,269 tags)"] --> B["🤖 Coordinated AI Agent Swarm<br/>Checks Mathlib first & aligns shared 'LEGO studs'"]
    B --> C{"⚖️ Lean 4 Kernel Referee<br/>(Zero 'sorry' shortcuts allowed)"}
    C -- "Proof clicks together!" --> D["🔍 Multi-Agent Faithfulness Audit<br/>Does it match the English text & support upper floors?"]
    C -- "Proof gets stuck!" --> E["🕵️ Detective Mode<br/>Build a machine-checked counterexample<br/>+ add missing rule or find a proof detour"]
    E --> C
    D --> F["🏛️ Unified Lean Library (15.75M Lines)<br/>StacksFrontier (AI-built) ➔ StacksCore (Human-polished)"]

4. Wait, Really?! (Mind-Blowing Facts & Edge Cases)

  • The AI Found Real Blind Spots in a 20-Year-Old Masterpiece!: Even though hundreds of professional mathematicians contributed to The Stacks Project over 21 years, Axiom’s agents uncovered dozens of statements that needed repair (including 30 tags flagged as wrong, conditional, or partial). For example, in Tag 0F2W (Chapter 37), the book claimed that if you cover any geometric space (called a scheme) with n+1n + 1 simple flat patches, you can slice it into at most nn clean layers. The AI agents discovered the author forgot one crucial word: the space must be separated ([X.IsSeparated]—meaning it doesn’t have weird “double points” glued together like a road that splits into two identical origins)!
  • Clock-Arithmetic Traps (Tag 03SS): Many geometry rules work great with ordinary numbers, but act strangely in finite fields—number systems that wrap around like a clock with a prime number of hours (pp). In Tag 03SS (Chapter 64, The Trace Formula), a remark about a symmetry map called the geometric Frobenius overlooked what happens when the same geometric object lives over two different-sized finite clocks at once (like a 2-element clock F2\mathbb{F}_2 and a 4-element clock F4\mathbb{F}_4). The AI agents built a complete, machine-checked counterexample using F2\mathbb{F}_2 and F4\mathbb{F}_4 right inside the code!
  • Why Human Books Hide 95% of the Wires: In the original English Stacks Project, human authors wrote down 43,355 citation links between tags. When translated into Lean 4, the computer uncovered 855,576 tag-to-tag dependency links—almost 20 hidden wires for every 1 link a human wrote down! Why? Because when a human mathematician writes a 10-line proof, their brain silently uses dozens of basic rules about sets, rings, and fractions without ever mentioning them out loud.
  • Respecting the “No AI Pull Requests” Rule: On October 21, 2026—just two weeks before Axiom’s release—Stacks Project creator Johan de Jong posted a polite note on his blog titled “No AI for now,” asking people not to flood his handmade website with AI-generated comments or code patches. Axiom respected his boundary 100%: instead of spamming the original project, they published their Lean code and counterexamples in an independent open-source library (stacks.axiommath.ai) where human mathematicians can browse them side-by-side at their own pace.

5. Grown-Up Words Unlocked (Mini Glossary)

  • Formalization (for-muh-lih-ZAY-shun): Translating math written in everyday human sentences into strict computer code so a proof-checking program can verify that every single step follows the rules of logic with zero gaps.
  • Scheme (SKEEM): A master invention by mathematician Alexander Grothendieck that lets you turn any system of algebra rules (called a ring) into a geometric shape you can zoom in on—even in weird number systems where numbers wrap around like a clock.
  • Algebraic Stack (al-juh-BRAY-ik STAK): A super-powered geometric space that doesn’t just keep track of points and shapes, but also remembers the hidden symmetries (like rotations or flips) of every object inside it.
  • sorry (in Lean 4) (SOR-ee): A special placeholder word in the Lean programming language that says “Pretend I proved this step for now”—useful while drafting, but completely banned (0 occurrences) in a finished verified library.
  • Counterexample (KOWN-ter-ig-zam-pul): A single, concrete test case that proves a general math claim is false as written—like proving “All birds can fly” is false by pointing to one penguin.

6. Dinner Table Test

“Mathematicians have a legendary 7,500-page online encyclopedia called The Stacks Project that explains how algebra equations and geometric shapes are secretly the same thing. Normally, it would take humans centuries to translate a book that huge into computer-checked code, because if two translators define a shape slightly differently, their pieces won’t snap together. A team at Axiom Math coordinated swarms of AI agents to translate all 7,500 pages into nearly 16 million lines of Lean 4 code with zero skipped steps—and the computer referee was so strict that the AI agents even caught dozens of hidden edge cases that human mathematicians missed over the last 20 years!”


7. Deep-Dive Reference: Architecture, Metrics & Formal Verification Audit

Below is the technical synthesis and quantitative breakdown of Axiom Math’s AxiomMath/Stacks repository (commit f8e70c5d, Lean v4.34.0-rc2, released November 4, 2026) and its structural mapping to Johan de Jong’s Stacks Project.

1. Corpus Scale & Dependency Graph Metrics

When informal mathematical prose is mechanized in dependent type theory (Lean 4’s Calculus of Inductive Constructions), implicit background lemmas and typeclass coercions become explicit nodes and edges in the compilation graph:

Quantitative Comparison: Informal Stacks Project vs. Lean 4 Formalization (Release f8e70c5d)
Dimension Informal Stacks Project (LaTeX) Formalized Stacks Library (Lean 4) Expansion / Mechanization Ratio Architectural Significance
Total Corpus Size ~7,500 PDF pages (115 chapters) 15,751,904 lines of Lean code across 62,975 files ~2,100 lines of Lean per textbook page Largest single integrated, machine-checked mathematical codebase ever built.
Mathematical Units (Tags vs. Declarations) 17,269 total tags (16,249 formalizable mathematical statements/definitions) 663,090 Lean declarations (373,267 carrying cross-references) ~40.8 Lean declarations per formalizable tag A single informal tag unfolds into multiple auxiliary definitions, typeclass instances, and helper lemmas.
Coverage Breakdown 12,379 lemmas, 1,688 definitions, 323 propositions, 212 theorems, 974 remarks 14,842 tags newly formalized in Stacks + 1,377 tags bridged via Mathlib + 30 refined/audited 100% of formalizable tags addressed (16,249 / 16,249) Also cross-tagged with Grothendieck's EGA (@[ega ...]) and SGA (@[sga ...]) numbering.
Dependency Graph Edges (DAG) 43,355 explicit natural-language tag citations 855,576 formal Lean tag-to-tag dependency edges (18,018 shared directly) 19.7x more formal dependencies than human citations Exposes "silent" foundational dependencies (algebraic hierarchy, universe polymorphism, sheafification) omitted in prose.
Axiomatic & Kernel Integrity Human peer review & community comments 0 sorry, 0 native_decide; standard axioms only (propext, Classical.choice, Quot.sound) 100% kernel-verified Eliminates proof gaps and unverified computational reflection across all 62,975 modules.

2. Representative Mathematical Obstructions, Counterexamples & Repairs

During full-graph formalization, Axiom’s agents identified 30 tags (6 wrong, 9 conditional, 15 partial) where the canonical prose statement failed in full generality or required strengthened hypotheses. Rather than halting, the pipeline isolated the mathematical obstruction, proved an explicit counterexample or repaired theorem, and re-routed downstream dependencies:

Selected Formal Verification Audits & Counterexamples in AxiomMath/Stacks
Stacks Tag & Status Chapter & Topic What the Original Text Claimed Why It Failed Mechanically Formal Resolution in Lean 4
Tag 0F2W
(Status: wrong)
Ch. 37: More on Morphisms (Affine stratifications) Any scheme $X$ with an open cover by $n + 1$ affine opens has affine stratification number $\le n$. Without separatedness, the inclusion $U_i \hookrightarrow X$ of an affine open is not necessarily an affine morphism (e.g., the affine line with doubled origin), so strata inclusions fail the affine requirement. Added the missing typeclass hypothesis [X.IsSeparated] and proved affineStratificationNumber_le_of_isOpenCover.
Tag 03SS
(Status: wrong)
Ch. 64: The Trace Formula (Frobenii in char $p$) Treated the geometric Frobenius endomorphism of a scheme over a finite field $k$ ($|k| = p^f$) as intrinsic without fixing the base structure morphism. Because the exponent $f$ is read off from the base field cardinality $p^f$, a single scheme over two finite fields $\mathbb{F}_p$ and $\mathbb{F}_{p^f}$ carries two distinct geometric Frobenius maps. Proved geometricFrobenius_left_eq_absoluteFrobenius_pow_and_exists_ne with an explicit counterexample using $U = \operatorname{Spec}(\mathbb{F}_4)$ over $\mathbb{F}_2$ ($f=1$) vs. $\mathbb{F}_4$ ($f'=2$).
Tag 048U
(Status: conditional)
Ch. 83: Quotients of Groupoids (Equivalence relations) Equivalence and weak equivalence of points/orbits under a pre-relation in algebraic spaces coincide unconditionally. Requires geometric finiteness or field-size hypotheses to prevent pathological fiber behavior when composing relation paths. Formalized two conditional variants: equivalent_iff_weaklyEquivalent_of_large_field and ..._of_locallyOfFiniteType.
Tag 0AIW / 0CB8
(Status: partial)
Ch. 87: Formal Spaces (Ideals of definition) Ideals of definition of a formal scheme Ă  la EGA do not classify all thickenings (pointing to conditional requirements in 0CB8). Requires constructing an explicit non-Noetherian adic valuation ring whose maximal ideal is a weak ideal of definition but no power lies in $(p)$. Constructed the ring of integers $\mathcal{O}_{\mathbb{C}_p}$ of $p$-adic complex numbers (PadicComplexInt) to prove the negative clause unconditionally in exists_isWeakIdealOfDefinitionOn_not_isIdealOfDefinitionOn.