module Cat.Displayed.Comprehension.Coproduct
  {ob β„“b od β„“d oe β„“e} {B : Precategory ob β„“b}
  {D : Displayed B od β„“d} {E : Displayed B oe β„“e}
  (D-fib : Cartesian-fibration D) (E-fib : Cartesian-fibration E)
  (P : Comprehension E)
  where

Coproducts in comprehension categoriesπŸ”—

Let be a comprehension category and a fibration over the same base. We say that has when:

  • For every and there exists an object

  • Every projection induces a cocartesian map

  • For every cubical diagram as below, if is cartesian in and are cartesian in and is cocartesian in then is cocartesian in

From a type-theoretic perspective, the first two conditions are rather straightforward. The first condition establishes that we have a type former that can quantify over objects of The second condition defines an introduction rule of the following form:

The elimination rule comes from each being cocartesian, as cocartesian maps satisfy a mapping-out universal property, exactly like a coproduct should!

However, at a glance, the last condition is somewhat mysterious. It says that cocartesian maps over projections are stable: but what does that have to do with coproducts? This, like many other questions in category theory, is elucidated by thinking type-theoretically: A cartesian map in a comprehension category is essentially a substitution: the stability condition says that the introduction rule for coproducts is actually type-theoretic: stable under substitution.

record has-comprehension-coproducts : Type (ob βŠ” β„“b βŠ” od βŠ” β„“d βŠ” oe βŠ” β„“e) where
  no-eta-equality
  field
    ∐ : βˆ€ {Ξ“} β†’ (x : E.Ob[ Ξ“ ]) (a : D.Ob[ Ξ“ β¨Ύ x ]) β†’ D.Ob[ Ξ“ ]
    ⟨_,_⟩
      : βˆ€ {Ξ“} β†’ (x : E.Ob[ Ξ“ ]) (a : D.Ob[ Ξ“ β¨Ύ x ])
      β†’ D.Hom[ Ο€αΆœ ] a (∐ x a)
    ⟨⟩-cocartesian
      : βˆ€ {Ξ“} β†’ (x : E.Ob[ Ξ“ ]) (a : D.Ob[ Ξ“ β¨Ύ x ])
      β†’ is-cocartesian D Ο€αΆœ ⟨ x , a ⟩
    cocartesian-stable
      : βˆ€ {Ξ“ Ξ” x y a a' b b'} {Οƒ : Hom Ξ“ Ξ”} {f : E.Hom[ Οƒ ] x y}
      β†’ {r : D.Hom[ Ο€αΆœ ] a a'} {h : D.Hom[ Οƒ ] a' b'}
      β†’ {g : D.Hom[ Οƒ β¨ΎΛ’ f ] a b} {s : D.Hom[ Ο€αΆœ ] b b'}
      β†’ is-cartesian E Οƒ f
      β†’ s D.∘' g D.≑[ sub-proj f ] h D.∘' r
      β†’ is-cocartesian D Ο€αΆœ s
      β†’ is-cartesian D (Οƒ β¨ΎΛ’ f) g
      β†’ is-cartesian D Οƒ h
      β†’ is-cocartesian D Ο€αΆœ r

  module ⟨⟩-cocartesian {Ξ“} (x : E.Ob[ Ξ“ ]) (a : D.Ob[ Ξ“ β¨Ύ x ]) =
    is-cocartesian (⟨⟩-cocartesian x a)

Now, some general facts about coproducts. To start, note that forming coproducts is a functorial operation. The proof is very routine β€” if you’ve seen one functoriality argument, you’ve seen them all β€” so we’ve hidden it from the page.1

  opaque
    ∐[_]
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a b : D.Ob[ Ξ“ β¨Ύ x ]}
      β†’ D.Hom[ id ] a b β†’ D.Hom[ id ] (∐ x a) (∐ x b)
    ∐[_] {Ξ“} {x} {a} {b} f =
      ⟨⟩-cocartesian.universal' x a id-comm-sym (⟨ x , b ⟩ D.∘' f)

    ∐[]-id : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} β†’ ∐[ D.id' {x = a} ] ≑ D.id'
    ∐[]-∘
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a b c : D.Ob[ Ξ“ β¨Ύ x ]}
      β†’ (f : D.Hom[ id ] b c) (g : D.Hom[ id ] a b)
      β†’ ∐[ f D↓.∘ g ] D.≑[ sym (idl _) ] ∐[ f ] D.∘' ∐[ g ]

