module Topoi.Reasoning where

Reasoning in topoiπŸ”—

As mentioned in the overture on topos theory, categories of sheaves are incredibly nice categories to work in logically, mirroring many of the same properties of the category of Sets. This follows from the fact that they are reflective subcategories of presheaf categories, and those categories enjoy many of the exactness properties of by virtue of being functor categories.

This module provides a companion to the overture which makes it more convenient to reason about a particular sheaf topos by computing explicit descriptions of finite limits and colimits, and establishing the key exactness properties of a topos: Coproducts are disjoint, equivalence relations are effective, and colimits are stable under pullback.

module Sheaf-topos {o β„“} {𝒯 : Precategory o β„“} (T : Topos β„“ 𝒯) where
  open Cat 𝒯 public
  open _⊣_ (T .Topos.L⊣ι) public

  module L = Func (T .Topos.L)
  module L-lex = is-lex (T .Topos.L-lex)
  module ΞΉ = Func (T .Topos.ΞΉ)

  open Topos T using (site) public

  module Presh = Cat (PSh β„“ site)

  LΞΉ-iso : βˆ€ x β†’ is-invertible (counit.Ξ΅ x)
  Lι-iso x = iso→invertible
    (is-reflectiveβ†’counit-is-iso (T .Topos.L⊣ι) (T .Topos.has-ff))

  Ρ⁻¹ : Id => T .Topos.L F∘ T .Topos.ι
  Ρ⁻¹ = Cat._β‰…_.from (is-reflectiveβ†’counit-iso (T .Topos.L⊣ι) (T .Topos.has-ff))
  module Ρ⁻¹ = _=>_ Ρ⁻¹

  psh-equal : βˆ€ {X Y} {f g : Hom X Y} β†’ ΞΉ.₁ f ≑ ΞΉ.₁ g β†’ f ≑ g
  psh-equal = ff→faithful {F = T .Topos.ι} (T .Topos.has-ff)
Terminology

We will refer to the objects of the topos, as sheaves, and the objects of as presheaves. Correspondingly, the left adjoint functor is called sheafification.

LimitsπŸ”—

Since the sheafification functor is left exact and the inclusion functor is fully faithful (thus the adjunction counit is an isomorphism, c.f. LΞΉ-iso), we can compute limits directly in the presheaf category and sheafify. Unfolding the result of this procedure, rather than appealing to the equivalence yields much better computational properties. We do it by hand for the terminal object, binary products, and binary pullbacks.

  open Terminal
  terminal-sheaf : Terminal 𝒯
  terminal-sheaf .top = L.β‚€ (PSh-terminal {C = site} .top)
  terminal-sheaf .has⊀ = L-lex.pres-⊀ (PSh-terminal {C = site} .has⊀)

  product-sheaf : βˆ€ A B β†’ Product 𝒯 A B
  product-sheaf A B = product' where
    product-presheaf : Product (PSh β„“ site) (ΞΉ.β‚€ A) (ΞΉ.β‚€ B)
    product-presheaf = PSh-products {C = site} _ _

    open Product
    product' : Product 𝒯 A B
    product' .apex = L.β‚€ (product-presheaf .apex)
    product' .π₁ = counit.Ξ΅ _ ∘ L.₁ (product-presheaf .π₁)
    product' .Ο€β‚‚ = counit.Ξ΅ _ ∘ L.₁ (product-presheaf .Ο€β‚‚)
    product' .has-is-product =
      let
        prod =
          L-lex.pres-product
            (PSh-terminal {C = site} .has⊀)
            (product-presheaf .has-is-product)
      in is-product-iso (LΞΉ-iso _) (LΞΉ-iso _) prod

  open Binary-products 𝒯 product-sheaf public

