Lean (proof assistant)

Last updated
Lean
Lean logo2.svg
Paradigm Functional programming, Imperative programming
Developer Lean FRO
First appeared2013;11 years ago (2013)
Stable release
4.6.1 / 4 March 2024;24 days ago (2024-03-04)
Preview release
4.7.0-rc2 / 5 March 2024;23 days ago (2024-03-05)
Typing discipline Static, strong, inferred
Implementation languageLean , C++
OS Cross-platform
License Apache License 2.0
Website lean-lang.org
Influenced by
ML
Coq
Haskell

Lean is a proof assistant and programming language. It is based on the calculus of constructions with inductive types. It is an open-source project hosted on GitHub. It was principally developed by Leonardo de Moura while employed by Microsoft Research and now Amazon Web Services, and has had significant contributions from other coauthors and collaborators during its history. Development is currently supported by the non-profit Lean Focused Research Organization (FRO).

Contents

History

Lean was initially launched by Leonardo de Moura at Microsoft Research in 2013. [1] The initial versions of the language, later known as Lean 1 and 2, were experimental and contained features such as support for homotopy type theory – based foundations that were later dropped.

Lean 3 (first released Jan 20, 2017) was the first moderately stable version of Lean. It was implemented primarily in C++ with some features written in Lean itself. After version 3.4.2 Lean 3 was officially end-of-lifed while development of Lean 4 began. In this interim period members of the Lean community developed and released unofficial versions up to 3.51.1.

In 2021, Lean 4 was released which was a reimplementation of the Lean theorem prover capable of producing C code which is then compiled, enabling the development of efficient domain-specific automation. [2] Lean 4 also contains a macro system and improved typeclass synthesis and memory management procedures over the previous version. Another benefit compared to Lean 3 is the ability to avoid touching C++ code in order to modify the frontend and other key parts of the core system, as they are now all implemented in Lean and available to the end user to be overridden as needed.[ citation needed ]

Lean 4 is not backwards-compatible with Lean 3. [3]

In 2023, the Lean FRO was formed, with the goals of improving the language's scalability and usability, and implementing proof automation. [4]

Overview

Libraries

The official lean package includes a standard library std4, which implements common data structures that may be used for both mathematical research and more conventional software development. [5]

In 2017, a community-maintained project to develop a Lean library mathlib began, with the goal to digitize as much of pure mathematics as possible in one large cohesive library, up to research level mathematics. [6] [7] As of November 2023, mathlib had formalized over 127,000 theorems and 70,000 definitions in Lean. [8]

Editors integration

Lean integrates with: [9]

Interfacing is done via a client-extension and Language Server Protocol server.

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.

Examples (Lean 4)

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.

inductiveNat:Type|zero:Nat|succ:NatNat

Addition of natural numbers can be defined recursively, using pattern matching.

defNat.add:NatNatNat|n,Nat.zero=>n-- n + 0 = n  |n,Nat.succm=>Nat.succ(Nat.addnm)-- n + succ(m) = succ(n + m)

This is a simple proof in Lean using tactic mode:

theoremand_swap(pq:Prop):pqqp:=byintroh-- assume p ∧ q with proof h, the goal is q ∧ papplyAnd.intro-- the goal is split into two subgoals, one is q and the other is p·exacth.right-- the first subgoal is exactly the right part of h : p ∧ q·exacth.left-- the second subgoal is exactly the left part of h : p ∧ q

This same proof in term mode:

theoremand_swap(pq:Prop):pqqp:=funhp,hq=>hq,hp

Usage

Mathematics

Lean has gotten attention from mathematicians Thomas Hales [10] and Kevin Buzzard. [11] Hales is using it for his project, Formal Abstracts. [12] Buzzard uses it for the Xena project. [13] 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.

In 2021, a team of researchers used Lean to verify the correctness of a proof by Peter Scholze in the area of condensed mathematics. The project garnered substantial attention for formalizing a result at the cutting edge of mathematical research. [14] In 2023, Terence Tao used Lean to formalize a proof of the Polynomial Freiman-Ruzsa (PFR) conjecture, a result published by Tao and collaborators in the same year. [15]

Artificial intelligence

In 2022, OpenAI created a neural network-based theorem prover for lean, which used a language model to generate proofs of various high-school-level olympiad problems. [16]

Later that year, Meta AI created an AI model that has solved 10 International Mathematical Olympiad problems; this model is available for public use with the Lean environment. [17]

See also

Related Research Articles

<span class="mw-page-title-main">Mathematical induction</span> Form of mathematical proof

