Manuscript Offprint
arXiv:2610.06768Complexity separations for optimal matchgate-Clifford synthesis
Abstract
Clifford and matchgate circuits are canonical families of classically simulable quantum circuits. Their intersection, the matchgate-Clifford group, plays an important role in randomized fermionic protocols and in matchgate synthesis. Its adjoint action is isomorphic to the group of unit-determinant signed permutations of 2n Majorana modes, and we study optimal exact synthesis in this group. That is, given a target unitary and a gate set, output an n-qubit circuit implementing the target using the fewest operations. We show that the complexity of this problem strongly depends on the gate set. In particular, we study gate sets consisting of Majorana braids with different connectivity graphs. For path and complete graphs, we prove that the problem is classically solvable in time, and we provide explicit gate-optimal compilers. In addition, we prove that when the connectivity graph is a tree, the decision version of the optimal synthesis problem becomes NP-complete. Finally, we benchmark our optimal compiler on chains of up to qubits against those of Qiskit and Tket, obtaining circuits with constant factor improvements and in the total number of gates, respectively.
1 Introduction
Unitary synthesis is a fundamental problem in quantum computing [1]. Given a target unitary realizing a desired polynomial-size quantum computation, one needs to decompose it (either exactly or approximately) using a fault-tolerant gate set. Naturally, it is desirable to find a circuit realization that uses fewer operations, as this can greatly reduce errors and total runtime [2, 3]. The task of finding a decomposition with the least number of gates, known as optimal synthesis, is however a hard problem in general. Its precise complexity has not been pinned down yet, but it has been shown that minimizing the T-count using the Clifford+T gate set is NP-hard (lower bound) and contained in NP (upper bound) [4]. Thus, finding optimal circuits is generally hopeless when the number of qubits grows beyond just a handful [5].
This has motivated the study of the synthesis problem for restricted classes of unitaries, where additional algebraic structure can be exploited. For instance, an impressive series of results has led to optimal single-qubit unitary compilers [6–14]. Clifford circuit synthesis has also been extensively studied [15–23], and the decision version of optimal synthesis for circuits consisting of CNOT gates
Matchgate-Clifford unitary
Signed permutation
Optimal circuit


?

| Generators | a) Path | b) All-to-all | c) Tree |
|---|---|---|---|
| Complexity | P | P | NP-complete |
| Optimal compiler | - |
Figure 1: Overview of our main results. We consider the problem of optimal unitary synthesis in the matchgate-Clifford group. Representing the target -qubit unitary as a signed permutation matrix with determinant , we ask for an optimal circuit with a minimum number of Majorana braids along the edges of a given connectivity graph. We show that for path and complete graphs, the problem can be solved efficiently on a classical computer by providing explicit algorithms that run in time. In addition, we prove that the problem becomes NP-complete when the connectivity graph is an arbitrary tree.
or CZ gates between arbitrary pairs of qubits has been proven to be NP-complete [21–23]. More recently, another important group of unitaries whose synthesis was addressed is that of matchgate or free-fermionic unitaries [24]. Here, the complexity of optimal synthesis remains open.
Importantly, the ultimate goal is not to compile an isolated single-qubit, Clifford or matchgate unitary, but rather to treat the circuits as chunks of a larger quantum computation. Indeed, any unitary can be approximated to arbitrary precision using layers of Clifford gates interleaved with layers of gates [1]. Similarly, any fermionic unitary can be factorized into layers of matchgates interleaved with layers of interacting operations [25]. The mathematical structure of the Clifford and matchgate unitaries can then be leveraged to exponentially reduce the size of the matrices to be synthesized, potentially allowing for significant savings in the gate counts of the corresponding layers. In turn, this would reduce the gate count of the entire computation as well.
In this work, we focus on the group of matchgate-Clifford unitaries [26], i.e., the intersection of the matchgate and Clifford groups (see Section 2 for details). This group forms a matchgate 3-design [27, 28] and can therefore be used in randomized fermionic protocols such as fermionic classical shadows [27–29], benchmarking of quantum devices [30–32], or fermionic sampling [33]. Moreover, it plays a crucial role in matchgate synthesis, analogous to that played by the Clifford group in general unitary compilation. Namely, the matchgate-Clifford group together with the gate (up to a phase) is universal for matchgates [24]. Hence the motivation to study optimal synthesis in this group.
At the mathematical level, the adjoint representation of -qubit matchgate-Clifford unitaries is isomorphic to the group of signed permutation matrices with determinant acting on the vector space of Majorana operators. Optimal matchgate-Clifford synthesis can therefore be formulated as an optimal word problem in this group, and consequently, our results may find application in the field of combinatorial group theory beyond the quantum setting [34].
We consider gate sets consisting of Majorana braids and their inverses [26] on different connectivity graphs, where a braid acts as a signed transposition between pairs of Majoranas connected by an edge. The optimal synthesis problem then asks to realize the desired signed permutation using the smallest number of braids along the edges of the connectivity graph. Our main results are summarized in Fig. 1. For both path and complete graphs, we prove that optimal synthesis can be solved classically in time. In particular, we find efficient algorithms for optimally assigning the signs, which combined with well-known sorting algorithms for permutation matrices [35] provide explicit optimal compilers. In addition, for path graphs we investigate the optimal two-qubit-gate count, bound it, and prove that there exists a circuit simultaneously achieving this quantity and optimal total gate count.
Furthermore, we benchmark our path-graph optimal compiler on chains of up to qubits against those of Qiskit [36, 37] and Tket [38], obtaining circuits with constant factor improvements and in the total number of gates, respectively. We choose to benchmark the path graph compiler because the generators are simply single-qubit gates (up to a phase) and two-qubit rotations, under the Jordan-Wigner mapping between fermions and qubits. Thus, this case is the most relevant for matchgate circuits in practice [24]. We nonetheless emphasize that, alternatively to the Jordan-Wigner picture where one works with qubits and matchgates, one could instead consider a genuinely fermionic device where many different connectivities between Majorana modes may be possible in principle [39, 42]. In such context, our results provide guidance as to which topologies may be more beneficial in practice.
Next, we study arbitrary tree connectivity and show that the decision version of the optimal synthesis problem is NP-complete. The complexity is inherited from the NP-completeness of token swapping on trees [43], which asks to minimize the number of swaps along the edges of an arbitrary tree to realize a given permutation of the tokens (in our case, the tokens would be the Majorana operators, except that we must also account for the signs). Finally, by providing a polynomial upper bound on the number of Majorana braids needed to synthesize a matchgate-Clifford unitary on any connected graph, we find that the synthesis problem on arbitrary connectivities is in NP and thus it is also NP-complete (since it is already complete for trees).
2.1 The matchgate group
The matchgate group on n qubits is generated by single-qubit Z and two-qubit XX rotations with nearest-neighbor connectivity in 1D with open boundaries,
and
where denotes the Pauli acting on qubit and the Pauli acting on neighboring qubits and . This group of unitaries is isomorphic to the Lie group , and we recall
We remark that this may no longer be true under a different fermion-to-qubit mapping [39–41].
that since the parity operator, , commutes with the rotation generators and , match-gate unitaries are parity-preserving. Under the Jordan-Wigner transformation between qubits and fermions, matchgate dynamics are equivalent to free-fermionic unitaries in second quantization [44–46]. For this reason, matchgates appear naturally in fermionic simulation primitives [47–59], where they are associated to the non-interacting part of the Hamiltonian (e.g., after Trotterization). Also known as fermionic Gaussian unitaries, they have been extensively studied in quantum computing, quantum information and quantum simulation [25–33, 44–77].
For an n-mode fermionic system, we introduce the corresponding 2n Majorana operators,
which satisfy the canonical anti-commutation relations . In Jordan-Wigner form, they are simply the following anti-commuting set of Paulis,
Importantly, all matchgate unitaries can be expressed as the exponential of a Hamiltonian that is strictly quadratic in the Majorana operators, and vice versa. The adjoint action of a matchgate unitary U is linear on the vector space of Majorana operators, and it is specified by
where is a special orthogonal matrix [62]. Notice that both and are associated to the same orthogonal matrix (i.e., ), since is the double cover of [78]. Working with in the standard representation of allows to bypass the exponential size of the matchgate unitaries , which is crucial to properly address the complexity of optimally synthesizing them [24].
2.2 The matchgate-Clifford group
We are interested in the intersection of the matchgate and Clifford groups. We recall that the Clifford group is the normalizer of the Pauli group in the unitary group (up to global phases), i.e., Clifford unitaries map elements of the Pauli group to elements of the Pauli group under conjugation. Since each Majorana operator is itself a Pauli string in the qubit picture, the adjoint action of a Clifford unitary must map every Majorana operator to another Pauli operator. If U is also matchgate, then the Heisenberg-evolved Majorana operator must remain within the Majorana subspace as per Eq. (5). Therefore, when U is a matchgate-Clifford unitary, we find that
for some permutation in the symmetric group . Consequently, the matrix has exactly one nonzero entry in each row and column, equal to , and is a signed permutation matrix with determinant equal to +1. The group of signed permutation matrices is isomorphic to the hyperoctahedral group , and we denote it by . Consequently, the matchgate-Clifford adjoint action is isomorphic to , and has order .
The group of symmetries of the hypercube.
Formally, a signed permutation of is a bijection of with , and so we write . Considering its matrix form , we have
where and are the canonical-basis vectors in . The underlying unsigned permutation is (see Eq. (6)). We also denote
which counts the number of negative signs in w, and it is related to the determinant by the identity
where is the parity of . The parity in turn is given by
with the number of inversions of , which we define now.
Definition 1 (Inversion number). Let be a permutation. An inversion of is a pair , with , such that . The inversion number of is defined as
For example, let us consider . We have that because , and .
Therefore, in order for a signed permutation matrix to belong to (i.e., have ), it must be such that the sum of its inversion number and the number of negative entries is even. Those will be the target matrices for which we will study the problem of optimal synthesis.
2.3 Optimal matchgate-Clifford synthesis
Given a generating set , and a target , we define
The quantity is therefore the minimum number of gates from needed to synthesize . The optimal synthesis problem consists in finding a word achieving . The decision version of the problem is obtained by asking whether there exists a word achieving for some given . Clearly, the decision version belongs to the complexity class NP (Non-deterministic Polynomial time) when , because given a witness sequence , it is efficient to check whether it actually implements by simply multiplying the matrices. However, as we show in the next section, the complexity of the problem turns out to depend strongly on the allowed generators.
A permutation is said to be even if and odd if .
3 Results
We study the complexity of optimal matchgate-Clifford synthesis for different choices of generating sets. We consider gate sets consisting of Majorana braids on different connectivity graphs. That is, unitaries of the form
with an edge in the connectivity graph. The adjoint action of the braids on Majorana operators correspond to signed transpositions, given by permutation (sub-)matrices on the plane,
These gates have the important property that .
We consider one-dimensional, all-to-all and tree connectivities, and we prove the following results.
-
On a path graph, we show in Section 3.1 that the optimal synthesis problem can be solved classically in time, and provide a closed-form expression for the optimal word length. We further benchmark our optimal synthesis algorithm against other standard compilers on up to qubits in Section 3.1.1, finding circuits with constant factors improvements ranging from and in the number of total gates and two-qubit gates. Finally, in Section 3.1.2 we derive bounds on the minimum number of two-qubit gates required to optimally synthesize a given matchgate-Clifford unitary.
-
On a complete graph, we show in Section 3.2 that the optimal synthesis can also be solved classically in time, and provide a closed-form expression for the optimal word length.
-
On tree graphs, we show in Section 3.3 that the decision version of the problem is NP-complete. As a corollary, we show that the problem is NP-complete on general connected graphs in Section 3.4.
3.1 Path graph
We first consider the physically motivated case when the generators correspond to matchgate-Clifford operations on nearest-neighboring qubits on an open path. A natural choice for the generators is given by the single-qubit phase gate acting on the -th qubit, and the two-qubit gate acting on qubits and . In matrix form,
These gates generate the matchgate-Clifford group [24] and are native in some important hardware platforms such as neutral atoms [79] and trapped ions [80]. Under the adjoint action introduced in Eq. (5), the associated orthogonal matrices and act as rotations (i.e., signed transpositions) of two adjacent Majorana modes,
(16) while leaving all other Majorana operators unchanged (see Eq. (14)). We denote the corresponding signed permutation matrices by . More precisely,
At the level of the abstract signed permutations,
while its inverse is
Now we consider the optimal synthesis problem with the following set of generators,
We find that to obtain the minimum length to synthesize a given signed permutation using gates from , the following quantity plays a crucial role.
Definition 2. Given , we define
where denotes the submatrix formed by the first rows and first columns of . We say that is a cut point of if
If, in addition, , we say that c is a negative defect or bad cut.
Equivalently, is a cut point of whenever , being the underlying permutation in . Cut points are the indices of the final rows of each block in the maximal direct sum decomposition of the permutation matrix in the (fixed) canonical basis,
Notice that each is itself a (sub-)permutation matrix, although the decomposition in Eq. (23) is not irreducible in general. This is because the irreducible decomposition is given by the cycle decomposition, so unless every cycle only involves consecutive integers, there is at least one block which is reducible. However, for our purposes, this decomposition turns out to be the most useful. For instance, it is easy to see that the negative defects appear for values of such that the partial product of the block determinants is equal to -1.
After these considerations, we can state our first main result, proven in Appendix A.
Theorem 1. Consider the generating set and the potential
with the number of negative defects. Then, for every target , there is a classical algorithm that runs in time and outputs a sequence of gates from that synthesizes with optimal length .

