WorksComputer Science
Lean Census: A Distributional Analysis of AI-Generated Lean Code
Abstract
We compare two human-written and four AI-generated Lean libraries with Mathlib through the distributions of simple statistics of their code. For each library we measure inline claims in proofs, proof length, how often each declaration is used, and design choices such as instances and private declarations, and we read each against the variation among Mathlib's own areas. The AI-generated libraries have more inline claims per theorem, longer proofs, fewer instances, and more private declarations than the human-written ones. We release the code for the analysis as a package, lean-census, at https://github.com/project-numina/lean-census.
Introduction
AI systems now write Lean libraries with millions of lines of code and little human review. A library is useful only if others can build on it. We compare the distributions of simple statistics over the code of human-written and AI-generated Lean libraries. We call a library human-written when people review every contribution, as in Mathlib [47], even if some of it was drafted with AI tools. We call it AI-generated when AI systems write it with little or no line-by-line human review.
We study six libraries against Mathlib (Table 1). Two are human-written, CSLib [10] and PhysLib [49, 48], and four are AI-generated, FormalFrontier [24], Tau Ceti [46], CSLib Frontier [19], and Atlas [43, 39]. Tau Ceti alone has nearly three times as many lines as Mathlib. Other large AI-generated projects include Anthropic’s Fermat’s Last Theorem project [3] and Axiom’s formalizations of the classification of finite simple groups [7] and of the Stacks Project [8]. We leave these out because they are expensive to build and analyze, and we assume smaller libraries suffice for our questions.
| Library | Written by | Lines (k) | Declarations | Revision | Lean | Mathlib |
| Mathlib | human | 2,358 | 254,173 | 56a00585 | 4.35.0 | – |
| CSLib | human | 49 | 4,776 | f8acdb37 | 4.36.0-rc2 | 887bb849 |
| PhysLib | human | 207 | 13,915 | 25465e80 | 4.35.0 | 56a00585 |
| FormalFrontier | AI | 713 | 38,365 | 44 libraries | 4.34.0-rc2 | 83abb3e7 |
| Tau Ceti | AI | 6,500 | 366,101 | 7550358f | 4.36.0-rc2 | 1b1ccf4b |
| CSLib Frontier | AI | 1,836 | 109,786 | 593563c5 | 4.36.0-rc2 | 69552756 |
| Atlas | AI | 1,805 | 84,645 | 321c3f1a | 4.35.0 | 56a00585 |
Table 1. The libraries of the main analysis and Mathlib, whose own statistics we report at the revision that PhysLib and Atlas use. Lines are thousands of source lines in the library’s own files. Declarations are theorems, definitions, instances, and types that an author wrote.
Audits of AI-generated Lean have so far relied mostly on judgment. An expert reviews a project’s definitions, file organization, and interfaces [34], or a language model flags unnecessary hypotheses and duplicated material one declaration or file at a time [40, 21]. A few static counts, such as how often definitions are unfolded, cover whole libraries [21]. These audits find concrete problems, but none reads the distributions of statements, proofs, and dependencies across a library against the variation within human-written code.
Our premise is that if AI-generated code is structured like human-written code, the two should have similar distributions. Proving intermediate facts as small lemmas, rather than having these inside a long proof, makes them reusable. A library built this way has short statements and proofs, and its declarations are used many times. This is compression in the sense of Aksenov et al. [1], where each fact is written once and referred to many times.
Preprint.
We find that every AI-generated library lies outside the range of the three human-written libraries on inline claims, proof length, instances, private declarations, and explicit arguments. AI-generated proofs state more intermediate facts, with 0.81 to 3.22 inline claims per theorem against 0.21 to 0.64. Their median proofs are 22 to 49 tokens long against 10 to 17, and 0.8 to 3.2% of their declarations are instances against 5.4 to 10.7%. They mark 14 to 37% of their declarations private, meaning that no other file can use them, against 1 to 4%. Part of the difference in proof structure may reflect purpose rather than authorship, since Mathlib’s own archive of one-off proofs is structured much like the AI-generated libraries. On instances, private declarations, and explicit arguments, however, the archive is like Mathlib (§ 5.4).
Mathematics as code
Formal mathematics is software, since by the Curry–Howard correspondence a proof is a program [33, 52]. As Martin-Löf [38] wrote, “it no longer seems possible to distinguish the discipline of programming from constructive mathematics.” We therefore draw on software engineering, which has long studied how to divide programs into parts, to ask how mathematical libraries should be structured [27]. Avigad [6] uses the same principles to explain how informal mathematics is organized, and Commelin and Topaz [18] argue that mathematicians already rely on abstraction boundaries, which formalization makes explicit.
Modules and interfaces. Parnas [41] argued that a program should be divided into modules that each hide one design decision behind a small interface. In Lean, a definition and the basic results about it form such a module [17]. As an example, Mathlib builds the real numbers from Cauchy sequences, but outside a few files it uses them only through results such as the field axioms and completeness, so the construction could be replaced. Finding a characterizing interface strong enough to work with can itself take new mathematics [14]. Mathlib has refactored fraction fields in this way, replacing a single construction with a characterizing property [9]. A theorem is like a function whose statement is its type and whose proof is its body, and callers depend only on the statement.
Coupling and cohesion. Stevens et al. [44] judged a division into modules by its coupling and its cohesion. Coupling is how strongly modules depend on one another, and it should be low. Cohesion is how closely the parts of one module belong together, and it should be high. A lemma that states one fact is fully cohesive, while a long proof whose have steps each establish a separate fact bundles several facts that could each be a lemma. In Lean, coupling shows in a statement’s arguments and in how often proofs unfold definitions. The little theories method of Farmer et al. [23] applies a related modular principle to formal mathematics, proving each theorem in the smallest theory that supports it and reusing it elsewhere through theory interpretations.
Fan-in, layers, and tails. Fan-in, the number of modules that use a given module, is one of the oldest structural measures of software design, and Henry and Kafura [32] built an early metric on a version of it based on information flow. A part with high fan-in is reused, which is the point of naming it. Parnas [42] defined the relation of one part using another and argued that it should form a hierarchy of levels, each built on those below. In a Lean library, the uses of a declaration measure its fan-in, and its dependency height its level. Fan-in is heavy-tailed in software [37], with a few parts used everywhere and most used rarely, so a mean says little. We therefore compare whole distributions against a reference library, much as software assessment derives quality thresholds from metric distributions over a benchmark of systems [2].
Refactoring and compression. The central refactoring of Fowler [25] extracts part of a long function into a named function of its own, which shortens the original and removes duplicated code. In Lean it turns a have step into a lemma. Commelin and Topaz [18] make a related point about constructions, which cannot be used outside the proof that builds them and so, if needed later, “must be factored out of the proof into a standalone definition.” REFACTOR [53] learns to make this extraction automatically, and library learning chooses the abstractions that most shorten a corpus of programs [22, 13, 28]. Aksenov et al. [1] argue that human mathematics is distinguished by its compressibility through nested definitions, lemmas, and theorems.
What we measure
We measure the theorems, definitions, instances, and types that authors wrote in each library, and leave out metaprogramming, aliases, and declarations generated by attributes (§ 4). Each measurement below captures one aspect of the structure described in § 2.
Inline claims. The number of have and suffices steps in a theorem’s proof. Each proves a fact that no other declaration can use. Some such facts belong where they are, but a rate well above that of human-written code suggests facts that could have been lemmas. We do not count obtain or rcases, which take apart existing facts rather than prove new ones.
Tactic steps. The number of tactic steps in a declaration’s elaborated proof, including the steps nested inside other steps. It measures how much work a proof does itself.
Statement and proof length. Source tokens before and after :=, comments excluded. A library of small lemmas has short statements and short proofs.
Explicit arguments. The share of theorems with three or more explicit arguments. Mathlib makes an argument implicit when Lean can infer it from the others, so that a theorem applies without restating the objects it is about.
Uses. The number of other declarations in the same library whose statement or proof refers to a declaration, which is its fan-in.
Dependency height. The longest chain of references from a theorem that stays inside its library.
Instances. The share of declarations that are type-class instances. Mathlib organizes mathematics through type classes, so a result proved for a structure applies to all of its instances.
Private declarations. The share of declarations marked private, which no other file can use.
Libraries and method
Libraries. Table 1 lists the six libraries of the main analysis with the revisions we measured. We leave out projects aimed at a single theorem, such as the human-written projects on Fermat’s Last Theorem [15], Carleson’s theorem [51], and the polynomial Freiman–Ruzsa conjecture [45], together with AI-generated projects of the same kind. For PhysLib we measure its reviewed libraries, Physlib and QuantumInfo, and leave out PhyslibAlpha, which accepts AI-generated contributions under lighter review. FormalFrontier is a collection of 44 libraries, many of which depend on others in the collection. We treat it as one library, so its combined size overstates the size of any one of them. Ten of them did not build completely, missing 32 of the collection’s 3,273 modules. One depends on a different Mathlib revision from the other 43, and we compare all 44 with the revision the 43 share.
Method. We build each library under its own toolchain. A Lean program [20] loads it with its Mathlib revision and records each constant’s kind, source range, and the constants its statement and proof refer to. A lexer splits each declaration’s source into tokens to measure lengths and count tactic steps. Constants that Lean generates for a declaration, such as pieces of its proof and its equation lemmas, count as part of it. We keep only declarations whose written name is their own, which drops aliases and declarations generated by attributes such as to_additive, and we leave out metaprogramming. To count steps and claims in elaborated proofs, a second program elaborates every file again under the library’s own options and records the goal before each tactic step. Every file elaborates without errors.
Comparison. We compare each library with the Mathlib revision it depends on. We also treat Mathlib’s 26 top-level areas (“Mathlib areas”) as separate libraries, which shows how much a statistic varies within human-written code and how it grows with size. Mathlib’s statistics barely change between the revisions the libraries pin. Reuse is counted only inside a library or area, so CSLib
Frontier’s uses of CSLib, for example, do not count. We do not control for subject. We computed several dozen candidate statistics and report the ones we found most illustrative of the differences. Appendix § 9 lists them all.
Reading the figures. The percentile figures (Figure 2 and Figure 4 and Appendix § 10) plot a statistic at each percentile of a library’s theorems, and a second panel shows how many percentiles higher each theorem would rank in Mathlib.
Figure 2. Left, the share of theorems with at least inline claims. Middle, proof length in tokens at each percentile of theorems. Right, how many percentiles higher each proof would rank in Mathlib, so a library on the zero line matches Mathlib.
Figure 4. Statement length of theorems in source tokens, from the declaration keyword up to the proof. Left, the length at each percentile of theorems. Right, how many percentiles higher each statement would rank in Mathlib, so a library on the zero line matches Mathlib.
Evidence
Local proof structure
Proofs in the AI-generated libraries contain 0.81 to 3.22 inline claims per theorem, against 0.21 to 0.64 in the human-written ones, and their median proof is 22 to 49 tokens long against 10 to 17 (Figure 2). Each inline claim is an intermediate fact proved inside the proof with have or suffices. No other declaration can use it, so reasoning that could have been a named lemma stays inside the one proof that needed it.
A quarter to a half of the theorems in each AI-generated library state at least one inline claim, against 10 to 21% in the human-written ones. In Atlas nearly one theorem in five has five or more, against fewer than one in a hundred in Mathlib. The difference runs through the whole distribution and is not confined to a few long proofs.
In every library the theorems that other declarations use carry more inline claims than those that nothing uses, 0.28 against 0.09 in Mathlib and 3.47 against 2.17 in Atlas, and the AI-generated libraries are above Mathlib in both groups. A library built to reach target theorems has many theorems that nothing uses, but its inline claims are not concentrated in them, so the difference does not come from what the libraries are for.
Per hundred tactic steps, the AI-generated libraries state 12 to 21 new facts against 6 to 8 in the human-written ones, while the number of steps per declaration separates the two groups less, 6.8 to 15.8 against 4.6 to 8.5 (Figure 3). The elaborated proofs thus give the same ordering as the source text, and the difference lies less in how many steps a proof takes than in how many new facts it states along the way. Statements differ less than proofs, with a median of 44 to 49 tokens against 31 to 35 (Figure 4).
Figure 3. Elaborated proofs against library size. Left and middle, tactic steps and inline claims per declaration with a tactic proof. Right, inline claims per tactic step. Human-written libraries are blue, AI-generated ones orange, and Mathlib black.
Observed reuse
Atlas and CSLib Frontier put half or more of their text into declarations used exactly once, against a third in Mathlib (Figure 5). Most of these declarations feed further declarations, forming chains of lemmas each used once. Proofs are split into steps rather than into parts that other proofs could share. Mathlib instead has the most declarations that nothing inside it uses, because a reference library states results for its users.
Figure 5. How many declarations of the same library use each declaration, as a share of declarations (left) and of source tokens (right). Labels give the share used exactly once.
Among declarations used at least once, the share used at least twice lies within the range of Mathlib’s areas in every library except Atlas. Weighted by length, Atlas and CSLib Frontier fall below every area, so the declarations they do reuse tend to be short.
The median theorem of Mathlib sits on a chain of 15 references inside its own area, against 3 to 9 in the six libraries (Figure 13 in Appendix § 10). Height depends on size, on the age of a library, on where its boundary is drawn, and on how much it takes from upstream, so we read it as a description of layering and not as a defect.
Figure 13. Dependency height inside the library. Longest chain of references that stays inside the library.
Design choices
The AI-generated libraries register 0.8 to 3.2% of their declarations as instances against 5.4 to 10.7% in the human-written ones, mark 14 to 37% private against at most 4%, and give about half of their theorems many explicit arguments against a quarter to a third (Figure 1 and Table 2). These are choices an author makes when declaring things rather than when proving them, and each affects how easily other code can use a result. Fewer instances mean that fewer general results apply to their structures automatically, a private declaration cannot be used from another file, and explicit arguments must be supplied by hand. On private declarations and explicit arguments every AI-generated library lies outside the range of Mathlib’s areas. None of the three depends on proof style.
Figure 1. Left and middle, the share of declarations that are instances and the share that are private, against library size. Right, the share of theorems with at least explicit arguments.
| Library | Inline claims per theorem | Theorems with a claim | Text used once | Instances | Private | Explicit arguments |
| Mathlib | 0.21 | 10% | 31% | 10.7% | 1.1% | 23% |
| Mathlib areas | 0.03–0.52 | 2–23% | 2.2–27.4% | 0.0–6.9% | 7–37% | |
| CSLib | 0.31 | 15% | 36% | 6.2% | 4.1% | 24% |
| PhysLib | 0.64 | 21% | 43% | 5.4% | 3.4% | 31% |
| FormalFrontier | 0.81 | 25% | 37% | 2.7% | 17.2% | 54% |
| Tau Ceti | 0.89 | 30% | 42% | 3.2% | 14.0% | 44% |
| CSLib Frontier | 1.61 | 37% | 51% | 0.8% | 18.7% | 44% |
| Atlas | 3.22 | 49% | 61% | 1.2% | 37.1% | 47% |
Table 2. Summary of each library. Text used once is the share of source tokens in declarations used exactly once in the library. The last column is the share of theorems with three or more explicit arguments. The Mathlib areas row gives the range across Mathlib’s 26 top-level areas.
Authorship and purpose
On inline claims, proof length, and instances, the two human-written libraries are nearest to Mathlib and the four AI-generated ones are further. Tau Ceti and FormalFrontier are the closest of the AI-generated libraries on proof structure, but they register instances at three fifths of the rate of the human-written libraries or less.
CSLib has 0.31 inline claims per theorem, a median proof of 12 tokens, 6.2% instances, and 4.1% private declarations, against 1.61, 34 tokens, 0.8%, and 18.7% in CSLib Frontier, which covers the same subject and builds on CSLib. The two differ in size and in aim as well as in authorship.
Mathlib’s Archive and Counterexamples, one-off proofs that the Mathlib community writes and reviews outside the main library, have 0.89 inline claims per theorem against Mathlib’s 0.21, and 31% of their theorems state at least one claim against 10%. On proof structure they look like the AI-generated libraries, which suggests that purpose, and not only authorship, shapes it. On instances (6.4%), private declarations (3.3%), and theorems with three or more explicit arguments (19%), however, they are like Mathlib, so purpose does not explain these three differences.
With two human-written and four AI-generated libraries, these observations describe the libraries studied and do not estimate an effect of authorship. Studies of AI coding tools in software report increased complexity and less refactoring [31, 30], in the same direction as our observations.
Limitations
Alternative explanations. Subject matters, since Mathlib’s own areas differ by a factor of seventeen on inline claims. Purpose may matter as much as authorship for proof structure, as the Archive suggests (§ 5.4). Mathlib has been refactored over many years, while the six libraries are younger and less maintained, so age may explain part of the gap. File and library boundaries are conventions, and FormalFrontier, a collection of 44 libraries, has no single boundary. Finally, every have or suffices counts as an inline claim, so a one-line have that feeds automation counts as much as a substantial one.
Validation. We have not tested whether the statistics respond to refactoring as they should. Material that a project moves into Mathlib, as large projects routinely do [50], should move towards Mathlib’s values, and inlining lemmas in a Mathlib area should move each statistic away from them.
Related work
Statistics of proof corpora. Blanchette et al. [12] mined the Archive of Formal Proofs for size and dependency statistics, Li et al. [36] study the dependency graph of Mathlib, and Aspinall and Kaliszyk [5] adapt software design metrics to proof libraries. Few studies compare human-written with AI-generated mathematics. Li et al. [35] find that language models reproving the propositions of
Euclid’s Elements cite foundational elements, such as definitions and postulates, far more often than human proofs do, an informal analogue of proving facts inside the proof. Aryal [4] compares human and AI-generated proofs by measures inside individual proof terms, while our measurements concern reuse across a library. Berlot-Attwell et al. [11] find that the lemma and function libraries built by two language-model library-learning systems are rarely reused.
Judging and improving proofs. ProofJudge [16] scores proofs with a language model, and the Lean quality indicators [21, 40] use one to flag unnecessary hypotheses and duplicated material in Mathlib, Tau Ceti, FormalFrontier, and other libraries. The indicators also include static counts over whole libraries, such as how often definitions are unfolded outside their own files, which is close to our view of coupling. Proof-Refactor [26] extracts lemmas from proofs, and ProofOptimizer [29] shortens generated proofs. The judged methods work one declaration or file at a time. Distributional measurements need no judge and are cheap to reproduce, but they describe a library and not a declaration, and their reference is itself the product of human review.
Conclusion
AI-generated Lean libraries differ from human-written ones in how proofs are structured and how declarations are reused and declared, and the differences show in simple distributions computed from the source and the dependency graph. Their proofs state more intermediate facts and run longer, more of their text sits in declarations used once, and they register fewer instances and mark more declarations private. One-off proofs written by Mathlib’s community share the proof structure of the AI-generated libraries but not their design choices, so purpose may explain part of the first difference but not the second. Whether these statistics track what reviewers and maintainers mean by quality remains open.
Candidate statistics
Table 3 lists the candidate library-level statistics from which the main-text measurements were chosen. “Trend” is the correlation, across Mathlib areas, between the statistic and the logarithm of the number of declarations.
| Statistic | Mathlib | Mathlib areas | CSLib | PhysLib | FF | Tau Ceti | CSLib Fr. | Atlas | Trend |
| Reuse as compression | |||||||||
| Reuse score, weighted by length | – | +0.61 | |||||||
| Reuse score, weighted by statement length | – | +0.62 | |||||||
| Reuse score, unweighted | – | +0.65 | |||||||
| Reuse score, uses from other files | – | +0.69 | |||||||
| Instances among declarations | 10.7% | 2.2%–27.4% | 6.2% | 5.4% | 2.7% | 3.2% | 0.8% | 1.2% | -0.18 |
| Local helpers | 37% | 32%–51% | 38% | 39% | 47% | 39% | 50% | 71% | -0.60 |
| Single-use theorems | 29% | 21%–46% | 37% | 39% | 34% | 35% | 46% | 53% | -0.33 |
| References that leave the file | 71% | 17%–78% | 55% | 70% | 41% | 65% | 65% | 34% | +0.79 |
| Used from another file | 29% | 12%–38% | 30% | 39% | 22% | 42% | 38% | 14% | +0.40 |
| References to the top 1% | 57% | 10%–67% | 31% | 40% | 28% | 40% | 40% | 28% | +0.83 |
| Lemmas that were not factored out | |||||||||
| Inline claims per theorem (have, suffices) | 0.21 | 0.03–0.52 | 0.31 | 0.64 | 0.81 | 0.89 | 1.61 | 3.22 | -0.20 |
| Theorems with an inline claim | 10% | 2%–23% | 15% | 21% | 25% | 30% | 37% | 49% | -0.23 |
| Inline claims per used theorem | 0.28 | 0.05–0.61 | 0.37 | 0.76 | 1.06 | 1.00 | 1.79 | 3.47 | -0.08 |
| Inline claims per unused theorem | 0.09 | 0.02–0.52 | 0.20 | 0.31 | 0.41 | 0.46 | 0.63 | 2.17 | -0.48 |
| Destructuring steps per theorem | 0.18 | 0.06–0.41 | 0.41 | 0.21 | 0.30 | 0.34 | 0.64 | 0.69 | -0.01 |
| Explicit unfoldings per theorem | 0.01 | 0.00–0.04 | 0.01 | 0.03 | 0.01 | 0.01 | 0.10 | 0.14 | -0.40 |
| Inline claims including obtain | 0.27 | 0.04–0.62 | 0.50 | 0.75 | 0.98 | 1.09 | 1.89 | 3.55 | -0.19 |
| Proof text in proofs over 200 tokens | 26% | 0%–53% | 23% | 51% | 54% | 45% | 62% | 74% | -0.16 |
| Proof text in the longest 1% of proofs | 18% | 7%–23% | 13% | 20% | 15% | 10% | 15% | 18% | +0.42 |
| Proof information | |||||||||
| Compressed proof per theorem (bits) | 338 | 166–528 | 305 | 561 | 654 | 697 | 903 | 1176 | -0.16 |
| Compressed proof per compressed statement | 1.0 | 0.8–2.1 | 1.2 | 1.7 | 1.3 | 1.3 | 1.6 | 2.2 | -0.55 |
| Bits per proof token | 12.3 | 8.7–11.8 | 9.3 | 8.6 | 9.1 | 11.3 | 9.0 | 7.3 | +0.86 |
| Source redundancy | |||||||||
| Bits per token | 9.9 | 6.5–9.0 | 7.4 | 7.8 | 7.8 | 9.7 | 8.4 | 7.3 | +0.73 |
| Bits per token given Mathlib | 8.0 | 6.1–8.2 | 7.0 | 7.3 | 7.1 | 8.8 | 8.0 | 6.8 | +0.70 |
| Repeated proof text | 0% | 1%–13% | 8% | 6% | 2% | 0% | 1% | 1% | -0.82 |
| Distance from Mathlib’s idiom | |||||||||
| Trigram bits under a Mathlib model | 6.9 | 7.1–8.7 | 9.8 | 8.8 | 7.9 | 8.1 | 9.4 | 8.3 | -0.47 |
| Information not predictable from Mathlib | 80% | 89%–95% | 95% | 93% | 91% | 90% | 95% | 92% | -0.52 |
| Other ideas tried | |||||||||
| Theorem leverage inside the library (log2) | 10.0 | 2.4–29.2 | 4.6 | 7.3 | 4.2 | 5.5 | 4.8 | 2.5 | +0.47 |
| Theorems about a definition (median) | 2 | 0–15 | 2 | 3 | 3 | 5 | 3 | 2 | -0.38 |
| Definitions with under 3 theorems | 57% | 0%–87% | 54% | 43% | 41% | 30% | 40% | 54% | +0.22 |
| Theorems stated twice | 2% | 0%–9% | 0% | 1% | 1% | 1% | 1% | 2% | -0.09 |
| Ad hoc names | 1% | 0%–4% | 2% | 2% | 0% | 1% | 2% | 4% | -0.07 |
| Elaborated terms | |||||||||
| Sharing inside proof terms | – | -0.19 | |||||||
| Proof term nodes per proof token | 22.1 | 11.0–97.7 | 12.6 | 27.7 | 21.9 | 26.5 | 11.7 | 11.2 | -0.05 |
| Unwrapped length per token (log2) | 73 | 16–229 | 42 | 201 | 115 | 166 | 74 | 95 | -0.19 |
Table 3. Candidate statistics. FF is FormalFrontier and CSLib Fr. is CSLib Frontier.
Candidates we did not report. On fixed-size samples, source compressibility mainly measures how much of a library a sample covers. Token-level distance from Mathlib (cross-entropy under a trigram model, and compression given Mathlib as context) mainly measures vocabulary, since CSLib and PhysLib are as far from Mathlib as any library. Statistics of elaborated terms, including a variant of the unwrapped length of Aksenov et al. [1], vary as much among Mathlib’s areas as among the libraries. The share of declarations used only in their own file depends on file conventions. An aggregate distance over many statistics loses the direction of each difference, so we report per-family distances only in Appendix § 10.
Measurements that need the elaborated proof. Several sharper statistics require more of the elaborated proof than the counts of Figure 3. One is the number of inline claims whose statement does not depend on the local context, so that each could stand alone as a lemma. Others are how often proofs unfold a definition where an interface lemma would serve, and how many subterms are duplicated across proofs up to renaming.
Further distributions and distances
Figure 6 to Figure 17 show the remaining per-theorem statistics that vary smoothly, for the six libraries, grouped by the families of Table 4 and each with the panels of Figure 4. Table 4 gives, for each family of per-declaration statistics, the median over the family of a distance ratio. The library’s values and Mathlib’s are expressed as percentiles of Mathlib, compared quantile by quantile, and divided by the median of the same distance between each Mathlib area and the rest of Mathlib. A ratio of 1 is the distance of a typical Mathlib area. The ratio has no direction and depends on the partition into areas.
| Library | Signature | Proof | Reuse | Compression |
| CSLib | 1.65 | 1.91 | 1.43 | 1.47 |
| PhysLib | 1.69 | 1.53 | 1.16 | 1.46 |
| FormalFrontier | 1.48 | 2.92 | 1.37 | 1.21 |
| Tau Ceti | 0.79 | 2.94 | 1.31 | 1.44 |
| CSLib Frontier | 1.67 | 3.01 | 1.19 | 0.62 |
| Atlas | 1.75 | 3.22 | 1.65 | 0.68 |
Table 4. Distance ratio by family of per-declaration statistics.
Figure 6. Statement term size. Distinct nodes of the elaborated type, so formatting and notation play no part.
Figure 17. Unwrapped length per token (). Unwrapped length divided by declaration length in tokens, a variant of the compression measure of Aksenov et al. [1], unrelated to the file compression of Appendix § 9.
Figure 7. Constants in the statement. Distinct declarations the elaborated statement mentions.
Figure 8. Proof length per statement length. Proof tokens divided by statement tokens.
Figure 9. Proof term size. Distinct nodes of the elaborated proof, with Lean’s auxiliary terms folded in.
Figure 10. Declarations used. Distinct declarations the statement and proof refer to.
Figure 11. Declarations used from the same library. Distinct declarations of the same library that the statement and proof refer to. For Mathlib, the library is the top-level area.
Figure 12. Declarations used from outside the library. Distinct declarations outside the library, mostly from Mathlib, that the statement and proof refer to.
Figure 14. Dependency height overall. Longest chain of references down to the axioms.
Figure 15. Declaration length in tokens. Statement and proof together, the source-token analogue of the wrapped length of Aksenov et al. [1].
Figure 16. Unwrapped length (). Primitive symbols after expanding every reference, core library included. Aksenov et al. [1] instead treat the core library as primitive and handle cycles differently.
References
- [1]Vitaly Aksenov, Eve Bodnia, Michael H. Freedman, and Michael Mulligan. Compression is all you need: Modeling mathematics, 2026. URL https://arxiv.org/abs/2603.20396.
- [2]Tiago L. Alves, Christiaan Ypma, and Joost Visser. Deriving metric thresholds from benchmark data. In Proceedings of the IEEE International Conference on Software Maintenance (ICSM), pages 1–10, 2010. doi: 10.1109/ICSM.2010.5609747.DOI
- [3]Anthropic. Fermat’s Last Theorem in Lean 4. https://github.com/anthropics/fermats-last-theorem, 2026.
- [4]Safal Raman Aryal. Studying proof data with proof theory: the case of AI-generated mathematics, 2026. URL https://arxiv.org/abs/2610.25357.
- [5]David Aspinall and Cezary Kaliszyk. Towards formal proof metrics. In Fundamental Approaches to Software Engineering (FASE 2016), volume 9633 of Lecture Notes in Computer Science, pages 325–341. Springer, 2016. doi: 10.1007/978-3-662-49665-7_19.DOI
- [6]Jeremy Avigad. Modularity in mathematics. The Review of Symbolic Logic, 13(1):47–79, 2020. doi: 10.1017/S1755020317000387.
- [7]Axiom Math. CFSG: A Lean formalization of the Classification of Finite Simple Groups. https://github.com/AxiomMath/CFSG, 2026.
- [8]Axiom Math. Stacks: A Lean formalization of the Stacks Project. https://github.com/AxiomMath/Stacks, 2026.
- [9]Anne Baanen, Sander R. Dahmen, Ashvni Narayanan, and Filippo A. E. Nuccio Mortarino Majno di Capriglio. A formalization of Dedekind domains and class groups of global fields. Journal of Automated Reasoning, 66(4):611–637, 2022. doi: 10.1007/s10817-022-09644-0.DOI
- [10]Clark Barrett, Swarat Chaudhuri, Fabrizio Montesi, Jim Grundy, Pushmeet Kohli, Leonardo de Moura, Alexandre Rademaker, and Sorrchai Yingchareonthawornchai. CSLib: The Lean computer science library, 2026. URL https://arxiv.org/abs/2602.04846.
- [11]Ian Berlot-Attwell, Frank Rudizc, and Xujie Si. Library learning doesn’t: The curious case of the single-use “library”, 2024. 4th MATH-AI Workshop at NeurIPS 2024.
- [12]Jasmin Christian Blanchette, Maximilian Haslbeck, Daniel Matichuk, and Tobias Nipkow. Mining the Archive of Formal Proofs. In Intelligent Computer Mathematics (CICM 2015), volume 9150 of Lecture Notes in Computer Science, pages 3–17. Springer, 2015. doi: 10.1007/978-3-319-20615-8_1.DOI
- [13]Matthew Bowers, Theo X. Olausson, Lionel Wong, Gabriel Grand, Joshua B. Tenenbaum, Kevin Ellis, and Armando Solar-Lezama. Top-down synthesis for library learning. Proceedings of the ACM on Programming Languages, 7(POPL):1182–1213, 2023. doi: 10.1145/3571234.DOI
- [14]Kevin Buzzard. Grothendieck’s use of equality, 2024. URL https://arxiv.org/abs/2405.10387.
- [15]Kevin Buzzard et al. FLT. https://github.com/ImperialCollegeLondon/FLT, 2026.
- [16]Shane Caldwell. ProofJudge: Tool-grounded LLM evaluation of formal proof quality in Mathlib, 2026. URL https://arxiv.org/abs/2608.20432.
- [17]Jacques Carette, William M. Farmer, and Michael Kohlhase. Realms: A structure for consolidating knowledge about mathematical theories. In Intelligent Computer Mathematics (CICM 2014), volume 8543 of Lecture Notes in Computer Science, pages 252–266. Springer, 2014. doi: 10.1007/978-3-319-08434-3_19.DOI
- [18]Johan Commelin and Adam Topaz. Abstraction boundaries and spec driven development in pure mathematics. Bulletin of the American Mathematical Society, 61(2):241–255, 2024. doi: 10.1090/bull/1831.DOI
- [19]csllib-frontier contributors. csllib-frontier: A frontier formalization of all of theoretical computer science built atop CSLib. https://github.com/cslib-community/cslib-frontier, 2026.
- [20]Leonardo de Moura and Sebastian Ullrich. The Lean 4 theorem prover and programming language. In Automated Deduction – CADE 28, volume 12699 of Lecture Notes in Computer Science, pages 625–635. Springer, 2021. doi: 10.1007/978-3-030-79876-5_37.DOI
- [21]Rémy Degenne and Kim Morrison. Quality indicators for Lean libraries. https://github.com/RemyDegenne/lean-quality-indicators, 2026.
- [22]Kevin Ellis, Catherine Wong, Maxwell Nye, Mathias Sab lé-Meyer, Lucas Morales, Luke Hewitt, Luc Cary, Armando Solar-Lezama, and Joshua B. Tenenbaum. DreamCoder: Bootstrapping inductive program synthesis with wake-sleep library learning. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI), pages 835–850, 2021. doi: 10.1145/3453480.3454080.DOI
- [23]William M. Farmer, Joshua D. Guttman, and F. Javier Thayer. Little theories. In Automated Deduction – CADE-11, volume 607 of Lecture Notes in Computer Science, pages 567–581. Springer, 1992. doi: 10.1007/3-540-55602-8_192.DOI
- [24]Formal Frontier. Formal Frontier: Lean 4 libraries that formalize mathematics from textbooks and the research literature. https://github.com/FormalFrontier, 2026.
- [25]Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999. With contributions by Kent Beck, John Brant, William Opdyke, and Don Roberts.
- [26]Yiming Fu, Peixuan Liu, Zichen Wang, and Kun Yuan. Proof-Refactor: Refactoring generated formal proofs into modular artifacts, 2026. URL https://arxiv.org/abs/2606.03743.
- [27]Georges Gonthier. Software engineering for mathematics (keynote). In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2013), page 13. ACM, 2013. doi: 10.1145/2491411.2505429.DOI
- [28]Gabriel Grand, Lio Wong, Maddy Bowers, Theo X. Olausson, Muxin Liu, Joshua B. Tenenbaum, and Jacob Andreas. LILO: Learning interpretable libraries by compressing and documenting code. In International Conference on Learning Representations (ICLR), 2024.arxiv.org/abs/2310.19791
- [29]Alex Gu, Bartosz Piotrowski, Fabian Gloeckle, Kaiyu Yang, and Aram H. Markosyan. ProofOptimizer: Training language models to simplify proofs without human demonstrations. In International Conference on Learning Representations (ICLR), 2026.arxiv.org/abs/2510.15700
- [30]William Harding and Matthew Kloster. Coding on Copilot: 2023 data shows downward pressure on code quality. Technical report, GitClear, 2024. URL https://www.gitclear.com/coding_on_copilot_data_shows_ais_downward_pressure_on_code_quality.
- [31]Hao He, Courtney Miller, Shyam Agarwal, Christian Kästner, and Bogdan Vasilescu. Speed at the cost of quality: How Cursor AI increases short-term velocity and long-term complexity in open-source projects. In Proceedings of the 23rd International Conference on Mining Software Repositories (MSR), pages 181–193, 2026. doi: 10.1145/3793302.3793349.DOI
- [32]Sallie Henry and Dennis Kafura. Software structure metrics based on information flow. IEEE Transactions on Software Engineering, SE-7(5):510–518, 1981. doi: 10.1109/TSE.1981.231113.DOI
- [33]William A. Howard. The formulae-as-types notion of construction. In Jonathan P. Seldin and J. Roger Hindley, editors, To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 479–490. Academic Press, London, 1980.
- [34]Vasily Ilin and Brian Nugent. Sorries are not the hard part: An expert-review case study of a semi-autonomous formalization, 2026. URL https://arxiv.org/abs/2606.13925.
- [35]Xiaokai Li, Ziyu Zhou, Qibin Cheng, Yangcheng Wu, An Zeng, and Ying Fan. AI has its own style in mathematical proving, 2026. URL https://arxiv.org/abs/2611.16527.
- [36]Xinze Li, Nanyun Peng, Simone Severini, and Patrick Shafto. The network structure of Mathlib, 2026. URL https://arxiv.org/abs/2604.24797.
- [37]Panagiotis Louridas, Diomidis Spinellis, and Vasileios Vlachos. Power laws in software. ACM Transactions on Software Engineering and Methodology, 18(1):2:1–2:26, 2008. doi: 10.1145/1391984.1391986.
- [38]Per Martin-Löf. Constructive mathematics and computer programming. Philosophical Transactions of the Royal Society of London. Series A, Mathematical and Physical Sciences, 312(1522):501–518, 1984. doi: 10.1098/rsta.1984.0073.
- [39]Meta. ATLAS: Large scale formalized mathematics. https://github.com/facebookresearch/atlas-lean, 2026. Version 2, commit 321c3f1a.
- [40]Kim Morrison and Rémy Degenne. Simple quality indicators for Lean libraries. Tau Ceti project blog, https://taucetiproject.org/blog/2026-10-28-simple-quality-indicators-for-lean-libraries/, 2026.
- [41]David L. Parnas. On the criteria to be used in decomposing systems into modules. Communications of the ACM, 15(12):1053–1058, 1972. doi: 10.1145/361598.361623.DOI
- [42]David L. Parnas. Designing software for ease of extension and contraction. IEEE Transactions on Software Engineering, SE-5(2):128–138, 1979. doi: 10.1109/TSE.1979.234169.DOI
- [43]Ahmad Rammal, Niket Patel, Fabian Gloeckle, Amaury Hayat, Julia Kempe, Remi Munos, Charles Arnal, and Vivien Cabannes. Formalizing mathematics at scale, 2026. URL https://arxiv.org/abs/2605.29955.
- [44]Wayne P. Stevens, Glenford J. Myers, and Larry L. Constantine. Structured design. IBM Systems Journal, 13(2):115–139, 1974. doi: 10.1147/sj.132.0115.DOI
- [45]Terence Tao et al. PFR. https://github.com/teorth/pfr, 2026.
- [46]Tau Ceti contributors. Tau Ceti: an open library of formal mathematics in Lean. https://github.com/TauCetiProject/TauCeti, 2026. Commit 7550358f.
- [47]The mathlib Community. The Lean mathematical library. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020), pages 367–381, 2020. doi: 10.1145/3372885.3373824.DOI
- [48]The Physlib community. Physlib: The Lean physics library. https://github.com/leanprover-community/physlib, 2026. Commit 25465e80.
- [49]Joseph Tooby-Smith. HepLean: Digitalising high energy physics. Computer Physics Communications, 308:109457, 2025. doi: 10.1016/j.cpc.2024.109457.
- [50]Floris van Doorn, Patrick Massot, and Oliver Nash. Formalising the h-principle and sphere eversion. In Proceedings of the 12th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2023), pages 121–134, 2023. doi: 10.1145/3573105.3575688.
- [51]Floris van Doorn et al. Carleson. https://github.com/fpvandoorn/carleson, 2026.
- [52]Philip Wadler. Propositions as types. Communications of the ACM, 58(12):75–84, 2015. doi: 10.1145/2699407.DOI
- [53]Jin Peng Zhou, Yuhui Wu, Qiyang Li, and Roger Grosse. REFACTOR: Learning to extract theorems from proofs. In International Conference on Learning Representations (ICLR), 2024.arxiv.org/abs/2402.17032
















