l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem map_aeval {B : Type*} [CommSemiring B] (g : σ → S₁) (φ : S₁ →+* B) (p : MvPolynomial σ R) :
    φ (aeval g p) = eval₂Hom (φ.comp (algebraMap R S₁)) (fun i => φ (g i)) p := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
inst✝² : Algebra R S₁
inst✝¹ : CommSemiring S₂
f : σ → S₁
B : Type u_2
inst✝ : CommSemiring B
g : σ → S₁
φ : S₁ →+* B
p : MvPolynomial σ R
⊢ φ ((aeval g) p) = (eval₂Hom (RingHom.comp φ (algebraMap R S₁)) fun i => φ (g i)) p

Next tactic:
rw [← comp_eval₂Hom]
@[simp]
theorem map_aeval {B : Type*} [CommSemiring B] (g : σ → S₁) (φ : S₁ →+* B) (p : MvPolynomial σ R) :
    φ (aeval g p) = eval₂Hom (φ.comp (algebraMap R S₁)) (fun i => φ (g i)) p := by
  rw [← comp_eval₂Hom]
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
inst✝² : Algebra R S₁
inst✝¹ : CommSemiring S₂
f : σ → S₁
B : Type u_2
inst✝ : CommSemiring B
g : σ → S₁
φ : S₁ →+* B
p : MvPolynomial σ R
⊢ φ ((aeval g) p) = (RingHom.comp φ (eval₂Hom (algebraMap R S₁) fun i => g i)) p

Next tactic:
rfl
@[simp]
theorem eval₂Hom_zero (f : R →+* S₂) : eval₂Hom f (0 : σ → S₂) = f.comp constantCoeff := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
⊢ eval₂Hom f 0 = RingHom.comp f constantCoeff

Next tactic:
ext
@[simp]
theorem eval₂Hom_zero (f : R →+* S₂) : eval₂Hom f (0 : σ → S₂) = f.comp constantCoeff := by
  ext <;> 

Proof state:
case hC.a
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
x✝ : R
⊢ (RingHom.comp (eval₂Hom f 0) C) x✝ = (RingHom.comp (RingHom.comp f constantCoeff) C) x✝

Next tactic:
simp
@[simp]
theorem eval₂Hom_zero (f : R →+* S₂) : eval₂Hom f (0 : σ → S₂) = f.comp constantCoeff := by
  ext <;> 

Proof state:
case hX
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
i✝ : σ
⊢ (eval₂Hom f 0) (X i✝) = (RingHom.comp f constantCoeff) (X i✝)

Next tactic:
simp
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
⊢ (eval₂Hom f g) φ = 0

Next tactic:
rw [φ.as_sum, map_sum]
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  rw [φ.as_sum, map_sum]
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
⊢ ∑ x in support φ, (eval₂Hom f g) ((monomial x) (coeff x φ)) = 0

Next tactic:
refine Finset.sum_eq_zero fun d hd => ?_
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  rw [φ.as_sum, map_sum]
  refine Finset.sum_eq_zero fun d hd => ?_
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
d : σ →₀ ℕ
hd : d ∈ support φ
⊢ (eval₂Hom f g) ((monomial d) (coeff d φ)) = 0

Next tactic:
obtain ⟨i, hi, hgi⟩ : ∃ i ∈ d.support, g i = 0 := h d (Finsupp.mem_support_iff.mp hd)
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  rw [φ.as_sum, map_sum]
  refine Finset.sum_eq_zero fun d hd => ?_
  obtain ⟨i, hi, hgi⟩ : ∃ i ∈ d.support, g i = 0 := h d (Finsupp.mem_support_iff.mp hd)
  

Proof state:
case intro.intro
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
d : σ →₀ ℕ
hd : d ∈ support φ
i : σ
hi : i ∈ d.support
hgi : g i = 0
⊢ (eval₂Hom f g) ((monomial d) (coeff d φ)) = 0

Next tactic:
rw [eval₂Hom_monomial, Finsupp.prod, Finset.prod_eq_zero hi, mul_zero]
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  rw [φ.as_sum, map_sum]
  refine Finset.sum_eq_zero fun d hd => ?_
  obtain ⟨i, hi, hgi⟩ : ∃ i ∈ d.support, g i = 0 := h d (Finsupp.mem_support_iff.mp hd)
  rw [eval₂Hom_monomial, Finsupp.prod, Finset.prod_eq_zero hi, mul_zero]
  

Proof state:
case intro.intro
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
d : σ →₀ ℕ
hd : d ∈ support φ
i : σ
hi : i ∈ d.support
hgi : g i = 0
⊢ g i ^ d i = 0

Next tactic:
rw [hgi, zero_pow]
theorem eval₂Hom_eq_zero (f : R →+* S₂) (g : σ → S₂) (φ : MvPolynomial σ R)
    (h : ∀ d, φ.coeff d ≠ 0 → ∃ i ∈ d.support, g i = 0) : eval₂Hom f g φ = 0 := by
  rw [φ.as_sum, map_sum]
  refine Finset.sum_eq_zero fun d hd => ?_
  obtain ⟨i, hi, hgi⟩ : ∃ i ∈ d.support, g i = 0 := h d (Finsupp.mem_support_iff.mp hd)
  rw [eval₂Hom_monomial, Finsupp.prod, Finset.prod_eq_zero hi, mul_zero]
  rw [hgi, zero_pow]
  

Proof state:
case intro.intro
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f✝ : σ → S₁
f : R →+* S₂
g : σ → S₂
φ : MvPolynomial σ R
h : ∀ (d : σ →₀ ℕ), coeff d φ ≠ 0 → ∃ i ∈ d.support, g i = 0
d : σ →₀ ℕ
hd : d ∈ support φ
i : σ
hi : i ∈ d.support
hgi : g i = 0
⊢ 0 < d i

Next tactic:
rwa [pos_iff_ne_zero, ← Finsupp.mem_support_iff]
theorem _root_.Algebra.adjoin_range_eq_range_aeval :
    Algebra.adjoin R (Set.range f) = (MvPolynomial.aeval f).range := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f : σ → S₁
⊢ Algebra.adjoin R (range f) = AlgHom.range (aeval f)

Next tactic:
simp only [← Algebra.map_top, ← MvPolynomial.adjoin_range_X, AlgHom.map_adjoin, ← Set.range_comp,
    (· ∘ ·), MvPolynomial.aeval_X]
theorem _root_.Algebra.adjoin_eq_range (s : Set S₁) :
    Algebra.adjoin R s = (MvPolynomial.aeval ((↑) : s → S₁)).range := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝³ : CommSemiring R
inst✝² : CommSemiring S₁
p q : MvPolynomial σ R
inst✝¹ : Algebra R S₁
inst✝ : CommSemiring S₂
f : σ → S₁
s : Set S₁
⊢ Algebra.adjoin R s = AlgHom.range (aeval Subtype.val)

Next tactic:
rw [← Algebra.adjoin_range_eq_range_aeval, Subtype.range_coe]
/-- Version of `aeval` for defining algebra homs out of `MvPolynomial σ R` over a smaller base ring
  than `R`. -/
def aevalTower (f : R →ₐ[S] A) (X : σ → A) : MvPolynomial σ R →ₐ[S] A :=
  { eval₂Hom (↑f) X with
    commutes' := fun r => by
      

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁷ : CommSemiring R
inst✝⁶ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
A : Type u_3
B : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommSemiring A
inst✝³ : CommSemiring B
inst✝² : Algebra S R
inst✝¹ : Algebra S A
inst✝ : Algebra S B
f : R →ₐ[S] A
X : σ → A
src✝ : MvPolynomial σ R →+* A := eval₂Hom (↑f) X
r : S
⊢ OneHom.toFun
      (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),
            map_add' :=
              (_ :
                ∀ (x y : MvPolynomial σ R),
                  OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) })
      ((algebraMap S (MvPolynomial σ R)) r) =
    (algebraMap S A) r

Next tactic:
simp [IsScalarTower.algebraMap_eq S R (MvPolynomial σ R), algebraMap_eq]
@[simp]
theorem aevalTower_id :
    aevalTower (AlgHom.id S S) = (aeval : (σ → S) → MvPolynomial σ S →ₐ[S] S) := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁷ : CommSemiring R
inst✝⁶ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
A : Type u_3
B : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommSemiring A
inst✝³ : CommSemiring B
inst✝² : Algebra S R
inst✝¹ : Algebra S A
inst✝ : Algebra S B
g : R →ₐ[S] A
y : σ → A
⊢ aevalTower (AlgHom.id S S) = aeval

Next tactic:
ext
@[simp]
theorem aevalTower_id :
    aevalTower (AlgHom.id S S) = (aeval : (σ → S) → MvPolynomial σ S →ₐ[S] S) := by
  ext
  

Proof state:
case h.hf
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁷ : CommSemiring R
inst✝⁶ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
A : Type u_3
B : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommSemiring A
inst✝³ : CommSemiring B
inst✝² : Algebra S R
inst✝¹ : Algebra S A
inst✝ : Algebra S B
g : R →ₐ[S] A
y : σ → A
x✝ : σ → S
i✝ : σ
⊢ (aevalTower (AlgHom.id S S) x✝) (X i✝) = (aeval x✝) (X i✝)

Next tactic:
simp only [aevalTower_X, aeval_X]
@[simp]
theorem aevalTower_ofId :
    aevalTower (Algebra.ofId S A) = (aeval : (σ → A) → MvPolynomial σ S →ₐ[S] A) := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁷ : CommSemiring R
inst✝⁶ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
A : Type u_3
B : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommSemiring A
inst✝³ : CommSemiring B
inst✝² : Algebra S R
inst✝¹ : Algebra S A
inst✝ : Algebra S B
g : R →ₐ[S] A
y : σ → A
⊢ aevalTower (Algebra.ofId S A) = aeval

Next tactic:
ext
@[simp]
theorem aevalTower_ofId :
    aevalTower (Algebra.ofId S A) = (aeval : (σ → A) → MvPolynomial σ S →ₐ[S] A) := by
  ext
  

Proof state:
case h.hf
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s : σ →₀ ℕ
inst✝⁷ : CommSemiring R
inst✝⁶ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
A : Type u_3
B : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommSemiring A
inst✝³ : CommSemiring B
inst✝² : Algebra S R
inst✝¹ : Algebra S A
inst✝ : Algebra S B
g : R →ₐ[S] A
y x✝ : σ → A
i✝ : σ
⊢ (aevalTower (Algebra.ofId S A) x✝) (X i✝) = (aeval x✝) (X i✝)

Next tactic:
simp only [aeval_X, aevalTower_X]
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
⊢ eval₂ f v p ∈ s

Next tactic:
classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
    · simpa using hs 0
    rw [eval₂_add, eval₂_monomial]
    refine' add_mem (mul_mem _ <| prod_mem fun i _ => pow_mem (hv _) _) (ih fun i => _)
    · have := hs a -- Porting note: was `simpa only [...]`
      rwa [coeff_add, MvPolynomial.not_mem_support_iff.1 ha, add_zero, coeff_monomial,
        if_pos rfl] at this
    have := hs i
    rw [coeff_add, coeff_monomial] at this
    split_ifs at this with h
    · subst h
      rw [MvPolynomial.not_mem_support_iff.1 ha, map_zero]
      exact zero_mem _
    · rwa [zero_add] at this
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
⊢ eval₂ f v p ∈ s

Next tactic:
replace hs : ∀ i, f (p.coeff i) ∈ s
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · 

Proof state:
case hs
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
⊢ ∀ (i : σ →₀ ℕ), f (coeff i p) ∈ s

Next tactic:
intro i
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      

Proof state:
case hs
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
i : σ →₀ ℕ
⊢ f (coeff i p) ∈ s

Next tactic:
by_cases hi : i ∈ p.support
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · 

Proof state:
case pos
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
i : σ →₀ ℕ
hi : i ∈ support p
⊢ f (coeff i p) ∈ s

Next tactic:
exact hs i hi
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · 

Proof state:
case neg
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
i : σ →₀ ℕ
hi : i ∉ support p
⊢ f (coeff i p) ∈ s

Next tactic:
rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        

Proof state:
case neg
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
hs : ∀ i ∈ support p, f (coeff i p) ∈ s
v : σ → S
hv : ∀ (i : σ), v i ∈ s
i : σ →₀ ℕ
hi : i ∉ support p
⊢ 0 ∈ s

Next tactic:
exact zero_mem s
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    

Proof state:
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p✝ q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
p : MvPolynomial σ R
s : subS
v : σ → S
hv : ∀ (i : σ), v i ∈ s
hs : ∀ (i : σ →₀ ℕ), f (coeff i p) ∈ s
⊢ eval₂ f v p ∈ s

