Start here¶
This guide checks one core Lean file and one file that imports Mathlib. It then records an exact environment for later reuse.
Requirements¶
- Python 3.10 or newer
- Git
- macOS or Linux for automatic Elan bootstrap
- On Windows, an existing Elan installation identified by
LEAN_RUNTIME_ELAN
Install Lean Runtime¶
lean-runtime doctor reports the runtime home, platform support, toolchain manager, and relevant configuration.
Check a core Lean file¶
Create Basic.lean:
Check it directly:
Lean Runtime selects a plausible catalog context and runs Lean. Exit code 0
means Lean accepted the file in the reported context.
Check a file that imports Mathlib¶
Create Primes.lean:
import Mathlib.Data.Nat.Prime.Infinite
example : ∀ n : ℕ, ∃ p, n ≤ p ∧ p.Prime :=
Nat.exists_infinite_primes
Run the check without specifying a context:
For a standalone file, Lean Runtime uses imports as evidence for automatic discovery. It tries exact catalog environments within a bounded policy. A candidate succeeds only when Lean accepts the source in that environment.
The first run may install a toolchain and acquire environment content. Later checks reuse retained content.
Record an exact lock¶
Write the environment used by a successful check:
Use the lock on a later run:
After the required toolchain and environment content are available locally, the same check can prohibit network access:
Offline mode does not acquire missing remote content. Missing requirements produce an infrastructure failure rather than a Lean rejection.
Troubleshoot or override selection¶
status previews routing without running Lean:
Most checks should rely on discovery. Use --using only when a particular
release or context is part of the request:
See Context selection for frontmatter, project precedence, and other explicit context forms.
Interpret the result¶
| Exit code | Meaning |
|---|---|
0 |
Lean accepted the source. |
1 |
Lean ran and rejected the source. |
2 |
Invocation, context, acquisition, or configuration failed, or a resource limit such as --timeout was hit. |
130 |
The operation was interrupted. |
Use --json for structured results and --verbose for the runtime event stream.