XOR-AND-XOR Logic Forms for Autosymmetric Functions and Applications to Quantum Computing

—We propose a new three-level XOR-AND-XOR form for autosymmetric functions, called XORAX expression. In general, a Boolean function f over n variables is k -autosymmetric if it can be projected onto a smaller function f k , which depends on n − k variables only. We show that XORAX expressions can ease the reversible synthesis of autosymmetric functions, producing compact reversible networks, without inserting additional new input lines. Autosymmetry occurs especially for functions that exhibit a regular structure, as for instance arithmetic functions. For this reason, compact reversible networks for autosymmetric functions might be interesting for quantum computing. Experimental results validate the proposed approach.


I. INTRODUCTION
Autosymmetric Boolean functions are functions that exhibit a structural regularity based on the notion of affine spaces and are easily expressed using XORs.They were introduced in [20] and further studied in [4], [8], [9], [18], where it was shown how this regularity can be exploited to derive, in shorter synthesis time, compact logic representations for CMOS technology.More recently, the autosymmetry property has been applied in logic synthesis for emerging technologies, i.e., Switching Nano-Crossbars [7], and to better estimate the multiplicative complexity of functions for security protocols [5], [41].
The aim of this paper is to establish whether the concept of autosymmetry can ease the synthesis of Boolean functions also in the context of reversible and quantum circuits.Indeed, since autosymmetry often occurs for functions presenting a regular structure, as for instance arithmetic functions, compact reversible networks for autosymmetric functions might be interesting to ease the quantum circuit synthesis of subroutines given as classical functions, an issue occurring in many contexts (e.g., Shor's algorithm for factoring and discrete logarithm and Grover's search algorithm).
For this reason, we first propose a new three-level XOR-AND-XOR form, called XORAX, for autosymmetric functions, and then we analyze theroretically and experimentally the applications of this new logic form for the synthesis of reversible and quantum circuits.Note that a XORAX form A. Bernasconi, A. Berti, G. Del Corso, and I. Fulginiti are with the Department of Computer Science, Università di Pisa, Italy.{anna.bernasconi,gianna.delcorso}@unipi.it,alessandro.berti@phd.unipi.itV. Ciriani is with the Department of Computer Science, Università degli Studi di Milano, Italy.valentina.ciriani@unimi.itcan be described as a generalization of Exclusive-or Sum-of-Products (ESOP) expressions, that is an XOR of ANDs of literals.Indeed, a XORAX is an XOR of ANDs of XORs of literals.
Intuitively, a Boolean function f over n variables is kautosymmetric if it can be projected onto a smaller function f k that depends on n − k variables and contains a reduced number of minterms.The regularity of a Boolean function f is then measured computing its autosymmetry degree k, with 0 ≤ k ≤ n, where k = 0 means no regularity.In this paper we prove that the reduction from f to f k can be efficiently implemented onto reversible and quantum circuits using only a limited number of CNOT gates and without adding additional input lines/qubits to the networks.Moreover, since f k is smaller than the original function f , both in terms of input variables and number of on-set minterms, its reversible synthesis should be easier and should lead to more compact quantum circuits.
Observe that in an exact synthesis scenario the autosymmetry preprocessing would not be necessary.However, in more realistic scenarios where heuristic procedures are applied, the autosimmetry property can actually ease the synthesis process by simplifying the input instances.Indeed, the experimental results of this paper show that the heuristic procedures are not in general sensitive to autosymmetry, and therefore a preprocessing exploiting this regularity, often guarantees better synthesis results.
Autosymmetric functions are just a subset of all Boolean functions.Nevertheless, a considerable amount of standard functions of practical interest falls in this class.For instance, about 24% of the functions in the classical ESPRESSO benchmark suite [44] have at least one non degenerate autosymmetric output [8], [9], [10].Notice that, on the other hand, the total number of classical symmetric functions, i.e., the Boolean functions invariant under any permutation of their variables, is much lower [8].
We have experimentally evaluated the approach proposed for the reversible synthesis of autosymmetric functions starting from their XORAX expressions, with interesting results.The main goal of our experiments is first to verify whether ESOP standard minimization is sensitive to the autosymmetry regularity and it is able to exploit it.The experimental results clarify that this regularity is not detected, therefore a second set of experiments aims at analyzing the gain of using a preprocessing phase, detecting autosymmetry and representing functions in XORAX form, before standard reversible synthesis.
To better evaluate the quality of the circuits obtained, we study their cost in terms of elementary quantum gates, after the technology mapping using the Clifford+T library [1], [19], [27].We consider two different methods for quantum compilation: one based on standard ESOP minimization, and a more recent one presented in [23] that finds a quantum circuit starting from XOR-AND Graph (XAG) representations of logic functions.In both cases, our experiments show that the autosymmetry-based strategy guarantees gains in area (measured in terms of the number of elementary quantum gates) of about 40-45% and requires 41-43% fewer ancillary qubits, on average, for the subset of non-degenerate autosymmetric functions.
We finally observe that any other quantum compilation method could be applied, with the only requirement of adding (before and after the quantum circuit for f k ) a small number of elementary quantum gates (CNOTs) needed to implement the projection of the original function f onto f k .
The paper is organized as follows.Motivations and previous work on quantum logic synthesis are reviewed in Section II.Preliminaries on autosymmetric functions, ESOP forms, quantum computing, and reversible circuits are given in Section III.Sections IV introduces the new three-level XORAX form, and Section V discusses the strategy for constructing compact reversible circuits starting from XORAX forms.Section VI reports the experimental results.Finally, Section VII concludes the work.

