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`
LeanImportString
​
LeanImportString
[src]
compiles a Lean 4 source string and returns a
LeanEnvironment
of the constants it declares.
​
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 elaborated by the embedded Lean runtime, so a type error in src surfaces as a
Failure
the same way
lakebuild
would report it.
▪
Use
LeanImportString
for ad-hoc definitions and round-trips; use
LeanImport
to pull constants from a compiled module such as Mathlib.
​
Examples  
(3)
Basic Examples  
(1)
Examples Initialization
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)

SeeAlso
LeanImport
 
▪
LeanExportString
 
▪
LeanEnvironment
 
▪
LeanTerm
RelatedGuides
▪
LeanLink
""

© 2026 Wolfram. All rights reserved.

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