l3lab/ntp-mathlib huggingface dataset:
theorem coeff_mul_prod_one_sub_of_lt_order {R ι : Type*} [CommRing R] (k : ℕ) (s : Finset ι)
    (φ : R⟦X⟧) (f : ι → R⟦X⟧) :
    (∀ i ∈ s, ↑k < (f i).order) → coeff R k (φ * ∏ i in s, (1 - f i)) = coeff R k φ := by
  classical
  induction' s using Finset.induction_on with a s ha ih t
  · simp
  · intro t
    

Proof state:
case insert
R✝ : Type u_1
inst✝¹ : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
ι : Type u_3
inst✝ : CommRing R
k : ℕ
φ : R⟦X⟧
f : ι → R⟦X⟧
a : ι
s : Finset ι
ha : a ∉ s
ih : (∀ i ∈ s, ↑k < order (f i)) → (coeff R k) (φ * ∏ i in s, (1 - f i)) = (coeff R k) φ
t : ∀ i ∈ insert a s, ↑k < order (f i)
⊢ (coeff R k) (φ * ∏ i in insert a s, (1 - f i)) = (coeff R k) φ

Next tactic:
simp only [Finset.mem_insert, forall_eq_or_imp] at t
theorem coeff_mul_prod_one_sub_of_lt_order {R ι : Type*} [CommRing R] (k : ℕ) (s : Finset ι)
    (φ : R⟦X⟧) (f : ι → R⟦X⟧) :
    (∀ i ∈ s, ↑k < (f i).order) → coeff R k (φ * ∏ i in s, (1 - f i)) = coeff R k φ := by
  classical
  induction' s using Finset.induction_on with a s ha ih t
  · simp
  · intro t
    simp only [Finset.mem_insert, forall_eq_or_imp] at t
    

Proof state:
case insert
R✝ : Type u_1
inst✝¹ : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
ι : Type u_3
inst✝ : CommRing R
k : ℕ
φ : R⟦X⟧
f : ι → R⟦X⟧
a : ι
s : Finset ι
ha : a ∉ s
ih : (∀ i ∈ s, ↑k < order (f i)) → (coeff R k) (φ * ∏ i in s, (1 - f i)) = (coeff R k) φ
t : ↑k < order (f a) ∧ ∀ a ∈ s, ↑k < order (f a)
⊢ (coeff R k) (φ * ∏ i in insert a s, (1 - f i)) = (coeff R k) φ

Next tactic:
rw [Finset.prod_insert ha, ← mul_assoc, mul_right_comm, coeff_mul_one_sub_of_lt_order _ t.1]
theorem coeff_mul_prod_one_sub_of_lt_order {R ι : Type*} [CommRing R] (k : ℕ) (s : Finset ι)
    (φ : R⟦X⟧) (f : ι → R⟦X⟧) :
    (∀ i ∈ s, ↑k < (f i).order) → coeff R k (φ * ∏ i in s, (1 - f i)) = coeff R k φ := by
  classical
  induction' s using Finset.induction_on with a s ha ih t
  · simp
  · intro t
    simp only [Finset.mem_insert, forall_eq_or_imp] at t
    rw [Finset.prod_insert ha, ← mul_assoc, mul_right_comm, coeff_mul_one_sub_of_lt_order _ t.1]
    

Proof state:
case insert
R✝ : Type u_1
inst✝¹ : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
ι : Type u_3
inst✝ : CommRing R
k : ℕ
φ : R⟦X⟧
f : ι → R⟦X⟧
a : ι
s : Finset ι
ha : a ∉ s
ih : (∀ i ∈ s, ↑k < order (f i)) → (coeff R k) (φ * ∏ i in s, (1 - f i)) = (coeff R k) φ
t : ↑k < order (f a) ∧ ∀ a ∈ s, ↑k < order (f a)
⊢ (coeff R k) (φ * ∏ x in s, (1 - f x)) = (coeff R k) φ

Next tactic:
exact ih t.2
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
⊢ X ^ Part.get (order φ) h ∣ φ

Next tactic:
refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  

Proof state:
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
⊢ φ = X ^ Part.get (order φ) h * mk fun n => (coeff R (n + Part.get (order φ) h)) φ

Next tactic:
ext n
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  

Proof state:
case h
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
⊢ (coeff R n) φ = (coeff R n) (X ^ Part.get (order φ) h * mk fun n => (coeff R (n + Part.get (order φ) h)) φ)

Next tactic:
simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  

Proof state:
case h
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
⊢ (coeff R n) φ =
    ∑ x in Finset.filter (fun x => x.1 = Part.get (order φ) h) (antidiagonal n),
      (coeff R (x.2 + Part.get (order φ) h)) φ

Next tactic:
rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
  

Proof state:
case h
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
⊢ (coeff R n) φ =
    ∑ x in if Part.get (order φ) h ≤ n then {(Part.get (order φ) h, n - Part.get (order φ) h)} else ∅,
      (coeff R (x.2 + Part.get (order φ) h)) φ

