-- Module: Mathlib.RingTheory.GradedAlgebra.HomogeneousLocalization
Goal:
ι : Type u_1
A : Type u_2
σ : Type u_3
inst : CommRing A
inst_1 : SetLike σ A
inst_2 : AddSubgroupClass σ A
inst_3 : AddCommMonoid ι
inst_4 : DecidableEq ι
𝒜 : ι → σ
inst_5 : GradedRing 𝒜
f : A
d : ι
hf : f ∈ 𝒜 d
ι' : Type u_4
inst_6 : Fintype ι'
v : ι' → A
hx : Eq (α := Subalgebra (↥(𝒜 0)) A) (Algebra.adjoin (↥(𝒜 0)) (Set.range v)) ⊤
dv : ι' → ι
hxd : ∀ (i : ι'), v i ∈ 𝒜 (dv i)
HH : ¬Subsingleton (Away 𝒜 f)
n : ι
a : A
j : ℕ
hb' : (fun (x : ℕ) ↦ f ^ x) j ∈ 𝒜 n
hfj : ¬f ^ j = 0
this : Membership.mem (γ := Submodule (↥(𝒜 0)) A) (Submodule.span ↥(𝒜 0) (↑(Submonoid.closure (Set.range v)) : Set A)) a
neg :
  ∀ (a : A) (ha' : a ∈ (↑(Submonoid.closure (Set.range v)) : Set A)),
    Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
      (Submodule.span ↥(𝒜 0)
        {x : Away 𝒜 f |
          ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
      (mk
        { deg := n, num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) a : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
          den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })
neg₁ :
  Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
    (Submodule.span ↥(𝒜 0)
      {x : Away 𝒜 f |
        ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
    (mk
      { deg := n, num := ((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) 0 : (a : ι) → ↥(𝒜 a)) n,
        den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })
neg₂ :
  ∀ (s t : A)
    (hs :
      Membership.mem (γ := Submodule (↥(𝒜 0)) A) (Submodule.span ↥(𝒜 0) (↑(Submonoid.closure (Set.range v)) : Set A)) s)
    (ht :
      Membership.mem (γ := Submodule (↥(𝒜 0)) A) (Submodule.span ↥(𝒜 0) (↑(Submonoid.closure (Set.range v)) : Set A)) t)
    (hs' :
      Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
        (Submodule.span ↥(𝒜 0)
          {x : Away 𝒜 f |
            ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
        (mk
          { deg := n, num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) s : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
            den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ }))
    (ht' :
      Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
        (Submodule.span ↥(𝒜 0)
          {x : Away 𝒜 f |
            ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
        (mk
          { deg := n, num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) t : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
            den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })),
    Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
      (Submodule.span ↥(𝒜 0)
        {x : Away 𝒜 f |
          ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
      (mk
        { deg := n,
          num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) (s + t) : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
          den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })
neg₃ :
  ∀ (r : ↥(𝒜 0)) (x : A)
    (hx :
      Membership.mem (γ := Submodule (↥(𝒜 0)) A) (Submodule.span ↥(𝒜 0) (↑(Submonoid.closure (Set.range v)) : Set A)) x)
    (hx' :
      Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
        (Submodule.span ↥(𝒜 0)
          {x : Away 𝒜 f |
            ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
        (mk
          { deg := n, num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) x : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
            den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })),
    Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
      (Submodule.span ↥(𝒜 0)
        {x : Away 𝒜 f |
          ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
      (mk
        { deg := n,
          num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) (r • x) : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
          den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })
⊢ Membership.mem (γ := Submodule (↥(𝒜 0)) (Away 𝒜 f))
    (Submodule.span ↥(𝒜 0)
      {x : Away 𝒜 f |
        ∃ (a : ℕ) (ai : ι' → ℕ) (hai : ∑ i : ι', ai i • dv i = a • d), Away.mk 𝒜 hf a (∏ i : ι', v i ^ ai i) ⋯ = x})
    (mk
      { deg := n, num := (((decompose 𝒜 : (a : A) → ⨁ (i : ι), ↥(𝒜 i)) a : ⨁ (i : ι), ↥(𝒜 i)) : (a : ι) → ↥(𝒜 a)) n,
        den := Subtype.mk (p := fun (x : A) ↦ x ∈ 𝒜 n) (f ^ j) hb', den_mem := ⋯ })

Tactic:
induction this using Submodule.span_induction with
  | mem a ha' =>
    obtain ⟨ai, rfl⟩ := Submonoid.exists_of_mem_closure_range _ _ ha'
    clear ha'
    by_cases H : ∑ i, ai i • dv i = n
    · apply Submodule.subset_span
      refine ⟨j, ai, H.trans ?_, ?_⟩
      · exact DirectSum.degree_eq_of_mem_mem 𝒜 hb'
          (SetLike.pow_mem_graded j hf) hfj
      · ext
        simp only [val_mk, Away.val_mk]
        congr
        refine (DirectSum.decompose_of_mem_same _ ?_).symm
        exact H ▸ SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i
    · convert! zero_mem (Submodule.span (𝒜 0) _)
      ext
      have : (DirectSum.decompose 𝒜 (∏ i : ι', v i ^ ai i) n).1 = 0 := by
        refine DirectSum.decompose_of_mem_ne _ ?_ H
        exact SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i
      simp [this, Localization.mk_zero]
  | zero =>
    convert! zero_mem (Submodule.span (𝒜 0) _)
    ext; simp [Localization.mk_zero]
  | add s t hs ht hs' ht' =>
    convert! add_mem hs' ht'
    ext; simp [← Localization.add_mk_self]
  | smul r x hx hx' =>
    convert! Submodule.smul_mem _ r hx'
    ext
    simp [Algebra.smul_def, algebraMap_eq, fromZeroRingHom, Localization.mk_mul,
      -decompose_mul, coe_decompose_mul_of_left_mem_zero 𝒜 r.2]

Premises used: DirectSum.decompose_of_mem_same, DirectSum.degree_eq_of_mem_mem, Membership.mem, Subtype, HomogeneousLocalization.fromZeroRingHom, HomogeneousLocalization.algebraMap_eq, HomogeneousLocalization.Away.val_mk, SetLike.pow_mem_graded, Submodule.span, Localization.mk_mul, Algebra.smul_def, DirectSum.decompose_mul, SetLike.smul, ZeroMemClass.zero_mem, Submodule.subset_span, OfNat.ofNat, Eq.symm, Localization.mk_zero, rfl, Localization.add_mk_self