Documentation

Mathlib.SetTheory.Ordinal.Basic

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 #

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.

Notation #

Definition of ordinals #

structure WellOrder :
Type (u + 1)

Bundled structure registering a well order on a type. Ordinals will be defined as a quotient of this type.

  • α : Type u

    The underlying type of the order.

  • r : self.αself.αProp

    The underlying relation of the order.

  • wo : IsWellOrder self.α self.r

    The proposition that r is a well-ordering for α.

Instances For
    @[implicit_reducible]
    instance WellOrder.inhabited :
    Inhabited WellOrder
    @[implicit_reducible]

    Equivalence relation on well orders on arbitrary types in universe u, given by order isomorphism.

    def Ordinal :
    Type (u + 1)

    Ordinal.{u} is the type of well orders in Type u, up to order isomorphism.

    Instances For

      A "canonical" type order-isomorphic to the ordinal o, living in the same universe. This is defined through the axiom of choice; in particular, it has no useful def-eqs, and it is not exposed.

      Use this over Iio o only when it is paramount to have a Type u rather than a Type (u + 1), and convert using

      Ordinal.ToType.mk : Iio o → o.ToType
      Ordinal.ToType.toOrd : o.ToType → Iio o
      
      Instances For
        @[deprecated Ordinal.ToType (since := "2025-12-04")]

        Alias of Ordinal.ToType.


        A "canonical" type order-isomorphic to the ordinal o, living in the same universe. This is defined through the axiom of choice; in particular, it has no useful def-eqs, and it is not exposed.

        Use this over Iio o only when it is paramount to have a Type u rather than a Type (u + 1), and convert using

        Ordinal.ToType.mk : Iio o → o.ToType
        Ordinal.ToType.toOrd : o.ToType → Iio o
        
        Instances For
          @[implicit_reducible]
          noncomputable instance linearOrder_toType (o : Ordinal.{u_1}) :
          @[implicit_reducible]
          noncomputable instance hasWellFounded_toType (o : Ordinal.{u_1}) :
          WellFoundedRelation o.ToType
          @[implicit_reducible]

          Basic properties of the order type #

          def Ordinal.type {α : Type u} (r : ααProp) [wo : IsWellOrder α r] :

          The order type of a well order is an ordinal.

          Instances For
            def Ordinal.termTypeLT_ :
            Lean.ParserDescr

            typeLT α is an abbreviation for the order type of the < relation of α.

            Instances For
              @[implicit_reducible]
              @[implicit_reducible]
              instance Ordinal.inhabited :
              Inhabited Ordinal.{u_1}
              @[implicit_reducible]
              @[simp]
              theorem Ordinal.type_toType (o : Ordinal.{u_1}) :
              (type fun (x1 x2 : o.ToType) => x1 < x2) = o
              theorem Ordinal.type_eq {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
              type r = type s Nonempty (r ≃r s)
              theorem RelIso.ordinal_type_eq {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (h : r ≃r s) :
              theorem Ordinal.type_eq_zero_of_empty {α : Type u} (r : ααProp) [IsWellOrder α r] [IsEmpty α] :
              type r = 0
              @[simp]
              theorem Ordinal.type_eq_zero_iff_isEmpty {α : Type u} {r : ααProp} [IsWellOrder α r] :
              type r = 0 IsEmpty α
              theorem Ordinal.type_ne_zero_iff_nonempty {α : Type u} {r : ααProp} [IsWellOrder α r] :
              type r 0 Nonempty α
              theorem Ordinal.type_ne_zero_of_nonempty {α : Type u} (r : ααProp) [IsWellOrder α r] [h : Nonempty α] :
              type r 0
              theorem Ordinal.type_pEmpty :
              type emptyRelation = 0
              theorem Ordinal.type_empty :
              type emptyRelation = 0
              theorem Ordinal.type_eq_one_of_unique {α : Type u} (r : ααProp) [IsWellOrder α r] [Nonempty α] [Subsingleton α] :
              type r = 1
              @[simp]
              theorem Ordinal.type_eq_one_iff_unique {α : Type u} {r : ααProp} [IsWellOrder α r] :
              type r = 1 Nonempty (Unique α)
              theorem Ordinal.type_pUnit :
              type emptyRelation = 1
              theorem Ordinal.type_unit :
              type emptyRelation = 1
              @[deprecated Ordinal.isEmpty_toType_iff (since := "2026-02-18")]

              Alias of Ordinal.isEmpty_toType_iff.

              @[simp]
              theorem Ordinal.nonempty_toType_iff {o : Ordinal.{u_1}} :
              Nonempty o.ToType o 0
              @[deprecated Ordinal.nonempty_toType_iff (since := "2026-02-18")]
              theorem Ordinal.toType_nonempty_iff_ne_zero {o : Ordinal.{u_1}} :
              Nonempty o.ToType o 0

              Alias of Ordinal.nonempty_toType_iff.

              theorem Ordinal.one_ne_zero :
              1 0
              theorem Ordinal.inductionOn {motive : Ordinal.{u_1}Prop} (o : Ordinal.{u_1}) (type : ∀ (α : Type u_1) (r : ααProp) [inst : IsWellOrder α r], motive (type r)) :
              motive o

              Quotient.inductionOn specialized to ordinals.

              Not to be confused with well-founded induction WellFoundedLT.induction.

              theorem Ordinal.inductionOn₂ {motive : Ordinal.{u_1}Ordinal.{u_2}Prop} (o₁ : Ordinal.{u_1}) (o₂ : Ordinal.{u_2}) (type : ∀ (α : Type u_1) (r : ααProp) [inst : IsWellOrder α r] (β : Type u_2) (s : ββProp) [inst_1 : IsWellOrder β s], motive (type r) (type s)) :
              motive o₁ o₂

              Quotient.inductionOn₂ specialized to ordinals.

              Not to be confused with well-founded induction WellFoundedLT.induction.

              theorem Ordinal.inductionOn₃ {motive : Ordinal.{u_1}Ordinal.{u_2}Ordinal.{u_3}Prop} (o₁ : Ordinal.{u_1}) (o₂ : Ordinal.{u_2}) (o₃ : Ordinal.{u_3}) (type : ∀ (α : Type u_1) (r : ααProp) [inst : IsWellOrder α r] (β : Type u_2) (s : ββProp) [inst_1 : IsWellOrder β s] (γ : Type u_3) (t : γγProp) [inst_2 : IsWellOrder γ t], motive (type r) (type s) (type t)) :
              motive o₁ o₂ o₃

              Quotient.inductionOn₃ specialized to ordinals.

              Not to be confused with well-founded induction WellFoundedLT.induction.

              theorem Ordinal.inductionOnWellOrder {motive : Ordinal.{u_1}Prop} (o : Ordinal.{u_1}) (type : ∀ (α : Type u_1) [inst : LinearOrder α] [inst_1 : WellFoundedLT α], motive (type fun (x1 x2 : α) => x1 < x2)) :
              motive o

              To prove a result on ordinals, it suffices to prove it for order types of well-orders.

              noncomputable def Ordinal.liftOnWellOrder {δ : Sort v} (o : Ordinal.{u_1}) (f : (α : Type u_1) → [inst : LinearOrder α] → [WellFoundedLT α] → δ) (c : ∀ (α : Type u_1) [inst : LinearOrder α] [inst_1 : WellFoundedLT α] (β : Type u_1) [inst_2 : LinearOrder β] [inst_3 : WellFoundedLT β], ((type fun (x1 x2 : α) => x1 < x2) = type fun (x1 x2 : β) => x1 < x2)f α = f β) :
              δ

              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.

              Instances For
                @[simp]
                theorem Ordinal.liftOnWellOrder_type {δ : Sort v} (f : (α : Type u_1) → [inst : LinearOrder α] → [WellFoundedLT α] → δ) (c : ∀ (α : Type u_1) [inst : LinearOrder α] [inst_1 : WellFoundedLT α] (β : Type u_1) [inst_2 : LinearOrder β] [inst_3 : WellFoundedLT β], ((type fun (x1 x2 : α) => x1 < x2) = type fun (x1 x2 : β) => x1 < x2)f α = f β) {γ : Type u_1} [LinearOrder γ] [WellFoundedLT γ] :
                (type fun (x1 x2 : γ) => x1 < x2).liftOnWellOrder f c = f γ

                The order on ordinals #

                @[implicit_reducible]

                For Ordinal:

                • less-equal is defined such that well orders r and s satisfy type rtype 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 Mathlib/Order/InitialSeg.lean file.

                @[implicit_reducible]
                theorem InitialSeg.ordinal_type_le {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (h : InitialSeg r s) :
                theorem RelEmbedding.ordinal_type_le {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (h : r ↪r s) :
                theorem PrincipalSeg.ordinal_type_lt {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (h : PrincipalSeg r s) :
                @[deprecated nonpos_iff_eq_zero (since := "2025-11-21")]
                theorem Ordinal.le_zero {o : Ordinal.{u_1}} :
                o 0 o = 0
                @[deprecated not_neg (since := "2025-11-21")]
                theorem Ordinal.not_lt_zero (o : Ordinal.{u_1}) :
                ¬o < 0
                @[deprecated eq_zero_or_pos (since := "2025-11-21")]
                theorem Ordinal.eq_zero_or_pos (a : Ordinal.{u_1}) :
                a = 0 0 < a
                theorem Ordinal.type_le_iff {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                type r type s Nonempty (InitialSeg r s)
                theorem Ordinal.type_le_iff' {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                type r type s Nonempty (r ↪r s)
                theorem Ordinal.type_lt_iff {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                type r < type s Nonempty (PrincipalSeg r s)
                noncomputable def Ordinal.initialSegToType {α β : Ordinal.{u_1}} (h : α β) :
                InitialSeg (fun (x1 x2 : α.ToType) => x1 < x2) fun (x1 x2 : β.ToType) => x1 < x2

                Given two ordinals α ≤ β, then initialSegToType α β is the initial segment embedding of α.ToType into β.ToType.

                Instances For
                  noncomputable def Ordinal.principalSegToType {α β : Ordinal.{u_1}} (h : α < β) :
                  PrincipalSeg (fun (x1 x2 : α.ToType) => x1 < x2) fun (x1 x2 : β.ToType) => x1 < x2

                  Given two ordinals α < β, then principalSegToType α β is the principal segment embedding of α.ToType into β.ToType.

                  Instances For

                    Enumerating elements in a well-order with ordinals #

                    def Ordinal.typein {α : Type u} (r : ααProp) [IsWellOrder α r] :
                    PrincipalSeg r fun (x1 x2 : Ordinal.{u}) => x1 < x2

                    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.

                    Instances For
                      @[simp]
                      theorem Ordinal.type_subrel {α : Type u} (r : ααProp) [IsWellOrder α r] (a : α) :
                      type (Subrel r fun (x : α) => r x a) = (typein r).toRelEmbedding a
                      @[simp]
                      theorem Ordinal.top_typein {α : Type u} (r : ααProp) [IsWellOrder α r] :
                      (typein r).top = type r
                      theorem Ordinal.typein_lt_type {α : Type u} (r : ααProp) [IsWellOrder α r] (a : α) :
                      theorem Ordinal.typein_lt_self {o : Ordinal.{u_1}} (i : o.ToType) :
                      (typein fun (x1 x2 : o.ToType) => x1 < x2).toRelEmbedding i < o
                      @[simp]
                      theorem Ordinal.typein_top {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : PrincipalSeg r s) :
                      @[simp]
                      theorem Ordinal.typein_lt_typein {α : Type u} (r : ααProp) [IsWellOrder α r] {a b : α} :
                      @[simp]
                      theorem Ordinal.typein_le_typein {α : Type u} (r : ααProp) [IsWellOrder α r] {a b : α} :
                      theorem Ordinal.typein_injective {α : Type u} (r : ααProp) [IsWellOrder α r] :
                      Function.Injective (typein r).toRelEmbedding
                      theorem Ordinal.typein_inj {α : Type u} (r : ααProp) [IsWellOrder α r] {a b : α} :
                      (typein r).toRelEmbedding a = (typein r).toRelEmbedding b a = b
                      theorem Ordinal.mem_range_typein_iff {α : Type u} (r : ααProp) [IsWellOrder α r] {o : Ordinal.{u}} :
                      o Set.range (typein r).toRelEmbedding o < type r
                      theorem Ordinal.typein_surj {α : Type u} (r : ααProp) [IsWellOrder α r] {o : Ordinal.{u}} (h : o < type r) :
                      noncomputable def Ordinal.enum {α : Type u} (r : ααProp) [IsWellOrder α r] :
                      (fun (x1 x2 : (Set.Iio (type r))) => x1 < x2) ≃r r

                      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 α.

                      Instances For
                        @[simp]
                        theorem Ordinal.enum_symm_apply_coe {α : Type u} (r : ααProp) [IsWellOrder α r] (a✝ : α) :
                        ((enum r).symm a✝) = (typein r).toRelEmbedding a✝
                        @[simp]
                        theorem Ordinal.typein_enum {α : Type u} (r : ααProp) [IsWellOrder α r] {o : Ordinal.{u}} (h : o < type r) :
                        (typein r).toRelEmbedding ((enum r) o, h) = o
                        theorem Ordinal.enum_type {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : PrincipalSeg s r) {h : type s < type r} :
                        (enum r) type s, h = f.top
                        @[simp]
                        theorem Ordinal.enum_typein {α : Type u} (r : ααProp) [IsWellOrder α r] (a : α) :
                        (enum r) (typein r).toRelEmbedding a, = a
                        theorem Ordinal.enum_lt_enum {α : Type u} {r : ααProp} [IsWellOrder α r] {o₁ o₂ : (Set.Iio (type r))} :
                        r ((enum r) o₁) ((enum r) o₂) o₁ < o₂
                        theorem Ordinal.enum_le_enum {α : Type u} (r : ααProp) [IsWellOrder α r] {o₁ o₂ : (Set.Iio (type r))} :
                        ¬r ((enum r) o₁) ((enum r) o₂) o₂ o₁
                        @[simp]
                        theorem Ordinal.enum_le_enum' (a : Ordinal.{u_1}) {o₁ o₂ : (Set.Iio (type fun (x1 x2 : a.ToType) => x1 < x2))} :
                        (enum fun (x1 x2 : a.ToType) => x1 < x2) o₁ (enum fun (x1 x2 : a.ToType) => x1 < x2) o₂ o₁ o₂
                        theorem Ordinal.enum_inj {α : Type u} {r : ααProp} [IsWellOrder α r] {o₁ o₂ : (Set.Iio (type r))} :
                        (enum r) o₁ = (enum r) o₂ o₁ = o₂
                        theorem Ordinal.enum_zero_le {α : Type u} {r : ααProp} [IsWellOrder α r] (h0 : 0 < type r) (a : α) :
                        ¬r a ((enum r) 0, h0)
                        theorem Ordinal.enum_zero_le' {o : Ordinal.{u_1}} (h0 : 0 < o) (a : o.ToType) :
                        (enum fun (x1 x2 : o.ToType) => x1 < x2) 0, a
                        theorem Ordinal.relIso_enum' {α β : Type u} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) (o : Ordinal.{u}) (hr : o < type r) (hs : o < type s) :
                        f ((enum r) o, hr) = (enum s) o, hs
                        theorem Ordinal.relIso_enum {α β : Type u} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) (o : Ordinal.{u}) (hr : o < type r) :
                        f ((enum r) o, hr) = (enum s) o,
                        noncomputable def Ordinal.ToType.mk {o : Ordinal.{u_1}} :

                        The order isomorphism between ordinals less than o and o.ToType.

                        Instances For
                          theorem Ordinal.ToType.mk_apply {o : Ordinal.{u_1}} (x : (Set.Iio o)) :
                          mk x = (enum fun (x1 x2 : o.ToType) => x1 < x2) x,
                          @[deprecated Ordinal.ToType.mk (since := "2025-12-04")]

                          Alias of Ordinal.ToType.mk.


                          The order isomorphism between ordinals less than o and o.ToType.

                          Instances For
                            @[reducible, inline]
                            noncomputable abbrev Ordinal.ToType.toOrd {o : Ordinal.{u_1}} (α : o.ToType) :
                            (Set.Iio o)

                            Convert an element of α.toType to the corresponding Ordinal

                            Instances For
                              @[implicit_reducible]
                              noncomputable instance Ordinal.instCoeToTypeElemIio (o : Ordinal.{u_1}) :
                              Coe o.ToType (Set.Iio o)
                              @[implicit_reducible]
                              noncomputable instance Ordinal.instCoeOutToType (o : Ordinal.{u_1}) :
                              @[implicit_reducible]
                              noncomputable def Ordinal.toTypeOrderBot {o : Ordinal.{u_1}} (ho : o 0) :

                              o.ToType is an OrderBot whenever o ≠ 0.

                              Instances For
                                theorem Ordinal.enum_zero_eq_bot {o : Ordinal.{u_1}} (ho : 0 < o) :
                                (enum fun (x1 x2 : o.ToType) => x1 < x2) 0, = have H := toTypeOrderBot ;
                                theorem Ordinal.lt_wf :
                                WellFounded fun (x1 x2 : Ordinal.{u_1}) => x1 < x2
                                @[implicit_reducible]
                                instance Ordinal.wellFoundedRelation :
                                WellFoundedRelation Ordinal.{u_1}
                                @[deprecated WellFoundedLT.induction (since := "2026-02-27")]
                                theorem Ordinal.induction {p : Ordinal.{u}Prop} (i : Ordinal.{u}) (h : ∀ (j : Ordinal.{u}), (∀ k < j, p k)p j) :
                                p i
                                theorem Ordinal.typein_apply {α β : Type u_1} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : InitialSeg r s) (a : α) :

                                Cardinality of ordinals #

                                The cardinal of an ordinal is the cardinality of any type on which a relation with that order type is defined.

                                Instances For
                                  @[simp]
                                  theorem Ordinal.card_type {α : Type u} (r : ααProp) [IsWellOrder α r] :
                                  @[simp]
                                  theorem Ordinal.card_typein {α : Type u} {r : ααProp} [IsWellOrder α r] (x : α) :
                                  ((typein r).toRelEmbedding x).card = Cardinal.mk { y : α // r y x }
                                  theorem Ordinal.card_le_card {o₁ o₂ : Ordinal.{u_1}} :
                                  o₁ o₂o₁.card o₂.card
                                  @[simp]
                                  theorem Ordinal.card_one :
                                  card 1 = 1
                                  theorem Ordinal.card_typein_min_le_mk {α : Type u} (r : ααProp) [IsWellOrder α r] {s : Set α} (hs : s.Nonempty) :

                                  The cardinality of a set is an upper-bound for the cardinality of the order type of the set's mex (minimum excluded value). See not_lt_enum_ord_mk_min_compl for the α version.

                                  Lifting ordinals to a higher universe #

                                  The universe lift operation for ordinals, which embeds Ordinal.{u} as a proper initial segment of Ordinal.{v} for v > u. For the initial segment version, see liftInitialSeg.

                                  Instances For
                                    @[simp]
                                    theorem Ordinal.type_ulift {α : Type u} (r : ααProp) [IsWellOrder α r] :
                                    type (ULift.down ⁻¹'o r) = lift.{v, u} (type r)
                                    @[deprecated Ordinal.type_ulift (since := "2026-02-20")]
                                    theorem Ordinal.type_uLift {α : Type u} (r : ααProp) [IsWellOrder α r] :
                                    type (ULift.down ⁻¹'o r) = lift.{v, u} (type r)

                                    Alias of Ordinal.type_ulift.

                                    @[simp]
                                    theorem Ordinal.type_lt_ulift {α : Type u} [LinearOrder α] [WellFoundedLT α] :
                                    (type fun (x1 x2 : ULift.{v, u} α) => x1 < x2) = lift.{v, u} (type fun (x1 x2 : α) => x1 < x2)
                                    theorem RelIso.ordinal_lift_type_eq {α : Type u} {β : Type v} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : r ≃r s) :
                                    @[simp]
                                    theorem Ordinal.type_preimage {α β : Type u} (r : ααProp) [IsWellOrder α r] (f : β α) :
                                    type (f ⁻¹'o r) = type r
                                    @[simp]
                                    theorem Ordinal.type_lift_preimage {α : Type u} {β : Type v} (r : ααProp) [IsWellOrder α r] (f : β α) :

                                    lift.{max u v, u} equals lift.{v, u}.

                                    Unfortunately, the simp lemma doesn't seem to work.

                                    An ordinal lifted to a lower or equal universe equals itself.

                                    Unfortunately, the simp lemma doesn't work.

                                    @[simp]

                                    An ordinal lifted to the same universe equals itself.

                                    @[simp]

                                    An ordinal lifted to the zero universe equals itself.

                                    theorem Ordinal.lift_type_le {α : Type u} {β : Type v} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                                    theorem Ordinal.lift_type_eq {α : Type u} {β : Type v} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                                    lift.{max v w, u} (type r) = lift.{max u w, v} (type s) Nonempty (r ≃r s)
                                    theorem Ordinal.lift_type_lt {α : Type u} {β : Type v} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] :
                                    @[simp]
                                    theorem Ordinal.lift_inj {a b : Ordinal.{v}} :
                                    lift.{u, v} a = lift.{u, v} b a = b
                                    @[simp]
                                    theorem Ordinal.lift_typein_top {α : Type u} {β : Type v} {r : ααProp} {s : ββProp} [IsWellOrder α r] [IsWellOrder β s] (f : PrincipalSeg r s) :
                                    def Ordinal.liftInitialSeg :
                                    InitialSeg (fun (x1 x2 : Ordinal.{v}) => x1 < x2) fun (x1 x2 : Ordinal.{max u v}) => x1 < x2

                                    Initial segment version of the lift operation on ordinals, embedding Ordinal.{u} in Ordinal.{v} as an initial segment when u ≤ v.

                                    Instances For

                                      The first infinite ordinal ω #

                                      ω is the first infinite ordinal, defined as the order type of .

                                      Conventions for notations in identifiers:

                                      • The recommended spelling of ω in identifiers is omega0.
                                      Instances For
                                        def Ordinal.termω :
                                        Lean.ParserDescr

                                        ω is the first infinite ordinal, defined as the order type of .

                                        Conventions for notations in identifiers:

                                        • The recommended spelling of ω in identifiers is omega0.
                                        Instances For
                                          @[simp]
                                          theorem Ordinal.type_nat_lt :
                                          (type fun (x1 x2 : ) => x1 < x2) = omega0

                                          Note that the presence of this lemma makes simp [omega0] form a loop.

                                          Definition and first properties of addition on ordinals #

                                          In this paragraph, we introduce the addition on ordinals, and prove just enough properties to deduce that the order on ordinals is total (and therefore well-founded). Further properties of the addition, together with properties of the other operations, are proved in Mathlib/SetTheory/Ordinal/Arithmetic.lean.

                                          @[implicit_reducible]
                                          instance Ordinal.add :

                                          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₂.

                                          @[simp]
                                          theorem Ordinal.card_add (o₁ o₂ : Ordinal.{u_1}) :
                                          (o₁ + o₂).card = o₁.card + o₂.card
                                          @[simp]
                                          theorem Ordinal.type_sum_lex {α β : Type u} (r : ααProp) (s : ββProp) [IsWellOrder α r] [IsWellOrder β s] :
                                          type (Sum.Lex r s) = type r + type s
                                          @[simp]
                                          theorem Ordinal.card_nat (n : ) :
                                          (↑n).card = n
                                          @[simp]
                                          theorem Ordinal.card_ofNat (n : ) [n.AtLeastTwo] :
                                          (OfNat.ofNat n).card = OfNat.ofNat n
                                          @[deprecated le_self_add (since := "2025-11-21")]
                                          theorem Ordinal.le_add_right (a b : Ordinal.{u_1}) :
                                          a a + b
                                          @[deprecated le_add_self (since := "2025-11-21")]
                                          theorem Ordinal.le_add_left (a b : Ordinal.{u_1}) :
                                          a b + a
                                          @[simp]
                                          theorem Ordinal.max_eq_zero {a b : Ordinal.{u_1}} :
                                          max a b = 0 a = 0 b = 0
                                          @[simp]
                                          theorem Ordinal.sInf_empty :
                                          sInf = 0

                                          Successor order properties #

                                          @[deprecated Order.succ_eq_add_one (since := "2026-02-26")]
                                          @[deprecated zero_add (since := "2026-02-26")]
                                          @[deprecated one_add_one_eq_two (since := "2026-02-26")]
                                          @[deprecated add_assoc (since := "2026-02-26")]
                                          theorem Ordinal.add_succ (o₁ o₂ : Ordinal.{u_1}) :
                                          o₁ + Order.succ o₂ = Order.succ (o₁ + o₂)
                                          @[deprecated Order.one_le_iff_ne_zero (since := "2026-03-24")]
                                          theorem Ordinal.one_le_iff_ne_zero {o : Ordinal.{u_1}} :
                                          1 o o 0
                                          theorem Ordinal.add_one_ne_zero (o : Ordinal.{u_1}) :
                                          o + 1 0
                                          @[deprecated Ordinal.add_one_ne_zero (since := "2026-02-27")]
                                          @[deprecated Order.lt_one_iff (since := "2026-03-24")]
                                          theorem Ordinal.lt_one_iff_zero {a : Ordinal.{u_1}} :
                                          a < 1 a = 0
                                          @[deprecated Order.le_one_iff (since := "2026-03-24")]
                                          theorem Ordinal.le_one_iff {a : Ordinal.{u_1}} :
                                          a 1 a = 0 a = 1
                                          @[deprecated Ordinal.card_add_one (since := "2026-02-27")]
                                          theorem Ordinal.natCast_succ (n : ) :
                                          n.succ = Order.succ n
                                          @[implicit_reducible]
                                          @[simp]
                                          theorem Ordinal.Iio_one_default_eq :
                                          default = 0,
                                          @[implicit_reducible]
                                          noncomputable instance Ordinal.uniqueToTypeOne :
                                          theorem Ordinal.one_toType_eq (x : ToType 1) :
                                          x = (enum fun (x1 x2 : ToType 1) => x1 < x2) 0, uniqueToTypeOne._proof_2
                                          theorem Ordinal.type_lt_mem_range_succ_iff {α : Type u} [LinearOrder α] [WellFoundedLT α] :
                                          (type fun (x1 x2 : α) => x1 < x2) Set.range Order.succ ∃ (x : α), IsMax x
                                          theorem Ordinal.type_lt_mem_range_succ {α : Type u} [LinearOrder α] [WellFoundedLT α] [OrderTop α] :
                                          (type fun (x1 x2 : α) => x1 < x2) Set.range Order.succ

                                          Extra properties of typein and enum #

                                          @[simp]
                                          theorem Ordinal.typein_one_toType (x : ToType 1) :
                                          (typein fun (x1 x2 : ToType 1) => x1 < x2).toRelEmbedding x = 0
                                          theorem Ordinal.typein_le_typein' (o : Ordinal.{u_1}) {x y : o.ToType} :
                                          (typein fun (x1 x2 : o.ToType) => x1 < x2).toRelEmbedding x (typein fun (x1 x2 : o.ToType) => x1 < x2).toRelEmbedding y x y
                                          theorem Ordinal.le_enum_succ {o : Ordinal.{u_1}} (a : (Order.succ o).ToType) :
                                          a (enum fun (x1 x2 : (Order.succ o).ToType) => x1 < x2) o,

                                          Universal ordinal #

                                          univ.{u v} is the order type of the ordinals of Type u as a member of Ordinal.{v} (when u < v). It is an inaccessible cardinal.

                                          Instances For
                                            @[simp]
                                            theorem Ordinal.type_lt_ordinal :
                                            (type fun (x1 x2 : Ordinal.{u}) => x1 < x2) = univ.{u, u + 1}
                                            @[deprecated Ordinal.type_lt_ordinal (since := "2026-03-20")]
                                            theorem Ordinal.univ_id :
                                            univ.{u, u + 1} = type fun (x1 x2 : Ordinal.{u}) => x1 < x2
                                            def Ordinal.liftPrincipalSeg :
                                            PrincipalSeg (fun (x1 x2 : Ordinal.{u}) => x1 < x2) fun (x1 x2 : Ordinal.{max (u + 1) v}) => x1 < x2

                                            Principal segment version of the lift operation on ordinals, embedding Ordinal.{u} in Ordinal.{v} as a principal segment when u < v.

                                            Instances For
                                              @[deprecated Ordinal.liftPrincipalSeg_top (since := "2026-03-20")]

                                              Representing a cardinal with an ordinal #

                                              noncomputable def Cardinal.ord (c : Cardinal.{u}) :

                                              The ordinal corresponding to a cardinal c is the least ordinal whose cardinal is c. For the order-embedding version, see ord.order_embedding.

                                              Instances For
                                                theorem Cardinal.ord_eq_iInf (α : Type u) :
                                                (mk α).ord = ⨅ (r : { r : ααProp // IsWellOrder α r }), Ordinal.type r
                                                @[deprecated Cardinal.ord_eq_iInf (since := "2026-03-15")]
                                                theorem Cardinal.ord_eq_Inf (α : Type u) :
                                                (mk α).ord = ⨅ (r : { r : ααProp // IsWellOrder α r }), Ordinal.type r

                                                Alias of Cardinal.ord_eq_iInf.

                                                theorem Cardinal.exists_ord_eq (α : Type u_1) :
                                                ∃ (r : ααProp) (x : IsWellOrder α r), (mk α).ord = Ordinal.type r

                                                There exists a well-order on α whose order type is exactly ord.

                                                @[deprecated Cardinal.exists_ord_eq (since := "2026-03-29")]
                                                theorem Cardinal.ord_eq (α : Type u_1) :
                                                ∃ (r : ααProp) (x : IsWellOrder α r), (mk α).ord = Ordinal.type r

                                                Alias of Cardinal.exists_ord_eq.


                                                There exists a well-order on α whose order type is exactly ord.

                                                theorem Cardinal.exists_ord_eq_type_lt (α : Type u_1) :
                                                ∃ (x : LinearOrder α) (x_1 : WellFoundedLT α), (mk α).ord = Ordinal.type fun (x1 x2 : α) => x1 < x2

                                                There exists a well-order on α whose order type is exactly ord.

                                                theorem Cardinal.ord_le_type {α : Type u} (r : ααProp) [h : IsWellOrder α r] :

                                                Galois coinsertion between Cardinal.ord and Ordinal.card.

                                                Instances For

                                                  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 = ℵ₀).

                                                  @[simp]
                                                  theorem Cardinal.ord_le_ord {c₁ c₂ : Cardinal.{u_1}} :
                                                  c₁.ord c₂.ord c₁ c₂
                                                  @[simp]
                                                  theorem Cardinal.ord_lt_ord {c₁ c₂ : Cardinal.{u_1}} :
                                                  c₁.ord < c₂.ord c₁ < c₂
                                                  @[simp]
                                                  theorem Cardinal.ord_zero :
                                                  ord 0 = 0
                                                  @[simp]
                                                  theorem Cardinal.ord_nat (n : ) :
                                                  (↑n).ord = n
                                                  @[simp]
                                                  theorem Cardinal.ord_ofNat (n : ) [n.AtLeastTwo] :
                                                  (OfNat.ofNat n).ord = OfNat.ofNat n
                                                  @[simp]
                                                  theorem Cardinal.ord_one :
                                                  ord 1 = 1
                                                  theorem Cardinal.card_typein_lt {α : Type u} {r : ααProp} [IsWellOrder α r] (x : α) (h : (mk α).ord = Ordinal.type r) :
                                                  theorem Cardinal.mk_Iio_lt {α : Type u} [LinearOrder α] [WellFoundedLT α] (i : α) (h : (mk α).ord = Ordinal.type fun (x1 x2 : α) => x1 < x2) :
                                                  mk (Set.Iio i) < mk α
                                                  @[deprecated Cardinal.mk_Iio_toType_ord_lt (since := "2026-03-20")]

                                                  Alias of Cardinal.mk_Iio_toType_ord_lt.

                                                  @[deprecated Cardinal.mk_Iio_toType_ord_lt (since := "2026-03-20")]
                                                  theorem Cardinal.card_typein_toType_lt (c : Cardinal.{u_1}) (x : c.ord.ToType) :
                                                  ((Ordinal.typein fun (x1 x2 : c.ord.ToType) => x1 < x2).toRelEmbedding x).card < c
                                                  theorem Cardinal.ord_injective :
                                                  Function.Injective ord
                                                  @[simp]
                                                  theorem Cardinal.ord_inj {a b : Cardinal.{u_1}} :
                                                  a.ord = b.ord a = b
                                                  @[simp]
                                                  theorem Cardinal.ord_eq_zero {a : Cardinal.{u_1}} :
                                                  a.ord = 0 a = 0
                                                  @[simp]
                                                  theorem Cardinal.ord_eq_one {a : Cardinal.{u_1}} :
                                                  a.ord = 1 a = 1
                                                  @[simp]
                                                  theorem Cardinal.ord_pos {a : Cardinal.{u_1}} :
                                                  0 < a.ord 0 < a

                                                  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.

                                                  Instances For

                                                    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).

                                                    Instances For
                                                      @[implicit_reducible]
                                                      noncomputable def Cardinal.toTypeOrderBot {c : Cardinal.{u_1}} (hc : c 0) :

                                                      If a cardinal c is nonzero, then c.ord.ToType has a least element.

                                                      Instances For
                                                        @[simp]
                                                        theorem Ordinal.nat_le_card {o : Ordinal.{u_1}} {n : } :
                                                        n o.card n o
                                                        @[simp]
                                                        theorem Ordinal.one_le_card {o : Ordinal.{u_1}} :
                                                        1 o.card 1 o
                                                        @[simp]
                                                        theorem Ordinal.ofNat_le_card {o : Ordinal.{u_1}} {n : } [n.AtLeastTwo] :
                                                        OfNat.ofNat n o.card OfNat.ofNat n o
                                                        @[simp]
                                                        theorem Ordinal.nat_lt_card {o : Ordinal.{u_1}} {n : } :
                                                        n < o.card n < o
                                                        @[simp]
                                                        theorem Ordinal.zero_lt_card {o : Ordinal.{u_1}} :
                                                        0 < o.card 0 < o
                                                        @[simp]
                                                        theorem Ordinal.one_lt_card {o : Ordinal.{u_1}} :
                                                        1 < o.card 1 < o
                                                        @[simp]
                                                        theorem Ordinal.ofNat_lt_card {o : Ordinal.{u_1}} {n : } [n.AtLeastTwo] :
                                                        OfNat.ofNat n < o.card OfNat.ofNat n < o
                                                        @[simp]
                                                        theorem Ordinal.card_lt_nat {o : Ordinal.{u_1}} {n : } :
                                                        o.card < n o < n
                                                        @[simp]
                                                        theorem Ordinal.card_lt_ofNat {o : Ordinal.{u_1}} {n : } [n.AtLeastTwo] :
                                                        o.card < OfNat.ofNat n o < OfNat.ofNat n
                                                        @[simp]
                                                        theorem Ordinal.card_le_nat {o : Ordinal.{u_1}} {n : } :
                                                        o.card n o n
                                                        @[simp]
                                                        theorem Ordinal.card_le_one {o : Ordinal.{u_1}} :
                                                        o.card 1 o 1
                                                        @[simp]
                                                        theorem Ordinal.card_le_ofNat {o : Ordinal.{u_1}} {n : } [n.AtLeastTwo] :
                                                        o.card OfNat.ofNat n o OfNat.ofNat n
                                                        @[simp]
                                                        theorem Ordinal.card_eq_nat {o : Ordinal.{u_1}} {n : } :
                                                        o.card = n o = n
                                                        @[simp]
                                                        theorem Ordinal.card_eq_zero {o : Ordinal.{u_1}} :
                                                        o.card = 0 o = 0
                                                        @[simp]
                                                        theorem Ordinal.card_eq_one {o : Ordinal.{u_1}} :
                                                        o.card = 1 o = 1
                                                        @[simp]
                                                        theorem Ordinal.card_eq_ofNat {o : Ordinal.{u_1}} {n : } [n.AtLeastTwo] :
                                                        o.card = OfNat.ofNat n o = OfNat.ofNat n
                                                        @[simp]
                                                        theorem Ordinal.type_fintype {α : Type u} (r : ααProp) [IsWellOrder α r] [Fintype α] :
                                                        type r = (Fintype.card α)
                                                        theorem Ordinal.type_fin (n : ) :
                                                        (type fun (x1 x2 : Fin n) => x1 < x2) = n
                                                        theorem Ordinal.ord_mk_le_type {α : Type u} (r : ααProp) [IsWellOrder α r] (s : Set α) :
                                                        theorem Ordinal.ord_mk_lt_type {α : Type u} (r : ααProp) [IsWellOrder α r] {s : Set α} (hfin : s.Finite) (h : s.Nonempty) :
                                                        theorem Ordinal.not_lt_enum_ord_mk_min_compl {α : Type u} (r : ααProp) [IsWellOrder α r] {s : Set α} (hfin : s.Finite) (h : s.Nonempty) :
                                                        ¬r ((enum r) (Cardinal.mk s).ord, ) (.min s h)

                                                        The #s-th element of α is an upper-bound for the set's mex (minimum excluded value), ordered by r, when s is finite. See card_typein_min_le_mk for the Ordinal version.

                                                        Sorted lists #

                                                        theorem List.SortedGT.lt_ord_of_lt {α : Type u} [LinearOrder α] [WellFoundedLT α] {l m : List α} {o : Ordinal.{u}} (hl : l.SortedGT) (hm : m.SortedGT) (hmltl : m < l) (hlt : il, (Ordinal.typein fun (x1 x2 : α) => x1 < x2).toRelEmbedding i < o) (i : α) :
                                                        i m(Ordinal.typein fun (x1 x2 : α) => x1 < x2).toRelEmbedding i < o
                                                        @[deprecated List.SortedGT.lt_ord_of_lt (since := "2025-11-27")]
                                                        theorem List.Sorted.lt_ord_of_lt {α : Type u} [LinearOrder α] [WellFoundedLT α] {l m : List α} {o : Ordinal.{u}} (hl : l.SortedGT) (hm : m.SortedGT) (hmltl : m < l) (hlt : il, (Ordinal.typein fun (x1 x2 : α) => x1 < x2).toRelEmbedding i < o) (i : α) :
                                                        i m(Ordinal.typein fun (x1 x2 : α) => x1 < x2).toRelEmbedding i < o

                                                        Alias of List.SortedGT.lt_ord_of_lt.