II. MOTIVATIONS AND RELATED WORK
In this section we briefly discuss the motivations of our work, and review some representative recent work on logic synthesis for quantum computing.
In the last few years, we have witnessed a growing interest in quantum computing motivated by the technological enhancement in quantum architectures.The new architectures will be able to both solve new problems and increase the performance of algorithms in many different application domains by exploiting the inherent parallelism provided by quantum computers.At the same time, there still are several issues that should be addressed, for instance regarding the quantum circuit implementations of subroutines given as classical functions.In this regards, we recall that many quantum algorithms, including Shor's and Grover's algorithms, usually require to compute some classical logic functions, the socalled oracles [27].According to the postulates of Quantum Mechanics, the evolution of quantum systems is described by unitary operators, which are reversible.Thus, this implies that logic functions, and oracles, must be first realized in terms of reversible logic networks, whose gates are then translated into unitary quantum gates.
Moreover, today's quantum computers only support a very limited set of quantum operations natively.Thus, nonnative operations have to be decomposed into sequences of simpler native operations of the targeted quantum hardware.This decomposition should be performed with the goal of minimizing the overall gate count of the quantum circuits to be executed.This is precisely the reference context of our current work: we intend to establish whether the concept of regularity (in particular, autosymmetry) can ease the synthesis of Boolean functions in the context of reversible and quantum circuit synthesis, and can lead to circuits with a reduced number of elementary quantum gates, thus mitigating the impact of combinational logic on the cost of quantum algorithms.
Standard approaches to synthesize quantum oracles generally consist of two steps.The logic function is first embedded into a classical reversible circuit containing only reversible gates, as for instance multiple-controlled Toffoli gates derived from an ESOP expression [12], [14] (these notions are reviewed in Section III-D).The second step consists of mapping each reversible gate into a sequence of elementary quantum gates.Indeed, since quantum oracles are typically formulated in an abstract way that does not take into account the restrictions imposed by physical hardware, one or more compilation steps are always required in order to execute them on a given target hardware.
Recently, many new methods for reversible circuit synthesis and quantum compilation have been proposed in the literature.In [39] a hierarchical reversible synthesis approach based on k-feasible Boolean logic networks is proposed.These are logic networks in which every gate has at most k inputs, often referred to as k-LUT (lookup table) networks.This approach to reversible circuit synthesis outperforms other existing stateof-the-art hierarchical methods [37], [38], [42].
In [24] an efficient method to map reversible single-target gates into a universal set of quantum gates (the Clifford+T library [1], [19], [27]) is discussed.The proposed mapping method aims at reducing the cost of the resulting quantum network.The paper also proposes a post-synthesis optimization method to further reduce the cost of the final quantum network.
Finally, [23] presents a constructive compilation algorithm that finds a quantum circuit starting from XOR-AND Graph (XAG) representations of Boolean functions, i.e., Boolean networks consisting only of 2-input AND gates, 2-input XOR gates, and that can have constant-1 inputs.A very interesting result of this work is that the number of elementary quantum T gates in the final quantum circuit for a given function f depends on the number of AND gates used to represent the function f in XAG form.Thus, this result suggests a new upper bound on the number of T gates proportional to the multiplicative complexity of the function f , i.e., to the minimum number of AND gates required to realize f in XAG form [11]. Since, as proved in [5], the autosymmetry property can be exploited to better estimate the multiplicative complexity of functions, this approach to quantum compilation should be particularly convenient for the class of autosymmetric functions.
Other approaches have been proposed and discussed in the recent literature.In contrast to standard approaches, [45] proposes a new strategy for designing reversible circuits based on the idea of combining the embedding step, in which additional variables are added to the circuit, and the synthesis steps that produces the reversible circuit, into a single one, thus avoiding the growth in complexity of the function representation.
In [2] a post-synthesis optimization technique based on templates is proposed: the authors introduce several templates to merge two or more consecutive multiple-Toffoli gates and then replace the high-cost subroutines with equivalent lowcost solutions.Along with the templates, they also provide an algorithm for template-matching and thus for optimizing reversible circuits.
Finally, we refer the reader to [31] for more details on reversible circuits, and to [43] for an overview of efficient quantum compilation methods.

