ArticleslgStudy

computer science

Lean (proof assistant)

Lean (proof assistant) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lean (proof assistant) rather than just read about it. In short: Lean is a proof assistant and a functional programming language. It is based on the calculus of constructions with inductive types, the foundational type theory developed with the Rocq theorem prover.

Lean (proof assistant) — main illustration
Lean (proof assistant) — illustration

Key takeaways

  • Lean (proof assistant) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lean (proof assistant) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lean (proof assistant) from memory before moving on to harder problems.

Reference excerpt

Lean is a proof assistant and a functional programming language. It is based on the calculus of constructions with inductive types, the foundational type theory developed with the Rocq theorem prover. It is a free and open-source software project hosted on GitHub. Development is currently supported by the nonprofit Lean Focused Research Organization (FRO).

History Lean was developed starting in 2013 primarily by Brazilian computer scientist Leonardo de Moura while employed by Microsoft Research (and now Amazon Web Services), and has had significant contributions from other coauthors and collaborators. Launched in 2013, 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, released in January 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. Lean 4 also contains a hygienic 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. Lean 4 is not backwards-compatible with Lean 3. It uses the C++17 version of C++. In 2023, the Lean FRO (Focused Research Organization) was formed, with the goals of improving the language's scalability and usability, and implementing proof automation. In 2025, ACM SIGPLAN Programming Languages Software Award was awarded to Gabriel Ebner, Soonho Kong, Leo de Moura and Sebastian Ullrich for Lean, cited for its "significant impact on mathematics, hardware and software verification, and AI". In 2026, the mathlib library was awarded the Demailly Prize for open science.

Overview Lean includes many features useful for functional programming and theorem proving, such as dependent types, type classes, multi-threading, an expressive tactic language, and a module system.

Libraries The official Lean standard library is called Std and contains common data structures and functions useful for programming, such as tree maps, hash maps, datetime functions, and concurrency primitives. The standard library is complemented by the community-maintained batteries, which implements additional data structures that may be used for both mathematical research and more conventional software development. 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. As of May 2025, mathlib had formalized over 210,000 theorems and 100,000 definitions in Lean. In October 2025, the Mathlib Initiative was launched as professional infrastructure to support the library. Other libraries include CSLib which is a theoretical computer science library, SciLean which is a library for scientific computing in Lean, and PhysLib, whose goal is to digitize physics using Lean.

Editor integration Lean integrates with Visual Studio Code, Neovim and Emacs. Interfacing is done via a client-extension and Language Server Protocol server. In these editors, Unicode symbols can be typed using LaTeX-like sequences, such as \times for "×".

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.

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

Here is a simple proof of (P∧Q)⟹(Q∧P) for two propositions P and Q (where ∧ is the conjunction and ⟹ the implication) in Lean using tactic mode:

This same proof in term mode:

The theorem can also be proved using the grind tactic, which uses techniques from satisfiability modulo theories (SMT) solvers to automatically construct proofs:

Usage

Mathematics Lean has received attention from mathematicians such as Thomas Hales, Kevin Buzzard, Terence Tao, and Heather Macbeth. Hales is using it for his project, Formal Abstracts. Buzzard uses it for the Xena project. One of the Xena Project's goals is to rewrite every theorem and proof in the undergraduate maths curriculum of Imperial College London in Lean. Tao released a Lean companion to his real analysis textbook Analysis I, consisting of a formalization of selected sections of the mathematical text. Macbeth is using Lean to teach students the fundamentals of mathematical proof with instant feedback.

Noteworthy formalizations

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Lean (proof assistant)

Start with the simplest possible case. Write down what Lean (proof assistant) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lean (proof assistant) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lean (proof assistant) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lean (proof assistant)

In research
Lean (proof assistant) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lean (proof assistant) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lean (proof assistant) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Dependently typed languages, Educational mathematical software, Extensible syntax programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Lean (proof assistant) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Lean (proof assistant)” →

How to study Lean (proof assistant) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lean (proof assistant) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lean (proof assistant) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lean (proof assistant) in simple terms?

Lean is a proof assistant and a functional programming language. It is based on the calculus of constructions with inductive types, the foundational type theory developed with the Rocq theorem prover.

Why does Lean (proof assistant) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lean (proof assistant)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lean (proof assistant).

Tags

  • Dependently typed languages
  • Educational mathematical software
  • Extensible syntax programming languages
  • Free software programmed in C++
  • Free theorem provers
  • Functional languages
  • Microsoft Research
  • Microsoft free software
  • Microsoft programming languages
  • Programming languages created in 2013
  • Proof assistants
  • Software using the Apache license

Keep exploring