Installation Instructions
To install this paclet in your Wolfram Language environment,
evaluate this code:
PacletInstall["Wolfram/LeanLink"]
To load the code after installation, evaluate this code:
Needs["Wolfram`LeanLink`"]
Examples
Basic Examples (4)
Load the bundled example environment:
How many constants, and of what kinds:
A single constant is a LeanTerm summary box:
Its type, pretty-printed as Lean source - the proposition it proves:
And the proof term:
Every expression is a tree; "ExprGraph" draws it:
"CallGraph" shows which constants a proof depends on:
Scope (2)
Import from Mathlib by pointing "ProjectDir" at a built mathlib4 checkout (gated so the page still builds without one):
The "Parameters" property unfolds a theorem's binder chain - explicit, implicit, and instance arguments - as a Dataset:
Applications (3)
Open any theorem as a proof goal and step through it with tactics:
Transpile a Wolfram ProofObject into a checkable Lean environment:
Lower a (non-dependent) Lean definition to native code via FunctionCompile:
Properties and Relations (1)
LeanImportString round-trips with LeanExportString: import a source string, query it, and export an environment back to Lean source:
ProofToLean complements MetamathImport - both bring an external formal-proof corpus into the Wolfram Language; LeanLink targets Lean 4 / Mathlib and additionally drives the prover interactively.
Possible Issues
The native bridge needs the platform shim under
LeanLink/LibraryResources/ and the Lean toolchain it was built against (
leanprover/lean4:v4.30.0) installed via
elan: the ~190 MB Lean runtime is not bundled, so on first use LeanLink links
libleanshared from that toolchain next to the shim. Install it with
elan toolchain install leanprover/lean4:v4.30.0. Mathlib import and the out-of-process graph functions (
LeanExprGraph,
LeanCallGraph) additionally need
lake on
PATH and a
built project -
LeanImport of an unbuilt module returns an empty environment.
LeanCompile's
dependent-type path (Vector-sized signatures via
TypePi) requires a forked Wolfram compiler; the non-dependent path works against the stock compiler.
A type shown in isolation can print an unresolved bound variable as #0 / #1; the full-theorem "TypeForm" resolves binder names.
Neat Examples (1)
The type of a Mathlib theorem, drawn as its expression tree (gated on a built checkout):
Disclosures
Compatibility
Wolfram Language Version 14.0
External Links
Version History
- 1.0.8
– 10 August 2026
- 1.0.7
– 08 August 2026
- 1.0.6
– 28 June 2026
- 1.0.5
– 27 June 2026
- 1.0.4
– 06 June 2026
- 1.0.3
– 06 June 2026
- 1.0.2
– 01 April 2026
- 1.0.1
– 31 March 2026
- 1.0.0
– 31 March 2026
MIT License
Paclet Source
See Also