III. PRELIMINARIES
A. Autosymmetric functions Autosymmetric Boolean functions [9], [10], [20] exhibit a special type of regularity based on the notion of affine spaces and are easily expressed using XORs.A function f over n variables is autosymmetric if it can be projected onto a function depending on a smaller number of variables and containing a reduced number of minterms.More precisely, the autosymmetry of a Boolean function f is measured computing an autosymmetry degree k, with 0 ≤ k ≤ n: k = 0 means no regularity, while for k ≥ 1, f is said autosymmetric, and a new function f k depending on n − k variables only and called the restriction of f , is identified in time polynomial in the dimension of some standard representations of the original function f , for instance the dimension of a reduced ordered binary decision diagram (ROBDD) for f [9].In particular, [4] and [9] describe implicit procedures for the test, working on BDD representations of incompletely and completely specified Boolean functions, respectively.
An autosymmetric function f can be expressed in terms of its restriction f k as follows: where the n − k variables y 1 , y 2 , . .., y n−k are given by XOR combinations of subsets of the original input variables x i 's.These combinations are denoted XOR(X i ), where X i ⊆ {x 1 , x 2 , . . ., x n }, and the equations are called reduction equations.Thus, the autosymmetry test consists of finding the value of k, the restriction f k , and every single XOR with its input variables (i.e., reduction equations).
The autosymmetry of a function can be exploited for any logic minimization problem, according to the overall structure shown in Figure 2. In fact, the reduction from f to f k can be obtained with an additional logic level of XOR gates, whose inputs are the original variables x 1 , . . ., x n and the outputs are the new variables y 1 , . . ., y n−k , that become the inputs to a circuit for f k .For example, in [5], [6], autosymmetry has been exploited to ease the XAG synthesis and better evaluate the multiplicative complexity.In this work, we exploit this regularity in order to derive compact reversible and quantum circuits.
As shown in [9], [10], any k-autosymmetric function f is associated to a k-dimensional vector space L f , defined as the set of all minterms α s.t.
for all x ∈ {0, 1} n .The k variables that are truly independent onto L f are called canonical variables, while the other variables are called non-canonical.Informally, the canonical variables are the ones that assume all the possible combinations of {0, 1} values in the vectors of the vector space L f , meanwhile, the non-canonical variables are the variables that, on L f , have a constant value or are a linear combination of the canonical ones.Moreover, the restriction f k corresponds to the projection of f onto the subspace {0, 1} n−k where all the canonical variables assume value 0, while the reduction equations correspond to the linear combinations that define each non-canonical variable in terms of the canonical ones.
The restriction f k is "equivalent" to, but smaller than f , and has |S(f )|/2 k minterms only, where S(f ) denotes the support of f , and thus |S(f )| is the number of minterms of f .As we will discuss in this paper, the reversible synthesis of f can be reduced to the synthesis of its restriction f k , which can be identified in polynomial time, as already mentioned.
Example 1: Consider the function f , depending on n = 6 variables, depicted in Figure 1 (a).It is possible to verify that f is autosymmetric, with vector space L f = {000000, 001100, 110000, 111100}.Since the dimension of L f is k = 2, f is 2-autosymmetric.The canonical variables are x 1 and x 3 .Indeed, x 1 and x 3 assume all possible combinations of 0 and 1 values onto L f , meanwhile x 2 and x 4 are always equal to x 1 and x 3 , respectively, and x 5 and x 6 are constant and equal to 0. The reduction equations are , and y 4 = x 6 (for details on the computation see [9]).Thus, the restriction f 2 depends on 4 variables only and corresponds to the projection of the function f onto the space where x 1 = 0 and x 3 = 0, as it can be noted from Figures 1 (a) and 1 (b).Finally, we can reconstruct f from f 2 in the following way: Autosymmetric functions are a subset of the total number of Boolean functions.Nevertheless, as already mentioned, a considerable amount of functions of practical interest falls in the class of autosymmetric functions, i.e., about 24% of the functions in the classical ESPRESSO benchmark suite [44] have at least one truly (i.e., non degenerate) autosymmetric output [9], [10].Moreover, autosymmetry occurs especially for functions that exhibit a regular structure, as for instance arithmetic functions.For this reason, compact reversible networks for autosymmetric functions might be interesting for quantum computing.

B. ESOP forms
An Exclusive-or Sum-of-Products (ESOP) form is a twolevel Boolean expression consisting of one level of AND gates followed by one XOR gate on the second level (i.e., is an XOR of ANDs of literals).The problem of synthesizing an ESOP form for a given Boolean function f thus consists of identifying a set of product terms over the Boolean input variables of f such that each minterm in the off-set of f is covered by the product terms an even number of times, or never, while each minterm in the on-set is covered an odd number of times.Such a representation is not unique: a Boolean function can Fig. 1.A 2-autosymmetric Boolean function f in a Karnaugh map of six variables (on the left) and its restriction f 2 that depends on the new input variables , and y 4 = x 6 (on the right).
Level of XOR gates implementing the reduction equation A general network for an autosymmetric function f , defined using a network for the restriction f k , and an XOR layer implementing the reduction equations [9].The restriction f k can be synthesized in any framework of logic minimization, e.g., in SOP form, ESOP form, as an And-Inverter graph, as a XAG, etc.In particular, if f k is represented in ESOP form, the overall circuit corresponds to a XORAX expression.
be expressed by different, but semantically equivalent, ESOP forms.
Example 2: Consider the function f depicted in Figure 1 (a).f can be represented in ESOP form with 5 products and 10 literals as follows: Observe that the on-set minterm 000011 is covered only once by the product x 5 x 6 , the on-set minterm 111111 is covered by all the 5 products in the ESOP, the off-set minterm 111100 is covered 4 times, and so on.An alternative and functionally equivalent ESOP representation for f is given by the following expression ESOP forms play an important role in logic synthesis, design for tests, and other areas of computer technology.Indeed, they require fewer products than standard SOP forms to realize randomly generated functions [34], [35]; they are more compact than other two-level representations, especially for arithmetic or communication circuits [33]; they have excellent testability properties [15], [17]; finally, thanks to the reversibility of the XOR operation, ESOP forms represent the backbone of synthesis schemes for reversible logic circuits [12], [14], [16] and are therefore important for quantum computing.
For all these reasons, in the last decades several algorithms have been proposed for exact and heuristic minimization of ESOP forms [26], [28], [29], [30], [32], [36], with the aim of reducing the overall costs of their hardware realizations and software implementations.Heuristic methods focus on finding small (but not necessarily minimum) ESOP forms; they are fast, but only examine a subset of the possible search space.Heuristic methods, e.g., the Exorcism approach [26], usually operate in two phases.In the first phase, an ESOP form with a sub-optimal number of product terms is derived, e.g., by translating each minterm of the function into one product term; in the second phase, the ESOP form is iteratively optimized and reshaped using cube transformations with the overall goal of merging as many product terms as possible.The second phase terminates when, after several iterations, no further size reduction is achieved.For this reason, heuristic methods produce small ESOP forms in reasonable time, but suffer from local minima that cannot be easily escaped.On the other hand, exact methods try to find an ESOP form with a minimum  number of product terms, but they hardly can deal with more than 8 Boolean variables and a few product terms.Recently, an exact synthesis method based on Boolean satisfiability (SAT) has been proposed in [30].This novel approach is hardly affected by the number of Boolean variables and turns out to be particularly fast if the Boolean function can be expressed by using only a reduced number of product terms.

