1700万行Lean代码验证黎曼猜想有多长?
Yes, 17M lines of Lean is a lot
直观量化了AI在形式化数学证明中的代码产出规模,对关注Agent工程极限与AI辅助科研的同学极具参考价值。
Yes, 17m lines of Lean is a lot
是的,1700万行的Lean代码确实很多
2026-11-22
The recent proof of the Riemann hypothesis came with a statistic attached: the proof is 17 million lines of Lean. Beyond the philosophical questions of what it means to have a proof longer than any human could comprehend, I’m left with a simpler question: is that as large as it sounds?
黎曼猜想最近的证明附带了一个统计数据:该证明包含1700万行Lean代码。除了关于“证明长度超过任何人类所能理解”这一现象的哲学思考外,我留下了一个更简单的问题:这真的像听起来那么多吗?
To investigate, I hunted for collections of Lean proofs online. I found two and charted the lengths of their proofs.
为了调查此事,我在网上搜寻了Lean证明的集合。我找到了两个,并绘制了它们证明长度的图表。
(All charts have a log x axis, which makes 17m lines look a lot closer to 1m and 100k than it really is.)
(所有图表的x轴均为对数坐标,这使得1700万行看起来比实际情况更接近100万行和10万行。)
Famous theorems in Mathlib
Mathlib中的著名定理
Mathlib maintains a collection of famous proofs. There are over 1k but only 259 have Lean associated, which I chart here.
Mathlib维护着一个著名证明的集合。其中超过1千个,但只有259个关联了Lean代码,我在这里对这些进行了图表化展示。
These are all human generated, and as we can see, they come nowhere close to 17m.
这些都是人工生成的,正如我们所见,它们与1700万行相差甚远。
Every Lean package on Reservoir
Reservoir上的每个Lean包
Reservoir indexes every published Lean package, 938 of which have Lean code on GitHub. This one has a lot more data, including AI assisted proofs. We even have a few that are over 16m!:
Reservoir索引了所有已发布的Lean包,其中有938个在GitHub上拥有Lean代码。这个数据集包含更多数据,包括AI辅助的证明。我们甚至有几个超过1600万行的!:
- 88m: Qiuzhen-CFSG/CFSG this appears to be an AI built proof that is still a work in progress.
- 36m: CBirkbeck/LeanBridge, a project linking the LMFDB database of number theory objects to Mathlib. This isn’t really a proof: about 98% of its Lean is files generated by scripts that check the database’s numbers one by one. The hand-written part is closer to 500k lines.
- 27m: anthropics/fermats-last-theorem is another Anthropic special: a complete proof of Fermat’s Last Theorem, published on GitHub in September. Its README says “the Lean sources were produced by AI agents building on human-written open-source Lean”, including the human FLT project led by Kevin Buzzard, which is about 60k lines and still in progress. The AI version is roughly 450 times longer.
- 8800万行:Qiuzhen-CFSG/CFSG,这似乎是一个仍在进行中的AI构建证明。
- 3600万行:CBirkbeck/LeanBridge,这是一个将LMFDB数论对象数据库链接到Mathlib的项目。这实际上不是一个证明:其Lean代码中约98%是由脚本生成的文件,用于逐一检查数据库中的数字。手写部分更接近50万行。
- 2700万行:anthropics/fermats-last-theorem是Anthropic的另一个特别项目:费马大定理的完整证明,于9月在GitHub上发布。其README指出,“Lean源代码由基于人工编写开源Lean的AI代理生成”,其中包括Kevin Buzzard领导的人工FLT项目,该项目约为6万行且仍在进行中。AI版本大约是其450倍长。
So yes, 17m lines is a lot.
所以是的,1700万行确实很多。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力