Imagine you’ve spent all day debugging a complex system, and now you’re settling in for the night. You hear that AI is now writing millions of lines of formal mathematical proofs in a language called Lean. You might think, "Great, the machines are doing the math for us!" But there’s a catch. Just because a program runs doesn't mean it’s well-written.
In the world of software, we hate "spaghetti code"—long, tangled messes that no one can reuse. This paper, Lean Census, asks a fascinating question: Is AI-generated math elegant and modular like a well-stocked library, or is it just a mountain of one-off, unreadable scripts?
TL;DR
By statistically "fingerprinting" millions of lines of code, researchers found that AI-generated math libraries are significantly "wordier" and less modular than human-written ones. While AI can prove the theorem, it struggles to build the reusable, elegant structures (lemmas and abstractions) that allow other mathematicians to stand on its shoulders.
What Problem Does This Paper Address?
Lean is a "proof assistant"—a programming language for math. The gold standard is Mathlib, a massive, human-curated library where every proof is polished for maximum reusability. Recently, AI systems have started churning out their own Lean libraries, some even larger than Mathlib itself.
The problem is that we’ve mostly been auditing these AI libraries by "vibes" or by checking if a few files are correct. We didn't have a systematic way to measure the quality of the architecture. If AI code is a tangled mess, it’s "dead code"—it might prove a theorem today, but no human or AI will be able to build on it tomorrow.
Methods
The authors treated mathematical proofs like software and applied "software engineering" metrics to them. They didn't just look at whether the proofs were correct; they looked at their distributional statistics.
Key metrics included:
- Inline Claims: How often does a proof use a "temporary" fact (a
haveorsufficesstatement) instead of citing a reusable lemma? - Proof Length: How many "tokens" (words/symbols) does it take to finish a proof?
- Fan-in (Reuse): How many other parts of the library actually use a specific definition or theorem?
- Design Choices: Does the AI make its tools "private" (hidden from others) or "public"? Does it use "instances" (Lean’s way of handling mathematical structures automatically)?
Datasets
The study compared three human-written libraries against four AI-generated ones:
- Human: Mathlib (the benchmark), CSLib (Computer Science), and PhysLib (Physics).
- AI-Generated: FormalFrontier, Tau Ceti, CSLib Frontier, and Atlas.
To give you a sense of scale, one AI library, Tau Ceti, has nearly three times as many lines of code as the entire human-written Mathlib.
Key Insights and Ideas
- The "Scrapbook" vs. the "Library": Human mathematicians are obsessed with compression. If we see a pattern, we factor it out into a named lemma so we can use it again. AI doesn't do this. It tends to write "monolithic" proofs—long, rambling sequences that prove everything from scratch every time.
- The Privacy Wall: AI-generated libraries mark a massive percentage of their declarations as
private. In Lean, a private declaration can't be used by any other file. It’s like writing a textbook where 30% of the chapters are locked behind a door that only the author has the key to. - The "Archive" Clue: Interestingly, AI code looks a lot like Mathlib’s "Archive"—a section for one-off proofs that aren't meant to be part of the main library. This suggests AI is currently a "one-off" problem solver, not a "system builder."
Key Results
The statistical gap between humans and AI is stark:
- Wordiness: AI proofs are much longer. The median AI proof is 22 to 49 tokens long, while human proofs are a lean 10 to 17 tokens.
- Lack of Abstraction: AI proofs use 0.81 to 3.22 inline claims per theorem. Humans use only 0.21 to 0.64. This confirms the AI is "rambling" rather than using lemmas.
- Isolation: AI libraries mark 14% to 37% of their code as private. Humans? Only 1% to 4%.
- Single-Use Code: In some AI libraries, over 60% of the source tokens belong to declarations that are used exactly once and then never mentioned again.
Limitations and Future Work
The authors are careful to note that some of this "messiness" might be due to the purpose of the libraries (one-off formalizations vs. long-term infrastructure) rather than just the fact that an AI wrote them. Additionally, Mathlib has been refactored by humans for years, while these AI libraries are "first drafts."
The big question for the future: Can we train AI to not just prove theorems, but to refactor its own work? Can we teach it to recognize when a "tangled mess" should actually be a beautiful, reusable lemma? Until then, AI might be a great mathematician, but it’s a pretty mediocre librarian.
Summary updated