Skip to content
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fdbb91f
add instance of Algebra for DirectLimit
drocta Apr 23, 2026
85519eb
add algebraMap_at in Algebra/Colimit/DirectLimit.lean
drocta Apr 23, 2026
e56da43
add lift, of, etc. for DirectLimit.Algebra
drocta Apr 23, 2026
0f0437a
remove an unnecessary rfl that was causing an error, an unused argume…
drocta Apr 29, 2026
db1e953
add docstring for algebraMapAux
drocta Apr 29, 2026
ff148d0
Merge branch 'master' into algebra-direct-limit2
drocta Apr 29, 2026
afee464
Merge branch 'master' into algebra-direct-limit2
drocta Apr 29, 2026
5a2bdcc
apply suggestions from code review (simplifying proofs)
drocta May 5, 2026
b7948a2
following PR feedback, use map_0 in algebraMapAux and map_0_def in al…
drocta May 5, 2026
34f10fc
add DirectLimit.Algebra.lift_comp_of
drocta May 5, 2026
9dc79d7
Merge branch 'master' of https://github.com/leanprover-community/math…
drocta May 5, 2026
b089524
rename algebraMap_at to algebraMap_def, and remove unnecessary type a…
drocta May 5, 2026
63d2d45
add @[simps] to DirectLimit.Algebra.of and DirectLimit.Algebra.lift
drocta May 5, 2026
15190eb
remove the @[simp] on DirectLimit.Algebra.of_f for consistency with t…
drocta May 6, 2026
1609007
add map0MonoidHom, map0RingHom, map0RingHom_def, & replace algebraMap…
drocta May 6, 2026
1026f06
add docstring to map0AddMonoidHom, and use the proper notation for th…
drocta May 6, 2026
2806655
Merge branch 'master' into algebra-direct-limit2
drocta May 6, 2026
61022bf
fix whitespace and remove excess parentheses in Mathlib/Algebra/Colim…
drocta May 6, 2026
dbdab9d
make lemma algebraMapAux_def private, and rename it to map0RingHom_al…
drocta May 6, 2026
28013cc
add R-algebras to the list of categories for which the lift map is de…
drocta May 6, 2026
b21c1e9
Simplify map₀RingHom
eric-wieser May 6, 2026
3b72e57
make variable (f) explicit in map0MonoidHom, map0AddMonoidHom, and ma…
drocta May 6, 2026
b850d12
remove commented out typeclass variable
drocta May 6, 2026
9ed65bc
pull out proofs of map_one' and map_mul' from definition of map0Monoi…
drocta May 6, 2026
8280c16
make map0RingHom work for NonAssocSemiring by using map0_one and map0…
drocta May 6, 2026
7172b17
tiny simplification to map0MonoidHom
drocta May 6, 2026
e6f64a0
make map0MonoidHom assume only MapOneClass (G i) rather than Monoid (…
drocta May 7, 2026
26ec4f4
add simp attr to the map0_one lemma
drocta May 7, 2026
720e839
remove todo comment in light of PR #39017
drocta May 7, 2026
1585f69
add DirectLimit.NonUnitalAlgebra.lift etc.
drocta May 7, 2026
abca651
Merge branch 'algebra-direct-limit2' of https://github.com/drocta/mat…
drocta May 7, 2026
c24b02d
remove @[simp] tag on the lift_of lemmas for Algebra and NonUnitalAlg…
drocta May 7, 2026
f4a7e82
add simp tag for map0_mul to match the tag on map0_one
drocta May 7, 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
151 changes: 151 additions & 0 deletions Mathlib/Algebra/Colimit/DirectLimit.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module

public import Mathlib.Algebra.Module.LinearMap.Defs
public import Mathlib.Algebra.Star.StarRingHom
public import Mathlib.Algebra.Algebra.NonUnitalHom
public import Mathlib.Algebra.Algebra.Pi
public import Mathlib.Data.Rat.Cast.Defs
public import Mathlib.Order.DirectedInverseSystem
public import Mathlib.Tactic.SuppressCompilation
Expand Down Expand Up @@ -44,6 +46,7 @@ So far we only show that `DirectLimit` is the colimit in the following categorie
* non-unital semirings
* rings
* (non-unital) star rings
* R-algebras

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
Expand Down Expand Up @@ -85,6 +88,9 @@ theorem lift_one (g : ∀ i, H i) (h) :
let ⟨i⟩ := ‹Nonempty ι›
rw [one_def, lift_def, map_one (g i)]

@[to_additive (attr := simp)]
lemma map₀_one : map₀ f (1 : ∀ i, G i) = 1 := by rw [map₀, Pi.one_apply, one_def]

end ZeroOne

section Star
Expand Down Expand Up @@ -133,6 +139,10 @@ theorem lift_mul (g : ∀ i, H i) (h) (x y : DirectLimit G f) :
DirectLimit.lift f (g ·) h x * DirectLimit.lift f (g ·) h y :=
DirectLimit.induction₂ _ (fun i x y ↦ by simp_rw [mul_def, lift_def, map_mul (g i)]) x y

@[to_additive (attr := simp)]
lemma map₀_mul [Nonempty ι] (r s : ∀ i, G i) : map₀ f (r * s) = map₀ f r * map₀ f s := by
simp_rw [map₀, Pi.mul_apply, mul_def]

end AddMul

@[to_additive] instance [∀ i, CommMagma (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)] :
Expand Down Expand Up @@ -193,6 +203,15 @@ variable [Nonempty ι]
one_mul := DirectLimit.induction _ fun i _ ↦ by simp_rw [one_def i, mul_def, one_mul]
mul_one := DirectLimit.induction _ fun i _ ↦ by simp_rw [one_def i, mul_def, mul_one]

variable (f) in
/-- `map₀` as a `MonoidHom`. -/
@[to_additive (attr := simps) /-- `map₀` as an `AddMonoidHom`. -/]
def map₀MonoidHom [∀ i, MulOneClass (G i)] [∀ i j h, MonoidHomClass (T h) (G i) (G j)] :
(∀ i, G i) →* DirectLimit G f where
toFun x := map₀ _ x
map_one' := map₀_one
map_mul' := map₀_mul

section Monoid
variable [∀ i, Monoid (G i)] [Monoid C]
variable [∀ i j h, MonoidHomClass (T h) (G i) (G j)] [∀ i, MonoidHomClass (H i) (G i) C]
Expand Down Expand Up @@ -432,6 +451,15 @@ instance [∀ i, NonAssocSemiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G
instance [∀ i, Semiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
Semiring (DirectLimit G f) where

variable (f) in
/-- `map₀` as a `RingHom`. -/
@[simps]
def map₀RingHom [∀ i, NonAssocSemiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
(∀ i, G i) →+* DirectLimit G f where
toFun r := map₀ _ r
__ := map₀AddMonoidHom f
__ := map₀MonoidHom f

instance [∀ i, NonUnitalNonAssocCommSemiring (G i)]
[∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)] :
NonUnitalNonAssocCommSemiring (DirectLimit G f) where
Expand Down Expand Up @@ -572,6 +600,31 @@ instance [∀ i, Field (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
__ : DivisionRing _ := inferInstance
mul_comm := mul_comm

section Algebra

variable [CommSemiring R]
variable [∀ i, Semiring (G i)]
variable [∀ i, Algebra R (G i)] [∀ i j h, AlgHomClass (T h) R (G i) (G j)]

lemma map₀_algebraMap (i : ι) (r : R) :
map₀ f (fun i ↦ algebraMap R (G i) r) = ⟦⟨i, algebraMap R (G i) r⟩⟧ :=
map₀_def _ _ (fun _ _ _ => AlgHomClass.commutes _ _) i

instance : Algebra R (DirectLimit G f) where
algebraMap := map₀RingHom (f := f).comp (algebraMap R (∀ i, G i))
commutes' r := DirectLimit.induction f fun i _ ↦ by
dsimp [Pi.algebraMap_def]
rw [map₀_algebraMap i, mul_def, mul_def, Algebra.commutes]
smul_def' r := DirectLimit.induction _ fun i _ => by
dsimp [Pi.algebraMap_def]
rw [smul_def, map₀_algebraMap i, mul_def, Algebra.smul_def']

lemma algebraMap_def (i : ι) (r : R) :
algebraMap R (DirectLimit G f) r = ⟦⟨i, algebraMap R (G i) r⟩⟧:=
map₀_algebraMap i r

end Algebra

end DirectLimit

namespace DirectLimit
Expand Down Expand Up @@ -759,4 +812,102 @@ theorem hom_ext {g₁ g₂ : DirectLimit G f →⋆ₙ+* P}

end NonUnitalStarRing

namespace Algebra

variable [CommSemiring R]
variable [∀ i, Semiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)]
variable [∀ i, Algebra R (G i)] [∀ i j h, AlgHomClass (T h) R (G i) (G j)]
variable [Nonempty ι]

variable (G f) in
/-- The canonical map from a component to the direct limit. -/
@[simps]
def of (i) : G i →ₐ[R] DirectLimit G f where
Comment thread
drocta marked this conversation as resolved.
toFun x := ⟦⟨i, x⟩⟧
__ := (DirectLimit.Ring.of G f i)
commutes' r := by rw [algebraMap_def i]

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*) [Semiring P] [Algebra R P]

variable (G f) in
/-- The universal property of the direct limit: maps from the components to another R-algebra
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit.
-/
@[simps]
def lift (g : ∀ i, G i →ₐ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
Comment thread
drocta marked this conversation as resolved.
DirectLimit G f →ₐ[R] P where
toFun := _root_.DirectLimit.lift _ (g · ·) fun i j h x ↦ (Hg i j h x).symm
__ := DirectLimit.Ring.lift G f P (g:= fun i => (g i).toRingHom) (Hg:=Hg)
commutes' r := by
let i := Classical.arbitrary ι
rw [algebraMap_def i r, lift_def, AlgHom.commutes]

variable (g : ∀ i, G i →ₐ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)

@[simp]
theorem lift_comp_of {i} : (lift G f P g Hg).comp (of G f i) = g i := rfl

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 →ₐ[R] 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 Algebra

namespace NonUnitalAlgebra

variable [CommSemiring R]
variable [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i, DistribMulAction R (G i)]
variable [∀ i j h, NonUnitalAlgHomClass (T h) R (G i) (G j)]
variable [Nonempty ι]

variable (G f) in
/-- The canonical map from a component to the direct limit. -/
@[simps]
def of (i) : G i →ₙₐ[R] DirectLimit G f where
toFun x := ⟦⟨i, x⟩⟧
__ := (DirectLimit.NonUnitalRing.of G f i)
map_smul' m x := by rw [smul_def, MonoidHom.id_apply]

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] [DistribMulAction R P]

variable (G f) in
/-- The universal property of the direct limit: maps from the components to another R-algebra
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit.
-/
@[simps]
def lift (g : ∀ i, G i →ₙₐ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →ₙₐ[R] P where
toFun := _root_.DirectLimit.lift _ (g · ·) fun i j h x ↦ (Hg i j h x).symm
__ := DirectLimit.NonUnitalRing.lift G f P (g:= fun i => (g i)) (Hg:=Hg)
map_smul' m := by apply lift_smul

variable (g : ∀ i, G i →ₙₐ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)

@[simp]
theorem lift_comp_of {i} : (lift G f P g Hg).comp (of G f i) = g i := rfl

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 →ₙₐ[R] 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 NonUnitalAlgebra

end DirectLimit
Loading