l3lab/ntp-mathlib huggingface dataset:
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ Monic (P ^ n + ∑ i in range n, P ^ i)

Next tactic:
refine' (hP.pow _).add_of_left _
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ degree (∑ i in range n, P ^ i) < degree (P ^ n)

Next tactic:
refine' lt_of_le_of_lt (degree_sum_le _ _) _
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ (sup (range n) fun b => degree (P ^ b)) < degree (P ^ n)

Next tactic:
rw [Finset.sup_lt_iff]
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · 

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ ∀ b ∈ range n, degree (P ^ b) < degree (P ^ n)

Next tactic:
simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
    

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ ∀ b < n, ↑(natDegree (P ^ b)) < ↑(natDegree (P ^ n))

Next tactic:
simp only [Nat.cast_lt, hP.natDegree_pow]
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
    simp only [Nat.cast_lt, hP.natDegree_pow]
    

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ ∀ b < n, b * natDegree P < n * natDegree P

Next tactic:
intro k
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
    simp only [Nat.cast_lt, hP.natDegree_pow]
    intro k
    

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
k : ℕ
⊢ k < n → k * natDegree P < n * natDegree P

Next tactic:
exact nsmul_lt_nsmul_left hdeg
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
    simp only [Nat.cast_lt, hP.natDegree_pow]
    intro k
    exact nsmul_lt_nsmul_left hdeg
  · 

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ ⊥ < degree (P ^ n)

Next tactic:
rw [bot_lt_iff_ne_bot, Ne.def, degree_eq_bot]
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
    (∑ i in range n, P ^ i).Monic := by
  nontriviality R
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
  rw [geom_sum_succ']
  refine' (hP.pow _).add_of_left _
  refine' lt_of_le_of_lt (degree_sum_le _ _) _
  rw [Finset.sup_lt_iff]
  · simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
    simp only [Nat.cast_lt, hP.natDegree_pow]
    intro k
    exact nsmul_lt_nsmul_left hdeg
  · rw [bot_lt_iff_ne_bot, Ne.def, degree_eq_bot]
    

Proof state:
case intro
R : Type u
S : Type u_1
inst✝ : Semiring R
P : R[X]
hP : Monic P
hdeg : 0 < natDegree P
✝ : Nontrivial R
n : ℕ
hn : Nat.succ n ≠ 0
⊢ ¬P ^ n = 0

Next tactic:
exact (hP.pow _).ne_zero
theorem monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) : (∑ i in range n, (X : R[X]) ^ i).Monic := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
hn : n ≠ 0
⊢ Monic (∑ i in range n, X ^ i)

Next tactic:
nontriviality R
theorem monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) : (∑ i in range n, (X : R[X]) ^ i).Monic := by
  nontriviality R
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
hn : n ≠ 0
✝ : Nontrivial R
⊢ Monic (∑ i in range n, X ^ i)

Next tactic:
apply monic_X.geom_sum _ hn
theorem monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) : (∑ i in range n, (X : R[X]) ^ i).Monic := by
  nontriviality R
  apply monic_X.geom_sum _ hn
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Semiring R
n : ℕ
hn : n ≠ 0
✝ : Nontrivial R
⊢ 0 < natDegree X

Next tactic:
simp only [natDegree_X, zero_lt_one]
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
⊢ ↑(coeff (restriction p) n) = coeff p n

Next tactic:
classical
  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    rfl
  · rfl
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  classical
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
⊢ ↑(coeff (restriction p) n) = coeff p n

Next tactic:
simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  classical
  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
⊢ ↑(if coeff p n = 0 then 0 else { val := coeff p n, property := (_ : coeff p n ∈ Subring.closure ↑(frange p)) }) =
    coeff p n

Next tactic:
split_ifs with h
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  classical
  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · 

Proof state:
case pos
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
h : coeff p n = 0
⊢ ↑0 = coeff p n

Next tactic:
rw [h]
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  classical
  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    

Proof state:
case pos
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
h : coeff p n = 0
⊢ ↑0 = 0

Next tactic:
rfl
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
  classical
  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    rfl
  · 

Proof state:
case neg
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
h : ¬coeff p n = 0
⊢ ↑{ val := coeff p n, property := (_ : coeff p n ∈ Subring.closure ↑(frange p)) } = coeff p n

Next tactic:
rfl
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ support (restriction p) = support p

Next tactic:
ext i
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  ext i
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
i : ℕ
⊢ i ∈ support (restriction p) ↔ i ∈ support p

Next tactic:
simp only [mem_support_iff, not_iff_not, Ne.def]
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
i : ℕ
⊢ coeff (restriction p) i = 0 ↔ coeff p i = 0

Next tactic:
conv_rhs => rw [← coeff_restriction]
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
i : ℕ
| coeff p i = 0

Next tactic:
rw [← coeff_restriction]
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => rw [← coeff_restriction]
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
i : ℕ
⊢ coeff (restriction p) i = 0 ↔ ↑(coeff (restriction p) i) = 0

