l3lab/ntp-mathlib huggingface dataset:
theorem LinearOrder.bot_topologicalSpace_eq_generateFrom [LinearOrder α] [PredOrder α]
    [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by
  refine' (eq_bot_of_singletons_open fun a => _).symm
  have h_singleton_eq_inter : {a} = Iic a ∩ Ici a := by rw [inter_comm, Ici_inter_Iic, Icc_self a]
  by_cases ha_top : IsTop a
  · rw [ha_top.Iic_eq, inter_comm, inter_univ] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `isOpen_univ` explicitly to fix an error.
      apply @isOpen_univ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
  · rw [isTop_iff_isMax] at ha_top
    rw [← Iio_succ_of_not_isMax ha_top] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq, inter_univ] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `IsOpen.inter` explicitly to fix an error.
      

Proof state:
case neg
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
a : α
h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a)
ha_top : ¬IsMax a
ha_bot : ¬IsMin a
⊢ IsOpen (Iio (succ a) ∩ Ioi (pred a))

Next tactic:
apply @IsOpen.inter _ _ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
theorem LinearOrder.bot_topologicalSpace_eq_generateFrom [LinearOrder α] [PredOrder α]
    [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by
  refine' (eq_bot_of_singletons_open fun a => _).symm
  have h_singleton_eq_inter : {a} = Iic a ∩ Ici a := by rw [inter_comm, Ici_inter_Iic, Icc_self a]
  by_cases ha_top : IsTop a
  · rw [ha_top.Iic_eq, inter_comm, inter_univ] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `isOpen_univ` explicitly to fix an error.
      apply @isOpen_univ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
  · rw [isTop_iff_isMax] at ha_top
    rw [← Iio_succ_of_not_isMax ha_top] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq, inter_univ] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `IsOpen.inter` explicitly to fix an error.
      apply @IsOpen.inter _ _ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
      · 

Proof state:
case neg.h₁
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
a : α
h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a)
ha_top : ¬IsMax a
ha_bot : ¬IsMin a
⊢ IsOpen (Iio (succ a))

Next tactic:
exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩
theorem LinearOrder.bot_topologicalSpace_eq_generateFrom [LinearOrder α] [PredOrder α]
    [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by
  refine' (eq_bot_of_singletons_open fun a => _).symm
  have h_singleton_eq_inter : {a} = Iic a ∩ Ici a := by rw [inter_comm, Ici_inter_Iic, Icc_self a]
  by_cases ha_top : IsTop a
  · rw [ha_top.Iic_eq, inter_comm, inter_univ] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `isOpen_univ` explicitly to fix an error.
      apply @isOpen_univ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
  · rw [isTop_iff_isMax] at ha_top
    rw [← Iio_succ_of_not_isMax ha_top] at h_singleton_eq_inter
    by_cases ha_bot : IsBot a
    · rw [ha_bot.Ici_eq, inter_univ] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩
    · rw [isBot_iff_isMin] at ha_bot
      rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter
      rw [h_singleton_eq_inter]
      -- Porting note: Specified instance for `IsOpen.inter` explicitly to fix an error.
      apply @IsOpen.inter _ _ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a })
      · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩
      · 

Proof state:
case neg.h₂
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
a : α
h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a)
ha_top : ¬IsMax a
ha_bot : ¬IsMin a
⊢ IsOpen (Ioi (pred a))

