Skip to main content

Python

leanfran for Python: write Lean blocks with lean(...), expose Lean types as pydantic models, and verify supported Python functions against Lean specifications.

Install

uv add leanfran
nix profile install 'github:conao3/lean-leanfran#leanfran'

Install the Python package and the compiler from the same release; leanfran exits 255 when their versions differ. Generation also requires Lean 4.35.0 (lean and lake) on PATH. Generated modules run with the Python package and pydantic.

First Lean block

Create src/myapp/__init__.py and put this in src/myapp/arith.py:

from leanfran import lean

arith = lean("arith", r"""
def double (n : Nat) : Nat := n + n

theorem double_eq (n : Nat) : double n = 2 * n := by
  unfold double; omega
""")

Generate the Python modules:

uv run leanfran --lang python sync --package src/myapp

Then call the function from your application:

from myapp.arith import arith

assert arith.double(21) == 42

Commit src/myapp/_lean/ and leanfran.manifest.json with your package. sync writes .leanfran/.gitignore, which keeps its workspace out of git. Run sync again when you change a Lean block, and run uv run leanfran --lang python status --package src/myapp in CI to check that the committed files are up to date.

Next steps

Metadata

Release files for leanfran 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leanfran 0.15.0
File Size Uploaded Provenance Actions
leanfran-0.15.0.tar.gz 47.1 kB With provenance Details for leanfran-0.15.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for leanfran 0.15.0
File Interpreter ABI Platform Actions
leanfran-0.15.0-py3-none-any.whl Python 3 none any Details for leanfran-0.15.0-py3-none-any.whl

Total release size: 103.4 kB

Release files / leanfran-0.15.0.tar.gz

Download URL leanfran-0.15.0.tar.gz
Size 47.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2196b9dba53b15ad5c3418d2baa7736669c43634b363ff08f702acab426f1dc7
BLAKE2b-256 checksum
How to use checksums
c2fa94d980e58d0a2ed842cfea6f05424bf9e7f38826d255aba515e7f9ae631c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / leanfran-0.15.0-py3-none-any.whl

Download URL leanfran-0.15.0-py3-none-any.whl
Size 56.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bd116e73345cf34bae7cb506fcd4ec77a27351268979678c431042f14a41f5f
BLAKE2b-256 checksum
How to use checksums
cb7947b0b36bc51361d7b438321cec9f62972970fa6d9e6bb9437ae9b4601da0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for leanfran 0.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for leanfran-0.15.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page