Working reference and glossary
Essential syntax
| Syntax | Meaning |
|---|---|
x : α | x has type α |
def f ... := ... | A named definition with a body |
theorem t : P := ... | A named proof of P |
example : P := ... | An unnamed checked example |
fun x => body | An anonymous function |
{x : α} | An implicit argument |
[C α] | An inferred instance argument |
let x := value | Bind a local value |
let x ← action | Sequence a monadic computation |
match x with ... | Inspect constructors |
if h : P then ... else ... | Branch with evidence for the condition |
by ... | Construct a term through tactics |
⟨a, b⟩ | Constructor notation guided by the expected type |
x :: xs | A list head followed by its tail |
#[a, b] | An array literal |
{x : α // P x} | A value with evidence of a property |
Terms worth knowing
| Term | Meaning |
|---|---|
| Elaboration | Converts surface syntax into core expressions, resolving implicit arguments, overloaded operations, and tactic scripts |
| Reduction | Computes an expression using Lean’s definitional rules |
| Definitional equality | Equality Lean recognises from its computation rules |
| Propositional equality | A claim such as a = b that may require a proof beyond reduction |
| Constructor | Builds a value of an inductive type |
| Recursor | Defines how to use an inductive value by handling its constructors |
| Structural recursion | Recursion on smaller constructor fields |
| Induction | Proves a property by using corresponding hypotheses about smaller values |
| Goal | The type of a missing term in a proof |
| Local context | The variables and hypotheses available for constructing the term |
| Metavariable | An unknown term or type that elaboration can assign. An unresolved metavariable may indicate missing type information |
| Type class | Packages operations or laws for instance inference |
| Instance | Supplies the operations or laws required by a type class |
| Coercion | A conversion Lean can insert to meet an expected type |
| Universe | A level in Lean’s hierarchy of types |
| Monad | Provides pure and sequencing in which a later computation can depend on an earlier result |
| Monad transformer | Adds an effect layer to another computation |
| Dependent type | A type that mentions a value |
| Index | Can vary across constructors of an inductive family |
| Parameter | Remains uniform across constructors of an inductive family |
| Kernel | Checks core terms against their types |
| Axiom | A constant declared without a defining proof or body |
| Proof erasure | Removes logical evidence from runtime code |
| Invariant | A property preserved as a computation proceeds |
| Specification | States the observable behaviour required of an implementation |
Commands to remember
lean --version
lake build
lake env lean File.lean
lake env lean -DwarningAsError=true Tests.lean
lake exe cache get
Use the cache command in projects that provide the Mathlib cache executable.
Inside a file, begin with #check name, #check @name, #print name, and #print axioms theoremName. In a proof, inspect the goal and its local context first.