Skip to main content

A Python interface for Lean 4.

Project description

LeanFlow

License: MIT Python Version Documentation

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.

LeanFlow Server Demo


Why LeanFlow?

  • 🚀 Fast & Efficient: Built on asyncio for 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 TypeCheck and BEq+ (semantic equivalence).

Installation

Install LeanFlow via pip:

pip install leanflow

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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leanflow-0.0.4.tar.gz (60.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leanflow-0.0.4-py3-none-any.whl (66.9 kB view details)

Uploaded Python 3

File details

Details for the file leanflow-0.0.4.tar.gz.

File metadata

  • Download URL: leanflow-0.0.4.tar.gz
  • Upload date:
  • Size: 60.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for leanflow-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5005a0331d70d9689da1622eb53bb75d48eb586db1b7b77cd6d1f0754addc84f
MD5 06ba3bbb791b4669554e5f8580f94893
BLAKE2b-256 b124f03667b94ab18c773e72fe55db3b26f6f4f1cf0e08b26ad7d5b2b22e12d5

See more details on using hashes here.

File details

Details for the file leanflow-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: leanflow-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 66.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for leanflow-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6631dfbf57953da4e2a72869cad986701f6ad16fdaf8e21d154858d0887deb15
MD5 6cfa867aed0074b3d90de5ec76ed26c8
BLAKE2b-256 85422d57f7cdf344d02e8a3a5b1271ee1ad53a19126a1608dd36911d9cd27dfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page