l3lab/ntp-mathlib huggingface dataset:
/-- Inducts on the base `b` expansion of an ordinal. -/
@[elab_as_elim]
noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by
    by_cases h : o = 0
    · 

Proof state:
case pos
b : Ordinal.{?u.2}
C : Ordinal.{?u.2} → Sort u_1
H0 : C 0
H : (o : Ordinal.{?u.2}) → o ≠ 0 → C (o % b ^ log b o) → C o
o : Ordinal.{?u.2}
h : o = 0
⊢ C o

Next tactic:
rw [h]
/-- Inducts on the base `b` expansion of an ordinal. -/
@[elab_as_elim]
noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by
    by_cases h : o = 0
    · rw [h]; 

Proof state:
case pos
b : Ordinal.{?u.2}
C : Ordinal.{?u.2} → Sort u_1
H0 : C 0
H : (o : Ordinal.{?u.2}) → o ≠ 0 → C (o % b ^ log b o) → C o
o : Ordinal.{?u.2}
h : o = 0
⊢ C 0

Next tactic:
exact H0
/-- Inducts on the base `b` expansion of an ordinal. -/
@[elab_as_elim]
noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by
    by_cases h : o = 0
    · rw [h]; exact H0
    · 

Proof state:
case neg
b : Ordinal.{?u.2}
C : Ordinal.{?u.2} → Sort u_1
H0 : C 0
H : (o : Ordinal.{?u.2}) → o ≠ 0 → C (o % b ^ log b o) → C o
o : Ordinal.{?u.2}
h : ¬o = 0
⊢ C o

Next tactic:
exact H o h (CNFRec _ H0 H (o % b ^ log b o))
/-- Inducts on the base `b` expansion of an ordinal. -/
@[elab_as_elim]
noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by
    by_cases h : o = 0
    · rw [h]; exact H0
    · exact H o h (CNFRec _ H0 H (o % b ^ log b o))
    termination_by CNFRec b H0 H o => o
    decreasing_by 

Proof state:
b o : Ordinal.{u_2}
h : ¬o = 0
⊢ (invImage (fun a => a) wellFoundedRelation).1 (o % b ^ log b o) o

Next tactic:
exact mod_opow_log_lt_self b h
@[simp]
theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by
  

Proof state:
C : Ordinal.{u_2} → Sort u_1
b : Ordinal.{u_2}
H0 : C 0
H : (o : Ordinal.{u_2}) → o ≠ 0 → C (o % b ^ log b o) → C o
⊢ CNFRec b H0 H 0 = H0

Next tactic:
rw [CNFRec, dif_pos rfl]
@[simp]
theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by
  rw [CNFRec, dif_pos rfl]
  

Proof state:
C : Ordinal.{u_2} → Sort u_1
b : Ordinal.{u_2}
H0 : C 0
H : (o : Ordinal.{u_2}) → o ≠ 0 → C (o % b ^ log b o) → C o
⊢ Eq.mpr (_ : C 0 = C 0) H0 = H0

Next tactic:
rfl
theorem CNFRec_pos (b : Ordinal) {o : Ordinal} {C : Ordinal → Sort*} (ho : o ≠ 0) (H0 : C 0)
    (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) :
    @CNFRec b C H0 H o = H o ho (@CNFRec b C H0 H _) := by 

Proof state:
b o : Ordinal.{u_2}
C : Ordinal.{u_2} → Sort u_1
ho : o ≠ 0
H0 : C 0
H : (o : Ordinal.{u_2}) → o ≠ 0 → C (o % b ^ log b o) → C o
⊢ CNFRec b H0 H o = H o ho (CNFRec b H0 H (o % b ^ log b o))

Next tactic:
rw [CNFRec, dif_neg ho]
theorem zero_CNF {o : Ordinal} (ho : o ≠ 0) : CNF 0 o = [⟨0, o⟩] := by 

Proof state:
o : Ordinal.{u_1}
ho : o ≠ 0
⊢ CNF 0 o = [(0, o)]

Next tactic:
simp [CNF_ne_zero ho]
theorem one_CNF {o : Ordinal} (ho : o ≠ 0) : CNF 1 o = [⟨0, o⟩] := by 

Proof state:
o : Ordinal.{u_1}
ho : o ≠ 0
⊢ CNF 1 o = [(0, o)]

Next tactic:
simp [CNF_ne_zero ho]
theorem CNF_of_le_one {b o : Ordinal} (hb : b ≤ 1) (ho : o ≠ 0) : CNF b o = [⟨0, o⟩] := by
  

Proof state:
b o : Ordinal.{u_1}
hb : b ≤ 1
ho : o ≠ 0
⊢ CNF b o = [(0, o)]

