AIで開発する

Comparing the 17 million line Riemann proof to other Lean projects

An analysis of Lean codebases reveals that the recent 17 million line Riemann hypothesis proof is an outlier compared to human-written Mathlib entries but aligns with emerging AI-generated verificatio

A comparison of a massive stack of papers representing AI-generated code versus a small notebook representing human-written code.
この記事用に生成されたイラスト

この記事は英語版のみ利用可能です。

The recent formal verification of the Riemann hypothesis in the Lean proof assistant has drawn attention for its sheer scale, totaling 17 million lines of code. This massive figure raises questions about the nature of modern formal proofs and how they compare to existing libraries in the ecosystem. By examining data from Mathlib and the Reservoir index, we can contextualize this size against both traditional human-written proofs and newer AI-assisted projects.

What happened

To understand whether 17 million lines is an anomaly or a new normal, an analysis was conducted on available collections of Lean proofs. The investigation focused on two primary sources: the famous theorems archived in Mathlib and the broader set of packages indexed by Reservoir. The goal was to chart the distribution of proof lengths and identify where the Riemann hypothesis proof fits within the current landscape of formal verification.

Mathlib, the standard library for mathematics in Lean, contains over 1,000 famous proofs. However, only 259 of these have associated Lean code that was strictly human-generated. When plotted, these human-written proofs cluster at much smaller sizes, nowhere near the multi-million line mark. This suggests that traditional formalization efforts prioritize conciseness and human readability, resulting in significantly smaller codebases than the recent Riemann hypothesis effort.

The Reservoir index, which tracks every published Lean package with code on GitHub, offers a wider view including AI-assisted work. Among the 938 packages analyzed, several projects exceed 16 million lines. These outliers include large-scale AI-generated proofs and database bridging tools. The data indicates that while human proofs remain compact, automated and semi-automated systems are producing verification artifacts of unprecedented volume, shifting the baseline for what constitutes a "large" formal proof.

How it works

The analysis relies on aggregating line counts from public repositories and visualizing them using logarithmic scales. A log x-axis is essential for this type of data because it compresses the vast range of values, allowing small human-written proofs and massive AI-generated files to appear on the same chart. Without this scaling, the smaller proofs would be indistinguishable from zero, and the true magnitude of the difference between 100,000 lines and 17 million lines would be visually obscured.

The distinction between human and AI-generated code is critical in interpreting these numbers. Human-written Lean code in Mathlib is crafted for mathematical elegance and maintainability. In contrast, AI agents often produce verbose outputs, generating repetitive structures or exhaustive checks that a human would abstract away. Some projects, like those linking external databases to Lean, generate code programmatically rather than writing proofs in the traditional sense. This mechanistic generation inflates line counts without necessarily increasing the mathematical complexity or insight of the verification.

Key details

  • The Riemann hypothesis proof in Lean consists of approximately 17 million lines of code.
  • Mathlib contains 259 human-generated Lean proofs for famous theorems, all significantly shorter than 17 million lines.
  • Reservoir indexes 938 Lean packages with GitHub code, revealing several projects exceeding 16 million lines.
  • The Qiuzhen-CFSG/CFSG project contains 88 million lines and appears to be an AI-built proof still in progress.
  • The CBirkbeck/LeanBridge project has 36 million lines, but 98% is script-generated code checking database numbers, with only 500,000 lines handwritten.
  • Anthropic’s Fermat’s Last Theorem proof is 27 million lines, roughly 450 times longer than the 60,000-line human-led project it builds upon.

Why it matters

For software engineers and researchers building with formal methods, these metrics highlight a shifting paradigm in verification. The explosion in line count suggests that AI agents are capable of producing complete formal proofs, but they do so with a level of verbosity that challenges traditional notions of code quality and maintainability. A proof that is 450 times longer than its human counterpart may be correct, but it introduces significant overhead for review, storage, and computation.

This trend also impacts how we evaluate the trustworthiness of automated verification. When a proof is too large for any human to comprehend, the reliance shifts entirely to the correctness of the proof assistant kernel and the generation pipeline. Understanding the source of the code—whether it is concise human logic or expansive AI output—becomes crucial for assessing risk. Teams adopting these tools must decide if they value the speed of automated generation over the clarity and compactness of human-written formalizations.

What you can do

  • Review the size distributions in your own formal verification projects to identify unnecessary verbosity introduced by automation tools.
  • Distinguish between handwritten logic and script-generated boilerplate when estimating the complexity of a Lean codebase.
  • Use logarithmic scales when visualizing code metrics to accurately represent disparities between small and large modules.
  • Evaluate AI-generated proofs not just for correctness, but for maintainability and the potential technical debt of excessive line counts.
  • Compare your project’s line count against the Mathlib baseline to gauge if your formalization approach aligns with community standards for conciseness.
  • Investigate the provenance of large Lean packages on Reservoir to understand whether their size stems from mathematical depth or mechanical generation.
  • #lean
  • #formal verification
  • #ai-generated code
  • #mathlib
  • #software metrics

Bytechapストアのツール

$89

DocBento

すべてのスキャンを読み取り、ページ出典を提示して回答するセルフホスト型ドキュメント管理システム。

ライブデモ

続きを読む

すべての記事