Skip to content
Closed
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f3166f5
add Star and InvolutiveStar instances for DirectLimit
drocta Apr 17, 2026
5ae6868
add StarMul instance for DirectLimit
drocta Apr 18, 2026
06ed721
add StarAddMonoid instance for DirectLimit
drocta Apr 18, 2026
b80e78f
add StarRing instance for DirectLimit
drocta Apr 18, 2026
a1ec83d
add StarModule instance for DirectLimit
drocta Apr 18, 2026
0168559
add DirectLimit.StarRing.(of, of_f, lift, lift_of, hom_ext)
drocta Apr 18, 2026
d034ef8
Merge branch 'master' into star-direct-limit
drocta Apr 20, 2026
75a0708
add DirectLimit.NonUnitalRing.lift and use it to shorten Ring.lift an…
drocta Apr 21, 2026
d794f22
Merge branch 'star-direct-limit' of https://github.com/drocta/mathlib…
drocta Apr 21, 2026
1e0c82d
Merge branch 'master' into star-direct-limit
drocta Apr 21, 2026
da8a600
make instance of Star for DirectLimit more concise
drocta Apr 21, 2026
90549ee
Merge branch 'star-direct-limit' of https://github.com/drocta/mathlib…
drocta Apr 21, 2026
9b37cfb
use the existing proofs for star_add and star_mul in the instance of …
drocta Apr 21, 2026
370d3f4
add NonUnitalRing.of and use it to shorten Ring.of and StarRing.of
drocta Apr 21, 2026
3890cd2
tidy syntax for Ring.lift and StarRing.lift
drocta Apr 21, 2026
cc7c011
Merge branch 'master' into star-direct-limit
drocta Apr 21, 2026
249547b
improve whitespace
drocta Apr 21, 2026
3ce7a77
add of_f, lift_of, hom_ext for DirectLimit.NonUnitalRing
drocta Apr 21, 2026
04f2eb1
update list of categories which have lift showing that the DirectLimi…
drocta Apr 22, 2026
8e2328d
remove excess newline
drocta Apr 22, 2026
a40734f
in Algebra/Colimit/DirectLimit.lean, improve whitespace
drocta Apr 22, 2026
4399ee3
Apply suggestions from code review
eric-wieser Apr 23, 2026
9b2d952
update formatting in Algebra/Colimit/DirectLimit.lean
drocta Apr 23, 2026
8f3d9cb
Merge branch 'master' into star-direct-limit
drocta Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 146 additions & 7 deletions Mathlib/Algebra/Colimit/DirectLimit.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Junyan Xu
module

