mathlib documentation

set_theory.​ordinal_notation

set_theory.​ordinal_notation

Ordinal notations

constructive ordinal arithmetic for ordinals < ε₀.

inductive onote  :
Type

Recursive definition of an ordinal notation. zero denotes the ordinal 0, and oadd e n a is intended to refer to ω^e * n + a. For this to be valid Cantor normal form, we must have the exponents decrease to the right, but we can't state this condition until we've defined repr, so it is a separate definition NF.

@[instance]

Notation for 0

Equations
@[simp]

@[instance]

Equations
@[instance]

Notation for 1

Equations

Notation for ω

Equations
@[simp]

The ordinal denoted by a notation

Equations

Auxiliary definition to print an ordinal notation

Equations

Print an ordinal notation

Equations

Print an ordinal notation

Equations
@[instance]

Equations
theorem onote.​lt_def {x y : onote} :
x < y x.repr < y.repr

theorem onote.​le_def {x y : onote} :
x y x.repr y.repr

@[simp]
def onote.​of_nat  :

Convert a nat into an ordinal

Equations
@[simp]

@[simp]
theorem onote.​repr_of_nat (n : ) :

@[simp]
theorem onote.​repr_one  :
1.repr = 1

theorem onote.​omega_le_oadd (e : onote) (n : ℕ+) (a : onote) :

theorem onote.​oadd_pos (e : onote) (n : ℕ+) (a : onote) :
0 < e.oadd n a

def onote.​cmp  :

Compare ordinal notations

Equations
theorem onote.​eq_of_cmp_eq {o₁ o₂ : onote} :
o₁.cmp o₂ = ordering.eqo₁ = o₂

theorem onote.​zero_lt_one  :
0 < 1

inductive onote.​NF_below  :
onoteordinal → Prop

NF_below o b says that o is a normal form ordinal notation satisfying repr o < ω ^ b.

@[class]
def onote.​NF  :
onote → Prop

A normal form ordinal notation has the form

ω ^ a₁ * n₁ + ω ^ a₂ * n₂ + ... ω ^ aₖ * nₖ

where a₁ > a₂ > ... > aₖ and all the aᵢ are also in normal form.

We will essentially only be interested in normal form ordinal notations, but to avoid complicating the algorithms we define everything over general ordinal notations and only prove correctness with normal form as an invariant.

Equations
Instances
@[instance]

Equations
theorem onote.​NF_below.​oadd {e : onote} {n : ℕ+} {a : onote} {b : ordinal} :
onote.NF ea.NF_below e.repre.repr < b(e.oadd n a).NF_below b

theorem onote.​NF_below.​fst {e : onote} {n : ℕ+} {a : onote} {b : ordinal} :
(e.oadd n a).NF_below bonote.NF e

theorem onote.​NF.​fst {e : onote} {n : ℕ+} {a : onote} :
onote.NF (e.oadd n a)onote.NF e

theorem onote.​NF_below.​snd {e : onote} {n : ℕ+} {a : onote} {b : ordinal} :
(e.oadd n a).NF_below ba.NF_below e.repr

theorem onote.​NF.​snd' {e : onote} {n : ℕ+} {a : onote} :
onote.NF (e.oadd n a)a.NF_below e.repr

theorem onote.​NF.​snd {e : onote} {n : ℕ+} {a : onote} :
onote.NF (e.oadd n a)onote.NF a

theorem onote.​NF.​oadd {e a : onote} (h₁ : onote.NF e) (n : ℕ+) :
a.NF_below e.repronote.NF (e.oadd n a)

@[instance]
def onote.​NF.​oadd_zero (e : onote) (n : ℕ+) [h : onote.NF e] :
onote.NF (e.oadd n 0)

Equations
  • _ = _
theorem onote.​NF_below.​lt {e : onote} {n : ℕ+} {a : onote} {b : ordinal} :
(e.oadd n a).NF_below be.repr < b

theorem onote.​NF_below_zero {o : onote} :
o.NF_below 0 o = 0

theorem onote.​NF.​zero_of_zero {e : onote} {n : ℕ+} {a : onote} :
onote.NF (e.oadd n a)e = 0a = 0

theorem onote.​NF_below.​mono {o : onote} {b₁ b₂ : ordinal} :
b₁ b₂o.NF_below b₁o.NF_below b₂

