Manuscript Offprint
arXiv:2609.04160Vanilla Exact Synthesis of CNOT Circuits is NP-hard
CHENJIAN LI, Institute of Software, Chinese Academy of Sciences and University of Chinese Academy of Sciences, China
JI GUAN, Institute of Software, Chinese Academy of Sciences, China
Exact CNOT synthesis asks for a minimum-size CNOT circuit implementing an invertible linear transformation. Although several related synthesis models have been shown to be computationally hard, their hardness proofs rely on additional structure such as restricted qubit connectivity, encoded inputs, or unrestricted intermediate variables. The complexity of the most basic setting—identity input, a fixed number of labelled qubits, no ancillas, and all-to-all CNOT connectivity—had remained unresolved. In this work, we prove that the decision version of this vanilla exact CNOT synthesis problem is NP-complete, and consequently that its optimization version is NP-hard. Our proof gives a polynomial-time reduction from the Hamiltonian-path problem on grid graphs in two steps. First, we isometrically embed the grid graph into a hypercube via a unary encoding map. We then encode this hypercube Hamiltonian path problem into vanilla exact CNOT synthesis. The main challenge is that CNOT synthesis specifies only the final parity matrix and cannot directly enforce the intermediate vertex visits required by a Hamiltonian path. To overcome this difficulty, we introduce extra recorder qubits that encode the required intermediate vertex visits into the final transformation, forcing any CNOT circuit implementation to realize the intended path structure. Beyond CNOT synthesis, our result directly implies hardness for several related problems, including the shortest word problem over GL, distance computation on Cayley graphs over GL, minimization of sequential XOR programs, and exact synthesis of phase polynomial circuits.
CCS Concepts: • Theory of computation → Quantum computation theory; • Hardware → Quantum computation; Logic synthesis.
Additional Key Words and Phrases: CNOT synthesis, exact synthesis, linear reversible circuits, NP-completeness, parity networks, Hamiltonian path
ACM Reference Format:
Chenjian Li and Ji Guan. 2026. Vanilla Exact Synthesis of CNOT Circuits is NP-hard. ACM Trans. Quantum Comput. 1, 1 (September 2026), 19 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn
1 Introduction
The Controlled-NOT (CNOT) gate is one of the central primitives of quantum computation. Together with arbitrary single-qubit gates, CNOT forms a standard universal gate set. Its optimization is particularly important on current quantum hardware in the NISQ era, as two-qubit gates typically have substantially higher error rates than single-qubit operations [1, 12, 14, 27]. Reducing the number of CNOT gates is therefore a fundamental objective in quantum circuit compilation.
Fortunately, CNOT circuits possess an unusually clean algebraic structure. An -qubit CNOT circuit implements an invertible linear transformation over , and each CNOT gate corresponds exactly to an elementary row addition. This correspondence makes CNOT circuits amenable to a broad range of classical mathematical and EDA techniques, and places CNOT synthesis at a natural intersection of classical logic synthesis, reversible computation, and quantum circuit optimization. A substantial body of work has exploited this structure. Patel, Markov, and Hayes [25] first developed
*Dated: September 4, 2026
Authors' Contact Information: Chenjian Li, Institute of Software, Chinese Academy of Sciences and University of Chinese Academy of Sciences, Beijing, China; Ji Guan, Institute of Software, Chinese Academy of Sciences, Beijing, China.
- Manuscript submitted to ACM
Chenjian Li and Ji Guan
a block Gaussian elimination method (block GEM) achieving the asymptotically optimal worst-case CNOT count . Subsequent work further improved practical synthesis through greedy algorithms [9], A* search [7, 30], and database-based search [8].
Asymptotic optimality, however, is fundamentally different from optimality for an individual target matrix, or instance-wise optimality. PMH's block GEM guarantees an asymptotically optimal worst-case gate count while remaining a polynomial-time algorithm, but it does not in general return a minimum-size circuit for a given instance. Following the terminology of the logic synthesis community, we will also refer to the latter task as exact synthesis of CNOT circuits: given a target linear transformation, find a circuit with the minimum possible number of CNOT gates that realizes it.
Algorithms capable of providing such instance-level optimality appeared only much more recently, and their behavior suggests a sharp contrast with Gaussian-elimination-based synthesis. Shaik and van de Pol encoded topology-aware optimal CNOT synthesis into SAT instances and solved them using general-purpose SAT solvers [28]. More recently, Lin-search and the semi-tensor-product (STP) solver have attacked unrestricted exact synthesis using specialized search procedures, pruning rules, algebraic structure, and parallelization [21, 22]. Despite these substantial domain-specific optimizations, the synthesis cost of these exact methods grows exponentially with the problem size and the optimal circuit length. This empirical behavior strongly suggests that exact CNOT synthesis is computationally intractable, but it does not by itself establish a complexity-theoretic lower bound.
Existing complexity results provide further evidence that exact CNOT synthesis is computationally difficult, but only for related models with additional structure. Kang showed that exact CNOT synthesis under restricted qubit connectivity is NP-hard via a reduction from VertexCover [20]. Amy, Azizmadeh, and Mosca proved NP-hardness for fixed-target parity networks and for parity networks with linearly encoded inputs, the latter via a reduction from maximum-likelihood syndrome decoding [3]. A closely related problem, XOR minimization, has also been studied in the context of cryptography: Boyar, Matthews, and Peralta showed that the XOR minimization problem (Shortest Linear Program) is NP-hard [5]; but such XOR programs may introduce arbitrary intermediate variables, whereas a CNOT circuit is a fixed-width, reversible computation in which the number of live variables remains unchanged. Hence, this hardness result does not directly apply to exact CNOT synthesis.
Taken together, these results provide substantial evidence that exact CNOT synthesis is intrinsically difficult, but they leave an important conceptual gap. Existing hardness proofs rely on additional structure—restricted connectivity, encoded inputs, or extra intermediate XOR variables—that is absent from the most elementary CNOT model. They therefore cannot rule out the possibility that the observed hardness originates from these auxiliary restrictions or resources rather than from the combinatorial complexity of CNOT synthesis itself. The most basic formulation asks for a minimum-size circuit on a fixed number of qubits (or variables), starting from the identity, using no ancillary qubits, and allowing a CNOT between every pair of qubits. The complexity of this unrestricted in-place exact-synthesis problem remained unresolved for many years after the question was raised by Amy et al. [3].
In this work, we show that this unconditioned (thus “vanilla”) problem, which we denote by , is indeed NP-hard, and that its bounded decision version is NP-complete. Our proof gives a polynomial-time reduction from the Hamiltonian path problem on grid graphs, which has been shown to be NP-complete by Itai et al. [16]. Table 1 summarizes our result together with previous hardness results for related CNOT and XOR synthesis models, and our result is shown as follows:
Table 1. Hardness results related to optimal CNOT and XOR synthesis.
| Work | Additional structure/assumption | Reduced from |
|---|---|---|
| Kang and Ma [20](Topology-Constrained CNOT Synthesis) | Restricted qubitconnectivity | Vertex Cover |
| Amy et al. [3](Fixed-Target Parity Network) | Fixed CNOT target | Hamming Salesman |
| Amy et al. [3](Encoded-Input Parity Network) | Encoded inputs | Maximum-LikelihoodSyndrome Decoding |
| Boyar et al. [5](Shortest Linear Program) | Arbitrary intermediateXOR variables | Vertex Cover |
| Ours(Vanilla Exact CNOT Synthesis) | None | Grid-GraphHamiltonian Path |
PROBLEM: Vanilla CNOT minimization of CNOT circuits (MinCNOT)
INSTANCE: A number of qubits , a target parity matrix , and a nonnegative integer .
QUESTION: Provided that CNOT gates are available between any pair of qubits, does there exist an -qubit CNOT circuit with length at most that realizes the linear transformation ?
THEOREM 1. MinCNOT is NP-complete.
Our proof proceeds in two stages. We first embed the input grid graph into a subset of vertices of a hypercube in a way that preserves adjacency. This representation naturally matches the algebra of CNOT circuits: a hypercube vertex is represented by the parity
where denotes formal input variables.
We then reduce the Hamiltonian path problem on the hypercube to an exact CNOT synthesis problem instance. Note that traversing one hypercube edge flips one coordinate of , which corresponds to adding one variable to and hence to a single CNOT gate. Thus, a walk in the hypercube can be represented by a gate in the CNOT circuit. The main obstacle is that a Hamiltonian path requires every vertex to be visited, whereas exact CNOT synthesis constrains only the final matrix and cannot directly prescribe intermediate parities. We overcome this challenge by introducing a group of recorder qubits, whose final outputs are required to record the intermediate parities (namely vertices in the hypercube) that the circuit must reach. A candidate circuit could nevertheless try to cheat and circumvent this requirement by mixing data and recorder qubits or by introducing temporary intermediate parities on the recorder qubits; to rule out such shortcuts, we require multiple replicas of the recorder qubits and impose a tight gate budget so that there is no room for such auxiliary computation. As a result, every sufficiently short circuit that meets the requirement would visit all required vertex parities, thereby inducing a Hamiltonian path.
Until very recently, the complexity of unrestricted, all-to-all CNOT exact synthesis remained open. While preparing this manuscript, we noted the concurrent independent work by Acuaviva et al. [2], which established NP-completeness for the same setting via a reduction from VertexCover. Our result provides an independent and complementary proof based on a structurally different reduction from Grid-HP, revealing a direct correspondence between CNOT parity trajectories and Hamiltonian paths in induced hypercube subgraphs.
Chenjian Li and Ji Guan
The remaining part of the manuscript is organized as follows. In Sec. 2, we give a brief introduction to CNOT circuits, exact CNOT synthesis, and the grid-graph Hamiltonian path problem. In Sec. 3, we present the reduction from GridGraphHamilton to MinCNOT , proving the hardness of MinCNOT and MinCNOT , and further strengthen the hardness result under several structural restrictions on the target matrix and gate budget. Finally, in Sec. 4 we discuss the broader complexity implications of our result, including shortest word problem over GL and the realted Cayley-graph distance problem, minimization of s-XOR programs, and exact synthesis of phase polynomial circuits.
2.1 CNOT circuits and exact synthesis
The CNOT gate, or the Controlled-NOT gate, is a two-qubit gate, which flips the target qubit (second qubit) if the control qubit (first qubit) is set:
Alternatively, CNOT gates can be characterized as an addition-modulo-2 operation over the binary field :
where , and “ ” denotes the addition modulo 2. As a result, a CNOT gate is linear, in the sense that it satisfies the relation for where denotes .
We will call circuits that only contain CNOT gates CNOT circuits. Although a quantum circuit generally requires a unitary matrix for its representation, a CNOT circuit is a linear transform over all input qubit variables, and can be compactly represented by an parity matrix . For example, a single CNOT gate can be represented as . Meanwhile, CNOT gates are reversible operators, so CNOT circuits are also reversible, and therefore is invertible and belongs to the general linear group over : .
Example 2. Consider the following CNOT circuit that was first introduced in [25]. Denote the input variables as to . Then the circuit