We can also re-package the cocartesianness of to give a method for constructing morphisms given morphisms Type theoretically, this gives a much more familiar presentation of the elimination rule.

  opaque
    ∐-elim
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
      β†’ D.Hom[ id ] a (Ο€*.Fβ‚€ x b)
      β†’ D.Hom[ id ] (∐ x a) b
    ∐-elim {x = x} {a = a} {b = b} f =
      ⟨⟩-cocartesian.universal' x a id-comm-sym (D-fib.lifting Ο€αΆœ b D.∘' f)

    ∐-elim-β
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] a (Ο€*.Fβ‚€ x b))
      β†’ ∐-elim f D.∘' ⟨ x , a ⟩ D.≑[ id-comm-sym ] D-fib.lifting Ο€αΆœ b D.∘' f
    ∐-elim-β f = ⟨⟩-cocartesian.commutesp _ _ _ _

Putting on our type-theorist goggles, we’re still missing one thing to call this a proper elimination rule: stability under substitution. In the categorical world, that’s satisfied by the proof that the operation we just constructed is natural, given below.

    ∐-elim-natural
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a b : D.Ob[ Ξ“ β¨Ύ x ]} {c : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] b (Ο€*.β‚€ x c)) (g : D.Hom[ id ] a b)
      β†’ ∐-elim f D.∘' ∐[ g ] D.≑[ idl _ ] ∐-elim (f D↓.∘ g)
    ∐-elim-natural {x = x} {a = a} {b = b} {c = c} f g =
      ⟨⟩-cocartesian.uniquep x a _ _ _ (∐-elim f D.∘' ∐[ g ]) $
        ((∐-elim f) D.∘' ∐[ g ]) D.∘' ⟨ x , a ⟩     D.≑[]⟨ Dr.pullr[] _ (∐[]-natural g) ⟩D.≑[]
        ∐-elim f D.∘' ⟨ x , b ⟩ D.∘' g              D.≑[]⟨ Dr.extendl[] id-comm-sym (⟨⟩-cocartesian.commutesp x b _ _) ⟩D.≑[]
        D-fib.lifting Ο€αΆœ c D.∘' f D.∘' g            D.≑[]⟨ to-pathp (Dr.unwhisker-r (ap (Ο€αΆœ ∘_) (idl _)) (idl _)) ⟩D.≑[]
        D-fib.lifting Ο€αΆœ c D.∘' Dr.hom[] (f D.∘' g) ∎

Conversely, we can make maps given maps This isn’t quite, type-theoretically, as the elimination principle: it’s a weird mash-up of the introduction rule for coproducts, followed by substitution.

  opaque
    ∐-transpose
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
      β†’ D.Hom[ id ] (∐ x a) b
      β†’ D.Hom[ id ] a (Ο€*.β‚€ x b)
    ∐-transpose {x = x} {a = a} {b = b} f =
      D-fib.universal' Ο€αΆœ b id-comm (f D.∘' ⟨ x , a ⟩)

