The Many-Worlds Calculus

We propose a new typed graphical language for quantum computation, based on compact categories with biproducts. Our language generalizes existing approaches such as ZX-calculus and quantum circuits, while offering a natural framework to support quantum control: it natively supports"quantum tests". The language comes equipped with a denotational semantics based on linear applications, and an equational theory. Through the use of normal forms for the diagrams, we prove the language to be universal, and the equational theory to be complete with respect to the semantics.


Introduction
The basic execution flow of a computation is arguably based on three notions: sequences, tuples and branches.Sequences form the building block of compositionality, tuples are what makes it possible to consider multiple pieces of information together, while branches allow the behavior to change depending on the inputs or on the state of the system.
Ranging from (sometimes informal) flow-chart languages [3] to sophisticated structures such as interaction or proof nets [25,19], graphical languages are commonly used to represent the possible control flow of a computation.On a formal level, a graphical language is a PROP [24], that is, a symmetric, strict monoidal structure (C, , ) whose objects are of the form W • • • W .The object W is a "wire", and any object stands for a bunch of wires.The monoidal structure formalizes how the bunching of wires behaves.
Two Canonical Monoidal Structures.The monoidal structure of a PROP is very versatile.On one hand, it can be considered in a multiplicative way, with A B seen as the pairing of an element of type A and an element of type B. This approach is one followed in the design of MLL proof-nets for instance [14].On the other hand, one can consider the monoidal structure in an additive way, with for instance being a co-or a bi-product.Standard examples are the category FinRel of finite sets and relations, forming an additive PROP with being the disjoint union, or the category of finite dimensional vector spaces (or semi-modules) and linear maps, with being the cartesian product.From a computational

XX:2
The Many-Worlds Calculus perspective, an additive monoidal structure can be regarded as the possibility to choose a computational path upon the state of the input.Depending on the underlying system, this choice can be regarded as deterministic (if based on Set), non-deterministic (if based on Rel), probabilistic (if based on a suitable semi-module), etc.
To be able to handle both pairing and branching in a PROP, we cannot uniquely identify as being multiplicative additive.We instead need to extend the PROP with two additional monoidal structures, one for pairing (⊗) and one for branching (⊕).
In this paper, we focus on a framework where these two monoidal structures are available.Graphical languages for such a setting usually rely on a notion of sheet, or worlds, to handle general branching [16,26].Figure 1a shows for instance how to represent the construction of the morphism f ⊕ g : A ⊕ A → B ⊕ B out of f : A → A and g : B → B .The symbol "⊕" stands for the "split" of worlds.Such a graphical language therefore comes with two distinct "splits": one for the monoidal structure -leaving inside one specific world-, and one for the coproduct -splitting worlds-.They can be intertwined, as shown in Figure 1b.Another approach followed by [13] externalizes the two products (tensor product and coproduct) into the structure of the diagrams themselves, at the price of a less intuitive tensor product and a form of synchronization constraint.
However, in the state of the art this "splitting-world" understanding has only been carried for deterministic or probabilistic branching [14,16,30].These existing approaches do not support more exotic branchings, such as quantum superposition.
are still tied to the quantum coprocessor model in the sense that the only monoidal structure that can be applied to quantum information is the (multiplicative) Kronecker product.The only possible branching is based on the (probabilistic) measurement.
Quantum Control Flow.However, one peculiar feature of quantum computation is noncausal execution paths.Indeed, the Janus-faced quantum computational paradigm features two seemingly distinct notions of control structure.On the one hand, a quantum program follows classical control: it is hosted on the conventional computer governing the coprocessor, and can therefore only enjoy loops, tests and other regular causally ordered sequences of operations.On the other hand, the lab bench turns out to be more flexible than the rigid coprocessor model, permitting more elaborate purely quantum computational constructs than what quantum circuits or ZX-calculus allow.
The archetypal example of a quantum computational behavior hardly attainable within quantum circuits or ZX-calculus is the Quantum Switch.Consider two quantum bits x and y and two unitary operations U and V acting on y.The problem consists in generating the operation that performs U V on y if x is in state |0 and V U if it is in state |1 .As x can be in superposition, in general the operation is then sending (α |0 + β |1 ) ⊗ |y to α |0 ⊗ (U V |y ) + β |1 ⊗ (V U |y ).It is a purely quantum test: not only can we have values in superpositions (here, x) but also execution orders.This is in sharp contrast with what happens within the standard quantum coprocessor model.
Computational models supporting superpositions of execution orders have been studied in the literature.One strand of research consists in proposing a suitable extension of quantum circuits [8,28,31,32].These approaches typically aim at discussing the notion of quantum channel from a quantum information theoretical standpoint.

Limitation of Current Approaches and Objective of the Paper.
Although there is a finer and finer understanding of superposition of causal orders in the literature, none of the existing PROPs can support both the quantum switch on complex data built from tensors and coproducts.We claim in this paper that the same intuition underlying probabilistic branching can be followed for quantum (and more general) branching.In the conventional case, 1 ⊕ 1 is a regular boolean: either "left" (standing e.g. for True) or "right" (standing e.g. for False).In quantum computation, the sum-type 1 ⊕ 1 can however be understood as a sum of vector spaces, giving an alternative interpretation to 1 ⊕ 1: it can be regarded as the type of a quantum bit, superposition of True and False.One should note that this appealing standpoint should be taken cautiously: (Pure) quantum information imposes strong constraints on the structure of the data in superposition: orthogonality and unit-norm have to be preserved [1,29].
The Quantum Switch can then be naturally understood in this framework.Consider for instance Figure 2, read from left to right: as input, a pair of an element of type A and a quantum bit.Based on the value of the qubit (True or False), the wire A goes in the upper or the lower sheet, and is fed with U then V or V then U .Then everything is merged back together.

Contributions.
In this paper, we introduce a new graphical language for quantum computation, based on compact category with biproduct [23].This language allows us to express any process with both pairing and a general notion of algebraic branching, encompassing deterministic, non-deterministic, probabilistic and quantum branching.We develop a denotational semantic and an equational theory, and prove its soundness and completeness with respect to the semantics.As a case-study, we show how the Quantum Switch can naturally be encoded in the language.In the paper, the missing proofs can be found in Appendix.

XX:4 The Many-Worlds Calculus
Figure 2 Quantum Switch with Worlds

The Many-Worlds Calculus
Our calculus is parameterized by a commutative semiring (R, +, 0, ×, 1).It can be instantiated by the complex numbers (C, +, 0, ×, 1) to represent pure quantum computations, the non-negative real numbers (R ≥0 , +, 0, ×, 1) for probabilistic computations, or the booleans ({False, True}, OR, False, AND, True) for non-deterministic computations.While the goal is to define a graphical language in which each wire can be enabled or disabled depending on the world in which the computation takes place, we first define the category C D of diagrams without any "worlds", and will then add the world annotations.

A First Graphical Language
We define our graphical language within the paradigm of colored PROP [4,21], meaning that a diagram will be composed of nodes, or generators, linked to each other through colored wires, that are allowed to cross each others.Additionally, we assume that our colored PROP is compact closed and auto-dual, i.e. we allow to bend wires to obtain a Cup ( A A

A A
).The generators of our language are described in Figure 3 and are respectively the Identity, the Swap, the Cup, the Cap, the Plus, the Tensor, the Unit, the n-ary Contraction for n ≥ 0, and the Scalar for s ranging over the commutative semiring R. Mirrored versions of those generators are defined as syntactic sugar through the compact closure, as shown for the mirrored Plus on the right-hand-side of Figure 3. Diagrams are read top-to-bottom: the top-most wires are the input wires and the bottom-most wires are the output wires.The labels A, B, etc correspond to the colors of our PROP.There is one color for every type generated by the syntax1 A, B :: As such, the Unit starts a wire of type 1, the Plus combines two wires of type A and B into a wire of type A ⊕ B, and similarly the Tensor combines two wires of type A and B into a wire of type A ⊗ B.
In a colored PROP, an object A is simply a list of colors A = A 1 . . .A n (or A = for the empty collection).For example, the Plus is a morphism from A B to A ⊕ B. The choice of the notation for wires in parallel is uncommon, we use it to put an emphasis on the fact that contrary to languages like the ZX-calculus, wires that are in parallel are not necessarily "in tensor with one another".In fact, A B can be understood semantically as "either A ⊗ B or A ⊕ B".
Diagrams are obtained from generators by composing them in parallel (written ), or sequentially (written •).Sequential composition requires the type (and number) of wires to match.We write C D for the category of diagrams we defined as such.

XX:5
Figure 4 A Quantum Bit and the Hadamard Unitary Example 1.We consider R = C.While C D lacks the worlds labeling2 , we can already illustrate our language by encoding some basic quantum primitive in it and show how they operate.In Figure 4 we show the encoding of a quantum bit α |0 + β |1 and the Hadamard unitary.In particular, the Plus allows to "build" a new quantum bit from two scalars in parallel or to "open" a quantum bit to recover its corresponding scalars, the left branch corresponding to |0 and the right branch to |1 .The meaning of the Contraction is better seen when applying Hadamard to a quantum bit as we show in Figure 5: it allows us to duplicate and sum scalars.The rewriting sequence of Figure 5 is made using the equational theory defined in Section 4, however to correctly define our equational theory, the worlds labeling are required.So while this specific worlds-free rewriting sequence is sound, many other similar worlds-free rewriting sequences are unsound.

Adding Worlds Labeling
We now label wires of our diagram with sets of worlds w ⊆ W from a given a world set W .
For each world a ∈ W , wires labeled by a set containing a are said to be "enabled in a", and the others are said "disabled in a".This allows us to correlate the enabling of wires.Before making this formal, we illustrate this notion through the following example: Example 3. The "controlled not" on quantum bits can be represented by the Figure 6a.The figure is split into two parts: the control part on the left-hand-side, and the computational part on the right-hand-side.The idea is that the control part, that uses ⊕, will behave as an if-then-else and will bind the world a to the case where the control quantum bit is |0 , and the worlds b and c to the case where the control quantum bit is |1 .Lastly, the world appears nowhere in the labels, and corresponds to "we do not evaluate this circuit at all"3 .On the computational part, we apply the identity within the world a, we negate |0 into |1  We now give a formal definition of the concept of worlds: Definition 4. Given a set of worlds W , we define the auto-dual compact closed colored PROP (MW W , , ) of many-worlds calculus over W as follows: Its colors are the pairs (A : w) of colors A of C D and subsets w ⊆ W .We write (A, A ) for the objects, where A is an object of C D and A is a labeling function from the colors composing A to the subsets of W .
and a labeling function f from the wires of D f to the subsets of W , satisfying the following constraints: The label on an input or output wire of color (A : w) must be equal to w, and where denotes disjoint set-theoretic union.The constraints for the mirrored versions are similar.The sequential composition • and the parallel composition preserve the labels.

We write [f ]
where A and B can be deduced from f using the first restriction on labels.We note that when considering [f ] W : A → B and [g] W : B → C, there is no reason for the labels deduced on B to be the same, so there is no reason for [g • f ] W : A → B to be defined.More generally, when building two diagrams [f ] W and [g] V , there is no reason for the worlds sets W and V to be equal, but we might still want to be able to compose them with one another.

The sequential composition is given by
is the greatest subset such that this composition is well-defined, as explained in the following example.
Example 6 (World Agnostic Composition).In Figure 6b, we show the result of the parallel composition of [f ] {a, } = id A:{a} and [g] {b, } = id A:{b} for a color A: the world (a, ) corresponds to the left wire being enabled and the right one disabled, the world ( , b) is the opposite, the world (a, b) is both enabled and the world ( , ) is both disabled.
Then, in Figure 8 we continue by composing with the Cup over A : {c, }.To compute the composition, we proceed in two steps: first we handle the situation as if it were a parallel composition, leading to a diagram labelled over W × V × U , but with multiple contradictory labels on the wire.Then, we eliminate as few worlds as possible to make those labels compatible: We eliminate (a, b, ) and (a, , ) which are on the left label but not on the bottom one.We eliminate ( , b, c) and ( , , c) which are on the bottom label but not on the left one.
Looking at the right, we eliminate ( , b, ) and (a, , c) for similar reasons.We eliminated six worlds, with the only remaining ones being Z = {(a, b, c), ( , , )}.

Representing Computation
As a motivational example, we may see how this Many-Worlds diagrams can be used to represent computations expressed in a language that explicitely uses the two compositions ⊗ (through pairs), and ⊕ (through pattern-matching), as in [29].As this translation is not the focus of this paper, a lot of technicalities are glossed over.

Syntax of the Language
The language we present here is adapted from [29], where we consider the values and types together with the enrichment that is linear combinations of terms, but without abstraction (a, ,c),(a, , ),  ( ,b,c),( ,b, ),  ( , ,c),( , ,  nor recursion.The syntax that is used in the language is given as follows, with scalars s ranging over the commutative semiring R: The language in particular features branching through the inj l and inj r constructors, linear combinations of terms and expressions, and crucially isos that have type A ↔ B: they turn a term of type A to a term of type B using pattern-matching.The language comes with a predicate (not presented here, although it could be given a diagrammatic meaning), used in the typing rule of isos, to ensure exhaustivity and the non-overlapping character of the left-hand and right expressions of the clauses, allowing in particular to define unitaries (in the complex setting).Constraints on the linear combinations may also be used to enforce probabilistic constraints (i.e. that states are normalised in the quantum setting).
There are two different typing judgements, one for terms t and one specific for isos ω .For a more complete description of the language, we refer the reader to [29].In the following, we will use the shorthands ff := inj l and tt := inj r .
Example 7. In the case where R = C, one can encode the Hadamard gate by: In this setting, any quantum circuit can be encoded by an iso.

Encoding into the Many-Worlds
One can encode any term of the language into a Many-Worlds diagram.Given some typing derivation ξ of a term x 1 : A 1 , . . ., x n : A n t t : B we write ξ for the function that maps ξ to a diagram in the Many-Worlds Calculus with n input wires of type A 1 , . . ., A n and one output wire of type B. For the typing derivation ξ of an iso ω ω : A ↔ B, ξ gives a diagram with one input wire of type A and one output wire of type B. ξ is defined inductively over t and ω as shown in appendix in Figure 14, where the worlds sets are handled by compositions of world-agnostic diagrams.
Example 8. We can represent the term (already given in [29]) as shown in Figure 9.The yellow box stands for the Hadamard gate (which one can build following Example 7).Each line of this isomorphism corresponds to a column of the figure.Each columns start by matching the input as tt, x or ff, x , then compute y from x, and then build the output by following the syntax.The world set is computed by composing each of the blocks of this term, using the world-agnostic composition of MW ∀ .It can be seen as a subset of {a, b} × {c, c } × {0, 1, 2, 3} where {a, b} corresponds to being on the first or second line of the matching, {c, c } being on the left or right of the sum, and {0, 1, 2, 3} being the world set of the Hadamard gate.

Comparison with Other Graphical Languages
The distinctive feature of the Many-Worlds Calculus is that it graphically puts the tensor and the biproduct on an equal footing.By comparison, other graphical language for quantum computing are inherently centered around either one of them.The ZX-calculus [11] and cousin languages ZW-and ZH-Calculi [2,22], as well as Duncan's Tensor-Sum Logic [16], use the tensor product as the default monoid, while more recent language -particularly for linear optics [9,15,10] -use the biproduct.We have a closer look at each of them in the following, and show how -at least part of -each language can be encoded naturally in the Many-Worlds Calculus.Most of them comes equipped with an equational theory.By completeness of our language (Theorem 11 to follow), all the equations expressible in the fragments we consider can be derived in our framework.

ZX-Calculus
The first difference is the restrictions of the ZX-calculus to computations between qubits, in other words linear map from C 2 n → C 2 m , while our language can encode any linear map from C n → C m .The Tensor generator allowing the decomposition of C 2 n into instances of C 2 was already present in the scalable extension of the ZX-calculus [5], but the main difference comes from the Plus (and the Contraction).
Additionally, every ZX-diagram can be encoded in our graphical language.The identity, swap, cup and cap of the ZX calculus are encoded by the similar generators over the type 1 ⊕ 1, the Hadamard gate is encoded as in Figure 4, and the green spider is encoded as shown on the right.An encoding for the red spider can then be deduced from those.Diagrams are composed them together with the world-agnostic composition of MW ∀ .

Tensor-Sum Logic
The core difference between their work and ours is the presence of the contraction in our graphical language.They instead rely on an enrichment of their category by a sum, which they represent graphically with boxes.We show on the right how the morphism f + g would be encoded in both their and our language.More generally, their boxes correspond to uses of our contraction generator in a "well-bracketed" way.Another point of difference is their approach to quantum computation, as we do not assign the same semantics to those superpositions of morphisms.In their approach, the superposition is a classical construction and corresponds to the measurement and the classical control flow, while in our approach the superposition is a quantum construction and corresponds to the quantum control.

PBS-Calculus
The PBS Calculus [9] allow one to represent coherent quantum control by the use of polarising beam splitters (pbs): whenever a qbit enter a pbs node, depending on the polarity of the qbit it will either go through or be reflected.By making implicit the target system, controlled by the optical system represented by the diagram, the PBS-Calculus allows one to encode the Quantum Switch (depicted on the right).The pbs generator is related to the ⊕ of the Many-Worlds.
The first main difference with our language is that, since the generators of the PBS-Calculus represent physical components, any PBS-diagram is by construction physical, while our approch is more atomic and decomposes physical components into abstract smaller ones.The second main difference lie in the trace: while they can allow a particle to pass through a wire at most twice, in our system, each wire can be used at most once: more formally, their trace is based on the coproduct while ours is on the tensor product.If we are assured that each wire can only be used once during the computation, any PBS-diagram can be translated to the Many-Worlds calculus direclty, with the transformation on the right, where we distinguish the control system (the part of the diagram connected to s) from the target system (connected to c s) which is implicit in the PBS-Calculus.

LOv-Calculus
In the PBS-Calculus, the qubit in the control system (the one explicitely represented) cannot be put in arbitrary superpositions of |0 and |1 during the computation.To allow this feature, we may add some linear optical components to the language's generators, and end up with the LOv-Calculus [10].In this language, there is no trace and there is a unique photon traveling the circuit, which relieves us of the previous constraint.There is also no need for an implicit target system anymore.All wires at the interface between the generators are of type 1 ⊕ 1, and parallel wires have disjoint sets of worlds.Each generator can then be interpreted as follows:

Path-Calculus
The Path-Calculus is another recent graphical language for linear optical circuits [15].Its generators correspond directly to a subset of the Many-Worlds' with ; where each wire has type 1 and where parallel wires are on disjoint sets of worlds.This language is then used as the core for a more expressive language called QPath, which this time cannot be direclty encoded in our language, except when restricting the set of generators (specifically to n = 1), in which case |1 .

Semantics of the Many-Worlds Calculus
Our calculus represent linear operators between finite dimension R-modules (FdM R ).In particular, in the case R = C we use linear operator between finite dimension Hilbert spaces, which correspond to pure quantum computations.More precisely, we will define two semantics, a world-dependent semantics − a for every world a ∈ W , which will be a monoidal functor from MW W to FdM R , and a worlds-agnostic semantics − from MW ∀ to FdM R .We start by defining those semantics on the objects.For every object A of C D , we define its enablings A • as "replacing any number of wire type by •".For example (A B) Then, for any object (A, A ) of MW W and any world a ∈ W , we define (A, A ) ∩ a to be the enabling of A in which every (A : w) with a ∈ w is preserved and every (A : w) with a / ∈ w is replaced by •.For example (A : Then, for the morphisms, we proceed by compositionality for − a , meaning that we define − a on every generator and compute the semantics of a diagram by decomposing it ∈ FdM R (R, R) otherwise and the (conjugate) transposed operator for the Cap and the (conjugate) transposed operator for the mirrored Plus with g • f a := g a • f a and f g a := f a ⊗ g a .The semantics of most generators is given in Figure 10; for all the other generators their semantics is simply the identity operator.The worlds-agnostic semantics is defined from the world-dependent semantics, as follows.Consider f ∈ MW W ((A, A ), (B, B )), we define: For example, the worlds-agnostic semantics of the Tensor and the Plus are simply the collection of all their world-dependent semantics assembled into a single linear operator: The worlds-agnostic semantics is functorial (see Appendix C) and is universal in the following sense: Theorem 9 (Universality).For every A, B objects of C D , and for every linear operator

there exists a world set W , and a morphism
Worlds annotations on wires are ommited when uniquely determined.We assume that: Mirrored up-down versions of those equations can be deduced from the compact closure.Additional equations for the ⊕ and the scalars are provided in the next

The Equational Theory
Similarly to how our semantics is defined in two steps, the equational theory is also defined in two steps: 1.A set of equations within MW W for a fixed set of worlds W , which will not be complete, but will be sound for − a for every a ∈ W , hence sound for − too.We write ≡ W for the induced congruence 5 over MW W .We list those equations in Figure 11.Quite notably, the last two rows describe the fact that the contraction is a natural transformation.2. Five additional equations with side effects on the set of worlds, which will be sound and complete for − (but not for − a ).We write ≡ for the induced equivalence relation, which is a congruence over MW ∀ .We have: One equation that allows us to rename the worlds: for every morphism (D f , f ) of MW W , and for every bijection i : Two equations allowing the annihilation (or creation, when looking at them from right to left) of worlds due to coproducts or scalars (first row of Figure 12); Two equations allowing the splitting (or merging, when looking at them from right to left) of worlds due to coproducts or scalars (second row of Figure 12).
Proposition 10 (Soundness).For f a morphism of MW W and g of MW V , whenever 5 In other words the smallest equivalence relation satisfying those equations and such that f XX:14 The Many-Worlds Calculus

Worlds sets
Worlds sets (W \w) w w where every instance of the world a i has been replaced by both a i and a i . Where: where every world of w (resp.z) has been removed from the labels.

Theorem 11 (Completeness). For every [f ]
The soundness can be proved by a case-by-case analysis on every equation.The completeness theorem follows from the existence of a normal form for ≡, as described in Appendix E.1.
Example 12 (The Quantum Switch).Similarly to the "controlled not" in Example 3 where a quantum bit controls whether the identity or a negation is applied to some data, one can consider the case where a quantum bit control whether U • V or V • U is applied to some data (for U and V two quantum operators on the same type A).
On the rightmost part of Figure 13, one can see the most direct implementation of this "quantum switch", but this implementation uses two copies of U and V .On the leftmost part of the figure, we show another implementation which only relies on one copy of each, and both can be rewritten into another using the equational theory.
In those diagrams, the world set is W = w v and we rely on violet, blue and red wires to indicate respectively worlds labels w v, w and v.Each figure has a control side which operates on a quantum bit (type 1 ⊕ 1) and binds the world w to |0 and the world v to |1 ; and a computational side which operates on some data of an arbitrary type A, on which could be applied U and/or V which stand for two morphisms of MW W (A : W, A : W ).
The first rewriting step relies on the two lemmas on the right, both of which being deducible from the equational theory (see Appendix B).The second rewriting step is simply using the properties of a compact closed category.
Figure 13 Rewriting the Quantum Switch

Conclusion
We introduced a new sound and complete graphical language based on compact categories with biproducts, along with an equational theory and a worlds system, helping us to build a denotational semantics of our language.This language is a first step towards the unification of languages based on the tensor ⊗ and those based on the biproduct ⊕.This allows us to reason about both systems in parallel, and superposition of executions, as shown by the encoding of the Quantum Switch in Example 12 and the translation from term of the language in Section 2.3.
Following this translation, a natural development of the Many-Worlds calculus consists in accomodating function abstraction and recursion in the language.The question of a complete equational theory for the language on mixed states (e.g. via the discard construction [6]) is also left open.
Finally, while our language allows for quantum control, it does not entirely capture another language that aims at formalizing quantum control, namely the PBS-Calculus [9].How and in which context could we capture the PBS-Calculus is left for future work.

A Encoding the Iso Language with the Many Worlds Calculus
For simplicity of the encoding, we give the following syntactic sugar: := ... ... ...

B Induced Equations
In Figure 11, we presented a set of equation reasonably small, by having equations parameterized by the arity of the contraction, and by omitting a lot of useful equations that can be deduced from them.In Figure 15, we take the opposite approach: we give equations using the contractions of arity zero and two (which are sufficient to generate all the other contractions) and we provide additional axioms that follows from Lemma 13 and Lemma 14.
Note that this is only an alternative presentation to the equational theory for ≡ W , the axioms of Figure 12 are still required for ≡.Lemma 13.Whenever w i are disjoints sets of worlds, we have the following: Whenever w i are disjoint sets of worlds, and that the v i s are disjoint sets of worlds too, we have the following: Proof.We provide a proof for the third equation, the first two are proven similarly.
Corollary 15 (Naturality of the Binary Contraction).For every f : n (A i : w i ) → m (B j : v j ) with world set W and every u ⊆ W , we have where f \u : n (A i : w i \u) → m (B j : v j \u) is equal to f where every worlds label w has been replaced by w\u, and similarly for f ∩ w.This is simply proven by induction over f .All the generator cases (including Cup and Cap) follow directly from the equations given in Figure 11 an Lemma 14 together with the properties of a compact close category.

Lemma 16 (Empty World). For every f :
This is simply proven by replacing every wire by two contractions of arity zero (sixth axiom of Figure 11 with n = 0), and then using the naturality of the contraction of arity zero (last two lines of Figure 11 with n = 0) to consume every generator.

C
Proof of Functoriality of the World-Agnostic Semantics Proposition 17.The worlds-agnostic semantics − defined in Section 3 is a monoidal functor from MW ∀ to FdM R .
Proof.We recall here the definition of the worlds-agnostic semantics of [f ] W : A → B: From the definition of the worlds-agnostic compositions, we directly have: The functoriality with respect to the parallel composition is then immediate: The functoriality with respect to the sequential composition is more subtle, as one must carefully manipulate the indices of the sum and remark that the set of worlds w eliminated by the worlds-agnostic composition satisfies the following: Then, we have

D Proof of Soundness
Given that most of the time, gen a is the identity, the equations defining ≡ W are quite straightforward to verify.We immediately have that ≡ W is sound with respect to − a for every a ∈ W . Since − is defined from − a , soundness with respect to − is also correct.
We then handle the five additional equations of ≡.
Renaming Applying a bijection to the worlds set W does not change the result computed by a∈W . . ., hence this equation is sound with respect to − .Annihilation due to Scalars This equation simply removes elements equal to zero from the sum a∈W . . ., hence it is sound with respect to − .Annihilation due to Plus Since ⊕ is a biproduct in FdHilb, we have proj One can then simply remove from the a∈W . . . the elements equal to zero, which proves that Annihilation due to Plus is sound with respect to − .Splitting due to Scalars Since FdHilb is a vector space, we have (s + t)

Figure 16
The Normal Form (left) and the Inductive Definition of iso A (right)

E Normal Form, Universality and Completeness
We can prove that the equational theory of Section 4 is complete, by defining a normal form on the morphisms, and by showing that all diagrams can be put in this normal form, which is unique.

E.1 Normal Form
It will be practical for our normal forms to define the following syntactic sugar, which we call the unitor, its unit and its generalized form:  We define the short-hand on the right with the assumption that the world set is in bijection with the set of scalars, in other words the scalars λ i j have for worlds label {a i j }.In particular, all the input (resp.output) wires live in mutually exclusive worlds.
A first important observation is that we can put this diagram in the following alternative form, with exactly the same assumption on the world set: (1) We will freely change between the two representations in the following.Another important observation is that any permutation of wires (all mutually exclusive, and of type 1) can easily be put in this form using the following equations: The normal form of a morphism f : A → B is defined as the form of the diagram on the left of Figure 16, where the morphism iso A is defined inductively right.The output wires of iso A for any A live in mutually exclusive worlds, but once again, we don't overload the diagrams with unitors or world names encoding this information, although it will be used in the following.
Notice that graphically, there is no difference between A (B C) and (A B) C, in other words is strictly associative.However iso A (B C) and iso (A B) C are different, but they are equivalent up to a rearranging of the output wires: Lemma 18.There exists a wire permutation σ such that iso Proof.First notice that in both iso A (B C) and iso (A B) C , we can use the bialgebra between contractions and unitors, followed by their respective fusions in the following way: and similarly for iso (A B) C .It then suffices to check which contractions the bottom unitors are linked to.Naming the ith contraction existing iso A as a i , and similarly for B and C, we can see that for each triple (a i , b j , c k ) there is exactly one unitor connected to precisely contraction a i , b j and c k , in both diagrams.The same is true for every pair (a i , b j ), (a i , c k ) and (b j , c k ), as well as for every 1-tuple (a i , ), (b j , ) and (c k , ).This shows that both diagrams are equal up to rearranging of the outputs.
We define iso -1 A inductively in the same way, but upside-down.We note that iso Proof of Lemma 20.We will use the following identities: We can show this result by induction on n and m.Case (0, m) is obvious.Case (1, 1) can be proven easily using world sets: The proof is similar for ⊗ and using the previous identities.
[iso A • iso -1 A ]: The result is again obvious for 1 and .The general result is easy to prove by induction using the above identities.

E.2 Universality
Now that we have defined a normal form, we may use it to show the universality (Theorem 9) of the language, i.e. that for every A, B objects of C D , and for every linear operator 16 satisfies f = Λ.As stated in the corresponding section, there is one world for each scalar in λ, so we write a i j the world associated to λ i j and W the set of all those worlds.Let us write 1 k 0 = • k for • . . .• (with k elements) and 1 k i for • k where the i-th • has been replaced by 1 if 1 ≤ i ≤ k.Beware that we consider 1 k 0 to be the last element of the canonical basis.We then have λ ai j : Additionally, one can show by induction that iso A ai j is simply the projection on the i-th element of the canonical basis, and iso −1 B ai j is simply the injection on the j-th element of the canonical basis.Since we have f a = iso −1 B a • λ a • iso A a for every a ∈ W , and f being the collection of all the f , we obtain that f = Λ.

E.3 Uniqueness of the Normal Form
An crucial feature of the normal form for the completeness is its uniqueness: Proposition 21.The normal form is unique.
Proof.Let f and g be two diagrams in normal form (with respectively λ and µ as inner block), such that f = g (the naming of the worlds is taken to be the same in both diagrams, and is the same as in the previous proof).By the definition of ., we have f a = g a for every a ∈ W .We hence have iso Denoting e A i (resp.e B i ) the i-th element of the basis of A (resp.B), we have: Hence, all coefficients in the scalars of f and g are the same.Since the structure is otherwise the same for f and g, they are the same diagram.

E.4 Completeness
We can now use this normal form to show that our equational theory is complete for arbitrary morphisms.To do so, we need to show that all the generators can be put in normal form, and then that any composition of morphisms in normal form can be put in normal form.To do so we will first derive a few lemmas:    Proof.Suppose the worlds of λ are the {a ij } ij and that of µ are the {b k } k .We count inputs/outputs starting at 1, hence p ≥ 1 in the following.
The p-th output of λ has world set {a ip } i and the p-th input of µ has world set {b p } .When composing the two in sequence, in the first step, each singleton world {a ij } (resp.{b k }) is mapped to {(a ij , b k )} k (resp.{(a ij , b k )} ij ), and unions of singleton worlds to unions of the worlds each is mapped to.
In particular, the p-th output of λ now has world set {(a ip , b k )} ik , and the p-th input of µ now has world set {(a ij , b p )} ij .After composition, the two sets have to match.They become {(a ip , b p )} i , and all pairs of world that were removed from these two sets are removed globally.
We do so for all p ≥ 1, which means all worlds in: are removed.Crucially, this means that the world sets {a i0 } i and {b 0 } are mapped to the same world set: Hence, the sequencial composition of λ and µ becomes:                This finally allows us to prove the completeness theorem claimed above:

Figure 1
Figure 1 Examples of branchings

Remark 2 .
Instead of having the Cup and the Cap as generators and defining the mirrored version of each generator through them, one could proceed the other way around by defining the Cap as follows, and the Cup in a mirrored way:

Figure 5 1 ⊕ 1 :
Figure 5 Applying the Hadamard unitary to a quantum bit

Figure 8
Figure 8 Example of Worlds-Agnostic Sequential Composition

y HFigure 9
Figure 9 Representation of the term t from Example 8.

Figure 10
Figure 10 Semantics of the Generators of MWW in a World a ∈ W .

Figure 11
Figure 11Equations with a Fixed World Set W

Figure 12
Figure 12Equations with Side-Effects on World Sets

Figure 14 w 1 w 2 w 3 w 1 w 2 w 3 w 1 w 2 w 3 w 1 w 2 w 3
Figure 14 Inductive translation of terms from Section 2.3 into Many-Worlds diagrams.

w 1 w 2 w w 1 w 2 w w 1 w 2 w w 1 w 2 Figure 15
Figure15 Alternative Presentation of the Equational Theory with a Fixed World Set W wires a ij , b i , c j are mutually exclusive For any n and m, we can then prove the case (n + 1, m) using the cases (n, m) and (1, m) (the case (n, m + 1) is completely symmetric): ≡ ... ... In a similar way, it is possible to show the following three identities: wires a ij , b i , c j are mutually exclusive c c wires a ij are mutually exclusive[iso -1 A • iso A ]:The result is obvious in cases 1 and .For A ⊕ B:

10 with ν ij = k λ ik µ kj . Lemma 27 .
For any "matrix block" λ, there exists a "matrix block" ν such that: We show the result through several steps.First we show the following: deal with the top dangling scalars and prove that:

Proposition 29 .
Compositions of diagrams in normal form can be put in normal form.It is then possible to show that compositions of diagrams in normal form can be put in normal form:Proof.In the case of sequential composition: represents the canonical choice of composition with (and similarly for B D).
which is exactly the property required for this equation to be sound for − .Splitting due to Plus Similarly, we have in FdHilb the property that id H⊕K = inj H⊕K −1 A• iso A is the normal form of id A .
). Single-colored isos distribute over the contraction: c c ... Lemma 24.Scalars distribute over single-colored isos: s Proof.The result is obvious for 1 and .For A ⊕ B: s = iso A s ≡ iso A