C. Qubits and Quantum operations
The unit of information of classical computation is the bit which can be either in state 0 or 1.Instead, the unit of information of quantum computation is the qubit and its state is a superposition of two basis states, |0 = 1 0 and |1 = 0 1 corresponding to the states 0 and 1 for a classical bit.The state |ψ of a qubit is described mathematically by a linear combination of the two basis states The evolution of a n-qubit quantum system is described by the multiplication of the state-vector, a vector of 2 n complex parameters, by 2 n × 2 n unitary matrices.Each quantum computation is then described as the composition of elementary quantum operations, or quantum gates, that act on one or two qubits and implement the abstract unitary matrices.This paper uses the so-called Clifford+T library, a universal and faulttolerant library.The generator gates in the Clifford+T group are and CNOT = I 0 0 X , where X = 0 1 1 0 .
This group includes also the Pauli matrices, which can be obtained by multiplying H and S gates, for example for the NOT gate denoted by X, we have X = HS 2 H.Quantum circuits are diagrams used to visualize the flux of computation.Each qubit is associated with a horizontal line (or a wire) and each operation (gate) with a box.Controlled gates are important gates acting on more than a qubit.Among them, the CNOT gate is the simplest and most important example.The NOT operation on the target (second) qubit is performed only when the control (first) qubit is |1 , otherwise it is left unchanged.In Figure 3 is depicted a simple circuit composed of a Hadamard gate (H gate) on the qubit |x 1 followed by a CNOT.Fig. 4. A MCMP Toffoli gate with four control lines, with polarities 0, 1, 0, and 1, respectively, where polarity 0 is represented by an empty bullet.

D. Reversible circuits
Reversible circuits are circuits with the same number of input and output signals that implement bijections, i.e., each input assignment maps to a unique output assignment.As a consequence, reversible computations can not only be performed from the inputs to the outputs but also in the other direction [13].A reversible circuit computes a reversible Boolean function, i.e., a bijective function that uniquely maps each input assignment to a unique output assignment and vice versa.Recall that an irreversible function can always be converted into a reversible one by adding extra outputs such that the input-output mapping is unique.
Reversible logic networks are usually composed as cascades of Toffoli gates [22], [25].Let X = {x 1 , x 2 , . . ., x n } be the set of input variables in the reversible circuit.A multiplecontrolled mixed-polarity (MCMP) Toffoli gate T (C, t) has a (possibly empty) set C ⊂ X of control lines, which are literals over X , and one target line t which is a variable in X \ C.
The MCMP Toffoli gate inverts the value of the variable assigned to the target line, if and only if the polarity of all inputs to the control lines match their polarity, or if C = ∅.All remaining values are passed through unaltered.More precisely, given C = {x c1 , x c2 , . . ., x c k } ⊂ X , the gate maps the target line , where p 1 , p 2 , . . ., p k denote the polarities, 0 or 1, of the control variables (i.e., x pi ci corresponds to x ci if p i = 1, and to x ci otherwise).Figure 4 illustrates one MCMP Toffoli gate with four control qubits.
An MCMP Toffoli gate is called a multiple-controlled (MC) Toffoli gate if all the control variables are positive literals, i.e., their polarities are all equal to 1.
Note that a MC Toffoli gate corresponds to the NOT (X) quantum gate if C = ∅, to the controlled NOT (CNOT) quantum gate if C contains only one variable, and to the standard Toffoli gate (used for computing the logic AND between two variables) if C contains two variables [27].
We can observe that there is a natural correspondence between product terms in an ESOP expression and MCMP Toffoli gates, and this is the reason why ESOP-based logic synthesis is widely used in reversible logic synthesis [12], [14], [16].Indeed, given an ESOP expression, one can extract a sequence of MCMP Toffoli gates whose control lines correspond to the literals in the product terms of the ESOP form.Observe that, when considering multiple-output functions, the resulting reversible circuit will contain n+m lines, where n is the number of input variables and m is the number of outputs of the function.
Example 3: Consider again the function f in our running example.From its ESOP representation (1), we can build the reversible circuit depicted in Figure 5.The circuit contains 5 standard Toffoli gates computing the AND of their two control variables.
Reversible logic synthesis, i.e., the ability to generate a reversible circuit for a given target function, has many applications, especially in the area of quantum computing.Indeed, as discussed in Section II, quantum algorithms consist of quantum and classical operations, and classical operations are first realized in terms of reversible logic networks.Such networks must then be mapped into quantum circuits using an additional synthesis step, whose goal is to transform reversible circuits of MCMP Toffoli gates into functionally equivalent quantum circuit implementations: input lines are translated into qubits and reversible gates, as MCMP Toffoli gates, are implemented into quantum circuits referring to a chosen quantum gate library [22], [25].This process often requires additional support qubits, that are called ancillary qubits.In this work, as already mentioned, we will refer to the Clifford+T library for this mapping step.

