l3lab/ntp-mathlib huggingface dataset:
theorem cmp_compares : ∀ (a b : ONote) [NF a] [NF b], (cmp a b).Compares a b
  | 0, 0, _, _ => rfl
  | oadd e n a, 0, _, _ => oadd_pos _ _ _
  | 0, oadd e n a, _, _ => oadd_pos _ _ _
  | o₁@(oadd e₁ n₁ a₁), o₂@(oadd e₂ n₂ a₂), h₁, h₂ => by -- TODO: golf
    rw [cmp]
    have IHe := @cmp_compares _ _ h₁.fst h₂.fst
    simp only [Ordering.Compares, gt_iff_lt] at IHe; revert IHe
    cases cmp e₁ e₂
    case lt => intro IHe; exact oadd_lt_oadd_1 h₁ IHe
    case gt => intro IHe; exact oadd_lt_oadd_1 h₂ IHe
    case eq =>
      intro IHe; dsimp at IHe; subst IHe
      unfold _root_.cmp; cases nh : cmpUsing (· < ·) (n₁ : ℕ) n₂ <;>
      rw [cmpUsing, ite_eq_iff, not_lt] at nh
      case lt =>
        cases' nh with nh nh
        · exact oadd_lt_oadd_2 h₁ nh.left
        · rw [ite_eq_iff] at nh; cases' nh.right with nh nh <;> cases nh <;> contradiction
      case gt =>
        cases' nh with nh nh
        · cases nh; contradiction
        · cases' nh with _ nh
          rw [ite_eq_iff] at nh; cases' nh with nh nh
          · exact oadd_lt_oadd_2 h₂ nh.left
          · cases nh; contradiction
      cases' nh with nh nh
      · cases nh; contradiction
      cases' nh with nhl nhr
      rw [ite_eq_iff] at nhr
      cases' nhr with nhr nhr
      · cases nhr; contradiction
      obtain rfl := Subtype.eq (eq_of_incomp ⟨(not_lt_of_ge nhl), nhr.left⟩)
      have IHa := @cmp_compares _ _ h₁.snd h₂.snd
      revert IHa; cases cmp a₁ a₂ <;> intro IHa <;> dsimp at IHa
      case lt => exact oadd_lt_oadd_3 IHa
      case gt => exact oadd_lt_oadd_3 IHa
      subst IHa; 

Proof state:
case eq.inr.intro.inr.eq
o₁ e₁ : ONote
n₁ : ℕ+
a₁ : ONote
h✝¹ : o₁ = oadd e₁ n₁ a₁
o₂ : ONote
h₁ : NF (namedPattern o₁ (oadd e₁ n₁ a₁) h✝¹)
nhl : ↑n₁ ≤ ↑n₁
nhr : ¬↑n₁ < ↑n₁ ∧ Ordering.eq = Ordering.eq
h✝ : o₂ = oadd e₁ n₁ a₁
h₂ : NF (namedPattern o₂ (oadd e₁ n₁ a₁) h✝)
⊢ Ordering.Compares (Ordering.orElse Ordering.eq (Ordering.orElse Ordering.eq Ordering.eq))
    (namedPattern o₁ (oadd e₁ n₁ a₁) h✝¹) (namedPattern o₂ (oadd e₁ n₁ a₁) h✝)

Next tactic:
exact rfl
theorem NF.of_dvd_omega_opow {b e n a} (h : NF (ONote.oadd e n a))
    (d : ω ^ b ∣ repr (ONote.oadd e n a)) :
    b ≤ repr e ∧ ω ^ b ∣ repr a := by
  

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
d : ω ^ b ∣ repr (ONote.oadd e n a)
⊢ b ≤ repr e ∧ ω ^ b ∣ repr a

