9

The circuit

enter image description here

can be translated to the following code:

operation Teleport(msg, there) {
    let register = AllocateRegister();
    let here = register;
    H(here);
    CNOT(here, there);
    CNOT(msg, here);
    H(msg);
    // 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?

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
R. Chopin
  • 1,199
  • 6
  • 17
  • May I ask what the language is in that example? Is it Q#? – Norrius Mar 31 '18 at 14:42
  • 2
    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. – R. Chopin Mar 31 '18 at 14:46

1 Answers1

12

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.

Niel de Beaudrap
  • 12,052
  • 1
  • 31
  • 69