Innocenzo Fulginiti June 2021
Si consideri la funzione: Di seguito è presentato un circuito quantistico che realizza la funzione f.In questo caso, per costruire il circuito, sono stati utilizzati cinque porte di To↵oli.Si può definire un'altro circuito che realizza sempre la stessa funzione, ma utilizzando le funzioni XORAX e aggiungendo due nuovi qubit, y 1 e y 2 .La funzione si può scrivere come: Di seguito viene mostrato il circuito che rappresenta f nella forma appena vista.IV.THE XORAX SYNTHESIS For any given function f : {0, 1} n → {0, 1}, the algorithms for computing the autosymmetry degree k, the restriction f k and the reduction equations are polynomial in the dimension of a reduced ordered binary decision diagram (ROBDD) for f [9].Obviously, note that the dimension of the ROBDD of f might be exponential in the number n of input variables.
Thus, in the synthesis process for f (x 1 , . . ., x n ), we could first obtain and implement the reduction from f to f k , through the construction of the new variables y 1 , . . ., y n−k from the original ones x 1 , . . ., x n by an additional level of XOR gates, and then synthesize the restriction f k (y 1 , . . ., y n−k ) in any two-level logic framework.This gives rise to a three-level form for autosymmetric functions.
In general, we expect that the time required by the minimization of f k will be obviously less than the time required for the minimization of f , since f k is defined on a smaller space: it depends only on n−k variables and has |S(f )|/2 k minterms only, where |S(f )| is the number of on-set minterms of f .A similar approach has been studied and proven to be particularly convenient within standard SOP (Sum of Products) minimization: a three-level OR-AND-XOR form (shortly, ORAX form) has been defined and experimentally evaluated in [10].
Unfortunately, the OR operator is not suited for reversible logic synthesis.For this reason, here we focus on ESOP synthesis and introduce a new three-level XOR-AND-XOR form for autosymmetric functions, which we call XORAX expression.In particular, since several methods in quantum synthesis start from ESOP (XOR-AND) forms instead of SOP (OR-AND) expressions, we consider here XORAX forms, that are a natural extension of ESOP forms, instead of ORAX (OR-AND-XOR) expressions.
As already mentioned, this expression can be derived by first running the autosymmetry test to detect the reduction equations and the restriction f k , and then by synthesizing in ESOP form the restriction f k only.
The reduction from f to f k is obtained through an initial logic level composed of XOR gates that implements the reduction equations.The inputs are the original variables x 1 , . . ., x n and the outputs are the new variables y 1 , . . ., y n−k , that become the inputs to a minimal ESOP form for f k , according to the network decomposition depicted in Figure 2. Notice that, if the function f is not autosymmetric, XORAX and ESOP expressions coincide.
Example 4: Consider again the function f and its restriction f 2 depicted in Figure 1.Recall from Example 1 that the reduction equations are y 1 = x 1 ⊕ x 2 , y 2 = x 3 ⊕ x 4 , y 3 = x 5 , and y 4 = x 6 .A minimal ESOP for f 2 is given by ESOP (f 2 ) = y 1 y 2 ⊕ y 3 y 4 , and the XORAX of f is then obtained by adding a level of XORs: Note how this expression is more compact than the ESOP representation (1) for f : it contains only 6 literals and 2 products, while ESOP (f ) contains 5 products and 10 literals.
As shown also by this simple example, in general, a minimal XORAX form has a smaller size than a standard minimal ESOP form for the same function, thanks to the extra level of XOR gates.Moreover, the gain in size can also become exponential, as proved in the following proposition.
Proposition 1: A XORAX form for a function f can be exponentially smaller than a minimal ESOP expression for f .Proof.To prove the proposition, we show an example of a function whose XORAX contains only one product of XOR combinations, while a minimal ESOP contains an exponential number of products.Consider the autosymmetric function f , that depends on n = 2m binary variables and whose XORAX form is This form contains n literals and just one product of m = n/2 XOR combinations of two variables each.This is a conse- quence of the fact that f is m-autosymmetric, with reduction equations y i = x 2i−1 ⊕ x 2i , 1 ≤ i ≤ m, and with restriction A minimal ESOP for f instead contains 2 m = 2 n/2 products, each containing m variables.This can be proved by induction on n, exploiting the fact that, when we add a new factor (x n+1 ⊕ x n+2 ), the resulting function f = f • (x n+1 ⊕ x n+2 ) is such that the cofactors obtained assigning a value to x n+1 and x n+2 , satisfy f 00 = f 11 = 0 and f 01 = f 10 = f .This, in turn, implies that any ESOP for f must contain an ESOP for f multiplied by x n+1 , and one multiplied by x n+2 .Thus, the number of products doubles each time leading to an exponential growth.

