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`
LeanImportString
​
LeanImportString
[src]
compiles a Lean 4 source string and returns a
LeanEnvironment
of the constants it declares.
​
​
LeanImportString
[{src1,src2,...}]
compiles the sources joined with newlines.
​
Details and Options
▪
src is ordinary Lean 4 source: any mix of
def
,
theorem
,
inductive
,
structure
, and so on. Each top-level declaration becomes one
LeanTerm
in the result.
▪
The string is compiled by the
lean
of LeanLink's pinned toolchain and loaded into the embedded runtime. A type error in src returns
$Failed
with a
LeanImport::err
message carrying Lean's diagnostic, as
lakebuild
would report it.
▪
With
"ProjectDir"*dir*
, src can
import
the modules of the built Lake project in dir, of its packages, and of its path dependencies (
path="../x"
in the lakefile). A theorem proved
bydecide
against the project's definitions is then a kernel-checked claim about them.
▪
Declarations inside a
namespace
are kept under their full names.
▪
A list of sources is one source, joined with newlines: an
import
line, a few declarations and generated source go in as they are, with no string joining.
▪
Use
LeanImportString
for ad-hoc definitions and round-trips; use
LeanImport
to pull constants from a compiled module such as Mathlib.
​
Examples  
(4)
Basic Examples  
(1)
Compile a single theorem:
In[1]:=
imported=
LeanImportString
["theorem myT : Nat.succ 0 = 1 := rfl"]
Out[1]=
LeanEnvironment
Constants: 1
Kinds: 1 theorem

Read back its type:
In[2]:=
imported["myT"]["TypeForm"]
Out[2]=
Nat.succ 0 = 1
Scope  
(1)

Properties & Relations  
(1)

Possible Issues  
(1)

SeeAlso
LeanImport
 
▪
LeanExportString
 
▪
LeanEnvironment
 
▪
LeanTerm
RelatedGuides
▪
Lean 4 from the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

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