Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

LeanLink

Tutorials

  • Checking Mathlib with TypeTheory
  • Exploring Mathlib with LeanLink
  • An Import Graph for Mathlib
  • Getting Started with LeanLink

Guides

  • Lean 4 from the Wolfram Language

Symbols

  • ImportDOT
  • LeanApp
  • LeanBuild
  • LeanBVar
  • LeanCallGraph
  • LeanCompile
  • LeanConstantInfo
  • LeanConstant
  • LeanConst
  • LeanEnvironment
  • LeanEvaluate
  • LeanExport
  • LeanExportString
  • LeanExprGraph
  • LeanExpr
  • LeanForall
  • LeanFreeEnvironment
  • LeanFVar
  • LeanGoal
  • LeanImport
  • LeanImportString
  • LeanLam
  • LeanLet
  • LeanLevelIMax
  • LeanLevelMax
  • LeanLevelMVar
  • LeanLevelParam
  • LeanLevelSucc
  • LeanLevelZero
  • LeanListConstants
  • LeanListTheorems
  • LeanLitNat
  • LeanLitStr
  • LeanLoadEnvironment
  • LeanMVar
  • LeanNoValue
  • LeanProj
  • LeanSort
  • LeanState
  • LeanTactic
  • LeanTerm
  • LeanToFunction
  • LeanToTypeTheory
  • LeanTruncated
  • LeanValue
  • ProofToLean
  • TypeTheoryToLean
Wolfram`LeanLink`
LeanLoadEnvironment
​
LeanLoadEnvironment
[{"Module1",...},searchPath]
loads a Lean environment from the given modules and returns an integer handle for repeated low-level queries.
​
Details and Options
▪
searchPath lists every directory the modules' compiled
.olean
files come from, separated by
":"
: the project's own build directory (for a lake project,
<project>/.lake/build/lib/lean
), each dependency's, and the Lean toolchain's
lib/lean
, which holds
Init
.
LeanImport
assembles this path for you from
"ProjectDir"
.
▪
The returned handle is a positive integer naming a native environment held open in the Lean runtime. A failed load returns
0
.
▪
Use the handle for many
LeanConstantInfo
/
LeanExpr
style queries against one loaded environment without reloading it each time, then release it with
LeanFreeEnvironment
.
▪
Most workflows use
LeanImport
instead, which loads, queries, and wraps constants in one step.
LeanLoadEnvironment
is the lower-level door for repeated queries where holding the environment open matters.
Examples  
(2)
Basic Examples  
(1)
Load the core
Init
module from the Lean toolchain into an environment handle, then free it:
In[1]:=
toolchainLib=FileNameJoin[{$HomeDirectory,".elan","toolchains","leanprover--lean4---v4.35.0","lib","lean"}];​​IfDirectoryQ[toolchainLib],​​handle=
LeanLoadEnvironment
[{"Init"},toolchainLib];​​result=handle>0;​​
LeanFreeEnvironment
[handle];​​result,​​"Lean toolchain not installed"​​
Out[1]=
True
Possible Issues  
(1)

SeeAlso
LeanFreeEnvironment
 
▪
LeanImport
 
▪
LeanConstantInfo
RelatedGuides
▪
Lean 4 from the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com