implements the following linear parity matrix:
At any point during the computation of a CNOT circuit, a qubit may contain a linear combination of the input variables such as . Following Amy's [3] notation, such expressions are called parities and are denoted by
(6) where a is the coefficient vector.
While CNOT circuits can be synthesized easily using Gaussian elimination methods, finding their smallest equivalent implementation, or exact CNOT synthesis, is much more challenging. The exact CNOT synthesis problem, and its bounded decision version, can be defined as follows:
PROBLEM: Vanilla exact CNOT synthesis (MinCNOT )
INSTANCE: A number of qubits , a target parity matrix .
QUESTION: Provided that CNOT gates are available between any pair of qubits, what is a smallest CNOT circuit that implements the linear transformation ?
PROBLEM: Vanilla minimization of CNOT circuit (MinCNOT )
INSTANCE: A number of qubits , a target parity matrix , and a nonnegative integer .
QUESTION: Provided that CNOT gates are available between any pair of qubits, does there exist an -qubit CNOT circuit with length at most that realizes the linear transformation ?
Apparently, . So it suffices to show the hardness of to demonstrate the hardness of the circuit synthesis problem. Furthermore, we can define the CNOT length of the parity matrix to be the smallest number of CNOT gates required to implement it:
DEFINITION 1 (CNOT LENGTH). For , its CNOT length is
Example 3. As shown in [22], the smallest CNOT circuits implementing Eq. (5) require only 5 CNOT gates. As a result, the CNOT length of (5) is #CNOT(A) = 5. The smallest implementations are shown as follows:


