Collaborative Compression of a Formal Riemann Hypothesis Proof: How Small Can the Code Get?
A public collaboration rapidly reduced a formal generalized Riemann hypothesis proof from tens of millions of lines to tens of thousands. This article explains why that work is proof-engineering governance, not mere deletion, and why line count must not replace machine checkability, readability, and auditability.
Collaborative Compression of a Formal Riemann Hypothesis Proof: How Small Can the Code Get?
1. What actually happened: proof-asset governance, not “deleting code”
Around a formalization of the generalized Riemann hypothesis, an open collaboration compressed proof scripts from tens of millions of lines in a short time. Public timeline figures include an initial version of more than 17 million lines, a reduction of about 2.4 million lines in roughly two days, and later versions around 300,000, 76,000, and about 52,000 lines.
On the surface this looks like line-count compression. From an engineering view it is large-scale proof-asset governance: removing duplicate proofs, unifying lemma names, merging similar derivations, extracting shared abstractions, cleaning auto-generated redundancy, locking dependency boundaries—and keeping every step machine-checkable.
The central rule is that formal proof compression must not sacrifice verifiability. Every merge, abstraction, and substitution must be re-checked by a proof checker. Otherwise compression is text editing, not trusted proof engineering. For large formal projects, line count is a surface metric. Quality is decided by checker pass rate, dependency clarity, build time, audit cost, and human readability.
2. Scale evolution and the readability paradox
Dropping from more than 17 million lines to 300,000, then 76,000 and about 52,000, is easy to grasp. Fewer lines do not automatically mean more readable code. Public discussion noted that the ~52k and 76k versions may be less readable than the 300k version. Aggressive compression often relies on stronger macros, deeper abstraction, more automated tactics, and more external library calls, so readers must learn more implicit conventions.
A joke “one-liner that calls an external library for the whole proof” marks the boundary: self-containment versus reuse. Delegating most of the proof to libraries can make line count tiny, but readers must trust those libraries, understand their contracts, and confirm versions and hypotheses match. For assets that must be maintained and audited, “minimal” is not always better than a medium-size, clearly structured version. The goal is not a single minimum line count, but a Pareto balance among trusted verification, readability, maintainability, and build efficiency.
3. How 2.4 million lines can disappear in two days
Large cuts usually are not hand edits line by line. Typical engineering moves include:
- Deduplication and lemma unification: extract repeated fragments into shared lemmas.
- Batch rewrite and pattern replacement: unify names, argument order, and proof structure.
- Remove generated redundancy: drop redundant steps, repeated premises, and unused intermediates.
- Merge similar proofs: parameterize structurally close cases.
- Replace long expansions with abstract calls: wrap verbose expansions in higher lemmas, with a documented mapping.
- Reuse verified libraries: avoid rebuilding known theorems, while pinning versions and hypothesis bounds.
- Formatting and comments: unify indent, names, and comments without changing proof meaning.
These are structured refactors, not text shrinking. Each round should be an atomic change that passes a full proof check. Otherwise large merges can inject implicit hypotheses or break traceability of proof terms.
4. Natural-language proofs and formal scripts complement each other
Alongside the scripts, public materials included natural-language versions: a full natural-language proof of about 322 pages, an English version of about 43 pages, a Simplified Chinese version of about 38 pages, and about 56 pages of formal correspondence, citing about 47 references. There were also a ~265-page working draft and a ~117-page conditional reconstruction that does not claim to be a complete proof and notes incomplete alignment of internal hypotheses with external theorem literature.
Mature proof engineering needs three layers: natural-language proof for human review and mathematical intuition; formal scripts for machine checking; correspondence documents mapping the two. Fewer pages of prose do not imply fewer formal lines, and fewer formal lines do not imply better human readability. The valuable practice is to maintain correspondence among theorem statements, proof ideas, formal lemmas, dependency hypotheses, and check results so readers can follow high-level logic and locate machine-checked details.
5. What actually sets a lower bound on size
There is no unique “how small” without constraints. Lower bounds depend at least on:
- Library boundary: how many external verified theorems are allowed, i.e. self-containment.
- Reuse of proof structure: more repetition means more room after abstraction.
- Automation: stronger tactics hide explicit steps but can hurt readability and debugging.
- Readability requirements: human-review versions need explanatory structure and names.
- Audit requirements: tracing every hypothesis and external theorem makes over-compression costly.
- Build resources: heavier abstraction can increase checking time; fewer lines need not mean lower compute.
A reasonable target is a multi-version policy: a minimal checkable build, a readable review build, a teaching build, and an audit-mapping build. Different readers need different artifacts; one line-count KPI should not capture every goal.
6. Quality gates for collaborative compression
The main risks of global relay compression are interface drift and silent hypothesis spread. Suggested gates:
- Every refactor must pass a full formal check; no “merge first, fix later.”
- Pin dependency versions; record external-theorem hypotheses and scope in correspondence docs.
- Unify naming; public lemmas must state inputs, outputs, and side effects.
- Separate readability review from line-count review so structure is not sacrificed for size.
- Map documents so each key natural-language step locates a formal lemma.
- Monitor build time, check failure rate, and dependency count so compression does not rebound verification cost.
- Isolate external theorems that are not fully literature-aligned; keep them out of “complete proof” versions.
Illustrative pseudocode (structure of abstract calls plus traceable comments, not a real tool syntax):
theorem Generalized_Riemann_Hypothesis_statement:for all objects s meeting the conditions, if hypothesis H holds, then conclusion C holds.proof:introduce s and hypothesis H-- reuse verified lemmas: analytic continuation, functional equation, zero-region estimatesapply global_zero_free_region_lemmaapply functional_equation_symmetryfrom zero_estimates and explicit_formula conclude Cqed-- correspondence:-- step 1 -> natural-language proof section X-- step 2 -> external lemma L, hypotheses A1/A2 pinned
7. Takeaways for engineering teams
The same lessons apply to large software or proof assets: compression must rest on automated verification, atomic changes, and traceable documentation. Line count is an observation metric, not the only KPI. Teams should also track readability, dependency clarity, check pass rate, and long-term maintenance cost. How small you can go depends on how much external dependency, implicit abstraction, and human review cost you accept. For trusted proof engineering, the best version is not the smallest—it is the one that balances machine checkability with human understanding.