The computation for finite connected limits (pullbacks, equalisers) is a bit more involved, but not by much:

  pullback-sheaf
    : βˆ€ {X Y Z} (f : Hom X Z) (g : Hom Y Z)
    β†’ Pullback 𝒯 f g
  pullback-sheaf f g = pullback' where
    pullback-presheaf : Pullback (PSh β„“ site) (ΞΉ.₁ f) (ΞΉ.₁ g)
    pullback-presheaf = PSh-pullbacks {C = site} _ _

    open Pullback
    open is-pullback
    module Pb = Pullback pullback-presheaf
    module lpb = is-pullback (L-lex.pres-pullback (pullback-presheaf .has-is-pb))

    pullback' : Pullback 𝒯 f g
    pullback' .apex = L.β‚€ Pb.apex
    pullback' .p₁ = counit.Ξ΅ _ ∘ L.₁ Pb.p₁
    pullback' .pβ‚‚ = counit.Ξ΅ _ ∘ L.₁ Pb.pβ‚‚
    pullback' .has-is-pb = pb' where
      pb' : is-pullback 𝒯 _ f _ g
      pb' .square = square' where abstract
        square' : f ∘ counit.Ξ΅ _ ∘ L.₁ Pb.p₁ ≑ g ∘ counit.Ξ΅ _ ∘ L.₁ Pb.pβ‚‚
        square' =
          f ∘ counit.Ξ΅ _ ∘ L.₁ Pb.p₁           β‰‘βŸ¨ extendl (sym (counit.is-natural _ _ _)) βŸ©β‰‘
          counit.Ξ΅ _ ∘ L.₁ (ΞΉ.₁ f) ∘ L.₁ Pb.p₁ β‰‘βŸ¨ refl⟩∘⟨ lpb.square βŸ©β‰‘
          counit.Ξ΅ _ ∘ L.₁ (ΞΉ.₁ g) ∘ L.₁ Pb.pβ‚‚ β‰‘βŸ¨ extendl (counit.is-natural _ _ _) βŸ©β‰‘
          g ∘ counit.Ξ΅ _ ∘ L.₁ Pb.pβ‚‚           ∎

      pb' .universal {p₁' = p₁'} {pβ‚‚'} p =
        lpb.universal {p₁' = Ρ⁻¹.Ξ· _ ∘ p₁'} {pβ‚‚' = Ρ⁻¹.Ξ· _ ∘ pβ‚‚'} path
        where abstract
          path : L.₁ (ΞΉ.₁ f) ∘ Ρ⁻¹.Ξ· _ ∘ p₁' ≑ L.₁ (ΞΉ.₁ g) ∘ Ρ⁻¹.Ξ· _ ∘ pβ‚‚'
          path =
            L.₁ (ΞΉ.₁ f) ∘ Ρ⁻¹.Ξ· _ ∘ p₁' β‰‘βŸ¨ extendl (sym (Ρ⁻¹.is-natural _ _ _)) βŸ©β‰‘
            Ρ⁻¹.Ξ· _ ∘ f ∘ p₁'           β‰‘βŸ¨ refl⟩∘⟨ p βŸ©β‰‘
            Ρ⁻¹.Ξ· _ ∘ g ∘ pβ‚‚'           β‰‘βŸ¨ extendl (Ρ⁻¹.is-natural _ _ _) βŸ©β‰‘
            L.₁ (ΞΉ.₁ g) ∘ Ρ⁻¹.Ξ· _ ∘ pβ‚‚' ∎

      pb' .pβ‚βˆ˜universal =
        pullr lpb.pβ‚βˆ˜universal βˆ™ cancell (LΞΉ-iso _ .is-invertible.invl)
      pb' .pβ‚‚βˆ˜universal =
        pullr lpb.pβ‚‚βˆ˜universal βˆ™ cancell (LΞΉ-iso _ .is-invertible.invl)
      pb' .unique p q = lpb.unique
        (sym ( apβ‚‚ _∘_ refl (sym p βˆ™ sym (assoc _ _ _))
             βˆ™ cancell (LΞΉ-iso _ .is-invertible.invr)))
        (sym ( apβ‚‚ _∘_ refl (sym q βˆ™ sym (assoc _ _ _))
             βˆ™ cancell (LΞΉ-iso _ .is-invertible.invr)))

  finitely-complete : Finitely-complete 𝒯
  finitely-complete .Finitely-complete.terminal = terminal-sheaf
  finitely-complete .Finitely-complete.products = product-sheaf
  finitely-complete .Finitely-complete.equalisers =
    with-pullbacks 𝒯 terminal-sheaf pullback-sheaf
      .Finitely-complete.equalisers
  finitely-complete .Finitely-complete.pullbacks = pullback-sheaf