module Cat.Instances.Presheaf.Exponentials {β„“} (C : Precategory β„“ β„“) where

Exponential objects in presheaf categoriesπŸ”—

This module presents a construction of exponential objects in presheaf categories. First, we’ll use the Yoneda lemma to divine what the answer should be, and then we’ll use that to finish the actual construction. First, fix a pair of presheaves and over some category and suppose that the exponential object exists.

module _ (A B : Functor (C ^op) (Sets β„“))
         (exp : Exponential Cat[ C ^op , Sets β„“ ] PSh-products PSh-terminal A B)
  where
  open Exponential exp

The Yoneda lemma says that the value of the assumed exponential object is the set of natural transformations In turn, the universal property of as an exponential tells us that this is equivalent to and this essentially fixes the value of

  _ : βˆ€ x β†’ ⌞ B^A .Fβ‚€ x ⌟ ≃ ((γ‚ˆβ‚€ C x βŠ—β‚€ A) => B)
  _ = Ξ» x β†’
    ⌞ B^A .Fβ‚€ x ⌟       β‰ƒβŸ¨ yo {C = C} B^A , yo-is-equiv _ βŸ©β‰ƒ
    (γ‚ˆβ‚€ C x => B^A)    β‰ƒΛ˜βŸ¨ Ζ› , lambda-is-equiv βŸ©β‰ƒΛ˜
    (γ‚ˆβ‚€ C x βŠ—β‚€ A) => B β‰ƒβˆŽ

Now that we know what the answer should be, we can fill in the details of the construction, which essentially work out to applying naturality and functoriality.

  PSh[_,_] : PSh.Ob
  PSh[_,_] .Fβ‚€ c = el ((γ‚ˆβ‚€ C c βŠ—β‚€ A) => B) Nat-is-set
  PSh[_,_] .F₁ f nt .Ξ· i (g , x) = nt .Ξ· i (f C.∘ g , x)
  PSh[_,_] .F₁ f nt .is-natural x y g = funext Ξ» (h , z) β†’
    nt .Ξ· y (f C.∘ h C.∘ g , A.₁ g z)    β‰‘βŸ¨ ap (nt .Ξ· y) (Ξ£-pathp (C.assoc _ _ _) refl) βŸ©β‰‘
    nt .Ξ· y ((f C.∘ h) C.∘ g , A.₁ g z)  β‰‘βŸ¨ nt .is-natural _ _ _ $β‚š _ βŸ©β‰‘
    B.₁ g (nt .Ξ· _ (f C.∘ h , z))        ∎
  PSh[_,_] .F-id = ext Ξ» f i g x β†’
    ap (f .Ξ· i) (Ξ£-pathp (C.idl _) refl)
  PSh[_,_] .F-∘ f g = ext Ξ» h i j x β†’
    ap (h .Ξ· i) (Ξ£-pathp (sym (C.assoc _ _ _)) refl)

All that remains is to show that, fixing this construction is functorial in which is essentially symbol shuffling; and to show that this functor is right adjoint to the β€œproduct with ” functor.

PSh-closed : Cartesian-closed (PSh β„“ C) PSh-products PSh-terminal
PSh-closed = cc where
  cat = PSh β„“ C

  module _ (A : PSh.Ob) where
    func : Functor (PSh β„“ C) (PSh β„“ C)
    func .Fβ‚€ = PSh[ A ,_]
    func .F₁ f .Ξ· i g .Ξ· j (h , x) = f .Ξ· _ (g .Ξ· _ (h , x))
    func .F₁ f .Ξ· i g .is-natural x y h = funext Ξ» x β†’
      ap (f .Ξ· _) (happly (g .is-natural _ _ _) _) βˆ™ happly (f .is-natural _ _ _) _
    func .F₁ nt .is-natural x y f = trivial!
    func .F-id = trivial!
    func .F-∘ f g = trivial!

    adj : Bifunctor.Left Γ—-functor A ⊣ func
    adj .unit .Ξ· x .Ξ· i a =
      NT (Ξ» j (h , b) β†’ x .F₁ h a , b) Ξ» _ _ _ β†’ funext Ξ» _ β†’
        Σ-pathp (happly (x .F-∘ _ _) _) refl
    adj .unit .Ξ· x .is-natural _ _ _ = ext Ξ» _ _ _ _ β†’ sym (x .F-∘ _ _ Β· _) ,β‚š refl
    adj .unit .is-natural x y f = ext Ξ» _ _ _ _ _ β†’ sym (f .is-natural _ _ _ $β‚š _) ,β‚š refl
    adj .counit .Ξ· _ .Ξ· _ x = x .fst .Ξ· _ (C.id , x .snd)
    adj .counit .Ξ· _ .is-natural x y f = funext Ξ» h β†’
      ap (h .fst .Ξ· _) (Ξ£-pathp C.id-comm refl) βˆ™ happly (h .fst .is-natural _ _ _) _
    adj .counit .is-natural x y f = trivial!
    adj .zig {A} = ext Ξ» x _ _ β†’ happly (F-id A) _ ,β‚š refl
    adj .zag {A} = ext Ξ» _ x i f g j β†’ x .Ξ· i (C.idr f j , g)

  cc : Cartesian-closed (PSh β„“ C) PSh-products PSh-terminal
  cc = product-adjoint→cartesian-closed (PSh ℓ C) _ _ func adj