Next tactic:
rcases le_one_iff.1 hb with (rfl | rfl)
theorem CNF_of_le_one {b o : Ordinal} (hb : b ≤ 1) (ho : o ≠ 0) : CNF b o = [⟨0, o⟩] := by
  rcases le_one_iff.1 hb with (rfl | rfl)
  · 

Proof state:
case inl
o : Ordinal.{u_1}
ho : o ≠ 0
hb : 0 ≤ 1
⊢ CNF 0 o = [(0, o)]

Next tactic:
exact zero_CNF ho
theorem CNF_of_le_one {b o : Ordinal} (hb : b ≤ 1) (ho : o ≠ 0) : CNF b o = [⟨0, o⟩] := by
  rcases le_one_iff.1 hb with (rfl | rfl)
  · exact zero_CNF ho
  · 

Proof state:
case inr
o : Ordinal.{u_1}
ho : o ≠ 0
hb : 1 ≤ 1
⊢ CNF 1 o = [(0, o)]

Next tactic:
exact one_CNF ho
theorem CNF_of_lt {b o : Ordinal} (ho : o ≠ 0) (hb : o < b) : CNF b o = [⟨0, o⟩] := by
  

Proof state:
b o : Ordinal.{u_1}
ho : o ≠ 0
hb : o < b
⊢ CNF b o = [(0, o)]

