Skip to content

Commit 17855c7

Browse files
mbkybkyThmoas-Guan
andcommitted
refactor(Algebra/Module/Projective): generalize universes (#24697)
Generalize `(P : Type max u v)` to `(P : Type v) [Small.{v} R]` in [Module.Projective.of_lifting_property](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Module/Projective.html#Module.Projective.of_lifting_property) and [IsProjective.iff_projective](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Category/ModuleCat/Projective.html#IsProjective.iff_projective). Also generalize universes in [Module.Projective.iff_split](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Module/Projective.html#Module.Projective.iff_split). Co-authored-by: Yongle Hu <140475041+mbkybky@users.noreply.github.com> Co-authored-by: Thmoas-Guan <150537269+Thmoas-Guan@users.noreply.github.com>
1 parent 1b18b0c commit 17855c7

File tree

4 files changed

+82
-47
lines changed

4 files changed

+82
-47
lines changed

Mathlib/Algebra/Category/ModuleCat/Projective.lean

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Markus Himmel, Kim Morrison
55
-/
66
import Mathlib.Algebra.Category.ModuleCat.EpiMono
7-
import Mathlib.Algebra.Small.Group
87
import Mathlib.Algebra.Module.Projective
8+
import Mathlib.Algebra.Small.Group
99
import Mathlib.CategoryTheory.Preadditive.Projective.Basic
1010

1111
/-!
@@ -14,36 +14,40 @@ import Mathlib.CategoryTheory.Preadditive.Projective.Basic
1414

1515
universe v u w
1616

17-
open CategoryTheory LinearMap ModuleCat
17+
open CategoryTheory ModuleCat
18+
19+
variable {R : Type u} [Ring R] (P : ModuleCat.{v} R)
20+
21+
instance ModuleCat.projective_of_categoryTheory_projective [Module.Projective R P] :
22+
CategoryTheory.Projective P := by
23+
refine ⟨fun E X epi => ?_⟩
24+
obtain ⟨f, h⟩ := Module.projective_lifting_property X.hom E.hom
25+
((ModuleCat.epi_iff_surjective _).mp epi)
26+
exact ⟨ofHom f, hom_ext h⟩
27+
28+
instance ModuleCat.projective_of_module_projective [Small.{v} R] [Projective P] :
29+
Module.Projective R P := by
30+
refine Module.Projective.of_lifting_property ?_
31+
intro _ _ _ _ _ _ f g s
32+
have : Epi (↟f) := (ModuleCat.epi_iff_surjective (↟f)).mpr s
33+
exact ⟨(Projective.factorThru (↟g) (↟f)).hom,
34+
ModuleCat.hom_ext_iff.mp <| Projective.factorThru_comp (↟g) (↟f)⟩
1835

1936
/-- The categorical notion of projective object agrees with the explicit module-theoretic notion. -/
20-
theorem IsProjective.iff_projective {R : Type u} [Ring R] {P : Type max u v} [AddCommGroup P]
21-
[Module R P] : Module.Projective R P ↔ Projective (ModuleCat.of R P) := by
22-
refine ⟨fun h => ?_, fun h => ?_⟩
23-
· letI : Module.Projective R (ModuleCat.of R P) := h
24-
refine ⟨fun E X epi => ?_⟩
25-
obtain ⟨f, h⟩ := Module.projective_lifting_property X.hom E.hom
26-
((ModuleCat.epi_iff_surjective _).mp epi)
27-
exact ⟨ofHom f, hom_ext h⟩
28-
· refine Module.Projective.of_lifting_property.{u,v} ?_
29-
intro E X mE mX sE sX f g s
30-
haveI : Epi (↟f) := (ModuleCat.epi_iff_surjective (↟f)).mpr s
31-
letI : Projective (ModuleCat.of R P) := h
32-
exact ⟨(Projective.factorThru (↟g) (↟f)).hom,
33-
ModuleCat.hom_ext_iff.mp <| Projective.factorThru_comp (↟g) (↟f)⟩
37+
theorem IsProjective.iff_projective [Small.{v} R] (P : Type v) [AddCommGroup P] [Module R P] :
38+
Module.Projective R P ↔ Projective (of R P) :=
39+
fun _ => (of R P).projective_of_categoryTheory_projective,
40+
fun _ => (of R P).projective_of_module_projective⟩
3441

3542
namespace ModuleCat
3643

37-
variable {R : Type u} [Ring R] {M : ModuleCat.{v} R}
44+
variable {M : ModuleCat.{v} R}
3845

3946
-- We transport the corresponding result from `Module.Projective`.
4047
/-- Modules that have a basis are projective. -/
41-
theorem projective_of_free {ι : Type w} (b : Basis ι R M) : Projective M := by
42-
letI : Module.Projective R (ModuleCat.of R M) := Module.Projective.of_basis b
43-
refine ⟨fun E X epi => ?_⟩
44-
obtain ⟨f, h⟩ := Module.projective_lifting_property X.hom E.hom
45-
((ModuleCat.epi_iff_surjective _).mp epi)
46-
exact ⟨ofHom f, hom_ext h⟩
48+
theorem projective_of_free {ι : Type w} (b : Basis ι R M) : Projective M :=
49+
have : Module.Projective R M := Module.Projective.of_basis b
50+
M.projective_of_categoryTheory_projective
4751

4852
/-- The category of modules has enough projectives, since every module is a quotient of a free
4953
module. -/
@@ -54,7 +58,7 @@ instance enoughProjectives [Small.{v} R] : EnoughProjectives (ModuleCat.{v} R) w
5458
projective := projective_of_free e
5559
f := ofHom <| e.constr ℕ _root_.id
5660
epi := by
57-
rw [epi_iff_range_eq_top, range_eq_top]
61+
rw [epi_iff_range_eq_top, LinearMap.range_eq_top]
5862
refine fun m ↦ ⟨Finsupp.single m 1, ?_⟩
5963
simp [e, Basis.constr_apply] }⟩
6064

Mathlib/Algebra/Module/Equiv/Defs.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ theorem apply_symm_apply (c : M₂) : e (e.symm c) = c :=
343343
theorem symm_apply_apply (b : M) : e.symm (e b) = b :=
344344
e.left_inv b
345345

346+
@[simp]
347+
theorem comp_symm : e.toLinearMap ∘ₛₗ e.symm.toLinearMap = LinearMap.id :=
348+
LinearMap.ext e.apply_symm_apply
349+
350+
@[simp]
351+
theorem symm_comp : e.symm.toLinearMap ∘ₛₗ e.toLinearMap= LinearMap.id :=
352+
LinearMap.ext e.symm_apply_apply
353+
346354
@[simp]
347355
theorem trans_symm : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm = e₂₃.symm.trans e₁₂.symm :=
348356
rfl

Mathlib/Algebra/Module/Projective.lean

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ Copyright (c) 2021 Kevin Buzzard. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kevin Buzzard, Antoine Labelle
55
-/
6-
import Mathlib.Algebra.Module.Defs
7-
import Mathlib.LinearAlgebra.Finsupp.SumProd
8-
import Mathlib.LinearAlgebra.FreeModule.Basic
6+
import Mathlib.Algebra.Equiv.TransferInstance
97
import Mathlib.LinearAlgebra.TensorProduct.Basis
10-
import Mathlib.LinearAlgebra.TensorProduct.Tower
8+
import Mathlib.Logic.UnivLE
119

1210
/-!
1311
@@ -61,7 +59,7 @@ projective module
6159
6260
-/
6361

64-
universe u v
62+
universe w v u
6563

6664
open LinearMap hiding id
6765
open Finsupp
@@ -205,12 +203,26 @@ variable {R : Type u} [Semiring R] {P : Type v} [AddCommMonoid P] [Module R P]
205203
variable {R₀ M N} [CommSemiring R₀] [Algebra R₀ R] [AddCommMonoid M] [Module R₀ M] [Module R M]
206204
variable [IsScalarTower R₀ R M] [AddCommMonoid N] [Module R₀ N]
207205

206+
/-- A variant of `Projective.iff_split` allowing for a more flexible selection of the universe
207+
for the free module `M`. -/
208+
theorem Projective.iff_split' [Small.{w} R] [Small.{w} P] : Module.Projective R P ↔
209+
∃ (M : Type w) (_ : AddCommMonoid M) (_ : Module R M) (_ : Module.Free R M)
210+
(i : P →ₗ[R] M) (s : M →ₗ[R] P), s.comp i = LinearMap.id := by
211+
let e : (Shrink.{w, v} P →₀ Shrink.{w, u} R) ≃ₗ[R] P →₀ R :=
212+
Finsupp.mapDomain.linearEquiv _ R (equivShrink P).symm ≪≫ₗ
213+
Finsupp.mapRange.linearEquiv (Shrink.linearEquiv R R)
214+
refine ⟨fun ⟨i, hi⟩ ↦ ⟨(Shrink.{w} P) →₀ (Shrink.{w} R), _, _, Free.of_basis ⟨e⟩,
215+
e.symm.toLinearMap ∘ₗ i, (linearCombination R id) ∘ₗ e.toLinearMap, ?_⟩,
216+
fun ⟨_, _, _, _, i, s, H⟩ ↦ Projective.of_split i s H⟩
217+
apply LinearMap.ext
218+
simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply, e.apply_symm_apply]
219+
exact hi
220+
208221
/-- A module is projective iff it is the direct summand of a free module. -/
209222
theorem Projective.iff_split : Module.Projective R P ↔
210223
∃ (M : Type max u v) (_ : AddCommMonoid M) (_ : Module R M) (_ : Module.Free R M)
211224
(i : P →ₗ[R] M) (s : M →ₗ[R] P), s.comp i = LinearMap.id :=
212-
fun ⟨i, hi⟩ ↦ ⟨P →₀ R, _, _, inferInstance, i, Finsupp.linearCombination R id, LinearMap.ext hi⟩,
213-
fun ⟨_, _, _, _, i, s, H⟩ ↦ Projective.of_split i s H⟩
225+
Projective.iff_split'.{max u v}
214226

215227
open TensorProduct in
216228
instance Projective.tensorProduct [hM : Module.Projective R M] [hN : Module.Projective R₀ N] :
@@ -230,34 +242,36 @@ instance Projective.tensorProduct [hM : Module.Projective R M] [hN : Module.Proj
230242

231243
end Ring
232244

233-
--This is in a different section because special universe restrictions are required.
234245
section OfLiftingProperty
235246

236-
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: generalize to `P : Type v`?
237-
/-- A module which satisfies the universal property is projective. Note that the universe variables
238-
in `huniv` are somewhat restricted. -/
239-
theorem Projective.of_lifting_property' {R : Type u} [Semiring R] {P : Type max u v}
240-
[AddCommMonoid P] [Module R P]
247+
/-- A module which satisfies the universal property is projective. -/
248+
theorem Projective.of_lifting_property' {R : Type u} [Semiring R] {P : Type v}
249+
[AddCommMonoid P] [Module R P] [Small.{v} R]
241250
-- If for all surjections of `R`-modules `M →ₗ N`, all maps `P →ₗ N` lift to `P →ₗ M`,
242-
(huniv : ∀ {M : Type max v u} {N : Type max u v} [AddCommMonoid M] [AddCommMonoid N]
251+
(h : ∀ {M : Type v} {N : Type v} [AddCommMonoid M] [AddCommMonoid N]
243252
[Module R M] [Module R N] (f : M →ₗ[R] N) (g : P →ₗ[R] N),
244253
Function.Surjective f → ∃ h : P →ₗ[R] M, f.comp h = g) :
245254
-- then `P` is projective.
246-
Projective R P :=
247-
.of_lifting_property'' (huniv · _)
255+
Projective R P := by
256+
refine of_lifting_property'' (fun p hp ↦ ?_)
257+
let e := Finsupp.mapRange.linearEquiv (α := P) (Shrink.linearEquiv R R)
258+
rcases h (p ∘ₗ e.toLinearMap) LinearMap.id (hp.comp e.surjective) with ⟨g, hg⟩
259+
exact ⟨e.toLinearMap ∘ₗ g, hg⟩
248260

249-
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: generalize to `P : Type v`?
250261
/-- A variant of `of_lifting_property'` when we're working over a `[Ring R]`,
251-
which only requires quantifying over modules with an `AddCommGroup` instance. -/
252-
theorem Projective.of_lifting_property {R : Type u} [Ring R] {P : Type max u v} [AddCommGroup P]
253-
[Module R P]
262+
which only requires quantifying over modules with an `AddCommGroup` instance. -/
263+
theorem Projective.of_lifting_property {R : Type u} [Ring R] {P : Type v} [AddCommGroup P]
264+
[Module R P] [Small.{v} R]
254265
-- If for all surjections of `R`-modules `M →ₗ N`, all maps `P →ₗ N` lift to `P →ₗ M`,
255-
(huniv : ∀ {M : Type max v u} {N : Type max u v} [AddCommGroup M] [AddCommGroup N]
266+
(h : ∀ {M : Type v} {N : Type v} [AddCommGroup M] [AddCommGroup N]
256267
[Module R M] [Module R N] (f : M →ₗ[R] N) (g : P →ₗ[R] N),
257268
Function.Surjective f → ∃ h : P →ₗ[R] M, f.comp h = g) :
258269
-- then `P` is projective.
259-
Projective R P :=
260-
.of_lifting_property'' (huniv · _)
270+
Projective R P := by
271+
refine of_lifting_property'' (fun p hp ↦ ?_)
272+
let e := Finsupp.mapRange.linearEquiv (α := P) (Shrink.linearEquiv R R)
273+
rcases h (p ∘ₗ e.toLinearMap) LinearMap.id (hp.comp e.surjective) with ⟨g, hg⟩
274+
exact ⟨e.toLinearMap ∘ₗ g, hg⟩
261275

262276
end OfLiftingProperty
263277

Mathlib/LinearAlgebra/Finsupp/Defs.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ theorem lmapDomain_comp (f : α → α') (g : α' → α'') :
155155
lmapDomain M R (g ∘ f) = (lmapDomain M R g).comp (lmapDomain M R f) :=
156156
LinearMap.ext fun _ => mapDomain_comp
157157

158+
/-- `Finsupp.mapDomain` as a `LinearEquiv`. -/
159+
def mapDomain.linearEquiv (f : α ≃ α') : (α →₀ M) ≃ₗ[R] (α' →₀ M) where
160+
__ := lmapDomain M R f.toFun
161+
invFun := mapDomain f.symm
162+
left_inv _ := by
163+
simp [← mapDomain_comp]
164+
right_inv _ := by
165+
simp [← mapDomain_comp]
166+
158167
end LMapDomain
159168

160169
section LComapDomain

0 commit comments

Comments
 (0)