The circuit

enter image description here

can be translated to the following code:

operation Teleport(msg, there) {
    let register = AllocateRegister();
    let here = register;
    CNOT(here, there);
    CNOT(msg, here);
    // Measure out the entanglement.
    if (M(msg) == One)  { Z(there); }
    if (M(here) == One) { X(there); }

How do the if-statements come about? Why are double-lines used after measurements?

  • $\begingroup$ May I ask what the language is in that example? Is it Q#? $\endgroup$
    – Norrius
    Commented Mar 31, 2018 at 14:42
  • 2
    $\begingroup$ No, but it was based on Q#. I didn't want to demand Q#-familiarity from readers, so I created this pseudo-code that uses only features from widely used languages. $\endgroup$
    – R. Chopin
    Commented Mar 31, 2018 at 14:46

1 Answer 1


The double lines are one common convention for classical bits in quantum circuit diagrams. In this case, they represent the bits arising from the measurements of the qubits msg and here.

The controlled operations involving the classical bits are just operations which are performed if those classical bits happen to have the value 1, which is what the if statements are for in the pseudocode.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.