Programming with Quantum Communication

# Programming with Quantum Communication

Anya Tafliovich\thanksrefALL\thanksrefmyemail    Eric C. R. Hehner\thanksrefcoemail
###### Abstract

This work develops a formal framework for specifying, implementing, and analysing quantum communication protocols. We provide tools for developing simple proofs and analysing programs which involve communication, both via quantum channels and exhibiting the LOCC (local operations, classical communication) paradigm.

Computer Science
University of Toronto

Computer Science
University of Toronto

Keywords:  Quantum Computing, Quantum Communication Protocol, Formal Verification, Formal Methods of Program Design

11footnotetext: This work is in part supported by NSERC.22footnotetext: Email: \normalshapeanya@cs.toronto.edu33footnotetext: Email: \normalshapehehner@cs.toronto.edu

## 1 Introduction

The term quantum communication refers to the process of transferring a quantum state between distinct physical locations. There are two ways of accomplishing this task. The first one is analogous to classical communication and involves sending a quantum bit over a quantum communication channel (just as classical communication is associated with sending classical bits over a classical communication channel). The second one has no classical analogue. In a quantum world it is possible to transfer a quantum bit without utilising a quantum channel, by using a classical communication channel and a pair of entangled states and applying quantum operations locally.

This work develops a formal framework for specifying, implementing, and analysing quantum communication protocols. We provide tools for developing simple proofs and analysing programs which involve communication, both via quantum channels and exhibiting the LOCC (local operations, classical communication) paradigm. We look at quantum communication in the context of formal methods of program development, or programming methodology. This is the field of computer science concerned with applications of mathematics and logic to software engineering tasks. In particular, the formal methods provide tools to formally express specifications, prove correctness of implementations, and reason about various properties of specifications (e.g. implementability) and of implementations (e.g. time and space complexity).

In this work the analysis of quantum communication protocols is based on quantum predicative programming ([22, 23, 21]), a recent generalisation of the well-established predicative programming ([14, 15]). It supports the style of program development in which each programming step is proved correct as it is made. We inherit the advantages of the theory, such as its generality, simple treatment of recursive programs, and of time and space complexity. The theory of quantum programming provides tools to write both classical and quantum specifications, develop quantum programs that implement these specifications, and reason about their comparative time, space, and communication complexity, all in the same framework.

There has been a number of proposals for formal approaches to quantum programming, including the language qGCL [19, 27], process algebraic approaches of [4, 17, 16], tools developed in the field of category theory [1, 2, 3, 10, 20], functional languages of [6, 7, 5, 24], as well as work of [12][11], and [13]. A detailed discussion of the work related to quantum predicative programming is presented in [22].

The contribution of this work is twofold. Firstly, we present a framework for implementing quantum communication protocols, specifying desired properties of the protocols, and formally proving whether these properties hold. The properties are not restricted to reasoning about the data sent or received by the parties involved. We provide tools to prove properties which deal with the complexity of the protocol, such as the number of classical and quantum bits sent during its execution. Secondly, the reasoning about quantum communication fits nicely in the general framework of quantum predicative programming, and thus inherits all of its advantages. The definitions of specification and program are simple: a specification is a boolean (or probabilistic) expression and a program is a specification. The treatment of recursion is simple: there is no need for additional semantics of loops. The treatment of termination simply follows from the introduction of a time variable; if the final value of the time variable is , then the program is a non-terminating one. There is a uniform method for proving correctness and time, space, and communication complexity; moreover, after proving them separately, we naturally obtain the conjunction. The use of Dirac-like notation makes it easy to write down specifications and develop algorithms. Finally, the treatment of computation with mixed states does not require any additional mechanisms.

The rest of this work is organised as follows. Section 2 is a brief introduction to quantum predicative programming. The contribution of this work is Section 3 which introduces a formal framework for specifying, implementing, and analysing quantum communication protocols and presents the analysis of two such protocols: quantum teleportation and quantum dense coding. Section 4 states conclusions and outlines directions for future research. A short introduction to quantum computing is presented in the Appendix A.

## 2 Quantum Predicative Programming

