Challenges
Datasets
Workspaces
Papers
Discussions
Leaderboard
Log inSign up
Challenges
Datasets
Workspaces
Papers
Discussions
Leaderboard
Blog
Job Board
Q3AS

© 2026 Aqora Quantum S.A.S.

TermsPrivacyLegal Notice

Proceedings of the Romanian Academy Series A Mathematics Physics Technical Sciences Information Science

Two examples of implementation of the if/then/else conditional statement with quantum computers

Guang Ping He

Published Sep 30, 2023• 0 citations
Publisher

Abstract

While quantum algorithms are known to be very powerful, there are also people who think that “quantum computers will never be able to run the if/then/else type of logic”. On the other hand, though many experts know that such a claim is a misconception, in literature there is still lacking of a general description of the procedure for implementing the if/then/else conditional statements in the quantum way. In the current work, we present such a general method in details, explaining how the unitary transformation required for any if/then/else operation can be constructed from simpler unitary transformations and projective operators. Moreover, by using the well-known controlled-NOT gate, Fredkin gate and Toffoli gate as examples, it is elaborated that the structure of the existing conditional quantum operations agrees with our general method. An even more complicated example is also provided, showing that our method is convenient for solving real-world if/then/else problems with quantum computers. Thus the result not only refutes the above claim, but also helps to develop the skill on quantum programming.

DOI
10.59277/pra-ser.a.24.3.09

Related papers

Programming with Quantum-Controlled Quantum Channels

Kengo Hirata, Takeshi Tsukada

In contrast to a classical bit, which can only take the value $0$ or $1$, its quantum counterpart -- a qubit -- can exist in a superposition of $0$ and $1$. This is a superposition of data values, naturally raising the question of whether one can superpose not only data but also programs. For example, a particular superposition of programs, known as the quantum SWITCH, has attracted much attention, and its implementations and computational advantages have been studied extensively within the physics community. A naive way to control a program by a qubit is by means of a controlled operation. Given an operation $F$, this amounts to considering an operation that behaves as $F$ when the control qubit is $|1\rangle$, and as the identity operation when the control qubit is $|0\rangle$. This idea works well when $F$ is a unitary operation, but it is not well-defined for a general quantum channel. By contrast, the quantum SWITCH is free from the well-definedness issue. This contrast leads to the key insight of this paper: controlled operations and the quantum SWITCH should be regarded as different kinds of quantum control mechanisms. Building on this insight, we develop a novel quantum programming language with quantum control and measurement that can express the quantum SWITCH over quantum channels. Using a semantic analysis based on program transformations, we identify the source of the ill-behavedness of controlled operations as the \emph{correspondence problem}: a lack of coordination between the measurements performed in the then- and else-branches of quantum conditional branching. We address this problem with a linear type system that enforces alignment of the quantum operations used in the two branches, yielding a well-behaved language capable of expressing the quantum SWITCH.

cs.PLCross-listedarXiv:2607.15873•Jul 20, 2026•0 citations

Quantum logic gates and circuits

Vinod Kumar Khanna

A quantum gate is the quantum analog of the classical logic gate of digital computers. It is a basic structural unit of a quantum circuit which operates on a small number of qubits to deliver a predefined output. A quantum circuit is a graphical representation of the sequence of the quantum gates used and the measurements performed in a quantum computation. Various quantum logic gates, namely, the Hadamard, T phase, NOT, Pauli-X, controlled NOT (CNOT), controlled-Z, SWAP and controlled phase gates as well as higher-level Toffoli and Fredkin gates are described. Conventions of reading quantum circuit diagrams are explained. Operation of a quantum full adder consisting of registers and gates is discussed, elaborating the role of the NOT gate, the sum calculation with CNOTgates and the carry C-out calculation with Toffoli gates. A primary tool used for performing arithmetic operations on a quantum computer is the quantum Fourier transform (QFT). The QFT adder and multiplier circuits are presented.

Institute of Physics eBooks•Jan 1, 2025•0 citations

Quantum conditional operations

Alessandro Bisio, Michele Dall’Arno, Paolo Perinotti

An essential element of classical computation is the ``if-then'' construct, that accepts a control bit and an arbitrary gate, and provides conditional execution of the gate depending on the value of the controlling bit. On the other hand, quantum theory prevents the existence of an analogous universal construct accepting a control qubit and an arbitrary quantum gate as its input. Nevertheless, there are controllable sets of quantum gates for which such a construct exists. Here we provide a necessary and sufficient condition for a set of unitary transformations to be controllable, and we give a complete characterization of controllable sets in the two-dimensional case. This result reveals an interesting connection between the problem of controllability and the problem of extracting information from an unknown quantum gate while using it.

