TL;DR
As mathematics formalized in Lean 4 explodes in volume, finding the right lemma in Mathlib—Lean’s massive mathematical library—has become a bottleneck for both humans and AI agents. LeanExplore Bench introduces a fair, 3,200-query benchmark across four distinct search styles, revealing that while top search engines almost always retrieve a correct answer in their top 10 results, they still struggle to rank it first and to answer real-world questions from Lean’s community forums.
What Problem Does This Paper Address?
Formalizing mathematics in Lean 4 is booming, with 2026 alone seeing major formalizations like Fermat’s Last Theorem and sphere packing. Yet reusing any of this work depends on finding the right declaration (theorem, definition, etc.) in Mathlib.
Several Lean search engines have popped up—like Lean Finder, LeanSearch, Octo Search, and LeanExplore—but comparing them has been messy. Authors typically evaluate their engines on benchmarks they designed themselves, which naturally favour their own system's strengths. Worse, existing benchmarks often label only a single correct declaration per query, even though Mathlib frequently states the same mathematical fact in multiple ways. If an engine returns an equally valid alternative, it gets marked wrong.
Methods
To level the playing field, the authors built LeanExplore Bench with a few key design choices:
- Equal weighting across search styles: Rather than mirroring any single engine's user logs, the benchmark weights four query types equally: names and keywords, natural language, formal statements and proof states, and real questions derived from Lean Zulip threads.
- LLM-assisted generation and judging: For the first three buckets, language models (Claude Opus 5.5 and Sonnet 5.5) wrote queries for target Mathlib declarations, while a separate model family (GPT-6.1 Terra) acted as a judge to ensure quality. Real questions were derived from Zulip threads where users asked if a result existed.
- Pooling for multiple answers: To avoid penalizing engines for returning valid alternative lemmas, the authors pooled the top 10 results from multiple engines (including Loogle) and had Claude Opus 5.5 grade them blindly from 1 to 3. Anything graded 2 ("useful after an obvious adaptation") or 3 ("answers directly") counts as a hit, adding 2,026 extra answers across 1,253 queries.
- Index-date fairness: Every answer had to exist under the same name and module in a January 2026 snapshot of Mathlib, ensuring engines with slightly older indices aren't unfairly penalized.
The authors also introduce Lumen, a development version of LeanExplore tuned on the benchmark's development split. Lumen combines dense embeddings (Qwen3-Embedding-8B) and BM25 candidates, then ranks them using LightGBM trees, a cross-encoder (Qwen3-Reranker-4B), and a final proprietary LLM reranker (Jev 1.14.0).
Datasets
LeanExplore Bench consists of 3,200 queries (640 in the development split, 2,560 in the test split), split into four buckets of 800 queries each:
- Names and keywords: Exact names, partial names, and keyword combinations.
- Natural language: Plain-English descriptions, sometimes mixed with Lean names.
- Formal: Lean statements, patterns, and proof states (goals).
- Real questions: Search queries derived from real Lean Zulip discussions.
Unlike MathlibQR (946 expert-written queries, no proof states, and heavily skewed toward structures/classes) or LeanSearch's 50-query set, LeanExplore Bench mirrors Mathlib’s actual distribution—about 80.5% theorems—and grades multiple valid answers per query.
Key Insights and Ideas
- Multiple right answers matter—a lot: Counting the extra pooled answers raised the hosted engines' scores by 8 to 12 points. Even so, the overall ranking of the engines stayed the same.
- Ranking, not retrieval, separates the leaders: The top two hosted engines, Lean Finder and LeanSearch, are nearly tied in getting a correct answer into the top 10 (92.6% vs. 91.3%). The real gap is putting it first: Lean Finder nails the #1 spot 77.8% of the time, compared to LeanSearch’s 62.8%.
- Real questions are the final boss: Every engine struggles most on queries derived from Zulip threads. For 64 out of 640 test questions, none of the hosted engines returned a valid answer, compared to just 12 out of 1,920 written queries.
- Overall scores hide specific blind spots: LeanExplore’s weakest area is formal queries (27.6 MRR@10), where it falls behind even a simple BM25 baseline (46.4) because it never compares a query's Lean statement directly against a declaration's statement. Conversely, Lean Finder stumbles on single-name queries (67.8), scoring below BM25 (76.1).
Key Results
Evaluated on the 2,560 test queries using MRR@10 (Mean Reciprocal Rank at 10, as a percentage):
- Hosted engines: Lean Finder leads at 83.4, followed by LeanSearch (73.6), Octo Search (67.0), and LeanExplore (48.4). A simple BM25 baseline scores 31.4 (a lower bound, as its results weren't pooled for extra answers).
- Lumen: The development version of LeanExplore scores 92.5 overall, and 81.2 on real questions (15.3 points ahead of Lean Finder). However, on the three written buckets, Lumen benefits from searching the exact descriptions the query-writing models saw.
Limitations and Future Work
The authors note that both the queries and the relevance grades were generated by language models and have not yet been reviewed by humans—a natural next step. Because extra answers were only sought among the six tested systems, valid declarations that none of them returned remain unlabelled. Additionally, the written queries may slightly favour LeanExplore/Lumen (since the query writer saw LeanExplore's descriptions), while the Zulip-based questions may overlap with Lean Finder's unreleased training data. Finally, Lumen’s final reranker is a paid, proprietary model, meaning reproducibility depends on its continued availability.
Summary updated