Lecture 15

L15 168 Presheaf categories

op Let C be a small .Thefunctorcategory SetC is called the category of preseaves on C. ! objects are contravariant from C to ! are natural transformations

Much used in the semantics of various dependently-typed languages and logics.

L15 169 Yoneda op y:C → SetC

(where C is a small category) is the Curried version of the hom functor

HomC C × Cop ! Cop × C −− − −→ Set

L15 170 Yoneda functor op y:C → SetC

(where C is a small category) is the Curried version of the hom functor

HomC C × Cop ! Cop × C −− − −→ Set

op ! For each C-object !,theobjecty! ∈ SetC is the functor C( ,!) : Cop → Set given by

" %→ C(",!) $ ◦ # # %→ % %→ C(%,!) $

L15 170 Yoneda functor op y:C → SetC

(where C is a small category) is the Curried version of the hom functor

HomC C × Cop ! Cop × C −− − −→ Set

op ! For each C-object !,theobjecty! ∈ SetC is the functor C( ,!) : Cop → Set given by

" %→ C(",!) $ ◦ # # %→ # ∗ % %→ C(%,!) $

this is o!en wri"en as # ∗

L15 170 Yoneda functor op y:C → SetC

(where C is a small category) is the Curried version of the hom functor

HomC C × Cop ! Cop × C −− − −→ Set

# y# ! For each C- % −→ !,themorphismy% −−→ y! in op SetC is the whose component at any given " ∈ Cop is the function (y# ) y% (") ! y! (") C(",%) C(",!)

$ # ◦ $

L15 170 Yoneda functor op y:C → SetC

(where C is a small category) is the Curried version of the hom functor

HomC C × Cop ! Cop × C −− − −→ Set

# y# ! For each C-morphism % −→ !,themorphismy% −−→ y! in op SetC is the natural transformation whose component at any given " ∈ Cop is the function (y# ) y% (") ! y! (") C C this function is o!en (",%) (",!) wri"en as #∗ #∗ $ # ◦ $

L15 170 The For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &.

L15 171 The Yoneda Lemma For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &.

the value of & : Cop → Set at ! the set of natural transformations from the functor y! : Cop → Set to the functor & : Cop → Set

L15 171 The Yoneda Lemma For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &. Cop Definition of the function '!,& : Set (y!,&)→& (!): op for each ( :y! → & in SetC we have the function ( C(!,!) = y! (!) −−→" & (!) and define

'!,&(() " (! (id! )

L15 171 The Yoneda Lemma For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &. −1 SetCop Definition of the function '!,& : & (!)→ (y!,&): for each ) ∈ & (!), % ∈ C and # ∈ y! (% ) = C(%,!), & (# ) we get a & (!) −−−→ & (% ) in Set and hence & (# )())∈& (% );

L15 171 The Yoneda Lemma For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &. −1 SetCop Definition of the function '!,& : & (!)→ (y!,&): for each ) ∈ & (!), % ∈ C and # ∈ y! (% ) = C(%,!), & (# ) we get a & (!) −−−→ & (% ) in Set and hence & (# )())∈& (% );

Define '−1 ()) :y! (% )→& (% ) by !,& % ! " check this gives a '−1 ()) (# ) " & (# )()) natural transformation !,& % −1 '",# ()) :y! → & L15 ! " 171 ◦ −1 = Proof of '!,& '!,& id& (!) For any ) ∈ & (!) we have

−1 " −1 '!,& '!,&()) '!,&()) (id! ) by definition of '!,& ! ! " " ! " −1 & (id! )()) by definition of '!,& = id& (! ) ()) since & is a functor = )

L15 172 −1 ◦ = Cop Proof of '!,& '!,& idSet (y!,&)

$ op % For any y! −→ & in SetC and % −→ ! in C,wehave

−1 " −1 '",# '",# (() # '",# ((" (id" ))) # by definition of '",# & & ! " " ! " −1 # $ & (# )((" (id" )) by definition of '",# ∗ =(& (# (*+" )) by naturality of ( ∗ " (& (id" ◦ # ) by definition of #

