/****************************************************************************** Program implementing teleportation protocol as described by Bennett et al. ******************************************************************************/ #library "library.libq" /****************************************************************************** In this method, we allocate a new quantum bit. This is allocated to maximally mixed state. We then use a nasty operation projTo0(psi) defined in library.libq to turn it into state |0> and then by \sigma_x transformation to (|1>). ******************************************************************************/ qbit computeSomething() { qbit psi; psi = new qbit(); ProjTo0(psi); Sigma_x(psi); dump_q(psi); return psi; } /****************************************************************************** In this method, EPR pair is created. We use a nasty operation projTo0(psi1) defined in library.libq to turn psi1 into state |0>. Then by Had we get (|0>+|1>)/sqrt(2) and finally by CNot to 1/2(|00>+|11>) ******************************************************************************/ qbit @ qbit createEPR() { qbit psi1, psi2; psiEPR aliasfor [psi1, psi2]; psi1 = new qbit(); psi2 = new qbit(); ProjTo0(psi1); ProjTo0(psi2); Had(psi1); CNot(psi1, psi2); return psiEPR; } /****************************************************************************** This method defines behaviour of one process - it gets one channel end and one particle from EPR pair as arguments, then it creates its own particle phi which is finally measured together with the half of EPR pair and the result is sent over the given channel. ******************************************************************************/ void angela(channelEnd[int] c0, qbit auxTeleportState) { int i; qbit phi; phi = computeSomething(); i = measure (BellBasis, phi, auxTeleportState); send (c0, i); } /****************************************************************************** In this method, an integer is received from a channel and the qubit stateToTeleportOn passed as parameter is modified according to received integer. This qubit is the destination qubit onto which the teleported state gets teleported on. ******************************************************************************/ void bert(channelEnd[int] c1, qbit stateToTeleportOn) { int i; i = recv(c1); if (i == 1) { Sigma_z(stateToTeleportOn); } else if (i == 2) { Sigma_x(stateToTeleportOn); } else if (i == 3) { Sigma_x(stateToTeleportOn); Sigma_z(stateToTeleportOn); } dump_q(stateToTeleportOn); } /****************************************************************************** Main method - from this method, the program is run. In its body, an EPR pair and a channel for sending integers is allocated. Then a new process is started from method angela(). One channel end and one EPR-pair particle is passed to it. Finally, method bert() is invoked. ******************************************************************************/ void main() { channel[int] c withends [c0,c1]; qbit psi1, psi2; psiEPR aliasfor [psi1, psi2]; psiEPR = createEPR(); c = new channel[int](); fork angela(c0, psi1); bert(c1, psi2); }