Next tactic:
exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α]
    [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by
  

Proof state:
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
⊢ DiscreteTopology α ↔ OrderTopology α

Next tactic:
refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩
theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α]
    [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by
  refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩
  · 

Proof state:
case refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
h : DiscreteTopology α
⊢ inst✝³ = generateFrom {s | ∃ a, s = Ioi a ∨ s = Iio a}

Next tactic:
rw [h.eq_bot]
theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α]
    [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by
  refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩
  · rw [h.eq_bot]
    

Proof state:
case refine'_1
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
h : DiscreteTopology α
⊢ ⊥ = generateFrom {s | ∃ a, s = Ioi a ∨ s = Iio a}

Next tactic:
exact LinearOrder.bot_topologicalSpace_eq_generateFrom
theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α]
    [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by
  refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩
  · rw [h.eq_bot]
    exact LinearOrder.bot_topologicalSpace_eq_generateFrom
  · 

Proof state:
case refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
h : OrderTopology α
⊢ inst✝³ = ⊥

Next tactic:
rw [h.topology_eq_generate_intervals]
theorem discreteTopology_iff_orderTopology_of_pred_succ [LinearOrder α] [PredOrder α]
    [SuccOrder α] : DiscreteTopology α ↔ OrderTopology α := by
  refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩
  · rw [h.eq_bot]
    exact LinearOrder.bot_topologicalSpace_eq_generateFrom
  · rw [h.topology_eq_generate_intervals]
    

Proof state:
case refine'_2
α : Type u_1
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : PredOrder α
inst✝ : SuccOrder α
h : OrderTopology α
⊢ generateFrom {s | ∃ a, s = Ioi a ∨ s = Iio a} = ⊥

Next tactic:
exact LinearOrder.bot_topologicalSpace_eq_generateFrom.symm
instance (priority := 100) DiscreteTopology.metrizableSpace [DiscreteTopology α] :
    MetrizableSpace α := by
  

Proof state:
α : Type u_1
inst✝¹ : TopologicalSpace α
inst✝ : DiscreteTopology α
⊢ MetrizableSpace α

Next tactic:
obtain rfl := DiscreteTopology.eq_bot (α := α)
instance (priority := 100) DiscreteTopology.metrizableSpace [DiscreteTopology α] :
    MetrizableSpace α := by
  obtain rfl := DiscreteTopology.eq_bot (α := α)
  

Proof state:
α : Type u_1
inst✝ : DiscreteTopology α
⊢ MetrizableSpace α

Next tactic:
exact @UniformSpace.metrizableSpace α ⊥ (isCountablyGenerated_principal _) _
theorem coeff_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n : ℕ
⊢ (coeff R n) (derivativeFun f) = (coeff R (n + 1)) f * (↑n + 1)

Next tactic:
rw [derivativeFun, coeff_mk]
theorem derivativeFun_coe (f : R[X]) : (f : R⟦X⟧).derivativeFun = derivative f := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f : R[X]
⊢ derivativeFun ↑f = ↑(derivative f)

Next tactic:
ext
theorem derivativeFun_coe (f : R[X]) : (f : R⟦X⟧).derivativeFun = derivative f := by
  ext
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
f : R[X]
n✝ : ℕ
⊢ (coeff R n✝) (derivativeFun ↑f) = (coeff R n✝) ↑(derivative f)

Next tactic:
rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative]
theorem derivativeFun_add (f g : R⟦X⟧) :
    derivativeFun (f + g) = derivativeFun f + derivativeFun g := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
⊢ derivativeFun (f + g) = derivativeFun f + derivativeFun g

Next tactic:
ext
theorem derivativeFun_add (f g : R⟦X⟧) :
    derivativeFun (f + g) = derivativeFun f + derivativeFun g := by
  ext
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
n✝ : ℕ
⊢ (coeff R n✝) (derivativeFun (f + g)) = (coeff R n✝) (derivativeFun f + derivativeFun g)

Next tactic:
rw [coeff_derivativeFun, map_add, map_add, coeff_derivativeFun,
    coeff_derivativeFun, add_mul]
theorem derivativeFun_C (r : R) : derivativeFun (C R r) = 0 := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
r : R
⊢ derivativeFun ((C R) r) = 0

Next tactic:
ext n
theorem derivativeFun_C (r : R) : derivativeFun (C R r) = 0 := by
  ext n
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
r : R
n : ℕ
⊢ (coeff R n) (derivativeFun ((C R) r)) = (coeff R n) 0

Next tactic:
rw [coeff_derivativeFun, coeff_succ_C, zero_mul, map_zero]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n : ℕ
⊢ trunc n (derivativeFun f) = derivative (trunc (n + 1) f)

