module Cat.Instances.Sheaves.Limits where

Limits of sheavesπŸ”—

This module proves that sheaves are closed under arbitrary limits, without regard for the size of the indexing category, independently of whether we are talking about sheaves on a site or functors that satisfy the sheaf condition for individual sieves.

This is a simultaneous specialisation and generalisation of the proof that monadic functors create limits. It’s a specialisation in the sense that the same strategy there works here; but it’s a generalisation in the sense that sheaves for an individual sieve are not the algebras for any monad.

Regardless, if we are talking about the topos of sheaves, we can obtain an abstract proof of its completeness through monadicity, without having to do the componentwise work here.

is-sheaf₁-limit
  : βˆ€ {o β„“ o' β„“'} {C : Precategory o β„“} {D : Precategory o' β„“'}
  β†’ βˆ€ (F : Functor D (PSh β„“ C)) L ψ
  β†’ is-limit F L ψ
  β†’ βˆ€ {U} (R : Sieve C U)
  β†’ (βˆ€ d β†’ is-sheaf₁ (F # d) R)
  β†’ is-sheaf₁ L R
is-sheaf₁-limit {C = C} {D} F L ψ lim {U} R F-sheaf ps = from-is-separated₁ L sep sec where
  open Precategory C

  module lim = is-limit lim
  module F x = PSh (F .Fβ‚€ x)
  module L = PSh L

  abstract
    sep : is-separated₁ L R
    sep {x} {y} loc = unyo-path $ lim.uniqueβ‚‚ {x = γ‚ˆβ‚€ C U} _
      (Ξ» f β†’ yo-natl (sym (ψ .is-natural _ _ _ Ξ·β‚š _ $β‚š _))) (Ξ» j β†’ yo-natl refl)
      (Ξ» j β†’ yo-natl (is-sheaf₁→is-separated₁ _ _ (F-sheaf j) Ξ» f hf β†’
        F.₁ j f (ψ .Ξ· j .Ξ· U y) β‰‘Λ˜βŸ¨ ψ .Ξ· j .is-natural _ _ _ $β‚š _ βŸ©β‰‘Λ˜
        ψ .Ξ· j .Ξ· _ (L.₁ f y)   β‰‘Λ˜βŸ¨ ap (ψ .Ξ· j .Ξ· _) (loc f hf) βŸ©β‰‘Λ˜
        ψ .Ξ· j .Ξ· _ (L.₁ f x)   β‰‘βŸ¨ ψ .Ξ· j .is-natural _ _ _ $β‚š _ βŸ©β‰‘
        F.₁ j f (ψ .Ξ· j .Ξ· U x) ∎))

  ps' : βˆ€ j β†’ Section (F # j) (map-patch (ψ .Ξ· j) ps)
  ps' j = F-sheaf j (map-patch (ψ .η j) ps) .centre

  elts : βˆ€ j β†’ γ‚ˆβ‚€ C U => F .Fβ‚€ j
  elts j = yo (F .Fβ‚€ j) (ps' j .whole)

  abstract
    elts-nat : βˆ€ {x y} (f : D .Precategory.Hom x y) β†’ F .F₁ f ∘nt elts x ≑ elts y
    elts-nat {x} {y} f = yo-natl $ is-sheaf₁→is-separated₁ _ _ (F-sheaf y) Ξ» g hg β†’ sym $
      F.₁ y g (ps' y .whole)                      β‰‘βŸ¨ ps' y .glues g hg βŸ©β‰‘
      ψ .Ξ· y .Ξ· _ (ps .part g hg)                 β‰‘βŸ¨ ψ .is-natural x y f Ξ·β‚š _ $β‚š ps .part g hg βŸ©β‰‘
      F .F₁ f .Ξ· _ (ψ .Ξ· x .Ξ· _ (ps .part g hg))  β‰‘Λ˜βŸ¨ ap (F .F₁ f .Ξ· _) (ps' x .glues g hg) βŸ©β‰‘Λ˜
      F .F₁ f .Ξ· _ (F.₁ x g (ps' x .whole))       β‰‘βŸ¨ F .F₁ f .is-natural _ _ _ $β‚š _ βŸ©β‰‘
      F.₁ y g (F .F₁ f .Ξ· _ (ps' x .whole))       ∎

  sec : Section L ps
  sec .whole = unyo _ (lim.universal elts elts-nat)
  sec .glues {V} f hf =
    L βŸͺ f ⟫ sec .whole                        β‰‘Λ˜βŸ¨ lim.universal _ _ .is-natural _ _ _ $β‚š _ βŸ©β‰‘Λ˜
    lim.universal elts elts-nat .Ξ· V (id ∘ f) β‰‘βŸ¨ ap (lim.universal _ _ .Ξ· _) (Cat.id-comm-sym C) βŸ©β‰‘
    lim.universal elts elts-nat .Ξ· V (f ∘ id) β‰‘βŸ¨ unext it _ id βŸ©β‰‘
    L βŸͺ id ⟫ (ps .part f hf)                  β‰‘βŸ¨ L.F-id βŸ©β‰‘
    ps .part f hf                             ∎
    where
      it = lim.uniqueβ‚‚ {x = γ‚ˆβ‚€ C V} _
        (Ξ» f β†’ Cat.pulll (PSh _ C) (elts-nat f))
        (Ξ» j β†’ Cat.pulll (PSh _ C) (lim.factors elts elts-nat))
        (Ξ» j β†’ yo-natl (sym (ps' j .glues f hf)) βˆ™ sym (yo-natr refl))