Skip to content

Commit 98c8a1b

Browse files
Merge pull request #452 from agda/limits-refactor
Factor (co)end (co)limits into their own modules
2 parents 58c75ac + 8952828 commit 98c8a1b

File tree

5 files changed

+192
-151
lines changed

5 files changed

+192
-151
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{-# OPTIONS --without-K --safe #-}
2+
3+
module Categories.Diagram.Coend.Colimit where
4+
5+
open import Categories.Category.Equivalence as SE using (StrongEquivalence)
6+
open import Categories.Category.Equivalence.Preserves using (pres-Initial)
7+
open import Categories.Category.Core using (Category)
8+
open import Categories.Functor using (Functor)
9+
open import Categories.Functor.Bifunctor using (Bifunctor)
10+
open import Categories.Functor.Instance.Twisted using (Twist′)
11+
open import Categories.Diagram.Coend using (Coend)
12+
open import Categories.Diagram.Coend.Properties using (Coend⇒Initial; Initial⇒Coend)
13+
open import Categories.Diagram.Colimit using (Colimit)
14+
open import Categories.Diagram.Cowedge using (module Cowedge-Morphism)
15+
open import Categories.Diagram.Cowedge.Properties using (CoconesTwist≅Cowedges)
16+
17+
import Categories.Category.Construction.Cowedges as Cowedges
18+
import Categories.Object.Initial as Initial
19+
import Categories.Morphism as M
20+
21+
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
22+
(F : Bifunctor (Category.op C) C D) where
23+
private
24+
Eq = CoconesTwist≅Cowedges F
25+
module O = M D
26+
open M (Cowedges.Cowedges F)
27+
open Functor
28+
29+
open StrongEquivalence Eq renaming (F to F⇒)
30+
31+
Coend-yields-colimit : Coend F Colimit (Twist′ C D F)
32+
Coend-yields-colimit ef = record { initial = pres-Initial (SE.sym Eq) (Coend⇒Initial F ef) }
33+
34+
colimit-yields-Coend : Colimit (Twist′ C D F) Coend F
35+
colimit-yields-Coend l = Initial⇒Coend F (pres-Initial Eq (Colimit.initial l))
36+
37+
-- Coends and Colimits are equivalent, in the category Cowedge F
38+
Coend-as-Colimit : (coend : Coend F) (cl : Colimit (Twist′ C D F)) Coend.cowedge coend ≅ F₀ F⇒ (Colimit.initial.⊥ cl)
39+
Coend-as-Colimit coend cl = Initial.up-to-iso (Cowedges.Cowedges F) (Coend⇒Initial F coend) (pres-Initial Eq initial)
40+
where
41+
open Colimit cl
42+
43+
-- Which then induces that the objects, in D, are also equivalent.
44+
Coend-as-Colimit-on-Obj : (coend : Coend F) (cl : Colimit (Twist′ C D F)) Coend.E coend O.≅ Colimit.coapex cl
45+
Coend-as-Colimit-on-Obj coend cl = record
46+
{ from = Cowedge-Morphism.u (M._≅_.from X≅Y)
47+
; to = Cowedge-Morphism.u (M._≅_.to X≅Y)
48+
; iso = record
49+
{ isoˡ = M._≅_.isoˡ X≅Y
50+
; isoʳ = M._≅_.isoʳ X≅Y
51+
}
52+
}
53+
where
54+
X≅Y = Coend-as-Colimit coend cl
55+
open Category D

src/Categories/Diagram/Coend/Properties.agda

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22

33
module Categories.Diagram.Coend.Properties where
44

5+
open import Level using (Level)
6+
open import Data.Product using (Σ; _,_)
7+
open import Function using (_$_)
8+
59
open import Categories.Category.Core using (Category)
6-
open import Categories.Category.Product
7-
import Categories.Category.Construction.Cowedges as Cowedges
8-
open import Categories.Category.Construction.Functors
9-
open import Categories.Category.Equivalence as SE
10-
open import Categories.Category.Equivalence.Preserves
11-
open import Categories.Diagram.Coend
12-
open import Categories.Diagram.Colimit
13-
open import Categories.Diagram.Cowedge
14-
open import Categories.Diagram.Cowedge.Properties
10+
open import Categories.Category.Construction.Functors using (Functors)
11+
open import Categories.Category.Product using (Product)
12+
open import Categories.Diagram.Coend using (Coend)
13+
open import Categories.Diagram.Cowedge using (Cowedge; module Cowedge-Morphism)
1514
open import Categories.Functor using (Functor)
1615
open import Categories.Functor.Bifunctor using (Bifunctor)
17-
open import Categories.Functor.Instance.Twisted
18-
import Categories.Morphism as M
19-
open import Categories.NaturalTransformation hiding (id)
20-
open import Categories.NaturalTransformation.Dinatural
21-
open import Categories.Object.Initial as Initial
16+
open import Categories.NaturalTransformation using (NaturalTransformation)
17+
open import Categories.NaturalTransformation.Dinatural using (DinaturalTransformation; dtHelper; _∘>_)
18+
open import Categories.Object.Initial as Initial using (Initial)
2219

20+
import Categories.Category.Construction.Cowedges as Cowedges
21+
import Categories.Morphism as M
2322
import Categories.Morphism.Reasoning as MR
2423

25-
open import Level
26-
open import Data.Product using (Σ; _,_)
27-
open import Function using (_$_)
28-
2924
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
3025
(F : Bifunctor (Category.op C) C D) where
3126
open Cowedges F
@@ -95,7 +90,7 @@ module _ (F : Functor E (Functors (Product (Category.op C) C) D)) where
9590

9691
-- A Natural Transformation between two functors induces an arrow between the
9792
-- (object part of) the respective coends.
98-
module _ {P Q : Functor (Product (Category.op C) C) D} (P⇒Q : NaturalTransformation P Q) where
93+
module _ {P Q : Bifunctor (Category.op C) C D} (P⇒Q : NaturalTransformation P Q) where
9994
open Coend renaming (E to coend)
10095
open Category D
10196

@@ -127,38 +122,3 @@ module _ {P Q : Functor (Product (Category.op C) C) D} (P⇒Q : NaturalTransform
127122
open Cowedge
128123
open MR D
129124

130-
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
131-
(F : Bifunctor (Category.op C) C D) where
132-
private
133-
Eq = CoconesTwist≅Cowedges F
134-
module O = M D
135-
open M (Cowedges.Cowedges F)
136-
open Functor
137-
138-
open StrongEquivalence Eq renaming (F to F⇒)
139-
140-
Coend-yields-colimit : Coend F Colimit (Twist′ C D F)
141-
Coend-yields-colimit ef = record { initial = pres-Initial (SE.sym Eq) (Coend⇒Initial F ef) }
142-
143-
colimit-yields-Coend : Colimit (Twist′ C D F) Coend F
144-
colimit-yields-Coend l = Initial⇒Coend F (pres-Initial Eq (Colimit.initial l))
145-
146-
-- Coends and Colimits are equivalent, in the category Cowedge F
147-
Coend-as-Colimit : (coend : Coend F) (cl : Colimit (Twist′ C D F)) Coend.cowedge coend ≅ F₀ F⇒ (Colimit.initial.⊥ cl)
148-
Coend-as-Colimit coend cl = Initial.up-to-iso (Cowedges.Cowedges F) (Coend⇒Initial F coend) (pres-Initial Eq initial)
149-
where
150-
open Colimit cl
151-
152-
-- Which then induces that the objects, in D, are also equivalent.
153-
Coend-as-Colimit-on-Obj : (coend : Coend F) (cl : Colimit (Twist′ C D F)) Coend.E coend O.≅ Colimit.coapex cl
154-
Coend-as-Colimit-on-Obj coend cl = record
155-
{ from = Cowedge-Morphism.u (M._≅_.from X≅Y)
156-
; to = Cowedge-Morphism.u (M._≅_.to X≅Y)
157-
; iso = record
158-
{ isoˡ = M._≅_.isoˡ X≅Y
159-
; isoʳ = M._≅_.isoʳ X≅Y
160-
}
161-
}
162-
where
163-
X≅Y = Coend-as-Colimit coend cl
164-
open Category D
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{-# OPTIONS --without-K --safe #-}
2+
3+
module Categories.Diagram.End.Limit where
4+
5+
open import Level
6+
7+
open import Categories.Category using (Category)
8+
open import Categories.Category.Construction.TwistedArrow using (Codomain)
9+
open import Categories.Category.Equivalence as SE using (StrongEquivalence)
10+
open import Categories.Category.Equivalence.Preserves using (pres-Terminal)
11+
open import Categories.Diagram.End using () renaming (End to ∫)
12+
open import Categories.Diagram.End.Properties using (End⇒Terminal; Terminal⇒End; end-η; end-unique; end-identity; end-η-resp-≈; end-η-resp-∘)
13+
open import Categories.Diagram.Limit using (Limit)
14+
open import Categories.Diagram.Limit.Properties using (≃-resp-lim)
15+
open import Categories.Diagram.Wedge using (module Wedge-Morphism)
16+
open import Categories.Diagram.Wedge.Properties using (ConesTwist≅Wedges)
17+
open import Categories.Functor using (Functor; _∘F_)
18+
open import Categories.Functor.Instance.Twisted using (Twist; Twistⁿⁱ)
19+
open import Categories.Functor.Limits using (Continuous)
20+
open import Categories.Functor.Bifunctor using (Bifunctor)
21+
open import Categories.NaturalTransformation using (NaturalTransformation; _∘ᵥ_) renaming (id to idN)
22+
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; sym-associator) renaming (_≃_ to _≃ⁱ_)
23+
open import Categories.Object.Terminal as Terminal
24+
25+
import Categories.Category.Construction.Wedges as Wedges
26+
import Categories.Morphism as M
27+
28+
private
29+
variable
30+
o ℓ e : Level
31+
C D E : Category o ℓ e
32+
33+
-- The real start of the End Calculus. Maybe need to move such properties elsewhere?
34+
-- This is an unpacking of the lhs of Eq. (25) of Loregian's book.
35+
module _ (F : Bifunctor (Category.op C) C D) where
36+
private
37+
Eq = ConesTwist≅Wedges F
38+
module O = M D
39+
open M (Wedges.Wedges F)
40+
open Functor
41+
42+
open StrongEquivalence Eq renaming (F to F⇒; G to F⇐)
43+
44+
End-yields-limit : ∫ F Limit (Twist C D F)
45+
End-yields-limit ef = record { terminal = pres-Terminal (SE.sym Eq) (End⇒Terminal F ef) }
46+
47+
limit-yields-End : Limit (Twist C D F) ∫ F
48+
limit-yields-End l = Terminal⇒End F (pres-Terminal Eq (Limit.terminal l))
49+
50+
-- Ends and Limits are equivalent, in the category Wedge F
51+
End-as-Limit : (end : ∫ F) (l : Limit (Twist C D F)) ∫.wedge end ≅ F₀ F⇒ (Limit.terminal.⊤ l)
52+
End-as-Limit end l = Terminal.up-to-iso (Wedges.Wedges F) (End⇒Terminal F end) (pres-Terminal Eq terminal)
53+
where
54+
open Limit l
55+
56+
-- Which then induces that the objects, in D, are also equivalent.
57+
End-as-Limit-on-Obj : (end : ∫ F) (l : Limit (Twist C D F)) ∫.E end O.≅ Limit.apex l
58+
End-as-Limit-on-Obj end l = record
59+
{ from = Wedge-Morphism.u (M._≅_.from X≅Y)
60+
; to = Wedge-Morphism.u (M._≅_.to X≅Y)
61+
; iso = record
62+
{ isoˡ = M._≅_.isoˡ X≅Y
63+
; isoʳ = M._≅_.isoʳ X≅Y
64+
}
65+
}
66+
where
67+
X≅Y = End-as-Limit end l
68+
open Category D
69+
70+
-- A stronger form of Categories.Diagram.End.Properties.end-resp-≅
71+
module _ {F G : Bifunctor (Category.op C) C D} (F≃G : F ≃ⁱ G) where
72+
≅-yields-end : ∫ F ∫ G
73+
≅-yields-end ef = limit-yields-End G (≃-resp-lim (Twistⁿⁱ C D F≃G) (End-yields-limit F ef))
74+
75+
-- continuous functors preserve ends
76+
module _ {C : Category o ℓ e}
77+
(J : Bifunctor (Category.op C) C D) (F : Functor D E)
78+
{cont : Continuous (o ⊔ ℓ) (ℓ ⊔ e) e F} where
79+
open Category E
80+
open M E
81+
open _≅_
82+
open Iso
83+
open hiding (E)
84+
private
85+
module F = Functor F
86+
module J = Bifunctor J
87+
module E = Category E
88+
-- i don't have a better name for this
89+
-- the converse follows only if J reflects limits
90+
open import Categories.Diagram.Cone.Properties
91+
open import Categories.Diagram.Limit.Properties
92+
93+
module _ (ej : ∫ J) where
94+
private
95+
module ej = ∫ ej
96+
j-limit : Limit (Twist C D J)
97+
j-limit = End-yields-limit J ej
98+
--new-limit
99+
f-limit : Limit (F ∘F (J ∘F Codomain C))
100+
f-limit .Limit.terminal = record
101+
{ ⊤ = F-map-Coneˡ F (Limit.limit j-limit)
102+
; ⊤-is-terminal = cont j-limit
103+
}
104+
-- for this we merely need to transport across the associator
105+
f-limit′ : Limit (Twist C E (F ∘F J))
106+
f-limit′ = ≃-resp-lim (sym-associator (Codomain C) J F) f-limit
107+
108+
-- really we want IsEnd `F.₀ (∫.E ej)` (F ∘F J)
109+
contF-as-end : ∫ (F ∘F J)
110+
contF-as-end = limit-yields-End (F ∘F J) f-limit′
111+
_ : F.₀ (∫.E ej) ≅ (∫.E contF-as-end)
112+
_ = ≅.refl
113+
114+
Continuous-pres-End : {ej : ∫ J} {ef : ∫ (F ∘F J)} F.₀ (∫.E ej) ≅ ∫.E ef
115+
Continuous-pres-End {ej} {ef} = end-unique (contF-as-end ej) ef

src/Categories/Diagram/End/Parameterized.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ open import Categories.Category
99
open import Categories.Category.Construction.Functors
1010
open import Categories.Category.Product renaming (Product to _×ᶜ_)
1111
open import Categories.Diagram.End renaming (End to ∫)
12+
open import Categories.Diagram.End.Limit
1213
open import Categories.Diagram.End.Properties
1314
open import Categories.Diagram.Wedge
1415
open import Categories.Functor hiding (id)

0 commit comments

Comments
 (0)