LeanFlow
A fast, scalable, and easy-to-use Python interface to Lean 4.
LeanFlow lets you run Lean code, interact with proofs, and evaluate formal statements directly from Python.
Why LeanFlow?
- 🚀 Fast & Efficient: Built on
asynciofor high-throughput, parallel execution. - 🔄 Flexible Deployment: Seamlessly switch between Local Mode for development and Server Mode for scalable production workloads.
- 🎯 Evaluation Ready: Includes built-in metrics for autoformalization like
TypeCheckandBEq+(semantic equivalence).
Installation
Install LeanFlow via pip:
pip install leanflow
Install Lean 4
LeanFlow requires Lean 4 to be installed on your system. Check out the official Lean 4 installation guide for installation details.
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh
Quickstart
1. Run Locally (Development)
The simplest way to start. LeanFlow automatically manages the Lean environment for you.
from leanflow import SyncREPL
repl = SyncREPL(lean_version="4.24.0", require_mathlib=True)
result = repl.run("theorem add_zero_nat (n : Nat) : n + 0 = n := by sorry")
print(result)
2. Run as a Server (Scalable)
For heavier workloads or shared environments, connect to a remote LeanFlow server.
Create a config file (server.yaml):
server:
host: localhost
port: 8000
repl:
lean_version: "4.24.0"
Then, start the server:
leanflow-serve --config server.yaml
And connect from Python:
import asyncio
from leanflow import Client
async def main():
async with Client(base_url="http://localhost:8000") as client:
result = await client.run("theorem add_zero_nat (n : Nat) : n + 0 = n := by sorry")
print(result)
if __name__ == "__main__":
asyncio.run(main())
🌟 Inspiration & Acknowledgements
This project builds upon the incredible work of the Lean community. We are deeply grateful to the authors of the following projects, which directly inspired LeanFlow:
- LeanInteract by Auguste Poiroux
- Rethinking and Improving Autoformalization by Qi Liu
- Kimina by Project Numina
We highly recommend checking out these projects!
Special thanks to the Lean community, the contributors to Mathlib, and the authors of the Lean REPL, whose tools make this ecosystem possible.
License
LeanFlow is released under the MIT License.
Metadata
Release files for leanflow 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| leanflow-0.0.6.tar.gz | 60.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leanflow-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 127.4 kB
Release files / leanflow-0.0.6.tar.gz
| Download URL | leanflow-0.0.6.tar.gz |
|---|---|
| Size | 60.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f4313d0f33e04f1ac3b8c5f3a38998b92413b6ca99e8f6bafba83986f9f1e96
|
|
BLAKE2b-256 checksum How to use checksums |
d717176400f85347c2d6d375e166bbe474d0ef77263c47e163adcf10a92f509a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / leanflow-0.0.6-py3-none-any.whl
| Download URL | leanflow-0.0.6-py3-none-any.whl |
|---|---|
| Size | 67.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c96fb7951bd0982ace38b19f95907b5ce374b12df764859ff88339566fe9e486
|
|
BLAKE2b-256 checksum How to use checksums |
1f79f2743ac7990f1bfd4fa07c1c46c41e58a0e271133e20bafa2a8b07916920
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|