module Cat.Functor.Hom {o h} (C : Precategory o h) whereThe 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
().
Hom[-,-] : 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
  g β (h β h') β g β f' β f β‘β¨ cat! C β©
      h β (h' β g β f') β f βWe also can define βpartially appliedβ versions of the hom functor:
Hom[_,-] : Ob β Functor C (Sets h)
Hom[ x ,-] .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)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
      Cat.Functor.Bifunctor {C = C ^op} {D = C} {E = Sets h} Hom[-,-]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)
γβ c .Fβ x    = el (Hom x c) (Hom-set _ _)
γβ c .Fβ f    = _β f
γβ c .F-id    = funext idr
γβ c .F-β f g = funext Ξ» h β assoc _ _ _We also define a synonym for γβ to better line up with the covariant direction.
Hom[-,_] : Ob β Functor (C ^op) (Sets h)
Hom[-,_] x = γβ xThe 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
γβ f .Ξ· _ g            = f β g
γβ f .is-natural x y g = funext Ξ» x β assoc f x gThe 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-fully-faithful = is-isoβis-equiv isom where
  open is-iso
  isom : is-iso γβ
  isom .inv nt = nt .Ξ· _ id
  isom .rinv nt = ext Ξ» c g β
    happly (sym (nt .is-natural _ _ _)) _ β ap (nt .Ξ· c) (idl g)
  isom .linv _ = idr _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.
γcovβ : Hom a b β Hom-from b => Hom-from a
γcovβ f .Ξ· _ g = g β f
γcovβ f .is-natural x y g = funext Ξ» x β sym (assoc g x f)
γcov : 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)As expected, the covariant yoneda embedding is also fully faithful.
γcov-is-fully-faithful : is-fully-faithful γcov
γcov-is-fully-faithful = is-isoβis-equiv isom where
  open is-iso
  isom : is-iso γcovβ
  isom .inv nt = nt .Ξ· _ id
  isom .rinv nt = ext Ξ» c g β
    sym (nt .is-natural _ _ _) $β _ β ap (nt .Ξ· c) (idr g)
  isom .linv _ = idl _