public import Mathlib.Algebra.Module.LinearMap.Defs
public import Mathlib.Algebra.Star.StarRingHom
public import Mathlib.Data.Rat.Cast.Defs
public import Mathlib.Order.DirectedInverseSystem
public import Mathlib.Tactic.SuppressCompilation
Expand Down Expand Up @@ -37,7 +38,13 @@ universal object for each type of algebraic structure; the same type `DirectLimi
works for all of them. This file is therefore more general than the `Module` and `Ring`
files in terms of the variety of algebraic structures supported.

So far we only show that `DirectLimit` is the colimit in the categories of modules and rings,
So far we only show that `DirectLimit` is the colimit in the following categories:

* modules
* non-unital semirings
* rings
* (non-unital) star rings

but for the other algebraic structures the constructions and proofs will be easy following
the same pattern. Since any two colimits are isomorphic, this allows us to golf proofs of
equality criteria for `Module/AddCommGroup/Ring.DirectLimit`.
Comment thread
drocta marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -73,6 +80,29 @@ variable [∀ i j h, OneHomClass (T h) (G i) (G j)]

end ZeroOne

section Star
variable [∀ i, Star (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]

instance : Star (DirectLimit G f) where
star := .map f f (fun _ x ↦ star x) (fun i j h x ↦ map_star (f i j h) x)

lemma star_def (i : ι) (x : G i) :
Comment thread
eric-wieser marked this conversation as resolved.
star ⟦⟨i, x⟩⟧ = (⟦⟨i, star x ⟩⟧ : DirectLimit G f) := by
Comment thread
drocta marked this conversation as resolved.
Outdated
rfl

end Star

section InvolutiveStar
variable [∀ i, InvolutiveStar (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]

instance : InvolutiveStar (DirectLimit G f) where
star_involutive := by
apply DirectLimit.induction
intro i x
rw [star_def, star_def, star_star]

end InvolutiveStar

section AddMul
variable [∀ i, Mul (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)]

Expand All @@ -97,6 +127,15 @@ end AddMul
CommSemigroup (DirectLimit G f) where
mul_comm := mul_comm

section StarMul
variable [∀ i, Mul (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)]
variable [∀ i, StarMul (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]

instance : StarMul (DirectLimit G f) where
star_mul := DirectLimit.induction₂ _ fun i _ _ ↦ by simp_rw [mul_def, star_def, star_mul, mul_def]

end StarMul

section SMul
variable [∀ i, SMul R (G i)] [∀ i j h, MulActionHomClass (T h) R (G i) (G j)]

Expand All @@ -108,6 +147,13 @@ variable [∀ i, SMul R (G i)] [∀ i j h, MulActionHomClass (T h) R (G i) (G j)

end SMul

instance [Star R] [∀ i, Star (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]
[∀ i, SMul R (G i)] [∀ i j h, MulActionHomClass (T h) R (G i) (G j)]
[∀ i, StarModule R (G i)] :
StarModule R (DirectLimit G f) where
star_smul r := DirectLimit.induction _ fun i x ↦ by
simp_rw [star_def, smul_def, ← star_smul, star_def]

@[to_additive] instance [Monoid R] [∀ i, MulAction R (G i)]
[∀ i j h, MulActionHomClass (T h) R (G i) (G j)] :
MulAction R (DirectLimit G f) where
Expand Down Expand Up @@ -140,6 +186,15 @@ end Monoid
CommMonoid (DirectLimit G f) where
mul_comm := mul_comm

section StarAddMonoid
variable [∀ i, AddMonoid (G i)] [∀ i j h, AddMonoidHomClass (T h) (G i) (G j)]
variable [∀ i, StarAddMonoid (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]

instance : StarAddMonoid (DirectLimit G f) where
star_add := DirectLimit.induction₂ _ fun i _ _ ↦ by simp_rw [add_def, star_def, star_add, add_def]

end StarAddMonoid

section Group
variable [∀ i, Group (G i)] [∀ i j h, MonoidHomClass (T h) (G i) (G j)]

Expand Down Expand Up @@ -291,6 +346,11 @@ instance [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i j h, NonUnitalRingHomCl
zero_mul := zero_mul
mul_zero := mul_zero

instance [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)]
[∀ i, StarRing (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]
: StarRing (DirectLimit G f) where
Comment thread
drocta marked this conversation as resolved.
Outdated
star_add := star_add

instance [∀ i, NonUnitalSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)] :
NonUnitalSemiring (DirectLimit G f) where
mul_assoc := mul_assoc
Expand Down Expand Up @@ -480,18 +540,57 @@ theorem hom_ext {g₁ g₂ : DirectLimit G f →ₗ[R] P}

end Module

namespace NonUnitalRing
variable [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)]
variable [Nonempty ι]

variable (G f) in
/-- The canonical map from a component to the direct limit. -/
nonrec def of (i) : G i →ₙ+* DirectLimit G f where
toFun x := ⟦⟨i, x⟩⟧
map_mul' _ _ := (mul_def ..).symm
map_zero' := (zero_def i).symm
map_add' _ _ := (add_def ..).symm

@[simp] theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x := .symm <| eq_of_le ..

variable (P : Type*) [NonUnitalNonAssocSemiring P]
variable (G f) in
/-- The universal property of the direct limit: maps from the components to another
NonUnitalNonAsssocSemiRing that respect the directed system structure
(i.e. make some diagram commute) give rise to a unique map out of the direct limit.
-/
noncomputable def lift
(g : ∀ i, (G i) →ₙ+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →ₙ+* P where
toFun := _root_.DirectLimit.lift _ (g · ·) (fun i j hij x ↦ (Hg i j hij x).symm)
map_mul' := DirectLimit.induction₂ _ fun i x y ↦ by simp_rw [mul_def, lift_def, map_mul (g i)]
map_zero' := by simp_rw [zero_def (Classical.arbitrary ι), lift_def, map_zero]
map_add' := DirectLimit.induction₂ _ fun i x y ↦ by simp_rw [add_def, lift_def, map_add (g i)]

Comment thread
eric-wieser marked this conversation as resolved.
variable (g : ∀ i, G i →ₙ+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)

@[simp] theorem lift_of (i x) : lift G f P g Hg (of G f i x) = g i x := rfl

@[ext]
theorem hom_ext {g₁ g₂ : DirectLimit G f →ₙ+* P} (h : ∀ i, g₁.comp (of G f i) = g₂.comp (of G f i)):
g₁ = g₂ := by
ext x
induction x using DirectLimit.induction with | _ i x
exact congr($(h i) x)

end NonUnitalRing

namespace Ring

variable [∀ i, NonAssocSemiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] [Nonempty ι]

variable (G f) in
/-- The canonical map from a component to the direct limit. -/
nonrec def of (i) : G i →+* DirectLimit G f where
__ := NonUnitalRing.of G f i
toFun x := ⟦⟨i, x⟩⟧
map_one' := (one_def i).symm
map_mul' _ _ := (mul_def ..).symm
map_zero' := (zero_def i).symm
map_add' _ _ := (add_def ..).symm

@[simp] theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x := .symm <| eq_of_le ..

Expand All @@ -504,11 +603,9 @@ to a unique map out of the direct limit.
-/
def lift (g : ∀ i, G i →+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →+* P where
__ := (NonUnitalRing.lift G f P (fun _ => (g _).toNonUnitalRingHom) Hg)
toFun := _root_.DirectLimit.lift _ (g · ·) fun i j h x ↦ (Hg i j h x).symm
map_one' := by rw [one_def (Classical.arbitrary ι), lift_def, map_one]
map_mul' := DirectLimit.induction₂ _ fun i x y ↦ by simp_rw [mul_def, lift_def, map_mul]
map_zero' := by simp_rw [zero_def (Classical.arbitrary ι), lift_def, map_zero]
map_add' := DirectLimit.induction₂ _ fun i x y ↦ by simp_rw [add_def, lift_def, map_add]

variable (g : ∀ i, G i →+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)

Expand All @@ -523,4 +620,46 @@ theorem hom_ext {g₁ g₂ : DirectLimit G f →+* P} (h : ∀ i, g₁.comp (of

end Ring

namespace StarRing
Comment thread
eric-wieser marked this conversation as resolved.
Outdated

variable [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)]
variable [∀ i, StarRing (G i)] [∀ i j h, StarHomClass (T h) (G i) (G j)]
variable [Nonempty ι]

variable (G f) in
/-- The canonical map from a component to the direct limit. -/
noncomputable def of (i) : G i →⋆ₙ+* DirectLimit G f where
__ := NonUnitalRing.of G f i
toFun x := ⟦⟨i, x⟩⟧
map_star' _ := (star_def ..).symm
Comment thread
eric-wieser marked this conversation as resolved.

@[simp] lemma of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x := .symm <| eq_of_le ..

variable (P : Type*) [NonUnitalNonAssocSemiring P] [StarRing P]
variable (G f) in
/-- The universal property of the direct limit: maps from the components to another StarRing
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit.
-/
noncomputable def lift
(g : ∀ i, (G i) →⋆ₙ+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →⋆ₙ+* P where
__ := (NonUnitalRing.lift G f P (fun _ => (g _).toNonUnitalRingHom) Hg)
toFun := _root_.DirectLimit.lift _ (g · ·) (fun i j hij x ↦ (Hg i j hij x).symm)
map_star' := DirectLimit.induction _ fun i x ↦ by simp_rw [star_def, lift_def, map_star (g i)]

variable (g : ∀ i, G i →⋆ₙ+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)

@[simp] theorem lift_of (i x) : lift G f P g Hg (of G f i x) = g i x := rfl

@[ext]
theorem hom_ext {g₁ g₂ : DirectLimit G f →⋆ₙ+* P}
(h : ∀ i, g₁.comp (of G f i) = g₂.comp (of G f i)) :
g₁ = g₂ := by
ext x
induction x using DirectLimit.induction with | _ i x
exact congr($(h i) x)

end StarRing
Comment thread
eric-wieser marked this conversation as resolved.
Outdated

end DirectLimit
Loading