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

Guides

  • Lean 4 from the Wolfram Language

Tech Notes

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

Symbols

  • ImportDOT
  • LeanApp
  • LeanBVar
  • LeanCallGraph
  • LeanCompile
  • LeanCompileTyped
  • LeanConstantInfo
  • LeanConstant
  • LeanConst
  • LeanEnvironment
  • LeanExport
  • LeanExportString
  • LeanExprGraph
  • LeanExpr
  • LeanExprToType
  • 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
  • LeanTruncated
  • LeanValue
  • ProofToLean
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 is the directory holding the compiled
.olean
files (for a lake project, typically
<project>/.lake/build/lib/lean
). The returned handle is an integer naming a native environment held open in the Lean runtime.
▪
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)
Examples Initialization
Load a Mathlib module into an environment handle, then free it (gated on a built checkout):
In[1]:=
leanLib=FileNameJoin[{$HomeDirectory,"src","mathlib4",".lake","build","lib","lean"}];​​IfDirectoryQ[leanLib],​​handle=
LeanLoadEnvironment
[{"Mathlib.Logic.Basic"},leanLib];​​result=IntegerQ[handle];​​
LeanFreeEnvironment
[handle];​​result,​​"Mathlib not built"​​
Out[1]=
True
Possible Issues  
(1)

SeeAlso
LeanFreeEnvironment
 
▪
LeanImport
 
▪
LeanConstantInfo
RelatedGuides
▪
LeanLink
""

© 2026 Wolfram. All rights reserved.

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