LeanSearch v2: Global Premise Retrieval for Lean 4 Theorem Proving
Guoxiong Gao Zeming Sun Jiedong Jiang Yutong Wang Jingda Xu Peihao Wu Bryan Dai Bin Dong School of Mathematical Sciences, Peking University IQuest Research Research Institute for Mathematical Sciences, Kyoto University Westlake Institute for Advanced Study, Westlake University Beijing International Center for Mathematical Research and the New Cornerstone Science Laboratory, Peking University Center for Machine Learning Research, Peking University Center for Intelligent Computing, Great Bay Institute for Advanced Study, Great Bay University Zhongguancun Academy Corresponding authors: [email protected] , [email protected] · 2026
Read LeanSearch v2: Global Premise Retrieval for Lean 4 Theorem Proving by Guoxiong Gao Zeming Sun Jiedong Jiang Yutong Wang Jingda Xu Peihao Wu Bryan Dai Bin Dong School of Mathematical Sciences, Peking University IQuest Research Research Institute for Mathematical Sciences, Kyoto University Westlake Institute for Advanced Study, Westlake University Beijing International Center for Mathematical Research and the New Cornerstone Science Laboratory, Peking University Center for Machine Learning Research, Peking University Center for Intelligent Computing, Great Bay Institute for Advanced Study, Great Bay University Zhongguancun Academy Corresponding authors: [email protected] , [email protected] (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-13137.txt.
Introduction
Gao and seven co-authors present LeanSearch v2, a two-mode retrieval system for global premise retrieval in Lean 4 theorem proving: finding the scattered library lemmas a whole proof needs. Standard mode pairs a hierarchy-informalised Mathlib corpus with an embedding-reranker pipeline, topping single-query retrieval without domain-specific fine-tuning. Reasoning mode iterates sketch-retrieve-reflect cycles over that substrate. On a 69-query benchmark of research-level theorems it recovers 46.1% of premise groups within 10 candidates, and in a fixed prover loop it reaches the highest proof success at 20%.
Catalog record
| CREATOR | Guoxiong Gao Zeming Sun Jiedong Jiang Yutong Wang Jingda Xu Peihao Wu Bryan Dai Bin Dong School of Mathematical Sciences, Peking University IQuest Research Research Institute for Mathematical Sciences, Kyoto University Westlake Institute for Advanced Study, Westlake University Beijing International Center for Mathematical Research and the New Cornerstone Science Laboratory, Peking University Center for Machine Learning Research, Peking University Center for Intelligent Computing, Great Bay Institute for Advanced Study, Great Bay University Zhongguancun Academy Corresponding authors: [email protected] , [email protected] |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 88131 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2605.13137
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
LeanSearch v2: Global Premise Retrieval for Lean 4 Theorem Proving Guoxiong Gao Zeming Sun Jiedong Jiang Yutong Wang Jingda Xu Peihao Wu Bryan Dai Bin Dong School of Mathematical Sciences, Peking University IQuest Research Research Institute for Mathematical Sciences, Kyoto University Westlake Institute for Advanced Study, Westlake University Beijing International Center for Mathematical Research and the New Cornerstone Science Laboratory, Peking University Center for Machine Learning Research, Peking University Center for Intelligent Computing, Great Bay Institute for Advanced Study, Great Bay University Zhongguancun Academy Corresponding authors: [email protected] , [email protected] Abstract Proving theorems in Lean 4 often requires identifying a scattered set of library lemmas whose joint use enables a concise proof—a task we call global premise retrieval . Existing tools address adjacent problems: semantic search engines find individual declarations matching a query, while premise-selection systems predict useful lemmas one tactic step at a time. Neither recovers the full premise set an entire theorem requires. We present LeanSearch v2, a two-mode retrieval system for this task. Its standard mode applies a hierarchy-informalized Mathlib corpus with an embedding–reranker pipeline, achieving state-of-the-art single-query retrieval without domain-specific fine-tuning (nDCG@10 of 0.62 0.62 vs. 0.53 0.53 for the next-best system). Its reasoning mode builds on standard mode as its retrieval substrate, targeting global premise retrieval through iterative sketch-retrieve-reflect cycles. On a 69-query benchmark of research-level Mathlib theorems, reasoning mode recovers 46.1 % 46.1\% of ground-truth premise groups within 10 retrieved candidates, outperforming strong reasoning retrieval systems ( 38.0 % 38.0\% ) and premise-selection baselines ( 9.3 % 9.3\% ) on the same benchmark. In a controlled downstream evaluation with a fixed prover loop, replacing alternative retrievers with LeanSearch v2 yields the highest proof success ( 20 % 20\% vs. 16 % 16\% for the next-best system and 4 % 4\% without retrieval), confirming that retrieval quality propagates to proof generation. We have open-sourced all code, data, and benchmarks. 1 1 1 Code and data are available at https://github.com/frenzymath/LeanSearch-v2 . 2 2 2 The standard mode is publicly available with API access at https://leansearch.net/ . 1 Introduction Rapid advances in Lean 4 and its central library Mathlib ( 30 ) have made formalization an increasingly accepted practice in the mathematical community, with the library now containing over one hundred thousand verified declarations spanning algebra, analysis, topology, and number theory. AI systems have further accelerated this trend, demonstrating growing capability in generating formal proofs ( 11 ; 24 ; 2 ) . A central challenge in working within this ecosystem is leveraging what Mathlib already contains. Locating the right library lemma carries two complementary benefits: a well-chosen result can collapse a lengthy derivation into a single tactic invocation, and reusing existing results is the community’s explicit coding standard. Mathlib prioritizes generality and actively discourages code duplication ( 20 ) ; indeed, “being able to find the library theorems you need constitutes an important part of formalization” ( 5 ) . This norm has direct consequences for automated provers: without effective retrieval, an AI system must repeatedly prove local versions of lemmas that already exist in the library for each problem it encounters, wasting computation and increasing proof difficulty. Yet finding the right lemmas is hard, not primarily because the library is large, though its scale compounds the problem, but because the connections require mathematical reasoning. Effectively applying a powerful theorem often demands reshaping the proof state to match its interface, generalizing or transforming the current goal in ways that temporarily complicate it, only to yield a far simpler overall proof by routing through a result in a seemingly unrelated area. The relevant lemmas are linked to the problem not by shared vocabulary but by the logical architecture of a proof strategy. Retrieving the set of supporting lemmas on which a complete proof should rest is a task we term global premise retrieval : identifying which library results are essential to the theorem’s overall proof strategy, considering the needs of the entire proof rather than what simplifies any single intermediate state. Example: Global Premise Retrieval Problem. Prove that \frac{x^{p}-1}{x-1} is irreducible in \mathbb{Z}[x] for every prime p . Supporting premises (from 3 distant Mathlib modules): Lemma Statement / Role geom_sum_mul Algebra.Ring.GeomSum (\sum_{i=0}^{n-1}x^{i})(x{-}1)=x^{n}{-}1 Establishes the algebraic identity. Polynomial.cyclotomic_prime RingTheory.Polynomial.Cyclotomic.Basic \Phi_{p}(x)=\sum_{i=0}^{p-1}x^{i} Identifies the quotient as the p -th cyclotomic polynomial. Polynomial.cyclotomic.irreducible RingTheory.Polynomial.Cyclotomic.Roots \Phi_{n} is irreducible over \mathbb{Z} for n>0 . Concludes the proof in one step. Note. The problem statement shares no vocabulary with these premises (“cyclotomic,” “geometric sum,” “ \Phi ” all absent). Identifying them requires reasoning about proof strategy, not lexical matching; the three lemmas chain together to close the proof, and missing any one leaves the argument incomplete. Figure 1: A global premise retrieval instance requiring three lemmas from distant Mathlib modules. Figure 1 illustrates why this task is difficult. The classical proof of irreducibility of (x^{p}{-}1)/(x{-}1) proceeds by substitution and Eisenstein’s criterion, but a more efficient proof in Lean bypasses this re-derivation entirely by routing through existing library results on cyclotomic polynomials, resolving the goal in one step once the algebraic equivalence is established. Recognizing that such a result exists is the first challenge, since the problem statement shares no vocabulary with the cyclotomic machinery. The second challenge is pinpointing the three specific lemmas that chain together to close the proof; missing any one leaves the argument incomplete. In graduate-level mathematics and beyond, this pattern is extremely common: a proof relies on a handful of supporting results dispersed across the library, connected not by shared terminology but by the logical architecture of the proof strategy. Two active research lines build retrieval tools for mathematics, yet neither addresses global premise retrieval. The premise selection line ( 34 ; 28 ; 26 ; 37 ) retrieves premises for a given proof state, improving tactic-level proving but operating at per-state granularity without considering what an entire proof requires. The reasoning retrieval line, catalyzed by the BRIGHT benchmark ( 27 ) , advances retrieval for queries requiring multi-step inference through reasoning-aware encoders, multi-stage pipelines, and LLM-based reranking ( 25 ; 18 ; 35 ) . However, current benchmarks evaluate each retrieved document’s relevance independently; these systems have not yet addressed the regime where multiple premises from different mathematical areas must jointly support a proof, nor the formal-language setting where problem statements may be deliberately reshaped to match a library theorem’s interface. Neither line is designed to recover a logically coherent set of premises for an entire theorem, where the elements are connected by the internal logic of a proof strategy rather than merely co-relevant to a query. We present LeanSearch v2 , a retrieval system designed for this task. Its standard mode serves as the foundation: it builds a hierarchy-informalized Mathlib corpus and retrieves against it with a two-stage embedding–reranker pipeline, without domain-specific fine-tuning. Its reasoning mode builds on standard mode as its retrieval substrate to target global premise retrieval directly: given a theorem statement, it generates a proof sketch, retrieves candidates for each proof step via standard mode, filters and judges the results, and iteratively revises the sketch until a coherent supporting-lemma set emerges. We evaluate on two new benchmarks: MathlibQR (Mathlib Queries), a 200 -declaration, 946 -query evaluation for standard-mode search, and MathlibMPR (Mathlib Merged Pull Requests), a