in qiskit using elementary gates.
Can it be done?
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.Sign up to join this community
The method of creating a quantum adder circuit is similar to how a half or full adder circuit is designed in elementary digital electronics. These circuits add numbers in the binary representation.
For example, for the half adder, there are 2 bits to be added (A and B). These are taken to be the inputs. The output has 2 bits - a sum bit (S)which is the least significant bit of the output and a carry bit (C) which is the MSB. For example, if the inputs to be added are 1 and 1, the result would be carry=1 and sum=0.
To figure out the logic for the adder, write the truth table for the operation:
A B C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
For the quantum half adder, take 1 qubit each to represent A,B,C and S respectively. A and B are initialized to the input bits that you wish to add. (For example if you want to add 1 and 0, initialize A = |1> and B=|0>).
Now we need to determine the quantum gates which can take A and B as inputs and give C and S as the outputs - this is like boolean logic minimization. Look at bit C in the truth table - it is 1 only when both A and B are 1. So, C can be obtained by a CCNOT operation using A and B as inputs and C as target. Also, S is a classical XOR operation - this can be achieved by 2 successive CNOTs, both havong S as target and one with A as control and other with B as control.
Keep in mind that the advantage of a quantum adder could be to add several possible input combinations in one go by creating superpostion states in A and B.
You may refer to this example present in the knowldege base of the Quantum Inspire platform by TU Delft for quantum circuits for adders. The qiskit textbook also has an example of how to implement a quantum adder here. It explaines how to apply the appropriate quantum gates, and it should be possible to follow this approach to implement the circuit of your choice.