arXiv:1509.01062•Physical Review A•Aug 30, 2016•20 citations

A Systematic Algorithm for Quantum Boolean Circuits Construction

I.-M. Tsai, Sy‐Yen Kuo

To build a general-purpose quantum computer, it is crucial for the quantum devices to implement classical boolean logic. A straightforward realization of quantum boolean logic is to use auxiliary qubits as intermediate storage. This inefficient implementation causes a large number of auxiliary qubits to be used. In this paper, we have derived a systematic way of realizing any general m-to-n bit combinational boolean logic using elementary quantum gates. Our approach transforms the m-to-n bit classical mapping into a t-bit unitary quantum operation with minimum number of auxiliary qubits, then a variation of Toffoli gate is used as the basic building block to construct the unitary operation. Finally, each of these building blocks can be decomposed into one-bit rotation and two-bit control-U gates. The efficiency of the network is taken into consideration by formulating it as a constrained set partitioning problem.

arXiv:quant-ph/0104037•Apr 9, 2001•2 citations

Optimal simulation of three-qubit gates

Nengkun Yu, Mingsheng Ying

In this paper, we study the optimal simulation of three-qubit unitary by using two-qubit gates. First, we give a lower bound on the two-qubit gates cost of simulating a multi-qubit gate. Secondly, we completely characterize the two-qubit gate cost of simulating a three-qubit controlled controlled gate by generalizing our result on the cost of Toffoli gate. The function of controlled controlled gate is simply a three-qubit controlled unitary gate and can be intuitively explained as follows: the gate will output the states of the two control qubit directly, and apply the given one-qubit unitary $u$ on the target qubit only if both the states of the control are $\ket{1}$. Previously, it is only known that five two-qubit gates is sufficient for implementing such a gate [Sleator and Weinfurter, Phys. Rev. Lett. 74, 4087 (1995)]. Our result shows that if the determinant of $u$ is 1, four two-qubit gates is achievable optimal. Otherwise, five is optimal. Thirdly, we show that five two-qubit gates are necessary and sufficient for implementing the Fredkin gate(the controlled swap gate), which settles the open problem introduced in [Smolin and DiVincenzo, Phys. Rev. A, 53, 2855 (1996)]. The Fredkin gate is one of the most important quantum logic gates because it is universal alone for classical reversible computation, and thus with little help, universal for quantum computation. Before our work, a five two-qubit gates decomposition of the Fredkin gate was already known, and numerical evidence of showing five is optimal is found.

arXiv:1301.3727•Jan 16, 2013•2 citations

Logical structures underlying quantum computing

Federico Holik, Giuseppe Sergioli, Héctor Freytes +1 more

In this work we advance a generalization of quantum computational logics capable of dealing with some important examples of quantum algorithms. We outline an algebraic axiomatization of these structures.

