让AI一次找出证明定理所需的所有关键前提,提升自动证明效率。
LeanSearch v2: Global Premise Retrieval for Lean 4 Theorem Proving

- 分两阶段检索:先用嵌入模型粗筛,再通过重排序精炼结果。
- 在69个高阶数学定理上,找回46.1%真实前提组,优于现有方法。
- 开源可用,适合研究形式化证明与AI辅助编程的开发者。
在Lean 4中证明定理常需从分散的库引理中识别出一组协同使用的前提——这一任务称为全局前提检索。现有工具仅解决局部问题:语义搜索匹配单个声明,前提选择系统逐步预测有用引理。二者均无法完整恢复整条定理所需的前提集合。本文提出LeanSearch v2,一种双模式检索系统。标准模式利用经层次结构建模的Mathlib语料库与嵌入-重排序流水线,在无需领域微调的情况下实现当前最优的单查询检索(nDCG@10达0.62,优于次优系统0.53)。推理模式以标准模式为检索基础,通过迭代的草图-检索-反思循环,实现全局前提检索。在包含69个研究级Mathlib定理的基准测试中,推理模式在前10个候选结果中找回46.1%的真实前提组,显著优于强基线系统(38.0%)与前提选择模型(9.3%)。在固定证明循环的受控下游评估中,将替代检索器替换为LeanSearch v2后,证明成功率提升至20%(次优系统为16%,无检索时仅为4%),验证了检索质量对生成证明的正向影响。所有代码、数据与基准均已开源。代码与数据:https://github.com/frenzymath/LeanSearch-v2。标准模式可通过API公开访问:https://leansearch.net/
原文摘要 · Abstract (English)
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 vs. 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% of ground-truth premise groups within 10 retrieved candidates, outperforming strong reasoning retrieval systems (38.0%) and premise-selection baselines (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% vs. 16% for the next-best system and 4% without retrieval), confirming that retrieval quality propagates to proof generation. We have open-sourced all code, data, and benchmarks. Code and data: https://github.com/frenzymath/LeanSearch-v2 . The standard mode is publicly available with API access at https://leansearch.net/ .
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。