olean-export
A Rust swiss army knife for reading and manipulating .olean files, usable from the CLI or inside Rust kernels, without running Lean.
- Emits lean4export NDJSON, much faster
- BLean, a compact binary export format
- Cone export of chosen constants
- Statement cones, a theorem's proof-free trusted base
- Per-module exports pinned by hash, with
join - Modular checking with module-system-restricted imports
- Closure keys and accepted store for incremental checking
inspectandcomparefor oleans and exports
The object layout is tied to the Lean release. This version reads olean format v2 as written by Lean 4.26 through 4.35, and refuses files from any other release.
Add --features mimalloc to build with the mimalloc allocator.
Example
examples/Hello.lean is compiled to an olean with plain lean:
def double (n : Nat) : Nat := n + n
theorem double_two : double 2 = 4 := rfl
Export one theorem with everything it depends on, then check it with a kernel such as nano-lean. Inside a Lake project, lake env sets LEAN_PATH for you, so you can run:
)
BLean
Blean is a new binary format that is more efficient to mmap and read than NDJSON.
Add -f blean for the same stream in a compact binary form, see docs/BLEAN.md.
Cone Export
A cone is a set of constants plus everything they mention. Without -c the export is the cone of every constant in the loaded modules, like lean4export.
-c NAME(repeatable) exports the full cone ofNAME, proofs included. Only theorem values inside the cone are decoded, the rest stay in their oleans.statement -c NAMEfollows only the statement: types, definition bodies and whole inductive families, no proofs. Theorems it reaches are taken as stated. It prints raw terms with source lines for review (-m Ncuts long terms), or with-f ndjson|bleanexports the cone with theorems as axioms for a checker.statement --trust MODULESleaves out what those modules, or modules under them, define, so you can review the trusted base of a Tau Ceti theorem without reading all of Tau Ceti.
Incremental
--per-module DIR writes one export per module, pinned to its imports by hash, and join merges them back into one. keys prints a closure key per declaration, and accepted lists a store of keys checkers have already accepted.
--interfaces gives modular checking with module-system-restricted imports. Each module is written against what Lean showed it, with its exports in out/public/, and join -m gives one module over its imports' interfaces.
Inspect
inspect summarizes an olean's imports, constants and bytes per section. -c lists every constant.
)
)
)
Compare
compare diffs two exports, NDJSON or blean, ignoring record order, ids and binders.
Performance
Modules decode in parallel on every core, and -j N sets the thread count. The output is identical for any -j. --rss shows peak resident memory.
Wall time:
| Target | lean4export | olean-export | Speedup |
|---|---|---|---|
Small model on Lean |
18.3s | 1.0s | 18x |
| All of Mathlib | 1526s | 18s | 85x |
One Mathlib theorem (-c) |
16.5s | 5.3s | 3x |
Peak memory:
| Target | lean4export | olean-export |
|---|---|---|
Small model on Lean |
1.3 GB | 0.5 GB |
| All of Mathlib | 9.4 GB | 4.3 GB |
One Mathlib theorem (-c) |
5.6 GB | 2.0 GB |
Mathlib is on Lean 4.35.0 (712,205 declarations, identical under compare), and the theorem is Fin.insertNth_apply_succAbove.
License
MIT Licensed. Copyright 2026 Stephen Diehl. See LICENSE for details.