LeanCert
v1 overhaul licensing: Post-baseline Python SDK work is source-available under a provisional evaluation license. Personal evaluation, non-commercial research, education, and bounded commercial, governmental, or other organizational proofs of concept are permitted; production and commercial use require written terms. Python SDK versions through
v0.3.2-apache-final, LeanCert Core, and LeanCert Bridge remain separately available under Apache-2.0. See LICENSE.
Formal verification for numerical Python code, powered by Lean4.
Write Python, get mathematical proofs. LeanCert proves properties about your code for all inputs, not just test samples.
Installation
pip install leancert
That's it! The package includes pre-built binaries - no Lean installation required.
Bridge binaries are sourced from the decoupled leancert-bridge release tag
pinned in bridge-version.txt.
The v1 overhaul also includes a bridge-independent, exact semantic model under
leancert.ast. Its versioned encoding, binder rules, claim closure, and legacy
conversion boundary are documented in Semantic AST v1.
The typed line-protocol negotiation and checked-response invariants are
documented in Python protocol model v2.
The semantic claim front door is documented in
Unified checked proving.
Verified bounds from Bridge Contract 2.1+ can also be exported as
independently rebuildable Lean evidence.
Bridge Contract 2.3 extends the same workflow to unique nonlinear-system roots
certified by exact rational Krawczyk certificates; NumPy and SciPy candidates
remain untrusted inputs.
Bridge Contract 2.4 adds exact reciprocal-power eventual bounds with supplied
or automatically discovered natural-number cutoffs.
Exported projects can be audited without rerunning Python or numerical search:
leancert verify exported_proofs/ --require-trust kernel
After installation, leancert doctor checks the bundled binary, negotiated
contract, replay support, adaptive checked route, and release provenance.
Quick Start
import leancert as lc
from leancert import ast
# Define an exact semantic claim
x = ast.var("x")
claim = ast.sin(x) <= 1
# Check it for every x in the closed interval [0, 1]
result = lc.prove(claim, where={x: (0, 1)})
if isinstance(result, lc.Verified):
print(f"Verified claim {result.claim_id}")
print(result.provenance)
else:
print(type(result).__name__, result.reason)
# Two-sided claims use an explicit conjunction.
two_sided = lc.prove(
ast.all_of(x >= 0, x <= 1),
where={x: (0, 1)},
)
# Discover and certify a cutoff for every n at or beyond it.
from fractions import Fraction
n = ast.var("n", sort=ast.NATURAL)
eventual = lc.prove(
ast.eventually(3 / n**2 <= Fraction(1, 1000), variable=n)
)
Neural Network Verification
Verify properties of neural networks across entire input domains:
import leancert as lc
from leancert.nn import TwoLayerReLUNetwork, Layer
import numpy as np
# Create/load a neural network
layer1 = Layer.from_numpy(
weights=np.array([[2.0, -2.0], [-2.0, 2.0]]),
bias=np.array([0.0, 0.0]),
activation='relu'
)
layer2 = Layer.from_numpy(
weights=np.array([[1.0, 1.0]]),
bias=np.array([0.0]),
activation='none'
)
network = TwoLayerReLUNetwork(layer1=layer1, layer2=layer2)
# Prove output bounds for ALL inputs in domain
verified = lc.verify_nn_bounds(
network,
{'x0': (-1, 1), 'x1': (-1, 1)},
output_lower=-5,
output_upper=5,
)
print(verified) # True - proven for every possible input!
Key Features
- Checked Bounds: Typed LeanCert checker outcomes with exact provenance
- Neural Networks: Verify ReLU networks, transformers
- Root Finding: Locate and isolate roots with guaranteed correctness
- Integration: Compute integral bounds
- Independent Audit: Rebuild exported fixed certificates with
leancert verify - PyTorch Import: Load weights directly from PyTorch models
Supported Functions
sin, cos, tan, exp, log, sqrt, abs, sinh, cosh, tanh, atan, erf, sinc, and more.
Why LeanCert?
Traditional testing samples inputs: f(0.5), f(1.0), etc. You can never test f(0.7) and the infinitely many values in between.
LeanCert uses interval arithmetic to check properties for all inputs
simultaneously. Every Verified result identifies the checker, Golden Theorem,
verification route, numerical backend, and exact bridge build that accepted the
certificate. Independently rebuildable Lean projects are a separate export
milestone rather than an implicit claim of this runtime API.
Verified, Rejected, Unsupported, DomainObstruction, and Inconclusive
are distinct outcomes. An enclosure that is too wide produces Inconclusive;
failure to find a counterexample is never reported as proof. Bridge Contract
2.2 provides a separate typed adaptive certificate route backed by LeanCert's
checked rational optimizer. It can close subdivision leaves that the fixed
replayable checker cannot, but is not mislabeled as a replayable bound-check/2
certificate.
Links
License
Post-baseline v1 Python SDK material is source-available under the provisional LeanCert Evaluation License 1.0. Personal evaluation, education, non-commercial research, and a bounded 90-day commercial, governmental, or other organizational proof of concept are permitted. Qualifying nonprofit education and non-commercial research are not subject to that 90-day limit. Production deployment, commercial product development, customer services, and SaaS/API deployment require a separate written commercial license. Generated reports, certificates, and proof artifacts lawfully created during permitted use remain free to retain, publish, and use, including commercially; this does not grant continued rights to execute the SDK. See COMMERCIAL.md for the commercial boundary and LICENSE_SCOPE.toml for the authoritative source classification.
Python SDK material through commit 716cb2d, preserved by the tag
v0.3.2-apache-final, remains available under Apache-2.0. LeanCert Core,
LeanCert Bridge, and third-party components retain their separate licenses.
See LICENSE,
LICENSES/LeanCert-Evaluation-1.0.txt,
and LICENSES/Apache-2.0.txt.
Metadata
Release files for leancert 1.0.0
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 | |
|---|---|---|---|---|
| leancert-1.0.0.tar.gz | 152.0 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| leancert-1.0.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| leancert-1.0.0-py3-none-manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| leancert-1.0.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| leancert-1.0.0-py3-none-macosx_10_15_x86_64.whl | Python 3 | none | macOS 10.15+ x86-64 | Details |
Total release size: 159.7 MB
Release files / leancert-1.0.0.tar.gz
| Download URL | leancert-1.0.0.tar.gz |
|---|---|
| Size | 152.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ea1a97be6137c91b7eb19ca91c62f4b4b548f775d5b32ccf3665254750d50ca
|
|
BLAKE2b-256 checksum How to use checksums |
2cd6907c626be7a1c3a769ed240cb887a97834f483c93012fd0f2399946b844c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 2, 2026.
Transparency logRelease files / leancert-1.0.0-py3-none-win_amd64.whl
| Download URL | leancert-1.0.0-py3-none-win_amd64.whl |
|---|---|
| Size | 42.7 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a2afac06214190cdd2abaebb41b213d8deaa84e0195bec749cef3b08ea1648f7
|
|
BLAKE2b-256 checksum How to use checksums |
2a7dd19517fbbc672301d8bd0d61afe0a647135c5e742c431d4ff3c5855cb0ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 2, 2026.
Transparency logRelease files / leancert-1.0.0-py3-none-manylinux2014_x86_64.whl
| Download URL | leancert-1.0.0-py3-none-manylinux2014_x86_64.whl |
|---|---|
| Size | 41.9 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
c4b43a593d6318cc3bd281f1cab597dea3603fd543e63c477a579a71caf9a8fb
|
|
BLAKE2b-256 checksum How to use checksums |
1075b1762ccd54782b2be9f9f9a9711ca7ba3638688553b142c62bb9ecaab06c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 2, 2026.
Transparency logRelease files / leancert-1.0.0-py3-none-macosx_11_0_arm64.whl
| Download URL | leancert-1.0.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 37.5 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
af683bffeef03e7b6c3b0a7e923e4a39592709f126c4419877070b500a968dcf
|
|
BLAKE2b-256 checksum How to use checksums |
7772779d6ca42f4af726bea434f4a4f1c8629ea9122b07cbc50cb002dc010119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 2, 2026.
Transparency logRelease files / leancert-1.0.0-py3-none-macosx_10_15_x86_64.whl
| Download URL | leancert-1.0.0-py3-none-macosx_10_15_x86_64.whl |
|---|---|
| Size | 37.5 MB |
| Tags | Python 3 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
2b224d77ee44cc1654fd1b01fb372332faead6d6fd924c61cc28ddc22b1ec696
|
|
BLAKE2b-256 checksum How to use checksums |
b2e213f3ea4bbf97b4856d5138c9dfbd50f4845b09fccb1494f87d907b76aeda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 2, 2026.
Transparency logSecurity for leancert 1.0.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
All 5 files in this release have been uploaded with provenance metadata.
Attestation for leancert-1.0.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 Aug 2, 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.