Skip to main content

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

lean_runtime-4.2.0.tar.gz (843.3 kB view details)

Uploaded Source

Built Distribution

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

lean_runtime-4.2.0-py3-none-any.whl (757.1 kB view details)

Uploaded Python 3

File details

Details for the file lean_runtime-4.2.0.tar.gz.

File metadata

  • Download URL: lean_runtime-4.2.0.tar.gz
  • Upload date:
  • Size: 843.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lean_runtime-4.2.0.tar.gz
Algorithm Hash digest
SHA256 7fc5583311e400b7a6b1a9454ad65338a9bc413e2bb7eed5bdb7724e34df8da5
MD5 3bdd8a193071d31d7c450c152e857104
BLAKE2b-256 e741917aafd30cb7fec97d144afb4a87286e133c93fbe5bae978ebbbc3916415

See more details on using hashes here.

Provenance

The following attestation bundles were made for lean_runtime-4.2.0.tar.gz:

Publisher: release.yml on alerad/lean-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lean_runtime-4.2.0-py3-none-any.whl.

File metadata

  • Download URL: lean_runtime-4.2.0-py3-none-any.whl
  • Upload date:
  • Size: 757.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lean_runtime-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0abbde6249b8702045e9dbee65a1e3e075209eae8b8ae1237f4fbd09eb993c3d
MD5 dfcc2dd2a0df191f82c695633c82924f
BLAKE2b-256 f6ee294ecac51fec14840e0dd81f15dee20c373ad1dc52ecb9b65f0f1aab208b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lean_runtime-4.2.0-py3-none-any.whl:

Publisher: release.yml on alerad/lean-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

4.22.0

2 files

4.21.0

2 files

This release

4.2.0 This release

2 files

4.1.1

2 files

4.1.0

2 files

4.0.1

2 files

4.0.0

2 files

3.0.3

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.10.0

2 files

2.9.2

2 files

2.9.1

2 files

2.9.0

2 files

2.8.0

2 files

2.7.0

2 files

2.6.2

2 files

2.6.1

2 files

2.6.0

2 files

2.5.0

2 files

2.4.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.9

2 files

2.0.8

2 files

2.0.7

2 files

2.0.6

2 files

2.0.5

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.0.0

2 files

0.6.0

2 files

Supported by

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