V. CONSTRUCTION OF REVERSIBLE CIRCUITS FROM XORAX FORMS
As reviewed in Sections III-B and III-D, ESOP-based logic synthesis is widely used in reversible logic synthesis because of the natural correspondence between product terms in an ESOP expression and MCMP Toffoli gates.
In particular, given an ESOP expression, one can easily extract a sequence of MCMP Toffoli gates whose control lines correspond to the literals in the product terms of the ESOP form, and whose target lines correspond to the output of the function.Notice that all MCMP Toffoli gates act on the same target line, thus realizing the exclusive OR sum of all product terms.
In this section, we propose a method for deriving compact reversible circuits computing k-autosymmetric functions, starting from their representation in XORAX form.The idea of the approach is to concatenate two circuits: a circuit implementing the transformation from the old input variables X = {x 1 , x 2 , . . ., x n } to the new n − k variables and a circuit implementing the restriction f k .
Observe that this approach will require n−k new lines (and therefore n − k new qubits in the quantum implementation of the reversible circuit for f ), corresponding to the new variables y 1 , . . ., y n−k .
Each reduction equation y i = XOR(X i ), where X i ⊆ X and i = 1, . . ., n − k, is then implemented through CNOT gates, one for any variable in X i .The control line of each CNOT corresponds to a different variable in X i , eventually complemented using a NOT gate, while the target line corresponds to the new variable y i .Then, the new variables y 1 , . . ., y n−k are used as control variables in the cascade of MCMP Toffoli gates implementing a reversible circuit for the restriction f k , as shown in Figure 6 (a).
The number of lines, and therefore of qubits, grows up to a factor 2 with respect to a standard reversible circuit build from an ESOP of f , but the reduced number of products and literals in the ESOP for f k should compensate the cost of the additional input lines, trading-off the number of qubits for the number of quantum gates.
However, due to the current technological limitations of quantum circuits (current machines contain just a few dozen qubits), it is very important to keep the number of input qubits as low as possible.Fortunately, the structural properties of autosymmetric functions can be better exploited, so that no additional input qubits must be added to the network for the new variables, as proved in the following proposition.
Proposition 2: Let f : {0, 1} n → {0, 1} be a k autosymmetric function, with vector space L f and restriction f k .Then, a reversible circuit for f can be derived from a reversible circuit for the restriction f k without adding new input lines, nor new MCMP Toffoli gates.Proof.Recall from Section III-A that any k-autosymmetric function f is associated to a k-dimensional vector space L f .Onto this space, only the k canonical variables are truly independent, i.e., can assume all the possible combinations of {0, 1} values.The remaining non-canonical variables have a constant value or are defined by linear combinations of the canonical ones.
These linear combinations can be used to derive the reduction equations, that precisely define each non-canonical variable in terms of the canonical ones.As proved in [9], each non-canonical variable appears in one and only one reduction equation, alone or in XOR combination with a subset of canonical variables.Thus, instead of adding new inputs, we can implement each equations y i = XOR(X i ), simply modifying the only non-canonical variable in X i .
In particular, the non-canonical variable is used as target variable, while the remaining canonical variables in X i , if any, are used as control variables in the CNOTs used to implement the linear combination defining the non-canonical one.The procedure is correct since the non-canonical variable that has been modified does not occur in any other reduction equation.Finally, we can use the n−k modified non-canonical variables as input variables for the reversible circuit implementing f k .
Once f has been computed on the output line, we can restore the non-canonical variables to their initial values applying the so-called uncomputing procedure [3], [27].Basically, we uncompute the linear combinations stored in the noncanonical variables by re-applying the CNOT gates used to implement the corresponding reduction equations in reverse order.This disentangles the variables, reverting them to their initial values.
Example 5: Let us consider the function f in our running example, and its XORAX representation (2).The reduction equations y 1 = x 1 ⊕ x 2 , y 2 = x 3 ⊕ x 4 , y 3 = x 5 , and y 4 = x 6 can be translated into the first two CNOT gates in Figure 6 (b) (blue box).The ESOP representation of the restriction f 2 , ESOP (f 2 ) = y 1 y 2 ⊕ y 3 y 4 , is represented by the two CNOTs in the red box.Finally, the last two CNOT gates (green box) are used for the uncomputing procedure on the non-canonical variables.
We finally observe that the methodology that we have proposed to derive a reversible circuit for an autosymmetric function is very flexible.Here we have considered the standard technique based on ESOP minimization, however we could apply any other reversible synthesis technique to the restriction f k , with the only requirement of adding (before and after the reversible circuit for f k ) the CNOT gates needed to implement and then to uncompute the reduction equations.In this section, we report our experimental results.First of all, we consider the practical gain, in terms of area, of XORAX forms with respect to ESOP expressions.(Recall that, by theoretical results, the area gain can be exponential.)Second, we evaluate the proposed decomposition in the context of reversible and quantum circuit synthesis, considering two different quantum compilation strategies.