theorem onote.​NF.​below_of_lt {e : onote} {n : ℕ+} {a : onote} {b : ordinal} :
e.repr < bonote.NF (e.oadd n a)(e.oadd n a).NF_below b

@[instance]

Equations
  • _ = _
@[instance]

Equations
theorem onote.​oadd_lt_oadd_1 {e₁ : onote} {n₁ : ℕ+} {o₁ e₂ : onote} {n₂ : ℕ+} {o₂ : onote} :
onote.NF (e₁.oadd n₁ o₁)e₁ < e₂e₁.oadd n₁ o₁ < e₂.oadd n₂ o₂

theorem onote.​oadd_lt_oadd_2 {e o₁ o₂ : onote} {n₁ n₂ : ℕ+} :
onote.NF (e.oadd n₁ o₁)n₁ < n₂e.oadd n₁ o₁ < e.oadd n₂ o₂

theorem onote.​oadd_lt_oadd_3 {e : onote} {n : ℕ+} {a₁ a₂ : onote} :
a₁ < a₂e.oadd n a₁ < e.oadd n a₂

theorem onote.​cmp_compares (a b : onote) [onote.NF a] [onote.NF b] :
(a.cmp b).compares a b

theorem onote.​repr_inj {a b : onote} [onote.NF a] [onote.NF b] :
a.repr = b.repr a = b

theorem onote.​NF.​of_dvd_omega_power {b : ordinal} {e : onote} {n : ℕ+} {a : onote} :
onote.NF (e.oadd n a)ordinal.omega ^ b (e.oadd n a).reprb e.repr ordinal.omega ^ b a.repr

theorem onote.​NF.​of_dvd_omega {e : onote} {n : ℕ+} {a : onote} :

def onote.​top_below  :
onoteonote → Prop

top_below b o asserts that the largest exponent in o, if it exists, is less than b. This is an auxiliary definition for decidability of NF.

Equations
@[instance]

Equations
def onote.​add  :
onoteonoteonote

Addition of ordinal notations (correct only for normal input)

Equations
@[instance]

Equations
@[simp]
theorem onote.​zero_add (o : onote) :
0 + o = o

theorem onote.​oadd_add (e : onote) (n : ℕ+) (a o : onote) :
e.oadd n a + o = onote.add._match_1 e n (a + o)

def onote.​sub  :
onoteonoteonote

Subtraction of ordinal notations (correct only for normal input)

Equations
  • (e₁.oadd n₁ a₁).sub (e₂.oadd n₂ a₂) = onote.sub._match_1 e₁ n₁ a₁ n₂ (a₁.sub a₂) (e₁.cmp e₂)
  • (a.oadd a_1 a_2).sub 0 = a.oadd a_1 a_2
  • 0.sub (a.oadd a_1 a_2) = 0
  • 0.sub onote.zero = 0
  • onote.sub._match_1 e₁ n₁ a₁ n₂ _f_1 ordering.gt = e₁.oadd n₁ a₁
  • onote.sub._match_1 e₁ n₁ a₁ n₂ _f_1 ordering.eq = onote.sub._match_2 e₁ n₁ a₁ n₂ _f_1 (n₁ - n₂)
  • onote.sub._match_1 e₁ n₁ a₁ n₂ _f_1 ordering.lt = 0
  • onote.sub._match_2 e₁ n₁ a₁ n₂ _f_1 k.succ = e₁.oadd k.succ_pnat a₁
  • onote.sub._match_2 e₁ n₁ a₁ n₂ _f_1 0 = ite (n₁ = n₂) _f_1 0
@[instance]

Equations
theorem onote.​add_NF_below {b : ordinal} {o₁ o₂ : onote} :
o₁.NF_below bo₂.NF_below b(o₁ + o₂).NF_below b

