module Cat.Diagram.Product.Indexed {o β„“} (C : Precategory o β„“) where

Indexed productsπŸ”—

If a category admits a terminal object and binary products, then it admits products of any finite cardinality: iterate the binary product, and use the terminal object when there aren’t any objects. However, these two classes of limit do not let us speak of products of arbitrary cardinality, or, in the univalent context, indexed by types which are not sets.

That’s where products come in: Rather than having a functor giving the objects to take the limit over, we have an arbitrary map from to the space of objects of An indexed product for this β€œdiagram” is then an object admitting an universal family of maps

record is-indexed-product (F : Idx β†’ C.Ob) (Ο€ : βˆ€ i β†’ C.Hom P (F i))
  : Type (o βŠ” β„“ βŠ” level-of Idx) where
  no-eta-equality
  field
    tuple   : βˆ€ {Y} β†’ (βˆ€ i β†’ C.Hom Y (F i)) β†’ C.Hom Y P
    commute : βˆ€ {i} {Y} {f : βˆ€ i β†’ C.Hom Y (F i)} β†’ Ο€ i C.∘ tuple f ≑ f i
    unique  : βˆ€ {Y} {h : C.Hom Y P} (f : βˆ€ i β†’ C.Hom Y (F i))
            β†’ (βˆ€ i β†’ Ο€ i C.∘ h ≑ f i)
            β†’ h ≑ tuple f

  eta : βˆ€ {Y} (h : C.Hom Y P) β†’ h ≑ tuple Ξ» i β†’ Ο€ i C.∘ h
  eta h = unique _ Ξ» _ β†’ refl

  uniqueβ‚‚ : βˆ€ {Y} {g h : C.Hom Y P} β†’ (βˆ€ i β†’ Ο€ i C.∘ g ≑ Ο€ i C.∘ h) β†’ g ≑ h
  uniqueβ‚‚ {g = g} {h} eq = eta g βˆ™ ap tuple (funext eq) βˆ™ sym (eta h)

  hom-iso : βˆ€ {Y} β†’ C.Hom Y P ≃ (βˆ€ i β†’ C.Hom Y (F i))
  hom-iso = (Ξ» f i β†’ Ο€ i C.∘ f) , is-isoβ†’is-equiv Ξ» where
    .is-iso.inv β†’ tuple
    .is-iso.rinv x β†’ funext Ξ» i β†’ commute
    .is-iso.linv x β†’ sym (unique _ Ξ» _ β†’ refl)

