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`
LeanToTypeTheory
​
LeanToTypeTheory
[env,name]
imports the Lean constant name from the
LeanEnvironment
env, with every constant it depends on, into a TypeTheoryEnvironment of the WolframInstitute/TypeTheory proof engine, whose own kernel checks each declaration again.
​
​
LeanToTypeTheory
[env,{name1,name2,...}]
imports several constants.
​
​
LeanToTypeTheory
[term]
imports the constant of the
LeanTerm
term.
​
Details and Options
▪
TypeTheory is a Calculus of Inductive Constructions kernel written in the Wolfram Language.
LeanToTypeTheory
gives the result of checking the import with it, independently of Lean's kernel: a
TypeTheoryEnvironment
, or a
Failure
naming the Lean constant TypeTheory rejects.
▪
The constants are taken in dependency order. An inductive type comes with its constructors; its recursor
X.rec
is generated by TypeTheory as
InductiveRecursor["X"]
, and then compared with Lean's: a recursor whose type differs gives a
"RecursorMismatch"
Failure
.
▪
Lean names stay strings, so the imported theorem
"Nat.zero_add"
is the constant
"Nat.zero_add"
of the TypeTheory environment, and Lean's
Nat
becomes its natural numbers, so literals mean the same.
▪
Every term is imported as a core term of TypeTheory, with every argument and every universe level given, so nothing is filled in again on the TypeTheory side. A subterm that occurs many times, as in a proof that a tactic such as
omega
writes, is imported once and shared, as Lean shares it.
▪
The option
"Environment"
gives a
TypeTheoryEnvironment
to import into; constants it already declares are not imported again.
▪
A block of mutually inductive types is imported as one declaration of all its types, and a type nested in a container, as Lean's syntax trees are in
Array
, as itself: TypeTheory checks the nesting as Lean's kernel does. Every recursor of the block,
X.rec_k
on a container included as
InductiveRecursor["X",k]
, is compared with Lean's.
▪
A string literal is written as Lean's kernel reads it:
String.ofList
applied to the list of its characters, each
Char.ofNat
of its code point.
▪
The operations Lean's kernel computes on literals with GMP,
Nat.add
,
Nat.mul
,
Nat.pow
,
Nat.div
,
Nat.ble
and the others, are registered with TypeTheory as they are imported, so it computes them on literals with integers too, and a proof about numbers near 2^64 checks at once.
▪
Lean's quotient types,
Quot
,
Quot.mk
,
Quot.lift
and
Quot.ind
, are TypeTheory's own: the import declares them at once with
TypeTheoryQuotients["Eq",{"Quot","Quot.mk","Quot.lift","Quot.ind"}]
, and TypeTheory's kernel computes a lift on a class as Lean's does. Under rules without quotients, given with the option
"Environment"
, and with a TypeTheory before 0.13, they are axioms, and the import adds their computation as the rewrite rules
"Quot.lift computes"
and
"Quot.ind computes"
where the rules allow rewrite rules.
▪
The first call loads the paclet
WolframInstitute/TypeTheory
, which must be installed.
​
Examples  
(6)
Basic Examples  
(1)
A Lean theorem, compiled from source:
In[1]:=
lean=
LeanImportString
["theorem probe (n : Nat) : 0 + n = n := Nat.zero_add n"]
Out[1]=
LeanEnvironment
Constants: 1
Kinds: 1 theorem

Import
Eq.symm
with what it depends on:
In[2]:=
env=
LeanToTypeTheory
[lean,"Eq.symm"]
Out[2]=
TypeTheoryEnvironment
Constants: 5
Theorems: 1

The constants TypeTheory checked:
In[3]:=
Keys[env]
Out[3]=
{Eq,Eq.refl,InductiveRecursor[Eq],rfl,Eq.symm}
The imported theorem, read back in TypeTheory:
In[4]:=
env["Eq.symm"]
Out[4]=
theorem
Eq.symm
:
∀
{α:Sortu}
∀
{a:α}
∀
{b:α}
Eq[a,b]⇒Eq[b,a]
Scope  
(5)

SeeAlso
TypeTheoryToLean
 
▪
LeanImport
 
▪
LeanImportString
 
▪
LeanEnvironment
 
▪
LeanTerm
TechNotes
▪
CheckingMathlib
RelatedGuides
▪
Lean 4 from the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

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