Wolfram Language paclet for native integration with Lean 4.
- Native LibraryLink bridge — embeds the Lean runtime directly via a C shim, no subprocess overhead
- Environment loading — loads
.oleanenvironments, queries constants, theorems, types - Symbolic expressions — Lean expressions as
LeanApp,LeanConst,LeanForall, etc. - Pretty printing — WL-side notation rules for source-code-like output (
a * b = b * a) - Interactive proofs —
LeanState/LeanTacticfor step-by-step proof construction - Mathlib support — import and inspect Mathlib modules
- ProofToLean — transpile Wolfram
ProofObjectto Lean environments
<< Wolfram`LeanLink`
(* Import Mathlib algebra *)
env = LeanImport["Mathlib.Algebra.Group.Basic",
"ProjectDir" -> "~/src/mathlib4"];
env["mul_comm"]["TypeForm"]
(* "∀ {G : Type u_1} [inst : CommMagma G] (a : G) (b : G), a * b = b * a" *)
(* Interactive proof *)
state = LeanState[env["one_mul"]];
state // LeanTactic["simp"]- Lean 4 via elan
- Wolfram Language 15.0+
- CMake 3.20+, C compiler
./build.shThis runs lake build for the Lean library, then cmake + make for the C shim.
The dylib is output to LeanLink/LibraryResources/<platform>/.
./build.wlsPacks LeanLink/ into a .paclet file, installs it, and uploads to Wolfram Cloud.
./run_tests.wls./publish_notebooks.wlsUploads .nb notebooks to Wolfram Cloud.
- LeanLinkIntro — Getting started with LeanLink
- MathlibExamples — Exploring Mathlib from Wolfram Language
- TuringMachineSuccessor — Proving Turing machines compute successor, with proof term graphs for every class in (2,2) and (3,2)
LeanLink/
├── LeanLink/ # Paclet root
│ ├── PacletInfo.wl
│ ├── Kernel/ # Wolfram Language package
│ │ └── Lean.wl # Main API, pretty-printer, proof engine
│ ├── Assets/ # Bundled .lean files
│ ├── Tests/ # .wlt test suite
│ └── LibraryResources/ # Built dylibs (per-platform, gitignored)
├── Native/ # Lean + C source
│ ├── lib/LeanLink/ # Lean 4 source
│ │ ├── EnvStore.lean # Environment loading, WXF goal export
│ │ └── WXF.lean # WXF binary serialization
│ └── shim/
│ ├── leanlink_shim.c # LibraryLink C bridge
│ └── CMakeLists.txt # Multi-platform build
├── Notebooks/ # Example notebooks (.md source + .nb)
├── build.sh # Native build script
├── build.wls # Paclet archive script
├── publish_notebooks.wls # Notebook evaluation + cloud upload
└── run_tests.wls # Test runner
MIT