# Gaussian elimination versus Greedy methods for the synthesis of linear reversible circuits

Timothée Goubault de Brugière, Marc Baboulin, Benoît Valiron, Simon

Martiel, Cyril Allouche

► To cite this version:

Timothée Goubault de Brugière, Marc Baboulin, Benoît Valiron, Simon Martiel, Cyril Allouche. Gaussian elimination versus Greedy methods for the synthesis of linear reversible circuits. ACM Transactions on Quantum Computing, 2021, 2 (3), pp.11. 10.1145/3474226. hal-03547117

HAL Id: hal-03547117

https://hal.science/hal-03547117

Submitted on 8 Feb 2024

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.
# Gaussian elimination versus Greedy methods for the synthesis of linear reversible circuits

Timothée Goubault de Brugière, Marc Baboulin, Benoît Valiron, Simon

Martiel, Cyril Allouche

► To cite this version:

Timothée Goubault de Brugière, Marc Baboulin, Benoît Valiron, Simon Martiel, Cyril Allouche. Gaussian elimination versus Greedy methods for the synthesis of linear reversible circuits. ACM Transactions on Quantum Computing, 2021, 2 (3), pp.11. 10.1145/3474226. hal-03547117

HAL Id: hal-03547117

https://hal.science/hal-03547117v1

Submitted on 8 Feb 2024

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Gaussian elimination versus greedy methods for the synthesis of linear reversible circuits*

Timothée Goubault de Brugière¹,³, Marc Baboulin¹, Benoît Valiron², Simon Martiel³ and Cyril Allouche³

¹Laboratoire de Recherche en Informatique, Université Paris-Saclay, Orsay, France

²Laboratoire de Recherche en Informatique, CentraleSupélec, Orsay, France

³Atos Quantum Lab, Les Clayes-sous-Bois, France

## Abstract

Linear reversible circuits represent a subclass of reversible circuits with many applications in quantum computing. These circuits can be efficiently simulated by classical computers and their size is polynomially bounded by the number of qubits, making them a good candidate to deploy efficient methods to reduce computational costs. We propose a new algorithm for synthesizing any linear reversible operator by using an optimized version of the Gaussian elimination algorithm coupled with a tuned LU factorization. We also improve the scalability of purely greedy methods. Overall, on random operators, our algorithms improve the state-of-the-art methods for specific ranges of problem sizes: the custom Gaussian elimination algorithm provides the best results for large problem sizes ($n > 150$) while the purely greedy methods provide quasi optimal results when $n < 30$. On a benchmark of reversible functions, we manage to significantly reduce the CNOT count and the depth of the circuit while keeping other metrics of importance (T-count, T-depth) as low as possible.

## 1 Introduction

Progress in scientific computing in recent decades is as much about improvements in algorithms as the increasing power of hardware. Some very active fields, such as machine learning, have benefited from the considerable increase in the amount of data available and from the ever more efficient hardware capable of processing this data, whereas the first algorithms were invented well before. This exponential increase in the power of our computers is often illustrated, now for 40 years, by Moore's second law [34], that predicts that the number of transistors in microprocessors doubles every 2 years since its formulation in 1975. Behind this law hides a race for the miniaturization of transistors. Today the transistors are only a few nanometers large, at this scale quantum effects such as the tunnel effect interfere with the proper performance of the transistors so that it becomes more and more complex to reduce their size.

New kind of computational models are developing in response to this future limitation of the so-called “conventional” or “classical” computing. We can mention biological [14, 11], photonic [21], neuromorphic [33, 45] or quantum [37] computing, booming these recent years. These new paradigms are promising because they perform the calculation at new scales and potentially overcome the limitations of classical computing. For example, in quantum computing, elementary particles are directly manipulated by exploiting their quantum properties to perform in polynomial time computations that may require an exponential amount of operations on a conventional machine [41, 16].

Our paper concerns reversible computing, i.e., boolean operations that can be “undone” because they consist in a bijection between the inputs and outputs of the system. Reversible computing is

<footnote>*This document is the author's version of the corresponding research manuscript prior to formal peer review. An updated version is published in ACM Transactions on Quantum Computing, Volume 2, Issue 3, Article 11. pp 1-26, 2021, 10.1145/3474226</footnote>
# Gaussian elimination versus greedy methods for the synthesis of linear reversible circuits*

Timothée Goubault de Brugière¹,³, Marc Baboulin¹, Benoît Valiron², Simon Martiel³ and Cyril Allouche³

¹Laboratoire de Recherche en Informatique, Université Paris-Saclay, Orsay, France

²Laboratoire de Recherche en Informatique, CentraleSupélec, Orsay, France

³Atos Quantum Lab, Les Clayes-sous-Bois, France

## Abstract

Linear reversible circuits represent a subclass of reversible circuits with many applications in quantum computing. These circuits can be efficiently simulated by classical computers and their size is polynomially bounded by the number of qubits, making them a good candidate to deploy efficient methods to reduce computational costs. We propose a new algorithm for synthesizing any linear reversible operator by using an optimized version of the Gaussian elimination algorithm coupled with a tuned LU factorization. We also improve the scalability of purely greedy methods. Overall, on random operators, our algorithms improve the state-of-the-art methods for specific ranges of problem sizes: the custom Gaussian elimination algorithm provides the best results for large problem sizes ($n > 150$) while the purely greedy methods provide quasi optimal results when $n < 30$. On a benchmark of reversible functions, we manage to significantly reduce the CNOT count and the depth of the circuit while keeping other metrics of importance (T-count, T-depth) as low as possible.

## 1 Introduction

Progress in scientific computing in recent decades is as much about improvements in algorithms as the increasing power of hardware. Some very active fields, such as machine learning, have benefited from the considerable increase in the amount of data available and from the ever more efficient hardware capable of processing this data, whereas the first algorithms were invented well before. This exponential increase in the power of our computers is often illustrated, now for 40 years, by Moore's second law [34], that predicts that the number of transistors in microprocessors doubles every 2 years since its formulation in 1975. Behind this law hides a race for the miniaturization of transistors. Today the transistors are only a few nanometers large, at this scale quantum effects such as the tunnel effect interfere with the proper performance of the transistors so that it becomes more and more complex to reduce their size.

New kind of computational models are developing in response to this future limitation of the so-called “conventional” or “classical” computing. We can mention biological [14, 11], photonic [21], neuromorphic [33, 45] or quantum [37] computing, booming these recent years. These new paradigms are promising because they perform the calculation at new scales and potentially overcome the limitations of classical computing. For example, in quantum computing, elementary particles are directly manipulated by exploiting their quantum properties to perform in polynomial time computations that may require an exponential amount of operations on a conventional machine [41, 16].

Our paper concerns reversible computing, i.e., boolean operations that can be “undone” because they consist in a bijection between the inputs and outputs of the system. Reversible computing is

<footnote>*This document is the author's version of the corresponding research manuscript prior to formal peer review. An updated version is published in ACM Transactions on Quantum Computing, Volume 2, Issue 3, Article 11. pp 1-26, 2021, 10.1145/3474226</footnote>
a subclass of photonic and quantum computing, which motivates its study. A consequence of the reversibility is that there is no loss of information during the calculation, resulting in lower energy consumption because no energy is dissipated at the erasure of a bit [25]. Here we study reversible circuits referred to as linear reversible circuits. These circuits have the particularity to be expressed as circuits containing only one reversible logic gate: the Controlled-Not (CNOT) gate which performs the operation NOT on a target qubit conditioned by the value of a control qubit. This class of circuits is particularly useful in quantum computing in the synthesis of stabilizer circuits: canonical forms for stabilizer circuits involving linear reversible circuits have been found and the size of stabilizer circuits is dominated by the size of reversible linear circuits [1, 29]. Stabilizer circuits are for instance used for error correction and are therefore essential for scaling up quantum computing [13], and so are linear reversible circuits by extension. Linear reversible circuits are also involved in circuits called “CNOT + T” (also called phase polynomials) whose optimization is the purpose of recent research [5, 31, 4, 17].

In the following we study the synthesis and optimization of linear reversible circuits. We are given a linear reversible operator as a Boolean matrix and we seek a quantum circuit that implements it as a series of elementary operations. Our contributions are the following :

* We propose GreedyGE: an optimized version of the Gaussian elimination algorithm for synthesizing any linear reversible operator. When we zero out the subdiagonal entries of the matrix, like in a standard Gaussian elimination, we perform the operations that minimize an ad-hoc cost function, resulting in less operations for the synthesis. We study the theoretical worst case behavior of our algorithm. Overall, our algorithm is asymptotically optimal with theoretical and practical improvements over the state-of-the-art methods [38, Algo. 1] and the syndrome decoding based method [9]. In terms of computational time our algorithm is faster than the standard Gaussian elimination algorithm.

* We propose a new way to compute the LU decomposition of a linear reversible operator. This provides us triangular operators *L* and *U* whose synthesis yield shorter circuits, especially when the circuit is expected to be "small enough". We will detail this notion of "small enough" later in the article. This optimization finds application in other synthesis methods relying on an LU decomposition, for instance the recent method we designed using the syndrome decoding problem [9].

* We show that cost minimization techniques are useful for finding circuits whose expected size is "small enough". We briefly review the existing algorithm and we propose our own cost function and implementation that increase the range of validity of this kind of technique.

* We provide benchmarks of our methods and compare them to state-of-the-art algorithms. First we test our algorithms on random circuits of various sizes. Overall, with GreedyGE, we can synthesize circuits with more than 150 qubits in a few seconds while giving circuits that are at least 10% smaller in average than the current state of the art. With purely greedy methods, we report quasi optimal results when $n < 30$. Then we include our methods into a more general Clifford+T quantum compiler — the Tpar algorithm [5] — and we show that our algorithms are also useful in practice: on a set of reversible functions we successfully reduce the total number of CNOTs and the circuit depth while keeping other metrics of interest (T-count, T-depth) as low as possible.

The plan of this paper is the following: in Section 2 we present the basic notions and state of the art about the synthesis of linear reversible circuits. In Section 3 we describe the improved Gaussian elimination algorithm on triangular operators. In Section 4 we extend our algorithm to treat any general linear reversible operator. Notably we present optimization techniques for computing the LU decomposition. We tackle the study of purely greedy methods in Section 5. Benchmarks are given in Section 6. We conclude in Section 7.
a subclass of photonic and quantum computing, which motivates its study. A consequence of the reversibility is that there is no loss of information during the calculation, resulting in lower energy consumption because no energy is dissipated at the erasure of a bit [25]. Here we study reversible circuits referred to as linear reversible circuits. These circuits have the particularity to be expressed as circuits containing only one reversible logic gate: the Controlled-Not (CNOT) gate which performs the operation NOT on a target qubit conditioned by the value of a control qubit. This class of circuits is particularly useful in quantum computing in the synthesis of stabilizer circuits: canonical forms for stabilizer circuits involving linear reversible circuits have been found and the size of stabilizer circuits is dominated by the size of reversible linear circuits [1, 29]. Stabilizer circuits are for instance used for error correction and are therefore essential for scaling up quantum computing [13], and so are linear reversible circuits by extension. Linear reversible circuits are also involved in circuits called “CNOT + T” (also called phase polynomials) whose optimization is the purpose of recent research [5, 31, 4, 17].

In the following we study the synthesis and optimization of linear reversible circuits. We are given a linear reversible operator as a Boolean matrix and we seek a quantum circuit that implements it as a series of elementary operations. Our contributions are the following :

* We propose GreedyGE: an optimized version of the Gaussian elimination algorithm for synthesizing any linear reversible operator. When we zero out the subdiagonal entries of the matrix, like in a standard Gaussian elimination, we perform the operations that minimize an ad-hoc cost function, resulting in less operations for the synthesis. We study the theoretical worst case behavior of our algorithm. Overall, our algorithm is asymptotically optimal with theoretical and practical improvements over the state-of-the-art methods [38, Algo. 1] and the syndrome decoding based method [9]. In terms of computational time our algorithm is faster than the standard Gaussian elimination algorithm.

* We propose a new way to compute the LU decomposition of a linear reversible operator. This provides us triangular operators *L* and *U* whose synthesis yield shorter circuits, especially when the circuit is expected to be "small enough". We will detail this notion of "small enough" later in the article. This optimization finds application in other synthesis methods relying on an LU decomposition, for instance the recent method we designed using the syndrome decoding problem [9].

* We show that cost minimization techniques are useful for finding circuits whose expected size is "small enough". We briefly review the existing algorithm and we propose our own cost function and implementation that increase the range of validity of this kind of technique.

* We provide benchmarks of our methods and compare them to state-of-the-art algorithms. First we test our algorithms on random circuits of various sizes. Overall, with GreedyGE, we can synthesize circuits with more than 150 qubits in a few seconds while giving circuits that are at least 10% smaller in average than the current state of the art. With purely greedy methods, we report quasi optimal results when $n < 30$. Then we include our methods into a more general Clifford+T quantum compiler — the Tpar algorithm [5] — and we show that our algorithms are also useful in practice: on a set of reversible functions we successfully reduce the total number of CNOTs and the circuit depth while keeping other metrics of interest (T-count, T-depth) as low as possible.

The plan of this paper is the following: in Section 2 we present the basic notions and state of the art about the synthesis of linear reversible circuits. In Section 3 we describe the improved Gaussian elimination algorithm on triangular operators. In Section 4 we extend our algorithm to treat any general linear reversible operator. Notably we present optimization techniques for computing the LU decomposition. We tackle the study of purely greedy methods in Section 5. Benchmarks are given in Section 6. We conclude in Section 7.
# 2 Background and state of the art

## 2.1 Notion of linear reversible function.

Let $\mathbb{F}_2$ be the Galois field of two elements. A boolean function $f: \mathbb{F}_2^n \to \mathbb{F}_2$ is said to be linear if

$$f(x_1 \oplus x_2) = f(x_1) \oplus f(x_2)$$

for any $x_1, x_2 \in \mathbb{F}_2^n$ where $\oplus$ is the bitwise XOR operation. Let $e_k$ be the k-th canonical vector of $\mathbb{F}_2^n$. By linearity we can write for any $x = \sum_k \alpha_k e_k$ (with $\alpha_k \in \{0, 1\}$)

$$f(x) = f\left(\sum_k \alpha_k e_k\right) = \sum_k \alpha_k f(e_k)$$

and the function $f$ can be represented with a column vector $c = [f(e_1), ..., f(e_n)]^T$ such that $f(x) = c^T x$. This expression easily extends to the n-inputs and m-outputs functions $f: \mathbb{F}_2^n \to \mathbb{F}_2^m$ where $f$ is defined by an $m \times n$ boolean matrix $A$ such that

$$f(x) = Ax.$$

In the case of reversible boolean functions we have $n = m$ and the matrix $A$ must be invertible. The application of two successive operators $A$ and $B$ is equivalent to the application of the operator product $BA$. There is a one-to-one correspondence between the linear reversible functions of parity $n$ and the invertible boolean matrices of size $n$. This was used for instance to count the number of different linear reversible functions of $n$ inputs in [38].

## 2.2 LU decomposition.

Given the matrix representation $A$ of a generic linear reversible operator, we can always perform an LU decomposition [12] such that there exists an upper (resp. lower) triangular matrix $U$ (resp. $L$) and a permutation matrix $P$ such that $A = PLU$. The invertibility of $A$ ensures that the diagonal elements of $L$ and $U$ are all equal to 1. In the remainder of this paper, the term “triangular operator” stands for an operator whose corresponding matrix is either upper or lower triangular. The LU decomposition is at the core of several synthesis of general linear reversible Boolean operators: synthesizing $U$, $L$, $P$ and concatenating the circuits gives an implementation of $A$.

## 2.3 Synthesis of linear reversible boolean functions.

We are interested in synthesizing a linear reversible boolean function into a reversible circuit, i.e., a series of elementary reversible gates that can be executed on suitable hardware. For instance in quantum computing the CNOT gate is used for superconducting and photonic qubits and performs the following 2-arity operation:

$$CNOT(x_1, x_2) = (x_1, x_1 \oplus x_2).$$

The CNOT gate is a linear reversible gate. It is also universal for linear reversible circuit synthesis, i.e., any linear reversible function can be implemented by a reversible circuit containing only CNOT gates [1]. In this paper we aim at producing CNOT-based reversible circuits for any linear reversible functions.

In terms of matrices, a CNOT gate controlled by the line $j$ acting on line $i \neq j$ can be written $E_{ij} = I + e_{ij}$ where $I$ is the identity matrix and $e_{ij}$ the elementary matrix with all entries equal 0 but the entry $(i, j)$ whose value is 1. Finding a CNOT circuit implementing an operator $A$ is therefore equivalent to finding a sequence of matrices $(E_{i_k j_k})_{1 \le i_k j_k \le n}$ such that

$$\prod_{k=1 \dots N} E_{i_k j_k} = A.$$
# 2 Background and state of the art

## 2.1 Notion of linear reversible function.

Let $\mathbb{F}_2$ be the Galois field of two elements. A boolean function $f: \mathbb{F}_2^n \to \mathbb{F}_2$ is said to be linear if

$$f(x_1 \oplus x_2) = f(x_1) \oplus f(x_2)$$

for any $x_1, x_2 \in \mathbb{F}_2^n$ where $\oplus$ is the bitwise XOR operation. Let $e_k$ be the k-th canonical vector of $\mathbb{F}_2^n$. By linearity we can write for any $x = \sum_k \alpha_k e_k$ (with $\alpha_k \in \{0, 1\}$)

$$f(x) = f\left(\sum_k \alpha_k e_k\right) = \sum_k \alpha_k f(e_k)$$

and the function $f$ can be represented with a column vector $c = [f(e_1), ..., f(e_n)]^T$ such that $f(x) = c^T x$. This expression easily extends to the n-inputs and m-outputs functions $f: \mathbb{F}_2^n \to \mathbb{F}_2^m$ where $f$ is defined by an $m \times n$ boolean matrix $A$ such that

$$f(x) = Ax.$$

In the case of reversible boolean functions we have $n = m$ and the matrix $A$ must be invertible. The application of two successive operators $A$ and $B$ is equivalent to the application of the operator product $BA$. There is a one-to-one correspondence between the linear reversible functions of parity $n$ and the invertible boolean matrices of size $n$. This was used for instance to count the number of different linear reversible functions of $n$ inputs in [38].

## 2.2 LU decomposition.

Given the matrix representation $A$ of a generic linear reversible operator, we can always perform an LU decomposition [12] such that there exists an upper (resp. lower) triangular matrix $U$ (resp. $L$) and a permutation matrix $P$ such that $A = PLU$. The invertibility of $A$ ensures that the diagonal elements of $L$ and $U$ are all equal to 1. In the remainder of this paper, the term “triangular operator” stands for an operator whose corresponding matrix is either upper or lower triangular. The LU decomposition is at the core of several synthesis of general linear reversible Boolean operators: synthesizing $U$, $L$, $P$ and concatenating the circuits gives an implementation of $A$.

## 2.3 Synthesis of linear reversible boolean functions.

We are interested in synthesizing a linear reversible boolean function into a reversible circuit, i.e., a series of elementary reversible gates that can be executed on suitable hardware. For instance in quantum computing the CNOT gate is used for superconducting and photonic qubits and performs the following 2-arity operation:

$$CNOT(x_1, x_2) = (x_1, x_1 \oplus x_2).$$

The CNOT gate is a linear reversible gate. It is also universal for linear reversible circuit synthesis, i.e., any linear reversible function can be implemented by a reversible circuit containing only CNOT gates [1]. In this paper we aim at producing CNOT-based reversible circuits for any linear reversible functions.

In terms of matrices, a CNOT gate controlled by the line $j$ acting on line $i \neq j$ can be written $E_{ij} = I + e_{ij}$ where $I$ is the identity matrix and $e_{ij}$ the elementary matrix with all entries equal 0 but the entry $(i, j)$ whose value is 1. Finding a CNOT circuit implementing an operator $A$ is therefore equivalent to finding a sequence of matrices $(E_{i_k j_k})_{1 \le i_k j_k \le n}$ such that

$$\prod_{k=1 \dots N} E_{i_k j_k} = A.$$
Using the fact that $E_{ij}^{-1} = E_{ij}$, it is more convenient to rewrite the synthesis problem as a reduction of A to the identity operator I

$$ \prod_{k=N...1} E_{i_k j_k} A = I $$

because we now show that the synthesis problem can be reformulated in terms of elementary operations applied on A. Given a CNOT with control j and target i applied on an operator A, the updated operator $E_{ij}A$ can be deduced from A with an elementary row operation:

$$ r_i \leftarrow r_i \oplus r_j, $$

writing $r_k$ for the k-th row of A. Therefore, if one can compute a sequence of row operations transforming A into the identity operator then one can construct a circuit implementing A by concatenating the CNOT gates associated to each row operation. With a standard Gaussian elimination algorithm it is always possible to reduce an invertible operator to the identity with row operations. This gives a simple proof that the CNOT gate is universal for linear reversible circuit synthesis. In some cases we will also authorize the use of column operations. A column operation $c_j \leftarrow c_i \oplus c_j$ is equivalent to right multiplying A by $E_{ij}$. Overall by combining row and column operations we get

$$ \prod_{(i_1 j_1)} E_{i_1 j_1} \times A \times \prod_{(i_2 j_2)} E_{i_2 j_2} = I $$

and finally

$$ A = \prod_{(i_1 j_1)} E_{i_1 j_1} \prod_{(i_2 j_2)} E_{i_2 j_2} $$

so we recover a CNOT circuit for the implementation of A.

Thus, synthesizing a linear reversible function into a CNOT-based reversible circuit is equivalent to transforming an invertible Boolean matrix A to the identity by applying elementary row and column operations. From now on we will privilege this more abstract point of view because it gives more freedom and often appears clearer for the design of algorithms. We note by $Row(i, j)$ the elementary row operation $r_j \leftarrow r_i \oplus r_j$ and $Col(i, j)$ the elementary column operation $c_j \leftarrow c_i \oplus c_j$.

We use the size of the circuit, i.e., the number of CNOT gates in it, to evaluate the quality of our synthesis. The size of the circuit gives the total number of instructions the hardware has to perform during its execution. Due to the presence of noise when executing every logical gate, it is of interest to have the shortest circuit possible. Another metric of interest is the depth of the circuit which is closely related to the number of time steps required to execute the circuit. In other words the depth of a quantum circuit gives its execution time. Given that the physical qubits are subject to the decoherence problem and that the total time available to perform a quantum algorithm is limited, it is also very important to be able to produce shallow circuits.

We now review the main algorithms designed for the synthesis of CNOT circuits.

## 2.4 State of the art and contributions

We distinguish algorithms that assume that all qubits are connected and algorithms that take into account a restricted connectivity between the qubits. The former usually give smaller and shallower circuits while the latter are adapted to real world hardware where row operations can be performed only between qubits that are neighbors in the hardware. Studying ideal cases with full connectivity is of interest for providing us with new solutions before transposing them to the restricted case.

**Gaussian elimination based algorithm.** In the literature, the first algorithm proposed is a Gaussian elimination algorithm that produces circuits of size $O(n^2)$ gates [1]. Later a lower bound of $O(n^2/\log_2(n))$ was established in [38] for the asymptotic optimal size of reversible circuits, with an algorithm that reaches this lower bound. The algorithm consists in performing the Gaussian elimination algorithm on a chunk of m columns. The gain in the number of operations arises when two words in $F_2^m$ are equal and that one can be zeroed in one row operation. Choosing $m = O(\log_2(n))$ leads to an optimal asymptotic complexity.
Using the fact that $E_{ij}^{-1} = E_{ij}$, it is more convenient to rewrite the synthesis problem as a reduction of A to the identity operator I

$$ \prod_{k=N...1} E_{i_k j_k} A = I $$