Next tactic:
split_ifs with hn
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
  split_ifs with hn
  · 

Proof state:
case pos
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
hn : Part.get (order φ) h ≤ n
⊢ (coeff R n) φ = ∑ x in {(Part.get (order φ) h, n - Part.get (order φ) h)}, (coeff R (x.2 + Part.get (order φ) h)) φ

Next tactic:
simp [tsub_add_cancel_of_le hn]
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
  split_ifs with hn
  · simp [tsub_add_cancel_of_le hn]
  · 

Proof state:
case neg
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
hn : ¬Part.get (order φ) h ≤ n
⊢ (coeff R n) φ = ∑ x in ∅, (coeff R (x.2 + Part.get (order φ) h)) φ

Next tactic:
simp only [Finset.sum_empty]
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
  split_ifs with hn
  · simp [tsub_add_cancel_of_le hn]
  · simp only [Finset.sum_empty]
    

Proof state:
case neg
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
hn : ¬Part.get (order φ) h ≤ n
⊢ (coeff R n) φ = 0

Next tactic:
refine' coeff_of_lt_order _ _
theorem X_pow_order_dvd (h : (order φ).Dom) : X ^ (order φ).get h ∣ φ := by
  refine' ⟨PowerSeries.mk fun n => coeff R (n + (order φ).get h) φ, _⟩
  ext n
  simp only [coeff_mul, coeff_X_pow, coeff_mk, boole_mul, Finset.sum_ite,
    Finset.sum_const_zero, add_zero]
  rw [Finset.filter_fst_eq_antidiagonal n (Part.get (order φ) h)]
  split_ifs with hn
  · simp [tsub_add_cancel_of_le hn]
  · simp only [Finset.sum_empty]
    refine' coeff_of_lt_order _ _
    

Proof state:
case neg
R : Type u_1
inst✝ : Semiring R
φ : R⟦X⟧
h : (order φ).Dom
n : ℕ
hn : ¬Part.get (order φ) h ≤ n
⊢ ↑n < order φ

Next tactic:
simpa [PartENat.coe_lt_iff] using fun _ => hn
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  

Proof state:
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
⊢ order φ = multiplicity X φ

Next tactic:
classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · rw [X_pow_eq, order_monomial]
    split_ifs
    · exact PartENat.natCast_lt_top _
    · rw [← hn, PartENat.coe_lt_coe]
      exact Nat.lt_succ_self _
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  

Proof state:
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
⊢ order φ = multiplicity X φ

Next tactic:
rcases eq_or_ne φ 0 with (rfl | hφ)
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · 

Proof state:
case inl
R✝ : Type u_1
inst✝² : Semiring R✝
φ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
⊢ order 0 = multiplicity X 0

Next tactic:
simp
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  

Proof state:
case inr
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
⊢ order φ = multiplicity X φ

Next tactic:
induction' ho : order φ using PartENat.casesOn with n
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · 

Proof state:
case inr.a
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
ho : order φ = ⊤
⊢ ⊤ = multiplicity X φ

Next tactic:
simp [hφ] at ho
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  

Proof state:
case inr.a
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
⊢ ↑n = multiplicity X φ

Next tactic:
have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by 

Proof state:
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
⊢ Part.get (order φ) (_ : (order φ).Dom) = n

Next tactic:
simp [ho]
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  

Proof state:
case inr.a
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
⊢ ↑n = multiplicity X φ

Next tactic:
rw [← hn]
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  

Proof state:
case inr.a
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
⊢ ↑(Part.get (order φ) (_ : (order φ).Dom)) = multiplicity X φ

Next tactic:
refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  

Proof state:
case inr.a
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
⊢ ¬X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) ∣ φ

Next tactic:
rintro ⟨ψ, H⟩
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  

Proof state:
case inr.a.intro
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
⊢ False

Next tactic:
have := congr_arg (coeff R n) H
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  

Proof state:
case inr.a.intro
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ)
⊢ False

Next tactic:
rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · 

Proof state:
case inr.a.intro
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R (Part.get (order φ) (_ : (order φ).Dom))) φ = 0
⊢ False

Next tactic:
exact coeff_order _ this
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · 

Proof state:
case inr.a.intro
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (ψ * X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))
⊢ ↑n < order (X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))

Next tactic:
rw [X_pow_eq, order_monomial]
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · rw [X_pow_eq, order_monomial]
    

Proof state:
case inr.a.intro
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (ψ * X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))
⊢ ↑n < if 1 = 0 then ⊤ else ↑(Part.get (order φ) (_ : (order φ).Dom) + 1)

Next tactic:
split_ifs
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · rw [X_pow_eq, order_monomial]
    split_ifs
    · 

Proof state:
case pos
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (ψ * X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))
h✝ : 1 = 0
⊢ ↑n < ⊤

