l3lab/ntp-mathlib huggingface dataset:
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by
  by_contra H; 

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
h : ∀ i < n, (coeff R i) φ = 0
H : ¬↑n ≤ order φ
⊢ False

Next tactic:
rw [not_le] at H
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by
  by_contra H; rw [not_le] at H
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
h : ∀ i < n, (coeff R i) φ = 0
H : order φ < ↑n
⊢ False

Next tactic:
have : (order φ).Dom := PartENat.dom_of_le_natCast H.le
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by
  by_contra H; rw [not_le] at H
  have : (order φ).Dom := PartENat.dom_of_le_natCast H.le
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
h : ∀ i < n, (coeff R i) φ = 0
H : order φ < ↑n
this : (order φ).Dom
⊢ False

Next tactic:
rw [← PartENat.natCast_get this, PartENat.coe_lt_coe] at H
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by
  by_contra H; rw [not_le] at H
  have : (order φ).Dom := PartENat.dom_of_le_natCast H.le
  rw [← PartENat.natCast_get this, PartENat.coe_lt_coe] at H
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
h : ∀ i < n, (coeff R i) φ = 0
this : (order φ).Dom
H : Part.get (order φ) this < n
⊢ False

Next tactic:
exact coeff_order this (h _ H)
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : PartENat
h : ∀ (i : ℕ), ↑i < n → (coeff R i) φ = 0
⊢ n ≤ order φ

Next tactic:
induction n using PartENat.casesOn
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · 

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
h : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
⊢ ⊤ ≤ order φ

Next tactic:
show _ ≤ _
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · show _ ≤ _
    

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
h : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
⊢ ⊤ ≤ order φ

Next tactic:
rw [top_le_iff, order_eq_top]
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · show _ ≤ _
    rw [top_le_iff, order_eq_top]
    

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
h : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
⊢ φ = 0

Next tactic:
ext i
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · show _ ≤ _
    rw [top_le_iff, order_eq_top]
    ext i
    

Proof state:
case a.h
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
h : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
i : ℕ
⊢ (coeff R i) φ = (coeff R i) 0

Next tactic:
exact h _ (PartENat.natCast_lt_top i)
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · show _ ≤ _
    rw [top_le_iff, order_eq_top]
    ext i
    exact h _ (PartENat.natCast_lt_top i)
  · 

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n✝ : ℕ
h : ∀ (i : ℕ), ↑i < ↑n✝ → (coeff R i) φ = 0
⊢ ↑n✝ ≤ order φ

Next tactic:
apply nat_le_order
/-- The order of a formal power series is at least `n` if
the `i`th coefficient is `0` for all `i < n`.-/
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) :
    n ≤ order φ := by
  induction n using PartENat.casesOn
  · show _ ≤ _
    rw [top_le_iff, order_eq_top]
    ext i
    exact h _ (PartENat.natCast_lt_top i)
  · apply nat_le_order
    

Proof state:
case a.h
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n✝ : ℕ
h : ∀ (i : ℕ), ↑i < ↑n✝ → (coeff R i) φ = 0
⊢ ∀ i < n✝, (coeff R i) φ = 0

Next tactic:
simpa only [PartENat.coe_lt_coe] using h
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq_nat {φ : R⟦X⟧} {n : ℕ} :
    order φ = n ↔ coeff R n φ ≠ 0 ∧ ∀ i, i < n → coeff R i φ = 0 := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
⊢ order φ = ↑n ↔ (coeff R n) φ ≠ 0 ∧ ∀ i < n, (coeff R i) φ = 0

Next tactic:
classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simpa using (PartENat.natCast_ne_top _).symm
  simp [order, dif_neg hφ, Nat.find_eq_iff]
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq_nat {φ : R⟦X⟧} {n : ℕ} :
    order φ = n ↔ coeff R n φ ≠ 0 ∧ ∀ i, i < n → coeff R i φ = 0 := by
  classical
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
⊢ order φ = ↑n ↔ (coeff R n) φ ≠ 0 ∧ ∀ i < n, (coeff R i) φ = 0

