## Introduction to quantum computing with Q# – Part 7, Quantum state teleportation

In the previous part of the series we discussed how quantum theory prohibits copying of an arbitrary quantum state. In computing terms, this means that regardless of the richness of features provided by high-level quantum-specific languages such as Q#, we cannot implement a classical functionality of copy-and-paste on a quantum computer.

It turns out, however, that we can achieve a cut-and-paste type of effect, through a remarkable process of quantum teleportation.

### Quantum teleportation

Quantum teleportation was first theoretically proposed in a 1993 paper Teleporting an unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels by Charles Bennett, Gilles Brassard, Claude Crépeau, Richard Jozsa, Asher Peres, and William Wootters. It contained an ingenious idea that “an unknown quantum state $\ket{\phi}$ can be disassembled into, then later reconstructed from, purely classical information and purely nonclassical Einstein-Podolsky-Rosen (EPR) correlations.”

In the process of quantum teleportation, there is no physical spatial movement of matter or particles. Instead, it is the quantum state itself that gets destroyed on one quantum object and recreated elsewhere on another already existing quantum object. A qualification is in order here – it is not the quantum object itself that gets destroyed, but the information about its arbitrary quantum state. This “destruction happens via the processes of measurement, forcing the quantum object (or a qubit in the quantum computing sense) to assume one of the orthogonal states $\ket{0}$ or $\ket{1}$. This is also precisely the reason why the process of teleportation doesn not violate the no-cloning theorem – at no point does the same quantum state exist in two places, as original and a copy. In other words, as Eleanor Rieffel and Wolfgang Polak put it in their Quantum Computing: A gentle introduction – “at any given time, only one of Alice or Bob can reconstruct the original quantum state.” Additionally, as we shall see, the teleportation protocol requires a classical communication channel between the two actors to be available too.

As stated by Bennett, Brassard, Crépeau, Jozsa, Peres, and Wootters in their paper:

We call the process we are about to describe teleportation, a term from science fiction meaning to make a person or object disappear while an exact replica appears somewhere else. It must be emphasized that our teleportation, unlike some science fiction versions, defies no physical laws. In particular, it cannot take place instantaneously or over a spacelike interval, because it requires, among other things, sending a classical message from Alice to Bob.

The protocol was successfuly confirmed experimentally for the first time using entangled photons by a group lead by Anton Zwellinger at the University of Innsbruck in 1997. In the summary of their experiment they reflected on the exciting new frontiers that lie ahead of quantum mechanics thanks to the realization of teleportation.

As any arbitrary state can be teleported, so can the fully undetermined state of a particle which is member of an entangled pair. Doing so, one transfers the entanglement between particles. This allows us not only to chain the transmission of quantum states over distances, where decoherence would have already destroyed the state completely, but it also enables us to perform a test of Bell’s theorem on particles which do not share any common past, a new step in the investigation of the features of quantum mechanics.

Even more remarkably, in 2015, a group from the University of Science and Technology of China, carried out a successful teleportation experiment between a ground observatory and low orbit Earth satellite – some 1400km away.

### Mathematics of quantum teleportation

As we established earlier in this series, it is quite difficult, if not impossible, to develop a picture or intuition for quantum processes using our classical macroscopic thinking. Therefore – and this should be of no surprise, given that this is part 7 of this series already – the most reliable approach to attempt to reason about teleportation of quantum objects, even before we dive into Q# code, is to use the mathematical formalism of quantum mechanics, namely linear algebra. We already do know almost all the necessary constituent pieces – the CNOT gate, a number of single qubit gates or the phenomenon of entanglement in general. As we’ll see in a moment, we shall also require to perform the so-called Bell-basis measurement, but that is also something we briefly touched upon earlier.

The circuit depicting the teleportation protocol is shown below:

We start off with two of our actors that will want to teleport a qubit state, Alice and Bob. Alice possesses a qubit $\ket{\psi_a}$ (called “message” on the circuit) in an arbitrary superposition state $\ket{\psi_a} = \alpha\ket{0} + \beta\ket{1}$. She’d like to teleport this state to Bob, who is spatially separated from her. Naturally, Alice cannot just measure her qubit and send that information to Bob using classical means because a measurement would cause a reduction of the state vector and would destroy the unique quantum state – simply yielding on of the orthogonal states $\ket{0}$ or $\ket{1}$.

Alice and Bob are also sharing a pre-created entangled pair of qubits, represented by one of the four Bell states, for example the $\ket{\Phi^+}$. These are shown on the circuit as “resource” (Alice’s part) and “target” (Bob’s part):

