module Cat.Functor.Hom {o h} (C : Precategory o h) where
The Hom functor🔗
We prove that the assignment of
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 = ext λ _ g → idl g
よ .F-∘ f g = ext λ _ h → sym (assoc f g h) よ
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