[KongchangAI]
· 2 min read· 1,053 words

What Does 17 Million Lines of Lean Code Mean? The Debate Over the Scale of Formal Verification

What Does 17 Million Lines of Lean Code Mean? The Debate Over the Scale of Formal Verification

17M lines of Lean spark community debate on formal project scale and evaluation standards.

A blog post about 17 million lines of Lean code sparked heated discussion on Hacker News. The focus is not the number itself but the reality of formal verification engineering. The article notes that writing formal proofs costs far more than ordinary code, and line counts are inflated by auxiliary lemmas, type annotations, and tactic scripts—so they do not directly equate to mathematical complexity or verification value. The community diverges: some see the scale as proof of Lean's industrial potential, others stress that value lies in verified theorems and reusable structures. The consensus is that more nuanced evaluation dimensions are needed, such as modularity, dependency library quality, and core propositions covered by verification. Large codebases also place higher demands on toolchains, compilation, dependency management, and collaboration conventions.

Lean, as a theorem prover and functional programming language, has drawn considerable attention in recent years thanks to mathematical formalization projects. A blog post titled "Yes, 17M lines of Lean is a lot" sparked heated discussion on Hacker News, earning 179 points and 221 comments. The core of the debate is not the number itself, but the reality of formal verification engineering that this scale represents.

Why the Scale Number Draws Attention

17 million lines of code would qualify as a large project in any programming language. In the context of Lean, this number is especially striking, because writing formal proofs is far more costly than ordinary business code. Every theorem statement and every proof step requires rigorous derivation, and the machine checks logical correctness line by line.

The debate around this number actually reflects differing judgments within the community about the maturity of formal methods. Some argue that a large-scale codebase proves the engineering feasibility of the Lean ecosystem, while others caution that lines of code do not equate to the complexity or verification value of mathematical content.

Lean's core is a small trusted kernel, through which all proofs must ultimately be checked line by line. This means that the correctness of Lean code does not depend on compiler optimizations or the runtime environment, but is guaranteed by a small set of kernel rules. This design gives formal proofs extremely high credibility, but it also means that when writing proofs, every step of reasoning must be explicitly constructed—unlike ordinary programs, which can rely on implicit conversions or runtime checks. Only by understanding this can one appreciate why writing formal code is far more costly than conventional programming, and why the scale of 17 million lines carries special weight in the context of Lean.

The True Meaning of Lines of Formal Code

In traditional software engineering, lines of code are often used as a rough measure of effort, but they have never been synonymous with quality. Lean projects face the same problem, and even more complexity.

A formal proof may contain a large number of auxiliary lemmas, type annotations, and tactic scripts. These significantly inflate the line count, yet do not directly correspond to mathematical insight. Conversely, a concise proof may rely on highly abstract library functions. Therefore, the number 17 million by itself cannot tell us whether a project is "padded" or "solid."

One main thread in the HN comment section is precisely this skepticism: if a large portion of the lines comes from repetitive mechanical proofs or automatically generated code, then its significance should be discounted. Another main thread holds that regardless of how the line count is composed, code that passes the Lean kernel check is valuable, and scale itself is a manifestation of engineering capability.

The Limitations of Line Count Metrics

Using line count to measure formal projects tends to overlook proof reuse and levels of abstraction. The growth in lines of large mathematical formalization libraries (such as mathlib) often reflects an expansion of coverage rather than an increase in the complexity of any single proof. Discussing absolute numbers out of context makes it hard to reach meaningful conclusions.

mathlib is a mathematical formalization library maintained by the Lean community, covering a wide range of areas from basic algebra to analysis and topology. It is organized in a highly modular way, with a large number of theorems existing as reusable lemmas. mathlib's growth in lines comes mainly from expanding coverage and raising levels of abstraction, rather than from the bloating of individual proofs. Therefore, when discussing the scale of Lean projects, mathlib is often used as a reference point: a mature formalization library should reduce repetitive work through reuse, and line count is merely a byproduct of breadth of coverage. Without the support of public libraries like mathlib, comparing line counts in isolation easily leads to one-sided conclusions.

Divergence and Consensus in Community Discussion

Combining the original blog post with the discussion on Hacker News, several relatively clear facts emerge: the fact that Lean projects have reached the tens-of-millions-of-lines level shows that its toolchain can support large-scale collaboration; the community is cautious about treating line count as a quality metric; and the evaluation of formal verification requires more nuanced dimensions.

The divergence centers on how to interpret this scale. One view holds that 17 million lines proves that formal methods have moved beyond the small-scale experimental stage and possess the potential for industrial-grade application. Another view emphasizes that the value of formal projects lies in the theorems that are verified and the reusable mathematical structures, with line count being merely an incidental product; excessive focus on it can misdirect resource allocation.

Implications for Practitioners of Formal Verification

For teams that are using or considering adopting Lean, this discussion offers several practical perspectives. When evaluating a formal project, rather than focusing on total lines of code, it is better to examine the degree of modularization of the proofs, the quality of the dependency libraries, and the core propositions covered by verification. Line count can reflect the scale of investment, but it cannot replace a review of proof structure.

At the same time, the existence of large-scale Lean codebases itself places higher demands on the toolchain: compilation and checking time, dependency management, and collaboration conventions all become bottlenecks. This is also an aspect that is less mentioned in community discussion but has far-reaching practical impact.

Formal verification is in a transitional stage from academic research to engineering practice. The number 17 million is worth discussing not because it is large, but because it forces people to rethink: by what standards should we measure the correctness of machine-verifiable mathematics and software?

The compilation and checking time of formal projects is an often-underestimated engineering bottleneck. Lean's proof checking requires the kernel to verify line by line, and large projects can take hours when incremental compilation is insufficient. In addition, dependency management is especially sensitive in the formal ecosystem: an interface change to a low-level lemma may invalidate a large number of downstream proofs. Therefore, maintaining a large-scale Lean codebase tests not only mathematical ability but also engineering discipline, including version pinning, checking strategies in continuous integration, and interface stability conventions during collaboration. These factors directly affect whether a team can sustain a verifiable codebase over the long term.

#Lean#formal verification#theorem prover#mathlib#Hacker News
Share:

Related articles