While ∐-transpose may not play an obvious type-theoretic role, it is extremely important categorically, since it is an inverse of ∐-elim! Moreover, it’s also natural, but that proof is also hidden from the page for brevity.

  opaque
    unfolding ∐-elim ∐-transpose
    ∐-elim-transpose
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] (∐ x a) b)
      β†’ ∐-elim (∐-transpose f) ≑ f
    ∐-elim-transpose {x = x} {a = a} {b = b} f = sym $
      ⟨⟩-cocartesian.uniquep x a _ _ _ f $ symP $
      D-fib.commutesp Ο€αΆœ b id-comm (f D.∘' ⟨ x , a ⟩)

    ∐-transpose-elim
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] a (Ο€*.Fβ‚€ x b))
      β†’ ∐-transpose (∐-elim f) ≑ f
    ∐-transpose-elim {x = x} {a = a} {b = b} f = sym $
      D-fib.uniquep Ο€αΆœ b _ _ _ f $ symP $
      ⟨⟩-cocartesian.commutesp x a id-comm-sym (D-fib.lifting Ο€αΆœ b D.∘' f)
  ∐-transpose-equiv
    : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b : D.Ob[ Ξ“ ]}
    β†’ is-equiv (∐-transpose {a = a} {b = b})
  ∐-transpose-equiv = is-isoβ†’is-equiv $
    iso ∐-elim ∐-transpose-elim ∐-elim-transpose

  opaque
    unfolding ∐-transpose
    ∐-transpose-naturall
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a b : D.Ob[ Ξ“ β¨Ύ x ]} {c : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] (∐ x b) c) (g : D.Hom[ id ] a b)
      β†’ ∐-transpose f D.∘' g D.≑[ idl _ ] ∐-transpose (f D↓.∘ ∐[ g ])
    ∐-transpose-naturall {x = x} {a = a} {b = b} {c = c} f g =
      D-fib.uniquep Ο€αΆœ c _ _ _ (∐-transpose f D.∘' g) $
        D-fib.lifting Ο€αΆœ c D.∘' ∐-transpose f D.∘' g D.≑[]⟨ Dr.pulll[] id-comm (D-fib.commutesp Ο€αΆœ c _ _) ⟩D.≑[]
        (f D.∘' ⟨ x , b ⟩) D.∘' g                    D.≑[]⟨ Dr.extendr[] _ (symP (∐[]-natural g)) ⟩D.≑[]
        (f D.∘' ∐[ g ]) D.∘' ⟨ x , a ⟩               D.≑[ ap (_∘ Ο€αΆœ) (idl _) ]⟨ to-pathp (Dr.unwhisker-l (ap (_∘ Ο€αΆœ) (idl _)) (idl _)) ⟩]
        (f D↓.∘ ∐[ g ]) D.∘' ⟨ x , a ⟩               ∎

    ∐-transpose-naturalr
      : βˆ€ {Ξ“} {x : E.Ob[ Ξ“ ]} {a : D.Ob[ Ξ“ β¨Ύ x ]} {b c : D.Ob[ Ξ“ ]}
      β†’ (f : D.Hom[ id ] b c) (g : D.Hom[ id ] (∐ x a) b)
      β†’ Ο€*.₁ x f D.∘' ∐-transpose g D.≑[ idl _ ] ∐-transpose (f D↓.∘ g)
    ∐-transpose-naturalr {x = x} {a = a} {b = b} {c = c} f g =
      D-fib.uniquep Ο€αΆœ c _ _ _ (Ο€*.F₁ x f D.∘' ∐-transpose g) $
        D-fib.lifting Ο€αΆœ c D.∘' Ο€*.₁ x f D.∘' ∐-transpose g     D.≑[]⟨ Dr.pulll[] _ (D-fib.commutesp Ο€αΆœ c id-comm _) ⟩D.≑[]
        (f D.∘' D-fib.lifting Ο€αΆœ b) D.∘' ∐-transpose g          D.≑[]⟨ Dr.extendr[] id-comm (D-fib.commutesp Ο€αΆœ b _ _) ⟩D.≑[]
        (f D.∘' g) D.∘' ⟨ x , a ⟩                               D.≑[ ap (_∘ Ο€αΆœ) (idl _) ]⟨ to-pathp (Dr.unwhisker-l (ap (_∘ Ο€αΆœ) (idl _)) (idl _)) ⟩]
        Dr.hom[ idl id ] (f D.∘' g) D.∘' ⟨ x , a ⟩              ∎

Next, we define an introduction rule for coproducts that also lets us apply a mediating substitution:

  opaque
    ⟨_⨾_⟩
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”}
      β†’ (f : E.Hom[ Οƒ ] x y) (a : D.Ob[ Ξ” β¨Ύ y ])
      β†’ D.Hom[ Ο€αΆœ ] (D*.β‚€ (Οƒ β¨ΎΛ’ f) a) (D*.β‚€ Οƒ (∐ y a))

    ⟨_β¨Ύ_⟩ {x = x} {y = y} {Οƒ = Οƒ} f a =
      D-fib.universal' Οƒ (∐ y a) (sym (sub-proj f)) $
      ⟨ y , a ⟩ D.∘' D-fib.lifting (Οƒ β¨ΎΛ’ f) a

    ⟨⨾⟩-weaken
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”}
      β†’ (f : E.Hom[ Οƒ ] x y) (a : D.Ob[ Ξ” β¨Ύ y ])
      β†’ D-fib.lifting Οƒ (∐ y a) D.∘' ⟨ f β¨Ύ a ⟩
      D.≑[ sym (sub-proj f) ] ⟨ y , a ⟩ D.∘' D-fib.lifting (Οƒ β¨ΎΛ’ f) a

    ⟨⨾⟩-weaken {y = y} {Οƒ = Οƒ} f a =
       D-fib.commutesp Οƒ (∐ y a) (symP (sub-proj f)) _

Because we have assumed that cocartesian maps are stable when pulled back along cartesian maps over projections2, this map is also cocartesian β€” and, you guessed it β€” the spiced-up introduction rule is also natural.

  opaque
    ⟨⨾⟩-cocartesian
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”} β†’ {f : E.Hom[ Οƒ ] x y}
      β†’ is-cartesian E Οƒ f β†’ (a : D.Ob[ Ξ” β¨Ύ y ])
      β†’ is-cocartesian D Ο€αΆœ ⟨ f β¨Ύ a ⟩
    ⟨⨾⟩-cocartesian {x = x} {y = y} {Οƒ = Οƒ} {f = f} cart a =
      cocartesian-stable cart
        (symP (⟨⨾⟩-weaken f a))
        (⟨⟩-cocartesian y a)
        (D-fib.cartesian (Οƒ β¨ΎΛ’ f) a)
        (D-fib.cartesian Οƒ (∐ y a))

  module ⟨⨾⟩-cocartesian
    {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”} {f : E.Hom[ Οƒ ] x y}
    (cart : is-cartesian E Οƒ f) (a : D.Ob[ Ξ” β¨Ύ y ])
    = is-cocartesian (⟨⨾⟩-cocartesian cart a)

This lets us extend a substitution into a substitution

  opaque
    ∐-sub
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”} {f : E.Hom[ Οƒ ] x y}
      β†’ is-cartesian E Οƒ f β†’ (a : D.Ob[ Ξ” β¨Ύ y ])
      β†’ D.Hom[ id ] (D*.β‚€ Οƒ (∐ y a)) (∐ x (D*.β‚€ (Οƒ β¨ΎΛ’ f) a))
    ∐-sub {x = x} {Οƒ = Οƒ} {f = f} cart a =
      ⟨⨾⟩-cocartesian.universalv cart a ⟨ x , (D*.β‚€ (Οƒ β¨ΎΛ’ f) a) ⟩

    ∐-sub-⟨⨾⟩
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”} {f : E.Hom[ Οƒ ] x y}
      β†’ (cart : is-cartesian E Οƒ f) β†’ (a : D.Ob[ Ξ” β¨Ύ y ])
      β†’ ∐-sub cart a D.∘' ⟨ f β¨Ύ a ⟩ D.≑[ idl _ ] ⟨ x , (D*.β‚€ (Οƒ β¨ΎΛ’ f) a) ⟩
    ∐-sub-⟨⨾⟩ cart a =
      ⟨⨾⟩-cocartesian.commutesv cart a _

    ∐-sub-natural
      : βˆ€ {Ξ“ Ξ” x y} {Οƒ : Hom Ξ“ Ξ”} {f : E.Hom[ Οƒ ] x y}
      β†’ {a b : D.Ob[ Ξ” β¨Ύ y ]}
      β†’ (cart : is-cartesian E Οƒ f)
      β†’ (g : D.Hom[ id ] a b)
      β†’ ∐-sub cart b D.∘' D*.₁ Οƒ ∐[ g ] ≑ ∐[ D*.₁ (Οƒ β¨ΎΛ’ f) g ] D.∘' ∐-sub cart a
    ∐-sub-natural {x = x} {y = y} {Οƒ = Οƒ} {f = f} {a = a} {b = b} cart g =
      ⟨⨾⟩-cocartesian.uniquepβ‚‚ cart a _ _ _ _ _
        (Dr.pullr[] _ (symP (⟨⨾⟩-natural g f))
         D.βˆ™[] Dr.pulll[] _ (⟨⨾⟩-cocartesian.commutesv cart b _))
        (Dr.pullr[] _ (⟨⨾⟩-cocartesian.commutesv cart a _)
         D.βˆ™[] ∐[]-natural (D*.₁ (Οƒ β¨ΎΛ’ f) g))

  1. As a reminder, you can choose to toggle hidden code on the sidebar.β†©οΈŽ

  2. what a mouthful!β†©οΈŽ