Basic Examples (4)
Load the bundled example environment:
The example environment bundled with the paclet:
How many constants:
Of what kinds:
The example environment bundled with the paclet:
A single constant is a LeanTerm summary box:
Its type, pretty-printed as Lean source - the proposition it proves:
And the proof term:
The example environment bundled with the paclet:
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 example environment bundled with the paclet:
The "Parameters" property unfolds a theorem's binder chain - explicit, implicit, and instance arguments - as a Dataset:
Applications (3)
The example environment bundled with the paclet:
Open any theorem as a proof goal and step through it with tactics:
Introduce the proposition:
Then the hypothesis:
And close the goal with the hypothesis:
The proof is complete:
Transpile a Wolfram ProofObject into a checkable Lean environment:
The generated constants - premises, derived step, and goal:
Opening the final goal confirms the transpiled proof:
A Lean definition, compiled from source:
Lower a (non-dependent) Lean definition to native code via FunctionCompile:
Run it:
Properties and Relations (3)
LeanImportString round-trips with LeanExportString. Import a source string:
Query it:
And export it 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.35.0) installed via
elan: the ~190 MB Lean runtime is not bundled, so on first use LeanLink copies the shim into the user's cache (
$CacheBaseDirectory) and links
libleanshared from that toolchain next to the copy. It writes nothing into the paclet's own folder, which can be read-only or shared. Install it with
elan toolchain install leanprover/lean4:v4.35.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.
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):