@[instance]
def onote.​add_NF (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
onote.NF (o₁ + o₂)

Equations
  • _ = _
@[simp]
theorem onote.​repr_add (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
(o₁ + o₂).repr = o₁.repr + o₂.repr

theorem onote.​sub_NF_below {o₁ o₂ : onote} {b : ordinal} :
o₁.NF_below bonote.NF o₂(o₁ - o₂).NF_below b

@[instance]
def onote.​sub_NF (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
onote.NF (o₁ - o₂)

Equations
  • _ = _
@[simp]
theorem onote.​repr_sub (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
(o₁ - o₂).repr = o₁.repr - o₂.repr

def onote.​mul  :
onoteonoteonote

Multiplication of ordinal notations (correct only for normal input)

Equations
@[instance]

Equations
@[simp]
theorem onote.​zero_mul (o : onote) :
0 * o = 0

@[simp]
theorem onote.​mul_zero (o : onote) :
o * 0 = 0

theorem onote.​oadd_mul (e₁ : onote) (n₁ : ℕ+) (a₁ e₂ : onote) (n₂ : ℕ+) (a₂ : onote) :
e₁.oadd n₁ a₁ * e₂.oadd n₂ a₂ = ite (e₂ = 0) (e₁.oadd (n₁ * n₂) a₁) ((e₁ + e₂).oadd n₂ (e₁.oadd n₁ a₁ * a₂))

theorem onote.​oadd_mul_NF_below {e₁ : onote} {n₁ : ℕ+} {a₁ : onote} {b₁ : ordinal} (h₁ : (e₁.oadd n₁ a₁).NF_below b₁) {o₂ : onote} {b₂ : ordinal} :
o₂.NF_below b₂(e₁.oadd n₁ a₁ * o₂).NF_below (e₁.repr + b₂)

@[instance]
def onote.​mul_NF (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
onote.NF (o₁ * o₂)

Equations
  • _ = _
  • _ = _
@[simp]
theorem onote.​repr_mul (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
(o₁ * o₂).repr = o₁.repr * o₂.repr

Calculate division and remainder of o mod ω. split' o = (a, n) means o = ω * a + n.

Equations

Calculate division and remainder of o mod ω. split o = (a, n) means o = a + n, where ω ∣ a.

Equations
def onote.​scale  :
onoteonoteonote

scale x o is the ordinal notation for ω ^ x * o.

Equations
def onote.​mul_nat  :
onoteonote

mul_nat o n is the ordinal notation for o * n.

Equations
def onote.​power_aux  :
onoteonoteonoteonote

Auxiliary definition to compute the ordinal notation for the ordinal exponentiation in power

Equations
def onote.​power  :
onoteonoteonote

power o₁ o₂ calculates the ordinal notation for the ordinal exponential o₁ ^ o₂.

Equations
  • o₁.power o₂ = onote.power._match_1 o₂ o₁.split
  • onote.power._match_1 o₂ (a0.oadd _x _x_1, m) = onote.power._match_3 a0 _x _x_1 m o₂.split
  • onote.power._match_1 o₂ (0, m + 1) = onote.power._match_2 m o₂.split'
  • onote.power._match_1 o₂ (0, 1) = 1
  • onote.power._match_1 o₂ (0, 0) = ite (o₂ = 0) 1 0
  • onote.power._match_3 a0 _x _x_1 m (b, k + 1) = let eb : onote := a0 * b in (eb + a0.mul_nat k).scale (a0.oadd _x _x_1) + eb.power_aux a0 ((a0.oadd _x _x_1).mul_nat m) k m
  • onote.power._match_3 a0 _x _x_1 m (b, 0) = (a0 * b).oadd 1 0
  • onote.power._match_2 m (b', k) = b'.oadd (m.succ_pnat ^ k) 0
theorem onote.​power_def (o₁ o₂ : onote) :
o₁ ^ o₂ = onote.power._match_1 o₂ o₁.split

theorem onote.​split_eq_scale_split' {o o' : onote} {m : } [onote.NF o] :
o.split' = (o', m)o.split = (1.scale o', m)

theorem onote.​NF_repr_split' {o o' : onote} {m : } [onote.NF o] :
o.split' = (o', m)onote.NF o' o.repr = ordinal.omega * o'.repr + m

theorem onote.​scale_eq_mul (x : onote) [onote.NF x] (o : onote) [onote.NF o] :
x.scale o = x.oadd 1 0 * o

@[instance]
def onote.​NF_scale (x : onote) [onote.NF x] (o : onote) [onote.NF o] :

Equations
  • _ = _
@[simp]
theorem onote.​repr_scale (x : onote) [onote.NF x] (o : onote) [onote.NF o] :

theorem onote.​NF_repr_split {o o' : onote} {m : } [onote.NF o] :
o.split = (o', m)onote.NF o' o.repr = o'.repr + m

theorem onote.​split_dvd {o o' : onote} {m : } [onote.NF o] :
o.split = (o', m)ordinal.omega o'.repr

theorem onote.​split_add_lt {o e : onote} {n : ℕ+} {a : onote} {m : } [onote.NF o] :
o.split = (e.oadd n a, m)a.repr + m < ordinal.omega ^ e.repr

@[simp]
theorem onote.​mul_nat_eq_mul (n : ) (o : onote) :

@[instance]
def onote.​NF_mul_nat (o : onote) [onote.NF o] (n : ) :

Equations
  • _ = _
@[instance]
def onote.​NF_power_aux (e a0 a : onote) [onote.NF e] [onote.NF a0] [onote.NF a] (k m : ) :
onote.NF (e.power_aux a0 a k m)

Equations
  • _ = _
  • _ = _
  • _ = _
  • _ = _
@[instance]
def onote.​NF_power (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
onote.NF (o₁ ^ o₂)

Equations
  • _ = _
theorem onote.​scale_power_aux (e a0 a : onote) [onote.NF e] [onote.NF a0] [onote.NF a] (k m : ) :
(e.power_aux a0 a k m).repr = ordinal.omega ^ e.repr * (0.power_aux a0 a k m).repr

theorem onote.​repr_power_aux₁ {e a : onote} [Ne : onote.NF e] [Na : onote.NF a] {a' : ordinal} (e0 : e.repr 0) (h : a' < ordinal.omega ^ e.repr) (aa : a.repr = a') (n : ℕ+) :

theorem onote.​repr_power_aux₂ {a0 a' : onote} [N0 : onote.NF a0] [Na' : onote.NF a'] (m : ) (d : ordinal.omega a'.repr) (e0 : a0.repr 0) (h : a'.repr + m < ordinal.omega ^ a0.repr) (n : ℕ+) (k : ) :
let R : ordinal := (0.power_aux a0 (a0.oadd n a' * onote.of_nat m) k m).repr in (k 0R < (ordinal.omega ^ a0.repr) ^ k.succ) (ordinal.omega ^ a0.repr) ^ k * (ordinal.omega ^ a0.repr * n + a'.repr) + R = (ordinal.omega ^ a0.repr * n + a'.repr + m) ^ k.succ

theorem onote.​repr_power (o₁ o₂ : onote) [onote.NF o₁] [onote.NF o₂] :
(o₁ ^ o₂).repr = o₁.repr ^ o₂.repr

def nonote  :
Type

The type of normal ordinal notations. (It would have been nicer to define this right in the inductive type, but NF o requires repr which requires onote, so all these things would have to be defined at once, which messes up the VM representation.)

Equations
@[instance]

Equations
@[instance]
def nonote.​NF (o : nonote) :

Equations
  • _ = _
def nonote.​mk (o : onote) [h : onote.NF o] :

Construct a nonote from an ordinal notation (and infer normality)

Equations

The ordinal represented by an ordinal notation. (This function is noncomputable because ordinal arithmetic is noncomputable. In computational applications nonote can be used exclusively without reference to ordinal, but this function allows for correctness results to be stated.)

Equations
@[instance]

Equations
@[instance]

Equations
@[instance]

Equations

Convert a natural number to an ordinal notation

Equations

Compare ordinal notations

Equations
theorem nonote.​cmp_compares (a b : nonote) :
(a.cmp b).compares a b

@[instance]

Equations
def nonote.​below  :
nonotenonote → Prop

Asserts that repr a < ω ^ repr b. Used in nonote.rec_on

Equations
def nonote.​oadd (e : nonote) (n : ℕ+) (a : nonote) :
a.below enonote

The oadd pseudo-constructor for nonote

Equations
def nonote.​rec_on {C : nonoteSort u_1} (o : nonote) :
C 0(Π (e : nonote) (n : ℕ+) (a : nonote) (h : a.below e), C eC aC (e.oadd n a h))C o

This is a recursor-like theorem for nonote suggesting an inductive definition, which can't actually be defined this way due to conflicting dependencies.

Equations
@[instance]

Addition of ordinal notations

Equations
theorem nonote.​repr_add (a b : nonote) :
(a + b).repr = a.repr + b.repr

@[instance]

Subtraction of ordinal notations

Equations
theorem nonote.​repr_sub (a b : nonote) :
(a - b).repr = a.repr - b.repr

@[instance]

Multiplication of ordinal notations

Equations
theorem nonote.​repr_mul (a b : nonote) :
(a * b).repr = a.repr * b.repr

Exponentiation of ordinal notations

Equations
theorem nonote.​repr_power (a b : nonote) :