# leanprover/lean4

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/leanprover-lean4).**

8,306 stars · 881 forks · Lean · Apache-2.0

## Links

- GitHub: https://github.com/leanprover/lean4
- Homepage: https://lean-lang.org
- awesome-repositories: https://awesome-repositories.com/repository/leanprover-lean4.md

## Topics

`lean` `lean4`

## Description

Lean 4 is a functional programming language and interactive proof assistant used to formalize mathematics and verify software correctness. It functions as a dependent type theorem prover and a formal verification tool that allows users to construct mathematical proofs and ensure program correctness. Additionally, it serves as a logic-based source for generating verified datasets used to train and benchmark artificial intelligence reasoning systems.

The system distinguishes itself through a small-kernel verification model, where all proofs are verified by a trusted core of basic logical rules. It employs a tactic-based approach to automate proof construction and supports the creation of modular mathematical libraries for collaborative development. The environment also includes capabilities for literate programming, combining formal proofs with informal prose for scientific documentation.

The project covers a broad range of capabilities, including formal software verification for distributed protocols and program semantics, as well as general-purpose functional programming with monadic effect management. It provides tools for automated reasoning, counterexample generation, and differential testing to ensure systems behave exactly as specified.

The language is designed for efficiency with pure functional compilation and reference-counting memory management, and it can be executed directly within a web browser.

## Tags

### Programming Languages & Runtimes

- [Functional Programming Logic](https://awesome-repositories.com/f/programming-languages-runtimes/functional-programming-logic.md) — Provides a pure functional programming environment with dependent types and monadic IO for general software and logic development.
- [Dependent Type Systems](https://awesome-repositories.com/f/programming-languages-runtimes/dependent-type-systems.md) — Implements a type system where types depend on values to enforce complex invariants before execution. ([source](https://lean-lang.org/functional_programming_in_lean/))
- [Dependent Type Theorem Provers](https://awesome-repositories.com/f/programming-languages-runtimes/dependent-type-theorem-provers.md) — Functions as a dependent type theorem prover used to formalize mathematics and verify software.
- [Dependent Types](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-definitions/type-aliases/object-aliasing/object-type-restrictions/exact-object-types/path-dependent-type-systems/dependent-types.md) — Implements a dependent-type system that allows types to depend on values for encoding complex mathematical properties.
- [General Purpose Languages](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/language-specific-resources/general-purpose-languages.md) — Provides a high-level, versatile functional programming language for general software development. ([source](https://lean-lang.org/doc/reference/latest/))
- [Pure Functional Runtimes](https://awesome-repositories.com/f/programming-languages-runtimes/pure-functional-runtimes.md) — Translates high-level logical expressions into an optimized bytecode format for execution on a pure functional runtime.
- [Purely Functional Languages](https://awesome-repositories.com/f/programming-languages-runtimes/purely-functional-languages.md) — Implements a purely functional language with immutable data and first-class support for monads.
- [Side Effect Management](https://awesome-repositories.com/f/programming-languages-runtimes/side-effect-management.md) — Provides techniques for controlling evaluation order and managing impure operations via monadic patterns. ([source](https://lean-lang.org/functional_programming_in_lean/))
- [Small-Kernel Verification Systems](https://awesome-repositories.com/f/programming-languages-runtimes/small-kernel-verification-systems.md) — Verifies all proofs by checking they reduce to a tiny, trusted core of basic logical rules.
- [Binary Size Optimizations](https://awesome-repositories.com/f/programming-languages-runtimes/binary-size-optimizations.md) — Optimizes binary size and execution speed using ownership-aware compilation and reference counting. ([source](https://lean-lang.org/fro/roadmap/y3))
- [Parser Grammar Extensions](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/metaprogramming-macros/custom-macro-definitions/parser-grammar-extensions.md) — Allows the definition of custom grammar rules to embed domain-specific languages directly into the core parser.
- [Reference Counting](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/ownership-borrowing/reference-counting.md) — Uses a refined reference counting system with ownership awareness to manage memory without a heavy garbage collector.

### Scientific & Mathematical Computing

- [Formal Mathematical Proofs](https://awesome-repositories.com/f/scientific-mathematical-computing/formal-mathematical-proofs.md) — Provides a system for generating and verifying formal mathematical proofs using a dependently typed functional language.
- [Automated Proof Construction](https://awesome-repositories.com/f/scientific-mathematical-computing/automated-proof-construction.md) — Uses a user-extensible tactic language to generate proof terms that are verified by a central kernel. ([source](https://lean-lang.org/doc/reference/latest/))
- [Automated Reasoning Tactics](https://awesome-repositories.com/f/scientific-mathematical-computing/automated-reasoning-tactics.md) — Implements a tactic-based approach to automate the construction of formal mathematical proofs. ([source](https://lean-lang.org/fro/roadmap/y3))
- [Correctness Proofs](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithm-analysis/correctness-proofs.md) — Combines programming with formal proofs and induction to ensure software behaves exactly as specified. ([source](https://lean-lang.org/functional_programming_in_lean/))
- [Formalization Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/mathematical-libraries-and-utilities/mathematical-libraries/formalization-libraries.md) — Provides a framework for building structured, modular libraries of definitions and lemmas for collaborative mathematics. ([source](https://lean-lang.org/doc/reference/latest/))
- [Tactic-Based Proof Construction](https://awesome-repositories.com/f/scientific-mathematical-computing/tactic-based-proof-construction.md) — Generates formal proof terms by executing high-level scripts that automate the search for logical evidence.
- [Modular Formalization Management](https://awesome-repositories.com/f/scientific-mathematical-computing/formal-mathematical-proofs/modular-formalization-management.md) — Organizes formalizations into modular components so multiple contributors can work on different parts of a complex proof. ([source](https://lean-lang.org/use-cases/flt))

### Part of an Awesome List

- [Formal Verification](https://awesome-repositories.com/f/awesome-lists/devtools/formal-verification.md) — Proves that a program behaves exactly as specified to ensure memory safety, correctness, and the absence of bugs.
- [Proof Assistants](https://awesome-repositories.com/f/awesome-lists/devtools/proof-assistants.md) — Acts as an interactive proof assistant for constructing proofs step-by-step via a tactic language.
- [Documentation and Literate Programming](https://awesome-repositories.com/f/awesome-lists/devtools/documentation-and-literate-programming.md) — Combines formal proofs with informal prose using a specialized language for scientific communication and web publishing. ([source](https://lean-lang.org/fro/roadmap/y3))
- [Mathematical Literate Programming](https://awesome-repositories.com/f/awesome-lists/devtools/documentation-and-literate-programming/mathematical-literate-programming.md) — Implements literate programming capabilities to combine formal proofs with informal prose for scientific documentation.

### Development Tools & Productivity

- [Interactive Proof Derivation](https://awesome-repositories.com/f/development-tools-productivity/human-in-the-loop-interfaces/interactive-prompts/proof-result-interaction/interactive-proof-derivation.md) — Guides the step-by-step derivation of mathematical proofs using interactive tactics and logical rules. ([source](https://lean-lang.org/theorem_proving_in_lean4/))
- [Collaborative Research Environments](https://awesome-repositories.com/f/development-tools-productivity/collaborative-research-environments.md) — Builds a shared foundation of formalized knowledge to allow multiple researchers to tackle complex mathematical theories together. ([source](https://lean-lang.org/use-cases/mathlib))

### Testing & Quality Assurance

- [Mathematical Property Specifications](https://awesome-repositories.com/f/testing-quality-assurance/property-verification/mathematical-property-specifications.md) — Uses inductive predicates and dependent types to define and prove complex mathematical properties of data structures. ([source](https://lean-lang.org/examples/))
- [Formal Verification Tools](https://awesome-repositories.com/f/testing-quality-assurance/validation-verification/formal-verification-tools.md) — Provides a framework for mathematically proving the correctness of software algorithms and protocols.
- [Differential Testing](https://awesome-repositories.com/f/testing-quality-assurance/differential-testing.md) — Executes random inputs against both a formal model and a production implementation to ensure identical outputs. ([source](https://lean-lang.org/use-cases/cedar))
- [Counterexample Identification](https://awesome-repositories.com/f/testing-quality-assurance/failing-case-shrinkers/counterexample-identification.md) — Provides tools to automatically generate counterexamples that disprove conjectures and identify logical bugs. ([source](https://lean-lang.org/fro/roadmap/y3))
- [Formal Protocol Verification](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/unit/unit-testing/race-condition-detection/formal-protocol-verification.md) — Includes tools for formally verifying the correctness of distributed communication and consensus protocols. ([source](https://lean-lang.org/use-cases/veil))

### Artificial Intelligence & ML

- [Mathematical Reasoning Training](https://awesome-repositories.com/f/artificial-intelligence-ml/large-scale-training/mathematical-reasoning-training.md) — Generates verified mathematical datasets used to train and benchmark AI reasoning systems.
- [Formalized Mathematics Datasets](https://awesome-repositories.com/f/artificial-intelligence-ml/large-scale-training/mathematical-reasoning-training/formalized-mathematics-datasets.md) — Supplies formalized mathematics datasets to train models for discovering and verifying mathematical proofs. ([source](https://lean-lang.org/use-cases/mathlib))
- [Synthetic Reasoning Data Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/synthetic-data-generators/synthetic-reasoning-data-generators.md) — Produces verified datasets of mathematical logic to train and benchmark artificial intelligence reasoning systems. ([source](https://lean-lang.org/use-cases/flt))

### Operating Systems & Systems Programming

- [Language Semantics Verification](https://awesome-repositories.com/f/operating-systems-systems-programming/memory-safety-diagnostics/memory-safety-verification/language-semantics-verification.md) — Translates code into functional representations to formally verify memory safety and borrow semantics. ([source](https://lean-lang.org/use-cases/aeneas))

### Software Engineering & Architecture

- [Grammar Extensions](https://awesome-repositories.com/f/software-engineering-architecture/extensible-plugin-architectures/grammar-extensions.md) — Defines custom syntax and grammar rules to embed new languages or domain-specific notations into the environment. ([source](https://lean-lang.org/examples/))
