AKLT-states as ZX-diagrams: diagrammatic reasoning for quantum states

From Feynman diagrams to tensor networks, diagrammatic representations of computations in quantum mechanics have catalysed progress in physics. These diagrams represent the underlying mathematical operations and aid physical interpretation, but cannot generally be computed with directly. In this paper we introduce the ZXH-calculus, a graphical language based on the ZX-calculus, that we use to represent and reason about many-body states entirely graphically. As a demonstration, we express the 1D AKLT state, a symmetry protected topological state, in the ZXH-calculus by developing a representation of spins higher than 1/2 within the calculus. By exploiting the simplifying power of the ZXH-calculus rules we show how this representation straightforwardly recovers the AKLT matrix-product state representation, the existence of topologically protected edge states, and the non-vanishing of a string order parameter. Extending beyond these known properties, our diagrammatic approach also allows us to analytically derive that the Berry phase of any finite-length 1D AKLT chain is $\pi$. In addition, we provide an alternative proof that the 2D AKLT state on a hexagonal lattice can be reduced to a graph state, demonstrating that it is a universal quantum computing resource. Lastly, we build 2D higher-order topological phases diagrammatically, which we use to illustrate a symmetry-breaking phase transition. Our results show that the ZXH-calculus is a powerful language for representing and computing with physical states entirely graphically, paving the way to develop more efficient many-body algorithms and giving a novel diagrammatic perspective on quantum phase transitions.


I. INTRODUCTION
Representing involved mathematical formulae with simple diagrams has been a common strategy to drive progress in physics. An important and widespread example of this are Feynman diagrams [1], where the often cumbersome integrals that predict the amplitude of a quantum field theory process are ordered in perturbation theory with the aid of simple diagrammatic representations.
A more recent example is the formulation of the quantum many-body problem in terms of tensor networks, that are often represented diagrammatically [2,3]. Tensor networks have triggered the development of computationally efficient variational algorithms that find an approximate solution to many-body problems [4][5][6][7][8][9][10]. These formulations are based on efficient representations of quantum states, for which matrix product states [11][12][13] (MPS) and projected entangled pair states [14,15] (PEPS) are among the most successful approaches. These states are often represented diagrammatically as sites that connect to each other by legs that represent tensor contractions.
Despite their unquestionable success in addressing the quantum many-body problem, tensor networks have known limitations. For example, MPS are a onedimensional (1D) representation of the wavefunction, which limit their scope, while PEPS cannot be contracted both efficiently and exactly [2,16]. Additionally, there are limitations to the type of states one can represent efficiently using existing tensor networks. MPS are well suited to describe gapped Hamiltonians in one and two di-mensions, but are less suited for critical states and higher dimensions [17][18][19]. PEPS can handle both gapped and critical states and can be defined in any dimension [20], but representing certain states is challenging, notably states with chiral topological order [21][22][23][24]. Although many other tensor-network methods exist [2,3], each tailored to solve different issues, finding novel ways to represent states is an ongoing challenge.
In this work we present a diagrammatic representation of quantum states with which we can compute directly, in contrast to the typical graphical representation of a tensor network which is merely a representation of the underlying mathematical operations (the tensor contractions). We use ZX-diagrams, a type of tensor network that comes equipped with a set of graphical rewrite rules known as the ZX-calculus. The ZX-calculus was developed to better understand the foundations of quantum information and entanglement [25][26][27]. It has seen use in quantum circuit optimisation [28][29][30][31], measurement-based quantum computation [32][33][34] and surface code lattice surgery [35][36][37][38]. The goal of this paper is to explore how the ZX-calculus can be used to represent quantum states, and to extract their useful physical properties.
The power of the ZX-calculus stems from the fact that we can simplify a given diagram without calculating its underlying matrix: the diagram is the calculation. The ZXcalculus is complete, which means that any diagrams representing the same linear map can be transformed into one another entirely diagrammatically [39][40][41][42][43]. ZX-diagrams are generated by a small set of generators that are symmetric tensors acting on a two-dimensional (i.e. spin-1/2) Hilbert space. While ZX-diagrams can in principle represent any linear map between qubits, some particularly canonical constructions are relatively hard to represent, in particular 'AND-like' constructions that are especially relevant for this work. To remedy this problem, in 2018 the ZH-calculus was introduced [43]. It adds another generator to the ZX-calculus, and suitable rewrite rules to reason about it. In this paper we will develop and use a slight variation on the ZH-calculus that we dub the ZXH-calculus.
The question we address in this work is to what extent the ZXH-calculus can efficiently represent quantum states, and simplify operations on them. We find that the ZXH-calculus presents some advantages compared to existing formulations, and an evident potential for further advances. We demonstrate this by writing 1D and 2D AKLT states [44,45] as ZXH-diagrams. For the 1D AKLT state we show that the ZXH representation allows us to detect its string order graphically [46]. We also map the ZXH representation of the 1D AKLT state to its MPS representation [8], establishing a bridge between graphical calculi and MPS representations. By exploiting the benefits of the diagrammatic calculus we derive that the Berry phase of the 1D AKLT state is π for any finite chain-length [47]. To exemplify the power of the ZXH representation further, we prove entirely diagrammatically that the 2D AKLT state reduces to a graph state under a suitable set of measurements. This result, originally proved in Ref. [48] and independently in Ref. [49], can be used to show that the 2D AKLT state is a universal resource for quantum computation. While Ref. [48] proved the reduction to a graph state using reasoning specific to their construction, using our representation it follows directly using relatively simple and standard diagrammatic rewrites of the ZXH-calculus.
Lastly, we consider how crystalline symmetries can be implemented in ZXH by constructing a higher-order topological phase protected by mirror symmetry. We find that symmetric diagrams represent symmetric states, offering a straightforward, diagrammatic way to implement crystal symmetries, not available to other tensor networks. We show how this result is advantageous to describe phase transitions diagrammatically; by breaking the mirror-symmetries that protect the higher-order topological state down to four-fold rotations (C 4 ), we can observe how the topological end-modes, originally pinned to the corners, move along the boundary.
For several of our computations we have used the Python software package PyZX to assist in the diagrammatic reasoning [50]. Many of the computations we present in this paper are shown for pedagogical purposes only as they can be performed in an entirely automated manner by PyZX, evidencing the power of using the ZXHcalculus to represent these states. For these calculations see the accompanying Jupyter notebooks 1 .
Based on the early work on the ZX-calculus of [51,52], the authors of [53,54] also graphically calculated properties of some tensor network states. However, they restricted to representing networks that are stabiliser states, and hence for which it is already known they can be efficiently contracted [55]. In contrast, our work deals with states that are computationally universal [48,49,56]. Other related work is the quon graphical language [57][58][59][60], that has so far also focused on stabiliser protocols, and Ref. [61] which recently developed a graphical tensornetwork representation of path integrals describing topological phases.
The main difficulty in using the ZXH-calculus to represent arbitrary quantum states is that all the indices of the tensors in a ZX-diagram are of dimension two (i.e. they are spin-1/2 degrees of freedom). Hence, to use ZXH-diagrams to represent quantum states that live in larger Hilbert spaces (such as the spin-1 states in a 1D AKLT state) we need to encode these larger Hilbert spaces into tensor products of two-dimensional Hilbert spaces. We solve this problem by resorting to the representation theory of SU (2), which tells us there is a unique N -dimensional representation given by the symmetric subspace of N − 1 copies of C 2 . Our construction of this symmetriser in terms of simple tensors and its ties to the representation theory of SU (2) might be of broader interest.
As the intersection of readers familiar with both the ZX-calculus and the AKLT state is probably quite narrow, we give a self-contained introduction to both. In Section II A we describe briefly what AKLT states are by introducing the paradigmatic 1D AKLT state. In Section II B we present a concise review of the ZX-calculus and its extension to the ZXH-calculus. Then in Section III we represent the 1D AKLT state in the ZXH-calculus and demonstrate some calculations on it. In Section IV we discuss how we can represent higher spin systems in the ZXH-calculus, and we use this in Section V to represent the 2D AKLT state on a hexagonal lattice in the ZXH-calculus and to derive its reduction to a graph state fully diagrammatically. We study symmetry transitions of states in Section VI and we end with some concluding remarks in Section VII.

