Rewriting and Completeness of Sum-Over-Paths in Dyadic Fragments of Quantum Computing

The"Sum-Over-Paths"formalism is a way to symbolically manipulate linear maps that describe quantum systems, and is a tool that is used in formal verification of such systems. We give here a new set of rewrite rules for the formalism, and show that it is complete for"Toffoli-Hadamard", the simplest approximately universal fragment of quantum mechanics. We show that the rewriting is terminating, but not confluent (which is expected from the universality of the fragment). We do so using the connection between Sum-over-Paths and graphical language ZH-calculus, and also show how the axiomatisation translates into the latter. We provide generalisations of the presented rewrite rules, that can prove useful when trying to reduce terms in practice, and we show how to graphically make sense of these new rules. We show how to enrich the rewrite system to reach completeness for the dyadic fragments of quantum computation, used in particular in the Quantum Fourier Transform, and obtained by adding phase gates with dyadic multiples of $\pi$ to the Toffoli-Hadamard gate-set. Finally, we show how to perform sums and concatenation of arbitrary terms, something which is not native in a system designed for analysing gate-based quantum computation, but necessary when considering Hamiltonian-based quantum computation.


Introduction
Sum-Over-Paths (SOP) is a formalism used to represent and manipulate quantum processes in a symbolic way, introduced in 2018 by Amy [Amy19].Its first important feature is its capacity to translate from most common (gate-based) descriptions of quantum processes in polynomial time and space.The formalism hence provides a intermediary view between usual (matrix) semantics and these usual process descriptions.Its second crucial feature is that it comes equipped with a rewrite system that simplifies the term, without altering its semantics.
Despite its links [Lem19,LvdWK21] with graphical languages such as the ZH-calculus [BK19] -which will be used in the following -, it provides a different view on the quantum processes, representing them as weighted sums of Dirac kets and bras (a very familiar notation in quantum mechanics).
The formalism has seen several applications, the first of which being verification.Verification is a crucial aspect of computations in the quantum realm, where physical constraints (like no-cloning, or the fundamental probabilistic nature of quantum) make it impossible to do debugging the way we do on classical algorithms.More specifically, the SOP formalism was introduced as a solution to circuit equivalence: To check the equivalence between two circuits C 1 and C 2 , the system represents C † 2 • C 1 as an SOP term (where C † 2 can be seen as the inverse of C 2 , easy to describe from it).It then tries to reduce it to the identity.If successful, this proves C 1 and C 2 represent the same unitary.Otherwise, the system searches for a witness that the term at hand does not represent the identity.As such, the system has been used in several different projects (e.g.[dBBW20,KvdW20]) to check precisely for circuit equivalence.It was later extended to account for families of morphisms and used within the Qbricks environment [CBB + 21, CBL + 21] together with automated solvers to verify algorithms and routines such as quantum phase estimation, Grover's search and Shor's algorithm.
Amongst other applications of the Sum-Over-Paths, we may cite noiseless simulation of quantum processes, where the rewrite strategy is used to reduce the number of variables in the term, effectively decreasing the number of summands when expanding the term to actually compute its semantics.It is for instance one of the simulators implemented in the supercomputer Atos QLM [HRA + 22].
While the initial suggestion for Sum-Over-Paths focussed on the Clifford+T fragmenta universal fragment of quantum computing, i.e. a restriction still capable of approximating with arbitrary precision any quantum process -, it also provided some interesting result for the Clifford fragment.It is known that the latter is not universal [AG04], and actually efficiently simulable with a classical computer, so it is a good test for the relevance of a formalism to check how it handles them.And indeed, it was shown [Amy19] a "weak" form of confluence of the rewrite system in the Clifford fragment.More precisely, in this fragment, C † 2 • C 1 reduces (in polynomial time) to the identity if and only if C 2 and C 1 represent the same unitary operator.However, SOP terms may represent more than unitary operator, but actually any linear map.With those, it is still possible to define the above restrictions, and the rewrite system was extended in [Vil21] to get confluence for the -not necessarily unitary -Clifford fragment.When moving to a universal fragment -like Clifford+T -it is expected that we cannot provide a rewrite system with all the good properties of the Clifford case: either reduction is not polynomial, or there is no confluence, or we need an infinite number of rewrites, ... The reason for this is that if we could provide such a system, deciding circuit equivalence would become polynomial, while we know that it is QMA-complete -a quantum variant of NP-complete - [Boo14,JWB05].A weaker property than that of confluence we can ask for is completeness: the question here is to decide whether two equivalent terms can be turned into one another, with the assumption that rewrites can be used in both directions (in that case, we rather speak of an equational theory, or axiomatisation, than a rewrite system).a fairly simple rewrite system that we show complete for the fragment, and also exhibit two important drawbacks: the non-confluence of the rewrite strategy and the potential explosion of the size of the morphisms during the rewrite.We then show how the rewrite strategy can be tweaked to reach completeness for every dyadic fragment -where we allow phase gates with phase a multiple of π 2 k for some k -, a restriction that encompasses Clifford, Clifford+T and Toffoli-Hadamard, and is crucially used in the Quantum Fourier Transform, a central block for algorithms such as Shor's and Quantum Phase Estimation.This paper extends [Vil23] which was presented at the Computer Science and Logic 2023 (CSL'23).Here we slightly simplify the rewrite system, provide further potential simplification rules, of which we give a graphical treatment, and finally show how to perform two non-trivial operations on SOP terms, namely their sum and their concatenation, both very useful when building arbitrary maps or when considering Hamiltonian-based computation, and which remain in the dyadic fragment at hand.Since the presentation of [Vil23], a complete rewrite system was given to Sum-Over-Paths with arbitrary phases and complex entries [Amy23], although in the "unbalanced" framework, which is noticeably different.
Structure of the paper.We first review the Sum-Over-Paths formalism in section 2, providing a rewrite strategy for Toffoli-Hadamard, as well as generalised rules.We then present the ZH-calculus in section 3 and the links between the two in section 4, and we show how to interpret the new rewrite rules of SOP graphically.We then show the completeness result for the Toffoli-Hadamard fragment in section 5.The extension to the dyadic fragments is then handled in section 6.Finally, in section 7, we show a way to "control" arbitrary terms allowing for their sum and their concatenation.

