• No results found

In this section, we demonstrate the translation through some examples.

6.3.1

Random Bit Generator

The example consists of a quantum random number generatorRwhich sends a random bit on a channel. The processQsimply receives the generated bit and is included to demonstrate communication. ProcessP is the starting process that invokes the other two. The three process definitions are:

P = (νc:b[Int])(Q(c)kR(c))

Q(c:b[Int]) =c?[r:Int].0

R(c:b[Int]) = (qbit x)({x∗=H}.c![measurex].0)

We begin the translation by constructing the sets of global and local variables from these process definitions. These are generated by the functionsanG andanL.

anG(P, Q, R) ={(signal,integer),(ack,integer),

(Q_ctrl,channel of integer),(R_ctrl,channel of integer),

(c1,channel of integer),(c_ack,channel of integer),(x,qubit),(r,integer)}

The local variables are empty for processesP and Q, while forR there is a variable

c_1used prior to sending:

anL(P) =∅

anL(Q) =∅

We now proceed by using the translation function TprogJK on the set of process definitions.

TprogJP, Q, RK=program Translated;

gVars(P, Q, R)

TprogJPKTprogJQKTprogJRK

endprogram

The translations of each processP,Q andR are considered separately before being substituted in the above program.

For the body of process P we have the following translation:

TprocJ(νc:b[Int])(Q(c)k R(c))K=TprocJQ(c)kR(c)K=

Q_ctrl!signal; R_ctrl!signal;

The set of local variablesanL(P) is empty, therefore there are no local declarations. The process definition is hence translated byTprogJKto the following:

TprogJP = (νc:b[Int])(Q(c)k R(c))K=process P

begin

Q_ctrl!signal; R_ctrl!signal; end

We now translate the processQ. The set of local variablesanL(Q) is empty, therefore

lVars(Q) results in an empty string. The process body, consisting of a single input action is translated as

TprocJc?[r]K=c1?r; c_ack!ack;,

thus we arrive at the following:

TprogJQ(c:b[Int]) =c?[r].0K=process Q

begin

c1?r; c_ack!ack; end

The most interesting part is the translation of processRusing TprocJK. TprocJ(qbit x){x∗=H}.c![measurex].0K

=x := newqubit;TprocJ{x∗=H}.c![measurex].0K =x := newqubit; had x;TprocJc![measurex].0K

=x := newqubit; had x; c_1 := meas x; c1!c_1; c_ack?ack;

TprocJ0K

=x := newqubit; had x; c_1 := meas x; c1!c_1; c_ack?ack;

Combining this with the local variable declarations for processRwe have the following translation:

TprogJR(c:b[Int]) = (qbit x){x∗=H}.d![measurex].0K=

process R var c_1:integer; begin x := newqubit; had x; c_1 := meas x; c1!c_1; c_ack?ack; end

These three process translations can now be substituted intoTprogJP, Q, RKto com-

plete the translation. The result is the QMC program listed in Figure 6.9.

6.3.2

Quantum Teleportation

We now apply this translation to the teleportation process defined in Figure 6.10. We expect the result to resemble the QMC program in Figure 6.2; the result is shown in Figure 6.11.

Unsurprisingly, the programs are not identical since differences in the languages allow for alternate representations of various components. The first point to note is the introduction of the signalling channelsTeleport_ctrl,Alice_ctrlandBob_ctrl. Since theTeleportprocess is not nested, the corresponding control channel is declared but never used. Incidentally, the use of the control channel inBob is superfluous in teleportation, because execution cannot start until a value is received fromAlice.

Another change is the conditional applications of the unitary operators by Bob; these have been compounded into oneifstatement in the QMC specification, however the simplistic support for conditionals by CQP leads to multiple statements in the

TprogJP, Q, RK=

program Translated;

var signal:integer, ack:integer,

Q_ctrl:channel of integer, R_ctrl:channel of integer, c1:channel of integer, c_ack:channel of integer, x:qubit, r:integer; process P begin Q_ctrl!signal; R_ctrl!signal; end process Q begin c1?r; c_ack!ack; end process R var c_1:integer; begin x := newqubit; had x; c_1 := meas x; c1!c_1; c_ack?ack; end endprogram

Figure 6.9. Translation of a quantum random number generator

Teleport= (qbity, z)({z∗=H}.{z, y∗=CNot}.(νe:b[Int,Int])(Alice(e, z)kBob(e, y)))

Alice(e, z) = (qbitx).{x∗=H}.{z, x∗=CNot}.{z∗=H}.e![measurez,measurex].0

Bob(e, y) =e?[r:Int, s:Int].{y∗=Xr}.{y∗=Zs}.0

program Translated;

var x: qubit; y: qubit; z: qubit;

e1: channel of integer; e2: channel of integer; e_ack: channel of integer;

Teleport_ctrl: channel of integer; Alice_ctrl: channel of integer; Bob_ctrl: channel of integer; r: integer; s: integer;

signal: integer; ack: integer; process Teleport; begin y := newqubit; z := newqubit; had z; cnot z y; Alice_ctrl!signal; Bob_ctrl!signal; end; process Alice;

var e_1: integer; e_2: integer; begin

Alice_ctrl?signal;

x := newqubit; had x; cnot z x; had z;

e_1 := meas x; e1!e_1; e_2 := meas z; e2!e_2; e_ack?ack;

end;

process Bob;

var X_cond: integer; Z_cond:integer; begin

Bob_ctrl?signal; e1?r; e2?s; e_ack!ack; X_cond := r; if :: (X_cond = 1) -> X y; break; :: (X_cond = 0) -> break; fi Z_cond := s; if :: (Z_cond = 1) -> Z y; break; :: (Z_cond = 0) -> break; fi end; endprogram

translation. We have introduced the assignments X_cond := r and Z_cond := s, although in this particular case, sincerand sare variables, they are not necessary.

Related documents