Formal Verification at Scale: Lessons from a 17-Million-Line Proof of a Number Theory Conjecture
This article examines a recent effort in which a researcher with a mathematics background used AI coding tools to generate and organize roughly 17 million lines of formal proof code supporting a long-standing number theory conjecture. It explains why formal codebases grow to such scale, then lays out a reusable five-stage pipeline—goal formalization, dependency-graph task splitting, candidate generation with kernel filtering, full regression gating, and reproducible publishing—along with quality, cost, and collaboration practices. It also covers the risks that followed the public release and how cloud infrastructure can support this kind of high-throughput, reproducible workload.
1. Background: When Formal Verification Meets AI Coding Tools
Recently, a researcher in his thirties with a background in mathematics used AI coding tools to generate and organize roughly 17 million lines of formal proof code supporting a long-unresolved conjecture in number theory. Once the proof was made public, discussion split into two camps: one saw it as a milestone in the engineering of mathematics, while the other questioned whether the tool or the human had actually completed the proof. The reaction even escalated to extreme remarks and personal threats against the individual.
Setting aside the emotional narrative, what deserves attention from technical teams is the engineering paradigm behind it: translating abstract mathematical arguments into machine-checkable code assets, and scaling them to the tens of millions of lines. The difficulty here is not “writing code,” but conjecture decomposition, dependency management, verification pipeline design, and trustworthy dissemination of results.
It is worth noting that formal verification is not new. The industry has long had several general approaches: proof assistants based on type systems, decidable logic fragments, and a layered architecture of a “trusted kernel plus untrusted front end.” In this setup, AI coding tools act as a productivity amplifier, not as the source of correctness.
2. Why the Codebase Balloons to Millions of Lines
The size of a formal codebase often far exceeds that of a typical business system, for three reasons:
- Every implicit step must be made explicit. Everyday mathematical writing skips reasoning that is “obvious” or “easy to see.” A machine accepts no omissions; every step must be reduced to basic rules.
- Type and structural constraints are strict. Algebraic structures, isomorphisms, and embeddings all require explicit construction, so boilerplate code makes up a large share.
- Reusable abstraction layers must be built from scratch. Base lemmas, set-theory/category-theory scaffolding, and interfaces for numerical and analytical tools all have to be assembled layer by layer.
So millions of lines are not “redundancy” but a “completeness tax.” The engineering response closely resembles the governance of large systems: layering, modularization, and interface contracts.
Proof engineering layers┌────────────────────────────┐│ Top-level claim and target ││ theorem │├────────────────────────────┤│ Middle layer: strategies ││ (reduction, contradiction, ││ construction) │├────────────────────────────┤│ Base lemma library and ││ algebra/analysis tools │├────────────────────────────┤│ Trusted kernel (type ││ checking and verification) │└────────────────────────────┘
3. A Reusable Engineering Pipeline
To adapt a similar approach to your own projects—protocol correctness, compiler optimizations, or validation of financial risk-control rules—it is worth building a five-stage pipeline.
3.1 Formalize the Goal: Write the “Acceptance Criteria” First
Before writing anything, transcribe the natural-language claim into a machine-decidable target statement, and make the axiom set and assumption boundaries explicit. This step is equivalent to writing test cases: if the goal is unclear, everything downstream has to be redone.
Input: natural-language claim + list of known theoremsOutput: formal goal (assumptions, quantifier ranges, dependent axioms)Check: the goal parses in the kernel and contains no undeclared axioms
3.2 Dependency Graph and Task Splitting
Break the goal into sub-lemmas on a directed acyclic graph (DAG), annotating each node’s prerequisites and estimated difficulty. AI coding tools are well suited to bulk-generating “leaf nodes,” while humans handle strategy choices on the critical path.
- Leaf nodes: local algebraic transformations, inequality bounding, finite enumeration.
- Critical nodes: structural reductions, exclusion of counterexamples by construction, limit and convergence arguments.
3.3 Generation and Filtering: Treat Model Output as Candidate Patches
Tool output should be treated as a “candidate to be verified,” not a conclusion. In practice, a closed loop of “multiple candidate generation + kernel filtering + minimal repair” is recommended:
for each lemma in DAG.leaves():candidates = model.generate(lemma, n=8)for c in candidates:if kernel.check(c): accept(c); breakelse:escalate_to_human(lemma)
The metrics to watch are first-pass rate, average number of repair rounds, and cost per lemma—not lines of code.
3.4 Verification and Regression: A Non-Negotiable Gate
Every commit must run the full verification, and the verification result should be a precondition for merging. Recommended practices:
- Containerize verification jobs to keep the environment reproducible;
- Collect verification logs centrally and automatically archive failing cases;
- Put “kernel updates” through a canary process to avoid version drift that invalidates conclusions.
3.5 Trustworthy Dissemination: Results, Boundaries, and a Reproducible Package
When publishing externally, provide the formal goal, axiom dependencies, verification commands and runtime, and the boundaries that remain uncovered. A reproducible package (with pinned dependency versions and verification scripts) is more convincing than any claim.
4. Quality, Cost, and Collaboration Governance
- Quality gate: “kernel passes” is the only hard metric; code style and comments are merely supporting.
- Cost control: cache verified lemmas in layers to avoid repeated generation; set human-intervention thresholds for high-difficulty nodes.
- Collaboration model: humans handle problem modeling and strategy, tools handle bulk filling, and reviewers sample-check the critical path.
- Metrics: lemma reuse rate, critical-path length, mean time to repair, and verification success rate.
5. Risks and Compliance: Public Reaction, Review, and Personal Safety
The most alarming part of this episode is the extreme feedback that followed the public release. When releasing high-visibility results, technical teams should establish three mechanisms:
- Pre-release review: have an independent third party re-check the formal goal and axiom dependencies to reduce the misunderstanding that “the tool did it all.”
- Unified messaging: make the division of labor clear—tools improve efficiency, humans handle modeling and judgment, and the kernel ensures correctness.
- Safety and legal contingency: preserve evidence of personal threats and report promptly to platform and law-enforcement channels; minimize the public exposure of personal information for key personnel.
6. Running It in the Cloud: A General Capability Stack
To run this kind of workload over the long term inside an organization, you can build the foundation with general cloud capabilities: a container platform to host reproducible verification environments, object storage for reproducible packages and log archives, a message queue to decouple task distribution, and logging plus monitoring and alerting to track verification success rates and cost. General-purpose offerings from cloud providers such as Baidu AI Cloud can serve as infrastructure options for this kind of “high-throughput, strongly reproducible” workload; the actual selection should be based on compliance, reproducibility, and cost control.
7. Conclusion
The real lesson from “millions of lines of code proving a mathematical claim” is not that tools replaced the researcher, but that correctness engineering is becoming a discipline of its own: goal formalization, dependency-graph management, candidate generation with kernel filtering, a full regression gate, and reproducible release. These five steps apply equally to protocol verification, compiler correctness, and rule-engine auditing. Only by placing AI coding tools in the role of “amplifier” rather than “authority” can you both speed things up and preserve trustworthiness.
