Weakening and Iterating Laws using String Diagrams

Distributive laws are a standard way of combining two monads, providing a compositional approach for reasoning about computational effects in semantics. Situations where no such law exists can sometimes be handled by weakening the notion of distributive law, still recovering a composite monad. A celebrated result from Eugenia Cheng shows that combining $n$ monads is possible by iterating more distributive laws, provided they satisfy a coherence condition called the Yang-Baxter equation. Moreover, the order of composition does not matter, leading to a form of associativity. The main contribution of this paper is to generalise the associativity of iterated composition to weak distributive laws in the case of $n = 3$ monads. To this end, we use string-diagrammatic notation, which significantly helps make increasingly complex proofs more readable. We also provide examples of new weak distributive laws arising from iteration.


Introduction
Monads have been very successful in computer science to model computational effects [29,32,37].In this context, being able to compose monads is of central importance.The primary framework for monad composition is undoubtedly Beck's celebrated theory of distributive laws [1].In practice, finding distributive laws between monads is hard, although some recipes are known to build them [26,27].In contrast, once a law is found, it often contains a significant semantic content -thus, it is common to find papers entirely dedicated to describing the construction and the consequences of a distributive law, see e.g.[21].More generally, monad composition is still a very active field in the computer science community nowadays, with possible applications in coalgebra [34,22,40,5] or in the semantics of computation [14,30].
With the help of a distributive law, one can compose two monads.Composing more monads can be performed by iterating [11], i.e., by using more distributive laws -yet, these must meet coherence axioms called the Yang-Baxter equations.While distributive laws are the first step towards monad compositionality, iterated distributive laws are all the following steps.
Although category theory is a language of choice to work on compositionality properties, there is one major obstacle in the field of distributive laws: monads may not always compose.And consequently, Goy 3-3 trivial weak distributive laws, and generic distributive laws involving the exception monad, the reader monad, and the writer monad.Finally, in Section 4.3, we give a new perspective on algebras for a monad by identifying them as distributive laws (Proposition 4.16).In this vision, algebras for a distributive law are identified as iterated distributive laws (Proposition 4.17).

Related Work.
The content of the present paper is partly based on the author's PhD thesis [16], with a slightly different perspective.In [16] the focus is put on the correspondence weak distributive laws -weak liftings -weak extensions.In contrast, in the present paper, we instead follow the approach of [35,Section 2] consisting in building the weak composite monad directly out of the weak distributive law.It has to be mentioned that iterated distributive laws have already been studied from a string-diagrammatic perspective in a paper from Hinze and Marsden [19].

Preliminaries and Notation
Definitional equality is denoted by .We assume basic knowledge of category theory, including: category, functor, natural transformation.Let C be a category and S, T be endofunctors on C. We use the Lie bracket notation [S, T ] as a shortcut for the type of natural transformations T S ⇒ ST .For example, λ : [S, T ] means that λ is a natural transformation of type T S ⇒ ST .This notation is convenient because (a) laws λ : [S, T ] are related to composite monads S • T and (b) the type T S ⇒ ST looks like a logical version of the formal expression −T S + ST .Identity morphisms will be denoted by 1 X : X → X, the identity functor by 1 : C → C, and the identity natural transformation on a functor F by 1 F : F ⇒ F .
In the whole paper we assume that C is idempotent complete, that is, for every morphism k : X → X in C such that k • k = k, there are morphisms p : X → Y and i : Y → X such that i • p = k and p • i = 1 Y .A direct consequence is that for any functor F : C → C, every idempotent natural transformation κ : F ⇒ F splits.Explicitly, there are a functor K and natural transformations π : F ⇒ K, ι : K ⇒ F such that ι • π = κ and π • ι = 1 K .All the forecoming examples live in the category Set of sets and functions, which is idempotent complete.So are, e.g., toposes and the category of compact Hausdorff spaces [18].We globally impose idempotent completeness to be able to split natural transformations denoted by κ in the sequel -all our results remain valid by only asserting locally that these κ split.

Introducing String Diagrams
We strongly encourage the reader to refer to [20, Sections 2 and 3] for a thorough introduction to string diagrams.In this short section, we will nonetheless provide a crash course in string diagrams, mainly to fix notations.
The following example sums up all useful notation.On the left part, we provide several basic natural transformations λ : T S ⇒ ST , ν : ST ⇒ U , ε : U ⇒ 1, η : 1 ⇒ T .On the right part, we provide two equivalent string diagrams representing the same composite natural transformation ν We use the following convention: diagrams are read from right to left and from bottom to top (note that [20] rather uses top to bottom).A functor F : C → D, represented by a vertical string, delineates two regions: the region on the right represents the category C, while the region on the left represents

3-4
Weakening and Iterating Laws Using String Diagrams the category D. In what follows, we only study endofunctors in C3 .Therefore all delineated regions remain blank and represent the category C. The identity functor 1 : C → C is not depicted.A natural transformation α : F ⇒ G is depicted by a symbol between functor F (below) and functor G (above).Using colours, we will define on-the-fly unambiguous symbols (typically, nodes) to distinguish between different natural transformations -see equation (1) for a first example.The identity natural transformation 1 F : F ⇒ F is a string with no symbol, i.e., it coincides with the representation of the functor F : C → C.
Let F , G, H, K be functors, and α : F ⇒ G, β : G ⇒ H, γ : H ⇒ K be natural transformations.Composition of functors is denoted by GF and depicted by horizontal juxtaposition of strings.Vertical composition of natural transformations is denoted by β • α : F ⇒ H, defined by (β • α) X β X • α X for all objects X, and depicted by vertical glueing of string diagrams.Left (respectively right) composition of a functor and a natural transformation is denoted by Hα : HF ⇒ HG (respectively αH : F H ⇒ GH), defined by (Hα) X H(α X ) (respectively (αH) X α HX ) for all objects X, and depicted by horizontal juxtaposition of string diagrams.Horizontal composition of natural transformations is denoted by γα : HF ⇒ KG, defined by γα Kα • γF = γG • Hα, and depicted by horizontal juxtaposition of string diagrams.
Each string diagram represents a natural transformation of some type.Two string diagrams of the same type are identified up to continuous operations such as dragging nodes and bending strings (provided it does not reverse the implicit bottom-up vertical direction).Discontinuous operations include sliding a node past another on the same string, crossing two strings, and deleting or adding strings or nodes.Such operations may be allowed punctually in the presence of a natural transformation that justifies them.For instance, a natural transformation λ : [S, T ], having type T S ⇒ ST , represents an ad hoc rule to cross the two strings representing S and T .String-diagrammatic notation is coherent with the usual laws of category theory in the sense that two identified string diagrams always denote the same natural transformation.
It is customary, as done in [20], to specify the types of the functors below and above each string diagram.In this paper, only a few functors are in play, so that our colour code would be sufficient to infer all types.For the sake of clarity, we opt for some redundancy by always indicating types.

A String-Diagrammatic Theory of Weak Distributive Laws
The present section introduces weak distributive laws in string-diagrammatic style, starting back from the standard theory of monads and distributive laws.

Monads and Distributive Laws
Definition 3.1 A monad is a triple (T, η T , µ T ) comprising a C-endofunctor T and two natural transformations, the unit η T : 1 ⇒ T and the multiplication µ String diagrammatically, these data are denoted by For the sake of readability, we may denote a monad (T, η T , µ T ) simply by T .Let us give some examples of monads in the category Set.The identity monad consists of the identity functor 1 with both the unit and the multiplication being the identity natural transformation 1 ⇒ 1.

Example 3.3
The exception monad E is defined as follows.Let 1 = { * } be a singleton set.For any set X, let inl X : X → X + 1 and inr X : 1 → X + 1 be the canonical injections.The functor E maps a set X to the set EX X + 1 and a function f : X → Y to Ef : and Ef (inr X ( * )) inr Y ( * ).The unit is η E inl : 1 ⇒ E and the multiplication µ E : EE ⇒ E is given by merging exceptions, i.e., µ E X (inl X+1 (z)) z for all z ∈ X + 1 and µ E X (inr X+1 ( * )) inr X ( * ).
Example 3.4 The reader monad R is defined as follows.Let A be a set of labels.The functor R maps a set X to the set RX X A and a function f : Example 3.5 The writer monad W is defined as follows.Let (M, •, e) be a monoid.The functor W maps a set X to the set W X M × X and a function f : ).The unit η W : 1 ⇒ W outputs the monoid unit η W X (x) (e, x).The multiplication µ W : W W ⇒ W implements the monoid multiplication, i.e., µ W X (m, (n, x)) (m • n, x).
Example 3.6 The powerset monad P is defined as follows.The functor P maps a set X to the set of its subsets P X and a function f : X → Y to its direct image P f : P X → P Y , defined by P f (U ) {f (x) | x ∈ U } for all U ⊆ X.The unit η P : 1 ⇒ P produces singletons η P X (x) {x}.The multiplication µ P : P P ⇒ P computes unions, i.e., µ P X (U ) U for all U ∈ P P X.
Example 3.7 The distribution monad D is defined as follows.The functor D maps a set X to the set of all finitely-supported probability distributions on X, i.e., where supp X (p) = {x ∈ X | p(x) > 0}.For a p ∈ DX, we may use the formal sum notation p = x∈X p x •x, where p x p(x).A function f : X → Y is mapped to Df : DX → DY , defined by Df The multiplication µ D : DD ⇒ D is a weighted average, defined by µ D X (q) p∈DX q p p x • x for all q ∈ DDX.
Definition 3.8 Given two monads S, T on C, a distributive law is a λ : [S, T ] such that the four following axioms hold: String diagrammatically, the monads S, T , and the distributive law λ : [S, T ] are pictured as (ST, η S η T , µ S µ T • SλT ), also denoted by S • T when no confusion can arise, and pictured as
In this definition, the weakening comes from dropping the (η − ) axiom, as done in [15].There are other possible weakenings that we briefly discuss in Remark 3.15.An interesting natural transformation emerges from the structure of a weak distributive law.Consider If λ were a distributive law, then κ would be the identity.In the weak case though, κ still is an idempotent that is compatible with units and multiplications in the following sense.
Lemma 3.10 The natural transformation κ satisfies the following equations.
As κ : ST ⇒ ST is an idempotent natural transformation and we assume C to be idempotent complete, there are a C-endofunctor K and two natural transformations π : ST ⇒ K and ι : K ⇒ ST such that ι • π = κ and π • ι = 1 K .Using these, one can build a monad that is to be interpreted as a weak composition of S and T , namely , also denoted by S • T when the context is clear.See Appendix A for a proof that this is indeed a monad.We now introduce some string diagrammatic notation that will make computations practicable: The composite monad S • T is, in turn, as follows -compare with diagrams (6) for S • T : We provide two concrete examples: Example 3.12 Given a monad T and a natural transformation α : T ⇒ T , one can view α as having type [1, T ] or [T, 1], where 1 is the identity monad described in Example 3.2.Table 1 describes how axioms of distributive laws can then be satisfied by α.One can infer that α : [1, T ] is a weak distributive law if and only if α is the identity, whereas α : [T, 1] is a weak distributive law exactly when α is an idempotent monad morphism.For example, given any monad morphism γ : T ⇒ 1 (that is, a natural transformation which is pointwise Eilenberg-Moore), the corresponding trivial weak distributive law is η T • γ : [T, 1] which is indeed an idempotent monad morphism.We provide two concrete examples: • The map proj 2 : W ⇒ 1 from the writer monad, defined by proj 2 X (m, x) x for any (m, x) ∈ W X, is a monad morphism.Therefore η W • proj 2 : [W, 1], defined by (m, x) → (e, x), is a weak distributive law.
• Given any letter a ∈ A, the map â : R ⇒ 1 from the reader monad, defined by âX (h) We provide two non-trivial examples of weak distributive laws, both of them arising from situations when no distributive law of their type exists [25,36].
is the unique monotone weak distributive law of its type -see [17] for a detailed study.
Example 3.14 The natural transformation λ : [P, P ] defined for any subset of subsets U by is the unique monotone weak distributive law of its type -see [15,18] for more details.
One can see that the theory of weak distributive laws is very similar to Beck's theory of distributive laws [1] modulo the transformations π and ι.For example, if λ : [S, T ] is a distributive law, then the classical theory shows that Sη T : S ⇒ S • λ T and η S T : T ⇒ S • λ T are monad morphisms.Similarly, if λ : [S, T ] is only weak, then π • Sη T : S ⇒ S • λ T and π • η S T : T ⇒ S • λ T are monad morphisms.Whenever the base category is idempotent complete, as is assumed in this paper, the renowned correspondence distributive laws -extensions -liftings also generalises (see [15]).
Remark 3.15 Deleting the (η − ) axiom is one of the many ways of weakening the notion of distributive law.In recent years, this approach has been very fruitful for computer science applications [17,18,16,4].One may ask, symmetrically, what happens by deleting the (η + ) axiom instead.This idea gives rise to the notion of coweak distributive law developed by the author in [16].Coweak distributive laws enjoy many symmetries with respect to weak distributive laws, but no non-trivial examples of them are known.Yet another way of weakening the notion of distributive law is the one of Street [35], who suggests keeping a weakened version of both the (η + ) and the (η − ) axiom.The presentation of the present paper -including the string diagrammatic approach -is greatly inspired by the one of Street-weak distributive laws in [35].A broader, 2-categorical account of distributive law weakenings can be found in [9,10].

Adapting Cheng's Theorem
In this section, we are interested in what happens when combining more laws.For the sake of simplicity, we will only consider the case when three laws are in play.In the whole section, let R, S, T be monads Equation (YB), known as the Yang-Baxter equation, intuitively states that these three natural transformations are coherent with each other.Diagrammatically, it means that when performing the three crossings in a row, their order does not matter: The result of Cheng [11,Theorem 1.6] can be rephrased as follows in the case of three monads.
• these two laws generate the same monad, i.e., (R • S) The result can be generalised to weak distributive laws.Let us consider separately what happens for the two possible composite laws.From now onwards, the natural transformations κ, π and ι from Section 3 will mention explicitly which law they relate toe.g., given a weak distributive law λ : [S, T ], they are denoted by κ λ , π λ and ι λ .

First Composite Law
Assume σ : [R, S] is a weak distributive law.We will derive which axioms on λ and τ are sufficient for to be a (weak) distributive law.The natural ϕ : [R • S, T ] can be depicted as follows, where H is short notation for the functor R • S: The (η + ) axiom for ϕ can be derived from equation (10) which states compatibility between units and the idempotent, the (η + ) axiom for τ , and the (η + ) axiom for λ: The (η − ) axiom for ϕ can be derived from the (η − ) axiom for τ , the (η − ) axiom for λ, and the retract equation The (µ + ) axiom for ϕ can be derived from equation (11) which states compatibility between multiplications and the idempotent, the retract equation π • ι = 1 R•S , the (µ + ) axiom for both τ and λ, the Yang-Baxter

3-10
Weakening and Iterating Laws Using String Diagrams equation, the retract equation again, and equation (11) again: To prove the last axiom, we need a technical lemma.
Table 2 sums up which axioms of τ and λ are sufficient to make axioms hold for ϕ.
Using the information contained in Table 2, we get the following result.
The natural ψ : [R, S • T ] can be depicted as follows, where K is short notation for the functor S • T : Again, assuming some axioms of distributive laws for σ and τ , one can infer axioms for ψ.Using string diagrams, one can easily see that the proofs are symmetrical from the ones in Section 4.1.1.As an instance, recall that Lemma 4.2 was required to prove the (µ − ) axiom for ϕ.Now, the following symmetrical result is required to prove the (µ + ) axiom for ψ: Proof.Easy to see using string diagrams:  3 sums up which axioms of σ and τ are sufficient to make axioms hold for ψ.
Using the information contained in Table 3, we get the following result.

3-12
Weakening and Iterating Laws Using String Diagrams

Associativity of Weak Iteration
According to the preceding paragraphs, provided the Yang-Baxter equation holds and enough axioms are satisfied, there are two ways of obtaining a composite weak distributive law.The first one, described in Proof.After some string-diagrammatic computations (see Appendix B), one can express the idempotents κ ϕ and κ ψ as follows: where α π σ T • Rι λ and β Rπ λ • ι σ T , as pictured below.
Now let us split κ ϕ = ι ϕ • π ϕ with π ϕ • ι ϕ = 1 (R•S)•T .We show that this splitting generates also a splitting for κ ψ .Indeed, one can choose ι ψ β • ι ϕ and π ψ π ϕ • α because Hence the splitting of κ ψ is as follows: Therefore, the functors (R • S) • T and R • (S • T ) can be identified.We denote it by R • S • T (short notation Ω) and picture it as follows: Moreover, one can separate the three functors -or merge the three functors -in any order up to an Goy 3-13 idempotent, as shown in the following diagrams (proved in Appendix B): Using these compatibility properties along with aforementioned properties of κ, it is then a matter of lengthy but straightforward computations to show that units and multiplications of (R • S) • T and R • (S • T ) coincide (see Appendix B). ✷

Examples
In this section, we illustrate many cases where the results of the previous section can be applied by proving the Yang-Baxter equation for some usual monads and (weak) distributive laws.

Iterating with Trivial Weak Distributive Laws
When one of the three laws involved is trivial, the Yang-Baxter equation usually simplifies to a condition relating the underlying monad morphism to the other laws.We mention the two following cases.
• Let σ : [R, S] be a distributive law and λ η S µ T • T γ : [S, T ] be a trivial weak distributive law arising from a monad morphism γ : S ⇒ T such that Rγ • σ = τ • γR.Then the Yang-Baxter equation is satisfied.

Iterating with Exceptions
The exception monad E from Example 3.3 can be described by seeing inl : 1 ⇒ E and inr : 1 ⇒ E as natural transformations, where 1 is the identity functor and 1 is the constant functor 1X 1 = { * }, 1f 1 { * } .One can then define a well-known generic distributive law relying directly on these two coproduct injections.
Example 4.8 For any Set monad T , there is a distributive law ε T : [T, E] defined by Moreover, for monads S and T , the distributive laws ε S and ε T are coherent with each other in the sense of the next proposition.Proposition 4.9 Let λ : [S, T ] be a natural transformation such that either the (η + ) or the (η − ) axiom holds.Then the following Yang-Baxter equation holds: Remark 4.10 The above proposition still holds true when E implements multiple exceptions.More generally, it can be generalised to any category with binary coproducts and any exception monad of the form EX = X + e, where e is an object of exceptions.
Consequently, by applying Theorem 4.6, given any weak distributive law [S, T ], one can safely compose the resulting monad with the exception monad E and get a monad S •T •E.We give two explicit examples.
• Applying Theorem 4.5 to the weak distributive law λ : [P, D] from Example 3.13, we derive a new weak distributive law λE • Dε P : [P, D ≤ ] between the powerset monad P and the subdistribution monad The expression of this new law is as in ( 16).• Remarking that P = P * •E where P * is the non-empty powerset monad, we identify the weak distributive law λ : [P, P ] from Example 3.14 as an iterated law built from ε P , ε P * , and a weak distributive law of type [P, P * ] whose expression is as in (17).

Iterating with the Reader
Recall that A is a set of labels and the reader monad in Set is defined as RX = X A .For any a ∈ A, define the function âX : RX → X by âX (h) = h(a).
Example 4.11 For any Set monad T , there is a distributive law ρ T : [R, T ] defined for any set X and any Moreover, for monads S and T , the distributive laws ρ S and ρ T are coherent with each other in the sense of the next proposition.Proposition 4.12 Let λ : [S, T ] be a natural transformation.Then the following Yang-Baxter equation holds:

Iterating with the Writer
Recall that M is a monoid and the writer monad in Set is defined as M X = M × X.For any m ∈ M , let m X : X → M × X be defined by m X (x) = (m, x).Example 4.13 For any Set monad T , there is a distributive law ω T : [T, W ] defined for any set X and any (m, t) Moreover, for monads S and T , the distributive laws ω S and ω T are coherent with each other in the sense of the next proposition.

Algebras as Distributive Laws, and Iterating them
In this short section we sketch how Eilenberg-Moore algebras are a particular kind of distributive laws, and how in this view λ-algebras are precisely Yang-Baxter equations.Given a monad T , an Eilenberg-Moore algebra -or T -algebra for short -is a pair (A, t) where A is an object of C and t : an Eilenberg-Moore distributive law -or EM-law for short -is a natural transformation λ : [F, T ] such that the (η − ) and (µ − ) axioms are satisfied.Let S and T be two monads and λ : [S, T ] be a natural transformation.A λ-algebra is a triple (A, s, t) such that (A, s) is an S-algebra, (A, t) is a T -algebra, and the following condition is satisfied: The following result is widely known: Theorem 4.15 ([1,15]) Let λ : [S, T ] be a natural transformation.
• If λ is a distributive law, then the categories of (S • λ T )-algebras and λ-algebras are isomorphic.
• If λ is a weak distributive law, then the categories of (S • λ T )-algebras and λ-algebras are isomorphic.
Let A be an object of C and let A : C → C be the constant functor AX A, Af 1 A .Proof.The Yang-Baxter equation is
Let us illustrate e.g. the second point.Let λ : [S, T ] be a weak distributive law and (A, s, t) be a λ-algebra.According to Propositions 4.16 and 4.17, we are in the presence of a Yang-Baxter equation with one weak distributive law λ and two EM-laws [s] and [t].By applying a mild variation of Theorem 4.5 -consisting in forgetting the monad structure of the functor R = A -we get an EM-law A is an (S • λ T )-algebra.As expected, this procedure amounts to the action of the functor λ-algebras 5 Discussion and Future Work

Advocating String Diagrams
One of the aims of this paper is to advocate string diagrams for proof research and communication.Let us provide two more examples that support our position.

3-16
Weakening and Iterating Laws Using String Diagrams

Cheng's theorem
Let us begin with Cheng's result [11,Theorem 1.6], proved in [11,Appendix A].The largest commutative diagram occurring in the proof for the initialisation case with 3 monads comprises 12 elementary commutative polygons, out of which 9 are naturality squares.Therefore, there are only 3 significant steps in the underlying proof.In an equivalent string-diagrammatic representation of the proof, these three steps are remarkably well identified: That computation (more precisely, its symmetric) has been generalised to weak distributive laws in the present paper: compare diagrams (49) and (24).

Winter's theorem
Another striking example arises from [38].As already mentioned in the introduction, the proof of [38,Theorem 5] [20], i.e., administrative operations devoid of significant mathematical content.

Conclusion
This paper generalises iteration to weak distributive laws using the graphical calculus of string diagrams.It is an additional step in developing the theory of weak distributive laws, as is our line of research in [17,18,16].The paper revolves around one main theoretical result, split in Theorems 4.3, 4.5 and 4.6, and provides several examples.A possible extension would be to derive -in the style of Section 4.2 -a generic Yang-Baxter equation stating compatibility of monotone laws.Monotone laws are a certain class of laws of type [P, T ] and often carry significant semantic content.This direction is particularly interesting, as all known non-trivial examples of weak distributive laws are based on monotone laws.One may also ask whether the existence of a composite law entails the Yang-Baxter equation -this question has been positively solved by Winter in the case of distributive laws [38,Proposition 11].
As hinted in Section 4.3, our results easily adapt to EM-laws (and their duals, called Kleisli-laws), i.e., distributive laws between a monad and a functor.This paves the way for applications of iterated laws in coalgebra theory -as already attempted in [38] -where both EM-laws and Kleisli-laws are ubiquitous.Another possible follow-up to the vision developed in Section 4.3 is to weaken algebras.Indeed, as some EM-laws turn out to be algebras, some weak EM-laws turn out to be so-called semi algebras (as defined in [15]).Dually, coweak Kleisli-laws probably correspond to an interesting class of free algebras.Clarifying the whole picture will most likely enhance the still underdeveloped theory of coweak distributive laws.
Iteration of standard distributive laws has been heavily exploited in the context of categories-asmonads [39,8,7,6].Phrasing our results in a 2-categorical setting, as did Cheng for iterated distributive laws [11], would enable new case studies to arise in that area.
On another level, our key message is to advocate string diagrams to deal with categorical proofs in contexts where traditional equational or commutative-diagrammatic proofs become unreadable.String diagrams are often more convenient in such proofs, as they allow to take a step further by hiding part of Goy 3-17 the complexity in the graphical formalism.Nevertheless, they also have limitations.In the main result of Cheng [11,Theorem 1.6], iteration is performed not only for three monads but for any finite number n of monads: the n = 3 case does only initialise an induction.Generalising the n = 3 result to weak laws becomes reachable using string diagrams -though some diagrams in the proof of Theorem 4.6 already have substantial size.Even with a string-diagrammatic approach, generalizing further to n monads may require tedious proofs.Our opinion is that ingenious string-diagrammatic reasoning significantly pushes back the -fuzzy and subjective -boundary between proofs that are intelligible and those that are not.

A Proofs of Section 3
In this section we prove that S • λ T is indeed a monad.To prove the first unitality axiom, i.e., that µ S•T • η S•T K = 1 K , we need equation (10), the equation ι • π = κ, the retract equation π • ι = 1 K , η S unitality and the retract equation again.

B Proofs of Section 4
In this section we provide the missing details from the proof sketch of Theorem 4.6.

B.1 Expressions of κ ϕ and κ ψ
First, let us justify the expressions of κ ϕ and κ ψ in equations ( 32) and (33).Recall that the definition of the idempotent derived from a weak distributive law λ : [S, T ] is given in equation (7) and in the third diagram of (12).Computing κ ϕ is easy by using the definition of the idempotent κ ϕ , the (η − ) diagram for τ and the definition of the idempotent κ λ .
Computing κ ψ is longer because it contains the composite multiplication µ S•T .We use the definition of κ ψ , Lemma 4.4, the retract equation, equation (10), the (η − ) axiom for τ , definitions of κ σ and κ λ , and the retract equation again.

B.2 Separate and Merge the Triple Functor
Let us prove the four equations displayed in (39), which we recall here: 3) For once we may restate and prove these properties using plain equational reasoning -they will nonetheless be applied in string-diagrammatic form in the next section.Equationally, the properties are as follows: To prove (S1) and (M1), recall that we defined and To prove (S2) and (M2), notice that  To prove that these are equal, we will manipulate separately both of them until their stringdiagrammatic representations coincide.The first multiplication can be transformed as follows, using equation (M2), equation (11), the retract equation, Lemma (4.2) and the retract equation again.

C Proofs of Section 5
In this section we restate one implication of [38,Theorem 5] and prove it using string diagrams.
Definition C.1 Let F be a functor, S and T be monads, and S •T be their composite monad with respect to some distributive law of type [S, T ].A Winter-law is a natural transformation λ : T F ⇒ F ST such that Theorem C.2 (Winter's theorem converse implication) Let F be a functor, S and T be monads, λ 0 : [S, T ] be a distributive law, λ 1 : T F ⇒ F ST be a Winter-law and λ 2 : [F, S] be an EM-law.Assume the following coherence axiom is satisfied: Then λ : [F, S • T ] is an EM-law.

T T T T T T T T T T T T T T (C.7) ✷
λ : [S, T ] yields a monad S • λ T

Goy 3 - 7
String diagrammatically, the equations from Lemma 3.10 can be represented as below.
T ] is a weak distributive law -and, in general, not a distributive law.Such distributive laws are called trivial, because S • T = T [16, Proposition 2.12].In diagrams: axiom

Example 3 . 13
The natural transformation λ : [P, D] defined for any distribution of subsets p and λ : [S, T ], σ : [R, S], τ : [R, T ] be natural transformations such that the following equation holds.