Next tactic:
rcases eq_or_ne φ 0 with (rfl | hφ)
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq_nat {φ : R⟦X⟧} {n : ℕ} :
    order φ = n ↔ coeff R n φ ≠ 0 ∧ ∀ i, i < n → coeff R i φ = 0 := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · 

Proof state:
case inl
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
n : ℕ
⊢ order 0 = ↑n ↔ (coeff R n) 0 ≠ 0 ∧ ∀ i < n, (coeff R i) 0 = 0

Next tactic:
simpa using (PartENat.natCast_ne_top _).symm
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq_nat {φ : R⟦X⟧} {n : ℕ} :
    order φ = n ↔ coeff R n φ ≠ 0 ∧ ∀ i, i < n → coeff R i φ = 0 := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simpa using (PartENat.natCast_ne_top _).symm
  

Proof state:
case inr
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : ℕ
hφ : φ ≠ 0
⊢ order φ = ↑n ↔ (coeff R n) φ ≠ 0 ∧ ∀ i < n, (coeff R i) φ = 0

Next tactic:
simp [order, dif_neg hφ, Nat.find_eq_iff]
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n : PartENat
⊢ order φ = n ↔ (∀ (i : ℕ), ↑i = n → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < n → (coeff R i) φ = 0

Next tactic:
induction n using PartENat.casesOn
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · 

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
⊢ order φ = ⊤ ↔ (∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0

Next tactic:
rw [order_eq_top]
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
⊢ φ = 0 ↔ (∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0

Next tactic:
constructor
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · 

Proof state:
case a.mp
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
⊢ φ = 0 → (∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0

Next tactic:
rintro rfl
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      

Proof state:
case a.mp
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
⊢ (∀ (i : ℕ), ↑i = ⊤ → (coeff R i) 0 ≠ 0) ∧ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) 0 = 0

Next tactic:
constructor
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> 

Proof state:
case a.mp.left
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
⊢ ∀ (i : ℕ), ↑i = ⊤ → (coeff R i) 0 ≠ 0

Next tactic:
intros
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> 

Proof state:
case a.mp.right
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
⊢ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) 0 = 0

Next tactic:
intros
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · 

Proof state:
case a.mp.left
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
i✝ : ℕ
a✝ : ↑i✝ = ⊤
⊢ (coeff R i✝) 0 ≠ 0

Next tactic:
exfalso
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        

Proof state:
case a.mp.left.h
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
i✝ : ℕ
a✝ : ↑i✝ = ⊤
⊢ False

Next tactic:
exact PartENat.natCast_ne_top ‹_› ‹_›
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        exact PartENat.natCast_ne_top ‹_› ‹_›
      · 

Proof state:
case a.mp.right
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
i✝ : ℕ
a✝ : ↑i✝ < ⊤
⊢ (coeff R i✝) 0 = 0

Next tactic:
exact (coeff _ _).map_zero
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        exact PartENat.natCast_ne_top ‹_› ‹_›
      · exact (coeff _ _).map_zero
    · 

Proof state:
case a.mpr
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
⊢ ((∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0) → φ = 0

Next tactic:
rintro ⟨_h₁, h₂⟩
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        exact PartENat.natCast_ne_top ‹_› ‹_›
      · exact (coeff _ _).map_zero
    · rintro ⟨_h₁, h₂⟩
      

Proof state:
case a.mpr.intro
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
_h₁ : ∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0
h₂ : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
⊢ φ = 0

Next tactic:
ext i
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        exact PartENat.natCast_ne_top ‹_› ‹_›
      · exact (coeff _ _).map_zero
    · rintro ⟨_h₁, h₂⟩
      ext i
      

Proof state:
case a.mpr.intro.h
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
_h₁ : ∀ (i : ℕ), ↑i = ⊤ → (coeff R i) φ ≠ 0
h₂ : ∀ (i : ℕ), ↑i < ⊤ → (coeff R i) φ = 0
i : ℕ
⊢ (coeff R i) φ = (coeff R i) 0

Next tactic:
exact h₂ i (PartENat.natCast_lt_top i)
/-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero,
and the `i`th coefficient is `0` for all `i < n`.-/
theorem order_eq {φ : R⟦X⟧} {n : PartENat} :
    order φ = n ↔ (∀ i : ℕ, ↑i = n → coeff R i φ ≠ 0) ∧ ∀ i : ℕ, ↑i < n → coeff R i φ = 0 := by
  induction n using PartENat.casesOn
  · rw [order_eq_top]
    constructor
    · rintro rfl
      constructor <;> intros
      · exfalso
        exact PartENat.natCast_ne_top ‹_› ‹_›
      · exact (coeff _ _).map_zero
    · rintro ⟨_h₁, h₂⟩
      ext i
      exact h₂ i (PartENat.natCast_lt_top i)
  · 

Proof state:
case a
R : Type u_1
inst✝ : Semiring R
φ✝ φ : R⟦X⟧
n✝ : ℕ
⊢ order φ = ↑n✝ ↔ (∀ (i : ℕ), ↑i = ↑n✝ → (coeff R i) φ ≠ 0) ∧ ∀ (i : ℕ), ↑i < ↑n✝ → (coeff R i) φ = 0

Next tactic:
simpa [PartENat.natCast_inj] using order_eq_nat
/-- The order of the sum of two formal power series
 is at least the minimum of their orders.-/
theorem le_order_add (φ ψ : R⟦X⟧) : min (order φ) (order ψ) ≤ order (φ + ψ) := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
⊢ min (order φ) (order ψ) ≤ order (φ + ψ)

Next tactic:
refine' le_order _ _ _
/-- The order of the sum of two formal power series
 is at least the minimum of their orders.-/
theorem le_order_add (φ ψ : R⟦X⟧) : min (order φ) (order ψ) ≤ order (φ + ψ) := by
  refine' le_order _ _ _
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
⊢ ∀ (i : ℕ), ↑i < min (order φ) (order ψ) → (coeff R i) (φ + ψ) = 0

Next tactic:
simp (config := { contextual := true }) [coeff_of_lt_order]
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
⊢ order (φ + ψ) ≤ order φ ⊓ order ψ

Next tactic:
suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
this : order (φ + ψ) = order φ
⊢ order (φ + ψ) ≤ order φ ⊓ order ψ

Next tactic:
rw [le_inf_iff, this]
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
this : order (φ + ψ) = order φ
⊢ order φ ≤ order φ ∧ order φ ≤ order ψ

Next tactic:
exact ⟨le_rfl, le_of_lt H⟩
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · 

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
⊢ order (φ + ψ) = order φ

Next tactic:
rw [order_eq]
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
⊢ (∀ (i : ℕ), ↑i = order φ → (coeff R i) (φ + ψ) ≠ 0) ∧ ∀ (i : ℕ), ↑i < order φ → (coeff R i) (φ + ψ) = 0

Next tactic:
constructor
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · 

Proof state:
case left
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
⊢ ∀ (i : ℕ), ↑i = order φ → (coeff R i) (φ + ψ) ≠ 0

Next tactic:
intro i hi
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · intro i hi
      

Proof state:
case left
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
i : ℕ
hi : ↑i = order φ
⊢ (coeff R i) (φ + ψ) ≠ 0

Next tactic:
rw [← hi] at H
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · intro i hi
      rw [← hi] at H
      

Proof state:
case left
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
i : ℕ
H : ↑i < order ψ
hi : ↑i = order φ
⊢ (coeff R i) (φ + ψ) ≠ 0

Next tactic:
rw [(coeff _ _).map_add, coeff_of_lt_order i H, add_zero]
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · intro i hi
      rw [← hi] at H
      rw [(coeff _ _).map_add, coeff_of_lt_order i H, add_zero]
      

Proof state:
case left
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
i : ℕ
H : ↑i < order ψ
hi : ↑i = order φ
⊢ (coeff R i) φ ≠ 0

Next tactic:
exact (order_eq_nat.1 hi.symm).1
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · intro i hi
      rw [← hi] at H
      rw [(coeff _ _).map_add, coeff_of_lt_order i H, add_zero]
      exact (order_eq_nat.1 hi.symm).1
    · 

Proof state:
case right
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
⊢ ∀ (i : ℕ), ↑i < order φ → (coeff R i) (φ + ψ) = 0

Next tactic:
intro i hi
private theorem order_add_of_order_eq.aux (φ ψ : R⟦X⟧) (_h : order φ ≠ order ψ)
    (H : order φ < order ψ) : order (φ + ψ) ≤ order φ ⊓ order ψ := by
  suffices order (φ + ψ) = order φ by
    rw [le_inf_iff, this]
    exact ⟨le_rfl, le_of_lt H⟩
  · rw [order_eq]
    constructor
    · intro i hi
      rw [← hi] at H
      rw [(coeff _ _).map_add, coeff_of_lt_order i H, add_zero]
      exact (order_eq_nat.1 hi.symm).1
    · intro i hi
      

Proof state:
case right
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
_h : order φ ≠ order ψ
H : order φ < order ψ
i : ℕ
hi : ↑i < order φ
⊢ (coeff R i) (φ + ψ) = 0

Next tactic:
rw [(coeff _ _).map_add, coeff_of_lt_order i hi, coeff_of_lt_order i (lt_trans hi H),
        zero_add]
/-- The order of the sum of two formal power series
 is the minimum of their orders if their orders differ.-/
theorem order_add_of_order_eq (φ ψ : R⟦X⟧) (h : order φ ≠ order ψ) :
    order (φ + ψ) = order φ ⊓ order ψ := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
h : order φ ≠ order ψ
⊢ order (φ + ψ) = order φ ⊓ order ψ

Next tactic:
refine' le_antisymm _ (le_order_add _ _)
/-- The order of the sum of two formal power series
 is the minimum of their orders if their orders differ.-/
theorem order_add_of_order_eq (φ ψ : R⟦X⟧) (h : order φ ≠ order ψ) :
    order (φ + ψ) = order φ ⊓ order ψ := by
  refine' le_antisymm _ (le_order_add _ _)
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
h : order φ ≠ order ψ
⊢ order (φ + ψ) ≤ order φ ⊓ order ψ

Next tactic:
by_cases H₁ : order φ < order ψ
/-- The order of the sum of two formal power series
 is the minimum of their orders if their orders differ.-/
theorem order_add_of_order_eq (φ ψ : R⟦X⟧) (h : order φ ≠ order ψ) :
    order (φ + ψ) = order φ ⊓ order ψ := by
  refine' le_antisymm _ (le_order_add _ _)
  by_cases H₁ : order φ < order ψ
  · 

Proof state:
case pos
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
h : order φ ≠ order ψ
H₁ : order φ < order ψ
⊢ order (φ + ψ) ≤ order φ ⊓ order ψ

Next tactic:
apply order_add_of_order_eq.aux _ _ h H₁
/-- The order of the sum of two formal power series
 is the minimum of their orders if their orders differ.-/
theorem order_add_of_order_eq (φ ψ : R⟦X⟧) (h : order φ ≠ order ψ) :
    order (φ + ψ) = order φ ⊓ order ψ := by
  refine' le_antisymm _ (le_order_add _ _)
  by_cases H₁ : order φ < order ψ
  · apply order_add_of_order_eq.aux _ _ h H₁
  

Proof state:
case neg
R : Type u_1
inst✝ : Semiring R
φ✝ φ ψ : R⟦X⟧
h : order φ ≠ order ψ
H₁ : ¬order φ < order ψ
⊢ order (φ + ψ) ≤ order φ ⊓ order ψ

Next tactic:
by_cases H₂ : order ψ < order φ