1. Introduction
Quantum computing, utilizing quantum superposition, offers unprecedented computational power, enabling simultaneous computations beyond traditional computers [1]. This power opens up applications like drug discovery [2] and accelerated artificial intelligence [3].
Quantum software architecture is the design and structure of quantum computing systems, encompassing the organization of components, information flow, and framework for developing and deploying applications [4]. Key elements include quantum hardware abstraction [5], a quantum programming language [6], quantum algorithms [7], quantum error correction [8], optimizers [9], quantum simulators [10], and cloud-based quantum computing services [11]. Quantum hardware abstraction provides a unified interface for interacting with quantum devices, while quantum programming languages provide necessary abstractions and tools. Quantum algorithms may also be included in libraries or modules, enabling developers to leverage existing quantum algorithms for various applications. Integration between classical and quantum computing is crucial for realizing hybrid quantum-classical algorithms [12].
Quantum programming languages and frameworks are specialized tools for writing quantum algorithms and working with quantum computers [6]. Popular examples include Qiskit, Cirq, Quil, ProjectQ, and Q#. Qiskit is an open-source framework developed by IBM, providing a Python-based interface for working with quantum circuits, simulators, and devices. Cirq is a flexible framework by Google, while Quil is hardware-agnostic. ProjectQ supports multiple quantum backends. Q#, pronounced Q sharp, is a high-level language developed by Microsoft for writing quantum algorithms and interacting with quantum simulators and hardware. QASM is proposed to be an open quantum assembly language [13]. Quipper is a scalable quantum programming language [14]. Recent advancements in software framework development aim to compile quantum algorithms from high-level descriptions to physical gates for fault-tolerant quantum computers [15].
Tables 1-3 list the building blocks of quantum computing, known as quantum gates. Beside the name, each gate has a symbol and a matrix notation. Controlled-X is known as CNOT gate. SWAP gate can be decomposed of 3 CNOT gates.
Table 1. Quantum gates operating on 1 qubit.
Gate Name |
Gate Symbol |
Matrix Representation |
Pauli-X |
X |
|
Pauli-Y |
Y |
|
Pauli-Z |
Z |
|
Hadamard |
H |
|
Rotation-X |
|
|
Rotation-Y |
|
|
Rotation-Z |
|
|
S |
S |
|
T |
T |
|
R4 |
R4 |
|
Measure |
|
Qubit to Bit |
Table 2. Quantum gates operating on 2 qubits.
Gate Name |
Gate Symbol |
Matrix Representation |
CNOT |
|
|
SWAP |
|
|
Controlled-Y |
|
|
Controlled-Z |
|
|
Controlled-S |
|
|
Controlled-T |
|
|
Table 3. Quantum gates operating on 3 qubits.
Gate Name |
Gate Symbol |
Matrix Representation |
Toffoli |
|
|
The Gödel numbering is a widely used numbering scheme for computable functions, assigning a unique natural number to each function [16]. This method involves encoding the description of a function as a string and converting it into a number. The process involves creating a list of possible symbols, assigning a unique number to each symbol, and encoding the description of a function as a string.
This paper extends the numbering of programs as presented in [17] to be applied in the quantum computing context. Then and based on the proposed numbering approach, this paper presents a mechanism to explore the set of possible quantum algorithms in two ways, namely the forward way and the backward way. Finally, the paper validates the proposed numbering approach.
The contributions of this paper can be listed as follows:
Introducing the concept of numbering of programs in the quantum computing context,
Presenting a mechanism to explore the set of possible quantum algorithms in two ways,
The forward way of exploring quantum algorithms generates code of quantum circuits,
The backward way of exploring quantum algorithms construct quantum circuits from corresponding numbers, and
The proposed approach is able to construct useful circuits such as Quantum Key Distribution BB84 protocol.
The rest of this paper is structured as follows. Section 2 presents two of the most reputable quantum algorithms to show a glimpse of the specific nature of quantum algorithms as compared to classical ones. In Section 3, the proposed numbering approach is provided. Section 4 contains the conclusion and recommendations for further work.
2. Quantum Algorithms
2.1. Grover’s Quantum Search Algorithm
Grover’s quantum search algorithm, proposed by Lov Grover in 1996 [18], is a quantum algorithm for searching specific items in unsorted databases. It uses quantum operations, such as the Hadamard transform and phase inversion, to amplify the target item’s amplitude. The algorithm runtime is proportional to the square root of the database size, faster than classical algorithms. However, it has limitations, such as a quadratic speedup and requires a quantum computer.
First, we define the initial state of the quantum system as:
(1)
where N is the size of the database and
represents the state of the quantum system corresponding to the item
in the database.
Next, we define the quantum oracle that marks the target item as:
(2)
where
if
is the target item and
otherwise.
We then apply the Grover iteration, which consists of two steps:
Apply the quantum oracle:
(3)
Apply the Grover diffusion operator:
(4)
where the Grover diffusion operator is defined as:
(5)
and I is the identity operator.
The Grover iteration is repeated k times, where k is approximately equal to:
(6)
After k iterations, the quantum system is measured, and the target item is found with high probability.
2.1.1. Shor’s Quantum Algorithm for Factoring Integers
Shor’s quantum algorithm, proposed by Peter Shor in 1994 [19], efficiently factored large composite numbers into prime factors using quantum modular exponentiation. The algorithm uses a random number a between 1 and N − 1, and a quantum circuit constructed using quantum Fourier transform and modular exponentiation. The runtime is
, faster than classical algorithms but requires a large number of qubits.
Here are some of the key equations involved in the algorithm:
The quantum Fourier transform is used to convert the period finding problem into a phase estimation problem. The quantum Fourier transform of a state
is defined as:
(7)
where i is the imaginary unit and N is the size of the quantum register.
The quantum modular exponentiation is used to compute
efficiently using a quantum computer. It is defined as:
(8)
where
and
represents bitwise addition modulo 2.
The phase estimation algorithm is used to estimate the phase of the eigenvalue of the unitary operator
. It is based on the application of the quantum Fourier transform to a superposition of eigenstates of
:
(9)
where u is the eigenvector of
corresponding to the eigenvalue
.
The period r of the function
can be obtained from the phase estimate using continued fractions:
(10)
where q is a power of 2 and the coefficients
are obtained from the convergents of the continued fraction expansion of x/q.
Once the period r is obtained, N can be factored using classical methods. The factors are given by:
(11)
where gcd denotes the greatest common divisor.
3. Proposed Numbering Approach
3.1. Numbering the Set of Quantum Gates
To prove that the set of quantum gates, denoted by
, is effectively denumerable, we need to show that there exists a bijective mapping from the set of quantum gates to the set of natural numbers. In other words, we need to show that we can assign a unique natural number to each quantum gate. The set of quantum gates typically consist of a finite number of gates, such as H, X, Y, Z, CNOT, etc. Each gate can be uniquely identified by its name and the qubits it operates on. To establish a bijective mapping, we can assign a unique natural number to each possible combination of gate name and qubits.
For numbering the X gate:
(12)
For numbering the Y gate:
(13)
For numbering the Z gate:
(14)
For numbering the H gate:
(15)
For numbering the S gate:
(16)
For numbering the T gate:
(17)
For numbering the R4 gate:
(18)
For numbering the Measure gate:
(19)
For numbering the
gate:
(20)
For numbering the
gate:
(21)
For numbering the
gate:
(22)
For numbering the CNOT gate:
(23)
For numbering the SWAP gate:
(24)
For numbering the Controlled-Y gate:
(25)
For numbering the Controlled-Z gate:
(26)
For numbering the Controlled-S gate:
(27)
For numbering the Controlled-T gate:
(28)
For numbering the Toffoli gate:
(29)
where
(30)
and
(31)
To find
, find u and r such that
with
. This value of r indicates which kind of gate
is.
(32)
(33)
(34)
where
(35)
and
(36)
where
and
are computable functions defined as follows.
(37)
and
(38)
Note that at r = 18 is kept unused for future usages.
3.2. Numbering the Set of Quantum Circuits
To prove that the set C of all quantum circuits is effectively denumerable, we need to show that there exists a bijective mapping from the set of quantum circuits to the set of natural numbers. In other words, we need to show that we can assign a unique natural number to each quantum circuit. A quantum circuit consists of a sequence of quantum gates. To establish a bijective mapping, we can use a standard encoding scheme, such as the Gödel numbering. If circuit C is a sequence of gates:
then
(39)
where
(40)
Calculating
, relies on the fact that every natural number can be expressed as a binary number. Given c, we can find a unique numbers k and
such that
(41)
So,
where
and
(42)
where
For a circuit C, the number
is called the code or the number of that circuit. We can say that
= the circuit with code number n =
. We say that
is the nth circuit.
Note that if
, then
is different from
even that they may compute the same operation.
3.3. Exploring Quantum Algorithms: The Forward Way
Figure 1 shows the circuit of EPR creation. This circuit consists of Hadamard and CNOT gates. Let us calculate the number or the code of this circuit.
Figure 1. EPR creation.
It can be listed as:
For numbering the H gate:
For numbering the CNOT gate:
At m = 1 and n = 2, let us first calculate the
function
For numbering the CNOT gate:
Now, let us compute the code of that circuit.
= τ(2, 49)
=
=
= 4,503,599,627,370,499
Figure 2 shows the circuit of SWAP operation. This circuit consists of three CNOT gates. Let us calculate the number or the code of this circuit.
Figure 2. SWAP circuit.
It can be listed as:
We previously calculated CNOT(1, 2) = 49. For numbering the CNOT(2, 1) gate
At m = 2 and n = 1, let us first calculate the
function
For numbering the CNOT gate:
Now, let us compute the code of that circuit.
= τ(49, 30, 49)
=
=
= 562,949,953,421,312
+ 1,208,925,819,614,629,174,706,176
+ 1,361,129,467,683,753,853,853,498,429,727,072,845,824
− 1
= 1,645,504,558,087,453,812,587,913,611,736,524,018,557,
890,457,442,949,424,440,410,111
Note that this code for numbering the SWAP gate is the equivalent to
based on
and
Figure 3 shows the teleportation circuit. This circuit consists of Hadamard, CNOT, Measure, Controlled-Z, and Controlled- X gates. Let us calculate the number or the code of this circuit.
Figure 3. Teleportation circuit.
It can be listed as:
Let us code each of the gates as follows.
The number of the circuit can then be calculated.
= τ(22, 182, 49, 3, 7, 26, 185, 87)
=
+
+
− 1
=
= 4,194,304
+ 51,422,017,416,287,688,817,342,786,954,917,203,
280,710,495,801,049,370,729,644,032
+ 57,896,044,618,658,097,711,785,492,504,343,953,
926,634,992,332,820,282,019,728,792,003,956,564,819,
968
+ 926,336,713,898,529,563,388,567,880,069,503,262,
826,159,877,325,124,512,315,660,672,063,305,037,119,
488
+ 237,142,198,758,023,568,227,473,377,297,792,835,
283,496,928,595,231,875,152,809,132,048,206,089,502,
588,928
+ 31,828,687,130,226,345,097,944,463,881,396,533,
766,429,193,651,030,253,916,189,694,521,162,207,
808,802,136,034,115,584
+ 3,121,748,550,315,992,231,381,597,229,793,166,
305,748,598,142,664,971,150,859,156,959,625,371,
738,819,765,620,120,306,103,063,491,971,159,826,
931,121,406,622,895,447,975,679,288,285,306,290,
176
+ 966,134,380,754,314,586,173,837,972,732,996,836,
074,731,832,426,608,749,664,308,812,862,879,785,
572,390,106,134,048,441,645,480,644,490,615,904,
007,875,544,294,341,269,665,260,746,913,935,727,
168,366,770,187,174,245,203,705,856
− 1
= 966,134,380,754,314,586,173,837,975,854,745,386,
390,724,063,808,205,979,457,475,118,611,477,928,237,
361,257,025,034,088,639,205,159,924,866,743,949,573,
929,210,916,805,793,710,442,371,339,067,812,831,970,
988,587,388,382,478,335
Figure 4 shows the circuit of Quantum Fourier Transform (QFT). This circuit consists of Hadamard, Controlled-S, Controlled-T, and SWAP gates. Let us calculate the number or the code of this circuit.
Figure 4. Quantum Fourier transform.
It can be listed as:
Let us code each of the gates as follows.
The number of the circuit can then be calculated.
= τ(3, 34, 73, 22, 224, 41, 88)
=
+
+
- 1
=
= 8 + 274,877,906,944
+ 5,192,296,858,534,827,628,530,496,329,220,096
+ 43,556,142,965,880,123,323,311,949,751,266,331,
066,368
+ 2,348,542,582,773,833,227,889,480,596,789,337,
027,375,682,548,908,319,870,707,290,971,532,209,
025,114,608,443,463,698,998,384,768,703,031,934,976
+ 10,328,999,512,347,634,358,623,676,688,012,047,497,
318,823,171,316,894,051,322,637,426,162,590,488,067,
364,778,518,581,413,120,551,325,743,612,687,890,989,
973,504
+ 6,393,341,031,047,152,089,869,511,126,616,404,594,173,
128,996,177,860,916,959,553,453,312,761,321,102,879,990,
006,386,899,074,031,556,935,325,554,936,640,763,689,877,
454,191,182,408,307,282,280,448
− 1
= 6,393,341,031,047,152,089,869,511,136,945,404,106,
523,111,897,384,311,438,199,490,431,228,373,829,447,
149,723,877,932,645,107,329,335,974,222,586,036,484,
943,430,874,337,072,758,146,938,842,382,343
3.4. Exploring Quantum Algorithms: The Backward Way
The backward way of exploring quantum algorithms is shown in Figure 5. The algorithm takes the initial and last values of numbering. It starts with setting empty set to Cs which is the list of valid quantum circuits. It loops until it reaches a stopping condition or the loop iterator reaches the last value of numbering. At each iteration, it calculates the valid quantum circuit that is associated with a number equals to the iterator. Validity of a quantum circuit means that it performs a desirable operation based on evaluation of an expert. The author played the role of expert for recognizing useful quantum circuits.
One of useful applications of quantum circuits is Quantum Key Distribution (QKD) BB84 protocol [20] which is proved to be secure [21]. Quantum Key
Figure 5. Exploring quantum algorithms.
Distribution (QKD) is a cryptographic protocol that uses quantum mechanics to establish a shared key between Alice and Bob. The BB84 protocol, named after its inventors Charles Bennett and Gilles Brassard, involves initialization, transmission, basis selection, measurement, public announcement, key sifting, error estimation, privacy amplification, and key generation [22]. A full software stack to integrate QKD in a cloud context was proposed in a recent publication [23]. Another recent paper presented a simulation of the QKD BB84 protocol using IBM’s Qiskit quantum computing platform [24]. The simulation involves implementing the protocol with and without an eavesdropper Eve.
Table 4 shows the quantum part of the channel between Alice and Bob implementing BB84 Protocol on 5 Qubits. There is also a classical channel between them. The proposed approach can generate the circuits of BB84 protocol. But it depends on the ability of the implementation runner to recognize the circuits.
Table 4. BB84 Protocol on 5 Qubits.
4. Conclusion and Future Work
This paper reports the construction of an effective numbering of quantum gates and circuits. Then based on this numbering, quantum algorithms can be explored. There is a caveat in the implementation of the proposed numbering. As you may have noticed, the code or number of a quantum circuits grows very rapidly. Python’s ability to handle large numbers has limitations, including memory consumption and slower computation times, making it impractical for performance and resource usage.
A possible future work can be seeking an efficient implementation of precise large numbers. Another future direction may be to extend the proposed numbering approach to other layers of quantum software architecture.