A. Introduction to AKLT states
The one-dimensional AKLT Hamiltonian, named after Affleck, Lieb, Kennedy and Tasaki, is defined as [44] 1 You can find the accompanying Jupyter notebooks here.
where β = 1/3. This Hamiltonian acts on a chain of N spin-1 degrees of freedom. Hence, the local Hilbert space at each site is C 3 , on which we act with the spin operator S i = (S x i , S y i , S z i ), where the S a i are the 3 × 3 spin-1 matrices (these matrices, along with other additional information on the AKLT state is given in Appendix A). Using representation theory it can be shown that the Hilbert space of a chain with N sites, (C 3 ) ⊗N , can be represented by N copies of the symmetric subspace of a pair of spin-1/2 particles. This decomposition is convenient for finding the groundstate of the AKLT Hamiltonian Eq. (1), because this Hamiltonian can be written as a positive sum of spin s = 2 projectors on neighbouring sites. Hence, by finding a state where two neighbouring spins are not in the s = 2 subspace, we can construct the ground state of the AKLT Hamiltonian. Specifically, the groundstate can be constructed by decomposing each spin-1 site into two spin-1/2 sites that form singlets between neighbouring sites ( Fig. 7 (a)), and thus have a maximum s = 1. These two spin-1/2 sites are then projected back to the physical s = 1 at each site by the appropriate symmetrising projectors ( Fig. 7(b)). By construction, the resulting state, depicted in Fig. 7(c) is annihilated by the s = 2 projectors, and is therefore an exact ground state of Eq. (1). We refer to this groundstate as the AKLT state 2 .
The AKLT state has three important properties that we will express using the ZXH-calculus [46,47,62,63]. The first property stems from the fact that terminating the chain necessarily breaks two singlets, one at each edge, leaving two free spin-1/2 degrees of freedom at the edges. Since each spin-1/2 has a local Hilbert space of C 2 (the dimensions corresponding to spin up or spin down), the AKLT state with open boundary conditions has a degeneracy of four (2 2 ).
The second property that we wish to express using the ZXH-calculus is that the AKLT state has a string order [46]. Namely, the AKLT state is a superposition of all spin configurations where, if we ignore the spins with s z = 0, the remaining spins are ordered anti-ferromagnetically: a spin s z = ±1 is followed by s z = ∓1 [64]. For example, |j 1 , j 2 , · · · j N = |1, 0, 0, 0, −1, 0, 0, 0, 1 is an allowed configuration, while |1, 0, 0, 1, 0, 0, 0, 1 is not. Analogous to how a spin-1/2 antiferromagnetic order can be captured by an alternating spin-spin correlation function, this string order can be captured by defining a string order parameter [46].
The last property of the 1D AKLT chain that we consider in this work is its Berry phase. In describing symmetry-protected topological phases, such as the 1D AKLT state, and their phase transitions, it is useful to define quantities that are quantised due to the underlying symmetries that protect the phase. Hatsugai showed that the Berry phase, to be defined in Sec. III C, is quantised to π for the 1D AKLT state in the thermodynamic limit [47]. This distinguishes this state from trivial 1D states, for which the Berry phase is zero. The quantisation of the Berry phase was later generalised to describe other symmetry protected topological phases [65][66][67][68].
The AKLT state has also a simple MPS representation. To describe it we follow the notation of Ref. [8] from which we recall that any quantum state can be written as a product of matrices as (2) The indices j i are called physical indices because they span the local Hilbert space at a given site n (e.g. j i = 0, ±1 for spin-1). For a given j i and n the M [n]jn αiαi+1 are matrices in the indices α i , known as bond indices 3 . Although (2) is an exact representation of any state of a finite system, the maximum dimension of the bond indices needed to write a given state, known as the bond dimension χ, generally grows exponentially with system size. The bond dimension χ is a measure of the entanglement of the state we wish to represent [8].
The AKLT state can be written as an exact MPS of bond dimension χ = 2. The local Hilbert space of each site consists of three spin-1 states and, with periodic boundary conditions, each site is equivalent. The AKLT state is defined by the three matrices which are the same for all sites 1 < n < N in the bulk (see Fig. 7(d)). The ideas behind the AKLT state and their generalisations are widely used to understand more complicated condensed matter systems [69], and used as well as computational tools [2]. The one-dimensional AKLT state can also be generalized to two-dimensional lattices [45]. The particular case we will consider in Section V is the AKLT state on a hexagonal lattice with a spin-3/2 degree of freedom at each site. It can be constructed using entangled pairs of spin-1/2 states projected to the appropriate subspace. Hence the 2D AKLT state can be represented as a 2D PEPS with dimension D = 2 [15]. This state was shown to be a universal source for measurement-based quantum computation [48].

