Content uploaded by Mingsheng Ying

Author content

All content in this area was uploaded by Mingsheng Ying on Mar 25, 2014

Content may be subject to copyright.

arXiv:1206.1935v1 [cs.LO] 9 Jun 2012

Reachability and Termination Analysis of

Concurrent Quantum Programs

Nengkun Yu and Mingsheng Ying

Tsinghua University, China

University of Technology, Sydney, Australia

{nengkunyu@gmail.com,Mingsheng.Ying@uts.edu.au}

Abstract. We introduce a Markov chain model of concurrent quantum

programs. This model is a quantum generalization of Hart, Sharir and

Pnueli’s probabilistic concurrent programs. Some characterizations of the

reachable space, uniformly repeatedly reachable space and termination

of a concurrent quantum program are derived by the analysis of their

mathematical structures. Based on these characterizations, algorithms

for computing the reachable space and uniformly repeatedly reachable

space and for deciding the termination are given.

Keywords: Quantum computation, concurrent programs, reachability,

termination

1 Introduction

Research on concurrency in quantum computing started about 10 years ago, and

it was motivated by two diﬀerent requirements:

–Veriﬁcation of quantum communication protocols: Quantum communication

systems are already commercially available from Id Quantique, MagiQ Tech-

nologies, SmartQuantum and NEC. Their advantage over classical commu-

nication is that security is provable based on the principles of quantum me-

chanics. As is well known, it is very diﬃcult to guarantee correctness of even

classical communication protocols in the stage of design. Thus, numerous

techniques for verifying classical communication protocols have been devel-

oped. Human intuition is much better adapted to the classical world than

the quantum world. This will make quantum protocol designers to commit

many more faults than classical protocol designers. So, it is even more criti-

cal to develop formal methods for veriﬁcation of quantum protocols (see for

example [10], [11], [4]). Concurrency is a feature that must be encompassed

into the formal models of quantum communication systems.

–Programming for distributed quantum computing: A major reason for dis-

tributed quantum computing, diﬀerent from the classical case, comes from

the extreme diﬃculty of the physical implementation of functional quan-

tum computers (see for example [1], [21]). Despite convincing laboratory

demonstrations of quantum computing devices, it is beyond the ability of

the current physical technology to scale them. Thus, a natural idea is to use

the physical resources of two or more small capacity quantum computers to

simulate a large capacity quantum computer. In fact, various experiments in

the physical implementation of distributed quantum computing have been

frequently reported in recent years. Concurrency naturally arises in the stud-

ies of programming for distributed quantum computing.

The majority of work on concurrency in quantum computing is based on

process algebras [13], [15], [8], [9], [14], [6], [22], [7], [3]. This paper introduces a

new model of concurrent quantum programs in terms of quantum Markov chains.

This model is indeed a quantum extension of Hart, Sharir and Pnueli’s model of

probabilistic concurrent programs [12], [19]. Speciﬁcally, a concurrent quantum

program consists of a ﬁnite set of processes. These processes share a state Hilbert

space, and each of them is seen as a quantum Markov chain on the state space.

The behaviour of each processes is described by a super-operator. This descrip-

tion of a single process follows Selinger, D’Hont and Panangaden’s pioneering

works [18], [5] on sequential quantum programs where the denotational semantics

of a quantum program is given as a super-operator. The super-operator descrip-

tion of sequential quantum programs was also adopted in one of the authors’

work on quantum Floyd-Hoare logic [20]. Similar to the classical and probabilis-

tic cases [12], an execution path of a concurrent quantum program is deﬁned

to be an inﬁnite sequence of the labels of their processes, and a certain fairness

condition is imposed on an execution path to guarantee that all the processes

fairly participate in a computation.

Reachability and termination are two of the central problems in program

analysis and veriﬁcation. The aim of this paper is to develop algorithms that

compute the reachable states and decide the termination, respectively, of a con-

current quantum program. To this end, we need to overcome two major diﬃ-

culties, which are peculiar to the quantum setting and would not arise in the

classical case:

–The state Hilbert space of a quantum program is a continuum and thus

doomed-to-be inﬁnite even when its dimension is ﬁnite. So, a brute-force

search is totally ineﬀective although it may works well to solve a correspond-

ing problem for a classical program. We circumvent the inﬁnity problem of

the state space by ﬁnding a ﬁnite characterization for reachability and termi-

nation of a quantum program through a careful analysis of the mathematical

structure underlying them.

–The super-operators used to describe the behaviour of the processes are op-

erators on the space of linear operators on the state space, and they are

very hard to directly manipulate. In particular, algorithms for computing

super-operators are lacking. We adopt a kind of matrix representation for

super-operators that allows us to conduct reachability and termination anal-

ysis of quantum programs by eﬃcient matrix algorithms.

The paper is organized as follows. For convenience of the reader we brieﬂy

recall some basic notions from quantum theory and ﬁx the notations in Sec. 2; but

we refer to [17] for more details. A Markov chain model of concurrent quantum

programs is deﬁned in Sec. 3, where we also give a running example of quantum

walks. In Sec. 4, we present a characterization for reachable space and one for

uniformly repeatedly reachable space of a quantum program, and develop two

algorithms to compute them. A characterization of termination of a quantum

