l3lab/ntp-mathlib huggingface dataset:
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    

Proof state:
case mp.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
⊢ (Finsupp.sum l fun a₁ b => (b • ↑a₁) (n + 1)) ∈ I • N F n

Next tactic:
apply Submodule.sum_mem _ _
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    

Proof state:
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
⊢ ∀ c ∈ l.support, (fun a₁ b => (b • ↑a₁) (n + 1)) c (l c) ∈ I • N F n

Next tactic:
rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
⊢ (fun a₁ b => (b • ↑a₁) (n + 1))
      { val := (single R n') m,
        property := (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }
      (l
        { val := (single R n') m,
          property := (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }) ∈
    I • N F n

Next tactic:
dsimp only [Subtype.coe_mk]
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
⊢ (l
          { val := (single R n') m,
            property :=
              (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) } •
        (single R n') m)
      (n + 1) ∈
    I • N F n

Next tactic:
rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by 

Proof state:
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
⊢ n' ≤ n + 1

Next tactic:
linarith
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
⊢ coeff
        (↑(l
            { val := (single R n') m,
              property :=
                (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }))
        (n + 1 - n') •
      m ∈
    I • N F n

Next tactic:
have e : n' ≤ n := by linarith
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by 

Proof state:
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
⊢ n' ≤ n

Next tactic:
linarith
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
e : n' ≤ n
⊢ coeff
        (↑(l
            { val := (single R n') m,
              property :=
                (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }))
        (n + 1 - n') •
      m ∈
    I • N F n

Next tactic:
have := F.pow_smul_le_pow_smul (n - n') n' 1
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    have := F.pow_smul_le_pow_smul (n - n') n' 1
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
e : n' ≤ n
this : I ^ (n - n' + 1) • N F n' ≤ I ^ 1 • N F (n - n' + n')
⊢ coeff
        (↑(l
            { val := (single R n') m,
              property :=
                (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }))
        (n + 1 - n') •
      m ∈
    I • N F n

Next tactic:
rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    have := F.pow_smul_le_pow_smul (n - n') n' 1
    rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
H :
  ∀ (i : ℕ),
    ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))
n : ℕ
hn : n ≥ n₀
x : M
hx : x ∈ N F (n + 1)
l : ↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)) →₀ ↥(reesAlgebra I)
hl :
  ((Finsupp.total (↑(⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))) (PolynomialModule R M) (↥(reesAlgebra I))
          Subtype.val)
        l)
      (n + 1) =
    x
n' : ℕ
hn' : n' ≤ n₀
m : M
hm : m ∈ ↑(N F n')
e : n' ≤ n
this : I ^ (n + 1 - n') • N F n' ≤ I • N F n
⊢ coeff
        (↑(l
            { val := (single R n') m,
              property :=
                (_ : ∃ t ∈ Set.range fun i => ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i), (single R n') m ∈ t) }))
        (n + 1 - n') •
      m ∈
    I • N F n

Next tactic:
exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    have := F.pow_smul_le_pow_smul (n - n') n' 1
    rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
    exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
  · 

Proof state:
case mpr
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F' : Filtration I M
h : Stable F
n₀ : ℕ
⊢ (∀ n ≥ n₀, I • N F n = N F (n + 1)) →
    ∀ (i : ℕ),
      ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))

Next tactic:
let F' := Submodule.span (reesAlgebra I) (⋃ i ≤ n₀, single R i '' (F.N i : Set M))
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    have := F.pow_smul_le_pow_smul (n - n') n' 1
    rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
    exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
  · let F' := Submodule.span (reesAlgebra I) (⋃ i ≤ n₀, single R i '' (F.N i : Set M))
    

Proof state:
case mpr
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F'✝ : Filtration I M
h : Stable F
n₀ : ℕ
F' : Submodule (↥(reesAlgebra I)) (PolynomialModule R M) :=
  Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))
⊢ (∀ n ≥ n₀, I • N F n = N F (n + 1)) →
    ∀ (i : ℕ),
      ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))

Next tactic:
intro hF i
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
    F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
      ∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
  rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
  swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
  constructor
  · intro H n hn
    refine' (F.smul_le n).antisymm _
    intro x hx
    obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp (H _ ⟨x, hx, rfl⟩)
    replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
    dsimp only at hl
    erw [Finsupp.single_eq_same] at hl
    rw [← hl, Finsupp.total_apply, Finsupp.sum_apply]
    apply Submodule.sum_mem _ _
    rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
    dsimp only [Subtype.coe_mk]
    rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by linarith)]
    have e : n' ≤ n := by linarith
    have := F.pow_smul_le_pow_smul (n - n') n' 1
    rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
    exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
  · let F' := Submodule.span (reesAlgebra I) (⋃ i ≤ n₀, single R i '' (F.N i : Set M))
    intro hF i
    

Proof state:
case mpr
R M : Type u
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
I : Ideal R
F F'✝ : Filtration I M
h : Stable F
n₀ : ℕ
F' : Submodule (↥(reesAlgebra I)) (PolynomialModule R M) :=
  Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i))
hF : ∀ n ≥ n₀, I • N F n = N F (n + 1)
i : ℕ
⊢ ⇑(single R i) '' ↑(N F i) ⊆ ↑(Submodule.span (↥(reesAlgebra I)) (⋃ i, ⋃ (_ : i ≤ n₀), ⇑(single R i) '' ↑(N F i)))

Next tactic:
have : ∀ i ≤ n₀, single R i '' (F.N i : Set M) ⊆ F' := by
      -- Porting note: Original proof was
      -- `fun i hi => Set.Subset.trans (Set.subset_iUnion₂ i hi) Submodule.subset_span`
      intro i hi
      refine Set.Subset.trans ?_ Submodule.subset_span
      refine @Set.subset_iUnion₂ _ _ _ (fun i => fun _ => ↑((single R i) '' ((N F i) : Set M))) i ?_
      exact hi