Figure 2: Example of an optimal synthesis with nearest-neighbor braids on an open path. The number of gates from the generating set required to synthesize is , which splits into five inversions plus four gates to correct the sign defects captured by the number of bad cuts, . We first decompose the permutation matrix into three sub-permutation blocks and . We then identify the bad cuts , for which . We use the inversions to synthesize the sub-permutation blocks, leveraging the freedom in choosing or to deposit the extra signs at the boundaries of the bad cuts, and finally use to correct them.
This theorem implies that the potential matches the optimal length to synthesize with the generating set , and guarantees that a sequence of such length can be found efficiently on a classical computer. We recall that for an unsigned permutation and generating set given by nearest-neighbor transpositions on a path, it is well known that [81]. What we find here is that correctly assigning the signs to match those in using the gates in requires twice the number of negative defects extra operations.
The proof of Theorem 1 consists of two steps (see Appendix A). First, we prove that is indeed a potential by showing that a single application of a generator only changes by at most one, implying that . Then, we prove the converse inequality, namely , by explicitly providing an efficient algorithm that exactly matches . A schematic explanation of how the algorithm works can be found in Fig. 2 .
When , all the blocks have determinant +1 and our algorithm can correctly synthesize all the signs by using the freedom in picking either or while sorting the blocks. On the contrary, when , there are some blocks with . Since and have positive determinant for all , it is clear that the signs of those blocks with determinant -1 cannot be adjusted by using only generators that act within the block. Instead, we have to use across the cuts to correct the signs. To ensure that we only apply operations for these sign corrections, we place the signs at the boundaries of the blocks, such that we minimize the number of applications. This leads to the optimal number of total gates. For more details, see Appendix A.
In the figure we use right multiplication for clarity, but the proof uses the equivalent left-multiplication convention.
Qiskit -■ pytket -♦ Sort-then-fix -♦ Givens elimination -♦ Ours (total-gate-optimal compiler)
(a) Total gate count

(b) Two-qubit gate count

Figure 3: Performance of our optimal path synthesis algorithm. Randomly generated Clifford-matchgate circuits are compiled using different strategies: our optimal compiler, a Givens elimination strategy, sort then fix, pyket and Qiskit. In panel (a) we plot the average total gate count for different circuit sizes, and in panel (b) we plot the average number of two-qubit gates. Error bars represent the standard deviation. In both plots, we fit the data to straight lines and show the constant relative improvement achieved by our compiler over the other methods.
3.1.1 Comparison against other compilers
Next, we numerically benchmark our path synthesis algorithm against several alternative compilation strategies. The goal is to quantify the improvement obtained with the optimal approach relative to both matchgate-specific heuristics and general-purpose quantum compilers.
Specifically, we compare the algorithm given by Theorem 1 against four alternative methods. Two of them take into account the signed-permutation structure. The first one is a sort-then-fix strategy based on bubble sort, which first realizes the underlying permutation and afterwards corrects the remaining signs. The second is a Givens-elimination strategy that operates directly on the signed-permutation matrix. This method is often used in the compilation of fermionic-shadow settings [28, 68]. The general purpose compilers we employ are Qiskit [36, 37] and pytket [38], which synthesize the original circuits without exploiting their signed-permutation representation.
To conduct the benchmark, we generate matchgate-Clifford circuits as random walks of length 10n over the generating set R. These circuits define the target signed permutations to be synthesized. For more details, see Appendix B. The results are shown in Fig 3. In panel (a), we plot the total number of gates in the compiled circuits up to n = 80 qubits, while in panel (b) the total number of two-qubit gates is depicted. For the total gate count, our compiler indeed produces circuits that are shorter than all other alternatives. In particular, we find constant factor improvements ranging from over matchgate-dedicated methods to up to over general compilers. We also observe similar reductions in the number of two-qubit gates, although our algorithm is designed to minimize the total gate count and therefore does not guarantee optimality in the two-qubit count. We address this gap in the following section.
3.1.2 Optimality in the number of two-qubit gates
So far we have treated and gates as equally costly, since both are Clifford gates. However, in general two-qubit gates are significantly more noisy than single-qubit unitaries. Here, we investigate how much we can reduce the number of operations, or equivalently, the number of generators with even (see Eq. (17)).
A useful tool for treating two-qubit gates differently is to group pairs of Majorana modes into physical modes, as
The only generators that move Majoranas between physical modes are even-index generators. For each Majorana , we denote its initial mode and its target mode. For a boundary between modes and , we define
which is the number of Majoranas that start to the left of the boundary and whose target position lies on the right of this boundary. By conservation, the same number must cross the boundary in the opposite direction as well. The total right (or left) flow over all boundaries is
In addition, we define as the number of bad cut points that lie at even positions,
Then, as proven in Appendix C, the following result holds.
Theorem 2. For every with underlying permutation , the minimum number of two-qubit gates over all words realizing , , is given by
where is the minimum number of even-indexed generators appearing in a reduced word for . The quantity satisfies
where is the net right (or left) flow of Majoranas over all physical boundaries. The upper bound is constructive and therefore gives a factor-2 approximation to .
Moreover, there exists a word that simultaneously achieves the minimum total length
as given by Theorem 1, and the minimum two-qubit gate count .
Let us discuss the implications of Theorem 2. First, Eq. (29) indicates that, when minimizing the total number of two-qubit gates, we can split the contribution from the sign correction from the number of two-qubit gates to build the underlying permutation . The sign correction cost is fixed and given by . The remaining contribution depends only on the underlying permutation
and is captured by , the minimum number of even-indexed generators among reduced words for . Thus, the nontrivial part of minimizing the two-qubit gate count is determining .
By definition, a reduced word attaining has total length . However, once the sign corrections required to realize the full signed permutation are included, it is not a priori obvious that minimizing the two-qubit gate count is compatible with minimizing the total synthesis length. Theorem 2 shows that these two objectives can in fact be achieved simultaneously.
The complexity in finding the optimal two-qubit gate count therefore lies in . Whether can be computed, and whether a word attaining this quantity can be generated efficiently, remains open. However, we show that this quantity admits efficiently computable upper and lower bounds, given by Eq. (30). This gives a factor-2 approximation to the optimal quantity .
Importantly, the upper bound for is constructive, and therefore gives an approximation to the optimal two-qubit gate word. For this construction, we build a word for containing at most even-indexed generators by routing the Majoranas across the mode boundaries. Then, we use the Coxeter deletion property and remove a pair of generators without increasing the number of even-indexed generators. Therefore,
where the last inequality follows from . Hence the constructed word provides a factor-2 approximation to the minimum number of even-indexed generators. For more details on this routing, see Appendix C.
Although the Coxeter deletion property does not specify which generators should be deleted, we can find a redundant pair of generators by iterating over them. We delete such a pair when it does not change the underlying permutation, and we repeat until there are generators left, which results in a reduced word. This procedure can be executed in polynomial time. The argument does not extend to signed permutations directly, but since we are only interested in and it only involves the underlying permutation, this is not an issue.
3.2 Complete graph
In this section, we consider a different connectivity graph and prove that optimal synthesis can be classically solved efficiently for generators with all-to-all connectivity. The generating set is given by
These generators act on the two-dimensional subspace spanned by the canonical basis vectors as
while other basis elements are left unchanged (see Eq. (14)). At the unitary level, is realized by the rotation
This unitary, for spatially separated modes, it is generally not a local two-qubit gate in the Jordan-Wigner representation, even though it admits a matchgate decomposition in terms of one- and two-qubit gates. This means that we are including non-local matchgates in our generating set. These operations may nevertheless be natively available in fermionic architectures. For instance, in reconfigurable arrays where fermionic modes can be exchanged with almost no overhead [82].
The optimal synthesis problem is now, given the all-to-all generating set in Eq. (33), whether we can efficiently find optimal sequences for signed permutation matrices . To answer this question, we need to take into account the cycle structure of the underlying permutation. Consider the unsigned permutation and its cycle decomposition,
where each is a cycle of the permutation and is the number of cycles, including fixed points. Now consider one cycle of length . In the signed permutation , there is a sign for each element,
with . We define the sign of the cycle as . The determinant associated to the cycle of the signed permutation is given by
where is the permutation matrix restricted to the cycle coordinates. We say that a cycle is defective whenever . Equivalently, we have a defective cycle when . Crucially, notice that the number of defective cycles must be even since the total determinant is equal to +1.
Then, as proven in Appendix D, the following result holds.
Theorem 3. For every signed permutation with underlying permutation , the minimum number of generators from required to synthesize is
where the number of cycles in and is the number of defective cycles. Moreover, , and an optimal word is computable in time on a classical computer.
The term in Eq. (39) is the cost associated to sorting the unsigned permutation using arbitrary swaps between Majoranas, corresponding to the classical transposition distance [83]. The number of residual signs that need to be corrected requires exactly extra generators. This term plays an analogous role to in Section 3.1. It takes into account the unavoidable sign defects that cannot be corrected without using generators that act non-trivially across cycles.
An example of the optimal sorting strategy is shown in Figure 4, where a signed permutation matrix associated to a 4-qubit matchgate-Clifford unitary is brought to the identity by a sequence of gates (pink and green arrows). By inverting the sequence, we obtain a word synthesizing with optimal length. The main idea is to express the underlying permutation in cycles and identify the defective ones (those with ). Then, we can readily sort the cycles using the minimum number of transpositions, employing the freedom in choosing between and to correctly deposit the signs, up to the negative defects. Since the number of negative defects is even, we can pair the corresponding cycles and use two consecutive braids, , with in one defective cycle and in another, to correct all negative defects.
The closed-form expression for the optimal length also gives the diameter of the corresponding Cayley graph, that is, the maximum value of over all . In particular,
This maximum is attained by . Consequently, every matchgate-Clifford element can be synthesized using at most all-to-all generators, and this bound is tight.

