Β 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 Lean Language
    1. 3.1. Files
    2. 3.2. The Type System
    3. 3.3. Module Contents
    4. 3.4. Axioms
    5. 3.5. Recursive Definitions
    6. 3.6. Attributes
    7. 3.7. Type Classes
    8. 3.8. Dynamic Typing
    9. 3.9. Coercions
  4. 4. Terms
    1. 4.1. Identifiers
    2. 4.2. Function Types
    3. 4.3. Functions
    4. 4.4. Function Application
    5. 4.5. Literals
    6. 4.6. Structures and Constructors
    7. 4.7. Conditionals
    8. 4.8. Pattern Matching
    9. 4.9. Holes
    10. 4.10. Type Ascription
    11. 4.11. Quotation and Antiquotation
    12. 4.12. do-Notation
    13. 4.13. Proofs
  5. 5. Functors, Monads and do-Notation
    1. 5.1. Laws
    2. 5.2. Lifting Monads
    3. 5.3. Syntax
    4. 5.4. API Reference
    5. 5.5. Varieties of Monads
  6. 6. IO
    1. 6.1. Logical Model
    2. 6.2. Control Structures
    3. 6.3. Console Output
    4. 6.4. Mutable References
    5. 6.5. Files, File Handles, and Streams
    6. 6.6. Environment Variables
    7. 6.7. Timing
    8. 6.8. Processes
    9. 6.9. Random Numbers
    10. 6.10. Tasks and Threads
  7. 7. Tactic Proofs
    1. 7.1. Running Tactics
    2. 7.2. Reading Proof States
    3. 7.3. The Tactic Language
    4. 7.4. Options
    5. 7.5. Tactic Reference
    6. 7.6. Targeted Rewriting with conv
    7. 7.7. Custom Tactics
  8. 8. The Simplifier
    1. 8.1. Invoking the Simplifier
    2. 8.2. Rewrite Rules
    3. 8.3. Simp sets
    4. 8.4. Simp Normal Forms
    5. 8.5. Terminal vs Non-Terminal Positions
    6. 8.6. Configuring Simplification
    7. 8.7. Simplification vs Rewriting
  9. 9. Basic Types
    1. 9.1. Natural Numbers
    2. 9.2. Integers
    3. 9.3. Finite Natural Numbers
    4. 9.4. Fixed-Precision Integer Types
    5. 9.5. Bitvectors
    6. 9.6. Floating-Point Numbers
    7. 9.7. Characters
    8. 9.8. Strings
    9. 9.9. The Unit Type
    10. 9.10. The Empty Type
    11. 9.11. Booleans
    12. 9.12. Optional Values
    13. 9.13. Tuples
    14. 9.14. Sum Types
    15. 9.15. Dependent Pairs
    16. 9.16. Linked Lists
    17. 9.17. Arrays
    18. 9.18. Subtypes
    19. 9.19. Lazy Computations
    20. 9.20. Tasks and Threads
  10. 10. Standard Library
  11. 11. Notations and Macros
    1. 11.1. Custom Operators
    2. 11.2. Precedence
    3. 11.3. Notations
    4. 11.4. Defining New Syntax
    5. 11.5. Macros
    6. 11.6. Elaborators
  12. 12. Output from Lean
  13. 13. Elan
  14. 14. Lake and Reservoir
    1. 14.1. Lake
    2. 14.2. Reservoir
  15. Index