module Cat.Diagram.Exponential
{o β} (C : Precategory o β) (cart : Cartesian-category C) whereExponential objectsπ
In a Cartesian category where by the usual internal logic dictionary we regard a morphism as an 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
open Cartesian-category cart
open Functor
open _β£_
private variable
A B : ObMoreover, exponential objects must satisfy a universal property relative to the product functor: if I have a derivation of a 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.from β unlambda
.is-iso.rinv x β sym (unique x refl)
.is-iso.linv x β commutes x uniqueβ : β {C} {m : Hom (C ββ _) _} mβ mβ
β ev β mβ ββ id β‘ m
β ev β mβ ββ id β‘ m
β mβ β‘ mβ
uniqueβ _ _ p q = unique _ p β sym (unique _ q)
lambda-ev : Ζ ev β‘ id
lambda-ev = sym (unique id (sym (intror (Γ-functor .F-id))))As 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 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 _)module _ where
is-exponential-is-prop : β {B^A} {ev : Hom (B^A ββ A) B} β is-prop (is-exponential B^A ev)
is-exponential-is-prop {B^A = B^A} {ev} x y = q where
open is-exponential
p : Path (β {C} m β Hom C B^A) (x .Ζ) (y .Ζ)
p i {C} m = y .unique (x .Ζ m) (x .commutes m) i
q : x β‘ y
q i .Ζ = p i
q i .commutes m =
is-propβpathp (Ξ» i β Hom-set _ _ (ev β p i m ββ id) m) (x .commutes m) (y .commutes m) i
q i .unique {m = m} m' q =
is-propβpathp (Ξ» i β Hom-set _ _ m' (p i m)) (x .unique m' q) (y .unique m' q) iPutting 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 _ A B where open Exponential (has-exp A B) renaming (B^A to [_,_]) using () public
unlambda-β : β {a b c d} (Ξ± : Hom a [ c , d ]) (Ξ² : Hom b a) β unlambda (Ξ± β Ξ²) β‘ unlambda Ξ± β Ξ² ββ id
unlambda-β Ξ± Ξ² = sym (Equiv.adjunctl (Ζ , lambda-is-equiv) (sym (unique (Ξ± β Ξ²) aux))) where
aux =
ev β (Ξ± β Ξ²) ββ id β‘β¨ ap (Ξ» x β ev β (Ξ± β Ξ²) ββ x) (sym $ idl id) β©
ev β (Ξ± β Ξ²) ββ (id β id) β‘β¨ ap (ev β_) (Γ-functor .F-β (Ξ± , id) (Ξ² , id)) β©
ev β Ξ± ββ id β Ξ² ββ id β‘β¨ assoc _ _ _ β©
(ev β Ξ± ββ id) β Ξ² ββ id β
Ζ-β' : β {a a' b b' c} (f : Hom (a ββ b) c) (g : Hom a' a) (h : Hom b' b)
β Ζ (f β g ββ h) β‘ Ζ (ev β id ββ h) β Ζ f β g
Ζ-β' f g h = sym (unique _ aux) where
aux =
unlambda (Ζ (ev β id ββ h) β Ζ f β g)
β‘β¨ unlambda-β (Ζ (ev β id ββ h)) (Ζ f β g) β©
unlambda (Ζ (ev β id ββ h)) β (Ζ f β g) ββ id
β‘β¨ pushl (commutes _) β©
ev β id ββ h β (Ζ f β g) ββ id
β‘β¨ ap (ev β_) (sym (Γ-functor .F-β (id , h) (Ζ f β g , id))) β©
ev β (id β (Ζ f β g)) ββ (h β id)
β‘β¨ (Ξ» i β ev β idl (Ζ f β g) i ββ idr h i) β©
ev β (Ζ f β g) ββ h
β‘β¨ (Ξ» i β ev β (Ζ f β g) ββ idl h (~ i)) β©
ev β (Ζ f β g) ββ (id β h)
β‘β¨ ap (ev β_) (Γ-functor .F-β (Ζ f , id) (g , h)) β©
ev β (Ζ f ββ id) β (g ββ h)
β‘β¨ pulll (commutes _) β©
f β g ββ h
β
Ζ-β-idl
: β {a b b' c} (f : Hom (a ββ b) c) (h : Hom b' b)
β Ζ (f β id ββ h) β‘ Ζ (ev β id ββ h) β Ζ f
Ζ-β-idl f h = Ζ-β' f id h β apβ _β_ refl (elimr refl)
Ζ-β-idr
: β {a a' b c} (f : Hom (a ββ b) c) (g : Hom a' a)
β Ζ (f β g ββ id) β‘ Ζ f β g
Ζ-β-idr f g = Ζ-β' f g id β eliml (ap Ζ (elimr (Functor.F-id Γ-functor)) β lambda-ev)
Ζ-β
: β {a b a' b' c} (f : Hom (a ββ b) c) (g : Hom a' a) (h : Hom b' b)
β Ζ (f β id ββ h) β g β‘ Ζ (f β g ββ h)
Ζ-β f g h = sym (Equiv.adjunctr (Ζ , lambda-is-equiv) (sym aux)) where
aux =
unlambda (Ζ (f β id ββ h) β g)
β‘β¨ unlambda-β _ _ β©
unlambda (Ζ (f β id ββ h)) β g ββ id
β‘β¨ pushl (commutes _) β©
f β id ββ h β g ββ id
β‘β¨ ap (f β_) (sym $ Γ-functor .F-β (id , h) (g , id)) β©
f β (id β g) ββ (h β id)
β‘β¨ apβ (Ξ» x y β f β x ββ y) (idl g) (idr h) β©
f β g ββ h
β open is-exponential
exponential-unique
: β {A B B^A B^A'} {ev : Hom (B^A ββ A) B} {ev' : Hom (B^A' ββ A) B}
β is-exponential B^A ev
β is-exponential B^A' ev'
β B^A β
B^A'
exponential-unique {ev = ev} {ev'} exp1 exp2 =
make-iso (exp2 .Ζ ev) (exp1 .Ζ ev')
(uniqueβ exp2 (exp2 .Ζ ev β exp1 .Ζ ev') id
( ap (ev' β_) (apβ _ββ_ refl (sym (idl id)) β Γ-functor .F-β _ _)
ββ pulll (exp2 .commutes _)
ββ exp1 .commutes _)
(elimr (Γ-functor .F-id)))
(uniqueβ exp1 (exp1 .Ζ ev' β exp2 .Ζ ev) id
( ap (ev β_) (apβ _ββ_ refl (sym (idl id)) β Γ-functor .F-β _ _)
ββ pulll (exp1 .commutes _)
ββ exp2 .commutes _)
(elimr (Γ-functor .F-id)))
Ζ-β
: β {A B C X A^X B^X} {evA : Hom (A^X ββ X) A} {evB : Hom (B^X ββ X) B}
β {f : Hom A B} {g : Hom C A^X}
β (exp : is-exponential B^X evB)
β exp .is-exponential.Ζ (f β evA) β g β‘ exp .is-exponential.Ζ (f β evA β g ββ id)
Ζ-β exb = is-exponential.unique exb _
( apβ _β_ refl (apβ _ββ_ refl (sym (idl id)) β Γ-functor .F-β _ _)
β extendl (is-exponential.commutes exb _))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 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
module _ (cc : Cartesian-closed) where
open Cartesian-closed cc [-,-]β : β {a a' b b'} β Hom b b' β Hom a' a β Hom [ a , b ] [ a' , b' ]
[-,-]β f g = Ζ (f β ev β β¨ Οβ , g β Οβ β©)
[-,-] : Functor (C ^op ΓαΆ C) C
[-,-] .Fβ (A , B) = [ 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 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 (products _ _) (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 .Ξ΅ 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π
open /-Obj
open /-Hom
open Pullback
module _ B (exp : β A β Exponential B A) where
private module _ A where open Exponential (exp A) renaming (B^A to -^Bβ) hiding (Ζ ; unlambda ; ev) public
private module _ {A} where open Exponential (exp A) renaming (unlambda to app) using (ev ; Ζ) publicWe 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 .com) β©ββ¨refl β©
Ζ ((y .map β h .map) β ev) β pb _ _ .pβ β‘β¨ pushl (-^B .F-β _ _) β©
Ζ (y .map β ev) β Ζ (h .map β ev) β pb _ _ .pβ β f .F-id = sym $ pb _ _ .Pullback.unique
(sym (eliml (-^B .F-id) β intror refl)) (sym (!-unique _))
f .F-β f g = sym $ pb _ _ .Pullback.unique
(pulll (pb _ _ .pββuniversal) ββ pullr (pb _ _ .pββuniversal) ββ pulll (sym (-^B .F-β _ _)))
(sym (!-unique _))
exponentiableβconstant-familyβ£product
: (pb : has-pullbacks C)
β constant-family products β£ exponentiableβproduct pb
exponentiableβconstant-familyβ£product pb =
hom-iso-invβadjoints (remβ _ .fst) (remβ _ .snd) nat where
module b = Functor (constant-family products)
module Ξ = Functor (exponentiableβproduct pb)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 .dom)))
β (Ζ (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) where
done : Ζ Οβ β ! β‘ Ζ Οβ
done = Exponential.unique (exp _) _ $
apβ _β_ refl (apβ _ββ_ refl (sym (idl id)) β Γ-functor .F-β _ _)
ββ pulll (Exponential.commutes (exp _) _)
ββ (Οβββ¨β© β idl _)
opaque
remβ : β {X} (f : /-Obj B)
β Hom X (Ξ .β f) β Slice C B .Precategory.Hom (b.β X) f
remβ {X = X} f =This is the last piece that we need to establish an equivalence between the 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 .dom))) (Ξ» h β Ξ£ (Hom X top) Ξ» h' β Ζ (f .map β ev) β h β‘ Ζ Οβ β h')
ββ¨ Ξ£-ap-snd (Ξ» x β Ξ£-contr-fst (hasβ€ X)) β©
Ξ£ (Hom X (-^B .Fβ (f .dom))) (Ξ» h β Ζ (f .map β ev) β h β‘ Ζ Οβ β !)
ββ¨ Ξ£-ap (Equiv.inverse (Ζ , lambda-is-equiv _)) (cohβ f) β©
Ξ£ (Hom (X ββ B) (f .dom)) (Ξ» h β f .map β h β‘ Οβ)
ββ¨ IsoβEquiv ((Ξ» x β record { com = x .snd }) , iso (Ξ» x β _ , x .com) (Ξ» _ β ext refl) (Ξ» _ β ext refl)) β©
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 products} {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.