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; // Quantum Register creg c; // Classical Register x q; measure q -> c; if (c==1) x q; measure q -> c;
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.