VI. EXPERIMENTAL RESULTS
Note that, as several methods in quantum synthesis start from ESOP (XOR-AND) forms instead of SOP (OR-AND) expressions, we consider XORAX (XOR-AND-XOR) forms instead of ORAX (OR-AND-XOR) expressions.
Our method has been tested on autosymmetric functions taken from the LGSynth'89 benchmark suite [44] and the EPFL benchmark suite [40], [41].Observe that autosymmetry is a property of single outputs, i.e., different outputs of the same benchmark can have different autosymmetry degrees.Therefore, we perform the autosymmetry test on single outputs of the benchmark functions.
We consider only proper autosymmetric functions, i.e., autosymmetric functions whose reduction equations contain at least one XOR operator.Notice that this choice excludes all functions whose autosymmetry is only due to the fact that they are degenerate.
The experiments have been run on a Pentium Intel core i7-6700HQ, 4 core, 2.60 GHz processor with 16GB RAM.
The first aim of the experiments is to compare the XO-RAX expression of an autosymmetric function and the corresponding ESOP form.For this purpose, we perform the autosymmetry test [4] (for non-completely specified functions) on the benchmark outputs.The functions f and f k are then minimized in ESOP form, using EXORCISM-4 [26].The average gain, in using XORAX expressions with respect to ESOP ones, is about 40% of literals in the form.Due to the heuristic nature of the ESOP minimizer, the synthesis times for the function f and the corresponding restriction f k are quite similar and very short (of order of 10 −2 seconds on average).Therefore, in our experiments, the gain in synthesis time is negligible.
This set of experiments verifies that the standard ESOP minimization is not sensitive to autosymmetry.Therefore, we propose a preprocessing phase detecting autosymmetry before standard reversible synthesis, as shown in the following set of experiments.
A. ESOP-and XORAX-based quantum circuit synthesis.
We now evaluate the impact of using XORAX forms for autosymmetric functions in quantum circuit synthesis.We emphasized in Section III-D the correspondence between ESOP expressions and multi-controlled Toffoli gates.However, controlled Toffoli gates are only an intermediate representation that needs to be mapped into elementary quantum gates.To perform this additional step, we select the universal faulttolerant Clifford+T quantum gate library [1], [19], [27] as lowlevel gate library.
The cost model for this last synthesis step is non-trivial.In general, heuristics try to minimize the number of MCMP  Toffoli gates and the number of control lines inside each gate in the reversible circuit that must be transformed into a quantum one.This in turn corresponds to minimize the number of products in the ESOP expression and the number of literals in each product, respectively, as smaller ESOP expressions naturally lead to fewer and smaller MCMP Toffoli gates.
As reviewed in Section III-C, the Clifford+T library is composed of the Pauli, Hadamard, and CNOT gates and of the additional non-Clifford T gate.Since the T gate is considered the most expensive gate in the library, usually the cost of a Toffoli gate is expressed in the number of T gates needed for its realization and the algorithms for the mapping of kcontrolled Toffoli gates minimize respect to this measure.In Table I we report the cost in terms of Hadamard, CNOTs, and T gates of the realization of k-controlled Toffoli gates with the algorithm described in [21].We report also the number of ancillary qubits used.Ancillas indeed impact the efficiency of connections between primary qubits.Both kinds of qubits share the same physical space and they need to be close to each other to ensure high efficiency.
Table II reports a significant subset of benchmarks as representative indicators of our experiments.The first column reports the name, the number of the considered output of each benchmark and the autosymmetry degree.The second column reports the number of inputs of the benchmark.The following group of 4 columns reports the costs, in terms of elementary quantum gates, of the quantum circuits derived from the ESOP representation of the functions, while the last group of 4 columns reports the costs of the circuits derived from the XORAX representation.The last column reports the gain in the number of T gates.The last row reports the average costs for all the benchmarks considered in our experiments.
The gain obtained synthesizing a quantum circuit starting from XORAX forms instead of ESOP ones is quite interesting.Indeed, the cost gain for T gates is about 46%, the cost gain for H gates is about 47%, the cost gain for CNOTs is about 45%, and the gain in ancillary qubits is about 43%, as shown in Table III.
Some particular benchmarks highly benefit from the pro-posed strategy.For example, the benchmark dk48 9 can be represented, exploiting the autosymmetry of the function, with a gain of 92%, in T gates.We can notice that benchmarks with a high autosymmetry degree often have a very high gain in T gates.See, for example, pdc 22 that has an autosymmetry degree 4 and has a gain of about 94%.
For other benchmarks we do not obtain any significant gain, for example add6 5 and in5 3. We can notice that there are cases, e.g., in5 3, where even if the autosymmetry degree is high, e.g., 5, the gain in T nodes is not relevant.In the specific case of the benchmark in5 3, we can notice that the proposed method gives a very high gain in terms of CNOT gates.This is due to the fact that, using our method, the XORs of the circuit have been factorized in the reduction equations.
Finally, we can observe that even if, in general, arithmetic functions are autosymmetric, this does not directly imply that arithmetic functions always benefit from this strategy.In fact the arithmetic benchmark add6 5 is autosymmetric, but the proposed method does not give any gain in terms of T gates.Also in this case, the main advantage is the gain in CNOT gates.To further confirm the efficacy of the autosymmetry-based synthesis strategy, we run another set of experiments considering the recent quantum compilation method proposed in [23].Indeed, as already pointed out, autosymmetry can be exploited by different optimization methods, simply adapting the general decomposition scheme shown in Figure 2 to the chosen framework.In the context of quantum compilation, this task simply requires to add (before and after any quantum circuit for the restriction f k ) some CNOT gates, acting on  the non-canonical input variables of f , in order to implement, and then to uncompute, the reduction equations.Recall that, as proved in Proposition 2, this task does not require any additional ancillary qubit.
These last experiments were run on two AMD EPYC 7282 processors with 16 cores each, at 2.8GHz, with 504GB of RAM in total.
The quantum compilation heuristic discussed in [23] starts from a XAG representation of a Boolean function f (a network consisting only of 2-input AND and XOR gates, and that can have constant-1 inputs), and targets quantum circuits over the Clifford+T gate set.
The experimental results show that, also for this method, the autosymmetry-based approach guarantees an overall reduction not only in the number of T gates, but also in the number of CNOT gates, T-depth, ancillary qubits, and compilation time.In particular, compiling a quantum circuit starting from a XAG for f k , instead of a XAG for f , we can obtain a cost gain in T gates of about 43%, a gain in CNOTs of about 39%, a gain in T-depth of 23%, and a gain in the number of ancillary qubits of about 41%, as shown in Table V.The computational times required by this compilation step are very short (a few milliseconds on average), with autosymmetrybased compilation about 66% faster on average.
We report in Table IV a subset of all the benchmarks that are considered for our experiments.The first column contains the name, the number of the output, and the autosymmetry degree of the considered benchmark.The second column reports the number of inputs of the benchmark.The following group of 4 columns reports the costs, in terms of elementary quantum gates, of the quantum circuit derived from the XAG representation of the function f , while the last group of 4 columns reports the costs of the quantum circuit for f derived from the XAG for f k and the reduction equations.The last column reports the gain in the number of T gates.The last row reports the average costs for all the benchmarks considered in our experiments.
We first observe that the overall T cost of the XAG based quantum compiler is much lower than the corresponding cost of the circuits derived from ESOP forms (see Tables II and IV).Moreover, from Table IV, we observe that there are cases where the proposed strategy gives a circuit with an higher number of T gates (see for instance, in5 3 and m181 6 ).This fact is due to the heuristic nature of the XAG optimization and of the quantum compiler.In any case, the overall T gain of the entire benchmark suite is very encouraging (i.e., 43%).Interesting enough, comparing the two Tables II and IV we notice that the autosymmetry property gives very different T gains.For example, add6 5 shows no T gain in Table II and presents a T gain of about 38% in Table IV.Conversely, the benchmark dk48 9 has no T gain for the XAG approach (Table IV) and 92% of T gain in Table II.This is due to the very different approaches of the two quantum compilers considered.