program with fair execution paths and an algorithm for deciding it are given in

Sec. 5. It should be pointed out that termination decision in Sec. 5 is based on

reachability analysis in Sec. 4. A brief conclusion is drawn in Sec. 6.

2 Preliminaries and Notations

2.1 Hilbert Spaces

The state space of a quantum system is a Hilbert space. In this paper, we only

consider a ﬁnite dimensional Hilbert space H, which is a complex vector space

equipped with an inner product h·|·i. A pure state of a quantum system is rep-

resented by a unit vector, i.e., a vector |ψiwith hψ|ψi= 1. Two vectors |ϕi,|ψi

in Hare orthogonal, written |ϕi ⊥ |ψi, if their inner product is 0. A basis of H

is orthonormal if its elements are mutually orthogonal, unit vectors. The trace

of a linear operator Aon His deﬁned to be tr(A) = Pihi|A|ii, where {|ii} is an

orthonormal basis of H. For a subset Vof H, the subspace spanVspanned by V

consists of all linear combinations of vectors in V. For any subspace Xof H, its

orthocomplement is the subspace X⊥={|ϕi ∈ H :|ϕi ⊥ |ψifor all |ψi ∈ X}.

The join of a family {Xi}of subspaces is WiXi= span(SiXi).In particular, we

write X∨Yfor the join of two subspaces Xand Y. A linear operator Pis called

the projection onto a subspace Xif P|ψi=|ψifor all |ψi ∈ Xand P|ψi= 0

for all |ψi ∈ X⊥. We write PXfor the projection onto X.

A mixed state of a quantum system is represented by a density operator.

A linear operator ρon His called a density operator (resp. partial density

operator) if ρis positive-semideﬁnite in the sense that hφ|ρ|φi ≥ 0for all |φi,

and tr(ρ) = 1 (resp. tr(ρ)≤1). For any statistical ensemble {(pi,|ψii)}of

pure quantum states with pi>0for all iand Pipi= 1,ρ=Pipi|ψiihψi|is

a density operator. Conversely, each density operator can be generated by an

ensemble of pure states in this way. In particular, we write ψfor the density

operator |ψihψ|generated by a single pure states |ψi. The support of a partial

density operator ρ, written supp(ρ), is the space spanned by its eigenvectors

with nonzero eigenvalues.

Lemma 1 For any p > 0and partial density operators ρ, σ, we have: (1)

supp(pρ) = supp(ρ); (2) supp(ρ)⊆supp(ρ+σ); (3) supp(ρ+σ) = supp(ρ)∨

supp(σ).

2.2 Super-Operators

A super-operator is a mathematical formalism used to describe a broad class

of transformations that a quantum system can undergo. A super-operator on

His a linear operator Efrom the space of linear operators on Hinto itself,

satisfying (1) tr[E(ρ)] ≤tr(ρ)for any ρ; (2) Complete positivity(CP): for any

extra Hilbert space Hk,(Ik⊗E)(A)is positive provided Ais a positive operator

on Hk⊗H, where Ikis the identity operation on Hk. Furthermore, if tr[E(ρ)] =

tr(ρ)for any ρ, then Eis said to be trace-preserving. Each super-operator E

enjoys the Kraus representation: there exists a set of operators {Ei}satisfying

(1) E(ρ) = PiEiρE†

ifor all density operators ρ; (2) PiE†

iEi≤I, with equality

for trace-preserving E, where Iis the identity operator. In this case, we write E=

PiEi·E†

i. The image of subspace Xof Hunder Eis E(X) = W|ψi∈Xsupp(E(ψ)),

and the pre-image of Xunder Eis E−1(X) = {|ψi ∈ H : supp(E(ψ)) ⊆X}.

Lemma 2 (1) supp(ρ)⊆supp(σ)⇒supp(E(ρ)) ⊆supp(E(σ)), and supp(ρ) =

supp(σ)⇒supp(E(ρ)) = supp(E(σ)).

(2) supp(E(ρ)) ⊆supp((E+F)(ρ)). (3) E(X) = supp(E(PX)).

(4) X⊆Y⇒ E(X)⊆ E(Y). (5) E(X)⊆(E+F)(X).

(6) If E=PiEi·E†

i, then E−1(X) = [supp(E∗(PX⊥))]⊥,where E∗=PiE†

i·

Eiis the (Schrödinger-Heisenberg) dual of E.

2.3 Matrix Representation of Super-Operator

The matrix representation of a super-operator is usually easier in [24] to manip-

ulate than the super-operator itself. If E=PiEi·E†

iand dim H=d, then the

matrix representation of Eis the d2×d2matrix M=PiEi⊗E∗

i,where A∗

stands for the conjugate of matrix A, i.e., A∗= (a∗

ij )with a∗

ij being the conju-

gate of complex number aij , whenever A= (aij ). According to [24], we have the

following

Lemma 3 (1) The modulus of any eigenvalue of Mis less or equal to 1.

(2) We write |Φi=Pj|jjifor the (unnormalized) maximally entangled state

in H⊗H, where {|ji} is an orthonormal basis of H. Then for any d×dmatrix

A, we have (E(A)⊗I)|Φi=M(A⊗I)|Φi.

2.4 Quantum Measurements

A quantum measurement is described by a collection {Mm}of operators, where

