doc-next-gen

Mathlib.SetTheory.Ordinal.Basic

Module docstring

{"# Ordinals

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 order r, this is the corresponding ordinal
  • Ordinal.typein r a: given a well-founded order r on a type α, and a : α, the ordinal corresponding to all elements smaller than a.
  • enum r ⟨o, h⟩: given a well-order r on a type α, and an ordinal o strictly smaller than the ordinal corresponding to r (this is the assumption h), returns the o-th element of α. In other words, the elements of α can be enumerated using ordinals up to type r.
  • Ordinal.card o: the cardinality of an ordinal o.
  • Ordinal.lift lifts an ordinal in universe u to an ordinal in universe max u v. For a version registering additionally that this is an initial segment embedding, see Ordinal.liftInitialSeg. For a version registering that it is a principal segment embedding if u < v, see Ordinal.liftPrincipalSeg.
  • Ordinal.omega0 or ω is the order type of . It is called this to match Cardinal.aleph0 and so that the omega function can be named Ordinal.omega. This definition is universe polymorphic: Ordinal.omega0.{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 of o₁ and o₂ obtained by declaring that every element of o₁ is smaller than every element of o₂. The main properties of addition (and the other operations on ordinals) are stated and proved in Mathlib/SetTheory/Ordinal/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 ordinal o.
  • Cardinal.ord c: when c 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 locale Ordinal. ","### Definition of ordinals ","### Basic properties of the order type ","### The order on ordinals ","### Enumerating elements in a well-order with ordinals ","### Cardinality of ordinals ","### Lifting ordinals to a higher universe ","### The first infinite ordinal ω ","### 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 Mathlib/SetTheory/Ordinal/Arithmetic.lean. ","### Successor order properties ","### Extra properties of typein and enum ","### Universal ordinal ","### Representing a cardinal with an ordinal ","### Sorted lists "}

WellOrder structure
Full source
/-- Bundled structure registering a well order on a type. Ordinals will be defined as a quotient
of this type. -/
structure WellOrder : Type (u + 1) where
  /-- The underlying type of the order. -/
  α : Type u
  /-- The underlying relation of the order. -/
  r : α → α → Prop
  /-- The proposition that `r` is a well-ordering for `α`. -/
  wo : IsWellOrder α r
Well-ordered type
Informal description
The structure `WellOrder` represents a type equipped with a well-order relation. Ordinals are defined as equivalence classes of such structures under order isomorphism.
Ordinal.isEquivalent instance
: Setoid WellOrder
Full source
/-- Equivalence relation on well orders on arbitrary types in universe `u`, given by order
isomorphism. -/
instance Ordinal.isEquivalent : Setoid WellOrder where
  r := fun ⟨_, r, _⟩ ⟨_, s, _⟩ => Nonempty (r ≃r s)
  iseqv :=
    ⟨fun _ => ⟨RelIso.refl _⟩, fun ⟨e⟩ => ⟨e.symm⟩, fun ⟨e₁⟩ ⟨e₂⟩ => ⟨e₁.trans e₂⟩⟩
Order Isomorphism as Equivalence Relation on Well-Orders
Informal description
The equivalence relation on well-ordered types is defined by order isomorphism. Two well-ordered types are considered equivalent if there exists an order-preserving bijection between them.
Ordinal definition
: Type (u + 1)
Full source
/-- `Ordinal.{u}` is the type of well orders in `Type u`, up to order isomorphism. -/
@[pp_with_univ]
def Ordinal : Type (u + 1) :=
  Quotient Ordinal.isEquivalent
Ordinals as equivalence classes of well-ordered sets
Informal description
The type `Ordinal.{u}` represents the collection of all well-ordered sets in the universe `Type u`, considered up to order isomorphism. An ordinal is an equivalence class of well-ordered sets under the relation of order isomorphism, which means two well-ordered sets are equivalent if there exists a bijection between them that preserves the order.
Ordinal.toType definition
(o : Ordinal.{u}) : Type u
Full source
/-- A "canonical" type order-isomorphic to the ordinal `o`, living in the same universe. This is
defined through the axiom of choice.

Use this over `Iio o` only when it is paramount to have a `Type u` rather than a `Type (u + 1)`. -/
def Ordinal.toType (o : OrdinalOrdinal.{u}) : Type u :=
  o.out.α
Canonical type isomorphic to an ordinal
Informal description
For a given ordinal $o$, the function returns a canonical type that is order-isomorphic to $o$, living in the same universe. This construction relies on the axiom of choice to select a representative well-ordered set from the equivalence class corresponding to $o$.
hasWellFounded_toType instance
(o : Ordinal) : WellFoundedRelation o.toType
Full source
instance hasWellFounded_toType (o : Ordinal) : WellFoundedRelation o.toType :=
  ⟨o.out.r, o.out.wo.wf⟩
Well-foundedness of the Canonical Type Associated with an Ordinal
Informal description
For any ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) is equipped with a well-founded relation. This means that every nonempty subset of $o.\text{toType}$ has a minimal element with respect to the order relation on $o.\text{toType}$.
linearOrder_toType instance
(o : Ordinal) : LinearOrder o.toType
Full source
instance linearOrder_toType (o : Ordinal) : LinearOrder o.toType :=
  @IsWellOrder.linearOrder _ o.out.r o.out.wo
Linear Order Structure on the Canonical Type of an Ordinal
Informal description
For any ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) is equipped with a linear order structure. This linear order is derived from the well-order relation on $o.\text{toType}$.
wellFoundedLT_toType_lt instance
(o : Ordinal) : WellFoundedLT o.toType
Full source
instance wellFoundedLT_toType_lt (o : Ordinal) : WellFoundedLT o.toType :=
  o.out.wo.toIsWellFounded
Well-foundedness of the Order on Canonical Types of Ordinals
Informal description
For any ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) has a well-founded strict less-than relation. This means every non-empty subset of $o.\text{toType}$ has a minimal element with respect to the order relation on $o.\text{toType}$.
Ordinal.instSuccOrderToType instance
(o : Ordinal) : SuccOrder o.toType
Full source
noncomputable instance (o : Ordinal) : SuccOrder o.toType :=
  SuccOrder.ofLinearWellFoundedLT o.toType
Successor Order Structure on Canonical Types of Ordinals
Informal description
For any ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) is equipped with a successor order structure. This means there is a successor function `succ` on $o.\text{toType}$ such that for any non-maximal element $a$, $a < \text{succ } a$ holds, and $\text{succ } a$ is the least element greater than $a$.
Ordinal.type definition
(r : α → α → Prop) [wo : IsWellOrder α r] : Ordinal
Full source
/-- The order type of a well order is an ordinal. -/
def type (r : α → α → Prop) [wo : IsWellOrder α r] : Ordinal :=
  ⟦⟨α, r, wo⟩⟧
Order type of a well-ordered set
Informal description
Given a well-order relation \( r \) on a type \( \alpha \), the function `Ordinal.type` returns the ordinal number representing the order type of \( (\alpha, r) \). This ordinal is the equivalence class of \( (\alpha, r) \) under order isomorphism.
Ordinal.zero instance
: Zero Ordinal
Full source
instance zero : Zero Ordinal :=
  ⟨type <| @EmptyRelation PEmpty⟩
The Zero Ordinal
Informal description
The ordinal number $0$ is the smallest ordinal, representing the order type of the empty set.
Ordinal.inhabited instance
: Inhabited Ordinal
Full source
instance inhabited : Inhabited Ordinal :=
  ⟨0⟩
Ordinals are Inhabited
Informal description
The type of ordinals is inhabited.
Ordinal.one instance
: One Ordinal
Full source
instance one : One Ordinal :=
  ⟨type <| @EmptyRelation PUnit⟩
The Ordinal One
Informal description
The ordinal number $1$ is the order type of a singleton set with the trivial ordering.
Ordinal.type_toType theorem
(o : Ordinal) : typeLT o.toType = o
Full source
@[simp]
theorem type_toType (o : Ordinal) : typeLT o.toType = o :=
  o.out_eq
Canonical Type Preserves Order Type: $\text{type}(o.\text{toType}) = o$
Informal description
For any ordinal $o$, the order type of the canonical well-ordered type associated with $o$ (via `Ordinal.toType`) is equal to $o$ itself. In other words, if we take the well-order on $o.\text{toType}$ and compute its order type, we recover the original ordinal $o$.
Ordinal.type_eq theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] : type r = type s ↔ Nonempty (r ≃r s)
Full source
theorem type_eq {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] :
    typetype r = type s ↔ Nonempty (r ≃r s) :=
  Quotient.eq'
Order Type Equality Criterion: $\text{type}(r) = \text{type}(s) \leftrightarrow (α, r) \cong (β, s)$
Informal description
For any two well-ordered sets $(α, r)$ and $(β, s)$, the order types $\text{type}(r)$ and $\text{type}(s)$ are equal if and only if there exists an order isomorphism between $(α, r)$ and $(β, s)$. In other words, two well-orders have the same ordinal type precisely when they are order-isomorphic.
RelIso.ordinal_type_eq theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (h : r ≃r s) : type r = type s
Full source
theorem _root_.RelIso.ordinal_type_eq {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] (h : r ≃r s) : type r = type s :=
  type_eq.2 ⟨h⟩
Order Isomorphism Implies Equal Order Types
Informal description
Given two well-ordered sets $(α, r)$ and $(β, s)$, if there exists an order isomorphism $h$ between them (i.e., $h : (α, r) \cong (β, s)$), then their order types are equal: $\text{type}(r) = \text{type}(s)$.
Ordinal.type_eq_zero_of_empty theorem
(r) [IsWellOrder α r] [IsEmpty α] : type r = 0
Full source
theorem type_eq_zero_of_empty (r) [IsWellOrder α r] [IsEmpty α] : type r = 0 :=
  (RelIso.relIsoOfIsEmpty r _).ordinal_type_eq
Order Type of Empty Set is Zero
Informal description
For any well-order relation $r$ on an empty type $\alpha$, the order type of $(\alpha, r)$ is equal to the zero ordinal $0$.
Ordinal.type_eq_zero_iff_isEmpty theorem
[IsWellOrder α r] : type r = 0 ↔ IsEmpty α
Full source
@[simp]
theorem type_eq_zero_iff_isEmpty [IsWellOrder α r] : typetype r = 0 ↔ IsEmpty α :=
  ⟨fun h =>
    let ⟨s⟩ := type_eq.1 h
    s.toEquiv.isEmpty,
    @type_eq_zero_of_empty α r _⟩
Zero Order Type Characterization: $\text{type}(r) = 0 \leftrightarrow \alpha$ is empty
Informal description
For any well-order relation $r$ on a type $\alpha$, the order type of $(\alpha, r)$ is equal to the zero ordinal $0$ if and only if $\alpha$ is empty.
Ordinal.type_ne_zero_iff_nonempty theorem
[IsWellOrder α r] : type r ≠ 0 ↔ Nonempty α
Full source
theorem type_ne_zero_iff_nonempty [IsWellOrder α r] : typetype r ≠ 0type r ≠ 0 ↔ Nonempty α := by simp
Nonzero Order Type Characterizes Nonempty Sets
Informal description
For any well-order relation $r$ on a type $\alpha$, the order type of $(\alpha, r)$ is nonzero if and only if $\alpha$ is nonempty. In other words, $\text{type}(r) \neq 0$ if and only if there exists at least one element in $\alpha$.
Ordinal.type_pEmpty theorem
: type (@EmptyRelation PEmpty) = 0
Full source
theorem type_pEmpty : type (@EmptyRelation PEmpty) = 0 :=
  rfl
Order Type of Empty Relation on Empty Type is Zero
Informal description
The order type of the empty relation on the type `PEmpty` (the empty type) is equal to the zero ordinal, i.e., $\text{type}(\text{EmptyRelation}_{\text{PEmpty}}) = 0$.
Ordinal.type_empty theorem
: type (@EmptyRelation Empty) = 0
Full source
theorem type_empty : type (@EmptyRelation Empty) = 0 :=
  type_eq_zero_of_empty _
Order Type of Empty Relation on Empty Type is Zero
Informal description
The order type of the empty relation on the empty type `Empty` is equal to the zero ordinal, i.e., $\text{type}(\text{EmptyRelation}_{\text{Empty}}) = 0$.
Ordinal.type_eq_one_iff_unique theorem
[IsWellOrder α r] : type r = 1 ↔ Nonempty (Unique α)
Full source
@[simp]
theorem type_eq_one_iff_unique [IsWellOrder α r] : typetype r = 1 ↔ Nonempty (Unique α) :=
  ⟨fun h ↦ let ⟨s⟩ := type_eq.1 h; ⟨s.toEquiv.unique⟩,
    fun ⟨_⟩ ↦ type_eq_one_of_unique r⟩
Order Type Equals One if and only if Type is Singleton
Informal description
For any well-order relation $r$ on a type $\alpha$, the order type of $(\alpha, r)$ is equal to the ordinal $1$ if and only if $\alpha$ has exactly one element (i.e., there exists a unique element in $\alpha$).
Ordinal.type_pUnit theorem
: type (@EmptyRelation PUnit) = 1
Full source
theorem type_pUnit : type (@EmptyRelation PUnit) = 1 :=
  rfl
Order Type of PUnit is One
Informal description
The order type of the well-ordered set `PUnit` (the type with exactly one element) equipped with the empty relation is equal to the ordinal $1$.
Ordinal.type_unit theorem
: type (@EmptyRelation Unit) = 1
Full source
theorem type_unit : type (@EmptyRelation Unit) = 1 :=
  rfl
Order Type of Unit Type is One
Informal description
The order type of the unit type with the empty relation is equal to the ordinal $1$.
Ordinal.toType_nonempty_iff_ne_zero theorem
{o : Ordinal} : Nonempty o.toType ↔ o ≠ 0
Full source
@[simp]
theorem toType_nonempty_iff_ne_zero {o : Ordinal} : NonemptyNonempty o.toType ↔ o ≠ 0 := by
  rw [← @type_ne_zero_iff_nonempty o.toType (· < ·), type_toType]
Nonemptiness of Canonical Type for Nonzero Ordinals: $\text{Nonempty}(o.\text{toType}) \leftrightarrow o \neq 0$
Informal description
For any ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) is nonempty if and only if $o$ is not equal to the zero ordinal. In other words, $o.\text{toType}$ has at least one element precisely when $o \neq 0$.
Ordinal.inductionOn theorem
{C : Ordinal → Prop} (o : Ordinal) (H : ∀ (α r) [IsWellOrder α r], C (type r)) : C o
Full source
/-- `Quotient.inductionOn` specialized to ordinals.

Not to be confused with well-founded recursion `Ordinal.induction`. -/
@[elab_as_elim]
theorem inductionOn {C : Ordinal → Prop} (o : Ordinal)
    (H : ∀ (α r) [IsWellOrder α r], C (type r)) : C o :=
  Quot.inductionOn o fun ⟨α, r, wo⟩ => @H α r wo
Ordinal Induction Principle
Informal description
For any property \( C \) of ordinals and any ordinal \( o \), to prove that \( C(o) \) holds, it suffices to show that for every well-ordered type \( \alpha \) with a well-order relation \( r \), the property \( C(\text{type } r) \) holds, where \(\text{type } r\) denotes the ordinal corresponding to the well-order \( r \) on \( \alpha \).
Ordinal.inductionOn₂ theorem
{C : Ordinal → Ordinal → Prop} (o₁ o₂ : Ordinal) (H : ∀ (α r) [IsWellOrder α r] (β s) [IsWellOrder β s], C (type r) (type s)) : C o₁ o₂
Full source
/-- `Quotient.inductionOn₂` specialized to ordinals.

Not to be confused with well-founded recursion `Ordinal.induction`. -/
@[elab_as_elim]
theorem inductionOn₂ {C : OrdinalOrdinal → Prop} (o₁ o₂ : Ordinal)
    (H : ∀ (α r) [IsWellOrder α r] (β s) [IsWellOrder β s], C (type r) (type s)) : C o₁ o₂ :=
  Quotient.inductionOn₂ o₁ o₂ fun ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ => @H α r wo₁ β s wo₂
Double Ordinal Induction Principle
Informal description
For any property $C$ of pairs of ordinals and any two ordinals $o_1$ and $o_2$, to prove $C(o_1, o_2)$ holds, it suffices to show that for any two well-ordered types $\alpha$ and $\beta$ with well-order relations $r$ and $s$ respectively, the property $C(\text{type } r, \text{type } s)$ holds. Here, $\text{type } r$ denotes the ordinal corresponding to the well-order $r$ on $\alpha$, and similarly for $\text{type } s$.
Ordinal.inductionOn₃ theorem
{C : Ordinal → Ordinal → Ordinal → Prop} (o₁ o₂ o₃ : Ordinal) (H : ∀ (α r) [IsWellOrder α r] (β s) [IsWellOrder β s] (γ t) [IsWellOrder γ t], C (type r) (type s) (type t)) : C o₁ o₂ o₃
Full source
/-- `Quotient.inductionOn₃` specialized to ordinals.

Not to be confused with well-founded recursion `Ordinal.induction`. -/
@[elab_as_elim]
theorem inductionOn₃ {C : OrdinalOrdinalOrdinal → Prop} (o₁ o₂ o₃ : Ordinal)
    (H : ∀ (α r) [IsWellOrder α r] (β s) [IsWellOrder β s] (γ t) [IsWellOrder γ t],
      C (type r) (type s) (type t)) : C o₁ o₂ o₃ :=
  Quotient.inductionOn₃ o₁ o₂ o₃ fun ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨γ, t, wo₃⟩ =>
    @H α r wo₁ β s wo₂ γ t wo₃
Triple Ordinal Induction Principle
Informal description
For any property \( C \) of triples of ordinals and any three ordinals \( o_1, o_2, o_3 \), to prove \( C(o_1, o_2, o_3) \) holds, it suffices to show that for any three well-ordered types \( \alpha, \beta, \gamma \) with well-order relations \( r, s, t \) respectively, the property \( C(\text{type } r, \text{type } s, \text{type } t) \) holds. Here, \(\text{type } r\) denotes the ordinal corresponding to the well-order \( r \) on \( \alpha \), and similarly for \(\text{type } s\) and \(\text{type } t\).
Ordinal.inductionOnWellOrder theorem
{C : Ordinal → Prop} (o : Ordinal) (H : ∀ (α) [LinearOrder α] [WellFoundedLT α], C (typeLT α)) : C o
Full source
/-- To prove a result on ordinals, it suffices to prove it for order types of well-orders. -/
@[elab_as_elim]
theorem inductionOnWellOrder {C : Ordinal → Prop} (o : Ordinal)
    (H : ∀ (α) [LinearOrder α] [WellFoundedLT α], C (typeLT α)) : C o :=
  inductionOn o fun α r wo ↦ @H α (linearOrderOfSTO r) wo.toIsWellFounded
Well-Order Induction Principle for Ordinals via Linear Orders
Informal description
To prove a property \( C \) holds for an ordinal \( o \), it suffices to prove that \( C(\text{typeLT } \alpha) \) holds for every linearly ordered type \( \alpha \) with a well-founded strict less-than relation \( < \), where \( \text{typeLT } \alpha \) denotes the ordinal corresponding to the well-order \( < \) on \( \alpha \).
Ordinal.liftOnWellOrder definition
{δ : Sort v} (o : Ordinal) (f : ∀ (α) [LinearOrder α] [WellFoundedLT α], δ) (c : ∀ (α) [LinearOrder α] [WellFoundedLT α] (β) [LinearOrder β] [WellFoundedLT β], typeLT α = typeLT β → f α = f β) : δ
Full source
/-- To define a function on ordinals, it suffices to define them on order types of well-orders.

Since `LinearOrder` is data-carrying, `liftOnWellOrder_type` is not a definitional equality, unlike
`Quotient.liftOn_mk` which is always def-eq. -/
def liftOnWellOrder {δ : Sort v} (o : Ordinal) (f : ∀ (α) [LinearOrder α] [WellFoundedLT α], δ)
    (c : ∀ (α) [LinearOrder α] [WellFoundedLT α] (β) [LinearOrder β] [WellFoundedLT β],
      typeLT α = typeLT β → f α = f β) : δ :=
  Quotient.liftOn o (fun w ↦ @f w.α (linearOrderOfSTO w.r) w.wo.toIsWellFounded)
    fun w₁ w₂ h ↦ @c
      w₁.α (linearOrderOfSTO w₁.r) w₁.wo.toIsWellFounded
      w₂.α (linearOrderOfSTO w₂.r) w₂.wo.toIsWellFounded
      (Quotient.sound h)