Section 4 . 1 . 1 ,Theorem 4 . 6
yields by Theorem 4.3 a weak distributive law ϕ : [R • S, T ] and thus a monad (R • S) • T .The second one, described in Section 4.1.2,yields by Theorem 4.5 a weak distributive law ψ : [R, S •T ] and thus a monad R •(S • T ).Contrary to Theorem 4.1, it is not obvious that even the underlying functors of these two monads are the same.It turns out that they are, and that more broadly, one can identify these two monads, allowing us to write unambiguously R • S • T .Let R, S, T be monads, λ : [S, T ], σ : [R, S] be weak distributive laws and τ : [R, T ] be a distributive law, satisfying the Yang-Baxter equation.Then the weak distributive laws ϕ π σ T • Rλ • τ S • T ι σ : [R•S, T ] and ψ Rπ λ •σT •Sτ •ι λ R : [R, S•T ] generate the same monad, i.e., (R • S)•T = R•(S • T ).
44) Applying Theorem 4.6 with e.g. the weak λ : [P, D] from Example 3.13, we deduce that the monad R • P • D can be obtained either using the distributive law ψ = ρ P •D : [R, P • D] or using the weak distributive law ϕ Rλ • ρ D P : [R • P, D] given by the expression

Proposition 4 . 14
Let λ : [S, T ] be a natural transformation.Then the following Yang-Baxter equation holds:λW • T ω S • ω T S = Sω T • ω S T • W λ(47) Applying Theorem 4.6 with e.g. the weak λ : [P, D] from Example 3.13, we deduce that the monad P • D • W can be obtained either using the distributive law ϕ = ω P •D : [P • D, W ] or using the weak distributive law ψ λW • T ω S : [P, D • W ] given by the expression all objects X, which simplifies into the associativity axiom t • T t = t • µ T A .✷ Proposition 4.17 Let (A, s) be an S-algebra, (A, t) be a T -algebra, and λ : [S, T ] be a natural transformation.Then (A, s, t) satisfies the (λ-condition) if and only if the Yang-Baxter equation holds between [s] : [A, S], [t] : [A, T ] and λ : [S, T ].
required a Prolog program to find a convenient tiling of the largest required commutative diagram, depicted in [38, Appendix A].That diagram comprises 13 + 10 = 23 elementary commutative polygons, out of which 15 are naturality squares.Therefore, there are only 8 significant steps in the underlying proof.An equivalent string-diagrammatic formalisation of the diagram in question is presented in Appendix C. As expected, it contains only 8 steps, and the computation can be carried out in one single line.Winter's proof research was obfuscated by what Hinze and Marsden call bookkeeping 12) andπ ϕ • π σ T = π ψ • β • π σ T (B.13) = π ψ • Rπ λ • ι σ T • π σ T (B.14) = π ψ • Rπ λ • κ σ T (B.15)B.3Units and Multiplications CoincideAt this point, we already know that the weak distributive laws ϕ : [R • S, T ] and ψ : [R, S • T ] generate respectively a monad (R • S) • T and a monad R • (S • T ) whose underlying functors coincide.It remains to prove that the units and multiplications coincide.Let us begin with units.

3 - 22 Weakening
and Iterating Laws Using String DiagramsAccording to the general theory of weak distributive laws from Section 3, the units of the monads generated by ϕ : [R • S, T ] and ψ : [R, S • T ] are respectively:η (R•S)•T = η R•(S•T )these are equal, we just need to use equation(10) for κ λ , and equation (M1).The situation is more intricated for multiplications.According to the general theory of weak distributive laws from Section 3, the multiplications of the monads generated by ϕ : [R • S, T ] and ψ : [R, S • T ] are respectively:= µ R•(S•T ) µ (R•S)•T Hence both multiplications are equal.This achieves the proof that (R • S) • T and R • (S • T ) coincide as monads.

Table 1
Required axioms for the law α

Table 2
Required axioms for the composite law ϕ

Table 3
Required axioms for the composite law ψ