This section explains the proposed Negative NCT gate library for building three-qubit reversible circuits. The Negative NCT gate library that works on three-qubit reversible circuits consists of three types of gates: one-qubit gates, two-qubit gates and three-qubit gates. This proposed library consists of 12 gates and their detailed information is represented in
Section 2. The 12 gates are three NOT gates, six OCNOT gates and three OToffoli gates. An implementation of the Schreier–Sims algorithm on the GAP software is used to generate the set of all possible three-qubit reversible circuits with the least length (40,319 circuits excluding the identity [
20]), which shows the universality of the Negative NCT gate library for 3-bit reversible circuits.
3.1. Gate Decomposition
Definition 2. Gate symbol is a unique symbol that refers to a gate where is an integer number. For example, and . Table 4 shows the gates with their corresponding gate symbol (sym.). The decomposition of a gate is a set of elementary gates that can be used to synthesize a quantum circuit equivalent to this gate, each set of these elementary gates is given a number d starting from 0. For example, represents the gate symbol in its 0th decomposition. One-qubit gates and two-qubit gates are elementary gates themselves; hence, each gate has only one decomposition denoted by the 0th decomposition, which is the gate itself.
Table 5 shows the Negative NCT gates with their corresponding decomposition(s) where each one-qubit gate or two-qubit gate has only one decomposition, which is the gate itself, while each three-qubit gate can be decomposed using (NOT, CNOT,
V,
) gates, which was shown to be optimal [
30]. The three-qubit gate has eight different decompositions.
Figure 2,
Figure 3 and
Figure 4 show the eight different decompositions for each OToffoli gate that depend on the Toffoli decompositions in [
21]. This paper uses only negative control decompositions, while [
21] uses only positive control decompositions.
Right and Left Gate Sets of a Decomposition
Definition 3. The ordered pair of a gate () is an ordered pair that contains the control qubit and the target qubit of a gate .
An example of an for a three-qubit system is , where the control is on the first qubit and the target is on the third qubit. , , , , and are some examples of gates in which their is .
Definition 4. The sets and of a circuit are the sets that contain the of the right-hand side gate and left-hand side gate, respectively.
The
set or the
set contains ordered pairs with the same control qubit or the same target qubit; otherwise the
set or the
set contains one
element only. An example of the
set of
gate in
Figure 2a is
, where the two ordered pairs in the
set have the same control qubit in this example and the
set of
gate is
. Another example of the
set of
gate in
Figure 3b is
and the
set of
gate is
, where the two ordered pairs in the
set have the same target qubit in this example.
Each decomposition of the OToffoli gates contains two gate sets; the
set and the
set where each of these sets contains
elements, the
of a gate is concerned with the control qubit and the target qubit only, and it does not concern with the condition on the control qubit nor the functionality of the gate itself. The
set and the
set of a decomposition contain the
of the gate on the right-hand side and the left-hand side, respectively. For example,
decomposition, which is shown in
Figure 2a has a left-hand side gate, which is
, where the control qubit is on qubit 2 (the second qubit) and the target qubit is on qubit 3 (the third qubit), so this gate’s
is (2,3); hence, the
set of
is
, if
gate and its next gate can be swapped, then the
of the
next gate can also be added to the
set;
cannot be swapped with
; hence, the
set for this decomposition remains unchanged. The right-hand side gate in
decomposition is
where this gate’s
is (1,3); hence, the
set of
is
if the
gate and its prior gate can be swapped then the
of
gate’s prior gate can be added to the
set;
can be swapped with
; hence, the
set is updated to
.
In two-qubit gates, the set = the set = the of the gate.
Table 6 shows the Negative NCT gates that have corresponding
and
sets.
3.3. Circuit Optimization Algorithm
Definition 8. The basic pair solitary () quantum cost is the summation of all quantum costs of all basic pairs and , which are used to build the circuit.
FunctionI (Algorithm 1) is used by the proposed circuit optimization algorithm (Algorithm 2) to reconstruct each circuit of the three-qubit system by using basic pairs of gates. In FunctionI (Algorithm 1), the gates are paired starting from the left-hand side gate of the circuit.
represents the corresponding basic pairs of the
ith and
ith + 1 gates in the circuit
C, if
S is odd, then the last gate on the right-hand side of the circuit is merged with the circuit as a
where
decomposes the OToffoli gate in its 0th decomposition and returns other gates unchanged. Finally,
applies optimization rules on the points of connection of the circuit.
Algorithm 1 FunctionI (C) |
function |
ifS = 1 |
then return (C) |
else if S ≠ 1 |
then for i ← 0 to S/2 |
|
ifS mod 2 = 1 |
then O+ = Solitary(CS) |
O = optimize(O) |
return (O) |
Algorithm 2 Circuit Optimization (ONCT) |
procedure |
for eachC ∈ ONCT |
do C = FunctionI(C) − |
For example, the
circuit has a quantum cost of 17 and is translated to
, and this circuit consists of five gates (where
), the reconstructed circuit is paired from the left-hand side into two pairs
and
maintaining the order of pairs from left to right; these pairs are replaced with their corresponding basic pairs;
with a quantum cost of 4 and
with a quantum cost of 7 according to
Table 7, the gate on the right-hand side is
and it will be decomposed into its decomposition number 0 since
S is odd, where
has a quantum cost of 1, the
quantum cost of this reconstructed circuit is 12 instead of 17 in the cost015 metric, the optimization rules are then applied on points of connection of the reconstructed circuit and the final quantum cost for this reconstructed circuit is 11.
Figure 8 shows the decomposition steps of the
circuit before and after applying the optimization rules. The dashed box in
Figure 8 refers to a two-qubit gate with a quantum cost of 1 [
15].
3.4. Modified Circuit Optimization Algorithm
In Algorithm 2, the optimization technique depends on FunctionI (Algorithm 1). FunctionII (Algorithm 3) splits the circuit into basic pairs starting from the second gate on the left-hand side instead of the first gate. If
S is odd and
, then the circuit is reconstructed as a
and basic pairs(s), while for even
, then the circuit is reconstructed as a
then basic pair(s) and finally a
. For example, the
circuit has a quantum cost of 11, which can be reconstructed using FunctionI (Algorithm 1) which results in two basic pairs and one
on the right-hand side:
with a quantum cost of 5,
with a quantum cost of 5 and
with a quantum cost of 0, the
quantum cost for this circuit using FunctionI (Algorithm 1) is 10; using FunctionII (Algorithm 3) gives one
on the left-hand side and two basic pairs:
with a quantum cost of 0,
with a quantum cost of 7 and
with a quantum cost of 1, where the
quantum cost for this circuit using FunctionII (Algorithm 3) is 8, the latter function shows a better quantum cost for this circuit and the final quantum cost using FunctionII (Algorithm 3) is 7 after applying the optimization rules on the points of connection instead of 11 in the cost015 metric as shown in
Figure 9.
Figure 9 illustrates the
circuit example before and after applying the optimization rules in the cost015 metric, the dashed box indicates forming a two-qubit gate with a quantum cost of 1 [
15].
Algorithm 3 FunctionII (C) |
function |
ifS = 1 |
then return (C) |
else if S = 2 |
|
else if S > 2 |
|
ifS mod 2 = 0 |
then O+ = Solitary(CS) |
O = optimize(O) |
return (O) |
IBM Quantum Experience
system [
31] was used to implement the
circuit, whose permutation was
. The
system has five qubits, a Canary r2 processor, with an average CNOT error of
, and average readout error of
. The IBM Quantum Experience does not currently support the
gate where qubit
qubit
b, so this gate is replaced with
gates since they are equivalent according to the splitting rules, which are the reverse of the merging rules in
Table 3. The IBM Quantum Experience does not also support the negative control qubit, so the positive control qubit is used and NOT gates are added before and after each positive control qubit in the quantum circuit as shown in
Figure 10 since they are equivalent according to [
32].
The reconstructed circuit
, which is obtained from applying FunctionII (Algorithm 3) is modified to be compatible with the
system by applying the splitting rules and the rule in
Figure 10. The implementation of the
circuit on the
system has a quantum cost of 7 as shown in
Figure 11, while the implementation of the equivalent quantum circuit, whose permutation is
using the NCT library has a quantum cost of 11 as shown in
Figure 12.
Some circuits have less quantum cost if they are reconstructed using FunctionI (Algorithm 1), other circuits have less quantum cost if FunctionII (Algorithm 3) is used to reconstruct them.
The modified circuit optimization algorithm (Algorithm 4) calculates the
quantum cost for each circuit using
of FunctionI (Algorithm 1) and FunctionII (Algorithm 3), then it chooses the function, which has less
quantum cost in order to reconstruct the quantum circuit, where
m represents a mark to the function having less
quantum cost.
Algorithm 4 Modified Circuit Optimization (ONCT) |
procedure |
for eachC ∈ ONCT |
|
For example, the
circuit, which is equivalent to the
permutation has a quantum cost of 8. The
quantum cost for the
circuit using FunctionI (Algorithm 1) is 6 and the
quantum cost using FunctionII (Algorithm 3) is 7, so Algorithm 4 chooses FunctionI (Algorithm 1) to decompose the circuit, where the circuit is reconstructed using two basic pairs, which are
with a quantum cost of 5, followed by
with a quantum cost of 1 according to [
15]. The
circuit is shown in
Figure 13 before optimization, after optimization, and the equivalent circuit on the
system after using the splitting rules and the preparation of negative gates as shown in
Figure 10. While the implementation of the equivalent
quantum circuit, whose permutation is
using the NCT library on the
system has a quantum cost of 15 as shown in
Figure 14.
From the examples in
Figure 13 and
Figure 14, it is shown that the Negative NCT library has less quantum cost for this example compared with the NCT library. Extending the Negative NCT library for
n-qubits, where n
is achievable since higher order gates can be decomposed into three-qubit gates according to [
30,
33].