module Cat.Displayed.Diagram.Total.Product whereopen β«HomTotal productsπ
module _ {ob βb oe βe} {B : Precategory ob βb} (E : Displayed B oe βe) where
  open Cat.Displayed.Reasoning E
  open Cat.Reasoning B
  private variable
    a x y p     : Ob
    a' x' y' p' : Ob[ a ]
    f g other   : Hom a x
    f' g'       : Hom[ f ] a' x'Let be a displayed category, and be a product diagram in A total diagram in is a diagram
satisfying a displayed version of the universal property of products.
  record is-product-over
      {Οβ : Hom p x} {Οβ : Hom p y} (prod : is-product B Οβ Οβ)
      (Οβ' : Hom[ Οβ ] p' x') (Οβ' : Hom[ Οβ ] p' y') : Type (ob β βb β oe β βe)
    where
    no-eta-equality
    open is-product prodMore explicitly, suppose that we had a triple displayed over as in the following diagram.
is a product, so there exists a unique that commutes with and
This leaves a conspicuous gap in the upstairs portion of the diagram between and is a total product precisely when we have a unique lift of that commutes with and
    field
      β¨_,_β©'
        : (f' : Hom[ f ] a' x') (g' : Hom[ g ] a' y')
        β Hom[ β¨ f , g β© ] a' p'
      Οβββ¨β©' : Οβ' β' β¨ f' , g' β©' β‘[ Οβββ¨β© ] f'
      Οβββ¨β©' : Οβ' β' β¨ f' , g' β©' β‘[ Οβββ¨β© ] g'
      unique'
        : {p1 : Οβ β other β‘ f} {p2 : Οβ β other β‘ g}
        β {other' : Hom[ other ] a' p'}
        β (p1' : (Οβ' β' other') β‘[ p1 ] f')
        β (p2' : (Οβ' β' other') β‘[ p2 ] g')
        β other' β‘[ unique p1 p2 ] β¨ f' , g' β©'    β¨_,_β©β
      : (f' : Hom[ Οβ β f ] a' x') (g' : Hom[ Οβ β f ] a' y')
      β Hom[ f ] a' p'
    β¨ f' , g' β©β = hom[ sym (unique refl refl) ] β¨ f' , g' β©'
    abstract
      Οβββ¨β©β : Οβ' β' β¨ f' , g' β©β β‘ f'
      Οβββ¨β©β = whisker-r _ β reindex _ _ β from-pathp[] Οβββ¨β©'
      Οβββ¨β©β : Οβ' β' β¨ f' , g' β©β β‘ g'
      Οβββ¨β©β = whisker-r _ β reindex _ _ β from-pathp[] Οβββ¨β©'A total product of and in consists of a choice of a total product diagram.
  record
    ProductP {x y} (prod : Product B x y) (x' : Ob[ x ]) (y' : Ob[ y ])
      : Type (ob β βb β oe β βe) where
    no-eta-equality
    open Product prod
    field
      apex' : Ob[ apex ]
      Οβ'   : Hom[ Οβ ] apex' x'
      Οβ'   : Hom[ Οβ ] apex' y'
      has-is-product'
        : is-product-over has-is-product Οβ' Οβ'
    open is-product-over has-is-product' publichas-products-over
  : β {o β o' β'} {B : Precategory o β}
  β Displayed B o' β'
  β has-products B
  β Type _
has-products-over {B = B} E prod = β {a b : β B β} (x : E Κ» a) (y : E Κ» b) β ProductP E (prod a b) x yTotal products and total categoriesπ
module _ {ob βb oe βe} {B : Precategory ob βb} {E : Displayed B oe βe} where
  open Cat.Reasoning B
  open Displayed E
  private module β«E = Cat.Reasoning (β« E)As the name suggests, a total product diagram in induces to a product diagram in the total category of
  is-total-productβtotal-is-product
    : β {x y p} {x' : Ob[ x ]} {y' : Ob[ y ]} {p' : Ob[ p ]}
    β {Οβ : β«E.Hom (p , p') (x , x')} {Οβ : β«E.Hom (p , p') (y , y')}
    β {prod : is-product B (Οβ .fst) (Οβ .fst)}
    β is-product-over E prod (Οβ .snd) (Οβ .snd)
    β is-product (β« E) Οβ ΟβThe proof is largely shuffling data about, so we elide the details.
  is-total-productβtotal-is-product {Οβ = Οβ} {Οβ = Οβ} {prod = prod} total-prod = β«prod where
    open is-product-over total-prod
    open is-product prod
    β«prod : is-product (β« E) Οβ Οβ
    β«prod .is-product.β¨_,_β© f g =
      β«hom β¨ f .fst , g .fst β© β¨ f .snd , g .snd β©'
    β«prod .is-product.Οβββ¨β© =
      β«Hom-path E Οβββ¨β© Οβββ¨β©'
    β«prod .is-product.Οβββ¨β© =
      β«Hom-path E Οβββ¨β© Οβββ¨β©'
    β«prod .is-product.unique p1 p2 =
      β«Hom-path E
        (unique (ap fst p1) (ap fst p2))
        (unique' (ap snd p1) (ap snd p2))Note that a product diagram in a total category does not necessarily yield a product diagram in the base category. For a counterexample, consider the following displayed category:
The total category is equivalent to the terminal category, and thus has products. However, the base category does not have products, as the uniqueness condition fails!
module
  Binary-products'
    {o β o' β'} {B : Precategory o β} {E : Displayed B o' β'} {fp : has-products B}
    (fp' : has-products-over E fp)
  where
  open Precategory B
  module _ {a b : Ob} (a' : E Κ» a) (b' : E Κ» b) where open ProductP (fp' a' b') renaming (apex' to _ββ'_) using () public
  module _ {a b : Ob} {a' : E Κ» a} {b' : E Κ» b} where open ProductP (fp' a' b') renaming (unique' to β¨β©'-unique) hiding (apex') public
record
  Cartesian-over
    {o β o' β'} {B : Precategory o β} (E : Displayed B o' β') (cart : Cartesian-category B)
    : Type (o β β β o' β β')
  where
  private module cart = Cartesian-category cart
  field
    terminal' : TerminalP E cart.terminal
    products' : has-products-over E cart.products
  open TerminalP terminal' hiding (hasβ€') public
  open Binary-products' products' public