Next tactic:
ext d
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  

Proof state:
case a
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
⊢ Polynomial.coeff (trunc n (derivativeFun f)) d = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
rw [coeff_trunc]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  

Proof state:
case a
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
⊢ (if d < n then (coeff R d) (derivativeFun f) else 0) = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
split_ifs with h
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  split_ifs with h
  · 

Proof state:
case pos
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
h : d < n
⊢ (coeff R d) (derivativeFun f) = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  split_ifs with h
  · have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
    

Proof state:
case pos
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
h : d < n
this : d + 1 < n + 1
⊢ (coeff R d) (derivativeFun f) = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  split_ifs with h
  · have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
    rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this]
  · 

Proof state:
case neg
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
h : ¬d < n
⊢ 0 = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
have : ¬d + 1 < n + 1 := by rwa [succ_lt_succ_iff]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  split_ifs with h
  · have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
    rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this]
  · have : ¬d + 1 < n + 1 := by 

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
h : ¬d < n
⊢ ¬d + 1 < n + 1

Next tactic:
rwa [succ_lt_succ_iff]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
    trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
  ext d
  rw [coeff_trunc]
  split_ifs with h
  · have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
    rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this]
  · have : ¬d + 1 < n + 1 := by rwa [succ_lt_succ_iff]
    

Proof state:
case neg
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n d : ℕ
h : ¬d < n
this : ¬d + 1 < n + 1
⊢ 0 = Polynomial.coeff (derivative (trunc (n + 1) f)) d

Next tactic:
rw [coeff_derivative, coeff_trunc, if_neg this, zero_mul]
private theorem derivativeFun_coe_mul_coe (f g : R[X]) : derivativeFun (f * g : R⟦X⟧) =
    f * derivative g + g * derivative f  := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f g : R[X]
⊢ derivativeFun (↑f * ↑g) = ↑f * ↑(derivative g) + ↑g * ↑(derivative f)

Next tactic:
rw [← coe_mul, derivativeFun_coe, derivative_mul,
    add_comm, mul_comm _ g, ← coe_mul, ← coe_mul, Polynomial.coe_add]
/-- **Leibniz rule for formal power series**.-/
theorem derivativeFun_mul (f g : R⟦X⟧) :
    derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
⊢ derivativeFun (f * g) = f • derivativeFun g + g • derivativeFun f

Next tactic:
ext n
/-- **Leibniz rule for formal power series**.-/
theorem derivativeFun_mul (f g : R⟦X⟧) :
    derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by
  ext n
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
n : ℕ
⊢ (coeff R n) (derivativeFun (f * g)) = (coeff R n) (f • derivativeFun g + g • derivativeFun f)

Next tactic:
have h₁ : n < n + 1 := lt_succ_self n
/-- **Leibniz rule for formal power series**.-/
theorem derivativeFun_mul (f g : R⟦X⟧) :
    derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by
  ext n
  have h₁ : n < n + 1 := lt_succ_self n
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
n : ℕ
h₁ : n < n + 1
⊢ (coeff R n) (derivativeFun (f * g)) = (coeff R n) (f • derivativeFun g + g • derivativeFun f)

Next tactic:
have h₂ : n < n + 1 + 1 := Nat.lt_add_right _ h₁
/-- **Leibniz rule for formal power series**.-/
theorem derivativeFun_mul (f g : R⟦X⟧) :
    derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by
  ext n
  have h₁ : n < n + 1 := lt_succ_self n
  have h₂ : n < n + 1 + 1 := Nat.lt_add_right _ h₁
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
f g : R⟦X⟧
n : ℕ
h₁ : n < n + 1
h₂ : n < n + 1 + 1
⊢ (coeff R n) (derivativeFun (f * g)) = (coeff R n) (f • derivativeFun g + g • derivativeFun f)

