Premise Selection for a Lean Hammer

Thomas Zhu, Joshua Clune, Jeremy Avigad, Albert Qiaochu Jiang, Sean Welleck

TL;DR

This paper introduces LEANPREMISE and LEANHAMMER, creating the first end-to-end, domain-general "hammer" tool for the Lean 4 proof assistant. By combining a novel neural premise selector with symbolic proof automation, the system successfully automates tedious verification steps, solving 21% more theorems than existing tools and dynamically adapting to user-defined local contexts.

What Problem Does This Paper Address?

Interactive proof assistants like Lean allow mathematicians and engineers to verify the absolute correctness of software, hardware, and mathematical theorems. However, formalizing a proof is notoriously painful. Users must explicitly name every single definition and lemma (chosen from libraries containing hundreds of thousands of options) to justify even minor logical steps.

In other proof assistants like Isabelle, a tool called a "hammer" alleviates this pain by automatically finding relevant premises, translating the problem to powerful external automated theorem provers (ATPs), and reconstructing the proof back inside the assistant. Because Lean relies on dependent type theory and lacked an integrated pipeline, it previously lacked a domain-general, end-to-end hammer.

Methods

The authors present LEANHAMMER, a unified pipeline that connects neural retrieval with symbolic reasoning.

Figure 1: Overview of the LEANHAMMER pipeline. Phases that can neither fail nor produce a terminal proof are green, phases that can fail but cannot produce a terminal proof are yellow, and phases that can produce a terminal proof are blue. Black solid arrows indicate control flow, while red dashed arrows indicate the transfer of information between phases.

The pipeline consists of several key components:

  1. LEANPREMISE: An encoder-only transformer model trained using a modified InfoNCE contrastive loss to retrieve the top-$k$ most relevant premises for a given proof state.
  2. Aesop: A proof search tactic that applies the retrieved premises directly.
  3. Lean-auto: A translation tool that converts Lean’s complex dependent types into higher-order logic problems.
  4. External ATPs (Zipperposition): Solves the translated logic problems.
  5. Duper: Reconstructs the proof back into Lean based on the premises used by Zipperposition.

"Hammer-Aware" Data Extraction

Unlike prior models that only predict the next step in a proof, LEANPREMISE uses a novel data extraction strategy optimized for finishing entire proofs. It normalizes signatures (disabling surface-level syntax and notation pretty-printing), extracts premises from both term-style and tactic-style proofs, and captures implicit premises called behind the scenes by automated tactics like simp or rw.

API Integration

To make it practical for everyday use, the authors built a fast client-server architecture. The server caches embeddings for the massive standard library (Mathlib) and dynamically computes embeddings for new, local lemmas defined by the user on the fly.

Usability comparison of existing premise selection tools

Datasets

The model was trained on data extracted from Lean’s core libraries: Mathlib, Batteries, and Lean core. This yielded 469,965 proof states across 206,005 theorem proofs, resulting in over 5.8 million training pairs.

For evaluation, the authors used:

  • A held-out test split of Mathlib.
  • miniCTX-v2-test: A challenging benchmark designed to test out-of-domain generalization on diverse repositories outside of Mathlib.

Key Insights and Ideas

  • Hammers Need Different Data Than Tactic Generators: Traditional neural theorem provers train on the "next tactic string." LEANPREMISE proves that extracting the entire set of premises used in a human proof—including implicit ones—dramatically improves a hammer's success rate.
  • Neural and Symbolic Methods are Complementary: The neural approach (LEANPREMISE) and the traditional heuristic approach (MePo) excel at different types of problems. Combining them yields a performance boost greater than simply scaling up the neural model size.
  • Low Latency is Achievable: By utilizing FAISS for similarity search and caching standard library embeddings, premise selection takes around 1 second, making it highly usable within an IDE.

Key Results

Evaluated on Mathlib-test, LEANHAMMER powered by LEANPREMISE (large model, 82M parameters) achieved a 30.1% proof rate on its own, and 33.3% when accumulating variants (cumul).

When combined with the symbolic selector MePo, the success rate jumped to 39.6%, approaching the theoretical upper bound of 43.0% (the success rate if the model had perfect 100% recall of ground-truth premises).

Table 2: Performance of LEANHAMMER with different premise selectors on Mathlib-test.

The system also demonstrated robust out-of-domain generalization on the miniCTX-v2 dataset, maintaining high proof rates even on libraries it had never seen during training.

Out-of-Mathlib performance of LEANHAMMER on miniCTX-v2-test

Limitations and Future Work

Despite its success, LEANHAMMER still faces bottlenecks:

  • Translation Gaps: 26.7% of failures occurred because Lean-auto could not translate complex dependent type theory features into higher-order logic.
  • Reasoning Limits: External provers like Zipperposition struggle with specific domains like advanced arithmetic or induction.
  • Future Directions: The authors suggest improving Lean-to-logic translation layers and integrating complementary internal tactics (like Lean 4's upcoming grind tactic) to handle arithmetic and structural reasoning gaps.

Summary updated

BibTeX
@inproceedings{zhu2026premise,
  author = {Thomas Zhu and Joshua Clune and Jeremy Avigad and Albert Qiaochu Jiang and Sean Welleck},
  title = {{Premise Selection for a Lean Hammer}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=m04JJNeRK6},
}
Figure