module Cat.Diagram.Exponential
  {o β} (C : Precategory o β) (fp : has-products C) (term : Terminal C) whereExponential objectsπ
In a category with all finite products (including a terminal object!), where by the usual internal logic dictionary we regard a morphism as an -term in context , the notion of exponential object captures what it means for an object to interpret function types. An exponential object for and is an object equipped with an evaluation map
standing for the essence of function application: if I have a function , and I have an , then application gives me an .
Moreover, exponential objects must satisfy a universal property relative to the product functor: if I have a derivation , of a -term in a context extended by , then I should be able to form the βabstractionβ .
record is-exponential (B^A : Ob) (ev : Hom (B^A ββ A) B) : Type (o β β) where
  no-eta-equality
  field
    Ζ        : β {Ξ} (m : Hom (Ξ ββ A) B) β Hom Ξ B^A
    commutes : β {Ξ} (m : Hom (Ξ ββ A) B) β ev β Ζ m ββ id β‘ m
    unique   : β {Ξ} {m : Hom (Ξ ββ _) _} m'
             β ev β m' ββ id β‘ m
             β m' β‘ Ζ mThe data above is an unpacked way of saying that the evaluation map extends to an equivalence between and : since being an equivalence is a proposition, once we have fixed the evaluation map, having abstractions is a property, not extra structure.
  unlambda : β {C} (m : Hom C B^A) β Hom (C ββ A) B
  unlambda m = ev β m ββ id
  lambda-is-equiv : β {C} β is-equiv (Ζ {C})
  lambda-is-equiv = is-isoβis-equiv Ξ» where
    .is-iso.inv    β unlambda
    .is-iso.rinv x β sym (unique x refl)
    .is-iso.linv x β commutes xAs an aside, let us remark that the evaluation map is sufficient to interpret the more familiar formation rule for function application,
by relativising to an arbitrary context through composition, and that this indeed interprets the -reduction rule:
  private
    app : β {Ξ} (f : Hom Ξ B^A) (x : Hom Ξ A) β Hom Ξ B
    app f x = ev β f ββ id β β¨ id , x β©
    beta : β {Ξ} (f : Hom (Ξ ββ A) B) (x : Hom Ξ A)
         β app (Ζ f) x β‘ f β β¨ id , x β©
    beta f x = pulll (commutes _)Putting this data together, we can define an exponential object to be a pair , with a witness that supports abstraction.
  record Exponential (A B : Ob) : Type (o β β) where
    no-eta-equality
    field
      B^A        : Ob
      ev         : Hom (B^A ββ A) B
      has-is-exp : is-exponential B^A ev
    open is-exponential has-is-exp publicSince a finite-products category is called Cartesian monoidal, a finite-products category where every pair of objects has an exponential is called Cartesian closed, and we abbreviate the phrase βCartesian closed categoryβ to βCCCβ.
  record Cartesian-closed : Type (o β β) where
    no-eta-equality
    field has-exp : β A B β Exponential A B
    module _ {A} {B} where open Exponential (has-exp A B) hiding (B^A) public
    module Exp A B = Exponential (has-exp A B)The connection between Cartesian closed categories and the lambda calculus is fundamental: however, it would take us too far afield of the basic properties of CCCs to discuss that in this module. You can find extended discussion, and an implementation, in the page on simply typed lambda calculus.
