Wolfram Language Paclet Repository
Community-contributed installable additions to the Wolfram Language
Native link between Wolfram Language and Lean 4
Contributed by: Nik Murzin
The entry points are and (load an environment) and / (write Lean source back). and are the two computable wrappers; the Parse*-style CIC heads - , , , , , , , , , , - build expressions, with universe levels , , . , , and run interactive proofs; transpiles a ProofObject; , compile to native code; , , query a project out of process.
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`"]
Load the bundled example environment:
| In[1]:= |
| Out[1]= |
How many constants, and of what kinds:
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
A single constant is a summary box:
| In[4]:= |
| Out[4]= |
Its type, pretty-printed as Lean source - the proposition it proves:
| In[5]:= |
| Out[5]= |
And the proof term:
| In[6]:= |
| Out[6]= |
Every expression is a tree; "ExprGraph" draws it:
| In[7]:= |
| Out[7]= | ![]() |
"CallGraph" shows which constants a proof depends on:
| In[8]:= |
| Out[8]= | ![]() |
Import from Mathlib by pointing "ProjectDir" at a built mathlib4 checkout (gated so the page still builds without one):
| In[9]:= | ![]() |
| Out[9]= |
The "Parameters" property unfolds a theorem's binder chain - explicit, implicit, and instance arguments - as a Dataset:
| In[10]:= |
| Out[10]= | ![]() |
Open any theorem as a proof goal and step through it with tactics:
| In[11]:= |
| Out[11]= |
| In[12]:= |
| Out[12]= |
Transpile a Wolfram ProofObject into a checkable Lean environment:
| In[13]:= |
| Out[13]= |
| In[14]:= |
| Out[14]= |
Lower a (non-dependent) Lean definition to native code via FunctionCompile:
| In[15]:= | ![]() |
| Out[15]= |
round-trips with : import a source string, query it, and export an environment back to Lean source:
| In[16]:= |
| Out[16]= |
complements MetamathImport - both bring an external formal-proof corpus into the Wolfram Language; LeanLink targets Lean 4 / Mathlib and additionally drives the prover interactively.
The type of a Mathlib theorem, drawn as its expression tree (gated on a built checkout):
| In[17]:= | ![]() |
| Out[17]= | ![]() |
Wolfram Language Version 14.0