Ordinal arithmetic #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Ordinals have an addition (corresponding to disjoint union) that turns them into an additive monoid, and a multiplication (corresponding to the lexicographic order on the product) that turns them into a monoid. One can also define correspondingly a subtraction, a division, a successor function, a power function and a logarithm function.
We also define limit ordinals and prove the basic induction principle on ordinals separating
successor ordinals and limit ordinals, in limit_rec_on
.
Main definitions and results #
o₁ + o₂
is the order on the disjoint union ofo₁
ando₂
obtained by declaring that every element ofo₁
is smaller than every element ofo₂
.o₁ - o₂
is the unique ordinalo
such thato₂ + o = o₁
, wheno₂ ≤ o₁
.o₁ * o₂
is the lexicographic order ono₂ × o₁
.o₁ / o₂
is the ordinalo
such thato₁ = o₂ * o + o'
witho' < o₂
. We also define the divisibility predicate, and a modulo operation.order.succ o = o + 1
is the successor ofo
.pred o
if the predecessor ofo
. Ifo
is not a successor, we setpred o = o
.
We discuss the properties of casts of natural numbers of and of ω
with respect to these
operations.
Some properties of the operations are also used to discuss general tools on ordinals:
is_limit o
: an ordinal is a limit ordinal if it is neither0
nor a successor.limit_rec_on
is the main induction principle of ordinals: if one can prove a property by induction at successor ordinals and at limit ordinals, then it holds for all ordinals.is_normal
: a functionf : ordinal → ordinal
satisfiesis_normal
if it is strictly increasing and order-continuous, i.e., the imagef o
of a limit ordinalo
is the sup off a
fora < o
.enum_ord
: enumerates an unbounded set of ordinals by the ordinals themselves.sup
,lsub
: the supremum / least strict upper bound of an indexed family of ordinals inType u
, as an ordinal inType u
.bsup
,blsub
: the supremum / least strict upper bound of a set of ordinals indexed by ordinals less than a given ordinalo
.
Various other basic arithmetic results are given in principal.lean
instead.
Further properties of addition on ordinals #
The predecessor of an ordinal #
The ordinal predecessor of o
is o'
if o = succ o'
,
and o
otherwise.
Equations
- o.pred = dite (∃ (a : ordinal), o = order.succ a) (λ (h : ∃ (a : ordinal), o = order.succ a), classical.some h) (λ (h : ¬∃ (a : ordinal), o = order.succ a), o)
Limit ordinals #
Main induction principle of ordinals: if one can prove a property by induction at successor ordinals and at limit ordinals, then it holds for all ordinals.
Equations
- o.limit_rec_on H₁ H₂ H₃ = ordinal.lt_wf.fix (λ (o : ordinal) (IH : Π (y : ordinal), y < o → C y), dite (o = 0) (λ (o0 : o = 0), _.mpr H₁) (λ (o0 : ¬o = 0), dite (∃ (a : ordinal), o = order.succ a) (λ (h : ∃ (a : ordinal), o = order.succ a), _.mpr (H₂ o.pred (IH o.pred _))) (λ (h : ¬∃ (a : ordinal), o = order.succ a), H₃ o _ IH))) o
Equations
- o.order_top_out_succ = {top := (λ (f : subrel has_lt.lt {b : ordinal | b < (ordinal.typein.principal_seg has_lt.lt).top} ≃r has_lt.lt), ⇑f) (ordinal.typein.principal_seg has_lt.lt).subrel_iso ⟨o, _⟩, le_top := _}
Normal ordinal functions #
A normal ordinal function is a strictly increasing function which is
order-continuous, i.e., the image f o
of a limit ordinal o
is the sup of f a
for
a < o
.
Alias of ordinal.add_is_limit
.
Subtraction on ordinals #
a - b
is the unique ordinal satisfying b + (a - b) = a
when b ≤ a
.
Equations
- ordinal.has_sub = {sub := λ (a b : ordinal), has_Inf.Inf {o : ordinal | a ≤ b + o}}
Multiplication of ordinals #
The multiplication of ordinals o₁
and o₂
is the (well founded) lexicographic order on
o₂ × o₁
.
Equations
- ordinal.monoid = {mul := λ (a b : ordinal), quotient.lift_on₂ a b (λ (_x : Well_order), ordinal.monoid._match_2 _x) ordinal.monoid._proof_1, mul_assoc := ordinal.monoid._proof_2, one := 1, one_mul := ordinal.monoid._proof_3, mul_one := ordinal.monoid._proof_4, npow := npow_rec (mul_one_class.to_has_mul ordinal), npow_zero' := ordinal.monoid._proof_7, npow_succ' := ordinal.monoid._proof_8}
- ordinal.monoid._match_2 {α := α, r := r, wo := wo} = λ (_x : Well_order), ordinal.monoid._match_1 α r wo _x
- ordinal.monoid._match_1 α r wo {α := β, r := s, wo := wo'} = ⟦{α := β × α, r := prod.lex s r, wo := _}⟧
Equations
- ordinal.monoid_with_zero = {mul := monoid.mul ordinal.monoid, mul_assoc := _, one := monoid.one ordinal.monoid, one_mul := _, mul_one := _, npow := monoid.npow ordinal.monoid, npow_zero' := _, npow_succ' := _, zero := 0, zero_mul := ordinal.monoid_with_zero._proof_1, mul_zero := ordinal.monoid_with_zero._proof_2}
Equations
- ordinal.left_distrib_class = {left_distrib := ordinal.left_distrib_class._proof_1}
Division on ordinals #
The set in the definition of division is nonempty.
a / b
is the unique ordinal o
satisfying a = b * o + o'
with o' < b
.
Equations
- ordinal.has_div = {div := λ (a b : ordinal), dite (b = 0) (λ (h : b = 0), 0) (λ (h : ¬b = 0), has_Inf.Inf {o : ordinal | a < b * order.succ o})}
Families of ordinals #
There are two kinds of indexed families that naturally arise when dealing with ordinals: those indexed by some type in the appropriate universe, and those indexed by ordinals less than another. The following API allows one to convert from one kind of family to the other.
In many cases, this makes it easy to prove claims about one kind of family via the corresponding claim on the other.
Converts a family indexed by a Type u
to one indexed by an ordinal.{u}
using a specified
well-ordering.
Equations
- ordinal.bfamily_of_family' r f = λ (a : ordinal) (ha : a < ordinal.type r), f (ordinal.enum r a ha)
Converts a family indexed by a Type u
to one indexed by an ordinal.{u}
using a well-ordering
given by the axiom of choice.
Converts a family indexed by an ordinal.{u}
to one indexed by an Type u
using a specified
well-ordering.
Equations
- ordinal.family_of_bfamily' r ho f = λ (i : ι), f (ordinal.typein r i) _
Converts a family indexed by an ordinal.{u}
to one indexed by a Type u
using a well-ordering
given by the axiom of choice.
Equations
Supremum of a family of ordinals #
The supremum of a family of ordinals
Equations
- ordinal.sup f = supr f
The range of an indexed ordinal function, whose outputs live in a higher universe than the
inputs, is always bounded above. See ordinal.lsub
for an explicit bound.
The supremum of a family of ordinals indexed by the set of ordinals less than some
o : ordinal.{u}
. This is a special case of sup
over the family provided by
family_of_bfamily
.
Equations
- o.bsup f = ordinal.sup (o.family_of_bfamily f)
The least strict upper bound of a family of ordinals.
Equations
- ordinal.lsub f = ordinal.sup (order.succ ∘ f)
The least strict upper bound of a family of ordinals indexed by the set of ordinals less than
some o : ordinal.{u}
.
This is to lsub
as bsup
is to sup
.
A two-argument version of ordinal.blsub
.
We don't develop a full API for this, since it's only used in a handful of existence results.
Equations
- o₁.blsub₂ o₂ op = ordinal.lsub (λ (x : (quotient.out o₁).α × (quotient.out o₂).α), op (ordinal.typein has_lt.lt x.fst) _ (ordinal.typein has_lt.lt x.snd) _)
Minimum excluded ordinals #
The minimum excluded ordinal in a family of ordinals.
Equations
- ordinal.mex f = has_Inf.Inf (set.range f)ᶜ
The minimum excluded ordinal of a family of ordinals indexed by the set of ordinals less than
some o : ordinal.{u}
. This is a special case of mex
over the family provided by
family_of_bfamily
.
This is to mex
as bsup
is to sup
.
Equations
- o.bmex f = ordinal.mex (o.family_of_bfamily f)
Results about injectivity and surjectivity #
The type of ordinals in universe u
is not small.{u}
. This is the type-theoretic analog of
the Burali-Forti paradox.
Enumerating unbounded sets of ordinals with ordinals #
The equation that characterizes enum_ord
definitionally. This isn't the nicest expression to
work with, so consider using enum_ord_def
instead.
The set in enum_ord_def'
is nonempty.
A more workable definition for enum_ord
.
An order isomorphism between an unbounded set of ordinals and the ordinals.
Equations
- ordinal.enum_ord_order_iso hS = strict_mono.order_iso_of_surjective (λ (o : ordinal), ⟨ordinal.enum_ord S o, _⟩) _ _
A characterization of enum_ord
: it is the unique strict monotonic function with range S
.
Casting naturals into ordinals, compatibility with operations #
Properties of omega
#
The rank of an element a
accessible under a relation r
is defined inductively as the
smallest ordinal greater than the ranks of all elements below it (i.e. elements b
such that
r b a
).
The rank of an element a
under a well-founded relation r
is defined inductively as the
smallest ordinal greater than the ranks of all elements below it (i.e. elements b
such that
r b a
).