Next tactic:
exact PartENat.natCast_lt_top _
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · rw [X_pow_eq, order_monomial]
    split_ifs
    · exact PartENat.natCast_lt_top _
    · 

Proof state:
case neg
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (ψ * X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))
h✝ : ¬1 = 0
⊢ ↑n < ↑(Part.get (order φ) (_ : (order φ).Dom) + 1)

Next tactic:
rw [← hn, PartENat.coe_lt_coe]
theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ (· ∣ ·)] (φ : R⟦X⟧) :
    order φ = multiplicity X φ := by
  classical
  rcases eq_or_ne φ 0 with (rfl | hφ)
  · simp
  induction' ho : order φ using PartENat.casesOn with n
  · simp [hφ] at ho
  have hn : φ.order.get (order_finite_iff_ne_zero.mpr hφ) = n := by simp [ho]
  rw [← hn]
  refine'
    le_antisymm (le_multiplicity_of_pow_dvd <| X_pow_order_dvd (order_finite_iff_ne_zero.mpr hφ))
      (PartENat.find_le _ _ _)
  rintro ⟨ψ, H⟩
  have := congr_arg (coeff R n) H
  rw [← (ψ.commute_X.pow_right _).eq, coeff_mul_of_lt_order, ← hn] at this
  · exact coeff_order _ this
  · rw [X_pow_eq, order_monomial]
    split_ifs
    · exact PartENat.natCast_lt_top _
    · rw [← hn, PartENat.coe_lt_coe]
      

Proof state:
case neg
R✝ : Type u_1
inst✝² : Semiring R✝
φ✝ : R✝⟦X⟧
R : Type u_2
inst✝¹ : Semiring R
inst✝ : DecidableRel fun x x_1 => x ∣ x_1
φ : R⟦X⟧
hφ : φ ≠ 0
n : ℕ
ho : order φ = ↑n
hn : Part.get (order φ) (_ : (order φ).Dom) = n
ψ : R⟦X⟧
H : φ = X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1) * ψ
this : (coeff R n) φ = (coeff R n) (ψ * X ^ (Part.get (order φ) (_ : (order φ).Dom) + 1))
h✝ : ¬1 = 0
⊢ Part.get (order φ) (_ : (order φ).Dom) < Part.get (order φ) (_ : (order φ).Dom) + 1

Next tactic:
exact Nat.lt_succ_self _
/-- The order of the formal power series `1` is `0`.-/
@[simp]
theorem order_one : order (1 : R⟦X⟧) = 0 := by
  

Proof state:
R : Type u_1
inst✝¹ : Semiring R
inst✝ : Nontrivial R
⊢ order 1 = 0

Next tactic:
simpa using order_monomial_of_ne_zero 0 (1 : R) one_ne_zero
/-- The order of the formal power series `X` is `1`.-/
@[simp]
theorem order_X : order (X : R⟦X⟧) = 1 := by
  

Proof state:
R : Type u_1
inst✝¹ : Semiring R
inst✝ : Nontrivial R
⊢ order X = 1

Next tactic:
simpa only [Nat.cast_one] using order_monomial_of_ne_zero 1 (1 : R) one_ne_zero
/-- The order of the formal power series `X^n` is `n`.-/
@[simp]
theorem order_X_pow (n : ℕ) : order ((X : R⟦X⟧) ^ n) = n := by
  

Proof state:
R : Type u_1
inst✝¹ : Semiring R
inst✝ : Nontrivial R
n : ℕ
⊢ order (X ^ n) = ↑n

Next tactic:
rw [X_pow_eq, order_monomial_of_ne_zero]
/-- The order of the formal power series `X^n` is `n`.-/
@[simp]
theorem order_X_pow (n : ℕ) : order ((X : R⟦X⟧) ^ n) = n := by
  rw [X_pow_eq, order_monomial_of_ne_zero]
  

Proof state:
case h
R : Type u_1
inst✝¹ : Semiring R
inst✝ : Nontrivial R
n : ℕ
⊢ 1 ≠ 0

Next tactic:
exact one_ne_zero
/-- The order of the product of two formal power series over an integral domain
 is the sum of their orders.-/
theorem order_mul (φ ψ : R⟦X⟧) : order (φ * ψ) = order φ + order ψ := by
  

Proof state:
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsDomain R
φ ψ : R⟦X⟧
⊢ order (φ * ψ) = order φ + order ψ

Next tactic:
classical
  simp_rw [order_eq_multiplicity_X]
  exact multiplicity.mul X_prime
/-- The order of the product of two formal power series over an integral domain
 is the sum of their orders.-/
theorem order_mul (φ ψ : R⟦X⟧) : order (φ * ψ) = order φ + order ψ := by
  classical
  

Proof state:
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsDomain R
φ ψ : R⟦X⟧
⊢ order (φ * ψ) = order φ + order ψ

Next tactic:
simp_rw [order_eq_multiplicity_X]