Skip to content

Commit 344975b

Browse files
committed
chore: tidy results around Module.Finite (leanprover-community#33614)
In particular this replaces many chains of `Module.finite_def` and `Submodule.fg_top` with `Module.Finite.iff_fg`, or aliases for the forward and reverse implications. This also golfs some `FiniteDimensional` results in terms of their `Finite` counterparts, and adds `Submodule.fg_range` as a shorthand for a common case of `Submodule.fg_map`.
1 parent 8ea945b commit 344975b

24 files changed

Lines changed: 92 additions & 83 deletions

File tree

Mathlib/Algebra/Module/FinitePresentation.lean

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ lemma Module.finitePresentation_of_projective [Projective R M] [Module.Finite R
154154
FinitePresentation R M :=
155155
have ⟨_n, _f, _g, surj, _, hfg⟩ := Finite.exists_comp_eq_id_of_projective R M
156156
Module.finitePresentation_of_free_of_surjective _ surj
157-
(Finite.iff_fg.mp <| LinearMap.ker_eq_range_of_comp_eq_id hfg ▸ inferInstance)
157+
(LinearMap.ker_eq_range_of_comp_eq_id hfg ▸ .of_finite)
158158

159159
variable {ι} [Finite ι]
160160

@@ -215,15 +215,14 @@ lemma Module.finitePresentation_of_ker [Module.FinitePresentation R N]
215215
obtain ⟨s, hs⟩ : (⊤ : Submodule R M).FG := by
216216
apply Submodule.fg_of_fg_map_of_fg_inf_ker l
217217
· rw [Submodule.map_top, LinearMap.range_eq_top.mpr hl]; exact Module.Finite.fg_top
218-
· rw [top_inf_eq, ← Submodule.fg_top]; exact Module.Finite.fg_top
218+
· rw [top_inf_eq, ← Module.Finite.iff_fg]; infer_instance
219219
refine ⟨s, hs, ?_⟩
220220
let π := Finsupp.linearCombination R ((↑) : s → M)
221221
have H : Function.Surjective π :=
222222
LinearMap.range_eq_top.mp
223223
(by rw [range_linearCombination, Subtype.range_val, ← hs])
224-
have inst : Module.Finite R (LinearMap.ker (l ∘ₗ π)) := by
225-
constructor
226-
rw [Submodule.fg_top]; exact Module.FinitePresentation.fg_ker _ (hl.comp H)
224+
have inst : Module.Finite R (LinearMap.ker (l ∘ₗ π)) :=
225+
.of_fg <| Module.FinitePresentation.fg_ker _ (hl.comp H)
227226
let f : LinearMap.ker (l ∘ₗ π) →ₗ[R] LinearMap.ker l := LinearMap.restrict π (fun x ↦ id)
228227
have e : π ∘ₗ Submodule.subtype _ = Submodule.subtype _ ∘ₗ f := by ext; rfl
229228
have hf : Function.Surjective f := by
@@ -255,8 +254,8 @@ lemma Module.finitePresentation_of_split_exact
255254
refine Module.finitePresentation_of_surjective (LinearMap.fst _ _ _ ∘ₗ e.toLinearMap)
256255
(Prod.fst_surjective.comp e.surjective) ?_
257256
rw [LinearMap.ker_comp, Submodule.comap_equiv_eq_map_symm,
258-
LinearMap.exact_iff.mp Function.Exact.inr_fst, ← Submodule.map_top]
259-
exact .map _ (.map _ (Module.Finite.fg_top))
257+
LinearMap.exact_iff.mp Function.Exact.inr_fst, ← LinearMap.range_comp]
258+
exact Submodule.fg_range _
260259

261260
/-- Given an exact sequence `0 → M → N → P → 0`
262261
with `N` finitely presented and `P` projective, then `M` is also finitely presented. -/
@@ -323,9 +322,8 @@ lemma Module.FinitePresentation.trans (S : Type*) [CommRing S] [Algebra R S]
323322
· obtain ⟨a, ha⟩ := K.mkQ_surjective (e m)
324323
exact ⟨a, by simp [f, ha]⟩
325324
· have : Module.Finite S
326-
(Submodule.restrictScalars R (LinearMap.ker (e.symm.toLinearMap ∘ₗ K.mkQ))) := by
327-
change Module.Finite S (LinearMap.ker (e.symm.toLinearMap ∘ₗ K.mkQ))
328-
simpa [Finite.iff_fg]
325+
(Submodule.restrictScalars R (LinearMap.ker (e.symm.toLinearMap ∘ₗ K.mkQ))) :=
326+
.of_fg <| show (LinearMap.ker (e.symm.toLinearMap ∘ₗ K.mkQ)).FG by simpa
329327
simp only [f, LinearMap.ker_restrictScalars, ← Module.Finite.iff_fg]
330328
exact Module.Finite.trans S _
331329

@@ -340,11 +338,10 @@ instance {A} [CommRing A] [Algebra R A] [Module.FinitePresentation R M] :
340338
have : Function.Exact ((LinearMap.ker f).subtype.baseChange A) (f.baseChange A) :=
341339
lTensor_exact A f.exact_subtype_ker_map hf
342340
rw [LinearMap.exact_iff] at this
343-
rw [this, ← Submodule.map_top]
344-
apply Submodule.FG.map
341+
rw [this]
345342
have : Module.Finite R (LinearMap.ker f) :=
346-
⟨(Submodule.fg_top _).mpr (Module.FinitePresentation.fg_ker f hf)
347-
exact Module.Finite.fg_top (R := A) (M := A ⊗[R] LinearMap.ker f)
343+
.of_fg (Module.FinitePresentation.fg_ker f hf)
344+
exact Submodule.fg_range _
348345

349346
open TensorProduct in
350347
lemma FinitePresentation.of_isBaseChange

Mathlib/Algebra/Module/ZLattice/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ theorem ZLattice.FG [hs : IsZLattice K L] : L.FG := by
486486
@[deprecated (since := "2025-08-11")] alias Zlattice.FG := ZLattice.FG
487487

488488
theorem ZLattice.module_finite [IsZLattice K L] : Module.Finite ℤ L :=
489-
Module.Finite.iff_fg.mpr (ZLattice.FG K L)
489+
.of_fg (ZLattice.FG K L)
490490

491491
instance instModuleFinite_of_discrete_submodule {E : Type*} [NormedAddCommGroup E]
492492
[NormedSpace ℝ E] [FiniteDimensional ℝ E] (L : Submodule ℤ E) [DiscreteTopology L] :

Mathlib/Analysis/Normed/Module/FiniteDimension.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,17 +390,16 @@ with norm at most `R` which is at distance at least `1` of all these points. -/
390390
theorem exists_norm_le_le_norm_sub_of_finset {c : 𝕜} (hc : 1 < ‖c‖) {R : ℝ} (hR : ‖c‖ < R)
391391
(h : ¬FiniteDimensional 𝕜 E) (s : Finset E) : ∃ x : E, ‖x‖ ≤ R ∧ ∀ y ∈ s, 1 ≤ ‖y - x‖ := by
392392
let F := Submodule.span 𝕜 (s : Set E)
393-
haveI : FiniteDimensional 𝕜 F :=
394-
Module.finite_def.2
395-
((Submodule.fg_top _).2 (Submodule.fg_def.2 ⟨s, Finset.finite_toSet _, rfl⟩))
393+
have hF : F.FG := ⟨s, rfl⟩
394+
haveI : FiniteDimensional 𝕜 F := .of_fg hF
396395
have Fclosed : IsClosed (F : Set E) := Submodule.closed_of_finiteDimensional _
397396
have : ∃ x, x ∉ F := by
398397
contrapose! h
399398
have : (⊤ : Submodule 𝕜 E) = F := by
400399
ext x
401400
simp [h]
402-
have : FiniteDimensional 𝕜 (⊤ : Submodule 𝕜 E) := by rwa [this]
403-
exact Module.finite_def.2 ((Submodule.fg_top _).1 (Module.finite_def.1 this))
401+
rw [← this] at hF
402+
exact .of_fg_top hF
404403
obtain ⟨x, xR, hx⟩ : ∃ x : E, ‖x‖ ≤ R ∧ ∀ y : E, y ∈ F → 1 ≤ ‖x - y‖ :=
405404
riesz_lemma_of_norm_lt hc hR Fclosed this
406405
have hx' : ∀ y : E, y ∈ F → 1 ≤ ‖y - x‖ := by

Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public import Mathlib.Algebra.Module.Projective
99
public import Mathlib.LinearAlgebra.Dimension.Finite
1010
public import Mathlib.LinearAlgebra.FiniteDimensional.Defs
1111
public import Mathlib.LinearAlgebra.Matrix.ToLin
12+
import Mathlib.RingTheory.Finiteness.Lattice
1213

1314
/-!
1415
# Finite-dimensional vector spaces
@@ -187,31 +188,23 @@ instance finiteDimensional_inf_right (S₁ S₂ : Submodule K V) [FiniteDimensio
187188
/-- The sup of two finite-dimensional submodules is
188189
finite-dimensional. -/
189190
instance finiteDimensional_sup (S₁ S₂ : Submodule K V) [h₁ : FiniteDimensional K S₁]
190-
[h₂ : FiniteDimensional K S₂] : FiniteDimensional K (S₁ ⊔ S₂ : Submodule K V) := by
191-
unfold FiniteDimensional at *
192-
rw [finite_def] at *
193-
exact (fg_top _).2 (((fg_top S₁).1 h₁).sup ((fg_top S₂).1 h₂))
191+
[h₂ : FiniteDimensional K S₂] : FiniteDimensional K (S₁ ⊔ S₂ : Submodule K V) :=
192+
finite_sup _ _
194193

195194
/-- The submodule generated by a finite supremum of finite-dimensional submodules is
196195
finite-dimensional.
197196
198197
Note that strictly this only needs `∀ i ∈ s, FiniteDimensional K (S i)`, but that doesn't
199198
work well with typeclass search. -/
200199
instance finiteDimensional_finset_sup {ι : Type*} (s : Finset ι) (S : ι → Submodule K V)
201-
[∀ i, FiniteDimensional K (S i)] : FiniteDimensional K (s.sup S : Submodule K V) := by
202-
refine
203-
@Finset.sup_induction _ _ _ _ s S (fun i => FiniteDimensional K ↑i) (finiteDimensional_bot K V)
204-
?_ fun i _ => by infer_instance
205-
intro S₁ hS₁ S₂ hS₂
206-
exact Submodule.finiteDimensional_sup S₁ S₂
200+
[∀ i, FiniteDimensional K (S i)] : FiniteDimensional K (s.sup S : Submodule K V) :=
201+
Submodule.finite_finset_sup _ _
207202

208203
/-- The submodule generated by a supremum of finite-dimensional submodules, indexed by a finite
209204
sort is finite-dimensional. -/
210205
instance finiteDimensional_iSup {ι : Sort*} [Finite ι] (S : ι → Submodule K V)
211-
[∀ i, FiniteDimensional K (S i)] : FiniteDimensional K ↑(⨆ i, S i) := by
212-
cases nonempty_fintype (PLift ι)
213-
rw [← iSup_plift_down, ← Finset.sup_univ_eq_iSup]
214-
exact Submodule.finiteDimensional_finset_sup _ _
206+
[∀ i, FiniteDimensional K (S i)] : FiniteDimensional K ↑(⨆ i, S i) :=
207+
Submodule.finite_iSup _
215208

216209
end DivisionRing
217210

Mathlib/LinearAlgebra/FiniteDimensional/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ variable [DivisionRing K] [AddCommGroup V] [Module K V]
237237

238238
/-- A submodule is finitely generated if and only if it is finite-dimensional -/
239239
theorem fg_iff_finiteDimensional (s : Submodule K V) : s.FG ↔ FiniteDimensional K s :=
240-
(fg_top s).symm.trans Module.finite_def.symm
240+
Module.Finite.iff_fg.symm
241241

242242
end DivisionRing
243243

Mathlib/RingTheory/Finiteness/Basic.lean

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ theorem FG.map {N : Submodule R M} (hs : N.FG) : (N.map f).FG :=
8787
let ⟨t, ht⟩ := fg_def.1 hs
8888
fg_def.2 ⟨f '' t, ht.1.image _, by rw [span_image, ht.2]⟩
8989

90+
/-- Maps from a finite module have a finite range. -/
91+
@[simp] lemma fg_range [Module.Finite R M] (f : M →ₛₗ[σ] P) : f.range.FG := by
92+
rw [LinearMap.range_eq_map]
93+
exact Module.Finite.fg_top.map f
94+
9095
theorem fg_of_fg_map_injective (hf : Function.Injective f) {N : Submodule R M}
9196
(hfn : (N.map f).FG) : N.FG :=
9297
let ⟨t, ht⟩ := hfn
@@ -97,6 +102,10 @@ theorem fg_of_fg_map_injective (hf : Function.Injective f) {N : Submodule R M}
97102
rw [← LinearMap.coe_range, ← span_le, ht, ← map_top]
98103
exact map_mono le_top⟩
99104

105+
theorem fg_map_iff (hf : Function.Injective f) {N : Submodule R M} :
106+
(N.map f).FG ↔ N.FG :=
107+
⟨(fg_of_fg_map_injective _ hf ·), (.map _)⟩
108+
100109
end
101110

102111
variable {P : Type*} [AddCommMonoid P] [Module R P]
@@ -108,10 +117,13 @@ theorem fg_of_fg_map {R M P : Type*} [Ring R] [AddCommGroup M] [Module R M] [Add
108117
(hfn : (N.map f).FG) : N.FG :=
109118
fg_of_fg_map_injective f (LinearMap.ker_eq_bot.1 hf) hfn
110119

111-
theorem fg_top (N : Submodule R M) : (⊤ : Submodule R N).FG ↔ N.FG :=
112-
fun h => N.range_subtype ▸ map_top N.subtype ▸ h.map _, fun h =>
113-
fg_of_fg_map_injective N.subtype Subtype.val_injective <| by rwa [map_top, range_subtype]⟩
120+
/-- The top submodule of another submodule `N` is FG iff `N` is `FG`.
121+
122+
See also `Module.Finite.fg_top`. -/
123+
protected theorem fg_top (N : Submodule R M) : (⊤ : Submodule R N).FG ↔ N.FG := by
124+
rw [← fg_map_iff N.subtype Subtype.val_injective, map_top, range_subtype]
114125

126+
/-- See also `Module.Finite.equiv_iff`. -/
115127
theorem fg_of_linearEquiv (e : M ≃ₗ[R] P) (h : (⊤ : Submodule R P).FG) : (⊤ : Submodule R M).FG :=
116128
e.symm.range ▸ map_top (e.symm : P →ₗ[R] M) ▸ h.map _
117129

@@ -294,28 +306,36 @@ instance [Module.Finite R M] : Module.Finite R Mᵐᵒᵖ := equiv (MulOpposite.
294306

295307
instance ulift [Module.Finite R M] : Module.Finite R (ULift M) := equiv ULift.moduleEquiv.symm
296308

309+
/-- A submodule is finite as a module iff it is finitely generated. -/
297310
theorem iff_fg {N : Submodule R M} : Module.Finite R N ↔ N.FG := Module.finite_def.trans N.fg_top
298311

312+
/-- A finitely-generated submodule is finite as a module. -/
313+
alias ⟨_, of_fg⟩ := iff_fg
314+
315+
/-- A submodule that is finite as a module is finitely generated. -/
316+
theorem _root_.Submodule.FG.of_finite {N : Submodule R M} [Module.Finite R N] : N.FG :=
317+
iff_fg.1 ‹_›
318+
299319
variable (R M)
300320

301-
instance bot : Module.Finite R (⊥ : Submodule R M) := iff_fg.mpr fg_bot
321+
instance bot : Module.Finite R (⊥ : Submodule R M) := .of_fg fg_bot
302322

303-
instance top [Module.Finite R M] : Module.Finite R (⊤ : Submodule R M) := iff_fg.mpr fg_top
323+
instance top [Module.Finite R M] : Module.Finite R (⊤ : Submodule R M) := .of_fg fg_top
304324

305325
variable {M}
306326

307327
/-- The submodule generated by a finite set is `R`-finite. -/
308328
theorem span_of_finite {A : Set M} (hA : Set.Finite A) :
309329
Module.Finite R (Submodule.span R A) :=
310-
⟨(Submodule.fg_top _).mpr ⟨hA.toFinset, hA.coe_toFinset.symm ▸ rfl
330+
.of_fg ⟨hA.toFinset, hA.coe_toFinset.symm ▸ rfl⟩
311331

312332
/-- The submodule generated by a single element is `R`-finite. -/
313333
instance span_singleton (x : M) : Module.Finite R (R ∙ x) :=
314334
Module.Finite.span_of_finite R <| Set.finite_singleton _
315335

316336
/-- The submodule generated by a finset is `R`-finite. -/
317337
instance span_finset (s : Finset M) : Module.Finite R (span R (s : Set M)) :=
318-
⟨(Submodule.fg_top _).mpr ⟨s, rfl
338+
.of_fg ⟨s, rfl⟩
319339

320340
variable {R}
321341

@@ -364,8 +384,8 @@ variable {R V} [Ring R] [AddCommGroup V] [Module R V]
364384
/-- The sup of two fg submodules is finite. Also see `Submodule.FG.sup`. -/
365385
instance finite_sup (S₁ S₂ : Submodule R V) [h₁ : Module.Finite R S₁]
366386
[h₂ : Module.Finite R S₂] : Module.Finite R (S₁ ⊔ S₂ : Submodule R V) := by
367-
rw [finite_def] at *
368-
exact (fg_top _).2 (((fg_top S₁).1 h₁).sup ((fg_top S₂).1 h₂))
387+
rw [Finite.iff_fg] at *
388+
exact .sup h₁ h₂
369389

370390
/-- The submodule generated by a finite supremum of finite-dimensional submodules is
371391
finite-dimensional.

Mathlib/RingTheory/Finiteness/Defs.lean

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,31 @@ variable (R A B M N : Type*)
118118

119119
/-- A module over a semiring is `Module.Finite` if it is finitely generated as a module. -/
120120
protected class Module.Finite [Semiring R] [AddCommMonoid M] [Module R M] : Prop where
121-
fg_top : (⊤ : Submodule R M).FG
121+
of_fg_top ::
122+
fg_top : (⊤ : Submodule R M).FG
122123

123124
attribute [inherit_doc Module.Finite] Module.Finite.fg_top
124125

125126
namespace Module
126127

127128
variable [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
128129

130+
/-- See also `Module.Finite.iff_fg` for a version when `M` is itself a submodule. -/
129131
theorem finite_def {R M} [Semiring R] [AddCommMonoid M] [Module R M] :
130132
Module.Finite R M ↔ (⊤ : Submodule R M).FG :=
131-
fun h => h.1, fun h => ⟨h⟩
133+
(·.fg_top), .of_fg_top
132134

133135
namespace Finite
134136

135137
open Submodule Set
136138

137139
theorem iff_addMonoid_fg {M : Type*} [AddCommMonoid M] : Module.Finite ℕ M ↔ AddMonoid.FG M :=
138-
fun h => AddMonoid.fg_def.2 <| (Submodule.fg_iff_addSubmonoid_fg ⊤).1 (finite_def.1 h), fun h =>
139-
finite_def.2 <| (Submodule.fg_iff_addSubmonoid_fg ⊤).2 (AddMonoid.fg_def.1 h)⟩
140+
fun h => AddMonoid.fg_def.2 <| (Submodule.fg_iff_addSubmonoid_fg ⊤).1 h.fg_top, fun h =>
141+
.of_fg_top <| (Submodule.fg_iff_addSubmonoid_fg ⊤).2 (AddMonoid.fg_def.1 h)⟩
140142

141143
theorem iff_addGroup_fg {G : Type*} [AddCommGroup G] : Module.Finite ℤ G ↔ AddGroup.FG G :=
142-
fun h => AddGroup.fg_def.2 <| (Submodule.fg_iff_addSubgroup_fg ⊤).1 (finite_def.1 h), fun h =>
143-
finite_def.2 <| (Submodule.fg_iff_addSubgroup_fg ⊤).2 (AddGroup.fg_def.1 h)⟩
144+
fun h => AddGroup.fg_def.2 <| (Submodule.fg_iff_addSubgroup_fg ⊤).1 h.fg_top, fun h =>
145+
.of_fg_top <| (Submodule.fg_iff_addSubgroup_fg ⊤).2 (AddGroup.fg_def.1 h)⟩
144146

145147
variable {R M N}
146148

Mathlib/RingTheory/Finiteness/Finsupp.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ theorem _root_.Module.Finite.of_submodule_quotient (N : Submodule R M) [Module.F
117117
[Module.Finite R (M ⧸ N)] : Module.Finite R M where
118118
fg_top := fg_of_fg_map_of_fg_inf_ker N.mkQ
119119
(by simpa only [map_top, range_mkQ] using Module.finite_def.mp ‹_›) <| by
120-
simpa only [top_inf_eq, ker_mkQ] using Module.Finite.iff_fg.mp ‹_›
120+
simpa only [top_inf_eq, ker_mkQ] using .of_finite
121121

122122
end Submodule
123123

Mathlib/RingTheory/Finiteness/NilpotentKer.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ lemma Module.finite_of_surjective_of_ker_le_nilradical
4747
· simpa [LinearMap.range_eq_top_of_surjective (φ.toLinearMap.restrictScalars R) hφ] using
4848
Module.Finite.fg_top
4949
· have : Module.Finite R ((S ⧸ I) ⊗[S] ↑(I ^ n)) := by
50-
have : Module.Finite S ↑(I ^ n) := Module.Finite.iff_fg.mpr (.pow hf₃ _)
50+
have : Module.Finite S ↑(I ^ n) := .of_fg (.pow hf₃ _)
5151
exact .trans (S ⧸ I) _
5252
let ψ : (S ⧸ I) ⊗[S] ↑(I ^ n) →ₗ[S] (S ⧸ I ^ (n + 1)) := by
5353
refine ?_ ∘ₗ (TensorProduct.quotTensorEquivQuotSMul _ I).toLinearMap

Mathlib/RingTheory/Flat/EquationalCriterion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ theorem exists_factorization_of_isFinitelyPresented [Flat R M] {P : Type*} [AddC
273273
[Module R P] [FinitePresentation R P] (h₁ : P →ₗ[R] M) :
274274
∃ (k : ℕ) (h₂ : P →ₗ[R] (Fin k →₀ R)) (h₃ : (Fin k →₀ R) →ₗ[R] M), h₁ = h₃ ∘ₗ h₂ := by
275275
have ⟨_, K, ϕ, hK⟩ := FinitePresentation.exists_fin R P
276-
haveI : Module.Finite R K := Module.Finite.iff_fg.mpr hK
276+
haveI : Module.Finite R K := .of_fg hK
277277
have : (h₁ ∘ₗ ϕ.symm ∘ₗ K.mkQ) ∘ₗ K.subtype = 0 := by
278278
simp_rw [comp_assoc, (LinearMap.exact_subtype_mkQ K).linearMap_comp_eq_zero, comp_zero]
279279
obtain ⟨k, a, y, hay, ha⟩ := exists_factorization_of_comp_eq_zero_of_free this

0 commit comments

Comments
 (0)