This section introduces the programming theory of our choice — quantum predicative programming. We briefly introduce parts of the theory necessary for understanding Section 3 of this work. For a course in predicative programming the reader is referred to [14]. An introduction to probabilistic predicative programming can be found in [15]. Quantum predicative programming is developed in [22, 23, 21].

### 2.1 Predicative programming

In predicative programming a specification is a boolean expression. The variables in a specification represent the quantities of interest, such as prestate (inputs), poststate (outputs), and computation time and space. We use primed variables to describe outputs and unprimed variables to describe inputs. For example, specification states that the final value of is its initial value plus . A computation satisfies a specification if, given a prestate, it produces a poststate, such that the pair makes the specification true. A specification is implementable if for each input state there is at least one output state that satisfies the specification.

We use standard logical notation for writing specifications: (conjunction), (disjunction), (logical implication), (equality, boolean equivalence), (non-equality, non-equivalence), and if then else. The larger operators , , and are the same as , , and , but with lower precedence. We use standard mathematical notation, such as . We use lowercase letters for variables of interest and uppercase letters for specifications.

In addition to the above, we use the following notations: (prestate), (poststate), (), and (). The notation specifies that the values of all variables are unchanged. In the assignment , is a state variable (unprimed) and is an expression (in unprimed variables) in the domain of .

If and are specifications in variables , then the sequential composition of and is defined by

 R;S==∃x′′,y′′,…⋅R′′∧S′′ \hb@xt@.01(1)

where is obtained from by substituting all occurrences of primed variables with double-primed variables , and is obtained from by substituting all occurrences of unprimed variables with double-primed variables .

Various laws can be proved about sequential composition. One of the most important ones is the substitution law, which states that for any expression of the prestate, state variable , and specification ,

 x:=e;P==(for x substitute e in P) \hb@xt@.01(2)

Specification is refined by specification if and only if is satisfied whenever is satisfied, that is . Given a specification, we are allowed to implement an equivalent specification or a stronger one.

A program is an implemented specification. A good basis for classical (non-quantum) programming is provided by: , assignment, if then else, sequential composition, booleans, numbers, bunches, and functions. Given a specification , we proceed as follows. If is a program, there is no work to be done. If it is not, we build a program , such that refines , i.e. . The refinement can proceed in steps: .

In it is possible for to appear in . No additional rules are required to prove the refinement. For example, it is trivial to prove that

 x≥0⇒x′=0⟸if x=0 then ok else (x:=x−1;x≥0⇒x′=0)

The specification says that if the initial value of is non-negative, its final value must be . The solution is: if the value of is zero, do nothing, otherwise decrement and repeat.

### 2.2 Probabilistic predicative programming

A probability is a real number between and , inclusive. A distribution is an expression whose value is a probability and whose sum over all values of variables is . Given a distribution of several variables, we can sum out some of the variables to obtain a distribution of the rest of the variables.

To generalise boolean specifications to probabilistic specifications, we use and both as numbers and as boolean and , respectively. If and are specifications in variables , then the definition (2.1) of sequential composition of and is generalised to

 R;S==∑x′′,y′′,…⋅R′′×S′′

where and are defined as before.

If is a probability and and are distributions, then

 if p then R else S==p×R+(1−p)×S

If is an implementable deterministic specification and is a distribution of the initial state , then the distribution of the final state is

 p′;S

Various laws can be proved about sequential composition. One of the most important ones, the substitution law, introduced earlier, applies to probabilistic specifications as well.

### 2.3 Quantum Predicative Programming

Let be the set of all complex numbers with the absolute value operator and the complex conjugate operator . Then a state of an -qubit system is a function , such that . Here notation means from (and including) to (and excluding) .

If and are two states of an -qubit system, then their inner product, denoted by , is defined by:

 ⟨ψ|ϕ⟩=∑x:0,..2n⋅(ψx)∗×(ϕx)

A basis of an -qubit system is a collection of quantum states , such that . We adopt the following Dirac-like notation for the computational basis: if is from the domain , then x denotes the corresponding -bit binary encoding of and is the following quantum state:

 |x⟩=λi:0,..2n⋅(i=x)