the indexes mrefer to the measurement outcomes. It is required that the mea-

surement operators satisfy the completeness equation PmM†

mMm=IH. If the

system is in state ρ, then the probability that measurement result moccurs is

given by p(m) = tr(M†

mMmρ), and the state of the system after the measurement

is MmρM†

m

p(m).

3 A Model of Concurrent Quantum Programs

Our model is a quantum extension of Hart, Sharir and Pnueli’s probabilistic

concurrent programs [12]. A concurrent quantum program consists of a ﬁnite set

K={1,2,···, m}of quantum processes, and these processes have a common

state space, which is assumed to be a d-dimensional Hilbert space H. With each

k∈Kwe associate a trace-preserving super-operator Ek, describing a single

atomic action or evolution of process k. Also, we assume a termination condi-

tion for the program. At the end of each execution step, we check whether this

condition is satisﬁed or not. The termination condition is modeled by a yes-no

measurement {M0, M1}: if the measurement outcome is 0, then the program ter-

minates, and we can imagine the program state falls into a terminal (absorbing)

space and it remains there forever; otherwise, the program will enter the next

step and continues to perform a quantum operation chosen from K.

Deﬁnition 1 A concurrent quantum program deﬁned on a d-dimensional Hilbert

space His a pair P= ({Ek:k∈K},{M0, M1}),where:

1. Ekis a super-operator on Hfor each k∈K;

2. {M0, M1}is a measurement on Has the termination test.

Any ﬁnite string s1s2···smor inﬁnite string s1s2···si··· of elements of K

is called a execution path of the program. Thus, the sets of ﬁnite and inﬁnite

execution paths of program Pare

S=Kω={s1s2···si···:si∈Kfor every i≥1},

Sfin =K∗={s1s2···sm:m≥0 and si∈Kfor all 1 ≤i≤m},

respectively. A subset of Sis usually called a schedule.

For simplicity of presentation, we introduce the notation Fkfor any k∈K

which stands for the super-operator deﬁned by Fk(ρ) = Ek(M1ρM †

1)for all den-

sity operators ρ. Assume the initial state is ρ0. The execution of the program

under path s=s1s2···sk··· ∈ Scan be described as follows. At the ﬁrst step,

we perform the termination measurement {M0, M1}on the initial state ρ0. The

probability that the program terminates; that is, the measurement outcome is

0, is tr[M0ρ0M†

0]. On the other hand, the probability that the program does

not terminate; that is, the measurement outcome is 1, is ps

1= tr[M1ρ0M†

1],and

the program state after the outcome 1is obtained is ρs

1=M1ρ0M†

1/ps

1.We

adopt Selinger’s normalization convention [18] to encode probability and density

operator into a partial density operator ps

1ρs

1=M1ρ0M†

1.Then this (partial)

state is transformed by the quantum operation Es1to Es1(M1ρ0M†

1) = Fs1(ρ0).

The program continues its computation step by step according to the path s.

In general, the (n+ 1)th step is executed upon the partial density operator

ps

nρs

n=Fsn◦ ··· ◦ Fs2◦ Fs1(ρ0),where ps

nis the probability that the pro-

gram does not terminate at the nth step, and ρs

nis the program state after

the termination measurement is performed and outcome 1is reported at the

nth step. For simplicity, let Ffdenote the super-operator Fsn◦ · ·· ◦ Fs2◦ Fs1

for string f=s1s2···sn. Thus, ps

nρs

n=Fs[n](ρ0),where s[n]is used to de-

note the head s1s2···snfor any s=s1s2···sn··· ∈ S. The probability that

the program terminates in the (n+ 1)th step is then tr(M0(Fs[n](ρ0))M†

0),and

the probability that the program does not terminate in the (n+ 1)th step is

ps

n+1 = tr(M1(Fs[n](ρ0))M†

1).

3.1 Fairness

To guarantee that all the processes in a concurrent program can fairly participate

in a computation, a certain fairness condition on its execution paths is needed.

Deﬁnition 2 An inﬁnite execution path s=s1s2...si... ∈Sis fair if each pro-

cess appears inﬁnitely often in s; that is, for each k∈K, there are inﬁnitely

many i≥1such that si=k.

We write F={s:s∈Sis fair}for the schedule of all fair execution paths.

Deﬁnition 3 A ﬁnite execution path σ=s1s2···sn∈Sf in is called a fair piece

if each process appears during σ; that is, for each k∈K, there exists i≤nsuch

that si=k.

Ffin is used to denote the set of all fair pieces: Ff in ={σ:σ∈Sf in is a fair piece}.

It is obvious that F=Fω

fin;in other words, every fair inﬁnite execution path

s∈Fcan be divided into an inﬁnite sequence of fair pieces: s=f1f2···fk···,

where fi∈Ffin for each i > 0. The fairness deﬁned above can be general-

ized by introducing the notion of fairness index, which measures the occurrence

frequency of every process in an inﬁnite execution path.

Deﬁnition 4 For any inﬁnite execution path s∈F, its fairness index f(s)is

the minimum, over all processes, of the lower limit of the occurrence frequency

of the processes in s; that is,

f(s) = min

k∈Klim

t→∞ inf

n>t

s(n, k)

n,