Next tactic:
exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => rw [← coeff_restriction]
  exact ⟨fun H => by 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
i : ℕ
H : coeff (restriction p) i = 0
⊢ ↑(coeff (restriction p) i) = 0

Next tactic:
rw [H, ZeroMemClass.coe_zero]
@[simp]
theorem map_restriction {R : Type u} [CommRing R] (p : R[X]) :
    p.restriction.map (algebraMap _ _) = p :=
  ext fun n => by 

Proof state:
R✝ : Type u
S : Type u_1
inst✝¹ : Ring R✝
R : Type u
inst✝ : CommRing R
p : R[X]
n : ℕ
⊢ coeff (map (algebraMap (↥(Subring.closure ↑(frange p))) R) (restriction p)) n = coeff p n

Next tactic:
rw [coeff_map, Algebra.algebraMap_ofSubring_apply, coeff_restriction]
@[simp]
theorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree := by 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ degree (restriction p) = degree p

Next tactic:
simp [degree]
@[simp]
theorem natDegree_restriction {p : R[X]} : (restriction p).natDegree = p.natDegree := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ natDegree (restriction p) = natDegree p

Next tactic:
simp [natDegree]
@[simp]
theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ Monic (restriction p) ↔ Monic p

Next tactic:
simp only [Monic, leadingCoeff, natDegree_restriction]
@[simp]
theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by
  simp only [Monic, leadingCoeff, natDegree_restriction]
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ coeff (restriction p) (natDegree p) = 1 ↔ coeff p (natDegree p) = 1

Next tactic:
rw [← @coeff_restriction _ _ p]
@[simp]
theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by
  simp only [Monic, leadingCoeff, natDegree_restriction]
  rw [← @coeff_restriction _ _ p]
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
⊢ coeff (restriction p) (natDegree p) = 1 ↔ ↑(coeff (restriction p) (natDegree p)) = 1

Next tactic:
exact ⟨fun H => by rw [H, OneMemClass.coe_one], fun H => Subtype.coe_injective H⟩
@[simp]
theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by
  simp only [Monic, leadingCoeff, natDegree_restriction]
  rw [← @coeff_restriction _ _ p]
  exact ⟨fun H => by 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
p : R[X]
H : coeff (restriction p) (natDegree p) = 1
⊢ ↑(coeff (restriction p) (natDegree p)) = 1

Next tactic:
rw [H, OneMemClass.coe_one]
@[simp]
theorem restriction_zero : restriction (0 : R[X]) = 0 := by
  

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
⊢ restriction 0 = 0

Next tactic:
simp only [restriction, Finset.sum_empty, support_zero]
@[simp]
theorem restriction_one : restriction (1 : R[X]) = 1 :=
  ext fun i => Subtype.eq <| by 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
i : ℕ
⊢ ↑(coeff (restriction 1) i) = ↑(coeff 1 i)

Next tactic:
rw [coeff_restriction', coeff_one, coeff_one]
@[simp]
theorem restriction_one : restriction (1 : R[X]) = 1 :=
  ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one]; 

Proof state:
R : Type u
S : Type u_1
inst✝ : Ring R
i : ℕ
⊢ (if i = 0 then 1 else 0) = ↑(if i = 0 then 1 else 0)

Next tactic:
split_ifs
@[simp]
theorem restriction_one : restriction (1 : R[X]) = 1 :=
  ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs <;> 

Proof state:
case pos
R : Type u
S : Type u_1
inst✝ : Ring R
i : ℕ
h✝ : i = 0
⊢ 1 = ↑1

Next tactic:
rfl
@[simp]
theorem restriction_one : restriction (1 : R[X]) = 1 :=
  ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs <;> 

Proof state:
case neg
R : Type u
S : Type u_1
inst✝ : Ring R
i : ℕ
h✝ : ¬i = 0
⊢ 0 = ↑0

Next tactic:
rfl
theorem eval₂_restriction {p : R[X]} :
    eval₂ f x p =
      eval₂ (f.comp (Subring.subtype (Subring.closure (p.frange : Set R)))) x p.restriction := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
⊢ eval₂ f x p = eval₂ (RingHom.comp f (Subring.subtype (Subring.closure ↑(frange p)))) x (restriction p)

Next tactic:
simp only [eval₂_eq_sum, sum, support_restriction, ← @coeff_restriction _ _ p, RingHom.comp_apply,
    Subring.coeSubtype]
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
⊢ ↑(coeff (toSubring p T hp) n) = coeff p n

Next tactic:
classical
  simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    rfl
  · rfl
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  classical
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
⊢ ↑(coeff (toSubring p T hp) n) = coeff p n

Next tactic:
simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  classical
  simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
⊢ ↑(if coeff p n = 0 then 0 else { val := coeff p n, property := (_ : coeff p n ∈ T) }) = coeff p n

Next tactic:
split_ifs with h
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  classical
  simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · 

Proof state:
case pos
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
h : coeff p n = 0
⊢ ↑0 = coeff p n

Next tactic:
rw [h]
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  classical
  simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    