because we now show that the synthesis problem can be reformulated in terms of elementary operations applied on A. Given a CNOT with control j and target i applied on an operator A, the updated operator $E_{ij}A$ can be deduced from A with an elementary row operation:

$$ r_i \leftarrow r_i \oplus r_j, $$

writing $r_k$ for the k-th row of A. Therefore, if one can compute a sequence of row operations transforming A into the identity operator then one can construct a circuit implementing A by concatenating the CNOT gates associated to each row operation. With a standard Gaussian elimination algorithm it is always possible to reduce an invertible operator to the identity with row operations. This gives a simple proof that the CNOT gate is universal for linear reversible circuit synthesis. In some cases we will also authorize the use of column operations. A column operation $c_j \leftarrow c_i \oplus c_j$ is equivalent to right multiplying A by $E_{ij}$. Overall by combining row and column operations we get

$$ \prod_{(i_1 j_1)} E_{i_1 j_1} \times A \times \prod_{(i_2 j_2)} E_{i_2 j_2} = I $$

and finally

$$ A = \prod_{(i_1 j_1)} E_{i_1 j_1} \prod_{(i_2 j_2)} E_{i_2 j_2} $$

so we recover a CNOT circuit for the implementation of A.

Thus, synthesizing a linear reversible function into a CNOT-based reversible circuit is equivalent to transforming an invertible Boolean matrix A to the identity by applying elementary row and column operations. From now on we will privilege this more abstract point of view because it gives more freedom and often appears clearer for the design of algorithms. We note by $Row(i, j)$ the elementary row operation $r_j \leftarrow r_i \oplus r_j$ and $Col(i, j)$ the elementary column operation $c_j \leftarrow c_i \oplus c_j$.

We use the size of the circuit, i.e., the number of CNOT gates in it, to evaluate the quality of our synthesis. The size of the circuit gives the total number of instructions the hardware has to perform during its execution. Due to the presence of noise when executing every logical gate, it is of interest to have the shortest circuit possible. Another metric of interest is the depth of the circuit which is closely related to the number of time steps required to execute the circuit. In other words the depth of a quantum circuit gives its execution time. Given that the physical qubits are subject to the decoherence problem and that the total time available to perform a quantum algorithm is limited, it is also very important to be able to produce shallow circuits.

We now review the main algorithms designed for the synthesis of CNOT circuits.

## 2.4 State of the art and contributions

We distinguish algorithms that assume that all qubits are connected and algorithms that take into account a restricted connectivity between the qubits. The former usually give smaller and shallower circuits while the latter are adapted to real world hardware where row operations can be performed only between qubits that are neighbors in the hardware. Studying ideal cases with full connectivity is of interest for providing us with new solutions before transposing them to the restricted case.

**Gaussian elimination based algorithm.** In the literature, the first algorithm proposed is a Gaussian elimination algorithm that produces circuits of size $O(n^2)$ gates [1]. Later a lower bound of $O(n^2/\log_2(n))$ was established in [38] for the asymptotic optimal size of reversible circuits, with an algorithm that reaches this lower bound. The algorithm consists in performing the Gaussian elimination algorithm on a chunk of m columns. The gain in the number of operations arises when two words in $F_2^m$ are equal and that one can be zeroed in one row operation. Choosing $m = O(\log_2(n))$ leads to an optimal asymptotic complexity.
**Syndrome decoding based algorithm** Recently, we proposed a new method for the synthesis of CNOT circuits [9]. We transformed the synthesis problem into a series of syndrome decoding problems and gave several strategies to solve them (either optimal with an integer programming solver or approximate with greedy methods). Our benchmarks reveal that our method outperforms [38, Algo. 1] for operators on medium-sized registers ($n < 400$ qubits) but performs poorly as $n$ gets larger.

**Other algorithms.** In [40] a cost-minimization approach was used with promising results.

To our knowledge, [38, Algo. 1] is state-of-the-art and it is used in the Tpar and Gray-Synth algorithms [4, 5]. Given that our recent results from [9] improve [38, Algo. 1], we also have to take them into consideration. Therefore, both [38, Algo. 1] and the syndrome decoding based algorithms will be our state-of-the-art methods in this paper.

**Related works.** Recently an algorithm asymptotically tight for the depth was also proposed [19]. All the algorithms we mentioned so far assume that all qubits are connected. For special hardware constraints, some variants have been designed. In the case of a Linear Nearest Neighbor (LNN) architecture, the works in [27, 24] provide circuits with linear depth. For a generic qubit connectivity, the works in [20, 36] propose an adaptation of the Gaussian elimination method using Steiner trees and reach circuits of size $\mathcal{O}(n^2)$. The syndrome decoding based algorithm has also been extended to arbitrary connectivities containing a Hamiltonian path [9].

**Contributions.** In this paper we focus on improving the size of the generated circuits when considering a full qubit connectivity. To our knowledge [38, Algo. 1] and the algorithm from [9] are in this case the best algorithms. The former is polynomial in time and produces asymptotically optimal circuits size. The latter is also polynomial in time if the algorithm for solving the syndrome decoding problem has a polynomial complexity. Better results can be obtained with an exact — but exponentially costly — solver but, in any case, the syndrome decoding based algorithm produces shorter circuits for medium sized circuits, without any theoretical guarantee though.

Our method relies on an efficient algorithm — GreedyGE — for synthesizing any triangular operator: at any time during the synthesis the next row operation is chosen such that it minimizes a custom cost function. Then we propose two extensions to be able to synthesize any generic operator. The first option is similar to [38, Algo. 1] : we slightly modify our algorithm such that it first transforms $A$ into an upper triangular operator $U$ and then we use our unmodified algorithm to synthesize $U$. The second option is to rely on the LU decomposition of the operator to synthesize: given $A = PLU$, the synthesis of $A$ can be performed by synthesizing $U$, $L$ and $P$ and concatenating the circuits. The permutation $P$ can be synthesized by applying successive SWAP gates that requires 3 CNOTs each. Yet, one can avoid applying the permutation by doing a post-processing of the circuit that would transfer the permutation operation directly at the end of the total circuit. In the case of a full connectivity this can be done without any overhead in the gate count. Consequently for that second option we do not consider the cost of implementing the permutation $P$ and the cost of synthesizing $A$ is twice the cost of synthesizing a triangular operator.

Our algorithm improves [38, Algo. 1] and [9] in several ways :

* first we improve the worst case synthesis of triangular operators with theoretical guarantee. Namely we show that the size of our circuits is upper bounded by $n^2/\log_2(n)$ and that we converge faster than [38, Algo. 1] to that asymptotic behavior.

* We propose a fast implementation of GreedyGE such that the running time is lower than the standard Gaussian elimination algorithm.

* We propose a new way to compute LU decompositions such that we get triangular operators whose synthesis leads to shorter circuits. This improvement can also be used in [9] as it also relies on an LU decomposition.
**Syndrome decoding based algorithm** Recently, we proposed a new method for the synthesis of CNOT circuits [9]. We transformed the synthesis problem into a series of syndrome decoding problems and gave several strategies to solve them (either optimal with an integer programming solver or approximate with greedy methods). Our benchmarks reveal that our method outperforms [38, Algo. 1] for operators on medium-sized registers ($n < 400$ qubits) but performs poorly as $n$ gets larger.

**Other algorithms.** In [40] a cost-minimization approach was used with promising results.

To our knowledge, [38, Algo. 1] is state-of-the-art and it is used in the Tpar and Gray-Synth algorithms [4, 5]. Given that our recent results from [9] improve [38, Algo. 1], we also have to take them into consideration. Therefore, both [38, Algo. 1] and the syndrome decoding based algorithms will be our state-of-the-art methods in this paper.

**Related works.** Recently an algorithm asymptotically tight for the depth was also proposed [19]. All the algorithms we mentioned so far assume that all qubits are connected. For special hardware constraints, some variants have been designed. In the case of a Linear Nearest Neighbor (LNN) architecture, the works in [27, 24] provide circuits with linear depth. For a generic qubit connectivity, the works in [20, 36] propose an adaptation of the Gaussian elimination method using Steiner trees and reach circuits of size $\mathcal{O}(n^2)$. The syndrome decoding based algorithm has also been extended to arbitrary connectivities containing a Hamiltonian path [9].

**Contributions.** In this paper we focus on improving the size of the generated circuits when considering a full qubit connectivity. To our knowledge [38, Algo. 1] and the algorithm from [9] are in this case the best algorithms. The former is polynomial in time and produces asymptotically optimal circuits size. The latter is also polynomial in time if the algorithm for solving the syndrome decoding problem has a polynomial complexity. Better results can be obtained with an exact — but exponentially costly — solver but, in any case, the syndrome decoding based algorithm produces shorter circuits for medium sized circuits, without any theoretical guarantee though.

Our method relies on an efficient algorithm — GreedyGE — for synthesizing any triangular operator: at any time during the synthesis the next row operation is chosen such that it minimizes a custom cost function. Then we propose two extensions to be able to synthesize any generic operator. The first option is similar to [38, Algo. 1] : we slightly modify our algorithm such that it first transforms $A$ into an upper triangular operator $U$ and then we use our unmodified algorithm to synthesize $U$. The second option is to rely on the LU decomposition of the operator to synthesize: given $A = PLU$, the synthesis of $A$ can be performed by synthesizing $U$, $L$ and $P$ and concatenating the circuits. The permutation $P$ can be synthesized by applying successive SWAP gates that requires 3 CNOTs each. Yet, one can avoid applying the permutation by doing a post-processing of the circuit that would transfer the permutation operation directly at the end of the total circuit. In the case of a full connectivity this can be done without any overhead in the gate count. Consequently for that second option we do not consider the cost of implementing the permutation $P$ and the cost of synthesizing $A$ is twice the cost of synthesizing a triangular operator.

Our algorithm improves [38, Algo. 1] and [9] in several ways :

* first we improve the worst case synthesis of triangular operators with theoretical guarantee. Namely we show that the size of our circuits is upper bounded by $n^2/\log_2(n)$ and that we converge faster than [38, Algo. 1] to that asymptotic behavior.

* We propose a fast implementation of GreedyGE such that the running time is lower than the standard Gaussian elimination algorithm.

* We propose a new way to compute LU decompositions such that we get triangular operators whose synthesis leads to shorter circuits. This improvement can also be used in [9] as it also relies on an LU decomposition.
Overall GreedyGE is suited to dense, worst case operators, or operators that act on several hundred or thousands of qubits. For operators on a much smaller number of qubits, or when the structure of the operator is such that we can expect the resulting circuit to be small (for instance if the operator is sparse), GreedyGE does not particularly outperform other existing algorithms. Instead we show that cost minimization techniques, like the one introduced in [40], produce much better results. We review the work in [40] and we propose a new cost function that improves the range of validity of such cost minimization method.

Finally we apply our new methods to real world circuits. Plugged into a global Clifford+T quantum compiler, here the Tpar algorithm [5], we show that we can significantly improve the CNOT cost of reversible functions without worsening other metrics like the T-depth.

# 3 GreedyGE: a Greedy Gaussian Elimination Algorithm for Triangular Boolean Matrices

## 3.1 General Presentation of the Algorithm

Given a lower triangular operator $L$ — the upper case can be treated similarly — the Gaussian elimination algorithm can be summarized as follows: by applying elementary row operations $Row(i, j)$ with $i < j$ we zero the sub-diagonal elements of $L$ without changing its triangular shape. This process is performed column by column, starting from the first one. This way one can easily see that if the $k$ first columns are treated, applying row operations $Row(i, j)$ with $k < i < j$ will not change the treated columns as all their elements are 0. Since $L$ is invertible, when zeroing the $k$-th column the $k$-th row is necessarily equal to $L[k, :] = e_k^T$ hence one can always add the row $k$ to any row $j > k$ to zero the entry $L[j, k]$. This guarantees the good behavior of the algorithm for any input matrix.

Usually, a Gaussian elimination algorithm always performs the row operations $Row(k, j)$ when zeroing the $k$-th column. As one row operation ensures to zero only one element at a time, we need at most $\frac{n(n-1)}{2}$ row operations to zero every sub-diagonal elements of $L$, leading to a worst-case complexity of $O(n^2)$ for the synthesis of a generic linear reversible operator.

A first straightforward improvement is to authorize any row operation $Row(i, j)$, $i < j$. This was exploited in [38, Algo. 1] : by partitioning the matrix of size $n$ into blocks of size $m$, the authors use the fact that there can only be at most $2^m$ different vectors in each block. So for $n > 2^m$ it is possible to zero $n - 2^m$ full vectors of size $m$ by applying one row operation for each vector. Using this method some row operations can zero up to $m$ entries at a time, diminishing the total number of row operations. By choosing $m = [\alpha \log_2(n)]$ (for arbitrary $0 < \alpha < 1$) they reach an asymptotic complexity of $n^2/(\alpha \log_2(n))$ in the worst case which meets the theoretical lower bound.

Our proposed algorithm can be seen as a direct improvement of [38, Algo. 1]. It comes from the following simple observation: given a row $i$ of our triangular operator and assuming that we follow a standard Gaussian elimination process, an upper bound on the number of row operations that will be applied to row $i$ during the synthesis is given by

$$ \#CNOTs = i - \min\{j \mid L[i, j] = 1\}. \qquad (1) $$

In other words, when zeroing the entries of a row, we have to focus first on the entries on the first columns and this can be done by minimizing the cost function given by Eq. (1). Once an entry is zeroed, we are sure that it is “treated” and will never be modified. Note on the other hand how zeroing entries in the last columns do not give us the guarantee that they would not be modified again during the synthesis. This simple observation is at the core of the Gaussian elimination algorithm: entries are acted upon one by one. It is also at the core of [38, Algo. 1] which improves on regular Gaussian elimination: entries are acted upon by fixed-size blocks. In this paper, we improve on [38, Algo. 1] by allowing for varying-size blocks. In other words, we do not fix a block size but at each iteration we let the greedy component of our algorithm choose the largest suitable block size.

Therefore we propose the following 3-step method:

1. choose among the rows with entries "1" in the left-most columns the two rows $i$ and $j$ that have the largest number of common left-non-zero-elements,
Overall GreedyGE is suited to dense, worst case operators, or operators that act on several hundred or thousands of qubits. For operators on a much smaller number of qubits, or when the structure of the operator is such that we can expect the resulting circuit to be small (for instance if the operator is sparse), GreedyGE does not particularly outperform other existing algorithms. Instead we show that cost minimization techniques, like the one introduced in [40], produce much better results. We review the work in [40] and we propose a new cost function that improves the range of validity of such cost minimization method.

Finally we apply our new methods to real world circuits. Plugged into a global Clifford+T quantum compiler, here the Tpar algorithm [5], we show that we can significantly improve the CNOT cost of reversible functions without worsening other metrics like the T-depth.

# 3 GreedyGE: a Greedy Gaussian Elimination Algorithm for Triangular Boolean Matrices

## 3.1 General Presentation of the Algorithm

Given a lower triangular operator $L$ — the upper case can be treated similarly — the Gaussian elimination algorithm can be summarized as follows: by applying elementary row operations $Row(i, j)$ with $i < j$ we zero the sub-diagonal elements of $L$ without changing its triangular shape. This process is performed column by column, starting from the first one. This way one can easily see that if the $k$ first columns are treated, applying row operations $Row(i, j)$ with $k < i < j$ will not change the treated columns as all their elements are 0. Since $L$ is invertible, when zeroing the $k$-th column the $k$-th row is necessarily equal to $L[k, :] = e_k^T$ hence one can always add the row $k$ to any row $j > k$ to zero the entry $L[j, k]$. This guarantees the good behavior of the algorithm for any input matrix.

Usually, a Gaussian elimination algorithm always performs the row operations $Row(k, j)$ when zeroing the $k$-th column. As one row operation ensures to zero only one element at a time, we need at most $\frac{n(n-1)}{2}$ row operations to zero every sub-diagonal elements of $L$, leading to a worst-case complexity of $O(n^2)$ for the synthesis of a generic linear reversible operator.

A first straightforward improvement is to authorize any row operation $Row(i, j), i < j$. This was exploited in [38, Algo. 1] : by partitioning the matrix of size $n$ into blocks of size $m$, the authors use the fact that there can only be at most $2^m$ different vectors in each block. So for $n > 2^m$ it is possible to zero $n - 2^m$ full vectors of size $m$ by applying one row operation for each vector. Using this method some row operations can zero up to $m$ entries at a time, diminishing the total number of row operations. By choosing $m = [\alpha \log_2(n)]$ (for arbitrary $0 < \alpha < 1$) they reach an asymptotic complexity of $n^2/(\alpha \log_2(n))$ in the worst case which meets the theoretical lower bound.

Our proposed algorithm can be seen as a direct improvement of [38, Algo. 1]. It comes from the following simple observation: given a row $i$ of our triangular operator and assuming that we follow a standard Gaussian elimination process, an upper bound on the number of row operations that will be applied to row $i$ during the synthesis is given by

$$ \#CNOTs = i - \min\{j \mid L[i, j] = 1\}. \qquad (1) $$

In other words, when zeroing the entries of a row, we have to focus first on the entries on the first columns and this can be done by minimizing the cost function given by Eq. (1). Once an entry is zeroed, we are sure that it is “treated” and will never be modified. Note on the other hand how zeroing entries in the last columns do not give us the guarantee that they would not be modified again during the synthesis. This simple observation is at the core of the Gaussian elimination algorithm: entries are acted upon one by one. It is also at the core of [38, Algo. 1] which improves on regular Gaussian elimination: entries are acted upon by fixed-size blocks. In this paper, we improve on [38, Algo. 1] by allowing for varying-size blocks. In other words, we do not fix a block size but at each iteration we let the greedy component of our algorithm choose the largest suitable block size.

Therefore we propose the following 3-step method:

1. choose among the rows with entries "1" in the left-most columns the two rows $i$ and $j$ that have the largest number of common left-non-zero-elements,
2. apply the row operation $Row(\min(i, j), \max(i, j))$,

3. repeat the first two steps until $L$ is the identity.

The pseudo-code of the algorithm is given in Algorithm 1. The time complexity of the algorithm mostly depends on step 1, i.e., the function SelectRowOperation. Actually, this step can be easily implemented iteratively on the columns :

* We start with the set of all the rows and, during the $k$-th step, we have in memory a set of rows having the same first $k-1$ entries.

* Then we separate those rows into two sets: those which have the $k$-th entry respectively equal to 0 and 1, corresponding respectively to the sets $set_0$ and $set_1$ in Algorithm 1. The rows in either $set_0$ or $set_1$ have the same first $k$ entries.

* We want to zero the maximum of 1 in priority so if $set_1$ contains 2 or more rows we continue with this set, otherwise we choose $set_0$ and go to step $k+1$.

By this process, the size of our set of lines always remains greater than 2 until we have only two lines: these are the two lines on which to do our row operation. Clearly, the algorithm is polynomial in the size of the matrix.

<caption>**Algorithm 1:** GreedyGE : Greedy Gaussian Elimination of a triangular operator $L$.</caption>

**Input:** $n \ge 0$, $L \in \mathbb{F}_2^{n \times n}$ lower triangular

**Output:** $C$ is a CNOT-circuit implementing $L$

**Function** *Synthesis*($L, n$)

$C \leftarrow []$

**while** $L \neq I_n$ **do**

set $\leftarrow SelectRowOperation(L, n)$

$i_0 \leftarrow \min(set[1], set[2])$

$j_0 \leftarrow \max(set[1], set[2])$

C.append(CNOT($i_0, j_0$))

$L[j_0, :] \leftarrow L[i_0, :] \oplus L[j_0, :]$

**end while**

**return** reverse($C$)

**Function** *SelectRowOperation*($L, n$)

set $\leftarrow [[1, n]]$

$j \leftarrow 1$

**while** $|set| > 2$ **do**

set$_0 \leftarrow \{i \in set \mid L[i, j] = 0\}$

set$_1 \leftarrow \{i \in set \mid L[i, j] = 1\}$

**if** $|set_1| < 2$ **then**

set $\leftarrow set_0$

**else**

set $\leftarrow set_1$

**end if**

$j \leftarrow j + 1$

**end while**

**return** set

Our algorithm belongs to the same family as the Gaussian elimination method and [38, Algo. 1] because we synthesize the operator column by column. However, this is an improvement over [38, Algo. 1] because we do not work with a fixed block size. At each step, we somewhat choose the largest block size possible to zero the largest number of elements in one row operation. We are then ensured that these entries will not be modified anymore. Thus this is also an improvement over cost minimization methods [40] that can take as cost function the number of ones in the matrix for
2. apply the row operation $Row(\min(i, j), \max(i, j))$,

3. repeat the first two steps until $L$ is the identity.

The pseudo-code of the algorithm is given in Algorithm 1. The time complexity of the algorithm mostly depends on step 1, i.e., the function SelectRowOperation. Actually, this step can be easily implemented iteratively on the columns :

* We start with the set of all the rows and, during the $k$-th step, we have in memory a set of rows having the same first $k-1$ entries.

* Then we separate those rows into two sets: those which have the $k$-th entry respectively equal to 0 and 1, corresponding respectively to the sets $set_0$ and $set_1$ in Algorithm 1. The rows in either $set_0$ or $set_1$ have the same first $k$ entries.

* We want to zero the maximum of 1 in priority so if $set_1$ contains 2 or more rows we continue with this set, otherwise we choose $set_0$ and go to step $k+1$.

By this process, the size of our set of lines always remains greater than 2 until we have only two lines: these are the two lines on which to do our row operation. Clearly, the algorithm is polynomial in the size of the matrix.

<caption>**Algorithm 1:** GreedyGE : Greedy Gaussian Elimination of a triangular operator $L$.</caption>

**Input:** $n \ge 0$, $L \in F_2^{n \times n}$ lower triangular

**Output:** $C$ is a CNOT-circuit implementing $L$

**Function** *Synthesis*($L, n$)

$C \leftarrow []$

**while** $L \neq I_n$ **do**

set $\leftarrow SelectRowOperation(L, n)$

$i_0 \leftarrow \min(set[1], set[2])$

$j_0 \leftarrow \max(set[1], set[2])$

C.append(CNOT($i_0, j_0$))

$L[j_0, :] \leftarrow L[i_0, :] \oplus L[j_0, :]$

**end while**

**return** reverse($C$)

**Function** *SelectRowOperation*($L, n$)

set $\leftarrow [[1, n]]$

$j \leftarrow 1$

**while** $|set| > 2$ **do**

set$_0 \leftarrow \{i \in set \mid L[i, j] = 0\}$

set$_1 \leftarrow \{i \in set \mid L[i, j] = 1\}$

**if** $|set_1| < 2$ **then**

set $\leftarrow set_0$

**else**

set $\leftarrow set_1$

**end if**

$j \leftarrow j + 1$

**end while**

**return** set

Our algorithm belongs to the same family as the Gaussian elimination method and [38, Algo. 1] because we synthesize the operator column by column. However, this is an improvement over [38, Algo. 1] because we do not work with a fixed block size. At each step, we somewhat choose the largest block size possible to zero the largest number of elements in one row operation. We are then ensured that these entries will not be modified anymore. Thus this is also an improvement over cost minimization methods [40] that can take as cost function the number of ones in the matrix for
instance. With such greedy methods, it may be possible that in one step more elements are zeroed
but it is not guaranteed that these elements will be left untouched thereafter. We keep a structure
in the synthesis which enforces the convergence of our greedy algorithm.

3.2 Improving the Time Complexity

When executing Algorithm 1 we find at each iteration the next row operation by selecting the rows
according to their number of common first elements. As a first approach, we keep the set of the most
promising rows until the size of the set is equal to 2. With a little more work we can in fact order
all the rows in one run and get the whole set of row operations required to zero the sub-diagonal
elements of the current column. It is more efficient than redoing the sorting work after each new
row operation because the selection algorithm will repeat the same calculations again and again but
without the presence of the modified rows. The new pseudo-code for a more efficient version of our
method is given Algorithm 2.

