jwiegley / category-theory

An axiom-free formalization of category theory in Coq for personal study and practical work
BSD 3-Clause "New" or "Revised" License
740 stars 67 forks source link

Universal property #117

Closed patrick-nicodemus closed 10 months ago

patrick-nicodemus commented 1 year ago

Let C be a category, and P a predicate on obj(C).

P is a universal property if there is a presheaf F : C^op -> Sets such that P(c) <-> F is representable by c, i.e. there is an isomorphism y(c) \cong F.

Actually, we require something stronger, that P(c) \cong NatIso(y(c), F) that is, we have a bijection (isomorphism of setoids) between P(c) and NatIso(y(c), F).

Class IsUniversalProperty (C : Category) (P : C → Type) (eqP : forall c, Setoid (P c)) :=
  {
    repr_functor : C ⟶ Sets ;
    repr_equivalence : forall c : C,
      @Isomorphism Sets 
        (Build_SetoidObject (P c) (eqP c))
        (Build_SetoidObject (Isomorphism [Hom c,─] repr_functor) _)
  }.

For example, if x and y are two objects in C, then the predicate P z := IsCartesianProduct x y z associates to z the set of pairs of maps (pi1 : z -> x , pi2 : z -> y) such that (z, pi1, pi2) has the universal mapping property of the Cartesian product.

P is a universal property, because a proof of P z corresponds to an isomorphism Hom(-, z) \cong Hom(- , x) \times Hom(-,y).

We have these useful theorems about universal properties -

Warning - there is one "admit" command in here for a subproof. I have a working proof for Coq 8.16 but unfortunately it does not work for Coq 8.15 or 8.14 as it takes advantage of the fact that setoid rewriting in 8.16 supports universe polymorphism. I have not had time to install Coq + Program for a lower version number and try to write it without this.