Lean 4 is an open-source language designed for both functional programming and formal verification. It lets you write programs, state mathematical theorems, and prove them correct—all in the same language. With an expressive type system rooted in dependent type theory, a rich tactic framework, and the Lake build system, Lean 4 is used by researchers, mathematicians, and software engineers worldwide.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/leanprover/lean4/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
Install Lean 4 and write your first program or proof in minutes.
Installation
Set up Lean 4 with Elan, the version manager, on Linux, macOS, or Windows.
Language Basics
Explore Lean’s syntax, types, functions, inductive types, and type classes.
Theorem Proving
Learn to state propositions and construct proofs using tactics and term mode.
What Is Lean 4?
Lean 4 unifies two traditionally separate worlds: functional programming and interactive theorem proving. You can write a sorting algorithm and formally prove its correctness in the same file, sharing definitions between your program and your proof.Tactic Proving
Use
simp, omega, decide, grind, and other built-in tactics to close proof goals interactively.Do-Notation & Monads
Write effectful code with Lean’s ergonomic
do-notation and monad abstractions.Metaprogramming
Extend the language with macros, custom syntax, elaborators, and tactic DSLs.
Lake Build System
Manage packages, libraries, executables, and dependencies with the Lake build tool.
Get Started in 3 Steps
Install Elan and Lean 4
Install the Lean toolchain manager
elan, which automatically downloads and manages Lean versions:Key Features
Dependent Types
Types that depend on values, enabling precise specifications and compile-time guarantees.
Interactive Proofs
The infoview shows proof goals in real time as you write tactics in VS Code or Emacs.
Native Compilation
Lean compiles to efficient native code via the LCNF intermediate representation.
Extensible Syntax
Define new notation, operators, and domain-specific languages directly in Lean.
LSP Server
Rich editor integration via the Language Server Protocol—autocomplete, hover, go-to-definition, and more.
FFI Support
Call C and C++ functions from Lean and expose Lean functions to C with the foreign function interface.
Explore the Documentation
Lake Build System
Learn to configure packages, manage dependencies, and publish libraries.
Writing Tactics
Build custom tactic combinators and register them with the elaborator.
Foreign Function Interface
Integrate with C libraries and expose Lean functions to external code.
Contributing to Lean
Build Lean from source and set up a development environment.