Notation
| Lean theorem prover: map |
|---|
| Reading the edition Three levels of reading Glossary Notation Chronology |
| Reading by level Start here: What a proof assistant does The type theory: Terms, types and judgments How Lean works: Elaboration The history: Automath The applications: Research mathematics |
| Sources Sources Bibliography Further reading |
| Related The move to Lean |
This page fixes the notation used across the edition. The Foundations pages write the rules of Lean's type theory in the notation of the type-theory literature, inside formulas. Lean writes many of the same things in its own syntax, inside code. The tables set the two side by side, with a one-line meaning and the page on which each first appears in the reading order; where the formula and the Lean syntax first appear on different pages, both are named. A dash means that the notation has no counterpart on that side.
The formulas follow Carneiro's presentation of Lean's type theory, as Terms, types and judgments explains; the Lean syntax is that of Lean 4.34.1.
Judgments and rules
A judgment is a statement about the theory, made by its rules; it is not a proposition
inside Lean, and Lean has no syntax for asserting one. Lean shows judgments in what it prints:
#check prints e : A, and the display of a goal lists a context above
⊢.
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
the lines above ⊢ in a goal |
a context: variables with their types, , each type may mention the variables before it | Terms, types and judgments | |
⊢ |
in a formula, "derives"; in a goal, it separates what may be used, above, from what must be shown, after it | formula: Terms, types and judgments; goal: Induction, as the machine sees it | |
e : A, as #check e prints it |
the typing judgment: in the context , the term has type | Terms, types and judgments | |
| – | definitional equality: and are equal by computation and unfolding, with no proof; Lean tests it when it checks rfl |
Terms, types and judgments | |
| – | Carneiro's algorithmic definitional equality, the relation the Lean kernel's test decides; it implies | Definitional equality | |
| , | – | the context is well formed; the empty context | Terms, types and judgments |
| – | an inference rule: from the judgments above the line, the one below | Terms, types and judgments | |
| – | with put in place of the variable | Terms, types and judgments |
Functions, types and universes
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
| , , | (x : A) → B, ∀ x : A, B |
dependent function type: functions whose result type may mention the argument ; Lean prints it with ∀ when is a proposition |
formula: Terms, types and judgments, at Dependent function types; Lean: Dependent function types |
A → B |
function type, when does not mention the argument; implication, when and are propositions | Propositions as types | |
fun (x : A) => e, also written fun x ↦ e or λ x => e |
function abstraction: the function sending to | formula: Terms, types and judgments; Lean: What the axioms are | |
f a |
application of to | Terms, types and judgments | |
let x : A := v; e |
a local definition | Terms, types and judgments | |
Sort u |
the universe at level , the type of the types at that level | formula: Terms, types and judgments; Lean: Building things from constructors | |
Prop |
the universe of propositions | Propositions as types | |
Type u; Type is Type 0 |
the universes of data | Why there is no type of all types | |
| – | Carneiro's name for the universe written in this edition | Terms, types and judgments | |
imax u v |
the level of a function type: if , otherwise | formula: Terms, types and judgments; Lean: Universes and Prop | |
c.{u} |
the constant used at the universe levels | formula: Terms, types and judgments; Lean: Building things from constructors | |
| – | {x : A}, [C A] |
an implicit argument, filled in by unification; an instance-implicit argument, filled in by instance resolution | Building things from constructors; explained at Dependent function types |
| – | ⟨a, b⟩ |
the anonymous constructor: a value of a type with one constructor, such as a pair or a proof of p ∧ q |
Propositions as types |
| – | A × B |
the type of pairs | Definitional equality |
(x : A) × B, Σ x : A, B |
dependent pair: pairs whose second part has a type that depends on the first | named at Structural and well-founded recursion; no page writes the symbol | |
Nat.rec |
the recursor of the natural numbers, at once induction and primitive recursion | formula: Inductive types and recursors; Lean: Building things from constructors | |
| , | WellFounded, Acc |
a well-founded relation; the proposition that is accessible, the basis of well-founded recursion | Structural and well-founded recursion |
In Lean the dependent function type, function abstraction and the dependent pair are written
as in the second column; the reference manual gives the full syntax, including ↦
in place of =>.[1][2] Each line below
is accepted by Lean 4.34.1:
example : Sort 0 = Prop := rfl example : Sort 1 = Type := rfl example : Type 1 = Sort 2 := rfl example : (fun (x : Nat) => x + 1) 2 = 3 := rfl example : (fun (x : Nat) ↦ x + 1) 2 = 3 := rfl example : (λ (x : Nat) => x + 1) 2 = 3 := rfl def pair : (n : Nat) × Fin (n + 1) := ⟨2, 0⟩ def pair' : Σ n : Nat, Fin (n + 1) := ⟨2, 0⟩ #check ∀ x : Nat, x = x #check (x : Nat) → Fin (x + 1) #check Nat → Nat #check fun (x : Nat) => x + 1 #check (Σ n : Nat, Fin (n + 1))
The five #check lines print:
∀ (x : Nat), x = x : Prop (x : Nat) → Fin (x + 1) : Type Nat → Nat : Type fun x => x + 1 : Nat → Nat (n : Nat) × Fin (n + 1) : Type
The same dependent function type is printed with ∀ when its result is a
proposition and with → otherwise, and Lean prints a dependent pair written with
Σ in the form (n : Nat) × ….
Logic
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
∀ x : A, P x |
for every ; a dependent function type into Prop |
formula: Classical logic from choice; Lean: Induction, as the machine sees it | |
∃ x : A, P x, the type Exists |
there is an ; proved by a witness and a proof, ⟨w, h⟩ |
formula: Classical logic from choice; Lean: Automation and its limits | |
| – | p ∧ q, the type And |
and | Propositions as types |
p ∨ q, the type Or |
or | formula: Classical logic from choice; Lean: Propositions as types | |
¬p, defined as p → False |
not | formula: Classical logic from choice; Lean: What the axioms are | |
p ↔ q, the type Iff |
if and only if | The three axioms | |
| , | True, False |
the proposition with one proof, and the one with none | formula: Classical logic from choice; Lean: True at What the axioms are, False at What has to be trusted
|
a ≠ b, meaning ¬(a = b) |
not equal | formula: Classical logic from choice; Lean: Automation and its limits |
Each of these proofs is accepted by Lean 4.34.1; the last shows that ¬p is
p → False by definition:
example (p q : Prop) (hp : p) (hq : q) : p ∧ q := ⟨hp, hq⟩ example (p q : Prop) (hp : p) : p ∨ q := Or.inl hp example (p q : Prop) (h : p → q) (hp : p) : q := h hp example (p q : Prop) : p ∧ q ↔ q ∧ p := ⟨fun ⟨a, b⟩ => ⟨b, a⟩, fun ⟨a, b⟩ => ⟨b, a⟩⟩ example : ∀ n : Nat, n + 0 = n := fun _ => rfl example : ∃ n : Nat, n + 2 = 5 := ⟨3, rfl⟩ example : (2 : Nat) ≠ 3 := by decide example (p : Prop) : (¬p) = (p → False) := rfl
Equality
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
a = b, the type Eq a b |
propositional equality: a proposition, whose proofs are terms | formula: Propositional equality; Lean: What the axioms are | |
| – | definitional equality, the judgment above | Terms, types and judgments | |
rfl, Eq.refl a |
the one constructor of equality: a proof of | formula: Propositional equality; Lean: Two kinds of equality | |
Eq.rec |
the eliminator of equality: what holds of holds of when | Propositional equality | |
| – | h ▸ e |
substitution: carried along a proof h : a = b |
Propositional equality |
| – | a ≍ b, the type HEq a b |
heterogeneous equality, between terms whose types may differ | Propositional equality |
| , | Quot r, Quot.mk r a |
the quotient of a type by a relation , and the element of it that gives | formula: Quotient types; Lean: Propositional equality |
example (a b : Nat) (h : a = b) (P : Nat → Prop) (hp : P a) : P b := h ▸ hp example (n : Nat) (x : Fin n) : x ≍ x := HEq.rfl #check @HEq
Lean 4.34.1 accepts both and prints @HEq : {α : Sort u_1} → α → {β : Sort u_1} → β → Prop:
the two sides of ≍ may have different types.
Holes and unification
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
?m.12 |
a metavariable, a hole the elaborator has yet to fill | formula: Metavariables and unification; Lean: Holes and goals | |
s =?= t |
a unification problem: find values of the metavariables that make the two sides definitionally equal | Metavariables and unification |
Metatheory
| in formulas | in Lean | meaning | first used |
|---|---|---|---|
| – | the theory proves that the theory is consistent | Consistency and the metatheory | |
| – | Zermelo–Fraenkel set theory with choice and inaccessible cardinals | Consistency and the metatheory | |
| , | – | the Calculus of Inductive Constructions, or Lean's type theory, with universes | Consistency and the metatheory |
Commands and keywords
| in Lean | meaning | first used |
|---|---|---|
example : A := e, theorem c : A := e, def c : A := e |
a term e of type A, unnamed, as a named theorem, or as a named definition |
Propositions as types |
by |
the term that follows is to be built by tactics | Types as specifications |
rfl |
the proof of a = a; it closes a goal whose two sides are definitionally equal |
Two kinds of equality |
sorry |
a placeholder for a missing proof, recorded as the axiom sorryAx |
What the axioms are |
#check e |
print the type of e |
Why there is no type of all types |
#print c |
print the definition of c |
What the axioms are |
#print axioms c |
list the axioms that c depends on |
What the axioms are |
#eval e |
compute e and print the result |
Functions that always finish |
Next
Sources, what was read for the edition.
References
- ↑ The Lean Language Reference, for Lean 4.34.0, lean-lang.org, 2026, section 13.3, "Functions". https://lean-lang.org/doc/reference/4.34.0/Terms/Functions/
- ↑ The Lean Language Reference, for Lean 4.34.0, lean-lang.org, 2026, section 4.1, "Functions". https://lean-lang.org/doc/reference/4.34.0/The-Type-System/Functions/