$$\ket{\varphi_{ab}} = \frac{1}{\sqrt{2}}(\ket{00} + \ket{11})$$

At this point we have a 3-qubit system, consisting of one qubit that is owned by Alice, and the shared entangled pair of qubits, where one is owned by Alice and the other by Bob. This initial state can be described as:

$$\ket{\psi_{a}} \otimes \ket{\varphi_{ab}} = \frac{1}{\sqrt{2}}(\alpha\ket{0} \otimes (\ket{00} + \ket{11}) \\ + \beta\ket{1} \otimes (\ket{00} + \ket{11})) \\ = \frac{1}{\sqrt{2}}(\alpha\ket{000} + \alpha\ket{011} + \beta\ket{100} + \beta\ket{111})$$

The first two kets in the equation describe Alice’s qubits, first the state to teleport, then her part of the entangled pair, while the last one describes Bob’s qubit, which is his part of the entangled pair and shall act as the target onto which the state $\ket{\psi_a}$ will be teleported. What Alice then does, is she allows her qubit $\ket{\psi_a}$ to interact with her part of the entangled pair $\ket{\varphi_{ab}}$. She first applies a $CNOT$ transformation to them, with the qubit that she wishes to teleport acting as a control qubit.

We can describe this mathematically in the following way:

$$(CNOT \otimes I)(\ket{\psi\_a} \otimes \ket{\varphi_{ab}}) = \\ (CNOT \otimes I)\frac{1}{\sqrt{2}}(\alpha\ket{000} + \alpha\ket{011} \\ + \beta\ket{100} + \beta\ket{111}) = \\ \frac{1}{\sqrt{2}}(\alpha\ket{000} + \alpha\ket{011} + \beta\ket{110} + \beta\ket{101})$$

Before we continue with Alice’s activites, let’s do a quick refresh on the Bell states, which we introduced in part 5. The four Bell states can be obtained via the so-called Bell circuit, consisting of $H$, followed by a $CNOT$. Together, they form an orthonormal basis for a two-qubit system in a four dimensional Hilbert space and represent two maximally entangled particles (or qubits):

$$\ket{00} \rightarrow \frac{1}{\sqrt{2}}(\ket{00} + \ket{11}) = \ket{\Phi^+}$$
$$\ket{10} \rightarrow \frac{1}{\sqrt{2}}(\ket{00} – \ket{11}) = \ket{\Phi^-}$$
$$\ket{01} \rightarrow \frac{1}{\sqrt{2}}(\ket{01} + \ket{10}) = \ket{\Psi^+}$$
$$\ket{11} \rightarrow \frac{1}{\sqrt{2}}(\ket{01} – \ket{10}) = \ket{\Psi^-}$$

We can measure two qubits in the Bell basis and obtain one of the Bell states as a result – in case of a uniform superposition, with equal probabilities. Now, since all quantum transformations are reversible, we can also apply a reverse Bell circuit – $CNOT$, followed by $H$, to transform the Bell state back to the input single qubits states. In other words, a Bell measurement can be converted into a standard measurement in the computational basis, as long as prior to the measurement such $(H \otimes I)CNOT$ unitary transformation is performed.

This is exactly what Alice is planning. She already applied a $CNOT$, so she is halfway into the reverse Bell circuit. She then follows with applying a Hadamard gate to the qubit she plans to teleport. Applying $H$ to the first qubit in the system, using the system state we have claculated above as input, results in:

$$(H \otimes I \otimes I)\frac{1}{\sqrt{2}}(\alpha\ket{000} + \alpha\ket{011} \\ + \beta\ket{110} + \beta\ket{101}) = \\ \frac{1}{2}(\alpha(\ket{000} + \ket{011} + \ket{100} + \ket{111}) + \\ \beta(\ket{010} + \ket{001} – \ket{110} – \ket{101})) = \\ \frac{1}{2}(\ket{00}(\alpha\ket{0} + \beta\ket{1}) + \ket{01}(\alpha\ket{1} + \beta\ket{0}) + \\ \ket{10}(\alpha\ket{0} – \beta\ket{1}) + \ket{11}(\alpha\ket{1} – \beta\ket{0}))$$

The final picture becomes clearer now. Upon Alice performing the measurement on her two qubits, the global wave function collapses into one of the four unentangled states – with equal probability of 25%. She could receive $\ket{00}$, $\ket{01}$, $\ket{10}$ or $\ket{11}$. As we see from the equation, each of these results has an impact on the state of the entangled qubit of Bob.