Functorialityπ
In a Cartesian closed category, we can think of the exponential-assigning operation as an internalised analogue of the -functor. In the same way that a pair of morphisms and would act on the ordinary sets by composition, they act on internal homs, too, defining a mapping .
  [-,-]β : β {a a' b b'} β Hom b b' β Hom a' a β Hom (Exp.B^A a b) (Exp.B^A a' b')
  [-,-]β f g = Ζ (f β ev β β¨ Οβ , g β Οβ β©)
  [-,-] : Functor (C ^op ΓαΆ C) C
  [-,-] .Fβ (A , B) = Exp.B^A A B
  [-,-] .Fβ (f , g) = [-,-]β g fThrough some calculations that are just annoying enough to stun the unsuspecting reader, we can show that this is indeed a functor . With a bit more effort, we can show that our defining equivalence between the -sets and satisfies the naturality condition required to to characterise as the right adjoint to .
  [-,-] .F-id =
    Ζ (id β ev β β¨ Οβ , id β Οβ β©) β‘β¨ ap Ζ (idl _ β ap (ev β_) (sym (apβ β¨_,_β© (idl _) refl))) β©
    Ζ (ev β id ββ id)              β‘Λβ¨ unique id refl β©
    id                             β
  [-,-] .F-β (f , g) (f' , g') = sym $ unique _ $
    ev β β¨ (Ζ (g β ev β β¨ Οβ , f β Οβ β©) β Ζ (g' β ev β β¨ Οβ , f' β Οβ β©)) β Οβ , id β Οβ β© β‘β¨ reflβ©ββ¨ apβ _ββ_ refl (introl refl) β Γ-functor .F-β _ _ β©
    ev β Ζ (g β ev β β¨ Οβ , f β Οβ β©) ββ id β Ζ (g' β ev β β¨ Οβ , f' β Οβ β©) ββ id          β‘β¨ pulll (commutes _) β©
    (g β ev β β¨ Οβ , f β Οβ β©) β Ζ (g' β ev β β¨ Οβ , f' β Οβ β©) ββ id                       β‘β¨ pullr (pullr (apβ _β_ (apβ β¨_,_β© (introl refl) refl) refl β sym (Bifunctor.firstβsecond Γ-functor))) β©
    g β ev β Ζ (g' β ev β β¨ Οβ , f' β Οβ β©) ββ id β id ββ f                                 β‘β¨ reflβ©ββ¨ pulll (commutes _) β©
    g β (g' β ev β β¨ Οβ , f' β Οβ β©) β id ββ f                                              β‘β¨ pulll refl β extendr (pullr (pullr (Product.unique (fp _ _) _ (pulll Οβββ¨β© Β·Β· Οβββ¨β© Β·Β· idl _) (pulll Οβββ¨β© β extendr Οβββ¨β©)))) β©
    (g β g') β ev β β¨ Οβ , (f' β f) β Οβ β©                                                  β
  productβ£exponential : β {A} β Bifunctor.Left Γ-functor A β£ Bifunctor.Right [-,-] A
  productβ£exponential {A} = hom-isoβadjoints Ζ lambda-is-equiv nat where
    module _ {a b c d} (g : Hom a b) (h : Hom c d) (x : Hom (d ββ A) a) where
      nat : Ζ (g β x β β¨ h β Οβ , id β Οβ β©) β‘ Ζ (g β ev β β¨ Οβ , id β Οβ β©) β Ζ x β h
      nat = sym $ unique _ $
        ev β (Ζ (g β ev β β¨ Οβ , id β Οβ β©) β Ζ x β h) ββ id        β‘β¨ reflβ©ββ¨ apβ _ββ_ refl (introl refl) β Γ-functor .F-β _ _ β©
        ev β Ζ (g β ev β β¨ Οβ , id β Οβ β©) ββ id β (Ζ x β h) ββ id  β‘β¨ pulll (commutes _) β©
        (g β β ev β β¨ Οβ , id β Οβ β© β) β (Ζ x β h) ββ id           β‘β¨ ap! (elimr (apβ β¨_,_β© (introl refl) refl β Γ-functor .F-id)) β©
        (g β ev) β (Ζ x β h) ββ id                                  β‘β¨ pullr (apβ _β_ refl (Bifunctor.firstβfirst Γ-functor)) β©
        g β ev β Ζ x ββ id β h ββ id                                β‘β¨ reflβ©ββ¨ pulll (commutes _) β©
        g β x β h ββ id                                             βFrom an adjunctionπ