2.2 Grid graphs and induced hypercube graphs
Grid graphs. A grid graph is a graph that takes grid points on a 2D integer grid as its vertices. Furthermore, vertices in a grid graph are connected if they correspond to neighboring grid points (Manhattan distance is one). That is, a grid graph contains exactly the unit edges between its vertices. Fig. 1 gives an illustration of the grid graph, and grid graphs can be formally defined as follows:
DEFINITION 2 (GRID GRAPH). A grid graph is a graph where , and , where is the Manhattan distance.
Moreover, we can consider the Hamiltonian path problem on grid graphs. Given distinct vertices and , the problem Grid-HP asks whether the grid graph has a Hamiltonian path from to . This specified-endpoint problem has been shown by Itai et al. to be NP-complete [16, Corollary 1].
PROBLEM: Grid graph Hamiltonian path problem (Grid-HP)
INSTANCE: A grid graph , a starting point s and ending point t.
QUESTION: Does a Hamiltonian path of G exist, with s and t being its endpoints?
Chenjian Li and Ji Guan

Fig. 1. Illustration of a grid graph G over the 2D grid, together with an illustrative Hamiltonian path.
Hypercubes. The -dimensional hypercube graph , or -dimensional hypercube for short, is a graph with vertex set . We also denote for the Manhattan distance between -dimensional vectors, which happens to be the Hamming distance between hypercube vertices and . Thus two cube vertices are adjacent (and connected) when . Furthermore, for , let denote the subgraph induced by .
DEFINITION 3 (INDUCED HYPERCUBE SUBGRAPHS). For a vertex set , a hypercube subgraph induced by is defined as where , where is the Hamming distance.
3 Reduction from Grid-HP
In this section we prove the NP-completeness of MinCNOT by reducing the grid graph Hamiltonian path problem to it. As a corollary, the optimization version of the problem MinCNOT is naturally NP-hard. Then in Sec. 3.1, we further adapt the reduction to show that the hardness results hold even under several additional structural restrictions on the target matrix and the gate budget.
THEOREM 4. MinCNOT is NP-complete.
PROOF. We first show that MinCNOT. Apparently, a CNOT circuit of length at most implementing the target parity matrix can serve as a witness for a yes-instance in MinCNOT. Note that each CNOT gate acts as an elementary row addition over , and can therefore be simulated on the parity matrix in time. Hence can be verified in time. After that, Patel, Markov, and Hayes [25] showed that every -qubit linear reversible transformation admits a CNOT implementation of size at most . Consequently, for each yes-instance there is a witness of polynomial length that can be verified in time. As a result, MinCNOT.
We next prove NP-hardness of MinCNOT by a polynomial-time many-one reduction from Grid-HP. The reduction has two stages. First, the grid graph is embedded isometrically into a hypercube. After that, the resulting cube vertices are encoded into the rows of a target matrix.
Step 1: From grid graph to hypercube. Let be a problem instance of Grid-HP, where is the grid graph, and are the specified endpoints. Denote the number of vertices as . We first embed the grid graph into a hypercube .
For a vertex with associated coordinates , we define the unary-prefix encoding as:
(8) where are the extremal horizontal coordinates for vertex coordinates in . Define similarly for the vertical coordinate; then the entire vertex can be encoded as
where denotes string concatenation and . As a slight abuse of notation, we do not distinguish the encoded binary strings and the -coordinate tuples, such as , as it should usually be clear from the context in our setting.
The unary encoding is isometric on each coordinate, hence the Manhattan distance on the original grid graph is preserved:
As a result, all neighboring (distance 1) vertices in the original grid graph remain neighboring after the encoding, and the original connections (edges) are preserved in the hypercube. In other words, the encoding scheme is an isomorphism.
Finally, we encode the specific problem instance into a Hamiltonian path problem instance on the hypercube graph . We define
Let . Here, we have added to every vertex after the initial unary encoding to shift the vertices so the path starts at . Then, serve as the new endpoints. As Eq. (10) shows that the connections are preserved after the encoding, the induced subgraph on hypercube is isomorphic to . Consequently,
The dimension is polynomially bounded. If is not connected, then the problem instance is trivial and can be immediately determined as negative without reduction. Since is connected, examining the minimal spanning tree of grid graphs shows that . Indeed, the spanning tree must contain at least horizontal edges to connect a leftmost vertex to a rightmost vertex, and at least vertical edges to connect a bottommost vertex to a topmost vertex. These two sets of edges are disjoint, so the tree contains at least edges. Since every spanning tree on vertices has exactly edges, we have .
Step 2: From hypercube Hamiltonian path to MinCNOT . The hypercube formulation is particularly amenable to CNOT circuits: the vertices are represented as binary strings, and can be directly translated to parities on qubits; walking along an edge on the hypercube is equivalent to flipping a vertex coordinate, and can be directly translated to a CNOT gate which flips the target qubit in the circuit. The main obstacle is that, in exact CNOT synthesis, we can only specify the final parity matrix A, but cannot directly require the circuit to reach certain intermediate parities. To overcome this challenge, we introduce recorder qubits whose outputs are required to contain the intermediate parities, forcing the circuit to first reach those parities and record them in the recorder qubits. A demonstration of the reduction from hypercube Hamiltonian path to MinCNOT is plotted in Fig. 2.
The encoding is as follows. Firstly, we introduce three different types of qubits:
The shifting also preserves distance, so the isomorphism is not broken after all vertices are shifted by .
Chenjian Li and Ji Guan