B. Introduction to the ZXH-calculus
In this paper we will use a graphical calculus that is a mixture of the ZX-calculus and the ZH-calculus. For ease of reference we dub this language the ZXH-calculus. First, we provide a brief overview of the more well-known ZX-calculus. For an in-depth reference see Ref. [27] or Ref. [70].
The ZX-calculus is a diagrammatic language similar to quantum circuit notation [25,26]. A ZX-diagram (or simply diagram) consists of wires and spiders. Wires entering the diagram from the left are inputs; wires exiting to the right are outputs. Given two diagrams we can compose them by joining the outputs of the first to the inputs of the second, or form their tensor product by stacking the two diagrams.
Spiders are linear operations which can have any number of input or output wires. There are two varieties: Z-spiders depicted as green dots and X-spiders depicted as red dots, each of which can be labelled by a phase α ∈ R: α ... ... := |0 · · · 0 0 · · · 0| + e iα |1 · · · 1 1 · · · 1| (4) α ... ... := |+ · · · + + · · · +| + e iα |− · · · − − · · · −| Note that if you are reading this document in monochrome or otherwise have difficulty distinguishing green and red, Z-spiders will appear lightly-shaded and X-spiders darklyshaded. ZX-diagrams are constructed iteratively from these spiders by composing them either sequentially, which on the level of the linear map corresponds to the regular composition of linear maps, or by stacking them, which forms the tensor product of the linear maps they represent. As a special case, diagrams with no inputs represent (unnormalised) state preparations, while diagrams with no open wires represent complex scalars. As a demonstration, let us write down some simple state preparations and unitaries in the ZX-calculus: Note that, while (8) and (9) have a label α, we have not given a label to the state preparations (6) and (7). By convention, a spider without a label is taken to have a label of 0. When we take α = π in (8) and (9) we get Pauli matrices:  Figure 2. The rules of the ZX-calculus. These rules hold for all α, β ∈ [0, 2π), and a ∈ {0, 1}. They also hold with the colours red and green interchanged, and with inputs and outputs permuted freely. Note '...' should be read as '0 or more', hence the spiders on the left-hand side of (f) are connected by one or more wires. Furthermore, the addition in (f) is taken to be modulo 2π. The right-hand side of (b) is a fully-connected bipartite graph. The rulenames stand respectively for (f)use, (πc)opy, (b)ialgebra, (c)opy, (id)entity and (ho)pf.
By composing spiders we can make more complicated linear maps, such as the CNOT gate: Here the symbol '∝' denotes that the diagram is proportional to the gate, i.e. that there exists a global non-zero scalar correction (in this case, the diagram needs to be multiplied by √ 2) that makes them exactly equal. For many of the calculations in this paper, the exact scalar value will not be important. For clarity, we will in those cases drop scalars implicitly. As above, we will write ∝ in a diagrammatic derivation to denote that the diagrams are merely equal up to a non-zero scalar.
We can treat a ZX-diagram as a graphical depiction of a tensor network, similar in style to the work of e.g. Penrose [71]. In this interpretation, a wire between two spiders denotes a tensor contraction. As tensors, Z and X spiders can be written as follows: where i α , j β range over {0, 1} and ⊕ is addition modulo 2.
ZX-diagrams have a number of symmetries that make them easy to work with. In particular, we can treat a ZX-diagram as an undirected (multi-)graph, so that we can move the vertices around in the plane, bending, unbending, crossing, and uncrossing wires, as long as the connectivity and the order of the inputs and outputs is maintained. These deformations of the diagram do not affect the linear map it represents. Indeed, the reader might have noticed that in the CNOT diagram (11) we drew a vertical wire without explaining whether this denotes an input or an output from the Z-and X-spider. We are warranted in drawing it this way because: Besides these topological symmetries, ZX-diagrams have a set of rewrite rules associated to them, collectively referred to as the ZX-calculus. See Figure 2 for a set of these rules. Note that these rules also hold with the Zand X-spider interchanged (i.e. with the colours flipped). When doing diagrammatic derivations, we will often label the equalities with one of the rule names of Figure 2, such as (f), to denote that rule was used there.
In Figure 2 we use a hybrid notation of writing numbers in the diagram itself to denote the correct global scalar needed to make the linear map of the two sides of the diagram exactly equal to one another. As noted above, we will sometimes drop these scalar factors when they are not relevant to the derivation at hand.
As a small demonstration of these rewrite rules, let us prove diagrammatically that the CNOT diagram (11) indeed acts like the CNOT. The computational basis states are given by the following diagrams.      on these basis states: ZX-diagrams were introduced over a decade ago [25] and have proven useful for reasoning about Clifford computation and single-qubit phase rotation gates [28,35,72]. It is however harder to reason about certain logical constructions, in particular the AND operation |x ⊗ |y → |x · y . For instance, the only way to represent a CCNOT gate (also commonly known as the Toffoli gate) in the ZXcalculus is to expand it into Clifford and phase gateswhich contains on the order of ≈ 25 spiders. In 2018 a new graphical calculus was introduced to remedy this problem: the ZH-calculus [43]. This calculus adds another generator to the ZX-calculus that allows for a compact representation of an AND gate. This new generator is the H-box : Here a can be any complex number, and the sum in this equation is over all i 1 , . . . , i m , j 1 , . . . , j n ∈ {0, 1} so that an H-box represents a matrix where all entries are equal to 1, except for the bottom right element, which is a. As a tensor we can write it as: Whereas for spiders we only draw the phase on the spider when it is nonzero, for H-boxes we only draw the label when it is not equal to −1. This is because the 1-input, 1-output H-box with a phase of −1 corresponds to the familiar Hadamard gate (up to a global scalar): Note that in this paper we only need H-boxes labelled by −1. We give the general definition for completeness' sake.
We have the following relations among the three generators, Z-spiders, X-spiders and H-boxes: Note that it is also possible to represent H-boxes of higher arity, i.e. boxes with a larger number of input and output wires, using just Z-and X-spiders, but this is quite involved and not necessary for our purposes [73].
In addition to the rules of the ZX-calculus of Figure 2 and the relations among the generators (20)-(23) we also have some rules specific to the ZH-calculus; see Figure 3. We present in Appendix D a condensed overview of all the rewrite rules and relations we have introduced so far.
An H-box with zero input and output wires that is labelled by a is equal to the scalar a. This means we can always translate the scalars in the hybrid notation of Figures 2 and 3 into a ZH-diagram. For instance, the self-inverseness of the Hadamard gate can be represented as follows: ZH-diagrams are universal, meaning that any linear map between complex vector spaces of dimension 2 n can be represented as a ZH-diagram. Furthermore, the ZHcalculus is complete, meaning that if two diagrams represent the same linear map, then we can find a sequence of rewrites from Figures 2 and 3 and equations (20)-(23) that transforms one diagram into the other [43]. However, in general, such a sequence of rewrites will involve diagrams of size exponential in the number of inputs and outputs (as otherwise we could establish efficient classical simulation of quantum computation, among other unlikely consequences such as P=NP). The key to working with ZH-diagrams efficiently is then to find good heuristics for simplifying diagrams.
H-boxes allow us to straightforwardly represent controlled-phase gates. For instance, a CCZ(θ) gate, i.e. a gate that maps the computational basis state |xyz to e iθxyz |xyz is given by: As a special case of (25) we also have the standard controlled-Z (CZ) gate: As another variation on these diagrams, we have the following diagram that we will use different iterations on throughout this paper: I.e. this linear map throws away a |11 input, but otherwise acts as the identity. As another variation on (25) we can represent the CC-NOT gate as follows: Those familiar with the ZX-calculus or the ZH-calculus might have noticed that they have conflicting definitions of the X-spider and the 2-ary H-box, resulting in different scalar factors of √ 2. In this paper we use the conventions also used in PyZX [50] in order to aid in our calculations. This means that our Z-and X-spider are defined as is usual in the ZX-calculus. However, most literature on the ZX-calculus also includes a yellow box to represent the Hadamard gate. In our case we use the convention of the ZH-calculus that such a box represents an unnormalised Hadamard gate (cf. (19)). Hence, certain scalar factors will be different than is usual in the literature on the ZXcalculus. Conversely, our H-box and Z-spider match the definition used in the ZH-calculus, but our X-spider does not match the corresponding definition in the ZH-calculus, and is off by certain factors of √ 2. It is unfortunately not possible to have a fully satisfactory convention when it comes to scalar factors in the ZX/ZH-calculus, and choices have to be made about where scalar corrections appear (see [74] for a longer discussion on this topic). In order to prevent confusion about these clashing scalar conventions, we will refer to our version of the ZX and ZH calculus as the ZXH-calculus throughout the paper.

C. Graph states
As it will be important for Section V, let us recall briefly the notion of graph states and how they can be represented in the ZX-calculus. Given a simple undirected graph G = (V, E), there is a corresponding graph state |G . The state |G is constructed by preparing for each vertex v ∈ V a qubit in the |+ state, and for each edge (v 1 , v 2 ) ∈ E applying a CZ gate between the qubits corresponding to v 1 and v 2 [75]. Recall that graph states are important as all stabiliser states can be reduced to a graph state (up to local Cliffords) [76], and because most measurement-based quantum computation protocols use a graph state as their resource state [77].
The representation of a graph state in the ZX-calculus is most easily explained by an example: In words: for each vertex of the graph we add a Z-spider with a single output, and for each edge we add a corresponding wire between spiders with a Hadamard gate on it.

