← Latest papers
🤖 AI

LeanSearch v2: Global Premise Retrieval for Lean 4 Theorem Proving

LeanSearch v2 is a two-mode retrieval system that achieves state-of-the-art performance in identifying the complete set of library lemmas required for Lean 4 theorem proving, significantly outperforming existing semantic search and premise-selection tools and directly improving downstream proof success rates.

Original authors: Guoxiong Gao, Zeming Sun, Jiedong Jiang, Yutong Wang, Jingda Xu, Peihao Wu, Bryan Dai, Bin Dong

Published 2026-05-14
📖 5 min read🧠 Deep dive

Original authors: Guoxiong Gao, Zeming Sun, Jiedong Jiang, Yutong Wang, Jingda Xu, Peihao Wu, Bryan Dai, Bin Dong

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to solve a massive, complex jigsaw puzzle. You have a giant box of 100,000 pieces (the Mathlib library), and your goal is to build a specific picture (a mathematical proof).

The problem isn't that you don't have the pieces; it's that the pieces are scattered across the room, and the instructions don't say, "Use the blue sky piece here." Instead, you have to figure out that a piece about "geometric sums" and a piece about "cyclotomic polynomials" (which sound completely unrelated) actually fit together to solve your specific problem.

This is the challenge the paper addresses. It introduces LeanSearch v2, a new tool designed to find the right puzzle pieces for mathematicians working with the Lean 4 computer language.

Here is how the paper breaks it down, using simple analogies:

1. The Problem: "Global Premise Retrieval"

The authors say that existing tools are like two different types of helpers, but neither is perfect:

  • The Semantic Search Engine: This is like a librarian who finds a single book that matches a keyword. If you ask for "prime numbers," it finds books about primes. But it doesn't know that you need three specific theorems from three different sections of the library to solve your puzzle.
  • The Premise Selector: This is like a tutor who helps you with one step of the puzzle at a time. They say, "Okay, for this specific move, use this piece." But they don't see the whole picture. They don't know that you need to plan a route through the library that connects three distant ideas to finish the job.

The paper calls the missing skill "Global Premise Retrieval." It's the ability to look at a problem and say, "To solve this, I need to pull these three specific, seemingly unrelated lemmas from the library and chain them together."

2. The Solution: LeanSearch v2

The authors built a two-mode system to solve this, acting like a smart research assistant with two different personalities.

Mode A: The "Standard Mode" (The Super Librarian)

This is the foundation. It acts as a high-speed search engine for the library.

  • How it works: It takes the entire library of 100,000+ math declarations and translates them from "computer code" into "human-friendly descriptions." It then uses a two-step process:
    1. Embedding: It turns every piece of text into a mathematical "fingerprint" to find similar concepts.
    2. Reranking: It takes the top 50 matches and uses a second, smarter AI to re-sort them, picking the absolute best ones.
  • The Result: It finds the right single piece of information better than any previous tool, even without being specifically trained on math data. It's like having a librarian who knows the library so well they can find the exact book you need just by hearing a vague description of it.

Mode B: The "Reasoning Mode" (The Detective)

This is the big innovation. It doesn't just look for one piece; it tries to find the whole set of pieces needed for a proof.

  • How it works: It uses a "Sketch-Retrieve-Reflect" loop, which is like a detective solving a mystery:
    1. Sketch: The AI makes a guess at the "story" of the proof (e.g., "First we do X, then we use Y, then Z").
    2. Retrieve: It uses the "Standard Mode" librarian to find the actual pieces for each step of that story.
    3. Reflect: A "Judge" AI looks at the results. Did the pieces fit? If the librarian couldn't find a piece for step Y, the Judge says, "That story doesn't work."
    4. Revise: The AI goes back, changes the story (the sketch), and tries again.
  • The Result: It keeps looping until it finds a coherent set of library lemmas that actually work together to solve the theorem.

3. The Evidence: Did it Work?

The authors tested this system on two main challenges:

  • The Search Test: They asked the system to find specific theorems based on descriptions. LeanSearch v2 won, finding the right answer more often than its competitors.
  • The "Global" Test: They gave it 69 difficult, graduate-level math problems and asked it to find the group of lemmas needed to solve them.
    • The Competitors: Old tools found the right group of pieces only about 9% to 38% of the time.
    • LeanSearch v2: Found the correct group of pieces 46.1% of the time.
    • The "Proof" Test: They plugged this tool into a robot that tries to write proofs. When the robot used LeanSearch v2, it successfully finished proofs 20% of the time. Without the tool, it only succeeded 4% of the time.

4. The Bottom Line

The paper claims that LeanSearch v2 is the first system to successfully treat math retrieval as a "reasoning" task rather than just a "search" task.

  • Analogy: Previous tools were like a GPS that could only tell you the next street to turn. LeanSearch v2 is like a GPS that can plan the entire trip, realizing that to get to the destination, you might need to take a scenic route through a neighborhood you didn't know existed, and it knows exactly which turns to take to get there.

The authors emphasize that this is a tool for retrieval (finding the right tools), not necessarily for generating the proof itself, though better retrieval clearly helps the proof-generation process succeed more often. They have made all their code and data public so others can use this "detective" approach to solve math problems.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →