-- Mathlib/Algebra/MvPolynomial/Eval.lean
theorem coeff_map (p : MvPolynomial σ R) : ∀ m : σ →₀ ℕ, coeff m (map f p) = f (coeff m p)

Proof state:
case h_add
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (p q : MvPolynomial σ R),
    (∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)) →
      (∀ (m : σ →₀ ℕ), coeff m ((map f) q) = f (coeff m q)) →
        ∀ (m : σ →₀ ℕ), coeff m ((map f) (p + q)) = f (coeff m (p + q))

Tactic:
intro p q hp hq m

Result:
case h_add
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p q : MvPolynomial σ R
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
hq : ∀ (m : σ →₀ ℕ), coeff m ((map f) q) = f (coeff m q)
m : σ →₀ ℕ
⊢ coeff m ((map f) (p + q)) = f (coeff m (p + q))

Proof state:
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
⊢ ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)

Tactic:
apply MvPolynomial.induction_on p <;> clear p

Result:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (a : R) (m : σ →₀ ℕ), coeff m ((map f) (C a)) = f (coeff m (C a))

case h_add
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (p q : MvPolynomial σ R),
    (∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)) →
      (∀ (m : σ →₀ ℕ), coeff m ((map f) q) = f (coeff m q)) →
        ∀ (m : σ →₀ ℕ), coeff m ((map f) (p + q)) = f (coeff m (p + q))

case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (p : MvPolynomial σ R) (n : σ),
    (∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)) →
      ∀ (m : σ →₀ ℕ), coeff m ((map f) (p * X n)) = f (coeff m (p * X n))

Proof state:
case neg
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
h✝ : ¬0 = m
⊢ 0 = f 0

Tactic:
rw [f.map_zero]

Result:
no goals

Proof state:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (p : MvPolynomial σ R) (n : σ),
    (∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)) →
      ∀ (m : σ →₀ ℕ), coeff m ((map f) (p * X n)) = f (coeff m (p * X n))

Tactic:
intro p i hp m

Result:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ coeff m ((map f) (p * X i)) = f (coeff m (p * X i))

Proof state:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ coeff m (C (f r)) = f (coeff m (C r))

Tactic:
simp only [coeff_C]

Result:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ (if 0 = m then f r else 0) = f (if 0 = m then r else 0)

Proof state:
case neg
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
h✝ : i ∉ m.support
⊢ 0 = f 0

Tactic:
rw [f.map_zero]

Result:
no goals

Proof state:
case pos
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
h✝ : 0 = m
⊢ f r = f r

Tactic:
rfl

Result:
no goals

Proof state:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
⊢ ∀ (a : R) (m : σ →₀ ℕ), coeff m ((map f) (C a)) = f (coeff m (C a))

Tactic:
intro r m

Result:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ coeff m ((map f) (C r)) = f (coeff m (C r))

Proof state:
case h_add
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p q : MvPolynomial σ R
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
hq : ∀ (m : σ →₀ ℕ), coeff m ((map f) q) = f (coeff m q)
m : σ →₀ ℕ
⊢ f (coeff m p) + f (coeff m q) = f (coeff m p + coeff m q)

Tactic:
rw [f.map_add]

Result:
no goals

Proof state:
case pos
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
h✝ : i ∈ m.support
⊢ f (coeff (m - Finsupp.single i 1) p) = f (coeff (m - Finsupp.single i 1) p)

Tactic:
rfl

Result:
no goals

Proof state:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ coeff m ((map f) (p * X i)) = f (coeff m (p * X i))

Tactic:
simp only [hp, (map f).map_mul, map_X]

Result:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ coeff m ((map f) p * X i) = f (coeff m (p * X i))

Proof state:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ (if 0 = m then f r else 0) = f (if 0 = m then r else 0)

Tactic:
split_ifs

Result:
case pos
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
h✝ : 0 = m
⊢ f r = f r

case neg
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
h✝ : ¬0 = m
⊢ 0 = f 0

Proof state:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ (if i ∈ m.support then f (coeff (m - Finsupp.single i 1) p) else 0) =
    f (if i ∈ m.support then coeff (m - Finsupp.single i 1) p else 0)

Tactic:
split_ifs

Result:
case pos
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
h✝ : i ∈ m.support
⊢ f (coeff (m - Finsupp.single i 1) p) = f (coeff (m - Finsupp.single i 1) p)

case neg
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
h✝ : i ∉ m.support
⊢ 0 = f 0

Proof state:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ coeff m ((map f) (C r)) = f (coeff m (C r))

Tactic:
rw [map_C]

Result:
case h_C
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
r : R
m : σ →₀ ℕ
⊢ coeff m (C (f r)) = f (coeff m (C r))

Proof state:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ coeff m ((map f) p * X i) = f (coeff m (p * X i))

Tactic:
simp only [hp, mem_support_iff, coeff_mul_X']

Result:
case h_X
R : Type u
S₁ : Type v
σ : Type u_1
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S₁
f : R →+* S₁
p : MvPolynomial σ R
i : σ
hp : ∀ (m : σ →₀ ℕ), coeff m ((map f) p) = f (coeff m p)
m : σ →₀ ℕ
⊢ (if i ∈ m.support then f (coeff (m - Finsupp.single i 1) p) else 0) =
    f (if i ∈ m.support then coeff (m - Finsupp.single i 1) p else 0)