where is a function of a variable with domain and body . If is a state of an -qubit system and is a state of an -qubit system, then , the tensor product of and , is the following state of a composite -qubit system:

 ψ⊗ϕ=λi:0,..2m+n⋅ψ(idiv2n)×ϕ(imod2n)

We write to mean “ tensored with itself times”. An operation defined on an -qubit quantum system is a higher-order function, whose domain and range are maps from to the complex numbers. An identity operation on a state of an -qubit system is defined by

 In=λψ:0,..2n→C⋅ψ

For a linear operation , the adjoint of , written , is the (unique) operation, such that for any two states and , .

The unitary transformations that describe the evolution of an -qubit quantum system are operations defined on the system, such that .

In this setting, the tensor product of operators is defined in the usual way. If is a state of an -qubit system, is a state of an -qubit system, and and are operations defined on and -qubit systems, respectively, then the tensor product of and is defined on an qubit system by

 (U⊗V)(ψ⊗ϕ)=(Uψ)⊗(Vϕ)

To apply an operation defined on a -qubit system to qubit in a composite -qubit system, we apply the operation to the entire system, where is defined by:

 Uni=I⊗...⊗Ii⊗U⊗I⊗...⊗In−i−1

Suppose we have a system of qubits in state and we measure (observe) it. Suppose also that we have a variable from the domain , which we use to record the result of the measurement, and variables , which are not affected by the measurement. Then the measurement corresponds to a probabilistic specification that gives the probability distribution of and (these depend on and on the type of measurement) and states that the variables are unchanged.

For a general quantum measurement described by a collection of measurement operators, which satisfy the completeness equation (see Appendix A), the specification is , where

 measureMψr==⟨ψ|M†r′Mr′ψ⟩×⎛⎜ ⎜⎝ψ′=Mr′ψ√⟨ψ|M†r′Mr′ψ⟩⎞⎟ ⎟⎠×(σ′=σ)

where is an abbreviation of and means “all other variables are unchanged”.

Given an arbitrary orthonormal basis , measurement of in basis is:

 measureBψr==|⟨br′|ψ⟩|2×(ψ′=br′)×(σ′=σ)

The simplest and the most commonly used measurement in the computational basis is:

 measure ψr==|ψr′|2×(ψ′=|r′⟩)×(σ′=σ)

In this case the distribution of is and the distribution of the quantum state is:

 ∑r′⋅|ψr′|2×(ψ′=|r′⟩)

which is precisely the mixed quantum state that results from the measurement.

In order to develop quantum programs we need to add to our list of implemented things. We add variables of type quantum state as above and we allow the following three kinds of operations on these variables. If is a state of an -qubit quantum system, is a natural variable, and is a collection of measurement operators that satisfy the completeness equation, then:

1. is a program

2. , where is a unitary transformation on an -qubit system, is a program

3. is a program

where the superscript means “tensored with itself times”. The special cases of measurements are therefore also allowed.

Some unitary operations that we will use in the later sections are (here ):

 I|x⟩=|x⟩ identity X|x⟩=|1−x⟩ X - Pauli matrix Y|x⟩=(−1)x×i×|1−x⟩ Y - Pauli matrix Z|x⟩=(−1)x×|x⟩ Z - Pauli matrix H|x⟩=(|0⟩+(−1)x×|1⟩)/√2 Hadamard CNOT|cx⟩=(I⊗Xc)|cx⟩ controlled-not

## 3 Distributed Quantum Systems and Communication

In predicative programming, to reason about distributed computation we (disjointly) partition the variables between the processes involved in a computation. Parallel composition is then simply boolean conjunction. For example, consider two processes and . owns integer variables and and owns an integer variable . Suppose . Parallel composition of with is then simply

 P||Q==P∧Q==x′=x+1∧y′=x+1∧z′=−z

In quantum predicative programming, one needs to reason about distributed quantum systems. Recall that if is a state of an -qubit system and is a state of an -qubit system, then , the tensor product of and , is the state of a composite -qubit system. On the other hand, given a composite -qubit system, it is not always possible to describe it in terms of the tensor product of the component - and -qubit systems. Such a composed system is entangled. Entanglement is one of the most non-classical, most poorly understood, and most interesting quantum phenomena. An entangled system is in some sense both distributed and shared. It is distributed in the sense that each party can apply operations and measurements to only its qubits. It is shared in the sense that the actions of one party affect the outcome of the actions of another party. Simple partitioning of qubits is therefore insufficient to reason about distributed quantum computation.