•Jan 1, 2019•6 citations
While quantum algorithms are known to be very powerful, there are also people who think that “quantum computers will never be able to run the if/then/else type of logic”. On the other hand, though many experts know that such a claim is a misconception, in literature there is still lacking of a general description of the procedure for implementing the if/then/else conditional statements in the quantum way. In the current work, we present such a general method in details, explaining how the unitary transformation required for any if/then/else operation can be constructed from simpler unitary transformations and projective operators. Moreover, by using the well-known controlled-NOT gate, Fredkin gate and Toffoli gate as examples, it is elaborated that the structure of the existing conditional quantum operations agrees with our general method. An even more complicated example is also provided, showing that our method is convenient for solving real-world if/then/else problems with quantum computers. Thus the result not only refutes the above claim, but also helps to develop the skill on quantum programming.
In contrast to a classical bit, which can only take the value 000 or 111, its quantum counterpart -- a qubit -- can exist in a superposition of 000 and 111. This is a superposition of data values, naturally raising the question of whether one can superpose not only data but also programs. For example, a particular superposition of programs, known as the quantum SWITCH, has attracted much attention, and its implementations and computational advantages have been studied extensively within the physics community. A naive way to control a program by a qubit is by means of a controlled operation. Given an operation FFF, this amounts to considering an operation that behaves as FFF when the control qubit is ∣1⟩|1\rangle∣1⟩, and as the identity operation when the control qubit is ∣0⟩|0\rangle∣0⟩. This idea works well when FFF is a unitary operation, but it is not well-defined for a general quantum channel. By contrast, the quantum SWITCH is free from the well-definedness issue. This contrast leads to the key insight of this paper: controlled operations and the quantum SWITCH should be regarded as different kinds of quantum control mechanisms. Building on this insight, we develop a novel quantum programming language with quantum control and measurement that can express the quantum SWITCH over quantum channels. Using a semantic analysis based on program transformations, we identify the source of the ill-behavedness of controlled operations as the \emph{correspondence problem}: a lack of coordination between the measurements performed in the then- and else-branches of quantum conditional branching. We address this problem with a linear type system that enforces alignment of the quantum operations used in the two branches, yielding a well-behaved language capable of expressing the quantum SWITCH.
A quantum gate is the quantum analog of the classical logic gate of digital computers. It is a basic structural unit of a quantum circuit which operates on a small number of qubits to deliver a predefined output. A quantum circuit is a graphical representation of the sequence of the quantum gates used and the measurements performed in a quantum computation. Various quantum logic gates, namely, the Hadamard, T phase, NOT, Pauli-X, controlled NOT (CNOT), controlled-Z, SWAP and controlled phase gates as well as higher-level Toffoli and Fredkin gates are described. Conventions of reading quantum circuit diagrams are explained. Operation of a quantum full adder consisting of registers and gates is discussed, elaborating the role of the NOT gate, the sum calculation with CNOTgates and the carry C-out calculation with Toffoli gates. A primary tool used for performing arithmetic operations on a quantum computer is the quantum Fourier transform (QFT). The QFT adder and multiplier circuits are presented.
An essential element of classical computation is the ``if-then'' construct, that accepts a control bit and an arbitrary gate, and provides conditional execution of the gate depending on the value of the controlling bit. On the other hand, quantum theory prevents the existence of an analogous universal construct accepting a control qubit and an arbitrary quantum gate as its input. Nevertheless, there are controllable sets of quantum gates for which such a construct exists. Here we provide a necessary and sufficient condition for a set of unitary transformations to be controllable, and we give a complete characterization of controllable sets in the two-dimensional case. This result reveals an interesting connection between the problem of controllability and the problem of extracting information from an unknown quantum gate while using it.
To build a general-purpose quantum computer, it is crucial for the quantum devices to implement classical boolean logic. A straightforward realization of quantum boolean logic is to use auxiliary qubits as intermediate storage. This inefficient implementation causes a large number of auxiliary qubits to be used. In this paper, we have derived a systematic way of realizing any general m-to-n bit combinational boolean logic using elementary quantum gates. Our approach transforms the m-to-n bit classical mapping into a t-bit unitary quantum operation with minimum number of auxiliary qubits, then a variation of Toffoli gate is used as the basic building block to construct the unitary operation. Finally, each of these building blocks can be decomposed into one-bit rotation and two-bit control-U gates. The efficiency of the network is taken into consideration by formulating it as a constrained set partitioning problem.
In this paper, we study the optimal simulation of three-qubit unitary by using two-qubit gates. First, we give a lower bound on the two-qubit gates cost of simulating a multi-qubit gate. Secondly, we completely characterize the two-qubit gate cost of simulating a three-qubit controlled controlled gate by generalizing our result on the cost of Toffoli gate. The function of controlled controlled gate is simply a three-qubit controlled unitary gate and can be intuitively explained as follows: the gate will output the states of the two control qubit directly, and apply the given one-qubit unitary uuu on the target qubit only if both the states of the control are ∣1⟩\ket{1}∣1⟩. Previously, it is only known that five two-qubit gates is sufficient for implementing such a gate [Sleator and Weinfurter, Phys. Rev. Lett. 74, 4087 (1995)]. Our result shows that if the determinant of uuu is 1, four two-qubit gates is achievable optimal. Otherwise, five is optimal. Thirdly, we show that five two-qubit gates are necessary and sufficient for implementing the Fredkin gate(the controlled swap gate), which settles the open problem introduced in [Smolin and DiVincenzo, Phys. Rev. A, 53, 2855 (1996)]. The Fredkin gate is one of the most important quantum logic gates because it is universal alone for classical reversible computation, and thus with little help, universal for quantum computation. Before our work, a five two-qubit gates decomposition of the Fredkin gate was already known, and numerical evidence of showing five is optimal is found.