As a converse to the results above, if each product functor has a right adjoint , then is a Cartesian closed category, with the object serving as the exponential. This means that we can prove that a category is Cartesian closed by appealing to general facts about the existence of right adjoints, if any apply.
product-adjointβcartesian-closed
  : (-^_ : Ob β Functor C C)
  β (β A β Bifunctor.Left Γ-functor A β£ -^ A)
  β Cartesian-closed
product-adjointβcartesian-closed Aβ adj = cc where
  open Exponential
  open is-exponential
  exp : β A B β Exponential A B
  exp A B .B^A = Aβ A .Fβ B
  exp A B .ev = adj A .counit.Ξ΅ B
  exp A B .has-is-exp .Ζ          = L-adjunct (adj A)
  exp A B .has-is-exp .commutes m = R-L-adjunct (adj A) m
  exp A B .has-is-exp .unique m' x = sym $
    Equiv.injectiveβ (_ , R-adjunct-is-equiv (adj A))
      (R-L-adjunct (adj A) _) x
  cc : Cartesian-closed
  cc .Cartesian-closed.has-exp = expExponentiable objectsπ
We refer to an object as exponentiable if, for every other , the exponential object exists. This means that we have a right adjoint to the functor , by the discussion above. It will, however, be more useful to us to characterise exponentiability of by a condition on the slice category .
  -^B : Functor C C
  -^B .Fβ = -^Bβ
  -^B .Fβ h = Ζ (h β ev)
  -^B .F-id = ap Ζ (idl ev) β lambda-ev _
  -^B .F-β f g = sym $ Exponential.unique (exp _) _
    (  apβ _β_ refl (apβ _ββ_ refl (introl refl) β Γ-functor .F-β _ _)
    Β·Β· pulll (Exponential.commutes (exp _) _)
    Β·Β· extendr (Exponential.commutes (exp _) _))Recall the constant families functor , which sends an object to the product projection . Following (Johnstone 2002, A1.5.2), we have the following characterisation of exponentiability: In a category with pullbacks, an object is exponentiable iff. we have a right adjoint functor .
Suppose is exponentiable. The value on a family is defined to be the pullback
where the map , on the right, is the action of on . An application of the universal properties at hand shows that we can extend maps over to maps . The calculation that this is functorial is routine, so we omit it from the page.
  exponentiableβproduct
    : has-pullbacks C
    β Functor (Slice C B) C
  exponentiableβproduct pb = f where
    f : Functor (Slice C B) C
    f .Fβ h = pb {B = top} (-^B .Fβ (h .map)) (Ζ Οβ) .apex
    f .Fβ {x} {y} h = pb _ _ .universal (sym p) where abstract
      p : Ζ Οβ β !  β‘ -^B .Fβ (y .map) β -^B .Fβ (h .map) β pb {B = top} (-^B .Fβ (x .map)) (Ζ Οβ) .pβ
      p = Ζ Οβ β !                                         β‘β¨ ap (Ζ Οβ β_) (!-unique _) β©
          Ζ Οβ β pb _ _ .pβ                                β‘Λβ¨ pb _ _ .square β©
          Ζ (x .map β ev) β pb _ _ .pβ                     β‘Λβ¨ ap (-^B .Fβ) (h .commutes) β©ββ¨refl β©
          Ζ ((y .map β h .map) β ev) β pb _ _ .pβ          β‘β¨ pushl (-^B .F-β _ _) β©
          Ζ (y .map β ev) β Ζ (h .map β ev) β pb _ _ .pβ   βIt remains to prove that this functor is actually a right adjoint to the constant-families functor like we had claimed. We start with an elementary observation: given maps and , asking for
