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 in docs/. Start with docs/getting-started.md, docs/cli.md, and docs/local-projects.md.

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.0.tar.gz (767.2 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.0-py3-none-any.whl (675.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lean_runtime-4.0.0.tar.gz
  • Upload date:
  • Size: 767.2 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.0.tar.gz
Algorithm Hash digest
SHA256 9cf6b2a97484d424374417a9061f8220d9bdf40dca5dea3e0d55ceb1dedea544
MD5 31f732c07cc0110d60bb9ee9fdcaeeab
BLAKE2b-256 fc4f86b2c52c3b9d08d3c44eda2051af70958d03d4ea01d3ab85b2813814d058

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lean_runtime-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 675.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4374ff0f6bb6738fc1b0f01c32d5a26f9e05a6535b04f6a146cda377a87aa8ed
MD5 59b01b0e573df09e59a40e7450ba9497
BLAKE2b-256 95689108b28f2dc46b8d19acce8262f66995ed14e63ea7162ad6b412cc394be4

See more details on using hashes here.

Provenance

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

4.2.0

2 files

4.1.1

2 files

4.1.0

2 files

4.0.1

2 files

This release

4.0.0 This release

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