= (& (# ) naturality of ( $! y! (% ) & (% )

% ∗ # (% )

y! (!) & (!) $"

L15 173 −1 ◦ = Cop Proof of '!,& '!,& idSet (y!,&)

$ op % For any y! −→ & in SetC and % −→ ! in C,wehave

−1 " −1 '",# '",# (() # '",# ((" (id" ))) # by definition of '",# & & ! " " ! " −1 # $ & (# )((" (id" )) by definition of '",# ∗ =(& (# (*+" )) by naturality of ( ∗ " (& (id" ◦ # ) by definition of #

= (& (# )

−1 so ∀(,%, ' '",# (() = (& ",# & ! " −1 # = $ so ∀(,'",# '",# (() (

−1 ◦ = so '",# '",## id. $

L15 173 The Yoneda Lemma For each small category C,eachobject! ∈ C and each op presheaf & ∈ SetC ,thereisabijectionofsets

Cop '!,& : Set (y!,&) ! & (!)

which is natural in both ! and &.

L15 174 Proof that '!,& is natural in &:

' op Given & −→ , in SetC ,havetoshowthat

op (",# SetC (y!,&) & (!)

'∗ '"

op SetC (y!,,) , (!) (",$

$ commutes in Set.Forally! −→ & we have

-" '",# (() " -" ((" (id" )) " # $ (- ◦ ()" (id" ) " '",) (- ◦ ()

" '",) (-∗ (())

L15 175 Proof that '!,& is natural in !: % Given % −→ ! in C,havetoshowthat

op (",# SetC (y!,&) & (!)

(y% )∗ # (% )

op SetC (y%,&) & (% ) (!,#

$ commutes in Set.Forally! −→ & we have

& (# )(('",# (()) " & (# )((" (id" )) ∗ = (& (# (id" )) by naturality of (

= (& (# )

= (& (#∗ (id& ))

" (( ◦ y# )& (id& )

" '&,# (( ◦ y# ) ∗ " '&,# ((y# ) (())

L15 176 Corollary of the Yoneda Lemma:

op the functor y:C → SetC is full and faithful.

In general, a functor & : C → D is ! faithful if for all !,% ∈ C the function C(!,%)→D(& (!),&(% )) # %→ & (# ) is injective: ∀#,#) ∈ C(!,%),&(# ) = & (# ))⇒# = # )

! full if the above functions are all surjective: ∀$ ∈ D(& (!),&(% )), ∃# ∈ C(!,%),&(# ) = $

L15 177 Corollary of the Yoneda Lemma:

op the functor y:C → SetC is full and faithful.

op Proof. From the proof of the Yoneda Lemma, for each & ∈ SetC we have a bijection −1 ((",#) Cop & (!) −−−−−−→ Set (y!,&) −1 By definition of ('",#) ,when& = y% the above function is equal to

op y% (!) = C(!,%)→SetC (y!,y% ) # %→ #∗ = y#

So, being a bijection, # %→ y# is both injective and surjective; so y is both faithful and full. #

L15 177 Recall (for a small category C): op Yoneda functor y:C → SetC Yoneda Lemma: there is a bijection op op SetC (y!,&) ! & (!) which is natural both in & ∈ SetC and ! ∈ C.

An application of the Yoneda Lemma: Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

L15 178 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

L15 179 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

Proof sketch. op Terminal object in SetC is the functor 1 : Cop → Set given by

1(!) " {0} terminal object in Set " %1(# ) id{0}

L15 179 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

Proof sketch. op Product of &,, ∈ SetC is the functor & × , : Cop → Set given by

(& × ,)(!) " & (!)×,(!) cartesian product of sets " %(& × ,)(# ) & (# )×,(# )

. . with projection morphisms & ←−1 & × , −→2 , given by the natural transformations whose components at ! ∈ C are the projection . . functions & (!) ←−1 & (!)×,(!) −→2 ,(!).

L15 179 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

Proof sketch. op We can work out what the value of the exponential ,& ∈ SetC at ! ∈ C has to be using the Yoneda Lemma:

Cop Cop ,& (!) ! Set (y!,,& ) ! Set (y! × &,,)

universal property of Yoneda Lemma the exponential

L15 179 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

Proof sketch. op We can work out what the value of the exponential ,& ∈ SetC at ! ∈ C has to be using the Yoneda Lemma:

Cop Cop ,& (!) ! Set (y!,,& ) ! Set (y! × &,,)

op We take the set SetC (y! × &,,) to be the definition of the value of ,& at !...

L15 179 op Exponential objects in SetC :

op ,& (!) " SetC (y! × &,,)

# y# op Given % −→ ! in C,wehavey% −−→ y! in SetC and hence

op op ,# (% ) " SetC (y% × &,,)→SetC (y! × &,,) " ,# (!) ( %→ ( ◦ (y# × id# ) We define

& ∗ , (# ) " (y# × id& )

Have to check that these definitions make ,& ino a functor Cop → Set.

L15 180 op Application morphisms in SetC : op Given &,, ∈ SetC ,theapplicationmorphism

app : ,& × & → ,

is the natural transformation whose component at ! ∈ C is the function

Cop app" (,# × &)(!) " ,# (!)×& (!) " Set (y! × &,,)×& (!) −− − −→ , (!)

defined by

" app! ((,)) (! (id! ,))

Have to check that this is natural in !.

L15 181 op operation in SetC :

( cur ( / × & −→ , %→ / −− − −→ ,& & ' & ' ( op Given / × & −→ , in SetC ,thecomponentofcur ( at ! ∈ C

(cur ()" Cop / (!) −−−−−−→ ,& (!) " Set (y! × &,,) is the function mapping each 0 ∈ / (!) to the natural transformation y! × & → , whose component at % ∈ C is the function (y! × &)(% ) " C(%,!)×& (% )→,(% ) defined by

((cur ()! (0))% (#,1) " (% (/ (# )(0),1)

L15 182 op Currying operation in SetC :

( cur ( / × & −→ , %→ / −− − −→ ,& & ' & '

((cur ()! (0))% (#,1) " (% (/ (# )(0),1)

Have to check that this is natural in % ,

then that (cur ()! is natural in !, - op then that cur ( is the unique morphism / −→ ,& in SetC satisfying app ◦(- × id& ) = (.

L15 182 Theorem. For each small category C,thecategory op SetC of presheaves is cartesian closed.

So we can interpret simply typed lambda calculus in any presheaf category. More than that, presheaf categories (usefully) model dependently-typed languages.

L15 183