Ordinals #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Ordinals are defined as equivalences of well-ordered sets under order isomorphism. They are endowed with a total order, where an ordinal is smaller than another one if it embeds into it as an initial segment (or, equivalently, in any way). This total order is well founded.
Main definitions #
-
ordinal
: the type of ordinals (in a given universe) -
ordinal.type r
: given a well-founded orderr
, this is the corresponding ordinal -
ordinal.typein r a
: given a well-founded orderr
on a typeα
, anda : α
, the ordinal corresponding to all elements smaller thana
. -
enum r o h
: given a well-orderr
on a typeα
, and an ordinalo
strictly smaller than the ordinal corresponding tor
(this is the assumptionh
), returns theo
-th element ofα
. In other words, the elements ofα
can be enumerated using ordinals up totype r
. -
ordinal.card o
: the cardinality of an ordinalo
. -
ordinal.lift
lifts an ordinal in universeu
to an ordinal in universemax u v
. For a version registering additionally that this is an initial segment embedding, seeordinal.lift.initial_seg
. For a version regiserting that it is a principal segment embedding ifu < v
, seeordinal.lift.principal_seg
. -
ordinal.omega
orω
is the order type ofℕ
. This definition is universe polymorphic:ordinal.omega.{u} : ordinal.{u}
(contrast withℕ : Type
, which lives in a specific universe). In some cases the universe level has to be given explicitly. -
o₁ + o₂
is the order on the disjoint union ofo₁
ando₂
obtained by declaring that every element ofo₁
is smaller than every element ofo₂
. The main properties of addition (and the other operations on ordinals) are stated and proved inordinal_arithmetic.lean
. Here, we only introduce it and prove its basic properties to deduce the fact that the order on ordinals is total (and well founded). -
succ o
is the successor of the ordinalo
. -
cardinal.ord c
: whenc
is a cardinal,ord c
is the smallest ordinal with this cardinality. It is the canonical way to represent a cardinal with an ordinal.
A conditionally complete linear order with bot structure is registered on ordinals, where ⊥
is
0
, the ordinal corresponding to the empty type, and Inf
is the minimum for nonempty sets and 0
for the empty set by convention.
Notations #
ω
is a notation for the first infinite ordinal in the localeordinal
.
Well order on an arbitrary type #
An embedding of any type to the set of cardinals.
Any type can be endowed with a well order, obtained by pulling back the well order over cardinals by some embedding.
Equations
Instances for well_ordering_rel
Definition of ordinals #
Bundled structure registering a well order on a type. Ordinals will be defined as a quotient of this type.
Instances for Well_order
- Well_order.has_sizeof_inst
- Well_order.inhabited
- ordinal.is_equivalent
Equivalence relation on well orders on arbitrary types in universe u
, given by order
isomorphism.
Equations
- ordinal.is_equivalent = {r := λ (_x : Well_order), ordinal.is_equivalent._match_2 _x, iseqv := ordinal.is_equivalent._proof_1}
- ordinal.is_equivalent._match_2 {α := α, r := r, wo := wo} = λ (_x : Well_order), ordinal.is_equivalent._match_1 α r _x
- ordinal.is_equivalent._match_1 α r {α := β, r := s, wo := wo'} = nonempty (r ≃r s)
ordinal.{u}
is the type of well orders in Type u
, up to order isomorphism.
Equations
Instances for ordinal
- ordinal.has_zero
- ordinal.inhabited
- ordinal.has_one
- ordinal.nontrivial
- ordinal.partial_order
- ordinal.order_bot
- ordinal.zero_le_one_class
- ordinal.has_well_founded
- ordinal.has_add
- ordinal.add_monoid_with_one
- ordinal.add_covariant_class_le
- ordinal.add_swap_covariant_class_le
- ordinal.linear_order
- ordinal.well_founded_lt
- ordinal.has_lt.lt.is_well_order
- ordinal.conditionally_complete_linear_order_bot
- ordinal.no_max_order
- ordinal.succ_order
- ordinal.add_contravariant_class_le
- ordinal.add_covariant_class_lt
- ordinal.add_contravariant_class_lt
- ordinal.add_swap_contravariant_class_lt
- ordinal.has_sub
- ordinal.has_exists_add_of_le
- ordinal.monoid
- ordinal.monoid_with_zero
- ordinal.no_zero_divisors
- ordinal.left_distrib_class
- ordinal.mul_covariant_class_le
- ordinal.mul_swap_covariant_class_le
- ordinal.has_div
- ordinal.has_dvd.dvd.is_antisymm
- ordinal.has_mod
- ordinal.has_pow
Equations
- has_well_founded_out o = {r := (quotient.out o).r, wf := _}
Equations
The order type of a well order is an ordinal.
Equations
Equations
- ordinal.inhabited = {default := 0}
Equations
The order type of an element inside a well order. For the embedding as a principal segment, see
typein.principal_seg
.
Equations
- ordinal.typein r a = ordinal.type (subrel r {b : α | r b a})
The order on ordinals #
Equations
- ordinal.partial_order = {le := λ (a b : ordinal), quotient.lift_on₂ a b (λ (_x : Well_order), ordinal.partial_order._match_2 _x) ordinal.partial_order._proof_1, lt := λ (a b : ordinal), quotient.lift_on₂ a b (λ (_x : Well_order), ordinal.partial_order._match_12 _x) ordinal.partial_order._proof_2, le_refl := ordinal.partial_order._proof_3, le_trans := ordinal.partial_order._proof_4, lt_iff_le_not_le := ordinal.partial_order._proof_5, le_antisymm := ordinal.partial_order._proof_6}
- ordinal.partial_order._match_2 {α := α, r := r, wo := wo} = λ (_x : Well_order), ordinal.partial_order._match_1 α r _x
- ordinal.partial_order._match_12 {α := α, r := r, wo := wo} = λ (_x : Well_order), ordinal.partial_order._match_11 α r _x
- ordinal.partial_order._match_1 α r {α := β, r := s, wo := wo'} = nonempty (initial_seg r s)
- ordinal.partial_order._match_11 α r {α := β, r := s, wo := wo'} = nonempty (principal_seg r s)
Equations
- ordinal.order_bot = {bot := 0, bot_le := ordinal.zero_le}
Equations
- ordinal.zero_le_one_class = {zero_le_one := ordinal.zero_le_one_class._proof_1}
Given two ordinals α ≤ β
, then initial_seg_out α β
is the initial segment embedding
of α
to β
, as map from a model type for α
to a model type for β
.
Equations
- ordinal.initial_seg_out h = id ((quotient.out α).cases_on (λ (α_1 : Type u_1) (r : α_1 → α_1 → Prop) (wo : is_well_order α_1 r), (quotient.out β).cases_on (λ (α_2 : Type u_1) (r_1 : α_2 → α_2 → Prop) (wo_1 : is_well_order α_2 r_1), classical.choice)) _)
Given two ordinals α < β
, then principal_seg_out α β
is the principal segment embedding
of α
to β
, as map from a model type for α
to a model type for β
.
Equations
- ordinal.principal_seg_out h = id ((quotient.out α).cases_on (λ (α_1 : Type u_1) (r : α_1 → α_1 → Prop) (wo : is_well_order α_1 r), (quotient.out β).cases_on (λ (α_2 : Type u_1) (r_1 : α_2 → α_2 → Prop) (wo_1 : is_well_order α_2 r_1), classical.choice)) _)
Enumerating elements in a well-order with ordinals. #
enum r o h
is the o
-th element of α
ordered by r
.
That is, enum
maps an initial segment of the ordinals, those
less than the order type of r
, to the elements of α
.
Equations
- ordinal.enum r o = quot.rec_on o (λ (_x : Well_order), ordinal.enum._match_1 r _x) _
- ordinal.enum._match_1 r {α := β, r := s, wo := _x} = λ (h : quot.mk setoid.r {α := β, r := s, wo := _x} < ordinal.type r), (classical.choice h).top
Equations
Principal segment version of the typein
function, embedding a well order into
ordinals as a principal segment.
Equations
- ordinal.typein.principal_seg r = {to_rel_embedding := rel_embedding.of_monotone (ordinal.typein r) _, top := ordinal.type r _inst_1, down' := _}
Cardinality of ordinals #
The cardinal of an ordinal is the cardinality of any type on which a relation with that order type is defined.
Equations
- ordinal.card = quotient.map Well_order.α ordinal.card._proof_1
Lifting ordinals to a higher universe #
The universe lift operation for ordinals, which embeds ordinal.{u}
as
a proper initial segment of ordinal.{v}
for v > u
. For the initial segment version,
see lift.initial_seg
.
Equations
- o.lift = quotient.lift_on o (λ (w : Well_order), ordinal.type (ulift.down ⁻¹'o w.r)) ordinal.lift._proof_2
lift.{(max u v) u}
equals lift.{v u}
. Using set_option pp.universes true
will make it much
easier to understand what's happening when using this lemma.
lift.{(max v u) u}
equals lift.{v u}
. Using set_option pp.universes true
will make it much
easier to understand what's happening when using this lemma.
An ordinal lifted to a lower or equal universe equals itself.
An ordinal lifted to the same universe equals itself.
An ordinal lifted to the zero universe equals itself.
Initial segment version of the lift operation on ordinals, embedding ordinal.{u}
in
ordinal.{v}
as an initial segment when u ≤ v
.
Equations
- ordinal.lift.initial_seg = {to_rel_embedding := {to_embedding := {to_fun := ordinal.lift, inj' := ordinal.lift.initial_seg._proof_1}, map_rel_iff' := ordinal.lift.initial_seg._proof_2}, init' := ordinal.lift.initial_seg._proof_3}
The first infinite ordinal omega
#
ω
is the first infinite ordinal, defined as the order type of ℕ
.
Equations
Note that the presence of this lemma makes simp [omega]
form a loop.
Definition and first properties of addition on ordinals #
In this paragraph, we introduce the addition on ordinals, and prove just enough properties to
deduce that the order on ordinals is total (and therefore well-founded). Further properties of
the addition, together with properties of the other operations, are proved in
ordinal_arithmetic.lean
.
o₁ + o₂
is the order on the disjoint union of o₁
and o₂
obtained by declaring that
every element of o₁
is smaller than every element of o₂
.
Equations
- ordinal.has_add = {add := λ (o₁ o₂ : ordinal), quotient.lift_on₂ o₁ o₂ (λ (_x : Well_order), ordinal.has_add._match_2 _x) ordinal.has_add._proof_1}
- ordinal.has_add._match_2 {α := α, r := r, wo := wo} = λ (_x : Well_order), ordinal.has_add._match_1 α r wo _x
- ordinal.has_add._match_1 α r wo {α := β, r := s, wo := wo'} = ordinal.type (sum.lex r s)
Equations
- ordinal.add_monoid_with_one = {nat_cast := nat.unary_cast (add_zero_class.to_has_add ordinal), add := has_add.add ordinal.has_add, add_assoc := ordinal.add_monoid_with_one._proof_8, zero := 0, zero_add := ordinal.add_monoid_with_one._proof_9, add_zero := ordinal.add_monoid_with_one._proof_10, nsmul := add_monoid.nsmul._default 0 has_add.add ordinal.add_monoid_with_one._proof_4 ordinal.add_monoid_with_one._proof_5, nsmul_zero' := ordinal.add_monoid_with_one._proof_11, nsmul_succ' := ordinal.add_monoid_with_one._proof_12, one := 1, nat_cast_zero := ordinal.add_monoid_with_one._proof_13, nat_cast_succ := ordinal.add_monoid_with_one._proof_14}
Equations
- ordinal.linear_order = {le := partial_order.le ordinal.partial_order, lt := partial_order.lt ordinal.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := ordinal.linear_order._proof_1, decidable_le := classical.dec_rel has_le.le, decidable_eq := decidable_eq_of_decidable_le (classical.dec_rel has_le.le), decidable_lt := decidable_lt_of_decidable_le (classical.dec_rel has_le.le), max := max_default (λ (a b : ordinal), classical.dec_rel has_le.le a b), max_def := ordinal.linear_order._proof_2, min := min_default (λ (a b : ordinal), classical.dec_rel has_le.le a b), min_def := ordinal.linear_order._proof_3}
Equations
- ordinal.succ_order = succ_order.of_succ_le_iff (λ (o : ordinal), o + 1) ordinal.succ_order._proof_1
Equations
- ordinal.unique_Iio_one = {to_inhabited := {default := ⟨0, _⟩}, uniq := ordinal.unique_Iio_one._proof_1}
Equations
- ordinal.unique_out_one = {to_inhabited := {default := ordinal.enum has_lt.lt 0 ordinal.unique_out_one._proof_2}, uniq := ordinal.unique_out_one._proof_3}
Extra properties of typein and enum #
A well order r
is order isomorphic to the set of ordinals smaller than type r
.
Equations
- ordinal.enum_iso r = {to_equiv := {to_fun := λ (x : ↥(λ (_x : ordinal), _x < ordinal.type r)), ordinal.enum r x.val _, inv_fun := λ (x : α), ⟨ordinal.typein r x, _⟩, left_inv := _, right_inv := _}, map_rel_iff' := _}
The order isomorphism between ordinals less than o
and o.out.α
.
Equations
- o.enum_iso_out = {to_equiv := {to_fun := λ (x : ↥(set.Iio o)), ordinal.enum has_lt.lt x.val _, inv_fun := λ (x : (quotient.out o).α), ⟨ordinal.typein has_lt.lt x, _⟩, left_inv := _, right_inv := _}, map_rel_iff' := _}
o.out.α
is an order_bot
whenever 0 < o
.
Equations
- ordinal.out_order_bot_of_pos ho = {bot := (λ (_x : Well_order), ordinal.enum._match_1 has_lt.lt _x) {α := pempty, r := empty_relation pempty, wo := _} _, bot_le := _}
Universal ordinal #
univ.{u v}
is the order type of the ordinals of Type u
as a member
of ordinal.{v}
(when u < v
). It is an inaccessible cardinal.
Equations
Principal segment version of the lift operation on ordinals, embedding ordinal.{u}
in
ordinal.{v}
as a principal segment when u < v
.
Equations
- ordinal.lift.principal_seg = {to_rel_embedding := ↑ordinal.lift.initial_seg, top := ordinal.univ, down' := ordinal.lift.principal_seg._proof_1}
Representing a cardinal with an ordinal #
The ordinal corresponding to a cardinal c
is the least ordinal
whose cardinal is c
. For the order-embedding version, see ord.order_embedding
.
Equations
- c.ord = let F : Type u → ordinal := λ (α : Type u), ⨅ (r : {r // is_well_order α r}), ordinal.type r.val in quot.lift_on c F cardinal.ord._proof_2
Galois coinsertion between cardinal.ord
and ordinal.card
.
Equations
- cardinal.gci_ord_card = cardinal.gc_ord_card.to_galois_coinsertion cardinal.gci_ord_card._proof_1
The ordinal corresponding to a cardinal c
is the least ordinal
whose cardinal is c
. This is the order-embedding version. For the regular function, see ord
.
Equations
- cardinal.ord.order_embedding = (rel_embedding.of_monotone cardinal.ord cardinal.ord.order_embedding._proof_1).order_embedding_of_lt_embedding
The cardinal univ
is the cardinality of ordinal univ
, or
equivalently the cardinal of ordinal.{u}
, or cardinal.{u}
,
as an element of cardinal.{v}
(when u < v
).