<caption>**Algorithm 2:** FastGreedyGE : Greedy Gaussian Elimination of a triangular operator *L*.</caption>

**Input:** $n \ge 0$, $L \in \mathbb{F}_2^{n \times n}$ lower triangular
**Output:** $C$ is a CNOT-circuit implementing $L$

**Function** *OptimizedSynthesis*(*L*, *n*)
**C** ← []
**for** *j* = 1 to n-1 **do**
  set ← {*i* ∈ [*j*, ..., *n*] | $L[i, j] = 1$}
  pairs, set = SelectAllRowOperations(*L*, *j* + 1, set)
  **for** pair = pairs **do**
    $i_0$ ← min(pair[1], pair[2])
    $j_0$ ← max(pair[1], pair[2])
    C.append(CNOT($i_0$, $j_0$))
    $L[j_0, :]$ ← $L[i_0, :] \oplus L[j_0, :]$
  **end for**
**end for**
**return** reverse(C)

**Function** *SelectAllRowOperations*(*L*, *j*, *set*)
**if** $|set| < 2$ **then**
  **return** $\emptyset$, set
**end if**
set$_0$ ← {*i* ∈ set | $L[i, j] = 0$}
set$_1$ ← {*i* ∈ set | $L[i, j] = 1$}
pairs$_0$, set$_0$ ← SelectAllRowOperations(*L*, *j* + 1, set$_0$)
pairs$_1$, set$_1$ ← SelectAllRowOperations(*L*, *j* + 1, set$_1$)
pairs ← [pairs$_0$, pairs$_1$]
**if** $|set_0| > 0$ **and** $|set_1| > 0$ **then**
  $i_0$ ← set$_0$[1]
  $i_1$ ← set$_1$[1]
  pairs ← [pairs, [min($i_0$, $i_1$), max($i_0$, $i_1$)]]
  set ← min($i_0$, $i_1$)
**else**
  **if** $|set_0| > 0$ **then**
    set ← set$_0$[1]
  **else**
    set ← set$_1$[1]
  **end if**
**end if**
**return** pairs, set
instance. With such greedy methods, it may be possible that in one step more elements are zeroed
but it is not guaranteed that these elements will be left untouched thereafter. We keep a structure
in the synthesis which enforces the convergence of our greedy algorithm.

## 3.2 Improving the Time Complexity

When executing Algorithm 1 we find at each iteration the next row operation by selecting the rows
according to their number of common first elements. As a first approach, we keep the set of the most
promising rows until the size of the set is equal to 2. With a little more work we can in fact order
all the rows in one run and get the whole set of row operations required to zero the sub-diagonal
elements of the current column. It is more efficient than redoing the sorting work after each new
row operation because the selection algorithm will repeat the same calculations again and again but
without the presence of the modified rows. The new pseudo-code for a more efficient version of our
method is given Algorithm 2.

<caption>**Algorithm 2:** FastGreedyGE : Greedy Gaussian Elimination of a triangular operator *L*.</caption>

**Input:** $n \ge 0$, $L \in \mathbb{F}_2^{n \times n}$ lower triangular
**Output:** $C$ is a CNOT-circuit implementing $L$

**Function** *OptimizedSynthesis*(*L*, *n*)
**C** ← []
**for** *j* = 1 to n-1 **do**
  set ← {*i* ∈ [*j*, ..., *n*] | $L[i, j] = 1$}
  pairs, set = SelectAllRowOperations(*L*, *j* + 1, set)
  **for** pair = pairs **do**
    $i_0$ ← min(pair[1], pair[2])
    $j_0$ ← max(pair[1], pair[2])
    C.append(CNOT($i_0$, $j_0$))
    $L[j_0, :]$ ← $L[i_0, :] \oplus L[j_0, :]$
  **end for**
**end for**
**return** reverse(C)

**Function** *SelectAllRowOperations*(*L*, *j*, *set*)
**if** $|set| < 2$ **then**
  **return** $\emptyset$, set
**end if**
set$_0$ ← {*i* ∈ set | $L[i, j] = 0$}
set$_1$ ← {*i* ∈ set | $L[i, j] = 1$}
pairs$_0$, set$_0$ ← SelectAllRowOperations(*L*, *j* + 1, set$_0$)
pairs$_1$, set$_1$ ← SelectAllRowOperations(*L*, *j* + 1, set$_1$)
pairs ← [pairs$_0$, pairs$_1$]
**if** $|set_0| > 0$ and $|set_1| > 0$ **then**
  $i_0$ ← set$_0$[1]
  $i_1$ ← set$_1$[1]
  pairs ← [pairs, [min($i_0$, $i_1$), max($i_0$, $i_1$)]]
  set ← min($i_0$, $i_1$)
**else**
  **if** $|set_0| > 0$ **then**
    set ← set$_0$[1]
  **else**
    set ← set$_1$[1]
  **end if**
**end if**
**return** pairs, set
The new version of SelectRowOperation, the function SelectAllRowOperations, is based on the idea that row operations should always be done, if possible, between rows belonging to the same sets. We implement this idea recursively on the columns: first, we only select the rows with a "1" entry in the first column. Then, after the creation of set0 and set1, we call recursively SelectAllRow-Operations on both sets: we have two sets of row operations that treat separately the rows with first entries "10" and "11". After the execution of SelectAllRowOperations, both set0 and set1 contains the unmodified rows. In both cases, there can be at most one row unmodified. If both sets have one row unmodified then we add another row operation Row(min(set0[1], set1[1]), max(set0[1], set1[1])) and the set returned contains min(set0[1], set1[1]). If only one set has an unmodified row then the set returned contains that row. We illustrate the behavior of our algorithm with the example given in Fig 1.

## 3.3 Bounding the CNOT Count

We denote with $C(n)$ the number of CNOTs required to synthesize a triangular operator $L$ of size $n$ with Algorithm 1. Given $1 \le k \le n$, we consider $c(n, k)$ the number of row operations required to synthesize the first $k$ columns.

Once the first $k$ columns are synthesized the $n \times k$ block matrix $L[\cdot, 1: k]$ is equal to the matrix $\begin{pmatrix} I_k \\ 0 \end{pmatrix}$ and we are left with the sub-matrix $L[k+1: end, k+1: end]$ to synthesize. Then we have

$$ \forall k \ge 1, C(n) \le c(n, k) + C(n-k) $$

and the total number of row operations to synthesize $L$ is upper bounded by

$$ C(n) \le \sum_{i=1}^{m} c \left( n - \sum_{j=1}^{i-1} k_j, k_i \right) \quad (2) $$

where $k_1, k_2, ..., k_m$ can represent any partition of $L$ into $m$ sub-blocks, i.e., $m$ positive integers such that $\sum_{i=1}^{m} k_i = n$. By considering the worst-case scenario for each block we do not take into consideration the side effects of the row operations that were applied on the first blocks and that could have an impact on the remaining matrix. Especially when looking strictly at one block, one can easily see that some row operations will only zero one element at a time in a block — the rightmost elements — but will certainly have an impact on the next block: by not considering this effect, we weaken our upper bound but the proof of the inequality (2) is straightforward.

We now turn to an estimation of an upper bound of $c(n, k)$. Considering a block of size $(n, k)$ and assuming that $k < \log_2(n)$, the algorithm process is the following:

* as there can be at most $2^k$ different bitstrings of $k$ bits, $n - 2^k$ row operations at most will be used to zero the duplicate rows.

* We are left with a rectangular block of size $(2^k, k)$. Using a similar argument we can zero $k-1$ bits of $2^{k-1}$ different rows by using one row operation for each, then the remaining bit on these rows can be zeroed with one row operation. We are now left with a block of size $(2^{k-1}, k)$, we zero $k-2$ bits of $2^{k-2}$ rows with one row operation each and the two remaining bits on these rows can be zeroed with two row operations. Repeating this process until the whole block has been reduced to $\begin{pmatrix} I \\ 0 \end{pmatrix}$, we perform at most

$$ 2^{k-1} \times (1+1) + 2^{k-2} \times (1+2) + 2^{k-3} \times (1+3) + \dots = 2^{k+1} \times \sum_{j=2}^{k+1} j/2^j \le 3 \times 2^k $$

row operations. We can save some row operations because the right upper triangular part of the block is already zeroed (as $L$ is triangular) but we neglect them for simplicity.
The new version of SelectRowOperation, the function SelectAllRowOperations, is based on the idea that row operations should always be done, if possible, between rows belonging to the same sets. We implement this idea recursively on the columns: first, we only select the rows with a "1" entry in the first column. Then, after the creation of set0 and set1, we call recursively SelectAllRow-Operations on both sets: we have two sets of row operations that treat separately the rows with first entries "10" and "11". After the execution of SelectAllRowOperations, both set0 and set1 contains the unmodified rows. In both cases, there can be at most one row unmodified. If both sets have one row unmodified then we add another row operation Row(min(set0[1], set1[1]), max(set0[1], set1[1])) and the set returned contains min(set0[1], set1[1]). If only one set has an unmodified row then the set returned contains that row. We illustrate the behavior of our algorithm with the example given in Fig 1.

## 3.3 Bounding the CNOT Count

We denote with $C(n)$ the number of CNOTs required to synthesize a triangular operator $L$ of size $n$ with Algorithm 1. Given $1 \le k \le n$, we consider $c(n, k)$ the number of row operations required to synthesize the first $k$ columns.

Once the first $k$ columns are synthesized the $n \times k$ block matrix $L[\cdot, 1: k]$ is equal to the matrix $\begin{pmatrix} I_k \\ 0 \end{pmatrix}$ and we are left with the sub-matrix $L[k+1: end, k+1: end]$ to synthesize. Then we have

$$ \forall k \ge 1, C(n) \le c(n, k) + C(n-k) $$

and the total number of row operations to synthesize $L$ is upper bounded by

$$ C(n) \le \sum_{i=1}^{m} c \left( n - \sum_{j=1}^{i-1} k_j, k_i \right) \quad (2) $$

where $k_1, k_2, ..., k_m$ can represent any partition of $L$ into $m$ sub-blocks, i.e., $m$ positive integers such that $\sum_{i=1}^{m} k_i = n$. By considering the worst-case scenario for each block we do not take into consideration the side effects of the row operations that were applied on the first blocks and that could have an impact on the remaining matrix. Especially when looking strictly at one block, one can easily see that some row operations will only zero one element at a time in a block — the rightmost elements — but will certainly have an impact on the next block: by not considering this effect, we weaken our upper bound but the proof of the inequality (2) is straightforward.

We now turn to an estimation of an upper bound of $c(n, k)$. Considering a block of size $(n, k)$ and assuming that $k < \log_2(n)$, the algorithm process is the following:

* as there can be at most $2^k$ different bitstrings of $k$ bits, $n - 2^k$ row operations at most will be used to zero the duplicate rows.

* We are left with a rectangular block of size $(2^k, k)$. Using a similar argument we can zero $k-1$ bits of $2^{k-1}$ different rows by using one row operation for each, then the remaining bit on these rows can be zeroed with one row operation. We are now left with a block of size $(2^{k-1}, k)$, we zero $k-2$ bits of $2^{k-2}$ rows with one row operation each and the two remaining bits on these rows can be zeroed with two row operations. Repeating this process until the whole block has been reduced to $\begin{pmatrix} I \\ 0 \end{pmatrix}$, we perform at most

$$ 2^{k-1} \times (1+1) + 2^{k-2} \times (1+2) + 2^{k-3} \times (1+3) + \dots = 2^{k+1} \times \sum_{j=2}^{k+1} j/2^j \le 3 \times 2^k $$

row operations. We can save some row operations because the right upper triangular part of the block is already zeroed (as $L$ is triangular) but we neglect them for simplicity.
$$L = \begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 \\
1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1
\end{pmatrix}$$

<figure><img src="image_1.png" /><figcaption>Figure 1: Illustration of the SelectAllRowOperations function on a specific example.</figcaption></figure>
$$L = \begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 \\
1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1
\end{pmatrix}$$

<figure><img src="image_2.png" /><figcaption>Figure 1: Illustration of the SelectAllRowOperations function on a specific example.</figcaption></figure>
So we have the estimation

$$c(n, k) \leq n + 2^{k+1}. \qquad (3)$$

From this we can derive an upper bound for $C(n)$. We replace Eq. (3) in Eq. (2):

$$C(n) \leq \sum_{i=1}^{m} \left( n - \sum_{j=1}^{i-1} k_j + 2^{k_i+1} \right).$$

As $n - \sum_{j=1}^{i-1} k_j = \sum_{j=i}^{m} k_j$ for any $i$ we rewrite the upper bound

$$C(n) \leq \sum_{i=1}^{m} \left( 2^{k_i+1} + \sum_{j=i}^{m} k_j \right) \\ C(n) \leq \sum_{i=1}^{m} (2^{k_i+1} + ik_i). \qquad (4)$$

For simplicity we assume that $k_1 = k_2 = \dots = k_{m-1} = k$. We also assume that $k_m = n - \sum_{i=1}^{m-1} k_i = k$ and $m = n/k$ because it does not affect the results.

Replacing in Eq. (4):

$$C(n) \leq m2^{k+1} + k \frac{m(m+1)}{2} = \frac{n^2}{2k} + \frac{n}{k} 2^{k+1} + \frac{n}{2} \qquad (5)$$

We now prove two things:

1. we show that our upper bound is better than the one given in [38].

2. we prove that the asymptotic complexity is at most $n^2/\log_2(n)$.

1. Taking $k = \alpha \log_2(n)$ with $0 < \alpha < 1$, we have

$$2 \times C(n) < \frac{n^2}{\alpha \log_2(n)} + \frac{4n^{1+\alpha}}{\alpha \log_2(n)} + n. \qquad (6)$$

where the multiplication by 2 gives an upper bound for the synthesis of a generic operator. This is a direct improvement over the upper bound in [38] given by

$$\text{total row op. [38]} \leq \frac{n^2}{\alpha \log_2(n)} + 2n^{1+\alpha} + \text{negligible terms} \qquad (7)$$

provided $\frac{4}{\alpha \log_2(n)} < 2$ which is the case if $n$ is sufficiently large. For instance, with $\alpha = 1/2$ then $n > 16$ is sufficient.

2. The coefficient of the leading term in Eq (6) is $1/\alpha$, yet taking the limit $\alpha \to 1$ in Eq. (6) leads to a complexity of $5n^2/\log_2(n)$. Instead, taking $k = \log_2(n) - p$ for some $p$, we have

$$2 \times C(n) < \frac{n^2}{\log_2(n)} \times \frac{1}{1 - p / \log_2(n)} \times \left( 1 + \frac{4}{2^p} \right) + n.$$

By choosing carefully $p$, for instance $p = \sqrt{\log_2(n)}$, we get

$$2 \times C(n) < a(n) \times \frac{n^2}{\log_2(n)} + n$$

with $a(n) = \frac{1}{1-1/\sqrt{\log_2(n)}} \times \left( 1 + \frac{4}{2\sqrt{\log_2(n)}} \right)$. As $a(n) \to 1$ this proves that the asymptotic complexity is $n^2/\log_2(n)$.
So we have the estimation

$$c(n, k) \le n + 2^{k+1}. \qquad (3)$$

From this we can derive an upper bound for $C(n)$. We replace Eq. (3) in Eq. (2):

$$C(n) \le \sum_{i=1}^{m} \left( n - \sum_{j=1}^{i-1} k_j + 2^{k_i+1} \right).$$

As $n - \sum_{j=1}^{i-1} k_j = \sum_{j=i}^{m} k_j$ for any $i$ we rewrite the upper bound

$$C(n) \le \sum_{i=1}^{m} \left( 2^{k_i+1} + \sum_{j=i}^{m} k_j \right) \\ C(n) \le \sum_{i=1}^{m} (2^{k_i+1} + ik_i). \qquad (4)$$

For simplicity we assume that $k_1 = k_2 = \dots = k_{m-1} = k$. We also assume that $k_m = n - \sum_{i=1}^{m-1} k_i = k$ and $m = n/k$ because it does not affect the results.

Replacing in Eq. (4):

$$C(n) \le m2^{k+1} + k \frac{m(m+1)}{2} = \frac{n^2}{2k} + \frac{n}{k} 2^{k+1} + \frac{n}{2} \qquad (5)$$

We now prove two things:

1. we show that our upper bound is better than the one given in [38].

2. we prove that the asymptotic complexity is at most $n^2/\log_2(n)$.

1. Taking $k = \alpha \log_2(n)$ with $0 < \alpha < 1$, we have

$$2 \times C(n) < \frac{n^2}{\alpha \log_2(n)} + \frac{4n^{1+\alpha}}{\alpha \log_2(n)} + n. \qquad (6)$$

where the multiplication by 2 gives an upper bound for the synthesis of a generic operator. This is a direct improvement over the upper bound in [38] given by

$$\text{total row op. [38]} \le \frac{n^2}{\alpha \log_2(n)} + 2n^{1+\alpha} + \text{negligible terms} \qquad (7)$$

provided $\frac{4}{\alpha \log_2(n)} < 2$ which is the case if $n$ is sufficiently large. For instance, with $\alpha = 1/2$ then $n > 16$ is sufficient.

2. The coefficient of the leading term in Eq (6) is $1/\alpha$, yet taking the limit $\alpha \to 1$ in Eq. (6) leads to a complexity of $5n^2/\log_2(n)$. Instead, taking $k = \log_2(n) - p$ for some $p$, we have

$$2 \times C(n) < \frac{n^2}{\log_2(n)} \times \frac{1}{1 - p/\log_2(n)} \times \left(1 + \frac{4}{2^p}\right) + n.$$

By choosing carefully $p$, for instance $p = \sqrt{\log_2(n)}$, we get

$$2 \times C(n) < a(n) \times \frac{n^2}{\log_2(n)} + n$$

with $a(n) = \frac{1}{1-1/\sqrt{\log_2(n)}} \times \left(1 + \frac{4}{2\sqrt{\log_2(n)}}\right)$. As $a(n) \to 1$ this proves that the asymptotic complexity is $n^2/\log_2(n)$.
We improve the upper bound Eq. (7) in two ways: we ensure that the coefficient of the leading term is 1 and we avoid other terms that distort the real complexity. Especially if one wants to have the best asymptotic complexity with [38, Algo. 1] by choosing $\alpha$ arbitrarily close to 1, the term $n^{1+\alpha}$ becomes arbitrarily close to $n^2$ and its impact is not negligible until very large values of $n$. Even with intermediate values of $n$, for example $n = 1000$, then $a(n) \approx 2.12$. To have the same leading term we have to choose $\alpha = 1/2.12$. With these values we now have

$$ \frac{2n^{1+\alpha} + n^2/(\alpha \log_2(n))}{n^2/(\alpha \log_2(n))} \approx 1.25 $$

which means that the term $2n^{1+\alpha}$ increases the upper bound by 25%.

**Discussion.** The main result we want to emphasize is that the upper bound in Eq. (4) is true for any partitioning of the matrix $L$. This means it performs better than any partitioning method unless a more efficient method for synthesizing one block is found. Notably, given $k_1 = k_2 = \dots = k_{m-1} = k$ the size of the block used for [38, Algo. 1], it is clear that the row operations done in [38, Algo. 1] to zero an entire k-bit row will also be performed by our algorithm. Then we are left with a sub-matrix to synthesize for which [38, Algo. 1] will use a Gaussian Elimination method whereas our algorithm will perform recursively by first zeroing the bitstrings of size $k-1$. In the worst case our algorithm will only zero one element at a time like the Gaussian elimination algorithm.

This gives insights about the advantage of GreedyGE over [38, Algo. 1]. When [38, Algo. 1] performs a standard Gaussian elimination process to zero some elements, we somewhat perform [38, Algo. 1] on a smaller sub-matrix. Thus, at these steps of the algorithm, we expect to have the same gain in the number of row operations than [38, Algo. 1] has compared to the classical Gaussian elimination algorithm. Consequently, although we cannot theoretically claim that our algorithm always generates shorter circuits than [38, Algo. 1] — as we cannot claim that [38, Algo. 1] always performs better than standard Gaussian elimination — we have strong confidence that our algorithm provides better results most of the time — for the same reasons that [38, Algo. 1] gives most of the time better results than the Gaussian elimination algorithm. This assertion is empirically verified in our benchmarks, see Chapter 6.

# 4 Extending GreedyGE to General Operators

So far we have presented an algorithm for the synthesis of triangular operators. To extend this to generic linear reversible operators A we give two strategies:

* we can modify our algorithm for triangular operators such that it transforms A into an upper triangular operator U on which we apply our unmodified algorithm,

* we can rely on an LU decomposition to factorize A into the product of two triangular operators. Then the concatenation of the circuits implementing U and L yields a circuit implementing A.

## 4.1 Modification of FastGreedyGE

Algorithm 2 works even if the input operator is not lower triangular. In the outer for-loop, during the j-th iteration the algorithm will zero the sub-diagonal elements of the j-th column provided that the element $A[j,j]$ is equal to 1. So all we need to do is adding an extra row operation to make sure that $A[j,j] = 1$ is satisfied. If $A[j,j] = 1$ then we do nothing otherwise we choose among the rows $\ll j + 1, n \gg$ whose j-th element is 1 the one that zeroes the largest number of right elements of the j-th row so that when executing FastGreedyGE on the future U operator we save some row operations. Overall this increases the CNOT count by at most $n$ so it is negligible in the derivation of the upper bound above.
We improve the upper bound Eq. (7) in two ways: we ensure that the coefficient of the leading term is 1 and we avoid other terms that distort the real complexity. Especially if one wants to have the best asymptotic complexity with [38, Algo. 1] by choosing $\alpha$ arbitrarily close to 1, the term $n^{1+\alpha}$ becomes arbitrarily close to $n^2$ and its impact is not negligible until very large values of $n$. Even with intermediate values of $n$, for example $n = 1000$, then $a(n) \approx 2.12$. To have the same leading term we have to choose $\alpha = 1/2.12$. With these values we now have

$$ \frac{2n^{1+\alpha} + n^2/(\alpha \log_2(n))}{n^2/(\alpha \log_2(n))} \approx 1.25 $$

which means that the term $2n^{1+\alpha}$ increases the upper bound by 25%.

**Discussion.** The main result we want to emphasize is that the upper bound in Eq. (4) is true for any partitioning of the matrix $L$. This means it performs better than any partitioning method unless a more efficient method for synthesizing one block is found. Notably, given $k_1 = k_2 = \dots = k_{m-1} = k$ the size of the block used for [38, Algo. 1], it is clear that the row operations done in [38, Algo. 1] to zero an entire k-bit row will also be performed by our algorithm. Then we are left with a sub-matrix to synthesize for which [38, Algo. 1] will use a Gaussian Elimination method whereas our algorithm will perform recursively by first zeroing the bitstrings of size $k-1$. In the worst case our algorithm will only zero one element at a time like the Gaussian elimination algorithm.

This gives insights about the advantage of GreedyGE over [38, Algo. 1]. When [38, Algo. 1] performs a standard Gaussian elimination process to zero some elements, we somewhat perform [38, Algo. 1] on a smaller sub-matrix. Thus, at these steps of the algorithm, we expect to have the same gain in the number of row operations than [38, Algo. 1] has compared to the classical Gaussian elimination algorithm. Consequently, although we cannot theoretically claim that our algorithm always generates shorter circuits than [38, Algo. 1] — as we cannot claim that [38, Algo. 1] always performs better than standard Gaussian elimination — we have strong confidence that our algorithm provides better results most of the time — for the same reasons that [38, Algo. 1] gives most of the time better results than the Gaussian elimination algorithm. This assertion is empirically verified in our benchmarks, see Chapter 6.

# 4 Extending GreedyGE to General Operators