Next tactic:
rw [coeff_derivativeFun, map_add, coeff_mul_eq_coeff_trunc_mul_trunc _ _ (lt_succ_self _),
    smul_eq_mul, smul_eq_mul, coeff_mul_eq_coeff_trunc_mul_trunc₂ g f.derivativeFun h₂ h₁,
    coeff_mul_eq_coeff_trunc_mul_trunc₂ f g.derivativeFun h₂ h₁, trunc_derivativeFun,
    trunc_derivativeFun, ← map_add, ← derivativeFun_coe_mul_coe, coeff_derivativeFun]
theorem derivativeFun_one : derivativeFun (1 : R⟦X⟧) = 0 := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
⊢ derivativeFun 1 = 0

Next tactic:
rw [← map_one (C R), derivativeFun_C (1 : R)]
theorem derivativeFun_smul (r : R) (f : R⟦X⟧) : derivativeFun (r • f) = r • derivativeFun f := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
r : R
f : R⟦X⟧
⊢ derivativeFun (r • f) = r • derivativeFun f

Next tactic:
rw [smul_eq_C_mul, smul_eq_C_mul, derivativeFun_mul, derivativeFun_C, smul_zero, add_zero,
    smul_eq_mul]
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
⊢ (d⁄dX R) X = 1

Next tactic:
ext
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  ext
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
n✝ : ℕ
⊢ (coeff R n✝) ((d⁄dX R) X) = (coeff R n✝) 1

Next tactic:
rw [coeff_derivative, coeff_one, coeff_X, boole_mul]
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  ext
  rw [coeff_derivative, coeff_one, coeff_X, boole_mul]
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
n✝ : ℕ
⊢ (if n✝ + 1 = 1 then ↑n✝ + 1 else 0) = if n✝ = 0 then 1 else 0

Next tactic:
simp_rw [add_left_eq_self]
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  ext
  rw [coeff_derivative, coeff_one, coeff_X, boole_mul]
  simp_rw [add_left_eq_self]
  

Proof state:
case h
R : Type u_1
inst✝ : CommSemiring R
n✝ : ℕ
⊢ (if n✝ = 0 then ↑n✝ + 1 else 0) = if n✝ = 0 then 1 else 0

Next tactic:
split_ifs with h
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  ext
  rw [coeff_derivative, coeff_one, coeff_X, boole_mul]
  simp_rw [add_left_eq_self]
  split_ifs with h
  · 

Proof state:
case pos
R : Type u_1
inst✝ : CommSemiring R
n✝ : ℕ
h : n✝ = 0
⊢ ↑n✝ + 1 = 1

Next tactic:
rw [h, cast_zero, zero_add]
@[simp] theorem derivative_X : d⁄dX R (X : R⟦X⟧) = 1 := by
  ext
  rw [coeff_derivative, coeff_one, coeff_X, boole_mul]
  simp_rw [add_left_eq_self]
  split_ifs with h
  · rw [h, cast_zero, zero_add]
  · 

Proof state:
case neg
R : Type u_1
inst✝ : CommSemiring R
n✝ : ℕ
h : ¬n✝ = 0
⊢ 0 = 0

Next tactic:
rfl
theorem trunc_derivative' (f : R⟦X⟧) (n : ℕ) :
    trunc (n-1) (d⁄dX R f) = Polynomial.derivative (trunc n f) := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n : ℕ
⊢ trunc (n - 1) ((d⁄dX R) f) = Polynomial.derivative (trunc n f)

Next tactic:
cases n with
  | zero =>
    simp
  | succ n =>
    rw [succ_sub_one, trunc_derivative]
theorem trunc_derivative' (f : R⟦X⟧) (n : ℕ) :
    trunc (n-1) (d⁄dX R f) = Polynomial.derivative (trunc n f) := by
  cases n with
  

Proof state:
case zero
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
⊢ trunc (Nat.zero - 1) ((d⁄dX R) f) = Polynomial.derivative (trunc Nat.zero f)

Next tactic:
| zero =>
    simp
theorem trunc_derivative' (f : R⟦X⟧) (n : ℕ) :
    trunc (n-1) (d⁄dX R f) = Polynomial.derivative (trunc n f) := by
  cases n with
  | zero =>
    

