module Cat.Functor.Hom {o h} (C : Precategory o h) where
The Hom functorπ
We prove that the assignment of
-sets
in a Precategory
is a functor
, specifically a
bifunctor from
to
.
The action of
on a morphism
is given by
;
Since
is acting by precomposition, the first coordinate is contravariant
().
: Functor ((C ^op) ΓαΆ C) (Sets h)
Hom[-,-] .Fβ (a , b) = el (Hom a b) (Hom-set a b)
Hom[-,-] .Fβ (f , h) g = h β g β f
Hom[-,-] .F-id = funext Ξ» x β ap (_ β_) (idr _) β idl _
Hom[-,-] .F-β (f , h) (f' , h') = funext Ξ» where
Hom[-,-] β (h β h') β g β f' β f β‘β¨ cat! C β©
g (h' β g β f') β f β h β
We also can define βpartially appliedβ versions of the hom functor:
_,-] : Ob β Functor C (Sets h)
Hom[.Fβ y = el (Hom x y) (Hom-set x y)
Hom[ x ,-] .Fβ f g = f β g
Hom[ x ,-] .F-id = funext (Ξ» f β idl f)
Hom[ x ,-] .F-β f g = funext Ξ» h β sym (assoc f g h) Hom[ x ,-]
The Yoneda embeddingπ
Abstractly and nonsensically, one could say that the Yoneda embedding
γ
is the exponential transpose of flipping
the Hom[-,-]
bifunctor. However, this
construction generates awful terms, so in the interest of
computational efficiency we build up the functor explicitly.
module _ where private
: Functor C (Cat[ C ^op , Sets h ])
γ = Curry Flip where
γ open import
.Functor.Bifunctor {C = C ^op} {D = C} {E = Sets h} Hom[-,-] Cat
We can describe the object part of this functor as taking an object to the functor of map into , with the transformation given by precomposition.
: Ob β Functor (C ^op) (Sets h)
γβ .Fβ x = el (Hom x c) (Hom-set _ _)
γβ c .Fβ f = _β f
γβ c .F-id = funext idr
γβ c .F-β f g = funext Ξ» h β assoc _ _ _ γβ c
We also define a synonym for γβ to better line up with the covariant direction.
_] : Ob β Functor (C ^op) (Sets h)
Hom[-,_] x = γβ x Hom[-,
The morphism part takes a map to the transformation given by postcomposition; This is natural because we must show , which is given by associativity in .
: Hom a b β γβ a => γβ b
γβ .Ξ· _ g = f β g
γβ f .is-natural x y g = funext Ξ» x β assoc f x g γβ f
The other category laws from ensure that this assignment of natural transformations is indeed functorial:
: Functor C Cat[ C ^op , Sets h ]
γ .Fβ = γβ
γ .Fβ = γβ
γ .F-id = Nat-path Ξ» _ i g β idl g i
γ .F-β f g = Nat-path Ξ» _ i h β assoc f g h (~ i) γ
The morphism mapping γβ
has an
inverse, given by evaluating the natural transformation with the
identity map; Hence, the Yoneda embedding functor is fully
faithful.
: is-fully-faithful γ
γ-is-fully-faithful = is-isoβis-equiv isom where
γ-is-fully-faithful open is-iso
: is-iso γβ
isom .inv nt = nt .Ξ· _ id
isom .rinv nt = ext Ξ» c g β
isom (sym (nt .is-natural _ _ _)) _ β ap (nt .Ξ· c) (idl g)
happly .linv _ = idr _ isom
The covariant yoneda embeddingπ
One common point of confusion is why category theorists prefer presheaves over covariant functors into . One key reason is that the yoneda embedding into presheaves is covariant, whereas the embedding into functors is contravariant. This makes the covariant yoneda embedding much less pleasant to work with, though we define it anyways for posterity.
: Hom a b β Hom-from b => Hom-from a
γcovβ .Ξ· _ g = g β f
γcovβ f .is-natural x y g = funext Ξ» x β sym (assoc g x f)
γcovβ f
: Functor (C ^op) Cat[ C , Sets h ]
γcov .Fβ = Hom-from
γcov .Fβ = γcovβ
γcov .F-id = ext Ξ» _ g β idr g
γcov .F-β f g = ext Ξ» _ h β (assoc h g f) γcov
As expected, the covariant yoneda embedding is also fully faithful.
: is-fully-faithful γcov
γcov-is-fully-faithful = is-isoβis-equiv isom where
γcov-is-fully-faithful open is-iso
: is-iso γcovβ
isom .inv nt = nt .Ξ· _ id
isom .rinv nt = ext Ξ» c g β
isom (nt .is-natural _ _ _) $β _ β ap (nt .Ξ· c) (idr g)
sym .linv _ = idl _ isom