l3lab/ntp-mathlib huggingface dataset:
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · 

Proof state:
case mk.refine'_1
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 : ι
x : R[M]
⊢ ∀ (hx : 0 ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := 0, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := 0, property := hx }

Next tactic:
intro hx
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    

Proof state:
case mk.refine'_1
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 : ι
x : R[M]
hx : 0 ∈ gradeBy R (⇑f) i
⊢ (decomposeAux f) ↑{ val := 0, property := hx } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := 0, property := hx }

Next tactic:
symm
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    

Proof state:
case mk.refine'_1
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 : ι
x : R[M]
hx : 0 ∈ gradeBy R (⇑f) i
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := 0, property := hx } =
    (decomposeAux f) ↑{ val := 0, property := hx }

Next tactic:
exact AddMonoidHom.map_zero _
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · 

Proof state:
case mk.refine'_2
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 : ι
x : R[M]
⊢ ∀ (a : M) (b : R) (f_1 : M →₀ R),
    a ∉ f_1.support →
      b ≠ 0 →
        (∀ (hx : f_1 ∈ gradeBy R (⇑f) i),
            (decomposeAux f) ↑{ val := f_1, property := hx } =
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := f_1, property := hx }) →
          ∀ (hx : (fun₀ | a => b) + f_1 ∈ gradeBy R (⇑f) i),
            (decomposeAux f) ↑{ val := (fun₀ | a => b) + f_1, property := hx } =
              (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | a => b) + f_1, property := hx }

Next tactic:
intro m b y hmy hb ih hmby
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    

Proof state:
case mk.refine'_2
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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := 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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
⊢ Disjoint (fun₀ | m => b).support y.support

Next tactic:
simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    

Proof state:
case mk.refine'_2
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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
this : Disjoint (fun₀ | m => b).support y.support
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    

Proof state:
case mk.refine'_2
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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby✝ : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
hmby : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {i} ∧ ↑y.support ⊆ ⇑f ⁻¹' {i}
this : Disjoint (fun₀ | m => b).support y.support
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby✝ } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | m => b) + y, property := hmby✝ }

Next tactic:
cases' hmby with h1 h2
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    

Proof state:
case mk.refine'_2.intro
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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
this : Disjoint (fun₀ | m => b).support y.support
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {i}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {i}
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := 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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
this : Disjoint (fun₀ | m => b).support y.support
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {i}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {i}
⊢ f m = i

Next tactic:
rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    

Proof state:
case mk.refine'_2.intro
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 : ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) i),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) i
this✝ : Disjoint (fun₀ | m => b).support y.support
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {i}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {i}
this : f m = i
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
subst this
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    

Proof state:
case mk.refine'_2.intro
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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
⊢ (decomposeAux f) ↑{ val := (fun₀ | m => b) + y, property := hmby } =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
    

Proof state:
case mk.refine'_2.intro
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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m))
        { val := fun₀ | m => b, property := (_ : (fun₀ | m => b) ∈ gradeBy R (⇑f) (f m)) } +
      (decomposeAux f) y =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
let ih' := ih h2
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
    let ih' := ih h2
    

Proof state:
case mk.refine'_2.intro
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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
ih' : (decomposeAux f) ↑{ val := y, property := h2 } =
  (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := h2 } :=
  ih h2
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m))
        { val := fun₀ | m => b, property := (_ : (fun₀ | m => b) ∈ gradeBy R (⇑f) (f m)) } +
      (decomposeAux f) y =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
dsimp at ih'
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
    let ih' := ih h2
    dsimp at ih'
    

Proof state:
case mk.refine'_2.intro
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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
ih' : (decomposeAux f) y = (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := h2 } := ih h2
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m))
        { val := fun₀ | m => b, property := (_ : (fun₀ | m => b) ∈ gradeBy R (⇑f) (f m)) } +
      (decomposeAux f) y =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
rw [ih', ← AddMonoidHom.map_add]
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
    let ih' := ih h2
    dsimp at ih'
    rw [ih', ← AddMonoidHom.map_add]
    

Proof state:
case mk.refine'_2.intro
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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
ih' : (decomposeAux f) y = (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := h2 } := ih h2
⊢ (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m))
      ({ val := fun₀ | m => b, property := (_ : (fun₀ | m => b) ∈ gradeBy R (⇑f) (f m)) } +
        { val := y, property := h2 }) =
    (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
apply DirectSum.of_eq_of_gradedMonoid_eq
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
    decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
  obtain ⟨x, hx⟩ := x
  revert hx
  refine' Finsupp.induction x _ _
  · intro hx
    symm
    exact AddMonoidHom.map_zero _
  · intro m b y hmy hb ih hmby
    have : Disjoint (Finsupp.single m b).support y.support := by
      simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
    rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
      at hmby
    cases' hmby with h1 h2
    have : f m = i := by
      rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
        at h1
    subst this
    simp only [AlgHom.map_add, Submodule.coe_mk, decomposeAux_single f m]
    let ih' := ih h2
    dsimp at ih'
    rw [ih', ← AddMonoidHom.map_add]
    apply DirectSum.of_eq_of_gradedMonoid_eq
    

Proof state:
case mk.refine'_2.intro.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 →+ ι
x : R[M]
m : M
b : R
y : M →₀ R
hmy : m ∉ y.support
hb : b ≠ 0
this : Disjoint (fun₀ | m => b).support y.support
ih :
  ∀ (hx : y ∈ gradeBy R (⇑f) (f m)),
    (decomposeAux f) ↑{ val := y, property := hx } =
      (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := hx }
hmby : (fun₀ | m => b) + y ∈ gradeBy R (⇑f) (f m)
h1 : ↑(fun₀ | m => b).support ⊆ ⇑f ⁻¹' {f m}
h2 : ↑y.support ⊆ ⇑f ⁻¹' {f m}
ih' : (decomposeAux f) y = (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) (f m)) { val := y, property := h2 } := ih h2
⊢ GradedMonoid.mk (f m)
      ({ val := fun₀ | m => b, property := (_ : (fun₀ | m => b) ∈ gradeBy R (⇑f) (f m)) } +
        { val := y, property := h2 }) =
    GradedMonoid.mk (f m) { val := (fun₀ | m => b) + y, property := hmby }

Next tactic:
congr 2
instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) :=
  GradedAlgebra.ofAlgHom _ (decomposeAux f)
    (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 →+ ι
⊢ AlgHom.comp (coeAlgHom (gradeBy R ⇑f)) (decomposeAux f) = AlgHom.id R R[M]

Next tactic:
ext : 2
instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) :=
  GradedAlgebra.ofAlgHom _ (decomposeAux f)
    (by
      ext : 2
      

Proof state:
case h.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 →+ ι
x✝ : Multiplicative M
⊢ (MonoidHom.comp (↑(AlgHom.comp (coeAlgHom (gradeBy R ⇑f)) (decomposeAux f))) (of R M)) x✝ =
    (MonoidHom.comp (↑(AlgHom.id R R[M])) (of R M)) x✝

Next tactic:
simp only [MonoidHom.coe_comp, MonoidHom.coe_coe, AlgHom.coe_comp, Function.comp_apply,
        of_apply, AlgHom.coe_id, id_eq]