Theorem: isNoetherian_of_fg_of_noetherian
File: Mathlib/RingTheory/Noetherian.lean

tactic: let ⟨s, hs⟩ := hN
state_before: R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
⊢ IsNoetherian R { x // x ∈ N }

tactic: haveI := Classical.decEq M
state_before: R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
⊢ IsNoetherian R { x // x ∈ N }

tactic: haveI := Classical.decEq R
state_before: R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this : DecidableEq M
⊢ IsNoetherian R { x // x ∈ N }

tactic: have : ∀ x ∈ s, x ∈ N := fun x hx => hs ▸ Submodule.subset_span hx
state_before: R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝ : DecidableEq M
this : DecidableEq R
⊢ IsNoetherian R { x // x ∈ N }

tactic: refine
  @isNoetherian_of_surjective
    R ((↑s : Set M) → R) N _ _ _ (Pi.module _ _ _) _ ?_ ?_ isNoetherian_pi
state_before: R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ IsNoetherian R { x // x ∈ N }

tactic: fapply LinearMap.mk
state_before: case refine_1
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ (↑↑s → R) →ₗ[R] { x // x ∈ N }

tactic: fapply AddHom.mk
state_before: case refine_1.toAddHom
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ AddHom (↑↑s → R) { x // x ∈ N }

tactic: exact fun f => ⟨∑ i in s.attach, f i • i.1, N.sum_mem fun c _ => N.smul_mem _ <| this _ c.2⟩
state_before: case refine_1.toAddHom.toFun
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ (↑↑s → R) → { x // x ∈ N }

tactic: intro f g
state_before: case refine_1.toAddHom.map_add'
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ ∀ (x y : ↑↑s → R),
    { val := ∑ i in Finset.attach s, (x + y) i • ↑i, property := (_ : ∑ i in Finset.attach s, (x + y) i • ↑i ∈ N) } =
      { val := ∑ i in Finset.attach s, x i • ↑i, property := (_ : ∑ i in Finset.attach s, x i • ↑i ∈ N) } +
        { val := ∑ i in Finset.attach s, y i • ↑i, property := (_ : ∑ i in Finset.attach s, y i • ↑i ∈ N) }

tactic: apply Subtype.eq
state_before: case refine_1.toAddHom.map_add'
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
f g : ↑↑s → R
⊢ { val := ∑ i in Finset.attach s, (f + g) i • ↑i, property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
    { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
      { val := ∑ i in Finset.attach s, g i • ↑i, property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }

tactic: change (∑ i in s.attach, (f i + g i) • _) = _
state_before: case refine_1.toAddHom.map_add'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
f g : ↑↑s → R
⊢ ↑{ val := ∑ i in Finset.attach s, (f + g) i • ↑i, property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
    ↑({ val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
        { val := ∑ i in Finset.attach s, g i • ↑i, property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) })

tactic: simp only [add_smul, Finset.sum_add_distrib]
state_before: case refine_1.toAddHom.map_add'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
f g : ↑↑s → R
⊢ ∑ i in Finset.attach s, (f i + g i) • ↑i =
    ↑({ val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
        { val := ∑ i in Finset.attach s, g i • ↑i, property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) })

tactic: rfl
state_before: case refine_1.toAddHom.map_add'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
f g : ↑↑s → R
⊢ ∑ x in Finset.attach s, f x • ↑x + ∑ x in Finset.attach s, g x • ↑x =
    ↑({ val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
        { val := ∑ i in Finset.attach s, g i • ↑i, property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) })

tactic: intro c f
state_before: case refine_1.map_smul'
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ ∀ (r : R) (x : ↑↑s → R),
    AddHom.toFun
        {
          toFun := fun f =>
            { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
          map_add' :=
            (_ :
              ∀ (f g : ↑↑s → R),
                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                    { val := ∑ i in Finset.attach s, g i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
        (r • x) =
      ↑(RingHom.id R) r •
        AddHom.toFun
          {
            toFun := fun f =>
              { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
            map_add' :=
              (_ :
                ∀ (f g : ↑↑s → R),
                  { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                    { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                      { val := ∑ i in Finset.attach s, g i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
          x

tactic: apply Subtype.eq
state_before: case refine_1.map_smul'
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
c : R
f : ↑↑s → R
⊢ AddHom.toFun
      {
        toFun := fun f =>
          { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
        map_add' :=
          (_ :
            ∀ (f g : ↑↑s → R),
              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                  { val := ∑ i in Finset.attach s, g i • ↑i, property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
      (c • f) =
    ↑(RingHom.id R) c •
      AddHom.toFun
        {
          toFun := fun f =>
            { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
          map_add' :=
            (_ :
              ∀ (f g : ↑↑s → R),
                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                    { val := ∑ i in Finset.attach s, g i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
        f

tactic: change (∑ i in s.attach, (c • f i) • _) = _
state_before: case refine_1.map_smul'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
c : R
f : ↑↑s → R
⊢ ↑(AddHom.toFun
        {
          toFun := fun f =>
            { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
          map_add' :=
            (_ :
              ∀ (f g : ↑↑s → R),
                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                    { val := ∑ i in Finset.attach s, g i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
        (c • f)) =
    ↑(↑(RingHom.id R) c •
        AddHom.toFun
          {
            toFun := fun f =>
              { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
            map_add' :=
              (_ :
                ∀ (f g : ↑↑s → R),
                  { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                    { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                      { val := ∑ i in Finset.attach s, g i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
          f)

tactic: simp only [smul_eq_mul, mul_smul]
state_before: case refine_1.map_smul'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
c : R
f : ↑↑s → R
⊢ ∑ i in Finset.attach s, (c • f i) • ↑i =
    ↑(↑(RingHom.id R) c •
        AddHom.toFun
          {
            toFun := fun f =>
              { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
            map_add' :=
              (_ :
                ∀ (f g : ↑↑s → R),
                  { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                    { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                      { val := ∑ i in Finset.attach s, g i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
          f)

tactic: exact Finset.smul_sum.symm
state_before: case refine_1.map_smul'.a
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
c : R
f : ↑↑s → R
⊢ ∑ x in Finset.attach s, c • f x • ↑x =
    ↑(↑(RingHom.id R) c •
        { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) })

tactic: rw [LinearMap.range_eq_top]
state_before: case refine_2
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ LinearMap.range
      {
        toAddHom :=
          {
            toFun := fun f =>
              { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
            map_add' :=
              (_ :
                ∀ (f g : ↑↑s → R),
                  { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                    { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                      { val := ∑ i in Finset.attach s, g i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
        map_smul' :=
          (_ :
            ∀ (c : R) (f : ↑↑s → R),
              AddHom.toFun
                  {
                    toFun := fun f =>
                      { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                    map_add' :=
                      (_ :
                        ∀ (f g : ↑↑s → R),
                          { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                              { val := ∑ i in Finset.attach s, g i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                  (c • f) =
                ↑(RingHom.id R) c •
                  AddHom.toFun
                    {
                      toFun := fun f =>
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                      map_add' :=
                        (_ :
                          ∀ (f g : ↑↑s → R),
                            { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                              { val := ∑ i in Finset.attach s, f i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                { val := ∑ i in Finset.attach s, g i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                    f) } =
    ⊤

tactic: rintro ⟨n, hn⟩
state_before: case refine_2
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
⊢ Surjective
    ↑{
        toAddHom :=
          {
            toFun := fun f =>
              { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
            map_add' :=
              (_ :
                ∀ (f g : ↑↑s → R),
                  { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                      property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                    { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                      { val := ∑ i in Finset.attach s, g i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
        map_smul' :=
          (_ :
            ∀ (c : R) (f : ↑↑s → R),
              AddHom.toFun
                  {
                    toFun := fun f =>
                      { val := ∑ i in Finset.attach s, f i • ↑i,
                        property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                    map_add' :=
                      (_ :
                        ∀ (f g : ↑↑s → R),
                          { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                              { val := ∑ i in Finset.attach s, g i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                  (c • f) =
                ↑(RingHom.id R) c •
                  AddHom.toFun
                    {
                      toFun := fun f =>
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                      map_add' :=
                        (_ :
                          ∀ (f g : ↑↑s → R),
                            { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                              { val := ∑ i in Finset.attach s, f i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                { val := ∑ i in Finset.attach s, g i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                    f) }

tactic: change n ∈ N at hn
state_before: case refine_2.mk
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
⊢ ∃ a,
    ↑{
            toAddHom :=
              {
                toFun := fun f =>
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                map_add' :=
                  (_ :
                    ∀ (f g : ↑↑s → R),
                      { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                          { val := ∑ i in Finset.attach s, g i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
            map_smul' :=
              (_ :
                ∀ (c : R) (f : ↑↑s → R),
                  AddHom.toFun
                      {
                        toFun := fun f =>
                          { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                        map_add' :=
                          (_ :
                            ∀ (f g : ↑↑s → R),
                              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                { val := ∑ i in Finset.attach s, f i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                  { val := ∑ i in Finset.attach s, g i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                      (c • f) =
                    ↑(RingHom.id R) c •
                      AddHom.toFun
                        {
                          toFun := fun f =>
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                          map_add' :=
                            (_ :
                              ∀ (f g : ↑↑s → R),
                                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                  { val := ∑ i in Finset.attach s, f i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                    { val := ∑ i in Finset.attach s, g i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                        f) }
        a =
      { val := n, property := hn }

tactic: rw [← hs, ← Set.image_id (s : Set M), Finsupp.mem_span_image_iff_total] at hn
state_before: case refine_2.mk
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
⊢ ∃ a,
    ↑{
            toAddHom :=
              {
                toFun := fun f =>
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                map_add' :=
                  (_ :
                    ∀ (f g : ↑↑s → R),
                      { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                          { val := ∑ i in Finset.attach s, g i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
            map_smul' :=
              (_ :
                ∀ (c : R) (f : ↑↑s → R),
                  AddHom.toFun
                      {
                        toFun := fun f =>
                          { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                        map_add' :=
                          (_ :
                            ∀ (f g : ↑↑s → R),
                              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                { val := ∑ i in Finset.attach s, f i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                  { val := ∑ i in Finset.attach s, g i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                      (c • f) =
                    ↑(RingHom.id R) c •
                      AddHom.toFun
                        {
                          toFun := fun f =>
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                          map_add' :=
                            (_ :
                              ∀ (f g : ↑↑s → R),
                                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                  { val := ∑ i in Finset.attach s, f i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                    { val := ∑ i in Finset.attach s, g i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                        f) }
        a =
      { val := n, property := hn }

tactic: rcases hn with ⟨l, hl1, hl2⟩
state_before: case refine_2.mk
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn✝ : n ∈ N
hn : ∃ l, l ∈ Finsupp.supported R R ↑s ∧ ↑(Finsupp.total M M R id) l = n
⊢ ∃ a,
    ↑{
            toAddHom :=
              {
                toFun := fun f =>
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                map_add' :=
                  (_ :
                    ∀ (f g : ↑↑s → R),
                      { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                          { val := ∑ i in Finset.attach s, g i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
            map_smul' :=
              (_ :
                ∀ (c : R) (f : ↑↑s → R),
                  AddHom.toFun
                      {
                        toFun := fun f =>
                          { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                        map_add' :=
                          (_ :
                            ∀ (f g : ↑↑s → R),
                              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                { val := ∑ i in Finset.attach s, f i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                  { val := ∑ i in Finset.attach s, g i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                      (c • f) =
                    ↑(RingHom.id R) c •
                      AddHom.toFun
                        {
                          toFun := fun f =>
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                          map_add' :=
                            (_ :
                              ∀ (f g : ↑↑s → R),
                                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                  { val := ∑ i in Finset.attach s, f i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                    { val := ∑ i in Finset.attach s, g i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                        f) }
        a =
      { val := n, property := hn✝ }

tactic: refine' ⟨fun x => l x, Subtype.ext _⟩
state_before: case refine_2.mk.intro.intro
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
l : M →₀ R
hl1 : l ∈ Finsupp.supported R R ↑s
hl2 : ↑(Finsupp.total M M R id) l = n
⊢ ∃ a,
    ↑{
            toAddHom :=
              {
                toFun := fun f =>
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                map_add' :=
                  (_ :
                    ∀ (f g : ↑↑s → R),
                      { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                          { val := ∑ i in Finset.attach s, g i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
            map_smul' :=
              (_ :
                ∀ (c : R) (f : ↑↑s → R),
                  AddHom.toFun
                      {
                        toFun := fun f =>
                          { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                        map_add' :=
                          (_ :
                            ∀ (f g : ↑↑s → R),
                              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                { val := ∑ i in Finset.attach s, f i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                  { val := ∑ i in Finset.attach s, g i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                      (c • f) =
                    ↑(RingHom.id R) c •
                      AddHom.toFun
                        {
                          toFun := fun f =>
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                          map_add' :=
                            (_ :
                              ∀ (f g : ↑↑s → R),
                                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                  { val := ∑ i in Finset.attach s, f i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                    { val := ∑ i in Finset.attach s, g i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                        f) }
        a =
      { val := n, property := hn }

tactic: change (∑ i in s.attach, l i • (i : M)) = n
state_before: case refine_2.mk.intro.intro
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
l : M →₀ R
hl1 : l ∈ Finsupp.supported R R ↑s
hl2 : ↑(Finsupp.total M M R id) l = n
⊢ ↑(↑{
            toAddHom :=
              {
                toFun := fun f =>
                  { val := ∑ i in Finset.attach s, f i • ↑i, property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                map_add' :=
                  (_ :
                    ∀ (f g : ↑↑s → R),
                      { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                          property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                        { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                          { val := ∑ i in Finset.attach s, g i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) },
            map_smul' :=
              (_ :
                ∀ (c : R) (f : ↑↑s → R),
                  AddHom.toFun
                      {
                        toFun := fun f =>
                          { val := ∑ i in Finset.attach s, f i • ↑i,
                            property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                        map_add' :=
                          (_ :
                            ∀ (f g : ↑↑s → R),
                              { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                  property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                { val := ∑ i in Finset.attach s, f i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                  { val := ∑ i in Finset.attach s, g i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                      (c • f) =
                    ↑(RingHom.id R) c •
                      AddHom.toFun
                        {
                          toFun := fun f =>
                            { val := ∑ i in Finset.attach s, f i • ↑i,
                              property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) },
                          map_add' :=
                            (_ :
                              ∀ (f g : ↑↑s → R),
                                { val := ∑ i in Finset.attach s, (f + g) i • ↑i,
                                    property := (_ : ∑ i in Finset.attach s, (f + g) i • ↑i ∈ N) } =
                                  { val := ∑ i in Finset.attach s, f i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, f i • ↑i ∈ N) } +
                                    { val := ∑ i in Finset.attach s, g i • ↑i,
                                      property := (_ : ∑ i in Finset.attach s, g i • ↑i ∈ N) }) }
                        f) }
        fun x => ↑l ↑x) =
    ↑{ val := n, property := hn }

tactic: rw [@Finset.sum_attach M M s _ fun i => l i • i, ← hl2,
  Finsupp.total_apply, Finsupp.sum, eq_comm]
state_before: case refine_2.mk.intro.intro
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
l : M →₀ R
hl1 : l ∈ Finsupp.supported R R ↑s
hl2 : ↑(Finsupp.total M M R id) l = n
⊢ ∑ i in Finset.attach s, ↑l ↑i • ↑i = n

tactic: refine' Finset.sum_subset hl1 fun x _ hx => _
state_before: case refine_2.mk.intro.intro
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
l : M →₀ R
hl1 : l ∈ Finsupp.supported R R ↑s
hl2 : ↑(Finsupp.total M M R id) l = n
⊢ ∑ a in l.support, ↑l a • id a = ∑ x in s, ↑l x • x

tactic: rw [Finsupp.not_mem_support_iff.1 hx, zero_smul]
state_before: case refine_2.mk.intro.intro
R : Type u_1
M : Type u_2
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
N : Submodule R M
I : IsNoetherianRing R
hN : FG N
s : Finset M
hs : span R ↑s = N
this✝¹ : DecidableEq M
this✝ : DecidableEq R
this : ∀ (x : M), x ∈ s → x ∈ N
n : M
hn : n ∈ N
l : M →₀ R
hl1 : l ∈ Finsupp.supported R R ↑s
hl2 : ↑(Finsupp.total M M R id) l = n
x : M
x✝ : x ∈ s
hx : ¬x ∈ l.support
⊢ ↑l x • id x = 0