l3lab/ntp-mathlib huggingface dataset:
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      

Proof state:
case pos
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m ∈ 0.support
H : 1 = 0
⊢ f m = 0

Next tactic:
cases h
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · 

Proof state:
case neg
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m ∈ (single 0 1).support
H : ¬1 = 0
⊢ f m = 0

Next tactic:
rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      

Proof state:
case neg
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m = 0
H : ¬1 = 0
⊢ f m = 0

Next tactic:
rw [h, AddMonoidHom.map_zero]
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      rw [h, AddMonoidHom.map_zero]
  mul_mem i j a b ha hb c hc := by
    

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : ι
a b : R[M]
ha : a ∈ gradeBy R (⇑f) i
hb : b ∈ gradeBy R (⇑f) j
c : M
hc : c ∈ (a * b).support
⊢ f c = i + j

Next tactic:
set h := support_mul a b hc
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      rw [h, AddMonoidHom.map_zero]
  mul_mem i j a b ha hb c hc := by
    set h := support_mul a b hc
    

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : ι
a b : R[M]
ha : a ∈ gradeBy R (⇑f) i
hb : b ∈ gradeBy R (⇑f) j
c : M
hc : c ∈ (a * b).support
h : c ∈ Finset.biUnion a.support fun a₁ => Finset.biUnion b.support fun a₂ => {a₁ + a₂} := support_mul a b hc
⊢ f c = i + j

Next tactic:
simp only [Finset.mem_biUnion] at h
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      rw [h, AddMonoidHom.map_zero]
  mul_mem i j a b ha hb c hc := by
    set h := support_mul a b hc
    simp only [Finset.mem_biUnion] at h
    

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : ι
a b : R[M]
ha : a ∈ gradeBy R (⇑f) i
hb : b ∈ gradeBy R (⇑f) j
c : M
hc : c ∈ (a * b).support
h : ∃ a_1 ∈ a.support, ∃ a ∈ b.support, c ∈ {a_1 + a}
⊢ f c = i + j

Next tactic:
rcases h with ⟨ma, ⟨hma, ⟨mb, ⟨hmb, hmc⟩⟩⟩⟩
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      rw [h, AddMonoidHom.map_zero]
  mul_mem i j a b ha hb c hc := by
    set h := support_mul a b hc
    simp only [Finset.mem_biUnion] at h
    rcases h with ⟨ma, ⟨hma, ⟨mb, ⟨hmb, hmc⟩⟩⟩⟩
    

Proof state:
case intro.intro.intro.intro
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : ι
a b : R[M]
ha : a ∈ gradeBy R (⇑f) i
hb : b ∈ gradeBy R (⇑f) j
c : M
hc : c ∈ (a * b).support
ma : M
hma : ma ∈ a.support
mb : M
hmb : mb ∈ b.support
hmc : c ∈ {ma + mb}
⊢ f c = i + j

Next tactic:
rw [← ha ma hma, ← hb mb hmb, Finset.mem_singleton.mp hmc]
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · rw [H, single, Finsupp.single_zero] at h
      cases h
    · rw [Finsupp.support_single_ne_zero _ H, Finset.mem_singleton] at h
      rw [h, AddMonoidHom.map_zero]
  mul_mem i j a b ha hb c hc := by
    set h := support_mul a b hc
    simp only [Finset.mem_biUnion] at h
    rcases h with ⟨ma, ⟨hma, ⟨mb, ⟨hmb, hmc⟩⟩⟩⟩
    rw [← ha ma hma, ← hb mb hmb, Finset.mem_singleton.mp hmc]
    

Proof state:
case intro.intro.intro.intro
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : ι
a b : R[M]
ha : a ∈ gradeBy R (⇑f) i
hb : b ∈ gradeBy R (⇑f) j
c : M
hc : c ∈ (a * b).support
ma : M
hma : ma ∈ a.support
mb : M
hmb : mb ∈ b.support
hmc : c ∈ {ma + mb}
⊢ f (ma + mb) = f ma + f mb

Next tactic:
apply AddMonoidHom.map_add
instance grade.gradedMonoid [AddMonoid M] [CommSemiring R] :
    SetLike.GradedMonoid (grade R : M → Submodule R R[M]) := by
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝² : DecidableEq M
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
⊢ SetLike.GradedMonoid (grade R)

Next tactic:
apply gradeBy.gradedMonoid (AddMonoidHom.id _)
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by 

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ GradedMonoid.mk (f (Multiplicative.toAdd 1))
      { val := fun₀ | Multiplicative.toAdd 1 => 1,
        property := (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
    GradedMonoid.mk 0 GradedMonoid.GOne.one

Next tactic:
congr 2
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> 

Proof state:
case h.e_3.h
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ f (Multiplicative.toAdd 1) = 0

Next tactic:
simp
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> 

Proof state:
case h.e_4.e_2.h
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ (fun x => x ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) = fun x => x ∈ (fun i => gradeBy R (⇑f) i) 0

Next tactic:
simp
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> 

Proof state:
case h.e_4.e_4
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ HEq (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1)))
    (_ : 1 ∈ gradeBy R (⇑f) 0)