is equivalent to asking for
which is in turn equivalent to asking that be a map , over .
    cohβ : β {X} (f : /-Obj B) (q : Hom X (-^Bβ (f .domain)))
         β (Ζ (f .map β ev) β q β‘ Ζ Οβ β !)
         β (f .map β app q β‘ Οβ)
    cohβ f h = prop-ext!
      (Ξ» p β Equiv.injective (_ , lambda-is-equiv _) (sym (Ζ-β (has-is-exp _)) Β·Β· p Β·Β· done))
      (Ξ» p β Ζ-β (has-is-exp _) Β·Β· ap Ζ p Β·Β· sym done)This is the last piece that we need to establish an equivalence between the -sets and , and even though it factors through the rather complicated path displayed below, it definitionally sends to
Having this very simple computational description will greatly simplify the proof that this meandering equivalence is actually natural β and that naturality is all that stands between us and the adjunction weβve been chasing.
        Hom X (Ξ .β f)
          ββ¨ Pullback.pullback-univ (pb _ _) β©
        Ξ£ (Hom X (-^B .Fβ (f .domain))) (Ξ» h β Ξ£ (Hom X top) Ξ» h' β Ζ (f .map β ev) β h β‘ Ζ Οβ β h')
          ββ¨ Ξ£-ap-snd (Ξ» x β Ξ£-contr-eqv (hasβ€ X)) β©
        Ξ£ (Hom X (-^B .Fβ (f .domain))) (Ξ» h β Ζ (f .map β ev) β h β‘ Ζ Οβ β !)
          ββ¨ Ξ£-ap (Equiv.inverse (Ζ , lambda-is-equiv _)) (cohβ f) β©
        Ξ£ (Hom (X ββ B) (f .domain)) (Ξ» h β f .map β h β‘ Οβ)
          ββ¨ IsoβEquiv ((Ξ» x β record { commutes = x .snd }) , iso (Ξ» x β _ , x .commutes) (Ξ» _ β trivial!) (Ξ» _ β trivial!)) β©
        Slice C B .Precategory.Hom (b.β X) f
          ββ
      remβ-Ξ² : β {X} (f : /-Obj B) (h : Hom X (Ξ .β f))
             β Equiv.to (remβ f) h .map β‘ app (pb _ _ .pβ β h)
      remβ-Ξ² f h = refl
    nat : hom-iso-inv-natural {L = constant-family fp} {R = exponentiableβproduct pb} (remβ _ .fst)
    nat g h x = ext $
     remβ _ .fst (Ξ .β g β x β h) .map                           β‘β¨ remβ-Ξ² _ _ β©
     app (pb _ _ .pβ β Ξ .β g β x β h)                           β‘β¨ ap app (pulll (pb _ _ .pββuniversal β Ζ-β {f = g .map} {g = pb _ _ .pβ} (has-is-exp _))) β©
     app (Ζ (g .map β ev β pb _ _ .pβ ββ id) β x β h)           β‘β¨ apβ _β_ refl (apβ _ββ_ refl (sym (idl id)) β Γ-functor .F-β _ _) β pulll refl β©
     app (Ζ (g .map β ev β pb _ _ .pβ ββ id)) β (x β h) ββ id   β‘β¨ apβ _β_ (Equiv.Ξ· (_ , lambda-is-equiv _) _) refl β©
     (g .map β ev β pb _ _ .pβ ββ id) β (x β h) ββ id           β‘β¨ pullr (pullr (sym (Γ-functor .F-β _ _) β apβ _ββ_ (assoc _ _ _) refl β Γ-functor .F-β _ _)) β©
     g .map β ev β (pb _ _ .pβ β x) ββ id β h ββ id             β‘β¨ reflβ©ββ¨ (pulll refl β apβ _β_ refl (apβ β¨_,_β© refl (idl _))) β©
     g .map β (ev β (pb _ _ .pβ β x) ββ id) β b.β h .map        β‘β¨ apβ _β_ refl (apβ _β_ (sym (remβ-Ξ² _ _)) refl) β©
     g .map β remβ _ .fst x .map β b.β h .map                   βReferences
- Johnstone, Peter T. 2002. Sketches of an Elephant: a Topos Theory Compendium. Oxford Logic Guides. New York, NY: Oxford Univ. Press. https://cds.cern.ch/record/592033.