Lean (proof assistant)
Lean is a theorem prover and programming language. It is based on the calculus of constructions with inductive types.
![]() | |
| Paradigm | Functional programming, Imperative programming |
|---|---|
| Developer | Microsoft Research |
| First appeared | 2013 |
| Stable release | 3.48.0
/ 17 September 2022 |
| Preview release | 4.0.0-m5
/ 7 August 2022 |
| Typing discipline | Static, strong, inferred |
| Implementation language | C++, Lean |
| OS | Cross-platform |
| License | Apache License 2.0 |
| Website | Stable: leanprover-community Preview: leanprover |
| Influenced by | |
| ML Coq Haskell | |
The Lean project is an open-source project hosted on GitHub. It was launched by Leonardo de Moura at Microsoft Research in 2013.[1]
Lean has an interface that differentiates it from other interactive theorem provers. It has native support for Unicode symbols, which can be typed using LaTeX-like sequences, such as "\times" for "×". Lean can also be compiled to JavaScript and accessed in a web browser and has extensive support for meta-programming.
Started in 2017, the user-maintained library mathlib contains the largest collection of mathematics that has been formalized in Lean. As of February 2023, mathlib contains over 100,000 theorems and 1,000,000 lines of code.[2]
Lean has gotten attention from mathematicians Thomas Hales[3] and Kevin Buzzard.[4] Hales is using it for his project, Formal Abstracts.[5] Buzzard uses it for the Xena project.[6] One of the Xena Project's goals is to rewrite every theorem and proof in the undergraduate math curriculum of Imperial College London in Lean.
Examples
The natural numbers can be defined as an inductive type. This definition is based on the Peano axioms and states that every natural number is either zero or the successor of some other natural number.
inductive nat : Type
| zero : nat
| succ : nat → nat
Addition of natural numbers can be defined recursively, using pattern matching.
definition add : nat → nat → nat
| n zero := n
| n (succ m) := succ (add n m)
This is a simple proof in lean in term mode.
theorem and_swap : p ∧ q → q ∧ p :=
assume h1 : p ∧ q,
⟨h1.right, h1.left⟩
This same proof can be accomplished using tactics.
theorem and_swap (p q : Prop) : p ∧ q → q ∧ p :=
begin
assume h : (p ∧ q), -- assume p ∧ q is true
cases h, -- extract the individual propositions from the conjunction
split, -- split the goal conjunction into two cases: prove p and prove q separately
repeat { assumption }
end
References
- "Lean Prover About Page".
- "Mathlib statistics". leanprover-community.github.io. Retrieved 2023-02-12.
- Hales, Thomas (18 September 2018). "A Review of the Lean Theorem Prover". Retrieved 6 October 2020.
- Buzzard, Kevin. "The Future of Mathematics?" (PDF). Retrieved 6 October 2020.
- "Formal Abstracts". Github.
- "What is the Xena project?". Xena. 8 May 2019.