• when Alice measures $\ket{00}$, Bob’s qubit would end up in the state $\alpha\ket{0} + \beta\ket{1}$
• when Alice measures $\ket{01}$, Bob’s qubit would end up in the state $\alpha\ket{1} + \beta\ket{0}$
• when Alice measures $\ket{10}$, Bob’s qubit would end up in the state $\alpha\ket{0} – \beta\ket{1}$
• when Alice measures $\ket{11}$, Bob’s qubit would end up in the state $\alpha\ket{1} – \beta\ket{0}$

Recall that Alice wanted to teleport her initial qubit state $\ket{\psi_a} = \alpha\ket{0} + \beta\ket{1}$. Thus, we can observe based in the above relations that:

• when Bob’s qubit ends up in the state $\alpha\ket{0} + \beta\ket{1}$, it is already the original state $\ket{\psi_a}$
• when Bob’s qubit ends up in the state $\alpha\ket{1} + \beta\ket{0}$, it is the equivalent to $X\ket{\psi_a}$
• when Bob’s qubit ends up in the state $\alpha\ket{0} – \beta\ket{1}$, it is the equivalent to $Z\ket{\psi_a}$
• when Bob’s qubit ends up in the state $\alpha\ket{1} – \beta\ket{0}$, it is the equivalent to $ZX\ket{\psi_a}$

Where $X$ and $Z$ are the single qubit Pauli transformations (gates) that we already discussed in depth in part 3. When Bob’s qubit has the state $\alpha\ket{0} + \beta\ket{1}$ we can consider the teleportation as completed, since that is the original state of Alice’s qubit. In other cases, we are very close, but not there yet. We know already that Pauli gates are all its own inverses, meaning the following relation holds:

$$X^2 = Z^2 = I$$

This is a critical information for Bob, because he can use that knowledge to expected recover the quantum state. Since we identified that in 3 out of the 4 cases the state is transformed by $X$, $Z$ or $ZX$, applying the same transformation again would undo its original effect:

$$X(\alpha\ket{1} + \beta\ket{0}) = \alpha\ket{0} + \beta\ket{1}$$
$$Z(\alpha\ket{0} + \beta\ket{1}) = \alpha\ket{0} + \beta\ket{1}$$
$$ZX(\alpha\ket{1} – \beta\ket{0}) = \alpha\ket{0} + \beta\ket{1}$$

This allows Bob to extract the initial quantum state that he and Alice wanted to be teleported. Now, the problem is that Bob doesn’t know the state of the qubit – so he doesn’t know which of the three transformations to apply to it, or whether to apply any at all (in some literature it might be mentioned that he’d then apply the $I$ transformation, which leaves the qubit intact). This problem is solved in the teleportation protocol by requiring an additional classical communication channel to exist between Alice and Bob – e.g. phone or email. Alice would then communicate to Bob the result of her measurement to Bob using 2 classical bits – $\ket{00}$, $\ket{01}$, $\ket{10}$ or $\ket{11}$. Bob knows that his four possible outcomes are tied to Alice’s measurement and thus can choose the relevant transformation to recover the qubit state.

This completes the teleportation protocol. The end result is that Alice’s original quantum state $\ket{\psi_a}$ on her “message” qubit gets destroyed upon measurement and assumes one of the orthogonal states $\ket{0}$ or $\ket{1}$. Alice’s qubit forming the entangled pair with Bob also gets “used up” – since we measured it too and it yielded $\ket{0}$ or $\ket{1}$ as well. On the other hand, Bob’s qubit assumed the state of $\ket{\psi_a}$, $X\ket{\psi_a}$, $Z\ket{\psi_a}$ or $ZX\ket{\psi_a}$, which Bob, based on the information from Alice about her measurement result, managed to correct to always be $\ket{\psi_a}$. Bob can now measure that qubit, or use it in any quantum alogrithm.

The requirement of sharing the two classical bits between Alice and Bob to complete the protocol also ensures that the protocol obeys the theory of special relativity, that is, that it cannot be used for superluminal communication. This is also proven in the original Bennett, Brassard, Crépeau, Jozsa, Peres, and Wootters paper, who assert that “reliable teleportation of a two-state particle cannot be achieved with a classical channel of less than two bits of capacity.”

### Qubit teleportation in Q#

As we already reflected upon in the earlier parts of this series, the remarkable feature of quantum computing is that we can now use high-level language like Q# to experimentally realize quantum protocols such as teleportation using nothing more than a code editor.