Next tactic:
have := mt repr_inj.1 (fun h => by injection h : ONote.oadd e n a ≠ 0)
theorem NF.of_dvd_omega_opow {b e n a} (h : NF (ONote.oadd e n a))
    (d : ω ^ b ∣ repr (ONote.oadd e n a)) :
    b ≤ repr e ∧ ω ^ b ∣ repr a := by
  have := mt repr_inj.1 (fun h => by 

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a : ONote
h✝ : NF (ONote.oadd e n a)
d : ω ^ b ∣ repr (ONote.oadd e n a)
h : ONote.oadd e n a = 0
⊢ False

Next tactic:
injection h
theorem NF.of_dvd_omega_opow {b e n a} (h : NF (ONote.oadd e n a))
    (d : ω ^ b ∣ repr (ONote.oadd e n a)) :
    b ≤ repr e ∧ ω ^ b ∣ repr a := by
  have := mt repr_inj.1 (fun h => by injection h : ONote.oadd e n a ≠ 0)
  

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
d : ω ^ b ∣ repr (ONote.oadd e n a)
this : ¬repr (ONote.oadd e n a) = repr 0
⊢ b ≤ repr e ∧ ω ^ b ∣ repr a

Next tactic:
have L := le_of_not_lt fun l => not_le_of_lt (h.below_of_lt l).repr_lt (le_of_dvd this d)
theorem NF.of_dvd_omega_opow {b e n a} (h : NF (ONote.oadd e n a))
    (d : ω ^ b ∣ repr (ONote.oadd e n a)) :
    b ≤ repr e ∧ ω ^ b ∣ repr a := by
  have := mt repr_inj.1 (fun h => by injection h : ONote.oadd e n a ≠ 0)
  have L := le_of_not_lt fun l => not_le_of_lt (h.below_of_lt l).repr_lt (le_of_dvd this d)
  

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
d : ω ^ b ∣ repr (ONote.oadd e n a)
this : ¬repr (ONote.oadd e n a) = repr 0
L : b ≤ repr e
⊢ b ≤ repr e ∧ ω ^ b ∣ repr a

Next tactic:
simp only [repr] at d
theorem NF.of_dvd_omega_opow {b e n a} (h : NF (ONote.oadd e n a))
    (d : ω ^ b ∣ repr (ONote.oadd e n a)) :
    b ≤ repr e ∧ ω ^ b ∣ repr a := by
  have := mt repr_inj.1 (fun h => by injection h : ONote.oadd e n a ≠ 0)
  have L := le_of_not_lt fun l => not_le_of_lt (h.below_of_lt l).repr_lt (le_of_dvd this d)
  simp only [repr] at d
  

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
d : ω ^ b ∣ ω ^ repr e * ↑↑n + repr a
this : ¬repr (ONote.oadd e n a) = repr 0
L : b ≤ repr e
⊢ b ≤ repr e ∧ ω ^ b ∣ repr a

Next tactic:
exact ⟨L, (dvd_add_iff <| (opow_dvd_opow _ L).mul_right _).1 d⟩
theorem NF.of_dvd_omega {e n a} (h : NF (ONote.oadd e n a)) :
    ω ∣ repr (ONote.oadd e n a) → repr e ≠ 0 ∧ ω ∣ repr a := by
  (

Proof state:
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
⊢ ω ∣ repr (ONote.oadd e n a) → repr e ≠ 0 ∧ ω ∣ repr a

Next tactic:
rw [← opow_one ω, ← one_le_iff_ne_zero]
theorem NF.of_dvd_omega {e n a} (h : NF (ONote.oadd e n a)) :
    ω ∣ repr (ONote.oadd e n a) → repr e ≠ 0 ∧ ω ∣ repr a := by
  (rw [← opow_one ω, ← one_le_iff_ne_zero]; 

Proof state:
e : ONote
n : ℕ+
a : ONote
h : NF (ONote.oadd e n a)
⊢ ω ^ 1 ∣ repr (ONote.oadd e n a) → 1 ≤ repr e ∧ ω ^ 1 ∣ repr a

Next tactic:
exact h.of_dvd_omega_opow
instance decidableTopBelow : DecidableRel TopBelow := by
  

Proof state:
⊢ DecidableRel TopBelow

Next tactic:
intro b o
instance decidableTopBelow : DecidableRel TopBelow := by
  intro b o
  

Proof state:
b o : ONote
⊢ Decidable (TopBelow b o)

Next tactic:
cases o
instance decidableTopBelow : DecidableRel TopBelow := by
  intro b o
  cases o <;> 

Proof state:
case zero
b : ONote
⊢ Decidable (TopBelow b zero)

Next tactic:
delta TopBelow
instance decidableTopBelow : DecidableRel TopBelow := by
  intro b o
  cases o <;> 

Proof state:
case oadd
b a✝² : ONote
a✝¹ : ℕ+
a✝ : ONote
⊢ Decidable (TopBelow b (oadd a✝² a✝¹ a✝))

Next tactic:
delta TopBelow
instance decidableTopBelow : DecidableRel TopBelow := by
  intro b o
  cases o <;> delta TopBelow <;> 

Proof state:
case zero
b : ONote
⊢ Decidable
    (match zero with
    | zero => True
    | oadd e a a_1 => cmp e b = Ordering.lt)

Next tactic:
infer_instance
instance decidableTopBelow : DecidableRel TopBelow := by
  intro b o
  cases o <;> delta TopBelow <;> 

Proof state:
case oadd
b a✝² : ONote
a✝¹ : ℕ+
a✝ : ONote
⊢ Decidable
    (match oadd a✝² a✝¹ a✝ with
    | zero => True
    | oadd e a a_1 => cmp e b = Ordering.lt)

Next tactic:
infer_instance
instance decidableNF : DecidablePred NF
  | 0 => isTrue NF.zero
  | oadd e n a => by
    

Proof state:
e : ONote
n : ℕ+
a : ONote
⊢ Decidable (NF (oadd e n a))

Next tactic:
have := decidableNF e
instance decidableNF : DecidablePred NF
  | 0 => isTrue NF.zero
  | oadd e n a => by
    have := decidableNF e
    

Proof state:
e : ONote
n : ℕ+
a : ONote
this : Decidable (NF e)
⊢ Decidable (NF (oadd e n a))

Next tactic:
have := decidableNF a
instance decidableNF : DecidablePred NF
  | 0 => isTrue NF.zero
  | oadd e n a => by
    have := decidableNF e
    have := decidableNF a
    

Proof state:
e : ONote
n : ℕ+
a : ONote
this✝ : Decidable (NF e)
this : Decidable (NF a)
⊢ Decidable (NF (oadd e n a))

Next tactic:
apply decidable_of_iff (NF e ∧ NF a ∧ TopBelow e a)
instance decidableNF : DecidablePred NF
  | 0 => isTrue NF.zero
  | oadd e n a => by
    have := decidableNF e
    have := decidableNF a
    apply decidable_of_iff (NF e ∧ NF a ∧ TopBelow e a)
    

Proof state:
case h
e : ONote
n : ℕ+
a : ONote
this✝ : Decidable (NF e)
this : Decidable (NF a)
⊢ NF e ∧ NF a ∧ TopBelow e a ↔ NF (oadd e n a)

Next tactic:
rw [← and_congr_right fun h => @nfBelow_iff_topBelow _ h _]
instance decidableNF : DecidablePred NF
  | 0 => isTrue NF.zero
  | oadd e n a => by
    have := decidableNF e
    have := decidableNF a
    apply decidable_of_iff (NF e ∧ NF a ∧ TopBelow e a)
    rw [← and_congr_right fun h => @nfBelow_iff_topBelow _ h _]
    

Proof state:
case h
e : ONote
n : ℕ+
a : ONote
this✝ : Decidable (NF e)
this : Decidable (NF a)
⊢ NF e ∧ NFBelow a (repr e) ↔ NF (oadd e n a)

Next tactic:
exact ⟨fun ⟨h₁, h₂⟩ => NF.oadd h₁ n h₂, fun h => ⟨h.fst, h.snd'⟩⟩
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
⊢ NFBelow (oadd e n a + o) b

Next tactic:
have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
h' : NFBelow (a + o) b
⊢ NFBelow (oadd e n a + o) b

Next tactic:
simp [oadd_add]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; 

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
h' : NFBelow (a + o) b
⊢ NFBelow (addAux e n (a + o)) b

Next tactic:
revert h'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; 

Proof state:
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
⊢ NFBelow (a + o) b → NFBelow (addAux e n (a + o)) b

Next tactic:
cases' a + o with e' n' a'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> 

Proof state:
case zero
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
⊢ NFBelow zero b → NFBelow (addAux e n zero) b

Next tactic:
intro h'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> 

Proof state:
case oadd
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
⊢ NFBelow (oadd e' n' a') b → NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
intro h'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · 

Proof state:
case zero
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
h' : NFBelow zero b
⊢ NFBelow (addAux e n zero) b

Next tactic:
exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    

Proof state:
case oadd
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
⊢ NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    

Proof state:
case oadd
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
⊢ NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
cases h: cmp e e'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> 

Proof state:
case oadd.lt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.lt
⊢ NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
dsimp [addAux]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> 

Proof state:
case oadd.eq
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.eq
⊢ NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
dsimp [addAux]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> 

Proof state:
case oadd.gt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.gt
⊢ NFBelow (addAux e n (oadd e' n' a')) b

Next tactic:
dsimp [addAux]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> 

Proof state:
case oadd.lt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.lt
⊢ NFBelow
    (match cmp e e' with
    | Ordering.lt => oadd e' n' a'
    | Ordering.eq => oadd e (n + n') a'
    | Ordering.gt => oadd e n (oadd e' n' a'))
    b

Next tactic:
simp [h]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> 

Proof state:
case oadd.eq
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.eq
⊢ NFBelow
    (match cmp e e' with
    | Ordering.lt => oadd e' n' a'
    | Ordering.eq => oadd e (n + n') a'
    | Ordering.gt => oadd e n (oadd e' n' a'))
    b

Next tactic:
simp [h]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> 

Proof state:
case oadd.gt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.gt
⊢ NFBelow
    (match cmp e e' with
    | Ordering.lt => oadd e' n' a'
    | Ordering.eq => oadd e (n + n') a'
    | Ordering.gt => oadd e n (oadd e' n' a'))
    b

Next tactic:
simp [h]
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · 

Proof state:
case oadd.lt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.lt
⊢ NFBelow (oadd e' n' a') b

Next tactic:
exact h'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · exact h'
    · 

Proof state:
case oadd.eq
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.eq
⊢ NFBelow (oadd e (n + n') a') b

Next tactic:
simp [h] at this
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · exact h'
    · simp [h] at this
      

Proof state:
case oadd.eq
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
h : cmp e e' = Ordering.eq
this : e = e'
⊢ NFBelow (oadd e (n + n') a') b

Next tactic:
subst e'
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · exact h'
    · simp [h] at this
      subst e'
      

Proof state:
case oadd.eq
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e n' a') b
h : cmp e e = Ordering.eq
⊢ NFBelow (oadd e (n + n') a') b

Next tactic:
exact NFBelow.oadd h'.fst h'.snd h'.lt
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · exact h'
    · simp [h] at this
      subst e'
      exact NFBelow.oadd h'.fst h'.snd h'.lt
    · 

Proof state:
case oadd.gt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
this : Ordering.Compares (cmp e e') e e'
h : cmp e e' = Ordering.gt
⊢ NFBelow (oadd e n (oadd e' n' a')) b

Next tactic:
simp [h] at this
theorem add_nfBelow {b} : ∀ {o₁ o₂}, NFBelow o₁ b → NFBelow o₂ b → NFBelow (o₁ + o₂) b
  | 0, _, _, h₂ => h₂
  | oadd e n a, o, h₁, h₂ => by
    have h' := add_nfBelow (h₁.snd.mono <| le_of_lt h₁.lt) h₂
    simp [oadd_add]; revert h'; cases' a + o with e' n' a' <;> intro h'
    · exact NFBelow.oadd h₁.fst NFBelow.zero h₁.lt
    have : ((e.cmp e').Compares e e') := @cmp_compares _ _ h₁.fst h'.fst
    cases h: cmp e e' <;> dsimp [addAux] <;> simp [h]
    · exact h'
    · simp [h] at this
      subst e'
      exact NFBelow.oadd h'.fst h'.snd h'.lt
    · simp [h] at this
      

Proof state:
case oadd.gt
b : Ordinal.{0}
e : ONote
n : ℕ+
a o : ONote
h₁ : NFBelow (oadd e n a) b
h₂ : NFBelow o b
e' : ONote
n' : ℕ+
a' : ONote
h' : NFBelow (oadd e' n' a') b
h : cmp e e' = Ordering.gt
this : e' < e
⊢ NFBelow (oadd e n (oadd e' n' a')) b

Next tactic:
exact NFBelow.oadd h₁.fst (NF.below_of_lt this ⟨⟨_, h'⟩⟩) h₁.lt
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by 

Proof state:
o : ONote
x✝¹ : NF 0
x✝ : NF o
⊢ repr (0 + o) = repr 0 + repr o

Next tactic:
simp
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by simp
  | oadd e n a, o, h₁, h₂ => by
    

Proof state:
e : ONote
n : ℕ+
a o : ONote
h₁ : NF (oadd e n a)
h₂ : NF o
⊢ repr (oadd e n a + o) = repr (oadd e n a) + repr o

Next tactic:
haveI := h₁.snd
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by simp
  | oadd e n a, o, h₁, h₂ => by
    haveI := h₁.snd; 

Proof state:
e : ONote
n : ℕ+
a o : ONote
h₁ : NF (oadd e n a)
h₂ : NF o
this : NF a
⊢ repr (oadd e n a + o) = repr (oadd e n a) + repr o

Next tactic:
have h' := repr_add a o
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by simp
  | oadd e n a, o, h₁, h₂ => by
    haveI := h₁.snd; have h' := repr_add a o
    

Proof state:
e : ONote
n : ℕ+
a o : ONote
h₁ : NF (oadd e n a)
h₂ : NF o
this : NF a
h' : repr (a + o) = repr a + repr o
⊢ repr (oadd e n a + o) = repr (oadd e n a) + repr o

Next tactic:
conv_lhs at h' => simp [HAdd.hAdd, Add.add]
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by simp
  | oadd e n a, o, h₁, h₂ => by
    haveI := h₁.snd; have h' := repr_add a o
    conv_lhs at h' => 

Proof state:
e : ONote
n : ℕ+
a o : ONote
h₁ : NF (oadd e n a)
h₂ : NF o
this : NF a
h' : repr (a + o) = repr a + repr o
| repr (a + o)

Next tactic:
simp [HAdd.hAdd, Add.add]
@[simp]
theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = repr o₁ + repr o₂
  | 0, o, _, _ => by simp
  | oadd e n a, o, h₁, h₂ => by
    haveI := h₁.snd; have h' := repr_add a o
    conv_lhs at h' => simp [HAdd.hAdd, Add.add]
    

Proof state:
e : ONote
n : ℕ+
a o : ONote
h₁ : NF (oadd e n a)
h₂ : NF o
this : NF a
h' : repr (add a o) = repr a + repr o
⊢ repr (oadd e n a + o) = repr (oadd e n a) + repr o

Next tactic:
have nf := ONote.add_nf a o