So far we have presented an algorithm for the synthesis of triangular operators. To extend this to generic linear reversible operators A we give two strategies:

* we can modify our algorithm for triangular operators such that it transforms A into an upper triangular operator U on which we apply our unmodified algorithm,

* we can rely on an LU decomposition to factorize A into the product of two triangular operators. Then the concatenation of the circuits implementing U and L yields a circuit implementing A.

## 4.1 Modification of FastGreedyGE

Algorithm 2 works even if the input operator is not lower triangular. In the outer for-loop, during the j-th iteration the algorithm will zero the sub-diagonal elements of the j-th column provided that the element $A[j,j]$ is equal to 1. So all we need to do is adding an extra row operation to make sure that $A[j,j] = 1$ is satisfied. If $A[j,j] = 1$ then we do nothing otherwise we choose among the rows $[j+1, n]$ whose j-th element is 1 the one that zeroes the largest number of right elements of the j-th row so that when executing FastGreedyGE on the future U operator we save some row operations. Overall this increases the CNOT count by at most $n$ so it is negligible in the derivation of the upper bound above.
## 4.2 Optimizing the Choice of L and U

An LU decomposition provides a way to decompose an operator into two simpler sub-operators. Ideally, the path from the identity to the target operator given by the concatenation of the paths of two sub-operators would be close to the optimal path. In our case, it is very unlikely that an LU decomposition would give such an ideal decomposition because the structure of triangular operators is too specific. Nonetheless, the matrices L and U in the LU decomposition are not unique and we can optimize the factorization by choosing appropriate L and U operators such that we minimize the overall complexity of the final reversible circuit. In this section, we report several strategies to choose the matrices L and U.

If we allow row and column permutations, we can compute the LU decomposition of an operator A following this algorithm:

1. Choose a row vector $v = A[i, :]$ and a column $j$ for which $A[i, j] = 1$.

2. Set the first line of U to $v$ and set the first column of L to $A[\because, j]$.

3. Update the matrix A, first by left-applying the gate SWAP(i, 1) and right-applying the gate SWAP(j, 1). Then add the vector $v$ to every row $A[k, :]$ where $A[k, 1] = 1$. Finally we are left with a matrix A with zeroed first column and first row.

4. Repeat the algorithm on this updated A until we obtain the null matrix.

At the end of the algorithm we have the relation

$$P_1 A P_2 = LU$$

where $P_1, P_2$ are permutation matrices. $P_1$ is the concatenation of the SWAP gates that were left-applied to A and $P_2$ is the concatenation of the SWAP gates that were right-applied to A. After the synthesis of L and U we can commute the gates with $P_2$ and have

$$A = P_1^{-1} P_2^{-1} L' U'$$

and we transfer the permutation matrix $P_1^{-1} P_2^{-1}$ to the end of the total circuit. $L'$ and $U'$ are triangular operators up to a permutation of their rows and columns.

At each step of the algorithm, we have several choices for the row and column vectors. We aim to construct L and U such that their synthesis will give short circuits. To do so we tried different strategies:

* First, if we believe that sparse L and U matrices can be implemented with shorter circuits, a first approach consists in choosing the row and column with smallest Hamming weights: this is the "sparse" approach.

* Secondly, we can adopt a "minimizing cost" approach. If the updated matrix $A'$ minimizes a cost function then the synthesis of $A'$ will require a shorter circuit. We choose the cost function to be the number of ones and we choose among all the possible rows and columns the pair that minimizes the number of ones in $A'$.

These decompositions transform a general operator A into two operators L, U with specific structures. Triangular operators are easier to synthesize but this also limits the optimality of the solution. Because we force the algorithm to synthesize two matrices with a specific structure, it is very unlikely that we can perform an optimized synthesis by going through this forced path. This also gives insights into the question about the global optimality of our algorithm: even if we use an optimal algorithm for synthesizing a triangular operator it is very unlikely that we can get an optimal solution for the whole synthesis. Our algorithm gives asymptotic optimal results in the worst case but will be suboptimal for specific operators. Notably, if the operators can indeed be synthesized with a small circuit, direct greedy methods have shown encouraging results. In the next section, we will review the greedy method used in the literature and propose an extension of this framework to improve the scalability of this kind of algorithms.
## 4.2 Optimizing the Choice of L and U

An LU decomposition provides a way to decompose an operator into two simpler sub-operators. Ideally, the path from the identity to the target operator given by the concatenation of the paths of two sub-operators would be close to the optimal path. In our case, it is very unlikely that an LU decomposition would give such an ideal decomposition because the structure of triangular operators is too specific. Nonetheless, the matrices L and U in the LU decomposition are not unique and we can optimize the factorization by choosing appropriate L and U operators such that we minimize the overall complexity of the final reversible circuit. In this section, we report several strategies to choose the matrices L and U.

If we allow row and column permutations, we can compute the LU decomposition of an operator A following this algorithm:

1. Choose a row vector $v = A[i, :]$ and a column $j$ for which $A[i, j] = 1$.

2. Set the first line of U to $v$ and set the first column of L to $A[\because, j]$.

3. Update the matrix A, first by left-applying the gate SWAP($i, 1$) and right-applying the gate SWAP($j, 1$). Then add the vector $v$ to every row $A[k, :]$ where $A[k, 1] = 1$. Finally we are left with a matrix A with zeroed first column and first row.

4. Repeat the algorithm on this updated A until we obtain the null matrix.

At the end of the algorithm we have the relation

$$P_1 A P_2 = LU$$

where $P_1, P_2$ are permutation matrices. $P_1$ is the concatenation of the SWAP gates that were left-applied to A and $P_2$ is the concatenation of the SWAP gates that were right-applied to A. After the synthesis of L and U we can commute the gates with $P_2$ and have

$$A = P_1^{-1} P_2^{-1} L' U'$$

and we transfer the permutation matrix $P_1^{-1} P_2^{-1}$ to the end of the total circuit. $L'$ and $U'$ are triangular operators up to a permutation of their rows and columns.

At each step of the algorithm, we have several choices for the row and column vectors. We aim to construct L and U such that their synthesis will give short circuits. To do so we tried different strategies:

* First, if we believe that sparse L and U matrices can be implemented with shorter circuits, a first approach consists in choosing the row and column with smallest Hamming weights: this is the “sparse” approach.

* Secondly, we can adopt a "minimizing cost" approach. If the updated matrix $A'$ minimizes a cost function then the synthesis of $A'$ will require a shorter circuit. We choose the cost function to be the number of ones and we choose among all the possible rows and columns the pair that minimizes the number of ones in $A'$.

These decompositions transform a general operator A into two operators L, U with specific structures. Triangular operators are easier to synthesize but this also limits the optimality of the solution. Because we force the algorithm to synthesize two matrices with a specific structure, it is very unlikely that we can perform an optimized synthesis by going through this forced path. This also gives insights into the question about the global optimality of our algorithm: even if we use an optimal algorithm for synthesizing a triangular operator it is very unlikely that we can get an optimal solution for the whole synthesis. Our algorithm gives asymptotic optimal results in the worst case but will be suboptimal for specific operators. Notably, if the operators can indeed be synthesized with a small circuit, direct greedy methods have shown encouraging results. In the next section, we will review the greedy method used in the literature and propose an extension of this framework to improve the scalability of this kind of algorithms.
# 5 Pathfinding Based Algorithms

The problem of linear reversible circuit synthesis can fit into a more generic problem called "pathfinding". In a pathfinding problem, we are generally given a starting state, a target state, and a set of operators that dictates the reachable states from a specific state. Then the goal is to find a path from the starting state to the goal state and the shorter the path is, the better it is. The reformulation of linear reversible circuit synthesis into a pathfinding problem is straightforward: the starting state is the operator A we want to implement, the goal state is the identity operator and the available operators are all the elementary row and column operations.