Fig. 2. Demonstration of the reduction from hypercube Hamiltonian path to MinCNOT . denote vertices in the hypercube. The CNOT gates corresponding to the first walking and recording steps are shown in the figure, where we have set the first nonzero vertex to for demonstration. Each double line denotes the recorder qubits associated with one vertex.
(1) 1 path qubit: a qubit that carries the parity whose value represents the current hypercube vertex in a candidate Hamiltonian path. The associated input variable of the path qubit is .
(2) coordinate qubits: qubits that always carry the unit parities . They serve as the control qubits used by CNOT gates to walk the path qubit along a direction in the hypercube. The associated input variables of the coordinate qubits are .
(3) recorder qubits: groups of qubits, one group for each vertex , with qubits per group. Their outputs are required to contain the corresponding parity \overline{\chi}_\boldsymbol{v}(\boldsymbol{x}), thereby forcing the circuit to reach each vertex during the computation. The associated input qubit variables of the recorder qubits are , for each hypercube vertex .
Then there are qubits altogether.
Now we first establish the correspondence between hypercube and CNOT circuits over the aforementioned qubits. Recall that each vertex is associated with the parity
Here, we have used to denote the augmented parities that additionally include the path variable . In particular, . Moreover, for two neighboring vertices that differ in the -th coordinate, we have the following relation:
(16) where is the -th standard basis vector of . Hence, whenever the path qubit carries , a CNOT controlled by the -th coordinate qubit updates its parity to , exactly corresponding to traversing the hypercube edge from to .
The target transformation is then specified as follows:
Furthermore, we let denote the parity matrix corresponding to the linear transform over . Equivalently, has the following block form:
where is a matrix formed by repeating each row exactly times. Apparently, is invertible; Eq. (20) therefore implies is invertible and belongs to .
Finally, we set the gate bound to
where m - 1 is the budget for the steps in the Hamiltonian path, and is the budget for the recording.
Next, we show that
Here, the reduction outputs
Completeness ( ): Constructing a CNOT circuit from a Hamiltonian path. Suppose
is a Hamiltonian path on V. We construct a CNOT circuit satisfying the specification in Eq. (23) as follows.
Initially, the path qubit carries . Whenever it carries , use this qubit as the control of CNOT gates, one targeting each recorder qubit associated with . This realizes
Over all vertices, these recorder updates require exactly CNOT gates.
For every consecutive pair , the Hamiltonian path edge implies that they differ in exactly one coordinate, say . A CNOT from data qubit to data qubit 0 then updates
The edges of the path therefore require exactly additional CNOT gates. At the end, the path qubit 0 carries , and the remaining coordinate qubits still carry , and every recorder has the prescribed output. Hence
Chenjian Li and Ji Guan
is implemented using exactly
CNOT gates.
Soundness (): Extracting a Hamiltonian path from a short CNOT circuit. Conversely, we now consider an arbitrary CNOT circuit of length that implements . This direction is considerably more subtle. The distinction among path, coordinate, and recorder qubits is part of our construction, but it is not a constraint imposed on the circuit synthesizer: an arbitrary implementation may mix these qubits, alter their intermediate parities, or use them as temporary workspace. Consequently, it is not trivial to extract the intended Hamiltonian path from the circuit. Fortunately, we can show, through some slightly involved reasoning, that the tight gate bound forces the intended division structure among the path, coordinate, and recorder qubits to appear under the prescribed target matrix .
We first note that all recorder qubits have changed after the circuit, so there are at least CNOT gates targeting the recorder qubits in . More precisely, denote the set of last recorder-targeting gates on the recorder qubits by , and the remaining gates by (we will see very soon why these are the gates corresponding to the parities). Then, we have
We can then prove the following facts, which lead to the path, coordinate, and recorder qubit structure (Proposition 1).
(1) All parities must appear in the circuit: On the other hand, the required changes on the recorder qubits are the distinct parities , which must be present in the circuit at some point. We show this fact by contradiction: if a parity never appears in the circuit, then it would cost at least CNOT gates targeting the corresponding recorder qubits to fulfill their target transformation . This would result in at least CNOT gates in total, which is impossible. As a result, all parities must be present in the circuit at some point.
(2) is precisely the set of gates that first generate the new parities : All the parities are absent at the beginning of the circuit except for , leaving distinct parities to be generated. It therefore takes at least another CNOT gates to generate them. These parity-generating CNOT gates cannot be the last gates targeting recorder qubits (and hence cannot belong to ), because they result in new parities that do not contain the variables required by the output transformation of a recorder qubit; in other words, they can only be in . As a result, we have . Combining with Eq. (28), we see that
The relation above shows that there is no gate surplus in , and every CNOT gate in must derive a new parity on its target qubit. As a result, there is a one-to-one correspondence between the gates in and all parities .
(3) Gates in cannot target recorder qubits: Note that every gate in leaves a parity on its target qubit, which does not contain the recorder variables . As the path and coordinate qubits do not contain recorder variables at the beginning and such variables are never injected into them (by gates in ), they never contain the recorder variables at any time during the computation of the circuit. If a gate in targets a recorder qubit, then one recorder qubit would carry and the recorder variables would be carried exclusively by the remaining
recorder qubits, contradicting the reversibility requirement of CNOT circuits. Consequently, gates in cannot target recorder qubits.
(4) Gates in cannot target coordinate qubits: If a gate in targets a coordinate qubit, then, as shown by (2), it leaves a parity on the target qubit. Note that for any coordinate , so at least one extra gate is needed to recover the required output on the coordinate qubit. However, no gate can fulfill this task: gates in do not target coordinate qubits by definition, and we have shown that gates in must leave on their target qubits, not . By contradiction, gates in cannot target coordinate qubits.
Finally, the properties proved above can be summarized as follows:
PROPOSITION 1. Suppose is a short circuit with CNOT gates implementing the problem instance specified by (23). Then:
(1) the CNOT gates in C can be divided into two disjoint gate sets and ;
(2) , and all gates in target the path qubit and leave a new parity on the path qubit;
(3) , and every gate in targets one of the recorder qubits and changes it from to the target .
From Prop. 1, we see that, starting from , the path qubit is targeted only by the parity-generating CNOT gates in , which leave consecutive parities on the path qubit. From Eq. (16), we see that all the vertices corresponding to the parities are adjacent on the hypercube. We can then naturally extract them and derive a Hamiltonian path .
As a direct result, the bounded decision version of the problem can be reduced to the optimization version of the problem. As a corollary, we immediately derive the following hardness result:
COROLLARY 1. MinCNOT is NP-hard.
3.1 Further strengthening of the hardness theorem
Note that in the reduction from the Hamiltonian path problem to MinCNOT , only a specific type of linear transformation is used (Eq. (23)). In this section we show how to exploit the fact and strengthen our hardness result. In particular, we have the following strengthened version of Theorem 4:
THEOREM 5. MinCNOT is NP-complete, and MinCNOT is NP-hard. Furthermore, the NP-completeness and NP-hardness hold even for problem instances in which
(1) the target linear transformation A is unitriangular;
(2) A satisfies ;
(3)
(4) .
PROOF. We modify the proof of Theorem 4 to show (1) and (2). In the reduction from Grid-HP to MinCNOT , reorder the qubits into (i) coordinate qubits, (ii) the path qubit, and (iii) recorder qubits; then the variable sequence becomes
Chenjian Li and Ji Guan
The corresponding constructed linear transformation A becomes
which is lower unitriangular. Thus it suffices to consider problem instances in where target linear transformations are lower unitriangular to make the problem intractable. The same reasoning also holds for upper unitriangular matrices: if we further exchange the position of the recorder qubits and the coordinate qubits, then we obtain an that is upper unitriangular. As a result, we have shown the first strengthening statement of the theorem.
Then direct computation of A - I can show the second strengthening statement :
where
is a matrix that contains copies of on each row. Consequently, it suffices to consider problem instances in in which to make the problem intractable.
The third and fourth strengthening statements require examining the relation between and . Recall that , , and . Then we have:
As a result, , demonstrating the third strengthening statement. That is to say, NP-completeness persists even when the target matrix is a low-rank perturbation of the identity.
Finally, using the relation , we see that for the used in the reduction we have the following relation:
thus completing the fourth strengthening statement in the theorem.
4 Discussion and Complexity Implications
The simplicity of MinCNOT makes its complexity implications extend beyond CNOT circuit synthesis itself. With no ancillary qubits, topology constraints, or other auxiliary structure, the problem amounts to finding a shortest sequence of elementary linear updates that realizes a prescribed invertible transformation over . Consequently, the same optimization problem admits several equivalent formulations in algebra, graph theory, linear cryptography, and also appears as a special case of more general quantum-circuit synthesis problems. In this section, we make these connections explicit and derive complexity implications for shortest words in , distances in the corresponding Cayley graph, shortest s-XOR programs, and exact synthesis of phase polynomial circuits.
Note is a row vector.
4.1 Shortest Word Problem
The most immediate algebraic interpretation of MinCNOT is as a shortest word problem over the general linear group GL. Recall that each CNOT gate corresponds to an elementary transvection
whose left multiplication performs the row addition of the matrix . Hence, the set
generates GL, and a CNOT circuit implementing directly corresponds to a word over whose product equals .
More generally, for a group generated by a set , a word over is a finite sequence with , and the word length of with respect to is
The corresponding shortest word problem asks, given and an integer , whether .
For and , the word length is precisely the minimum number of CNOT gates required to synthesize . Thus, MinCNOT directly corresponds to the shortest word problem for under the generating set of elementary transvections.
COROLLARY 2. The shortest word problem over with respect to the elementary transvections is NP-complete. Consequently, computing is NP-hard.
4.2 Cayley Graph Distance
The shortest-word formulation has an equivalent graph-theoretic interpretation in terms of Cayley graphs. Let be a finite group generated by . The Cayley graph of with respect to is the graph with
Thus, group elements form the vertices of , while multiplication by a generator corresponds to the edges. The Cayley graph of is shown in Fig. 3.
For , the distance between them is defined as the length of the shortest path connecting them on the Cayley graph. Let denote their distance in . By definition,
and, in particular, if denotes the identity element of ,
For CNOT synthesis, we take and
where each elementary transvection corresponds to one CNOT gate. Since , can be viewed as an undirected graph. An invertible parity matrix is therefore a vertex of , a CNOT gate corresponds to an edge, and a CNOT circuit corresponds to a path. Consequently, computing the distance on the Cayley graph
Chenjian Li and Ji Guan