Mathematical induction is a method for proving that a statement is true for every natural number , that is, that the infinitely many cases   all hold. This is done by first proving a simple case, then also showing that if we assume the claim is true for a given case, then the next case is also true. Informal metaphors help to explain this technique, such as falling dominoes or climbing a ladder:

Mathematical induction proves that we can climb as high as we like on a ladder, by proving that we can climb onto the bottom rung and that from each rung we can climb up to the next one.

In mathematics and theoretical computer science, a type theory is the formal presentation of a specific type system. Type theory is the academic study of type systems.

<span class="mw-page-title-main">Isabelle (proof assistant)</span> Higher-order logic (HOL) automated theorem prover

The Isabelle automated theorem prover is a higher-order logic (HOL) theorem prover, written in Standard ML and Scala. As an LCF-style theorem prover, it is based on a small logical core (kernel) to increase the trustworthiness of proofs without requiring — yet supporting — explicit proof objects.

<i>abc</i> conjecture The product of distinct prime factors of a,b,c, where c is a+b, is rarely much less than c

The abc conjecture is a conjecture in number theory that arose out of a discussion of Joseph Oesterlé and David Masser in 1985. It is stated in terms of three positive integers and that are relatively prime and satisfy . The conjecture essentially states that the product of the distinct prime factors of is usually not much smaller than . A number of famous conjectures and theorems in number theory would follow immediately from the abc conjecture or its versions. Mathematician Dorian Goldfeld described the abc conjecture as "The most important unsolved problem in Diophantine analysis".

In combinatorics, Ramsey's theorem, in one of its graph-theoretic forms, states that one will find monochromatic cliques in any edge labelling (with colours) of a sufficiently large complete graph. To demonstrate the theorem for two colours (say, blue and red), let r and s be any two positive integers. Ramsey's theorem states that there exists a least positive integer R(r, s) for which every blue-red edge colouring of the complete graph on R(r, s) vertices contains a blue clique on r vertices or a red clique on s vertices. (Here R(r, s) signifies an integer that depends on both r and s.)

In mathematics, the adjective trivial is often used to refer to a claim or a case which can be readily obtained from context, or an object which possesses a simple structure. The noun triviality usually refers to a simple technical aspect of some proof or definition. The origin of the term in mathematical language comes from the medieval trivium curriculum, which distinguishes from the more difficult quadrivium curriculum. The opposite of trivial is nontrivial, which is commonly used to indicate that an example or a solution is not simple, or that a statement or a theorem is not easy to prove.

The QED manifesto was a proposal for a computer-based database of all mathematical knowledge, strictly formalized and with all proofs having been checked automatically.

<span class="mw-page-title-main">Coq (software)</span> Proof assistant

Coq is an interactive theorem prover first released in 1989. It allows for expressing mathematical assertions, mechanically checks proofs of these assertions, helps find formal proofs, and extracts a certified program from the constructive proof of its formal specification. Coq works within the theory of the calculus of inductive constructions, a derivative of the calculus of constructions. Coq is not an automated theorem prover but includes automatic theorem proving tactics (procedures) and various decision procedures.

<span class="mw-page-title-main">Recursive definition</span> Defining elements of a set in terms of other elements in the set

In mathematics and computer science, a recursive definition, or inductive definition, is used to define the elements in a set in terms of other elements in the set. Some examples of recursively-definable objects include factorials, natural numbers, Fibonacci numbers, and the Cantor ternary set.

<span class="mw-page-title-main">Proof assistant</span> Software tool to assist with the development of formal proofs by human-machine collaboration

In computer science and mathematical logic, a proof assistant or interactive theorem prover is a software tool to assist with the development of formal proofs by human-machine collaboration. This involves some sort of interactive proof editor, or other interface, with which a human can guide the search for proofs, the details of which are stored in, and some steps provided by, a computer.

Twelf is an implementation of the logical framework LF developed by Frank Pfenning and Carsten Schürmann at Carnegie Mellon University. It is used for logic programming and for the formalization of programming language theory.

<span class="mw-page-title-main">Cauchy's theorem (group theory)</span> Existence of group elements of prime order

In mathematics, specifically group theory, Cauchy's theorem states that if G is a finite group and p is a prime number dividing the order of G, then G contains an element of order p. That is, there is x in G such that p is the smallest positive integer with xp = e, where e is the identity element of G. It is named after Augustin-Louis Cauchy, who discovered it in 1845.

A computer-assisted proof is a mathematical proof that has been at least partially generated by computer.

In combinatorial number theory, the Erdős–Graham problem is the problem of proving that, if the set of integers greater than one is partitioned into finitely many subsets, then one of the subsets can be used to form an Egyptian fraction representation of unity. That is, for every , and every -coloring of the integers greater than one, there is a finite monochromatic subset of these integers such that