Figure 4: Example of an optimal synthesis with all-to-all braids. The underlying permutation is decomposed into its cycle structure, with . Sorting these cycles requires generators, as shown in green. The target contains defective cycles, which require two additional generators for the sign correction. After the permutation has been sorted, the remaining sign defects are paired and removed by , as shown in pink. This gives an optimal total length . For visual clarity, we use right multiplication convention.
Finally an optimal synthesis sequence can be constructed in polynomial time. At each step, the algorithm applies a generator that decreases the distance to the identity by one. These operations require at most steps (identify defective cycles and sort the cycles and signs). Since the Cayley-graph diameter is , at most of such iterations are required. The complete synthesis procedure can therefore be implemented in time.
3.3 Tree graphs
We now consider the case when the connectivity graph is a tree given as input to the synthesis problem (in other words, when the connectivity graph is an arbitrary tree). We prove the following result, see Appendix E for details.
Theorem 4. The decision version of gate-optimal matchgate-Clifford synthesis with Majorana braids on tree connectivity graphs is NP-complete.
This result showcases that the complexity of the optimal synthesis problem heavily depends on the chosen generating set. Indeed, the previous sections explained how optimal synthesis can be achieved with polynomial-time classical computation when the connectivity graph is an open path or a complete graph. In contrast, we here show that when the graph is an arbitrary tree, the complexity of the problem jumps to NP-complete, for which no worse-case polynomial-time algorithm exist unless P=NP. The reduction is from the well-known routing problem, which is NP-complete on trees [43] and asks to minimize the number of swaps in a given graph required to realize a prescribed permutation of the tokens placed on its vertices. This problem is very similar but not completely equivalent to optimal matchgate-Clifford synthesis, and the difference resides in the signs introduced by the Majorana braids. We prove that for every permutation, it is always possible to efficiently find a configuration of signs such that the minimum length of a braid sequence synthesizing the signed permutation is exactly the minimum number of swaps required for the original permutation. Consequently, if an algorithm solves the signed permutation synthesis problem, it also solves the routing problem. Importantly, notice that, for the reduction to work in this direction, we have to determine the sign configuration from the permutation itself, without prior knowledge of an optimal routing. We furthermore provide a polynomial upper bound on the length of a sequence synthesizing a given unit-determinant signed permutation on a tree, which guarantees that the problem is indeed in NP and thus it is NP-complete.
In addition, we show that optimizing the depth in matchgate-Clifford circuit synthesis with tree connectivity is also NP-complete, again using the results in Ref. [43] and the same idea as before to handle the signs (see Appendix E for a proof).
Theorem 5. The decision version of depth-optimal matchgate-Clifford synthesis with Majorana braids on tree connectivity graphs is NP-complete.
3.4 Connected graphs
A fairly direct corollary of Theorems 4 and 5 is that when we are allowed to pick arbitrary Majorana braids as generators (equivalently, choose arbitrary connectivity graphs, that are assumed to be connected), the optimal synthesis problem in the matchgate-Clifford group is NP-complete. Since we have already shown that optimal matchgate-Clifford synthesis is NP-complete for tree connectivity, it suffices to provide a polynomial upper bound on the length of sequences synthesizing signed permutations on any graph in terms of Majorana braids. We do so in Appendix F, and hence arrive at the following corollary.
Corollary 1. The decision version of gate-optimal and depth-optimal matchgate-Clifford synthesis with Majorana braids on general connectivity graphs is NP-complete.
4 Discussion
In this work, we have explored optimal exact synthesis within the matchgate-Clifford group. In particular, we have derived two closed-form expressions for the optimal synthesis length in terms of Majorana braids with path and complete-graph connectivity, together with efficient optimal synthesis algorithms. We have additionally benchmarked our path-synthesis algorithm against standard quantum compilers on chains of up to n = 80 qubits, and derived bounds on the minimum number of two-qubit gates. Moreover, we have shown that when an arbitrary tree connectivity graph is supplied as part of the input, the decision version of the optimal synthesis problem becomes NP-complete.
These results showcase that the complexity of optimal synthesis strongly depends on how the generating set, and, more specifically, its connectivity, enter the problem. Identifying fixed connectivities that admit efficient optimal synthesis thus remains an interesting open question. Overall, our results help to better understand the synthesis of an important group of unitaries in quantum computing and may find application in compressing circuits for fermionic simulation. This topic has received some attention lately, and recent progress on fermionic routing has shown that polylogarithmic-depth implementations of fermionic-mode permutations can be obtained [84, 85], while depth synthesis of matchgate-Clifford unitaries using general Clifford circuits under all-to-all qubit connectivity was proven asymptotically optimal [86]. Here, we have taken a complementary approach by pinning down the complexity in terms of the total number of gates needed for synthesis within the matchgate-Clifford group.
More broadly, this work constitutes a step towards understanding optimal synthesis for structured subgroups of the unitary group, where the complexity landscape still remains incomplete.
Recently, both the decision version of optimal CNOT circuit synthesis under all-to-all connectivity and of depth-optimal CZ circuit synthesis were shown to be NP-complete [21–23]. In contrast to Clifford circuits, the complexity of optimal synthesis for the full matchgate group (either exact or approximate) remains unknown [24]. Hence, determining how algebraic structure, generating sets, and hardware connectivity combine to make exact optimal synthesis tractable or intractable constitutes an interesting research direction for future work.
To conclude, we stress that although our main motivation comes from matchgate-Clifford synthesis, our results can also be viewed as statements about the shortest word length in signed permutation groups. Indeed, the adjoint representation of the matchgate-Clifford group is isomorphic to the unit-determinant signed permutation group, . Standard word-length formulas are known for Coxeter groups of type B and D [81] and for related rotation subgroups [87], but they apply to different generating sets, not the Majorana-braid generators considered here. In particular, the standard Coxeter length functions do not capture the additional sign-correction term. Our results therefore provide exact word-length formulas for this physically motivated generating set.
Data and code availability. The source code and benchmark scripts to reproduce Fig. 3, together with the plotted raw data, are publicly available on GitHub at https://github.com/yuxuanzhang1995/matchgate-clifford-synthesis.
Acknowledgments. We thank Richard Küieng and Luna Lima Keller for insightful conversations on the complexity of circuit synthesis of restricted groups of unitaries, and Paolo Braccia for in-depth discussions on the synthesis of (Haar-random) matchgate-Clifford unitaries. B.C. received funding from the European Union, supported by the EuroHPC Joint Undertaking and its members under the Grant Agreement N° 101159808, including top-up funding by Ministry for Digital Transformation and the Civil Service of the Spanish Government. B.C. was also supported by the Laboratory Directed Research and Development (LDRD) program of Los Alamos National Laboratory (LANL) under project number 20260043DR. D.G.-M. acknowledges financial support from the ERC via the Starting grant q-shadows (101117138) and from the Austrian Science Fund (FWF) via the SFB BeyondC (10.55776/FG7). Y.Z. acknowledges funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (grant agreement No. 864597).
AI assistance disclosure. We acknowledge the use of ChatGPT 5.6 and Claude to prove the main results in the paper and help develop the code used to generate Fig. 3. All scientific arguments, results, and conclusions were independently reviewed, verified and simplified by the authors.
References
[1] M. A. Nielsen and I. L. Chuang, Quantum computation and quantum information (Cambridge University Press, Cambridge, 2000).
[2] A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, “Surface codes: towards practical large-scale quantum computation”, Physical Review A 86, 032324 (2012).
[3] D. Litinski, “A Game of Surface Codes: Large-Scale Quantum Computing with Lattice Surgery”, Quantum 3, 128 (2019).
[4] J. van de Wetering and M. Amy, “Optimising quantum circuits is generally hard”, arXiv preprint arXiv:2310.05958 (2023).
[5] É. Gouzien and N. Sangouard, “Provably optimal exact gate synthesis from a discrete gate set”, arXiv preprint arXiv:2503.15452 (2025).
[6] K. Matsumoto and K. Amano, “Representation of quantum circuits with clifford and gates”, arXiv preprint arXiv:0806.3834 (2008).
[7] B. Giles and P. Selinger, “Remarks on matsumoto and amano’s normal form for single-qubit clifford+ t operators”, arXiv preprint arXiv:1312.6584 (2013).
[8] V. Kliuchnikov, D. Maslov, and M. Mosca, “Asymptotically optimal approximation of single qubit unitaries by clifford and t circuits using a constant number of ancillary qubits”, Physical Review Letters 110, 190502 (2013).
[9] N. J. Ross and P. Selinger, “Optimal ancilla-free Clifford+T approximation of z-rotations”, Quantum Info. Comput. 16, 901–953 (2016).
[10] P. Selinger, Exact and approximate synthesis of quantum circuits.
[11] V. Kliuchnikov, K. Lauter, R. Minko, A. Paetznick, and C. Petit, “Shorter quantum circuits via single-qubit gate approximation”, Quantum 7, 1208 (2023).
[12] S. Yamamoto and N. Yoshioka, “Pygridsynth: a fast numerical tool for ancilla-free clifford+t synthesis”, arXiv preprint arXiv:2604.21333 (2026).
[13] S. Yamamoto, H. Hamaguchi., and J. Lapeyre, Pygridsynth.
[14] H. Morisaki, K. Sano, and S. Akibue, “Optimal ancilla-free clifford+ t synthesis for general single-qubit unitaries”, arXiv preprint arXiv:2510.05816 (2025).
[15] D. Maslov, “Linear depth stabilizer and quantum fourier transformation circuits with no auxiliary qubits in finite-neighbor quantum architectures”, Physical Review A 76, 052310 (2007).
[16] D. Maslov and M. Roetteler, “Shorter stabilizer circuits via bruhat decomposition and quantum circuit transformations”, IEEE Transactions on Information Theory 64, 4729–4738 (2018).
[17] S. Bravyi, R. Shaydulin, S. Hu, and D. Maslov, “Clifford circuit optimization with templates and symbolic pauli gates”, Quantum 5, 580 (2021).
[18] S. Bravyi and D. Maslov, “Hadamard-free circuits expose the structure of the clifford group”, IEEE Transactions on Information Theory 67, 4546 (2021).
[19] S. Bravyi, J. A. Latone, and D. Maslov, “6-qubit optimal clifford circuits”, npj Quantum Information 8, 79 (2022).
[20] T. Peham, N. Brandl, R. Kueng, R. Wille, and L. Burgholzer, “Depth-optimal synthesis of clifford circuits with sat solvers”, 2023 IEEE International Conference on Quantum Computing and Engineering (QCE) 1, 802 (2023).
[21] A. Acuaviva, A. Acuaviva, and P. Acuaviva, “Cnot-distance is np-complete under all-to-all connectivity”, arXiv preprint arXiv:2608.03825 (2026).
[22] C. Li and J. Guan, “Vanilla exact synthesis of cnot circuits is np-hard”, arXiv preprint arXiv:2609.04160 (2026).
[23] L. L. Keller and R. Küeng, "(a variant of) clifford circuit synthesis is np-complete", arXiv preprint arXiv:2610.02029 (2026).
[24] B. Casas, P. Braccia, É. Gouzien, M. Cerezo, and D. García-Martín, “Matchgate synthesis via clifford matchgates and T gates”, arXiv preprint arXiv:2602.05425 (2026).
[25] M. Oszmaniec and Z. Zimboras, “Universal extensions of restricted classes of quantum operations”, Physical Review Letters 119, 220502 (2017).
[26] S. Bravyi and A. Kitaev, “Universal quantum computation with ideal clifford gates and noisy ancillas”, Phys. Rev. A 71, 022316 (2005).
[27] K. Wan, W. J. Huggins, J. Lee, and R. Babbush, “Matchgate Shadows for Fermionic Quantum Simulation”, Communications in Mathematical Physics 404, 629 (2023).
[28] V. Heyraud, H. Chomet, and J. Tilly, “Unified framework for matchgate classical shadows”, npj Quantum Information 11, 65 (2025).
[29] M. West, M. Cerezo, and M. Larocca, “Particle-preserving fermionic shadows with mode-independent sample complexity”, arXiv preprint arXiv:2606.27254 (2026).
[30] J. Helsen, S. Nezami, M. Reagor, and M. Walter, “Matchgate benchmarking: scalable benchmarking of a continuous family of many-qubit gates”, Quantum 6, 657 (2022).
[31] J. Carrasco, M. Langer, A. Neven, and B. Kraus, “Gaining confidence on the correct realization of arbitrary quantum computations”, Physical Review Research 6, L032074 (2024).
[32] A. Portik, O. Kálmán, T. Monz, and Z. Zimboras, “Clifford volume and free fermion volume: complementary scalable benchmarks for quantum computers”, arXiv preprint arXiv:2512.19413 (2025).
[33] M. Oszmaniec, N. Dangniam, M. E. Morales, and Z. Zimboras, “Fermion Sampling: A Robust Quantum Computational Advantage Scheme Using Fermionic Linear Optics and Magic Input States”, PRX Quantum 3, 020328 (2022).
[34] R. C. Lyndon and P. E. Schupp, Combinatorial group theory (Springer, 2001).
[35] T. Miltzow, L. Narins, Y. Okamoto, G. Rote, A. Thomas, and T. Uno, “Approximation and hardness for token swapping”, Algorithms-ESA 2016, Proc. 24th Annual European Symposium on Algorithms, Aarhus, 2016, Leibniz International Proceedings in Informatics (LIPIcs) (2016).
[36] A. Javadi-Abhari, M. Treinish, K. Krsulich, C. J. Wood, J. Lishman, J. Gacon, S. Martiel, P. D. Nation, L. S. Bishop, A. W. Cross, et al., “Quantum computing with qiskit”, arXiv preprint arXiv:2405.08810 (2024).
[37] Qiskit contributors, Qiskit: an open-source framework for quantum computing, 2023.
[38] S. Sivarajah, S. Dilkes, A. Cowtan, W. Simmons, A. Edgington, and R. Duncan, “T|ket>: a retargetable compiler for NISQ devices”, Quantum Science and Technology 6, 014003 (2020).
[39] S. B. Bravyi and A. Y. Kitaev, “Fermionic quantum computation”, Annals of Physics 298, 210–226 (2002).
[40] F. Verstraete and J. I. Cirac, “Mapping local hamiltonians of fermions to local hamiltonians of spins”, Journal of Statistical Mechanics: Theory and Experiment 2005, P09012–P09012 (2005).
[41] Z. Jiang, A. Kalev, W. Mruczkiewicz, and H. Neven, “Optimal fermion-to-qubit mapping via ternary trees with applications to reduced quantum states learning”, Quantum 4, 276 (2020).
[42] J. Alicea, Y. Oreg, G. Refael, F. Von Oppen, and M. P. Fisher, “Non-abelian statistics and topological quantum information processing in 1d wire networks”, Nature Physics 7, 412–417 (2011).
[43] O. Aichholzer, E. D. Demaine, M. Korman, J. Lynch, A. Lubiw, Z. Masárová, M. Rudoy, V. V. Williams, and N. Wein, “Hardness of token swapping on trees”, In 30th Annual European Symposium on Algorithms (ESA 2022). Leibniz International Proceedings in Informatics 244, 3 (2022).
[44] E. Knill, “Fermionic Linear Optics and Matchgates”, arXiv preprint arXiv:quant-ph/0108033 (2001).
[45] B. M. Terhal and D. P. DiVincenzo, “Classical simulation of noninteracting-fermion quantum circuits”, Physical Review A 65, 032325 (2002).
[46] D. P. DiVincenzo and B. M. Terhal, “Fermionic linear optics revisited”, Foundations of Physics 35, 1967 (2005).
[47] I. D. Kivlichan, J. McClean, N. Wiebe, C. Gidney, A. Aspuru-Guzik, G. K.-L. Chan, and R. Babbush, “Quantum simulation of electronic structure with linear depth and connectivity”, Physical Review Letters 120, 110501 (2018).
[48] F. Arute, K. Arya, R. Babbush, D. Bacon, J. C. Bardin, R. Barends, S. Boixo, M. Broughton, B. B. Buckley, D. A. Buell, et al., “Hartree-fock on a superconducting qubit quantum computer”, Science 369, 1084–1089 (2020).
[49] J. M. Arrazola, O. Di Matteo, N. Quesada, S. Jahangiri, A. Delgado, and N. Killoran, “Universal quantum circuits for quantum chemistry”, Quantum 6, 742 (2022).
[50] F. Verstraete, J. I. Cirac, and J. I. Latorre, “Quantum circuits for strongly correlated quantum systems”, Physical Review A 79, 032316 (2009).
[51] B. Kraus, “Compressed quantum simulation of the ising model”, Physical Review Letters 107, 250503 (2011).
[52] A. Cervera-Lierta, “Exact ising model simulation on a quantum computer”, Quantum 2, 114 (2018).
[53] Z. Jiang, K. J. Sung, K. Kechedzhi, V. N. Smelyanskiy, and S. Boixo, “Quantum algorithms to simulate many-body physics of correlated fermions”, Physical Review Applied 9, 044036 (2018).
[54] P.-L. Dallaire-Demers, J. Romero, L. Veis, S. Sim, and A. Aspuru-Guzik, “Low-depth circuit ansatz for preparing correlated fermionic states on a quantum computer”, Quantum Science and Technology 4, 045005 (2019).
[55] A. Sopena, M. H. Gordon, D. García-Martín, G. Sierra, and E. López, “Algebraic Bethe Circuits”, Quantum 6, 796 (2022).
[56] R. Ruiz, A. Sopena, M. H. Gordon, G. Sierra, and E. López, “The bethe ansatz as a quantum circuit”, Quantum 8, 1356 (2024).
[57] R. Ruiz, A. Sopena, B. Pozsgay, and E. López, “Efficient eigenstate preparation in an integrable model with hilbert space fragmentation”, arXiv preprint arXiv:2411.15132 (2024).
[58] E. Kökcü, T. Steckmann, Y. Wang, J. Freericks, E. F. Dumitrescu, and A. F. Kemper, "Fixed depth hamiltonian simulation via cartan decomposition", Physical Review Letters 129, 070501 (2022).
[59] E. Kökcü, D. Camps, L. B. Oftelie, J. K. Freericks, W. A. de Jong, R. Van Beeumen, and A. F. Kemper, “Algebraic compression of quantum circuits for hamiltonian evolution”, Physical Review A 105, 032420 (2022).
[60] L. G. Valiant, “Quantum computers that can be simulated classically in polynomial time”, in Proceedings of the thirty-third annual acm symposium on theory of computing (2001), pp. 114–123.
[61] S. Bravyi, “Lagrangian representation for fermionic linear optics”, Quantum Info. Comput. 5, 216–238 (2005).
[62] R. Jozsa and A. Miyake, “Matchgates and classical simulation of quantum circuits”, Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences 464, 3089–3106 (2008).
[63] R. Jozsa, B. Kraus, A. Miyake, and J. Watrous, “Matchgate and space-bounded quantum computations are equivalent”, Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences 466, 809 (2010).
[64] S. Ramelow, A. Fedrizzi, A. M. Steinberg, and A. White, “Matchgate quantum computing and non-local process analysis”, New Journal of Physics 12, 083027 (2010).
[65] D. J. Brod and E. F. Galvao, “Extending matchgates into universal quantum computation”, Physical Review A 84, 022310 (2011).
[66] D. J. Brod and A. M. Childs, “The computational power of matchgates and the xy interaction on arbitrary graphs”, Quantum Information and Computation 14, 901 (2014).
[67] D. J. Brod, “Efficient classical simulation of matchgate circuits with generalized inputs and measurements”, Physical Review A 93, 062332 (2016).
[68] A. Zhao, N. C. Rubin, and A. Miyake, “Fermionic Partial Tomography via Classical Shadows”, Physical Review Letters 127, 110504 (2021).
[69] N. L. Diaz, D. García-Martín, S. Kazi, M. Larocca, and M. Cerezo, “Showcasing a barren plateau theory beyond the dynamical lie algebra”, arXiv preprint arXiv:2310.11505 (2023).
[70] A. A. Mele and Y. Herasymenko, “Efficient Learning of Quantum States Prepared With Few Fermionic Non-Gaussian Gates”, PRX Quantum 6, 010319 (2025).
[71] M. Stroeks, D. Lenterman, B. Terhal, and Y. Herasymenko, “Solving free fermion problems on a quantum computer”, arXiv preprint arXiv:2409.04550 (2024).
[72] P. Braccia, N. Diaz, M. Larocca, M. Cerezo, and D. García-Martín, “Optimal haar random fermionic linear optics circuits”, arXiv preprint arXiv:2505.24212 (2025).
[73] P. Sierant, T. X., and P. S. Tarabunga, “Theory of the matchgate commutant”, arXiv preprint arXiv:2603.12392 (2026).
[74] P. Braccia, N. Diaz, M. Larocca, M. Cerezo, and D. García-Martín, “The commutant of fermionic gaussian unitaries”, arXiv preprint arXiv:2603.19210 (2026).
[75] M. Lastres and S. Moudgalya, “Geometry of free fermion commutants”, arXiv preprint arXiv:2604.05031 (2026).
[76] M. West, S. Y. Chang, L. Coffman, M. Larocca, and M. Cerezo, “Practical fermionic shadows enabled by improved sample-complexity bounds”, arXiv preprint arXiv:2609.40173 (2026).
[77] M. West and M. Larocca, “Fermionic gaussianity can be tested with mode-independent sample-complexity”, arXiv preprint arXiv:2610.02050 (2026).
[78] T. Guaita, L. Hackl, and T. Quella, “Representation theory of gaussian unitary transformations for bosonic and fermionic systems”, arXiv preprint arXiv:2409.11628 (2024).
[79] A. Mitra, M. J. Martin, G. W. Biedermann, A. M. Marino, P. M. Poggi, and I. H. Deutsch, “Robust mølmer-sørensen gate for neutral atoms using rapid adiabatic rydberg dressing”, Physical Review A 101, 030301 (2020).
[80] R. Blümel, N. Grzesiak, N. Pisenti, K. Wright, and Y. Nam, “Power-optimal, stabilized entangling gate between trapped-ion qubits”, npj Quantum Information 7, 147 (2021).
[81] A. Bjorner and F. Brenti, Combinatorics of coxeter groups (Springer, 2005).
[82] D. González-Cuadra, D. Bluvstein, M. Kalinowski, R. Kaubruegger, N. Maskara, P. Naldesi, T. V. Zache, A. M. Kaufman, M. D. Lukin, H. Pichler, et al., “Fermionic quantum processing with programmable neutral atom arrays”, Proceedings of the National Academy of Sciences 120, e2304294120 (2023).
[83] P. Diaconis, Group representations in probability and statistics, Vol. 11 (Institute of mathematical statistics Hayward, CA, 1988).
[84] N. Maskara, M. Kalinowski, D. Gonzalez-Cuadra, and M. D. Lukin, “Fast simulation of fermions with reconfigurable qubits”, arXiv preprint arXiv:2509.08898 (2025).
[85] N. Constantinides, J. Yu, D. Devulapalli, A. Fahimniya, L. Schaeffer, A. M. Childs, M. J. Gullans, A. Schuckert, and A. V. Gorshkov, “Low-depth fermion routing without ancillas”, arXiv preprint arXiv:2510.05099 (2025).
[86] M. West, M. Cerezo, and M. Larocca, “Strong matchgate designs in nearly optimal depth”, arXiv preprint arXiv:2609.26677 (2026).
[87] F. Brenti, V. Reiner, and Y. Roichman, “Alternating subgroups of coxeter groups”, arXiv preprint math/0702177 (2007).
[88] A. Schrijver, Combinatorial optimization: polyhedra and efficiency, Vol. 24 (Springer Science & Business Media, 2003).
A Proof of Theorem 1
In this section, we present a proof of Theorem 1, which we restate here for clarity.
Theorem 1. Consider the generating set and the potential
with the number of negative defects. Then, for every target , there is a classical algorithm that runs in time and outputs a sequence of gates from that synthesizes with optimal length .
Proof. The proof consists of two steps. First, we provide a lower bound on the length of a sequence synthesizing w. Then, we prove a matching upper bound on .
We start by showing that is a lower bound on the word length. To do so, we show that multiplication by any generator changes the potential by at most one in absolute value.
Lemma 1. for all and .
Proof. We have to bound the change of both contributions in once we apply a given generator. Let us start with the change in the number of bad cuts. For a cut and , we find that for all . We can split this into two cases:
-
: In this case, does not change because does not affect the sub-matrix .
-
: contains both coordinates affected by . The generator acts entirely inside the first coordinates. Consequently, (which is not true in general). Therefore, the determinant is unchanged,
(42)
where we have used that .
We can thus see that the value of the determinant at every pre-existing cut in is unchanged. However, we must note that when , new cuts can appear inside . For instance, consider , which has no bad cut. Then has one bad cut. Importantly, a new cut can only appear at , because for every , the transposition leaves invariant, and hence
where is the underlying permutation of and similarly .
We next focus on the case when for some cut. Here, the sub-matrix contains coordinate but not coordinate . It is clear that a cut point at cannot be preserved by the action of , since the underlying permutation satisfies and left multiplication by exchanges the values and wherever they occur in the window notation (also adding an extra sign). Hence, the application of necessarily removes one cut point, merging two contiguous blocks and in (recall Eq. (23)). This in turn implies that the number of bad cuts in this case can only change by at most one. Consequently, we have
For the inversion number, left multiplication by an adjacent transposition changes the inversion number by exactly one,
Therefore, we arrive at
We now show that jumps cannot occur. Let us consider the two possible cases:
- A negative defect at is destroyed, so . This can only happen when for some cut . Since , it follows that and the transposition between and creates an inversion, resulting in . Hence
- A negative defect at is created, so . Then is a cut point of , while it was not a cut point of . Since , we have
| Changed induced at a | |||
|---|---|---|---|
| Negative defect destroyed | -1 | +1 | -1 |
| Negative defect created | +1 | -1 | +1 |
| No change in , inversion created | 0 | +1 | +1 |
| No change in , inversion destroyed | 0 | -1 | -1 |
Table 1: Possible changes of the potential under multiplication by a generator .
where is the underlying permutation of and we used is the identity permutation . Hence
Thus, this is an inversion of . Left multiplication by exchanges the values and , removing this inversion. Since an adjacent transposition changes the inversion number by exactly one, . Consequently,
- If , then .
Thus, in every case,
which proves the lemma. All the cases are summarized in Table 1.
□
Since and each application of a generator changes the absolute value of by at most one, any word over that reaches from the identity must have length at least , i.e.,
Now we continue with the upper bound, which is constructive. Namely, we provide an algorithm that builds a word of length exactly , which both certifies and is the optimal compiler we use throughout.
First, let us recall that a signed permutation matrix decomposes in the fixed canonical basis of at its cut points into cut-free blocks , being the number of such blocks (see Eq. (23)). A cut point of is a value such that , where is the underlying permutation of . Thus, we say that is cut-free if it has no non-trivial cut, that is, there is no such that . Similarly, we say that a block is cut-free if does not contain any non-trivial cut, i.e., the only cut it contains is located at the last row of the block.
We define the inversion graph as the graph with vertex set , where two vertices are connected by an edge if is an inversion of . We prove the following lemma.
Lemma 2. Let be a permutation in . Then, is connected if and only if is cut-free.
Proof. First, suppose that has some non-trivial cut. Then, there exists such that
Therefore, every value appears before every value in . Since , the pair is not an inversion. Hence, there are no edges in connecting the sets and . Thus, is disconnected.
(a)
(b)


