Builds declaration-level indexes and dependency graphs from compiled Lean 4/Mathlib projects to trace declarations across three versions of a Lean Riemann Hypothesis proof.
Abstract
A Lean 4 proof of the Riemann Hypothesis was released on 20 November 2026 with 175,187 files and 17.4 million lines. Within a week it existed in three versions: the original release, a branch consolidated by volunteers (47,885 modules, 14.6 million lines), and a condensed rewriting that became the community's main line (802 files, 0.48 million lines, 2.8% of the original). We ask whether the reduction came from pruning or from rewriting, and how far pruning alone could have gone. Using compiled indexes and declaration-level dependency graphs, we trace declarations across the versions. Consolidation kept the names: 92% of the consolidated branch's real declarations have a counterpart of the same name in the original. The condensed version shares almost nothing with the consolidated branch: only 47 of its 26,018 real declarations in the dependency graph (0.18%) match one by name and statement, and the nine full names common to all three versions are the fixed statements of the challenge. The declarations dropped were not the unused ones; their use profile is close to that of the whole branch. Removing every declaration of the consolidated branch that is unreachable from the five main theorems would cut its declaration lines by only 2.8% (deleting whole declarations, without changing the others), whereas the condensed version has 2.7% of the reachable lines. At the level of declaration text, the reduction is therefore almost entirely due to rewriting, not to pruning. The condensed version is also organised differently: it separates a library with no counted use of the proof-specific part, whereas the top-level namespaces of the consolidated branch all depend on one another. We discuss what this implies for checking and maintaining very large AI-written formal artifacts.
Problem
A 17.4-million-line Lean 4 proof of the Riemann Hypothesis existed within a week in three versions: the original release, a volunteer-consolidated branch, and a condensed rewriting with 2.8% of the original lines. The study asks whether the size reduction came from pruning unused declarations or from rewriting, and how far pruning alone could go.
Approach
Compiled indexes and declaration-level dependency graphs, reused from earlier work, give counts of real declarations. Declarations are matched across versions by full name, short name plus normalised statement, or statement alone. Reachability from the five main theorems gives a lower bound on what pruning could achieve. Dependency structure matrices of namespace groups compare how the versions are organised.
Results
Consolidation kept names: 92% of the consolidated branch's declarations match the original by name. Only 47 of 26,018 declarations in the condensed version (0.18%) match the consolidated branch, and dropped declarations had a use profile similar to the whole branch. Pruning unreachable declarations would cut only 2.8% of declaration lines, so the reduction is almost entirely due to rewriting. The condensed version also separates a library that does not use the proof-specific part.
Fig. 4: Dependency structure matrices of namespace groups in (a) version (2) and (b) version (3). A row uses a column; the shade is the logarithm of the number of uses (pairs of a module and a name that it uses) between the two groups. Groups are ordered from Main , the module of the five theorems, downward by a heuristic that reduces uses below the diagonal (backward uses). Dashed squares enclose
Real declarations
Declaration lines
Share (%)
Version (2), all
871,784
10,737,061
100.0
Version (2), reachable
826,654
10,432,860
97.2
Version (3)
26,019
278,198
2.59
Pruning lower bound: reachable declarations in version (2) vs version (3)