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`
LeanCompile
​
LeanCompile
[term]
compiles a
LeanTerm
to native code via
FunctionCompile
, returning a
CompiledCodeFunction
.
​
​
LeanCompile
[env]
compiles every eligible term in a
LeanEnvironment
, returning an
Association
from name to compiled function.
​
Details and Options
▪
The Lean definition's argument and result types are mapped to Wolfram compiler types -
Nat
and
Int
to
"MachineInteger"
,
Bool
to
"Boolean"
,
Float
to
"Real64"
,
String
to
"String"
- and the body is lowered through
FunctionCompile
.
▪
Only computational definitions compile; propositions and theorems are skipped by the environment form.
▪
The non-dependent path runs against the stock Wolfram compiler. The dependent-type path (
Vector
sizes carried in a
TypePi
signature) needs a forked compiler; see
LeanCompileTyped
and [Possible Issues].
​
Examples  
(3)
Basic Examples  
(1)
Examples Initialization
Compile a Lean definition to a native function and run it:
In[1]:=
addEnv=
LeanImportString
["def myAdd (x y : Nat) : Nat := x + y"];​​cf=
LeanCompile
[addEnv["myAdd"]]
Out[1]=
CompiledCodeFunction
Type:
{Integer64,Integer64}Integer64

In[2]:=
cf[3,4]
Out[2]=
7
Scope  
(1)

Possible Issues  
(1)

SeeAlso
LeanToFunction
 
▪
LeanCompileTyped
 
▪
LeanImportString
 
▪
LeanTerm
RelatedGuides
▪
LeanLink
""

© 2026 Wolfram. All rights reserved.

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