Figure 5: Inversion graphs for two permutations in . (a) The permutation has non-trivial cuts and its inversion graph is disconnected. (b) In contrast, has no non-trivial cuts, and its inversion graph is connected.
Conversely, suppose that is disconnected. Consider the connected component containing the value 1, and let be the maximum value in this component such that is in the component. If , then all vertices belong to the same connected component, in contradiction with the assumption that is disconnected. Therefore, , and does not belong to the component. Since there is no edge between and any value in , the value must appear after every value less than or equal to in .
Moreover, suppose that a value appears before a value . If this happened, then would be an inversion and would belong to the same connected component as . But since appears before , and appears before , the pair would also be an inversion, connecting to that same component, which is a contradiction.
Hence, every value in appears before every value larger than , so
Thus, has a non-trivial cut.
We conclude that is connected if and only if is cut-free.
Figure 5 illustrates the connection between the presence of non-trivial cuts and the connectivity of the inversion graph with two examples.
Now consider a signed permutation , with underlying permutation . We can always write , where is a binary vector and a diagonal matrix. For example, let . Then because the value ending on the first position has a minus sign, while the rest do not. With this, we prove the following lemma.
Lemma 3. Consider a word over the generators , with underlying permutation and containing exactly generators. Moreover, assume is cut-free. Then, any sign vector satisfying
can be realized by changing the orientation of the generators.
Proof. Let us denote by the sign vector associated to the fixed word over . Since the generators have determinant +1, Eq. (9) implies
Choosing between and for a given generator in the word amounts to changing both signs of the exchanged Majorana operators (see Eq. (14)). In terms of the sign vector, the relative change is
(57) where are the values exchanged by and are canonical basis vectors of . The pairs of Majoranas that are swapped in the word are precisely those corresponding to the inversion pairs of . Hence, every edge of the inversion graph corresponds to one generator in the word.
Now consider two arbitrary values u and v which are not contiguous. Since is cut-free, Lemma 2 implies that is connected. Therefore, there exists a path from u to v in , given by the sequence of edges
Every edge on this path corresponds to one generator in the word. By changing the orientation of all these generators, the resulting relative change in the sign vector is
because every intermediate term appears twice and therefore cancels out modulo 2. Thus, we can flip the final signs of any chosen pair of Majoranas without changing either the underlying permutation or the length of the word.
Consequently, suppose is the target sign vector we wish to implement. Since it must satisfy Eq. (56), it must differ from in an even number of entries. We can then pair the values whose signs differ, and realize each pair flip using a path in as above, without changing the length of the word.
This lemma implies that, for a cut-free permutation , all sign vectors can be realized using generators, subject to the parity constraint imposed by . However, the blocks with determinant -1 cannot be completely synthesized using only generators that act within the block, since the generators have determinant +1. In particular, given a word with underlying permutation and length , we need to correct the parity of its sign vector in all blocks with determinant -1, using generators that act across contiguous blocks.
Let
be the cut points of a target , where we have included the trivial endpoint . These define the cut-free blocks
with . For convenience, we extend the definition of the cut determinant by . Notice also that .
For each , we define
and set . Thus, the number of bad cuts is
Since w is block diagonal, we have
Consequently,
To correct the signs of the block determinants, we use at every bad cut, i.e.,
Recall that leaves the underlying permutation unchanged and flips the signs at c and . Therefore, on the block , the operator D flips one sign if the cut j-1 is bad and another sign if the cut j is bad. Hence,
Consider now
The underlying permutation of u is still , while for every block,
where we used Eqs. (65) and (67).
Each block is cut-free, and by Lemma 3 can therefore be realized by choosing the orientations of a word with underlying permutation and length , where is the restriction of to the set . Since there are no inversions between different cut-free blocks, concatenating these words gives a word for of length
Finally, using that , it follows that
There is one factor in D for every bad cut, and each such factor requires two generators from R. Therefore, this construction realizes w using
generators, which proves
Combining this with the lower bound established in Lemma 1, we conclude that
The construction can moreover be implemented in time on a classical computer. Indeed, the cut points can be found in time by scanning . Likewise the bad cuts in can be identified from the parities and signs of the cut-free blocks in linear time. Sorting the underlying permutation of each block using the standard bubble-sort algorithm takes time. Then, to determine the orientations of the braids we need the vector , which can be found in linear time from . Finally, the required changes in orientation needed to implement can be done employing the procedure explained in Lemma 3, by finding a spanning tree of the inversion graph and traversing it, which also takes linear time. Summing over all blocks, the total runtime is . And since there exist targets with , this worst-case runtime is asymptotically tight.
25
☐
B Details on numerical benchmarks
In this section, we provide the details of the numerical benchmarks shown in Figure 3.
We generate the targets as random walks of length 10n over the generating set of Eq. (20). At each step, with probability we apply or , each with probability , to a uniformly random qubit , which is the generator ; otherwise we apply , with a uniformly random sign, to a uniformly random adjacent pair, which is . This ensemble is not uniform on , and the typical optimal gate count depends on it.
We use and 80 qubits (2n Majorana modes) with 10, 10, 8, 8, 6 and 5 targets, respectively, and the -th target at each size is generated with seed . We use fewer targets at larger sizes. In the sampled targets, the relative range, , decreases from approximately 83% at to 15% at for our total gate count, and from 96% to 12% for our count. Each walk is stored as a circuit over , and we read off its signed permutation from the action of the circuit on the Majorana operators, as dictated by Eq. (5). All compilers receive the same targets.
For our compiler we use a greedy descent on the potential of Theorem 1, which returns words of optimal length. Starting from , it repeatedly applies a generator of that lowers by one until it reaches the identity. When several such generators are available, we select the first in the fixed order , without any preference based on whether the corresponding gate is one- or two-qubit. Because , such a generator exists for every (undo the last letter of an optimal word for ), so the loop ends after exactly steps. Thus, the compiler optimizes only the total gate count. The number of gates obtained upper-bounds , whose exact evaluation requires .
We compare against four methods: two compilers that act directly on signed permutations, the sort-then-fix heuristic and Givens elimination, and two production transpilers, Qiskit [36, 37] and pytket [38]. The first two sort the permutation first and repair the signs afterwards, without using the choice between and to place the signs during the sort. Sort-then-fix sorts by bubble sort, repeatedly swapping the leftmost adjacent pair that is out of order, always with the same one of and . It then pairs up the entries left with a negative sign, from left to right, and flips each pair back with , which changes only the signs at and . The Givens-elimination compiler, the method used to compile measurement settings for fermionic classical shadows [68], goes through the matrix representation one column at a time from left to right and rotates the nonzero entry of each column up to the diagonal with adjacent rotations, again always of the same orientation. This leaves a diagonal matrix of signs, which it clears in pairs in the same way.
The production transpilers receive the random-walk circuit itself. With Qiskit 2.1 [36, 37], we run transpile with basis gates and a line coupling map at optimization levels 1 to 3 and keep the best verified output. We include the input circuit and all verified transpilation outputs as candidates, and select the candidate minimizing total native gate count, with count as a secondary criterion. Failed transpilation attempts and outputs that do not pass verification are discarded. With pytket 2.9 [38], we apply CommuteThroughMultis followed by RemoveRedundancies. The first command commutes single-qubit gates through two-qubit gates, while the second one applies cancellations when possible.
For verifying our compiler and the two transpilers, we check that the circuit contains only , and gates and that its Clifford tableau equals that of the target, which fixes the unitary up to a global phase. The word returned by our compiler is first converted back into such a circuit. The outputs of sort-then-fix and Givens elimination are words over , and we check that they multiply out to w. Each counts as one two-qubit gate. The pytket passes merge some pairs of adjacent gates into , and the value we plot is pytket's own two-qubit count, in which such a gate counts twice.
In Fig. 3, the plotted points show the mean gate count over the targets at each size, with error bars indicating one sample standard deviation above and below the mean. The lines are unweighted linear least-squares fits to these means, and the multiplicative annotations denote , comparing the fit growth rates across the sampled range. For total gate count, these ratios are approximately 2.57, 2.28, 1.58 and 1.53 for Qiskit, pytket, sort-then-fix and Givens elimination, respectively. For count, the corresponding ratios are 2.99, 2.44, 1.58 and 1.50.
The scripts that generate the targets and run all five compilers are publicly available online .
C Proof of Theorem 2
In this section, we prove the main results related to two-qubit gate count for path graph generators. We restate the results for clarity.
Theorem 2. For every with underlying permutation , the minimum number of two-qubit gates over all words realizing , , is given by
where is the minimum number of even-indexed generators appearing in a reduced word for , and is defined as in Eq. (28). The quantity satisfies
where is the net right (or left) flow of Majoranas over all physical boundaries. The upper bound is constructive and therefore gives a factor-2 approximation to .
Moreover, there exists a word that simultaneously achieves the minimum total length
as given by Theorem 1, and the minimum two-qubit gate count .
Proof. We first prove Eq. (75). For it, we prove lower and upper bounds separately. For the lower bound, consider any word over that realizes , and let denote the number of even-indexed generators in .
Ignoring the signs for a moment, the word projects to a word in adjacent transpositions that realizes , where both and project to the same adjacent transposition . In other words, describes the permutation produced by ignoring the signs.
If the word is not reduced, the Coxeter deletion property [81] allows us to successively delete pairs of letters until we obtain a reduced expression for the same permutation. Since by definition every reduced word for contains at least even-indexed transpositions, must contain at least generators. Consequently
We now consider an even cut point of with , and consider how many occurrences of are required for it to happen. The generator is the only one moving values across the
https://github.com/yuxuanzhang1995/matchgate-clifford-synthesis boundary of the bad cut. Hence, if no appears in , is necessarily +1 as the two sides of the boundaries never interact. If appears only once, cannot be a cut as it mixes values and and would not be satisfied. Hence, a bad cut at requires at least two occurrences of .
Moreover, because is a cut point of , no reduced word for contains the transposition . Indeed, exchanges the two values and and since , these two values do not form an inversion in and consequently do not cross in a reduced word.
For even , correspond to two-qubit gates. Thus, every bad even cut contributes at least two additional even-indexed generators beyond those contained in . Summing over all bad even cuts,
Since V is reduced, , and therefore
Since this holds for every word realizing w,
For the upper bound we construct a word for that uses only two-qubit gates. The first step is to build a word for that results in a signed permutation such that . Among those words, choose one that uses only two-qubit gates. Initially, for each transposition in the reduced word choose .
Since is the signed permutation produced by a reduced word, it does not use any at a cut of . This means that for all cuts. However, it is possible that has some bad cuts. We apply to for all corresponding to a bad cut of , which results in a permutation with
for all cuts in w. This costs exactly two-qubit gates.
We now use this lemma:
Lemma 4. Consider two signed permutations such that and for all cut points of . The sign mismatch between and has even parity on every cut-free block of .
Proof. Consider the sign mismatch vector with components
We recall the definition of :
Since and have the same underlying permutation, the term is identical for both quantities and . Moreover, because is a cut point, the first positions contain exactly the values in . Therefore,
Since , we find that
Next, consider that decomposes into cut-free blocks . We write the -th block as
being the cut points and setting and . Since the two ends of the j-th block are cut points, we have
Therefore, the number of sign defects inside each block satisfies
This shows that for every block , the sign mismatch has even parity, which proves the lemma. ☐
To correct the even signs inside each block, we use the fact that the inversion graph of every cut-free block is connected (Lemma 2). If we want to flip the signs of two Majoranas in the same block, we choose a path that connects them and apply the change to every crossing corresponding to an edge on the path. This effectively changes the signs of the two endpoints Majoranas. Importantly, this operation does not add any extra gate count and it is enough to correct all signs by pairing the remaining defects.
To sum up, the construction uses two-qubit gates to correct even bad cuts and two-qubit gates in the reduced word. All remaining sign corrections do not introduce additional two-qubit gates. This proves that
Combining Eqs. (81) and (90) gives
We now prove the simultaneous optimality in two-qubit gates and optimal length. Consider the construction used in the upper bound above. We start from a reduced word for that contains exactly even-indexed transpositions. Since the word is reduced, its total length is .
For every bad cut of , we introduce the correction . There are bad cuts, and each correction adds exactly two generators. Hence, these corrections increase the total length by . Among them, only the corrections associated with even cuts contribute to the two-qubit gate count. Therefore, they add exactly two-qubit gates.
As shown in the proof of Theorem 2, after these corrections the remaining sign mismatch has even parity within every cut-free block. It can therefore be corrected by changing the orientations
along the connected inversion graph of each block. These orientation changes do not modify either the total number of gates or the number of two-qubit gates.
Consequently, the resulting word W realizes w and satisfies
and simultaneously has a number of even-indexed generators
By Theorem 1, the first quantity is the minimum possible total length, and as proven above, the second is the minimum possible number of two-qubit gates. We conclude that same word W simultaneously achieves both minima.
The exact evaluation of the routing term and how to construct a word that achieves it remains open. However, we can derive the bounds given in Eq. (76). To do so, we use the following lemma:
Lemma 5. For every , the minimum number of even-indexed generators required for a reduced word for is bounded by
where is the net right (or left) flow of Majoranas over all boundaries and is the pairing number. Both bounds are computable in polynomial time, and the upper bound is constructive.
Proof. For the upper bound, we first construct a sequence of generators realizing using at most even-indexed generators. To ease the proof, we track the inverse permutation . If the current permutation is updated by left multiplication, , then its inverse transforms as . Thus, in the window notation of , the generator exchanges the entries at positions and .
Define physical modes as bins containing two Majoranas as
We consider each mode as a bin, and label every Majorana i by its target mode , according to the permutation w. Odd-indexed generators only exchange Majoranas within the same bin, whereas even-indexed generators exchange Majoranas across two neighboring bins.
A Majorana is said to be a right-moving if its target mode (dictated by ) lies in the right, in other words, its source mode is smaller than its target mode . Equivalently, a left-moving Majorana satisfies .
Consider a boundary between modes and . We consider two types of exchange across this boundary:
-
Productive exchange: if it moves a Majorana whose target lies to the right of from left to right and, simultaneously, moves a Majorana whose target lies to the left of from right to left. Thus, an exchange is productive if both Majoranas move towards their target modes.
-
Neutral exchange: if a right-moving Majorana needs to get through the next bin and it forces to move the Majoranas from bin (who actually belonged there) to bin . In other words, we are temporarily displacing the Majoranas in bin .
We use the following routing procedure. Whenever a productive exchange is available, we perform one. If no productive exchange is available, we choose a right-moving Majorana u whose current mode b is as far right as possible, and exchange it with one of the Majoranas in mode .
We first show that this second type of exchange is always possible and is a neutral exchange. Since u is right-moving,
Because no productive exchange is available, both Majoranas currently in mode must have target mode at least . Otherwise, one of them would need to move to the left and could be productively exchanged with u.
Moreover, neither Majorana in mode can have target mode strictly larger than . If this happened, that Majorana would itself be a right-mover located in a mode to the right of b, contradicting the maximality of b used in the routing procedure. Hence both Majoranas in mode have target mode exactly .
Since there are exactly two Majoranas whose target is mode , we must have
Therefore, exchanging u with one of the Majoranas in mode moves u one mode towards its target, while temporarily displacing a Majorana from its target mode. Therefore, this corresponds to a neutral exchange.
We now bound the number of productive and neutral exchanges. For each boundary , define
Initially, . We recall that
is the number of right-moving Majoranas across boundary . At the end of the routing , as we have moved all the modes in their target position.
A productive exchange across boundary decreases by one: a Majorana whose target lies to the right leaves the left side, while the Majorana entering the left side has its target there. Therefore,
By contrast, a neutral exchange leaves unchanged. A right-moving Majorana leaves the left side, decreasing by one, but a Majorana whose target is mode is simultaneously displaced to the left side, increasing by one. Hence,
Exchanges across other boundaries do not change .
It follows that exactly productive exchanges must occur across boundary . Denote this number by :
Let denote the number of neutral exchanges across the same boundary. Consider one such exchange. It displaces a Majorana v whose target mode is from mode into mode . This Majorana cannot subsequently move farther to the left under the routing rule. Since it must eventually return to its target mode, it must later cross boundary from left to right.
After this exchange, v is a right-moving Majorana. We claim that v cannot subsequently move farther to the left. A productive exchange cannot do so, since this would move v away from its target mode. Moreover, v cannot be displaced to the left by another neutral exchange. Indeed, neutral exchanges are performed only when no productive exchange is available, in which case the algorithm chooses a right-moving Majorana whose current mode is as far right as possible. Since v is already right-moving in mode , a Majorana in mode cannot be selected to displace it further to the left, as this would contradict the routing rule.
Consequently, we associate each neutral exchange with the later productive exchange that returns its displaced Majorana to mode . Different neutral exchanges must be associated with different productive exchanges, because a single productive swap moves only one Majorana from left to right and therefore can return at most one displaced Majorana. Hence the association is injective, and
Taking this into account, the total number of inter-mode exchanges across boundary is at most
Summing over all boundaries gives
This routing gives a left-multiplication synthesis of , suppose that the routing of uses the generators in this order. Since the routing acts by right multiplication, . Taking inverses and using , we obtain . Therefore, applying the same generators in the temporal order by left multiplication produces .
The resulting word does not need to be reduced. However, by the Coxeter deletion property, we may delete letters until obtaining a reduced word for the same permutation, without increasing the number of even-indexed generators. Therefore,
We now prove the lower bound
Choose a reduced word for that achieves . As in the upper-bound argument, we track the inverse permutation . The same temporal sequence of generators defining gives a reduced positional routing of . For each mode boundary , let denote the number of swaps across that boundary in this routing. Since every even-indexed generator crosses exactly one mode boundary,
Consider a boundary . There are Majoranas that start to the left of and end to its right. For each such Majorana, consider its last crossing of . Since the Majorana finishes on the right, this last crossing must be from left to right. We call these the R-essential crossings. Thus, there are exactly R-essential crossings.
By conservation, there are also Majoranas that start to the right of and end to its left. Their last crossings are necessarily from right to left. We call these the L-essential crossings. Again, there are exactly of them.
These essential crossings consider one unavoidable crossing for every Majorana that must change sides of the boundary. Other swaps across may also occur, for example crossings that are not the last crossing of either Majorana. A single swap across may be both R-essential and L-essential, realizing one required crossing in each direction simultaneously.
Let denote the number of such doubly essential swaps. The union of the R-essential and L-essential crossings therefore contains
swaps. Since all of these are among the swaps performed across boundary ,
Summing over all boundaries gives
where we used
It remains to upper bound M. For it, consider the sets
We now construct a bipartite graph, with nodes in one partition and in the other. We connect two vertices between and with and if
This condition implies that r and l must form an inversion of . These edges represent the possible Majoranas that can have a double essential swap.
Since each Majorana can participate in up to doubly essential crossings, the vertex gets capacity at most . Similarly, vertex gets capacity . All edges have capacity one, as in the corresponding reduced routing of , a given pair of Majoranas can cross at most once.
Given this bipartite graph let denote the maximum number of edges that can be selected subject to the constraints that each edge is selected at most once and each vertex is incident to at most selected edges. Therefore, the doubly essential swaps define a feasible degree-constrained matching in the grap. By maximality of ,
Substituting this into the previous inequality gives
Finally, combining the upper and lower bounds gives
33
□
Moreover, since the total capacity of the right-moving vertices is
the number of selected edges in any feasible matching is at most . Therefore,
which results in
This bound gives a constructive factor-2 approximation to .
It remains to bound in terms of the number of physical modes . For each boundary , at most Majoranas start to the left of the boundary, while at most target positions lie to its right. Therefore,
Summing over all physical-mode boundaries gives
We now show that both bounds can be evaluated in polynomial time. The quantity is obtained directly from the source and target modes of the Majoranas by summing the boundary flows , and can therefore be computed in polynomial time.
For the upper bound, the routing procedure used in the proof is constructive. At each step, one can determine whether a productive exchange is available or otherwise select the rightmost right-moving Majorana. The proof above shows that the total number of inter-mode exchanges is at most . Since , the number of such steps is polynomial in , and hence the resulting routing can be generated in polynomial time.
For the lower bound, the bipartite graph defining has at most vertices and at most edges. The vertex capacities are given by , and is the maximum cardinality degree-constrained matching in this graph. This is a standard capacitated bipartite matching problem and can be solved in polynomial time, for example by reducing it to a maximum-flow problem [88].
D Proof of Theorem 3
In this section, we prove that optimal synthesis is efficiently achievable with Majorana braids and all-to-all connectivity.
Theorem 3. For every signed permutation with underlying permutation , the minimum number of generators from required to synthesize is
where is the number of cycles in and is the number of defective cycles. Moreover, , and an optimal word is computable in time on a classical computer.
Proof. We recall that the generating set is
For a cycle C of , we denote
where is the restriction of to the coordinates in . We say that is defective if , and consider the number of defective cycles,
We furthermore denote by the number of cycles of , including fixed points.
The proof follows the same strategy as in Appendix A. Namely, we define
and show that this potential characterizes the optimal word length by providing matching lower and upper bounds on .
We start by proving that gives a lower bound.
Lemma 6. For every and every ,
Proof. Multiplication by has one of two possible effects on the cycle decomposition of : it either merges two distinct cycles or splits a single cycle into two. We analyze both cases separately.
First, consider the case when and belong to different cycles and . Multiplication by merges them into a single cycle of . Since two cycles merge, we have one less cycle in . Consequently, the difference in the first term of the potential is
Moreover, since the non-trivial action of lies entirely inside the coordinates in , and , we have
Before applying g, the restriction of w to decomposes into the two cycle blocks,
Therefore
Hence, regarding the second term of the potential, there are three possibilities:
• If and are both non-defective (i.e., ), then is non-defective (i.e., ), so .
• If exactly one of , is defective, then is defective and again .
• If and are both defective, then , so the two defective cycles are replaced by one non-defective cycle. Therefore, .
Consequently, we find
We now consider the second case, when and belong to the same cycle in . Multiplication by splits into two cycles and . Splitting one cycle into two gives
Moreover, the same reasoning as before leads to
Again, there are three possibilities for the change in the second term of the potential:
• If is defective, then by Eq. (135), exactly one of is defective. Therefore, the number of defective cycles is unchanged, so .
• If is non-defective, and are also both non-defective, we have .
• If is non-defective, and are both defective, we have .
Therefore, in all possible cases,
which proves the lemma.
Since and each application of a generator changes the potential by at most one in absolute value, any word over producing w from the identity must contain at least generators. Hence,
We now prove the converse inequality by providing an algorithm that efficiently synthesizes w using generators.
Suppose first that the underlying permutation contains a cycle of length at least two. Choose two distinct elements . Multiplication by splits into two cycles.
If is defective, we have shown that either orientation decreases by one. If is non-defective, choose the orientation that produces two non-defective cycles. As shown in the proof of Lemma 6, this again gives . Repeating this procedure eventually removes every nontrivial cycle of , so that the underlying permutation becomes the identity.
Once we follow these steps, we have and therefore every cycle is a fixed point. We may have defective fixed points, which correspond to negative entries. Since , the number of negative fixed points is even. To fix this, choose a pair of defective fixed points and . On these two coordinates, the signed permutation is . Using the established convention,
The first application merges the two defective fixed points into a non-defective 2-cycle, decreasing by one. The second application splits this non-defective 2-cycle into two non-defective fixed points, again decreasing by one.
Therefore, from every , there exists a generator that decreases the potential by exactly one. Iterating this descent gives a word satisfying and . Consequently, and reversing the word and inverting each generator does not change its length. Hence,
Combining Eqs. (137) and (139), we conclude that
The expression for the optimal length also determines the diameter of the Cayley graph associated with . Since the generating set is symmetric, the Cayley distance from the identity to w is precisely . Moreover, for every signed permutation,
since every defective cycle is, in particular, a cycle of . Therefore,
This upper bound is attained, for example, by . In this case , so , while all fixed-point cycles are defective and hence . Thus
and consequently
The constructive proof directly provides an optimal synthesis algorithm. Starting from , at each step we choose a generator such that , and repeat until the identity is reached. A suitable generator can be found in time. Indeed, from the window notation of , the cycle decomposition of the underlying permutation and the defect of each cycle can be obtained by traversing the entries once. If a nontrivial cycle is present, the proof specifies a pair of elements in that cycle and an orientation that decreases the potential. If the underlying permutation is already the identity, the same traversal identifies a pair of defective fixed points , which can be removed using .
Since every generator selected in this way decreases by exactly one, the number of iterations is precisely the optimal length . Moreover, the Cayley-graph diameter gives
so at most generators have to be selected. Performing work to determine each of at most generators therefore gives a total classical runtime of .
37
☐
E Proof of Theorems 4 and 5
In this appendix, we prove NP-completeness of optimal matchgate-Clifford synthesis on tree connectivity graphs, namely Theorems 4 and 5.
Theorem 4. The decision version of gate-optimal matchgate-Clifford synthesis with Majorana braids on tree connectivity graphs is NP-complete.
Proof. Let be a tree on the vertex set . For every edge , we denote by and by the signed transpositions in Eq. (14) that swap and . We write for the minimum number of such generators required to synthesize .
First, we show that the problem is NP-hard by reducing from optimal token swapping on a tree. The latter asks for an optimal sequence of swaps along the edges of the tree that synthesizes a target permutation of tokens placed on the vertices, and its decision version is NP-Complete [43]. Given an input permutation , we associate to it a signed permutation , with the following sign configuration: For every even-length cycle of , we assign a negative sign to the smallest element in , and positive signs to all other elements. We denote the resulting signs by , and define the signed permutation by
Therefore, for every cycle of , the product of the assigned signs is if its length is even and if it is odd, i.e.,
The same identity holds for every -invariant set, since such a set is a union of cycles. In particular, we have that
and so we arrive at
Hence, , and it is clear that can be constructed in polynomial time from the cycle decomposition of .
We next show that the signs of can be efficiently synthesized simply by choosing between and for each braid in an arbitrary routing of .
Lemma 7. Let be any sequence of swaps along edges of that realizes . There always exist orientations such that
and they can be found in polynomial time on a classical computer.
Proof. Let
The cycle decomposition of can also be efficiently computed on a classical computer.
so that . Immediately before step i, the two Majoranas exchanged by the swap are
We define the swap multigraph on the token set by adding an edge for every step . Clearly, the set of Majoranas on a connected component of is -invariant, as acts on this set by transpositions whose endpoints belong to the same component.
Let us consider
such that . We aim to determine what sign configurations can be attained by changing the orientation of the braids in Eq. (153). In particular, we note that we can write an arbitrary signed permutation as , where and . Choosing between and flips the signs of both swapped Majoranas in Eq. (152), corresponding to . Hence, is in the span of binary vectors with even Hamming weight on every connected component. Conversely, any binary vector with even Hamming weight on a connected component can be realized by orienting the braids. Indeed, since there is always a path between any two Majoranas (by definition of connectedness), we can implement , for any in the connected component (see Lemma 3).
Moreover, since and have the same underlying permutation, there is a unique such that
The previous equations implies that on every connected component C of ,
where in the last equality we used that
with the induced sub-permutation on (this follows because a product of Majorana braids always has determinant +1). Thus, has even Hamming weight on every component and can be realized by a choice of in Eq. (150). The orientations can be efficiently found classically by solving the associated linear system over , namely, Eq. (154).
Lemma 7 directly implies that given an instance of token swapping on a tree , we can reduce it to solving the optimal synthesis problem for , as an optimal sequence for gives an optimal sequence for by simply replacing the braids by swaps. For if that were not optimal for , there would exist a shorter sequence, but also orientations realizing , contradicting the assumption that the original sequence was optimal for in the first place. Hence the decision version of gate-optimal matchgate-Clifford synthesis with Majorana braids on tree connectivity graphs is NP-hard.
To prove membership in NP, we need a polynomial upper bound on the length of a synthesis witness. Indeed, given a polynomial-length witness sequence, it can be efficiently verified whether it actually implements the target permutation matrix. And if the length threshold exceeds the bound, the instance is automatically a yes-instance, which concludes the proof.
Lemma 8. For every tree T on and every ,
Proof. Let . Any permutation can be routed on a tree using at most swaps. First, we move the token bound for a leaf to that leaf using at most swaps, remove the leaf, and continue recursively. The next leaf will require at most swaps and so on, so at most swaps suffice. We orient all braids in this routing in the same direction, and let be their product. Since and have the same underlying permutation and both have determinant +1, there exists an even-weight vector such that .
We can implement using at most braids. To see this, let be vertices of such that , and let , with and , be the unique path between them in . Using the fact that flips the signs at the two endpoints of the corresponding edge, , we find
Since on a tree with vertices, implementing requires at most generators. Moreover, there are at most pairs of ones in (recall that has even Hamming weight), and therefore
☐
Next, we consider optimal synthesis with respect to depth.
Theorem 5. The decision version of depth-optimal matchgate-Clifford synthesis with Majorana braids on tree connectivity graphs is NP-complete.
Proof. In this case, the reduction is from the version of token swapping which asks to minimize the number of parallel rounds of swaps, where every round contains pairwise disjoint swaps. This problem was proven NP-complete in Ref. [43]. The reduction works exactly in the same way as for Theorem 4, using to prove NP-hardness. To show inclusion in NP, we just note that the optimal depth cannot be larger than the optimal gate count from Lemma 8.
F Proof of Corollary 1
In this appendix, we provide a polynomial upper bound on the number of Majorana braids required to synthesize an arbitrary matchgate-Clifford unitary on a connected graph.
Let be a connected graph on the vertex set . For every edge , we include the generators and , and denote by the minimum number of such generators required to synthesize . We prove the following lemma.
Lemma 9. For every connected graph G on and every ,
Proof. Since G is connected, it contains a spanning tree T on the same vertex set (obtained for instance by successively removing edges from cycles while preserving connectedness). Hence, every Majorana braid allowed on T is also an allowed generator on G, which implies
By Lemma 8, we arrive at
Therefore, combining Theorems 4 and 5 with Lemma 9 we obtain Corollary 1, that we restate for convenience.
Corollary 1. The decision version of gate-optimal and depth-optimal matchgate-Clifford synthesis with Majorana braids on general connectivity graphs is NP-complete.