This file was created automatically by vma2nb from an .vma file. It should be suitable to be loaded by Mathematica's GUI front end but you probably don't want to edit it; edit the corresponding .vma source file instead!

teleporter.vma   (C) 1999, 2000  Timo Felbinger

  A demonstration of the quantum teleportation protocol for qubits.
  (C. H. Bennett et. al. (1995))

SetOptions[ $Output, PageWidth -> 72 ];

<< qmatrix.m

Define the actors: Alice and Bob:

Alice has two qubits, named source and qa:

alice = { source, qa }

Bob only gets a single qubit:

bob = { qb }

The physical system comprises Alice and Bob:

setSystem[ { alice, bob } ]

All modes are indeed qubits (fermionic modes are 2-dimensional!):

setModeType[ #1, fermionic ] & /@ Flatten[ system ]

Alice and Bob share one ebit of entanglement, the resource:

resource = singlet[ qa, qb ]

Alice has another qubit, which is in some arbitrary and
 generally mixed state (which she wants to teleport to Bob):

input = generalState[ source, "a" ]

Our total initial state is the product of input and resource:

initial = input ** resource

The teleporation protocol starts by alice performing a bell
 measurement. We define the observable to be measured: the
 following operator's eigenstates are the 4 bell states, with
 the numbers 1..4 being the eigenvalues:

bellOperator = Plus @@ (
 #1 * bellState[ source, qa, #1 ] & /@ { 1, 2, 3, 4 } 
 );

In case you are in doubt: it is indeed an observable:

hermitianQ[ bellOperator ]

Now we perform the measurement, storing the result under the
 label "pbell":

intermediate = initial ~measure~ { bellOperator, pbell };

To complete the teleportation, the protocol now calls for Bob
 to perform one of the following maps (they are all unitary):

(
   map1 = map[ { identityMatrix[ qb ] } ]; 
 ; map2 = map [ { 2 * matrix[ op[ jz, qb ] ] } ] 
 ; map3 = map[ { notGate[ qb ] } ] 
 ; map4 = map[ { 2 * matrix[ op[ jz, qb ] ] ** notGate[ qb ] } ] 
 );

Which of these maps Bob has to perform depends on the result of
 Alice's Bell measurement, so Bob's map is a conditional map:

bobsMap = condmap[ {
 { map1, pbell == 1} 
 , { map2, pbell == 2} 
 , { map3, pbell == 3} 
 , { map4, pbell == 4} 
 } ]

We just have to apply it:

final = bobsMap ** intermediate;

If we look at Bob's qubit, discarding Alice's qubits as well
 well as the classical knowledge, we find that the teleportation
 was indeed successful, with probability p=1.0:

final ~contract~ Not[bob] ~forget~ pbell

-----------

We are finished now but you may find it interesting to take a
 closer look at what was going on:

This is the observable of the Bell measurement:

bellOperator

bellOperator // eigenvalues

The intermediate state which was created by Alice's Bell measurement
 contains 4 different quantum states, one per measurement outcome.
 The quantum states are deliberately _not_ normalized; rather, their
 trace represents the probability of getting the corresponding result.
 Here, all 4 outcomes are equally likely:

intermediate

If we just look at what Bob holds in this intermediate state,
 it becomes clear that the teleportation is already almost complete
 up to some simple transformation which depends on the outcome of
 the Bell measurement:

intermediate ~contract~ Not[bob]

Knowing the result of the Bell measurement is crucial;
 if we forget it, Bob is left with a perfect mixture:

intermediate ~contract~ Not[bob] ~forget~ pbell

The result of the measurement is crucial for factorization
 of Bob's qubit:

intermediate ~factorizes~ qb

Without the knowledge, we get a lengthy expression but it
 is easy to verify that it cannot be fulfilled:

intermediate ~forget~ pbell ~factorizes~ qb // FullSimplify

The full final state looks like this:

final

Bob's quantum state is now already the correct one, independent
 of the outcome of the Bell measurement:

final ~contract~ Not[bob]

Alice OTOH still holds one of the four Bell states:
 (here we have to force Mathematica to make use of the
 fact that a11 + a22 == 1)

final ~contract~ Not[alice] //. (a11->1-a22)