A Lean 4 formalization of the Stacks Project, the open-source algebraic geometry reference, built on Mathlib with machine-checked proofs.
lean-dojo/LeanCopilot
LLM-powered proof automation for the Lean theorem prover, offering tactic suggestions, proof search and premise selection.
- Stars
- 1,341
- Forks
- 129
- Open issues
- 0
- Last commit
- 26 days ago
What is it?
Lean Copilot lets large language models run directly inside the Lean 4 theorem prover to automate parts of writing formal proofs. It provides tactics such as suggest_tactics, which proposes next proof steps, search_proof, which combines LLM-generated tactics with aesop to find multi-step proofs, and select_premises, which retrieves potentially useful lemmas from Lean and mathlib4.
The project ships with built-in models from LeanDojo, downloaded from Hugging Face, and runs them locally through CTranslate2, with or without a GPU. Users can also plug in their own models, either local or remote, through a generic generator and encoder interface or an external API server.
Lean Copilot is a Lean package added via lakefile configuration. It requires a Lean version of at least v4.3.0-rc2 and supports Linux, macOS, Windows and WSL, with prebuilt releases for most platforms.
Key features
- 01Suggests tactics for the current proof state, optionally constrained by a prefix.
- 02Searches multi-tactic proofs by combining LLM tactics with aesop.
- 03Retrieves relevant premises from Lean and mathlib4 with a LeanDojo retriever.
- 04Runs built-in or custom models locally via CTranslate2 or remotely via an external API.
- 05Exposes a general LLM inference interface usable beyond theorem proving.
Use cases
- Getting suggestions for the next tactic while writing a Lean proof.
- Automatically searching for short multi-step proofs of simple goals.
- Finding relevant lemmas in mathlib4 when you don't know their names.
- Building custom LLM-based proof automation or other applications inside Lean.
Quick start
- 1
Add the LeanCopilot require line to your lakefile
- 2
Fetch the LeanCopilot package
lake update LeanCopilot - 3
Download the built-in models from Hugging Face
lake exe LeanCopilot/download - 4
Build your project
lake build
Things to know
- Requires a Lean version of at least lean4:v4.3.0-rc2.
- On Linux, a lean_exe target needs extra linker configuration to build.
- search_proof can sometimes produce erroneous proofs.
- select_premises only covers a fixed snapshot of Lean and mathlib4.
In collections
Topics
FAQ
- What is LeanCopilot?
- LLM-powered proof automation for the Lean theorem prover, offering tactic suggestions, proof search and premise selection. Lean Copilot lets large language models run directly inside the Lean 4 theorem prover to automate parts of writing formal proofs. It provides tactics such as suggest_tactics, which proposes next proof steps, search_proof, which combines LLM-generated tactics with aesop to find multi-step proofs, and select_premises, which retrieves potentially useful lemmas from Lean and mathlib4.
- Is LeanCopilot free to use? What license does it have?
- LeanCopilot is open source under the MIT license. Check the license terms before using it in commercial products.
- Is LeanCopilot still maintained?
- Actively maintained. The last commit to LeanCopilot was on Oct 13, 2026.
- What can I use LeanCopilot for?
- Getting suggestions for the next tactic while writing a Lean proof. Automatically searching for short multi-step proofs of simple goals. Finding relevant lemmas in mathlib4 when you don't know their names. Building custom LLM-based proof automation or other applications inside Lean.
- How do I install LeanCopilot?
- Add the LeanCopilot require line to your lakefile Fetch the LeanCopilot package: lake update LeanCopilot Download the built-in models from Hugging Face: lake exe LeanCopilot/download Build your project: lake build
- Where can I get LeanCopilot?
- The source code and installation instructions are on GitHub: https://github.com/lean-dojo/LeanCopilot
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Lean 4 framework for specifying, executing, and formally verifying neural networks, with shape-checked tensors and PyTorch-style training.
A Lean 4 framework for machine-checked proofs of correctness and memory safety against compiled .NET CIL from C#, F#, and other .NET languages.
A programming language that uses laws and proofs to make AI-written code verifiable, and compiles to fast parallel CPU and GPU code.
Formally verified Ethereum primitives written in Lean, meant as a shared library of specifications and proofs for Lean projects.
Lean 4 ahead-of-time compiler that turns ordinary Lean programs into WebAssembly for Node, serverless, edge, WASI and browser targets.