This is a simple circuit introduced in Moran's book "Mastering Quantum Computing with IBM QX" to demonstrate how if works in OpenQASM:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5]; // Quantum Register
creg c[5]; // Classical Register
x q[0];
measure q[0] -> c[0];
if (c==1) x q[1];
measure q[1] -> c[1];
And this is how the circuit visually looks in IBM QX Circuit Composer:
The book states that at the end of the circuit, the classical register should read 00011 because after the first measurement it holds a value 1 (as a decimal number), thus satisfying the if condition. However, when I test this exact circuit in IBM QX's Circuit Composer, the result shows 00001 with 100% probability.
Interestingly enough, when if (c==1)
is changed to if (c==0)
, the result is now 00011 with 100% probability, which I don't think is logically right.
What should be an explanation for this discrepancy? The book argues that the if statement is not supported by IBM QX (as of Jan 2019), so could this be a sort of bug?
Any help would be appreciated.