<span class="mw-page-title-main">Kevin Buzzard</span> British mathematician

Kevin Mark Buzzard is a British mathematician and currently a professor of pure mathematics at Imperial College London. He specialises in arithmetic geometry and the Langlands program.

In mathematics, an approximately finite-dimensional (AF) C*-algebra is a C*-algebra that is the inductive limit of a sequence of finite-dimensional C*-algebras. Approximate finite-dimensionality was first defined and described combinatorially by Ola Bratteli. Later, George A. Elliott gave a complete classification of AF algebras using the K0 functor whose range consists of ordered abelian groups with sufficiently nice order structure.

<span class="mw-page-title-main">Wiles's proof of Fermat's Last Theorem</span> 1995 publication in mathematics

Wiles's proof of Fermat's Last Theorem is a proof by British mathematician Andrew Wiles of a special case of the modularity theorem for elliptic curves. Together with Ribet's theorem, it provides a proof for Fermat's Last Theorem. Both Fermat's Last Theorem and the modularity theorem were believed to be impossible to prove using current knowledge by almost all contemporary mathematicians.

Univalent foundations are an approach to the foundations of mathematics in which mathematical structures are built out of objects called types. Types in univalent foundations do not correspond exactly to anything in set-theoretic foundations, but they may be thought of as spaces, with equal types corresponding to homotopy equivalent spaces and with equal elements of a type corresponding to points of a space connected by a path. Univalent foundations are inspired both by the old Platonic ideas of Hermann Grassmann and Georg Cantor and by "categorical" mathematics in the style of Alexander Grothendieck. Univalent foundations depart from the use of classical predicate logic as the underlying formal deduction system, replacing it, at the moment, with a version of Martin-Löf type theory. The development of univalent foundations is closely related to the development of homotopy type theory.

<span class="mw-page-title-main">Dafny</span> Programming language

Dafny is an imperative and functional compiled language that compiles to other programming languages, such as C#, Java, JavaScript, Go and Python. It supports formal specification through preconditions, postconditions, loop invariants, loop variants, termination specifications and read/write framing specifications. The language combines ideas from the functional and imperative paradigms; it includes support for object-oriented programming. Features include generic classes, dynamic allocation, inductive datatypes and a variation of separation logic known as implicit dynamic frames for reasoning about side effects. Dafny was created by Rustan Leino at Microsoft Research after his previous work on developing ESC/Modula-3, ESC/Java, and Spec#.

Condensed mathematics is a theory developed by Dustin Clausen and Peter Scholze which aims to unify various mathematical subfields, including topology, complex geometry, and algebraic geometry.

References

  1. "About". Lean Language. Retrieved 2024-03-13.
  2. Moura, Leonardo de; Ullrich, Sebastian (2021). Platzer, Andr'e; Sutcliffe, Geoff (eds.). Automated Deduction -- CADE 28. Springer International Publishing. pp. 625–635. doi:10.1007/978-3-030-79876-5_37. ISBN   978-3-030-79876-5. S2CID   235800962 . Retrieved 24 March 2023.
  3. "Significant changes from Lean 3". Lean Manual. Retrieved 24 March 2023.
  4. "Mission". Lean FRO. 2023-07-25. Retrieved 2024-03-14.
  5. "std4". GitHub . Retrieved 2024-03-13.
  6. "Building the Mathematical Library of the Future". Quanta Magazine . Archived from the original on 2 Oct 2020.
  7. "Lean community". leanprover-community.github.io. Retrieved 2023-10-24.
  8. "Mathlib statistics". leanprover-community.github.io. Retrieved 2023-11-01.
  9. "Installing Lean 4 on Linux". leanprover-community.github.io. Retrieved 2023-10-24.
  10. Hales, Thomas (September 18, 2018). "A Review of the Lean Theorem Prover". Jigger Wit. Archived from the original on 21 Nov 2020.
  11. Buzzard, Kevin. "The Future of Mathematics?" (PDF). Retrieved 6 October 2020.
  12. "Formal Abstracts". Github.
  13. "What is the Xena project?". Xena. 8 May 2019.
  14. Hartnett, Kevin (July 28, 2021). "Proof Assistant Makes Jump to Big-League Math". Quanta Magazine . Archived from the original on 2 Jan 2022.
  15. Sloman, Leila (2023-12-06). "'A-Team' of Math Proves a Critical Link Between Addition and Sets". Quanta Magazine. Retrieved 2023-12-07.
  16. "Solving (some) formal math olympiad problems". OpenAI . February 2, 2022. Retrieved March 13, 2024.
  17. "Teaching AI advanced mathematical reasoning". Meta AI . November 3, 2022. Retrieved March 13, 2024.