Lean (proof assistant)

Last updated
Lean
Lean logo2.svg
Paradigm Functional programming, Imperative programming
Family Proof assistant
Developer Lean FRO
First appeared2013;11 years ago (2013)
Stable release
4.11.0 / 1 September 2024;3 months ago (2024-09-01)
Preview release
4.12.0-rc1 / 2 September 2024;3 months ago (2024-09-02)
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 a functional programming language. [1] It is based on the calculus of constructions with inductive types. It is an open-source project hosted on GitHub. It was developed primarily 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 launched by Leonardo de Moura at Microsoft Research in 2013. [2] 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. [3] Lean 4 also contains a macro system and improved type class 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. [4]

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

Overview

Libraries

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

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. [7] [8] As of September 2024, mathlib had formalised over 165,000 theorems and 85,000 definitions in Lean. [9]

Editors integration

Lean integrates with: [10]

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 of for two propositions and (where is the conjunction and the implication) 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 received attention from mathematicians such as Thomas Hales, [11] Kevin Buzzard, [12] and Heather Macbeth. [13] Hales is using it for his project, Formal Abstracts. [14] Buzzard uses it for the Xena project. [15] 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. Macbeth is using Lean to teach students the fundamentals of mathematical proof with instant feedback. [16]

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 attention for formalizing a result at the cutting edge of mathematical research. [17] 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. [18]

Artificial intelligence

In 2022, OpenAI and Meta AI independently created AI models to generate proofs of various high-school-level olympiad problems in Lean. [19] Meta AI's model is available for public use with the Lean environment. [20]

In 2023, Vlad Tenev and Tudor Achim co-founded startup Harmonic, which aims to reduce AI hallucinations by generating and checking Lean code. [21]

In 2024, Google DeepMind created AlphaProof [22] which proves mathematical statements in Lean at the level of a silver medalist at the International Mathematical Olympiad. This was the first AI system that achieved a medal-worthy performance on a math olympiad's problems. [23]

See also

Related Research Articles

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.

In logic and proof theory, natural deduction is a kind of proof calculus in which logical reasoning is expressed by inference rules closely related to the "natural" way of reasoning. This contrasts with Hilbert-style systems, which instead use axioms as much as possible to express the logical laws of deductive reasoning.

<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 a Logic for Computable Functions (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.

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.)

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">Timothy Gowers</span> British mathematician

Sir William Timothy Gowers, is a British mathematician. He is Professeur titulaire of the Combinatorics chair at the Collège de France, and director of research at the University of Cambridge and Fellow of Trinity College, Cambridge. In 1998, he received the Fields Medal for research connecting the fields of functional analysis and combinatorics.

In mathematical logic, a deduction theorem is a metatheorem that justifies doing conditional proofs from a hypothesis in systems that do not explicitly axiomatize that hypothesis, i.e. to prove an implication A → B, it is sufficient to assume A as a hypothesis and then proceed to derive B. Deduction theorems exist for both propositional logic and first-order logic. The deduction theorem is an important tool in Hilbert-style deduction systems because it permits one to write more comprehensible and usually much shorter proofs than would be possible without it. In certain other formal proof systems the same conveniency is provided by an explicit inference rule; for example natural deduction calls it implication introduction.

<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.

In computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, called the modulus of the operation.

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.

In additive combinatorics, a discipline within mathematics, Freiman's theorem is a central result which indicates the approximate structure of sets whose sumset is small. It roughly states that if is small, then can be contained in a small generalized arithmetic progression.

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

Peter Benedict Kronheimer is a British mathematician, known for his work on gauge theory and its applications to 3- and 4-dimensional topology. He is William Caspar Graustein Professor of Mathematics at Harvard University and former chair of the mathematics department.

<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.

<span class="mw-page-title-main">Universal parabolic constant</span> Mathematical constant in conic sections

The universal parabolic constant is a mathematical constant.

<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 Sir 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 previous knowledge by almost all living mathematicians at the time.

In category theory, a branch of mathematics, Grothendieck's homotopy hypothesis states that the ∞-groupoids are spaces.

<span class="mw-page-title-main">James A. Maynard</span> British mathematician (born 1987)

James Alexander Maynard is an English mathematician working in analytic number theory and in particular the theory of prime numbers. In 2017, he was appointed Research Professor at Oxford. Maynard is a fellow of St John's College, Oxford. He was awarded the Fields Medal in 2022 and the New Horizons in Mathematics Prize in 2023.

Condensed mathematics is a theory developed by Dustin Clausen and Peter Scholze which replaces a topological space by a certain sheaf of sets, in order to solve some technical problems of doing homological algebra on topological groups.

References

  1. Moura, Leonardo de; Ullrich, Sebastian (2021). "The Lean 4 Theorem Prover and Programming Language". In Platzer, André; Sutcliffe, Geoff (eds.). Automated Deduction – CADE 28. Lecture Notes in Computer Science. Vol. 12699. Cham: Springer International Publishing. pp. 625–635. doi: 10.1007/978-3-030-79876-5_37 . ISBN   978-3-030-79876-5.
  2. "About". Lean Language. Retrieved 2024-03-13.
  3. 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.
  4. "Significant changes from Lean 3". Lean Manual. Retrieved 24 March 2023.
  5. "Mission". Lean FRO. 2023-07-25. Retrieved 2024-03-14.
  6. "batteries". GitHub . Retrieved 2024-09-22.
  7. "Building the Mathematical Library of the Future". Quanta Magazine . October 2020. Archived from the original on 2 Oct 2020.
  8. "Lean community". leanprover-community.github.io. Retrieved 2023-10-24.
  9. "Mathlib statistics". leanprover-community.github.io. Retrieved 2024-09-22.
  10. "Installing Lean 4 on Linux". leanprover-community.github.io. Retrieved 2023-10-24.
  11. Hales, Thomas (September 18, 2018). "A Review of the Lean Theorem Prover". Jigger Wit. Archived from the original on 21 Nov 2020.
  12. Buzzard, Kevin. "The Future of Mathematics?" (PDF). Retrieved 6 October 2020.
  13. Macbeth, Heather. "The Mechanics of Proof". hrmacbeth.github.io. Archived from the original on 5 Jun 2024.
  14. "Formal Abstracts". Github.
  15. "What is the Xena project?". Xena. 8 May 2019.
  16. Roberts, Siobhan (July 2, 2023). "A.I. Is Coming for Mathematics, Too". New York Times. Archived from the original on 1 May 2024.
  17. Hartnett, Kevin (July 28, 2021). "Proof Assistant Makes Jump to Big-League Math". Quanta Magazine . Archived from the original on 2 Jan 2022.
  18. Sloman, Leila (2023-12-06). "'A-Team' of Math Proves a Critical Link Between Addition and Sets". Quanta Magazine. Retrieved 2023-12-07.
  19. "Solving (some) formal math olympiad problems". OpenAI . February 2, 2022. Retrieved March 13, 2024.
  20. "Teaching AI advanced mathematical reasoning". Meta AI . November 3, 2022. Retrieved March 13, 2024.
  21. Metz, Cade (23 September 2024). "Is Math the Path to Chatbots That Don't Make Stuff Up?". New York Times. Archived from the original on 24 Sep 2024.
  22. "AI achieves silver-medal standard solving International Mathematical Olympiad problems". Google DeepMind. 2024-05-14. Retrieved 2024-07-25.
  23. Roberts, Siobhan (July 25, 2024). "Move Over, Mathematicians, Here Comes AlphaProof". New York Times . Archived from the original on July 29, 2024.