open import Cat.Instances.Sets.Complete
open import Cat.Diagram.Terminal
open import Cat.Functor.Adjoint
open import  Cat.Functor.Closed
open import Cat.Functor.Base
open import Cat.Functor.Hom
open import Cat.Prelude
open import Cat.Total
module Cat.Total.Instances.Set {โ„“} where
open Terminal (Sets-terminal {โ„“}) renaming (top to โ˜…)
open _โŠฃ_
open _=>_
open Functor
private

Total cocompleteness of sets๐Ÿ”—

If we are to show that the category of sets is total, we must give a colimit over the category of elements of every presheaf.

Suppose What would a colimit of look like? Let We require a universal function Notice that any element of a set is equivalent to a subobject sending the single element to Furthermore, sends this to a function Thus, setting we have a function from to as desired.

Now, let in the category of elements. Our cocone commutes as, for any as

  ใ• : Functor (PSh โ„“ (Sets โ„“)) (Sets โ„“)
  ใ• = eval-at โ˜…

  has-ใ‚ˆ-adj : ใ• โŠฃ ใ‚ˆ (Sets โ„“)
  has-ใ‚ˆ-adj .unit .ฮท P .ฮท X p s = P โŸช (ฮป _ โ†’ s) โŸซ p
  has-ใ‚ˆ-adj .unit .ฮท P .is-natural x y f = ext ฮป r s โ†’ sym $ unext (P .F-โˆ˜ _ _) _
  has-ใ‚ˆ-adj .unit .is-natural F G nt  = ext ฮป X s r โ†’
    G โŸช (ฮป _ โ†’ r) โŸซ (nt .ฮท X s)                   โ‰กห˜โŸจ unext (nt .is-natural  _ _ _) _ โŸฉ
    (nt .ฮท โ˜… (F โŸช (ฮป _ โ†’ r) โŸซ s))                 โ‰กห˜โŸจ unext (G .F-id) _ โŸฉ
    G โŸช (ฮป x โ†’ x) โŸซ (nt .ฮท โ˜… (F โŸช (ฮป _ โ†’ r) โŸซ s)) โˆŽ
  has-ใ‚ˆ-adj .counit .ฮท X s = s _
  has-ใ‚ˆ-adj .counit .is-natural _ _ _ = refl
  has-ใ‚ˆ-adj .zig {F} = F .F-id
  has-ใ‚ˆ-adj .zag  = trivial!

Sets-total : is-total (Sets โ„“)
Sets-total .is-total.ใ• = ใ•
Sets-total .is-total.has-ใ‚ˆ-adj = has-ใ‚ˆ-adj