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#python'
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:
leanfran 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/ with your package, and add .leanfran/ to .gitignore. Run sync again when you change a Lean block.
Next steps
- Full Python guide: pydantic models, JSON,
@model, verification, CLI and limitations. - Samples, including pricing, word count and step-by-step examples.
- Development and implementation notes.
Metadata
Release files for leanfran 0.13.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| leanfran-0.13.1.tar.gz | 46.9 kB | With provenance | Details for leanfran-0.13.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| leanfran-0.13.1-py3-none-any.whl | Python 3 | none | any | Details for leanfran-0.13.1-py3-none-any.whl |
Total release size: 102.7 kB
Release files / leanfran-0.13.1.tar.gz
| Download URL | leanfran-0.13.1.tar.gz |
|---|---|
| Size | 46.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2ae092a8b137c7f033c165aadea4395f4993ba29f1e1246c1866f2c8a05c66f
|
|
BLAKE2b-256 checksum How to use checksums |
5b7c4e83dd0c0472edab25b6cbf46e39a905d6c43d117006584a91fe76629911
|
| 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 25, 2026.
Transparency logRelease files / leanfran-0.13.1-py3-none-any.whl
| Download URL | leanfran-0.13.1-py3-none-any.whl |
|---|---|
| Size | 55.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5274fa6d6f033966bc4a41e311e571ad7d80a83c4a9f777a6ac9167d6f3968fe
|
|
BLAKE2b-256 checksum How to use checksums |
68f50a2800ff9fac8495218c6c528f2e2c41bccae555047578326eda598eef33
|
| 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 25, 2026.
Transparency logSecurity for leanfran 0.13.1
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.
Attestation for leanfran-0.13.1.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 25, 2026.
Transparency logA 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.