The Compression Limits of Million-Line Formal Proofs

    This article examines what "proof size" actually means in large formal verification projects, using a recent community-driven compression effort as a case study. It separates three independent metrics—source code volume, maintainable structure, and human-reviewable argument—and shows why fewer source lines can still mean more data for the checker after elaboration. It also outlines a practical slimming workflow and the engineering takeaways for reproducible verification pipelines.

    1. A Recurring Question: How Short Can a Proof Really Be?

    A mathematical proof generated with the help of AI coding tools was recently compressed collaboratively by developers across the public community. The original formalized version contained roughly 175,187 files and about 17 million lines of source code. A compact version released afterward was reduced to about 76,000 lines, while a readable version came in at around 300,000 lines—cutting on the order of 2.4 million lines within two days.

    Behind the excitement, the question worth asking as an engineering team is this: “how big is the proof” actually points to three different questions, and their answers do not agree with each other.

    • How short can the source code be while still passing machine verification?
    • How much structure must a formalized project retain to stay maintainable by researchers over the long term?
    • How much detail does an argument need so that mathematicians can read and independently review it?

    Conflating these three leads to the wrong conclusion that “fewer lines of source code is always better.” As the following sections show, line count is only a surface metric. What really drives cost is the size of the proof terms after expansion, maintainability, and reviewability.

    2. Three Kinds of “Length” Are Not the Same Thing

    A useful mental framework treats code volume, maintainable structure, and human-reviewable argument as three independent curves that can even conflict with one another.

    1. Code volume: measured by lines of source and file count, focused on “how much has been written.”
    2. Maintainable structure: measured by module boundaries, naming stability, and lemma layering, focused on “whether changes are safe.”
    3. Reviewable argument: measured by whether a human can reconstruct the chain of reasoning, focused on “whether someone else is willing to sign off.”

    The original version is usually large not because the mathematics is extensive, but because formalized projects are full of import declarations, repetitive wrappers, auto-generated helper lemmas, and guiding statements written to help automated search find intermediate steps. This content is useful to the machine but has almost no value for human readers, which makes it the first target for compression.

    3. The Overlooked Key Fact: Shorter Source, Bigger Data for the Checker

    What the machine actually checks is not the source itself but the proof terms obtained after the source is elaborated. A very short instruction in the source can make the proof assistant generate thousands of lines of internal derivation. One public independent verification showed that the compact version exported about 5.17 GB of proof data, while the readable version exported about 4.49 GB. The set with fewer source lines handed the checker more data.

    This leads to an important engineering judgment:

    1. source lines ≠ expanded proof term size ≠ verification time and memory usage

    So before discussing “how small can it get,” three things must be stated up front: whether you are measuring source or the expanded artifact; whether content already settled in the public library is counted; and whether memory and time during verification are a fixed budget or can be relaxed. Without these premises, any “minimum line count” is an incomparable number.

    4. Why the “Seemingly Redundant” Lines Must Stay

    From a maintenance perspective, module boundaries, stable naming, local comments, and lemmas split by layer are not redundancy. They control the blast radius of changes: when someone replaces an estimate, checks a boundary condition, or ports the project to another base library, they need to know immediately which dependencies a change will touch.

    A maintainable formalized project typically has these characteristics:

    • Layering: general lemmas at the bottom, domain results in the middle, the target theorem on top, with a single dependency direction.
    • Stable naming: names carry semantics, avoiding large-scale diffs from bulk renaming.
    • Local comments: explain “why it is split this way” rather than restating the code.
    • Replaceable interfaces: converge volatile estimates and assumptions into a few entry points so replacement stays contained.

    5. A Practical Slimming Workflow

    1. Establish a baseline: record four metrics—source lines, file count, expanded proof term size, and verification time.
    2. Deduplicate: identify repeated wrappers and equivalent lemmas, and merge them into a unified abstraction layer.
    3. Converge automation: wrap one-off automation tactics as named lemmas to reduce non-reproducible search scripts.
    4. Clean up generated artifacts: put auto-generated content in a separate directory, physically isolated from hand-written code, so it can be rebuilt as a whole.
    5. Layered acceptance: verify each layer separately to avoid being unable to localize a failure when the top layer fails.
    6. Regression monitoring: wire the four metrics into logging and alerting; trigger a review when size grows abnormally.

    6. Engineering Takeaways

    The real value of this kind of collaborative compression is not setting a new record for “shortest line count,” but confirming one thing: the cost structure of formalized projects can be measured and optimized. The same holds for ordinary software projects—storing historical artifacts in object storage, pinning the verification environment with a container platform, and decoupling long-running tasks with a message queue can all make “reproducibility” a default capability. If you need to run large-scale verification workloads, you can build an elastic pipeline on the general capabilities of a cloud platform such as Baidu AI Cloud, and make metric collection and alerting routine.

    The conclusion is clear: source code can be compressed to a very small size, but the maintainable and reviewable parts cannot. Define your measurement criteria first, then talk about compression limits—that is the rigorous engineering attitude.