The formalism we introduce fully reflects the physical properties of a distributed quantum system. We start by partitioning the qubits between the parties involved. For example, consider two parties and . owns the first qubit of the composite entangled quantum system and owns the second qubit. A specification is a program only if each party computes with its own qubits. In our example,

 P==ψ0:=Hψ0;measure ψ0pandQ==measure ψ1q

are programs, if and are integer variables owned by and , respectively. Note that we cannot write down expressions for and : this is consistent with the laws of quantum mechanics as is an entangled state. Parties and can access only their own qubits: they could in theory be light years apart.

Sometimes we want to explicitly include partitioning of variables as part of a specification. For this purpose, we introduce notation to mean the bunch of variables that belong to process . In the above example we can make the partitioning of variables explicit with the specification

 ψ0,p:varP∧ψ1,q:varQ

We define parallel composition of and which share an quantum system in state with the first qubits belonging to and the other qubits belonging to as follows. If

 P==ψ0,..n:=UPψ0,..nand% Q==ψn,..n+m:=UQψn,..n+m

where is a unitary operation on an -qubit system and is a unitary operation on an -qubit system, then

 P||ψQ==ψ:=(UP⊗UQ)ψ

Performing is equivalent to performing the identity unitary operation, and therefore if

 P==ψ0,..n:=UPψ0,..nand% Q==ok

then

 P||ψQ==ψ:=(UP⊗I⊗m)ψ

Similarly, if

 P==measureMPψ0,..npandQ==measureMQψn,..n+mq

where and are a collection of proper measurement operators for - and -qubit systems, respectively, then

 P||ψQ==measureMP⊗MQψpq

where is the number that corresponds to the binary string pq.

In our example,

 ψ:=|00⟩/√2+|11⟩/√2;P||ψQ expand, substitute == ψ:=|00⟩/√2+|11⟩/√2; measure (Hψ0)p||ψmeasure ψ1q compose on ψ == ψ:=|00⟩/√2+|11⟩/√2;measure% (H⊗I)ψpq substitute == measure (H⊗I)(|00⟩/√2+|11⟩/√2)pq apply H⊗I == measure (|00⟩+|01⟩+|10⟩−|11⟩)/2pq measure == |(|00⟩+|01⟩+|10⟩−|11⟩)/2pq|2×(ψ′=|p′q′⟩) application == (ψ′=|p′q′⟩)/4

When explicitly specifying partitioning of variables in a parallel composition, it is convenient to allow the variables to appear as subscripts on the corresponding processes. For example, the specification denotes a parallel composition of processes and that share an entangled state , such that and belong to and and belong to .

To reason about communication between processes we use the framework of Hehner’s calculus([14]). A named, one-way communication channel is described by an infinite message script , an infinite time script , and read and write cursors and . The message and time scripts are the list of all messages that appear on the channel and the list of corresponding times. The read and write cursors specify how many messages have been read from and written to a channel. To specify two-way communication, we use two channels. The input and output on channel are defined by the following operations (here is the time variable):

 c!e == Mcwc=e∧Tcwc=t∧wc:=wc+1 c output e c? == rc:=rc+1 c input c == Mc(rc−1)

A channel declaration defines a new channel with communication of type ; the declaration applies to the specification (here stands for naturals extended with ):

 chan c:T⋅P==∃Mc:[∞∗T]⋅∃Tc:[∞∗real]⋅var rc,wc:xnat:=0⋅P

where is an infinite sequence of elements of type . One useful theorem that we use in later examples is the equivalence of communication on a local channel with assignment:

 chan c:T⋅c!e||(c?;x:=c)==x:=e

The reader is referred to [14] for a detailed description of formal treatment of classical communication in Hehner’s calculus.