Next tactic:
simp only [CNF_ne_zero ho, log_eq_zero hb, opow_zero, div_one, mod_one, CNF_zero]
/-- Evaluating the Cantor normal form of an ordinal returns the ordinal. -/
theorem CNF_foldr (b o : Ordinal) : (CNF b o).foldr (fun p r ↦ b ^ p.1 * p.2 + r) 0 = o :=
  CNFRec b (by 

Proof state:
b o : Ordinal.{u_1}
⊢ foldr (fun p r => b ^ p.1 * p.2 + r) 0 (CNF b 0) = 0

Next tactic:
rw [CNF_zero]
/-- Evaluating the Cantor normal form of an ordinal returns the ordinal. -/
theorem CNF_foldr (b o : Ordinal) : (CNF b o).foldr (fun p r ↦ b ^ p.1 * p.2 + r) 0 = o :=
  CNFRec b (by rw [CNF_zero]; 

Proof state:
b o : Ordinal.{u_1}
⊢ foldr (fun p r => b ^ p.1 * p.2 + r) 0 [] = 0

Next tactic:
rfl
/-- Evaluating the Cantor normal form of an ordinal returns the ordinal. -/
theorem CNF_foldr (b o : Ordinal) : (CNF b o).foldr (fun p r ↦ b ^ p.1 * p.2 + r) 0 = o :=
  CNFRec b (by rw [CNF_zero]; rfl)
    (fun o ho IH ↦ by 

Proof state:
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : foldr (fun p r => b ^ p.1 * p.2 + r) 0 (CNF b (o % b ^ log b o)) = o % b ^ log b o
⊢ foldr (fun p r => b ^ p.1 * p.2 + r) 0 (CNF b o) = o

Next tactic:
rw [CNF_ne_zero ho, foldr_cons, IH, div_add_mod]
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  

Proof state:
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b o → x.1 ≤ log b o

Next tactic:
refine' CNFRec b _ (fun o ho H ↦ _) o
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · 

Proof state:
case refine'_1
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b 0 → x.1 ≤ log b 0

Next tactic:
rw [CNF_zero]
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    

Proof state:
case refine'_1
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ [] → x.1 ≤ log b 0

Next tactic:
intro contra
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    intro contra; 

Proof state:
case refine'_1
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
contra : x ∈ []
⊢ x.1 ≤ log b 0

Next tactic:
contradiction
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    intro contra; contradiction
  · 

Proof state:
case refine'_2
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
H : x ∈ CNF b (o % b ^ log b o) → x.1 ≤ log b (o % b ^ log b o)
⊢ x ∈ CNF b o → x.1 ≤ log b o

Next tactic:
rw [CNF_ne_zero ho, mem_cons]
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    intro contra; contradiction
  · rw [CNF_ne_zero ho, mem_cons]
    

Proof state:
case refine'_2
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
H : x ∈ CNF b (o % b ^ log b o) → x.1 ≤ log b (o % b ^ log b o)
⊢ x = (log b o, o / b ^ log b o) ∨ x ∈ CNF b (o % b ^ log b o) → x.1 ≤ log b o

Next tactic:
rintro (rfl | h)
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    intro contra; contradiction
  · rw [CNF_ne_zero ho, mem_cons]
    rintro (rfl | h)
    · 

Proof state:
case refine'_2.inl
b o✝ o : Ordinal.{u}
ho : o ≠ 0
H : (log b o, o / b ^ log b o) ∈ CNF b (o % b ^ log b o) → (log b o, o / b ^ log b o).1 ≤ log b (o % b ^ log b o)
⊢ (log b o, o / b ^ log b o).1 ≤ log b o

Next tactic:
exact le_rfl
/-- Every exponent in the Cantor normal form `CNF b o` is less or equal to `log b o`. -/
theorem CNF_fst_le_log {b o : Ordinal.{u}} {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.1 ≤ log b o := by
  refine' CNFRec b _ (fun o ho H ↦ _) o
  · rw [CNF_zero]
    intro contra; contradiction
  · rw [CNF_ne_zero ho, mem_cons]
    rintro (rfl | h)
    · exact le_rfl
    · 

Proof state:
case refine'_2.inr
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
H : x ∈ CNF b (o % b ^ log b o) → x.1 ≤ log b (o % b ^ log b o)
h : x ∈ CNF b (o % b ^ log b o)
⊢ x.1 ≤ log b o

Next tactic:
exact (H h).trans (log_mono_right _ (mod_opow_log_lt_self b ho).le)
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  

Proof state:
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b o → 0 < x.2

Next tactic:
refine' CNFRec b (by simp) (fun o ho IH ↦ _) o
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  refine' CNFRec b (by 

Proof state:
b o : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b 0 → 0 < x.2

Next tactic:
simp
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  refine' CNFRec b (by simp) (fun o ho IH ↦ _) o
  

Proof state:
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → 0 < x.2
⊢ x ∈ CNF b o → 0 < x.2

Next tactic:
rw [CNF_ne_zero ho]
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  refine' CNFRec b (by simp) (fun o ho IH ↦ _) o
  rw [CNF_ne_zero ho]
  

Proof state:
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → 0 < x.2
⊢ x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o) → 0 < x.2

Next tactic:
rintro (h | ⟨_, h⟩)
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  refine' CNFRec b (by simp) (fun o ho IH ↦ _) o
  rw [CNF_ne_zero ho]
  rintro (h | ⟨_, h⟩)
  · 

Proof state:
case head
b o✝ o : Ordinal.{u}
ho : o ≠ 0
IH : (log b o, o / b ^ log b o) ∈ CNF b (o % b ^ log b o) → 0 < (log b o, o / b ^ log b o).2
⊢ 0 < (log b o, o / b ^ log b o).2

Next tactic:
exact div_opow_log_pos b ho
/-- Every coefficient in a Cantor normal form is positive. -/
theorem CNF_lt_snd {b o : Ordinal.{u}} {x : Ordinal × Ordinal} : x ∈ CNF b o → 0 < x.2 := by
  refine' CNFRec b (by simp) (fun o ho IH ↦ _) o
  rw [CNF_ne_zero ho]
  rintro (h | ⟨_, h⟩)
  · exact div_opow_log_pos b ho
  · 

Proof state:
case tail
b o✝ : Ordinal.{u}
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → 0 < x.2
h : Mem x (CNF b (o % b ^ log b o))
⊢ 0 < x.2

Next tactic:
exact IH h
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  

Proof state:
b o : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b o → x.2 < b

Next tactic:
refine' CNFRec b _ (fun o ho IH ↦ _) o
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · 

Proof state:
case refine'_1
b o : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
⊢ x ∈ CNF b 0 → x.2 < b

Next tactic:
simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · 

Proof state:
case refine'_2
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
⊢ x ∈ CNF b o → x.2 < b

Next tactic:
rw [CNF_ne_zero ho]
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · rw [CNF_ne_zero ho]
    

Proof state:
case refine'_2
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
⊢ x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o) → x.2 < b

Next tactic:
intro h
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · rw [CNF_ne_zero ho]
    intro h
    

Proof state:
case refine'_2
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
h : x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o)
⊢ x.2 < b

Next tactic:
cases' (mem_cons.mp h) with h h
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · rw [CNF_ne_zero ho]
    intro h
    cases' (mem_cons.mp h) with h h
    · 

Proof state:
case refine'_2.inl
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
h✝ : x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o)
h : x = (log b o, o / b ^ log b o)
⊢ x.2 < b

Next tactic:
rw [h]
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · rw [CNF_ne_zero ho]
    intro h
    cases' (mem_cons.mp h) with h h
    · rw [h]; 

Proof state:
case refine'_2.inl
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
h✝ : x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o)
h : x = (log b o, o / b ^ log b o)
⊢ (log b o, o / b ^ log b o).2 < b