This field of research in AI has been very active for the last decades and we can rely on many algorithms to solve our problem. The most famous one is probably the A\* algorithm and all its derivatives (IDA\* [22], Weighted A\* [23], Anytime A\* [26], etc.). These algorithms have been successfully used to solve toy problems (Rubik's cube, Tile puzzles, Hanoi towers, Top Spin puzzle) but also concrete problems in video games [2], robotics [26, 2], genomics [46, 15, 44, 18], planning [7, 15], etc. Yet we are quickly faced with some crucial limitations:

* First the size of the search space grows much faster in our case than in any of the cases mentioned above. To give an order of magnitude, in [43] they compare greedy search algorithms - a subclass of pathfinding algorithms known for providing suboptimal solutions very quickly - and they highlight time and memory limitations of some algorithms especially on the largest problem they ran on: the 48-puzzle. The 48-puzzle and its variations (8-puzzle, 15-puzzle) are sliding puzzles. In the case of the 48-puzzle, 48 tiles are arranged in a 7 × 7 square with one tile missing. The goal of the puzzle is to order the tiles by moving the empty space around. For this specific problem the authors of [43] show that the computational time for most of the pathfinding algorithms they consider increases substantially while providing solutions of poor quality. The number of different positions in the 48-puzzle is equal to 49!/2 ≈ 3 × 10⁶². This is less than the number of linear reversible functions on 15 qubits. As we expect to be able to synthesize circuits on 50 qubits and even more, it is clear that we cannot use all the pathfinding algorithms in the literature.

* Secondly we need a function that will evaluate the distance between the current state and the target state. The properties of this function, usually called the heuristic, will deeply influence the performance of the pathfinding algorithms. Its goal is to guide the search by giving priority to more promising states and prune a whole part of the search space. More generally there are two sources of improvement for a pathfinding algorithm: the accuracy of the heuristic function and the management of the path discovery, i.e., what strategy do you employ to explore the search space. If the latter can be quite independent of the problem, the former is very problem-specific and unfortunately to our knowledge no good heuristics exist that satisfy good theoretical properties. For instance, for A\* to provide an optimal solution we need the heuristic to be admissible and consistent, i.e., it must always underestimate the length of the optimal path and the value of the heuristic should always decrease of at most one after the application of one elementary operation. By taking a function that always returns 0 we have an admissible and consistent heuristic but the search will result in a brute-force search. Generally to obtain an admissible heuristic we can consider a simpler version of our problem and the optimal solution of this problem gives an underestimation of the distance to the target state. In the case of linear reversible circuits, the closest simplified subproblem we found is the Shortest Linear Straight-Line Program [8] but this problem is also NP-hard and cannot be approximated exactly by a polynomial algorithm.

For all these reasons, we believe that using the standard A\* algorithm or its derivatives is a dead end. Instead of that, we focused our work on greedy best-first search algorithms that can be seen as a cost minimization/discrete gradient descent approach. It has been shown that the heuristics that are efficient for this kind of search are different than the ones for A\* algorithms [42], so we expect that we can exploit the properties of the matrix A of our operator to guide our search.

To our knowledge, the cost minimization approach for linear reversible circuits synthesis has only been investigated in [40]. Yet, with their methods, the authors can only synthesize circuits on at most
# 5 Pathfinding Based Algorithms

The problem of linear reversible circuit synthesis can fit into a more generic problem called "pathfinding". In a pathfinding problem, we are generally given a starting state, a target state, and a set of operators that dictates the reachable states from a specific state. Then the goal is to find a path from the starting state to the goal state and the shorter the path is, the better it is. The reformulation of linear reversible circuit synthesis into a pathfinding problem is straightforward: the starting state is the operator A we want to implement, the goal state is the identity operator and the available operators are all the elementary row and column operations.

This field of research in AI has been very active for the last decades and we can rely on many algorithms to solve our problem. The most famous one is probably the A\* algorithm and all its derivatives (IDA\* [22], Weighted A\* [23], Anytime A\* [26], etc.). These algorithms have been successfully used to solve toy problems (Rubik's cube, Tile puzzles, Hanoi towers, Top Spin puzzle) but also concrete problems in video games [2], robotics [26, 2], genomics [46, 15, 44, 18], planning [7, 15], etc. Yet we are quickly faced with some crucial limitations:

* First the size of the search space grows much faster in our case than in any of the cases mentioned above. To give an order of magnitude, in [43] they compare greedy search algorithms - a subclass of pathfinding algorithms known for providing suboptimal solutions very quickly - and they highlight time and memory limitations of some algorithms especially on the largest problem they ran on: the 48-puzzle. The 48-puzzle and its variations (8-puzzle, 15-puzzle) are sliding puzzles. In the case of the 48-puzzle, 48 tiles are arranged in a 7 × 7 square with one tile missing. The goal of the puzzle is to order the tiles by moving the empty space around. For this specific problem the authors of [43] show that the computational time for most of the pathfinding algorithms they consider increases substantially while providing solutions of poor quality. The number of different positions in the 48-puzzle is equal to 49!/2 ≈ 3 × 10⁶². This is less than the number of linear reversible functions on 15 qubits. As we expect to be able to synthesize circuits on 50 qubits and even more, it is clear that we cannot use all the pathfinding algorithms in the literature.

* Secondly we need a function that will evaluate the distance between the current state and the target state. The properties of this function, usually called the heuristic, will deeply influence the performance of the pathfinding algorithms. Its goal is to guide the search by giving priority to more promising states and prune a whole part of the search space. More generally there are two sources of improvement for a pathfinding algorithm: the accuracy of the heuristic function and the management of the path discovery, i.e., what strategy do you employ to explore the search space. If the latter can be quite independent of the problem, the former is very problem-specific and unfortunately to our knowledge no good heuristics exist that satisfy good theoretical properties. For instance, for A\* to provide an optimal solution we need the heuristic to be admissible and consistent, i.e., it must always underestimate the length of the optimal path and the value of the heuristic should always decrease of at most one after the application of one elementary operation. By taking a function that always returns 0 we have an admissible and consistent heuristic but the search will result in a brute-force search. Generally to obtain an admissible heuristic we can consider a simpler version of our problem and the optimal solution of this problem gives an underestimation of the distance to the target state. In the case of linear reversible circuits, the closest simplified subproblem we found is the Shortest Linear Straight-Line Program [8] but this problem is also NP-hard and cannot be approximated exactly by a polynomial algorithm.

For all these reasons, we believe that using the standard A\* algorithm or its derivatives is a dead end. Instead of that, we focused our work on greedy best-first search algorithms that can be seen as a cost minimization/discrete gradient descent approach. It has been shown that the heuristics that are efficient for this kind of search are different than the ones for A\* algorithms [42], so we expect that we can exploit the properties of the matrix A of our operator to guide our search.

To our knowledge, the cost minimization approach for linear reversible circuits synthesis has only been investigated in [40]. Yet, with their methods, the authors can only synthesize circuits on at most
25 qubits. More crucially, they did not investigate the behavior of their methods when the resulting circuits are supposed to be small. According to us, this is a behavior that has to be considered because as we will see the results of the methods drastically change depending on the size of the optimal circuits.

We consider two different heuristic functions to guide our search. The first one, already used in [40], is the function

$$h_{sum}(A) = \sum_{i,j} a_{i,j}$$

that is to say the number of ones in the matrix A. We also propose a new cost function to solve this problem, it is defined by

$$h_{prod}(A) = \sum_{i=1}^{n} \log \left( \sum_{j=1}^{n} a_{i,j} \right)$$

which corresponds to the log of the product of the number of ones on each row. These two cost functions reach their minimum when A is a permutation matrix, motivating their use in a cost minimization process. If the cost function $h_{sum}$ seems the first natural choice, we propose the cost function $h_{prod}$ because it gives priority to "almost done" rows. Namely, if one row has only a few nonzero entries, the minimization process with $h_{prod}$ will treat this row in priority and then it will not modify it anymore. This enables to avoid a problem which one meets with the cost function $h_{sum}$ where one ends up with a very sparse matrix but where the rows and columns have few nonzero common entries. This type of matrix represents a local minimum from which it can be difficult to escape. With this new cost function, as we put an additional priority on the rows with few remaining nonzero entries, we avoid this pitfall.

An important improvement given in [40] is to add the value of the cost function applied to the inverse as well, i.e.,

$$H_{sum}(A) = h_{sum}(A) + h_{sum}(A^{-1}),$$

$$H_{prod}(A) = h_{prod}(A) + h_{prod}(A^{-1}).$$

Again, these two new cost functions are minimum when A is a permutation. As we will see adding the cost value of the inverse tightens the possible paths and can improve the results because we escape more easily from local minima during the search.

We now give a few details on our implementation. We directly work on a cost matrix that stores the impact of each possible CNOT on the cost function. Namely let M be such matrix, then $M[i,j] = h(E_{ij}A) - h(A)$ where $h \in \{h_{sum}, h_{prod}\}$. We can define similar cost matrices for $A^{-1}$ and for column operations. Overall we have four matrices $M_{A, row}$, $M_{A, col}$, $M_{A^{-1}, row}$, $M_{A^{-1}, col}$. Note that $(E_{ij}A)^{-1} = A^{-1}E_{ij}$ so a row operation Row(i, j) on A is a column operation Col(j, i) on $A^{-1}$. The cost minimization algorithm is simple if we work with such matrices: at each iteration we look for the pair (i, j) that minimizes $min(M_{A, row}[i, j] + M_{A^{-1}, col}[j, i], M_{A, col}[i, j] + M_{A^{-1}, row}[j, i])$, we update A and $A^{-1}$ and we pursue the algorithm until A is a permutation matrix. The advantage of working on cost matrices rather than directly on A is that the update of the M's is cheaper than updating A and computing the costs. For instance, suppose we apply Row(i, j) to A, then if $h = h_{sum}$ the impact on the cost function of any row operation that does not involve row j will be the same than before the application of Row(i, j). This means that we only need to update $M_{A, Row}[i, j]$, $M_{A, Row}[j, i]$, $M_{A^{-1}, Col}[i, j]$, $M_{A^{-1}, Col}[j, i]$ for $i = 1..n$. The updates of $M_{A, Col}$ and $M_{A^{-1}, Row}$ are also simpler because only one element of each column of A has been modified. However, for our new cost function the updates are not that simple and it will have an impact on the computational time.

With cost minimization techniques it is not rare to fall into local minima. In that case we simply select among the best operations a random one and pursue the search. If the number of iterations exceeds a certain number then we consider that the algorithm is stuck in a local minimum and we stop it.

# 6 Benchmarks

This section presents our experimental results. We have the following algorithms to benchmark:
25 qubits. More crucially, they did not investigate the behavior of their methods when the resulting circuits are supposed to be small. According to us, this is a behavior that has to be considered because as we will see the results of the methods drastically change depending on the size of the optimal circuits.

We consider two different heuristic functions to guide our search. The first one, already used in [40], is the function

$$h_{sum}(A) = \sum_{i,j} a_{i,j}$$

that is to say the number of ones in the matrix A. We also propose a new cost function to solve this problem, it is defined by

$$h_{prod}(A) = \sum_{i=1}^{n} \log \left( \sum_{j=1}^{n} a_{i,j} \right)$$

which corresponds to the log of the product of the number of ones on each row. These two cost functions reach their minimum when A is a permutation matrix, motivating their use in a cost minimization process. If the cost function $h_{sum}$ seems the first natural choice, we propose the cost function $h_{prod}$ because it gives priority to "almost done" rows. Namely, if one row has only a few nonzero entries, the minimization process with $h_{prod}$ will treat this row in priority and then it will not modify it anymore. This enables to avoid a problem which one meets with the cost function $h_{sum}$ where one ends up with a very sparse matrix but where the rows and columns have few nonzero common entries. This type of matrix represents a local minimum from which it can be difficult to escape. With this new cost function, as we put an additional priority on the rows with few remaining nonzero entries, we avoid this pitfall.

An important improvement given in [40] is to add the value of the cost function applied to the inverse as well, i.e.,

$$H_{sum}(A) = h_{sum}(A) + h_{sum}(A^{-1}),$$

$$H_{prod}(A) = h_{prod}(A) + h_{prod}(A^{-1}).$$

Again, these two new cost functions are minimum when A is a permutation. As we will see adding the cost value of the inverse tightens the possible paths and can improve the results because we escape more easily from local minima during the search.

We now give a few details on our implementation. We directly work on a cost matrix that stores the impact of each possible CNOT on the cost function. Namely let M be such matrix, then $M[i,j] = h(E_{ij}A) - h(A)$ where $h \in \{h_{sum}, h_{prod}\}$. We can define similar cost matrices for $A^{-1}$ and for column operations. Overall we have four matrices $M_{A, row}$, $M_{A, col}$, $M_{A^{-1}, row}$, $M_{A^{-1}, col}$. Note that $(E_{ij}A)^{-1} = A^{-1}E_{ij}$ so a row operation Row$(i, j)$ on A is a column operation Col$(j, i)$ on $A^{-1}$. The cost minimization algorithm is simple if we work with such matrices: at each iteration we look for the pair $(i, j)$ that minimizes $min(M_{A, row}[i, j] + M_{A^{-1}, col}[j, i], M_{A, col}[i, j] + M_{A^{-1}, row}[j, i])$, we update A and $A^{-1}$ and we pursue the algorithm until A is a permutation matrix. The advantage of working on cost matrices rather than directly on A is that the update of the M's is cheaper than updating A and computing the costs. For instance, suppose we apply Row$(i, j)$ to A, then if $h = h_{sum}$ the impact on the cost function of any row operation that does not involve row j will be the same than before the application of Row$(i, j)$. This means that we only need to update $M_{A, Row}[i, j]$, $M_{A, Row}[j, i]$, $M_{A^{-1}, Col}[i, j]$, $M_{A^{-1}, Col}[j, i]$ for $i = 1..n$. The updates of $M_{A, Col}$ and $M_{A^{-1}, Row}$ are also simpler because only one element of each column of A has been modified. However, for our new cost function the updates are not that simple and it will have an impact on the computational time.

With cost minimization techniques it is not rare to fall into local minima. In that case we simply select among the best operations a random one and pursue the search. If the number of iterations exceeds a certain number then we consider that the algorithm is stuck in a local minimum and we stop it.

# 6 Benchmarks

This section presents our experimental results. We have the following algorithms to benchmark:
* GreedyGE from Sections 3 and 4,

* cost minimization techniques from Section 5,

The state-of-the-art algorithms are the following:

* The PMH algorithm [38, Algo. 1],

* The algorithm based on the syndrome decoding problem from [9].

Two kinds of datasets are used to benchmark our algorithms:

* First, a set of random operators. The test on random operators gives an overview of the average performance of our algorithm. We generate random operators by creating random CNOT circuits. Our routine takes two inputs: the number of qubit $n$ and the number of CNOT gates $k$ in the random circuit. Each CNOT is randomly placed by selecting a random control and a random target and the simulation of the circuit gives a random operator. Empirically we noticed that when $k$ is sufficiently large – $k = n^2$ is enough – then the operators generated have strong probability to represent the worst case scenario.

* Secondly, a set of reversible functions, given as circuits, taken from Matthew Amy's github repository [3]. This experiment shows how our algorithms can optimize useful quantum algorithms in the literature like the Galois Field multipliers, integer addition, Hamming coding functions, the hidden weighted bit functions, etc.

To evaluate the performance of our algorithms for the random set, two types of experiments are conducted:

1. a worst-case asymptotic experiment, namely for increasing problem sizes $n$ we generate circuits with $n^2$ gates and we compute the average number of gates for each problem size. This experiment reveals the asymptotic behavior of the algorithms and gives insights about strict upper bounds on their performance.

2. a close-to-optimal experiment, namely for one specific problem size we generate operators with different number of gates to show how close to optimal our algorithms are if the optimal circuits are expected to be smaller than the worst case.

All our algorithms are implemented in Julia [6] and executed on the ATOS QLM (Quantum Learning Machine) whose processor is an Intel Xeon(R) E7-8890 v4 at 2.4 GHz.

# 6.1 Random Operators

## 6.1.1 GreedyGE

First, we present the worst-case asymptotic experiment with the following algorithms:

* GreedyGE with standard LU decomposition,

* Syndrome decoding with the cost minimization heuristic with unlimited width and depth 1,

* Syndrome decoding with the integer programming solver (Coin-or branch and cut solver),

* Syndrome decoding with the cost minimization heuristic ($width=Inf, depth=1$) and 50 random changes of basis, the "Information Set Decoding" (ISD) case.

* Syndrome decoding with the cost minimization heuristic with width 60 and depth 2,

* Syndrome decoding with the cost minimization heuristic with width 15 and depth 3,
* GreedyGE from Sections 3 and 4,

* cost minimization techniques from Section 5,

The state-of-the-art algorithms are the following:

* The PMH algorithm [38, Algo. 1],

* The algorithm based on the syndrome decoding problem from [9].

Two kinds of datasets are used to benchmark our algorithms:

* First, a set of random operators. The test on random operators gives an overview of the average performance of our algorithm. We generate random operators by creating random CNOT circuits. Our routine takes two inputs: the number of qubit $n$ and the number of CNOT gates $k$ in the random circuit. Each CNOT is randomly placed by selecting a random control and a random target and the simulation of the circuit gives a random operator. Empirically we noticed that when $k$ is sufficiently large – $k = n^2$ is enough – then the operators generated have strong probability to represent the worst case scenario.

* Secondly, a set of reversible functions, given as circuits, taken from Matthew Amy's github repository [3]. This experiment shows how our algorithms can optimize useful quantum algorithms in the literature like the Galois Field multipliers, integer addition, Hamming coding functions, the hidden weighted bit functions, etc.

To evaluate the performance of our algorithms for the random set, two types of experiments are conducted:

1. a worst-case asymptotic experiment, namely for increasing problem sizes $n$ we generate circuits with $n^2$ gates and we compute the average number of gates for each problem size. This experiment reveals the asymptotic behavior of the algorithms and gives insights about strict upper bounds on their performance.

2. a close-to-optimal experiment, namely for one specific problem size we generate operators with different number of gates to show how close to optimal our algorithms are if the optimal circuits are expected to be smaller than the worst case.

All our algorithms are implemented in Julia [6] and executed on the ATOS QLM (Quantum Learning Machine) whose processor is an Intel Xeon(R) E7-8890 v4 at 2.4 GHz.

# 6.1 Random Operators

## 6.1.1 GreedyGE

First, we present the worst-case asymptotic experiment with the following algorithms:

* GreedyGE with standard LU decomposition,

* Syndrome decoding with the cost minimization heuristic with unlimited width and depth 1,

* Syndrome decoding with the integer programming solver (Coin-or branch and cut solver),

* Syndrome decoding with the cost minimization heuristic ($width=Inf, depth=1$) and 50 random changes of basis, the "Information Set Decoding" (ISD) case.

* Syndrome decoding with the cost minimization heuristic with width 60 and depth 2,

* Syndrome decoding with the cost minimization heuristic with width 15 and depth 3,
<figure><img src="image_2.png" /><figcaption>Figure 2: Average performance of GreedyGE and the Syndrome Decoding based algorithms versus the PMH algorithm.</figcaption></figure>

<table><caption>Table 1: Computational time of GreedyGE vs PMH and standard Gaussian elimination algorithms.</caption><thead><tr><th rowspan="2">Algorithm</th><th colspan="5">Average computational time (s)</th></tr><tr><th>n = 10</th><th>n = 100</th><th>n = 500</th><th>n = 1000</th><th>n = 5000</th></tr></thead><tbody><tr><td>Gaussian elimination</td><td>0.00004</td><td>0.00125</td><td>0.14</td><td>1.2</td><td>140</td></tr><tr><td>PMH algorithm</td><td>0.00015</td><td>0.006</td><td>0.75</td><td>7</td><td>980</td></tr><tr><td>GreedyGE</td><td>0.00015</td><td>0.0035</td><td>0.1</td><td>0.6</td><td>45</td></tr></tbody></table>

The results are given in Fig 2. For the sake of clarity, instead of showing the circuit size we plot the ratio between the circuit size given by our method and the circuit size given by the PMH algorithm. So if the ratio is below 1 this means that we outperform the state-of-the art method [38, Algo. 1]. We also have a better view of which algorithm is better in which qubit range. We stopped the calculations when the running time was too large for producing benchmarks within several hours.

Overall, for the considered range of qubits, GreedyGE outperforms [38, Algo. 1]. As the number of qubits increases the syndrome decoding based algorithm performs worse and GreedyGE eventually produces the shortest circuits when $n > 120$. Notably, the average gain over the PMH algorithm stabilizes around 25%. On the other hand the syndrome decoding based algorithms performances deteriorate as $n$ increases or the algorithm cannot terminate when the heuristic is too costly. Therefore, for large $n$, GreedyGE is the best method so far. GreedyGE is also fast: we compare the computational time of GreedyGE against the standard Gaussian elimination and the PMH algorithm. The results are given in Table 1. Not only GreedyGE produces the smallest circuits but in addition it is the fastest method to our knowledge.

Next, we show the impact of the choice of the LU decomposition. We provide results with GreedyGE considering it can be directly transposed to the syndrome decoding based algorithms as well. We perform the close-to-optimal experiment with the GreedyGE and three different LU decompositions:

* a standard LU decomposition for matrix in $F_2$, taken from the Julia package Nemo [10],

* the LU decomposition algorithm with the "sparse" strategy,

* the LU decomposition algorithm with the "cost minimization" strategy.
<figure><img src="image_3.png" /><figcaption>Figure 2: Average performance of GreedyGE and the Syndrome Decoding based algorithms versus the PMH algorithm.</figcaption></figure>

<table><caption>Table 1: Computational time of GreedyGE vs PMH and standard Gaussian elimination algorithms.</caption><thead><tr><th rowspan="2">Algorithm</th><th colspan="5">Average computational time (s)</th></tr><tr><th>n = 10</th><th>n = 100</th><th>n = 500</th><th>n = 1000</th><th>n = 5000</th></tr></thead><tbody><tr><td>Gaussian elimination</td><td>0.00004</td><td>0.00125</td><td>0.14</td><td>1.2</td><td>140</td></tr><tr><td>PMH algorithm</td><td>0.00015</td><td>0.006</td><td>0.75</td><td>7</td><td>980</td></tr><tr><td>GreedyGE</td><td>0.00015</td><td>0.0035</td><td>0.1</td><td>0.6</td><td>45</td></tr></tbody></table>

The results are given in Fig 2. For the sake of clarity, instead of showing the circuit size we plot the ratio between the circuit size given by our method and the circuit size given by the PMH algorithm. So if the ratio is below 1 this means that we outperform the state-of-the art method [38, Algo. 1]. We also have a better view of which algorithm is better in which qubit range. We stopped the calculations when the running time was too large for producing benchmarks within several hours.

Overall, for the considered range of qubits, GreedyGE outperforms [38, Algo. 1]. As the number of qubits increases the syndrome decoding based algorithm performs worse and GreedyGE eventually produces the shortest circuits when $n > 120$. Notably, the average gain over the PMH algorithm stabilizes around 25%. On the other hand the syndrome decoding based algorithms performances deteriorate as $n$ increases or the algorithm cannot terminate when the heuristic is too costly. Therefore, for large $n$, GreedyGE is the best method so far. GreedyGE is also fast: we compare the computational time of GreedyGE against the standard Gaussian elimination and the PMH algorithm. The results are given in Table 1. Not only GreedyGE produces the smallest circuits but in addition it is the fastest method to our knowledge.

Next, we show the impact of the choice of the LU decomposition. We provide results with GreedyGE considering it can be directly transposed to the syndrome decoding based algorithms as well. We perform the close-to-optimal experiment with the GreedyGE and three different LU decompositions:

* a standard LU decomposition for matrix in $F_2$, taken from the Julia package Nemo [10],

* the LU decomposition algorithm with the "sparse" strategy,

* the LU decomposition algorithm with the "cost minimization" strategy.
<figure><img src="image_3.png" /><figcaption>Figure 3: Performance of GreedyGE with different LU decompositions vs Syndrome Decoding on 60 qubits for different input circuit sizes.</figcaption></figure>

The experiment is done on 60 qubits. We also add the best method for this problem size: the syndrome decoding based algorithm with the "Information Set Decoding" strategy. The results are given in Fig 3. Computing more efficient LU decompositions has almost no effect on the worst-case results but provides some improvements when the input circuits are smaller. There is no significant difference between the two strategies "sparse" and "cost minimization" in terms of circuit sizes but the running time is much lower for the sparse approach so we would privilege it. This improvement also benefits the syndrome decoding based method as it also relies on an LU decomposition. On the other hand we also see that there is no obvious advantage of using GreedyGE instead of the syndrome decoding based methods when the optimal circuit is expected to be small.

### 6.1.2 Path Finding Methods

We now evaluate the performance of purely greedy methods. We remind that we have four cost functions to study:

$$ \bullet h_{sum}(A) = \sum_{i,j} a_{i,j}, $$

$$ \bullet h_{prod}(A) = \sum_{i=1}^{n} \log (\sum_{j=1}^{n} a_{i,j}), $$

$$ \bullet H_{sum}(A) = h_{sum}(A) + h_{sum}(A^{-1}), $$

$$ \bullet H_{prod}(A) = h_{prod}(A) + h_{prod}(A^{-1}). $$

First, we show the asymptotic behavior of those four methods. The results are given in Fig 4. The first graph in Fig 4a shows that the cost function $h_{sum}$ does not scale well with the number of qubits so we decide to remove it for clarity. The new graph is given in Fig 4b. We notice two things: first, the cost function $H_{prod}$ always underperforms $h_{prod}$, secondly both $H_{sum}$ and $h_{prod}$ outperform our syndrome decoding based algorithm for small problem sizes ($n < 30$) but with an advantage for $H_{sum}$ when $n < 25$. There is a thin window — between 25 and 30 qubits — where it is preferable to use $h_{prod}$ instead of $H_{sum}$.

The results given in Fig 4 are mainly there to discredit two of the four cost functions: $h_{sum}$ and $H_{prod}$. The result that really interests us is that of the close-to-optimal experiment, here on 50 qubits and given in Fig 5. For this problem size on the worst case the syndrome decoding based algorithm outperforms our greedy methods. But when we are not in the worst case the results are completely different: the greedy methods follow more faithfully the bound $y = x$ than the syndrome decoding
<figure><img src="image_4.png" /><figcaption>Figure 3: Performance of GreedyGE with different LU decompositions vs Syndrome Decoding on 60 qubits for different input circuit sizes.</figcaption></figure>

The experiment is done on 60 qubits. We also add the best method for this problem size: the syndrome decoding based algorithm with the "Information Set Decoding" strategy. The results are given in Fig 3. Computing more efficient LU decompositions has almost no effect on the worst-case results but provides some improvements when the input circuits are smaller. There is no significant difference between the two strategies "sparse" and "cost minimization" in terms of circuit sizes but the running time is much lower for the sparse approach so we would privilege it. This improvement also benefits the syndrome decoding based method as it also relies on an LU decomposition. On the other hand we also see that there is no obvious advantage of using GreedyGE instead of the syndrome decoding based methods when the optimal circuit is expected to be small.

### 6.1.2 Path Finding Methods

We now evaluate the performance of purely greedy methods. We remind that we have four cost functions to study:

$$h_{sum}(A) = \sum_{i,j} a_{i,j},$$

$$h_{prod}(A) = \sum_{i=1}^{n} \log (\sum_{j=1}^{n} a_{i,j}),$$

$$H_{sum}(A) = h_{sum}(A) + h_{sum}(A^{-1}),$$

$$H_{prod}(A) = h_{prod}(A) + h_{prod}(A^{-1}).$$

First, we show the asymptotic behavior of those four methods. The results are given in Fig 4. The first graph in Fig 4a shows that the cost function $h_{sum}$ does not scale well with the number of qubits so we decide to remove it for clarity. The new graph is given in Fig 4b. We notice two things: first, the cost function $H_{prod}$ always underperforms $h_{prod}$, secondly both $H_{sum}$ and $h_{prod}$ outperform our syndrome decoding based algorithm for small problem sizes ($n < 30$) but with an advantage for $H_{sum}$ when $n < 25$. There is a thin window — between 25 and 30 qubits — where it is preferable to use $h_{prod}$ instead of $H_{sum}$.

The results given in Fig 4 are mainly there to discredit two of the four cost functions: $h_{sum}$ and $H_{prod}$. The result that really interests us is that of the close-to-optimal experiment, here on 50 qubits and given in Fig 5. For this problem size on the worst case the syndrome decoding based algorithm outperforms our greedy methods. But when we are not in the worst case the results are completely different: the greedy methods follow more faithfully the bound $y = x$ than the syndrome decoding
<figure><img src="image_4.png" /><figcaption>(a) Average performance of {$h_{sum}$, $h_{prod}$, $H_{sum}$, $H_{prod}$} vs Syndrome decoding (Information Set Decoding).</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>(b) Same graph as in Fig 4a without $h_{sum}$.</figcaption></figure>

Figure 4: Average performance of Cost minimization techniques vs Syndrome decoding (Information Set Decoding).
<figure><img src="image_5.png" /><figcaption>(a) Average performance of {$h_{sum}$, $h_{prod}$, $H_{sum}$, $H_{prod}$} vs Syndrome decoding (Information Set Decoding).</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>(b) Same graph as in Fig 4a without $h_{sum}$.</figcaption></figure>

Figure 4: Average performance of Cost minimization techniques vs Syndrome decoding (Information Set Decoding).
<figure><img src="image_6.png" /><figcaption>Figure 5: Performance of Cost minimization techniques vs Syndrome Decoding on 50 qubits for different input circuit sizes.</figcaption></figure>

based algorithm. We have to wait input circuits of size 300 for the syndrome decoding algorithm to be better. The greedy algorithm based on the cost function $h_{prod}$ produces much more stable results than the one with the cost function $H_{sum}$. For the cost function $H_{sum}$ the variance is extremely large because the method struggles finding a global minimum. However, it is $H_{sum}$ that produces the best results most of the time in the range of size 0 – 300. Again there is a thin window where it may be relevant to use $h_{prod}$ instead of $H_{sum}$.

### 6.1.3 Conclusion: Combining the Methods

Each method has its own range of validity:

* GreedyGE is suited when the number of qubits exceeds 120, it outperforms the PMH algorithm and our other algorithms in both circuit size and computational time.

* The syndrome decoding based algorithms must be used for intermediate problem sizes ($30 < n < 120$) with the best possible solver of the syndrome decoding problem (in order: integer programming, Information Set Decoding if $n < 70$, maximum depth otherwise). Both GreedyGE and the family of syndrome decoding based algorithms are state of the art in a worst case scenario.

* When the output circuit is expected to be small, or when $n < 30$, then direct greedy methods have shown to produce the best results. The proposal of a new cost function paid off as this offers a more scalable direct greedy search. However, the moment when our new custom function outperforms the one proposed in [40] coincides with the moment when the syndrome decoding based algorithm also outperforms the direct greedy search. More investigation needs to be done to clarify which cost function should be preferred and when.

Given the variety of methods, each providing the best results in particular cases, the best method when trying to synthesize an operator would be simply to test each method and to keep the best result. Except for the direct greedy methods, the computational time of each method is well understood. Given a specific problem size, it is easy to know which method can be used and how long it will take. It is more delicate with the direct greedy methods, we have to set a limit in the maximum number of iterations before considering that the search will not converge to a solution.
<figure><img src="image_7.png" /><figcaption>Figure 5: Performance of Cost minimization techniques vs Syndrome Decoding on 50 qubits for different input circuit sizes.</figcaption></figure>

based algorithm. We have to wait input circuits of size 300 for the syndrome decoding algorithm to be better. The greedy algorithm based on the cost function $h_{prod}$ produces much more stable results than the one with the cost function $H_{sum}$. For the cost function $H_{sum}$ the variance is extremely large because the method struggles finding a global minimum. However, it is $H_{sum}$ that produces the best results most of the time in the range of size 0 – 300. Again there is a thin window where it may be relevant to use $h_{prod}$ instead of $H_{sum}$.

### 6.1.3 Conclusion: Combining the Methods

Each method has its own range of validity:

* GreedyGE is suited when the number of qubits exceeds 120, it outperforms the PMH algorithm and our other algorithms in both circuit size and computational time.

* The syndrome decoding based algorithms must be used for intermediate problem sizes ($30 < n < 120$) with the best possible solver of the syndrome decoding problem (in order: integer programming, Information Set Decoding if $n < 70$, maximum depth otherwise). Both GreedyGE and the family of syndrome decoding based algorithms are state of the art in a worst case scenario.

* When the output circuit is expected to be small, or when $n < 30$, then direct greedy methods have shown to produce the best results. The proposal of a new cost function paid off as this offers a more scalable direct greedy search. However, the moment when our new custom function outperforms the one proposed in [40] coincides with the moment when the syndrome decoding based algorithm also outperforms the direct greedy search. More investigation needs to be done to clarify which cost function should be preferred and when.

Given the variety of methods, each providing the best results in particular cases, the best method when trying to synthesize an operator would be simply to test each method and to keep the best result. Except for the direct greedy methods, the computational time of each method is well understood. Given a specific problem size, it is easy to know which method can be used and how long it will take. It is more delicate with the direct greedy methods, we have to set a limit in the maximum number of iterations before considering that the search will not converge to a solution.
## 6.2 Benchmarks on Reversible Functions

We apply our CNOT circuit synthesis to the optimization of quantum algorithms. A library to evaluate the quality of a quantum compiler is a library of reversible functions consisting of adders, Hamming coding functions, multipliers, etc. This library is a standard benchmark for circuit optimization algorithms and is used in recent articles about quantum circuit optimization [17, 5, 4, 35]. However, we must be aware that our results can only be compared to those using the same methodology. There are many other methods for the synthesis and optimization of reversible circuits [39], notably for the synthesis of oracles [30, 32], which we do not take into account here. The aim of this section is to show that our methods can bring promising results on specific circuits and that it will be interesting to apply it on other classes of circuits, but it will also be necessary to put it in perspective with other methods.

The original circuits are from Matthew Amy's github Feynman repository [3].

Recent quantum compilers mainly focused on the T-count or T-depth optimization of quantum circuits but these optimizations often lead to an increased CNOT count [17, 5]. Although it is experimentally more costly to implement a T gate, the total number of CNOT gates in a quantum circuit should not be too large otherwise the CNOT cost of the total circuit will not be negligible. In practice it may even be possible that the CNOT cost represents the most costly part of a quantum circuit [28] and it cannot be neglected.

In [4] the algorithm Gray-Synth for the optimization of the CNOT count in CNOT+T circuits is proposed. It efficiently reduces the total number of CNOT gates but it comes at the price of an increased T-depth. Here we show that, using our methods for CNOT circuit synthesis, one can reduce significantly the CNOT count without paying the price of increasing the T depth. We used the C++ implementation of Matthew Amy's Tpar algorithm to produce optimized circuits with low T-count and T-depth. We post process the circuits by re-synthesizing any chunk of purely CNOT circuits. It is possible to further optimize the synthesis of the CNOT+T circuits, using for instance the TODD optimizer [17] but as we are concerned about showing the impact of our method on the CNOT count and the T-depth we did not pursue the optimization to have a lower T-count so that we can directly compare against the results from [4].

The results are given in Table 2. For each reversible function we provide the results (T-count, T-depth, Total depth) of different methods implementing it. Namely, the original circuits, the circuits optimized solely with the Tpar algorithm and GraySynth as the state-of-the-art methods and the circuits optimized with the Tpar method and our own method, i.e., a mix of GreedyGE, the syndrome decoding based methods and the purely greedy methods. For each CNOT circuit we keep the best result encountered. To generate the Gray-Synth results we used the Haskell implementation, still from [3]. The savings given always compare against the circuits given by solely the Tpar algorithm. We notice several interesting points:

* we cannot decrease the CNOT count as much as with GraySynth, but we still manage to decrease the CNOT count consistently and above all we do not modify the T-depth. Our circuits therefore represent a tradeoff between the T-cost the CNOT-cost.

* We also considerably reduce the total depth of the circuits, making their execution faster on NISQ architectures. This is explained by the fact that most of the CNOT circuits involved in those reversible functions are elementary operators, requiring only a few CNOTs to be implemented. Therefore the size and the depth are very close and greedy methods find close-to-optimal implementations.

To illustrate our last statement, we kept track of the best algorithm that was used to compute each CNOT sub-circuit that appeared in the synthesis of one reversible function. The results are given in Table 3. Most of the time, both purely greedy methods and the syndrome decoding based methods provide the best results. According to us, this highlights the simplicity of the operators to synthesize otherwise there would be many more cases where we would observe a difference of even one CNOT. Overall, for this library of reversible functions, the use of methods other than the pure greedy methods is useless. This is not surprising as the number of qubits never exceeds 40 except for three operators. For such small problem sizes, we saw that pure greedy methods always outperform
## 6.2 Benchmarks on Reversible Functions

We apply our CNOT circuit synthesis to the optimization of quantum algorithms. A library to evaluate the quality of a quantum compiler is a library of reversible functions consisting of adders, Hamming coding functions, multipliers, etc. This library is a standard benchmark for circuit optimization algorithms and is used in recent articles about quantum circuit optimization [17, 5, 4, 35]. However, we must be aware that our results can only be compared to those using the same methodology. There are many other methods for the synthesis and optimization of reversible circuits [39], notably for the synthesis of oracles [30, 32], which we do not take into account here. The aim of this section is to show that our methods can bring promising results on specific circuits and that it will be interesting to apply it on other classes of circuits, but it will also be necessary to put it in perspective with other methods.

The original circuits are from Matthew Amy's github Feynman repository [3].

Recent quantum compilers mainly focused on the T-count or T-depth optimization of quantum circuits but these optimizations often lead to an increased CNOT count [17, 5]. Although it is experimentally more costly to implement a T gate, the total number of CNOT gates in a quantum circuit should not be too large otherwise the CNOT cost of the total circuit will not be negligible. In practice it may even be possible that the CNOT cost represents the most costly part of a quantum circuit [28] and it cannot be neglected.

In [4] the algorithm Gray-Synth for the optimization of the CNOT count in CNOT+T circuits is proposed. It efficiently reduces the total number of CNOT gates but it comes at the price of an increased T-depth. Here we show that, using our methods for CNOT circuit synthesis, one can reduce significantly the CNOT count without paying the price of increasing the T depth. We used the C++ implementation of Matthew Amy's Tpar algorithm to produce optimized circuits with low T-count and T-depth. We post process the circuits by re-synthesizing any chunk of purely CNOT circuits. It is possible to further optimize the synthesis of the CNOT+T circuits, using for instance the TODD optimizer [17] but as we are concerned about showing the impact of our method on the CNOT count and the T-depth we did not pursue the optimization to have a lower T-count so that we can directly compare against the results from [4].

The results are given in Table 2. For each reversible function we provide the results (T-count, T-depth, Total depth) of different methods implementing it. Namely, the original circuits, the circuits optimized solely with the Tpar algorithm and GraySynth as the state-of-the-art methods and the circuits optimized with the Tpar method and our own method, i.e., a mix of GreedyGE, the syndrome decoding based methods and the purely greedy methods. For each CNOT circuit we keep the best result encountered. To generate the Gray-Synth results we used the Haskell implementation, still from [3]. The savings given always compare against the circuits given by solely the Tpar algorithm. We notice several interesting points:

* we cannot decrease the CNOT count as much as with GraySynth, but we still manage to decrease the CNOT count consistently and above all we do not modify the T-depth. Our circuits therefore represent a tradeoff between the T-cost the CNOT-cost.

* We also considerably reduce the total depth of the circuits, making their execution faster on NISQ architectures. This is explained by the fact that most of the CNOT circuits involved in those reversible functions are elementary operators, requiring only a few CNOTs to be implemented. Therefore the size and the depth are very close and greedy methods find close-to-optimal implementations.

To illustrate our last statement, we kept track of the best algorithm that was used to compute each CNOT sub-circuit that appeared in the synthesis of one reversible function. The results are given in Table 3. Most of the time, both purely greedy methods and the syndrome decoding based methods provide the best results. According to us, this highlights the simplicity of the operators to synthesize otherwise there would be many more cases where we would observe a difference of even one CNOT. Overall, for this library of reversible functions, the use of methods other than the pure greedy methods is useless. This is not surprising as the number of qubits never exceeds 40 except for three operators. For such small problem sizes, we saw that pure greedy methods always outperform
the other methods, in addition to the fact that we have strong suspicions that the majority of the
operators encountered are easy to synthesize. We note the interest of using the cost function $h_{\text{prod}}$
as an alternative because in some cases it allows to synthesize operators more efficiently.

# 7 Conclusion

We presented the simple algorithm GreedyGE for the synthesis of linear reversible circuits. We improved state-of-the-art algorithms by adding a greedy feature in the Gaussian elimination algorithm while keeping an overall structure in the synthesis process for triangular operators. We combined this method with a practical LU decomposition that improves the results for input circuits of small sizes. Overall our method is fast and provides the best results when *n* is sufficiently large (*n* > 150). For operators acting on a small number of qubits (*n* < 30) or when we expect the operators to be synthesized with a small circuit, then purely greedy methods have shown to give quasi optimal results. We also managed to significantly reduce the CNOT count and, surprisingly, the depth of well-known reversible functions while keeping the T-count and the T-depth as low as possible, as given by other optimization algorithms [5].

Theoretically, GreedyGE worst case complexity is guaranteed to be at most asymptotically equal to $n^2/\log_2(n)$, which is still a factor of 2 larger than the theoretical lower bound. We will investigate in future work if this theoretical lower bound can be reached. Another main issue will be to extend this algorithm to the case where the qubits connectivity follows a restricted topology. It would also be interesting to look at the performance of GreedyGE for the synthesis of CNOT+T circuits. It is known that the synthesis of a CNOT+T circuit can be performed by manipulating a rectangular parity table via row operations [4]. Although the goal is not exactly to reduce the parity table to an identity operator, it involves to reduce the Hamming weight of the columns to 1 and to remove them from the table until the table is empty. Given that GreedyGE, at each step, reduces the Hamming weight of a column to 1, it can be used to CNOT+T circuits synthesis as well.

# Acknowledgment

This work was supported in part by the French National Research Agency (ANR) under the research project SoftQPRO ANR-17-CE25-0009-02, and by the DGE of the French Ministry of Industry under the research project PIA-GDN/QuantEx P163746-484124.
the other methods, in addition to the fact that we have strong suspicions that the majority of the
operators encountered are easy to synthesize. We note the interest of using the cost function $h_{\text{prod}}$
as an alternative because in some cases it allows to synthesize operators more efficiently.

# 7 Conclusion

We presented the simple algorithm GreedyGE for the synthesis of linear reversible circuits. We improved state-of-the-art algorithms by adding a greedy feature in the Gaussian elimination algorithm while keeping an overall structure in the synthesis process for triangular operators. We combined this method with a practical LU decomposition that improves the results for input circuits of small sizes. Overall our method is fast and provides the best results when *n* is sufficiently large (*n* > 150). For operators acting on a small number of qubits (*n* < 30) or when we expect the operators to be synthesized with a small circuit, then purely greedy methods have shown to give quasi optimal results. We also managed to significantly reduce the CNOT count and, surprisingly, the depth of well-known reversible functions while keeping the T-count and the T-depth as low as possible, as given by other optimization algorithms [5].

Theoretically, GreedyGE worst case complexity is guaranteed to be at most asymptotically equal to $n^2/\log_2(n)$, which is still a factor of 2 larger than the theoretical lower bound. We will investigate in future work if this theoretical lower bound can be reached. Another main issue will be to extend this algorithm to the case where the qubits connectivity follows a restricted topology. It would also be interesting to look at the performance of GreedyGE for the synthesis of CNOT+T circuits. It is known that the synthesis of a CNOT+T circuit can be performed by manipulating a rectangular parity table via row operations [4]. Although the goal is not exactly to reduce the parity table to an identity operator, it involves to reduce the Hamming weight of the columns to 1 and to remove them from the table until the table is empty. Given that GreedyGE, at each step, reduces the Hamming weight of a column to 1, it can be used to CNOT+T circuits synthesis as well.

# Acknowledgment

This work was supported in part by the French National Research Agency (ANR) under the research project SoftQPRO ANR-17-CE25-0009-02, and by the DGE of the French Ministry of Industry under the research project PIA-GDN/QuantEx P163746-484124.
<table><caption>Table 2: CNOT optimization of a library of reversible functions with several CNOT circuits synthesis methods.</caption><thead><tr><th rowspan="2">Function</th><th rowspan="2">#n</th><th colspan="10">Original</th><th colspan="10">Tpar</th><th colspan="10">Tpar + GraySynth</th><th colspan="10">Tpar + CNOT size opt.</th></tr><tr><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th></tr></thead><tbody><tr><td>Adder_8</td><td>24</td><td>399</td><td>69</td><td>466</td><td>223</td><td>213</td><td>30</td><td>741</td><td>302</td><td>215</td><td>74 (147%)</td><td>399 (-46%)</td><td>257 (-15%)</td><td>213</td><td>30</td><td>491 (-34%)</td><td>204 (-32%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>barenco_tof_10</td><td>19</td><td>224</td><td>96</td><td>224</td><td>288</td><td>100</td><td>43</td><td>332</td><td>272</td><td>100</td><td>81 (88%)</td><td>146 (-56%)</td><td>264 (-3%)</td><td>100</td><td>43</td><td>188 (-43%)</td><td>217 (-20%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>barenco_tof_3</td><td>5</td><td>28</td><td>12</td><td>28</td><td>36</td><td>16</td><td>8</td><td>52</td><td>60</td><td>16</td><td>16 (100%)</td><td>20 (-62%)</td><td>40 (-33%)</td><td>16</td><td>8</td><td>26 (-50%)</td><td>34 (-43%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>barenco_tof_4</td><td>7</td><td>56</td><td>24</td><td>56</td><td>72</td><td>28</td><td>13</td><td>96</td><td>96</td><td>26 (100%)</td><td>38 (-60%)</td><td>64 (-33%)</td><td>28</td><td>13</td><td>50 (-48%)</td><td>61 (-36%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>barenco_tof_5</td><td>9</td><td>84</td><td>36</td><td>84</td><td>108</td><td>40</td><td>18</td><td>134</td><td>123</td><td>40</td><td>34 (89%)</td><td>56 (-58%)</td><td>88 (-28%)</td><td>40</td><td>18</td><td>73 (-46%)</td><td>89 (-28%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>csla_max_3</td><td>15</td><td>70</td><td>21</td><td>90</td><td>67</td><td>62</td><td>8</td><td>379</td><td>210</td><td>62</td><td>28 (250%)</td><td>115 (-70%)</td><td>91 (-57%)</td><td>62</td><td>8</td><td>187 (-51%)</td><td>81 (-61%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>csum_max_9</td><td>30</td><td>196</td><td>18</td><td>196</td><td>59</td><td>84</td><td>6</td><td>366</td><td>153</td><td>84</td><td>16 (167%)</td><td>160 (-56%)</td><td>78 (-49%)</td><td>84</td><td>6</td><td>179 (-51%)</td><td>70 (-54%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>cycle_17_3</td><td>35</td><td>4739</td><td>2001</td><td>4742</td><td>5974</td><td>1944</td><td>562</td><td>6608</td><td>5231</td><td>1955</td><td>1857 (230%)</td><td>3040 (-54%)</td><td>5698 (9%)</td><td>1944</td><td>562</td><td>4267 (-35%)</td><td>4229 (-19%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>10</sup>)_mult</td><td>30</td><td>700</td><td>108</td><td>709</td><td>290</td><td>410</td><td>16</td><td>2206</td><td>1026</td><td>410</td><td>109 (581%)</td><td>648 (-71%)</td><td>324 (-68%)</td><td>410</td><td>16</td><td>955 (-57%)</td><td>307 (-70%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>32</sup>)_mult</td><td>48</td><td>1792</td><td>180</td><td>1837</td><td>489</td><td>1040</td><td>24</td><td>6724</td><td>2551</td><td>1040</td><td>585 (2338%)</td><td>1691 (-75%)</td><td>1488 (-42%)</td><td>1040</td><td>24</td><td>2542 (-62%)</td><td>678 (-73%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>4</sup>)_mult</td><td>96</td><td>7168</td><td>372</td><td>7292</td><td>1001</td><td>4128</td><td>47</td><td>34244</td><td>11520</td><td>4128</td><td>2190 (4560%)</td><td>6636 (-81%)</td><td>5391 (-53%)</td><td>4128</td><td>47</td><td>10953 (-68%)</td><td>2113 (-82%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>5</sup>)_mult</td><td>12</td><td>112</td><td>36</td><td>115</td><td>99</td><td>68</td><td>6</td><td>307</td><td>173</td><td>68</td><td>39 (550%)</td><td>106 (-65%)</td><td>117 (-32%)</td><td>68</td><td>6</td><td>135 (-56%)</td><td>80 (-54%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>6</sup>)_mult</td><td>15</td><td>175</td><td>48</td><td>179</td><td>130</td><td>115</td><td>9</td><td>502</td><td>239</td><td>115</td><td>51 (467%)</td><td>166 (-67%)</td><td>152 (-41%)</td><td>115</td><td>9</td><td>209 (-58%)</td><td>107 (-59%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>7</sup>)_mult</td><td>18</td><td>252</td><td>60</td><td>257</td><td>163</td><td>150</td><td>9</td><td>660</td><td>350</td><td>150</td><td>63 (600%)</td><td>235 (-64%)</td><td>189 (-46%)</td><td>150</td><td>9</td><td>310 (-53%)</td><td>137 (-61%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>8</sup>)_mult</td><td>21</td><td>343</td><td>72</td><td>349</td><td>195</td><td>217</td><td>12</td><td>996</td><td>490</td><td>217</td><td>75 (525%)</td><td>319 (-68%)</td><td>224 (-54%)</td><td>217</td><td>12</td><td>442 (-56%)</td><td>184 (-62%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>9</sup>)_mult</td><td>24</td><td>448</td><td>84</td><td>469</td><td>233</td><td>264</td><td>13</td><td>1254</td><td>619</td><td>264</td><td>87 (569%)</td><td>428 (-66%)</td><td>266 (-57%)</td><td>264</td><td>13</td><td>588 (-53%)</td><td>224 (-64%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GF(2<sup>9</sup>)_mult</td><td>27</td><td>567</td><td>96</td><td>575</td><td>258</td><td>351</td><td>15</td><td>1712</td><td>499</td><td>154</td><td>95 (533%)</td><td>528 (-69%)</td><td>283 (-65%)</td><td>351</td><td>15</td><td>753 (-56%)</td><td>266 (-67%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>grover_5</td><td>9</td><td>336</td><td>144</td><td>336</td><td>457</td><td>154</td><td>51</td><td>477</td><td>477</td><td>154</td><td>130 (155%)</td><td>233 (-54%)</td><td>440 (-8%)</td><td>154</td><td>51</td><td>331 (-34%)</td><td>384 (-19%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ham15-high</td><td>20</td><td>2457</td><td>996</td><td>2500</td><td>3026</td><td>1019</td><td>380</td><td>3427</td><td>2956</td><td>1019</td><td>839 (121%)</td><td>1588 (-54%)</td><td>2583 (-13%)</td><td>1019</td><td>380</td><td>2183 (-36%)</td><td>2226 (-25%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ham15-low</td><td>17</td><td>161</td><td>69</td><td>259</td><td>263</td><td>97</td><td>33</td><td>471</td><td>360</td><td>97</td><td>83 (152%)</td><td>221 (-53%)</td><td>271 (-25%)</td><td>97</td><td>33</td><td>280 (-41%)</td><td>223 (-38%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ham15-med</td><td>7</td><td>574</td><td>240</td><td>616</td><td>750</td><td>230</td><td>84</td><td>759</td><td>682</td><td>230</td><td>194 (131%)</td><td>368 (-52%)</td><td>622 (-9%)</td><td>230</td><td>84</td><td>481 (-37%)</td><td>506 (-267%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>hw86</td><td>10</td><td>585</td><td>12</td><td>7970</td><td>7956</td><td>3531</td><td>860</td><td>22670</td><td>15838</td><td>3531</td><td>2752 (220%)</td><td>6841 (-70%)</td><td>9338 (-41%)</td><td>3531</td><td>860</td><td>13353 (-41%)</td><td>9261 (-42%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mod5_4</td><td>5</td><td>28</td><td>12</td><td>32</td><td>41</td><td>16</td><td>6</td><td>48</td><td>57</td><td>16</td><td>15 (150%)</td><td>28 (-42%)</td><td>51 (-11%)</td><td>16</td><td>6</td><td>32 (-33%)</td><td>39 (-32%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mod_adder_1024</td><td>28</td><td>1995</td><td>831</td><td>2005</td><td>2503</td><td>1011</td><td>258</td><td>3650</td><td>2560</td><td>1011</td><td>864 (235%)</td><td>1390 (-62%)</td><td>2474 (-3%)</td><td>1011</td><td>258</td><td>2369 (-35%)</td><td>1913 (-25%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mod_adder_1048576</td><td>58</td><td>17290</td><td>7292</td><td>17310</td><td>21807</td><td>7298</td><td>1927</td><td>29794</td><td>19975</td><td>7323</td><td>6577 (241%)</td><td>11080 (-63%)</td><td>20089 (1%)</td><td>7298</td><td>1927</td><td>19122 (-36%)</td><td>15286 (-23%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mod_mult_55</td><td>9</td><td>49</td><td>15</td><td>55</td><td>50</td><td>35</td><td>7</td><td>106</td><td>75</td><td>35</td><td>20 (186%)</td><td>40 (-62%)</td><td>52 (-31%)</td><td>35</td><td>7</td><td>73 (-31%)</td><td>61 (-19%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mod red 21</td><td>11</td><td>119</td><td>48</td><td>122</td><td>158</td><td>73</td><td>25</td><td>223</td><td>207</td><td>73</td><td>59 (136%)</td><td>102 (-54%)</td><td>179 (-14%)</td><td>73</td><td>25</td><td>136 (-39%)</td><td>144 (-30%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>qcla_adder_10</td><td>36</td><td>238</td><td>24</td><td>267</td><td>73</td><td>162</td><td>13</td><td>648</td><td>195</td><td>162</td><td>33 (154%)</td><td>225 (-65%)</td><td>94 (-52%)</td><td>162</td><td>13</td><td>362 (-44%)</td><td>86 (-56%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>qcla_com_7</td><td>24</td><td>203</td><td>27</td><td>215</td><td>81</td><td>94</td><td>12</td><td>371</td><td>154</td><td>94</td><td>31 (158%)</td><td>150 (-60%)</td><td>89 (-42%)</td><td>94</td><td>12</td><td>202 (-46%)</td><td>76 (-51%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>qcla_mod_7</td><td>26</td><td>413</td><td>66</td><td>441</td><td>197</td><td>231</td><td>28</td><td>813</td><td>296</td><td>237</td><td>67 (139%)</td><td>386 (-53%)</td><td>212 (-28%)</td><td>231</td><td>28</td><td>479 (-41%)</td><td>188 (-36%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>qft_4</td><td>5</td><td>69</td><td>48</td><td>48</td><td>142</td><td>67</td><td>44</td><td>96</td><td>185</td><td>67</td><td>60 (36%)</td><td>48 (-50%)</td><td>163 (-12%)</td><td>67</td><td>44</td><td>56 (-42%)</td><td>150 (-19%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>rc_adder_6</td><td>14</td><td>77</td><td>33</td><td>104</td><td>104</td><td>47</td><td>22</td><td>165</td><td>157</td><td>47</td><td>39 (77%)</td><td>79 (-52%)</td><td>111 (-29%)</td><td>47</td><td>22</td><td>100 (-39%)</td><td>103 (-34%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>tof_10</td><td>19</td><td>119</td><td>51</td><td>119</td><td>153</td><td>71</td><td>27</td><td>236</td><td>190</td><td>71</td><td>61 (126%)</td><td>86 (-64%)</td><td>172 (-9%)</td><td>71</td><td>27</td><td>130 (-45%)</td><td>143 (-25%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>tof_3</td><td>5</td><td>21</td><td>9</td><td>21</td><td>27</td><td>15</td><td>6</td><td>35</td><td>46</td><td>15</td><td>12 (100%)</td><td>16 (-54%)</td><td>32 (-30%)</td><td>15</td><td>6</td><td>21 (-40%)</td><td>31 (-33%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>tof_4</td><td>7</td><td>35</td><td>15</td><td>35</td><td>45</td><td>23</td><td>9</td><td>63</td><td>71</td><td>23</td><td>18 (100%)</td><td>26 (-59%)</td><td>51 (-28%)</td><td>23</td><td>9</td><td>37 (-41%)</td><td>49 (-31%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>tof_5</td><td>9</td><td>49</td><td>21</td><td>49</td><td>63</td><td>31</td><td>12</td><td>97</td><td>104</td><td>31</td><td>24 (100%)</td><td>36 (-63%)</td><td>70 (-33%)</td><td>31</td><td>12</td><td>50 (-48%)</td><td>67 (-36%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>vhe_adder_3</td><td>10</td><td>70</td><td>24</td><td>80</td><td>79</td><td>24</td><td>9</td><td>120</td><td>88</td><td>24</td><td>18 (100%)</td><td>54 (-55%)</td><td>71 (-19%)</td><td>24</td><td>8</td><td>61 (-49%)</td><td>45 (-49%)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Mean savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Maximum savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Minimum savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table>
<table><caption>Table 2: CNOT optimization of a library of reversible functions with several CNOT circuits synthesis methods.</caption><thead><tr><th rowspan="2">Function</th><th rowspan="2">#n</th><th colspan="3">Original</th><th colspan="3">Tpar</th><th colspan="3">Tpar + GraySynth</th><th colspan="3">Tpar + CNOT size opt.</th></tr><tr><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th><th>T-count</th><th>T-depth</th><th>CNOT count</th><th>Depth</th></tr></thead><tbody><tr><td>Adder_8</td><td>24</td><td>399</td><td>69</td><td>466</td><td>223</td><td>213</td><td>30</td><td>741</td><td>302</td><td>215</td><td>74 (-147%)</td><td>399 (-46%)</td><td>257 (-15%)</td><td>213</td><td>30</td><td>491 (-34%)</td><td>204 (-32%)</td></tr><tr><td>barenco_tof_10</td><td>19</td><td>224</td><td>96</td><td>224</td><td>288</td><td>100</td><td>43</td><td>332</td><td>272</td><td>100</td><td>81 (-88%)</td><td>146 (-56%)</td><td>264 (-3%)</td><td>100</td><td>43</td><td>188 (-43%)</td><td>217 (-20%)</td></tr><tr><td>barenco_tof_3</td><td>5</td><td>28</td><td>12</td><td>28</td><td>36</td><td>16</td><td>8</td><td>52</td><td>60</td><td>16</td><td>16 (-100%)</td><td>20 (-62%)</td><td>40 (-33%)</td><td>16</td><td>8</td><td>26 (-50%)</td><td>34 (-43%)</td></tr><tr><td>barenco_tof_4</td><td>7</td><td>56</td><td>24</td><td>56</td><td>72</td><td>28</td><td>13</td><td>96</td><td>96</td><td>28</td><td>26 (-100%)</td><td>38 (-60%)</td><td>64 (-33%)</td><td>28</td><td>13</td><td>50 (-48%)</td><td>61 (-36%)</td></tr><tr><td>barenco_tof_5</td><td>9</td><td>84</td><td>36</td><td>84</td><td>108</td><td>40</td><td>18</td><td>134</td><td>123</td><td>40</td><td>34 (-89%)</td><td>56 (-58%)</td><td>88 (-28%)</td><td>40</td><td>18</td><td>73 (-46%)</td><td>89 (-28%)</td></tr><tr><td>csla_max_3</td><td>15</td><td>70</td><td>21</td><td>90</td><td>67</td><td>62</td><td>8</td><td>379</td><td>210</td><td>62</td><td>28 (-250%)</td><td>115 (-70%)</td><td>91 (-57%)</td><td>62</td><td>8</td><td>187 (-51%)</td><td>81 (-61%)</td></tr><tr><td>csum_max_9</td><td>30</td><td>196</td><td>18</td><td>196</td><td>59</td><td>84</td><td>6</td><td>366</td><td>153</td><td>84</td><td>16 (-167%)</td><td>160 (-56%)</td><td>78 (-49%)</td><td>84</td><td>6</td><td>179 (-51%)</td><td>70 (-54%)</td></tr><tr><td>cycle_17_3</td><td>35</td><td>4739</td><td>2001</td><td>4742</td><td>5974</td><td>1944</td><td>562</td><td>5231</td><td>1955</td><td>109 (-58%)</td><td>1857 (-230%)</td><td>3040 (-54%)</td><td>5698 (-9%)</td><td>1944</td><td>562</td><td>4267 (-35%)</td><td>4229 (-19%)</td></tr><tr><td>GF(2<sup>10</sup>)_mult</td><td>30</td><td>700</td><td>108</td><td>709</td><td>290</td><td>410</td><td>16</td><td>2206</td><td>1026</td><td>410</td><td>109 (-58%)</td><td>648 (-71%)</td><td>324 (-68%)</td><td>410</td><td>16</td><td>955 (-57%)</td><td>307 (-70%)</td></tr><tr><td>GF(2<sup>20</sup>)_mult</td><td>48</td><td>1792</td><td>180</td><td>1837</td><td>489</td><td>1040</td><td>24</td><td>6724</td><td>2551</td><td>1040</td><td>585 (-238%)</td><td>1691 (-75%)</td><td>1488 (-42%)</td><td>1040</td><td>24</td><td>2542 (-62%)</td><td>678 (-73%)</td></tr><tr><td>GF(2<sup>30</sup>)_mult</td><td>96</td><td>7168</td><td>372</td><td>7292</td><td>1001</td><td>4128</td><td>47</td><td>34244</td><td>11520</td><td>4128</td><td>2190 (-4560%)</td><td>6636 (-81%)</td><td>5391 (-53%)</td><td>4128</td><td>47</td><td>10953 (-68%)</td><td>2113 (-82%)</td></tr><tr><td>GF(2<sup>4</sup>)_mult</td><td>12</td><td>112</td><td>36</td><td>115</td><td>99</td><td>68</td><td>6</td><td>307</td><td>173</td><td>68</td><td>39 (-550%)</td><td>106 (-65%)</td><td>117 (-32%)</td><td>68</td><td>6</td><td>135 (-56%)</td><td>80 (-54%)</td></tr><tr><td>GF(2<sup>5</sup>)_mult</td><td>15</td><td>175</td><td>48</td><td>179</td><td>130</td><td>115</td><td>9</td><td>502</td><td>239</td><td>115</td><td>51 (-467%)</td><td>166 (-67%)</td><td>152 (-41%)</td><td>115</td><td>9</td><td>209 (-58%)</td><td>107 (-59%)</td></tr><tr><td>GF(2<sup>6</sup>)_mult</td><td>18</td><td>252</td><td>60</td><td>257</td><td>163</td><td>150</td><td>9</td><td>660</td><td>350</td><td>150</td><td>63 (-600%)</td><td>235 (-64%)</td><td>189 (-46%)</td><td>150</td><td>9</td><td>310 (-53%)</td><td>137 (-61%)</td></tr><tr><td>GF(2<sup>7</sup>)_mult</td><td>21</td><td>343</td><td>72</td><td>349</td><td>195</td><td>217</td><td>12</td><td>996</td><td>490</td><td>217</td><td>75 (-525%)</td><td>319 (-68%)</td><td>224 (-54%)</td><td>217</td><td>12</td><td>442 (-56%)</td><td>184 (-62%)</td></tr><tr><td>GF(2<sup>8</sup>)_mult</td><td>24</td><td>448</td><td>84</td><td>469</td><td>233</td><td>264</td><td>13</td><td>1254</td><td>619</td><td>264</td><td>87 (-569%)</td><td>428 (-66%)</td><td>266 (-57%)</td><td>264</td><td>13</td><td>588 (-53%)</td><td>224 (-64%)</td></tr><tr><td>GF(2<sup>9</sup>)_mult</td><td>27</td><td>567</td><td>96</td><td>575</td><td>258</td><td>351</td><td>15</td><td>1712</td><td>499</td><td>477</td><td>95 (-533%)</td><td>528 (-69%)</td><td>283 (-65%)</td><td>351</td><td>15</td><td>753 (-56%)</td><td>266 (-67%)</td></tr><tr><td>grover_5</td><td>9</td><td>336</td><td>144</td><td>336</td><td>457</td><td>154</td><td>51</td><td>499</td><td>154</td><td>477</td><td>130 (-155%)</td><td>233 (-54%)</td><td>440 (-8%)</td><td>154</td><td>51</td><td>331 (-34%)</td><td>384 (-19%)</td></tr><tr><td>ham15-high</td><td>20</td><td>2457</td><td>996</td><td>2500</td><td>3026</td><td>1019</td><td>380</td><td>3427</td><td>2956</td><td>1019</td><td>839 (-121%)</td><td>1588 (-54%)</td><td>2583 (-13%)</td><td>1019</td><td>380</td><td>2183 (-36%)</td><td>2226 (-25%)</td></tr><tr><td>ham15-low</td><td>17</td><td>161</td><td>69</td><td>259</td><td>263</td><td>97</td><td>33</td><td>471</td><td>360</td><td>97</td><td>83 (-152%)</td><td>221 (-53%)</td><td>271 (-25%)</td><td>97</td><td>33</td><td>280 (-41%)</td><td>223 (-38%)</td></tr><tr><td>ham15-med</td><td>7</td><td>574</td><td>240</td><td>616</td><td>750</td><td>230</td><td>84</td><td>759</td><td>682</td><td>230</td><td>194 (-131%)</td><td>368 (-52%)</td><td>622 (-9%)</td><td>230</td><td>84</td><td>481 (-37%)</td><td>506 (-267%)</td></tr><tr><td>hw86</td><td>105</td><td>45</td><td>131</td><td>152</td><td>75</td><td>24</td><td>270</td><td>248</td><td>75</td><td>63 (-162%)</td><td>111 (-59%)</td><td>188 (-24%)</td><td>75</td><td>24</td><td>172 (-36%)</td><td>164 (-34%)</td></tr><tr><td>hw88</td><td>12</td><td>5887</td><td>2139</td><td>7970</td><td>7956</td><td>3531</td><td>860</td><td>22670</td><td>15838</td><td>3531</td><td>2752 (-220%)</td><td>6841 (-70%)</td><td>9338 (-41%)</td><td>3531</td><td>860</td><td>13353 (-41%)</td><td>9261 (-42%)</td></tr><tr><td>mod5_4</td><td>5</td><td>28</td><td>12</td><td>32</td><td>41</td><td>16</td><td>48</td><td>57</td><td>16</td><td>15 (-150%)</td><td>28 (-42%)</td><td>51 (-11%)</td><td>16</td><td>6</td><td>32 (-33%)</td><td>39 (-32%)</td></tr><tr><td>mod_adder_1024</td><td>28</td><td>1995</td><td>831</td><td>2005</td><td>2503</td><td>1011</td><td>258</td><td>3650</td><td>2560</td><td>1011</td><td>1390 (-62%)</td><td>2474 (-3%)</td><td>1011</td><td>258</td><td>2369 (-35%)</td><td>1913 (-25%)</td></tr><tr><td>mod_adder_1048576</td><td>58</td><td>17290</td><td>7292</td><td>17310</td><td>21807</td><td>7298</td><td>1927</td><td>29794</td><td>19975</td><td>7323</td><td>6577 (-241%)</td><td>11080 (-63%)</td><td>20089 (-1%)</td><td>7298</td><td>1927</td><td>19122 (-36%)</td><td>15286 (-23%)</td></tr><tr><td>mod_mult_55</td><td>9</td><td>49</td><td>15</td><td>55</td><td>50</td><td>35</td><td>7</td><td>106</td><td>75</td><td>35</td><td>20 (-186%)</td><td>40 (-62%)</td><td>52 (-31%)</td><td>35</td><td>7</td><td>73 (-31%)</td><td>61 (-19%)</td></tr><tr><td>mod red_21</td><td>11</td><td>119</td><td>48</td><td>122</td><td>158</td><td>73</td><td>25</td><td>223</td><td>207</td><td>73</td><td>59 (-136%)</td><td>102 (-54%)</td><td>179 (-14%)</td><td>73</td><td>25</td><td>136 (-39%)</td><td>144 (-30%)</td></tr><tr><td>qcla_adder_10</td><td>36</td><td>238</td><td>24</td><td>267</td><td>73</td><td>162</td><td>13</td><td>648</td><td>195</td><td>162</td><td>33 (-154%)</td><td>225 (-65%)</td><td>94 (-52%)</td><td>162</td><td>13</td><td>362 (-44%)</td><td>86 (-56%)</td></tr><tr><td>qcla_com_7</td><td>24</td><td>203</td><td>27</td><td>215</td><td>81</td><td>94</td><td>12</td><td>371</td><td>154</td><td>94</td><td>31 (-158%)</td><td>150 (-60%)</td><td>89 (-42%)</td><td>94</td><td>12</td><td>202 (-46%)</td><td>76 (-51%)</td></tr><tr><td>qcla_mod_7</td><td>26</td><td>413</td><td>66</td><td>441</td><td>197</td><td>231</td><td>28</td><td>813</td><td>296</td><td>237</td><td>67 (-139%)</td><td>386 (-53%)</td><td>212 (-28%)</td><td>231</td><td>28</td><td>479 (-41%)</td><td>188 (-36%)</td></tr><tr><td>qft_4</td><td>5</td><td>69</td><td>48</td><td>48</td><td>142</td><td>67</td><td>44</td><td>96</td><td>185</td><td>67</td><td>60 (-36%)</td><td>48 (-50%)</td><td>163 (-12%)</td><td>44</td><td>44</td><td>56 (-42%)</td><td>150 (-19%)</td></tr><tr><td>rc_adder_6</td><td>14</td><td>77</td><td>33</td><td>104</td><td>104</td><td>47</td><td>22</td><td>165</td><td>157</td><td>47</td><td>39 (-77%)</td><td>79 (-52%)</td><td>111 (-29%)</td><td>47</td><td>22</td><td>100 (-39%)</td><td>103 (-34%)</td></tr><tr><td>tof_10</td><td>19</td><td>119</td><td>51</td><td>119</td><td>153</td><td>71</td><td>27</td><td>236</td><td>190</td><td>71</td><td>61 (-126%)</td><td>86 (-64%)</td><td>172 (-9%)</td><td>71</td><td>27</td><td>130 (-45%)</td><td>143 (-25%)</td></tr><tr><td>tof_3</td><td>5</td><td>21</td><td>9</td><td>21</td><td>27</td><td>15</td><td>6</td><td>35</td><td>46</td><td>15</td><td>12 (-100%)</td><td>16 (-54%)</td><td>32 (-30%)</td><td>15</td><td>6</td><td>21 (-40%)</td><td>31 (-33%)</td></tr><tr><td>tof_4</td><td>7</td><td>35</td><td>15</td><td>35</td><td>45</td><td>23</td><td>9</td><td>63</td><td>71</td><td>23</td><td>18 (-100%)</td><td>26 (-59%)</td><td>51 (-28%)</td><td>23</td><td>9</td><td>37 (-41%)</td><td>49 (-31%)</td></tr><tr><td>tof_5</td><td>9</td><td>49</td><td>21</td><td>49</td><td>63</td><td>31</td><td>12</td><td>97</td><td>104</td><td>31</td><td>24 (-100%)</td><td>36 (-63%)</td><td>70 (-33%)</td><td>31</td><td>12</td><td>50 (-48%)</td><td>67 (-36%)</td></tr><tr><td>vhe_adder_3</td><td>10</td><td>70</td><td>24</td><td>80</td><td>79</td><td>24</td><td>9</td><td>120</td><td>88</td><td>24</td><td>18 (-100%)</td><td>54 (-55%)</td><td>71 (-19%)</td><td>24</td><td>8</td><td>61 (-49%)</td><td>45 (-49%)</td></tr><tr><td>Mean savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>+391.39%</td><td>-60.21%</td><td>-29.66%</td><td></td><td></td><td>-45.03%</td><td>-41.26%</td></tr><tr><td>Maximum savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>+36%</td><td>-81%</td><td>-68%</td><td></td><td></td><td>-68%</td><td>-82%</td></tr><tr><td>Minimum savings (compared to Tpar)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>+4560%</td><td>-42%</td><td>+9%</td><td></td><td></td><td>-31%</td><td>-19%</td></tr></tbody></table>
<table><caption>Table 3: Frequency of best performance of each algorithm during the optimization of reversible circuits. For each algorithm, the first column gives the number of times it has returned the best result (possibly other algorithms returned circuits of same size). The second column reports the number of times it was the only one to provide the best possible circuit.</caption><thead><tr><th>Function</th><th>#n</th><th>#CNOT sub-circuits</th><th>PMH</th><th>GreedyGE</th><th>Syndrome (Information Set Decoding)</th><th>Syndrome (Depth 3)</th><th>Syndrome (IP)</th><th>Greedy Ones (H<sub>sum</sub>)</th><th>Greedy Log (H<sub>log</sub>)</th></tr><tr><th></th><th></th><th></th><th>Best choice</th><th>Only Choice</th><th>Best choice</th><th>Only Choice</th><th>Best choice</th><th>Only Choice</th><th>Best choice</th><th>Only Choice</th></tr></thead><tbody><tr><td>Adder_8</td><td>24</td><td>60</td><td>12 (20%)</td><td>0 (0)</td><td>13 (22%)</td><td>0 (0%)</td><td>42 (70%)</td><td>0 (0%)</td><td>42 (70%)</td><td>0 (0%)</td></tr><tr><td>barenco_lof_10</td><td>19</td><td>99</td><td>29 (29%)</td><td>0 (0)</td><td>33 (33%)</td><td>0 (0%)</td><td>83 (84%)</td><td>0 (0%)</td><td>83 (84%)</td><td>0 (0%)</td></tr><tr><td>barenco_lof_3</td><td>5</td><td>14</td><td>8 (57%)</td><td>0 (0)</td><td>8 (57%)</td><td>0 (0%)</td><td>12 (86%)</td><td>0 (0%)</td><td>12 (86%)</td><td>0 (0%)</td></tr><tr><td>barenco_lof_4</td><td>7</td><td>27</td><td>12 (44%)</td><td>0 (0)</td><td>12 (44%)</td><td>0 (0%)</td><td>24 (89%)</td><td>0 (0%)</td><td>24 (89%)</td><td>0 (0%)</td></tr><tr><td>barenco_lof_5</td><td>9</td><td>39</td><td>16 (41%)</td><td>0 (0)</td><td>16 (41%)</td><td>0 (0%)</td><td>32 (82%)</td><td>0 (0%)</td><td>32 (82%)</td><td>0 (0%)</td></tr><tr><td>esla_max_3</td><td>15</td><td>15</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>8 (53%)</td><td>0 (0%)</td><td>8 (53%)</td><td>0 (0%)</td></tr><tr><td>esum_max_9</td><td>30</td><td>14</td><td>1 (7%)</td><td>0 (0)</td><td>1 (7%)</td><td>0 (0%)</td><td>6 (43%)</td><td>0 (0%)</td><td>6 (43%)</td><td>0 (0%)</td></tr><tr><td>cycle_17_3</td><td>35</td><td>1436</td><td>219 (15%)</td><td>0 (0)</td><td>330 (23%)</td><td>0 (0%)</td><td>1094 (76%)</td><td>0 (0%)</td><td>1094 (76%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>26</sup>)_mult</td><td>30</td><td>20</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>1 (5%)</td><td>0 (0%)</td><td>1 (5%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>26</sup>)_mult</td><td>48</td><td>28</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (7%)</td><td>0 (0%)</td><td>2 (7%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>96</td><td>51</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (4%)</td><td>0 (0%)</td><td>2 (4%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>12</td><td>10</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (30%)</td><td>0 (0%)</td><td>3 (30%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>15</td><td>13</td><td>1 (8%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (23%)</td><td>0 (0%)</td><td>3 (23%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>18</td><td>13</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (15%)</td><td>0 (0%)</td><td>2 (15%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>21</td><td>16</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (19%)</td><td>0 (0%)</td><td>3 (19%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>24</td><td>17</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (12%)</td><td>0 (0%)</td><td>2 (12%)</td><td>0 (0%)</td></tr><tr><td>GF(2<sup>22</sup>)_mult</td><td>27</td><td>19</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>4 (21%)</td><td>0 (0%)</td><td>4 (21%)</td><td>0 (0%)</td></tr><tr><td>grover_5</td><td>9</td><td>123</td><td>39 (32%)</td><td>0 (0)</td><td>39 (32%)</td><td>0 (0%)</td><td>110 (89%)</td><td>0 (0%)</td><td>110 (89%)</td><td>0 (0%)</td></tr><tr><td>ham15-high</td><td>20</td><td>852</td><td>220 (26%)</td><td>0 (0)</td><td>256 (20%)</td><td>0 (0%)</td><td>698 (82%)</td><td>0 (0%)</td><td>698 (82%)</td><td>0 (0%)</td></tr><tr><td>ham15-low</td><td>17</td><td>69</td><td>21 (20%)</td><td>0 (0)</td><td>18 (26%)</td><td>0 (0%)</td><td>57 (83%)</td><td>0 (0%)</td><td>57 (83%)</td><td>0 (0%)</td></tr><tr><td>ham15-med</td><td>7</td><td>189</td><td>56 (30%)</td><td>0 (0)</td><td>63 (33%)</td><td>0 (0%)</td><td>161 (88%)</td><td>0 (0%)</td><td>161 (88%)</td><td>0 (0%)</td></tr><tr><td>hw66</td><td>48</td><td>11</td><td>11 (23%)</td><td>0 (0)</td><td>12 (25%)</td><td>0 (0%)</td><td>40 (83%)</td><td>0 (0%)</td><td>40 (83%)</td><td>0 (0%)</td></tr><tr><td>hw68</td><td>12</td><td>2130</td><td>270 (13%)</td><td>0 (0)</td><td>343 (16%)</td><td>0 (0%)</td><td>1248 (59%)</td><td>0 (0%)</td><td>1248 (58%)</td><td>0 (0%)</td></tr><tr><td>mod5_4</td><td>5</td><td>14</td><td>8 (57%)</td><td>0 (0)</td><td>8 (57%)</td><td>0 (0%)</td><td>13 (93%)</td><td>0 (0%)</td><td>13 (93%)</td><td>0 (0%)</td></tr><tr><td>mod_adder_1024</td><td>28</td><td>716</td><td>173 (24%)</td><td>0 (0)</td><td>214 (30%)</td><td>0 (0%)</td><td>564 (79%)</td><td>0 (0%)</td><td>564 (79%)</td><td>0 (0%)</td></tr><tr><td>mod_adder_1048576</td><td>58</td><td>5615</td><td>857 (15%)</td><td>0 (0)</td><td>1335 (24%)</td><td>0 (0%)</td><td>4276 (76%)</td><td>0 (0%)</td><td>4276 (76%)</td><td>0 (0%)</td></tr><tr><td>mod_mult_55</td><td>9</td><td>14</td><td>4 (29%)</td><td>0 (0)</td><td>4 (29%)</td><td>0 (0%)</td><td>9 (64%)</td><td>0 (0%)</td><td>9 (64%)</td><td>0 (0%)</td></tr><tr><td>mod_red_21</td><td>11</td><td>46</td><td>19 (41%)</td><td>0 (0)</td><td>19 (41%)</td><td>0 (0%)</td><td>40 (87%)</td><td>0 (0%)</td><td>40 (87%)</td><td>0 (0%)</td></tr><tr><td>qcla_adder_10</td><td>36</td><td>24</td><td>3 (12%)</td><td>0 (0)</td><td>4 (17%)</td><td>0 (0%)</td><td>17 (71%)</td><td>0 (0%)</td><td>17 (71%)</td><td>0 (0%)</td></tr><tr><td>qcla_com_7</td><td>26</td><td>26</td><td>4 (15%)</td><td>0 (0)</td><td>4 (15%)</td><td>0 (0%)</td><td>15 (58%)</td><td>0 (0%)</td><td>15 (58%)</td><td>0 (0%)</td></tr><tr><td>qcla_mult_7</td><td>26</td><td>52</td><td>5 (10%)</td><td>0 (0)</td><td>5 (10%)</td><td>0 (0%)</td><td>35 (67%)</td><td>0 (0%)</td><td>35 (67%)</td><td>0 (0%)</td></tr><tr><td>qft_4</td><td>5</td><td>29</td><td>9 (31%)</td><td>0 (0)</td><td>12 (41%)</td><td>0 (0%)</td><td>28 (97%)</td><td>0 (0%)</td><td>28 (97%)</td><td>0 (0%)</td></tr><tr><td>rc_adder_6</td><td>14</td><td>49</td><td>33 (67%)</td><td>0 (0)</td><td>34 (69%)</td><td>0 (0%)</td><td>43 (88%)</td><td>0 (0%)</td><td>43 (88%)</td><td>0 (0%)</td></tr><tr><td>lof_10</td><td>19</td><td>52</td><td>21 (40%)</td><td>0 (0)</td><td>21 (40%)</td><td>0 (0%)</td><td>48 (92%)</td><td>0 (0%)</td><td>48 (92%)</td><td>0 (0%)</td></tr><tr><td>lof_3</td><td>5</td><td>12</td><td>7 (58%)</td><td>0 (0)</td><td>8 (67%)</td><td>0 (0%)</td><td>11 (92%)</td><td>0 (0%)</td><td>11 (92%)</td><td>0 (0%)</td></tr><tr><td>lof_4</td><td>7</td><td>17</td><td>10 (59%)</td><td>0 (0)</td><td>11 (65%)</td><td>0 (0%)</td><td>16 (94%)</td><td>0 (0%)</td><td>16 (94%)</td><td>0 (0%)</td></tr><tr><td>lof_5</td><td>9</td><td>22</td><td>11 (50%)</td><td>0 (0)</td><td>11 (50%)</td><td>0 (0%)</td><td>18 (82%)</td><td>0 (0%)</td><td>18 (82%)</td><td>0 (0%)</td></tr><tr><td>vbe_adder_3</td><td>10</td><td>19</td><td>4 (21%)</td><td>0 (0)</td><td>4 (21%)</td><td>0 (0%)</td><td>18 (95%)</td><td>0 (0%)</td><td>18 (95%)</td><td>0 (0%)</td></tr></tbody></table>
<table><caption>Table 3: Frequency of best performance of each algorithm during the optimization of reversible circuits. For each algorithm, the first column gives the number of times it has returned the best result (possibly other algorithms returned circuits of same size). The second column reports the number of times it was the only one to provide the best possible circuit.</caption><thead><tr><th>Function</th><th>#n</th><th>#CNOT sub-circuits</th><th>PMH</th><th>GreedyGE</th><th>Syndrome (Information Set Decoding)</th><th>Syndrome (Depth 3)</th><th>Syndrome (IP)</th><th>Greedy Ones (H<sub>sum</sub>)</th><th>Greedy Log (H<sub>log</sub>)</th></tr><tr><th></th><th></th><th></th><th>Best choice</th><th>Only Choice</th><th>Best choice</th><th>Only Choice</th><th>Best choice</th><th>Only Choice</th><th>Best choice</th></tr></thead><tbody><tr><td>Adder_8</td><td>24</td><td>60</td><td>12 (20%)</td><td>0 (0)</td><td>42 (70%)</td><td>0 (0%)</td><td>42 (70%)</td><td>0 (0%)</td><td>58 (97%)</td></tr><tr><td>barenco_lof_10</td><td>19</td><td>99</td><td>29 (29%)</td><td>0 (0)</td><td>83 (84%)</td><td>0 (0%)</td><td>83 (84%)</td><td>0 (0%)</td><td>99 (100%)</td></tr><tr><td>barenco_lof_3</td><td>5</td><td>14</td><td>8 (57%)</td><td>0 (0)</td><td>12 (86%)</td><td>0 (0%)</td><td>12 (86%)</td><td>0 (0%)</td><td>13 (93%)</td></tr><tr><td>barenco_lof_4</td><td>7</td><td>27</td><td>12 (44%)</td><td>0 (0)</td><td>8 (57%)</td><td>0 (0%)</td><td>24 (89%)</td><td>0 (0%)</td><td>26 (96%)</td></tr><tr><td>barenco_lof_5</td><td>9</td><td>39</td><td>16 (41%)</td><td>0 (0)</td><td>12 (44%)</td><td>0 (0%)</td><td>32 (82%)</td><td>0 (0%)</td><td>38 (97%)</td></tr><tr><td>esla_max_3</td><td>15</td><td>15</td><td>0 (0%)</td><td>0 (0)</td><td>16 (41%)</td><td>0 (0%)</td><td>8 (53%)</td><td>0 (0%)</td><td>15 (100%)</td></tr><tr><td>esum_max_9</td><td>30</td><td>14</td><td>1 (7%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>6 (43%)</td><td>0 (0%)</td><td>2 (13%)</td></tr><tr><td>cycle_17_3</td><td>35</td><td>1436</td><td>219 (15%)</td><td>0 (0)</td><td>330 (23%)</td><td>0 (0%)</td><td>6 (43%)</td><td>0 (0%)</td><td>13 (93%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>30</td><td>20</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>1 (5%)</td><td>0 (0%)</td><td>1429 (100%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>48</td><td>28</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>1 (5%)</td><td>0 (0%)</td><td>13 (65%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>96</td><td>51</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (7%)</td><td>0 (0%)</td><td>18 (64%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>12</td><td>10</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (4%)</td><td>0 (0%)</td><td>30 (59%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>15</td><td>13</td><td>1 (8%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (30%)</td><td>0 (0%)</td><td>9 (90%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>18</td><td>13</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (23%)</td><td>0 (0%)</td><td>10 (77%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>21</td><td>16</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (15%)</td><td>0 (0%)</td><td>6 (46%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>24</td><td>17</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>3 (19%)</td><td>0 (0%)</td><td>7 (44%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>27</td><td>19</td><td>0 (0%)</td><td>0 (0)</td><td>0 (0%)</td><td>0 (0%)</td><td>2 (12%)</td><td>0 (0%)</td><td>15 (88%)</td></tr><tr><td>GF(2<sup>2</sup>)_mult</td><td>9</td><td>123</td><td>39 (32%)</td><td>0 (0)</td><td>39 (32%)</td><td>0 (0%)</td><td>4 (21%)</td><td>0 (0%)</td><td>14 (74%)</td></tr><tr><td>grover_5</td><td>20</td><td>852</td><td>220 (26%)</td><td>0 (0)</td><td>256 (20%)</td><td>0 (0%)</td><td>110 (89%)</td><td>0 (0%)</td><td>122 (99%)</td></tr><tr><td>ham15-high</td><td>17</td><td>69</td><td>21 (20%)</td><td>0 (0)</td><td>18 (26%)</td><td>0 (0%)</td><td>698 (82%)</td><td>0 (0%)</td><td>852 (100%)</td></tr><tr><td>ham15-low</td><td>17</td><td>189</td><td>56 (30%)</td><td>0 (0)</td><td>63 (33%)</td><td>0 (0%)</td><td>57 (83%)</td><td>0 (0%)</td><td>69 (100%)</td></tr><tr><td>ham15-med</td><td>7</td><td>48</td><td>11 (23%)</td><td>0 (0)</td><td>12 (25%)</td><td>0 (0%)</td><td>161 (88%)</td><td>0 (0%)</td><td>189 (100%)</td></tr><tr><td>hw66</td><td>12</td><td>2130</td><td>270 (13%)</td><td>0 (0)</td><td>343 (16%)</td><td>0 (0%)</td><td>40 (83%)</td><td>0 (0%)</td><td>47 (98%)</td></tr><tr><td>hw68</td><td>28</td><td>716</td><td>173 (24%)</td><td>0 (0)</td><td>214 (30%)</td><td>0 (0%)</td><td>1245 (58%)</td><td>0 (0%)</td><td>2115 (99%)</td></tr><tr><td>mod5_4</td><td>5</td><td>14</td><td>8 (57%)</td><td>0 (0)</td><td>8 (57%)</td><td>0 (0%)</td><td>13 (93%)</td><td>0 (0%)</td><td>159 (7%)</td></tr><tr><td>mod_adder_1024</td><td>58</td><td>5615</td><td>857 (15%)</td><td>0 (0)</td><td>1335 (24%)</td><td>0 (0%)</td><td>40 (83%)</td><td>0 (0%)</td><td>14 (100%)</td></tr><tr><td>mod_adder_1048576</td><td>9</td><td>14</td><td>4 (29%)</td><td>0 (0)</td><td>4 (29%)</td><td>0 (0%)</td><td>9 (64%)</td><td>0 (0%)</td><td>14 (100%)</td></tr><tr><td>mod_mult_55</td><td>11</td><td>46</td><td>19 (41%)</td><td>0 (0)</td><td>19 (41%)</td><td>0 (0%)</td><td>40 (87%)</td><td>0 (0%)</td><td>45 (98%)</td></tr><tr><td>mod_red_21</td><td>36</td><td>24</td><td>3 (12%)</td><td>0 (0)</td><td>4 (17%)</td><td>0 (0%)</td><td>17 (71%)</td><td>0 (0%)</td><td>23 (96%)</td></tr><tr><td>qcla_adder_10</td><td>24</td><td>26</td><td>4 (15%)</td><td>0 (0)</td><td>4 (15%)</td><td>0 (0%)</td><td>15 (58%)</td><td>0 (0%)</td><td>26 (100%)</td></tr><tr><td>qcla_com_7</td><td>24</td><td>26</td><td>5 (10%)</td><td>0 (0)</td><td>5 (10%)</td><td>0 (0%)</td><td>35 (67%)</td><td>0 (0%)</td><td>51 (98%)</td></tr><tr><td>qcla_mult_7</td><td>26</td><td>52</td><td>9 (31%)</td><td>0 (0)</td><td>12 (41%)</td><td>0 (0%)</td><td>28 (97%)</td><td>0 (0%)</td><td>29 (100%)</td></tr><tr><td>qft_4</td><td>5</td><td>29</td><td>33 (67%)</td><td>0 (0)</td><td>34 (69%)</td><td>0 (0%)</td><td>43 (88%)</td><td>0 (0%)</td><td>48 (98%)</td></tr><tr><td>rc_adder_6</td><td>14</td><td>49</td><td>21 (40%)</td><td>0 (0)</td><td>21 (40%)</td><td>0 (0%)</td><td>48 (92%)</td><td>0 (0%)</td><td>51 (98%)</td></tr><tr><td>tot_10</td><td>19</td><td>52</td><td>7 (58%)</td><td>0 (0)</td><td>8 (67%)</td><td>0 (0%)</td><td>11 (92%)</td><td>0 (0%)</td><td>11 (92%)</td></tr><tr><td>tot_4</td><td>5</td><td>12</td><td>10 (59%)</td><td>0 (0)</td><td>11 (65%)</td><td>0 (0%)</td><td>16 (94%)</td><td>0 (0%)</td><td>16 (94%)</td></tr><tr><td>tot_5</td><td>9</td><td>22</td><td>11 (50%)</td><td>0 (0)</td><td>11 (50%)</td><td>0 (0%)</td><td>18 (82%)</td><td>0 (0%)</td><td>21 (95%)</td></tr><tr><td>vbe_adder_3</td><td>10</td><td>19</td><td>4 (21%)</td><td>0 (0)</td><td>4 (21%)</td><td>0 (0%)</td><td>18 (95%)</td><td>0 (0%)</td><td>18 (95%)</td></tr></tbody></table>
References

[1] AARONSON, S., AND GOTTESMAN, D. Improved simulation of stabilizer circuits. *Physical Review A* 70, 5 (2004), 052328.

[2] ALGFOOR, Z. A., SUNAR, M. S., AND KOLIVAND, H. A comprehensive study on pathfinding techniques for robotics and video games. *Int. J. Comput. Games Technol.* 2015 (2015), 736138:1–736138:11.

[3] AMY, M. Matthew Amy's Github. https://github.com/meamy.

[4] AMY, M., AZIMZADEH, P., AND MOSCA, M. On the controlled-NOT complexity of controlled-NOT-phase circuits. *Quantum Science and Technology* 4, 1 (2018), 015002.

[5] AMY, M., MASLOV, D., AND MOSCA, M. Polynomial-time T-depth optimization of Clifford+T circuits via matroid partitioning. *IEEE Trans. on CAD of Integrated Circuits and Systems* 33, 10 (2014), 1476–1489.

[6] BEZANSON, J., EDELMAN, A., KARPINSKI, S., AND SHAH, V. B. Julia: A fresh approach to numerical computing. *SIAM review* 59, 1 (2017), 65–98.

[7] BONET, B., AND GEFFNER, H. Planning as heuristic search. *Artif. Intell.* 129, 1-2 (2001), 5–33.

[8] BOYAR, J., MATTHEWS, P., AND PERALTA, R. Logic minimization techniques with applications to cryptology. *J. Cryptology* 26, 2 (2013), 280–312.

[9] DE BRUGIÈRE, T. G., BABOULIN, M., VALIRON, B., MARTIEL, S., AND ALLOUCHE, C. Quantum CNOT circuits synthesis for NISQ architectures using the syndrome decoding problem. In *Reversible Computation - 12th International Conference, RC 2020, Oslo, Norway, July 9-10, 2020, Proceedings* (2020), I. Lanese and M. Rawski, Eds., vol. 12227 of *Lecture Notes in Computer Science*, Springer, pp. 189–205.

[10] FIEKER, C., HART, W., HOFMANN, T., AND JOHANSSON, F. Nemo/hecke: Computer algebra and number theory packages for the Julia programming language. In *Proceedings of the 2017 ACM on International Symposium on Symbolic and Algebraic Computation* (New York, NY, USA, 2017), ISSAC '17, ACM, pp. 157–164.

[11] GANDER, M. W., VRANA, J. D., VOJE, W. E., CAROTHERS, J. M., AND KLAVINS, E. Digital logic circuits in yeast with CRISPR-dCas9 NOR gates. *Nature communications* 8 (2017), 15459.

[12] GOLUB, G. H., AND VAN LOAN, C. F. *Matrix Computations*. The Johns Hopkins University Press, Baltimore, 1996. Third edition.

[13] GOTTESMAN, D. *Stabilizer codes and quantum error correction*. PhD thesis, Caltech, 1997.

[14] GUET, C. C., ELOWITZ, M. B., HSING, W., AND LEIBLER, S. Combinatorial synthesis of genetic networks. *Science* 296, 5572 (2002), 1466–1470.

[15] HANSEN, E. A., AND ZHOU, R. Anytime heuristic search. *J. Artif. Intell. Res.* 28 (2007), 267–297.

[16] HARROW, A. W., HASSIDIM, A., AND LLOYD, S. Quantum algorithm for linear systems of equations. *Phys. Rev. Lett.* 103 (2009), 150502.

[17] HEYFRON, L. E., AND CAMPBELL, E. T. An efficient quantum compiler that reduces T count. *Quantum Science and Technology* 4, 1 (2019), 015004.

[18] IKEDA, T., AND IMAI, H. Enhanced A\* algorithms for multiple alignments: Optimal alignments for several sequences and *k*-opt approximate alignments for large cases. *Theor. Comput. Sci.* 210, 2 (1999), 341–374.
References

[1] AARONSON, S., AND GOTTESMAN, D. Improved simulation of stabilizer circuits. *Physical Review A* 70, 5 (2004), 052328.

[2] ALGFOOR, Z. A., SUNAR, M. S., AND KOLIVAND, H. A comprehensive study on pathfinding techniques for robotics and video games. *Int. J. Comput. Games Technol.* 2015 (2015), 736138:1–736138:11.

[3] AMY, M. Matthew Amy's Github. https://github.com/meamy.

[4] AMY, M., AZIMZADEH, P., AND MOSCA, M. On the controlled-NOT complexity of controlled-NOT-phase circuits. *Quantum Science and Technology* 4, 1 (2018), 015002.

[5] AMY, M., MASLOV, D., AND MOSCA, M. Polynomial-time T-depth optimization of Clifford+T circuits via matroid partitioning. *IEEE Trans. on CAD of Integrated Circuits and Systems* 33, 10 (2014), 1476–1489.

[6] BEZANSON, J., EDELMAN, A., KARPINSKI, S., AND SHAH, V. B. Julia: A fresh approach to numerical computing. *SIAM review* 59, 1 (2017), 65–98.

[7] BONET, B., AND GEFFNER, H. Planning as heuristic search. *Artif. Intell.* 129, 1-2 (2001), 5–33.

[8] BOYAR, J., MATTHEWS, P., AND PERALTA, R. Logic minimization techniques with applications to cryptology. *J. Cryptology* 26, 2 (2013), 280–312.

[9] DE BRUGIÈRE, T. G., BABOULIN, M., VALIRON, B., MARTIEL, S., AND ALLOUCHE, C. Quantum CNOT circuits synthesis for NISQ architectures using the syndrome decoding problem. In *Reversible Computation - 12th International Conference, RC 2020, Oslo, Norway, July 9-10, 2020, Proceedings* (2020), I. Lanese and M. Rawski, Eds., vol. 12227 of *Lecture Notes in Computer Science*, Springer, pp. 189–205.

[10] FIEKER, C., HART, W., HOFMANN, T., AND JOHANSSON, F. Nemo/hecke: Computer algebra and number theory packages for the Julia programming language. In *Proceedings of the 2017 ACM on International Symposium on Symbolic and Algebraic Computation* (New York, NY, USA, 2017), ISSAC '17, ACM, pp. 157–164.

[11] GANDER, M. W., VRANA, J. D., VOJE, W. E., CAROTHERS, J. M., AND KLAVINS, E. Digital logic circuits in yeast with CRISPR-dCas9 NOR gates. *Nature communications* 8 (2017), 15459.

[12] GOLUB, G. H., AND VAN LOAN, C. F. *Matrix Computations*. The Johns Hopkins University Press, Baltimore, 1996. Third edition.

[13] GOTTESMAN, D. *Stabilizer codes and quantum error correction*. PhD thesis, Caltech, 1997.

[14] GUET, C. C., ELOWITZ, M. B., HSING, W., AND LEIBLER, S. Combinatorial synthesis of genetic networks. *Science* 296, 5572 (2002), 1466–1470.

[15] HANSEN, E. A., AND ZHOU, R. Anytime heuristic search. *J. Artif. Intell. Res.* 28 (2007), 267–297.

[16] HARROW, A. W., HASSIDIM, A., AND LLOYD, S. Quantum algorithm for linear systems of equations. *Phys. Rev. Lett.* 103 (2009), 150502.

[17] HEYFRON, L. E., AND CAMPBELL, E. T. An efficient quantum compiler that reduces T count. *Quantum Science and Technology* 4, 1 (2019), 015004.

[18] IKEDA, T., AND IMAI, H. Enhanced A\* algorithms for multiple alignments: Optimal alignments for several sequences and k-opt approximate alignments for large cases. *Theor. Comput. Sci.* 210, 2 (1999), 341–374.
[19] JIANG, J., SUN, X., TENG, S., WU, B., WU, K., AND ZHANG, J. Optimal space-depth trade-off of CNOT circuits in quantum logic synthesis. In *Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms, SODA 2020, Salt Lake City, UT, USA, January 5-8, 2020* (2020), S. Chawla, Ed., SIAM, pp. 213–229.

[20] KISSINGER, A., AND DE GRIEND, A. M. CNOT circuit extraction for topologically-constrained quantum memories. *Quantum Inf. Comput.* 20, 7&8 (2020), 581–596.

[21] KOK, P., MUNRO, W. J., NEMOTO, K., RALPH, T. C., DOWLING, J. P., AND MILBURN, G. J. Linear optical quantum computing with photonic qubits. *Reviews of Modern Physics* 79 (Jan 2007), 135–174.

[22] KORF, R. E. Depth-first iterative-deepening: An optimal admissible tree search. *Artificial intelligence* 27, 1 (1985), 97–109.

[23] KORF, R. E. *Artificial intelligence search algorithms*. 1996.

[24] KUTIN, S. A., MOULTON, D. P., AND SMITHLINE, L. Computation at a distance. *Chicago J. Theor. Comput. Sci.* 2007 (2007).

[25] LANDAUER, R. Irreversibility and heat generation in the computing process. *IBM journal of research and development* 5, 3 (1961), 183–191.

[26] LIKHACHEV, M., GORDON, G. J., AND THRUN, S. ARA*: Anytime A* with provable bounds on sub-optimality. In *Advances in neural information processing systems* (2004), pp. 767–774.

[27] MASLOV, D. Linear depth stabilizer and quantum Fourier transformation circuits with no auxiliary qubits in finite-neighbor quantum architectures. *Physical Review A* 76, 5 (2007), 052310.

[28] MASLOV, D. Optimal and asymptotically optimal NCT reversible circuits by the gate types. *Quantum Information & Computation* 16, 13&14 (2016), 1096–1112.

[29] MASLOV, D., AND ROETTELER, M. Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations. *IEEE Trans. Inf. Theory* 64, 7 (2018), 4729–4738.

[30] MEULI, G., SOEKEN, M., CAMPBELL, E., ROETTELER, M., AND MICHELI, G. D. The role of multiplicative complexity in compiling low $t$-count oracle circuits. In *Proceedings of the International Conference on Computer-Aided Design, ICCAD 2019, Westminster, CO, USA, November 4-7, 2019* (2019), D. Z. Pan, Ed., ACM, pp. 1–8.

[31] MEULI, G., SOEKEN, M., AND DE MICHELI, G. SAT-based {CNOT, T} quantum circuit synthesis. In *International Conference on Reversible Computation* (2018), Springer, pp. 175–188.

[32] MEULI, G., SOEKEN, M., ROETTELER, M., AND MICHELI, G. D. ROS: resource-constrained oracle synthesis for quantum computers. *CoRR abs/2005.00211* (2020).

[33] MONROE, D. Neuromorphic computing gets ready for the (really) big time, 2014.

[34] MOORE, G. E., ET AL. Progress in digital integrated electronics. In *Electron Devices Meeting* (1975), vol. 21, pp. 11–13.

[35] NAM, Y., ROSS, N. J., SU, Y., CHILDS, A. M., AND MASLOV, D. Automated optimization of large quantum circuits with continuous parameters. *npj Quantum Information* 4, 1 (2018), 23.

[36] NASH, B., GHEORGHIU, V., AND MOSCA, M. Quantum circuit optimizations for NISQ architectures. *Quantum Science and Technology* 5, 2 (2020), 025010.

[37] NIELSEN, M. A., AND CHUANG, I. L. *Quantum Computation and Quantum Information*. Cambridge University Press, 2011.

[38] PATEL, K. N., MARKOV, I. L., AND HAYES, J. P. Optimal synthesis of linear reversible circuits. *Quantum Information & Computation* 8, 3 (2008), 282–294.
[19] JIANG, J., SUN, X., TENG, S., WU, B., WU, K., AND ZHANG, J. Optimal space-depth trade-off of CNOT circuits in quantum logic synthesis. In *Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms, SODA 2020, Salt Lake City, UT, USA, January 5-8, 2020* (2020), S. Chawla, Ed., SIAM, pp. 213–229.

[20] KISSINGER, A., AND DE GRIEND, A. M. CNOT circuit extraction for topologically-constrained quantum memories. *Quantum Inf. Comput.* 20, 7&8 (2020), 581–596.

[21] KOK, P., MUNRO, W. J., NEMOTO, K., RALPH, T. C., DOWLING, J. P., AND MILBURN, G. J. Linear optical quantum computing with photonic qubits. *Reviews of Modern Physics* 79 (Jan 2007), 135–174.

[22] KORF, R. E. Depth-first iterative-deepening: An optimal admissible tree search. *Artificial intelligence* 27, 1 (1985), 97–109.

[23] KORF, R. E. *Artificial intelligence search algorithms*. 1996.

[24] KUTIN, S. A., MOULTON, D. P., AND SMITHLINE, L. Computation at a distance. *Chicago J. Theor. Comput. Sci.* 2007 (2007).

[25] LANDAUER, R. Irreversibility and heat generation in the computing process. *IBM journal of research and development* 5, 3 (1961), 183–191.

[26] LIKHACHEV, M., GORDON, G. J., AND THRUN, S. ARA*: Anytime A* with provable bounds on sub-optimality. In *Advances in neural information processing systems* (2004), pp. 767–774.

[27] MASLOV, D. Linear depth stabilizer and quantum Fourier transformation circuits with no auxiliary qubits in finite-neighbor quantum architectures. *Physical Review A* 76, 5 (2007), 052310.

[28] MASLOV, D. Optimal and asymptotically optimal NCT reversible circuits by the gate types. *Quantum Information & Computation* 16, 13&14 (2016), 1096–1112.

[29] MASLOV, D., AND ROETTELER, M. Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations. *IEEE Trans. Inf. Theory* 64, 7 (2018), 4729–4738.

[30] MEULI, G., SOEKEN, M., CAMPBELL, E., ROETTELER, M., AND MICHELI, G. D. The role of multiplicative complexity in compiling low $t$-count oracle circuits. In *Proceedings of the International Conference on Computer-Aided Design, ICCAD 2019, Westminster, CO, USA, November 4-7, 2019* (2019), D. Z. Pan, Ed., ACM, pp. 1–8.

[31] MEULI, G., SOEKEN, M., AND DE MICHELI, G. SAT-based {CNOT, T} quantum circuit synthesis. In *International Conference on Reversible Computation* (2018), Springer, pp. 175–188.

[32] MEULI, G., SOEKEN, M., ROETTELER, M., AND MICHELI, G. D. ROS: resource-constrained oracle synthesis for quantum computers. *CoRR abs/2005.00211* (2020).

[33] MONROE, D. Neuromorphic computing gets ready for the (really) big time, 2014.

[34] MOORE, G. E., ET AL. Progress in digital integrated electronics. In *Electron Devices Meeting* (1975), vol. 21, pp. 11–13.

[35] NAM, Y., ROSS, N. J., SU, Y., CHILDS, A. M., AND MASLOV, D. Automated optimization of large quantum circuits with continuous parameters. *npj Quantum Information* 4, 1 (2018), 23.

[36] NASH, B., GHEORGHIU, V., AND MOSCA, M. Quantum circuit optimizations for NISQ architectures. *Quantum Science and Technology* 5, 2 (2020), 025010.

[37] NIELSEN, M. A., AND CHUANG, I. L. *Quantum Computation and Quantum Information*. Cambridge University Press, 2011.

[38] PATEL, K. N., MARKOV, I. L., AND HAYES, J. P. Optimal synthesis of linear reversible circuits. *Quantum Information & Computation* 8, 3 (2008), 282–294.
[39] SAEEDI, M., AND MARKOV, I. L. Synthesis and optimization of reversible circuits—a survey. *ACM Computing Surveys (CSUR)* 45, 2 (2013), 1–34.

[40] SCHAEFFER, B., AND PERKOWSKI, M. A cost minimization approach to synthesis of linear reversible circuits. *arXiv preprint arXiv:1407.0070* (2014).

[41] SHOR, P. W. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. *SIAM review* 41, 2 (1999), 303–332.

[42] WILT, C., AND RUML, W. Effective heuristics for suboptimal best-first search. *Journal of Artificial Intelligence Research* 57 (2016), 273–306.

[43] WILT, C. M., THAYER, J. T., AND RUML, W. A comparison of greedy search algorithms. In *third annual symposium on combinatorial search* (2010).

[44] YOSHIZUMI, T., MIURA, T., AND ISHIDA, T. A* with partial expansion for large branching factor problems. In *Proceedings of the Seventeenth National Conference on Artificial Intelligence and Twelfth Conference on on Innovative Applications of Artificial Intelligence, July 30 - August 3, 2000, Austin, Texas, USA* (2000), H. A. Kautz and B. W. Porter, Eds., AAAI Press / The MIT Press, pp. 923–929.

[45] ZHAO, W., AGNUS, G., DERYCKE, V., FILORAMO, A., BOURGOIN, J., AND GAMRAT, C. Nanotube devices based crossbar architecture: toward neuromorphic computing. *Nanotechnology* 21, 17 (2010), 175202.

[46] ZHOU, R., AND HANSEN, E. A. Multiple sequence alignment using anytime A*. In *Proceedings of the Eighteenth National Conference on Artificial Intelligence and Fourteenth Conference on Innovative Applications of Artificial Intelligence, July 28 - August 1, 2002, Edmonton, Alberta, Canada* (2002), R. Dechter, M. J. Kearns, and R. S. Sutton, Eds., AAAI Press / The MIT Press, pp. 975–977.
[39] SAEEDI, M., AND MARKOV, I. L. Synthesis and optimization of reversible circuits—a survey. *ACM Computing Surveys (CSUR)* 45, 2 (2013), 1–34.

[40] SCHAEFFER, B., AND PERKOWSKI, M. A cost minimization approach to synthesis of linear reversible circuits. *arXiv preprint arXiv:1407.0070* (2014).

[41] SHOR, P. W. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. *SIAM review* 41, 2 (1999), 303–332.

[42] WILT, C., AND RUML, W. Effective heuristics for suboptimal best-first search. *Journal of Artificial Intelligence Research* 57 (2016), 273–306.

[43] WILT, C. M., THAYER, J. T., AND RUML, W. A comparison of greedy search algorithms. In *third annual symposium on combinatorial search* (2010).

[44] YOSHIZUMI, T., MIURA, T., AND ISHIDA, T. A* with partial expansion for large branching factor problems. In *Proceedings of the Seventeenth National Conference on Artificial Intelligence and Twelfth Conference on on Innovative Applications of Artificial Intelligence, July 30 - August 3, 2000, Austin, Texas, USA* (2000), H. A. Kautz and B. W. Porter, Eds., AAAI Press / The MIT Press, pp. 923–929.

[45] ZHAO, W., AGNUS, G., DERYCKE, V., FILORAMO, A., BOURGOIN, J., AND GAMRAT, C. Nanotube devices based crossbar architecture: toward neuromorphic computing. *Nanotechnology* 21, 17 (2010), 175202.

[46] ZHOU, R., AND HANSEN, E. A. Multiple sequence alignment using anytime A*. In *Proceedings of the Eighteenth National Conference on Artificial Intelligence and Fourteenth Conference on Innovative Applications of Artificial Intelligence, July 28 - August 1, 2002, Edmonton, Alberta, Canada* (2002), R. Dechter, M. J. Kearns, and R. S. Sutton, Eds., AAAI Press / The MIT Press, pp. 975–977.