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`
TypeTheoryToLean
​
TypeTheoryToLean
[env,name]
gives Lean 4 source declaring the constant name of the
TypeTheoryEnvironment
env, with every constant it depends on that Lean does not have, for
LeanImportString
to compile and Lean's kernel to check.
​
​
TypeTheoryToLean
[env,{name1,name2,...}]
gives the source for several constants.
​
Details and Options
▪
The declarations are read back from the
WolframInstitute/TypeTheory
environment exactly and written with every application explicit (
@fab
) and every universe level given, so Lean fills in nothing.
▪
A constant that came from Lean, through
LeanToTypeTheory
, keeps its Lean name and is not declared again.
▪
TypeTheory's prelude constants that Lean has in
Init
are written as Lean's:
NonNegativeIntegers
is
Nat
,
Equal
is
Eq
,
And
is
And
,
Equivalent
is
Iff
,
Booleans
is
Bool
, and their constructors and recursors likewise; the Booleans' constants
"true"
,
"false"
,
"not"
,
"and"
and
"or"
are
Bool.true
,
Bool.false
,
Bool.not
,
Bool.and
and
Bool.or
, with the same definitions.
Plus
becomes
Nat.add
, which computes the same on constructors, so a proof that does not depend on how
Plus
is defined checks in Lean too.
▪
The prelude's axioms are Lean's:
PropositionalExtensionality
is
propext
,
FunctionExtensionality
is
funext
and
Choice
is
Classical.choice
, so a classical proof depends on Lean's own axioms and declares none.
▪
Every other constant is declared under the namespace
TypeTheory
, as an
axiom
, a
noncomputabledef
, a
theorem
or an
inductive
; a block of mutually inductive types is written as Lean's
mutual
block.
▪
Compiling the source with
LeanImportString
has Lean's kernel check every declaration, independently of TypeTheory's.
▪
Lean's kernel follows the calculus of inductive constructions, the rules of TypeTheory's prelude. An environment whose rules have no Prop, such as TypeTheory's HoTT environment, or that has rewrite rules other than the quotient rules
LeanToTypeTheory
adds, which are Lean's own, gives
Failure["UnsupportedRules",...]
.
​
Examples  
(5)
Basic Examples  
(1)
Prove
0+n==n
by induction in TypeTheory:
In[1]:=
proof=TypeTheoryProof[ForAll[{Typed[n,NonNegativeIntegers]},0+nn],{​​TypeTheoryTactic["Introduce",n],​​TypeTheoryTactic["Induction",n],​​TypeTheoryTactic["Reflexivity"],​​TypeTheoryTactic["Introduce",k,ih],​​TypeTheoryTactic["Exact",EqualityCongruence[NaturalNumberSuccessor,ih]]​​}]
Out[1]=
A theorem with that proof, added to the prelude:
In[2]:=
proved=TypeTheoryEnvironment[{TypeTheoryTheorem[ZeroLeftIdentity,proof]}]
Out[2]=
TypeTheoryEnvironment
Constants: 170
Theorems: 73

Write the theorem as Lean source:
In[3]:=
source=
TypeTheoryToLean
[proved,ZeroLeftIdentity]
Out[3]=
-- Generated by LeanLink's TypeTheoryToLean: TypeTheory declarations, for Lean's kernel to check.​theorem TypeTheory.EqualityCongruence.{u, v} : ({α : Sort u} -> {β : Sort v} -> {x : α} -> {y : α} -> (f : (α -> β)) -> ((@Eq.{u} α x y) -> (@Eq.{v} β (f x) (f y)))) := (@fun {α : Sort u} {β : Sort v} {x : α} {y : α} (f : (α -> β)) (h : (@Eq.{u} α x y)) => (@Eq.rec.{0, u} α x (@fun (z : α) (e : (@Eq.{u} α x z)) => (@Eq.{v} β (f x) (f z))) (@Eq.refl.{v} β (f x)) y h))​theorem TypeTheory.ZeroLeftIdentity : ((n : @Nat) -> (@Eq.{1} @Nat (@Nat.add (0 : Nat) n) n)) := (@fun (n : @Nat) => (@Nat.rec.{0} (@fun (n1 : @Nat) => (@Eq.{1} @Nat (@Nat.add (0 : Nat) n1) n1)) (@Eq.refl.{1} @Nat (@Nat.add (0 : Nat) @Nat.zero)) (@fun (k : @Nat) (ih : (@Eq.{1} @Nat (@Nat.add (0 : Nat) k) k)) => (@TypeTheory.EqualityCongruence.{1, 1} @Nat @Nat (@Nat.add (0 : Nat) k) k @Nat.succ ih)) n))
Lean compiles it, and its kernel accepts the proof:
In[4]:=
leanEnv=
LeanImportString
[source]
Out[4]=
LeanEnvironment
Constants: 2
Kinds: 2 theorem

The theorem, as Lean states it:
In[5]:=
leanEnv["TypeTheory.ZeroLeftIdentity"]["TypeForm"]
Out[5]=
∀ (n : Nat), Nat.add 0 n = n
Scope  
(2)

Possible Issues  
(2)

SeeAlso
LeanToTypeTheory
 
▪
LeanImportString
 
▪
LeanExportString
 
▪
LeanEnvironment
RelatedGuides
▪
Lean 4 from the Wolfram Language
""

© 2026 Wolfram. All rights reserved.

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