Magnushammer: A Transformer-Based Approach to Premise Selection
Maciej MikulaSzymon TworkowskiSzymon AntoniakBartosz PiotrowskiAlbert Q. JiangJin Peng ZhouChristian SzegedyLukasz KucinskiPiotr MilosYuhuai Wu
Introduces Magnushammer, a transformer-based premise selection method that outperforms the symbolic Sledgehammer tool and increases automated theorem proving success on PISA from 57% to 71% with four times fewer model parameters.
Automated theorem proving and interactive proof assistants are essential tools for verifying complex mathematical reasoning and ensuring software correctness. However, a major bottleneck in formal verification is premise selection: the challenging task of retrieving a few relevant mathematical facts from libraries containing tens of thousands of lemmas to advance a proof. Traditional automation tools, such as Sledgehammer, rely on complex, hand-engineered symbolic heuristics and external provers. These traditional tools face diminishing returns as compute increases and require substantial engineering effort to adapt across different logical systems.
The article evaluates whether a purely data-driven, neural retrieval approach based on transformer models can outperform traditional symbolic methods on premise selection without requiring specialized domain engineering.
To address this question, the researchers developed Magnushammer, a generic transformer-based retrieval system. Magnushammer operates in two stages: first, an embedding-based contrastive selection stage rapidly narrows down tens of thousands of available facts to the top 1,024 candidates; second, a cross-attention reranking stage scores and reorders these candidates in the direct context of the current proof state. To train and evaluate the model, the authors created and open-sourced the largest formal premise selection dataset to date, comprising 4.4 million training pairs extracted from human-written proofs and machine-generated proofs in the Isabelle theorem prover.
The findings demonstrate that Magnushammer substantially outperforms established methods across standard benchmarks. In single-step proof automation on the PISA benchmark, Magnushammer achieved a 59.5% success rate compared to Sledgehammer's 38.3%, and achieved 34.0% versus 20.9% on the miniF2F competition benchmark. When integrated into Thor, a multi-step neural theorem proving system, Magnushammer established a new state of the art on PISA by lifting the overall proof rate from 57.0% to 71.0% while using a language model with four times fewer parameters. Furthermore, the approach exhibited strong data efficiency: a pre-trained Magnushammer model fine-tuned on just 0.1% of the training dataset (approximately 4,000 examples) still surpassed Sledgehammer. Even lightweight models with fewer than one million parameters outperformed the traditional baseline.
These results indicate that treating mathematical premises as standard text allows general deep-learning architectures to bypass the complex logic translations and external solvers that have historically limited theorem proving pipelines. By significantly improving retrieval precision, neural premise selection lowers the compute overhead and engineering cost needed to build automated assistants across diverse formal environments.
Organizations developing or deploying formal verification workflows should consider adopting neural retrieval pipelines as drop-in enhancements for existing hammer systems. Practitioners can also deploy the initial selection stage independently to enable fast, accelerator-free CPU inference using cached embeddings. Future initiatives should focus on testing Magnushammer across other interactive proof systems, such as Lean, and exploring end-to-end models that generate both proof tactics and premise arguments simultaneously.
While the findings demonstrate high reliability within the evaluated environments, the authors note that the current implementation relies strictly on textual representations provided by the proof assistant, omitting deeper semantic structures such as full type definitions. Confidence in the core performance gains remains high given consistent improvements across multiple compute budgets, model scales, and test suites.
- Paper: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, Patrick Lewis et al. (2020). Introduces Retrieval-Augmented Generation (RAG) using dense retrieval and transformer generation, providing foundational concepts for Magnushammer's dense premise retrieval methodology.
- Paper: Attention Is All You Need, Ashish Vaswani et al. (2017). Establishes the core Transformer architecture, including self-attention and cross-attention mechanisms, upon which Magnushammer's two-stage retrieval and reranking design is built.
- Paper: Measuring Mathematical Problem Solving With the MATH Dataset, Dan Hendrycks et al. (2021). Introduces the MATH dataset and benchmark framework for evaluating automated mathematical problem solving and reasoning in neural models.
- Paper: LEAP: Supercharging LLMs for Formal Mathematics with Agentic Frameworks, Po-Nien Kung et al. (2026). Extends automated formal theorem proving by introducing an agentic proof-decomposition framework in Lean that complements Magnushammer's premise retrieval pipeline.
- Paper: Search-o1: Agentic Search-Enhanced Large Reasoning Models, Xiaoxi Li et al. (2025). Generalizes neural retrieval during step-by-step reasoning by agentically interleaving web search into long-horizon reasoning trajectories.
- Paper: Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning, Bowen Jin et al. (2025). Applies reinforcement learning to train models to autonomously retrieve external information during multi-step reasoning tasks without explicit premise labels.
- Paper: AI Co-Mathematician: Accelerating Mathematicians with Agentic AI, Daniel Zheng et al. (2026). Expands premise selection and formal proof automation into an interactive, end-to-end agentic workbench assisting mathematicians with literature search and formal drafting.
