l3lab/ntp-mathlib huggingface dataset:
theorem coeff_ofSubring (p : T[X]) (n : ℕ) : coeff (ofSubring T p) n = (coeff p n : T) := by
  

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

Next tactic:
simp only [ofSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    ite_eq_right_iff, Ne.def, ite_not, Classical.not_not, ite_eq_left_iff]
theorem coeff_ofSubring (p : T[X]) (n : ℕ) : coeff (ofSubring T p) n = (coeff p n : T) := by
  simp only [ofSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    ite_eq_right_iff, Ne.def, ite_not, Classical.not_not, ite_eq_left_iff]
  

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

Next tactic:
intro h
theorem coeff_ofSubring (p : T[X]) (n : ℕ) : coeff (ofSubring T p) n = (coeff p n : T) := by
  simp only [ofSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
    ite_eq_right_iff, Ne.def, ite_not, Classical.not_not, ite_eq_left_iff]
  intro h
  

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

Next tactic:
rw [h, ZeroMemClass.coe_zero]
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  

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

Next tactic:
classical
  intro i hi
  simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe,
    (Finset.coe_image)] at hi
  rcases hi with ⟨n, _, h'n⟩
  rw [← h'n, coeff_ofSubring]
  exact Subtype.mem (coeff p n : T)
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  classical
  

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

Next tactic:
intro i hi
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  classical
  intro i hi
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
T : Subring R
p : (↥T)[X]
i : R
hi : i ∈ ↑(frange (ofSubring T p))
⊢ i ∈ ↑T

Next tactic:
simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe,
    (Finset.coe_image)] at hi
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  classical
  intro i hi
  simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe,
    (Finset.coe_image)] at hi
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
T : Subring R
p : (↥T)[X]
i : R
hi : ∃ x, ¬coeff (ofSubring T p) x = 0 ∧ coeff (ofSubring T p) x = i
⊢ i ∈ ↑T

Next tactic:
rcases hi with ⟨n, _, h'n⟩
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  classical
  intro i hi
  simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe,
    (Finset.coe_image)] at hi
  rcases hi with ⟨n, _, h'n⟩
  

Proof state:
case intro.intro
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
T : Subring R
p : (↥T)[X]
i : R
n : ℕ
left✝ : ¬coeff (ofSubring T p) n = 0
h'n : coeff (ofSubring T p) n = i
⊢ i ∈ ↑T