Sums-Over-Paths
2.1.The Morphisms.Sums-Over-Paths [Amy19] are a way to symbolically describe linear maps of dimensions powers of 2 over the complex numbers.These linear maps form a †-compact monoidal category [ML13,Sel10] denoted Qubit where the objects are natural numbers (this makes the category a PROP [Lac04,Zan15]), where morphisms from n to m are linear maps C 2 n → C 2 m , and where is the usual composition (resp.tensor product) of linear maps.The category is endowed with a symmetric braiding σ n,m : n+m → m+n, as well as a compact structure (η n : 0 → 2n, ϵ n : 2n → 0).Furthermore, there exists an inductive contravariant endofunctor (•) † , that behaves properly with the symmetric braiding and the compact structure.For more information on these structures, see [Sel10].
The formalism of SOP relies heavily on the Dirac notation for quantum states and operators of Qubit.The two canonical states of a single qubit are denoted |0⟩ and |1⟩.They form a basis of C 2 , and can be viewed as vectors |0⟩ = 1 0 ⊺ and |1⟩ = 0 1 ⊺ .A 1-qubit state is then merely a normalised linear combination of these two elements.Using (• ⊗ •), they can be used to build the basis states of larger systems, e.g.|010⟩ := |0⟩ ⊗ |1⟩ ⊗ |0⟩ is a basis state of a 3-qubit system.Again, the state of an arbitrary n-qubit system is a normalised linear combination of the 2 n basis states.We will use extensively the following notation ⟨x| to represent the dagger (transpose conjugate) of |x⟩.The identity on a qubit can then be expressed in Dirac notation as I := |0⟩⟨0| + |1⟩⟨1|, where |x⟩⟨y| := |x⟩ • ⟨y|.
We give in the following the definition of Sum-Over-Paths of [Vil21], which differs from [Amy19] in the way the input qubits are treated, by making them more symmetric with the outputs.This makes some concepts, like the † or the compact structure, more natural.Definition 2.1 (SOP).We define SOP as the collection of objects N and morphisms between them that are tuples f : n → m := (s, ⃗ y, P, ⃗ O, ⃗ I), which we write: ) n -F 2 being the binary field, whose only two elements are its additive and multiplicative identities, denoted 0 and 1. Compositions are obtained as 2 : We distinguish particular morphisms: • Identity morphisms id n : |⃗ y, ⃗ y⟩⟨| and ϵ n = ⃗ y

