Lean Runtime
Check the proof. Reuse everything else.
python -m pip install lean-runtime
Give Lean Runtime an ordinary file:
-- Main.lean
import Mathlib.Tactic.NormNum
example : 2 + 2 = 4 := by norm_num
$ lean-runtime check Main.lean
✓ Main.lean accepted in 2.60s
No Lake project, dependency checkout, or toolchain setup required. Lean Runtime discovers and verifies the exact environment, then keeps it ready for offline reuse.
Get started · Read the documentation · Explore the CLI
Start where you are
Create a project:
lean-runtime new MyProof
cd MyProof
lean-runtime check
lean-runtime build
Use an existing pinned Lake project from its directory:
lean-runtime check
lean-runtime adopt
adopt verifies the existing exact dependency graph, previews reuse and disk
recovery, asks for confirmation, and swaps dependency links atomically. It does
not change lean-toolchain or lake-manifest.json. Passing a directory that
contains several projects discovers them automatically:
lean-runtime adopt ~/research
Check a standalone source file:
lean-runtime check Main.lean
The same command uses the nearest pinned Lake project when one exists and
otherwise performs bounded exact-environment discovery. Automatic discovery
uses retained or verified downloadable environments; building a missing
candidate from source requires --allow-source-build. A file can carry its
context in strict comment frontmatter:
-- /// lean-runtime
-- requires = ["mathlib@v4.33.0"]
-- ///
import Mathlib
example : 2 + 2 = 4 := by norm_num
When inference needs an override, there is one spelling:
lean-runtime check Main.lean --using mathlib@v4.33.0
lean-runtime check Main.lean --using environment.lock.json
lean-runtime check Main.lean --using research-stack
lean-runtime check Main.lean --using lean:v4.33.0
lean-runtime check Main.lean --using ~/proofs/MyProject
Typed package:, lock:, env:, toolchain:, and project: prefixes resolve
rare ambiguities. A project context applies to files inside that project's
root. Persistent store, registry, and trust policy belongs in
environment configuration rather than everyday command lines.
Commands
The normal surface is deliberately small:
new NAME create a project
adopt [PATH] share dependencies from existing project(s)
check [PATH…] check a project, directory, source file, or stdin (-)
watch FILE re-check on save
build [TARGET] build the current project
update preview and apply a safe project update
publish configure verified project publication
status [PATH] explain the selected project or environment
verify SUBJECT verify an exact artifact
doctor diagnose and offer safe repairs
clean preview and reclaim unused storage
replay CAPTURE replay an execution capture
completion SHELL generate shell completion
Project commands use the current directory when no path is supplied. Guided
mutations show their plan and ask before changing anything; automation passes
--yes, and inspection-only calls pass --dry-run.
Persistent registry, availability, store, and publisher-trust policy belongs
in ~/.config/lean-runtime/config.toml; the nearest project's
lean-runtime.toml can override it. Daily commands therefore normally need no
configuration flags.
Exact and operator workflows live under noun namespaces:
env list · info · lock · acquire · diff · export · import
project info · scan · share · unshare · lock · export
program create · run · info · acquire · export · import · publish
toolchain list · info · install · optimize
storage usage · verify
catalog catalog maintenance
There are no v3 command aliases. run, init, prepare, open, download,
environments, inspect, compare, copy, finalize, lean-run, and
lean-runtime-catalog were removed in 4.0.
Existing Elan installations
Lean Runtime automatically reuses an exact compatible toolchain already
installed by the user's Elan. This access is read-only: it never changes the
user's default, installs into the user's Elan home, or removes user toolchains.
Missing toolchains and downloadable slim checking runtimes remain isolated in
Lean Runtime's private store. lean-runtime status and doctor expose the
choice when it matters.
Exact environments
lean-runtime env lock environment.toml --output environment.lock.json
lean-runtime env acquire environment.lock.json --name research-stack
lean-runtime env info research-stack
lean-runtime env diff previous.lock.json environment.lock.json
lean-runtime env export research-stack --output research-stack.lean-environment
lean-runtime env import research-stack.lean-environment --name imported-stack
Locks are canonical and content-addressed. Full environments preserve source; downloaded sparse capsules project only verified import closures and keep the same environment identity as their projection grows.
Python
import lean_runtime as lean
env = lean.setup(deps=["mathlib@v4.33.0"])
result = env.check("import Mathlib\nexample : 2 + 2 = 4 := by norm_num\n")
result.raise_for_error()
The Python API retains the explicit Runtime, EnvironmentSpec,
EnvironmentLock, project, capture, program, cancellation, and verification
interfaces for infrastructure code.
Guarantees and limits
- Exact Git commits, trees, locks, toolchains, platform identities, and artifact digests are verified before an environment becomes ready.
- Acquisitions and project sharing are staged, probed, and published atomically.
- User project metadata and user Elan state are not silently rewritten.
- The local execution backend enforces supported resource limits but is not a network sandbox; unsupported isolation requests fail explicitly.
- Logical Lean rejections exit 1; invalid/infrastructure invocations exit 2; publication failures retain their documented classified exit statuses.
Documentation lives at alerad.github.io/lean-runtime.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lean_runtime-4.1.1.tar.gz.
File metadata
- Download URL: lean_runtime-4.1.1.tar.gz
- Upload date:
- Size: 771.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700dd5acd8a7459932e63c48688936622a681147e5e25b14c89c5b023522686f
|
|
| MD5 |
9b2613d65fc559d1c8c820530388b77b
|
|
| BLAKE2b-256 |
99875f3e34697f3941a7ad4997e12afd7cf093bea91e8c702b75897901acfc7b
|
Provenance
The following attestation bundles were made for lean_runtime-4.1.1.tar.gz:
Publisher:
release.yml on alerad/lean-runtime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lean_runtime-4.1.1.tar.gz -
Subject digest:
700dd5acd8a7459932e63c48688936622a681147e5e25b14c89c5b023522686f - Sigstore transparency entry: 2543942804
- Sigstore integration time:
-
Permalink:
alerad/lean-runtime@1c66954d80d10f1f699252292912d13f179c3c56 -
Branch / Tag:
refs/tags/v4.1.1 - Owner: https://github.com/alerad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c66954d80d10f1f699252292912d13f179c3c56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lean_runtime-4.1.1-py3-none-any.whl.
File metadata
- Download URL: lean_runtime-4.1.1-py3-none-any.whl
- Upload date:
- Size: 689.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818dcc22ce47dfe617dc9d70095e45c463be39e1823d884152ab91f040810d2a
|
|
| MD5 |
d42f3f39988b0d566e31e9da140bf7ad
|
|
| BLAKE2b-256 |
e1c0f19fa8f73cdca27c0a8af1ebe3de687663a31afc1b0d496179b9949f7be3
|
Provenance
The following attestation bundles were made for lean_runtime-4.1.1-py3-none-any.whl:
Publisher:
release.yml on alerad/lean-runtime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lean_runtime-4.1.1-py3-none-any.whl -
Subject digest:
818dcc22ce47dfe617dc9d70095e45c463be39e1823d884152ab91f040810d2a - Sigstore transparency entry: 2543943447
- Sigstore integration time:
-
Permalink:
alerad/lean-runtime@1c66954d80d10f1f699252292912d13f179c3c56 -
Branch / Tag:
refs/tags/v4.1.1 - Owner: https://github.com/alerad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c66954d80d10f1f699252292912d13f179c3c56 -
Trigger Event:
push
-
Statement type: