Routed quantum circuits

We argue that the quantum-theoretical structures studied in several recent lines of research cannot be adequately described within the standard framework of quantum circuits. This is in particular the case whenever the combination of subsystems is described by a nontrivial blend of direct sums and tensor products of Hilbert spaces. We therefore propose an extension to the framework of quantum circuits, given by \textit{routed linear maps} and \textit{routed quantum circuits}. We prove that this new framework allows for a consistent and intuitive diagrammatic representation in terms of circuit diagrams, applicable to both pure and mixed quantum theory, and exemplify its use in several situations, including the superposition of quantum channels and the causal decompositions of unitaries. We show that our framework encompasses the `extended circuit diagrams' of Lorenz and Barrett [arXiv:2001.07774 (2020)], which we derive as a special case, endowing them with a sound semantics.


Introduction
Finite-dimensional quantum theory is often described through the framework of quantum circuits [1,2,3,4,5]. This framework is built on the possibility of both sequential and parallel compositions, with the latter represented by tensor products of completely positive trace-preserving maps. This enables quantum theory to be expressed graphically through circuit diagrams, the intuitive nature of which is an important reason for the success of the framework of quantum circuits. Yet, two different lines of research recently led to the introduction of scenarios and structures which, as we shall argue in the present work, cannot be described in a fully satisfactory way when using the sole framework of standard quantum circuits 1 . These scenarios and structures share two deeply interlinked key features. The first of these features is the presence of quantum channels satisfying specific constraints on their ability to relate given sectors (i.e. orthogonal subspaces) of their input and output spaces (we shall call these constraints 'sectorial constraints'). The second is the existence of parallel compositions of 1 This has to be distinguished from the recent surge in interest in indefinite causal order (ICO) [6,7,8,9], which also goes beyond standard quantum circuits in a different way. Even though the framework presented here would have natural applications to the study of ICO [10], it is important to emphasise that the features that differentiate it from standard quantum circuits are not of the same kind as those that give rise to ICO; all the constructions under study in the present work display a definite causal order. such channels which consist in non-trivial blends of tensor products and direct sums (we shall characterise them as featuring 'sectorial correlations' between parallel systems).
The first of the lines of research exhibiting these features is that of coherent control, or superpositions, of quantum channels [11,12,13,14]. The coherent control of quantum channels generalises the 'if' clause in classical computation to the quantum level, where the use or not of a given quantum channel is determined by the value of another quantum system -enabling the possibility of using multiple quantum channels in a superposition. This idea can be applied equally to computation, where it is often referred to as control of unknown unitaries (or channels) [15,16,17,18,19,20,21] and communication, where it takes the form of communication in a superposition of trajectories [22,23,24,25,26,27,28]. We shall describe superpositions of quantum channels in depth in Section 2.1, focusing on the communication perspective of Ref. [24]. In this line of research, in particular from the communication point of view, sectorial constraints and non-trivial parallel compositions have a direct physical meaning, as they serve to describe a physical setup in which a particle is sent in a coherent superposition of two transmission lines. The sectorial constraints correspond to the fact that transmission lines are required not to modify the number of particles going through them. The non-trivial parallel composition of the two transmission lines corresponds to the fact that there is exactly one particle in total.
A second line of research, that of causal decompositions [29,30,31,10] (described more comprehensively in Section 2.2), aims at probing the equivalence between the compatibility of a unitary channel with a given causal structure, and the existence of a decomposition for this channel along a given unitary circuit in which this causal structure is made obvious. In this context, it was found that, in order to prove such an equivalence in some cases, one has to consider decompositions in which some of the unitary channels satisfy sectorial constraints and are parallelly composed in a non-trivial way. In other words, describing the full scope of possible compositional structures of channels in quantum theory requires the introduction of sectorial constraints and non-trivial parallel compositions -something which cannot be done through the use of standard quantum circuits. Here, in contrast with the previous example, these new structures are not introduced to depict physical specifications, but to unlock a more flexible mathematical description.
It is striking that two very different lines of research led to the introduction of the same structures; this might be an indication that such structures are common in the study of quantum phenomena. Indeed, they can be seen as being the proper tools to depict the breaking down of a finite-dimensional C* algebra into (possibly non-factor) commuting subalgebras [32], a decomposition which is central to powerful theorems and techniques in quantum theory, such as the Schur-Weyl duality and its generalisations [33,34], or the existence of decoherence-free subspaces [35,36,37,38,39,40]. Possibly non-factor sub-C* algebras have also been argued to yield the proper mathematical notion of subsystems in quantum theory (for an overview, see Ref. [41] and the references therein), and have recently been studied for the properties of their entanglement entropy [42,43,44]. Finally, these structures are common in quantum optical setups, in which photons are usually sent in a superposition of trajectories; it has already been argued in [17] that such setups cannot in general be suitably described by standard quantum circuits (the discussion in [18] also relates to this point, see footnote 3).
Even though they were shown to be fairly natural and physically meaningful in the two lines of research in which they have been introduced, the new structures corresponding to sectorial constraints and correlations were described, and had their consistency proven, only at the level of the specific situations considered in each case; no systematic description and formalisation has been undertaken. As we shall argue in Section 2, such a systematic description cannot be faithfully obtained when solely using the framework of quantum circuits, as this framework lacks the tools both to hardcode sectorial constraints on quantum channels, and to describe non-trivial parallel compositions. An extension of this framework is therefore needed.
Such an extension would need to satisfy several requirements. First, given the strong compositional flavour of the structures at hand, it would need to be appropriately compositional (i.e., emphasising the sequential and parallel composition operations on channels and their structures). Second, drawing lessons from recent successful re-expressions of quantum theory [45,46,47,48,3], this extension would have to form a process theory [5], focusing on dynamical processes (i.e., channels) and obtaining states as specific cases of the latter: the emphasis on compositional structure is more natural in process theories. Third, it should yield intuitive, higherlevel (i.e. diagrammatic) expressions, from which the sectorial constraints and correlations can be read off. Finally, this extension should be general enough, encompassing all possible situations in which sectorial constraints and correlations could appear, and should yield a theory of pure states and unitaries as well as one of mixed states and general quantum channels.
The aim of this paper is to present such an extension, obtained through the introduction of routed maps. In addition to a linear map, a routed map includes a boolean matrix, called the route, which encodes constraints on the possibility for the linear map to relate given subspaces of its input and output spaces (sectorial constraints). Sectorial correlations are then obtained as a contextual feature, specified by the global circuit in which a parallel composition is present (and, more specifically, by the routes in this circuit). We prove that routed maps form a consistent theory which faithfully describes the structures previously mentioned, and which possesses the compositional features required to accept a consistent diagrammatic expression. In both the pure and mixed theories, we single out physically meaningful routed maps and provide rules for the (non-trivial) problem of their sequential composition. We present and exemplify a general and user-friendly diagrammatic representation for routed maps, and show how it allows for faithful and intuitive depictions of physical scenarios.
Finally, we use our framework to provide a solid mathematical basis for the 'extended quantum circuits' of Ref. [31], previously introduced in a qualitative and non-systematic way for the study of causal decompositions of unitary channels. We show here how a sub-framework of routed maps, that of index-matching routed maps, allows to give a precise meaning to the 'extended quantum circuits' of Ref. [31] (which we shall here denote as 'index-matching quantum circuits'). We use this framework to provide a systematic account of index-matching quantum circuits and of their interpretations, and in particular to prove a simple rule which singles out the well-indexed index-matching quantum circuits, which correspond to physical circuits.
One of the main achievements of this paper is to prove that the frameworks we build can be expressed in a fully diagrammatic language, in terms of circuits. The proper mathematical characterisation of this feature is given by category theory, and more specifically by the fact that these frameworks form dagger symmetric monoidal categories (dagger SMCs). In order not to burden the paper with formal notions, we leave our discussion of these categorical features to the appendices; in the main text, we will be describing the structural qualities of our frameworks in more natural terms. An account of the categorical constructions leading to routed theories will also be provided in an upcoming paper [49].
The structure of this paper is as follows. In Section 2, we argue for the necessity of going beyond standard quantum circuits, by presenting and analysing the results of two recent lines of research. In Section 3, we present the framework of routed maps in the case of pure quantum theory, prove that it allows for a consistent diagrammatic representation, and show it in action by means of an example. In Section 4, we describe the kinds of diagrams this framework leads to, and their interpretation. In Section 5, we extend our framework to encompass general quantum channels, and illustrate with an example how it leads to natural decoherence computations. Finally, in Section 6, we show how a sub-framework of routed maps gives rise to the index-matching quantum circuits of Ref. [31], endowing them with a sound and systematic semantics.

Motivation
In order to motivate the introduction of routed maps, we will first describe the objects of study and the results of two recent lines of research, and argue why they cannot be described in a fully satisfactory manner within the sole framework of quantum circuits 2 .

Communication and computation in a superposition of trajectories
The study of communication in a superposition of trajectories was recently proposed as a framework which extends standard quantum Shannon theory [24,26]. In this framework, not only is the information carried by a particle allowed to be in a quantum state, but also the trajectory of the quantum information carrier is allowed to be in a coherent superposition of different transmission lines. The goal of Refs. [23,24] was to study the communication advantages that using such scenarios can lead to. In a similar spirit, several recent works have investigated the use in quantum computation of controlling unknown 'black box' quantum operations, where a quantum control system determines if one unknown operation is used, or another, or both in a superposition [15,16,17,18,19,20,21]. Here, we will describe the challenges that these works raise in terms of mathematical formalisation. To do so, we will focus on a paradigmatic example of communication in a superposition of trajectories, the 'one particle in two trajectories' scenario [24,23], focusing specifically on the perspective of Ref. [24].
Even though we will focus on this specific example in order to present sharp arguments on a well-defined situation, the following analysis applies to a wide range of quantum-optical or interferometric setups to show that, in general, they cannot be faithfully described by standard quantum circuits. Indeed, the features of this example are common in quantum optics, in which sending a photon in a superposition of trajectories, and applying operations which do not modify the number of photons (such as waveplates) are standard protocols. This point has, in particular, been encountered in different guises in the literature discussing the possibility of coherently controlling unknown unitaries [15,17,18,19] or quantum channels [11,12,13,14,20,23,24,21]: no-go theorems forbid such coherent control in standard quantum circuits, yet it is achievable in 2 In technical terms, this means that they cannot be adequately described using the categories FHilb or CPM [FHilb]. In Appendix B, we extend this discussion to the case of other standard categorical constructions such as CP*[FHilb] and the Karoubi envelope of CPM [FHilb]. simple quantum optical implementations. This is because these quantum optical implementations of coherent control of quantum channels cannot be correctly described by standard quantum circuits 3 .
In this work, we will not discuss further the specific problem of coherently controlling an unknown unitary; we will provide a detailed analysis and an account in terms of routed circuits in a separate work [50]. In general, however, we note that the coherent control of a unitary is a special case of a superposition of trajectories through two independent unitaries, discussed below, where one of the two unitaries is the identity.
Going back to our main example, let us describe it in physical terms. There is a sender S and a receiver R, and there are two different communication lines from S to R. These communication lines, A and B, can be thought of as being under the control of two agents, Alice and Bob. The sender wants to transmit a qudit message (also called a particle) M , and there is an additional control qubit C, whose value coherently determines whether the message goes through Alice's or Bob's communication lines. The agent who does not get the message is instead handed a 'vacuum state', orthogonal to the possible states of the message. The agents' operations do not modify the number of particles in their communication lines. Afterwards, the two communication lines are merged back, yielding again a message and a control qubit for the receiver to analyse.
A mathematical description of this scenario is the following. The communication lines are represented as quantum channels (i.e. completely positive trace-preserving (CPTP) maps) A and B, acting on L(H A ) and L(H B ), where H A and H B are Hilbert spaces of dimension d + 1, and L(H) is the set of linear operators on H. Moreover, each of these Hilbert spaces is partitioned 3 On this point, see in particular the discussions in [17] and [18]. Ref. [17] concludes that 'the language of quantum circuits should be extended in order to capture all information processing possibilities allowed by quantum physics': the present work precisely describes such an extension. Ref. [18] argues that implementations of coherent control can be represented using standard quantum circuits, but that 'the correct circuit representation of a schematic may not resemble it visually'; in terms of our requirements for 'adequate representations', this entails that this representation in standard quantum circuits will be inadequate as it does not neatly distinguish the subsystem on which the operation to be controlled is acting. into two orthogonal subspaces (also called sectors): a one-dimensional subspace corresponding to the vacuum state, and a d-dimensional subspace corresponding to the possible states of the message. This partitioning is written as A and B are constrained to map the vacuum sector to itself, and the one-particle sector to itself; this is called the no-leakage condition in Ref. [24]. Finally, initialisation of the trajectories' superposition is described by a unitary channel U from L( is the one-particle subspace of H A ⊗ H B ; the termination of the superposition is given by U † (it could also be given by any other unitary channel from L( H AB ) to L(H M ⊗ H C )). Note that this scenario is consistent because of the crucial requirement that the vacuum and one-particle sectors are preserved by A and B.
Let us now elaborate on why the sole framework of standard quantum circuits cannot provide a fully satisfactory description of this scenario. Given that Alice and Bob's channels are applied in parallel and in different regions of spacetime, a natural diagrammatic representation of this scenario should have the following form (here, E stands for 'encoding' and D for 'decoding'): If this diagram is to be understood as a quantum circuit, its boxes correspond to CPTP maps, and its wires correspond to spaces of linear operations on Hilbert spaces. The conjunction of wires A and B should correspond to the space L(H A ⊗ H B ). This description as a standard quantum circuit depicts neither sectorial correlations -here, the fact that B gets the vacuum state if A gets the particle, and reciprocally -nor sectorial constraints -here, the fact that A and B have to preserve the number of particles.
A first, general source of dissatisfaction with such a description is therefore its looseness: it does not include key elements of the scenario. For example, E is a map to L(H A ⊗ H B ), and not to its subspace L( H AB ), even though the latter is the sector which will always be 'used' in this scenario, no matter Alice and Bob's choices of operations; in general, one is forced to manipulate Hilbert spaces that are 'too big' in comparison with the Hilbert spaces in actual use. Such a looseness implies, for example, that D cannot be taken to be equal to U † , as the latter has input space L( H AB ) and is therefore not tracepreserving if extended to L(H A ⊗ H B ). To make D trace-preserving, one will have to incorporate to it elements that specify how it acts on the other sectors of L(H A ⊗ H B ), even though this is irrelevant information as far as the scenario is concerned.
This leads to a second, sharper critique: if we restrict to the scenario where A and B are unitary channels, then a description in standard quantum circuits will have to use the non-unitary channels E and D, even though the scenario itself is then fully unitary. In other words, this is then an example of a fully unitary scenario which cannot be described in unitary quantum circuits.
The absence of a depiction of sectorial constraints on A and B is also a source of looseness, as the quantum circuit description will be missing a key aspect of the scenario, one that is pivotal not only to its physical interpretation -as the constraints correspond to a natural physical requirement, that of not modifying the number of -but also to its consistency at the mathematical level, as A and B do not map L( H AB ) to itself if they do not respect the sectorial constraints.
The mathematical consistency of a scenario can of course always be proven 'by hand', by explicitly stating the sectorial correlations and constraints and showing that they lead to an overall consistent description; Refs. [24,25] proceed in this way. Yet, such an unsystematic account has two drawbacks. First, it yields no diagrammatic depiction of the existence of crucial sectorial correlations and constraints. Second, it will not scale up nicely to more elaborate situations: for more particles, for more channels, for more intricate sectorial constraints (where Alice, for example, is allowed to destroy a particle but not to create one), and for sectorial constraints which also include coherence conditions (for example, if Alice's action on one sector is restricted to be decoherent with her action on another sector). Proving the consistency of such scenarios by hand would quickly become tedious. In contrast, a systematic and consistent framework, such as the framework of routed maps, will not only enable a faithful and intuitive depiction of their structural features, but also include general consistency theorems ensuring that they are well-defined.

Causal decompositions of unitary channels
We now move on to our second example. The study of causal decompositions [29,30,31,10] aims at exploring the connection between the causal structure and the compositional structure of unitary channels. Given a unitary channel with several inputs and several outputs (i.e., such that their input and output Hilbert spaces have preferred factorisations into tensor products), its causal structure is described by a set of noinfluence relations. A no-influence relation is the fact that modifications of a given input cannot affect a given output. Formally, it is defined in the following way: if U is a unitary channel from inputs A and B to outputs C and D, one says where the symbol denotes the trace-out channel.
Compositional structure, on the other hand, corresponds to the existence of decompositions of a given unitary channel into several unitary channels along a given graph. For example, there exist unitary channels from inputs A and B to outputs C and D which admit a decomposition of the following form: Clearly, for a given unitary channel, the existence of a decomposition of the form (3) implies that this channel satisfies the no-influence relation A → D, as described in (2). Interestingly, the converse is also true [51]: if a unitary channel satisfies A → D, then it admits a decomposition of the form (3). The central conjecture that the research programme of causal decompositions aims to probe is that this equivalence between causal and compositional structures for unitary channels, which we just illustrated in a simple example, holds in general: for any number of inputs and outputs, a given set of no-influence relations is equivalent to the existence of a decomposition along a given graph, in which these no-influence relations are made obvious. So far, no counterexample to this conjecture has been found, and it has been proven in numerous cases; yet, in some of these cases, the compositional structure had to be expressed by going beyond standard quantum circuits.
However, if we take this graph to represent a standard unitary quantum circuit (i.e. if we interpret each box as a unitary channel), it is not equivalent to the causal structure: there exist unitary channels which obey the two previously mentioned no-influence relations, but which cannot be decomposed in the form of (4) (see Ref. [31] for an example). Yet there exists a slightly different kind of circuit for which the theorem holds [31], namely: The decomposition on the right-hand side is written in terms of index-matching quantum circuits, with distinctive 'k' superscripts written on some of the wires. Such diagrams were first introduced in Ref. [31], where they were called 'extended circuit diagrams'. In the present work, we shall adopt the more specific name 'indexmatching quantum circuits', and use somewhat different notation to that in the original work [31] 4 . The superscripts can be interpreted in the following way (where this is again slightly different from the presentation in Ref. [31]). There exists a finite set of indices K; the Hilbert space H R admits a partition into orthogonal subspaces H k R , with indices k ∈ K; so do the other wires with 'k' superscripts. U 3 is a unitary map from  (5). It is therefore natural to argue that index-matching quantum circuits are the proper tool to study causal decompositions. Indeed, beyond this paradigmatic example, several other cases of causal decompositions have been proven which involve index-matching quantum circuits, and do not hold if one limits oneself to standard quantum circuits (see Ref. [31] for an overview). As in the previous example, the inability of stan-dard quantum circuits to represent these compositional structures is due to their incapacity to encode sectorial correlations and constraints; the repetition of indices in index-matching quantum circuits is precisely used as a graphical depiction of such correlations and constraints.
In Section 6, we will show how index-matching quantum circuits can be seen as a handy diagrammatic representation of a sub-framework of routed maps: the framework of index-matching routed maps. This will allow us to properly formalise such diagrams in full generality, to provide them with rigorous semantics, and to prove that simple rules single out the physically meaningful index-matching quantum circuits, such as the one above.
3 Routed maps for pure quantum theory

Routed linear maps
We will first present routed linear maps (or routed maps for short), which can be used to describe pure quantum theory (i.e. for pure states and isometric channels). Routed maps come from the introduction of routes, which are mathematical objects encoding sectorial constraints on linear maps. To talk about sectorial constraints, one first has to work with spaces which are formally partitioned into sectors.
We want to define a partitioned space as a (finite-dimensional) Hilbert space H A partitioned into orthogonal subspaces, i.e. H A = k∈Z A H k A , with Z A a finite set. A practical way to define partitions is the following: we say that a family (π k A ) k∈Z of orthogonal projectors on a finitedimensional Hilbert space H A defines an orthogonal partition of H A if ∀k, l, π k A • π l A = δ kl π k A and k π k A = id A . The length of this partition is the size of Z A .
A partitioned space can then be formally defined: We will colloquially refer to such a partitioned space by the name A k . It is important to stress that in the framework we are building, partitions are hardcoded: formally, two different partitions of the same space give rise to two different partitioned spaces, which should not be confused with each other. From two par- . Given two partitioned spaces A k and B l , sectorial constraints on linear maps A k → B l can be encoded by relations. Relations are a way of modelling connections between elements of two sets; they can be thought of as generalisations of functions, in which a given element of the input set can be mapped to any number of elements of the output set (including the possibility that it is mapped to no element at all) [52]. For example, λ, as represented by the following graph, is a relation from Z A to Z B .
The fact that λ relates k ∈ Z A to l ∈ Z B is denoted k λ ∼ l: here, for instance, 2 Relations can be sequentially composed in a natural way, following the rule that two elements are related if there exists at least one path between them: Relations can be parallelly composed using cartesian products, with the rule: (k 1 , k 2 )  ∼ l 2 . Finally, from a relation λ : Z A → Z B , one can define the opposite relation λ : Z B → Z A , given by reversing the arrows in λ's graph. A relation λ can equivalently be represented by a matrix 5 (λ l k ) k∈Z A ,l∈Z B with coefficients in the semiring of booleans: λ l k = 1 if k λ ∼ l, and 0 otherwise. In this picture, sequential composition is given by matrix products, parallel composition by tensor products of matrices, and taking the opposite relation corresponds to matrix transposition. In the rest of this paper, we will predominantly work with the representation of relations as boolean matrices, and refer to a relation λ by its boolean components λ l k . A route is a relation which represents a set of sectorial constraints: the constraint that a sector H k A of the input space is forbidden from being connected to a sector H l B of the output space will be denoted by the fact that λ features no arrow from k to l, or equivalently, λ l k = 0. For example, if we take the partitioned Hilbert spaces represented by the route λ = 1 0 1 1 . Formally, we have: One also says that λ is a route for f .
An equivalent condition to (8), proven in Appendix C.2, is This yields an intuitive interpretation of routes: the 1's in the matrix of a route λ can be thought of as designating the blocks that are allowed to be non-zero in the block decomposition of f .
On partitioned Hilbert spaces, compatibility of linear maps with routes plays well with sequential composition, parallel composition, and hermitian adjoints: if f follows λ and g follows σ, then g • f follows σ • λ, f ⊗ g follows λ × σ, and f † follows λ (this is proven in Appendix C.2).
We are now in a position to define routed maps, which, together with partitioned spaces, form the basic components of our framework: For example, if we go back to the scenario described in Section 2.1 (restricting for now to the pure version, in which all operations are unitary operators), Alice and Bob's wires and operations can be modelled, respectively, as partitioned spaces of the form H = H 0 ⊕ H 1 , and as routed maps of the form (δ, V ), where δ = 1 0 0 1 , and V is a unitary map (which, by definition, has to follow the route δ). Routed maps themselves can be sequentially and parallelly composed, through pairwise composition in both cases 6 , and one can take their hermitian adjoint: (λ, f ) † := (λ , f † ). These features are all encompassed formally by Theorem 8, stated and proven in Appendix C.2, which, more generally, characterises the framework of partitioned Hilbert spaces and routed linear maps as a †-symmetric monoidal category. This has another important practical consequence: routed maps can be represented graphically in a welldefined way using circuit diagrams. Circuit diagrams where the wires are interpreted as partitioned Hilbert spaces and the boxes are interpreted as routed linear maps shall be referred to as routed quantum circuits, or simply, routed circuits.
Formally, we have: The framework of partitioned Hilbert spaces and routed linear maps admits a sound representation in terms of circuit diagrams.
Proof. This follows from Theorem 8, of Appendix C.2, and the fact that symmetric monoidal categories are suitable for diagrammatic representation in terms of circuit diagrams [53,5].
Soundness in Theorem 1 means the following. We take two circuit diagrams whose wires are interpreted as partitioned Hilbert spaces and whose boxes are interpreted as routed linear maps; if these are provably equal as diagrams (i.e. if one can be obtained by simply deforming the other), then the routed linear maps they represent are provably equal [5]. Essentially, this should be understood as ensuring that circuit diagrams can be used without second thoughts when dealing with routed linear maps, just as they could be used without second thoughts when dealing with standard linear maps.
Note that in Appendix A, we provide additional comments on how the 'route' part of a routed map can be understood at the conceptual level.

Practical isometries
An important task is to single out those routed maps which correspond to physical evolutions. In the standard framework of quantum circuits for pure quantum theory, they are given by isometries; for routed maps, we will instead coin the notion of practical isometries. The reasons why this notion is necessary can be understood by considering two examples.
A first example shows that the naive notion of isometricity cannot be directly applied to routed i.e., U is an isometry but λ is not. This will be, for example, the generic case for routed maps which 'delete' an index, i.e. when λ is a relation with the singleton as output set. As the latter maps are necessary components of our framework, we will have to relax the condition of isometricity, by not imposing it on the 'route' part of a routed map.
There is a second fact to take into consideration. For a given routed map (λ, U ) : A k → B l , there can be elements of Z A that λ relates to no element of Z B at all (this is for example the case of '4' in (6)). The fact that U follows λ then entails that it is null on the corresponding sectors of H A . Thus we should only ask U to be an isometry when restricted to the sectors corresponding to the other elements of Z A , those that λ relates to at least one element of Z B . This yields the notion of practical isometries.
For a routed map (λ, U ) : A k → B l , we define the practical input set of λ, S λ , as the subset of Z A whose elements are related by λ to at least one element of Z B (for example, for λ as defined in (6), we have S λ = {1, 2, 3}). We define the corresponding practical input space of (λ, U ) The symmetric notions of practical output set T λ and practical output space H T λ B are defined in the same way. This enables us to define practical isometries and practical unitaries: In the routed maps framework for pure quantum theory, the physically meaningful routed maps are the practical isometries. One, however, has to be careful on one point: the sequential composition of two practical isometries is not necessarily a practical isometry itself. The badlybehaved compositions of practical isometries correspond to situations in which we have complete descriptions for two individual gates, but where these descriptions are not sufficient to specify a complete description of the sequential composition of these two gates. Parallel compositions of practical isometries, on the other hand, always yield practical isometries, as proven in Appendix D.
We therefore need to single out the sequential compositions which are well-behaved for practical isometries. We can do so with a condition which, crucially, depends solely on the maps' routes: Then, for any practical isometries (λ, U ) : When the condition (10) is satisfied, we say that the sequential composition of λ and σ is proper for practical isometries.
Theorem 2 and its forthcoming generalisation to quantum channels are the crucial consistency theorems for routed quantum circuits. In routed quantum circuits made of practical isometries, all sequential compositions have to satisfy (10), in order to ensure that the global map they form is also a practical isometry. For the case of practical unitaries, sequential composition is well-behaved if the routes satisfy both (10) and a symmetric condition: Then, for any practical unitaries (λ, U ) : Under these conditions, we say that the sequential composition of λ and σ is proper for unitaries.

An example: superposition of two trajectories
Before we move on to general quantum channels, let us provide a first didactic example of a routed circuit, by showing how our framework allows to properly formalise the scenario of a superposition of two trajectories described in Section 2.1 -restricting for now to the case of unitary channels. Diagrammatically, we represent partitioned spaces as wires, and routed maps as boxes: we write the linear map within the box, and depict the matrix elements of its route floating next to it. Spaces with a trivial partition are denoted without superscripts. The scenario is then formalised as the following routed circuit: where ω = 0 1 1 0 , and δ = 1 0 0 1 .
As we can see, Alice and Bob's channels are now represented as routed maps of the form (δ, V ), in which the sectorial constraints inherent to the scenario have been included. Let us also carefully break down the meaning of the encoding operation, (ω, U ). As the input wires of this operation are not partitioned, ω is a relation from a trivial set of indices -represented by the singleton As we can see, ω is characterised by its practical output set T ω = {(0, 1), (1, 0)}. (ω, U )'s practical output space, H Tω AB , is thus precisely the H AB introduced in section 2.1: this enforces the sectorial correlations present in the scenario. It is important to stress that within the framework of routed maps, these sectorial correlations are obtained as a contextual feature (see footnote 8 about our use of the word 'contextual'): they are specified by the routes present in the global routed circuit. This point is elaborated upon in Section 4.3.
All the routed maps in this routed circuit are practical unitaries, and it is easy to check that all the compositions are proper for practical unitaries. This means that the framework of routed maps allowed us to provide a suitable unitary description of this unitary scenario -something which, as we argued in section 2.1, is not possible within the sole framework of standard quantum circuits. More generally, it is straightforward to see that the use of routed maps solves all the points of dissatisfaction we had with the description of this scenario in standard quantum circuits.
One can reduce graphical clutter in the above routed circuit by using a handy graphical convention, that of contracting Kronecker deltas. The idea is, not to write explicitly the δ-routes δ l k between a wire A k and a wire A l , and to instead just write down these wires with the same superscript 7 . The above routed circuit, for example, then becomes: 4 Diagrammatic representation: routed circuits Let us provide a thorough description of the diagrammatic representation that we just introduced in a simple example. Indeed, one of the objectives of the introduction of routed maps is to use them as a mathematical basis for a faithful and systematic diagrammatic representation, in which the routes can be read in an intuitive way. We provide such a representation in the form of so-called routed circuits. The well-definition of these diagrams as a faithful representation of the mathematical framework is guaranteed by Theorem 1. A specific challenge in this context is to give clear rules on the physical interpretation of slices in a given routed circuit: we will do so by 7 Contraction of Kronecker deltas can sometimes lead to ambiguities about the routes in a given diagram (this will be elaborated upon in Section 6); one should therefore keep in mind that it is simply a graphical shorthand, and that the rigorous diagrammatic representation of routed quantum circuits is properly done through explicitly writing down all the routes. establishing a distinction between formal space and accessible space.

Diagrams for routed linear maps
An example of a routed circuit is (12). We represent the objects X k := (H X , Z X , (π k X ) k∈Z X ) by wires. We represent the morphisms (λ, f ) by boxes: we write the linear maps f inside the boxes, whereas the matrix elements of the route, λ m,...,n k,...,l , are drawn as numbers floating next to the boxes. In general, we ask that no two wires bear the same superscript (except in the case of the shorthand notation given by contractions of Kronecker deltas). When |Z X | = 1, we simply write X in place of X k .
Remember that a diagram composed of practical isometries represents a practical isometry itself if and only if the sequential compositions of routes in this diagram are suitable for isometries, as per Theorem 2. In this case, the diagram is called an iso-diagram. In the same way, a diagram in which sequential compositions of routes are suitable for unitaries is called a uni-diagram.

How to interpret slices
An important question is that of the interpretation of slices in a diagram. By slices, we mean horizontal combinations of wires. For example, if we take the slice comprising wires A k and B m in (12), a simple formulation of the question at hand would be: 'What is the Hilbert space corresponding to this slice?'. As we will show, the answer depends on whether one is asking from a mathematical or physical perspective. This will lead us to distinguishing two spaces corresponding to a slice: the formal space, and the accessible space.
A first possible answer comes from strictly sticking to the mathematical formalism. As is clear from its definition in Section 3.1, the tensor product We will define this as the formal space corresponding to the slice. In contrast to what will come later, the formal space corresponding to a slice is non-contextual 8 , in the sense that it only depends on the slice itself. As we can see, the formal space is the 'big' Hilbert space: it contains all the sectors of the partition.
It is clear, however, that some of these sectors are in general forbidden from being populated, due to the sectorial constraints imposed by the routes. Thus, in the context of the diagram at hand, one can give a more refined meaning to the slice. This is formalised by the notion of the accessible space corresponding to a slice: we define it as the subspace of the formal space in which states will be constrained to lie due to the routes. The accessible space corresponds to a more physical understanding of the situation, and encodes physical correlations between sectors in each of the wires which compose it. For example, the accessible space corresponding to the slice comprising wires A k and B m in (12) is , a strict subspace of its formal space. We give the general recipe for computing the accessible Hilbert space corresponding to a slice in section 4.3.
Before that, it is important to emphasise that the accessible space is a contextual notion: it depends on the whole diagram (more specifically, on the routes thereof) and not only on the slice itself. This somewhat counter-intuitive feature should not come as a surprise. To see why, it is enlightening to take the view in which routed circuits are understood as representing a physical setup and the sectorial constraints this setup implies (this is for example the case in (12)). In this context, the whole point of the notion of accessible space is to take into account the fact that some setups lead to only a subspace of a given formal space being populated. It is thus natural that the whole setup should be taken into account when computing the accessible space.
That the notion of accessible space is a contextual one entails another important consequence: the accessible space of a given slice can get modified (and, more specifically, reduced) when additional maps are adjoined to a diagram. For example, if one considers a diagram containing only the middle layer of (12), then the accessible space of the slice comprising wires A k and B m is equal to its formal space; but when one adjoins the other layers to recover the diagram above, this accessible space gets reduced to Once again, this is in fact natural: in the physical interpretation of routed maps, adding more routed maps means specify-ing a setup further -which could mean that we are adding new constraints on the possible physical correlations in a given slice 9 .

Computing the accessible space corresponding to a slice
An example of a more elaborate routed circuit, with slices explicitly drawn out, is given below; we will use this as an example to illustrate the general procedure which yields the accessible space corresponding to a slice. Two possible slices are drawn in blue and magenta, and their respective accessible Hilbert spaces are written out on the side: One can compute the accessible space corresponding to a given slice with the following formal procedure (using the blue slice above as an example). We call K the set of indices present in this slice [e.g. K = {i, j}]. This procedure is justified more formally in Appendix E.
1. write down the matrix components of all the routes featuring an index in K [e.g. δ i m γ j n ]; 2. write down the matrix components of all the routes (both above and below the slice under consideration 10 ) featuring an index among those already present [e.g. λ mn k ]; 9 There is a specific case of interest, however, in which the previous comment will not apply: when one is considering a diagram whose global input and output wires (the inputs and outputs of the whole diagram) are not partitioned (i.e. bear no indices). It is easy to see that adjoining more routed maps to such a diagram will not modify the accessible space of a given slice inside it; one can thus consider the accessible space to be the exact subspace which will be populated. For example, this is the case for the slice comprising wires A k and B m in (12), as the global inputs and outputs in (12)  As one can see, this displays formal similarities with the Einstein summation convention of linear algebra. One should not take these similarities too seriously, however, as some conventions are different. In particular, in the formula for the accessible space, the indices in K appear three times, and indices born by input or output wires of the diagram appear one time yet are still summed over.

Routed maps for mixed quantum theory 5.1 Routed quantum channels
Let us now show how to extend the theory of routed maps to encompass mixed states and general quantum channels. In the same way that one goes from linear maps to completely positive linear maps, we will be going from relations to completely positive relations. These will be used to encode sectorial constraints which can not only forbid connections between some sectors, but also forbid some of the allowed connections to be coherent with one another.
The broad idea is to generalise (8) to the case where we take a completely positive linear map between linear operators on partitioned Hilbert spaces. A natural way to do so is to use relations of the form Λ : Z A × Z A → Z B × Z B as routes, leading to the following definition: formed by the whole diagram forces one to restrict the states which can populate a given slice so that they do not lie out of the practical input space of a subsequent routed map.
be two partitioned spaces, and Λ : (16) One also says that Λ is a route for C.
However, we need not use all of the possible Λ's; some are superfluous. Take, for instance, a Λ which is not symmetric, in the sense that, for some k, k , l, l , 1 = Λ ll kk = Λ l l k k = 0. As completely positive maps are symmetric, any C following Λ will also followΛ defined from Λ by set-tingΛ ll kk to 0. In other words, a non-symmetric Λ expresses a set of constraints which could be expressed just as suitably by a symmetric one.
In addition, let us define the diagonal of Λ as the relationΛ : Z A → Z B defined byΛ l k := Λ ll kk . It is easy to see that if there exist k, l such thaṫ Λ l k = 0, then any completely positive C that follows Λ will also follow the routeΛ obtained from the former by setting ∀k , l ,Λ ll kk =Λ l l k k = 0. Let us define diagonally dominant relations Λ as the ones satisfying for any k, l,Λ l k = 0 =⇒ ∀k , l , Λ ll kk = Λ l l k k = 0. This entails that a non diagonally dominant Λ expresses a set of constraints which could be expressed just as suitably by a diagonally dominant one. One can thus, without loss of generality, work only with symmetric and diagonally dominant Λ's.
Remarkably, the symmetric and diagonally dominant Λ's can be recovered in another way: they are exactly the completely positive relations that one can obtain by mimicking, on relations, the procedure that leads from linear maps to completely positive linear maps, through 'doubling then tracing out'. Completely positive relations will thus be used to express sectorial constraints for quantum channels, providing completely positive routes. The diagonalΛ l k of a completely positive route encodes constraints on whether a channel is allowed to connect the sectors k and l; and the offdiagonal coefficients Λ ll kk encode constraints on whether the connections between sectors k and l on the one hand, and sectors k and l on the other hand, are allowed to be coherent with each other (these will be called coherence constraints).
In analogy with the construction for the pure case, routed CPMs are defined as follows, with partitioned spaces colloquially written as A kk :

Definition 6 (Routed CPMs). A routed completely positive map (CPM) from
The framework of partitioned Hilbert spaces and routed CPMs satisfies the exact analogue of Theorem 1: Proof. This follows from Theorem 10, of Appendix C.3, and from the fact that symmetric monoidal categories are suitable for diagrammatic representation in terms of circuit diagrams [53,5].
Just as Theorem 1, this should be understood as ensuring that circuit diagrams can be used without second thoughts when dealing with routed CPMs.
Practically trace-preserving routed CPMs are defined in the same way as practical isometries: Finally, the condition for a composition of routed quantum channels to be proper (i.e., to always yield a routed quantum channel) is similar to that for practical isometries, and solely depends on their routes' diagonals: Then, for any routed quantum channels (Λ, C) : The proof of this is similar to the one for practical isometries. When the condition (17) is satisfied, we say that the sequential composition of Λ and Σ is proper for routed quantum channels.

Link with Kraus representations
A question of interest is whether the condition (16), expressing that a CP map C follows a completely positive route Λ, can be translated in terms of the Kraus representations {K i } i of C. A first answer is that the sectorial constraints expressed by Λ's diagonalΛ have to be satisfied by each of the Kraus operators in any Kraus decomposition of C. This is also a sufficient condition when Λ has full coherence, i.e. when it is a route of the form Λ ll kk =Λ l kΛ l k which includes no constraints on coherence: The other situation in which one can give conditions equivalent to (16) in terms of Kraus representations is the opposite extremal case: the one in which Λ is a route with full decoherence, i.e. is of the form Λ ll kk = δ kk δ ll Λl k . We say that a given Kraus decomposition {K i } i is adapted to a completely positive route Λ with full decoherence if for each i, there exists a unique pair (k, l)

Diagrammatic representation
Let us quickly elaborate on how the diagrammatic constructions and notions of Section 4 generalise to the case of mixed quantum theory. As exemplified in the next subsection, routed diagrams for mixed states and general quantum channels are in simple analogy with those for pure states and isometries: one simply switches to writing wires with doubled superscripts, of the form A kk , and to writing the completely positive routes with these same doubled indices. All compositions in such diagrams have to be suitable for routed quantum channels. The well-definition of these diagrams as a faithful representation of the mathematical framework is guaranteed by Theorem 4.

Two examples: Superposition of three trajectories and decoherence of copied information
We will exemplify the routed maps framework for general quantum channels with two examples to show how completely positive routes can include constraints on the coherence between sectors, and how this leads to easy decoherence computations. In order to also present a somewhat more involved use of the routed circuits framework, let us extend the scenario we already formalised in Section 3.3, and consider now the superposition of three trajectories. This scenario is the same as before, except that the control system is now a qutrit, and the message can now go in a superposition of three different channels A, B, and C, which once again preserve the number of particles [24]. Now that we are working with general quantum channels, there are in fact two different routes that one could attribute to A (and, in the same way, to B and C); the choice between them depends on the features of the physical scenario we want to describe. On the one hand, we could be asking only that A preserves the number of particles, without setting constraints on the coherence between the vacuum sector and the oneparticle sector. In this case, the route constraining A will be δ l k δ l k . But one could also be considering a more restrictive situation, in which A not only acts separately on the two sectors, but also acts incoherently on each [24,26]. The choice of route corresponding to this situation is then δ ll kk 13 . The use of completely positive routes, therefore, allows to neatly distinguish between the two different scenarios.
Let us, for example, look at the scenario in which each channel is allowed to preserve coherence between the sectors. The routed circuit representing such a scenario (using contractions of Kronecker deltas) is then: where, for given k, m and p, ω kmp = 1 if and only if k + m + p = 1. Remember that, because of the convention of contracting Kronecker deltas, writing the names of A's input and output wires with the same superscripts implicitly means that we are considering the routed quantum channel (δ l k δ l k , A); the same goes with the routed quantum channels corresponding to Bob's and Charlie's actions. 13 The Kronecker delta here means that δ ll kk = 1 if and only if l = l = k = k , else δ ll kk = 0.
On the other hand, in the scenario where the one-particle and vacuum sectors evolve incoherently with each other, the systems corresponding to Alice, Bob and Charlie would have repeated indices A kk , B mm and C pp .
Another example shows how routes can help derive some immediate consequences of discardings on the coherence between sectors. Suppose we have a routed channel from one system A to two partitioned systems B kk and C ll , which features perfect (possibly coherent) sectorial correlations between B kk and C ll -i.e. this routed channel is of the form (δ kl δ k l , C). This can be understood as a channel which, in particular, sends copies of the same information to two agents, Bob and Charlie. Indeed, if Bob measures in which of the sectors B k his system is, and Charlie does the same with the sectors C l , they will find the same result.
Let us now look at what happens if Bob discards his system (or, more generally, if Bob's system never reaches Charlie, as the latter's description of his own system is then the one obtained by discarding Bob's part). The discarding on B kk is given by the routed quantum channel (δ kk , B ), where B is the trace on L(H B ). The quantum channel this yields is therefore In the equation above, some simple calculus on routes alone yielded an important physical theorem. Indeed, the routed quantum channel obtained by discarding Bob's system is of the form (δ ll , C ): its route means that it yields states that are completely decohered with respect to the partition l. Thus we proved in a natural way a wellknown feature of quantum theory: copying information and then discarding one of the copies necessarily leads to the loss of any coherence in the other copy, between the sectors which encoded this information.
What is remarkable is that the use of completely positive routes allows to derive such a theorem from very simple calculus on boolean matrices, and without having to know anything specific about the channel C, except its crucial structural features. Moreover, the systematic nature of our framework means that one will be able to scale up such proofs easily: in any scenario in which information is copied in some way between any number of subsystems, for any number of subsystems being discarded, calculus on routes will yield direct consequences on the coherence between sectors for the other subsystems.

Computing the accessible space corresponding to a slice
The discussion of interpretations of slices in a routed diagram can also be generalised to routed quantum channels. The formal space corresponding to a slice will, once again, be the 'big' space of linear operators corresponding to it: for example, the one corresponding to the slice comprising wires A kk , B mm and C pp in (18) is . Accessible spaces will be defined as solely depending on the routes' diagonals: indeed, including the information on coherence encoded by the routes' off-diagonal elements would not yield satisfactory operator spaces. The accessible space corresponding to the previously mentioned slice, for example, is Since we are only using the routes' diagonals, the accessible space corresponding to the same slice in the incoherent case will be the same. The general procedure of Section 4.3 for computing the accessible space can easily be accommodated to general quantum channels: one follows it using the routes' diagonals, thus ending up with a Hilbert space H acc ; the accessible space of linear operators corresponding to the slice is then L(H acc ).

Index-matching quantum circuits
A drawback of general routed quantum circuits is that the sectorial correlations and constraints they feature are not represented in a completely graphical way; the routes are denoted by abstract symbols which do not depict graphically the possible connections between sectors 14 .
14 A possible systematic way to depict such connections would be to add a third dimension to diagrams, in order to represent direct sums, as is done with the sheet diagrams of Ref. [56]. Sheet diagrams, however, can quickly grow unwieldy to write down and to decipher as the number of summands in a direct sum increases, in particular because Nevertheless, there is a sub-framework of routed quantum circuits which encompasses a fair share of scenarios (though not all of them), and in which sectorial correlations and constraints can be represented in a fully graphical way: this is the framework of index-matching quantum circuits. As we will see, index-matching quantum circuits correspond to the 'extended quantum circuits' introduced for the study of causal decompositions in Refs. [29,30,31,10], and presented in Section 2.2. The theory of index-matching quantum circuits will thus also serve to provide a sound and systematic mathematical foundation to the use of the diagrams introduced in these earlier works.
The simple idea behind index-matching circuits is to make the most out of the graphical trick of Kronecker delta contraction, which we described earlier in a simple example. Thus, in this framework, one restricts the partitions to be indexed by a rigid combination of several indices, and only considers routes built from Kronecker deltas between such indices. This allows to represent these routes directly on a diagram, by repeating indices to denote the Kronecker deltas. The conditions for suitable composition also take a particularly simple form in this context, making it easier to ensure that an index-matching circuit is suitable for practical isometries, practical unitaries, or practically trace-preserving maps. A typical example of an index-matching circuit is the causal decomposition (5).
We formalise thoroughly the framework of index-matching routed maps in Appendix G; here, we will present it in a more accessible way. At the level of pure states and operators, it has two major components. The first one is partitioned Hilbert spaces whose partitions are labelled by several indices, i.e. which are of the form A k 1 ...km . Each index k i has a length |k i |, denoting the number of values it can take. The second components is index-matching routed maps, which are routed maps whose route is solely writtheir representations will necessarily be 2d projections of their 3d structures. Note also that 1) they can only be used to represent a subset of routed maps (for instance, a routed map with route λ = 1 0 1 1 cannot be represented using a sheet diagram, as it is not a direct sum of maps on the sectors); and 2) in a theory of completely positive maps, they are unable to encompass routed maps which feature coherence between the sectors. ten in terms of Kronecker deltas (in order to make sense, these Kronecker deltas necessarily have to relate indices of the same length). Examples of possible index-matching routes from A k 1 k 2 to B l 1 l 2 are δ l 1 k 1 δ l 2 k 2 , δ l 1 l 2 k 1 k 2 , δ l 1 l 2 , δ l 2 k 1 k 2 , 1, etc. Using graphical Kronecker delta contractions, the routes of index-matching routed maps can therefore be represented in a fully graphical way. For example, if we look at maps of type A k 1 ⊗ B k 2 → C l 1 ⊗ D l 2 , the maps (δ l 1 l 2 k 1 k 2 , U 1 ), (δ l 1 l 2 , U 2 ) and (1, U 3 ) will respectively be represented as (20) Contractions of Kronecker deltas, however, can sometimes lead to ambiguities about the routes which are associated to each map in an indexmatching circuit. For example, if we composed the channels (δ l 1 in which one now cannot properly read the first channel's route anymore, as it has been 'overwritten' by the route of the second channel. Such issues entail that, if we want to make sure we will be able to give an unambiguous meaning to index-matching circuits, we will need to define the theory of such circuits in a more restrictive way. This is done formally in Appendix H; here, we will stress the main features of the theory thus obtained. The idea is to go in the opposite direction: instead of starting with maps and defining graphs to represent their compositions, we shall start with abstract graphs, then interpret their wires and nodes as spaces and maps (this idea was loosely inspired by the approach developed in Ref. [57] for the formalisation of superpositions of causal order). We thus define indexed open directed acyclic graphs (IODAGs) as abstract open graphs made of nodes and directed wires, with the wires additionally bearing indices, and with an equivalence relation on indices (indicating which ones are 'the same index'). Figure 1 shows some examples of IODAGs.
One can, as a second step, interpret an IODAG by assigning partitioned Hilbert spaces to wires and maps to nodes, where the maps follow the routes specified by the index-matching in the diagram; this provides an index-matching circuit. This procedure allows to attribute proper semantics to index-matching quantum circuits.
IODAGs can be composed sequentially and in parallel. To prevent the appearance, in their interpretations, of ambiguities such as the ones described above, the possibility of sequential composition will be restricted: sequentially composing Γ 1 and Γ 2 is allowed only if Γ 1 's output wires are the same as Γ 2 's input wires, and if the equivalence classes among Γ 1 's outputs' indices are the same as those among Γ 2 's inputs' indices. For instance, taking the following IODAGs: , (e) cannot be composed with (f1) or with (f2), but it can be composed with (f3). In a sequential composition, equivalence classes which appear in the interface wires are merged; at the graphical level, this can lead to some relabelling. For instance, the composition of (e) and (f3) defined above yields Parallel composition, on which there are no restrictions, can lead to some relabelling as well; for instance, the parallel composition of (e) and (f2) is The rules for suitable composition of practical isometries take a particularly simple form in index-matching diagrams. Let us define a 'starting point' for an index as a node which features this index in its outputs but not in its inputs. An IODAG is proper for practical isometries if, for any index appearing in it, there is at most one starting point in the circuit for this index, and no starting point if this index appears in the global input wires of the diagram. It is proper for practical unitaries if it satisfies both this rule and a symmetric one for endpoints. For example, if we consider the diagrams of Figure 1, (a), (b) and (c) are suitable for isometries, but not (d), as it features two starting points for the index k. (a) and (b) are also suitable for unitaries, but not (c), as the index k is present in the global outputs of the diagram and has an endpoint.
Finally, as we have said, interpretations of IODAGs are given by assigning partitioned Hilbert spaces to wires and maps to nodes, where the maps follow the routes specified by the indexmatching in the diagram. An interpretation of an IODAG thus yields a global index-matching routed map, called the meaning of this interpretation. The meaning is obtained by composing the maps for each node in accordance with the graph, then composing with a pre-processing map, which serves to match input indices: the meaning of an interpretation of (f3), for instance, needs to include a pre-processing with a projector which will match the indices of its two input wires. Theorems 20, 21 and 22 in Appendix H ensure that interpreting is a well-defined protocol, playing well with sequential and parallel compositions of IODAGS. Interpreting (a) in practical unitaries, for example, yields a circuit of the form (5), which will therefore have a proper and unambiguous signification as a circuit of index-matching routed maps, and whose meaning will automatically be a unitary map. This ensures that our paradigmatic example of an indexmatching quantum circuit is completely sound.
IODAGs could be applied to general quantum channels as well; the only difference is that each index will then become a pair of indices, to be able to denote constraints on coherence.
Finally, let us note that index-matching quantum circuits only form a sub-framework of routed quantum circuits. A first example is that a route λ = 1 0 1 1 cannot be written in terms of Kronecker-deltas; thus a routed map with this route would not be describable in the sole framework of index-matching quantum circuits. Another, more physically grounded example is that of the superposition of three trajectories, as depicted in (18): it can be shown that (even in the unitary case) the sectorial correlations among the three wires in this diagram cannot be described using only Kronecker deltas.

Conclusion
In this paper, we argued for the necessity of an extension to the framework of standard quantum circuits, and introduced such an extension, given by routed linear maps and routed quantum circuits. We proved that routed maps form a consistent framework, suitable for a sound and faithful diagrammatic expression in terms of circuits, and applicable to both pure and mixed quantum theory; we exemplified its use and interpretation in several cases. We showed how a recently introduced extension of quantum circuits [31] can be seen as arising naturally from a sub-framework of routed maps, and made use of this fact to provide a sound and consistent semantics to the use of this previous extension. We believe that the tighter and more flexible description of quantum theory unlocked by the framework of routed maps could be the basis for significant advances in the understanding of the structure and possibilities of quantum theory. For example, in the two lines of research which we discussed to motivate the introduction of this framework, taking into consideration sectorial constraints and correlations led to a variety of novel results. In Ref. [24], this allowed to rigorously formalise the use of a superposi-tion of two communication channels, which in turn led to the creation of a new communication paradigm exhibiting various communication advantages over what is possible in standard quantum Shannon theory, including a new generalised definition of the capacity of a quantum channel [26]. In Refs. [29,30,31,10], taking sectorial constraints and correlations into account proved an unavoidable step in order to unravel the full scope of causal decompositions. The systematic and self-contained nature of the framework of routed quantum circuits could make it easier, neater and more natural to derive further such advances in the future, both in these lines of research and in others.
In the specific case of the study of causal decompositions, such decompositions were so far always found to be encompassed by what we called (practically unitary) 'index-matching routed quantum circuits' in this paper. As the latter are a sub-framework of general practically unitary routed circuits, this raises an interesting question: is it possible that, in some more involved and still unproven cases, causal decompositions (of a unitary into a routed quantum circuit of practical unitaries) might not be encompassed by index-matching routed quantum circuits, but only by the more general ones? A positive answer to this question would prove that the full scope of routed quantum circuits is required in order to describe faithfully the causal structure of quantum theory.
Following on the results of Ref. [24], routed quantum circuits could also be used to provide clarifications on the possibility of implementing coherent control of quantum channels in more general scenarios, and to describe and prove the communication advantages which could be yielded by such a control. The possibility of formalising and harnessing quantum superpositions of quantum operations could also prove useful in various algorithms of quantum computation [15,20,21].
Finally, the example of Ref. [10], in which causal decompositions involving index-matching routed quantum circuits were used to describe scenarios featuring indefinite causal order (ICO), and to prove theorems about the structure of some of these scenarios, demonstrates that the framework of routed quantum maps could also find fruitful applications in the study of ICO -another research direction which goes beyond the framework of standard quantum circuits [8,9] -which gathered significant interest in the past decade. It is reasonable to think that a framework which encompasses the full scope of quantum-theoretical scenarios should be able to describe both ICO and sectorial correlations and constraints.

Acknowledgments
It is a pleasure to thankÄmin Baumeler, Giulio Chiribella, Bob Coecke, James Hefford, Robin Lorenz and Matt Wilson for helpful discussions, advice and comments. AV is supported by the EPSRC Centre for Doctoral Training in Con-

A Comments on the conceptual role of routes
In this Appendix, we will provide a few comments on the conceptual role of the route in a routed map. This conceptual role can be understood by appealing to the notion of type. Usually, specifying the type of a linear map f means declaring its input space and its ouput space. Thus the type of a map is a structural piece of data which is prior to the specification of this map itself, with which the map itself is consistent, and which gives information about the ways in which this map can be composed: for instance, f and g can be composed only if f 's output space matches g's input space. In a routed map (λ, f ), λ should be morally understood as having the role of an additional type for f , that comes as a supplement to the declaration of its partitioned input and output spaces 15 . This is indeed the case once one restricts to the theory of practical isometries or to that of routed quantum channels: routesand not solely input and output spaces -have to be taken into consideration to determine which maps can be meaningfully composed.
That routes play the part of an additional type should also shed light on the seemingly disturbing fact that a given linear map f can be compatible with several different routes 16 , and on the natural question one can then ask: 'what is the difference between (λ, f ) and (λ, f ) ?'. Our comments entail that this is essentially a question about the meaning that is to be ascribed to a modification of the type assigned to what is, morally, the same map. In fact, similar questions about the meaning of a type change can also arise for non-routed linear maps. Indeed, a same given linear map can also, while morally staying the same map, be ascribed a variety of output spaces (basically any space of which its 'actual' output space is a subspace). In both this case and the case of a route change, the type change does not essentially modify the map, but it does modify our capacity to hold structural statements about it, and, in particular, to state what it is meaningful to compose it with.

B Connection with the CP* construction and other strategies
In Section 2, we showed that standard quantum circuits (i.e. those interpreted in either FHilb or CPM [FHilb]) could not be used to provide an adequate description of superpositions of trajectories or causal decompositions. Here, we extend this discussion to the use of the CP* construction [58] Let us first explain why it might be hoped that CP*[FHilb] would provide a sound basis for a representation of these scenarios 17 . The idea is that the objects of CP*[FHilb], being defined as C* algebras, can equivalently be thought of as arising from the choice of a preferred partition of a Hilbert space; therefore, the use of CP*[FHilb] would bypass the need for a definition of partitions 'by hand' as is done in the present paper. From there, routes could be defined, not as a structure on maps, but rather as a purely diagrammatic piece of data, and it would suffice to impose that the interpretation of the diagrams in terms of morphisms in CP*[FHilb] be consistent with this diagrammatic information.
We will first explain why this strategy cannot in fact be implemented using CP*[FHilb]; then we will explain why we believe that the idea of defining routes as diagrammatic data to construct a suitable theory is at least as difficult as the approach taken in this paper.
First, CP*[FHilb] is too restrictive to be used for the encoding of preferred partitions of Hilbert spaces. Indeed, if we define partitioned Hilbert spaces A k and B l as objects in CP*[FHilb], then the morphisms A k → B l in CP*[FHilb] can be defined as the CP linear maps from L(H A ) to L(H B ) that destroy coherence between the sectors of A and do not allow for any coherence between those of B. However, we want the channels in our theory to possibly feature coherence between the sectors. This is in particular crucial in both examples of Section 2: in superpositions of trajectories, the non-coherent case is a trivial and uninteresting one [26]; and in causal decompositions, all channels have to be unitary and thus perfectly coherent. CP*[FHilb] therefore cannot be used to model the structures we want to model.
We now comment on the more general idea of defining routes as mere diagrammatic data, rather than full-fledged morphisms, and simply asking for interpretations of diagrams to be consistent with that data. While this strategy has some advantages, it also presents significant drawbacks. First, it does not allow for the rewriting of a diagram in which, for instance, the composition of a box f and of a box g is replaced with a box g • f , as the 'route' diagrammatic data associated to this box will be undefined -unless compositions of routes are defined as well, which would bring one back towards a theory of routed maps as defined in this paper.
Second, it makes the problem of defining physical maps more difficult. Indeed, to obtain such a definition, we have a crucial need for a notion of practical input and output spaces, one that can only be defined from the data given by the routes themselves 18 . Here again, in the absence of the structural handles provided by the acknowledgement that routes are not just graphical objects but morphisms with their own compositions, it would be difficult to express the conditions for the composition of such physical maps to be welldefined; expressing them would once again essentially amount to going back to a theory of routed maps.
C Categorical perspective C.1 Dagger symmetric monoidal categories Let us introduce, in a non-technical way, the mathematical concepts which can be used to characterise the properties of the frameworks built in the present paper. These concepts encapsulate the fact that a framework is suited for a diagrammatic representation of its maps in terms of circuits. The structure necessary for this mimics the basic structure of quantum theory: exis- 18 The alternative would be to hardcode these 'practical input and output spaces' into objects, using, for instance, Karoubi envelopes. However, going this way would come at the cost of defining a very complex pseudo-tensor product structure. Indeed, one would for instance have to express the way in which L k and R k in (5) can be tensored in such a way as to yield not 'L k ⊗R k ', but 'L k ⊗R k '; and more generally there should be pseudo-tensor products defined for every possible case of sectorial correlations. In the general case of non-sector-preserving routed maps, these tensor products would present very exotic features: for instance, the codomain of the pseudo-tensor product of two maps would in general depend on the routes they follow. Therefore 1) doing things in this way would still require to define routes as more than diagrammatic pieces of data, and 2) even though conceivable, it would require mathematical constructions which are more involved than those in this paper. tence of sequential and parallel compositions, of identity maps, of trivial spaces, and of hermitian conjugates, all interacting in a natural way. Any theory with these features accepts sound and intuitive diagrammatic representations of its maps in terms of circuits [53,5]. These concepts originate from category theory, a mathematical theory which has been at the centre of a recent reformalisation of quantum theory [3,5,48,59]. Our point here is not to present them in depth, but to provide the reader with an intuition of the simple structures that they express.
Categorical frameworks adopt the perspective of process theories: this means a theory is described not through its states, but through its processes, i.e. its dynamical transformationsstates will be recovered as special cases of processes [5]. In the context of process theories, the main questions are about how processes can be composed together. A simple mathematical framework to describe sequential composition of processes is that of categories. A category contains two kinds of components: objects, corresponding to what would usually be called a space; and morphisms (or maps), with a specified domain (i.e. input space) and a specified codomain (i.e. output space), both chosen among the objects of the category. Two morphisms can be sequentially composed if the codomain of the first matches the domain of the second: i.e. if f : A → B and g : B → C are maps, they can be composed to form a map g • f : A → C. In a category, sequential composition is associative, and for any object A there exists an identity morphism id A : A → A.
Some categories, called symmetric monoidal categories (SMC), also feature the structure for parallel composition of morphisms, in the form of an operation called the tensor product 19 , ⊗. The tensor product of two objects A and B yields an object A ⊗ B, and the tensor product of two morphisms f : A → B and g : C → D yields a morphism f ⊗ g : A ⊗ C → B ⊗ D. The tensor product is associative. SMCs also feature a 'unit object' I satisfying A ⊗ I = I ⊗ A = A, which can be thought of as the trivial space of the theory; and swap morphisms, which are, for any pair of objects A and B, involutions from 19 Note that what we call the 'tensor product' in this context is not necessarily the tensor product of linear maps.
A ⊗ B to B ⊗ A. These structures satisfy a set of various coherence conditions which ensure that they interplay appropriately (for instance, that sequential composition distributes over parallel composition, and so on). In an SMC, states on an object A are morphisms from the unit object I to A.
Finally, a dagger SMC is an SMC featuring an involution, called the adjoint, which, to any morphism f : A → B, associates a morphism f † : B → A. The adjoint satisfies various coherence conditions ensuring that it interplays consistently with the rest of the symmetric monoidal structure. Combinations of parallel and sequential compositions of maps in dagger SMCs can always be faithfully represented by so-called circuit diagrams, in which maps are represented by boxes, and objects are represented by wires. For instance, the theory of linear maps between finite-dimensional Hilbert spaces forms a dagger SMC FHilb. We refer the interested reader to Refs. [60,5,61] for accessible introductions to symmetric monoidal categories.
All the theories we will be considering in this paper are dagger SMCs 20 , which makes them suitable for diagrammatic representation in terms of circuit diagrams [53,5]. In the following appendices we shall give the main elements of the proofs that the theories discussed in this paper form dagger SMCs; more refined proofs will be available in another paper focusing on the categorical structures which lead to the existence of routed categories [49].

C.2 Routed maps form a dagger SMC
In this appendix, we prove the following theorem, which can be thought of as a rigorous version of Theorem 1. 20 In fact, all the theories presented here are dagger compact categories: on top of the dagger symmetric monoidal structure, they feature some additional structure, which can be roughly described as corresponding to the existence of a Choi-Jamio lkowski isomorphism. In particular, this entails that they can be faithfully represented by string diagrams, an extension of circuit diagrams [5]. As the presence of this structure is not essential to the purposes of the present work, we leave our discussion of it to another paper [49].

Theorem 8. Partitioned spaces and routed maps form, respectively, the objects and morphisms of a dagger SMC RoutedFHilb, in which:
• composition is given by pairwise composition; • parallel composition is given on objects by , and on morphisms by the cartesian product on the routes together with the tensor product on the linear maps; • the trivial space is the trivial partition of C: 1 RoutedFHilb := (C, { * }, (1)); • the adjoint of (λ, f ) : We shall prove here the main features of RoutedFHilb's dagger symmetric monoidal structure: that it is closed under sequential and parallel compositions and under taking adjoints, that sequential and parallel compositions are associative, and that parallel composition distributes over sequential composition. That the various coherence conditions are also satisfied can be proven easily. In the following we will freely use some partitioned Hilbert spaces . Let us first prove a useful equivalent definition of the fact that a linear map follows a route: a map f : H A → H B follows a route λ if and only if ∀k, l, λ l k = 0 =⇒ µ l B • f • π k A = 0. Considering first the direct implication and supposing that f follows λ, one then has Hitting this equation with the µ l 's on the left and the π k 's on the left yields: ∀k, l : Reciprocally, supposing the latter, one has We now prove that routed maps are closed under sequential composition. If we take two routed maps (λ, f ) : A k → B l and (σ, g) : B l → C m and take indices k, m such that A . Yet the fact that l σ m l λ l k = 0 implies that for any given l, one has either σ m l = 0 or λ l k = 0. The first case implies that ν m C • g • µ l B = 0, and the second that µ l B • f • π k A = 0. Thus all the terms in this sum are null and ν m For parallel composition, taking (λ, f ) : For closure under taking adjoints, take (λ, f ) : A k → B l . Then for given k and l, (λ ) k where in the last implication we used the fact that orthogonal projectors are self-adjoint. (λ , f † ) is thus a routed map.
Finally, that parallel and sequential compositions are associative (both on objects and on morphisms) and that the former distributes over the latter is direct as these were defined pairwise from sequential and parallel compositions which possess all these properties.

C.3 Routed CPMs form a dagger SMC
Here, we prove the analogue of Theorem 8 for the case of routed completely positive maps. Let us start with a formal characterisation of how an orthogonal partition of a Hilbert space H A induces an orthogonal partition of the space L(H A ) of linear operators on H A . Theorem 9. If (π k A ) k∈Z A is an orthogonal partition of H A , then, defining the following linear operators on L(H A ), (π k,k ) (k,k )∈Z A ×Z A is an orthogonal partition of L(H A ) (with respect to the Hilbert-Schmidt inner product).
The proof is direct. We can then characterise the dagger SMC formed by routed CPMs.

Theorem 10.
There exists a dagger SMC RoutedCPMFHilb, in which: • objects are partitioned Hilbert spaces , whose underlying space is a space of linear operators on a given Hilbert space, and whose orthogonal partition is one obtained from an orthogonal partition of this Hilbert space through the procedure of Theorem 9; • morphisms A kk → B ll are routed maps (Λ, C), with Λ a completely positive relation and C a completely positive linear map; • composition is given by pairwise composition; • parallel composition is given on objects by • the adjoint of (Λ, C) is (Λ, C) † := (Λ , C † ).
The proof is very similar to the proof of Theorem 8. Closure under sequential and parallel composition come from the combination of two facts: that sequential and parallel compositions of routed maps are themselves routed maps, and that sequential and parallel compositions of completely positive linear maps and relations are themselves completely positive. The first fact was proven in Appendix C.2; the second comes from the fact that completely positive morphisms can be obtained from the universal construction of Selinger [55] for any †-compact category, and therefore form a †-compact category themselves. The same facts entail that routed completely positive maps are closed under taking adjoints. Finally, that parallel and sequential compositions are associative (both on objects and on morphisms) and that the former distributes over the latter is direct as these were defined pairwise from sequential and parallel compositions which possess all these properties.

D Compositions of practical isometries
We first prove Theorem 2. Let (λ, U ) : A k → B l and (σ, V ) : B l → C m be practical isometries, such that λ and σ satisfy (10). Then the practi- As U is a partial isometry with initial subspace H S λ A , it is in particular an isometry when restricted to H S σ•λ A . Moreover, condition (10) and the fact that U follows λ imply that We now prove that parallel composition of practical isometries always yields practical isometries. Let (λ, U ) : A k → B l and (σ, V ) : C m → D n be two practical isometries.
The restriction of U ⊗ V to (H A ⊗ H B ) S λ×σ is thus the tensor product of the restriction of U to H S λ A with the restriction of V to H Sσ B . As both of these are isometries, (λ, U ) ⊗ (σ, V ) is a practical isometry. The rest of the proof for the case of practical unitaries is similar.

E Computing the accessible space
In this Appendix, we provide a more formal justification of the method presented in Section 4.3 to compute the accessible space corresponding to a slice in a given routed diagram.
Let us start with a formal definition of the accessible space. We take a routed circuit and pick a slice in it. We restrict ourselves to considering only the interpretation of this diagram in the theory of relations; considering the 'linear map' part of the interpretations is not important here, as we will only use the route information. We call Z the set of possible values of the indices in our slice, P the set of possible values of the indices of the open wires at the bottom of the diagram and F that of the open wires at the top of the diagram. We will consider what our diagram yields if we insert a given relation at this slice; given a relation λ : Z → Z, we call E(λ) : P → F the interpretation of the diagram when λ is inserted at the slice.
For any k ∈ Z, let us define the relation We say that k ∈ Z non−acc if E( [k]) = 0, and define Z acc as the complement of Z non−acc in Z. Z acc corresponds to the index values that will form the accessible Hilbert space, i.e. we can define H acc := ⊕ k∈Z acc H k ; indeed, the complementary set Z non−acc is defined as containing those values of k which we know will be 'killed' by the routes.
We thus have: k ∈ Z acc ⇐⇒ ς F • E(

F Sectorial constraints and Kraus representations
We first prove Theorem 6. We take a routed CPM (Λ, C) : A kk → B ll . One can prove, in a similar way to how it was done for linear maps in Appendix C.2, that condition (16) is equivalent to the fact that for all k, k , l, l , Let us take k, k , l, l such thatΛ l k = 0, and a Kraus representation {K i } i of C. If we take any states |ψ ∈ H k A , |φ ∈ H l B , we have ∀i, φ| K i |ψ ψ| K † i |φ ∈ R + and i φ| K i |ψ ψ| K † i |φ = φ| C(|ψ ψ|) |φ = 0, which implies ∀i, φ| K i |ψ ψ| K † i |φ = 0. As this is true for any |ψ ∈ H k A , |φ ∈ H l B , one has ∀i, µ l B K i π k A = 0. Thus each of the K i 's followΛ. Let us prove the reverse implication for a Λ with full coherence. If we take C with Kraus representation {K i } i such that each of the K i 's fol-lowΛ, then for all k, k , l, l , Λ ll kk =Λ l kΛ l k = 0 implies that at least one ofΛ l k andΛ l k is null, and thus that for any given i, at least one of µ l We turn to the proof of Theorem 7. Let us take a completely positive route Λ with full decoherence, i.e. Λ ll kk =Λ l k δ kk δ ll , and a completely positive map C following Λ. Then ∀ρ, . Taking a Kraus representation for each of the C l k 's yields a Kraus representation of C of the form given by Theorem 7. The reverse implication is direct.
G A formal construction of indexmatching routed maps G.1 Index-matching routed maps as a category In this appendix, we present a formal construction of the framework of index-matching routed maps, which was introduced in a more intuitive way in Section 6.
We first need to formally define multiple indexings: families of indices, each with its length, i.e. the number of different values it can take. Routes in index-matching routed maps have to be corelations [62] (this is written with a single r). Corelations will be used to define, among the union of their input and output indices, clusters of indices which will be matched (i.e. will 'be the same index').

Definition 9.
Let X A and X B be two finite sets. A (finite) corelation κ : X A → X B is an equivalence relation on the disjoint union X A X B .
Finite corelations can be composed sequentially and in parallel, and form a dagger SMC FCoRel [63].
It is easy to see that the theory in which objects are index families and morphisms are indexmatchings itself forms a dagger SMC FMatch.
The following ensures that index-matchings are just special cases of relations: for each indexmatching between index families, there is a corresponding relation between the corresponding multiple indexings, in a consistent way. This can be considered as a formal way of defining the relation corresponding to an index-matching as made of Kronecker deltas determined by this index-matching.

Definition 11.
For any index-matching κ : X A → X B , the relation associated to κ isκ : X A →X B , defined by the following condition: an Going from index families to multiple indexings, and from index-matchings to relations, is an operation which preserves the dagger SMC structure of FMatch into that of FRel. Theorem 11. The 'bar' operation, which associates to an index family its corresponding multiple indexing, and to an index-matching its associated relation, is a functor of dagger SMCs.
Proof. Let us first prove that it preserves sequential composition, i.e., κ • κ =κ •κ. From κ ∼ and κ ∼, one can form an equivalence relation ∼ on One can thus complete this by finding a family With the same reasoning, one can prove the same thing if x and x are both either in X A or in X C and k From this implication and the previous one, it follows that κ • κ =κ •κ.
It is then a routine check to prove that Thus, index-matchings can be seen as forming a subtheory of relations. This allows us to define notions for index-matchings from the notions for relations. The following is then direct. Theorem 12. Index-matching routed maps form a dagger SMC MatchedFHilb, which is embedded into RoutedFHilb.

G.2 Practical isometries and their composition
The definitions of practical isometries and practical unitaries in RoutedFHilb can be used in MatchedFHilb as well. In this context, Theorem 2 becomes more intuitive. First, we will define formally what it means to create and delete an index. Definition 13. An index created (resp. deleted) by an index-matching κ is an equivalence class under κ which only contains output (resp. input) elements. Each of these elements is a representative of the created (resp. deleted) index.
This leads to a characterisation of those compositions which do not satisfy Theorem 2.
Theorem 13. Let κ : X A → X B and ι : X B → X C be index-matchings. The composition of κ and ι is improper for isometries if and only if there exists an index of length greater than or equal to 2 created by κ, such that, noting W ⊆ X B as the set of representatives of this index, ι matches at least one index in W with an index in If the composition of κ and ι is not proper for isometries, there exist k ∈ Sῑ, k ∈X B \ Sῑ such that kκ which would be a contradiction. Thus one of them (say, x) , so its equivalence class under κ ∼ is an index created by κ. Calling this equivalence class W ⊆ X B , one has x ∈ X B \ W, as x ∈ W would imply k x = k x . Finally, as x ι ∼ x , x and x have the same length, and k x = k x implies that this length is at least 2; so the index which W represents has length at least 2.
Reciprocally, suppose there exists an index of length greater than or equal to 2 created by κ, with set of representatives W ⊆ X B , such that ι matches x ∈ W with x ∈ X B \ W. Then there exists a k ∈X B whose indices k y all have value 1, except for the y's in the equivalence class of x under κ ∼, for which the value is k y = 2. We also define k ∈X B whose indices all have value 1.
We now just need to spell out the corresponding requirement for unitaries. An indexed open directed acyclic graph (IODAG) will then be a map from one indexed wire system to another, taking the form of a multi-indexed directed acyclic graph. Note that h −1 : N Γ → P(I E Γ ) and t −1 : N Γ → P(E Γ O) both serve to specify, respectively, the subset of edges coming in a given node and the subset of edges going out of it. We will note p Γ := p I , p EΓ , p O .
Most structural theorems for IODAGs will hold only up to isomorphism of IODAGs.

Definition 16. An isomorphism of IODAGs
We will therefore work with equivalence classes of IODAGs under isomorphisms of IODAGs. For the sake of clarity, we will still call such an equivalence class an IODAG, and usually refer to it by specifying a representative of this class.
We can then explain how to compose IODAGs. First, we will need a way to compose equivalence relations which, contrary to the standard composition of corelations, does not forget about the intermediary set.
Theorem 15. Let ∼ 1 and ∼ 2 be equivalence relations respectively defined on A B and B C, and whose restrictions to B coincide. There exists a unique equivalence relation ∼ on A B C such that ∼ reduces to ∼ 1 on A B, to ∼ 2 on B C, and to the composition of ∼ 1 and ∼ 2 (seen as corelations) on A C. We will call ∼ the nonforgetting composition of ∼ 1 and ∼ 2 .
Proof. To build such an equivalence relation, let us take a cospan A which defines an equivalence relation ∼ on A B C. As this is the standard way to define compositions of corelations, it follows that ∼ reduces to the composition of ∼ 1 and ∼ 2 (seen as corelations) on A C.
Let us prove that ∼ reduces to ∼ 1 on A B and to ∼ 2 on B C. The pushout Z is defined as the set of equivalence classes of X Y under the equivalence relation ≈ generated by the requirement: Yet, the fact that ∼ 1 and ∼ 2 coincide on B implies that there exists a partition B = i B i and families (x i ), (y i ) such that ∀b ∈ B i , f B (b) = x i ∧g B (b) = y i . Therefore, the equivalence classes of ≈ are the {x i , y i } and the singletons {w} where w ∈ f B (B) g B (B). This implies that i 1 and i 2 are bijections. As a 1 is a bijection, two elements of A B are mapped to the same element of X if and only if they are mapped to the same element of Z; thus ∼ restricts to ∼ 1 on A B. Symmetrically, it restricts to ∼ 2 on B C.
Let us finally prove uniqueness; suppose that ∼ satisfies the same requirements and that there exist d, d such that d ∼ d and d ∼ d . Then, given that ∼ and ∼ coincide on A B and on B C, one must have d ∈ A and d ∈ C; this contradicts the fact that ∼ and ∼ coincide on A C.

Definition 17. The sequential composition of two IODAGs
and where ∼Γ is the nonforgetting composition of ∼ 1 and ∼ 2 .

Theorem 16. Sequential composition of IODAGs is associative.
Proof. The only non-trivial thing to check is associativity of the non-forgetting composition. This is ensured by the way we built it using cospans and pushouts in the proof of Theorem 15, and the fact that pushouts are unique up to isomorphism. The following is then direct. Theorem 17. The parallel composition of IODAGs is associative, and distributes over sequential composition.
Note, however, that the theory of IODAGs, thus defined, does not form a symmetric monoidal category, as it lacks identity morphisms. This can be dealt with by extending the definition of IODAGs, in order to allow for empty nodes.

Definition 19.
One can extend the definition of IODAGs by further equipping them with a seṫ N Γ ⊆ N Γ of empty nodes, such that for a given n ∈Ṅ Γ , n has only one ingoing wire in(n), and one outgoing wire out(n), whose indices are related in a consistent way: i.e. there exists a bijection ξ Γ n : p −1 Γ (in(n)) → p −1 Γ (out(n)) such that ∀k ∈ p −1 Γ (in(n)), k ∼ Γ ξ Γ n (k). One can further redefine a IODAG to be an equivalence class under the rewriting operations which consist in getting rid of some empty nodes and identifying their ingoing wire with their outgoing wire.

Theorem 18. The theory of IODAGs with possibly empty nodes is a symmetric monoidal category.
Proof. The non-trivial part is to prove that this theory has identity morphisms and swaps. The identity morphism from I to itself is given by the IODAG with no inner edges, |I| empty nodes, each of which connects an element of I in the inputs with its counterpart in the outputs, and such that two elements k, k ∈ K I K I are related if and only if they are related as elements of K I . The swap from I J to J I is built in an analogous way.
We can now single out these IODAGs which are well indexed, for an interpretation in practical isometries and for one in practical unitaries. Definition 20. Let Γ : I → O be a IODAG. For a given node n of Γ, the set of incoming indices for this node is p −1 Γ • h −1 (n), and the set of outgoing indices for this node is p −1 Γ • t −1 (n). Let c be an equivalence class of K I K E Γ K O under ∼ Γ , a starting point for c is a node n such that c has at least one representative in the set of outgoing indices of n, but no representatives in its incoming indices. An endpoint for c is defined symmetrically.
Γ is an iso-IODAG if each equivalence class c of K I K E Γ K O under ∼ Γ has at most one starting point, and has no starting point if it appears in the inputs of the diagram (i.e. if it has a representative in K I ).
Γ is a uni-IODAG if it is an iso-IODAG in which each equivalence class c of K I K E Γ K O under ∼ Γ has at most one endpoint, and has no endpoint if it appears in the outputs of the diagram (i.e. if it has a representative in K O ).
Being well-indexed is a property preserved by composing diagrams, sequentially and in parallel: Theorem 19. Sequential and parallel compositions of iso-IODAGs are iso-IODAGs, and sequential and parallel compositions of uni-IODAGs are uni-IODAGs.
Proof. Let us take two iso-IODAGs I → O and look at their sequential compositionΓ. Take an equivalence class of indices c. Then the fact that ∼Γ reduces to ∼ 1 on K I K J and to ∼ 2 on K J K O implies that: • if c has a representative in K J , then there is an equivalence class c 1 under ∼ 1 and an equivalence class c 2 under ∼ 2 which correspond to c (i.e., an element belongs to one of these classes if and only if it belongs to c). As Γ 2 is an iso-IODAG and c 2 has a representative in K J , it has no starting point in Γ 2 , and thus neither does c. If c has a representative in K I , then so does c 1 , which therefore has no starting point in Γ 1 ; c then has no starting point in Γ. Otherwise, c 1 has one starting point, and thus so does c.
• if c has no representative in K J , then its representatives are either all in Γ 1 or all in Γ 2 ; as both are iso-IODAGs, c therefore satisfies the conditions of Definition 20.
Γ is therefore an iso-IODAG. The rest of the proof for uni-IODAGs is symmetric.
For parallel compositions, as one has ∼ Γ 1 Γ 2 =∼ 1 ∼ 2 , the set of representatives of a given class is included in one of the two diagrams; thus, that the requirements of Definition 20 are satisfied by Γ 1 and by Γ 2 directly implies that they are satisfied by Γ 1 Γ 2 .

H.2 Interpretation
Finally, it is time to turn ourselves to interpretations of IODAGs in terms of index-matching routed maps. First, the index-matching routes are, in fact, defined even before having to interpret anything: they are given by the IODAGs alone.

Definition 21.
Let Γ be an iso-IODAG. For each edge e ∈ I E Γ O, we define its set of indices X e := p −1 Γ (e). For each node n ∈ N Γ , we define its corelation κ n : e∈h −1 (n) X e → e ∈t −1 (n) X e by the fact that it relates two elements if and only if these are related under ∼ Γ . Furthermore, we define a pre-processing corelation κ pre from K I to itself by the requirement that it relates two elements of K I K I if and only if, when considered as elements of K I , they are related by ∼ I .
Before interpreting, we can show that the compositions of such corelations are suitable.

Lemma 1.
Given an iso-IODAG (resp. a uni-IODAG) Γ, let us consider the corelation obtained by composing all of its nodes' corelations according to Γ's graph, then pre-composing the result with κ pre . It is equal to κ tot , the corelation which relates two elements of K I K O if and only if they are related by ∼ Γ . Furthermore, all the compositions in this construction are suitable for isometries (resp. for unitaries).
Proof. We call κ tot the corelation thus built; let us prove that it is equal to κ tot . If we take two elements k, k of K I which are related by κ tot , then they are related by κ pre and therefore also by κ tot ; the same holds if we take two elements of K O which are related by κ tot . If we take k ∈ K I and k ∈ K O related by κ tot , this means that they belong to a same equivalence class; as Γ is an iso-IODAG, this implies that this equivalence class has no starting point. There is therefore necessarily a path of related indices going downwards from k to at least one index k in the inputs of the diagram, which implies that k and k are related by κ tot . As k is itself related to k by κ pre and therefore also by κ tot , transitivity allows to conclude that k and k are related by κ tot .
Reciprocally, if we take two elements of K I K O which are related by κ tot , this means that either they are related by κ pre , or we can find a path of related indices connecting them through the graph of Γ. In the first case, they are clearly related by κ tot ; in the second case, as each of the index-matching route maps was obtained through a restriction of ∼ Γ , and as ∼ Γ is transitive, this means that these two indices are also related by ∼ Γ , and therefore also by κ tot .
Let us now prove, for the isometric case, that the compositions are suitable for isometries. One can build κ tot by foliating the graph, then composing the corelations layer by layer, starting with the pre-processing. The composition of the pre-processing with the first layer is suitable for isometries by Theorem 13, as there are no indices created by the pre-processing. Say we have composed the pre-processing and the m first layers, yielding a corelation κ m ; its composition with layer m+1 is suitable for isometries as well, again by Theorem 13; indeed, an index created by κ m is an index which is not present in the inputs of the diagram; it therefore has a starting point in the m first layers. This entails that the set of wires bearing this index is connected in the graph of Γ; therefore, all elements of the corresponding equivalence class in the outputs of the m first layers are related by κ n . The m + 1 layer therefore cannot relate these elements with others, as it has to respect ∼ Γ . The rest of the proof in the unitary case is similar.

Definition 22.
An interpretation of an iso-IODAG (resp. a uni-IODAG) Γ : I → O in practically isometric (resp. practically unitary) IM-RMs consists of the following: • a function length : K I K E Γ K O → N, satisfying k ∼ Γ k =⇒ length(k) = length(k ); • a function sys which, to any e ∈ I E Γ O, associates a partitioned Hilbert space of the form (H A ,X e , (π k ) k∈Xe ), whereX e := × x∈Xe 1, length(x) ; • a function morph which, to any n ∈ N Γ , associates a practically isometric (resp. practically unitary) index-matching routed map of the form (κ n , f ) from e∈h −1 (n) sys(e) to e ∈t −1 (n) sys(e ).
In addition, the input and output wires of an empty node must have the same interpretation and the interpretation of the empty node must be an identity morphism.
Interpreted IODAGs are called index-matching quantum circuits. The global index-matching routed map that an index-matching quantum circuit represents will be called its meaning.

23.
Given an interpretation (length, sys, morph) of an iso-IODAG, we define a pre-processing map (κ pre , π pre ) from e∈I sys(e) to itself, where κ pre was defined in Definition 21, and π pre := k∈× e∈IX eκ k, k pre π k . The meaning of (length, sys, morph) is then F • (κ pre , π pre ), where F is the index-matching routed map obtained by composing the morph(n) according to the graph of Γ.
Theorem 20. Given an interpretation of an iso-IODAG (resp. of a uni-IODAG) in practically isometric (resp. in practically unitary) IMRMs, its meaning is a practical isometry (resp. a practical unitary).