Library UniMath.CategoryTheory.UnitorsAndAssociatorsForEndofunctors

**********************************************************
Benedikt Ahrens, Ralph Matthes
2015
Modified by: Anders Mörtberg, 2016 Ralph Matthes, 2017
**********************************************************
Contents :
  • Definition of the (weak) monoidal structure on endofunctors (however, the definitions are not confined to endofunctors)
    Here, we only give the unitors and associators and do not build a monoidal category (anyway, this is not possible since we are not considering only endofunctors).
There is a monoidal structure on endofunctors, given by composition. While this is considered to be strict in set-theoretic category theory, it ain't strict in type theory with respect to convertibility. So we consider it to be a weak monoidal structure instead. However, pointwise, it suffices to take the identity for all those natural transformations (the identity is also behind the definition of nat_trans_functor_assoc).
To understand the need for this structure even better, notice that the proofs of functor axioms for one composition in the unitality and associativity properties are slightly different from the proofs for the other and because of it the composition of functors is not strictly unital or associative. However, these proofs are not used in the definition of natural transformations, to be precise only functor_data is used, and the composition of functor_data is strictly unital and associative.
while this is normally used for endofunctors, it can be done more generally, but already for endofunctors, this is crucial for the development of substitution systems

Context {C D : precategory}.

Goal X Y : C D, functor_composite X (functor_identity D) Y = (X Y).
Show proof.
  intros X Y.
  apply idpath.

this also holds in the target but is not needed here
trivially, this observed convertibility implies the following three convertibilities
Goal X Y : C D, functor_composite (functor_identity C) X Y = (X Y).
Show proof.
  intros X Y.
  apply idpath.

again, this also holds in the target but is not needed here
end of implied convertibilities
the last convertibility fails for the composition with the identity as second argument
Goal (E: precategory)(hs: has_homsets D)(H: functor [C,D,hs] E) (X: C D),
         H(functor_composite X (functor_identity D)) = H X.
Show proof.
  intros.
  Fail (apply idpath).
Abort.
in particular, there is no convertibility between the arguments to H

Goal (X : functor C D)(Y : functor D E)(Z : functor E F) (U: functor C F),
  U (functor_composite (functor_composite X Y) Z) =
  U (functor_composite X (functor_composite Y Z)).
Show proof.
  intros.
  apply idpath.

Definition α_functors (X : functor C D)(Y : functor D E)(Z : functor E F) :
  nat_trans (functor_composite (functor_composite X Y) Z)
            (functor_composite X (functor_composite Y Z)) := nat_trans_id ((X Y) Z).

Definition α_functors_inv (X : functor C D)(Y : functor D E)(Z : functor E F) :
  nat_trans (functor_composite X (functor_composite Y Z))
            (functor_composite (functor_composite X Y) Z) := nat_trans_id ((X Y) Z).

Lemma α_functors_pointwise_is_z_iso (hsF: has_homsets F)(X : functor C D)(Y : functor D E)(Z : functor E F) :
  is_z_isomorphism(C:= functor_precategory C F hsF) (α_functors X Y Z).
Show proof.
  exists (α_functors_inv X Y Z).
  split; apply nat_trans_eq; try assumption; intro c; apply id_left.

as a motivation, we show here that, propositionally, the functors in source and target of these are equal, for each of the three pairs of functors; the extra assumption on having homsets is only used in order to have simple proofs, it is not necessary, as shown below
Local Lemma motivation_ρ_functors (hsD : has_homsets D)(X : functor C D) : functor_composite X (functor_identity D) = X.
Show proof.
  now apply (functor_eq _ _ hsD); induction X as [data laws]; induction data as [onobs onmorphs].

Local Lemma motivation_λ_functors (hsD : has_homsets D)(X : functor C D) : functor_composite (functor_identity C) X = X.
Show proof.
  now apply (functor_eq _ _ hsD); induction X as [data laws]; induction data as [onobs onmorphs].

Local Lemma motivation_α_functors (hsF : has_homsets F)(X : functor C D)(Y : functor D E)(Z : functor E F) :
  functor_composite (functor_composite X Y) Z = functor_composite X (functor_composite Y Z).
Show proof.
  now apply (functor_eq _ _ hsF); induction X as [data laws]; induction data as [onobs onmorphs].

these laws do not help in type-checking definitions which is why the transformations further above are needed
now we get rid of the homset assumptions by using results of Section "functor_equalities" in UniMath.CategoryTheory.Core.Functors.v