When defining a quantum communication channel one must be careful not to introduce any unwanted behaviour, such as violation of the no-cloning principle (i.e. creation of identical copies of an unknown arbitrary quantum state). For this purpose we make the change of ownership of the transported qubit explicit in the definition:

 c!ψ == Mcwc=ψ∧Tcwc=t∧w′c=wc+1∧var′P=varP∖ψ∧σ′=σ c?ψ == r′c=rc+1∧ψ′=Mcrc∧% var′Q=varQ,ψ∧σ′=σ

where is a quantum communication channel from process to process and is shorthand for “the rest of the variables are unchanged”.

Now that we allow changing of ownership of the variables, the specification , “the rest of the variables of process are unchanged” is defined by .

The declaration of a quantum channel is similar to the declaration of a local classical channel:

 qchan q:T⋅P==∃Mq:[∞∗T]⋅∃Tq:[∞∗real]⋅var rq,wq:xnat:=0⋅P

Similarly to the above-mentioned theorem, we can prove the equivalence of communication on a local quantum channel with the change of ownership. If and , then (leaving out time)

 qchan c:qbit⋅P||Q def. qchan == ∃M:[∞∗qbit]⋅var r,w:xnat:=0⋅P||Q expand == ∃M:[∞∗qbit]⋅var r,w:xnat:=0⋅ Mw=ψ∧w′=w+1∧var′P=varP∖ψ ∧var′Q=varQ,ψ∧r′=r+1∧ψ′=Mr initialisation == ∃M:[∞∗qbit]⋅var r,w:xnat⋅ M0=ψ∧w′=1∧var′P=varP∖ψ ∧var′Q=varQ,ψ∧r′=1∧ψ′=M0 simplify == var′P=varP∖ψ∧var′Q=varQ,ψ∧σ′=σ

### 3.1 Quantum teleportation

Quantum teleportation is the most famous quantum communication protocol. Its description first appeared in a seminal article by Bennett et al in 1993 ([9]), it has since been extensively used as part of more complex quantum communication protocols, and has received much attention in experimental research. The protocol achieves transmission of quantum information by utilising only a classical communication channel and an entangled pair of qubits: no qubits are sent in the process.

The protocol: Alice and Bob share an entangled pair of qubits in the state . Alice has some qubit in her possession (she may not know the state of the qubit) that she wishes to transfer to Bob. Alice starts by interacting the qubit she wishes to teleport with her half of the entangled pair (she applies a controlled-not followed by a Hadamard transform) and measuring her two qubits. She then sends the results of her measurements to Bob (two classical bits). Bob receives the two classical bits and, depending of their values, applies one of the three Pauli operators or the identity to his qubit. Surprisingly, he has recovered the state Alice wished to teleport.

The protocol is usually described informally, by using a diagram as in Figure 1\@footnotemark\@footnotetextThe figure is generated with qasm2pdf. Such a description is insufficient, in part since it only describes the evolution of the quantum system and does not specify the distribution of the system nor the communication. Alternatively, the description of the protocol is given informally, in English. Our goal is to formally define and prove correctness of the quantum teleportation protocol. Some approaches proposed in the literature (e.g. [26]) define teleportation as a program that implements a specification of the form . We point out that this specification may as well be implemented by a program that involves sending a qubit on a quantum channel, which is not teleportation. Furthermore, the specification does not mention that two classical bits are sent on a classical channel, which is an important part of the specification of teleportation. Similarly, it is important to specify that a pair of maximally entangled qubits is required.

To formalise the quantum teleportation protocol we let be the number of classical bits sent on a communication channel and be the number of quantum bits sent. The formal specification of quantum teleportation is:

 S== ϕ01:varAlice∧ϕ2:varBob∧ ϕ0,..3=(α×|0⟩+β×|1⟩)⊗(|00⟩+|11⟩)/√2 ⇒ ϕ′2=α×|0⟩+β×|1⟩∧c′=c+2∧q′=q

The specification says that if the computation starts with a qubit (specified in the most general form) in Alice’s possession and if Alice and Bob share a maximally entangled state , then at the end of the computation the qubit is teleported to Bob at a cost of 2 classical bits of communication and 0 qubits of communication. The specification does not restrict the quantum system to three qubits, so that teleportation can be a part of a bigger computation.

