Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Working reference and glossary

Essential syntax

SyntaxMeaning
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 => bodyAn anonymous function
{x : α}An implicit argument
[C α]An inferred instance argument
let x := valueBind a local value
let x ← actionSequence 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 :: xsA list head followed by its tail
#[a, b]An array literal
{x : α // P x}A value with evidence of a property

Terms worth knowing

TermMeaning
ElaborationConverts surface syntax into core expressions, resolving implicit arguments, overloaded operations, and tactic scripts
ReductionComputes an expression using Lean’s definitional rules
Definitional equalityEquality Lean recognises from its computation rules
Propositional equalityA claim such as a = b that may require a proof beyond reduction
ConstructorBuilds a value of an inductive type
RecursorDefines how to use an inductive value by handling its constructors
Structural recursionRecursion on smaller constructor fields
InductionProves a property by using corresponding hypotheses about smaller values
GoalThe type of a missing term in a proof
Local contextThe variables and hypotheses available for constructing the term
MetavariableAn unknown term or type that elaboration can assign. An unresolved metavariable may indicate missing type information
Type classPackages operations or laws for instance inference
InstanceSupplies the operations or laws required by a type class
CoercionA conversion Lean can insert to meet an expected type
UniverseA level in Lean’s hierarchy of types
MonadProvides pure and sequencing in which a later computation can depend on an earlier result
Monad transformerAdds an effect layer to another computation
Dependent typeA type that mentions a value
IndexCan vary across constructors of an inductive family
ParameterRemains uniform across constructors of an inductive family
KernelChecks core terms against their types
AxiomA constant declared without a defining proof or body
Proof erasureRemoves logical evidence from runtime code
InvariantA property preserved as a computation proceeds
SpecificationStates 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.