Universal Gates making using Reversible Computing in QISKIT
Md. Zubair
Posted on March 10, 2024
There are different types of classical gates like AND, OR , NOT, NOR, NAND etc. If we think about it classically , Only the NOT gate is reversible and rests are not.
By reversible I meant we can get the input value by looking at the value of output. If we look at the truth table of NOT gate,
Here you can infer the input or the output value by looking at the other .
But this is not the case with other gates. To understand it clearly , let's take OR gate truth table,
Here , suppose by using or gate on 2 unknown bits you got the output 1, now can you infer from here the input values of 2 bits ? No you can't . It is because there can be 3 possibilites like 01,10,11.
But we can do this in Quantum Computer. Quantum Computer is reversible according to the laws of physics . Quantum Gates U are invertible (U^-1 = U^t) and hence quantum circuit (without measurement) are invertible . The idea for making it reversible is whenever you compute a gate save the inputs. So, And & OR gates should be implemented in a reversible manner . The idea is to create a 3-qubit circuit which donot modify the input bits and writes the output of 3rd bit.
Reversible AND gates implementaion:
It is implemented using a Toffoli gate , It is revertible in the sense that given x1,x2 and y (xor) (x1 and x2) , we can compute back y.
Now the Qiskit Implementation,
The output of the code will be ,
OR gate Implementation:
Now there can be a lot of ways to implement this,
I am showing here two method.
Method 1: By using the rule A xor B xor AB = A OR B
Method 2: Simply negating and using De-Morgan
XOR gate Implementation:
Posted on March 10, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024