The well-known solution is the following parallel program:

 P== chan ch:bit⋅Alicea0,a1,ϕ01||ϕBobb0,b1,ϕ2 where Alice==ϕ01:=CNOTϕ01;ϕ0:=Hϕ0;% measure ϕ01a0a1;c:=c+1;ch!a0;c:=c+1;ch!a1 and Bob==ch?;b0:=ch;ch?;b1:=ch;ϕ2:=Zb0Xb1ϕ2

That is, two processes, and , partition a 3-qubit quantum system , so that owns the first qubit (the one she wants to teleport) and the second qubit and owns the third qubit. can write to a local classical communication channel and can read from it. Finally, and are two bits that belong to , and and are two bits that belong to . The process performs local operations and measurements and sends two classical bits on the channel. The process reads from the channel and performs local operations.

Our goal is to prove that the program implements the specification . We first note the following equivalence:

 P⇒S def. S == P∧ϕ01:varAlice∧ϕ2:varBob∧ ϕ0,..3=(α×|0⟩+β×|1⟩)⊗(|00⟩+|11⟩)/√2 ⇒ ϕ′2=α×|0⟩+β×|1⟩∧c′=c+2∧q′=q simplification == P∧ϕ=(α×|0⟩+β×|1⟩)⊗(|00⟩+|11⟩)/√2 ⇒ ϕ′2=α×|0⟩+β×|1⟩∧c′=c+2∧q′=q

Next, we simplify to prove the above implication. With implicit partitioning of variables (as it does not change):

 chan ch:bit⋅((ϕ01:=CNOTϕ01;ϕ0:=Hϕ0;% measure ϕ01a0a1;c:=c+1;ch!a0;c:=c+1;ch!a1)||ϕ(ch?;b0:=ch;ch?;b1:=ch;ϕ2:=Zb0Xb1ϕ2)) ==% substitute, H on first qubit chan ch:bit⋅((measure H⊗I(CNOTϕ01)a0a1;c:=c+1;ch!a0;c:=c+1;ch!a1)||ϕ(ch?;b0:=ch;ch?;b1:=ch;ϕ2:=Zb0Xb1ϕ2)) ==parallel % composition, simplification chan ch:bit⋅ measure01H⊗I⊗I(CNOT⊗Iϕ)a0a1; ((c:=c+1;ch!a0;c:=c+1;ch!a1)||(ch?;b0:=ch;ch?;b1:=ch)); ϕ:=I⊗I⊗Zb0(I⊗I⊗Xb1ϕ) ==% classical channel measure01H⊗I⊗I(CNOT⊗Iϕ)a0a1; c′=c+2∧b′0=a0∧b′1=a1∧σ′=σ; ϕ:=I⊗I⊗Zb0(I⊗I⊗Xb1ϕ)

Next we notice that the first line in the above specification (which is, in fact, the effect of Alice’s actions) conjoined with the specification of the initial state of the quantum system, result in the following distribution over the states of the computation:

 ϕ′=|a′0a′1⟩⊗(α×|a′1⟩+(−1)a′0×β×|1−a′1⟩)/4

That is, with probability the quantum system is in state and the values of Alice’s bits are and ; with probability the quantum system is in state and the values of Alice’s bits are and ; etc.

To prove this formally, we first note that:

 H⊗I⊗I(CNOT⊗I((α×|0⟩+β×|1⟩)⊗(|00⟩+|11⟩)/√2)) == % apply CNOT H⊗I⊗I(α×|000⟩+β×|110⟩+α×|011⟩+β×|101⟩)/√2 == % apply H α×(|0⟩+|1⟩)⊗|00⟩/2+β×(|0⟩−|1⟩)⊗|10⟩/2+ α×(|0⟩+|1⟩)⊗|11⟩/2+β×(|0⟩−|1⟩)⊗|01⟩/2 == % rearrange terms |00⟩⊗(α×|0⟩+β×|1⟩)/2+|01⟩⊗(α×|1⟩+β×|0⟩)/2+ |10⟩⊗(α×|0⟩−β×|1⟩)/2+|11⟩⊗(α×|1⟩−β×|0⟩)/2

