Documentation

Mathlib.SetTheory.Ordinal.Arithmetic

Ordinal arithmetic #

Ordinals have an addition (corresponding to the disjoint union) that turns them into an additive monoid, and a multiplication (corresponding to the lexicographic order on the product) that turns them into a monoid. One can also define (truncated) subtraction and division operators.

Ordinal powers and logarithms are defined in Mathlib.SetTheory.Ordinal.Exponential.

Main definitions and results #

We discuss the properties of casts of natural numbers of and of ω with respect to these operations.

Note that some basic functions and properties of ordinals have been generalized to other orders, and exist on other files:

Various other basic arithmetic results are given in Principal.lean instead.

Further properties of addition on ordinals #

theorem Ordinal.add_le_add_iff_right {a b : Ordinal.{u_4}} (n : ) :
a + n b + n a b
theorem Ordinal.add_right_cancel {a b : Ordinal.{u_4}} (n : ) :
a + n = b + n a = b
@[simp]
theorem Ordinal.add_eq_zero_iff {a b : Ordinal.{u_4}} :
a + b = 0 a = 0 b = 0

Limit ordinals #

noncomputable def Ordinal.limitRecOn {motive : Ordinal.{u_5}Sort u_4} (o : Ordinal.{u_5}) (zero : motive 0) (add_one : (o : Ordinal.{u_5}) → motive omotive (o + 1)) (limit : (o : Ordinal.{u_5}) → Order.IsSuccLimit o((o' : Ordinal.{u_5}) → o' < omotive o')motive o) :
motive o

Limit induction on ordinals: if one can prove a property by induction at successor ordinals and at limit ordinals, then it holds for all ordinals.

Note that this is just a special (though sometimes convenient) case of the more general well-founded recursion WellFoundedLT.fix.

Equations
Instances For
    @[simp]
    theorem Ordinal.limitRecOn_zero {motive : Ordinal.{u_4}Sort u_5} (H₁ : motive 0) (H₂ : (o : Ordinal.{u_4}) → motive omotive (o + 1)) (H₃ : (o : Ordinal.{u_4}) → Order.IsSuccLimit o((o' : Ordinal.{u_4}) → o' < omotive o')motive o) :
    limitRecOn 0 H₁ H₂ H₃ = H₁
    @[simp]
    theorem Ordinal.limitRecOn_add_one {motive : Ordinal.{u_4}Sort u_5} (o : Ordinal.{u_4}) (H₁ : motive 0) (H₂ : (o : Ordinal.{u_4}) → motive omotive (o + 1)) (H₃ : (o : Ordinal.{u_4}) → Order.IsSuccLimit o((o' : Ordinal.{u_4}) → o' < omotive o')motive o) :
    limitRecOn (o + 1) H₁ H₂ H₃ = H₂ o (limitRecOn o H₁ H₂ H₃)
    @[deprecated Ordinal.limitRecOn_add_one (since := "2026-05-21")]
    theorem Ordinal.limitRecOn_succ {motive : Ordinal.{u_4}Sort u_5} (o : Ordinal.{u_4}) (H₁ : motive 0) (H₂ : (o : Ordinal.{u_4}) → motive omotive (o + 1)) (H₃ : (o : Ordinal.{u_4}) → Order.IsSuccLimit o((o' : Ordinal.{u_4}) → o' < omotive o')motive o) :
    limitRecOn (Order.succ o) H₁ H₂ H₃ = H₂ o (limitRecOn o H₁ H₂ H₃)
    @[simp]
    theorem Ordinal.limitRecOn_limit {motive : Ordinal.{u_4}Sort u_5} (o : Ordinal.{u_4}) (H₁ : motive 0) (H₂ : (o : Ordinal.{u_4}) → motive omotive (o + 1)) (H₃ : (o : Ordinal.{u_4}) → Order.IsSuccLimit o((o' : Ordinal.{u_4}) → o' < omotive o')motive o) (h : Order.IsSuccLimit o) :
    limitRecOn o H₁ H₂ H₃ = H₃ o h fun (x : Ordinal.{u_4}) (_h : x < o) => limitRecOn x H₁ H₂ H₃
    @[instance_reducible]
    Equations
    theorem Ordinal.enum_succ_eq_top {o : Ordinal.{u_4}} :
    (enum fun (x1 x2 : (Order.succ o).ToType) => x1 < x2) o, =
    @[deprecated Ordinal.isSuccPrelimit_type_lt_iff (since := "2026-04-12")]
    theorem Ordinal.has_succ_of_type_succ_lt {α : Type u_4} {r : ααProp} [wo : IsWellOrder α r] (h : a < type r, Order.succ a < type r) (x : α) :
    ∃ (y : α), r x y
    @[deprecated Ordinal.isSuccPrelimit_type_lt_iff (since := "2026-04-12")]
    theorem Ordinal.bounded_singleton {α : Type u_1} {r : ααProp} [IsWellOrder α r] (hr : Order.IsSuccLimit (type r)) (x : α) :

    The predecessor of an ordinal #

    noncomputable def Ordinal.pred (o : Ordinal.{u_4}) :

    The ordinal predecessor of a is b if a = succ b, and a otherwise.

    Equations
    Instances For
      @[simp]
      theorem Ordinal.pred_add_one (o : Ordinal.{u_4}) :
      (o + 1).pred = o
      @[deprecated Ordinal.pred_add_one (since := "2026-05-25")]
      @[simp]
      theorem Ordinal.pred_zero :
      pred 0 = 0

      Subtraction on ordinals #

      @[instance_reducible]
      noncomputable instance Ordinal.sub :

      a - b is the unique ordinal satisfying b + (a - b) = a when b ≤ a.

      Equations
      theorem Ordinal.add_sub_cancel_of_le {a b : Ordinal.{u_4}} (h : b a) :
      b + (a - b) = a
      @[simp]
      theorem Ordinal.add_sub_cancel (a b : Ordinal.{u_4}) :
      a + b - a = b
      theorem Ordinal.le_add_sub (a b : Ordinal.{u_4}) :
      a b + (a - b)
      theorem Ordinal.sub_le {a b c : Ordinal.{u_4}} :
      a - b c a b + c
      theorem Ordinal.lt_sub {a b c : Ordinal.{u_4}} :
      a < b - c c + a < b
      theorem Ordinal.sub_eq_of_add_eq {a b c : Ordinal.{u_4}} (h : a + b = c) :
      c - a = b
      theorem Ordinal.le_sub_of_le {a b c : Ordinal.{u_4}} (h : b a) :
      c a - b b + c a
      theorem Ordinal.sub_lt_of_le {a b c : Ordinal.{u_4}} (h : b a) :
      a - b < c a < b + c
      @[simp]
      theorem Ordinal.sub_zero (a : Ordinal.{u_4}) :
      a - 0 = a
      @[simp]
      theorem Ordinal.zero_sub (a : Ordinal.{u_4}) :
      0 - a = 0
      @[simp]
      theorem Ordinal.sub_self (a : Ordinal.{u_4}) :
      a - a = 0
      theorem Ordinal.sub_sub (a b c : Ordinal.{u_4}) :
      a - b - c = a - (b + c)
      @[simp]
      theorem Ordinal.add_sub_add_cancel (a b c : Ordinal.{u_4}) :
      a + b - (a + c) = b - c
      theorem Ordinal.le_sub_of_add_le {a b c : Ordinal.{u_4}} (h : b + c a) :
      c a - b
      theorem Ordinal.sub_lt_of_lt_add {a b c : Ordinal.{u_4}} (h : a < b + c) (hc : 0 < c) :
      a - b < c
      theorem Ordinal.lt_add_iff {a b c : Ordinal.{u_4}} (hc : c 0) :
      a < b + c d < c, a b + d
      theorem Ordinal.add_le_iff {a b c : Ordinal.{u_4}} (hb : b 0) :
      a + b c d < b, a + d < c
      theorem Ordinal.lt_add_iff_of_isSuccLimit {a b c : Ordinal.{u_4}} (hc : Order.IsSuccLimit c) :
      a < b + c d < c, a < b + d
      theorem Ordinal.add_le_iff_of_isSuccLimit {a b c : Ordinal.{u_4}} (hb : Order.IsSuccLimit b) :
      a + b c d < b, a + d c

      Multiplication of ordinals #

      @[instance_reducible]

      The multiplication of ordinals a and b is the order type of the lexicographic order on b × a.

      Equations
      • One or more equations did not get rendered due to their size.
      @[simp]
      theorem Ordinal.type_prod_lex {α β : Type u} (r : ααProp) (s : ββProp) [IsWellOrder α r] [IsWellOrder β s] :
      type (Prod.Lex s r) = type r * type s
      @[instance_reducible]
      Equations
      @[simp]
      theorem Ordinal.card_mul (a b : Ordinal.{u_4}) :
      (a * b).card = a.card * b.card
      theorem Ordinal.mul_succ (a b : Ordinal.{u_4}) :
      a * Order.succ b = a * b + a
      theorem Ordinal.le_mul_left (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (hb : 0 < b) :
      a a * b
      theorem Ordinal.le_mul_right (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (hb : 0 < b) :
      a b * a
      theorem Ordinal.mul_le_iff_of_isSuccLimit {a b c : Ordinal.{u_4}} (h : Order.IsSuccLimit b) :
      a * b c b' < b, a * b' c
      theorem Ordinal.lt_mul_iff_of_isSuccLimit {a b c : Ordinal.{u_4}} (h : Order.IsSuccLimit c) :
      a < b * c c' < c, a < b * c'
      theorem Ordinal.lt_mul_add_one_iff {a b c : Ordinal.{u_4}} :
      a < b * (c + 1) d < b, a b * c + d
      @[deprecated Ordinal.isSuccLimit_mul_right (since := "2026-02-01")]

      Alias of Ordinal.isSuccLimit_mul_right.

      @[simp]
      theorem Ordinal.nsmul_eq_mul (n : ) (a : Ordinal.{u_4}) :
      n a = a * n
      @[deprecated Ordinal.nsmul_eq_mul (since := "2026-03-14")]
      theorem Ordinal.smul_eq_mul (n : ) (a : Ordinal.{u_4}) :
      n a = a * n

      Alias of Ordinal.nsmul_eq_mul.

      theorem Ordinal.add_mul_add_one {a b : Ordinal.{u_4}} (c : Ordinal.{u_4}) (ba : b + a = a) :
      (a + b) * (c + 1) = a * (c + 1) + b
      theorem Ordinal.add_mul_succ {a b : Ordinal.{u_4}} (c : Ordinal.{u_4}) (ba : b + a = a) :
      (a + b) * Order.succ c = a * Order.succ c + b
      theorem Ordinal.add_mul_of_isSuccLimit {a b c : Ordinal.{u_4}} (ba : b + a = a) (l : Order.IsSuccLimit c) :
      (a + b) * c = a * c
      theorem Ordinal.mul_two (o : Ordinal.{u_4}) :
      o * 2 = o + o

      Division on ordinals #

      @[instance_reducible]
      noncomputable instance Ordinal.div :

      a / b is the unique ordinal q satisfying a = b * q + r with r < b.

      Equations
      @[simp]
      theorem Ordinal.div_zero (a : Ordinal.{u_4}) :
      a / 0 = 0
      theorem Ordinal.mul_div_gc {a : Ordinal.{u_4}} (ha : a 0) :
      GaloisConnection (fun (x : Ordinal.{u_4}) => a * x) fun (x : Ordinal.{u_4}) => x / a

      Multiplication and division by a non-zero ordinal form a Galois connection.

      theorem Ordinal.mul_le_iff_le_div {a b c : Ordinal.{u_4}} (ha : a 0) :
      a * b c b c / a
      theorem Ordinal.lt_mul_iff_div_lt {a b c : Ordinal.{u_4}} (ha : a 0) :
      c < a * b c / a < b
      theorem Ordinal.lt_mul_succ_div (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (h : b 0) :
      a < b * Order.succ (a / b)
      theorem Ordinal.lt_mul_div_add (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (h : b 0) :
      a < b * (a / b) + b
      theorem Ordinal.div_le {a b c : Ordinal.{u_4}} (b0 : b 0) :
      a / b c a < b * Order.succ c
      theorem Ordinal.lt_div {a b c : Ordinal.{u_4}} (h : c 0) :
      a < b / c c * Order.succ a b
      theorem Ordinal.div_pos {b c : Ordinal.{u_4}} (h : c 0) :
      0 < b / c c b
      @[deprecated Ordinal.mul_le_iff_le_div (since := "2026-02-27")]
      theorem Ordinal.le_div {a b c : Ordinal.{u_4}} (c0 : c 0) :
      a b / c c * a b
      @[deprecated Ordinal.lt_mul_iff_div_lt (since := "2026-02-27")]
      theorem Ordinal.div_lt {a b c : Ordinal.{u_4}} (b0 : b 0) :
      a / b < c a < b * c
      theorem Ordinal.div_le_of_le_mul {a b c : Ordinal.{u_4}} (h : a b * c) :
      a / b c
      theorem Ordinal.mul_lt_of_lt_div {a b c : Ordinal.{u_4}} :
      a < b / cc * a < b
      @[simp]
      theorem Ordinal.zero_div (a : Ordinal.{u_4}) :
      0 / a = 0
      theorem Ordinal.mul_div_le (a b : Ordinal.{u_4}) :
      b * (a / b) a
      theorem Ordinal.div_le_left {a b : Ordinal.{u_4}} (h : a b) (c : Ordinal.{u_4}) :
      a / c b / c
      theorem Ordinal.mul_add_div (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (b0 : b 0) (c : Ordinal.{u_4}) :
      (b * a + c) / b = a + c / b
      theorem Ordinal.div_eq_zero_of_lt {a b : Ordinal.{u_4}} (h : a < b) :
      a / b = 0
      @[simp]
      theorem Ordinal.mul_div_cancel (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (b0 : b 0) :
      b * a / b = a
      theorem Ordinal.mul_add_div_mul {a c : Ordinal.{u_4}} (hc : c < a) (b d : Ordinal.{u_4}) :
      (a * b + c) / (a * d) = b / d
      theorem Ordinal.mul_div_mul_cancel {a : Ordinal.{u_4}} (ha : a 0) (b c : Ordinal.{u_4}) :
      a * b / (a * c) = b / c
      theorem Ordinal.div_eq {a b c : Ordinal.{u_4}} (hle : b * c a) (hlt : a < b * (c + 1)) :
      a / b = c
      theorem Ordinal.div_eq_iff {a b c : Ordinal.{u_4}} (hb : b 0) :
      a / b = c b * c a a < b * (c + 1)

      Characterization of a / b = c assuming b ≠ 0. See div_eq_iff' for a version assuming c ≠ 0 instead.

      theorem Ordinal.div_eq_iff' {a b c : Ordinal.{u_4}} (hc : c 0) :
      a / b = c b * c a a < b * (c + 1)

      Characterization of a / b = c assuming c ≠ 0. See div_eq_iff for a version assuming b ≠ 0 instead.

      theorem Ordinal.div_eq_one_iff {a b : Ordinal.{u_4}} :
      a / b = 1 b a a < b * 2
      @[simp]
      theorem Ordinal.div_one (a : Ordinal.{u_4}) :
      a / 1 = a
      @[simp]
      theorem Ordinal.div_self {a : Ordinal.{u_4}} (h : a 0) :
      a / a = 1
      theorem Ordinal.mul_sub (a b c : Ordinal.{u_4}) :
      a * (b - c) = a * b - a * c
      theorem Ordinal.dvd_add_iff {a b c : Ordinal.{u_4}} :
      a b → (a b + c a c)
      theorem Ordinal.div_mul_cancel {a b : Ordinal.{u_4}} :
      a 0a ba * (b / a) = b
      theorem Ordinal.le_of_dvd {a b : Ordinal.{u_4}} (b0 : b 0) (h : a b) :
      a b
      theorem Ordinal.dvd_antisymm {a b : Ordinal.{u_4}} (h₁ : a b) (h₂ : b a) :
      a = b
      @[instance_reducible]
      noncomputable instance Ordinal.mod :

      a % b is the unique ordinal r satisfying a = b * q + r with r < b.

      Equations
      theorem Ordinal.mod_def (a b : Ordinal.{u_4}) :
      a % b = a - b * (a / b)
      theorem Ordinal.mod_le (a b : Ordinal.{u_4}) :
      a % b a
      @[simp]
      theorem Ordinal.mod_zero (a : Ordinal.{u_4}) :
      a % 0 = a
      theorem Ordinal.mod_eq_of_lt {a b : Ordinal.{u_4}} (h : a < b) :
      a % b = a
      @[simp]
      theorem Ordinal.zero_mod (b : Ordinal.{u_4}) :
      0 % b = 0
      theorem Ordinal.div_add_mod (a b : Ordinal.{u_4}) :
      b * (a / b) + a % b = a
      theorem Ordinal.mod_lt (a : Ordinal.{u_4}) {b : Ordinal.{u_4}} (h : b 0) :
      a % b < b
      @[simp]
      theorem Ordinal.mod_self (a : Ordinal.{u_4}) :
      a % a = 0
      @[simp]
      theorem Ordinal.mod_one (a : Ordinal.{u_4}) :
      a % 1 = 0
      theorem Ordinal.dvd_of_mod_eq_zero {a b : Ordinal.{u_4}} (H : a % b = 0) :
      b a
      theorem Ordinal.mod_eq_zero_of_dvd {a b : Ordinal.{u_4}} (H : b a) :
      a % b = 0
      @[simp]
      theorem Ordinal.mul_add_mod_self (x y z : Ordinal.{u_4}) :
      (x * y + z) % x = z % x
      @[simp]
      theorem Ordinal.mul_mod (x y : Ordinal.{u_4}) :
      x * y % x = 0
      theorem Ordinal.mul_add_mod_mul {w x : Ordinal.{u_4}} (hw : w < x) (y z : Ordinal.{u_4}) :
      (x * y + w) % (x * z) = x * (y % z) + w
      theorem Ordinal.mul_mod_mul (x y z : Ordinal.{u_4}) :
      x * y % (x * z) = x * (y % z)
      theorem Ordinal.mod_mod_of_dvd (a : Ordinal.{u_4}) {b c : Ordinal.{u_4}} (h : c b) :
      a % b % c = a % c
      @[simp]
      theorem Ordinal.mod_mod (a b : Ordinal.{u_4}) :
      a % b % b = a % b
      theorem Ordinal.lt_mul_iff {a b c : Ordinal.{u_4}} :
      a < b * c q < c, r < b, a = b * q + r
      theorem Ordinal.forall_lt_mul {b c : Ordinal.{u_4}} {P : Ordinal.{u_4}Prop} :
      (∀ a < b * c, P a) q < c, r < b, P (b * q + r)
      theorem Ordinal.exists_lt_mul {b c : Ordinal.{u_4}} {P : Ordinal.{u_4}Prop} :
      (∃ a < b * c, P a) q < c, r < b, P (b * q + r)

      Casting naturals into ordinals, compatibility with operations #

      @[deprecated Nat.cast_add_one_comm (since := "2026-05-10")]
      theorem Ordinal.one_add_natCast (m : ) :
      1 + m = (Order.succ m)
      @[deprecated Nat.cast_add_one_comm (since := "2026-05-10")]
      @[simp]
      theorem Ordinal.natCast_mul (m n : ) :
      ↑(m * n) = m * n
      @[simp]
      theorem Ordinal.natCast_sub (m n : ) :
      ↑(m - n) = m - n
      @[simp]
      theorem Ordinal.natCast_div (m n : ) :
      ↑(m / n) = m / n
      @[simp]
      theorem Ordinal.natCast_mod (m n : ) :
      ↑(m % n) = m % n
      @[simp]
      theorem Ordinal.lift_natCast (n : ) :
      lift.{u, v} n = n
      @[simp]
      theorem Ordinal.typein_lt_fin {n : } (x : Fin n) :
      @[simp]
      theorem Ordinal.enum_lt_fin {n : } (x : Fin n) :
      (enum LT.lt) x, = x

      Properties of ω #

      theorem Ordinal.lt_omega0 {o : Ordinal.{u_4}} :
      o < omega0 ∃ (n : ), o = n
      @[simp]
      @[deprecated Ordinal.natCast_lt_omega0 (since := "2026-03-08")]
      theorem Ordinal.nat_lt_omega0 (n : ) :
      n < omega0

      Alias of Ordinal.natCast_lt_omega0.

      @[simp]
      theorem Ordinal.enum_lt_nat (x : ) :
      (enum LT.lt) x, = x
      theorem Ordinal.eq_natCast_of_le_natCast {a : Ordinal.{u_4}} {b : } (h : a b) :
      ∃ (c : ), a = c
      @[deprecated Ordinal.eq_natCast_or_omega0_le (since := "2026-03-12")]
      theorem Ordinal.eq_nat_or_omega0_le (o : Ordinal.{u_4}) :
      (∃ (n : ), o = n) omega0 o

      Alias of Ordinal.eq_natCast_or_omega0_le.

      @[simp]
      theorem Ordinal.omega0_le {o : Ordinal.{u_4}} :
      omega0 o ∀ (n : ), n o
      @[simp]
      theorem Ordinal.natCast_add_of_omega0_le {o : Ordinal.{u_4}} (h : omega0 o) (n : ) :
      n + o = o
      @[simp]
      @[deprecated Ordinal.isSuccPrelimit_iff_omega0_dvd (since := "2026-02-01")]
      @[simp]
      theorem Ordinal.natCast_mod_omega0 (n : ) :
      n % omega0 = n
      @[simp]
      @[reducible, inline]

      This can be made a local instance in order to get in Cardinal.aleph0.ord.ToType.

      Equations
      Instances For