Proof state:
case zero
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
⊢ trunc (Nat.zero - 1) ((d⁄dX R) f) = Polynomial.derivative (trunc Nat.zero f)

Next tactic:
simp
theorem trunc_derivative' (f : R⟦X⟧) (n : ℕ) :
    trunc (n-1) (d⁄dX R f) = Polynomial.derivative (trunc n f) := by
  cases n with
  | zero =>
    simp
  

Proof state:
case succ
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n : ℕ
⊢ trunc (succ n - 1) ((d⁄dX R) f) = Polynomial.derivative (trunc (succ n) f)

Next tactic:
| succ n =>
    rw [succ_sub_one, trunc_derivative]
theorem trunc_derivative' (f : R⟦X⟧) (n : ℕ) :
    trunc (n-1) (d⁄dX R f) = Polynomial.derivative (trunc n f) := by
  cases n with
  | zero =>
    simp
  | succ n =>
    

Proof state:
case succ
R : Type u_1
inst✝ : CommSemiring R
f : R⟦X⟧
n : ℕ
⊢ trunc (succ n - 1) ((d⁄dX R) f) = Polynomial.derivative (trunc (succ n) f)

Next tactic:
rw [succ_sub_one, trunc_derivative]
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  

Proof state:
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
⊢ f = g

Next tactic:
ext n
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  

Proof state:
case h
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
n : ℕ
⊢ (coeff R n) f = (coeff R n) g

Next tactic:
cases n with
  | zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
  | succ n =>
    have equ : coeff R n (d⁄dX R f) = coeff R n (d⁄dX R g) := by rw [hD]
    rwa [coeff_derivative, coeff_derivative, ← cast_succ, mul_comm, ← nsmul_eq_mul,
      mul_comm, ← nsmul_eq_mul, smul_right_inj n.succ_ne_zero] at equ
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  

Proof state:
case h.zero
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
⊢ (coeff R Nat.zero) f = (coeff R Nat.zero) g

Next tactic:
| zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  | zero =>
    

Proof state:
case h.zero
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
⊢ (coeff R Nat.zero) f = (coeff R Nat.zero) g

Next tactic:
rw [coeff_zero_eq_constantCoeff, hc]
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  | zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
  

Proof state:
case h.succ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
n : ℕ
⊢ (coeff R (succ n)) f = (coeff R (succ n)) g

Next tactic:
| succ n =>
    have equ : coeff R n (d⁄dX R f) = coeff R n (d⁄dX R g) := by rw [hD]
    rwa [coeff_derivative, coeff_derivative, ← cast_succ, mul_comm, ← nsmul_eq_mul,
      mul_comm, ← nsmul_eq_mul, smul_right_inj n.succ_ne_zero] at equ
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  | zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
  | succ n =>
    

Proof state:
case h.succ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
n : ℕ
⊢ (coeff R (succ n)) f = (coeff R (succ n)) g

Next tactic:
have equ : coeff R n (d⁄dX R f) = coeff R n (d⁄dX R g) := by rw [hD]
/-- If `f` and `g` have the same constant term and derivative, then they are equal.-/
theorem derivative.ext {R} [CommRing R] [NoZeroSMulDivisors ℕ R] {f g} (hD : d⁄dX R f = d⁄dX R g)
    (hc : constantCoeff R f = constantCoeff R g) : f = g := by
  ext n
  cases n with
  | zero =>
    rw [coeff_zero_eq_constantCoeff, hc]
  | succ n =>
    have equ : coeff R n (d⁄dX R f) = coeff R n (d⁄dX R g) := by 

Proof state:
R : Type u_1
inst✝¹ : CommRing R
inst✝ : NoZeroSMulDivisors ℕ R
f g : R⟦X⟧
hD : (d⁄dX R) f = (d⁄dX R) g
hc : (constantCoeff R) f = (constantCoeff R) g
n : ℕ
⊢ (coeff R n) ((d⁄dX R) f) = (coeff R n) ((d⁄dX R) g)

Next tactic:
rw [hD]