Fig. 3. The Cayley graph for generated by .
corresponds to the exact CNOT synthesis of . The complexity of exact CNOT synthesis therefore directly translates to the complexity of computing distances in .
COROLLARY 3. Let and let be the set of elementary transvections. Given and , deciding whether
is NP-complete. Consequently, computing the exact distance in is NP-hard.
4.3 Sequential XOR Programs
Another implication of our result concerns XOR-program optimization in linear cryptography. An XOR program is a sequence of instructions that computes its outputs using only XOR operations. Since XOR is addition over , every value produced by such a program is a linear combination of the input bits. Consequently, XOR programs provide a natural implementation model for binary linear transformations. In symmetric cryptography, such transformations appear prominently as linear layers, which are important building blocks in many linear cryptographic protocols. Their implementation cost is therefore closely related to the number of XOR operations required, and optimizing XOR programs has thereby been extensively studied [11, 18, 31, 32].
Several XOR-program models have been considered, differing mainly in how intermediate values are stored and reused. Two particularly relevant models are general XOR (g-XOR) and sequential XOR (s-XOR) [31, 32]. In a g-XOR program, an instruction may create a fresh intermediate variable, for example
where is a new distinct variable and the resulting value can subsequently be reused in later instructions. In contrast, an s-XOR program uses only in-place updates of the form
so the result overwrites one of the existing variables and no additional intermediate variable is introduced. For an invertible linear layer , an s-XOR program starts from the input variables and successively updates them until they realize the outputs specified by . We denote the minimum number of such instructions required to implement the target linear layer by #sXOR(A).
The distinction between the two models is important from a complexity perspective. Boyar, Matthews, and Peralta [5] proved that minimizing a g-XOR program, equivalently the Shortest Linear Program problem, is NP-hard. This result, however, exploits a model in which arbitrary intermediate variables can be introduced. The complexity of the more restrictive in-place s-XOR optimization problem was not resolved by that result; subsequent works instead developed exhaustive-search and heuristic methods for minimizing s-XOR count [18, 31, 32].
It is immediate that s-XOR programs and CNOT circuits are closely related. Each s-XOR instruction corresponds exactly to a CNOT gate with control and target , and vice versa. Therefore, the correspondence is gate-by-gate: under the fixed-variable model, an s-XOR program is precisely the classical counterpart of a CNOT circuit. Consequently, for every ,
Our hardness result therefore also establishes the intrinsic difficulty of finding an optimal fixed-width, in-place XOR program:
COROLLARY 4. Given and , deciding whether admits an s-XOR program of length at most is NP-complete. Consequently, computing is NP-hard.
4.4 Exact Phase Polynomial Synthesis
Our result also has an immediate implication for the exact synthesis of phase polynomial circuits, a class of quantum circuits consisting of CNOT and gates that has broader applications in variational quantum algorithms such as VQE [26] and QAOA [13]. Following Amy et al. [3, 4], a circuit over CNOT and Z-axis phase rotations ( gates) can be described by a pair , where specifies the linear transformation on the computational basis states and is a phase polynomial of the form
The corresponding circuit maps a computational basis state according to
Thus, the synthesis problem contains both a linear component, specified by A, and a phase component, specified by the phases and parities appearing in f.
Following Amy et al. [4], synthesizing a phase polynomial circuit requires satisfying two kinds of parity constraints. Besides realizing the prescribed final linear transformation , the CNOT network must also reach certain intermediate parities associated with the nonzero terms of the phase polynomial . These intermediate parities serve as checkpoints: once a required parity appears on a qubit, the corresponding (or phase) gate can be inserted at that location to realize the associated phase term. Thus, phase polynomial synthesis can be viewed as constructing a CNOT network that reaches a prescribed set of intermediate parity checkpoints while ending at the target transformation .
Amy et al. [3] established hardness for a restricted phase polynomial synthesis setting through the fixed-target parity-network problem, where all CNOT gates must target a common qubit and all the required parity checkpoints are synthesized on that specific qubit. In this fixed-target setting, however, the synthesis problem is essentially equivalent to a traveling-salesman problem over the required parities, making the corresponding hardness proof relatively trivial. Our result provides a complementary route to hardness: even when the phase polynomial is trivial, i.e., f = 0, synthesizing
Chenjian Li and Ji Guan
the prescribed output transformation with the minimum number of CNOT gates is already intractable. Since this CNOT-only case is a special case of general phase polynomial synthesis, we immediately obtain the following result:
COROLLARY 5. Exact synthesis of phase polynomial circuits with minimum CNOT count is NP-hard, even when the phase polynomial is trivial.
This reduction, however, deliberately places all of the hardness in the target linear transformation and does not exploit the intermediate parity requirements introduced by a nontrivial phase polynomial. It naturally leaves a question: do the checkpoint constraints themselves intrinsically contribute to the complexity of exact phase polynomial synthesis? In the extremal case where we fix the target linear transform as , can we still prove that exact phase polynomial synthesis is still intractable in this setting? This question essentially asks whether the hardness of exact phase polynomial synthesis arises from the phase polynomial , the target transformation , or both. Our result does not answer this question, which we leave as an interesting direction for future work.
5 Related Works
Computational complexity of circuit optimization. Amy et al. [3] proved NP-completeness for fixed-target parity networks and parity networks with encoded inputs, while Kang and Ma [20] established NP-hardness for ancilla-free CNOT synthesis under restricted topology. Jiang et al. [19] further proved strong inapproximability for topology-constrained CNOT synthesis with clean ancillas and for local size minimization: approximating either problem within any constant factor is NP-hard.
For the Clifford+ gate set, Van de Wetering and Amy [29] proved that minimizing the count or depth and the CNOT or Hadamard count of Clifford+ circuits is NP-hard under polynomial-time Turing reductions; their argument also covers Toffoli-count minimization in classical reversible circuits.
Classical logic synthesis likewise contains many hard circuit-minimization problems, echoing our result. Boyar et al. [5] proved NP-hardness of minimizing general XOR straight-line programs, while Parberry showed that sorting-network verification is coNP-complete even near optimal depth [24]. Correspondingly, SAT is widely used for exact logic and sorting-network synthesis [6, 15].
Synthesis and optimization of CNOT and phase polynomial circuits. CNOT and phase polynomial synthesis has been studied extensively; representative elimination, greedy, and heuristic methods were summarized in the introduction [3, 7, 9, 25]. Shaik and van de Pol encoded exact CNOT synthesis into SAT, classical planning, and quantified Boolean formula (QBF) instances and solved them with existing solvers; the SAT-based method was the most effective overall [28]. Qiskit-SAT similarly encodes exact CNOT synthesis as SAT and uses Z3 to solve the resulting instances [10, 17].
More recently, methods for exact CNOT synthesis other than SAT have emerged. Webster et al. [30] studied heuristic and exact synthesis for CNOT and Clifford circuits; their exact synthesis uses pre-computed databases and does not scale at runtime. Lin-search instead scales exact CNOT synthesis through hybrid iterative deepening search [22]. Li et al. [21] developed a parallel STP-based framework for the exact synthesis of both CNOT and phase polynomial circuits.
HOPPS subsequently introduced, to our knowledge, the first dedicated hardware-aware optimal phase polynomial synthesizer for arbitrary device topologies [23]. The NP-hardness result in Section 4.4 provides a complexity-theoretic foundation for these exact methods, even without topology constraints or a nontrivial phase polynomial.
Concurrent work. While validating the proof and preparing this manuscript, we became aware of independent concurrent work by Acuaviva et al. [2], which independently proves NP-completeness of all-to-all, fixed-label CNOT Manuscript submitted to ACM distance. Their reduction is from VertexCover, following a source problem also used in earlier CNOT and XOR-program hardness proofs [5, 20], whereas ours introduces a distinct reduction from Grid-HPbridged from an isometric hypercube embedding.
The two reductions expose complementary sources of difficulty. In the construction of Acuaviva et al., vertex selection represents which intermediate parities should be computed and shared; their lower bound extracts this structure from an unrestricted circuit through XOR-DAG projection and contraction. Our proof instead exposes the difficulty of ordering intermediate parities: recorder qubits and a rank argument force a single trajectory through the required hypercube vertices.
The structural strengthenings obtained by the two constructions are broadly comparable. Both establish hardness for unitriangular transformations with , while Acuaviva et al. additionally obtain sparse conditions and approximation hardness. Our construction sharpens two other parameters: Theorem 5 gives hardness even when and under tighter budget , making the two proofs complementary in both technique and structural implications.
6 Conclusion
In this work, we established the NP-completeness of vanilla exact CNOT synthesis: given an invertible parity matrix and a gate bound , deciding whether can be implemented by at most CNOT gates is NP-complete even with all-to-all connectivity, no ancillas, fixed labelled qubits, and identity input. Our reduction proceeds from Grid-HPthrough an induced hypercube representation, exploiting the direct correspondence between hypercube moves and parity updates on CNOT circuits. The main difficulty is that CNOT synthesis constrains only the final parity matrix, whereas a Hamiltonian path imposes requirements on the intermediate states. Recorder qubits, replication, and a tight gate budget bridge this gap and force every sufficiently short implementation to expose the required Hamiltonian path structure. The result therefore shows that the combinatorial complexity of in-place linear reversible synthesis alone is sufficient to make exact CNOT optimization intractable, without relying on topology restrictions, ancillary workspace, or encoded inputs.
Because the vanilla problem has a particularly simple algebraic formulation, the result also transfers directly to several different but important optimization problems. In particular, it establishes NP-completeness of (1) the shortest word problem over generated by elementary transvections, (2) the distance problem on Cayley graphs, (3) the NP-hardness of optimal fixed-width s-XOR programs and (4) exact synthesis of phase polynomial circuits. The latter connection (4) also leaves a natural open question: our reduction places the hardness entirely in the final linear transformation ; it does not determine whether the intermediate parity checkpoints required by a nontrivial phase polynomial are themselves sufficient to make exact synthesis hard. In particular, the complexity of exact phase polynomial synthesis when the final transformation is fixed to remains an interesting direction for future work.
AI Tool Usage Statement
The authors used GPT-5.6 in the development of this work. All mathematical proofs, analysis, citations and the final text were reviewed and validated by the authors, who take full responsibility for the final work.
References
[1] Rajeev Acharya, Laleh Aghababaie-Beni, Igor Aleiner, Trond I Andersen, Markus Ansmann, Frank Arute, Kunal Arya, Abraham Asfaw, Nikita Astrakhantsev, Juan Atalaya, et al. 2024. Quantum error correction below the surface code threshold. arXiv preprint arXiv:2408.13687 (2024).
Chenjian Li and Ji Guan
[2] Antonio Acuaviva, Arturo Acuaviva, and Pablo Acuaviva. 2026. CNOT-Distance is NP-complete under all-to-all connectivity. arXiv preprint arXiv:2608.03825 (2026).
[3] Matthew Amy, Parsiad Azimzadeh, and Michele Mosca. 2018. On the CNOT-complexity of CNOT-PHASE Circuits. Quantum Science and Technology 4, 1 (Sept. 2018), 015002. arXiv:1712.01859 [quant-ph] doi:10.1088/2058-9565/aad8ca
[4] Matthew Amy, Dmitri Maslov, and Michele Mosca. 2014. Polynomial-Time T-depth Optimization of Clifford+ T Circuits via Matroid Partitioning. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 33, 10 (2014), 1476–1489.
[5] Joan Boyar, Philip Matthews, and René Peralta. 2013. Logic minimization techniques with applications to cryptology. Journal of Cryptology 26, 2 (2013), 280–312. doi:10.1007/s00145-012-9124-7
[6] Daniel Bundala, Michael Codish, Luís Cruz-Filipe, Peter Schneider-Kamp, and Jakub Závodný. 2017. Optimal-Depth Sorting Networks. J. Comput. System Sci. 84 (2017), 185–204. doi:10.1016/j.jccs.2016.09.004
[7] Zihan Chen, Henry Chen, Yuwei Jin, Minghao Guo, Enhyeok Jang, Jiakang Li, Caitlin Chan, Won Woo Ro, and Eddy Z Zhang. 2025. PhasePoly: An Optimization Framework for Phase Polynomials in Quantum Circuits. arXiv preprint arXiv:2506.20624 (2025).
[8] Jens Emil Christensen, Søren Fuglede Jørgensen, Andreas Pavlogiannis, and Jaco Van De Pol. 2025. On Exact Sizes of Minimal CNOT Circuits. In Reversible Computation, Robert Glück and Robin Kaarsgaard (Eds.). Vol. 15716. Springer Nature Switzerland, Cham, 71–88. doi:10.1007/978-3-031-97063-4_6
[9] Timothée Goubault De Brugière, Marc Baboulin, Benoit Valiron, Simon Martiel, and Cyril Allouche. 2021. Gaussian Elimination versus Greedy Methods for the Synthesis of Linear Reversible Circuits. ACM Transactions on Quantum Computing 2, 3 (Sept. 2021), 1–26. doi:10.1145/3474226
[10] Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. 337–340. doi:10.1007/978-3-540-78800-3_24
[11] Sébastien Duval and Gaëtan Leurent. 2018. MDS matrices with lightweight circuits. IACR Transactions on Symmetric Cryptology (2018), 48–78.
[12] Simon J Evered, Dolev Bluvstein, Marcin Kalinowski, Sepehr Ebadi, Tom Manovitz, Hengyun Zhou, Sophie H Li, Alexandra A Geim, Tout T Wang, Nishad Maskara, et al. 2023. High-fidelity parallel entangling gates on a neutral-atom quantum computer. Nature 622, 7982 (2023), 268–272.
[13] Edward Farhi, Jeffrey Goldstone, and Sam Gutmann. 2014. A Quantum Approximate Optimization Algorithm. arXiv:1411.4028 [quant-ph] doi:10.48550/arXiv.1411.4028
[14] Dongxin Gao, Daojin Fan, Chen Zha, Jiahao Bei, Guoqing Cai, Jianbin Cai, Sirui Cao, Fusheng Chen, Jiang Chen, Kefu Chen, et al. 2025. Establishing a new benchmark in quantum computational advantage with 105-qubit Zuchongzhi 3.0 processor. Physical Review Letters 134, 9 (2025), 090601.
[15] Winston Haaswijk, Mathias Soeken, Alan Mishchenko, and Giovanni De Micheli. 2020. SAT-Based Exact Synthesis: Encodings, Topology Families, and Parallelism. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 39, 4 (April 2020), 871–884. doi:10.1109/TCAD.2019.2897703
[16] Alon Itai, Christos H Papadimitriou, and Jayme Luiz Szwarcfiter. 1982. Hamilton paths in grid graphs. SIAM J. Comput. 11, 4 (1982), 676–686. doi:10.1137/0211056
[17] Alexander Ivrii and Matthew Treinish. 2021. qiskit-sat-synthesis. https://github.com/qiskit-community/qiskit-sat-synthesis Accessed: 2025-11-16.
[18] Jérémé Jean, Thomas Peyrin, Siang Meng Sim, and Jade Tourteaux. 2017. Optimizing implementations of lightweight building blocks. IACR Transactions on Symmetric Cryptology (2017), 130–168.
[19] Jiaqing Jiang, Xiaoming Sun, Shang-Hua Teng, Bujiao Wu, Kewen Wu, and Jialin Zhang. 2020. Optimal space-depth trade-off of CNOT circuits in quantum logic synthesis. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms. SIAM, 213–229.
[20] Yifan Kang and Henry Ma. 2023. CNOT-Optimal Circuit Synthesis. In Massachusetts Institute of Technology. Research Science Institute.
[21] Chenjian Li, Dingchao Gao, Xiangzhen Zhou, Ji Guan, Pengcheng Zhu, and Zhufei Chu. 2026. Parallelizable Exact Synthesis of Quantum Circuits via Semi-Tensor Product. arXiv preprint arXiv:2607.24195 (2026).
[22] Chenjian Li, Xiangzhen Zhou, Ji Guan, Fanxu Meng, Pengcheng Zhu, and Yu Luo. 2026. Lin-search: Scaling Exact Synthesis of CNOT Circuits via Hybrid Iterative Deepening Search. In Proceedings of the 63rd ACM/IEEE Design Automation Conference. Association for Computing Machinery, New York, NY, USA, 7 pages. doi:10.1145/3770743.3804378
[23] Xinpeng Li, Ji Liu, Shuai Xu, Paul Hovland, and Vipin Chaudhary. 2025. HOPPS: Hardware-Aware Optimal Phase Polynomial Synthesis with Blockwise Optimization for Quantum Circuits. arXiv:2511.18770 [quant-ph] doi:10.48550/arXiv.2511.18770
[24] Ian Parberry. 1991. On the Computational Complexity of Optimal Sorting Network Verification. In PARLE '91 Parallel Architectures and Languages Europe (Lecture Notes in Computer Science, Vol. 505), Emile H. L. Aarts, Jan van Leeuwen, and Martin Rem (Eds.). Springer, Berlin, Heidelberg, 252–269. doi:10.1007/978-3-662-25209-3_18
[25] K.N. Patel, I.L. Markov, and J.P. Hayes. 2008. Optimal Synthesis of Linear Reversible Circuits. Quantum Information and Computation 8, 3&4 (March 2008), 282–294. doi:10.26421/QIC8.3-4-4
[26] Alberto Peruzzo, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J. Love, Alán Aspuru-Guzik, and Jeremy L. O'brien. 2014. A Variational Eigenvalue Solver on a Photonic Quantum Processor. Nature communications 5, 1 (2014), 4213.
[27] John Preskill. 2018. Quantum Computing in the NISQ Era and Beyond. Quantum 2 (Aug. 2018), 79. arXiv:1801.00862 [cond-mat, physics:quant-ph] doi:10.22331/q-2018-08-06-79
[28] Irfansha Shaik and Jaco van de Pol. 2024. Optimal Layout-Aware CNOT Circuit Synthesis with Qubit Permutation. arXiv:2408.04349 [quant-ph] doi:10.48550/arXiv.2408.04349
[29] John van de Wetering and Matthew Amy. 2024. Optimising Quantum Circuits Is Generally Hard. arXiv:2310.05958 [quant-ph] doi:10.48550/arXiv.2310.05958
[30] Mark Webster, Stergios Koutsioumpas, and Dan E. Browne. 2025. Heuristic and Optimal Synthesis of CNOT and Clifford Circuits. arXiv:2503.14660 [quant-ph] doi:10.48550/arXiv.2503.14660
[31] Zejun Xiang, Xiangyoung Zeng, Da Lin, Zhenzhen Bao, and Shasha Zhang. 2020. Optimizing implementations of linear layers. IACR Transactions on Symmetric Cryptology (2020), 120–145.
[32] Yufei Yuan, Wenling Wu, Tairong Shi, Lei Zhang, and Yu Zhang. 2024. A framework to improve the implementations of linear layers. IACR Transactions on Symmetric Cryptology 2024, 2 (2024), 322–347.