Next tactic:
simpa only using div_opow_log_lt o hb
/-- Every coefficient in the Cantor normal form `CNF b o` is less than `b`. -/
theorem CNF_snd_lt {b o : Ordinal.{u}} (hb : 1 < b) {x : Ordinal × Ordinal} :
    x ∈ CNF b o → x.2 < b := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [CNF_zero, not_mem_nil, IsEmpty.forall_iff]
  · rw [CNF_ne_zero ho]
    intro h
    cases' (mem_cons.mp h) with h h
    · rw [h]; simpa only using div_opow_log_lt o hb
    · 

Proof state:
case refine'_2.inr
b o✝ : Ordinal.{u}
hb : 1 < b
x : Ordinal.{u} × Ordinal.{u}
o : Ordinal.{u}
ho : o ≠ 0
IH : x ∈ CNF b (o % b ^ log b o) → x.2 < b
h✝ : x ∈ (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o)
h : x ∈ CNF b (o % b ^ log b o)
⊢ x.2 < b

Next tactic:
exact IH h
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  

Proof state:
b o : Ordinal.{u_1}
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
refine' CNFRec b _ (fun o ho IH ↦ _) o
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · 

Proof state:
case refine'_1
b o : Ordinal.{u_1}
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b 0))

Next tactic:
simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · 

Proof state:
case refine'_2
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
rcases le_or_lt b 1 with hb | hb
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · 

Proof state:
case refine'_2.inl
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : b ≤ 1
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · 

Proof state:
case refine'_2.inr
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
cases' lt_or_le o b with hob hbo
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · 

Proof state:
case refine'_2.inr.inl
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hob : o < b
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
      · 

Proof state:
case refine'_2.inr.inr
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hbo : b ≤ o
⊢ Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b o))

Next tactic:
rw [CNF_ne_zero ho, map_cons, sorted_cons]
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
      · rw [CNF_ne_zero ho, map_cons, sorted_cons]
        

Proof state:
case refine'_2.inr.inr
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hbo : b ≤ o
⊢ (∀ b_1 ∈ map Prod.fst (CNF b (o % b ^ log b o)), (log b o, o / b ^ log b o).1 > b_1) ∧
    Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))

Next tactic:
refine' ⟨fun a H ↦ _, IH⟩
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
      · rw [CNF_ne_zero ho, map_cons, sorted_cons]
        refine' ⟨fun a H ↦ _, IH⟩
        

Proof state:
case refine'_2.inr.inr
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hbo : b ≤ o
a : Ordinal.{u_1}
H : a ∈ map Prod.fst (CNF b (o % b ^ log b o))
⊢ (log b o, o / b ^ log b o).1 > a

Next tactic:
rw [mem_map] at H
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
      · rw [CNF_ne_zero ho, map_cons, sorted_cons]
        refine' ⟨fun a H ↦ _, IH⟩
        rw [mem_map] at H
        

Proof state:
case refine'_2.inr.inr
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hbo : b ≤ o
a : Ordinal.{u_1}
H : ∃ a_1 ∈ CNF b (o % b ^ log b o), a_1.1 = a
⊢ (log b o, o / b ^ log b o).1 > a

Next tactic:
rcases H with ⟨⟨a, a'⟩, H, rfl⟩
/-- The exponents of the Cantor normal form are decreasing. -/
theorem CNF_sorted (b o : Ordinal) : ((CNF b o).map Prod.fst).Sorted (· > ·) := by
  refine' CNFRec b _ (fun o ho IH ↦ _) o
  · simp only [gt_iff_lt, CNF_zero, map_nil, sorted_nil]
  · rcases le_or_lt b 1 with hb | hb
    · simp only [CNF_of_le_one hb ho, gt_iff_lt, map_cons, map, sorted_singleton]
    · cases' lt_or_le o b with hob hbo
      · simp only [CNF_of_lt ho hob, gt_iff_lt, map_cons, map, sorted_singleton]
      · rw [CNF_ne_zero ho, map_cons, sorted_cons]
        refine' ⟨fun a H ↦ _, IH⟩
        rw [mem_map] at H
        rcases H with ⟨⟨a, a'⟩, H, rfl⟩
        

Proof state:
case refine'_2.inr.inr.intro.mk.intro
b o✝ o : Ordinal.{u_1}
ho : o ≠ 0
IH : Sorted (fun x x_1 => x > x_1) (map Prod.fst (CNF b (o % b ^ log b o)))
hb : 1 < b
hbo : b ≤ o
a a' : Ordinal.{u_1}
H : (a, a') ∈ CNF b (o % b ^ log b o)
⊢ (log b o, o / b ^ log b o).1 > (a, a').1

Next tactic:
exact (CNF_fst_le_log H).trans_lt (log_mod_opow_log_lt_log_self hb ho hbo)