module Cat.Monoidal.Instances.Day
  {β„“} {C : Precategory β„“ β„“} (cmon : Monoidal-category C)
  where

The Day convolution productπŸ”—

The Day convolution monoidal structure on is the free cocompletion of a small monoidal category within the context of monoidal categories: its monoidal cocompletion. This uniquely determines the construction of which is perhaps sufficient motivation to a category theorist. However, it’s worth pointing out that the Day convolution comes up in practice surprisingly often, so that the motivation for this page does not rest entirely on abstract nonsense. Here are a few examples, before we get started:

  • Automata theory: If we have a set which we call the alphabet, then, as usual, we call a subset a language on Languages are closed under the generic operations of intersection and union of subsets, but we also have an operation specific to this domain: concatenation, which arises from the free monoid structure on

    More concretely, the concatenation is the subset which, expressed as a predicate, has value

    That is, the words belonging to are precisely those which decompose as a concatenation of a word from followed by a word from The operation of concatenation preserves joins in each variable: We can calculate

    and the other variable is symmetric. To give a concrete example, we can define the Kleene star where denotes the composition. Then our cocontinuity result says that we can compute concatenation with a star as a union of simpler concatenations. For example, an enumeration of starts

  • Algebra: if we have a group and a ring there is a universal way to equip the free module with a multiplication that makes it into a ring, and where this multiplication is also in each variable: the group , which we also refer to as For simplicity, let us assume that is a finite group.

    Note that, since is finite, we can take the elements of to simply be arbitrary functions If we think of as a polynomial, then we associate to it the function that sends each to the element which appears as its coefficient. In the other direction, an assignment of coefficients determines the polynomial

    The multiplication on is determined uniquely by the requirement that it extends the multiplication on in an way: for polynomials we should have

    It is not immediately obvious that we can rewrite this double summation in β€œcoefficient form”. But if we recall the diagonal function defined so that if (and otherwise), then we can express this as

    since, intuitively, we have = since, for each value of if we do not have then the summand is equal to zero.

Drawing a generalisation from the cases above, we can equip the collection of functions with a monoid structure whenever and are monoids, and admits an operation for aggregation over , to play the role of the existential quantifier and summation. Writing for this aggregation operation, the product is given pointwise by

This operation is generally referred to as the convolution product of and and it can be seen as the special case of the Day convolution where the domain is a discrete category.

For those curious but unfamiliar with the abstract nonsense, we should explain what, exactly, is meant by monoidal cocompletion: in addition to showing that is cocomplete, and equipping it with a monoidal structure we must show that these behave nicely together:
  • The tensor product we construct must be cocontinuous in each variable;

  • Our chosen cocompletion which in this case is the Yoneda embedding must be a strong monoidal functor: We should have 1

As usual when we have an object defined by a universal property, the Day convolution monoidal structure is unique: making this particular case explicit, given any other monoidal cocompletion we have a unique equivalence of monoidal categories Among the univalent monoidal categories, we may sharpen this result to saying that has a contractible space of monoidal cocompletions.

The constructionπŸ”—

We will interpret the formula above literally, relying on the fact that coends are also written with an integral sign. To generalise away from a discrete domain, we must express the idea of decomposing an object into parts without the use of equality. An obvious idea would be isomorphism, but this turns out to be too strong: we can simply take the product with the into the product:

\ Warning

It’s worth taking a second to read the formalised definition, below, if you are unfamiliar with coends. We must express the β€œintegrand” as a functor This provides us with β€œpolarised” versions of the variables which we write and

We then distribute these variables according to the polarities of each functor. Since is covariant in its second argument, it sees but the presheaves are contravariant, so we have factors and

module Day (X Y : ⌞ PSh β„“ C ⌟) where
  Day-diagram : Ob β†’ Functor ((C Γ—αΆœ C) ^op Γ—αΆœ (C Γ—αΆœ C)) (Sets β„“)
  ∣ Day-diagram c .Fβ‚€ ((c₁⁻ , c₂⁻) , c₁⁺ , c₂⁺) ∣ = Hom c (c₁⁺ βŠ— c₂⁺) Γ— (X Κ» c₁⁻) Γ— (Y Κ» c₂⁻)
  opaque
    Day-coend : (c : Ob) β†’ Coend (Day-diagram c)
    Day-coend c = Set-coend (Day-diagram c)

We shall now repeat some of our knowledge about coends valued in sets, but specialised to the case of the Day convolution. First, we note that we can write the elements of the coend (at as triples where and

    day : {i a b : Ob} (h : Hom i (a βŠ— b)) (x : X Κ» a) (y : Y Κ» b) β†’ Day.nadir Κ» i
    day h x y = inc ((_ , _) , h , x , y)

Moreover, these triples have identifications generated by letting be whenever these both make sense. More generally, we have equal to whenever

    day-glue
      : {i a b a' b' : Ob} {f : Hom a' a} {g : Hom b' b} {h : Hom i (a' βŠ— b')} {x : X Κ» a} {y : Y Κ» b}
      β†’ {fgh : Hom i (a βŠ— b)} (p : fgh ≑ (f βŠ—β‚ g) ∘ h)
      β†’ day fgh x y ≑ day h (X .F₁ f x) (Y .F₁ g y)
    day-glue {i} {a} {b} {a'} {b'} {f} {g} {h} {x} {y} {fgh} p =
      day fgh x y                                  β‰‘βŸ¨ day-ap p (sym (X .F-id) #β‚š x) (sym (Y .F-id) #β‚š y) βŸ©β‰‘
      day ((f βŠ—β‚ g) ∘ h) (X .F₁ id x) (Y .F₁ id y) β‰‘βŸ¨ Coeq.glue {f = dimapl (Day-diagram i)} {g = dimapr (Day-diagram i)} ((a , b) , (a' , b') , (f , g) , h , x , y) βŸ©β‰‘
      day ((id βŠ—β‚ id) ∘ h) (X .F₁ f x) (Y .F₁ g y) β‰‘βŸ¨ day-apβ‚˜ (eliml βŠ—.F-id) βŸ©β‰‘
      day h (X .F₁ f x) (Y .F₁ g y)                ∎

Finally, we will use the formalism of cowedges to define functions out of Essentially, this says that we can define a function whenever we can define in a way compatible with the relation above.

    factor : βˆ€ {i} (W : Cowedge (Day-diagram i)) β†’ Day.nadir Κ» i β†’ ⌞ W .nadir ⌟
    factor W = Day.factor _ W
    factor-day
      : βˆ€ {i a b} {W : Cowedge (Day-diagram i)} {h : Hom i (a βŠ— b)} {x : X Κ» a} {y : Y Κ» b}
      β†’ factor W (day h x y) ≑ W .ψ (a , b) (h , x , y)
    factor-day = refl

  {-# REWRITE factor-day #-}

  -- To have better type inference we define the Day-coend and its
  -- associated projections as opaque symbols. Agda will treat them as
  -- injective so e.g. an equation between `Day.nadir F G i = Day.nadir
  -- ? ? ?` will actually solve those three metas.
  --
  -- But, of course, opaque symbols don't compute, and we'd really
  -- really like to have `factor W (day h x y) = W .ψ h x y`. One
  -- approach would be to lift everything that needs this definitional
  -- equality into an opaque block, but that would massively bloat the
  -- file with mandatory type signatures.
  --
  -- Rewrite rules to the rescue: `factor-day` allows us to "export" the
  -- computation rule for `factor W (day ...)` without exposing the
  -- computational behaviour of any other of the symbols here.

  private
    extensional-work
      : βˆ€ {i β„“' β„“r} {C : Type β„“'} ⦃ _ : H-Level C 2 ⦄
      β†’ ⦃ sf : βˆ€ {a b} β†’ Extensional ((h : Hom i (a βŠ— b)) (x : X Κ» a) (y : Y Κ» b) β†’ C) β„“r ⦄
      β†’ Extensional (⌞ Day.nadir i ⌟ β†’ C) (β„“ βŠ” β„“r)
    extensional-work {i} {C = C} ⦃ sf ⦄ = done where
      T : Type _
      T = {a b : Ob} (h : Hom i (a βŠ— b)) (x : X Κ» a) (y : Y Κ» b) β†’ C

      unday : (⌞ Day.nadir i ⌟ β†’ C) β†’ T
      unday f h x y = f (day h x y)

      opaque
        unfolding Day-coend day

        -- Note: Extensional-day-map and Extensional-coeq-map well and
        -- truly overlap whenever Day.nadir is unfoldable (which it is
        -- in the definition of to-p). So we can't let to-p see
        -- Extensional-day-map as an instance.

        to-p : βˆ€ {f g} β†’ Path T (unday f) (unday g) β†’ f ≑ g
        to-p p = ext Ξ» a b h x y i β†’ p i {a} {b} h x y

      done : Extensional (⌞ Day.nadir i ⌟ β†’ C) _
      done = injection→extensional (hlevel 2) to-p auto

  instance
    Extensional-day-map
      : βˆ€ {i β„“' β„“r} {C : Type β„“'} ⦃ _ : H-Level C 2 ⦄
      β†’ ⦃ sf : βˆ€ {a b} β†’ Extensional ((h : Hom i (a βŠ— b)) (x : X Κ» a) (y : Y Κ» b) β†’ C) β„“r ⦄
      β†’ Extensional (⌞ Day.nadir i ⌟ β†’ C) (β„“ βŠ” β„“r)
    Extensional-day-map = extensional-work

  day-swap
    : βˆ€ {i a b a' b'} {f : Hom a' a} {g : Hom b' b} {h : Hom i (a' βŠ— b')}
        {a'' b''} {f' : Hom a'' a} {g' : Hom b'' b} {h' : Hom i (a'' βŠ— b'')}
        {x : X Κ» a} {y : Y Κ» b}
    β†’ (f βŠ—β‚ g) ∘ h ≑ (f' βŠ—β‚ g') ∘ h'
    β†’ day h (X .F₁ f x) (Y .F₁ g y) ≑ day h' (X .F₁ f' x) (Y .F₁ g' y)
  day-swap p = sym (day-glue refl) Β·Β· day-apβ‚˜ p Β·Β· day-glue refl

As an example of constructing a map using cowedges, we can construct the restriction given Pointwise, this sends to It’s a straightforward-but-annoying calculation to show that this extends to the quotient.

  Day-cowedge : βˆ€ {x} {y} β†’ Hom y x β†’ Cowedge (Day-diagram x)
  Day-cowedge {y = y} h .nadir = Day.nadir y
  Day-cowedge h .ψ (a , b) (f , x , y) = day (f ∘ h) x y
  Day-cowedge h .extranatural {a , b} {a' , b'} (f , g) = funext Ξ» (i , x , y) β†’
    day (((f βŠ—β‚ g) ∘ i) ∘ h) (X .F₁ id x) (Y .F₁ id y) β‰‘βŸ¨ day-ap refl (X .F-id #β‚š x) (Y .F-id #β‚š y) βŸ©β‰‘
    day (((f βŠ—β‚ g) ∘ i) ∘ h) x y                       β‰‘βŸ¨ day-glue (sym (assoc _ _ _)) βŸ©β‰‘
    day (i ∘ h) (X .F₁ f x) (Y .F₁ g y)                β‰‘βŸ¨ day-apβ‚˜ (introl βŠ—.F-id βˆ™ assoc _ _ _) βŸ©β‰‘
    day (((id βŠ—β‚ id) ∘ i) ∘ h) (X .F₁ f x) (Y .F₁ g y) ∎

  _βŠ—α΄°_ : ⌞ PSh β„“ C ⌟
  _βŠ—α΄°_ .Fβ‚€ c = Day.nadir c
  _βŠ—α΄°_ .F₁ {x} {y} h v = factor (Day-cowedge h) v
  _βŠ—α΄°_ .F-id    = ext Ξ» h x y β†’ day-apβ‚˜ (idr h)
  _βŠ—α΄°_ .F-∘ f g = ext Ξ» h x y β†’ day-apβ‚˜ (assoc h g f)
Together with some quick functoriality proofs, we have shown above that the Day convolution is a presheaf. If we have natural transformations and then we can extend these to a so that we actually have a functor This is but another annoying calculation.
Day-bifunctor-cowedge
  : βˆ€ {X Y X' Y' : ⌞ PSh β„“ C ⌟} {i}
  β†’ X => X'
  β†’ Y => Y'
  β†’ Cowedge (Day-diagram X Y i)
Day-bifunctor-cowedge {X} {Y} {X'} {Y'} {i} F G = go where
  private module D = Day X' Y'
  go : Cowedge (Day-diagram X Y i)
  go .nadir           = D.nadir i
  go .ψ c (h , x , y) = D.day h (F .η _ x) (G .η _ y)
  go .extranatural (f , g) = ext Ξ» h x y β†’
    D.day ((f βŠ—β‚ g) ∘ h)   (F .Ξ· _ (X .F₁ id x))   (G .Ξ· _ (Y .F₁ id y))   β‰‘βŸ¨ D.day-ap refl (F .is-natural _ _ id #β‚š _) (G .is-natural _ _ id #β‚š _) βŸ©β‰‘
    D.day ((f βŠ—β‚ g) ∘ h)   (X' .F₁ id (F .Ξ· _ x))  (Y' .F₁ id (G .Ξ· _ y))  β‰‘βŸ¨ D.day-swap (extendl (eliml βŠ—.F-id βˆ™ intror βŠ—.F-id)) βŸ©β‰‘
    D.day ((id βŠ—β‚ id) ∘ h) (X' .F₁ f (F .Ξ· _ x))   (Y' .F₁ g (G .Ξ· _ y))   β‰‘Λ˜βŸ¨ D.day-ap refl (F .is-natural _ _ f #β‚š _) (G .is-natural _ _ g #β‚š _) βŸ©β‰‘Λ˜
    D.day ((id βŠ—β‚ id) ∘ h) (F .Ξ· _ (X .F₁ f x))    (G .Ξ· _ (Y .F₁ g y))    ∎

Day-map : βˆ€ {X X' Y Y'} (F : X => X') (G : Y => Y') β†’ X βŠ—α΄° Y => X' βŠ—α΄° Y'
Day-map F G .Ξ· i = Day-rec (Day-bifunctor-cowedge F G)
Day-map F G .is-natural x y f = trivial!

Day-bifunctor : Functor (PSh β„“ C Γ—αΆœ PSh β„“ C) (PSh β„“ C)
Day-bifunctor .Fβ‚€ (X , Y) = X βŠ—α΄° Y
Day-bifunctor .F₁ (F , G) = Day-map F G
Day-bifunctor .F-id    = trivial!
Day-bifunctor .F-∘ f g = trivial!

The monoidal structureπŸ”—

The rest of this module is devoted to showing that the Day convolution is actually a monoidal structure: that is, we have unitors and an associator, which satisfy the triangle and pentagon identities. We will give an overview of the constructor of the right unitor, It’s a representative example of the nasty calculations to come.

Fixing a presheaf and coordinate we want to show that

is isomorphic to Were we not working in a proof assistant, we could do this by coend calculus: it’s an instance of the Yoneda lemma. However, it will be much easier in the long run to bang out an explicit isomorphism. At the level of points, we are given and We must produce an element of The composite

acts on to give us precisely the element we want. In the other direction, we can send to We can then perform the extremely annoying calculations to show that (a) this map extends to the coend, (b) the resulting map is a natural transformation, and (c) the inverse construction we sketched is actually an inverse.

module _ (X : ⌞ PSh β„“ C ⌟) where
  idr-to-cowedge : βˆ€ x β†’ Cowedge (Day-diagram X (γ‚ˆβ‚€ C Unit) x)
  idr-to-cowedge i .nadir = X # i
  idr-to-cowedge i .ψ (a , b) (h , x , y) = X .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ h) x
  idr-to-cowedge i .extranatural {a , b} {a' , b'} (f , g) = ext Ξ» h x y β†’
    X .F₁ (ρ← ∘ (id βŠ—β‚ y ∘ id) ∘ (f βŠ—β‚ g) ∘ h) (X .F₁ id x) β‰‘βŸ¨ apβ‚‚ (X .F₁) (ap (ρ← ∘_) (βŠ—.pulll (apβ‚‚ _,_ (idl f) (ap (_∘ g) (idr y))))) refl βŸ©β‰‘
    X .F₁ (ρ← ∘ (f βŠ—β‚ y ∘ g) ∘ h) (X .F₁ id x)              β‰‘βŸ¨ apβ‚‚ (X .F₁) (ap (ρ← ∘_) (βŠ—.pushl (apβ‚‚ _,_ (intror refl) (introl refl)))) refl βŸ©β‰‘
    X .F₁ (ρ← ∘ (f βŠ—β‚ id) ∘ (id βŠ—β‚ y ∘ g) ∘ h) (X .F₁ id x) β‰‘βŸ¨ apβ‚‚ (X .F₁) (extendl (unitor-r .Isoⁿ.from .is-natural a a' f)) refl βŸ©β‰‘
    X .F₁ (f ∘ ρ← ∘ (id βŠ—β‚ y ∘ g) ∘ h) (X .F₁ id x)         β‰‘βŸ¨ X .F-∘ _ _ #β‚š _ βŸ©β‰‘
    X .F₁ (ρ← ∘ (id βŠ—β‚ y ∘ g) ∘ h) (X .F₁ f (X .F₁ id x))   β‰‘βŸ¨ apβ‚‚ (X .F₁) (ap (ρ← ∘_) (apβ‚‚ _∘_ refl (introl βŠ—.F-id))) (ap (X .F₁ f) (X .F-id #β‚š x)) βŸ©β‰‘
    X .F₁ (ρ← ∘ (id βŠ—β‚ y ∘ g) ∘ (id βŠ—β‚ id) ∘ h) (X .F₁ f x) ∎

  Day-idr : X βŠ—α΄° γ‚ˆβ‚€ C Unit ≅ⁿ X
  Day-idr = to-natural-iso mk-idr where
    mk-idr : make-natural-iso (X βŠ—α΄° γ‚ˆβ‚€ C Unit) X
    mk-idr .eta x   = Day-rec (idr-to-cowedge x)
    mk-idr .inv x a = day ρ→ a id
    mk-idr .eta∘inv x = ext Ξ» a β†’ apβ‚‚ (X .F₁) (ap (ρ← ∘_) (eliml βŠ—.F-id) βˆ™ unitor-r .Isoⁿ.invr Ξ·β‚š _) refl βˆ™ (X .F-id #β‚š a)
    mk-idr .inv∘eta i = ext Ξ» h x y β†’
      day ρ→ (X .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ h) x) id          β‰‘βŸ¨ day-ap refl refl (introl refl) βŸ©β‰‘
      day ρ→ (X .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ h) x) (id ∘ id)   β‰‘βŸ¨ day-swap (sym (unitor-r .Isoⁿ.to .is-natural _ _ _) βˆ™ cancell (unitor-r .Isoⁿ.invl Ξ·β‚š _)) βŸ©β‰‘
      day h (X .F₁ id x) (id ∘ y)                       β‰‘βŸ¨ day-ap refl (X .F-id #β‚š x) (idl y) βŸ©β‰‘
      day h x y                                         ∎
    mk-idr .natural x y f = ext Ξ» h x y β†’
      X .F₁ f (X .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ h) x) β‰‘βŸ¨ sym (X .F-∘ _ _) #β‚š _ βŸ©β‰‘
      X .F₁ ((ρ← ∘ (id βŠ—β‚ y) ∘ h) ∘ f) x     β‰‘βŸ¨ apβ‚‚ (X .F₁) (pullr (pullr refl)) refl βŸ©β‰‘
      X .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ h ∘ f) x       ∎

This completes the construction of the right unitor. It also completes the commentary on this module: the construction of the left unitor, is analogous: just flip everything. The construction of the associator must be done in steps. However, at the level of points, these are all trivial operations, and the vast majority of this module is dedicated to (extra)naturality conditions and proofs of isomorphy.

module _ (Y : ⌞ PSh β„“ C ⌟) where
  idl-to-cowedge : βˆ€ x β†’ Cowedge (Day-diagram (γ‚ˆβ‚€ C Unit) Y x)
  idl-to-cowedge i .nadir = Y # i
  idl-to-cowedge i .ψ (a , b) (h , x , y) = Y .F₁ (λ← ∘ (x βŠ—β‚ id) ∘ h) y
  idl-to-cowedge i .extranatural {a , b} {a' , b'} (f , g) = ext Ξ» h x y β†’
       apβ‚‚ (Y .F₁) (ap (λ← ∘_) (βŠ—.extendl (apβ‚‚ _,_ (ap (_∘ f) (idr x) βˆ™ introl refl) id-comm-sym)) βˆ™ extendl (unitor-l .Isoⁿ.from .is-natural _ _ _)) (Y .F-id #β‚š y)
    Β·Β· (Y .F-∘ _ _ #β‚š y)
    Β·Β· apβ‚‚ (Y .F₁) (ap (λ← ∘_) (apβ‚‚ _∘_ refl (introl βŠ—.F-id))) refl

  Day-idl : γ‚ˆβ‚€ C Unit βŠ—α΄° Y ≅ⁿ Y
  Day-idl = to-natural-iso mk-idl where
    mk-idl : make-natural-iso (γ‚ˆβ‚€ C Unit βŠ—α΄° Y) Y
    mk-idl .eta x = Day-rec (idl-to-cowedge x)
    mk-idl .inv x a = day Ξ»β†’ id a
    mk-idl .eta∘inv x = ext Ξ» a β†’ apβ‚‚ (Y .F₁) (ap (λ← ∘_) (eliml βŠ—.F-id) βˆ™ unitor-l .Isoⁿ.invr Ξ·β‚š _) refl βˆ™ (Y .F-id #β‚š a)
    mk-idl .inv∘eta i = ext Ξ» h x y β†’
      day Ξ»β†’ id (Y .F₁ (λ← ∘ (x βŠ—β‚ id) ∘ h) y)        β‰‘βŸ¨ day-ap refl (introl refl) refl βŸ©β‰‘
      day Ξ»β†’ (id ∘ id) (Y .F₁ (λ← ∘ (x βŠ—β‚ id) ∘ h) y) β‰‘βŸ¨ day-swap (sym (unitor-l .Isoⁿ.to .is-natural _ _ _) βˆ™ cancell (unitor-l .Isoⁿ.invl Ξ·β‚š _)) βŸ©β‰‘
      day h (id ∘ x) (Y .F₁ id y)                     β‰‘βŸ¨ day-ap refl (idl x) (Y .F-id #β‚š y) βŸ©β‰‘
      day h x y                                       ∎
    mk-idl .natural = Ξ» x y f β†’ ext Ξ» h x y β†’
      Y .F₁ f (Y .F₁ (λ← ∘ (x βŠ—β‚ id) ∘ h) y) β‰‘Λ˜βŸ¨ Y .F-∘ _ _ #β‚š _ βŸ©β‰‘Λ˜
      Y .F₁ ((λ← ∘ (x βŠ—β‚ id) ∘ h) ∘ f) y     β‰‘βŸ¨ apβ‚‚ (Y .F₁) (pullr (pullr refl)) refl βŸ©β‰‘
      Y .F₁ (λ← ∘ (x βŠ—β‚ id) ∘ h ∘ f) y       ∎

module _ (X Y Z : ⌞ PSh β„“ C ⌟) where
  assoc-toβ‚€ : βˆ€ i {a b} (h : Hom i (a βŠ— b)) (z : Z Κ» b) β†’ Cowedge (Day-diagram X Y a)
  assoc-toβ‚€ i h z .nadir = Day.nadir X (Y βŠ—α΄° Z) i
  assoc-toβ‚€ i h z .ψ (a' , b') (h' , x , y) = day (Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h) x (day id y z)
  assoc-toβ‚€ i h z .extranatural (f , g) = ext Ξ» h' x y β†’
    day (Ξ±β†’ _ _ _ ∘ ((f βŠ—β‚ g) ∘ h' βŠ—β‚ id) ∘ h) (X .F₁ id x) (day id (Y .F₁ id y) z)  β‰‘βŸ¨ day-ap (ap (Ξ±β†’ _ _ _ ∘_) (βŠ—.pushl (apβ‚‚ _,_ refl (introl refl)))) (X .F-id #β‚š x) (day-ap refl (Y .F-id #β‚š y) refl) βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ ((f βŠ—β‚ g) βŠ—β‚ id) ∘ (h' βŠ—β‚ id) ∘ h) x (day id y z)                β‰‘βŸ¨ day-apβ‚˜ (extendl (associator .Isoⁿ.to .is-natural _ _ _)) βŸ©β‰‘
    day ((f βŠ—β‚ (g βŠ—β‚ id)) ∘ Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h) x (day id y z)                β‰‘βŸ¨ day-glue refl βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h) (X .F₁ f x) (day (id ∘ (g βŠ—β‚ id)) y z)           β‰‘βŸ¨ day-ap (ap (Ξ±β†’ _ _ _ ∘_) (ap (_∘ h) (apβ‚‚ _βŠ—β‚_ (introl βŠ—.F-id) refl))) refl (day-apβ‚˜ id-comm-sym Β·Β· day-glue refl Β·Β· day-ap refl refl (Z .F-id #β‚š z)) βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ ((id βŠ—β‚ id) ∘ h' βŠ—β‚ id) ∘ h) (X .F₁ f x) (day id (Y .F₁ g y) z)  ∎

  assoc-to-cowedge : βˆ€ i β†’ Cowedge (Day-diagram (X βŠ—α΄° Y) Z i)
  assoc-to-cowedge i .nadir = Day.nadir X (Y βŠ—α΄° Z) i
  assoc-to-cowedge i .ψ (a , b) (h , x , y) = Day-rec (assoc-toβ‚€ i h y) x
  assoc-to-cowedge i .extranatural (f , g) = ext Ξ» h h' x y z β†’
    day (Ξ±β†’ _ _ _ ∘ (h' ∘ id βŠ—β‚ id) ∘ (f βŠ—β‚ g) ∘ h) x (day id y (Z .F₁ id z))   β‰‘βŸ¨ day-ap (ap (Ξ±β†’ _ _ _ ∘_) (βŠ—.extendl (apβ‚‚ _,_ (ap (_∘ f) (idr h') βˆ™ introl βŠ—.F-id) id-comm-sym))) refl (day-ap refl refl (Z .F-id #β‚š z)) βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ ((id βŠ—β‚ id) βŠ—β‚ g) ∘ (h' ∘ f βŠ—β‚ id) ∘ h) x (day id y z)      β‰‘βŸ¨ day-apβ‚˜ (extendl (associator .Isoⁿ.to .is-natural _ _ _)) βŸ©β‰‘
    day ((id βŠ—β‚ (id βŠ—β‚ g)) ∘ Ξ±β†’ _ _ _ ∘ (h' ∘ f βŠ—β‚ id) ∘ h) x (day id y z)      β‰‘βŸ¨ day-glue refl βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ (h' ∘ f βŠ—β‚ id) ∘ h) (X .F₁ id x) (day (id ∘ (id βŠ—β‚ g)) y z) β‰‘βŸ¨ day-ap (ap (Ξ±β†’ _ _ _ ∘_) (apβ‚‚ _∘_ refl (introl βŠ—.F-id))) (X .F-id #β‚š x) (day-glue id-comm-sym βˆ™ day-ap refl (Y .F-id #β‚š y) refl) βŸ©β‰‘
    day (Ξ±β†’ _ _ _ ∘ (h' ∘ f βŠ—β‚ id) ∘ (id βŠ—β‚ id) ∘ h) x (day id y (Z .F₁ g z))   ∎

  assoc-fromβ‚€ : βˆ€ i {a b} (h : Hom i (a βŠ— b)) (x : X Κ» a) β†’ Cowedge (Day-diagram Y Z b)
  assoc-fromβ‚€ i h x .nadir = Day.nadir (X βŠ—α΄° Y) Z i
  assoc-fromβ‚€ i h x .ψ (a' , b') (h' , y , z) = day (α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) (day id x y) z
  assoc-fromβ‚€ i h x .extranatural (f , g) = ext Ξ» h' y z β†’
    day (α← _ _ _ ∘ (id βŠ—β‚ ((f βŠ—β‚ g) ∘ h')) ∘ h) (day id x (Y .F₁ id y)) (Z .F₁ id z) β‰‘βŸ¨ day-ap (extendl (pushr (apβ‚‚ _βŠ—β‚_ (introl refl) refl βˆ™ βŠ—.F-∘ _ _) Β·Β· pullr refl Β·Β· extendl (associator .Isoⁿ.from .is-natural _ _ _))) (day-ap refl refl (Y .F-id #β‚š y)) (Z .F-id #β‚š z) βŸ©β‰‘
    day (((id βŠ—β‚ f) βŠ—β‚ g) ∘ (α← _ _ _ ∘ (id βŠ—β‚ h')) ∘ h) (day id x y) z               β‰‘βŸ¨ day-glue refl βŸ©β‰‘
    day ((α← _ _ _ ∘ (id βŠ—β‚ h')) ∘ h) (day (id ∘ (id βŠ—β‚ f)) x y) (Z .F₁ g z)          β‰‘βŸ¨ day-ap (pullr (ap (_∘ h) (apβ‚‚ _βŠ—β‚_ refl (introl βŠ—.F-id)))) (day-glue id-comm-sym βˆ™ day-ap refl (X .F-id #β‚š x) refl) refl βŸ©β‰‘
    day (α← _ _ _ ∘ (id βŠ—β‚ ((id βŠ—β‚ id) ∘ h')) ∘ h) (day id x (Y .F₁ f y)) (Z .F₁ g z) ∎

  assoc-from-cowedge : βˆ€ i β†’ Cowedge (Day-diagram X (Y βŠ—α΄° Z) i)
  assoc-from-cowedge i .nadir = Day.nadir (X βŠ—α΄° Y) Z i
  assoc-from-cowedge i .ψ (a , b) (h , x , y) = Day-rec (assoc-fromβ‚€ i h x) y
  assoc-from-cowedge i .extranatural (f , g) = ext Ξ» h x h' y z β†’
    day (α← _ _ _ ∘ (id βŠ—β‚ h' ∘ id) ∘ (f βŠ—β‚ g) ∘ h) (day id (X .F₁ id x) y) z   β‰‘βŸ¨ day-ap (ap (α← _ _ _ ∘_) (βŠ—.extendl (apβ‚‚ _,_ id-comm-sym (ap (_∘ g) (idr h') βˆ™ introl βŠ—.F-id)))) (day-ap refl (X .F-id #β‚š _) refl) refl βŸ©β‰‘
    day (α← _ _ _ ∘ (f βŠ—β‚ (id βŠ—β‚ id)) ∘ (id βŠ—β‚ h' ∘ g) ∘ h) (day id x y) z      β‰‘βŸ¨ day-apβ‚˜ (extendl (associator .Isoⁿ.from .is-natural _ _ _)) βŸ©β‰‘
    day (((f βŠ—β‚ id) βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ h' ∘ g) ∘ h) (day id x y) z      β‰‘βŸ¨ day-glue refl βŸ©β‰‘
    day (α← _ _ _ ∘ (id βŠ—β‚ h' ∘ g) ∘ h) (day (id ∘ (f βŠ—β‚ id)) x y) (Z .F₁ id z) β‰‘βŸ¨ day-ap (ap (α← _ _ _ ∘_) (apβ‚‚ _∘_ refl (introl βŠ—.F-id))) (day-glue id-comm-sym βˆ™ day-ap refl refl (Y .F-id #β‚š y)) (Z .F-id #β‚š z) βŸ©β‰‘
    day (α← _ _ _ ∘ (id βŠ—β‚ h' ∘ g) ∘ (id βŠ—β‚ id) ∘ h) (day id (X .F₁ f x) y) z   ∎

  Day-assoc : (X βŠ—α΄° Y) βŠ—α΄° Z ≅ⁿ X βŠ—α΄° (Y βŠ—α΄° Z)
  Day-assoc = to-natural-iso mk-assoc where
    mk-assoc : make-natural-iso ((X βŠ—α΄° Y) βŠ—α΄° Z) (X βŠ—α΄° (Y βŠ—α΄° Z))
    mk-assoc .eta x = Day-rec (assoc-to-cowedge x)
    mk-assoc .inv x = Day-rec (assoc-from-cowedge x)
    mk-assoc .eta∘inv x = ext Ξ» h x h' y z β†’
      day (Ξ±β†’ _ _ _ ∘ (id βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) x (day id y z) β‰‘βŸ¨ day-apβ‚˜ (pulll (elimr βŠ—.F-id) βˆ™ cancell (associator .Isoⁿ.invl Ξ·β‚š _)) βŸ©β‰‘
      day ((id βŠ—β‚ h') ∘ h) x (day id y z)                                    β‰‘βŸ¨ day-glue refl βŸ©β‰‘
      day h (X .F₁ id x) (day (id ∘ h') y z)                                 β‰‘βŸ¨ day-ap refl (X .F-id #β‚š x) (day-apβ‚˜ (idl h')) βŸ©β‰‘
      day h x (day h' y z)                                                   ∎
    mk-assoc .inv∘eta x = ext Ξ» h h' x y z β†’
      day (α← _ _ _ ∘ (id βŠ—β‚ id) ∘ Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h) (day id x y) z β‰‘βŸ¨ day-apβ‚˜ (pulll (elimr βŠ—.F-id) βˆ™ cancell (associator .Isoⁿ.invr Ξ·β‚š _)) βŸ©β‰‘
      day ((h' βŠ—β‚ id) ∘ h) (day id x y) z                                    β‰‘βŸ¨ day-glue refl βŸ©β‰‘
      day h (day (id ∘ h') x y) (Z .F₁ id z)                                 β‰‘βŸ¨ day-ap refl (day-apβ‚˜ (idl h')) (Z .F-id #β‚š z) βŸ©β‰‘
      day h (day h' x y) z                                                   ∎
    mk-assoc .natural x y f = ext Ξ» h h' x y z β†’
      day ((Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h) ∘ f) x (day id y z) β‰‘βŸ¨ day-ap (pullr (pullr refl)) refl refl βŸ©β‰‘
      day (Ξ±β†’ _ _ _ ∘ (h' βŠ—β‚ id) ∘ h ∘ f) x (day id y z)   ∎

private module M = Monoidal-category

abstract
  day-triangle : βˆ€ {A B : ⌞ PSh β„“ C ⌟} β†’ Day-map (Day-idr A .Isoⁿ.to) idnt ∘nt Day-assoc A (γ‚ˆβ‚€ C Unit) B .Isoⁿ.from ≑ Day-map idnt (Day-idl B .Isoⁿ.to)
  day-triangle {A} {B} = ext Ξ» i h x h' y z β†’
    day (α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) (A .F₁ (ρ← ∘ (id βŠ—β‚ y) ∘ id) x) z         β‰‘βŸ¨ day-ap refl (apβ‚‚ (A .F₁) (ap (ρ← ∘_) (idr _)) refl) (sym (B .F-id #β‚š z)) βŸ©β‰‘
    day (α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) (A .F₁ (ρ← ∘ (id βŠ—β‚ y)) x) (B .F₁ id z)   β‰‘βŸ¨ sym (day-glue refl) βŸ©β‰‘
    day ((ρ← ∘ (id βŠ—β‚ y) βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) x z              β‰‘βŸ¨ day-apβ‚˜ (βŠ—.pushl (apβ‚‚ _,_ refl (introl refl))) βŸ©β‰‘
    day ((ρ← βŠ—β‚ id) ∘ ((id βŠ—β‚ y) βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) x z      β‰‘βŸ¨ day-apβ‚˜ (apβ‚‚ _∘_ refl (extendl (sym (associator .Isoⁿ.from .is-natural _ _ _)))) βŸ©β‰‘
    day ((ρ← βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ (y βŠ—β‚ id)) ∘ (id βŠ—β‚ h') ∘ h) x z      β‰‘βŸ¨ day-apβ‚˜ (pulll triangle) βŸ©β‰‘
    day ((id βŠ—β‚ λ←) ∘ (id βŠ—β‚ (y βŠ—β‚ id)) ∘ (id βŠ—β‚ h') ∘ h) x z                 β‰‘βŸ¨ day-apβ‚˜ (pulll (sym (βŠ—.F-∘ _ _)) βˆ™ pulll (sym (βŠ—.F-∘ _ _)) βˆ™ ap (_∘ h) (apβ‚‚ _βŠ—β‚_ (eliml (eliml refl)) (pullr refl))) βŸ©β‰‘
    day ((id βŠ—β‚ (λ← ∘ (y βŠ—β‚ id) ∘ h')) ∘ h) x z                               β‰‘βŸ¨ day-glue refl βŸ©β‰‘
    day h (A .F₁ id x) (B .F₁ (λ← ∘ (y βŠ—β‚ id) ∘ h') z)                        β‰‘βŸ¨ day-ap refl (A .F-id #β‚š x) refl βŸ©β‰‘
    day h x (B .F₁ (λ← ∘ (y βŠ—β‚ id) ∘ h') z)                                   ∎

  day-pentagon
    : βˆ€ {A B C D : ⌞ PSh β„“ C ⌟}
    β†’ Day-map (Day-assoc A B C .Isoⁿ.from) idnt
      ∘nt Day-assoc A (B βŠ—α΄° C) D .Isoⁿ.from
      ∘nt Day-map idnt (Day-assoc B C D .Isoⁿ.from)
    ≑ Day-assoc (A βŠ—α΄° B) C D .Isoⁿ.from
      ∘nt Day-assoc A B (C βŠ—α΄° D) .Isoⁿ.from
  day-pentagon {D = D} = ext Ξ» i h a h' b h'' c d β†’
    let
      it =
        (α← _ _ _ βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ α← _ _ _ ∘ (id βŠ—β‚ h'') ∘ h') ∘ h         β‰‘βŸ¨ apβ‚‚ _∘_ refl (apβ‚‚ _∘_ refl (βŠ—.pushl (apβ‚‚ _,_ (intror refl) refl))) βŸ©β‰‘
        (α← _ _ _ βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ α← _ _ _) ∘ (id βŠ—β‚ (id βŠ—β‚ h'') ∘ h') ∘ h β‰‘βŸ¨ pulll refl βˆ™ extendl (pullr refl βˆ™ pentagon) βŸ©β‰‘
        α← _ _ _ ∘ α← _ _ _ ∘ (id βŠ—β‚ (id βŠ—β‚ h'') ∘ h') ∘ h                            β‰‘βŸ¨ apβ‚‚ _∘_ refl (apβ‚‚ _∘_ refl (βŠ—.pushl (apβ‚‚ _,_ (intror refl) refl))) βŸ©β‰‘
        α← _ _ _ ∘ α← _ _ _ ∘ (id βŠ—β‚ (id βŠ—β‚ h'')) ∘ (id βŠ—β‚ h') ∘ h                    β‰‘βŸ¨ apβ‚‚ _∘_ refl (extendl (associator .Isoⁿ.from .is-natural _ _ _)) βŸ©β‰‘
        α← _ _ _ ∘ ((id βŠ—β‚ id) βŠ—β‚ h'') ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h                    β‰‘βŸ¨ apβ‚‚ _∘_ refl (apβ‚‚ _∘_ (ap (_βŠ—β‚ h'') βŠ—.F-id) refl) βŸ©β‰‘
        (α← _ _ _ ∘ (id βŠ—β‚ h'') ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h)                          ∎
    in
      day (α← _ _ _ ∘ (id βŠ—β‚ (α← _ _ _) ∘ (id βŠ—β‚ h'') ∘ h') ∘ h) (day (α← _ _ _ ∘ (id βŠ—β‚ id) ∘ id) (day id a b) c) d  β‰‘βŸ¨ day-ap refl (day-ap (elimr (eliml βŠ—.F-id) βˆ™ introl refl) refl refl) (sym (D .F-id #β‚š d)) βŸ©β‰‘
      day (α← _ _ _ ∘ (id βŠ—β‚ (α← _ _ _) ∘ (id βŠ—β‚ h'') ∘ h') ∘ h) (day (id ∘ α← _ _ _) (day id a b) c) (D .F₁ id d)    β‰‘βŸ¨ sym (day-glue refl) βŸ©β‰‘
      day ((α← _ _ _ βŠ—β‚ id) ∘ α← _ _ _ ∘ (id βŠ—β‚ (α← _ _ _) ∘ (id βŠ—β‚ h'') ∘ h') ∘ h) (day id (day id a b) c) d         β‰‘βŸ¨ day-apβ‚˜ it βŸ©β‰‘
      day (α← _ _ _ ∘ (id βŠ—β‚ h'') ∘ α← _ _ _ ∘ (id βŠ—β‚ h') ∘ h) (day id (day id a b) c) d                              ∎

Day-monoidal : Monoidal-category (PSh β„“ C)
Day-monoidal .M.-βŠ—-      = Day-bifunctor
Day-monoidal .M.Unit     = γ‚ˆβ‚€ C Unit
Day-monoidal .M.unitor-l = to-natural-iso mk-Ξ» where
  mk-Ξ» : make-natural-iso _ _
  mk-λ .eta x = Day-idl x .Isoⁿ.from
  mk-λ .inv x = Day-idl x .Isoⁿ.to
  mk-λ .eta∘inv x = Day-idl x .Isoⁿ.invr
  mk-λ .inv∘eta x = Day-idl x .Isoⁿ.invl
  mk-Ξ» .natural x y f = trivial!
Day-monoidal .M.unitor-r = to-natural-iso mk-ρ where
  mk-ρ : make-natural-iso _ _
  mk-ρ .eta x = Day-idr x .Isoⁿ.from
  mk-ρ .inv x = Day-idr x .Isoⁿ.to
  mk-ρ .eta∘inv x = Day-idr x .Isoⁿ.invr
  mk-ρ .inv∘eta x = Day-idr x .Isoⁿ.invl
  mk-ρ .natural x y f = trivial!
Day-monoidal .M.associator = to-natural-iso mk-Ξ± where
  mk-Ξ± : make-natural-iso _ _
  mk-α .eta (x , y , z) = Day-assoc x y z .Isoⁿ.to
  mk-α .inv (x , y , z) = Day-assoc x y z .Isoⁿ.from
  mk-α .eta∘inv (x , y , z) = Day-assoc x y z .Isoⁿ.invl
  mk-α .inv∘eta (x , y , z) = Day-assoc x y z .Isoⁿ.invr
  mk-Ξ± .natural x y f = trivial!
Day-monoidal .M.triangle {A} {B} = day-triangle
Day-monoidal .M.pentagon {A} {B} {C} {D} = day-pentagon

  1. This is actually a slight under-approximation of strong monoidal functors: the unit must also be preserved, of course, and the preservation isomorphisms need to be compatible with the structural morphisms β€” the unitors and associator.β†©οΈŽ