Skip to main content

Lean Runtime

Lean Runtime makes Lean projects and standalone proofs work without asking you to manage toolchains, dependency checkouts, exact environments, or caches.

python -m pip install lean-runtime

The daily workflow

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. 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. 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

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.0.1.tar.gz (770.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.0.1-py3-none-any.whl (675.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lean_runtime-4.0.1.tar.gz
  • Upload date:
  • Size: 770.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.0.1.tar.gz
Algorithm Hash digest
SHA256 1ff4faa1f8d437678e2826f430fdae534b4b2629c172bb870a354f59d55fe4f4
MD5 4a0b6a0f7b844adae740431edd835444
BLAKE2b-256 a714d35b2bbc340cbccd88647b2633ae70d48295229228bbe59a539e7cc62b86

See more details on using hashes here.

Provenance

The following attestation bundles were made for lean_runtime-4.0.1.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.0.1-py3-none-any.whl.

File metadata

  • Download URL: lean_runtime-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 675.6 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f88a245797c5fa5c6be8e45ecb8e9c5a763f20439d2c5eca7b449cc1598ebcc0
MD5 8f7293ae93aff6835dea7e351819bcc6
BLAKE2b-256 49db7a65290df71d14956f4b1bd90475a3839c35b33ba0bb7e3f7d9ab9fd8416

See more details on using hashes here.

Provenance

The following attestation bundles were made for lean_runtime-4.0.1-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

4.2.0

2 files

4.1.1

2 files

4.1.0

2 files

This release

4.0.1 This release

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