Introduction
Magnushammer introduces a novel, transformer-based approach to "premise selection"—the task of finding relevant mathematical facts required to complete a formal proof. By leveraging contrastive learning on a massive new dataset, Magnushammer significantly outperforms the previous industry standard, Sledgehammer. It boosts proof success rates on the PISA benchmark from 38.3% to 59.5%, setting a new state-of-the-art for automated theorem proving.
The Challenge of Premise Selection
In the realm of formal mathematics, Interactive Theorem Provers (ITPs) like Isabelle act as rigorous judges, ensuring every step of a proof is logically sound. However, writing these proofs is incredibly tedious. To prove a new theorem, a mathematician must often cite specific "premises"—previously proven lemmas or definitions—from a library containing tens of thousands of facts.
Traditionally, this needle-in-a-haystack search is handled by "hammers" like Sledgehammer. These tools rely on complex, handcrafted symbolic filters and external automated theorem provers. While effective, they are difficult to maintain, hard to port to new logical systems, and have reached a performance plateau where adding more compute power yields diminishing returns. The authors ask: Can we replace these brittle symbolic heuristics with a scalable, deep-learning-based retrieval system?
Magnushammer's Architecture
To address these limitations, the authors introduce Magnushammer, a two-stage neural retrieval engine built on the Transformer architecture. Unlike previous methods that translate math into specialized logical formats, Magnushammer treats the proof state and premises as raw text.
- The SELECT Stage (Fast Filter): The model embeds the current proof state and all available premises into a shared vector space. It uses contrastive training (specifically InfoNCE loss) to ensure that relevant premises are close to the proof state in this space. At inference time, it calculates the cosine similarity to quickly retrieve the top 1,024 candidates.
- The RERANK Stage (Precise Filter): The model takes the top candidates from the SELECT stage and performs a more computationally expensive cross-attention pass. It evaluates the proof state and a candidate premise simultaneously to output a final, highly accurate relevance score.
The entire system is built on a shared transformer backbone (ranging from 38M to 86M parameters) pre-trained on vast amounts of technical content from GitHub and arXiv.
Training Data: The MAPL Dataset
Training a robust neural retriever requires massive amounts of data. The authors created and open-sourced the Machine-Augmented Proofs Library (MAPL), the largest premise selection dataset to date for the Isabelle assistant. It consists of:
- Human Proofs Library (HPL): 1.1 million (proof state, premise) pairs extracted from human-written proofs.
- Sledgehammer (SH) Partition: 3.3 million pairs generated by running the traditional Sledgehammer tool to find alternative ways to close proof steps.
Key Insights
- Text is a First-Class Citizen: A striking finding is that "high-level" textual representations of math are sufficient. Transformers do not need low-level logical formalisms to understand the relationship between a goal and a lemma.
- Extreme Data Efficiency: While the model was trained on millions of examples, pre-training on general technical text provided a massive head start. Magnushammer actually outperformed Sledgehammer with as few as 4,000 training examples (just 0.1% of the dataset).
- Scalability is King: Unlike symbolic methods that plateau, Magnushammer’s performance scales consistently with model size and the number of premises evaluated.
- Hard Negatives are Crucial: For the RERANK stage to be effective, the model had to be explicitly trained on "hard negatives"—premises that the SELECT stage incorrectly scored as highly relevant.
State-of-the-Art Results
Magnushammer represents a massive leap over existing automation tools:
- Single-Step Success: On the PISA benchmark, Magnushammer solved 59.5% of problems in a single step, compared to Sledgehammer’s 38.3%.
- Overall SOTA: When plugged into a multi-step neural prover called Thor, Magnushammer improved the overall proof success rate on PISA from 57.0% to 71.0%.
- Efficiency: It achieved these SOTA results using a model with 4x fewer parameters than previous leading neural approaches.
- Competition Math: On the difficult miniF2F test set, it outperformed Sledgehammer 34.0% to 20.9%.
Limitations and Future Work
Despite its power, Magnushammer has a few limitations:
- Semantic Depth: Because it treats math as text, it might miss deep semantic connections that aren't explicitly written out, such as implicit type conversions or complex object definitions.
- Integration: Currently, the retrieval (Magnushammer) and the generation (the language model writing the proof) are separate processes. Tighter integration—where the model retrieves facts while it generates the proof—is a promising next step.
- Cross-Language Generalization: While this paper focuses on Isabelle, the "text-only" approach should theoretically work for other languages like Lean or Coq. Testing this cross-language portability remains an area for future research.
Summary updated