Next tactic:
simp
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
⊢ OneHom.toFun
      {
        toFun := fun m =>
          (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
            { val := fun₀ | Multiplicative.toAdd m => 1,
              property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
        map_one' :=
          (_ :
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                { val := fun₀ | Multiplicative.toAdd 1 => 1,
                  property :=
                    (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
      (i * j) =
    OneHom.toFun
        {
          toFun := fun m =>
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
              { val := fun₀ | Multiplicative.toAdd m => 1,
                property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
          map_one' :=
            (_ :
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                  { val := fun₀ | Multiplicative.toAdd 1 => 1,
                    property :=
                      (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
                (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
        i *
      OneHom.toFun
        {
          toFun := fun m =>
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
              { val := fun₀ | Multiplicative.toAdd m => 1,
                property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
          map_one' :=
            (_ :
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                  { val := fun₀ | Multiplicative.toAdd 1 => 1,
                    property :=
                      (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
                (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
        j

Next tactic:
symm
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
⊢ OneHom.toFun
        {
          toFun := fun m =>
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
              { val := fun₀ | Multiplicative.toAdd m => 1,
                property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
          map_one' :=
            (_ :
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                  { val := fun₀ | Multiplicative.toAdd 1 => 1,
                    property :=
                      (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
                (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
        i *
      OneHom.toFun
        {
          toFun := fun m =>
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
              { val := fun₀ | Multiplicative.toAdd m => 1,
                property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
          map_one' :=
            (_ :
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                  { val := fun₀ | Multiplicative.toAdd 1 => 1,
                    property :=
                      (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
                (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
        j =
    OneHom.toFun
      {
        toFun := fun m =>
          (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd m)))
            { val := fun₀ | Multiplicative.toAdd m => 1,
              property := (_ : (fun₀ | Multiplicative.toAdd m => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd m))) },
        map_one' :=
          (_ :
            (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd 1)))
                { val := fun₀ | Multiplicative.toAdd 1 => 1,
                  property :=
                    (_ : (fun₀ | Multiplicative.toAdd 1 => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd 1))) } =
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) 0) GradedMonoid.GOne.one) }
      (i * j)

Next tactic:
dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
        

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd i)))
        { val := fun₀ | Multiplicative.toAdd i => 1,
          property := (_ : (fun₀ | Multiplicative.toAdd i => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd i))) } *
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd j)))
        { val := fun₀ | Multiplicative.toAdd j => 1,
          property := (_ : (fun₀ | Multiplicative.toAdd j => 1) ∈ gradeBy R (⇑f) (f (Multiplicative.toAdd j))) } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f (Multiplicative.toAdd i + Multiplicative.toAdd j)))
      { val := fun₀ | Multiplicative.toAdd i + Multiplicative.toAdd j => 1,
        property :=
          (_ :
            (fun₀ | Multiplicative.toAdd i + Multiplicative.toAdd j => 1) ∈
              gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) }

Next tactic:
convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
        convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
        repeat { 

Proof state:
case h.e'_3.h.e'_1.h.e'_1.h.e'_2.h.h.e'_5.h.e'_7
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
x✝ : R[M]
⊢ f (Multiplicative.toAdd i + Multiplicative.toAdd j) = f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)

Next tactic:
rw [ AddMonoidHom.map_add]
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
        convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
        repeat { 

Proof state:
case h.e'_3.h.e'_1.h.e'_3.e'_2.e'_2.e'_8
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
e_1✝ :
  ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) =
    ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)))
⊢ f (Multiplicative.toAdd i + Multiplicative.toAdd j) = f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)

Next tactic:
rw [ AddMonoidHom.map_add]
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
        convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
        repeat { 

Proof state:
case h.e'_3.h.e'_2.h.e'_2.h.h.e'_5.h.e'_7
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
x✝ : R[M]
⊢ f (Multiplicative.toAdd i + Multiplicative.toAdd j) = f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)

Next tactic:
rw [ AddMonoidHom.map_add]
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
  AddMonoidAlgebra.lift R M _
    { toFun := fun m =>
        DirectSum.of (fun i : ι => gradeBy R f i) (f (Multiplicative.toAdd m))
          ⟨Finsupp.single (Multiplicative.toAdd m) 1, single_mem_gradeBy _ _ _⟩
      map_one' :=
        DirectSum.of_eq_of_gradedMonoid_eq
          (by congr 2 <;> simp)
      map_mul' := fun i j => by
        symm
        dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
          OneHom.coe_mk, toAdd_mul]
        convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
        repeat { 

Proof state:
case h.e'_3.h.e'_4.e'_4.e'_2.e'_2.e'_2.e'_8
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i j : Multiplicative M
e_1✝¹ :
  (↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) →+ ⨁ (i : ι), ↥(gradeBy R (⇑f) i)) =
    (↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j))) →+ ⨁ (i : ι), ↥(gradeBy R (⇑f) i))
e_2✝¹ :
  ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) =
    ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)))
e_3✝ : HEq (fun x => ⨁ (i : ι), ↥(gradeBy R (⇑f) i)) fun x => ⨁ (i : ι), ↥(gradeBy R (⇑f) i)
e_2✝ :
  ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) =
    ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)))
e_1✝ :
  ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i + Multiplicative.toAdd j))) =
    ↥(gradeBy R (⇑f) (f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)))
⊢ f (Multiplicative.toAdd i + Multiplicative.toAdd j) = f (Multiplicative.toAdd i) + f (Multiplicative.toAdd j)

Next tactic:
rw [ AddMonoidHom.map_add]