|⟩⟨⃗ y, ⃗ y|
We also distinguish two functors that have SOP as a domain: • The †-functor is given by: f The †-functor is particularly important to characterise maps that are unitary -the pure transformations that are allowed by quantum mechanics: where ⃗ O g = (O g 1 , ..., O g m ) and ⃗ y = (y 1 , ..., y m ); and where the map (•) : , which translates a boolean polynomial into a phase polynomial, The quotient in the phase polynomial means that we consider each occurrence of the square of a variable to be equal to the variable itself X 2 i − Xi = 0, since they will be evaluated over {0, 1}.We can further constrain the polynomial by taking it modulo 1, but only when considered as an element of a group, once all the products have been evaluated, as otherwise all phase polynomials would be evaluated to 0 as P = P × 1 = P × 0 = 0.
2 To avoid further clutter, we may not specify the variables of polynomials, e.g.Pg actually stands for Pg(⃗ yg), ⃗ Og for ⃗ Og(⃗ yg) etc... is inductively defined as: This translation will also be used in most of the upcoming rewrite rules of the system.
Example 2.3.The Hadamard and Toffoli gates (which justify the name of the first fragment we will consider in the following), can be represented in this formalism as: when taken modulo 1.
As is customary, and as was already done in the previous example, we consider equality of the SOP morphisms up to α-conversion, i.e. renaming of the variables.Notice that the definition of the composition (• • •) gets somewhat involved.This is to cope with the way we deal with the inputs, which can be any boolean polynomial.The additional terms enforce that O gi = I f i for all 0 ≤ i < m.Indeed, when summing over the variable y i , we get (1 + e iπ(O gi +I f i ) ) -which is non-null only when O gi = I f i -as a factor of the whole morphism.This presentation has the advantage of keeping the size of the morphism polynomial with the size of the quantum circuit -or ZH-diagram, see below -it can be built from, no matter what gate set is used.A downside, however, is that the above does not directly constitute a category, as for instance id • id ̸ = id.However, it suffices to quotient the formalism with rewrite rules to turn it into a proper category [Vil21], hence justifying the use of the term "functor" for the last two maps.2.2.A Rewrite System.We hence give in Figure 1  ⃗ y Figure 1: Rewrite system − − →