Next tactic:
rw [← h'n, coeff_ofSubring]
@[simp]
theorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T := by
  classical
  intro i hi
  simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe,
    (Finset.coe_image)] at hi
  rcases hi with ⟨n, _, h'n⟩
  rw [← h'n, coeff_ofSubring]
  

Proof state:
case intro.intro
R : Type u
S : Type u_1
inst✝¹ : Ring R
inst✝ : Semiring S
f : R →+* S
x : S
T : Subring R
p : (↥T)[X]
i : R
n : ℕ
left✝ : ¬coeff (ofSubring T p) n = 0
h'n : coeff (ofSubring T p) n = i
⊢ ↑(coeff p n) ∈ ↑T

Next tactic:
exact Subtype.mem (coeff p n : T)
/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/
def ofPolynomial (I : Ideal R[X]) : Submodule R R[X] where
  carrier := I.carrier
  zero_mem' := I.zero_mem
  add_mem' := I.add_mem
  smul_mem' c x H := by
    

Proof state:
R : Type u
S : Type u_1
inst✝ : Semiring R
I : Ideal R[X]
c : R
x : R[X]
H :
  x ∈
    { toAddSubsemigroup := { carrier := I.carrier, add_mem' := (_ : ∀ {a b : R[X]}, a ∈ I → b ∈ I → a + b ∈ I) },
          zero_mem' := (_ : 0 ∈ I) }.toAddSubsemigroup.carrier
⊢ c • x ∈
    { toAddSubsemigroup := { carrier := I.carrier, add_mem' := (_ : ∀ {a b : R[X]}, a ∈ I → b ∈ I → a + b ∈ I) },
          zero_mem' := (_ : 0 ∈ I) }.toAddSubsemigroup.carrier

Next tactic:
rw [← C_mul']
/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/
def ofPolynomial (I : Ideal R[X]) : Submodule R R[X] where
  carrier := I.carrier
  zero_mem' := I.zero_mem
  add_mem' := I.add_mem
  smul_mem' c x H := by
    rw [← C_mul']
    

Proof state:
R : Type u
S : Type u_1
inst✝ : Semiring R
I : Ideal R[X]
c : R
x : R[X]
H :
  x ∈
    { toAddSubsemigroup := { carrier := I.carrier, add_mem' := (_ : ∀ {a b : R[X]}, a ∈ I → b ∈ I → a + b ∈ I) },
          zero_mem' := (_ : 0 ∈ I) }.toAddSubsemigroup.carrier
⊢ C c * x ∈
    { toAddSubsemigroup := { carrier := I.carrier, add_mem' := (_ : ∀ {a b : R[X]}, a ∈ I → b ∈ I → a + b ∈ I) },
          zero_mem' := (_ : 0 ∈ I) }.toAddSubsemigroup.carrier

Next tactic:
exact I.mul_mem_left _ H
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
⊢ f ∈ map C I ↔ ∀ (n : ℕ), coeff f n ∈ I

Next tactic:
constructor
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · 

Proof state:
case mp
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
⊢ f ∈ map C I → ∀ (n : ℕ), coeff f n ∈ I

Next tactic:
intro hf
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    

Proof state:
case mp
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : f ∈ map C I
⊢ ∀ (n : ℕ), coeff f n ∈ I

Next tactic:
apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · 

Proof state:
case mp.Hs
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : f ∈ map C I
⊢ ∀ x ∈ ⇑C '' ↑I, ∀ (n : ℕ), coeff x n ∈ I

Next tactic:
intro f hf n
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      

Proof state:
case mp.Hs
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f : R[X]
hf : f ∈ ⇑C '' ↑I
n : ℕ
⊢ coeff f n ∈ I

Next tactic:
cases' (Set.mem_image _ _ _).mp hf with x hx
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      

Proof state:
case mp.Hs.intro
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f : R[X]
hf : f ∈ ⇑C '' ↑I
n : ℕ
x : R
hx : x ∈ ↑I ∧ C x = f
⊢ coeff f n ∈ I

Next tactic:
rw [← hx.right, coeff_C]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      

Proof state:
case mp.Hs.intro
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f : R[X]
hf : f ∈ ⇑C '' ↑I
n : ℕ
x : R
hx : x ∈ ↑I ∧ C x = f
⊢ (if n = 0 then x else 0) ∈ I

Next tactic:
by_cases h : n = 0
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · 

Proof state:
case pos
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f : R[X]
hf : f ∈ ⇑C '' ↑I
n : ℕ
x : R
hx : x ∈ ↑I ∧ C x = f
h : n = 0
⊢ (if n = 0 then x else 0) ∈ I

Next tactic:
simpa [h] using hx.left
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · 

Proof state:
case neg
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f : R[X]
hf : f ∈ ⇑C '' ↑I
n : ℕ
x : R
hx : x ∈ ↑I ∧ C x = f
h : ¬n = 0
⊢ (if n = 0 then x else 0) ∈ I

Next tactic:
simp [h]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · 

Proof state:
case mp.H0
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : f ∈ map C I
⊢ ∀ (n : ℕ), coeff 0 n ∈ I

Next tactic:
simp
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · 

Proof state:
case mp.H1
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : f ∈ map C I
⊢ ∀ (x y : R[X]), (∀ (n : ℕ), coeff x n ∈ I) → (∀ (n : ℕ), coeff y n ∈ I) → ∀ (n : ℕ), coeff (x + y) n ∈ I

Next tactic:
exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by 

Proof state:
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf✝ : f✝ ∈ map C I
f g : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
hg : ∀ (n : ℕ), coeff g n ∈ I
n : ℕ
⊢ coeff (f + g) n ∈ I

Next tactic:
simp [I.add_mem (hf n) (hg n)]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · 

Proof state:
case mp.H2
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : f ∈ map C I
⊢ ∀ (a x : R[X]), (∀ (n : ℕ), coeff x n ∈ I) → ∀ (n : ℕ), coeff (a • x) n ∈ I

Next tactic:
refine' fun f g hg n => _
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      

Proof state:
case mp.H2
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf : f✝ ∈ map C I
f g : R[X]
hg : ∀ (n : ℕ), coeff g n ∈ I
n : ℕ
⊢ coeff (f • g) n ∈ I

Next tactic:
rw [smul_eq_mul, coeff_mul]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      

Proof state:
case mp.H2
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f✝ : R[X]
hf : f✝ ∈ map C I
f g : R[X]
hg : ∀ (n : ℕ), coeff g n ∈ I
n : ℕ
⊢ ∑ x in antidiagonal n, coeff f x.1 * coeff g x.2 ∈ I

Next tactic:
exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · 

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
⊢ (∀ (n : ℕ), coeff f n ∈ I) → f ∈ map C I

Next tactic:
intro hf
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · intro hf
    

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
⊢ f ∈ map C I

Next tactic:
rw [← sum_monomial_eq f]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · intro hf
    rw [← sum_monomial_eq f]
    

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
⊢ (sum f fun n a => (monomial n) a) ∈ map C I

Next tactic:
refine' (I.map C : Ideal R[X]).sum_mem fun n _ => _
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · intro hf
    rw [← sum_monomial_eq f]
    refine' (I.map C : Ideal R[X]).sum_mem fun n _ => _
    

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
n : ℕ
x✝ : n ∈ support f
⊢ (fun n a => (monomial n) a) n (coeff f n) ∈ map C I

Next tactic:
simp only [← C_mul_X_pow_eq_monomial, ne_eq]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · intro hf
    rw [← sum_monomial_eq f]
    refine' (I.map C : Ideal R[X]).sum_mem fun n _ => _
    simp only [← C_mul_X_pow_eq_monomial, ne_eq]
    

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
n : ℕ
x✝ : n ∈ support f
⊢ C (coeff f n) * X ^ n ∈ map C I

Next tactic:
rw [mul_comm]
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
 is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
  constructor
  · intro hf
    apply @Submodule.span_induction _ _ _ _ _ f _ _ hf
    · intro f hf n
      cases' (Set.mem_image _ _ _).mp hf with x hx
      rw [← hx.right, coeff_C]
      by_cases h : n = 0
      · simpa [h] using hx.left
      · simp [h]
    · simp
    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]
    · refine' fun f g hg n => _
      rw [smul_eq_mul, coeff_mul]
      exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
  · intro hf
    rw [← sum_monomial_eq f]
    refine' (I.map C : Ideal R[X]).sum_mem fun n _ => _
    simp only [← C_mul_X_pow_eq_monomial, ne_eq]
    rw [mul_comm]
    

Proof state:
case mpr
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
I : Ideal R
f : R[X]
hf : ∀ (n : ℕ), coeff f n ∈ I
n : ℕ
x✝ : n ∈ support f
⊢ X ^ n * C (coeff f n) ∈ map C I

Next tactic:
exact (I.map C : Ideal R[X]).mul_mem_left _ (mem_map_of_mem _ (hf n))
theorem _root_.Polynomial.ker_mapRingHom (f : R →+* S) :
    LinearMap.ker (Polynomial.mapRingHom f).toSemilinearMap = f.ker.map (C : R →+* R[X]) := by
  

Proof state:
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
f : R →+* S
⊢ LinearMap.ker (RingHom.toSemilinearMap (mapRingHom f)) = map C (RingHom.ker f)

Next tactic:
ext
theorem _root_.Polynomial.ker_mapRingHom (f : R →+* S) :
    LinearMap.ker (Polynomial.mapRingHom f).toSemilinearMap = f.ker.map (C : R →+* R[X]) := by
  ext
  

Proof state:
case h
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
f : R →+* S
x✝ : R[X]
⊢ x✝ ∈ LinearMap.ker (RingHom.toSemilinearMap (mapRingHom f)) ↔ x✝ ∈ map C (RingHom.ker f)

Next tactic:
simp only [LinearMap.mem_ker, RingHom.toSemilinearMap_apply, coe_mapRingHom]
theorem _root_.Polynomial.ker_mapRingHom (f : R →+* S) :
    LinearMap.ker (Polynomial.mapRingHom f).toSemilinearMap = f.ker.map (C : R →+* R[X]) := by
  ext
  simp only [LinearMap.mem_ker, RingHom.toSemilinearMap_apply, coe_mapRingHom]
  

Proof state:
case h
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
f : R →+* S
x✝ : R[X]
⊢ OneHom.toFun (↑↑(mapRingHom f)) x✝ = 0 ↔ x✝ ∈ map C (RingHom.ker f)

Next tactic:
rw [mem_map_C_iff, Polynomial.ext_iff]
theorem _root_.Polynomial.ker_mapRingHom (f : R →+* S) :
    LinearMap.ker (Polynomial.mapRingHom f).toSemilinearMap = f.ker.map (C : R →+* R[X]) := by
  ext
  simp only [LinearMap.mem_ker, RingHom.toSemilinearMap_apply, coe_mapRingHom]
  rw [mem_map_C_iff, Polynomial.ext_iff]
  

Proof state:
case h
R : Type u
S : Type u_1
inst✝¹ : CommSemiring R
inst✝ : Semiring S
f : R →+* S
x✝ : R[X]
⊢ (∀ (n : ℕ), coeff (OneHom.toFun (↑↑(mapRingHom f)) x✝) n = coeff 0 n) ↔ ∀ (n : ℕ), coeff x✝ n ∈ RingHom.ker f

Next tactic:
simp_rw [RingHom.mem_ker f]