In the Q# code, we shall stick to the names we already established at the quantum circuit – “message”, “resource” and “target”, to allow better cognitive association between the circuit and the code. Since we mentioned that the message to be teleported could be an arbitrary quantum state, we will do just that – and we will be teleporting a state specified in the Pauli X (Hadamard) basis ($\ket{+} ,\ket{-}$). We know that a superposition is base dependent so states $\ket{+}$ are $\ket{-}$ in a uniform superposition with respect to the Z-axis.

$$\ket{+} = H(\ket{0}) = \frac{1}{\sqrt{2}}(\ket{0}+\ket{1})$$
$$\ket{-} = H(\ket{1}) = \frac{1}{\sqrt{2}}(\ket{0}-\ket{1})$$

In order to make it more digestible, the code will be split into multiple blocks. The first part of Q# code looks as follows:

We start off by preparing the $\ket{+}$ or $\ket{-}$ state based on the input parameter into the operation. As defined above, $\ket{+}$ is produced by applying an $H$ to $\ket{0}$, while $\ket{-}$ is created by applying $H$ to $\ket{1}$.

Once the message to teleport is prepared, we proceed to create a Bell state using the $resource$ and $target$ qubits. Those are now entangled and will facilitate the teleportation process. Next, a reverse Bell circuit, to decompose a joint measurement in the Bell basis into standard single qubit measurements in the computational basis is applied. This creates an entanglement between the $message$ and a $resource$.

Finally, we measure both $message$ and $resource$ mimicking the activites of Alice that we discussed earlier in this post. Next step will be do perform the state decoding – something that will follow the footsteps of Bob.

We shall simply follow the rules we already defined – based on the results of Alice’s measurement, an $I$ (no-op), $X$, $Z$ or $XZ$ needs to be applied to the $target$ qubit. At the end, we can measure the qubit in the Pauli X basis. The obtained resulted will be either $\ket{+}$ or $\ket{-}$, which confirms to us that the original state was telported intact. If we measured it using the Pauli Z basis, we would obtain $\ket{0}$ or $\ket{1}$ with 50% probability each.

To cap things off, we can define the entry point operation for our Q# code and pass in the “sign” parameter we defined on the $Teleport$ operation – this would give us a chance to invoke the operation a number of times and compare the results.

Invoking this program, which repeats the teleportation of both $\ket{+}$ and $\ket{-}$ three times, should yield the output similar to the one below (remembering that the joint Bell measurement results are random and non-deterministic):

### Entanglement as a resource

In his article “Quantum Entanglement as a Resource for Communication”, published as part of Springer’s Quantum Mechanics at the Crossroads: new perspectives from history, philosophy and physics, William Wootters, whom we already met as the co-author of the no-cloning theorem and one of the co-authors of the teleportation protocol, makes quite an insightful observation related to how teleportation is facilitated by entanglement. Namely, in the communication scheme such as teleportation, he proposes to view entanglement as a “resource”.

We have seen that entanglement, in addition to being an amazing physical phenomenon, can also be useful as a resource for communication. It is a resource like any other resource, in that it can be used up and replenished. (…) If entanglement is a resource, then one should be able to quantify it, just as one can quantify other resources such as energy and information.

This is a very valuable perspective. Indeed, if quantum information theory and quantum computing are to become anything more than a laboratory curiosity and really truly revolutionize the world of communication and information, it will definitely be because of the features facilitated by entanglement. Commoditization of entanglement, as well as ensuring stability and coherence of entangled particles, is thus one of the keys to unlocking and harnessing the true potential buried in the quantum world.

### Summary

The process of quantum entanglement is remarkable for two primary reasons. First of all, an arbitrary quantum state got teleported using no physical connection between the two actors Alice and Bob. Yes, there was a classical communication link between to transmit the two classical bits representing Alice’s measurement, but no information regarding the quantum state was shared. Additionally, it means that the message was moved between Alice and Bob in a fully safe way – there is no way for an eavesdropper or a malicious party to intercept the quantum message. Secondly, and this is no immediately clear, but definitely worth mentioning, using only two bits of classical data, Alice sent a continuous quantum state – after all the coefficients $\alpha$ and $\beta$ could be any values as long $\alpha^2 + \beta^2 = 1$ – so a concept impossible to classically express in just two bits.

In the next part of this series, we shall continue exploring the inetersting application scenarios around entanglement, by looking at a concept of “superdense coding”.