TL;DR
Alchemy is a new framework that tackles the chronic data scarcity in automated theorem proving by "mutating" existing mathematical theorems into millions of new, valid ones. By systematically replacing terms with their logical equivalents or antecedents and verifying them with the Lean proof assistant, the authors expanded the standard Mathlib dataset from 110,000 to over 6 million theorems. This massive data augmentation leads to significant performance boosts for large language models (LLMs) trained for formal reasoning.
What Problem Does This Paper Address?
Neural Theorem Proving (NTP)—using AI to write formal mathematical proofs—is a "grand challenge" for machine learning. Unlike writing a poem or generating code, a formal proof must be 100% logically sound and verifiable by a computer (like the Lean proof assistant).
The biggest bottleneck in NTP is data scarcity. While LLMs have trillions of words of natural language to learn from, formal mathematical libraries like Lean’s Mathlib contain only about 110,000 theorems. This is several orders of magnitude smaller than what is typically needed to train robust reasoning models. Previous attempts to synthesize data often relied on "autoformalization" (translating natural language math to code), which is notoriously error-prone and difficult to scale.
Methods
The authors introduce Alchemy, a framework that operates entirely within the "symbolic space" of formal logic. Instead of dreaming up new math from scratch, it performs Symbolic Mutation on existing theorems to generate new, valid statements.
The process follows four main steps:
- Finding Invocable Theorems: For every theorem in Mathlib, the system searches for other theorems that could be "applied" to it or used to "rewrite" its terms.
- Mutation: It creates a new theorem statement by replacing a component of the original with something logically related.
rw(Rewrite): Replaces a term with an equivalent form (e.g., replacing $A$ with $B$ if $A=B$).apply(Implication): Replaces a goal with a sufficient condition (e.g., if $P \implies Q$, and we want to prove $Q$, we mutate the goal to $P$).- Proof Construction: To ensure the new theorem is actually provable, Alchemy uses a clever trick: it inserts a
havetactic into the proof. This essentially creates a "bridge" lemma that reverses the mutation, allowing the model to reuse the original, human-written proof. - Verification: Every synthetic theorem and proof is passed through the Lean compiler. If it doesn't "type-check," it’s discarded, ensuring 100% accuracy in the synthetic dataset.
Datasets
- Seed Data: Mathlib4, the standard library for the Lean 4 proof assistant (~110k theorems).
- Synthetic Data: The Alchemy corpus, which expanded the seed data to 6.3 million verified theorems.
- Evaluation Benchmarks:
- LeanDojo: A benchmark for testing provers on Mathlib theorems, specifically the "novel premises" split which tests the ability to use previously unseen mathematical rules.
- miniF2F: A challenging "out-of-distribution" benchmark featuring high-school competition math (AIME, AMC) and IMO-level problems.
Key Insights and Ideas
- The "Have" Tactic is a Game Changer: Instead of trying to generate a brand-new proof for a mutated theorem (which is computationally difficult), the authors used the
havetactic to logically link the new statement back to the old one. This guarantees a valid proof path exists. - Scaling via Mutation: By treating theorem proving like function construction in programming, the authors showed that "mutating" existing code is a far more efficient way to generate massive, high-quality datasets than trying to generate "synthetic thoughts" from scratch.
- Tactic-Specific Strengths: The researchers found that different mutation types help in different areas. The
rwtactic (equality) significantly improved performance in Algebra and Number Theory, while theapplytactic (implication) was more beneficial for Analysis and Topology. - Pretraining vs. Finetuning: The paper highlights that "continual pretraining" on these millions of synthetic statements helps the model understand the "landscape" of formal math before it even starts learning how to write the step-by-step proofs during supervised finetuning.
Key Results
- Performance Boost: Using the Alchemy-augmented data, a Llama-3-8B model achieved a 4.70% absolute improvement on the LeanDojo "novel premises" benchmark.
- Generalization: On the miniF2F benchmark (competition math), the model saw a 2.47% absolute gain, proving that synthetic data derived from a general library can help solve specific, difficult out-of-distribution competition problems.
- Efficiency: The method increased the size of Mathlib by an order of magnitude (from 110k to 6M theorems) using only CPU resources, demonstrating a highly cost-effective path to scaling formal math data.
Limitations and Future Work
- Tactic Diversity: Currently, Alchemy only uses two tactics (
rwandapply). Real-world proofs use dozens of specialized tactics (likeinductionorsimp). Expanding the mutation library is a clear next step. - Computational Complexity: Finding "invocable" theorems is currently an $O(N^2)$ problem, which becomes very expensive as the library grows. More efficient retrieval methods are needed.
- Single-Step Mutations: The current framework only performs one mutation at a time. "Multi-round" mutations—where a theorem is mutated, then that mutation is mutated again—could lead to even more complex and diverse synthetic data but would be harder to verify.
- Domain Knowledge: The system is currently "general-purpose." The authors suggest that adding domain-specific knowledge (e.g., specific rules for geometry) could improve the quality of the synthesized theorems.
Summary updated