Definition by Well-Ordered Representatives for Ordinals
Informal description
Given an ordinal \( o \), a type \( \delta \), and a function \( f \) that takes any linearly ordered type \( \alpha \) with a well-founded strict order and produces an element of \( \delta \), the function `Ordinal.liftOnWellOrder` applies \( f \) to a representative of \( o \). The function \( f \) must satisfy the condition that if two well-ordered types \( \alpha \) and \( \beta \) have the same order type, then \( f \) produces the same result for both. This construction allows defining functions on ordinals by specifying their behavior on well-ordered types.
Ordinal.liftOnWellOrder_type theorem
{δ : Sort v} (f : ∀ (α) [LinearOrder α] [WellFoundedLT α], δ) (c : ∀ (α) [LinearOrder α] [WellFoundedLT α] (β) [LinearOrder β] [WellFoundedLT β], typeLT α = typeLT β → f α = f β) {γ} [LinearOrder γ] [WellFoundedLT γ] : liftOnWellOrder (typeLT γ) f c = f γ
Full source
@[simp]
theorem liftOnWellOrder_type {δ : Sort v} (f : ∀ (α) [LinearOrder α] [WellFoundedLT α], δ)
    (c : ∀ (α) [LinearOrder α] [WellFoundedLT α] (β) [LinearOrder β] [WellFoundedLT β],
      typeLT α = typeLT β → f α = f β) {γ} [LinearOrder γ] [WellFoundedLT γ] :
    liftOnWellOrder (typeLT γ) f c = f γ := by
  change Quotient.liftOn' ⟦_⟧ _ _ = _
  rw [Quotient.liftOn'_mk]
  congr
  exact LinearOrder.ext_lt fun _ _ ↦ Iff.rfl
Lifting Function on Well-Orders Preserves Application to Order Types
Informal description
Let $\delta$ be a type, and let $f$ be a function that takes any linearly ordered type $\alpha$ with a well-founded strict order and produces an element of $\delta$. Suppose $f$ satisfies the condition that for any two such types $\alpha$ and $\beta$, if their order types are equal (i.e., $\text{typeLT } \alpha = \text{typeLT } \beta$), then $f(\alpha) = f(\beta)$. Then, for any linearly ordered type $\gamma$ with a well-founded strict order, applying the lifted function $\text{liftOnWellOrder}$ to the order type of $\gamma$ (i.e., $\text{typeLT } \gamma$) yields the same result as directly applying $f$ to $\gamma$. In other words, $\text{liftOnWellOrder } (\text{typeLT } \gamma) f c = f \gamma$.
Ordinal.partialOrder instance
: PartialOrder Ordinal
Full source
/--
For `Ordinal`:

* less-equal is defined such that well orders `r` and `s` satisfy `type r ≤ type s` if there exists
  a function embedding `r` as an *initial* segment of `s`.
* less-than is defined such that well orders `r` and `s` satisfy `type r < type s` if there exists
  a function embedding `r` as a *principal* segment of `s`.

Note that most of the relevant results on initial and principal segments are proved in the
`Order.InitialSeg` file.
-/
instance partialOrder : PartialOrder Ordinal where
  le a b :=
    Quotient.liftOn₂ a b (fun ⟨_, r, _⟩ ⟨_, s, _⟩ => Nonempty (r ≼i s))
      fun _ _ _ _ ⟨f⟩ ⟨g⟩ => propext
        ⟨fun ⟨h⟩ => ⟨f.symm.toInitialSeg.trans <| h.trans g.toInitialSeg⟩, fun ⟨h⟩ =>
          ⟨f.toInitialSeg.trans <| h.trans g.symm.toInitialSeg⟩⟩
  lt a b :=
    Quotient.liftOn₂ a b (fun ⟨_, r, _⟩ ⟨_, s, _⟩ => Nonempty (r ≺i s))
      fun _ _ _ _ ⟨f⟩ ⟨g⟩ => propext
        ⟨fun ⟨h⟩ => ⟨PrincipalSeg.relIsoTrans f.symm <| h.transRelIso g⟩,
          fun ⟨h⟩ => ⟨PrincipalSeg.relIsoTrans f <| h.transRelIso g.symm⟩⟩
  le_refl := Quot.ind fun ⟨_, _, _⟩ => ⟨InitialSeg.refl _⟩
  le_trans a b c :=
    Quotient.inductionOn₃ a b c fun _ _ _ ⟨f⟩ ⟨g⟩ => ⟨f.trans g⟩
  lt_iff_le_not_le a b :=
    Quotient.inductionOn₂ a b fun _ _ =>
      ⟨fun ⟨f⟩ => ⟨⟨f⟩, fun ⟨g⟩ => (f.transInitial g).irrefl⟩, fun ⟨⟨f⟩, h⟩ =>
        f.principalSumRelIso.recOn (fun g => ⟨g⟩) fun g => (h ⟨g.symm.toInitialSeg⟩).elim⟩
  le_antisymm a b :=
    Quotient.inductionOn₂ a b fun _ _ ⟨h₁⟩ ⟨h₂⟩ =>
      Quot.sound ⟨InitialSeg.antisymm h₁ h₂⟩
Partial Order on Ordinals via Initial Segment Embeddings
Informal description
The type of ordinals `Ordinal` is equipped with a partial order structure where for two ordinals `α` and `β`, we have `α ≤ β` if and only if there exists an initial segment embedding from a well-order representing `α` to a well-order representing `β`.
Ordinal.instLinearOrder instance
: LinearOrder Ordinal
Full source
instance : LinearOrder Ordinal :=
  {inferInstanceAs (PartialOrder Ordinal) with
    le_total := fun a b => Quotient.inductionOn₂ a b fun ⟨_, r, _⟩ ⟨_, s, _⟩ =>
      (InitialSeg.total r s).recOn (fun f => Or.inl ⟨f⟩) fun f => Or.inr ⟨f⟩
    toDecidableLE := Classical.decRel _ }
Linear Order on Ordinals
Informal description
The type of ordinals `Ordinal` is equipped with a linear order structure, where for any two ordinals `α` and `β`, either `α ≤ β` or `β ≤ α` holds. This linear order extends the partial order defined by initial segment embeddings between well-ordered sets representing the ordinals.
InitialSeg.ordinal_type_le theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (h : r ≼i s) : type r ≤ type s
Full source
theorem _root_.InitialSeg.ordinal_type_le {α β} {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (h : r ≼i s) : type r ≤ type s :=
  ⟨h⟩
Initial Segment Embedding Implies Inequality of Order Types
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively. If there exists an initial segment embedding from $r$ to $s$, then the order type of $r$ is less than or equal to the order type of $s$, i.e., $\text{type}(r) \leq \text{type}(s)$.
RelEmbedding.ordinal_type_le theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (h : r ↪r s) : type r ≤ type s
Full source
theorem _root_.RelEmbedding.ordinal_type_le {α β} {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (h : r ↪r s) : type r ≤ type s :=
  ⟨h.collapse⟩
Relation Embedding Implies Inequality of Order Types
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively. If there exists a relation embedding from $r$ to $s$, then the order type of $r$ is less than or equal to the order type of $s$, i.e., $\text{type}(r) \leq \text{type}(s)$.
PrincipalSeg.ordinal_type_lt theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (h : r ≺i s) : type r < type s
Full source
theorem _root_.PrincipalSeg.ordinal_type_lt {α β} {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (h : r ≺i s) : type r < type s :=
  ⟨h⟩
Principal Segment Embedding Implies Strict Inequality of Order Types
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively. If there exists a principal segment embedding from $r$ to $s$, then the order type of $r$ is strictly less than the order type of $s$, i.e., $\text{type}(r) < \text{type}(s)$.
Ordinal.zero_le theorem
(o : Ordinal) : 0 ≤ o
Full source
@[simp]
protected theorem zero_le (o : Ordinal) : 0 ≤ o :=
  inductionOn o fun _ r _ => (InitialSeg.ofIsEmpty _ r).ordinal_type_le
Zero is the smallest ordinal
Informal description
For any ordinal $o$, the zero ordinal $0$ is less than or equal to $o$.
Ordinal.instOrderBot instance
: OrderBot Ordinal
Full source
instance : OrderBot Ordinal where
  bot := 0
  bot_le := Ordinal.zero_le
Zero is the Least Ordinal
Informal description
The type of ordinals `Ordinal` is equipped with an order structure where the zero ordinal $0$ is the least element. That is, for any ordinal $o$, we have $0 \leq o$.
Ordinal.bot_eq_zero theorem
: (⊥ : Ordinal) = 0
Full source
@[simp]
theorem bot_eq_zero : ( : Ordinal) = 0 :=
  rfl
Bottom Element is Zero Ordinal
Informal description
The bottom element of the order on ordinals is equal to the zero ordinal, i.e., $\bot = 0$.
Ordinal.instIsEmptyIioZero instance
: IsEmpty (Iio (0 : Ordinal))
Full source
instance instIsEmptyIioZero : IsEmpty (Iio (0 : Ordinal)) := by
  simp [← bot_eq_zero]
No Ordinals Below Zero
Informal description
The set of ordinals strictly less than $0$ is empty.
Ordinal.le_zero theorem
{o : Ordinal} : o ≤ 0 ↔ o = 0
Full source
@[simp]
protected theorem le_zero {o : Ordinal} : o ≤ 0 ↔ o = 0 :=
  le_bot_iff
Characterization of Zero Ordinal: $o \leq 0 \leftrightarrow o = 0$
Informal description
For any ordinal $o$, the inequality $o \leq 0$ holds if and only if $o = 0$.
Ordinal.pos_iff_ne_zero theorem
{o : Ordinal} : 0 < o ↔ o ≠ 0
Full source
protected theorem pos_iff_ne_zero {o : Ordinal} : 0 < o ↔ o ≠ 0 :=
  bot_lt_iff_ne_bot
Positivity of an Ordinal is Equivalent to Non-Zero
Informal description
For any ordinal $o$, the ordinal $0$ is strictly less than $o$ if and only if $o$ is not equal to $0$, i.e., $0 < o \leftrightarrow o \neq 0$.
Ordinal.not_lt_zero theorem
(o : Ordinal) : ¬o < 0
Full source
protected theorem not_lt_zero (o : Ordinal) : ¬o < 0 :=
  not_lt_bot
No Ordinal is Less Than Zero: $\neg (o < 0)$
Informal description
For any ordinal $o$, it is not the case that $o$ is strictly less than the zero ordinal $0$.
Ordinal.instZeroLEOneClass instance
: ZeroLEOneClass Ordinal
Full source
instance : ZeroLEOneClass Ordinal :=
  ⟨Ordinal.zero_le _⟩
Zero is Less Than or Equal to One in Ordinals
Informal description
The type of ordinals `Ordinal` satisfies the property that $0 \leq 1$, where $0$ is the smallest ordinal (representing the empty order) and $1$ is the ordinal representing the order type of a singleton set.
Ordinal.type_le_iff theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] : type r ≤ type s ↔ Nonempty (r ≼i s)
Full source
theorem type_le_iff {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] : typetype r ≤ type s ↔ Nonempty (r ≼i s) :=
  Iff.rfl
Order Type Comparison via Initial Segment Embeddings
Informal description
Let $\alpha$ and $\beta$ be types with well-order relations $r$ and $s$ respectively. The order type of $r$ is less than or equal to the order type of $s$ if and only if there exists an initial segment embedding from $r$ to $s$.
Ordinal.type_le_iff' theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] : type r ≤ type s ↔ Nonempty (r ↪r s)
Full source
theorem type_le_iff' {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] : typetype r ≤ type s ↔ Nonempty (r ↪r s) :=
  ⟨fun ⟨f⟩ => ⟨f⟩, fun ⟨f⟩ => ⟨f.collapse⟩⟩
Order Type Comparison via Order Embeddings
Informal description
For any two well-ordered sets $(α, r)$ and $(β, s)$, the order type of $r$ is less than or equal to the order type of $s$ if and only if there exists an order embedding from $(α, r)$ into $(β, s)$.
Ordinal.type_lt_iff theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] : type r < type s ↔ Nonempty (r ≺i s)
Full source
theorem type_lt_iff {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] : typetype r < type s ↔ Nonempty (r ≺i s) :=
  Iff.rfl
Order Type Strict Comparison via Principal Segment Embeddings
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively. The order type of $r$ is strictly less than the order type of $s$ if and only if there exists a principal segment embedding from $r$ to $s$.
Ordinal.initialSegToType definition
{α β : Ordinal} (h : α ≤ β) : α.toType ≤i β.toType
Full source
/-- Given two ordinals `α ≤ β`, then `initialSegToType α β` is the initial segment embedding of
`α.toType` into `β.toType`. -/
def initialSegToType {α β : Ordinal} (h : α ≤ β) : α.toType ≤i β.toType := by
  apply Classical.choice (type_le_iff.mp _)
  rwa [type_toType, type_toType]
Initial segment embedding between canonical types of ordinals
Informal description
Given two ordinals $\alpha \leq \beta$, the function $\text{initialSegToType}$ provides an initial segment embedding from the canonical type associated with $\alpha$ (denoted $\alpha.\text{toType}$) to the canonical type associated with $\beta$ (denoted $\beta.\text{toType}$). More precisely, this means there exists an order-preserving embedding $f : \alpha.\text{toType} \hookrightarrow \beta.\text{toType}$ where the image of $f$ forms a lower set in $\beta.\text{toType}$ (i.e., for any $x \in \alpha.\text{toType}$ and $y \in \beta.\text{toType}$, if $y < f(x)$ then $y$ is in the image of $f$).
Ordinal.principalSegToType definition
{α β : Ordinal} (h : α < β) : α.toType <i β.toType
Full source
/-- Given two ordinals `α < β`, then `principalSegToType α β` is the principal segment embedding
of `α.toType` into `β.toType`. -/
def principalSegToType {α β : Ordinal} (h : α < β) : α.toType <i β.toType := by
  apply Classical.choice (type_lt_iff.mp _)
  rwa [type_toType, type_toType]
Principal segment embedding between canonical types of ordinals
Informal description
Given two ordinals $\alpha < \beta$, the function $\text{principalSegToType}$ constructs a principal segment embedding from the canonical type associated with $\alpha$ (denoted $\alpha.\text{toType}$) to the canonical type associated with $\beta$ (denoted $\beta.\text{toType}$). More precisely, this means there exists an order-preserving embedding $f : \alpha.\text{toType} \hookrightarrow \beta.\text{toType}$ whose range is exactly the set of all elements strictly below some fixed element in $\beta.\text{toType}$ (i.e., the range is an initial segment of $\beta.\text{toType}$).
Ordinal.typein definition
(r : α → α → Prop) [IsWellOrder α r] : @PrincipalSeg α Ordinal.{u} r (· < ·)
Full source
/-- The order type of an element inside a well order.

This is registered as a principal segment embedding into the ordinals, with top `type r`. -/
def typein (r : α → α → Prop) [IsWellOrder α r] : @PrincipalSeg α OrdinalOrdinal.{u} r (· < ·) := by
  refine ⟨RelEmbedding.ofMonotone _ fun a b ha ↦
    ((PrincipalSeg.ofElement r a).codRestrict _ ?_ ?_).ordinal_type_lt, type r, fun a ↦ ⟨?_, ?_⟩⟩
  · rintro ⟨c, hc⟩
    exact trans hc ha
  · exact ha
  · rintro ⟨b, rfl⟩
    exact (PrincipalSeg.ofElement _ _).ordinal_type_lt
  · refine inductionOn a ?_
    rintro β s wo ⟨g⟩
    exact ⟨_, g.subrelIso.ordinal_type_eq⟩
Order type of an initial segment in a well-order
Informal description
Given a well-order relation \( r \) on a type \( \alpha \), the function `Ordinal.typein` constructs a principal segment embedding from \( (\alpha, r) \) to the ordinals under the standard order \( < \). More precisely, for each element \( a \in \alpha \), `typein r a` represents the ordinal corresponding to the initial segment of \( \alpha \) consisting of all elements \( b \) such that \( r(b, a) \). The top element of this principal segment is the ordinal `type r`, which represents the order type of the entire well-order \( r \).
Ordinal.type_subrel theorem
(r : α → α → Prop) [IsWellOrder α r] (a : α) : type (Subrel r (r · a)) = typein r a
Full source
@[simp]
theorem type_subrel (r : α → α → Prop) [IsWellOrder α r] (a : α) :
    type (Subrel r (r · a)) = typein r a :=
  rfl
Order Type of Initial Segment Equals `typein` Value
Informal description
Given a well-order relation $r$ on a type $\alpha$ and an element $a \in \alpha$, the order type of the initial segment $\{b \in \alpha \mid r(b, a)\}$ (with the restricted relation $r$) is equal to the ordinal `typein r a`, which represents the order type of this initial segment within the well-order $r$.
Ordinal.top_typein theorem
(r : α → α → Prop) [IsWellOrder α r] : (typein r).top = type r
Full source
@[simp]
theorem top_typein (r : α → α → Prop) [IsWellOrder α r] : (typein r).top = type r :=
  rfl
Top Element of Initial Segment Embedding Equals Order Type
Informal description
Given a well-order relation $r$ on a type $\alpha$, the top element of the principal segment embedding `typein r` is equal to the order type of $r$, i.e., $(\text{typein}\ r).\text{top} = \text{type}\ r$.
Ordinal.typein_lt_type theorem
(r : α → α → Prop) [IsWellOrder α r] (a : α) : typein r a < type r
Full source
theorem typein_lt_type (r : α → α → Prop) [IsWellOrder α r] (a : α) : typein r a < type r :=
  (typein r).lt_top a
Initial Segment Order Type is Less Than Full Order Type
Informal description
Given a well-order relation $r$ on a type $\alpha$ and an element $a \in \alpha$, the ordinal `typein r a` representing the order type of the initial segment $\{b \in \alpha \mid r(b, a)\}$ is strictly less than the ordinal `type r` representing the order type of the entire well-order $r$.
Ordinal.typein_lt_self theorem
{o : Ordinal} (i : o.toType) : typein (α := o.toType) (· < ·) i < o
Full source
theorem typein_lt_self {o : Ordinal} (i : o.toType) : typein (α := o.toType) (· < ·) i < o := by
  simp_rw [← type_toType o]
  apply typein_lt_type
Initial Segment Ordinal is Less Than the Original Ordinal
Informal description
For any ordinal $o$ and any element $i$ in the canonical type associated with $o$, the ordinal corresponding to the initial segment of $o.\text{toType}$ below $i$ is strictly less than $o$ itself.
Ordinal.typein_top theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≺i s) : typein s f.top = type r
Full source
@[simp]
theorem typein_top {α β} {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (f : r ≺i s) : typein s f.top = type r :=
  f.subrelIso.ordinal_type_eq
Principal Segment Top Element Yields Original Order Type
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively, and let $f : r \prec_i s$ be a principal segment embedding. Then the ordinal corresponding to the initial segment of $\beta$ below $f.\text{top}$ (i.e., $\mathrm{typein}\, s\, f.\text{top}$) equals the ordinal corresponding to the entire well-order $r$ (i.e., $\mathrm{type}\, r$).
Ordinal.typein_lt_typein theorem
(r : α → α → Prop) [IsWellOrder α r] {a b : α} : typein r a < typein r b ↔ r a b
Full source
@[simp]
theorem typein_lt_typein (r : α → α → Prop) [IsWellOrder α r] {a b : α} :
    typeintypein r a < typein r b ↔ r a b :=
  (typein r).map_rel_iff
Comparison of Initial Segment Ordinals via Well-Order Relation
Informal description
Let $\alpha$ be a type equipped with a well-order relation $r$, and let $a, b \in \alpha$. The ordinal $\mathrm{typein}\, r\, a$ is strictly less than $\mathrm{typein}\, r\, b$ if and only if $r(a, b)$ holds.
Ordinal.typein_le_typein theorem
(r : α → α → Prop) [IsWellOrder α r] {a b : α} : typein r a ≤ typein r b ↔ ¬r b a
Full source
@[simp]
theorem typein_le_typein (r : α → α → Prop) [IsWellOrder α r] {a b : α} :
    typeintypein r a ≤ typein r b ↔ ¬r b a := by
  rw [← not_lt, typein_lt_typein]
Comparison of Initial Segment Ordinals via Non-Strict Inequality in Well-Order Relation
Informal description
Let $\alpha$ be a type equipped with a well-order relation $r$, and let $a, b \in \alpha$. The ordinal $\mathrm{typein}\, r\, a$ is less than or equal to $\mathrm{typein}\, r\, b$ if and only if $b$ does not precede $a$ in the order $r$, i.e., $\neg r(b, a)$.
Ordinal.typein_injective theorem
(r : α → α → Prop) [IsWellOrder α r] : Injective (typein r)
Full source
theorem typein_injective (r : α → α → Prop) [IsWellOrder α r] : Injective (typein r) :=
  (typein r).injective
Injectivity of the Initial Segment Ordinal Mapping
Informal description
For any well-order relation $r$ on a type $\alpha$, the function $\mathrm{typein}\, r : \alpha \to \mathrm{Ordinal}$ that maps each element $a \in \alpha$ to the ordinal corresponding to the initial segment $\{b \in \alpha \mid r(b, a)\}$ is injective. In other words, if $\mathrm{typein}\, r\, a = \mathrm{typein}\, r\, b$ for $a, b \in \alpha$, then $a = b$.
Ordinal.typein_inj theorem
(r : α → α → Prop) [IsWellOrder α r] {a b} : typein r a = typein r b ↔ a = b
Full source
theorem typein_inj (r : α → α → Prop) [IsWellOrder α r] {a b} : typeintypein r a = typein r b ↔ a = b :=
  (typein_injective r).eq_iff
Injectivity of Initial Segment Ordinals: $\mathrm{typein}\, r\, a = \mathrm{typein}\, r\, b \leftrightarrow a = b$
Informal description
For any well-order relation $r$ on a type $\alpha$ and any elements $a, b \in \alpha$, the ordinal corresponding to the initial segment determined by $a$ is equal to the ordinal corresponding to the initial segment determined by $b$ if and only if $a = b$. In other words, the function $\mathrm{typein}\, r$ is injective.
Ordinal.mem_range_typein_iff theorem
(r : α → α → Prop) [IsWellOrder α r] {o} : o ∈ Set.range (typein r) ↔ o < type r
Full source
theorem mem_range_typein_iff (r : α → α → Prop) [IsWellOrder α r] {o} :
    o ∈ Set.range (typein r)o ∈ Set.range (typein r) ↔ o < type r :=
  (typein r).mem_range_iff_rel
Characterization of ordinals in the range of $\mathrm{typein}\, r$ as those less than $\mathrm{type}\, r$
Informal description
For any well-order relation $r$ on a type $\alpha$ and any ordinal $o$, the ordinal $o$ belongs to the range of the function $\mathrm{typein}\, r$ if and only if $o$ is strictly less than the order type of $r$ (i.e., $o < \mathrm{type}\, r$).
Ordinal.typein_surj theorem
(r : α → α → Prop) [IsWellOrder α r] {o} (h : o < type r) : o ∈ Set.range (typein r)
Full source
theorem typein_surj (r : α → α → Prop) [IsWellOrder α r] {o} (h : o < type r) :
    o ∈ Set.range (typein r) :=
  (typein r).mem_range_of_rel_top h
Surjectivity of Initial Segment Ordinals Below Order Type
Informal description
For any well-order relation $r$ on a type $\alpha$ and any ordinal $o$ strictly less than the order type of $r$ (i.e., $o < \mathrm{type}\, r$), there exists an element $a \in \alpha$ such that the ordinal corresponding to the initial segment of $\alpha$ determined by $a$ equals $o$. In other words, the function $\mathrm{typein}\, r$ is surjective onto the set of ordinals less than $\mathrm{type}\, r$.
Ordinal.typein_surjOn theorem
(r : α → α → Prop) [IsWellOrder α r] : Set.SurjOn (typein r) Set.univ (Set.Iio (type r))
Full source
theorem typein_surjOn (r : α → α → Prop) [IsWellOrder α r] :
    Set.SurjOn (typein r) Set.univ (Set.Iio (type r)) :=
  (typein r).surjOn
Surjectivity of Initial Segment Ordinals Below Order Type
Informal description
For any well-order relation \( r \) on a type \( \alpha \), the function \(\mathrm{typein}\, r\) mapping elements of \( \alpha \) to their corresponding initial segment ordinals is surjective from the universal set of \( \alpha \) onto the set of all ordinals strictly less than the order type of \( r \). In other words, every ordinal \( o \) with \( o < \mathrm{type}\, r \) is equal to \(\mathrm{typein}\, r(a)\) for some element \( a \in \alpha \).
Ordinal.enum definition
(r : α → α → Prop) [IsWellOrder α r] : (· < · : Iio (type r) → Iio (type r) → Prop) ≃r r
Full source
/-- A well order `r` is order-isomorphic to the set of ordinals smaller than `type r`.
`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 `α`. -/
@[simps! symm_apply_coe]
def enum (r : α → α → Prop) [IsWellOrder α r] : (· < · : Iio (type r) → Iio (type r) → Prop) ≃r r :=
  (typein r).subrelIso
Enumeration of a well-ordered set by ordinals
Informal description
Given a well-order relation \( r \) on a type \( \alpha \), the function `Ordinal.enum` provides an order isomorphism between the ordinals less than the order type of \( r \) (ordered by the standard order \( < \)) and the elements of \( \alpha \) (ordered by \( r \)). More precisely, for each ordinal \( o \) with \( o < \text{type } r \), `enum r o` returns the \( o \)-th element in the enumeration of \( \alpha \) according to the well-order \( r \). This establishes a bijection that preserves the order structure between the initial segment of ordinals below \( \text{type } r \) and the elements of \( \alpha \).
Ordinal.typein_enum theorem
(r : α → α → Prop) [IsWellOrder α r] {o} (h : o < type r) : typein r (enum r ⟨o, h⟩) = o
Full source
@[simp]
theorem typein_enum (r : α → α → Prop) [IsWellOrder α r] {o} (h : o < type r) :
    typein r (enum r ⟨o, h⟩) = o :=
  (typein r).apply_subrelIso _
Inversion of Enumeration and Initial Segment Correspondence in Well-Orders
Informal description
Given a well-order relation \( r \) on a type \( \alpha \) and an ordinal \( o \) such that \( o < \text{type } r \), the ordinal corresponding to the initial segment of \( \alpha \) up to the \( o \)-th element (as enumerated by `enum r o`) is equal to \( o \). In other words, the function `typein r` inverts the enumeration function `enum r` on the initial segment of ordinals below `type r`.
Ordinal.enum_type theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : s ≺i r) {h : type s < type r} : enum r ⟨type s, h⟩ = f.top
Full source
theorem enum_type {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s]
    (f : s ≺i r) {h : type s < type r} : enum r ⟨type s, h⟩ = f.top :=
  (typein r).injective <| (typein_enum _ _).trans (typein_top _).symm
Principal Segment Top Element as Enumeration at Order Type
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively, and let $f : s \prec_i r$ be a principal segment embedding. If the order type of $s$ is strictly less than the order type of $r$ (i.e., $\mathrm{type}\, s < \mathrm{type}\, r$), then the $\mathrm{type}\, s$-th element in the enumeration of $\alpha$ via $r$ equals the top element of the principal segment $f$.
Ordinal.enum_typein theorem
(r : α → α → Prop) [IsWellOrder α r] (a : α) : enum r ⟨typein r a, typein_lt_type r a⟩ = a
Full source
@[simp]
theorem enum_typein (r : α → α → Prop) [IsWellOrder α r] (a : α) :
    enum r ⟨typein r a, typein_lt_type r a⟩ = a :=
  enum_type (PrincipalSeg.ofElement r a)
Enumeration at Initial Segment Type Recovers Original Element
Informal description
Given a well-order relation $r$ on a type $\alpha$ and an element $a \in \alpha$, the $\mathrm{typein}\, r\, a$-th element in the enumeration of $\alpha$ via $r$ is equal to $a$. Here, $\mathrm{typein}\, r\, a$ is the ordinal representing the order type of the initial segment $\{b \in \alpha \mid r(b, a)\}$.
Ordinal.enum_lt_enum theorem
{r : α → α → Prop} [IsWellOrder α r] {o₁ o₂ : Iio (type r)} : r (enum r o₁) (enum r o₂) ↔ o₁ < o₂
Full source
theorem enum_lt_enum {r : α → α → Prop} [IsWellOrder α r] {o₁ o₂ : Iio (type r)} :
    r (enum r o₁) (enum r o₂) ↔ o₁ < o₂ :=
  (enum _).map_rel_iff
Order-Preserving Property of Enumeration: $r(\text{enum}_r(o_1), \text{enum}_r(o_2)) \leftrightarrow o_1 < o_2$
Informal description
Let $r$ be a well-order on a type $\alpha$, and let $o_1$ and $o_2$ be ordinals less than the order type of $r$. Then the $o_1$-th element in the enumeration of $\alpha$ via $r$ is related to the $o_2$-th element by $r$ if and only if $o_1$ is strictly less than $o_2$ as ordinals.
Ordinal.enum_le_enum theorem
(r : α → α → Prop) [IsWellOrder α r] {o₁ o₂ : Iio (type r)} : ¬r (enum r o₁) (enum r o₂) ↔ o₂ ≤ o₁
Full source
theorem enum_le_enum (r : α → α → Prop) [IsWellOrder α r] {o₁ o₂ : Iio (type r)} :
    ¬r (enum r o₁) (enum r o₂)¬r (enum r o₁) (enum r o₂) ↔ o₂ ≤ o₁ := by
  rw [enum_lt_enum (r := r), not_lt]
Order-Reversing Property of Enumeration: $\neg r(\text{enum}_r(o_1), \text{enum}_r(o_2)) \leftrightarrow o_2 \leq o_1$
Informal description
Let $r$ be a well-order relation on a type $\alpha$, and let $o_1, o_2$ be ordinals less than the order type of $r$. Then the $o_1$-th element in the enumeration of $\alpha$ via $r$ is not related to the $o_2$-th element by $r$ if and only if $o_2 \leq o_1$.
Ordinal.enum_le_enum' theorem
(a : Ordinal) {o₁ o₂ : Iio (type (· < ·))} : enum (· < ·) o₁ ≤ enum (α := a.toType) (· < ·) o₂ ↔ o₁ ≤ o₂
Full source
@[simp]
theorem enum_le_enum' (a : Ordinal) {o₁ o₂ : Iio (type (· < ·))} :
    enumenum (· < ·) o₁ ≤ enum (α := a.toType) (· < ·) o₂ ↔ o₁ ≤ o₂ := by
  rw [← enum_le_enum, not_lt]
Order-Preserving Property of Enumeration on Canonical Types: $\text{enum}_<(o_1) \leq \text{enum}_<(o_2) \leftrightarrow o_1 \leq o_2$
Informal description
Let $a$ be an ordinal, and let $o_1, o_2$ be ordinals less than the order type of the standard well-order $<$ on $a.\text{toType}$. Then the $o_1$-th element in the enumeration of $a.\text{toType}$ via $<$ is less than or equal to the $o_2$-th element if and only if $o_1 \leq o_2$.
Ordinal.enum_inj theorem
{r : α → α → Prop} [IsWellOrder α r] {o₁ o₂ : Iio (type r)} : enum r o₁ = enum r o₂ ↔ o₁ = o₂
Full source
theorem enum_inj {r : α → α → Prop} [IsWellOrder α r] {o₁ o₂ : Iio (type r)} :
    enumenum r o₁ = enum r o₂ ↔ o₁ = o₂ :=
  EmbeddingLike.apply_eq_iff_eq _
Injectivity of Ordinal Enumeration in Well-Orders
Informal description
Let $r$ be a well-order relation on a type $\alpha$, and let $o_1, o_2$ be ordinals less than the order type of $r$. Then the enumeration function $\mathrm{enum}_r$ satisfies $\mathrm{enum}_r(o_1) = \mathrm{enum}_r(o_2)$ if and only if $o_1 = o_2$.
Ordinal.enum_zero_le theorem
{r : α → α → Prop} [IsWellOrder α r] (h0 : 0 < type r) (a : α) : ¬r a (enum r ⟨0, h0⟩)
Full source
theorem enum_zero_le {r : α → α → Prop} [IsWellOrder α r] (h0 : 0 < type r) (a : α) :
    ¬r a (enum r ⟨0, h0⟩) := by
  rw [← enum_typein r a, enum_le_enum r]
  apply Ordinal.zero_le
First Element in Well-Order Enumeration is Minimal
Informal description
Let $r$ be a well-order relation on a type $\alpha$ such that the order type of $r$ is greater than $0$. Then for any element $a \in \alpha$, $a$ is not less than the first element in the enumeration of $\alpha$ via $r$ (i.e., $\neg r(a, \mathrm{enum}_r(0))$).
Ordinal.enum_zero_le' theorem
{o : Ordinal} (h0 : 0 < o) (a : o.toType) : enum (α := o.toType) (· < ·) ⟨0, type_toType _ ▸ h0⟩ ≤ a
Full source
theorem enum_zero_le' {o : Ordinal} (h0 : 0 < o) (a : o.toType) :
    enum (α := o.toType) (· < ·) ⟨0, type_toType _ ▸ h0⟩ ≤ a := by
  rw [← not_lt]
  apply enum_zero_le
Minimality of the First Element in Ordinal Enumeration
Informal description
For any ordinal $o$ with $0 < o$ and any element $a$ in the canonical type associated with $o$, the first element in the enumeration of $o.\text{toType}$ (with respect to the standard order $<$) is less than or equal to $a$.
Ordinal.relIso_enum' theorem
{α β : Type u} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) (o : Ordinal) : ∀ (hr : o < type r) (hs : o < type s), f (enum r ⟨o, hr⟩) = enum s ⟨o, hs⟩
Full source
theorem relIso_enum' {α β : Type u} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] (f : r ≃r s) (o : Ordinal) :
    ∀ (hr : o < type r) (hs : o < type s), f (enum r ⟨o, hr⟩) = enum s ⟨o, hs⟩ := by
  refine inductionOn o ?_; rintro γ t wo ⟨g⟩ ⟨h⟩
  rw [enum_type g, enum_type (g.transRelIso f)]; rfl
Order Isomorphism Preserves Enumeration of Well-Ordered Sets
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively, and let $f : (\alpha, r) \cong (\beta, s)$ be an order isomorphism between them. For any ordinal $o$ such that $o < \mathrm{type}\, r$ and $o < \mathrm{type}\, s$, the image under $f$ of the $o$-th element in the enumeration of $\alpha$ via $r$ equals the $o$-th element in the enumeration of $\beta$ via $s$.
Ordinal.relIso_enum theorem
{α β : Type u} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) (o : Ordinal) (hr : o < type r) : f (enum r ⟨o, hr⟩) = enum s ⟨o, hr.trans_eq (Quotient.sound ⟨f⟩)⟩
Full source
theorem relIso_enum {α β : Type u} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r]
    [IsWellOrder β s] (f : r ≃r s) (o : Ordinal) (hr : o < type r) :
    f (enum r ⟨o, hr⟩) = enum s ⟨o, hr.trans_eq (Quotient.sound ⟨f⟩)⟩ :=
  relIso_enum' _ _ _ _
Order Isomorphism Preserves Enumeration of Well-Ordered Sets
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively, and let $f : (\alpha, r) \cong (\beta, s)$ be an order isomorphism between them. For any ordinal $o$ such that $o < \mathrm{type}\, r$, the image under $f$ of the $o$-th element in the enumeration of $\alpha$ via $r$ equals the $o$-th element in the enumeration of $\beta$ via $s$ (where the latter enumeration is well-defined since $o < \mathrm{type}\, s$ by the isomorphism).
Ordinal.enumIsoToType definition
(o : Ordinal) : Set.Iio o ≃o o.toType
Full source
/-- The order isomorphism between ordinals less than `o` and `o.toType`. -/
@[simps! -isSimp]
noncomputable def enumIsoToType (o : Ordinal) : Set.IioSet.Iio o ≃o o.toType where
  toFun x := enum (α := o.toType) (· < ·) ⟨x.1, type_toType _ ▸ x.2⟩
  invFun x := ⟨typein (α := o.toType) (· < ·) x, typein_lt_self x⟩
  left_inv _ := Subtype.ext_val (typein_enum _ _)
  right_inv _ := enum_typein _ _
  map_rel_iff' := enum_le_enum' _
Order isomorphism between initial segment of ordinals and canonical type of an ordinal
Informal description
For any ordinal \( o \), there exists an order isomorphism between the set of ordinals less than \( o \) (denoted \( \mathrm{Iio}\, o \)) and the canonical type associated with \( o \) (denoted \( o.\mathrm{toType} \)). More precisely: - The forward direction maps an ordinal \( x < o \) to the \( x \)-th element in the enumeration of \( o.\mathrm{toType} \) with respect to its canonical well-order. - The inverse direction maps an element \( y \) of \( o.\mathrm{toType} \) to the ordinal corresponding to the initial segment of \( o.\mathrm{toType} \) below \( y \). This isomorphism preserves the order structure in both directions.
Ordinal.small_Iio instance
(o : Ordinal.{u}) : Small.{u} (Iio o)
Full source
instance small_Iio (o : OrdinalOrdinal.{u}) : Small.{u} (Iio o) :=
  ⟨_, ⟨(enumIsoToType _).toEquiv⟩⟩
Smallness of Initial Segments of Ordinals
Informal description
For any ordinal $o$, the set of ordinals less than $o$ (denoted $\mathrm{Iio}\, o$) is $u$-small, meaning it is in bijection with some type in the universe $\mathrm{Type}\, u$.
Ordinal.small_Iic instance
(o : Ordinal.{u}) : Small.{u} (Iic o)
Full source
instance small_Iic (o : OrdinalOrdinal.{u}) : Small.{u} (Iic o) := by
  rw [← Iio_union_right]
  infer_instance
Smallness of Closed Initial Segments of Ordinals
Informal description
For any ordinal $o$, the set of ordinals less than or equal to $o$ (denoted $\mathrm{Iic}\, o$) is $u$-small, meaning it is in bijection with some type in the universe $\mathrm{Type}\, u$.
Ordinal.small_Ico instance
(a b : Ordinal.{u}) : Small.{u} (Ico a b)
Full source
instance small_Ico (a b : OrdinalOrdinal.{u}) : Small.{u} (Ico a b) := small_subset Ico_subset_Iio_self
Smallness of Left-Closed Right-Open Intervals of Ordinals
Informal description
For any two ordinals $a$ and $b$ in the same universe, the interval $[a, b)$ of ordinals is $u$-small, meaning it is in bijection with some type in the universe $\mathrm{Type}\, u$.
Ordinal.small_Icc instance
(a b : Ordinal.{u}) : Small.{u} (Icc a b)
Full source
instance small_Icc (a b : OrdinalOrdinal.{u}) : Small.{u} (Icc a b) := small_subset Icc_subset_Iic_self
Smallness of Closed Intervals of Ordinals
Informal description
For any two ordinals $a$ and $b$ in the same universe, the closed interval $[a, b]$ of ordinals is $u$-small, meaning it is in bijection with some type in the universe $\mathrm{Type}\, u$.
Ordinal.small_Ioo instance
(a b : Ordinal.{u}) : Small.{u} (Ioo a b)
Full source
instance small_Ioo (a b : OrdinalOrdinal.{u}) : Small.{u} (Ioo a b) := small_subset Ioo_subset_Iio_self
Smallness of Open Intervals of Ordinals
Informal description
For any ordinals $a$ and $b$ in the universe `Type u`, the open interval $(a, b)$ of ordinals is $u$-small, meaning it is in bijection with some type in the universe `Type u$.
Ordinal.small_Ioc instance
(a b : Ordinal.{u}) : Small.{u} (Ioc a b)
Full source
instance small_Ioc (a b : OrdinalOrdinal.{u}) : Small.{u} (Ioc a b) := small_subset Ioc_subset_Iic_self
Smallness of Left-Open Right-Closed Intervals of Ordinals
Informal description
For any ordinals $a$ and $b$ in the universe `Type u`, the left-open right-closed interval $(a, b]$ of ordinals is $u$-small, meaning it is in bijection with some type in the universe `Type u$.
Ordinal.toTypeOrderBot definition
{o : Ordinal} (ho : o ≠ 0) : OrderBot o.toType
Full source
/-- `o.toType` is an `OrderBot` whenever `o ≠ 0`. -/
def toTypeOrderBot {o : Ordinal} (ho : o ≠ 0) : OrderBot o.toType where
  bot := (enum (· < ·)) ⟨0, _⟩
  bot_le := enum_zero_le' (by rwa [Ordinal.pos_iff_ne_zero])
Bottom element in the canonical type of a nonzero ordinal
Informal description
For any nonzero ordinal $o$, the canonical type associated with $o$ (via `Ordinal.toType`) has a bottom element in its order structure. Specifically, the bottom element is given by the enumeration of the ordinal $0$ in the well-order corresponding to $o$.
Ordinal.toTypeOrderBotOfPos definition
{o : Ordinal} (ho : 0 < o) : OrderBot o.toType
Full source
/-- `o.toType` is an `OrderBot` whenever `0 < o`. -/
@[deprecated "use toTypeOrderBot" (since := "2025-02-13")]
def toTypeOrderBotOfPos {o : Ordinal} (ho : 0 < o) : OrderBot o.toType where
  bot := (enum (· < ·)) ⟨0, _⟩
  bot_le := enum_zero_le' ho
Bottom element in the canonical type of a positive ordinal
Informal description
For any ordinal \( o \) with \( 0 < o \), the canonical type associated with \( o \) (via `Ordinal.toType`) has a bottom element in its order structure. Specifically, the bottom element is given by the enumeration of the ordinal \( 0 \) in the well-order corresponding to \( o \), and this element is less than or equal to all other elements in the type.
Ordinal.enum_zero_eq_bot theorem
{o : Ordinal} (ho : 0 < o) : enum (α := o.toType) (· < ·) ⟨0, by rwa [type_toType]⟩ = have H := toTypeOrderBot (o := o) (by rintro rfl; simp at ho) (⊥ : o.toType)
Full source
theorem enum_zero_eq_bot {o : Ordinal} (ho : 0 < o) :
    enum (α := o.toType) (· < ·) ⟨0, by rwa [type_toType]⟩ =
      have H := toTypeOrderBot (o := o) (by rintro rfl; simp at ho)
      ( : o.toType) :=
  rfl
Enumeration of Zero Yields Bottom Element in Nonzero Ordinal Types
Informal description
For any ordinal $o$ with $0 < o$, the enumeration of the ordinal $0$ in the canonical well-ordered type associated with $o$ (via `Ordinal.toType`) is equal to the bottom element of that type. In other words, $\text{enum}_{o.\text{toType}}(0) = \bot$ where $\bot$ is the least element in the order structure of $o.\text{toType}$.
Ordinal.wellFoundedRelation instance
: WellFoundedRelation Ordinal
Full source
instance wellFoundedRelation : WellFoundedRelation Ordinal :=
  ⟨(· < ·), lt_wf⟩
Well-founded Relation on Ordinals
Informal description
The type of ordinals `Ordinal` is equipped with a well-founded relation given by the strict order $<$, where every nonempty set of ordinals has a minimal element with respect to this order.
Ordinal.wellFoundedLT instance
: WellFoundedLT Ordinal
Full source
instance wellFoundedLT : WellFoundedLT Ordinal :=
  ⟨lt_wf⟩
Well-foundedness of the Strict Order on Ordinals
Informal description
The strict less-than relation $<$ on the type of ordinals is well-founded. That is, every nonempty set of ordinals has a minimal element with respect to $<$.
Ordinal.instConditionallyCompleteLinearOrderBot instance
: ConditionallyCompleteLinearOrderBot Ordinal
Full source
instance : ConditionallyCompleteLinearOrderBot Ordinal :=
  WellFoundedLT.conditionallyCompleteLinearOrderBot _
Conditionally Complete Linear Order with Bottom Element on Ordinals
Informal description
The type of ordinals `Ordinal` is equipped with a conditionally complete linear order with bottom element structure, where the bottom element is the zero ordinal $0$. This means that every nonempty subset of ordinals that is bounded above has a supremum, and every nonempty subset has an infimum (which is bounded below by $0$). The order is linear (total) and well-founded.
Ordinal.induction theorem
{p : Ordinal.{u} → Prop} (i : Ordinal.{u}) (h : ∀ j, (∀ k, k < j → p k) → p j) : p i
Full source
/-- Reformulation of well founded induction on ordinals as a lemma that works with the
`induction` tactic, as in `induction i using Ordinal.induction with | h i IH => ?_`. -/
theorem induction {p : OrdinalOrdinal.{u} → Prop} (i : OrdinalOrdinal.{u}) (h : ∀ j, (∀ k, k < j → p k) → p j) :
    p i :=
  lt_wf.induction i h
Well-founded induction principle for ordinals
Informal description
For any property $p$ on ordinals and any ordinal $i$, if for every ordinal $j$ the implication $(\forall k < j, p(k)) \to p(j)$ holds, then $p(i)$ holds. This is a reformulation of well-founded induction on ordinals that is compatible with Lean's `induction` tactic.
Ordinal.typein_apply theorem
{α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≼i s) (a : α) : typein s (f a) = typein r a
Full source
theorem typein_apply {α β} {r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s]
    (f : r ≼i s) (a : α) : typein s (f a) = typein r a := by
  rw [← f.transPrincipal_apply _ a, (f.transPrincipal _).eq]
Preservation of Initial Segment Ordinals under Initial Segment Embeddings
Informal description
Let $\alpha$ and $\beta$ be types with well-order relations $r$ and $s$ respectively. For any initial segment embedding $f : (\alpha, r) \preceq_i (\beta, s)$ and any element $a \in \alpha$, the ordinal corresponding to the initial segment of $\beta$ up to $f(a)$ equals the ordinal corresponding to the initial segment of $\alpha$ up to $a$. In other words, $\text{typein}_s(f(a)) = \text{typein}_r(a)$.
Ordinal.card definition
: Ordinal → Cardinal
Full source
/-- The cardinal of an ordinal is the cardinality of any type on which a relation with that order
type is defined. -/
def card : OrdinalCardinal :=
  Quotient.map WellOrder.α fun _ _ ⟨e⟩ => ⟨e.toEquiv⟩
Cardinality of an ordinal
Informal description
The cardinality of an ordinal $o$ is the cardinality of any type equipped with a well-order relation that has order type $o$. More precisely, given an ordinal $o$ (which is an equivalence class of well-ordered types under order isomorphism), $\text{card}(o)$ is defined as the cardinality of any representative well-ordered type in this equivalence class.
Ordinal.card_type theorem
(r : α → α → Prop) [IsWellOrder α r] : card (type r) = #α
Full source
@[simp]
theorem card_type (r : α → α → Prop) [IsWellOrder α r] : card (type r) =  :=
  rfl
Cardinality of Order Type Equals Cardinality of Underlying Type
Informal description
For any well-order relation \( r \) on a type \( \alpha \), the cardinality of the ordinal number representing the order type of \( (\alpha, r) \) is equal to the cardinality of \( \alpha \). In other words, \( \text{card}(\text{type}(r)) = \#\alpha \).
Ordinal.card_typein theorem
{r : α → α → Prop} [IsWellOrder α r] (x : α) : #{ y // r y x } = (typein r x).card
Full source
@[simp]
theorem card_typein {r : α → α → Prop} [IsWellOrder α r] (x : α) :
    #{ y // r y x } = (typein r x).card :=
  rfl
Cardinality of Initial Segment Equals Cardinality of Its Order Type
Informal description
For any well-order relation $r$ on a type $\alpha$ and any element $x \in \alpha$, the cardinality of the set $\{y \in \alpha \mid r(y, x)\}$ is equal to the cardinality of the ordinal $\mathrm{typein}\, r\, x$, which represents the order type of the initial segment determined by $x$ under $r$.
Ordinal.card_le_card theorem
{o₁ o₂ : Ordinal} : o₁ ≤ o₂ → card o₁ ≤ card o₂
Full source
theorem card_le_card {o₁ o₂ : Ordinal} : o₁ ≤ o₂ → card o₁ ≤ card o₂ :=
  inductionOn o₁ fun _ _ _ => inductionOn o₂ fun _ _ _ ⟨⟨⟨f, _⟩, _⟩⟩ => ⟨f⟩
Monotonicity of Cardinality with Respect to Ordinal Ordering
Informal description
For any two ordinals $o₁$ and $o₂$, if $o₁ \leq o₂$, then the cardinality of $o₁$ is less than or equal to the cardinality of $o₂$.
Ordinal.card_zero theorem
: card 0 = 0
Full source
@[simp]
theorem card_zero : card 0 = 0 := mk_eq_zero _
Cardinality of Zero Ordinal: $\text{card}(0) = 0$
Informal description
The cardinality of the zero ordinal is zero, i.e., $\text{card}(0) = 0$.
Ordinal.card_one theorem
: card 1 = 1
Full source
@[simp]
theorem card_one : card 1 = 1 := mk_eq_one _
Cardinality of the Ordinal One
Informal description
The cardinality of the ordinal $1$ is equal to $1$, i.e., $\text{card}(1) = 1$.
Ordinal.lift definition
(o : Ordinal.{v}) : Ordinal.{max v u}
Full source
/-- 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 `liftInitialSeg`. -/
@[pp_with_univ]
def lift (o : OrdinalOrdinal.{v}) : OrdinalOrdinal.{max v u} :=
  Quotient.liftOn o (fun w => type <| ULift.downULift.down.{u} ⁻¹'o w.r) fun ⟨_, r, _⟩ ⟨_, s, _⟩ ⟨f⟩ =>
    Quot.sound
      ⟨(RelIso.preimage Equiv.ulift r).trans <| f.trans (RelIso.preimage Equiv.ulift s).symm⟩
Universe lift for ordinals
Informal description
The function `Ordinal.lift` maps an ordinal `o` in universe `v` to an ordinal in the universe `max v u` by embedding it as a proper initial segment. Specifically, for a well-ordered type `(α, r)` representing `o`, the lift is defined as the order type of the preimage of `r` under the universe-lifting function `ULift.down`.
Ordinal.type_uLift theorem
(r : α → α → Prop) [IsWellOrder α r] : type (ULift.down ⁻¹'o r) = lift.{v} (type r)
Full source
@[simp]
theorem type_uLift (r : α → α → Prop) [IsWellOrder α r] :
    type (ULift.downULift.down ⁻¹'o r) = lift.{v} (type r) :=
  rfl
Order Type Preservation under Universe Lifting: $\text{type}(\text{ULift.down}^{-1} \circ r) = \text{lift}_{v}(\text{type}(r))$
Informal description
For any well-order relation $r$ on a type $\alpha$, the order type of the preimage relation $\text{ULift.down}^{-1} \circ r$ on the lifted type $\text{ULift }\alpha$ is equal to the universe-lifted order type of $r$, i.e., \[ \text{type}(\text{ULift.down}^{-1} \circ r) = \text{lift}_{v}(\text{type}(r)). \]
RelIso.ordinal_lift_type_eq theorem
{r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) : lift.{v} (type r) = lift.{u} (type s)
Full source
theorem _root_.RelIso.ordinal_lift_type_eq {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) : lift.{v} (type r) = lift.{u} (type s) :=
  ((RelIso.preimage Equiv.ulift r).trans <|
      f.trans (RelIso.preimage Equiv.ulift s).symm).ordinal_type_eq
Lifted Order Types are Equal Under Order Isomorphism
Informal description
Let $(α, r)$ and $(β, s)$ be well-ordered sets, and let $f : (α, r) \cong (β, s)$ be an order isomorphism between them. Then the lifted order types satisfy $\text{lift}_{v}(\text{type}(r)) = \text{lift}_{u}(\text{type}(s))$, where $\text{lift}$ denotes the operation of lifting an ordinal to a higher universe level.
Ordinal.type_preimage theorem
{α β : Type u} (r : α → α → Prop) [IsWellOrder α r] (f : β ≃ α) : type (f ⁻¹'o r) = type r
Full source
@[simp]
theorem type_preimage {α β : Type u} (r : α → α → Prop) [IsWellOrder α r] (f : β ≃ α) :
    type (f ⁻¹'o r) = type r :=
  (RelIso.preimage f r).ordinal_type_eq
Order Type Invariance under Preimage of Equivalence: $\text{type}(f^{-1} \circ r) = \text{type}(r)$
Informal description
Given a well-order relation $r$ on a type $\alpha$ and an equivalence $f : \beta \simeq \alpha$, the order type of the preimage relation $f^{-1} \circ r$ on $\beta$ is equal to the order type of $r$ on $\alpha$. In other words, $\text{type}(f^{-1} \circ r) = \text{type}(r)$.
Ordinal.type_lift_preimage theorem
(r : α → α → Prop) [IsWellOrder α r] (f : β ≃ α) : lift.{u} (type (f ⁻¹'o r)) = lift.{v} (type r)
Full source
@[simp]
theorem type_lift_preimage (r : α → α → Prop) [IsWellOrder α r]
    (f : β ≃ α) : lift.{u} (type (f ⁻¹'o r)) = lift.{v} (type r) :=
  (RelIso.preimage f r).ordinal_lift_type_eq
Lifted Order Type Invariance under Preimage of Equivalence: $\text{lift}(\text{type}(f^{-1} \circ r)) = \text{lift}(\text{type}(r))$
Informal description
Let $r$ be a well-order relation on a type $\alpha$, and let $f : \beta \simeq \alpha$ be an equivalence (bijection) between types $\beta$ and $\alpha$. Then the lifted order type of the preimage relation $f^{-1} \circ r$ on $\beta$ is equal to the lifted order type of $r$ on $\alpha$, i.e., $\text{lift}_u(\text{type}(f^{-1} \circ r)) = \text{lift}_v(\text{type}(r))$.
Ordinal.lift_umax theorem
: lift.{max u v, u} = lift.{v, u}
Full source
/-- `lift.{max u v, u}` equals `lift.{v, u}`.

Unfortunately, the simp lemma doesn't seem to work. -/
theorem lift_umax : liftlift.{max u v, u} = liftlift.{v, u} :=
  funext fun a =>
    inductionOn a fun _ r _ =>
      Quotient.sound ⟨(RelIso.preimage Equiv.ulift r).trans (RelIso.preimage Equiv.ulift r).symm⟩
Universe Lift Identity for Ordinals: $\text{lift}_{\max(u,v), u} = \text{lift}_{v, u}$
Informal description
The universe lift operation on ordinals satisfies the identity $\text{lift}_{\max(u,v), u} = \text{lift}_{v, u}$, where $\text{lift}_{v, u}$ denotes lifting an ordinal from universe level $v$ to $\max(u,v)$.
Ordinal.lift_id' theorem
(a : Ordinal) : lift a = a
Full source
/-- An ordinal lifted to a lower or equal universe equals itself.

Unfortunately, the simp lemma doesn't work. -/
theorem lift_id' (a : Ordinal) : lift a = a :=
  inductionOn a fun _ r _ => Quotient.sound ⟨RelIso.preimage Equiv.ulift r⟩
Lift Invariance of Ordinals in Lower or Equal Universes
Informal description
For any ordinal $a$, lifting $a$ to a lower or equal universe results in $a$ itself, i.e., $\text{lift}(a) = a$.
Ordinal.lift_id theorem
: ∀ a, lift.{u, u} a = a
Full source
/-- An ordinal lifted to the same universe equals itself. -/
@[simp]
theorem lift_id : ∀ a, lift.{u, u} a = a :=
  lift_id'lift_id'.{u, u}
Identity of Ordinal Lifting within the Same Universe
Informal description
For any ordinal $a$, lifting $a$ to the same universe level leaves it unchanged, i.e., $\text{lift}(a) = a$.
Ordinal.lift_uzero theorem
(a : Ordinal.{u}) : lift.{0} a = a
Full source
/-- An ordinal lifted to the zero universe equals itself. -/
@[simp]
theorem lift_uzero (a : OrdinalOrdinal.{u}) : lift.{0} a = a :=
  lift_id' a
Lift Invariance of Ordinals to Zero Universe: $\text{lift}_{0}(a) = a$
Informal description
For any ordinal $a$ in universe level $u$, lifting $a$ to the zero universe (i.e., `lift.{0} a`) results in $a$ itself, i.e., $\text{lift}_{0}(a) = a$.
Ordinal.lift_type_le theorem
{α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] : lift.{max v w} (type r) ≤ lift.{max u w} (type s) ↔ Nonempty (r ≼i s)
Full source
theorem lift_type_le {α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] :
    liftlift.{max v w} (type r) ≤ lift.{max u w} (type s) ↔ Nonempty (r ≼i s) := by
  constructor <;> refine fun ⟨f⟩ ↦ ⟨?_⟩
  · exact (RelIso.preimage Equiv.ulift r).symm.toInitialSeg.trans
      (f.trans (RelIso.preimage Equiv.ulift s).toInitialSeg)
  · exact (RelIso.preimage Equiv.ulift r).toInitialSeg.trans
      (f.trans (RelIso.preimage Equiv.ulift s).symm.toInitialSeg)
Lifted Order Type Comparison via Initial Segment Embeddings
Informal description
Let $\alpha$ and $\beta$ be types with well-orders $r$ and $s$ respectively. The lifted order type of $(\alpha, r)$ is less than or equal to the lifted order type of $(\beta, s)$ if and only if there exists an initial segment embedding from $r$ to $s$.
Ordinal.lift_type_eq theorem
{α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] : lift.{max v w} (type r) = lift.{max u w} (type s) ↔ Nonempty (r ≃r s)
Full source
theorem lift_type_eq {α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] :
    liftlift.{max v w} (type r) = lift.{max u w} (type s) ↔ Nonempty (r ≃r s) := by
  refine Quotient.eq'.trans ⟨?_, ?_⟩ <;> refine fun ⟨f⟩ ↦ ⟨?_⟩
  · exact (RelIso.preimage Equiv.ulift r).symm.trans <| f.trans (RelIso.preimage Equiv.ulift s)
  · exact (RelIso.preimage Equiv.ulift r).trans <| f.trans (RelIso.preimage Equiv.ulift s).symm
Lifted Order Types are Equal if and only if Underlying Orders are Isomorphic
Informal description
For any two well-ordered types $\alpha$ (with order $r$) and $\beta$ (with order $s$), the lifted order types $\text{lift}(\text{type } r)$ and $\text{lift}(\text{type } s)$ are equal if and only if there exists an order isomorphism between $r$ and $s$. Here: - $\text{type } r$ denotes the ordinal corresponding to the well-order $r$ on $\alpha$. - $\text{lift}$ denotes the operation that lifts an ordinal to a higher universe. - $r \simeqr s$ denotes an order isomorphism between the relations $r$ and $s$.
Ordinal.lift_type_lt theorem
{α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] : lift.{max v w} (type r) < lift.{max u w} (type s) ↔ Nonempty (r ≺i s)
Full source
theorem lift_type_lt {α : Type u} {β : Type v} {r s} [IsWellOrder α r] [IsWellOrder β s] :
    liftlift.{max v w} (type r) < lift.{max u w} (type s) ↔ Nonempty (r ≺i s) := by
  constructor <;> refine fun ⟨f⟩ ↦ ⟨?_⟩
  · exact (f.relIsoTrans (RelIso.preimage Equiv.ulift r).symm).transInitial
      (RelIso.preimage Equiv.ulift s).toInitialSeg
  · exact (f.relIsoTrans (RelIso.preimage Equiv.ulift r)).transInitial
      (RelIso.preimage Equiv.ulift s).symm.toInitialSeg
Lifted Order Type Comparison via Principal Segment Embeddings
Informal description
For any two well-ordered types $\alpha$ (with order $r$) and $\beta$ (with order $s$), the lifted ordinal $\text{lift}(\text{type } r)$ is strictly less than the lifted ordinal $\text{lift}(\text{type } s)$ if and only if there exists a principal segment embedding from $r$ to $s$.
Ordinal.lift_le theorem
{a b : Ordinal} : lift.{u, v} a ≤ lift.{u, v} b ↔ a ≤ b
Full source
@[simp]
theorem lift_le {a b : Ordinal} : liftlift.{u, v} a ≤ lift.{u, v} b ↔ a ≤ b :=
  inductionOn₂ a b fun α r _ β s _ => by
    rw [← lift_umax]
    exact lift_type_le.{_,_,u}
Lift Preserves Order on Ordinals: $\mathrm{lift}_{u,v}(a) \leq \mathrm{lift}_{u,v}(b) \leftrightarrow a \leq b$
Informal description
For any two ordinals $a$ and $b$, the inequality $\mathrm{lift}_{u,v}(a) \leq \mathrm{lift}_{u,v}(b)$ holds if and only if $a \leq b$.
Ordinal.lift_inj theorem
{a b : Ordinal} : lift.{u, v} a = lift.{u, v} b ↔ a = b
Full source
@[simp]
theorem lift_inj {a b : Ordinal} : liftlift.{u, v} a = lift.{u, v} b ↔ a = b := by
  simp_rw [le_antisymm_iff, lift_le]
Injectivity of Ordinal Lifting: $\text{lift}_{u,v}(a) = \text{lift}_{u,v}(b) \leftrightarrow a = b$
Informal description
For any two ordinals $a$ and $b$, the lifted ordinals $\text{lift}_{u,v}(a)$ and $\text{lift}_{u,v}(b)$ are equal if and only if $a = b$.
Ordinal.lift_lt theorem
{a b : Ordinal} : lift.{u, v} a < lift.{u, v} b ↔ a < b
Full source
@[simp]
theorem lift_lt {a b : Ordinal} : liftlift.{u, v} a < lift.{u, v} b ↔ a < b := by
  simp_rw [lt_iff_le_not_le, lift_le]
Lift Preserves Strict Order on Ordinals: $\mathrm{lift}_{u,v}(a) < \mathrm{lift}_{u,v}(b) \leftrightarrow a < b$
Informal description
For any two ordinals $a$ and $b$, the lifted ordinal $\mathrm{lift}_{u,v}(a)$ is strictly less than $\mathrm{lift}_{u,v}(b)$ if and only if $a$ is strictly less than $b$.
Ordinal.lift_typein_top theorem
{r : α → α → Prop} {s : β → β → Prop} [IsWellOrder α r] [IsWellOrder β s] (f : r ≺i s) : lift.{u} (typein s f.top) = lift (type r)
Full source
@[simp]
theorem lift_typein_top {r : α → α → Prop} {s : β → β → Prop}
    [IsWellOrder α r] [IsWellOrder β s] (f : r ≺i s) : lift.{u} (typein s f.top) = lift (type r) :=
  f.subrelIso.ordinal_lift_type_eq
Lifted Order Type of Initial Segment Equals Lifted Order Type of Original Well-Order
Informal description
Let $(α, r)$ and $(β, s)$ be well-ordered sets, and let $f : r \prec_i s$ be a principal segment embedding from $r$ to $s$. Then the lift of the ordinal corresponding to the initial segment of $β$ below $f.\text{top}$ (i.e., $\text{lift}_{u}(\text{typein}\ s\ f.\text{top})$) is equal to the lift of the ordinal corresponding to the entire well-order $(α, r)$ (i.e., $\text{lift}(\text{type}\ r)$).
Ordinal.liftInitialSeg definition
: Ordinal.{v} ≤i Ordinal.{max u v}
Full source
/-- Initial segment version of the lift operation on ordinals, embedding `Ordinal.{u}` in
`Ordinal.{v}` as an initial segment when `u ≤ v`. -/
def liftInitialSeg : OrdinalOrdinal.{v}Ordinal.{v} ≤i Ordinal.{max u v} := by
  refine ⟨RelEmbedding.ofMonotone lift.{u} (by simp),
    fun a b ↦ Ordinal.inductionOn₂ a b fun α r _ β s _ h ↦ ?_⟩
  rw [RelEmbedding.ofMonotone_coe, ← lift_id'.{max u v} (type s),
    ← lift_umaxlift_umax.{v, u}, lift_type_lt] at h
  obtain ⟨f⟩ := h
  use typein r f.top
  rw [RelEmbedding.ofMonotone_coe, ← lift_umax, lift_typein_top, lift_id']
Initial segment embedding for ordinal universe lift
Informal description
The function `Ordinal.liftInitialSeg` is an initial segment embedding that lifts an ordinal from universe `v` to universe `max u v`. Specifically, it embeds `Ordinal.{v}` into `Ordinal.{max u v}` as an initial segment, meaning that the image of any ordinal under this embedding forms a lower set in the target universe.
Ordinal.liftInitialSeg_coe theorem
: (liftInitialSeg.{v, u} : Ordinal → Ordinal) = lift.{v, u}
Full source
@[simp]
theorem liftInitialSeg_coe : (liftInitialSegliftInitialSeg.{v, u} : OrdinalOrdinal) = liftlift.{v, u} :=
  rfl
Equality of `liftInitialSeg` and `lift` for ordinals
Informal description
The function `liftInitialSeg` from ordinals in universe `v` to ordinals in universe `max v u` is equal to the universe lift function `lift` when viewed as a function between ordinal types.
Ordinal.lift_lift theorem
(a : Ordinal.{u}) : lift.{w} (lift.{v} a) = lift.{max v w} a
Full source
@[simp]
theorem lift_lift (a : OrdinalOrdinal.{u}) : lift.{w} (lift.{v} a) = lift.{max v w} a :=
  (liftInitialSeg.trans liftInitialSeg).eq liftInitialSeg a
Commutativity of Ordinal Lifting Across Universes: $\text{lift}_w \circ \text{lift}_v = \text{lift}_{\max(v, w)}$
Informal description
For any ordinal $a$ in universe $u$, lifting $a$ to universe $w$ after first lifting it to universe $v$ is equivalent to lifting $a$ directly to the universe $\max(v, w)$. That is, $\text{lift}_{w}(\text{lift}_{v}(a)) = \text{lift}_{\max(v, w)}(a)$.
Ordinal.lift_zero theorem
: lift 0 = 0
Full source
@[simp]
theorem lift_zero : lift 0 = 0 :=
  type_eq_zero_of_empty _
Lift of Zero Ordinal is Zero
Informal description
The universe lift of the zero ordinal is equal to the zero ordinal, i.e., $\text{lift}(0) = 0$.
Ordinal.lift_one theorem
: lift 1 = 1
Full source
@[simp]
theorem lift_one : lift 1 = 1 :=
  type_eq_one_of_unique _
Lift of One Ordinal is One
Informal description
The universe lift of the ordinal $1$ is equal to $1$, i.e., $\text{lift}(1) = 1$.
Ordinal.lift_card theorem
(a) : Cardinal.lift.{u, v} (card a) = card (lift.{u} a)
Full source
@[simp]
theorem lift_card (a) : Cardinal.lift.{u, v} (card a) = card (lift.{u} a) :=
  inductionOn a fun _ _ _ => rfl
Cardinality Preservation under Ordinal Lift: $\text{lift}(\text{card}(a)) = \text{card}(\text{lift}(a))$
Informal description
For any ordinal $a$, the cardinality of the universe-lifted ordinal $\text{lift}_{u,v}(a)$ is equal to the universe-lifted cardinality of $a$, i.e., $\text{lift}_{u,v}(\text{card}(a)) = \text{card}(\text{lift}_{u,v}(a))$.
Ordinal.mem_range_lift_of_le theorem
{a : Ordinal.{u}} {b : Ordinal.{max u v}} (h : b ≤ lift.{v} a) : b ∈ Set.range lift.{v}
Full source
theorem mem_range_lift_of_le {a : OrdinalOrdinal.{u}} {b : OrdinalOrdinal.{max u v}} (h : b ≤ lift.{v} a) :
    b ∈ Set.range lift.{v} :=
  liftInitialSeg.mem_range_of_le h
Range Membership of Lifted Ordinals under Inequality
Informal description
For any ordinal $a$ in universe $u$ and any ordinal $b$ in universe $\max(u, v)$, if $b \leq \text{lift}_{v}(a)$, then $b$ is in the range of the lifting function $\text{lift}_{v} \colon \text{Ordinal}_{u} \to \text{Ordinal}_{\max(u, v)}$.
Ordinal.le_lift_iff theorem
{a : Ordinal.{u}} {b : Ordinal.{max u v}} : b ≤ lift.{v} a ↔ ∃ a' ≤ a, lift.{v} a' = b
Full source
theorem le_lift_iff {a : OrdinalOrdinal.{u}} {b : OrdinalOrdinal.{max u v}} :
    b ≤ lift.{v} a ↔ ∃ a' ≤ a, lift.{v} a' = b :=
  liftInitialSeg.le_apply_iff
Characterization of Inequality for Lifted Ordinals: $b \leq \text{lift}(a) \leftrightarrow \exists a' \leq a, \text{lift}(a') = b$
Informal description
For any ordinal $a$ in universe $u$ and any ordinal $b$ in universe $\max(u, v)$, we have $b \leq \text{lift}_v(a)$ if and only if there exists an ordinal $a' \leq a$ in universe $u$ such that $\text{lift}_v(a') = b$.
Ordinal.lt_lift_iff theorem
{a : Ordinal.{u}} {b : Ordinal.{max u v}} : b < lift.{v} a ↔ ∃ a' < a, lift.{v} a' = b
Full source
theorem lt_lift_iff {a : OrdinalOrdinal.{u}} {b : OrdinalOrdinal.{max u v}} :
    b < lift.{v} a ↔ ∃ a' < a, lift.{v} a' = b :=
  liftInitialSeg.lt_apply_iff
Characterization of Strictly Smaller Lifted Ordinals
Informal description
For any ordinal $a$ in universe $u$ and any ordinal $b$ in universe $\max(u, v)$, we have $b < \text{lift}_v(a)$ if and only if there exists an ordinal $a' < a$ in universe $u$ such that $\text{lift}_v(a') = b$.
Ordinal.omega0 definition
: Ordinal.{u}
Full source
/-- `ω` is the first infinite ordinal, defined as the order type of `ℕ`. -/
def omega0 : OrdinalOrdinal.{u} :=
  lift (typeLT ℕ)
First infinite ordinal (omega)
Informal description
The first infinite ordinal $\omega$ is defined as the order type of the natural numbers $\mathbb{N}$ under their usual ordering. This definition is universe polymorphic, meaning $\omega$ exists in every universe level.
Ordinal.termω definition
: Lean.ParserDescr✝
Full source
@[inherit_doc]
scoped notation "ω" => Ordinal.omega0
First infinite ordinal (omega)
Informal description
The notation `ω` represents the first infinite ordinal, which is the order type of the natural numbers `ℕ`. This notation is universe polymorphic, meaning `ω.{u} : Ordinal.{u}` for any universe level `u`.
Ordinal.type_nat_lt theorem
: typeLT ℕ = ω
Full source
/-- Note that the presence of this lemma makes `simp [omega0]` form a loop. -/
@[simp]
theorem type_nat_lt : typeLT ℕ = ω :=
  (lift_id _).symm
Order Type of Natural Numbers is Omega ($\mathrm{type}(\mathbb{N}, <) = \omega$)
Informal description
The order type of the natural numbers $\mathbb{N}$ with their standard strict less-than relation $<$ is equal to the first infinite ordinal $\omega$.
Ordinal.card_omega0 theorem
: card ω = ℵ₀
Full source
@[simp]
theorem card_omega0 : card ω = ℵ₀ :=
  rfl
Cardinality of $\omega$ equals $\aleph_0$
Informal description
The cardinality of the first infinite ordinal $\omega$ is equal to $\aleph_0$, the smallest infinite cardinal. In other words, $|\omega| = \aleph_0$.
Ordinal.lift_omega0 theorem
: lift ω = ω
Full source
@[simp]
theorem lift_omega0 : lift ω = ω :=
  lift_lift _
Invariance of $\omega$ under Universe Lifting: $\text{lift}(\omega) = \omega$
Informal description
The lift of the first infinite ordinal $\omega$ to any higher universe is equal to $\omega$ itself, i.e., $\text{lift}(\omega) = \omega$.
Ordinal.add instance
: Add Ordinal.{u}
Full source
/-- `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₂`. -/
instance add : Add OrdinalOrdinal.{u} :=
  ⟨fun o₁ o₂ => Quotient.liftOn₂ o₁ o₂ (fun ⟨_, r, _⟩ ⟨_, s, _⟩ => type (Sum.Lex r s))
    fun _ _ _ _ ⟨f⟩ ⟨g⟩ => (RelIso.sumLexCongr f g).ordinal_type_eq⟩
Addition of Ordinals via Disjoint Union Ordering
Informal description
The addition operation $+$ on ordinals is defined as follows: for two ordinals $o_1$ and $o_2$, the sum $o_1 + o_2$ is the ordinal corresponding to the disjoint union of $o_1$ and $o_2$ ordered such that every element of $o_1$ is less than every element of $o_2$.
Ordinal.addMonoidWithOne instance
: AddMonoidWithOne Ordinal.{u}
Full source
instance addMonoidWithOne : AddMonoidWithOne OrdinalOrdinal.{u} where
  add := (· + ·)
  zero := 0
  one := 1
  zero_add o :=
    inductionOn o fun α _ _ =>
      Eq.symm <| Quotient.sound ⟨⟨(emptySum PEmpty α).symm, Sum.lex_inr_inr⟩⟩
  add_zero o :=
    inductionOn o fun α _ _ =>
      Eq.symm <| Quotient.sound ⟨⟨(sumEmpty α PEmpty).symm, Sum.lex_inl_inl⟩⟩
  add_assoc o₁ o₂ o₃ :=
    Quotient.inductionOn₃ o₁ o₂ o₃ fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ =>
      Quot.sound
        ⟨⟨sumAssoc _ _ _, by
          intros a b
          rcases a with (⟨a | a⟩ | a) <;> rcases b with (⟨b | b⟩ | b) <;>
            simp only [sumAssoc_apply_inl_inl, sumAssoc_apply_inl_inr, sumAssoc_apply_inr,
              Sum.lex_inl_inl, Sum.lex_inr_inr, Sum.Lex.sep, Sum.lex_inr_inl]⟩⟩
  nsmul := nsmulRec
Ordinals as an Additive Monoid with One
Informal description
The ordinals form an additive monoid with one, where the addition operation is given by the sum of ordinals (via disjoint union ordering), the zero element is the empty ordinal, and the one element is the ordinal corresponding to a singleton set.
Ordinal.card_add theorem
(o₁ o₂ : Ordinal) : card (o₁ + o₂) = card o₁ + card o₂
Full source
@[simp]
theorem card_add (o₁ o₂ : Ordinal) : card (o₁ + o₂) = card o₁ + card o₂ :=
  inductionOn o₁ fun _ __ => inductionOn o₂ fun _ _ _ => rfl
Cardinality of Ordinal Sum Equals Sum of Cardinalities
Informal description
For any two ordinals $o₁$ and $o₂$, the cardinality of their sum $o₁ + o₂$ equals the sum of their cardinalities, i.e., \[ \text{card}(o₁ + o₂) = \text{card}(o₁) + \text{card}(o₂). \]
Ordinal.type_sum_lex theorem
{α β : Type u} (r : α → α → Prop) (s : β → β → Prop) [IsWellOrder α r] [IsWellOrder β s] : type (Sum.Lex r s) = type r + type s
Full source
@[simp]
theorem type_sum_lex {α β : Type u} (r : α → α → Prop) (s : β → β → Prop) [IsWellOrder α r]
    [IsWellOrder β s] : type (Sum.Lex r s) = type r + type s :=
  rfl
Order Type of Lexicographic Sum Equals Sum of Order Types
Informal description
Let $\alpha$ and $\beta$ be types equipped with well-order relations $r$ and $s$ respectively. Then the order type of the lexicographic sum order on $\alpha \oplus \beta$ is equal to the sum of the order types of $(\alpha, r)$ and $(\beta, s)$. That is, \[ \text{type}(\text{Sum.Lex } r \ s) = \text{type}(r) + \text{type}(s). \]
Ordinal.card_nat theorem
(n : ℕ) : card.{u} n = n
Full source
@[simp]
theorem card_nat (n : ) : card.{u} n = n := by
  induction n <;> [simp; simp only [card_add, card_one, Nat.cast_succ, *]]
Cardinality of Finite Ordinals: $\text{card}(n) = n$ for $n \in \mathbb{N}$
Informal description
For any natural number $n$, the cardinality of the ordinal $n$ is equal to $n$ itself, i.e., $\text{card}(n) = n$.
Ordinal.card_ofNat theorem
(n : ℕ) [n.AtLeastTwo] : card.{u} ofNat(n) = OfNat.ofNat n
Full source
@[simp]
theorem card_ofNat (n : ) [n.AtLeastTwo] :
    card.{u} ofNat(n) = OfNat.ofNat n :=
  card_nat n
Cardinality of Finite Ordinals ≥ 2: $\text{card}(n) = n$
Informal description
For any natural number $n \geq 2$, the cardinality of the ordinal corresponding to $n$ (via the `OfNat` instance) is equal to $n$ itself, i.e., $\text{card}(n) = n$.
Ordinal.instAddLeftMono instance
: AddLeftMono Ordinal.{u}
Full source
instance instAddLeftMono : AddLeftMono OrdinalOrdinal.{u} where
  elim c a b := by
    refine inductionOn₃ a b c fun α r _ β s _ γ t _ ⟨f⟩ ↦
      (RelEmbedding.ofMonotone (Sum.recOn · Sum.inl (Sum.inrSum.inr ∘ f)) ?_).ordinal_type_le
    simp [f.map_rel_iff]
Left Monotonicity of Ordinal Addition
Informal description
For any ordinals $a$, $b$, and $c$, if $b \leq c$, then $a + b \leq a + c$. In other words, addition of ordinals is monotone in the second argument.
Ordinal.instAddRightMono instance
: AddRightMono Ordinal.{u}
Full source
instance instAddRightMono : AddRightMono OrdinalOrdinal.{u} where
  elim c a b := by
    refine inductionOn₃ a b c fun α r _ β s _ γ t _  ⟨f⟩ ↦
      (RelEmbedding.ofMonotone (Sum.recOn · (Sum.inlSum.inl ∘ f) Sum.inr) ?_).ordinal_type_le
    simp [f.map_rel_iff]
Monotonicity of Ordinal Addition in the Right Argument
Informal description
For any ordinals $a$ and $b$, the function $a \mapsto b + a$ is monotone with respect to the order on ordinals. That is, if $a_1 \leq a_2$, then $b + a_1 \leq b + a_2$.
Ordinal.le_add_right theorem
(a b : Ordinal) : a ≤ a + b
Full source
theorem le_add_right (a b : Ordinal) : a ≤ a + b := by
  simpa only [add_zero] using add_le_add_left (Ordinal.zero_le b) a
Right Addition Preserves Order in Ordinals: $a \leq a + b$
Informal description
For any ordinals $a$ and $b$, the ordinal $a$ is less than or equal to the sum $a + b$.
Ordinal.le_add_left theorem
(a b : Ordinal) : a ≤ b + a
Full source
theorem le_add_left (a b : Ordinal) : a ≤ b + a := by
  simpa only [zero_add] using add_le_add_right (Ordinal.zero_le b) a
Left Addition Preserves Ordinal Order: $a \leq b + a$
Informal description
For any ordinals $a$ and $b$, the ordinal $a$ is less than or equal to the sum $b + a$.
Ordinal.max_zero_left theorem
: ∀ a : Ordinal, max 0 a = a
Full source
theorem max_zero_left : ∀ a : Ordinal, max 0 a = a :=
  max_bot_left
Maximum with Zero Ordinal is Identity
Informal description
For any ordinal $a$, the maximum of the zero ordinal $0$ and $a$ is equal to $a$, i.e., $\max(0, a) = a$.
Ordinal.max_zero_right theorem
: ∀ a : Ordinal, max a 0 = a
Full source
theorem max_zero_right : ∀ a : Ordinal, max a 0 = a :=
  max_bot_right
Maximum with Zero Ordinal Equals Itself
Informal description
For any ordinal $a$, the maximum of $a$ and the zero ordinal $0$ is equal to $a$, i.e., $\max(a, 0) = a$.
Ordinal.max_eq_zero theorem
{a b : Ordinal} : max a b = 0 ↔ a = 0 ∧ b = 0
Full source
@[simp]
theorem max_eq_zero {a b : Ordinal} : maxmax a b = 0 ↔ a = 0 ∧ b = 0 :=
  max_eq_bot
Characterization of when maximum equals zero in ordinals: $\max(a,b) = 0 \leftrightarrow a = 0 \land b = 0$
Informal description
For any ordinals $a$ and $b$, the maximum $\max(a, b)$ equals the zero ordinal $0$ if and only if both $a = 0$ and $b = 0$.
Ordinal.sInf_empty theorem
: sInf (∅ : Set Ordinal) = 0
Full source
@[simp]
theorem sInf_empty : sInf ( : Set Ordinal) = 0 :=
  dif_neg Set.not_nonempty_empty
Infimum of Empty Set of Ordinals is Zero
Informal description
The infimum of the empty set of ordinals is equal to the zero ordinal, i.e., $\inf(\emptyset) = 0$.
Ordinal.instSuccOrder instance
: SuccOrder Ordinal.{u}
Full source
instance : SuccOrder OrdinalOrdinal.{u} :=
  SuccOrder.ofSuccLeIff (fun o => o + 1) succ_le_iff'
Successor Order Structure on Ordinals
Informal description
The type of ordinals `Ordinal.{u}` is equipped with a successor order structure, where for each ordinal `o`, the successor `succ o` is the least ordinal greater than `o`. This structure satisfies the property that for any ordinals `a` and `b`, `succ a ≤ b` if and only if `a < b`.
Ordinal.instSuccAddOrder instance
: SuccAddOrder Ordinal
Full source
instance : SuccAddOrder Ordinal := ⟨fun _ => rfl⟩
Successor-Additive Order Structure on Ordinals
Informal description
The type of ordinals `Ordinal` is equipped with a successor-additive order structure, where the successor operation `succ` is compatible with addition in the sense that `succ (a + b) = a + succ b` for all ordinals `a` and `b`.
Ordinal.add_one_eq_succ theorem
(o : Ordinal) : o + 1 = succ o
Full source
@[simp]
theorem add_one_eq_succ (o : Ordinal) : o + 1 = succ o :=
  rfl
Ordinal Addition of One Equals Successor
Informal description
For any ordinal $o$, the sum $o + 1$ is equal to the successor ordinal $\text{succ}(o)$.
Ordinal.succ_zero theorem
: succ (0 : Ordinal) = 1
Full source
@[simp]
theorem succ_zero : succ (0 : Ordinal) = 1 :=
  zero_add 1
Successor of Zero is One
Informal description
The successor of the zero ordinal is equal to the ordinal one, i.e., $\text{succ}(0) = 1$.
Ordinal.succ_one theorem
: succ (1 : Ordinal) = 2
Full source
@[simp]
theorem succ_one : succ (1 : Ordinal) = 2 := by congr; simp only [Nat.unaryCast, zero_add]
Successor of One in Ordinals: $\text{succ}(1) = 2$
Informal description
The successor of the ordinal $1$ is equal to the ordinal $2$.
Ordinal.add_succ theorem
(o₁ o₂ : Ordinal) : o₁ + succ o₂ = succ (o₁ + o₂)
Full source
theorem add_succ (o₁ o₂ : Ordinal) : o₁ + succ o₂ = succ (o₁ + o₂) :=
  (add_assoc _ _ _).symm
Successor Distributes Over Ordinal Addition
Informal description
For any two ordinals $o_1$ and $o_2$, the sum of $o_1$ and the successor of $o_2$ is equal to the successor of the sum $o_1 + o_2$. That is, $o_1 + \text{succ}(o_2) = \text{succ}(o_1 + o_2)$.
Ordinal.succ_pos theorem
(o : Ordinal) : 0 < succ o
Full source
theorem succ_pos (o : Ordinal) : 0 < succ o :=
  bot_lt_succ o
Successor Ordinals are Positive
Informal description
For any ordinal $o$, the successor ordinal $\mathrm{succ}(o)$ is strictly greater than $0$.
Ordinal.succ_ne_zero theorem
(o : Ordinal) : succ o ≠ 0
Full source
theorem succ_ne_zero (o : Ordinal) : succsucc o ≠ 0 :=
  ne_of_gt <| succ_pos o
Successor Ordinals are Nonzero
Informal description
For any ordinal $o$, the successor ordinal $\mathrm{succ}(o)$ is not equal to $0$.
Ordinal.lt_one_iff_zero theorem
{a : Ordinal} : a < 1 ↔ a = 0
Full source
@[simp]
theorem lt_one_iff_zero {a : Ordinal} : a < 1 ↔ a = 0 := by
  simpa using @lt_succ_bot_iff _ _ _ a _ _
Characterization of ordinals less than one: $a < 1 \leftrightarrow a = 0$
Informal description
For any ordinal $a$, $a < 1$ if and only if $a = 0$.
Ordinal.le_one_iff theorem
{a : Ordinal} : a ≤ 1 ↔ a = 0 ∨ a = 1
Full source
theorem le_one_iff {a : Ordinal} : a ≤ 1 ↔ a = 0 ∨ a = 1 := by
  simpa using @le_succ_bot_iff _ _ _ a _
Characterization of Ordinals Less Than or Equal to One: $a \leq 1 \leftrightarrow a = 0 \lor a = 1$
Informal description
For any ordinal $a$, $a \leq 1$ if and only if $a = 0$ or $a = 1$.
Ordinal.card_succ theorem
(o : Ordinal) : card (succ o) = card o + 1
Full source
@[simp]
theorem card_succ (o : Ordinal) : card (succ o) = card o + 1 := by
  simp only [← add_one_eq_succ, card_add, card_one]
Cardinality of Successor Ordinal: $\text{card}(\text{succ}(o)) = \text{card}(o) + 1$
Informal description
For any ordinal $o$, the cardinality of its successor ordinal $\text{succ}(o)$ is equal to the cardinality of $o$ plus one, i.e., \[ \text{card}(\text{succ}(o)) = \text{card}(o) + 1. \]
Ordinal.natCast_succ theorem
(n : ℕ) : ↑n.succ = succ (n : Ordinal)
Full source
theorem natCast_succ (n : ) : ↑n.succ = succ (n : Ordinal) :=
  rfl
Successor of Natural Number Embedding in Ordinals
Informal description
For any natural number $n$, the canonical embedding of the successor $n+1$ into the ordinals is equal to the successor ordinal of the embedding of $n$, i.e., $\uparrow(n+1) = \text{succ}(\uparrow n)$.
Ordinal.Iio_one_default_eq theorem
: (default : Iio (1 : Ordinal)) = ⟨0, zero_lt_one' Ordinal⟩
Full source
@[simp]
theorem Iio_one_default_eq : (default : Iio (1 : Ordinal)) = ⟨0, zero_lt_one' Ordinal⟩ :=
  rfl
Default Element of Ordinals Below One is Zero with Proof of Inequality
Informal description
The default element of the interval $(-\infty, 1)$ of ordinals is the pair $\langle 0, \text{zero\_lt\_one}' \rangle$, where $0$ is the smallest ordinal and $\text{zero\_lt\_one}'$ is the proof that $0 < 1$ in the ordinals.
Ordinal.uniqueToTypeOne instance
: Unique (toType 1)
Full source
instance uniqueToTypeOne : Unique (toType 1) where
  default := enum (α := toType 1) (· < ·) ⟨0, by simp⟩
  uniq a := by
    rw [← enum_typein (α := toType 1) (· < ·) a]
    congr
    rw [← lt_one_iff_zero]
    apply typein_lt_self
Uniqueness of the Canonical Type for Ordinal One
Informal description
The canonical type associated with the ordinal $1$ is a unique type, meaning it has exactly one element up to equality. This reflects the fact that the ordinal $1$ represents the order type of a singleton set.
Ordinal.one_toType_eq theorem
(x : toType 1) : x = enum (· < ·) ⟨0, by simp⟩
Full source
theorem one_toType_eq (x : toType 1) : x = enum (· < ·) ⟨0, by simp⟩ :=
  Unique.eq_default x
Canonical Type of Ordinal One is a Singleton: $x = \text{enum}(0)$ for all $x \in \text{toType}(1)$
Informal description
For any element $x$ in the canonical type associated with the ordinal $1$, $x$ is equal to the enumeration of the well-order $(<)$ at the ordinal $0$ (which is the only element in the initial segment of $1$).
Ordinal.typein_one_toType theorem
(x : toType 1) : typein (α := toType 1) (· < ·) x = 0
Full source
@[simp]
theorem typein_one_toType (x : toType 1) : typein (α := toType 1) (· < ·) x = 0 := by
  rw [one_toType_eq x, typein_enum]
Initial Segment Ordinal for Singleton Type: $\text{typein}(x) = 0$ for all $x \in \text{toType}(1)$
Informal description
For any element $x$ in the canonical type associated with the ordinal $1$, the ordinal corresponding to the initial segment up to $x$ under the standard order is equal to $0$.
Ordinal.typein_le_typein' theorem
(o : Ordinal) {x y : o.toType} : typein (α := o.toType) (· < ·) x ≤ typein (α := o.toType) (· < ·) y ↔ x ≤ y
Full source
theorem typein_le_typein' (o : Ordinal) {x y : o.toType} :
    typeintypein (α := o.toType) (· < ·) x ≤ typein (α := o.toType) (· < ·) y ↔ x ≤ y := by
  simp
Order-Preserving Property of Initial Segment Ordinals: $\text{typein}(x) \leq \text{typein}(y) \leftrightarrow x \leq y$
Informal description
For any ordinal $o$ and elements $x, y$ in the canonical type associated with $o$, the ordinal corresponding to the initial segment up to $x$ is less than or equal to the ordinal corresponding to the initial segment up to $y$ if and only if $x$ is less than or equal to $y$ in the canonical order on $o.\text{toType}$.
Ordinal.le_enum_succ theorem
{o : Ordinal} (a : (succ o).toType) : a ≤ enum (α := (succ o).toType) (· < ·) ⟨o, (type_toType _ ▸ lt_succ o)⟩
Full source
theorem le_enum_succ {o : Ordinal} (a : (succ o).toType) :
    a ≤ enum (α := (succ o).toType) (· < ·) ⟨o, (type_toType _ ▸ lt_succ o)⟩ := by
  rw [← enum_typein (α := (succ o).toType) (· < ·) a, enum_le_enum', Subtype.mk_le_mk,
    ← lt_succ_iff]
  apply typein_lt_self
Successor Ordinal Enumeration Yields Upper Bound: $a \leq \mathrm{enum}_<(o)$ for all $a \in (\mathrm{succ}\, o).\mathrm{toType}$
Informal description
For any ordinal $o$ and any element $a$ in the canonical type associated with the successor ordinal $\mathrm{succ}(o)$, $a$ is less than or equal to the element corresponding to $o$ in the enumeration of $\mathrm{succ}(o).\mathrm{toType}$ with respect to the standard well-order $<$. More precisely, if we enumerate the elements of $\mathrm{succ}(o).\mathrm{toType}$ via the well-order $<$, then the element at position $o$ (which exists because $o < \mathrm{succ}(o)$) is an upper bound for all elements in $\mathrm{succ}(o).\mathrm{toType}$.
Ordinal.univ definition
: Ordinal.{max (u + 1) v}
Full source
/-- `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. -/
@[pp_with_univ, nolint checkUnivs]
def univ : OrdinalOrdinal.{max (u + 1) v} :=
  lift.{v, u + 1} (typeLT Ordinal)
Universal ordinal (order type of all ordinals in a universe)
Informal description
The ordinal `univ.{u v}` is defined as the order type of the collection of all ordinals in the universe `Type u`, when viewed as a member of the larger universe `Ordinal.{v}` (where `u < v`). This ordinal is an inaccessible cardinal.
Ordinal.univ_id theorem
: univ.{u, u + 1} = typeLT Ordinal
Full source
theorem univ_id : univuniv.{u, u + 1} = typeLT Ordinal :=
  lift_id _
Universal Ordinal Identity: $\text{univ}_{u, u+1} = \text{type}(<)$ on $\text{Ordinal}_u$
Informal description
The universal ordinal `univ.{u, u + 1}` (the order type of all ordinals in universe `Type u` when viewed in the next universe `Ordinal.{u + 1}`) is equal to the order type of the strict less-than relation on the type of ordinals `Ordinal.{u}`.
Ordinal.lift_univ theorem
: lift.{w} univ.{u, v} = univ.{u, max v w}
Full source
@[simp]
theorem lift_univ : lift.{w} univuniv.{u, v} = univuniv.{u, max v w} :=
  lift_lift _
Lift of Universal Ordinal: $\text{lift}_w(\text{univ}_{u,v}) = \text{univ}_{u,\max(v,w)}$
Informal description
For any universes $u$, $v$, and $w$, lifting the universal ordinal $\text{univ}_{u,v}$ (the order type of all ordinals in universe $u$ when viewed in universe $v$) to universe $w$ yields the universal ordinal $\text{univ}_{u,\max(v,w)}$. That is, $\text{lift}_w(\text{univ}_{u,v}) = \text{univ}_{u,\max(v,w)}$.
Ordinal.univ_umax theorem
: univ.{u, max (u + 1) v} = univ.{u, v}
Full source
theorem univ_umax : univuniv.{u, max (u + 1) v} = univuniv.{u, v} :=
  congr_fun lift_umax _
Universal Ordinal Equality: $\text{univ}_{u, \max(u+1, v)} = \text{univ}_{u, v}$
Informal description
The universal ordinal `univ.{u, max (u + 1) v}` is equal to `univ.{u, v}`, where `univ.{u, v}` represents the order type of all ordinals in universe `Type u` when viewed in the larger universe `Ordinal.{v}`.
Ordinal.liftPrincipalSeg definition
: Ordinal.{u} <i Ordinal.{max (u + 1) v}
Full source
/-- Principal segment version of the lift operation on ordinals, embedding `Ordinal.{u}` in
`Ordinal.{v}` as a principal segment when `u < v`. -/
def liftPrincipalSeg : OrdinalOrdinal.{u}Ordinal.{u} <i Ordinal.{max (u + 1) v} :=
  ⟨↑liftInitialSeg.{max (u + 1) v, u}, univ.{u, v}, by
    refine fun b => inductionOn b ?_; intro β s _
    rw [univ, ← lift_umax]; constructor <;> intro h
    · obtain ⟨a, e⟩ := h
      rw [← e]
      refine inductionOn a ?_
      intro α r _
      exact lift_type_lt.{u, u + 1, max (u + 1) v}.2 ⟨typein r⟩
    · rw [← lift_id (type s)] at h ⊢
      obtain ⟨f⟩ := lift_type_lt.{_,_,v}.1 h
      obtain ⟨f, a, hf⟩ := f
      exists a
      revert hf
      -- Porting note: apply inductionOn does not work, refine does
      refine inductionOn a ?_
      intro α r _ hf
      refine lift_type_eq.{u, max (u + 1) v, max (u + 1) v}.2
        ⟨(RelIso.ofSurjective (RelEmbedding.ofMonotone ?_ ?_) ?_).symm⟩
      · exact fun b => enum r ⟨f b, (hf _).1 ⟨_, rfl⟩⟩
      · refine fun a b h => (typein_lt_typein r).1 ?_
        rw [typein_enum, typein_enum]
        exact f.map_rel_iff.2 h
      · intro a'
        obtain ⟨b, e⟩ := (hf _).2 (typein_lt_type _ a')
        exists b
        simp only [RelEmbedding.ofMonotone_coe]
        simp [e]⟩
Principal segment embedding for ordinal universe lift
Informal description
The principal segment embedding `Ordinal.liftPrincipalSeg` lifts an ordinal from universe `u` to universe `max (u + 1) v` as a principal segment. Specifically, it embeds `Ordinal.{u}` into `Ordinal.{max (u + 1) v}` in such a way that the image is the set of all ordinals strictly below the universal ordinal `univ.{u, v}` in the target universe. This means that for any ordinal `α` in `Ordinal.{u}`, the lift `liftPrincipalSeg α` is an ordinal in `Ordinal.{max (u + 1) v}` that corresponds to `α` under this embedding, and the top element of this principal segment is the universal ordinal `univ.{u, v}`.
Ordinal.liftPrincipalSeg_coe theorem
: (liftPrincipalSeg.{u, v} : Ordinal → Ordinal) = lift.{max (u + 1) v}
Full source
@[simp]
theorem liftPrincipalSeg_coe :
    (liftPrincipalSegliftPrincipalSeg.{u, v} : OrdinalOrdinal) = liftlift.{max (u + 1) v} :=
  rfl
Equality of Principal Segment Embedding and Universe Lift for Ordinals
Informal description
The underlying function of the principal segment embedding `liftPrincipalSeg.{u, v}` from ordinals in universe `u` to ordinals in universe `max (u + 1) v` is equal to the universe lift function `lift.{max (u + 1) v}`.
Ordinal.liftPrincipalSeg_top theorem
: (liftPrincipalSeg.{u, v}).top = univ.{u, v}
Full source
@[simp]
theorem liftPrincipalSeg_top : (liftPrincipalSeg.{u, v}).top = univuniv.{u, v} :=
  rfl
Top Element of Principal Segment Embedding Equals Universal Ordinal
Informal description
For any universes `u` and `v`, the top element of the principal segment embedding `liftPrincipalSeg.{u, v}` is equal to the universal ordinal `univ.{u, v}` in the target universe `Ordinal.{max (u + 1) v}`.
Ordinal.liftPrincipalSeg_top' theorem
: liftPrincipalSeg.{u, u + 1}.top = typeLT Ordinal
Full source
theorem liftPrincipalSeg_top' : liftPrincipalSeg.{u, u + 1}.top = typeLT Ordinal := by
  simp only [liftPrincipalSeg_top, univ_id]
Top of Principal Segment Embedding Equals Order Type of Ordinals' Strict Order
Informal description
For any universe level $u$, the top element of the principal segment embedding `liftPrincipalSeg.{u, u + 1}` is equal to the order type of the strict less-than relation on the type of ordinals `Ordinal.{u}`.
Cardinal.mk_toType theorem
(o : Ordinal) : #o.toType = o.card
Full source
@[simp]
theorem mk_toType (o : Ordinal) : #o.toType = o.card :=
  (Ordinal.card_type _).symm.trans <| by rw [Ordinal.type_toType]
Cardinality of Canonical Type Equals Cardinality of Ordinal
Informal description
For any ordinal $o$, the cardinality of the canonical type associated with $o$ (via `Ordinal.toType`) is equal to the cardinality of $o$ itself, i.e., $\#(o.\text{toType}) = \text{card}(o)$.
Cardinal.ord definition
(c : Cardinal) : Ordinal
Full source
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
  whose cardinal is `c`. For the order-embedding version, see `ord.order_embedding`. -/
def ord (c : Cardinal) : Ordinal :=
  let F := fun α : Type u => ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2
  Quot.liftOn c F
    (by
      suffices ∀ {α β}, α ≈ β → F α ≤ F β from
        fun α β h => (this h).antisymm (this (Setoid.symm h))
      rintro α β ⟨f⟩
      refine le_ciInf_iff'.2 fun i => ?_
      haveI := @RelEmbedding.isWellOrder _ _ (f ⁻¹'o i.1) _ (↑(RelIso.preimage f i.1)) i.2
      exact
        (ciInf_le' _
              (Subtype.mk (f ⁻¹'o i.val)
                (@RelEmbedding.isWellOrder _ _ _ _ (↑(RelIso.preimage f i.1)) i.2))).trans_eq
          (Quot.sound ⟨RelIso.preimage f i.1⟩))
Smallest ordinal with given cardinality
Informal description
Given a cardinal number \( c \), the ordinal \( \mathrm{ord}(c) \) is defined as the smallest ordinal whose cardinality is \( c \). More precisely, for a type \( \alpha \) representing the cardinal \( c \), \( \mathrm{ord}(c) \) is the infimum of the order types of all well-orders on \( \alpha \).
Cardinal.ord_eq_Inf theorem
(α : Type u) : ord #α = ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2
Full source
theorem ord_eq_Inf (α : Type u) : ord  = ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2 :=
  rfl
$\mathrm{ord}(\#\alpha)$ as Infimum of Well-Order Types on $\alpha$
Informal description
For any type $\alpha$, the smallest ordinal $\mathrm{ord}(\#\alpha)$ with cardinality equal to that of $\alpha$ is given by the infimum of the order types of all well-orders on $\alpha$. That is, \[ \mathrm{ord}(\#\alpha) = \inf \left\{ \mathrm{type}(r) \mid r \text{ is a well-order on } \alpha \right\}. \]
Cardinal.ord_eq theorem
(α) : ∃ (r : α → α → Prop) (wo : IsWellOrder α r), ord #α = @type α r wo
Full source
theorem ord_eq (α) : ∃ (r : α → α → Prop) (wo : IsWellOrder α r), ord #α = @type α r wo :=
  let ⟨r, wo⟩ := ciInf_mem fun r : { r // IsWellOrder α r } => @type α r.1 r.2
  ⟨r.1, r.2, wo.symm⟩
Existence of Well-Order Realizing Minimal Ordinal for Type's Cardinality
Informal description
For any type $\alpha$, there exists a well-order relation $r$ on $\alpha$ such that the smallest ordinal $\mathrm{ord}(\#\alpha)$ with the same cardinality as $\alpha$ is equal to the order type of $(\alpha, r)$. In other words, there exists a well-ordering of $\alpha$ whose order type realizes the minimal ordinal with cardinality $\#\alpha$.
Cardinal.ord_le_type theorem
(r : α → α → Prop) [h : IsWellOrder α r] : ord #α ≤ type r
Full source
theorem ord_le_type (r : α → α → Prop) [h : IsWellOrder α r] : ord type r :=
  ciInf_le' _ (Subtype.mk r h)
Ordinal Bound: $\mathrm{ord}(\#\alpha) \leq \mathrm{type}(r)$ for Well-Orders
Informal description
For any well-order relation $r$ on a type $\alpha$, the ordinal $\mathrm{ord}(\#\alpha)$ (the smallest ordinal with the same cardinality as $\alpha$) is less than or equal to the order type of $(\alpha, r)$, denoted $\mathrm{type}(r)$.
Cardinal.ord_le theorem
{c o} : ord c ≤ o ↔ c ≤ o.card
Full source
theorem ord_le {c o} : ordord c ≤ o ↔ c ≤ o.card :=
  inductionOn c fun α =>
    Ordinal.inductionOn o fun β s _ => by
      let ⟨r, _, e⟩ := ord_eq α
      simp only [card_type]; constructor <;> intro h
      · rw [e] at h
        exact
          let ⟨f⟩ := h
          ⟨f.toEmbedding⟩
      · obtain ⟨f⟩ := h
        have g := RelEmbedding.preimage f s
        haveI := RelEmbedding.isWellOrder g
        exact le_trans (ord_le_type _) g.ordinal_type_le
Ordinal-Cardinal Inequality: $\mathrm{ord}(c) \leq o \leftrightarrow c \leq \mathrm{card}(o)$
Informal description
For any cardinal number $c$ and any ordinal $o$, the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$ satisfies $\mathrm{ord}(c) \leq o$ if and only if $c \leq \mathrm{card}(o)$, where $\mathrm{card}(o)$ denotes the cardinality of $o$.
Cardinal.gc_ord_card theorem
: GaloisConnection ord card
Full source
theorem gc_ord_card : GaloisConnection ord card := fun _ _ => ord_le
Galois Connection Between Ordinals and Cardinals: $\mathrm{ord} \dashv \mathrm{card}$
Informal description
The functions $\mathrm{ord}$ (from cardinals to ordinals) and $\mathrm{card}$ (from ordinals to cardinals) form a Galois connection. That is, for any cardinal $c$ and ordinal $o$, we have $\mathrm{ord}(c) \leq o$ if and only if $c \leq \mathrm{card}(o)$.
Cardinal.lt_ord theorem
{c o} : o < ord c ↔ o.card < c
Full source
theorem lt_ord {c o} : o < ord c ↔ o.card < c :=
  gc_ord_card.lt_iff_lt
Inequality Relating Ordinals and Cardinals: $o < \mathrm{ord}(c) \leftrightarrow \mathrm{card}(o) < c$
Informal description
For any cardinal number $c$ and any ordinal $o$, the ordinal $o$ is strictly less than the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$ if and only if the cardinality of $o$ is strictly less than $c$. In symbols: $$ o < \mathrm{ord}(c) \leftrightarrow \mathrm{card}(o) < c. $$
Cardinal.card_ord theorem
(c) : (ord c).card = c
Full source
@[simp]
theorem card_ord (c) : (ord c).card = c :=
  c.inductionOn fun α ↦ let ⟨r, _, e⟩ := ord_eq α; e ▸ card_type r
Cardinality of Minimal Ordinal: $\mathrm{card}(\mathrm{ord}(c)) = c$
Informal description
For any cardinal number $c$, the cardinality of the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$ is equal to $c$ itself, i.e., $\mathrm{card}(\mathrm{ord}(c)) = c$.
Cardinal.card_surjective theorem
: Function.Surjective card
Full source
theorem card_surjective : Function.Surjective card :=
  fun c ↦ ⟨_, card_ord c⟩
Surjectivity of the Ordinal-to-Cardinal Mapping
Informal description
The cardinality function $\mathrm{card} : \mathrm{Ordinal} \to \mathrm{Cardinal}$ is surjective. That is, for every cardinal number $c$, there exists an ordinal $o$ such that $\mathrm{card}(o) = c$.
Cardinal.gciOrdCard definition
: GaloisCoinsertion ord card
Full source
/-- Galois coinsertion between `Cardinal.ord` and `Ordinal.card`. -/
def gciOrdCard : GaloisCoinsertion ord card :=
  gc_ord_card.toGaloisCoinsertion fun c => c.card_ord.le
Galois coinsertion between ordinals and cardinals: $\mathrm{ord} \dashv \mathrm{card}$
Informal description
The functions $\mathrm{ord}$ (from cardinals to ordinals) and $\mathrm{card}$ (from ordinals to cardinals) form a Galois coinsertion. That is, for any cardinal $c$ and ordinal $o$, we have $\mathrm{ord}(c) \leq o$ if and only if $c \leq \mathrm{card}(o)$, and moreover $\mathrm{card}(\mathrm{ord}(c)) = c$ for every cardinal $c$.
Cardinal.ord_card_le theorem
(o : Ordinal) : o.card.ord ≤ o
Full source
theorem ord_card_le (o : Ordinal) : o.card.ord ≤ o :=
  gc_ord_card.l_u_le _
$\mathrm{ord}(\mathrm{card}(o)) \leq o$ for all ordinals $o$
Informal description
For any ordinal $o$, the ordinal corresponding to the cardinality of $o$ is less than or equal to $o$ itself, i.e., $\mathrm{ord}(\mathrm{card}(o)) \leq o$.
Cardinal.lt_ord_succ_card theorem
(o : Ordinal) : o < (succ o.card).ord
Full source
theorem lt_ord_succ_card (o : Ordinal) : o < (succ o.card).ord :=
  lt_ord.2 <| lt_succ _
Ordinal is strictly less than the ordinal of its cardinal successor: $o < \mathrm{ord}(\mathrm{succ}(\mathrm{card}(o)))$
Informal description
For any ordinal $o$, the ordinal $o$ is strictly less than the smallest ordinal with cardinality equal to the successor of the cardinality of $o$. In symbols: $$ o < \mathrm{ord}(\mathrm{succ}(\mathrm{card}(o))). $$
Cardinal.card_le_iff theorem
{o : Ordinal} {c : Cardinal} : o.card ≤ c ↔ o < (succ c).ord
Full source
theorem card_le_iff {o : Ordinal} {c : Cardinal} : o.card ≤ c ↔ o < (succ c).ord := by
  rw [lt_ord, lt_succ_iff]
Cardinality Bound Characterization: $\text{card}(o) \leq c \leftrightarrow o < \text{ord}(\text{succ}(c))$
Informal description
For any ordinal $o$ and cardinal $c$, the cardinality of $o$ is less than or equal to $c$ if and only if $o$ is strictly less than the smallest ordinal with cardinality $\text{succ}(c)$. In symbols: $$\text{card}(o) \leq c \leftrightarrow o < \text{ord}(\text{succ}(c)).$$
Cardinal.card_le_of_le_ord theorem
{o : Ordinal} {c : Cardinal} (ho : o ≤ c.ord) : o.card ≤ c
Full source
/--
A variation on `Cardinal.lt_ord` using `≤`: If `o` is no greater than the
initial ordinal of cardinality `c`, then its cardinal is no greater than `c`.

The converse, however, is false (for instance, `o = ω+1` and `c = ℵ₀`).
-/
lemma card_le_of_le_ord {o : Ordinal} {c : Cardinal} (ho : o ≤ c.ord) :
    o.card ≤ c := by
  rw [← card_ord c]; exact Ordinal.card_le_card ho
Cardinality Bound from Ordinal Comparison: $\mathrm{card}(o) \leq c$ when $o \leq \mathrm{ord}(c)$
Informal description
For any ordinal $o$ and cardinal $c$, if $o$ is less than or equal to the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$, then the cardinality of $o$ is less than or equal to $c$, i.e., $\mathrm{card}(o) \leq c$.
Cardinal.ord_strictMono theorem
: StrictMono ord
Full source
@[mono]
theorem ord_strictMono : StrictMono ord :=
  gciOrdCard.strictMono_l
Strict Monotonicity of Ordinal Construction from Cardinals: $c_1 < c_2 \Rightarrow \mathrm{ord}(c_1) < \mathrm{ord}(c_2)$
Informal description
The function $\mathrm{ord}$ from cardinals to ordinals is strictly monotone. That is, for any two cardinals $c_1$ and $c_2$, if $c_1 < c_2$, then $\mathrm{ord}(c_1) < \mathrm{ord}(c_2)$.
Cardinal.ord_mono theorem
: Monotone ord
Full source
@[mono]
theorem ord_mono : Monotone ord :=
  gc_ord_card.monotone_l
Monotonicity of the Ordinal Construction from Cardinals: $c_1 \leq c_2 \Rightarrow \mathrm{ord}(c_1) \leq \mathrm{ord}(c_2)$
Informal description
The function $\mathrm{ord}$ from cardinals to ordinals is monotone. That is, for any two cardinals $c_1$ and $c_2$, if $c_1 \leq c_2$, then $\mathrm{ord}(c_1) \leq \mathrm{ord}(c_2)$.
Cardinal.ord_le_ord theorem
{c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂
Full source
@[simp]
theorem ord_le_ord {c₁ c₂} : ordord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
  gciOrdCard.l_le_l_iff
Ordinal Comparison via Cardinal Comparison: $\mathrm{ord}(c_1) \leq \mathrm{ord}(c_2) \leftrightarrow c_1 \leq c_2$
Informal description
For any two cardinal numbers $c_1$ and $c_2$, the ordinal $\mathrm{ord}(c_1)$ is less than or equal to $\mathrm{ord}(c_2)$ if and only if $c_1$ is less than or equal to $c_2$.
Cardinal.ord_lt_ord theorem
{c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂
Full source
@[simp]
theorem ord_lt_ord {c₁ c₂} : ordord c₁ < ord c₂ ↔ c₁ < c₂ :=
  ord_strictMono.lt_iff_lt
Strict Monotonicity of Ordinal Construction: $\mathrm{ord}(c_1) < \mathrm{ord}(c_2) \leftrightarrow c_1 < c_2$
Informal description
For any two cardinal numbers $c_1$ and $c_2$, the ordinal $\mathrm{ord}(c_1)$ is strictly less than $\mathrm{ord}(c_2)$ if and only if $c_1$ is strictly less than $c_2$.
Cardinal.ord_zero theorem
: ord 0 = 0
Full source
@[simp]
theorem ord_zero : ord 0 = 0 :=
  gc_ord_card.l_bot
$\mathrm{ord}(0) = 0$ (Zero Cardinal Maps to Zero Ordinal)
Informal description
The smallest ordinal with cardinality zero is the zero ordinal, i.e., $\mathrm{ord}(0) = 0$.
Cardinal.ord_one theorem
: ord 1 = 1
Full source
@[simp]
theorem ord_one : ord 1 = 1 := by simpa using ord_nat 1
Ordinal-Cardinal Correspondence for One: $\mathrm{ord}(1) = 1$
Informal description
The smallest ordinal with cardinality $1$ is the ordinal $1$, i.e., $\mathrm{ord}(1) = 1$.
Cardinal.ord_ofNat theorem
(n : ℕ) [n.AtLeastTwo] : ord ofNat(n) = OfNat.ofNat n
Full source
@[simp]
theorem ord_ofNat (n : ) [n.AtLeastTwo] : ord ofNat(n) = OfNat.ofNat n :=
  ord_nat n
Ordinal-Cardinal Correspondence for Numerals ≥ 2: $\mathrm{ord}(n) = n$
Informal description
For any natural number $n \geq 2$, the smallest ordinal with cardinality $n$ is equal to the ordinal representation of $n$, i.e., $\mathrm{ord}(n) = n$.
Cardinal.ord_aleph0 theorem
: ord.{u} ℵ₀ = ω
Full source
@[simp]
theorem ord_aleph0 : ord.{u} ℵ₀ = ω :=
  le_antisymm (ord_le.2 le_rfl) <|
    le_of_forall_lt fun o h => by
      rcases Ordinal.lt_lift_iff.1 h with ⟨o, h', rfl⟩
      rw [lt_ord, ← lift_card, lift_lt_aleph0, ← typein_enum (· < ·) h']
      exact lt_aleph0_iff_fintype.2 ⟨Set.fintypeLTNat _⟩
$\mathrm{ord}(\aleph_0) = \omega$ (First Infinite Ordinal as Minimal Ordinal for $\aleph_0$)
Informal description
The smallest ordinal with cardinality $\aleph_0$ is equal to the first infinite ordinal $\omega$.
Cardinal.lift_ord theorem
(c) : Ordinal.lift.{u, v} (ord c) = ord (lift.{u, v} c)
Full source
@[simp]
theorem lift_ord (c) : Ordinal.lift.{u,v} (ord c) = ord (lift.{u,v} c) := by
  refine le_antisymm (le_of_forall_lt fun a ha => ?_) ?_
  · rcases Ordinal.lt_lift_iff.1 ha with ⟨a, _, rfl⟩
    rwa [lt_ord, ← lift_card, lift_lt, ← lt_ord, ← Ordinal.lift_lt]
  · rw [ord_le, ← lift_card, card_ord]
Lift Commutes with Ordinal Assignment: $\mathrm{lift}(\mathrm{ord}(c)) = \mathrm{ord}(\mathrm{lift}(c))$
Informal description
For any cardinal number $c$, the lift of the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$ is equal to the smallest ordinal with cardinality equal to the lift of $c$. In symbols: $$\mathrm{lift}_{u,v}(\mathrm{ord}(c)) = \mathrm{ord}(\mathrm{lift}_{u,v}(c)).$$
Cardinal.mk_ord_toType theorem
(c : Cardinal) : #c.ord.toType = c
Full source
theorem mk_ord_toType (c : Cardinal) : #c.ord.toType = c := by simp
Cardinality of Canonical Type for Minimal Ordinal: $\#(\mathrm{ord}(c).\mathrm{toType}) = c$
Informal description
For any cardinal number $c$, the cardinality of the canonical type associated with the smallest ordinal $\mathrm{ord}(c)$ of cardinality $c$ is equal to $c$, i.e., $\#(\mathrm{ord}(c).\mathrm{toType}) = c$.
Cardinal.card_typein_lt theorem
(r : α → α → Prop) [IsWellOrder α r] (x : α) (h : ord #α = type r) : card (typein r x) < #α
Full source
theorem card_typein_lt (r : α → α → Prop) [IsWellOrder α r] (x : α) (h : ord  = type r) :
    card (typein r x) <  := by
  rw [← lt_ord, h]
  apply typein_lt_type
Cardinality of Initial Segment Ordinal is Less Than Type Cardinality
Informal description
Let $r$ be a well-order relation on a type $\alpha$, and let $x \in \alpha$. If the smallest ordinal $\mathrm{ord}(\#\alpha)$ with cardinality $\#\alpha$ is equal to the order type of $r$ (i.e., $\mathrm{ord}(\#\alpha) = \mathrm{type}(r)$), then the cardinality of the initial segment ordinal $\mathrm{typein}(r, x)$ is strictly less than $\#\alpha$. In symbols: $$ \mathrm{card}(\mathrm{typein}(r, x)) < \#\alpha. $$
Cardinal.card_typein_toType_lt theorem
(c : Cardinal) (x : c.ord.toType) : card (typein (α := c.ord.toType) (· < ·) x) < c
Full source
theorem card_typein_toType_lt (c : Cardinal) (x : c.ord.toType) :
    card (typein (α := c.ord.toType) (· < ·) x) < c := by
  rw [← lt_ord]
  apply typein_lt_self
Cardinality of Initial Segment in Canonical Type is Less Than Cardinal
Informal description
For any cardinal number $c$ and any element $x$ in the canonical type associated with the smallest ordinal $\mathrm{ord}(c)$ of cardinality $c$, the cardinality of the initial segment of $\mathrm{ord}(c).\mathrm{toType}$ below $x$ is strictly less than $c$. In symbols: $$ \mathrm{card}(\mathrm{typein}(\cdot < \cdot, x)) < c. $$
Cardinal.mk_Iio_ord_toType theorem
{c : Cardinal} (i : c.ord.toType) : #(Iio i) < c
Full source
theorem mk_Iio_ord_toType {c : Cardinal} (i : c.ord.toType) : #(Iio i) < c :=
  card_typein_toType_lt c i
Cardinality of Initial Segment in Canonical Type is Less Than Cardinal
Informal description
For any cardinal number $c$ and any element $i$ in the canonical type associated with the smallest ordinal $\mathrm{ord}(c)$ of cardinality $c$, the cardinality of the set $\{x \mid x < i\}$ is strictly less than $c$. In symbols: $$ \#\{x \mid x < i\} < c. $$
Cardinal.ord_injective theorem
: Injective ord
Full source
theorem ord_injective : Injective ord := by
  intro c c' h
  rw [← card_ord c, ← card_ord c', h]
Injectivity of the Ordinal Construction from Cardinals
Informal description
The function $\mathrm{ord} : \mathrm{Cardinal} \to \mathrm{Ordinal}$, which maps each cardinal to the smallest ordinal with that cardinality, is injective. In other words, if $\mathrm{ord}(a) = \mathrm{ord}(b)$ for two cardinals $a$ and $b$, then $a = b$.
Cardinal.ord_inj theorem
{a b : Cardinal} : a.ord = b.ord ↔ a = b
Full source
@[simp]
theorem ord_inj {a b : Cardinal} : a.ord = b.ord ↔ a = b :=
  ord_injective.eq_iff
Equality of Cardinals via Their Smallest Ordinals
Informal description
For any two cardinal numbers $a$ and $b$, the smallest ordinals with these cardinalities are equal if and only if the cardinals themselves are equal, i.e., $\mathrm{ord}(a) = \mathrm{ord}(b) \leftrightarrow a = b$.
Cardinal.ord_eq_zero theorem
{a : Cardinal} : a.ord = 0 ↔ a = 0
Full source
@[simp]
theorem ord_eq_zero {a : Cardinal} : a.ord = 0 ↔ a = 0 :=
  ord_injective.eq_iff' ord_zero
$\mathrm{ord}(a) = 0 \leftrightarrow a = 0$ (Zero Cardinal and Zero Ordinal Correspondence)
Informal description
For any cardinal number $a$, the smallest ordinal with cardinality $a$ is equal to the zero ordinal if and only if $a$ is equal to the zero cardinal, i.e., $\mathrm{ord}(a) = 0 \leftrightarrow a = 0$.
Cardinal.ord_eq_one theorem
{a : Cardinal} : a.ord = 1 ↔ a = 1
Full source
@[simp]
theorem ord_eq_one {a : Cardinal} : a.ord = 1 ↔ a = 1 :=
  ord_injective.eq_iff' ord_one
Ordinal-Cardinal Correspondence for One: $\mathrm{ord}(a) = 1 \leftrightarrow a = 1$
Informal description
For any cardinal number $a$, the smallest ordinal with cardinality $a$ is equal to the ordinal $1$ if and only if $a$ is equal to the cardinal $1$, i.e., $\mathrm{ord}(a) = 1 \leftrightarrow a = 1$.
Cardinal.omega0_le_ord theorem
{a : Cardinal} : ω ≤ a.ord ↔ ℵ₀ ≤ a
Full source
@[simp]
theorem omega0_le_ord {a : Cardinal} : ωω ≤ a.ord ↔ ℵ₀ ≤ a := by
  rw [← ord_aleph0, ord_le_ord]
$\omega \leq \mathrm{ord}(a) \leftrightarrow \aleph_0 \leq a$
Informal description
For any cardinal number $a$, the first infinite ordinal $\omega$ is less than or equal to the smallest ordinal with cardinality $a$ if and only if the first infinite cardinal $\aleph_0$ is less than or equal to $a$.
Cardinal.ord_le_omega0 theorem
{a : Cardinal} : a.ord ≤ ω ↔ a ≤ ℵ₀
Full source
@[simp]
theorem ord_le_omega0 {a : Cardinal} : a.ord ≤ ω ↔ a ≤ ℵ₀ := by
  rw [← ord_aleph0, ord_le_ord]
$\mathrm{ord}(a) \leq \omega \leftrightarrow a \leq \aleph_0$ (Ordinal-Cardinal Comparison for $\omega$ and $\aleph_0$)
Informal description
For any cardinal number $a$, the smallest ordinal $\mathrm{ord}(a)$ with cardinality $a$ satisfies $\mathrm{ord}(a) \leq \omega$ if and only if $a \leq \aleph_0$, where $\omega$ is the first infinite ordinal and $\aleph_0$ is the smallest infinite cardinal.
Cardinal.ord_lt_omega0 theorem
{a : Cardinal} : a.ord < ω ↔ a < ℵ₀
Full source
@[simp]
theorem ord_lt_omega0 {a : Cardinal} : a.ord < ω ↔ a < ℵ₀ :=
  le_iff_le_iff_lt_iff_lt.1 omega0_le_ord
$\mathrm{ord}(a) < \omega \leftrightarrow a < \aleph_0$ (Strict comparison of ordinals and cardinals at $\omega$ and $\aleph_0$)
Informal description
For any cardinal number $a$, the smallest ordinal $\mathrm{ord}(a)$ with cardinality $a$ satisfies $\mathrm{ord}(a) < \omega$ if and only if $a < \aleph_0$, where $\omega$ is the first infinite ordinal and $\aleph_0$ is the smallest infinite cardinal.
Cardinal.omega0_lt_ord theorem
{a : Cardinal} : ω < a.ord ↔ ℵ₀ < a
Full source
@[simp]
theorem omega0_lt_ord {a : Cardinal} : ωω < a.ord ↔ ℵ₀ < a :=
  le_iff_le_iff_lt_iff_lt.1 ord_le_omega0
$\omega < \mathrm{ord}(a) \leftrightarrow \aleph_0 < a$ (Strict comparison between $\omega$ and $\mathrm{ord}(a)$)
Informal description
For any cardinal number $a$, the smallest ordinal $\mathrm{ord}(a)$ with cardinality $a$ satisfies $\omega < \mathrm{ord}(a)$ if and only if $\aleph_0 < a$, where $\omega$ is the first infinite ordinal and $\aleph_0$ is the smallest infinite cardinal.
Cardinal.ord_eq_omega0 theorem
{a : Cardinal} : a.ord = ω ↔ a = ℵ₀
Full source
@[simp]
theorem ord_eq_omega0 {a : Cardinal} : a.ord = ω ↔ a = ℵ₀ :=
  ord_injective.eq_iff' ord_aleph0
$\mathrm{ord}(a) = \omega \leftrightarrow a = \aleph_0$ (Characterization of $\aleph_0$ via smallest ordinal)
Informal description
For any cardinal number $a$, the smallest ordinal with cardinality $a$ is equal to the first infinite ordinal $\omega$ if and only if $a$ is equal to $\aleph_0$.
Cardinal.ord.orderEmbedding definition
: Cardinal ↪o Ordinal
Full source
/-- 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`.
-/
def ord.orderEmbedding : CardinalCardinal ↪o Ordinal :=
  RelEmbedding.orderEmbeddingOfLTEmbedding
    (RelEmbedding.ofMonotone Cardinal.ord fun _ _ => Cardinal.ord_lt_ord.2)
Order embedding from cardinals to ordinals via smallest ordinals
Informal description
The function `Cardinal.ord.orderEmbedding` is an order embedding from the type of cardinal numbers to the type of ordinals, where each cardinal \( c \) is mapped to the smallest ordinal \( \mathrm{ord}(c) \) whose cardinality is \( c \). This embedding preserves the order relation, meaning that for any two cardinals \( c_1 \) and \( c_2 \), we have \( c_1 \leq c_2 \) if and only if \( \mathrm{ord}(c_1) \leq \mathrm{ord}(c_2) \).
Cardinal.ord.orderEmbedding_coe theorem
: (ord.orderEmbedding : Cardinal → Ordinal) = ord
Full source
@[simp]
theorem ord.orderEmbedding_coe : (ord.orderEmbedding : CardinalOrdinal) = ord :=
  rfl
Order embedding from cardinals to ordinals coincides with the ord function
Informal description
The underlying function of the order embedding from cardinals to ordinals, which maps each cardinal $c$ to the smallest ordinal $\mathrm{ord}(c)$ with cardinality $c$, is equal to the function $\mathrm{ord}$ itself.
Cardinal.univ definition
Full source
/-- 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`). -/
@[pp_with_univ, nolint checkUnivs]
def univ :=
  lift.{v, u + 1} #Ordinal
Universe-lifted cardinality of ordinals
Informal description
The cardinal `univ` is defined as the lift of the cardinality of the type of ordinals `Ordinal.{u}` to a higher universe `Type (max u v)`. In other words, it represents the size of the collection of all ordinals in universe `Type u`, but considered as an element of a larger universe `Type v` (where `u < v`).
Cardinal.univ_id theorem
: univ.{u, u + 1} = #Ordinal
Full source
theorem univ_id : univuniv.{u, u + 1} = #Ordinal :=
  lift_id _
Universe-Lifted Cardinality of Ordinals Equals Cardinality of Ordinals Type
Informal description
For any universe level $u$, the universe-lifted cardinality of ordinals `univ.{u, u+1}` is equal to the cardinality of the type of ordinals `Ordinal.{u}`, i.e., $\text{univ}_{u, u+1} = \#\text{Ordinal}$.
Cardinal.lift_univ theorem
: lift.{w} univ.{u, v} = univ.{u, max v w}
Full source
@[simp]
theorem lift_univ : lift.{w} univuniv.{u, v} = univuniv.{u, max v w} :=
  lift_lift _
Lift of Universe Cardinality: $\text{lift}_w(\text{univ}_{u,v}) = \text{univ}_{u,\max(v,w)}$
Informal description
For any universe levels $u$, $v$, and $w$, the lift of the universe-lifted cardinality of ordinals `univ.{u, v}` to universe level $w$ equals the universe-lifted cardinality of ordinals in the maximum universe level $\max(v, w)$. That is, $\text{lift}_w(\text{univ}_{u,v}) = \text{univ}_{u,\max(v,w)}$.
Cardinal.univ_umax theorem
: univ.{u, max (u + 1) v} = univ.{u, v}
Full source
theorem univ_umax : univuniv.{u, max (u + 1) v} = univuniv.{u, v} :=
  congr_fun lift_umax _
Universality of Ordinal Cardinality under Maximal Universe Lift
Informal description
For any universe levels $u$ and $v$, the universe-lifted cardinality of ordinals satisfies $\text{univ}_{u, \max(u+1, v)} = \text{univ}_{u, v}$.
Cardinal.lift_lt_univ theorem
(c : Cardinal) : lift.{u + 1, u} c < univ.{u, u + 1}
Full source
theorem lift_lt_univ (c : Cardinal) : lift.{u + 1, u} c < univuniv.{u, u + 1} := by
  simpa only [liftPrincipalSeg_coe, lift_ord, lift_succ, ord_le, succ_le_iff] using
    le_of_lt (liftPrincipalSeg.{u, u + 1}.lt_top (succ c).ord)
Lifted Cardinal is Less Than Universe Cardinal: $\text{lift}(c) < \text{univ}$
Informal description
For any cardinal number $c$ in universe level $u$, the lift of $c$ to universe level $u+1$ is strictly less than the cardinality of the type of ordinals in universe level $u$ lifted to universe level $u+1$. In symbols: $$\text{lift}_{u+1,u}(c) < \text{univ}_{u,u+1}.$$
Cardinal.lift_lt_univ' theorem
(c : Cardinal) : lift.{max (u + 1) v, u} c < univ.{u, v}
Full source
theorem lift_lt_univ' (c : Cardinal) : lift.{max (u + 1) v, u} c < univuniv.{u, v} := by
  have := lift_lt.{_, max (u+1) v}.2 (lift_lt_univ c)
  rw [lift_lift, lift_univ, univ_umaxuniv_umax.{u,v}] at this
  exact this
Lifted Cardinal is Less Than Universe Cardinal in Higher Universe: $\text{lift}_{\max(u+1,v)}(c) < \text{univ}_v$
Informal description
For any cardinal number $c$ in universe level $u$, the lift of $c$ to universe level $\max(u+1, v)$ is strictly less than the cardinality of the type of ordinals in universe level $u$ lifted to universe level $v$. In symbols: $$\text{lift}_{\max(u+1,v),u}(c) < \text{univ}_{u,v}.$$
Cardinal.ord_univ theorem
: ord univ.{u, v} = Ordinal.univ.{u, v}
Full source
@[simp]
theorem ord_univ : ord univuniv.{u, v} = Ordinal.univOrdinal.univ.{u, v} := by
  refine le_antisymm (ord_card_le _) <| le_of_forall_lt fun o h => lt_ord.2 ?_
  have := liftPrincipalSeg.mem_range_of_rel_top (by simpa only [liftPrincipalSeg_coe] using h)
  rcases this with ⟨o, h'⟩
  rw [← h', liftPrincipalSeg_coe, ← lift_card]
  apply lift_lt_univ'
Equality of the smallest ordinal with universe cardinality and the universal ordinal: $\mathrm{ord}(\mathrm{univ}) = \mathrm{Ordinal.univ}$
Informal description
The smallest ordinal with the same cardinality as the universe-lifted cardinality of all ordinals in universe `u` (lifted to universe `v`) is equal to the universal ordinal `Ordinal.univ.{u, v}`. In symbols: $$\mathrm{ord}(\mathrm{univ}_{u,v}) = \mathrm{Ordinal.univ}_{u,v}.$$
Cardinal.lt_univ theorem
{c} : c < univ.{u, u + 1} ↔ ∃ c', c = lift.{u + 1, u} c'
Full source
theorem lt_univ {c} : c < univ.{u, u + 1} ↔ ∃ c', c = lift.{u + 1, u} c' :=
  ⟨fun h => by
    have := ord_lt_ord.2 h
    rw [ord_univ] at this
    obtain ⟨o, e⟩ := liftPrincipalSeg.mem_range_of_rel_top (by simpa only [liftPrincipalSeg_top])
    have := card_ord c
    rw [← e, liftPrincipalSeg_coe, ← lift_card] at this
    exact ⟨_, this.symm⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ _⟩
Characterization of Cardinals Below Universe Cardinal: $c < \text{univ}_{u, u+1} \leftrightarrow \exists c', c = \text{lift}(c')$
Informal description
For any cardinal number $c$ in universe level $u$, the inequality $c < \text{univ}_{u, u+1}$ holds if and only if there exists a cardinal number $c'$ in universe level $u$ such that $c$ is equal to the lift of $c'$ to universe level $u+1$, i.e., $c = \text{lift}_{u+1, u}(c')$.
Cardinal.lt_univ' theorem
{c} : c < univ.{u, v} ↔ ∃ c', c = lift.{max (u + 1) v, u} c'
Full source
theorem lt_univ' {c} : c < univ.{u, v} ↔ ∃ c', c = lift.{max (u + 1) v, u} c' :=
  ⟨fun h => by
    let ⟨a, h', e⟩ := lt_lift_iff.1 h
    rw [← univ_id] at h'
    rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩
    exact ⟨c', by simp only [e.symm, lift_lift]⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ' _⟩
Characterization of Cardinals Below Universe Cardinal via Lifting: $c < \text{univ}_{u,v} \leftrightarrow \exists c', c = \text{lift}_{\max(u+1,v)}(c')$
Informal description
For any cardinal number $c$ in universe level $u$, the inequality $c < \text{univ}_{u,v}$ holds if and only if there exists a cardinal number $c'$ in universe level $u$ such that $c$ is equal to the lift of $c'$ to universe level $\max(u+1, v)$. In symbols: $$c < \text{univ}_{u,v} \leftrightarrow \exists c',\ c = \text{lift}_{\max(u+1,v),u}(c').$$
Cardinal.small_iff_lift_mk_lt_univ theorem
{α : Type u} : Small.{v} α ↔ Cardinal.lift.{v + 1, _} #α < univ.{v, max u (v + 1)}
Full source
theorem small_iff_lift_mk_lt_univ {α : Type u} :
    SmallSmall.{v} α ↔ Cardinal.lift.{v+1,_} #α < univ.{v, max u (v + 1)} := by
  rw [lt_univ']
  constructor
  · rintro ⟨β, e⟩
    exact ⟨#β, lift_mk_eq.{u, _, v + 1}.2 e⟩
  · rintro ⟨c, hc⟩
    exact ⟨⟨c.out, lift_mk_eq.{u, _, v + 1}.1 (hc.trans (congr rfl c.mk_out.symm))⟩⟩
Characterization of Small Types via Cardinality Comparison
Informal description
A type $\alpha$ in universe `Type u` is $v$-small (i.e., there exists a bijection between $\alpha$ and some type in `Type v$) if and only if the lifted cardinality of $\alpha$ to universe `Type (v + 1)` is strictly less than the universal cardinal `univ.{v, max u (v + 1)}`. In symbols: $$\text{Small}_v \alpha \leftrightarrow \text{lift}_{v+1} \#\alpha < \text{univ}_{v, \max(u, v+1)}.$$
Cardinal.toTypeOrderBot definition
{c : Cardinal} (hc : c ≠ 0) : OrderBot c.ord.toType
Full source
/-- If a cardinal `c` is non zero, then `c.ord.toType` has a least element. -/
noncomputable def toTypeOrderBot {c : Cardinal} (hc : c ≠ 0) :
    OrderBot c.ord.toType :=
  Ordinal.toTypeOrderBot (fun h ↦ hc (ord_injective (by simpa using h)))
Bottom element in the canonical type of a nonzero cardinal's ordinal
Informal description
For any nonzero cardinal number \( c \), the canonical type associated with the smallest ordinal \( \mathrm{ord}(c) \) (which has cardinality \( c \)) has a least element in its order structure.
Ordinal.card_univ theorem
: card univ.{u, v} = Cardinal.univ.{u, v}
Full source
@[simp]
theorem card_univ : card univuniv.{u,v} = Cardinal.univCardinal.univ.{u,v} :=
  rfl
Cardinality of the Universal Ordinal Equals the Universal Cardinal
Informal description
The cardinality of the universal ordinal `univ.{u, v}` (the order type of all ordinals in universe `Type u` when viewed in `Ordinal.{v}`) is equal to the universal cardinal `Cardinal.univ.{u, v}` (the cardinality of the type of all ordinals in `Type u` when lifted to `Type (max u v)`). In other words, $\text{card}(\text{univ}) = \text{univ}$.
Ordinal.nat_le_card theorem
{o} {n : ℕ} : (n : Cardinal) ≤ card o ↔ (n : Ordinal) ≤ o
Full source
@[simp]
theorem nat_le_card {o} {n : } : (n : Cardinal) ≤ card o ↔ (n : Ordinal) ≤ o := by
  rw [← Cardinal.ord_le, Cardinal.ord_nat]
Cardinal-Ordinal Inequality for Finite Numbers: $n \leq \text{card}(o) \leftrightarrow n \leq o$
Informal description
For any ordinal $o$ and any natural number $n$, the cardinality of $n$ is less than or equal to the cardinality of $o$ if and only if the ordinal $n$ is less than or equal to $o$. In other words, $(n : \text{Cardinal}) \leq \text{card}(o) \leftrightarrow (n : \text{Ordinal}) \leq o$.
Ordinal.one_le_card theorem
{o} : 1 ≤ card o ↔ 1 ≤ o
Full source
@[simp]
theorem one_le_card {o} : 1 ≤ card o ↔ 1 ≤ o := by
  simpa using nat_le_card (n := 1)
Cardinal-Ordinal Inequality for the Unit Ordinal: $1 \leq \mathrm{card}(o) \leftrightarrow 1 \leq o$
Informal description
For any ordinal $o$, the cardinality of $o$ is at least $1$ if and only if the ordinal $o$ itself is at least $1$. In other words, $1 \leq \mathrm{card}(o) \leftrightarrow 1 \leq o$.
Ordinal.ofNat_le_card theorem
{o} {n : ℕ} [n.AtLeastTwo] : (ofNat(n) : Cardinal) ≤ card o ↔ (OfNat.ofNat n : Ordinal) ≤ o
Full source
@[simp]
theorem ofNat_le_card {o} {n : } [n.AtLeastTwo] :
    (ofNat(n) : Cardinal) ≤ card o ↔ (OfNat.ofNat n : Ordinal) ≤ o :=
  nat_le_card
Cardinal-Ordinal Inequality for Numerals ≥ 2: $n \leq \text{card}(o) \leftrightarrow n \leq o$
Informal description
For any ordinal $o$ and any natural number $n \geq 2$, the cardinality of $n$ is less than or equal to the cardinality of $o$ if and only if the ordinal $n$ is less than or equal to $o$. In symbols: \[ (n : \text{Cardinal}) \leq \text{card}(o) \leftrightarrow (n : \text{Ordinal}) \leq o. \]
Ordinal.aleph0_le_card theorem
{o} : ℵ₀ ≤ card o ↔ ω ≤ o
Full source
@[simp]
theorem aleph0_le_card {o} : ℵ₀ℵ₀ ≤ card o ↔ ω ≤ o := by
  rw [← ord_le, ord_aleph0]
$\aleph_0 \leq \mathrm{card}(o) \leftrightarrow \omega \leq o$ (Cardinal-Ordinal Inequality for $\aleph_0$)
Informal description
For any ordinal $o$, the cardinality $\aleph_0$ is less than or equal to the cardinality of $o$ if and only if the first infinite ordinal $\omega$ is less than or equal to $o$. In symbols: \[ \aleph_0 \leq \mathrm{card}(o) \leftrightarrow \omega \leq o. \]
Ordinal.card_lt_aleph0 theorem
{o} : card o < ℵ₀ ↔ o < ω
Full source
@[simp]
theorem card_lt_aleph0 {o} : cardcard o < ℵ₀ ↔ o < ω :=
  le_iff_le_iff_lt_iff_lt.1 aleph0_le_card
Cardinal-Ordinal Inequality: $\mathrm{card}(o) < \aleph_0 \leftrightarrow o < \omega$
Informal description
For any ordinal $o$, the cardinality of $o$ is strictly less than $\aleph_0$ if and only if $o$ is strictly less than the first infinite ordinal $\omega$. In symbols: \[ \mathrm{card}(o) < \aleph_0 \leftrightarrow o < \omega. \]
Ordinal.nat_lt_card theorem
{o} {n : ℕ} : (n : Cardinal) < card o ↔ (n : Ordinal) < o
Full source
@[simp]
theorem nat_lt_card {o} {n : } : (n : Cardinal) < card o ↔ (n : Ordinal) < o := by
  rw [← succ_le_iff, ← succ_le_iff, ← nat_succ, nat_le_card]
  rfl
Cardinal-Ordinal Inequality for Finite Numbers: $(n : \text{Cardinal}) < \text{card}(o) \leftrightarrow n < o$
Informal description
For any ordinal $o$ and any natural number $n$, the cardinality of $n$ is strictly less than the cardinality of $o$ if and only if the ordinal $n$ is strictly less than $o$. In symbols: \[ (n : \text{Cardinal}) < \text{card}(o) \leftrightarrow (n : \text{Ordinal}) < o. \]
Ordinal.zero_lt_card theorem
{o} : 0 < card o ↔ 0 < o
Full source
@[simp]
theorem zero_lt_card {o} : 0 < card o ↔ 0 < o := by
  simpa using nat_lt_card (n := 0)
Cardinal-Ordinal Inequality for Zero: $0 < \text{card}(o) \leftrightarrow 0 < o$
Informal description
For any ordinal $o$, the cardinality of $o$ is strictly greater than $0$ if and only if $o$ is strictly greater than the zero ordinal. In symbols: \[ 0 < \text{card}(o) \leftrightarrow 0 < o. \]
Ordinal.one_lt_card theorem
{o} : 1 < card o ↔ 1 < o
Full source
@[simp]
theorem one_lt_card {o} : 1 < card o ↔ 1 < o := by
  simpa using nat_lt_card (n := 1)
Cardinal-Ordinal Inequality for the Unit Ordinal: $1 < \text{card}(o) \leftrightarrow 1 < o$
Informal description
For any ordinal $o$, the cardinality of $o$ is strictly greater than $1$ if and only if $o$ is strictly greater than $1$ (as an ordinal). In symbols: \[ 1 < \text{card}(o) \leftrightarrow 1 < o. \]
Ordinal.ofNat_lt_card theorem
{o} {n : ℕ} [n.AtLeastTwo] : (ofNat(n) : Cardinal) < card o ↔ (OfNat.ofNat n : Ordinal) < o
Full source
@[simp]
theorem ofNat_lt_card {o} {n : } [n.AtLeastTwo] :
    (ofNat(n) : Cardinal) < card o ↔ (OfNat.ofNat n : Ordinal) < o :=
  nat_lt_card
Cardinal-Ordinal Inequality for Numerals ≥ 2: $(n : \text{Cardinal}) < \text{card}(o) \leftrightarrow n < o$
Informal description
For any ordinal $o$ and any natural number $n \geq 2$, the cardinality of $n$ is strictly less than the cardinality of $o$ if and only if the ordinal $n$ is strictly less than $o$. In symbols: \[ (n : \text{Cardinal}) < \text{card}(o) \leftrightarrow n < o. \]
Ordinal.card_lt_nat theorem
{o} {n : ℕ} : card o < n ↔ o < n
Full source
@[simp]
theorem card_lt_nat {o} {n : } : cardcard o < n ↔ o < n :=
  lt_iff_lt_of_le_iff_le nat_le_card
Cardinal-Ordinal Strict Inequality for Finite Numbers: $\text{card}(o) < n \leftrightarrow o < n$
Informal description
For any ordinal $o$ and any natural number $n$, the cardinality of $o$ is strictly less than $n$ if and only if $o$ is strictly less than $n$ (as ordinals).
Ordinal.card_lt_ofNat theorem
{o} {n : ℕ} [n.AtLeastTwo] : card o < ofNat(n) ↔ o < OfNat.ofNat n
Full source
@[simp]
theorem card_lt_ofNat {o} {n : } [n.AtLeastTwo] :
    cardcard o < ofNat(n) ↔ o < OfNat.ofNat n :=
  card_lt_nat
Cardinal-Ordinal Inequality for Numerals ≥ 2: $\text{card}(o) < n \leftrightarrow o < n$
Informal description
For any ordinal $o$ and any natural number $n \geq 2$, the cardinality of $o$ is strictly less than $n$ (as a cardinal) if and only if $o$ is strictly less than $n$ (as an ordinal). In symbols: \[ \text{card}(o) < n \leftrightarrow o < n. \]
Ordinal.card_le_nat theorem
{o} {n : ℕ} : card o ≤ n ↔ o ≤ n
Full source
@[simp]
theorem card_le_nat {o} {n : } : cardcard o ≤ n ↔ o ≤ n :=
  le_iff_le_iff_lt_iff_lt.2 nat_lt_card
Cardinal-Ordinal Inequality for Finite Numbers: $\text{card}(o) \leq n \leftrightarrow o \leq n$
Informal description
For any ordinal $o$ and any natural number $n$, the cardinality of $o$ is less than or equal to $n$ if and only if $o$ is less than or equal to $n$ (as ordinals). In symbols: \[ \text{card}(o) \leq n \leftrightarrow o \leq n. \]
Ordinal.card_le_one theorem
{o} : card o ≤ 1 ↔ o ≤ 1
Full source
@[simp]
theorem card_le_one {o} : cardcard o ≤ 1 ↔ o ≤ 1 := by
  simpa using card_le_nat (n := 1)
Cardinal-Ordinal Inequality for the Unit Ordinal: $\text{card}(o) \leq 1 \leftrightarrow o \leq 1$
Informal description
For any ordinal $o$, the cardinality of $o$ is less than or equal to $1$ if and only if $o$ is less than or equal to the ordinal $1$. In symbols: \[ \text{card}(o) \leq 1 \leftrightarrow o \leq 1. \]
Ordinal.card_le_ofNat theorem
{o} {n : ℕ} [n.AtLeastTwo] : card o ≤ ofNat(n) ↔ o ≤ OfNat.ofNat n
Full source
@[simp]
theorem card_le_ofNat {o} {n : } [n.AtLeastTwo] :
    cardcard o ≤ ofNat(n) ↔ o ≤ OfNat.ofNat n :=
  card_le_nat
Cardinal-Ordinal Inequality for Natural Numbers ≥ 2: $\text{card}(o) \leq n \leftrightarrow o \leq n$
Informal description
For any ordinal $o$ and any natural number $n \geq 2$, the cardinality of $o$ is less than or equal to $n$ if and only if $o$ is less than or equal to $n$ (as ordinals). In symbols: \[ \text{card}(o) \leq n \leftrightarrow o \leq n. \]
Ordinal.card_eq_nat theorem
{o} {n : ℕ} : card o = n ↔ o = n
Full source
@[simp]
theorem card_eq_nat {o} {n : } : cardcard o = n ↔ o = n := by
  simp only [le_antisymm_iff, card_le_nat, nat_le_card]
Characterization of Finite Ordinals via Cardinality: $\text{card}(o) = n \leftrightarrow o = n$
Informal description
For any ordinal $o$ and natural number $n$, the cardinality of $o$ equals $n$ if and only if $o$ is equal to the ordinal corresponding to $n$.
Ordinal.card_eq_zero theorem
{o} : card o = 0 ↔ o = 0
Full source
@[simp]
theorem card_eq_zero {o} : cardcard o = 0 ↔ o = 0 := by
  simpa using card_eq_nat (n := 0)
Zero Cardinality Characterization of the Zero Ordinal: $\text{card}(o) = 0 \leftrightarrow o = 0$
Informal description
For any ordinal $o$, the cardinality of $o$ is zero if and only if $o$ is the zero ordinal.
Ordinal.card_eq_one theorem
{o} : card o = 1 ↔ o = 1
Full source
@[simp]
theorem card_eq_one {o} : cardcard o = 1 ↔ o = 1 := by
  simpa using card_eq_nat (n := 1)
Characterization of Ordinals with Cardinality One: $\text{card}(o) = 1 \leftrightarrow o = 1$
Informal description
For any ordinal $o$, the cardinality of $o$ is equal to $1$ if and only if $o$ is equal to the ordinal $1$.
Ordinal.mem_range_lift_of_card_le theorem
{a : Cardinal.{u}} {b : Ordinal.{max u v}} (h : card b ≤ Cardinal.lift.{v, u} a) : b ∈ Set.range lift.{v, u}
Full source
theorem mem_range_lift_of_card_le {a : CardinalCardinal.{u}} {b : OrdinalOrdinal.{max u v}}
    (h : card b ≤ Cardinal.lift.{v, u} a) : b ∈ Set.range lift.{v, u} := by
  rw [card_le_iff, ← lift_succ, ← lift_ord] at h
  exact mem_range_lift_of_le h.le
Range Inclusion of Lifted Ordinals under Cardinality Bound: $\text{card}(b) \leq \text{lift}(a) \implies b \in \text{range}(\text{lift})$
Informal description
For any cardinal number $a$ in universe $u$ and any ordinal $b$ in universe $\max(u, v)$, if the cardinality of $b$ is less than or equal to the lift of $a$ to universe $\max(u, v)$, then $b$ is in the range of the ordinal lifting function $\text{lift}_{v,u} \colon \text{Ordinal}_{u} \to \text{Ordinal}_{\max(u, v)}$.
Ordinal.card_eq_ofNat theorem
{o} {n : ℕ} [n.AtLeastTwo] : card o = ofNat(n) ↔ o = OfNat.ofNat n
Full source
@[simp]
theorem card_eq_ofNat {o} {n : } [n.AtLeastTwo] :
    cardcard o = ofNat(n) ↔ o = OfNat.ofNat n :=
  card_eq_nat
Characterization of Finite Ordinals via Cardinality: $\text{card}(o) = n \leftrightarrow o = n$ for $n \geq 2$
Informal description
For any ordinal $o$ and natural number $n \geq 2$, the cardinality of $o$ equals $n$ if and only if $o$ is equal to the ordinal corresponding to $n$.
Ordinal.type_fintype theorem
(r : α → α → Prop) [IsWellOrder α r] [Fintype α] : type r = Fintype.card α
Full source
@[simp]
theorem type_fintype (r : α → α → Prop) [IsWellOrder α r] [Fintype α] :
    type r = Fintype.card α := by rw [← card_eq_nat, card_type, mk_fintype]
Order Type of Finite Well-Ordered Set Equals Its Cardinality
Informal description
For any finite type $\alpha$ equipped with a well-order relation $r$, the order type of $(\alpha, r)$ is equal to the cardinality of $\alpha$ (i.e., the number of elements in $\alpha$). In other words, if $\alpha$ is a finite set with $n$ elements and $r$ is a well-ordering on $\alpha$, then the ordinal representing the order type of $(\alpha, r)$ is exactly $n$.
Ordinal.type_fin theorem
(n : ℕ) : typeLT (Fin n) = n
Full source
theorem type_fin (n : ) : typeLT (Fin n) = n := by simp
Order Type of $\mathrm{Fin}\,n$ Equals $n$
Informal description
For any natural number $n$, the order type of the finite set $\mathrm{Fin}\,n$ (natural numbers less than $n$) equipped with the standard strict order $<$ is equal to $n$ as an ordinal.
List.Sorted.lt_ord_of_lt theorem
[LinearOrder α] [WellFoundedLT α] {l m : List α} {o : Ordinal} (hl : l.Sorted (· > ·)) (hm : m.Sorted (· > ·)) (hmltl : m < l) (hlt : ∀ i ∈ l, Ordinal.typein (α := α) (· < ·) i < o) : ∀ i ∈ m, Ordinal.typein (α := α) (· < ·) i < o
Full source
theorem List.Sorted.lt_ord_of_lt [LinearOrder α] [WellFoundedLT α] {l m : List α}
    {o : Ordinal} (hl : l.Sorted (· > ·)) (hm : m.Sorted (· > ·)) (hmltl : m < l)
    (hlt : ∀ i ∈ l, Ordinal.typein (α := α) (· < ·) i < o) :
      ∀ i ∈ m, Ordinal.typein (α := α) (· < ·) i < o := by
  replace hmltl : List.Lex (· < ·) m l := hmltl
  cases l with
  | nil => simp at hmltl
  | cons a as =>
    cases m with
    | nil => intro i hi; simp at hi
    | cons b bs =>
      intro i hi
      suffices h : i ≤ a by refine lt_of_le_of_lt ?_ (hlt a mem_cons_self); simpa
      cases hi with
      | head as => exact List.head_le_of_lt hmltl
      | tail b hi => exact le_of_lt (lt_of_lt_of_le (List.rel_of_sorted_cons hm _ hi)
          (List.head_le_of_lt hmltl))
Lexicographic Order Preserves Ordinal Bounds in Sorted Lists
Informal description
Let $\alpha$ be a linearly ordered type with a well-founded strict less-than relation $<$. Given two lists $l$ and $m$ of elements of $\alpha$ that are sorted in strictly decreasing order, if $m$ is lexicographically less than $l$ and every element $i$ in $l$ satisfies $\mathrm{typein}(<, i) < o$ for some ordinal $o$, then every element $i$ in $m$ also satisfies $\mathrm{typein}(<, i) < o$. Here, $\mathrm{typein}(<, i)$ denotes the ordinal corresponding to the initial segment of $\alpha$ consisting of all elements less than $i$ under the relation $<$.