Shrinking a Formal Proof: How Global Collaboration Cut 2.4 Million Lines in Two Days — and How Small Can It Get?

    Large-scale formal proofs are entering an "engineering-driven compression" phase. This article examines a public community effort around the formalization of a proof related to the generalized Riemann hypothesis, where proof code grew to tens of millions of lines and was successively compressed to hundreds of thousands, tens of thousands, and further reduced by millions of lines in days. It covers why line count matters (and doesn't), the semantics-preserving refactoring techniques behind compression, layered proof artifacts that separate machine verification from human readability, engineering workflows for global collaborative compression, and what a realistic end state looks like. Note: this article discusses proof engineering and collaboration methods only; it does not endorse the correctness of the underlying mathematical claims, which still require rigorous peer review and long-term validation.

    Shrinking a Formal Proof: How Global Collaboration Cut 2.4 Million Lines in Two Days — and How Small Can It Get?

    Large-scale formal proofs are entering an “engineering-driven compression” phase. A public community effort has emerged around the formalization of a proof related to the generalized Riemann hypothesis: the proof code once reached the tens-of-millions-of-lines scale, was compressed to hundreds of thousands of lines, then tens of thousands, and was further slimmed by millions of lines within a short period. It must be emphasized that this article is about proof engineering and collaboration methods — it is not an endorsement of the correctness of the underlying mathematical claims. Mathematical proofs still require rigorous peer review and long-term validation.

    1. Why Line Count Matters — and Why It Doesn’t

    The core value of a formal proof lies in machine checkability: as long as the verifier accepts it, the proof term is semantically verified. Line count is therefore not a direct indicator of correctness. In real-world collaboration, however, line count significantly affects review cost, dependency comprehension, build time, conflict resolution, and knowledge transfer. A ten-million-line proof may be verifiable but nearly impossible for humans to review; likewise, a tens-of-thousands-of-lines proof that heavily relies on external libraries, macros, and automated tactics can be harder to read than a hundreds-of-thousands-of-lines version.

    The public effort’s compression trajectory went roughly from the 17-million-line scale down to 300,000 lines, then 76,000, and then around 52,000 lines. The case of cutting roughly 2.4 million lines within two days shows that, given established module boundaries and lemma libraries, substantial compression headroom remains. But the community also observed that the 52,000-line and 76,000-line versions may be less readable than the 300,000-line version. The reason: over-compression tends to fold proof logic into external library calls, tactic wrappers, and implicit automation. Machines verify it more easily, but humans find it harder to trace why the proof holds.

    Reasonable evaluation metrics should therefore go beyond line count and include at least: whether semantic-equivalence verification passes, dependency closure size, verification time and memory usage, manual review time, comment and documentation coverage, and the completeness of natural-language correspondences.

    2. The Essence of Compression: Semantics-Preserving Proof Refactoring

    Compression is not deleting code; it is proof refactoring under the constraint of preserved verifiable semantics. Common techniques include:

    • Extracting common lemmas: abstract repeated proof fragments into reusable lemmas to reduce duplication.
    • Merging repeated tactics: encapsulate stable proof steps as macros or tactics, while controlling the depth of encapsulation to avoid hurting readability.
    • Replacing expanded proofs with library theorems: calling mature theorem libraries dramatically shortens code but increases external dependencies and reading-context-switching costs.
    • Dependency pruning: remove unused lemmas and simplify the import closure to reduce build and comprehension overhead.
    • Proof-term refactoring: adjust inlining and outlining boundaries, layering “machine-friendly” and “human-friendly” content separately.
    • Automated search and candidate substitution: tools generate candidate compression schemes, which are then vetted by both the verifier and human reviewers.

    A general compression workflow can be abstracted as:

    1. compress(proof, readability_threshold):
    2. baseline = verify(proof)
    3. for rule in [extract_common_lemma, fold_macro,
    4. replace_with_library, prune_dependency]:
    5. candidate = apply(rule, proof)
    6. if verify(candidate) == baseline
    7. and readability(candidate) >= readability_threshold:
    8. proof = candidate
    9. return proof, metrics(proof)

    The key is the gate: after every compression step, perform full or incremental verification, lock dependency versions, keep audit records of diffs, and manually spot-check high-impact modules. Otherwise, “fewer lines” may simply mean the complexity has been shifted into invisible external dependencies.

    3. Multiple Artifacts: Separating Machine Verification from Human Reading

    The public materials include multiple artifacts: a 300-plus-page natural-language proof, a shorter natural-language version of dozens of pages, a formal correspondence document of dozens of pages, a 200-plus-page working draft, and a 100-plus-page conditional reconstruction. They serve different purposes: the long document provides full narrative and literature citations; the short version enables fast dissemination; the correspondence document bridges natural-language intuition and formal code; and the conditional reconstruction makes explicit internal assumptions and external theorems not yet aligned.

    This suggests an important principle: do not try to make a single artifact simultaneously serve machine verification, human reading, and rapid dissemination. A more workable release strategy is layered artifacts:

    1. Machine-verified core: the formal proof code, as the final checkable object.
    2. Human-readable synopsis: per-module explanations of key lemmas, proof ideas, and dependencies.
    3. Long-form natural-language document: full narrative, literature citations, and boundary statements.
    4. Formal correspondence table: mappings between natural-language sections and formal modules.
    5. Dependency and reproduction manifest: version locks, build steps, and verification environment descriptions.

    4. Engineering Workflows for Global Collaboration

    Global relay-style compression must avoid the chaos of “everyone edits their own piece and nothing merges at the end,” which requires engineering process support. First, build a dependency graph: split the proof into modules with clear boundaries and define lemma interfaces and input/output contracts. Second, adopt changesets and review mechanisms: every compression commit carries verification results, line-count changes, dependency changes, and readability notes. Third, set up an automated verification pipeline that runs builds, verification, dependency audits, and diff checks for every candidate version.

    A compression sprint can follow a closed loop: baseline snapshot → candidate compression → verification gate → readability review → rollback. Metrics to monitor, beyond line count, include verification pass rate, dependency closure size, verification duration, manual review time, comment coverage, and the frequency of high-frequency code jumps. For readability, introduce human scoring and sampled reading rather than judging by line count alone.

    5. How Small Can It Ultimately Get?

    There is no single answer divorced from goals. If the only requirements are machine verifiability and extreme compactness, tens of thousands of lines — or even fewer — are achievable. If the proof must be barely readable, reviewable, and maintainable by humans, a balance between compression and expansion is necessary. The 52,000-line figure may be a reference point for a compact version, but its readability may be weaker than larger versions. A more realistic goal is bi-objective optimization: make the machine version as small as possible with stable verification, and the human version as clear as possible while strictly corresponding to the machine version.

    Some researchers estimate that, if the proof is correct, a barely human-readable version could appear in the near future; others argue that page count is not the point — readability is — and that a hundreds-of-thousands-of-pages version can never be readable. Taken together, the endpoint of compression is not some magic line count, but the formation of a multi-layer proof engineering system that is verifiable, reviewable, reproducible, and disseminable.