III. THE 1D AKLT STATE IN THE ZXH-CALCULUS
A. ZXH representation and relation to matrix-product states We now have all we need to show how the AKLT state is represented in the ZXH-calculus. We start by representing the singlet operator |01 − |10 of Fig. 7(a). Note that the Bell state |00 + |11 is related to the singlet state by application of a Pauli Z and X on one of its qubits. Hence, the operator in ZXH is: Indeed, an empty curved wire (commonly referred to as a 'cup' in the ZX-calculus literature) is the Bell state |00 + |11 . If we then apply a Z π-phase (|0 0| + e iπ |1 1|) to the first (upper) qubit we get |00 − |11 . Applying a NOT gate (an X π-phase) on the second (lower) qubit we then get |01 − |10 as desired. The next operator we need to represent is the symmetriser on two spin-1/2 spaces. We encode the spin-1 state |+1 as the paired spin-1/2 state |00 , the spin-1 state |0 as |01 +|10 √ 2 and |−1 as |11 . This is a convenient basis for us, and indeed the projector operator in Fig. 7(b) acts as the identity on this basis. In fact, the operator of Fig. 7(b) only acts to project away the |01 − |10 state, which reduces the basis , |11 . We can represent the projection operator as a ZXH-diagram as follows: Indeed, this can be shown by checking its action on each of the basis states in {|00 , |01 +|10 or composing the matrices presented in (11) and (27). We leave this as an exercise for the reader. Note how this diagram is symmetric under interchange of the inputs and outputs (i.e. under a horizontal flip), and hence we will generally not care about its orientation in our diagrams. We will find a different diagram that implements the same operator in Section IV where we show how to construct the symmetrising projector for larger Hilbert spaces. In Figure 7 we summarise our construction of the one-dimensional AKLT state as a ZXH-diagram. We show the diagrammatic representation of its constituents, the singlet ( Fig. 7(a)) and the projector (Fig. 7(b)). The ZXH-diagram of the 1D AKLT state is obtained by joining these in a (periodic) chain, as shown in Fig. 7(f). This diagram consists of repetitions of the same block which is built out the symmetriser projector (31) (Fig. 7(b)) and singlets (30) (Fig. 7(a)): π π π π π π . . . . . . π π π π (32) Note how we have a Z π phase on the left, respectively an X π phase on the right, open wires. We are allowed to do this as we are free to choose a basis for these degrees of freedom. We choose this convention as it allows us to see that there is a repeating block structure. We can now show explicitly how the ZXH-diagrammatic representation and the MPS representation of the AKLT state are connected. In Fig. 7(f) we have overlaid a gray box over the part of the ZXH-diagram that encodes the MPS matrices given in (3), as we now show.
Recall that we represent the spin-1 |+1 state as |00 on a pair of spin-1/2 wires. If we apply this state, given by the first diagram in Eq. (15), to one of the sites of (32), we get a diagram that can be drastically simplified and be shown to be equal as a matrix to M [n]+1 up to a scalar factor of 1 (33) As we are plugging |00 into the top wires, we start with a scalar 1 2 as shown in (15). Note that in the last dia-grammatic step we used that a Z-spider with no legs is equal to a scalar 2. The reason we keep track of scalars here is because for the MPS representation it is important that the matrices are scaled correctly with respect to each other. We now proceed analogously, showing that if we plug the two remaining spin-1 states, |0 and |−1 , into one of the sites of (32) that we get the corresponding MPS matrices up to the same scalar factor of 1 √ 6 . First, we obtain M [n]0 by plugging 1 √ 2 (|01 + |10 ), which corresponds to the |0 spin-1 state: Note here that the last instance of (c) introduced an e iπ = −1 scalar.
As summarized in Fig. 7(e), Eqs. (33), (34) and (35) show that the ZXH representation encodes the same information as the MPS representation Eq. (3), up to a global factor that can be fixed by normalising the state. We can conclude that our ZXH-diagram is indeed equal to the AKLT state. The advantage of the ZXH representation is that we can compute with it diagrammatically, as we will now show.

B. Edge states and string order
From the ZXH-diagram of the 1D AKLT state in Eq. (32) and Fig. 7(f) we can immediately infer one of its main properties: the presence of spin-1/2 edge states under open boundary conditions. Observe that the finite chain Eq. (32) has two dangling wires at the bottom on the left and on the right. The precise way of ending the chain amounts to a choice in boundary conditions, as in a conventional MPS, which fixes the edge two-dimensional spin-1/2 degrees of freedom [78]. If the boundary condition is not fixed, the dangling edge wires can be understood as the projective (or fractionalized) symmetry representation of the bulk spin-1 rotation symmetry [79].
A second property of the AKLT state, the non-zero string order parameter, can be shown by direct computation on its ZXH-diagram as follows. We take L sites in a chain, and we post-select each of the physical indices on the sites 2, 3, . . . , L − 1 to the state |0 : . . . π π π π π π (36) The non-vanishing of the string order parameter then tells us that the sites 1 and L cannot then both be in the spin +1 or spin −1 state. On the level of the diagram we can see this behaviour when we post-select both of the states j 1 and j L to the same non-zero spin state: = 0. π π π π π π π . . . . . . π π π π π π π π π π (37) That this diagram is zero tells us that the spin configuration where j 1 and j L are equal is not part of the AKLT state.
While one could use software such as the PyZX Python package [50] to simplify the diagrams above to show that these diagrams are indeed (non-)zero, it is illustrative to rewrite the diagram manually. Note that the central repeated building block consisting of the projection to the spin-1 subspace followed by a post-selection for the |0 spin-1 state is exactly the diagram we simplified in (34). Hence, (36) simplifies to: π π π . . . . . . π π π π π (39) Note that this diagram is only equal to (36) up to nonzero scalar, but as we only care about whether the coming diagrams are zero or not, this is enough for our purposes. Depending on the number of repetitions of the central block this diagram simplifies to one of the following: π π or π π π π π (40) Whether this middle Z phase appears depends on whether there are an even or odd number of intermediate |0 states applied -giving a Z π-phase in the former case and none in the latter. Now suppose we take j 1 = j L = |+1 . Then we get the following diagram and simplification: A spider with a phase π with no legs is equal to 1 + e iπ = 1 − 1 = 0, and hence this is indeed zero as we expect. The case where we take j 1 = j L = |−1 is shown similarly. Now when we set j 1 = j L , for instance, j 1 = |−1 and j L = |+1 we get a non-zero diagram: aπ π π π π π ∝ aπ π π ∝ (33) (35) (c) (f) π (42) Indeed, as the scalar red spider we get is equal to 2, this diagram is indeed non-zero.
To summarise: we started with the 1D AKLT chain (32). We then post-selected an arbitrary number of adjacent sites to the spin-1 |0 state, resulting in the diagram (36) which we simplified to one of the diagrams in (40) depending on the parity of the number of |0 sites. Then, in Eq. (41) we saw that post-selecting the j 1 and j L sites to be equal but non-zero spins resulted in a zero diagram. However, in (42) we saw that post-selecting the j 1 and j L sites to be different non-zero spins resulted in a non-zero diagram. These observations signal the non-vanishing of the anti-ferromagnetic string order, as expected for the AKLT state.
The calculations presented in this section are also available in the accompanying Jupyter notebook. 4

C. Quantized Berry phase
We now show how to calculate the Berry phase for the 1D AKLT state [47] diagrammatically, obtaining an exact result for any finite chain. To calculate the Berry phase one introduces a phase twist within a given bond (a phase in our case, but a unitary matrix in general). For the periodic 1D AKLT state, this amounts to picking one singlet of the AKLT state |ψ and transforming it to |10 − e iθ |01 . This defines a twisted AKLT state |ψ θ for each angle θ and we recover the standard 1D AKLT state when θ = 0 [47]. The Berry phase is then defined as were we have used the expression for an unnormalised wavefunction (see e.g. [80]) in terms of the normalisation factor ψ θ |ψ θ .
To calculate this value diagrammatically we start by writing the twisted AKLT state |ψ θ as a ZXH diagram: To obtain the Berry phase we need to take the derivative of this diagram. For this we could use the techniques for diagrammatic differentiation described in [81,82]. For our purposes however it suffices to derive a couple of simple equations which can then be described as diagrams. In particular we will need the following diagram equality: Here the factor of 1 2 is introduced because single-wire spiders are equal to states up to a constant √ 2. Using this identity we get: . . .
4 Click here to see the relevant Jupyter notebook.
Each of the four diagrams we get on the right we have already calculated the value of. The diagrams for a = b = 0 and a = b = 1 are equal to that in (56), while the other two are equal to those in (55). Hence: It is simple to check that for θ = 0 the norm can be rewritten as 6 N +3(−2) N = ( √ 6) 2N (1+3(−1/3) N ), which coincides with the usual AKLT normalisation (see e.g. below equation (90) in [7]) up to the prefactor ( √ 6) 2N . This different prefactor is the same √ 6 factor as seen in Eqs. (33), (34) and (35).
Combining Eqs. (60), (55) and (56) the Berry phase is given by Now, factor out the term 3 N + (−1) N from the fraction and define the constant We then see that γ = 1 2 2π 0 ge iθ + 1 g cos θ + 1 dθ = 1 2 2π 0 g cos θ + ig sin θ + 1 g cos θ + 1 dθ Here the second integral evaluates to zero because it is an odd function. We thus arrive to γ = π as was already known in the thermodynamic limit, but which here is shown to hold for all finite lengths [47].

IV. ENCODING HIGHER SPINS IN MULTIPLE WIRES
The wires in a ZXH-diagram represent two-dimensional Hilbert spaces, or in other words, they carry a spin-1/2 representation of SU (2). In the previous section we represented a spin-1 wire (a three-dimensional Hilbert space) by a pair of spin-1/2 wires together with a projector to the appropriate subspace. This raises the question of how we can generalise this construction to higher spin representations, and thus larger Hilbert spaces.
To do this we need some basic representation theory. Recall that the group SU (2) has a unique irreducible representation on C n for each n [83]. For n = 1 this is the trivial representation, and for n = 2 this is the fundamental representation where each matrix M simply acts by matrix multiplication. For our purposes a convenient way to write the n-dimensional irreducible representation of SU (2) (which is spin-n/2) is to take the symmetric subspace of n copies of the fundamental representation [84]. That is, we build spin-n/2 from the symmetric subspace of n spin-1/2 spaces. So, starting with the space of the fundamental representation H = C 2 we build the the space of the (n + 1)-dimensional representation as Sym(H ⊗n ). Indeed, Sym(H ⊗n ) has dimension n + 1 as a basis for it is given by |0 · · · 0 , |1 · · · 1 and the uniform superpositions of computational basis states containing a fixed number of |1 's, such as |10 · · · 0 + |010 · · · 0 + · · · + |0 · · · 01 . In summary, if we can represent the projector to the symmetric subspace on n wires as a ZXH-diagram then we will have succeeded in representing arbitrary-dimensional (spin) systems on a collection of qubit wires.
Let σ ∈ S n be a permutation on n points. We write U σ for the unitary on H ⊗n that permutes each of the composite H spaces via σ: U σ |x 1 · · · x n = |x σ1 · · · x σn . Note that a space can be symmetrised by taking the superposition over all the permutations. Hence, the symmetrising projector P (n) S on n wires is given by Each U σ can straightforwardly be written as a ZXHdiagram by just permuting the wires, but as we need to represent a coherent superposition of these permutation unitaries we need a controlled permutation operator. It turns out to be sufficient to use controlled SWAP (CSWAP) operators that have the control qubit postselected into +|. Recall that the CSWAP is defined by |0xy → |0xy and |1xy → |1yx , i.e. the first qubit determines whether the second and third qubit are swapped. Including the post-selection, we can represent this (up to a non-zero scalar) as a ZXH-diagram in a convenient way: We will refer to the right-hand side as a CSWAP in what follows.
Here the top wire is the control. By inputting a computational basis state we can verify that it indeed performs the maps required. First, when the input is |0 : (67) And second, when the input is |1 : Now, to write the symmetrising projector on n = 2 wires we need an equal superposition of the identity permutation and the SWAP. Hence, if we make the control of (66) a |+ = |0 + |1 state we get the desired map: (69) To generalise this to larger n we use induction. Indeed, if we have a coherent superposition of all the permutations on n wires P (n) S , then to get a coherent superposition of the permutations on n + 1 wires we need to compose P (n) S with a coherent superposition of the identity and the SWAP gates from the (n + 1)th qubit to every other qubit: id + SWAP 1,n+1 + SWAP 2,n+1 + · · · + SWAP n,n+1 . We construct this superposition as a ZXH-diagram by writing CSWAP gates from the (n + 1)th qubit to each other qubit and then connecting all the control wires in such a way that at most one CSWAP 'fires' at the same time. This gives us the general construction for n wires.
For n = 3 this gives the following diagram: This works, because and hence the appropriate superposition is created. We present a general construction for higher spins in Appendix C.
Notice that the symmetric subspace encoding for two wires of (69) seems to give an alternative form of the symmetrising projection given in (31). They can however be shown to be equal, up to an irrelevant scalar: and as such our 1D AKLT chain (cf. Eq. (32)) can alternatively be written as: π π π π . . . . . . π π (73) Where the projector now is of the form (69).
Note that there are modified versions of the ZX-calculus where a wire carries a three-dimensional Hilbert space [85,86]. However, much less is known about rewriting those diagrams, and it is harder to reason about the types of diagrams we have in this paper where we mix systems of different types of spins.

V. THE 2D AKLT STATE AS A UNIVERSAL RESOURCE FOR QUANTUM COMPUTING
We will now study the generalization of the 1D AKLT state to the 2D hexagonal lattice [44], depicted in Fig. 4(a). π π π π π π π π π π π π π π π π π π π π π π Projector Singlet (a) (b) First, we derive the representation of this state as a ZXHdiagram, and then we show how it can be used as a universal resource for quantum computing, by showing that it reduces to a graph state. As mentioned in the introduction, it is possible to construct an AKLT type state on a hexagonal lattice using spin-3/2 degrees of freedom at each site ( Fig. 4(a)). Each spin-3/2 degree of freedom corresponds to a fourdimensional Hilbert space and, by the discussion in the previous section, can be represented on a set of three qubit wires with the projector presented in (70). So whereas in the 1D AKLT state we projected two spin-1/2 states down to the symmetric subspace to represent a spin-1 degree of freedom, here we project three spin-1/2 degrees of freedom to form a spin-3/2. This projector, with each of the component spin-1/2 wires linked to another by singlet states, forms the basic unit (a site) of the 2D AKLT state. As a ZXH-diagram: π π π π π π (74) Here we have a single spin-3/2 degree of freedom of the 2D AKLT state with singlet states on each of its legs. These can then be combined to give a diagram of a lattice that is not just a convenient visual aid for the 2D AKLT state, but literally is the 2D AKLT state; see Figure 4(b).
Analogous to the 1D AKLT example in Fig. 7 where two wires corresponded to the physical spin-1 state, the triples of wires coming out to the right of (74) correspond to the physical spin-3/2 degrees of freedom that form the state. The remaining wires of the diagram should be considered to be connected to other parts in the hexagonal lattice periodically (see Fig. 4(b)).
We will now show how a hexagonal lattice AKLT state reduces to a graph state under a suitable measurement of the spin-3/2 degrees of freedom. A consequence of this result is that the 2D AKLT state is a universal resource for measurement-based quantum computing [87]. This result was already shown in Ref. [48] and independently in Ref. [49]. The proof in Ref. [48] consists of two parts. First, they showed the hexagonal lattice reduces to a graph state. Second, they used a percolation argument to prove the resulting state is a universal resource for quantum computation. We will derive the first part entirely diagrammatically. In the process we will see that certain derivations concerning the simplification of the lattice presented in Ref. [48] are in our approach just the standard spider fusion rule (f) and the Hopf rule (ho) of the ZX-calculus.
To reduce the 2D AKLT state to a graph state, we need to reduce it to a simpler state. We do this by measuring each of the spin-3/2 states. Recall that each of these spin-3/2 states is presented as a symmetric three qubit state and hence a measurement on it can be present as a simultaneous measurement on these three qubits. The measurement is a POVM (Positive operator-valued measurement, the most general type of measurement [88]) with three elements: Here the sets {|0 , |1 }, {|+ , |− } and {|i , |−i } denote respectively the eigenbases of the Z, X and Y Pauli matrices. Usually the elements of a POVM should sum up to the identity, but as we are working in the symmetric subspace, we instead have E z + E x + E y = P S , where P S is the projection on the symmetric subspace, as desired. Conveniently, each of these POVM elements can be represented as a small ZX-diagram (up to global scalar): The forms of E z and E x follow directly from the definition of the Z-and X-spider. To see the correctness of E y note that a Z π 2 -rotation R z ( π 2 ) acts as R z ( π 2 ) |+ = |i and Hence, we can see (80) as an X-projector surrounded by a basis transformation from the Y eigenbasis to the X eigenbasis. We could have equivalently chosen a Z-projector surrounded by X ± π 2 rotations which corresponds to flipping the colours and the signs of the rotations; cf. [27,Section 9.4]. Note that E y is not symmetric under interchange of inputs and outputs, and thus unlike the case for E z or E x , when considering E y we must keep in mind what we consider an input and output.
Importantly, each of the POVM elements E z , E x , E y projects to a 2D subspace, and hence encodes a spin-1/2 degree of freedom. While we could continue to work with the three output wires as a single qubit with the qubit operations encoded onto the three wires, we will instead represent the collapse to a single spin-1/2 degree of freedom by simply writing one wire: We will use this 'squigly arrow' to denote when we make a step that corresponds to a redefinition of the output basis. Here this is a collapse of a two-dimensional degree of freedom spread out over three wires to a single wire, but later on we will also use redefinitions to absorb single qubit gates that appear on output wires. Physically, this corresponds to updating the correspondence between the 'logical' or 'encoded' |0 and |1 , and the actual physical states.
As these POVM elements are symmetric on the three qubits, they are preserved by the projection to the symmetric subspace, a fact we can prove diagrammatically. For instance, considering E x , we first show that it absorbs a CSWAP gate: Iterating this three times we then get the following equality: The floating scalar diagram on top multiplied by the scalar produced by the sequence of rewrites represents the eigenvalue of this operation under the projection. This scalar is not important for our purposes, and we will drop it implicitly in later diagrams.
We can do a similar derivation for E z (see Appendix B 2): An analogous equation and derivation exists for E y as well (see Appendix B 2).
We started with the 2D AKLT state on a hexagonal lattice (Figure 4), and then we measured each of the spin-3/2 states with this POVM {E z , E x , E y }. Due to equations (85) and (86) and the analogous one for E y , we see that regardless of the measurement outcome E z , E x or E y that the symmetrising projector on each spin-3/2 output is 'consumed' and replaced by the spider associated to one of E z , E x and E y . Hence, what remains of the 2D AKLT state is a set of singlet states, connected via a network of spiders of the form (81)- (83). The state resulting from applying this measurement to the 2D AKLT state will hence be a hexagonal lattice where at each site we randomly have a X,Y or Z spider (which depends on the measurement outcome), and these are connected via singlet states. For example, the hexagonal unit cell of Fig. 4(b) could be reduced to a diagram like the following: π π π π − π 2 − π 2 − π 2 π π π π π π π π − π 2 − π 2 − π 2 π π π π π π π π π π π 2 π 2 π π (87) Readers familiar with the ZX-calculus can easily see that the resulting diagram is a Clifford diagram. Indeed, it does not contain any higher-arity H-boxes, and the only phases that appear are multiples of π 2 making it a ZXdiagram in the Clifford fragment [72]. As it only has outputs, it is a state, and hence is a Clifford state 5 . Any Clifford state can be presented as a graph state with single-qubit Clifford unitaries on its outputs (see Ref. [76], or for a proof using the ZX-calculus, see for instance Refs. [28,72]). Hence, we can already conclude that the state we get is a graph state.
However, to show that the state we obtain is a universal resource for quantum computing we need to know more about the specific construction of the graph state, so let us go through the derivation manually. This happens in a few steps.
The first step is to get rid of the Z and X π-phases arising from the singlet states. We will do this by commuting these phases through the spiders onto the outputs of the state (the spin-3/2 outputs). For instance, for a E z outcome, we can do the following: π π π π π π = π π (f) (πc) (88) Here the site is understood to be in the bulk of the lattice, with the top wire corresponding to its spin-3/2 degree of 5 Recall that a Clifford state, also called a stabiliser state, is a state that is uniquely determined by being a eigenvalue 1 eigenvector of a set of Pauli operators. Any Clifford state can be represented by a ZX-diagram containing only spiders with phases that are multiples of π 2 . freedom 6 . Hence, we can remove the internal π phases by moving them onto the external edges. The analogous procedure for E x and E y measurement outcomes is demonstrated in Appendix B 3.
Since each Z and X π-phase is connected to two spiders we need to make a choice about which way to commute each π. As the hexagonal lattice is two-colourable this is indeed possible in a consistent way.
After this procedure, we will have a diagram where the only π phases are on the spin-3/2 outputs of the states. As discussed beneath (83), our choice of representation of the spin-3/2 degree of freedom can be chosen arbitrarily. Hence we can redefine our basis here to remove these π phases (this again corresponds to a redefinition of how we encode the |0 and |1 states on our physical system): The second step is to bring the diagram closer to the form of a graph state as presented in (29) by changing the X-spiders coming from E x and E y measurement outcomes to Z-spiders. This can be done easily using (21), and a redefinition of the output basis to remove the resulting Hadamard: . . . . . .
We leave the other cases to the reader. The diagram we have now consists solely of Z-spiders and Hadamards. Now, the third step of our reduction to a graph state is to fuse all the spiders that can be fused. In practice this means that two adjacent sites that had the same measurement outcome will be fused together. This fusing results in sites that have multiple outputs, which we again collapse to a single output as we did in (81)- (83). See Figure 5 for a demonstration of this procedure.
The final step is to remove parallel Hadamard-edges that could have been introduced by sites that were fused together. To do this we use a variation on the Hopf Figure 5. This figure shows the AKLT hexagonal lattice after the Ex, Ey, and Ez projectors have been applied and the π phases moved onto the external wires and absorbed into basis redefinitions. In the first diagram on the left note that we have added X,Y,Z labels to the Z-spiders. These aren't formally part of the diagram, but are just labels to indicate which projector was applied to reach this diagram. The first equality shows that spiders with the same measurement outcome are merged. Following this, the Hopf rule (ho) is applied to remove pairs of wires with a Hadamard box on them between the same spiders. The final step is to redefine the output basis to collapse multiple output wires coming from the same spider into a single wire. The resulting diagram can indeed be seen to be a graph state. This bears strong resemblance to the diagram seen in [48] (figure 4 diagram C) where now their ad-hoc reduction is describable entirely in quantum-informational terms via the ZXH-calculus.

rule (ho):
(hh) (92) The resulting diagram consists of phaseless Z-spiders connected via single Hadamard-edges, and hence is a graph state, as was desired. Note that this entire procedure can also be done in an automated fashion using PyZX [50]; see the accompanying Jupyter notebook. 7 Because neighbouring sites that have the same measurement outcome get fused, and parallel edges resulting from this fusing get disconnected, the highly regular hexagonal graph will generally collapse to a much less regular and more sparsely connected graph. For example, consider the hexagonal graph given in Figure 5 where the vertices are labelled by X,Y , or Z to denote the 2D AKLT state with the E x , E y or E z measurement outcomes, and consider also its reduction with the rules outlined above.
Not any graph state can be used as a universal resource for measurement-based quantum computing. The most 7 Click here to see the relevant Jupyter notebook. canonical example of a universal resource state is the cluster state that as a graph is just a regular square tiling. In Ref. [48] it is shown via a percolation argument that given a large enough initial hexagonal lattice the irregular graph state resulting from the measurement of a 2D AKLT state can, with high probability, be further reduced to a cluster state. In particular, they show that the expected connectivity of the graph is above the critical 'percolation threshold' [89] which means that it includes a large cluster state subgraph with high probability. Hence, for a large enough lattice we can use, with high probability, the 2D AKLT state to do universal measurement-based quantum computation.
The goal of this section is to diagrammatically represent a transition between topological states with different crystal symmetries. Using mirror and rotational symmetries as a specific example, we will first discuss how to diagrammatically construct states that are symmetric crystal symmetries. This will require that the diagram representing the state is also symmetric, in a way that we will specify shortly. With these states in hand, we will construct a ZXH-diagram that transitions between two states with different crystal symmetries as a function of a control parameter. The possibility of diagrammatic transitions between topological states serves as an example of the potential of diagrammatic reasoning compared to other tensor networks, even for relatively simple states.
Concretely, we consider the higher-order symmetry protected topological state based on the AKLT state shown in Fig. 6(a) [96]. Each site represents a spin-2 degree of freedom, which can be decomposed into four spin-1/2 wires. Coupling these spin-1/2s with singlets in the configuration shown pictorially in Fig. 6(a) results in four unpaired spin-1/2 degrees of freedom that reside at the corners (red circles). The existence of each one of these unpaired spin-1/2 degrees of freedom is protected by mirror symmetry: they cannot be removed unless mirror symmetry is broken, for example by acting with different local unitary operators at sites related by mirror symmetry.
Constructing this state as a ZXH-diagram is straightforward using our previous discussions. For each site we construct the n = 4 symmetriser, as we did in Eq. (70) for n = 3. Then we connect the sites with singlets in the way specified in Fig. 6(a). This results in the diagram shown in Fig. 6(b), where we have only shown the lower-left quadrant for clarity. Note that we know that the symmetriser is symmetric under any permutation of its wires, by definition of it representing the symmetriser. Concretely this means it is irrelevant which intra-site wire connects to other sites as all wires within a site are equivalent. Hence, for the purposes of symmetry, any reordering of the connectivity at the individual site level is irrelevant and we need only to concern ourselves with the connectivity between different sites.
So long as we connect sites in a way that respects the desired symmetry (which will be either mirror or rotational symmetry in our example) the diagram will possess the same crystal symmetries as the state it represents. This follows from a general property of ZXH-diagrams. If one constructs a diagram which can be brought to a symmetric form with respect to some lattice symmetry, the state that it represents must also have these symmetries. This is the case because the generating elements of the diagram, spiders and H-boxes, are themselves fullysymmetric tensors and thus any symmetry in the relation of the diagrammatic elements is also a symmetry of the tensors they represent. Note this does not imply that an asymmetric diagram represents an asymmetric tensor, as it is is possible to apply rewrites to one side of a symmetric diagram to remove the diagrammatic symmetry. For instance, our symmetriser diagram is asymmetric, yet represents a symmetric tensor. Note however that because the calculus is complete, there will always be a series of rewrites that transforms a diagram representing a tensor with some symmetry to a diagram with the same symmetry.
Instead of constructing a state with a mirror symmetry, as in Fig. 6(a), we can similarly construct a state which has four-fold rotational symmetry; see Fig. 6(c). This state also has dangling spin-1/2 states on each side, at positions related by C 4 symmetry. Its corresponding ZXH representation is depicted in Fig. 6(d), where once more we only show the lower-left quadrant for clarity.
While a desirable property of ZXH-diagrams is that a symmetric diagram mathematically represents a symmetric state, one might feel that the schematic representations in Fig. 6(a) and Fig. 6(c) already imply that the states possess the symmetries we are interested in, even if they lack mathematical rigour. The ZXH-representations in and of themselves may then not seem like a sufficient advantage, at least for simple states. The advantage becomes clearer however when we consider what one can do once the states are rigorously defined. As we show next, the ZXH-diagrams allow us to go further than is possible with informal representations. We will show how to model a transition between these two states by diagrammatically breaking the symmetry. It is unclear how one would represent this schematically in a useful way. More importantly, it also goes beyond what one could achieve using other tensor network approaches, which would require explicit knowledge of the tensors that define these states.
Let us now describe how to interpolate between the mirror-symmetric state of Fig. 6(a,b) and the C 4symmetric state in Fig. 6(c,d) using a parametrised ZXH-diagram. Since we are dealing with (at least) C 4symmetric states it is sufficient to focus on a quadrant, e.g. the bottom-left quadrant. Our goal will be to break the symmetry by moving the corner mode one site down, from the corner to the edge, along with the relevant intersite singlets. We can represent the path between these two states by a parametrised ZXH diagram. To do this we will make repeated use of the following diagrammatic element that can represent both a singlet as well as a product state: when f (θ) = π π π π π 2 √ 2 (93) When f (θ) = 0 it disconnects, while for f (θ) = π it generates a singlet between the spiders. These two cases are easily derived by application of (ex) and (ab). By iterating this construction we can toggle the connectivity of many singlets at once in a diagram. It is precisely this mechanism that allows us to demonstrate a diagramatic transition between the two symmetric higher-order symmetry-protected states of Fig 6; see Fig 7. For f (θ) = 0 or f (θ) = π we can start to apply (c) to push the corresponding X spider through the diagram, where it encounters some π phases to toggle its behaviour for that particular singlet.
To summarise, we have shown that if a diagram has crystal symmetries, or is built with elements that respect the symmetry, the state the diagram represents has the same symmetries. This allowed us to build a diagram that interpolates, as a function of a control phase, between two different symmetry-protected higher-order topological phases.
symmetries can be implemented by constructing symmetric diagrams. This observation allowed us to exemplify a transition between a mirror-symmetric and C 4 symmetric higher-order topological phase. In addition, many of the diagrammatic calculations (the entirety of sections III and V) were presented solely for pedagogical purposes and are of such a mechanical nature that they can be done straightforwardly by PyZX, a Python package that can simplify ZXH-diagrams. In the process of constructing the AKLT states, we also found a general way to represent the symmetrising projector on a tensor product of qubit Hilbert spaces in the ZXH-calculus.
Our work opens several directions for further research. One is to seek ZXH-representations of more general quantum states that would allow computations on them to be simplified. The success in representing AKLT-type states suggests that more general resonating valence bond states [69], as well as fractional quantum Hall states [99] have useful representations in the ZXH-calculus. Another natural direction is to construct more elaborate symmetry-protected topological phases [63,[91][92][93]. For example, other higher-order topological phases could be built based on the coupled wire construction [100], which consists of piling coupled d−1-dimensional states together to construct d-dimensional topological states. More generally, it would be desirable to explore representations of chiral topological states using the ZXH-calculus, especially those with gapped bulk excitations, as those have been challenging to study as PEPS [2]. However, it is worth remembering that injective MPS or PEPS cannot represent topological order [101,102], a restriction which might present so-far unexplored complications in the ZXH formalism. Interestingly, our discussion of symmetries suggests that a chiral ZXH diagram would necessarily represent a chiral state. However, finding which chiral ZXH diagrams possess non-trivial topological order remains an open question. One possible example of a chiral phase is one that would be realised by stacking C 4 symmetric 2D-HOTIS in Fig. 6 in such a way that for each consecutive layer the dangling spin-1/2 has moved one site along the edge. This state would have C 4 symmetry in each plane, but the end states will spiral in the z direction, defining a 3D chiral state with no mirror symmetry. Lastly, it is also worth investigating if the ZXH-calculus allows us to represent and apply matrix product operators (MPO) more efficiently, which are central to MPS-based algorithms [4,5,7,8]. For example, it might be possible for the MPO to be 'compressed' using ZXH-calculus rewrite rules. Lastly, since the ZXH-representation of higherdimensional Hilbert spaces are not conceptually different, the ZXH-calculus offers a practical way to describe and reason about a broad number of systems, not restricted to one or two spatial dimensions.
More intriguingly, the versatility of the ZXH-calculus could inspire the search for simpler algorithms to tackle many-body problems. For example, it is in principle possible to formulate existing algorithms, such as the density matrix renormalisation group [4,5,8], in terms of ZXHdiagrams and use rewrite rules to reduce the complexity of the involved mathematical objects. It is interesting to note that our Berry phase proof employed the derivative of a diagram. This suggests that implementing a variational principle based on minimising over a parameter could be feasible. It would overlap with work using these diagrams to analyse problems in quantum machine learning [81,82]. Simplifying to logically equivalent, but representationally simpler objects could be a way to reduce the number of variational parameters. However, it is an open question how to implement an algorithm that benefits explicitly from the rewrite rules. That said, given successes in quantum compilation algorithms [28-30, 38, 103] and the aforementioned work on diagrammatic quantum machine learning, we are optimistic.
In summary, we have presented how the ZXH-calculus can significantly enhance the scope of diagrammatic reasoning to solve many-body quantum problems. Our work promotes the helpful pictorial representations of tensornetworks to full-fledged methods of computation, where the diagram is the calculation.

ACKNOWLEDGMENTS
NC was funded by EPSRC fellowship EP/S00114X/1. AGG is indebted to C. Repellin, F. Pollmann, and M. A. Sánchez-Martínez for enlightening discussions, and acknowledges funding from the French National Research Agency through the project ANR-18-CE30-0001-01 (TOPODRIVE). RDPE would like to acknowledge financial support from the "Investissements d'avenir" (ANR-15-IDEX-02) program of the French National Research Agency and discussions with P. Martin-Dussaud. JvdW is funded by a NWO Rubicon personal fellowship. m i S i ) · ( m i S i ) − j(j + 1) where j = s. This can be seen by noticing that S 2 |s, s z = s(s + 1) |s, s z , and thusÔ j returns zero when applied to a state with total spin j.
The projector P (2) onto spin-2 annihilates any state with total spin s equal to 0 or 1, i.e. P (2) |s = 1, s z = P (2) |s = 0, s z = 0, where s z denotes the eigenvalue of the state for S z . The coefficient λ is fixed by the requirement that P (2) |s = 2, s z = |s = 2, s z which results in 1/λ = [2(2+1)−0][2(2+1)−1(1+1)] = 24. By using that S 1 + S 2 2 = S 2 1 + S 2 2 + 2 S 1 · S 2 and that S 2 1 = S 2 2 = 2 for spin-1 we have As a result, the AKLT Hamiltonian can be written as As we observed below Eq. (A6), the only way for two spin-1 particles to be in the s = 2 subspace is for each to be in s = 1 subspace. Since the AKLT Hamiltonian is the sum of projectors onto the spin-2 subspace of neighbouring spins, it annihilates any state where any two of the four neighbouring spin-1/2 degrees of freedom are in a spinsinglet, because such states have total spin s = 0. Lastly, as mentioned in the main text, the AKLT state has a dilute anti-ferromagnetic order (a site with s z = ±1 is followed by a site ∓1, with a string of s z = 0 in between), as discussed in the main text. It can be shown that this order is captured by a non-zero string-order parameter [46]. (B4)

CSWAP POVM calculations
In the main text it was shown that if the E x operator is applied to a CSWAP, that the CSWAP is absorbed (see (84)). In this appendix we will show the same for E z and E y . First, with E z : (ex) (c) (B5) As such: (B6) For the analogous derivation with E y we need a couple more types of rewrites. First, there is a way to commute a π X-phase through an H-box: This can be proven easily using (f) to unspider the π phase, followed by (hb) and (ab). Second, there are ways to remove π 2 -labelled Z-spiders and π-labelled Z-spiders from a diagram, by complementing the connectivity of their neighbours in a suitable way. These were proven in [28]. To write them down clearly we adopt the notation of Hadamard-edges from [28]: The first rule is known as local complementation: (B9) Note that on the right-hand side the middle spider is removed, at the cost of introducing edges between all its neighbours. Because of (92), if there was already an edge present between the spiders, the edge is cancelled, hence the name complementation.
As a result we must 'bin' the rest of the states. This is done by using an AND gate that is post-selected to a |0 outcome. We can represent such a post-selected AND by an H-box with a Z-spider attached to it (see the top of the diagram). Indeed, looking at the crown of (C2) we see that it selects four elements of the superposition to trigger gates (which precise ones it selects is not irrelevant). It then discards three more states leaving one state (|111 ) left over that is present in the superposition, but triggers no additional CSWAPs so that we get the required identity gate. This construction for n = 5 generalises to any desired n.