VII. CONCLUSION
In this paper we have proposed and evaluated a methodology to derive compact reversible circuits for autosymmetric functions.This methodology is very flexible and can be applied to any quantum compilation method.We have experimentally tested two different compilation methods, the classic one based on ESOP minimization, and a more recent one, based on XAG representations of logic functions.
As future work, it would be interesting to verify whether other quantum synthesis techniques are sensitive to this structural regularities and are able to exploit it in the optimization process.
This article has been accepted for publication in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.This is the author's version which has not been fully edit content may change prior to final publication.Citation information: DOI 10.1109/TCAD.2022.3213214This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.This is the author's version which has not been fully edit content may change prior to final publication.Citation information: DOI 10.1109/TCAD.2022.3213214This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/

Fig. 5 .
Fig. 5.A reversible circuit for the function f , derived from the ESOP representation (1).
This article has been accepted for publication in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.This is the author's version which has not been fully edit content may change prior to final publication.Citation information: DOI 10.1109/TCAD.2022.3213214This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/

Fig. 6 .
Fig. 6.Reversible circuits, with and without new lines, for the function f of the running example, derived from its XORAX representation (2).The last two CNOTs of the circuit (b) are used for restoring the two non-canonical variables x 2 and x 4 to their initial values.
This article has been accepted for publication in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.This is the author's version which has not been fully edit content may change prior to final publication.Citation information: DOI 10.1109/TCAD.2022.3213214This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/

TABLE I THE
COST OF k-CONTROLLED TOFFOLI GATES IN NUMBER OF T, H AND

TABLE II COMPARISON
BETWEEN QUANTUM CIRCUITS COMPUTED WITHOUT AND WITH AUTOSYMMETRY TEST, STARTING FROM ESOPS

TABLE III THE
GAIN FOR T, H, CNOT GATES AND ANCILLARY QUBITS FOR THE This article has been accepted for publication in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.This is the author's version which has not been fully edit content may change prior to final publication.Citation information: DOI 10.1109/TCAD.2022.3213214This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/

TABLE IV COMPARISON
BETWEEN QUANTUM CIRCUITS COMPUTED WITHOUT AND WITH AUTOSYMMETRY TEST, STARTING FROM XAGS (COMPUTATIONAL TIMES ARE OF A FEW MILLISECONDS ON AVERAGE AND ARE NOT REPORTED)

TABLE V THE
GAIN FOR T AND CNOT GATES, T-DEPTH, AND ANCILLARY QUBITS