l3lab/ntp-mathlib huggingface dataset:
/-- The map between multivariate formal power series induced by a map on the coefficients.-/
def map : MvPowerSeries σ R →+* MvPowerSeries σ S where
  toFun φ n := f <| coeff R n φ
  map_zero' := ext fun _n => f.map_zero
  map_one' :=
    ext fun n =>
      show f ((coeff R n) 1) = (coeff S n) 1 by
        classical
        rw [coeff_one, coeff_one]
        split_ifs with h
        · simp only [RingHom.map_ite_one_zero, ite_true, map_one, h]
        · simp only [RingHom.map_ite_one_zero, ite_false, map_zero, h]
  map_add' φ ψ :=
    ext fun n => show f ((coeff R n) (φ + ψ)) = f ((coeff R n) φ) + f ((coeff R n) ψ) by simp
  map_mul' φ ψ :=
    ext fun n =>
      show f _ = _ by
        classical
        rw [coeff_mul, map_sum, coeff_mul]
        apply Finset.sum_congr rfl
        rintro ⟨i, j⟩ _; 

Proof state:
case mk
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
φ ψ : MvPowerSeries σ R
n i j : σ →₀ ℕ
a✝ : (i, j) ∈ antidiagonal n
⊢ f ((coeff R (i, j).1) φ * (coeff R (i, j).2) ψ) =
    (coeff S (i, j).1)
        (OneHom.toFun { toFun := fun φ n => f ((coeff R n) φ), map_one' := (_ : (fun φ n => f ((coeff R n) φ)) 1 = 1) }
          φ) *
      (coeff S (i, j).2)
        (OneHom.toFun { toFun := fun φ n => f ((coeff R n) φ), map_one' := (_ : (fun φ n => f ((coeff R n) φ)) 1 = 1) }
          ψ)

Next tactic:
rw [f.map_mul]
/-- The map between multivariate formal power series induced by a map on the coefficients.-/
def map : MvPowerSeries σ R →+* MvPowerSeries σ S where
  toFun φ n := f <| coeff R n φ
  map_zero' := ext fun _n => f.map_zero
  map_one' :=
    ext fun n =>
      show f ((coeff R n) 1) = (coeff S n) 1 by
        classical
        rw [coeff_one, coeff_one]
        split_ifs with h
        · simp only [RingHom.map_ite_one_zero, ite_true, map_one, h]
        · simp only [RingHom.map_ite_one_zero, ite_false, map_zero, h]
  map_add' φ ψ :=
    ext fun n => show f ((coeff R n) (φ + ψ)) = f ((coeff R n) φ) + f ((coeff R n) ψ) by simp
  map_mul' φ ψ :=
    ext fun n =>
      show f _ = _ by
        classical
        rw [coeff_mul, map_sum, coeff_mul]
        apply Finset.sum_congr rfl
        rintro ⟨i, j⟩ _; rw [f.map_mul]; 

Proof state:
case mk
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
φ ψ : MvPowerSeries σ R
n i j : σ →₀ ℕ
a✝ : (i, j) ∈ antidiagonal n
⊢ f ((coeff R (i, j).1) φ) * f ((coeff R (i, j).2) ψ) =
    (coeff S (i, j).1)
        (OneHom.toFun { toFun := fun φ n => f ((coeff R n) φ), map_one' := (_ : (fun φ n => f ((coeff R n) φ)) 1 = 1) }
          φ) *
      (coeff S (i, j).2)
        (OneHom.toFun { toFun := fun φ n => f ((coeff R n) φ), map_one' := (_ : (fun φ n => f ((coeff R n) φ)) 1 = 1) }
          ψ)

Next tactic:
rfl
/-- The map between multivariate formal power series induced by a map on the coefficients.-/
def map : MvPowerSeries σ R →+* MvPowerSeries σ S where
  toFun φ n := f <| coeff R n φ
  map_zero' := ext fun _n => f.map_zero
  map_one' :=
    ext fun n =>
      show f ((coeff R n) 1) = (coeff S n) 1 by
        classical
        rw [coeff_one, coeff_one]
        split_ifs with h
        · simp only [RingHom.map_ite_one_zero, ite_true, map_one, h]
        · simp only [RingHom.map_ite_one_zero, ite_false, map_zero, h]
  map_add' φ ψ :=
    ext fun n => show f ((coeff R n) (φ + ψ)) = f ((coeff R n) φ) + f ((coeff R n) ψ) by 

Proof state:
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
φ ψ : MvPowerSeries σ R
n : σ →₀ ℕ
⊢ f ((coeff R n) (φ + ψ)) = f ((coeff R n) φ) + f ((coeff R n) ψ)

Next tactic:
simp
@[simp]
theorem map_monomial (n : σ →₀ ℕ) (a : R) : map σ f (monomial R n a) = monomial S n (f a) := by
  

Proof state:
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
n : σ →₀ ℕ
a : R
⊢ (map σ f) ((monomial R n) a) = (monomial S n) (f a)

Next tactic:
classical
  ext m
  simp [coeff_monomial, apply_ite f]
@[simp]
theorem map_monomial (n : σ →₀ ℕ) (a : R) : map σ f (monomial R n a) = monomial S n (f a) := by
  classical
  

Proof state:
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
n : σ →₀ ℕ
a : R
⊢ (map σ f) ((monomial R n) a) = (monomial S n) (f a)

Next tactic:
ext m
@[simp]
theorem map_monomial (n : σ →₀ ℕ) (a : R) : map σ f (monomial R n a) = monomial S n (f a) := by
  classical
  ext m
  

Proof state:
case h
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
n : σ →₀ ℕ
a : R
m : σ →₀ ℕ
⊢ (coeff S m) ((map σ f) ((monomial R n) a)) = (coeff S m) ((monomial S n) (f a))

Next tactic:
simp [coeff_monomial, apply_ite f]
@[simp]
theorem map_X (s : σ) : map σ f (X s) = X s := by 

Proof state:
σ : Type u_1
R : Type u_2
S : Type u_3
T : Type u_4
inst✝² : Semiring R
inst✝¹ : Semiring S
inst✝ : Semiring T
f : R →+* S
g : S →+* T
s : σ
⊢ (map σ f) (X s) = X s

Next tactic:
simp [MvPowerSeries.X]
instance : Algebra R (MvPowerSeries σ A) :=
  {
    show Module R (MvPowerSeries σ A) by 

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
⊢ Module R (MvPowerSeries σ A)

Next tactic:
infer_instance
instance : Algebra R (MvPowerSeries σ A) :=
  {
    show Module R (MvPowerSeries σ A) by infer_instance with
    commutes' := fun a φ => by
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : Module R (MvPowerSeries σ A) :=
  let_fun this := inferInstance;
  this
a : R
φ : MvPowerSeries σ A
⊢ (RingHom.comp (map σ (algebraMap R A)) (C σ R)) a * φ = φ * (RingHom.comp (map σ (algebraMap R A)) (C σ R)) a

Next tactic:
ext n
instance : Algebra R (MvPowerSeries σ A) :=
  {
    show Module R (MvPowerSeries σ A) by infer_instance with
    commutes' := fun a φ => by
      ext n
      

Proof state:
case h
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : Module R (MvPowerSeries σ A) :=
  let_fun this := inferInstance;
  this
a : R
φ : MvPowerSeries σ A
n : σ →₀ ℕ
⊢ (coeff A n) ((RingHom.comp (map σ (algebraMap R A)) (C σ R)) a * φ) =
    (coeff A n) (φ * (RingHom.comp (map σ (algebraMap R A)) (C σ R)) a)

Next tactic:
simp [Algebra.commutes]
instance : Algebra R (MvPowerSeries σ A) :=
  {
    show Module R (MvPowerSeries σ A) by infer_instance with
    commutes' := fun a φ => by
      ext n
      simp [Algebra.commutes]
    smul_def' := fun a σ => by
      

Proof state:
σ✝ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : Module R (MvPowerSeries σ✝ A) :=
  let_fun this := inferInstance;
  this
a : R
σ : MvPowerSeries σ✝ A
⊢ a • σ = (RingHom.comp (map σ✝ (algebraMap R A)) (C σ✝ R)) a * σ

Next tactic:
ext n
instance : Algebra R (MvPowerSeries σ A) :=
  {
    show Module R (MvPowerSeries σ A) by infer_instance with
    commutes' := fun a φ => by
      ext n
      simp [Algebra.commutes]
    smul_def' := fun a σ => by
      ext n
      

Proof state:
case h
σ✝ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : Module R (MvPowerSeries σ✝ A) :=
  let_fun this := inferInstance;
  this
a : R
σ : MvPowerSeries σ✝ A
n : σ✝ →₀ ℕ
⊢ (coeff A n) (a • σ) = (coeff A n) ((RingHom.comp (map σ✝ (algebraMap R A)) (C σ✝ R)) a * σ)

Next tactic:
simp [(coeff A n).map_smul_of_tower a, Algebra.smul_def]
theorem algebraMap_apply {r : R} :
    algebraMap R (MvPowerSeries σ A) r = C σ A (algebraMap R A r) := by
  

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
r : R
⊢ (algebraMap R (MvPowerSeries σ A)) r = (C σ A) ((algebraMap R A) r)

Next tactic:
change (MvPowerSeries.map σ (algebraMap R A)).comp (C σ R) r = _
theorem algebraMap_apply {r : R} :
    algebraMap R (MvPowerSeries σ A) r = C σ A (algebraMap R A r) := by
  change (MvPowerSeries.map σ (algebraMap R A)).comp (C σ R) r = _
  

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
r : R
⊢ (RingHom.comp (map σ (algebraMap R A)) (C σ R)) r = (C σ A) ((algebraMap R A) r)

Next tactic:
simp
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
⊢ ⊥ ≠ ⊤

Next tactic:
classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
      intro x
      rw [ext_iff, not_forall]
      refine' ⟨Finsupp.single default 1, _⟩
      simp [algebraMap_apply, coeff_C]
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
⊢ ⊥ ≠ ⊤

Next tactic:
rw [Ne.def, SetLike.ext_iff, not_forall]
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
⊢ ∃ x, ¬(x ∈ ⊥ ↔ x ∈ ⊤)

Next tactic:
inhabit σ
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
⊢ ∃ x, ¬(x ∈ ⊥ ↔ x ∈ ⊤)

Next tactic:
refine' ⟨X default, _⟩
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
⊢ ¬(X default ∈ ⊥ ↔ X default ∈ ⊤)

Next tactic:
simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
⊢ ∀ (x : R), ¬(algebraMap R (MvPowerSeries σ R)) x = X default

Next tactic:
intro x
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
      intro x
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
x : R
⊢ ¬(algebraMap R (MvPowerSeries σ R)) x = X default

Next tactic:
rw [ext_iff, not_forall]
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
      intro x
      rw [ext_iff, not_forall]
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
x : R
⊢ ∃ x_1, ¬(coeff R x_1) ((algebraMap R (MvPowerSeries σ R)) x) = (coeff R x_1) (X default)

Next tactic:
refine' ⟨Finsupp.single default 1, _⟩
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
  ⟨⟨⊥, ⊤, by
      classical
      rw [Ne.def, SetLike.ext_iff, not_forall]
      inhabit σ
      refine' ⟨X default, _⟩
      simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top]
      intro x
      rw [ext_iff, not_forall]
      refine' ⟨Finsupp.single default 1, _⟩
      

Proof state:
σ : Type u_1
R : Type u_2
A : Type u_3
inst✝⁴ : CommSemiring R
inst✝³ : Semiring A
inst✝² : Algebra R A
inst✝¹ : Nonempty σ
inst✝ : Nontrivial R
inhabited_h : Inhabited σ
x : R
⊢ ¬(coeff R fun₀ | default => 1) ((algebraMap R (MvPowerSeries σ R)) x) = (coeff R fun₀ | default => 1) (X default)

Next tactic:
simp [algebraMap_apply, coeff_C]
theorem coeff_truncFun [DecidableEq σ] (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
    (truncFun n φ).coeff m = if m < n then coeff R m φ else 0 := by
  

Proof state:
σ : Type u_1
R : Type u_2
inst✝¹ : CommSemiring R
n : σ →₀ ℕ
inst✝ : DecidableEq σ
m : σ →₀ ℕ
φ : MvPowerSeries σ R
⊢ MvPolynomial.coeff m (truncFun n φ) = if m < n then (coeff R m) φ else 0

Next tactic:
classical
  simp [truncFun, MvPolynomial.coeff_sum]
theorem coeff_truncFun [DecidableEq σ] (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
    (truncFun n φ).coeff m = if m < n then coeff R m φ else 0 := by
  classical
  

Proof state:
σ : Type u_1
R : Type u_2
inst✝¹ : CommSemiring R
n : σ →₀ ℕ
inst✝ : DecidableEq σ
m : σ →₀ ℕ
φ : MvPowerSeries σ R
⊢ MvPolynomial.coeff m (truncFun n φ) = if m < n then (coeff R m) φ else 0

Next tactic:
simp [truncFun, MvPolynomial.coeff_sum]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
⊢ truncFun n 0 = 0

Next tactic:
classical
    ext
    simp [coeff_truncFun]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
⊢ truncFun n 0 = 0

Next tactic:
ext
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    

Proof state:
case a
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n m✝ : σ →₀ ℕ
⊢ MvPolynomial.coeff m✝ (truncFun n 0) = MvPolynomial.coeff m✝ 0

Next tactic:
simp [coeff_truncFun]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
⊢ ∀ (x y : MvPowerSeries σ R),
    ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } (x + y) =
      ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } x +
        ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } y

Next tactic:
classical
    intros x y
    ext m
    simp only [coeff_truncFun, MvPolynomial.coeff_add]
    split_ifs
    · rw [map_add]
    · rw [zero_add]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
⊢ ∀ (x y : MvPowerSeries σ R),
    ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } (x + y) =
      ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } x +
        ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } y

Next tactic:
intros x y
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    intros x y
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
x y : MvPowerSeries σ R
⊢ ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } (x + y) =
    ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } x +
      ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } y

Next tactic:
ext m
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    intros x y
    ext m
    

Proof state:
case a
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
x y : MvPowerSeries σ R
m : σ →₀ ℕ
⊢ MvPolynomial.coeff m (ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } (x + y)) =
    MvPolynomial.coeff m
      (ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } x +
        ZeroHom.toFun { toFun := truncFun n, map_zero' := (_ : truncFun n 0 = 0) } y)

Next tactic:
simp only [coeff_truncFun, MvPolynomial.coeff_add]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    intros x y
    ext m
    simp only [coeff_truncFun, MvPolynomial.coeff_add]
    

Proof state:
case a
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
x y : MvPowerSeries σ R
m : σ →₀ ℕ
⊢ (if m < n then (coeff R m) (x + y) else 0) = (if m < n then (coeff R m) x else 0) + if m < n then (coeff R m) y else 0

Next tactic:
split_ifs
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    intros x y
    ext m
    simp only [coeff_truncFun, MvPolynomial.coeff_add]
    split_ifs
    · 

Proof state:
case pos
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
x y : MvPowerSeries σ R
m : σ →₀ ℕ
h✝ : m < n
⊢ (coeff R m) (x + y) = (coeff R m) x + (coeff R m) y

Next tactic:
rw [map_add]
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
  toFun := truncFun n
  map_zero' := by
    classical
    ext
    simp [coeff_truncFun]
  map_add' := by
    classical
    intros x y
    ext m
    simp only [coeff_truncFun, MvPolynomial.coeff_add]
    split_ifs
    · rw [map_add]
    · 

Proof state:
case neg
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n : σ →₀ ℕ
x y : MvPowerSeries σ R
m : σ →₀ ℕ
h✝ : ¬m < n
⊢ 0 = 0 + 0

Next tactic:
rw [zero_add]
theorem coeff_trunc (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
    (trunc R n φ).coeff m = if m < n then coeff R m φ else 0 := by
  

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n m : σ →₀ ℕ
φ : MvPowerSeries σ R
⊢ MvPolynomial.coeff m ((trunc R n) φ) = if m < n then (coeff R m) φ else 0

Next tactic:
classical simp [trunc, coeff_truncFun]
theorem coeff_trunc (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
    (trunc R n φ).coeff m = if m < n then coeff R m φ else 0 := by
  classical 

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n m : σ →₀ ℕ
φ : MvPowerSeries σ R
⊢ MvPolynomial.coeff m ((trunc R n) φ) = if m < n then (coeff R m) φ else 0

Next tactic:
simp [trunc, coeff_truncFun]
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
⊢ MvPolynomial.coeff m ((trunc R n) 1) = MvPolynomial.coeff m 1

Next tactic:
classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      simp
    · symm
      rw [MvPolynomial.coeff_one]
      exact if_neg (Ne.symm H')
    · symm
      rw [MvPolynomial.coeff_one]
      refine' if_neg _
      rintro rfl
      apply H
      exact Ne.bot_lt hnn
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
⊢ MvPolynomial.coeff m ((trunc R n) 1) = MvPolynomial.coeff m 1

Next tactic:
rw [coeff_trunc, coeff_one]
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    

Proof state:
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
⊢ (if m < n then if m = 0 then 1 else 0 else 0) = MvPolynomial.coeff m 1

Next tactic:
split_ifs with H H'
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · 

Proof state:
case pos
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
H : m < n
H' : m = 0
⊢ 1 = MvPolynomial.coeff m 1

Next tactic:
subst m
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      

Proof state:
case pos
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
H : 0 < n
⊢ 1 = MvPolynomial.coeff 0 1

Next tactic:
simp
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      simp
    · 

Proof state:
case neg
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
H : m < n
H' : ¬m = 0
⊢ 0 = MvPolynomial.coeff m 1

Next tactic:
symm
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      simp
    · symm
      

Proof state:
case neg
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
H : m < n
H' : ¬m = 0
⊢ MvPolynomial.coeff m 1 = 0

Next tactic:
rw [MvPolynomial.coeff_one]
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      simp
    · symm
      rw [MvPolynomial.coeff_one]
      

Proof state:
case neg
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
H : m < n
H' : ¬m = 0
⊢ (if 0 = m then 1 else 0) = 0

Next tactic:
exact if_neg (Ne.symm H')
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
  MvPolynomial.ext _ _ fun m => by
    classical
    rw [coeff_trunc, coeff_one]
    split_ifs with H H'
    · subst m
      simp
    · symm
      rw [MvPolynomial.coeff_one]
      exact if_neg (Ne.symm H')
    · 

Proof state:
case neg
σ : Type u_1
R : Type u_2
inst✝ : CommSemiring R
n✝ n : σ →₀ ℕ
hnn : n ≠ 0
m : σ →₀ ℕ
H : ¬m < n
⊢ 0 = MvPolynomial.coeff m 1

Next tactic:
symm