module Cat.Instances.Sets.Complete where
Sets is completeπ
We prove that the category of is for any universe levels and Inverting this to speak of maxima rather than ordering, to admit all we must be in at least the category of but any extra adjustment is also acceptable. So, suppose we have an indexing category and a diagram Letβs build a limit for it!
: β {ΞΉ ΞΊ o} β is-complete ΞΉ ΞΊ (Sets (ΞΉ β ΞΊ β o))
Sets-is-complete {J = D} F = to-limit (to-is-limit lim) module Sets-is-complete where
Sets-is-complete module D = Precategory D
module F = Functor F
open make-is-limit
Since Set
is closed
under (arbitrary) products, we can build the
limit of an arbitrary diagram
β which we will write
β by first taking the product
(which is a set of dependent functions), then restricting ourselves to
the subset of those for which
i.e., those which are cones over
: Set _
apex = el! $
apex ((j : D.Ob) β β£ F.β j β£) ]
Ξ£[ f β (β x y (g : D.Hom x y) β F.β g (f x) β‘ (f y))
To form a cone, given an object
and an inhabitant
of the type underlying f-apex
, we
must cough up (for Ο
) an object of
But this is exactly what
gives us. Similarly, since
witnesses that
commutes
, we can project it
directly.
Given some other cone to build a cone homomorphism recall that comes equipped with its own function which we can simply flip around to get a function This function is in the subset carved out by since is a cone, hence as required.
-- open Terminal
: make-is-limit F apex
lim .Ο x (f , p) = f x
lim .commutes f = funext Ξ» where
lim (_ , p) β p _ _ f
.universal eta p x =
lim (Ξ» j β eta j x) , Ξ» x y f β p f $β _
.factors _ _ = refl
lim .unique eta p other q = funext Ξ» x β
lim (funext Ξ» j β q j $β x) Ξ£-prop-path!
Finite set-limitsπ
For expository reasons, we present the computation of the most famous shapes of finite limit (terminal objects, products, pullbacks, and equalisers) in the category of sets. All the definitions below are redundant, since finite limits are always small, and thus the category of sets of any level admits them.
: Terminal (Sets β)
Sets-terminal .top = el! (Lift _ β€)
Sets-terminal .hasβ€ _ = hlevel 0 Sets-terminal
Products are given by product sets:
: Binary-products (Sets β)
Sets-products ._ββ_ A B = el! (β£ A β£ Γ β£ B β£)
Sets-products .Οβ = fst
Sets-products .Οβ = snd
Sets-products .β¨_,_β© f g x = f x , g x
Sets-products .Οβββ¨β© = refl
Sets-products .Οβββ¨β© = refl
Sets-products .β¨β©-unique p q i x = p i x , q i x Sets-products
Equalisers are given by carving out the subset of where and agree using
: Equalisers (Sets β)
Sets-equalisers .Equ {X} {Y} f g = el! (Ξ£[ x β X ] (f x β‘ g x))
Sets-equalisers .equ f g = fst
Sets-equalisers .equal = funext snd
Sets-equalisers .equalise e p x = e x , p $β x
Sets-equalisers .equβequalise = refl
Sets-equalisers .equalise-unique p =
Sets-equalisers Ξ» x β Ξ£-prop-path! (p $β x) funext
Pullbacks are the same, but carving out a subset of
: Pullbacks (Sets β)
Sets-pullbacks .Pb {X} {Y} {Z} f g = el! (Ξ£[ x β X ] Ξ£[ y β Y ] (f x β‘ g y))
Sets-pullbacks .pβ f g (x , _ , _) = x
Sets-pullbacks .pβ f g (_ , y , _) = y
Sets-pullbacks .square = funext (snd β snd)
Sets-pullbacks .pb p1 p2 sq x = p1 x , p2 x , sq $β x
Sets-pullbacks .pββpb = refl
Sets-pullbacks .pββpb = refl
Sets-pullbacks .pb-unique p q =
Sets-pullbacks Ξ» x β Ξ£-pathp (p $β x) (Ξ£-pathp (q $β x) prop!) funext
Hence, Sets
is finitely
complete:
open Finitely-complete
: Finitely-complete (Sets β)
Sets-finitely-complete .terminal = Sets-terminal
Sets-finitely-complete .products = Sets-products
Sets-finitely-complete .equalisers = Sets-equalisers
Sets-finitely-complete .pullbacks = Sets-pullbacks Sets-finitely-complete