A category admits indexed products (of level if, for any type and family there is an indexed product of

record Indexed-product (F : Idx β†’ C.Ob) : Type (o βŠ” β„“ βŠ” level-of Idx) where
  no-eta-equality
  field
    {Ξ F}      : C.Ob
    Ο€         : βˆ€ i β†’ C.Hom Ξ F (F i)
    has-is-ip : is-indexed-product F Ο€
  open is-indexed-product has-is-ip public
module _ {β„“'} {I : Type β„“'} (F : I β†’ C .Precategory.Ob) (ip : Indexed-product F) where
  private module ip = Indexed-product ip

  tuple∘ : βˆ€ {A B} (f : βˆ€ i β†’ C.Hom B (F i))
          {g : C.Hom A B}
        β†’ ip.tuple f C.∘ g ≑ ip.tuple Ξ» i β†’ f i C.∘ g
  tuple∘ f = ip.unique _ Ξ» i β†’ C.pulll ip.commute

Indexed-product-≃
  : βˆ€ {β„“ β„“'} {I : Type β„“} {J : Type β„“'} β†’ (e : I ≃ J)
  β†’ {F : I β†’ C.Ob} β†’ Indexed-product (F βŠ™ Equiv.from e) β†’ Indexed-product F
Indexed-product-≃ e {F} p = Ξ» where
  .Ξ F β†’ p .Ξ F
  .Ο€ j β†’ C.to (pathβ†’iso (ap F (e.Ξ· _))) C.∘ p .Ο€ (e.to j)
  .has-is-ip .tuple f β†’ p .tuple (f βŠ™ e.from)
  .has-is-ip .commute {f = f} β†’
    C.pullr (p .commute) βˆ™ from-pathp-to C _ (ap f (e.Ξ· _))
  .has-is-ip .unique f comm β†’ p .unique _ Ξ» j β†’
      ap (C._∘ _) (sym (from-pathp-to C _ (ap (p .Ο€) (e.Ξ΅ j)))
                  βˆ™ ap (Ξ» z β†’ C.to (pathβ†’iso (ap F z)) C.∘ p .Ο€ _) (e.zag j))
    βˆ™ comm (e.from j)
    where
      open Indexed-product
      open is-indexed-product
      module e = Equiv e

Lift-Indexed-product
  : βˆ€ {β„“} β„“' β†’ {I : Type β„“} β†’ {F : I β†’ C.Ob}
  β†’ Indexed-product {Idx = Lift β„“' I} (F βŠ™ Lift.lower)
  β†’ Indexed-product F
Lift-Indexed-product _ = Indexed-product-≃ (Lift-≃ e⁻¹)

is-indexed-product-is-prop
  : βˆ€ {β„“'} {Idx : Type β„“'}
  β†’ {F : Idx β†’ C.Ob} {Ξ F : C.Ob} {Ο€ : βˆ€ idx β†’ C.Hom Ξ F (F idx)}
  β†’ is-prop (is-indexed-product F Ο€)
is-indexed-product-is-prop {Idx = Idx} {F = F} {Ξ F = Ξ F} {Ο€ = Ο€} P Q = path where
  open is-indexed-product

  p : βˆ€ {X} β†’ (f : (i : Idx) β†’ C.Hom X (F i)) β†’ P .tuple f ≑ Q .tuple f
  p f = Q .unique f (Ξ» idx β†’ P .commute)

  path : P ≑ Q
  path i .tuple f = p f i
  path i .commute {i = idx} {f = f} =
    is-propβ†’pathp (Ξ» i β†’ C.Hom-set _ _ (Ο€ idx C.∘ p f i) (f idx))
      (P .commute)
      (Q .commute) i
  path i .unique {h = h} f q =
      is-prop→pathp (λ i → C.Hom-set _ _ h (p f i))
        (P .unique f q)
        (Q .unique f q) i

module _ {β„“'} {Idx : Type β„“'} {F : Idx β†’ C.Ob} {P P' : Indexed-product F} where
  private
    module P = Indexed-product P
    module P' = Indexed-product P'

  Indexed-product-path
    : (p : P.Ξ F ≑ P'.Ξ F)
    β†’ (βˆ€ idx β†’ PathP (Ξ» i β†’ C.Hom (p i) (F idx)) (P.Ο€ idx) (P'.Ο€ idx))
    β†’ P ≑ P'
  Indexed-product-path p q i .Indexed-product.Ξ F = p i
  Indexed-product-path p q i .Indexed-product.Ο€ idx = q idx i
  Indexed-product-path p q i .Indexed-product.has-is-ip =
    is-prop→pathp (λ i → is-indexed-product-is-prop {ΠF = p i} {π = λ idx → q idx i})
      P.has-is-ip
      P'.has-is-ip i

UniquenessπŸ”—

As is traditional with universal constructions, β€œhaving an indexed product for a diagram” is property of a category, not structure: Put another way, for any particular diagram, in a univalent category, there is (at most) a contractible space of indexed products of that diagram. And again as is traditional with universal constructions, the proof is surprisingly straightforward!

First, a general result: if two objects are both indexed products over the same family of objects, then those objects are isomorphic. This isomorphism is induced by the universal properties, and is readily seen to commute with both projections:

is-indexed-product→iso
  : βˆ€ {β„“'} {Idx : Type β„“'} {F : Idx β†’ C.Ob}
  β†’ {Ξ F Ξ F' : C.Ob}
  β†’ {Ο€ : βˆ€ i β†’ C.Hom Ξ F (F i)} {Ο€' : βˆ€ i β†’ C.Hom Ξ F' (F i)}
  β†’ is-indexed-product F Ο€
  β†’ is-indexed-product F Ο€'
  β†’ Ξ F C.β‰… Ξ F'
is-indexed-product→iso {π = π} {π' = π'} ΠF-prod ΠF'-prod =
  C.make-iso (Ξ F'.tuple Ο€) (Ξ F.tuple Ο€')
    (Ξ F'.uniqueβ‚‚ (Ξ» i β†’ C.pulll Ξ F'.commute βˆ™ Ξ F.commute βˆ™ sym (C.idr _)))
    (Ξ F.uniqueβ‚‚ Ξ» i β†’ C.pulll Ξ F.commute βˆ™ Ξ F'.commute βˆ™ sym (C.idr _))
  where
    module Ξ F = is-indexed-product Ξ F-prod
    module Ξ F' = is-indexed-product Ξ F'-prod

With that out of the way, we can proceed to show our original result! First, note that paths between indexed products are determined by a path between apices, and a corresponding path-over between projections. We can upgrade the iso from our previous lemma into a path, so all that remains is to construct the path-over.

Indexed-product-unique
  : βˆ€ {β„“'} {I : Type β„“'} (F : I β†’ C.Ob)
  β†’ is-category C β†’ is-prop (Indexed-product F)
Indexed-product-unique {I = I} F c-cat x y =
  Indexed-product-path
    (c-cat .to-path apices)
    pres
  where
    module x = Indexed-product x
    module y = Indexed-product y

    apices : x.Ξ F C.β‰… y.Ξ F
    apices = Indexed-product→iso x y

By the characterisation of paths-over in Hom-sets, we get paths-over between the projection maps and the product maps:

    module apices = C._β‰…_ apices
    abstract
      pres : βˆ€ j β†’ PathP (Ξ» i β†’ C.Hom (c-cat .to-path apices i) (F j)) (x.Ο€ j) (y.Ο€ j)
      pres j = Univalent.Hom-pathp-refll-iso c-cat x.commute

We can also prove the converse direction: if indexed products in are unique, then is univalent. In fact, we only need limits of one-object diagrams to be unique.

unique-products→is-category
  : ({x : C.Ob} β†’ is-prop (Indexed-product {Idx = ⊀} (Ξ» _ β†’ x)))
  β†’ is-category C
unique-products→is-category prop = cat where

Given an isomorphism we build two products for the one-object diagram one with apex itself and identity as projection, and one with apex and the given isomorphism as projection.

  module _ {a b : C.Ob} (is : a C.β‰… b) where
    open Indexed-product
    open is-indexed-product

    Pa : Indexed-product {Idx = ⊀} (Ξ» _ β†’ a)
    Pa .Ξ F = a
    Pa .Ο€ _ = C.id
    Pa .has-is-ip .tuple f = f _
    Pa .has-is-ip .commute = C.idl _
    Pa .has-is-ip .unique f p = sym (C.idl _) βˆ™ p _

    Pb : Indexed-product {Idx = ⊀} (Ξ» _ β†’ a)
    Pb .Ξ F = b
    Pb .Ο€ _ = is .C.from
    Pb .has-is-ip .tuple f = is .C.to C.∘ f _
    Pb .has-is-ip .commute = C.cancell (is .C.invr)
    Pb .has-is-ip .unique f p = sym (C.lswizzle (sym (p _)) (is .C.invl))

By uniqueness, the two products are equal, which gives us an equality lying over our isomorphism.

    path : a ≑ b
    path = ap Ξ F (prop Pa Pb)

    path-over : PathP (Ξ» i β†’ a C.β‰… path i) C.id-iso is
    path-over = C.β‰…-pathp-from _ _ (ap (Ξ» p β†’ p .Ο€ _) (prop Pa Pb))

  cat : is-category C
  cat .to-path = path
  cat .to-path-over = path-over

PropertiesπŸ”—

Let be a family of objects in If the the indexed products and exists, then they are isomorphic.

is-indexed-product-assoc
  : βˆ€ {ΞΊ ΞΊ'} {A : Type ΞΊ} {B : A β†’ Type ΞΊ'}
  β†’ {X : Ξ£ A B β†’ C.Ob}
  β†’ {ΠᡃᡇX : C.Ob} {ΠᡃΠᡇX : C.Ob} {ΠᡇX : A β†’ C.Ob}
  β†’ {πᡃᡇ : (ab : Ξ£ A B) β†’ C.Hom ΠᡃᡇX (X ab)}
  β†’ {πᡃ : βˆ€ a β†’ C.Hom ΠᡃΠᡇX (ΠᡇX a)}
  β†’ {πᡇ : βˆ€ a β†’ (b : B a) β†’ C.Hom (ΠᡇX a) (X (a , b))}
  β†’ is-indexed-product X πᡃᡇ
  β†’ is-indexed-product ΠᡇX πᡃ
  β†’ (βˆ€ a β†’ is-indexed-product (Ξ» b β†’ X (a , b)) (πᡇ a))
  β†’ ΠᡃᡇX C.β‰… ΠᡃΠᡇX

The proof is surprisingly straightforward: as indexed products are unique up to iso, it suffices to show that is an indexed product over

is-indexed-product-assoc {A = A} {B} {X} {ΠᡃΠᡇX = ΠᡃΠᡇX} {πᡃ = πᡃ} {πᡇ} Πᡃᡇ ΠᡃΠᡇ Πᡇ =
  is-indexed-productβ†’iso Πᡃᡇ Πᡃᡇ'
  where
    open is-indexed-product

We can construct projections by composing the projections out of each successive product.

    πᡃᡇ' : βˆ€ (ab : Ξ£ A B) β†’ C.Hom ΠᡃΠᡇX (X ab)
    πᡃᡇ' (a , b) = πᡇ a b C.∘ πᡃ a

The rest of the structure follows a similar pattern.

    Πᡃᡇ' : is-indexed-product X πᡃᡇ'
    Πᡃᡇ' .tuple f = ΠᡃΠᡇ .tuple Ξ» a β†’ Πᡇ a .tuple Ξ» b β†’ f (a , b)
    Πᡃᡇ' .commute = C.pullr (ΠᡃΠᡇ .commute) βˆ™ Πᡇ _ .commute
    Πᡃᡇ' .unique {h = h} f p =
      ΠᡃΠᡇ .unique _ Ξ» a β†’
      Πᡇ _ .unique _ Ξ» b β†’
      C.assoc _ _ _ βˆ™ p (a , b)

Categories with all indexed productsπŸ”—

has-products-indexed-by : βˆ€ {β„“} (I : Type β„“) β†’ Type _
has-products-indexed-by I = βˆ€ (F : I β†’ C.Ob) β†’ Indexed-product F

has-indexed-products : βˆ€ β„“ β†’ Type _
has-indexed-products β„“ = βˆ€ {I : Type β„“} β†’ has-products-indexed-by I

module Indexed-products
  {ΞΊ : Level}
  (has-ip : has-indexed-products ΞΊ)
  where
  module ∏ {Idx : Type ΞΊ} (F : Idx β†’ C.Ob) = Indexed-product (has-ip F)

  open ∏ renaming (commute to Ο€-commute; unique to tuple-unique) public