module Cat.Functor.Hom {o h} (C : Precategory o h) where

The Hom functorπŸ”—

The assignment of in a precategory thought of as a function of two arguments valued in sets, extends naturally to a bifunctor A morphism acts on the left by precomposition, and on the right by postcompoosition,

Hom[-,-] : Bifunctor (C ^op) C (Sets h)
Hom[-,-] = make-bifunctor record where
  Fβ‚€ X Y = el! (Hom X Y)

  lmap     f = _∘ f
  rmap     f = f ∘_

Both functoriality constraints, as well as the interchange law lrmap, boil down to the category laws.

  lmap-∘ f g = ext Ξ» h β†’
    h ∘ g ∘ f   β‰‘βŸ¨ assoc _ _ _ βŸ©β‰‘
    (h ∘ g) ∘ f ∎
  lmap-id    = ext Ξ» h β†’ idr _

  rmap-∘ f g = ext Ξ» h β†’ sym (assoc _ _ _)
  rmap-id    = ext Ξ» h β†’ idl _

  lrmap  f g = ext Ξ» h β†’ sym (assoc _ _ _)

As a bifunctor, has associated partial applications on either side. We use the intuitive names Hom-from and Hom-into, instead of directional names referring to β€œleft” and β€œright”.

open Bifunctor Hom[-,-] public using ()
  renaming (Left to Hom-into)

open Functor Hom[-,-] public using ()
  renaming (Fβ‚€ to Hom-from)

The Yoneda embeddingπŸ”—

The Yoneda embedding from a precategory into its category of presheaves is the functor which assigns to each object the partially applied of morphisms into that object.

Since is a functor it flips to give a functor this is Yoneda embedding.

γ‚ˆ : Bifunctor C (C ^op) (Sets h)
γ‚ˆ = Flip Hom[-,-]

open Functor γ‚ˆ renaming (Fβ‚€ to γ‚ˆβ‚€) using () public

The action of γ‚ˆ on morphisms 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 Ξ» where
  .is-iso.from nt β†’ nt .Ξ· _ id
  .is-iso.rinv nt β†’ ext Ξ» c g β†’
    nt .Ξ· _ id ∘ g   β‰‘βŸ¨ sym (nt .is-natural _ _ _) $β‚š _ βŸ©β‰‘
    nt .Ξ· c (id ∘ g) β‰‘βŸ¨ ap (nt .Ξ· c) (idl g) βŸ©β‰‘
    nt .η c g        ∎
  .is-iso.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 functor, thought of as an 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 : Functor (C ^op) Cat[ C , Sets h ]
γ‚ˆcov = Hom[-,-]

As expected, the covariant yoneda embedding is also fully faithful.

Hom[-,-]-is-fully-faithful : is-fully-faithful Hom[-,-]
Hom[-,-]-is-fully-faithful = is-iso→is-equiv λ where
  .is-iso.from nt β†’ nt .Ξ· _ id
  .is-iso.rinv nt β†’ ext Ξ» c g β†’ sym (nt .is-natural _ _ _) $β‚š _ βˆ™ ap (nt .Ξ· c) (idr g)
  .is-iso.linv h  β†’ idl h