Β The Lean Language ReferenceπŸ”—

This is the Lean Language Reference, an in-progress reference work on Lean. It is intended to be a comprehensive, precise description of Lean: a reference work in which Lean users can look up detailed information, rather than a tutorial intended for new users. For other documentation, please refer to the Lean documentation site.

This reference manual is not yet complete, but there's enough information to provide value to users. The top priority is to add the missing information as quickly as possible while staying up to date with Lean development. As the rest of the text is written, regular snapshots will be released, tracking upstream changes. This snapshot covers Lean version 4.15.0-rc1.

Our prioritization of content is based on our best understanding of our users' needs. Please use the issue tracker to help us better understand what you need to know. In particular, please create or upvote issues for topics that are important to you. Your feedback is much appreciated! Once sufficient content is available, we will begin saving snapshots for each release of Lean and making them conveniently available.

API reference documentation is included from the Lean standard library source code. Due to technical limitations at the moment, the Lean terms and examples embedded in it do not render as nicely as we would like. In the near future, we will be working on removing these limitations. Additionally, we will be adding missing API reference documentation and revising and improving the existing API reference documentation.

Release History

2024-12-16

This is the initial release of the reference manual.

  1. 1. Introduction
    1. 1.1. Lean
    2. 1.2. Typographical Conventions
  2. 2. Elaboration and Compilation
    1. 2.1. Parsing
    2. 2.2. Macro Expansion and Elaboration
    3. 2.3. The Kernel
    4. 2.4. Elaboration Results
    5. 2.5. Initialization
  3. 3. The Type System
    1. 3.1. Functions
    2. 3.2. Propositions
    3. 3.3. Universes
    4. 3.4. Inductive Types
    5. 3.5. Quotients
  4. 4. Source Files
    1. 4.1. Files
    2. 4.2. Module Contents
    3. 4.3. Axioms
    4. 4.4. Recursive Definitions
    5. 4.5. Attributes
    6. 4.6. Dynamic Typing
    7. 4.7. Coercions
  5. 5. Terms
    1. 5.1. Identifiers
    2. 5.2. Function Types
    3. 5.3. Functions
    4. 5.4. Function Application
    5. 5.5. Literals
    6. 5.6. Structures and Constructors
    7. 5.7. Conditionals
    8. 5.8. Pattern Matching
    9. 5.9. Holes
    10. 5.10. Type Ascription
    11. 5.11. Quotation and Antiquotation
    12. 5.12. do-Notation
    13. 5.13. Proofs
  6. 6. Type Classes
    1. 6.1. Class Declarations
    2. 6.2. Instance Declarations
    3. 6.3. Instance Synthesis
    4. 6.4. Deriving Instances
    5. 6.5. Basic Classes
  7. 7. Functors, Monads and do-Notation
    1. 7.1. Laws
    2. 7.2. Lifting Monads
    3. 7.3. Syntax
    4. 7.4. API Reference
    5. 7.5. Varieties of Monads
  8. 8. IO
    1. 8.1. Logical Model
    2. 8.2. Control Structures
    3. 8.3. Console Output
    4. 8.4. Mutable References
    5. 8.5. Files, File Handles, and Streams
    6. 8.6. Environment Variables
    7. 8.7. Timing
    8. 8.8. Processes
    9. 8.9. Random Numbers
    10. 8.10. Tasks and Threads
  9. 9. Tactic Proofs
    1. 9.1. Running Tactics
    2. 9.2. Reading Proof States
    3. 9.3. The Tactic Language
    4. 9.4. Options
    5. 9.5. Tactic Reference
    6. 9.6. Targeted Rewriting with conv
    7. 9.7. Custom Tactics
  10. 10. The Simplifier
    1. 10.1. Invoking the Simplifier
    2. 10.2. Rewrite Rules
    3. 10.3. Simp sets
    4. 10.4. Simp Normal Forms
    5. 10.5. Terminal vs Non-Terminal Positions
    6. 10.6. Configuring Simplification
    7. 10.7. Simplification vs Rewriting
  11. 11. Basic Types
    1. 11.1. Natural Numbers
    2. 11.2. Integers
    3. 11.3. Finite Natural Numbers
    4. 11.4. Fixed-Precision Integer Types
    5. 11.5. Bitvectors
    6. 11.6. Floating-Point Numbers
    7. 11.7. Characters
    8. 11.8. Strings
    9. 11.9. The Unit Type
    10. 11.10. The Empty Type
    11. 11.11. Booleans
    12. 11.12. Optional Values
    13. 11.13. Tuples
    14. 11.14. Sum Types
    15. 11.15. Dependent Pairs
    16. 11.16. Linked Lists
    17. 11.17. Arrays
    18. 11.18. Subtypes
    19. 11.19. Lazy Computations
    20. 11.20. Tasks and Threads
  12. 12. Standard Library
  13. 13. Notations and Macros
    1. 13.1. Custom Operators
    2. 13.2. Precedence
    3. 13.3. Notations
    4. 13.4. Defining New Syntax
    5. 13.5. Macros
    6. 13.6. Elaborators
  14. 14. Output from Lean
  15. 15. Elan
  16. 16. Lake and Reservoir
    1. 16.1. Lake
    2. 16.2. Reservoir
  17. Index