0
$\begingroup$

I am watching this video in which a programming language for quantum computing is introduced. There is code like this:

// Inside TeleportClassicalMessage function
let msg = register[0]; // Initialized to |0⟩ state
let there = register[1]; // Initialized to |0⟩ state

// Inside Teleport function
let here = register[0]; // Initialized to |0⟩ state
H(here); // here is now |+⟩
CNOT(here, there); // 'here' and 'there' are now entangled as the Bell state

CNOT(msg, here); // What does this do?

For those of you not familiar with coding, what it seems to be doing is feeding $|+⟩$ (control) and $|0⟩$ (target) to a CNOT gate, which creates the entangled Bell state. Then it takes the first qubit out of that state, here (without examining it), and feeds $|0⟩$ and here to a CNOT gate again.

What exactly does this do?

$\endgroup$
1
  • 1
    $\begingroup$ are you sure msg is initialised to $\lvert0\rangle$? Because if it is, then the second CNOT is not active and does nothing $\endgroup$
    – glS
    Dec 24, 2017 at 17:04

1 Answer 1

0
$\begingroup$

FWIW, this is the code used in the video: https://github.com/Microsoft/Quantum/blob/master/Samples/Teleportation/TeleportationSample.qs

In the TeleportClassicalMessage function (from which Teleport is called), msg is conditionally inverted (depending on the outside argument).

Note the line:

if(message) { X(msg); }

which does the conditional flipping.

Inside Teleport function, the second CNOT will flip here if the original message was 1. It would also mean changing the state of there because it's entangled with here. In case the original message was 0, the state of there will be unchanged.

$\endgroup$

Your Answer

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

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