TH
We need in the conditions of all the rules the function Var, that, given a set or list of polynomials, gives the set of all variables used in them.We call internal variable a variable that is present in the morphism t but not in its inputs/outputs, i.e. a variable y 0 such that y 0 ∈ Var(t) \ Var( ⃗ O, ⃗ I).It is worth noting that searching for an occurrence of, and applying any of these rules once, can be done in polynomial time.
The rules (ket) and (bra) correspond to changes of variables that are necessary to get a unique normal form in the Clifford case [Vil21], and the rule (Elim) simply gets rid of a variable that is used nowhere in the term and simply contributes to a global phase (since that variable is supposed to range over two values, it contributes to a multiplicative scalar 2).
The cornerstone rule of [Amy19] and [Vil21] denoted (HH) was given as: It has been generalised into (HHgen) here ((HH) is the special case where Q = 1).It is important to notice that the rule (HHgen) requires that QQ ′ = Q.Rule (HH) is so often used that we may, in the following, distinguish it from (HHgen). ) |y 1 , y 2 , y 4 ⟩⟨y 5 , y 6 , y 7 | we got from Example 2.3.Its internal variables are y 0 , y 3 , y 8 , y 9 , y 10 .It is often the case that the variables created by the sequential composition (y 8 , y 9 and y 10 here), can be used right away to rewrite the term using (HH).For instance, the term y 8 2 (y 0 + y 5 ) where y 8 appears nowhere else in the morphism, allows for an application of the rule, that will replace y 0 by y 5 (or vice-versa).We get: ) |y 1 , y 2 , y 4 ⟩⟨y 5 , y 6 , y 7 | The rule (HH) can always be followed by (Elim): here y 8 remains in the variables, but isn't used anywhere anymore.t can then be further reduced to: ) |y 1 , y 2 , y 4 ⟩⟨y 5 , y 6 , y 7 | Proceeding similarly for y 9 and y 10 , we get: ) |y 1 , y 6 , y 4 ⟩⟨y 5 , y 6 , y 7 | The term cannot be reduced further with the rewrite system − − → TH .
In the following, we assume that (Elim) is always applied after (HH), without necessarily mentioning it.
The rules (HH), (HHgen) and (Z) all stem from a particular observation: In the morphism t = e 2iπ( y 0 2 Q+R) ⃗ O ⃗ I where y 0 is internal and not in R, if Q is evaluated to 1, then the whole morphism is interpreted as null.This is exactly what (Z) captures -and the conditions on R, ⃗ O and I are simply here to avoid applying the rule indefinitely.The rule (HH) deals with a case where the polynomial Q can be forced to 0, whilst the rule (HHgen) more generally deals with a case where one of the variables in the polynomial Q is forced to get a precise value due to the form of the polynomial.
The rule (HH) is of particular interest.It was introduced in [Amy19] and gives enough power to the formalism to become a †-compact PROP [Vil21].We can extend this result here thanks to: Proposition 2.5.
Proof.The result is obvious for the tensor product (.⊗ .).For the composition, we show that if In other words, we have to show it for every rule in − − → TH : • (Elim): Obvious.
• (HHgen): Thanks to this Proposition, and since SOP/ ∼ HH is a †-compact PROP by [Vil21], we get: The set of rules was obviously chosen so as to preserve the semantics: Proposition 2.7 (Soundness).For any two SOP morphisms t 1 and t Proof.We mean to show that for any single step rewrite, the interpretation is preserved.As most of the rules were present in [Amy19] or [Vil21], this was proven for them.It remains to show the result for (HHgen).The soundness of a stronger version of (HHgen) is proven in upcoming Lemma 2.11.The result is then a direct consequence of this.
The addition of the rule (HHgen) allows for further reductions: ) |y 3 ⟩⟨y 0 | is irreducible using the rules of [Amy19] and [Vil21].However, here it can be reduced to: where the rewrite can be made clearer by writing the phase polynomial as y 2 2 (y 1 (y 0 + y 3 + y 2 y 3 ) + 0 + 1) and checking that (obviously) (y 0 + y 3 + y 2 y 3 ) × 0 = 0. 2.3.Generalising Rules.In [Vil23] another rule was introduced to allow for the proof of completeness: This rule was only used when proving that one of the axioms of ZH TH from [vdWW19] was provable with ∼ TH .However, it was proven in [BKMB + 23] that this axiom could be replaced by two simpler ones and otherwise provable, hence making (HHnl) unnecessary for completeness, as will be shown in the following of the paper.
Completeness however assumes rules can be used both ways, while we ideally only want to reduce a term when analysing it.With this in mind, it is relevant to look for rules that allow for further reduction, and (HHnl) is one of them.
Example 2.9.The following term, while irreducible with −→ TH , can be reduced using (HHnl): We can rewrite it in two different ways, which give both sides of the (HHnl) rule:

⃗ O ⃗ I
When rewriting SOP-morphisms for simplification or verification, it can be beneficial to not only reduce the number of variables -which is what all rules but (ket/bra) do -, but also to keep the size of the phase polynomial as short as possible.In that respect, the rule (HHgen) itself can be generalised to: where the polynomial Q ′ can here be smaller (in the number of terms) than the one in (HHgen).However, finding a "minimal" Q ′ for this rule is a hard problem, as it requires the use of boolean Groebner bases [SIS + 11], while instances (HHgen) can easily be found.
(HHgen) can be seen as a particular case of (HHgen'), where The previous observation can be made into another rule, which again uses the fact that when a term has a phase polynomial of the form y 0 2 Q + R with y 0 internal, then we can force Q to be 0.This means we can replace R by a remainder in the euclidean division of R by Q: Notice that, in contrast with the (HH), (HHgen) and (HHgen'), this rule does not reduce the number of variables, but instead equates polynomials that are equivalent "modulo Q".In practice, this rule is also hard to use as it again uses Groebner bases to properly implement.The proximity between the last two aforementioned rules is not surprising once we realise that (Rem) can be deduced from (HHgen) and (HHgen'): We can show that (HHgen') is sound, which implies that (HHgen) -as a particular case -and both (HHnl) and (Rem) -as a compositions of particular cases of (HHgen') -are also sound: While we have identified stronger rewrite rules than the ones in ∼ TH , as the rest of the paper is mainly focussed on completeness, we stick to the rules of ∼ TH , since, as we shall see later, they are enough for that particular problem.

The ZH-Calculus
As a foundation towards completeness of the Toffoli-Hadamard fragment of SOP, we will use a similar result on another formalism: the graphical calculus ZH.The graphical calculi ZX, ZW and ZH [BK19, CD11, CK10] are calculi for quantum computing, with a tight link with the Sum-Over-Paths formalism [Lem19, LvdWK21, Vil21], and whose completeness was proven in particular for the Toffoli-Hadamard fragment [BKMB + 23, Had15,vdWW19,Vil19].
This fragment of quantum mechanics is approximately universal [Aha03,Shi03], and it is arguably the simplest one with this property.This is the fragment we will be interested in, in most of the following of the paper; and the associated completeness result will be paramount in the development of the following.
We choose to present here the ZH-calculus, because of its proximity with both SOP and the Toffoli-Hadamard fragment.Notice however that there exist translations between all the aforementioned graphical calculi, so by composition, we can connect SOP to all of them.The language comes with a way of interpreting the morphisms as morphisms of Qubit.The standard interpretation • : ZH → Qubit is a †-compact-PROP-functor, defined as: ... Notice that we used the same symbol for two different functors: the two interpretations • : SOP → Qubit and • : ZH → Qubit.It should be clear from the context which one is to be used.The language is universal: ∀f ∈ Qubit, ∃D f ∈ ZH, D f = f .In other words, the interpretation • is surjective.
3.2.Equational Theory.The language comes with an equational theory, which in particular gives the axioms for a †-compact PROP.We will not present it here.
Notice that the two black spiders can still be defined if we also define 1 . We denote this restriction by ZH TH .
This restriction is provided with an equational theory, given in Figure 2, that makes it complete 3 .• each monomial αy i 1 ...y is in P gives a single H-spider with parameter e i α 2π and connected to the Z-spiders that represent y i 1 ,...,y is where the inputs are connected to the Z-spiders that represent y i 1 ,...,y is .Notice that the only (non-zero) constant monomial is • these monomials are then added to form O i thanks to ...
• the nodes I i are defined similarly, but upside-down For more details, see [Vil21].
Example 4.1.The SOP morphism: The boolean polynomials as defined above are given in their (unique) expanded form.These can easily be shown to be copied through the white node: The functor furthermore maps the symmetric braiding (resp.the compact structure) of ZH to the symmetric braiding (resp.the compact structure) of SOP.This does not give a full description of [•] sop , as we did not describe the interpretation of the H-spider for all parameters, but only for phases and 0. However, any H-spider can be decomposed using the previous ones: .Then, we have: Hence, when |r| / ∈ {0, 1}, we have equality between the two with α := 2 arctan 1−r 1+r , β = arg 1−r 1+r + π 2 and s := (since r ̸ = 1, α is well defined and α ̸ = π mod 2π so s is also well-defined).From this, we get:   We will focus on the rules mentioned above, that were not present in the previous works on SOP, namely (HHgen), (HHgen'), (HHnl) and (Rem).
Rule (HHgen) uses a side condition, that is QQ ′ = Q, which translates to The pattern y 0 2 (y i Q + Q ′ + 1) is represented by: and can be rewritten into: ... ...
where the last equality (that uses Lemma 4.2) is the substitution Rule (HHgen') can be proven graphically exactly in the same way, except we start from the second diagram in the derivation above.
Rule (HHnl) turns an occurrence of , when the two variables are linked to nothing else than their respective polynomials Q and Q ′ .The induced ZH identity can be derived using its rules: ... ...
Although the overall number of nodes usually increases, the number of white nodes that amount to SOP-variables (i.e.white nodes that are not part of a polynomial) decreases.Finally, Rule (Rem) turns the phase polynomial y 0 2 Q + SQ + R into y 0 2 Q + R, which can be derived graphically as:

Completeness for Toffoli-Hadamard
In this section, we aim to show that the set of rules − − → TH captures the whole Toffoli-Hadamard fragment of quantum mechanics.We do so by transporting the similar result from ZH TH to SOP[ 1 2 ].First, we show: Proof.We show that all the rules of ZH TH hold in SOP[ 1 2 ], which together with Proposition 2.5 proves the result.
The translation of rule (IP) is implicit in SOP: it essentially states that y i • y i = y i for boolean variable y i .Checking the rules (ZS1), (ZS2), (HS1), (HS2) and (M) is straightforward using the rule (HH).We give for instance a check of the rule (ZS1):  We give derivations to prove the remaining rules of ZH TH .Recall that equality is up to α-conversion.
(IV): We can now use the previous proposition to show the main result of this paper: Proof.Let t 1 and t 2 be two SOP[ 1 2 ]-morphisms such that t 1 = t 2 .By Proposition 4.3: Finally, by Proposition 4.6: The rewrite system is however not sufficient to get to a unique normal form, as: Lemma 5.4 (Non-Confluence).The rewrite system − − → TH is not confluent.
Proof.We can exhibit a term which can be reduced into two different irreducible terms.To do so, we can use an instance of derived Rule (HHnl).As a by-product, this shows that rule (HHnl) would be necessary in the oriented setting, i.e. in −→ Proof.For any k ≥ 1 we can define the following term: on which we can apply (HH) k times in a row with [ In that case we end up with: While t k has only 3(k + 1) terms (each of degree 2 except one of degree k) in its phase polynomial, it can rewrite into a morphism with 2 k+1 terms (each of degree k).
Hence, if one were to perform simplifications with this rewrite system, they ought to give special attention as to where and in which order to apply the rules.

Completeness for the Dyadic Fragment
We show here how we can turn an SOP[ 1 2 n+1 ]-morphism into an SOP[ 1 2 n ]-morphism in a "reversible" manner.This will allow us to extend the completeness result to all the restrictions SOP[ 1 2 n ].This is particularly interesting as the phase gates with dyadic multiples of π, used in particular in the quantum Fourier transform, belong in these fragments: Remark 6.1.The construction we are about to define to relate the different dyadic levels together can be seen as a (non-unitary) instance of "catalysis", defined and studied at length in the recent paper [ACG + 23], where the complexity of applying gate (or piece of circuit) U several times in the overall circuit is offset to a particular state |χ U ⟩ and several occurrences of a "simpler" piece of circuit ϕ U such that ϕ U • (id ⊗ |χ U ⟩) = U ⊗ |χ U ⟩.In our case, U is an occurrence of the π 2 n+1 phase, and |χ U ⟩ encodes that phase.Both U and 6.1.Ascending the Dyadic Levels.These transformations between restrictions of SOP are more easily defined on SOP-morphisms of a particular shape, namely, when their phase polynomial is reduced to a single monomial.Because of this, we show how a SOP-morphism can be turned into a composition of these.
Notice that this decomposed form is not unique, as different orderings on the monomials of P define different orderings of the compositions.However, this will not matter.
A particular care is sadly needed for the overall scalar.Because of this, we will first focus on a slightly different notion of restriction of SOP.
I where P has integer coefficients.
The only difference with SOP[ 1 2 n ] is that the overall scalar is now a power of 1 2 and not of 1 √ 2 .There always exists a SOP[ 1 2 n ] ′ -morphism that represents the same linear map as any SOP[ 1 2 n ]-morphism.
We can now define the family of maps that will link the different levels of the "dyadic levels": Definition 6.5.For any k ≥ 1, we define the functor O ⃗ I with phase polynomial of size 0 or 1: The functor is then extended to any SOP[ 1 2 k+1 ] ′ -morphism by the decomposition of Lemma 6.2 (and given a particular ordering on the monomials of the phase polynomial).
(2) Let x = Obviously, x can be decomposed as . We now need to show that this decomposition is unique.To do so, let us consider Q[e 2 k ] can hence be seen as a vector space over Q[e i π 2 k−1 ].This vector space is of dimension: where φ is Euler's totient function.The vector space has (1, e i π (3) We now need to define ψ k .We are going to define it first on scalars, and on the basis (1, e i π 2 k ): We then naturally extend this definition to any matrix over these elements.Formally: 2 k is the aforementioned decomposition extended to matrices.One can check that ψ k is a homomorphism, i.e. ψ k (.+.) = ψ k (.)+ψ k (.) and ψ k (.•.) = ψ k (.)•ψ k (.).
It remains to show that ↿ ⌊.⌋ ↾ k = ψ k ( .).Since ψ k is a homomorphism, it is enough to show the result on the terms in the decomposed form of Lemma 6.2.Let t = s e 2iπ ℓ 2 k+1 y i 1 ...y iq ⃗ O ⃗ I be such a term.
Definition 6.7.For any k ≥ 1, we define the (partial Notice that ⇃ ⌈ • ⌉ ⇂ k can only be applied on morphisms that have at least one input and one output. ⇃ ⌈ • ⌉ ⇂ k reverses the action of ↿ ⌊ • ⌋ ↾ k (up to some rewrites): The second result in the Proposition simply comes from the fact that ⇃ ⌈t i ⌉ ⇂ is built by composition from t i , so Proposition 2.5 gives the desired result.6.3.Completeness.We may now show completeness first for SOP[ 1 2 k+1 ] ′ and then tweak the equational theory to extend the result to SOP[ 1 2 k+1 ].Theorem 6.9 Finally, by Proposition 6.8: This is not entirely satisfactory, as we would like to relate any two morphisms of the same interpretation.However: Proof.There is no rule in − − → TH that changes the overall scalar from an odd power of 1 √ 2 to an even one, or vice-versa.

SOP FOR DYADIC FRAGMENTS OF QUANTUM COMPUTATION 20:25
However, adding a single rule: fixes this caveat.This rule can also be recovered from the more general one: ⃗ y e 2iπ( y 0 ).Let us write −−→ TH' Let us also write: We define t ′ i as: t ′ i .By Theorem 6.9: We hence have completeness for all dyadic fragments of quantum computation.By taking their union, we can get completeness for the "whole dyadic fragment".).

Summing and Concatenating SOP-Morphisms
We show in this section two interesting constructions that allow us to perform operations on SOP-morphisms that are not primitively doable in SOP or more generally in gate-based quantum computation, but necessary when considering Hamiltonian-based computation [SWY22], namely their sum and concatenation.Specifically, for any two SOP-morphisms t 0 , t 1 : n → m, we want to be able to build terms t sum and t concat such that: As we will see, these constructions are well suited to the dyadic fragments, as they can be performed entirely inside them.and: , controlling s gives a morphism in a dyadic fragment of SOP.
We now give a general construction for controlling an arbitrary SOP-term.
We finally define: Proposition 7.13.Λt is a controlled morphism, that controls t, i.e.:   This proves Λ 2 ( t |⃗ v 1 , ⃗ v 2 , ρ, θ) = ⟨0| ⊗ H n m (1) + ⟨1| ⊗ t .In order to control t : n → m in this version, we only need around 2(n+m+log 2 (|sρe iθ |)) additional variables, and the initial phase polynomial is simply added another polynomial.However, it requires some prior knowledge on the linear map that is represented by t, namely, one of its coefficients.Another caveat of importance is that 1 ρe iθ , which is needed in the definition of the control, will in general get us out of the dyadic fragments.
Remark 7.16.In the definitions of Λ and Λ 2 for SOP-terms, we used the control of scalars denoted Λ.However, any other notion of control of scalars (like Λ ′ for instance) would work.

Conclusion and Discussion
We have given a new rewrite system for the (balanced) Toffoli-Hadamard fragment of Sums-Over-Paths, and showed the induced equational theory to be complete.We then extended this rewrite strategy by adding a single new rewrite, which we then proved to be complete for any dyadic fragment of quantum computation.As expected from the universality of the fragments at hand, we do not get all the nice properties of the rewriting in the Clifford fragment.In particular, we showed that the rewrite strategies given above are not confluent, and that the size of the terms may grow exponentially when rules are applied carelessly.Whether one of the above two drawbacks can be removed by a different rewrite system remains an open question.In particular, we have exhibited two rules that, in order to be applied properly, require solving a hard but well studied problem, i.e. that of building Groebner bases.We wonder if this is a sufficient price to pay to get confluence.If not, it would be interesting to see if a completion of the rewrite strategy à la Knuth-Bendix is possible in this framework, and if such completion would eventually yield a finite set of rules (note that this would not necessarily make problems like circuit equivalence classically tractable, as the size of the phase polynomial may still grow exponentially quickly, and application of some rules may require solving hard problems).
On a more foundational note, we conjecture that the rewrite strategy −→ TH is minimal, i.e. that none of the rewrites can be derived from the others.The same question can be asked in ZH, but no proof (confirming or refuting it) has been provided yet.The graphical study of the rewrite rules of subsection 4.4 hint at directions to simplify the rules of ZH thanks to their interpretation in SOP, or to transport potential proofs of minimality between the two.The completeness result derived from that of the ZH, and this small study of how the rewrites translate as ZH transformations, really show how the two formalisms give different and complementary approaches to rewriting and simplifying representations of quantum processes.
a set of rewrite rules denoted − − → TH that induces an equational theory ∼ TH (the symmetric and transitive closure of − − → TH ).

3. 1 .
The Diagrams and their Interpretation.ZH is a PROP whose morphisms -read here from top to bottom -are composed (sequentially (• • •) or in parallel (• ⊗ •)) from Z-spiders and H-spiders: • Z n m : n → m :: ... ... , called Z-spider • H n m (r) : n → m :: r ... ... , called H-spider, with a parameter r ∈ C When r is not specified, the parameter in the H-spider is taken to be −1.ZH is made a †-compact PROP, which means it also has a symmetric structure σ n,m :: n ... m ... ... ... , a compact structure η n :: ... n ... , and a †-functor (•) † : ZH op → ZH.It is defined by: (Z n m ) † := Z m n and (H n m (r)) † := H m n (r) where r is the complex conjugate of r.For convenience, we define two additional spiders:

3
Imwhere the row of Z-spiders represents the variables y 1 , . . ., y k .Informally: The axiomatisation provided here is based on that of [BKMB + 23] together with [BKMB + 23, Thm.8.6] which simplifies one of the rules.It simplifies the axiomatisation found in[vdWW19], however the fragment considered is slightly different, as [BKMB + 23] does not contain the scalar 1 √ 2 , but only 1 2 .It is however very easy to extend the completeness to the language obtained by adjoining a generator for the 1 √ 2 scalar, using the additional rule that states that 2 * 1 √ 2 * 1 √ 2 = 1.This is what is done in the axiomatisation provided here.A proof that completeness does extend can be adapted from e.g.[JPV18, Prop.1].

sop•
As a consequence, we extend the definition of[•]  sop by: This interpretation of ZH-diagrams as SOP-morphisms preserves the semantics: Proposition 4.5 [Vil21].[•] sop = • .In other words, the following diagram commutes:The composition of the two interpretations is the identity up to small rewrites:Proposition 4.6 [Vil21].[•] ZH sop ∼ TH (•) 4.3.Restrictions of SOP.Recall that ZH TH exactly captures the Toffoli-Hadamard fragment of quantum mechanics.We can then use the two interpretations to define the Toffoli-Hadamard fragment of SOP.We actually go a step beyond and define a family of fragments indexed by n:Definition 4.7 (SOP[ 1 2 n ]).We define SOP[ 1 2 n ] as the restriction of SOP to morphisms of the form: t = 1 where p ∈ Z and P has integer coefficients.The Toffoli-Hadamard fragment is then the first such restriction (n = 1):

4. 4 .
The Rewrite System −→ TH , Graphically.Before moving on to show the result of completeness the Toffoli-Hadamard fragment of SOP, it is worth checking how the rules of − − → TH translate in ZH.

|y 2 y 3 y 4 y 5 ⟩y 4 y 5 |y 2
can be reduced into (at least) two different irreducible terms: y 3 y 4 y 5 ⟩ 2 e 2iπ( y 0 2 (y 2 y 3 +y 4 y 5 +y 2 y 3 y 4 y 5 )) |y 2 y 3 y 4 y 5 ⟩Another important downside is the potential explosion of the size of the phase polynomial:Lemma 5.5.Applying (HH) k times in a row on an SOP morphism with phase polynomial of size O(k) may give a morphism with phase polynomial of size O(2 k ).
1⊕y 0 ⊕y 4 y 2 , y 5 ⟩⟨y 4 , y 5 ⊕y 2 ⊕y 3 | Notice in particular that the Hadamard and Toffoli gates given in Example 2.3 lie in this fragment; and that compositions of elements of this fragment remain in the fragment.Not all of SOP[ 1 2 ] can be generated by the two gates H and Tof, however, as SOP[ 1 2 ] comprises linear maps that are not unitary, i.e. such that t † • t ̸ = id.
for any two terms t 1 , t 2 .Proof.Again, we can use the decomposition given in Lemma 6.2.We can show that if t = s e