LeanDojo: Theorem Proving with Retrieval-Augmented Language Models

Kaiyu Yang, Aidan M. Swope, Alex Gu, Rahul Chalamala, Peiyang Song +4 more
6/27/2023
cs.LGcs.AIcs.LO

Official code: lean-dojo/LeanDojo (816 stars, MIT, last commit 2026-01-18). 2 more implementations below.

Abstract

Large language models (LLMs) have shown promise in proving formal theorems using proof assistants such as Lean. However, existing methods are difficult to reproduce or build on, due to private code, data, and large compute requirements. This has created substantial barriers to research on machine learning methods for theorem proving. This paper removes these barriers by introducing LeanDojo: an open-source Lean playground consisting of toolkits, data, models, and benchmarks. LeanDojo extracts data from Lean and enables interaction with the proof environment programmatically. It contains fine-grained annotations of premises in proofs, providing valuable data for premise selection: a key bottleneck in theorem proving. Using this data, we develop ReProver (Retrieval-Augmented Prover): an LLM-based prover augmented with retrieval for selecting premises from a vast math library. It is inexpensive and needs only one GPU week of training. Our retriever leverages LeanDojo's program analysis capability to identify accessible premises and hard negative examples, which makes retrieval much more effective. Furthermore, we construct a new benchmark consisting of 98,734 theorems and proofs extracted from Lean's math library. It features challenging data split requiring the prover to generalize to theorems relying on novel premises that are never used in training. We use this benchmark for training and evaluation, and experimental results demonstrate the effectiveness of ReProver over non-retrieval baselines and GPT-4. We thus provide the first set of open-source LLM-based theorem provers without any proprietary datasets and release it under a permissive MIT license to facilitate further research.

View on arXivView PDF

Code Implementations(3)

lean-dojo/LeanDojoOfficial100%
MIT

Tool for data extraction and interacting with Lean programmatically.

816116Lean, ShellJun 13, 20239 months agoMIT
leanlean4llmmachine-learningtheorem-proving
lean-dojo/ReProverOfficial100%
MIT

Retrieval-Augmented Theorem Provers for Lean

33172Shell, PythonMar 16, 20231 years agoMIT
leanlean4llmmachine-learningtheorem-proving
MIT

ChatGPT plugin for theorem proving in Lean

12515PythonJun 21, 20232 years agoMIT
chatgptchatgpt-pluginlarge-language-modelsleanlean4+2 more

Similar Papers

Cite this paper

@article{yang2023leandojo,
  title  = {LeanDojo: Theorem Proving with Retrieval-Augmented Language Models},
  author = {Kaiyu Yang and Aidan M. Swope and Alex Gu and Rahul Chalamala and Peiyang Song and Shixing Yu and Saad Godil and Ryan Prenger and Anima Anandkumar},
  year   = {2023},
  eprint = {2306.15626},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2306.15626v2},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.15626.svg)](https://codeofpaper.com/paper/2306.15626)

Discussion