Next tactic:
induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
    · 

Proof state:
case h_C
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a✝ a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f : R →+* S
s : subS
v : σ → S
hv : ∀ (i : σ), v i ∈ s
a : R
hs : ∀ (i : σ →₀ ℕ), f (coeff i (C a)) ∈ s
⊢ eval₂ f v (C a) ∈ s

Next tactic:
simpa using hs 0
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
    · simpa using hs 0
    

Proof state:
case h_add_weak
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a✝¹ a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f✝ : R →+* S
s : subS
v : σ → S
hv : ∀ (i : σ), v i ∈ s
a : σ →₀ ℕ
b : R
f : (σ →₀ ℕ) →₀ R
ha : a ∉ f.support
a✝ : b ≠ 0
ih : (∀ (i : σ →₀ ℕ), f✝ (coeff i f) ∈ s) → eval₂ f✝ v f ∈ s
hs :
  ∀ (i : σ →₀ ℕ),
    f✝
        (coeff i
          ((let_fun this := (monomial a) b;
            this) +
            f)) ∈
      s
⊢ eval₂ f✝ v
      ((let_fun this := (monomial a) b;
        this) +
        f) ∈
    s

Next tactic:
rw [eval₂_add, eval₂_monomial]
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
    · simpa using hs 0
    rw [eval₂_add, eval₂_monomial]
    

Proof state:
case h_add_weak
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a✝¹ a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f✝ : R →+* S
s : subS
v : σ → S
hv : ∀ (i : σ), v i ∈ s
a : σ →₀ ℕ
b : R
f : (σ →₀ ℕ) →₀ R
ha : a ∉ f.support
a✝ : b ≠ 0
ih : (∀ (i : σ →₀ ℕ), f✝ (coeff i f) ∈ s) → eval₂ f✝ v f ∈ s
hs :
  ∀ (i : σ →₀ ℕ),
    f✝
        (coeff i
          ((let_fun this := (monomial a) b;
            this) +
            f)) ∈
      s
⊢ (f✝ b * Finsupp.prod a fun n e => v n ^ e) + eval₂ f✝ v f ∈ s

Next tactic:
refine' add_mem (mul_mem _ <| prod_mem fun i _ => pow_mem (hv _) _) (ih fun i => _)
theorem eval₂_mem {f : R →+* S} {p : MvPolynomial σ R} {s : subS}
    (hs : ∀ i ∈ p.support, f (p.coeff i) ∈ s) {v : σ → S} (hv : ∀ i, v i ∈ s) :
    MvPolynomial.eval₂ f v p ∈ s := by
  classical
    replace hs : ∀ i, f (p.coeff i) ∈ s
    · intro i
      by_cases hi : i ∈ p.support
      · exact hs i hi
      · rw [MvPolynomial.not_mem_support_iff.1 hi, f.map_zero]
        exact zero_mem s
    induction' p using MvPolynomial.induction_on''' with a a b f ha _ ih
    · simpa using hs 0
    rw [eval₂_add, eval₂_monomial]
    refine' add_mem (mul_mem _ <| prod_mem fun i _ => pow_mem (hv _) _) (ih fun i => _)
    · 

Proof state:
case h_add_weak.refine'_1
R : Type u
S₁ : Type v
S₂ : Type w
S₃ : Type x
σ : Type u_1
a✝¹ a' a₁ a₂ : R
e : ℕ
n m : σ
s✝ : σ →₀ ℕ
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S₁
p q : MvPolynomial σ R
S : Type u_2
subS : Type u_3
inst✝² : CommSemiring S
inst✝¹ : SetLike subS S
inst✝ : SubsemiringClass subS S
f✝ : R →+* S
s : subS
v : σ → S
hv : ∀ (i : σ), v i ∈ s
a : σ →₀ ℕ
b : R
f : (σ →₀ ℕ) →₀ R
ha : a ∉ f.support
a✝ : b ≠ 0
ih : (∀ (i : σ →₀ ℕ), f✝ (coeff i f) ∈ s) → eval₂ f✝ v f ∈ s
hs :
  ∀ (i : σ →₀ ℕ),
    f✝
        (coeff i
          ((let_fun this := (monomial a) b;
            this) +
            f)) ∈
      s
⊢ f✝ b ∈ s

Next tactic:
have := hs a