where s(n, k)is the number of occurrences of kin s[n].

For any δ≥0, we write Fδfor the set of inﬁnite execution paths whose fairness

index is greater than δ:Fδ={s:s∈Sand f(s)> δ}.Intuitively, within

an inﬁnite execution path in Fδ, each process will be woken up with frequency

greater than δ. It is clear that F0(F.

3.2 Running Example

We consider two quantum walks on a circle C3= (V, E )with vertices V=

{0,1,2}and edges E={(0,1),(1,2),(2,0)}. The ﬁrst quantum walk W1=

({W1},{M0, M1})is given as follows:

–The state space is the 3−dimensional Hilbert space with computational basis

{|ii|i∈V};

–The initial state is |0i; this means that the walk starts at the vertex 0;

–A single step of the walk is deﬁned by the unitary operator:

W1=1

√3

1 1 1

1w w2

1w2w

,

where w=e2πi/3. Intuitively, the probabilities of walking to the left and to

the right are both 1/3, and there is also a probability 1/3of not walking.

–The termination measurement {M0, M1}is deﬁned by

M0=|2ih2|, M1=I3− |2ih2|,

where I3is the 3×3unit matrix.

The second walk W2= ({W2},{M0, M1})is similar to the ﬁrst one, but its single

step is described by unitary operator

W2=1

√3

1 1 1

1w2w

1w w2

.

Then we can put these two quantum walks together to form a concurrent pro-

gram P= ({W1, W2},{M0, M1}). For example, the execution of this concurrent

program according to unfair path 1ω/∈Fis equivalent to a sequential program

({W1},{P0, P1}); and the execution of Paccording to fair path (12)ω∈Fis as

follows: we perform the termination measurement {M0, M1}on the initial state

ρ0, then the nonterminating part of the program state is transformed by the

super-operator U1=W1·W†

1, followed by the termination measurement, and

then the application of the super-operator U2=W2·W†

2, and this procedure is

repeated inﬁnitely many times.

4 Reachability

Reachability is at the centre of program analysis. A state is reachable if some

ﬁnite execution starting in the initial state ends in it. What concerns us in the

quantum case is the subspace of Hspanned by reachable states.

Deﬁnition 5 The reachable space of program P= ({Ek:k∈K},{M0, M1})

starting in the initial state ρ0is

HR=_

s∈S,j≥0

supp Fs[j](ρ0) = _

f∈Sfin

supp Ff(ρ0).

We have the following closed form characterization of the reachable space.

Theorem 1 HR= supp(Pd−1

i=0 Fi(ρ0)),where d= dim His the dimension of

H, and F=Pk∈KFk.

Proof: We write Xfor the right-hand side. From Lemma 1, we see that X=

W{suppFf(ρ0) : f∈Sfin,|f|< d},where |f|denotes the length of string

f. According to the deﬁnition of reachable space, we know that X⊆ HR. To

prove the inverse part X⊇ HR, for each n≥0, we deﬁne subspace Ynas

follows: Yn:= supp(Pn

i=0 Fi(ρ0)).Due to Lemma 1, we know that Y0⊆Y1⊆

··· ⊆ Yn⊆ ··· .Suppose ris the smallest integer satisfying Yr=Yr+1 . We

observe that Yn+1 = supp(ρ+F(PYn)) for all n≥0. Then it follows that

Yn=Yrfor all n≥r. On the other hand, we have Y0(Y1(··· (Yr.

So, 0< d0< d1<··· < dr≤d, where d0is the rank of ρ0, and diis the

dimension of subspace Yifor 1≤i≤r. Therefore, we have r≤d−1and

Yd−1=Yr⊇Ynfor all n. Finally, for any f∈Sfin, it follows from Lemma 2

that supp(Ff(ρ0)) ⊆supp(F|f|(ρ0)) ⊆Y|f|⊆Yd−1=X. Thus, HR⊆X.

Now we are able to present an algorithm computing reachable subspace using

matrix representation of super-operators. We deﬁne G=Pk∈KFk/|K|.

Algorithm 1: Computing reachable space

input : An input state ρ0, and the matrix representation Gof G

output: An orthonormal basis Bof HR.

|xi ← (I−G/2)−1(ρ0⊗I)|Φi;

(* |Φi=Pj|jAjBiis the unnormalized maximally entangled state in H ⊗ H *)

for j= 1 : ddo

|yji ← hjB|xi;

end

set of states B← ∅;

integer l←0;

for j= 1 : ddo

|zi ← |yji − Pl

k=1hbk|yji|bki;

if |zi 6= 0 then

l←l+ 1;

|bli ← |zi/phz|zi;

B←B∪ {|bli};

end

end

return

Theorem 2 Algorithm 1 computes the reachable space in time O(d4.7454),

where d= dim H.

Proof: It follows from Lemma 3(1) that I−G/2is invertible, and P∞

i=0(G/2)i=

(I−G/2)−1. We write ρ=P∞

i=0 Gi(ρ0)/2i, and have

(ρ⊗I)|Φi=

∞

X

i=0

(G/2)i(ρ0⊗I)|Φi,

and the existence of ρimmediately follows from Lemma 3. We further see that

|xi= (ρ⊗I)|Φi=Pjρ|jAi|jBiand |yii=ρ|jAi. Note that Bis obtained from

{|yji} by the Gram-Schmidt procedure. So, supp(ρ) = span{ρ|ji} = spanB. It

is clear that HR= supp(Pd−1

i=0 Fi(ρ0)) ⊆supp(ρ). Therefore, HR= supp(ρ) =

spanB, and the algorithm is correct.

The complexity comes from three the following parts: (1) it costs O(d2∗2.3727 )

to compute (I−G/2)−1by using Coppersmith-Winograd algorithm [2]; (2) it

requires O(d4)to obtain |xifrom (I−G/2)−1; (3) the Gram-Schmidt orthonor-

malization is in time O(d3). So, the time complexity is O(d4.7454 )in total.

An advantage of Algorithm 1 is that we can store (I−G/2)−1. Then for any

input state ρ0, we only need O(d4)to compute the space reachable from ρ0.

Deﬁnition 6 The uniformly repeatedly reachable space of program P= ({Ek:

k∈K},{M0, M1})starting in the initial state ρ0is

HURR =\

n≥0_

s∈S,j≥n

supp Fs[j](ρ0) = \

n≥0_{supp Ff(ρ0) : f∈Sfin,|f| ≥ n}.

The uniformly repeatedly reachable space enjoys the following closed form,

Theorem 3 HURR = supp(P2d−1

i=dFi(ρ0)),where d= dim H, and F=Pk∈KFk.

Proof: For each n≥0, we deﬁne subspace Znas follows: Zn:= Wj≥nsupp Fj(ρ0).

It is obvious that Z0⊇Z1⊇ ··· ⊇ Zn⊇ ·· · .Suppose ris the smallest integer

satisfying Zr=Zr+1. By noting that Zn+1 = supp(F(PZn)), we can show that

Zn=Zrfor all n≥r. On the other hand, we have Z0)Z1)··· )Zr.So,

d0> d1>···> dr≥0,and diis the dimension of subspace Zifor 0≤i≤r.

Therefore, we have r≤d0≤dand Zd=Zr. Therefore, HURR =Tn≥0Zn=Zd.

It is obvious that Zdis the reachable space starting in state Fd(ρ0). Using The-

orem 1 we obtain Zd= supp(Pd−1

i=0 Fi(Fd(ρ0))) = supp(P2d−1

i=dF(ρ0)).

We can give an algorithm computing the uniformly repeatedly reachable space

by combining the above theorem and matrix representation of super-operators.

Algorithm 2: Compute uniformly repeatedly reachable space

input : An input state ρ0, and the matrix representation Gof G

output: An orthonormal basis BURR of HU RR .

|xi ← Gd(I−G/2)−1(ρ0⊗I)|Φi;

(* |Φi=Pj|jAjBiis the unnormalized maximally entangled state in H ⊗ H *)

for j= 1 : ddo

|yji ← hjB|xi;

end

set of states BU RR ← ∅;

integer l←0;

for j= 1 : ddo

|zi ← |yii − Pl

k=1hbk|yji|bki;

if |zi 6= 0 then

l←l+ 1;

|bli ← |zi/phz|zi;

BURR ←BU RR ∪ {|bli};

end

end

return

Theorem 4 Algorithm 2 computes the uniformly repeatedly reachable space in

time O(d4.7454 log d), where d= dim H.

Proof: This theorem is a corollary of Theorem 2. Here, log din the complexity

comes from computing Mdusing the method of exponentiation by squaring.

5 Termination

Another important problem concerning the behaviour of a program is its termi-

nation.

Deﬁnition 7 Let the program P= ({Ek:k∈K},{M0, M1}). Then Pwith

input ρ0terminates for execution path s∈Sif ps

nρs

n=Fs[n]= 0 for some

positive integer n.

Deﬁnition 8 1. If a program Pwith input ρ0terminates for all s∈A, then

we say that it terminates in schedule A.

2. If there is a positive integer nsuch that ps

nρs

n= 0 for all s∈A, then it is

said that the program Pwith input ρ0uniformly terminates in schedule A.

We ﬁrst prove the equivalence between termination and uniform termination.

Of course, this equivalence comes from ﬁniteness of the dimension of the state

space.

Theorem 5 The program P= ({Ek:k∈K},{M0, M1})with initial state ρ0

terminates in the biggest schedule S=Kωif and only if it uniformly terminates

in schedule S.

Proof. The “if” part is obvious. We prove the “only if” part in two steps:

(1) We consider the case of |K|= 1, where {Ek:k∈K}is a singleton {E}.

Now the program is indeed a sequential program, and it is a quantum loop [23].

We write F(ρ) = E(M1ρM †

1)for all ρ. What we need to prove is that if P

terminates, i.e., Fn(ρ0) = 0 for some n, then it terminates within dsteps, i.e.,

Fd(ρ0) = 0. If ρ0is a pure state |ψi, then we deﬁne the termination sets as

follows: Xn:= {|ψi:Fn(ψ) = 0}for each integer n > 0.

(1.1) If |ϕi,|χi ∈ Xn, then Fn(ϕ+χ) = 0, which leads to α|ϕi+β|χi ∈ Xn

for any α, β ∈C. Thus Xnis a subspace of H.

(1.2) Since Fn(ψ) = 0 ⇒ Fn+1 (ψ) = 0, it holds that that Xn⊆Xn+1 for

any n > 0. So, we have the inclusion relation X1⊆X2⊆ · ·· ⊆ Xn⊆ · ·· .

Now suppose tis the smallest integer satisfying Xt=Xt+1 . Invoking Lemma

2, we obtain that supp(F∗t(I)) = X⊥

t=X⊥

t+1 = supp(F∗t+1(I)),where F∗(·)

denotes the (Schrödinger-Heisenberg) dual of F(·). We have supp(F∗n(I)) =

supp(F∗t(I)), which leads to Xn=Xtfor all n≥t. Now, it holds that X1(

X2(···(Xt=Xt+1 =Xt+2 =···.This implies d1< d2···< dt,where diis

the dimension of subspace Xi. Thus, t≤d. If Fn(ψ) = 0, then |ψi ∈ Xn⊆Xd,

and Fd(ψ) = 0.

In general, if ρ0is a mixed input state ρ0=Ppi|ψiihψi|with all pi>0, and

Fn(ρ0) = 0, then Fn(ψi) = 0 for all i. Therefore, Fd(ψi) = 0 for all i, and it

follows immediately that Fd(ρ0) = 0.

(2) For the general case of |K| ≥ 2, we assume that Pstarting in ρ0terminates

in S, i.e., for any s∈S, there exists an integer nssuch that Fs[ns](ρ0) = 0. Our

purpose is to show that there exists an integer nsuch that Fs[n](ρ0) = 0 for

all s∈S. Indeed, we can choose n=d. We do this by refutation. Assume that

Fs[d](ρ0)6= 0 for some s∈S. We are going to construct an execution path

s∈Ssuch that Fs[n](ρ0)6= 0 for any n≥0. Let F=Pk∈KFk. Then the

assumption means that there exist f∈Kdsuch that Ff(ρ0)6= 0, and it follows

that Fd(ρ0)6= 0.Now we consider the loop program ({F},{M0, M1})with initial

state ρ0. Applying (1) to it, we obtain F2d(ρ0)6= 0. Then there exist g1, h1∈Kd

such that Fh1(Fg1(ρ0)) = Fg1h1(ρ0)6= 0, and Fd(Fg1(ρ0)) 6= 0. Applying (1)

again leads to F2d(Fg1(ρ0)) 6= 0, which means that there exist h2, g2∈K2dsuch

that Fh2(Fg1g2(ρ0)) = Fg2h2(Fg1(ρ0)) 6= 0. Thus, we have Fd(Fg2g1(ρ0)) 6= 0.

Repeating this procedure, we can ﬁnd an inﬁnite sequence g1, g2, ... ∈Kd. Put

s=g1g2... ∈S. Then it holds that Ts[kd](ρ0)6= 0 for any integer k. Thus, we

have Ts[n](ρ)6= 0 for all n.

Now we are ready to consider termination under fairness. Of course, any per-

mutation of Kis a fair piece. We write PKfor the set of permutations of K. For

σ=s1s2···sm∈PK, a ﬁnite execution path of the form s1σ1s2σ2···σm−1sm

is called an expansion of σ. Obviously, for any σ∈PK, all of its expansions are

in Ffin . We will use a special class of fair pieces generated by permutations:

Π={s1σ1s2σ2···σm−1sm:s1s2···sm∈PKand |σi|< d for every 1 ≤i < m},

where dis the dimension of the Hilbert space Hof program states. It is easy to

see that Π(Ff in.

Theorem 6 A program P= ({Ek:k∈K},{M0, M1})with initial state ρ0

terminates in the fair schedule Fif and only if it terminates in the schedule Πω.

Proof. The “only if” part is clear because Πω⊆F. To prove the “if” part, assume

Pterminates in the schedule Πω. We proceed in four steps:

(1) Since Πis a ﬁnite set, we can construct a new program P′= ({Ff:f∈

Π},{0, I}). (We should point out that Ffis usually not trace-preserving, and

thus P′is indeed not a program in the sense of Deﬁnition 1. However, this does

not matter for the following arguments.) It is easy to see that the termination

of Pwith ρ0in schedule Πωimplies the termination of P′with ρ0in Πω. Note

that Πωis the biggest schedule in P′, although it is not the biggest schedule

in P. So, we can apply Theorem 5 to P′and assert that (Pf∈ΠFf)d(ρ0) = 0.

That is equivalent to

supp[( X

f∈ΠFf)d(ρ0)] = {0}(0 −dimensional subspace).(1)

(2) For each σ∈PK, we set Aσ={σ′∈Π:σ′is an expansion of σ}.Then

S

σ∈PK

Aσ=Π. Moreover, we write Gσ=Pf∈AσFffor every σ∈PK. It is worth

noting that Pσ∈PKGσ=Pf∈ΠFfis not true in general because it is possible

that Aσ1∩Aσ26=∅for diﬀerent σ1and σ2. But by Lemma 1.1 and 3 we have

supp[( X

σ∈PKGσ)(ρ0)] = supp[( X

f∈ΠFf)(ρ0)],

and furthermore, it follows from Eq. (1) that

supp[( X

σ∈PKGσ)d(ρ0)] = supp[( X

f∈ΠFf)d(ρ0)] = {0}.(2)

(3) For each fair piece σ′∈Ff in , and for any ρ, we can write σ′=s1f1s2···

sm−1fm−1smfor some σ0=s1s2···sm∈PK, and f1, ..., fm−1∈Sf in. Fur-

thermore, we write G=Pd−1

i=0 (Pm

k=1 Fk)i. First, a routine calculation leads to

Gσ0=Fsm◦G ◦Fsm−1···Fs2◦ G ◦ Fs1.Second, it follows from Theorem 1 that

for each 1≤i≤m−1, and for any ρ,supp(Ffi(ρ)) ⊆supp(G(ρ)).Repeatedly

applying this inclusion together with Lemma 2.1 we obtain

supp(Fσ′(ρ)) = supp[(Fsm◦ Ffm−1◦ Fsm−1◦ · ·· ◦ Fs2◦ Ff1◦ Fs1)(ρ)]

⊆supp[(Fsm◦ G ◦ Fsm−1◦ · · · ◦ Fs2◦ G ◦ Fs1)(ρ)]

= supp(Gσ0(ρ)) ⊆supp( X

σ∈ΠFσ)(ρ).

(3)

(4) Now we are able to complete the proof by showing that for any fair

execution path s∈F,shas an initial segment tsuch that Ft(ρ0) = 0. In fact, s

can be written as an inﬁnite sequence of fair piece, i.e., s=σ′

1σ′

2···, where each

σ′

iis a fair piece. We take tto be the initial segment of scontaining the ﬁrst d

fair pieces, i.e., t=σ1σ2···σd. Repeatedly applying Eq. (3) and Lemma 2.1 we

obtain

suppFt(ρ0) = supp[(Fσ′

d◦ · ·· ◦ Fσ′

2◦ Fσ′

1)(ρ0)]

⊆supp[(X

p∈ΠFp)d(ρ)] = {0}.

Thus, Ft(ρ) = 0.

The above theorem can be slightly strengthened by employing the notion of

fairness index in Deﬁnition 4. First, we have:

Lemma 4 Πω(F1

md .

Proof. For any s=σ1σ2·· · ∈ Πωwith σi∈Π, we know that σi(|σi|, k)≥1for

any k∈Kand |σi|< md, where σi(|σi|, k)is the number of occurrences of k

in σi. Then the occurrence frequency f(s)>1

md , which means that Πω⊆F1

md .

On the other hand, we choose an arbitrary s∈F1

md . Then 1mds∈F1

md but

1mds /∈Πω.

Actually, what we proved in Theorem 6 is that for any two schedules A, B

between Πωand F, i.e., Πω⊂A, B ⊂F, a program terminates in schedule A

if and only if it terminates in schedule B. Combining Theorem 6 and Lemma 4

yields:

Corollary 1 For any 0≤δ, ǫ ≤1

md , a program terminates in schedule Fδif and

only if it terminates in schedule Fǫ.

Now an algorithm checking termination of a concurrent quantum program

can be developed based on Theorem 5.

Algorithm 3: Decide termination of a concurrent quantum program

input : An input state ρ0, and the matrix representation of each Fii.e, Ni

output: b.(If the program terminates under F,b= 0; Otherwise, b= 1.)

N←0;

for k= 1 : mdo

N←Ni+N;

end

G←I;

for k= 1 : d−1do

G←I+NG;

end

(*Compute the matrix representation of G*)

M←0;

Generate PK;

for p=p1p2···pm∈PKdo

L←Np1;

for l= 2 : mdo

L←NplGL;

end

(*Compute the matrix representation of Fp*)

M←M+L;

end

(*Compute the matrix representation of Pp∈PKFp*)

|xi ← Md(ρ0⊗I)|Φi;

if |xi 6= 0 then

b←1;

end

if |xi= 0 then

b←0;

end

return b

Theorem 7 Algorithm 3 decides termination of a concurrent quantum program

in time O(mmd4.7454), where mis the number of the processes, and d= dim H.

Proof: In the algorithm, we use the for loop to compute the matrix rep-

resentation Gof G=Pd−1

i=0 (Pm

k=1 Fk)i. Then the matrix representation of

Fσ=Fs1◦ G ◦ Fs2· ··G ◦ Fsm(·)is obtained for any σ=s1s2···sm∈PK.

All Fσs are added up to M. Then Mbecomes the matrix representation of

Pσ∈PKFσ. Consequently, we can apply Theorem 6 to assert that this algorithm

outputs 0 if the program terminates in the fair schedule F; otherwise, 1.

To analyse its complexity, the algorithm can be divided into three steps: (1)

Computing Gcosts O(m+d d2∗2.3727) = O(m+d5.7454 ); (2) Computing Mcosts

m!∗2m∗O(d2∗2.3727 ) = O(mmd4.7454); (3) Computing |xicosts O(d4.7454 log d).

So the total cost is O((mm+d)d4.7454 ).

6 Conclusion

In this paper, we studied two of the central problems, namely, reachability and

termination for concurrent quantum programs. A concurrent quantum program

is modeled by a family of quantum Markov chains sharing a state Hilbert space

and a termination measurement, with each chain standing for a participating

process. This model extends Hart, Sharir and Pnueli’s model of probabilistic

concurrent programs [12] to the quantum setting. We show that the reachable

space and the uniformly repeatedly reachable space of a concurrent quantum

program can be computed and its termination can be decided in time O(d4.7454 ),

O(d4.7454 log d),O((mm+d)d4.7454), respectively, where mis the number of

participating processes, and dis the dimension of state space.

For further studies, an obvious problem is: how to improve the above al-

gorithm complexities? In this paper, reachability and termination of quantum

programs were deﬁned in a way where probabilities are abstracted out; that is,

only reachability and termination with certainty are considered. A more delicate,

probability analysis of the reachability and termination is also an interesting

open problem. The algorithms for computing the reachable space and checking

termination of a quantum program presented in this paper are all algorithms for

classical computers. So, another interesting problem is to ﬁnd eﬃcient quantum

algorithms for reachability and termination analysis of a quantum program.

Acknowledgment

We are grateful to Dr Yangjia Li, Runyao Duan and Yuan Feng for useful dis-

cussions. This work was partly supported by the Australian Research Council

(Grant No. DP110103473).

References

1. J. I. Cirac, A. K. Ekert, S. F. Huelga and C. Macchiavello, Distributed quantum

computation over noisy channels, Physical Review A 59(1999)4249-4254.

2. C. Don and W. Shmuel, Matrix multiplication via arithmetic progressions, Journal

of Symbolic Computation 9(1990)251-280.

3. T. A. S. Davidson, Formal Veriﬁcation Techniques using Quantum Process Calcu-

lus, Ph.D. thesis, University of Warwick, 2011.

4. T. Davidson, S. Gay, R. Nagarajan and I. V. Puthoor, Analysis of a quantum error

correcting code using quantum process calculus, Proceedingds of QPL 2011, the 8th

Workhop on Quantum Physics and Logic, pp. 107-120.

5. E. D’Hondt and P. Panangaden, Quantum weakest preconditions, Mathematical

Structures in Computer Science 16(2006)429-451.

6. Y. Feng, R. Y. Duan, Z. F. Ji and M. S. Ying, M, Probabilistic bisimulations for

quantum processes, Information and Computation 205(2007)1608-1639.

7. Y. Feng, R. Y. Duan and M. S. Ying, Bisimulation for quantum processes, Pro-

ceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Pro-

gramming Languages (POPL), 2011, pp. 523-534.

8. S. J. Gay and R. Nagarajan, Communicating Quantum Processes, Proceedings

of the 32nd ACM Symposium on Principles of Programming Languages (POPL),

2005, pp. 145-157.

9. S. J. Gay and R. Nagarajan, Types and typechecking for communicating quantum

processes, Mathematical Structures in Computer Science 16(2006)375Ð406.

10. S. J. Gay, N. Papanikolaou and R. Nagarajan, QMC: a model checker for quan-

tum systems. Proceedings of the 20th International Conference on Computer Aided

Veriﬁcation (CAV), 2008, Springer LNCS 5123, pp. 543-547.

11. S. J. Gay, N. Papanikolaou and R. Nagarajan, Speciﬁcation and veriﬁcation of

quantum protocols, Semantic Techniques in Quantum Computation (S. J. Gay

and I. Mackie, eds.), Cambridge University Press, 2010, pp. 414-472.

12. S. Hart, M. Sharir and A. Pnueli, Termination of probabilistic concurrent programs,

ACM Transactions on Programming Languages and Systems 5(1983)356-380.

13. P. Jorrand and M. Lalire, Toward a quantum process algebra, Proceedings of the

First ACM Conference on Computing Frontiers, 2004, pp. 111-119.

14. M. Lalire, Relations among quantum processes: bisimilarity and congruence, Math-

ematical Structures in Computer Science 16(2006)407-428.

15. M. Lalire and P. Jorrand, A process algebraic approach to concurrent and dis-

tributed quantum computation: operational semantics, Proceedings of the 2nd In-

ternational Workshop on Quantum Programming Languages, 2004.

16. Y. Y. Li, N. K. Yu and M. S. Ying, Termination of nondeterministic quantum

programs, Short presentation of LICS’2012 (For full paper, see arXiv: 1201.0891).

17. M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information,

Cambridge University Press, Cambridge, 2000.

18. P. Selinger, Towards a quantum programming language, Mathematical Structure

in Computer Science 14(2004)527-586.

19. M. Sharir, A. Pnueli and S. Hart, Veriﬁcation of probabilistic programs, SIAM

Journal on Computing 13(1984)292-314.

20. M. S. Ying, Floyd-Hoare logic for quantum programs, ACM Transactions on Pro-

gramming Languages and Systems 33(2011) art. no: 19.

21. M. S. Ying and Y. Feng, An algebraic language for distributed quantum computing,

IEEE Transactions on Computers 58(2009)728-743.

22. M. S. Ying, Y. Feng, R. Y. Duan and Z. F. Ji, An algebra of quantum processes,

ACM Transactions on Computational Logic 10(2009) art. no. 19.

23. M. S. Ying and Y. Feng, Quantum loop programs, Acta Informatica 47(2010)221-

250.

24. M. S. Ying, N. K. Yu, Y. Feng and R. Y. Duan, Veriﬁcation of Quantum Programs,

arXiv:1106.4063.