Therefore, measurement of the first two qubits of the above state in the computational basis gives:

 measure01(|00⟩⊗(α×|0⟩+β×|1⟩)/2+|01⟩⊗(α×|1⟩+β×|0⟩)/2+|10⟩⊗(α×|0⟩−β×|1⟩)/2+|11⟩⊗(α×|1⟩−β×|0⟩)/2)a0a1 ==ϕ′=|a′0a′1⟩⊗(α×|a′1⟩+(−1)a′0×β×|1−a′1⟩)/4

Let be the specification of the initial state of the quantum system:

 Q==ϕ=(α×|0⟩+β×|1⟩)⊗(|00⟩+|11⟩)/√2

Putting it all together, we get:

 Q∧P == Q×(measure01H⊗I⊗I(CNOT⊗Iϕ)a0a1; c′=c+2∧b′0=a0∧b′1=a1∧σ′=σ; one point law, ϕ:=I⊗I⊗Zb0(I⊗I⊗Xb1ϕ)) as above == Q×ϕ′=|a′0a′1⟩⊗(α×|a′1⟩+(−1)a′0×β×|1−a′1⟩)/4; sequential c′=c+2∧b′0=a0∧b′1=a1∧σ′=σ; composition, ϕ:=I⊗I⊗Zb0(I⊗I⊗Xb1ϕ) one point law == Q×(c′=c+2)×(b′0=a′0)×(b′1=a′1)×(σ′=σ)× ϕ′=I⊗I⊗Zb′0(I⊗I⊗Xb′1 (|b′0b′1⟩⊗(α×|b′1⟩+(−1)b′0×β×|1−b′1⟩)/4)) apply Xb′1 == Q×(c′=c+2)×(b′0=a′0)×(b′1=a′1)×(σ′=σ)× ϕ′=I⊗I⊗Zb′0(|b′0b′1⟩⊗(α×|0⟩+(−1)b′0×β×|1⟩)/4 apply Zb′0 == Q×(c′=c+2)×(b′0=a′0)×(b′1=a′1)×(σ′=σ)× (ϕ′=|b′0b′1⟩⊗(α×|0⟩+β×|1⟩)/4) ≤ (c′=c+2)×(q′=q)×(ϕ′2=α×|0⟩+β×|1⟩) == S

where is the generalisation of for probabilistic specification (see [15]).

This example shows formalisation and analysis of an LOCC (local operations, classical communication) quantum communication protocol. We now turn to our attention to a protocol which involves a quantum communication channel.

### 3.2 Quantum dense coding

The quantum dense coding (sometimes called super-dense coding) protocol is less famous than the quantum teleportation protocol, but it is no less important. It achieves the transfer of 2 bits of classical information by sending 1 bit of quantum information and utilising 1 entangled pair of qubits. That is, its goal is the opposite of that of the quantum teleportation protocol.

Just as with teleportation, the protocol is usually described informally: either with a diagram or in English. We formalise the specification of the protocol by using the same variables as in section 3.1:

 S== a0,a1,ϕ0:varAlice∧b0,b1,ϕ1:varBob∧ϕ01=(|00⟩+|11⟩)/√2 ⇒ b′0=a0∧b′1=a1∧c′=c∧q′=q+1

The specification says that if the computation starts with Alice and Bob sharing a maximally entangled state, with classical bits and in Alice’s possession and and in Bob’s possession, then at the end of the computation Bob has the values of Alice’s classical bits, at a cost of sending no bits on a classical channel and one qubit on a quantum channel. The program for the protocol is:

 P== qchan qch:qbit⋅Alicea0,a1,ϕ0||ϕBobb0,b1,ϕ1 where Alice== if a0=a1=0 then ok else if a0=0∧a1=1 then ϕ0:=Xϕ0 else if a0=1∧a1=0 then ϕ0:=Zϕ0 else ϕ0:=Yϕ0; q:=q+1;qch!ϕ0 and Bob== qch?ϕ0;ϕ:=CNOTϕ;ϕ0:=Hϕ0;measure ϕb0b1

That is, Alice applies one of the three Pauli operators or an identity to her half of the entangled pair, depending on the values of her classical bits, and sends her qubit to Bob. Bob receives the qubit, applies a controlled-not followed by a Hadamard, and measures the two qubits in his possession. We now show that the program implements the specification