Proof state:
case pos
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
h : coeff p n = 0
⊢ ↑0 = 0

Next tactic:
rfl
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
  classical
  simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    Ne.def, ite_not]
  split_ifs with h
  · rw [h]
    rfl
  · 

Proof state:
case neg
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
h : ¬coeff p n = 0
⊢ ↑{ val := coeff p n, property := (_ : coeff p n ∈ T) } = coeff p n

Next tactic:
rfl
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ support (toSubring p T hp) = support p

Next tactic:
ext i
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  ext i
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ i ∈ support (toSubring p T hp) ↔ i ∈ support p

Next tactic:
simp only [mem_support_iff, not_iff_not, Ne.def]
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ coeff p i = 0

Next tactic:
conv_rhs => rw [← coeff_toSubring p T hp]
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
| coeff p i = 0

Next tactic:
rw [← coeff_toSubring p T hp]
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => rw [← coeff_toSubring p T hp]
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ coeff (toSubring p T hp) i = 0 ↔ ↑(coeff (toSubring p T hp) i) = 0

Next tactic:
exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
  ext i
  simp only [mem_support_iff, not_iff_not, Ne.def]
  conv_rhs => rw [← coeff_toSubring p T hp]
  exact ⟨fun H => by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
H : coeff (toSubring p T hp) i = 0
⊢ ↑(coeff (toSubring p T hp) i) = 0

Next tactic:
rw [H, ZeroMemClass.coe_zero]
@[simp]
theorem degree_toSubring : (toSubring p T hp).degree = p.degree := by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ degree (toSubring p T hp) = degree p

Next tactic:
simp [degree]
@[simp]
theorem natDegree_toSubring : (toSubring p T hp).natDegree = p.natDegree := by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ natDegree (toSubring p T hp) = natDegree p

Next tactic:
simp [natDegree]
@[simp]
theorem monic_toSubring : Monic (toSubring p T hp) ↔ Monic p := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ Monic (toSubring p T hp) ↔ Monic p

Next tactic:
simp_rw [Monic, leadingCoeff, natDegree_toSubring, ← coeff_toSubring p T hp]
@[simp]
theorem monic_toSubring : Monic (toSubring p T hp) ↔ Monic p := by
  simp_rw [Monic, leadingCoeff, natDegree_toSubring, ← coeff_toSubring p T hp]
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ coeff (toSubring p T hp) (natDegree p) = 1 ↔ ↑(coeff (toSubring p T hp) (natDegree p)) = 1

Next tactic:
exact ⟨fun H => by rw [H, OneMemClass.coe_one], fun H => Subtype.coe_injective H⟩
@[simp]
theorem monic_toSubring : Monic (toSubring p T hp) ↔ Monic p := by
  simp_rw [Monic, leadingCoeff, natDegree_toSubring, ← coeff_toSubring p T hp]
  exact ⟨fun H => by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
H : coeff (toSubring p T hp) (natDegree p) = 1
⊢ ↑(coeff (toSubring p T hp) (natDegree p)) = 1

Next tactic:
rw [H, OneMemClass.coe_one]
@[simp]
theorem toSubring_zero : toSubring (0 : R[X]) T (by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ ↑(frange 0) ⊆ ↑T

Next tactic:
simp [frange_zero]
@[simp]
theorem toSubring_zero : toSubring (0 : R[X]) T (by simp [frange_zero]) = 0 := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ toSubring 0 T (_ : ↑∅ ⊆ ↑T) = 0

Next tactic:
ext i
@[simp]
theorem toSubring_zero : toSubring (0 : R[X]) T (by simp [frange_zero]) = 0 := by
  ext i
  

Proof state:
case a.a
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ ↑(coeff (toSubring 0 T (_ : ↑∅ ⊆ ↑T)) i) = ↑(coeff 0 i)

Next tactic:
simp
@[simp]
theorem toSubring_one :
    toSubring (1 : R[X]) T
        (Set.Subset.trans frange_one <| Finset.singleton_subset_set_iff.2 T.one_mem) =
      1 :=
  ext fun i => Subtype.eq <| by
    

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
i : ℕ
⊢ ↑(coeff (toSubring 1 T (_ : ↑(frange 1) ⊆ ↑T)) i) = ↑(coeff 1 i)

Next tactic:
rw [coeff_toSubring', coeff_one, coeff_one, apply_ite Subtype.val, ZeroMemClass.coe_zero,
      OneMemClass.coe_one]
@[simp]
theorem map_toSubring : (p.toSubring T hp).map (Subring.subtype T) = p := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
⊢ map (Subring.subtype T) (toSubring p T hp) = p

Next tactic:
ext n
@[simp]
theorem map_toSubring : (p.toSubring T hp).map (Subring.subtype T) = p := by
  ext n
  

Proof state:
case a
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
p : R[X]
T : Subring R
hp : ↑(frange p) ⊆ ↑T
n : ℕ
⊢ coeff (map (Subring.subtype T) (toSubring p T hp)) n = coeff p n

Next tactic:
simp [coeff_map]