<<

Models of quantum computation and languages

Jaroslaw Adam MISZCZAK Institute of Theoretical and Applied Informatics, Polish Academy of Sciences, Ba ltycka 5, 44-100 Gliwice, Poland

The goal of the presented paper is to provide an introduction to the basic computational mod- els used in theory. We review various models of quantum , quantum circuits and quantum random access machine (QRAM) along with their classical counter- parts. We also provide an introduction to quantum programming languages, which are developed using the QRAM model. We review the syntax of several existing quantum programming languages and discuss their features and limitations.

I. INTRODUCTION of existing models of quantum computation is biased towards the models interesting for the development of Computational process must be studied using the fixed quantum programming languages. Thus we neglect some model of computational device. This paper introduces models which are not directly related to this area (e.g. the basic models of computation used in quantum in- quantum automata or topological quantum computa- formation theory. We show how these models are defined tion). by extending classical models. We start by introducing some basic facts about clas- A. Quantum information theory sical and quantum Turing machines. These models help to understand how useful can be. It can be also used to discuss the difference between Quantum information theory is a new, fascinating field quantum and classical computation. For the sake of com- of research which aims to use quantum mechanical de- pleteness we also give a brief introduction to the main res- scription of the system to perform computational tasks. ults of quantum complexity theory. Next we introduce It is based on quantum physics and classical computer Boolean circuits and describe the most widely used model science, and its goal is to use the laws of quantum mech- of quantum computation, namely quantum circuits. We anics to develop more powerful algorithms and protocols. focus on this model since many presented facts about According to the Moore’s Law [3, 4] the number of quantum circuits are used in the following sections. Fi- transistors on a given chip is doubled every two years nally we introduce another model which is more suited for (see Figure 1). Since classical computation has its natural defining programming languages operating on quantum limitations in the terms of the size of computing devices, memory — quantum random access machine (QRAM). it is natural to investigate the behaviour of objects in micro scale. We also describe selected examples of the existing quantum programming languages. We start by formu- 1010 8-Core Xeon Nehalem-EX lating the requirements which must be fulfilled by any Dual-Core 2 109 universal quantum programming language. Next we de- Itanium 2 (9 MB cache) Itanium 2 scribe languages based on imperative paradigm – QCL 108 Pentium 4 (Quantum Computation Language) and LanQ. We also Itanium describe recent research efforts focused on implementing 107 Pentium III

transistors Pentium II languages based on functional paradigm and discuss the of Pentium 6 er 10 Intel486 advantages of a language based on this paradigm. As the b

Num Intel386 example of functional quantum programming language Intel286 105 we present cQPL. 8086

We introduce the syntax and discuss the features of the 104 4004 8080 presented languages. We also point out their weaknesses. 8008 arXiv:1012.6035v2 [cs.PL] 3 Dec 2011 103 For the sake of completeness a few examples of quantum 1970 1975 1980 1985 1990 1995 2000 2005 2010 algorithms and protocols are presented. We use these Year of introduction examples to introduce the main features of the presented Figure 1. Illustration of Moore’s hypothesis. The number of languages. transistors which can be put on a single chip grows exponen- Note that we will not discuss problems related to the tially. The squares represent introduced by physical realisation of the described models. We also do Intel Corporation [4]. The dotted line illustrates the rate of not cover the area of quantum error correcting codes, growth, with the number of transistors doubling every two which aims to provide methods for dealing with decoher- years. ence in quantum systems. For an introduction to these problems and recent progress in this area see e.g. [1, 2]. Quantum effects cannot be neglected in microscale and One should be also aware that the presented overview thus they must be taken into account when designing fu- 2 ture computers. Quantum computation aims not only at classical complexity classes like NP. taking them into account, but also at developing methods for controlling them. Quantum algorithms and protocols are recipes how one should control quantum system to B. Progress in quantum algorithms achieve higher efficiency. Information processing on quantum computer was first Due to the slow progress in discovering new quantum mentioned in 1982 by Feynman [5]. This seminal work algorithms novel methods for studying the impact of was motivated by the fact that simulation of a quantum on algorithmic problems were pro- system on the classical machine requires exponential re- posed. sources. Thus, if we could control a physical system at The first of these methods aims at applying the rules the quantum level we should be able to simulate other of quantum mechanics to game theory [16, 23]. Classical quantum systems using such machines. games are used to model the situation of conflict between The first quantum protocol was proposed two years competing agents. The simplest application of quantum later by Bennett and Brassard [6]. It gave the first ex- games is presented in the form of quantum prisoners di- ample of the new effects which can be obtained by using lemma [15]. In this case one can analyse the impact of the rules of quantum theory for information processing. quantum information processing on classical scenarios. In 1991 Ekert described the protocol [7] showing the us- On the other hand quantum games can be also used to age of quantum entanglement [8] in communication the- analyse typical quantum situations like state estimation ory. and cloning [24]. Today we know that thanks to the quantum nature Quantum walks provide the second promising method of photons it is possible to create unconditionally se- for developing new quantum algorithms. Quantum cure communication links [9] or send information with walks are the counterparts of classical random walks the efficiency unachievable using classical carriers. Dur- [17, 18]. For example, in [25] the ing the last few years quantum cryptographic protocols for element distinctness using this method was proposed. / have been implemented in real-world systems. Quantum It requires O(n2 3) queries to determine if the input key distribution is the most promising application of x1, . . . , xn consisting of n elements contains two equal { } quantum information theory, if one takes practical ap- numbers. Classical algorithm solving this problem re- plications [10, 11] into account. quires O(n log n) queries. The generalisation of this al- On the other hand we know that the quantum mech- gorithm, with applications to the problem of subset find- anical laws of nature allow us to improve the solution ing, was described in [26]. Other application of quantum of some problems [12–14], construct games [15, 16] and walks include searching algorithms [27] and subset find- random walks [17, 18] with new properties. ing problem. It was also shown that quantum walks can Nevertheless, the most spectacular achievements in be used to perform a universal quantum computation quantum information theory up to the present moment [28, 29]. In [30] the survey of quantum algorithms based are: the quantum algorithm for factoring numbers and on quantum walks is presented. More information con- calculating discrete logarithms over finite field proposed cerning recent developments in quantum walks and their in the late nineties by Shor [13]. The quantum al- applications can be found in [31]. gorithm solves the factorisation problem in polynomial One should note that the development of quantum al- time, while the best known probabilistic classical al- gorithms is still a very lively area of research [20, 32]. gorithm runs in time exponential with respect to the size General introduction to quantum algorithms can be of input number. Shor’s factorisation algorithm is one of found in [33]. The in-depth review of the recent results the strongest arguments for the conjecture that quantum in the area of quantum algorithms for algebraic problems computers can be used to solve in polynomial time prob- can be found in [34]. lems which cannot be solved classically in reasonable (i.e. polynomial) time. II. COMPUTABILITY Taking into account research efforts focused on dis- covering new quantum algorithms it is surprising that for the last ten years no similar results have been ob- Classically computation can be described using vari- tained [19, 20]. One should note that there is no proof ous models. The choice of the model used depends on that quantum computers can actually solve NP-complete the particular purpose or problem. Among the most im- problems in polynomial time [21, 22]. This proof could portant models of computation we can point: be given by quantum algorithms solving in polynomial Turing Machine introduced in 1936 by Turing time problems known to be NP-complete such as k- • and used as the main model in complexity the- colorability. The complexity of quantum computation ory [35]. remains poorly understood. We do not have much evid- ence how useful quantum computers can be. Still much Random Access Machine [36, 37] which is the remains to be discovered in the area of the relations • example of register machines; this model cap- between quantum complexity classes such as BQP and tures the main features of modern computers and 3

provides a theoretical model for programming lan- On the other hand for practical purposes the notion guages. of Turing machine is clumsy. Even for simple algorithms it requires quite complex description of transition rules. Boolean circuits [38] defined in terms of logical • Also, programming languages defined using a Turing ma- gates and used to compute Boolean functions f : chine [43], have rather limited set of instructions. Thus 0, 1 m 0, 1 n; they are used in complexity the- { } 7→ { } we use more sophisticated methods like Boolean circuits ory to study circuit complexity. and programming languages based on QRAM model. Lambda calculus defined by Church [39] and used • as the basis for many functional programming lan- guages [40]. A. Turing machine Universal programming languages which are The model of a Turing machine is widely used in clas- • probably the most widely used model of computa- sical and quantum complexity theory. Despite its simpli- tion [41]. city it captures the notion of computability. It can be shown that all these models are equivalent In what follows by alphabet A = a1, . . . , an we mean [35, 38]. In other words the function which is computable any finite set of characters or digits.{ Elements} of A are using one of these models can be computed using any called letters. Set Ak contains all strings of length k other model. It is quite surprising since Turing machine composed from elements of A. Elements of Ak are called is a very simple model, especially when compared with words and the length of the word w is denoted by w . RAM or programming languages. The set of all words over A is denoted by A∗. Symbol| | In particular the model of a  is used to denote an empty word. The complement of is regarded as a canonical one. This fact is captured by language L A∗ is denoted by L¯ and it is the language the Church-Turing hypothesis. defined as L¯⊂= A∗ L. − Hypothesis 1 (Church-Turing) Every function which would be naturally regarded as computable can be 1. Classical Turing machine computed by a .

Although stated as a hypothesis, this thesis is one of A Turing machine can operate only using one data the fundamental axioms of modern computer science. A structure – the string of symbols. Despite its simplicity, Universal Turing machine is a machine which is able to this model can simulate any algorithm with inconsequen- simulate any other machine. The simplest method for tial loss of efficiency [35]. A Classical Turing machine constructing such device is to use the model of a Turing consists of machine with two tapes [35]. Research in quantum information processing is motiv- an infinitely long tape containing symbols from the • ated by the extended version of Church-Turing thesis for- finite alphabet A, mulated by Deutsch [42]. a head, which is able to read symbols from the tape Hypothesis 2 (Church-Turing-Deutsch) Every • and write them on the tape, physical process can be simulated by a universal comput- ing device. memory for storing programme for the machine. • In other words this thesis states that if the laws of phys- The programme for a Turing machine is given in terms ics are used to construct a Turing machine, this model of transition function δ. The schematic illustration of a might provide greater computational power when com- Turing machine is presented in Figure 2. pared with the classical model. Since the basic laws of Formally, the classical deterministic Turing machine is physics are formulated as quantum mechanics, this im- defined as follows. proved version of a Turing machine should be governed by the laws of quantum physics. Definition 1 (Deterministic Turing machine) A In this section we review some of these computational deterministic Turing machine M over an alphabet A is models focusing on their quantum counterparts. The dis- a sixtuple (Q, A, δ, q0, qa, qr), where cussion of quantum programming languages, which are based on the quantum random access machines (QRAM), Q is the set of internal control states, is presented in Section III. • We start be recalling the basic facts concerning a Tur- q0, qa, qr Q are initial, accepting and rejecting • ∈ ing machine. This model allows to establish clear notion states, of computational resources like time and space used dur- ing computation. It is also used to define other models δ : Q A Q A 1, 0, 1 is a transition • × 7→ × × {− } introduced in this section precisely. function i.e. the programme of a machine. 4

By a configuration of machine M we understand a Language H used in the above theorem is defined in ∗ triple (qi, x, y), qi Q, x, y A . This describes a halting problem [35]. It consists of all words composed ∈ ∈ situation where the machine is in the state qi, the tape of words encoding Turing machines and input words for contains the word xy and the machine starts to scan the these machines, such that a particular machine halts on a 0 0 word y. If x = x and y = b1y we can illustrate this given word. A universal Turing machine can simulate any situation as in Figure 2. machine, thus for a given input word encoding machine and input for this machine we can easily perform the required computation. A ¡ A deterministic Turing machine is used to measure A¡ of algorithms. Note that if for some lan- guage there exists a Turing machine accepting it, we can 0 0 x a b1 y use this machine as an algorithm for solving this problem. Thus we can measure the running time of the algorithm (a)Configuration (q , x0a, b y0) i 1 by counting the number of computational steps required for Turing machine to output the result. A ¡ The time complexity of algorithms can be described A¡ using the following definition. Definition 4 TIME consists of x0 a b y0 (f(n)) 2 all languages L such that there exists a deterministic Tur- 0 0 (b)Configuration (qj , x , ab2y ) ing machine running in time f(n) accepting input w iff w L. ∈ Figure 2. Computational step of the Turing machine. Con- 0 0 P figuration (qi, x a, b1y ) is presented in (a). If the transition In particular complexity class defined as function is defined such that δ(qi, b1) = (q2, b2, −1) this com- 0 0 [ k putational step leads to configuration (qj , x , ab2y ) (see (b)). P = TIME(n ), (1) k

The transition from the configuration c1 to the config- 0 captures the intuitive class of problems which can be uration c2 is called a computational step. We write c c solved easily on a Turing machine. if δ defines the transition from c to c0. In this case c`0 is called the successor of c. A Turing machine can be used to compute values of 2. Nondeterministic and probabilistic computation functions or to decide about input words. The com- putation of a machine with input w A∗ is defined Since one of the main features of quantum computers as a sequence of configurations c , c , c∈,..., such that 0 1 2 is their ability to operate on the superposition of states c = (q , , w) and c c . We say that computation 0 i i i+1 we can easily extend the classical model of a probab- halts if some c has no` successor or for configuration c , i i ilistic Turing machine and use it to describe quantum the state of the machine is q (machine accepts input) or a computation. Since in general many results in the area q (machine rejects input). r of algorithms complexity are stated in the terms of a The computational power of the Turing machine has its nondeterministic Turing machine we start by introducing limits. Let us define two important classes of languages. this model.

Definition 2 A set of words L A∗ is a recursively enu- Definition 5 (Nondeterministic Turing machine) ∈ merable language if there exists a Turing machine accept- A nondeterministic Turing machine M over an alphabet ing input w iff w L. A is a sixtuple (Q, A, δ, q , q , q ), where ∈ 0 a r ∗ Q is the set of internal control states, Definition 3 A set of words L A is a recursive lan- • guage if there exists a Turing machine∈ M such that q0, qa, qr Q are initial, accepting and rejecting • states, ∈ M accepts w iff w L, • ∈ δ Q A Q A 1, 0, 1 is a relation. M halts for any input. • ⊂ × × × × {− } • The last condition in the definition of a nondetermin- The computational power of the Turing machine is lim- istic machine is the reason for its power. It also requires ited by the following theorem. to change the definition of acceptance by the machine. We say that a nondeterministic Turing machine ac- Theorem 1 There exists a language H which is recurs- cepts input w if, for some initial configuration (qi, , w), ively enumerable but not recursive. computation leads to configuration (qa, a1, a2) for some 5

For a moment we can assume that the probabilities of transition used by a probabilistic Turing machine can be represented only by rational numbers. We do this to time flow avoid problems with machines operating on arbitrary real numbers. We will address this problem when extending the above definition to the quantum case. The time complexity of computation can be measured in terms of the number of computational steps of the Tur- ing machine required to execute a programme. Among important complexity classes we have chosen to point out: P – the class of languages for which there exists • a deterministic Turing machine running in polyno- mial time, Figure 3. Schematic illustration of the computational paths of a nondeterministic Turing machine [35]. Each circle rep- NP – the class of languages for which there ex- resents the configuration of the machine. The machine can • ists a nondeterministic Turing machine running in be in many configurations simultaneously. polynomial time,

RP – the class of languages L for which there exists words a and a . Thus a nondeterministic machine ac- 1 2 • a probabilistic Turing machine M such that: M cepts the input if there exists some computational path accepts input w with probability at least 1 if w L defined by transition relation δ leading to an accepting 2 and always rejects w if w L, ∈ state qa. 6∈ The model of a nondeterministic Turing machine is coRP – the class of languages L for which L¯ is in used to define complexity classes NTIME. • RP, Definition 6 Complexity class NTIME consists (f(n)) ZPP – RP coRP. of all languages L such that there exists a nondetermin- • ∩ istic Turing machine running in time f(n) accepting in- More examples of interesting complexity classes and put w iff w L. computational problems related to them can be found ∈ The most prominent example of these complexity classes in [44]. is NP, which is the union of all NTIME(nk), i.e. [ NP = NTIME(nk). (2) 3. k A nondeterministic Turing machine is used as a theor- A quantum Turing machine was introduced by Deutsch etical model in complexity theory. However, it is hard to [42]. This model is equivalent to a model imagine how such device operates. One can illustrate the [45, 46]. However, it is very inconvenient for describing computational path of a nondeterministic machine as in quantum algorithms since the state of a head and the Figure 3 [35]. state of a tape are described by state vectors. Since our aim is to provide the model of a physical A quantum Turing machine consists of device we restrict ourselves to more realistic model. We : M 2-state observables ni i . can do that by assigning to each element of relation a • { | ∈ZM } number representing probability. In this case we obtain Memory: infinite sequence of 2-state observables the model of a probabilistic Turing machine. • mi i Z . { | ∈ } Definition 7 (Probabilistic Turing machine) A Observable x, which represents the address of the probabilistic Turing machine M over an alphabet A is a • current head position. sixtuple (Q, A, δ, q0, qa, qr), where Q is the set of internal control states, The state of the machine is described by the vector • ψ(t) = x; n0, n1,... ; m in the Hilbert space asso- q , qa, qr Q are initial, accepting and rejecting | i | i H • 0 ∈ ciated with the machine. states, At the moment t = 0 the state of the machine is described by the vectors ψ(0) = δ : Q A Q A 1, 0, 1 [0, 1] is a transition P | i • × × × ×{− } 7→ am 0; 0,..., 0; ..., 0, 0, 0,... such that probability function i.e. m | i X X 2 δ(q1, a1, q2, a2, d) = 1. (3) ai = 1. (4) | | (q2,a2,d)∈Q×A×{−1,0,1} i 6

The evolution of the quantum Turing machine is de- Definition 9 Complexity class BQP contains languages scribed by the unitary operator U acting on . L for which there exists a quantum Turing machine run- A classical probabilistic (or nondeterministic)H Turing ning in polynomial time such that, for any input word x, 3 machine can be described as a quantum Turing machine this word is accepted with probability at least 4 if x L such that, at each step of its evolution, the state of the 3 ∈ and is rejected with probability at least 4 if x L. machine is represented by the base vector. 6∈ The formal definition of the quantum Turing machine Class BQP is a quantum counterpart of the classical was introduced in [21]. class BPP. It is common to use real numbers as amplitudes when describing the state of quantum systems during quantum Definition 10 Complexity class BPP contains lan- computation. To avoid problems with an arbitrary real guages L for which there exists a nondeterministic Turing number we introduce the class of numbers which can be machine running in polynomial time such that, for any used as amplitudes for amplitude transition functions of input word x, this word is accepted with probability at the quantum Turing machine. 3 3 least 4 if x L and is rejected with probability at least 4 Let us denote by Ce the set of complex numbers c C, if x L. ∈ such that there exists a deterministic Turing machine,∈ 6∈ which allows to calculate Re (c) and Im (c) with accuracy 1 Since many results in complexity theory are stated in 2n in time polynomial in n. terms of oracles, we define an oracle as follows. Definition 8 (Quantum Turing Machine) A Definition 11 An oracle or black box is an imaginary quantum Turing machine (QTM) M over an alphabet A machine which can decide certain problems in a single is a sixtuple (Q, A, δ, q , q , q ), where 0 a r operation. Q is the set of internal control states, • We use notation AB to describe the class of problems q0, qa, qr Q are initial, accepting and rejecting solvable by an algorithm in class A with an oracle for the • states, ∈ language B. It was shown [21] that the quantum complexity classes δ : Q A Q A 1, 0, 1 Ce is a transition are related as follows. • amplitude× × function× ×i.e. {− } 7→ X Theorem 2 Complexity classes fulfil the following in- δ(q , a , q , a , d) 2 = 1. (5) | 1 1 2 2 | equality (q2,a2,d)∈Q×A×{−1,0,1} BPP BQP P#P. (6) ⊆ ⊆ Reversible classical Turing machines (i.e.Turing ma- chines with reversible transition function) can be viewed Complexity class #P consists of problems of the form as particular examples of quantum machines. Since any compute f(x), where f is the number of accepting paths of classical algorithm can be transformed into reversible an NP machine. For example problem #SAT formu- form, it is possible to simulate a classical Turing machine lated below is in #P. using quantum Turing machine. Problem 1 (#SAT) For a given Boolean formula, compute how many satisfying true assignments it has. 4. Quantum complexity Complexity class P#P consists of all problems solvable Quantum Turing machine allows for rigorous analysis by a machine running in polynomial time which can use of algorithms. This is important since the main goal oracle for solving problems in #P. of quantum information theory is to provide some gain Complexity ZOO [44] contains the description of com- in terms of speed or memory with respect to classical plexity classes and many famous problems from complex- algorithms. It should be stressed that at the moment ity theory. The complete introduction to the complexity no formal proof has been given that a quantum Turing theory can be found in [35]. Theory of NP-completeness machine is more powerful than a classical Turing ma- with many examples of problems from this class is presen- chine [22]. ted in [48]. In this section we give some results concerning Many important results and basic definitions concern- quantum complexity theory. See also [21, 47] for a in- ing quantum complexity theory can be found in [21]. troduction to this subject. The proof of equivalence between quantum circuit and In analogy to classical case it is possible to define com- quantum Turing machine was given in [45]. An interest- plexity classes for the quantum Turing machine. The ing discussion of quantum complexity classes and relation most important complexity class is this case is BQP. of BQP class to classical classes can be found in [22]. 7

B. Quantum computational networks functions , and provide a universal set of gates we defined Boolean∨ ∧ circuit∼ using these particular functions. m After presenting the basic facts about Turing machines Function f : 0, 1 0, 1 is defined on the binary { } 7→ { } m n we are ready to introduce more usable models of comput- string of arbitrary length. Let fn : 0, 1 0, 1 be a restriction of f to 0, 1 n. For each{ such} restriction7→ { } ing devices. We start by defining Boolean circuits and { } extending this model to the quantum case. there is a Boolean circuit Cn computing fn. We say that C0,C1,C2,... is a family of Boolean circuits computing f. 1. Boolean circuits Note that any binary language L 0, 1 ∗ can be accepted by some family of circuits. But⊂ { since} we need Boolean circuits are used to compute functions of the to know the value of fn to construct a circuit Cn such form family is not an algorithmic device at all. We can state that there exists a family accepting the language, but we f : 0, 1 m 0, 1 n. (7) do not know how to build it [35]. { } 7→ { } To show how Boolean circuits are related to Turing Basic gates (functions) which can be used to define such machines we introduce uniformly generated circuits. circuits are Definition 13 We say that language L A∗ has uni- : 0, 1 2 0, 1 , (x, y) = 1 x = y = 1 formly polynomial circuits if there exists∈ a Turing ma- • ∧(logical{ and} ),7→ { } ∧ ⇔ chine M that an input 1 ... 1 outputs the graph of circuit | {z } n : 0, 1 2 0, 1 , (x, y) = 0 x = y = 0 • ∨ { } 7→ { } ∨ ⇔ Cn using space O(log n), and the family C0,C1,... ac- (logical or), cepts L. : 0, 1 0, 1 , (x) = 1 x (logical not). The following theorem provides a link between uni- • ∼ { } 7→ { } ∼ − formly generated circuits and Turing machines. The set of gates is called universal if all functions 0, 1 n 0, 1 can be constructed using the gates from Theorem 3 A language L has uniformly polynomial cir- this{ set.} 7→ It { is easy} to show that the set of functions com- cuit iff L P. posed of , and is universal. Thus it is possible ∈ to compute∼ any∨ functions∧ 0, 1 n 0, 1 m using only Quantum circuits model is an analogous to uniformly these functions. The full characteristic{ } 7→ { of} universal sets polynomial circuits. They can be introduced as the of functions was given by Post in 1949 [49]. straightforward generalisation of reversible circuits. Using the above set of functions a Boolean circuit is defined as follows. 2. Reversible circuits Definition 12 (Boolean circuit) A Boolean circuit is an acyclic direct graph with nodes labelled by input vari- The evolution of isolated quantum systems is described ables, output variables or logical gates , or . by a unitary operator U. The main difference with re- ∨ ∧ ∼ spect to classical evolution is that this type of evolution Input variable node has no incoming arrow while output is reversible. variable node has no outcoming arrows. The example of Before introducing a quantum circuit we define a re- a Boolean circuit computing the sum of bits x1 and x2 is versible Boolean circuit given in Figure 4. Definition 14 (Reversible gate) A classical revers- - - - - x2 ∼ ∨ ∼ y2 ible function (gate) 0, 1 m 0, 1 m is a permutation.  Z     { } 7→ { } Z >  Z ∼    Definition 15 A reversible Boolean circuit is a Boolean Z> circuit composed of reversible gates. Z  Z  Z The important fact expressed by the following the-  Z~ orem allows us to simulate any classical computation on  - - - x1 ∨ ∧ y1 a described using a reversible circuit     Theorem 4 All Boolean circuits can be simulated using     reversible Boolean circuits. Figure 4. The example of a Boolean circuit computing the sum of bits x1 and x2 [50]. Nodes labelled x1 and x2 represent Like in the case of nonreversible circuit one can intro- input variables and nodes labelled y1 and y2 represent output duce the universal set of functions for reversible circuits. variables. The important example of a gate universal for revers- ible Boolean circuits is a Toffoli gate. The graphical rep- Note that in general it is possible to define a Boolean resentation of this gate is presented in Figure 5. The circuit using different sets of elementary functions. Since following theorem was proved by Toffoli [52]. 8

x1 y1 inputs as outputs. Each n- quantum gate repres- ents the 2n-dimensional unitary operation of the group t SU(2n), i.e. generalised rotation in a complex Hilbert

x2 y2 space. The main advantage of this model is its simplicity. It t also provides very convenient representation of physical

x3 y3 evolution in quantum systems. From the mathematical point of view quantum gates Figure 5. Classical Toffoli gated is universal for reversible cir- are unitary matrices acting on n-dimensional Hilbert cuits. It was also used to provide the universal set of quantum space. They represent the evolution of an isolated gates [51]. quantum system [53]. The problem of constructing new quantum algorithms requires more careful study of operations used in Theorem 5 A Toffoli gate is a universal reversible gate. quantum circuit model. In particular we are interested in As we will see in the following section it is possible to efficient decomposition of quantum gates into elementary introduce two-bit quantum gates which are universal for operations. quantum circuits. This is impossible in the classical case We start by providing basic charactersistic of unitary and one needs at least a three-bit gate to construct the matrices [53, 54] universal set of reversible gates. Theorem 6 Every unitary 2 2 matrix G U(2) can In particular, any reversible circuit is automatically a be decomposed using elementary× rotations as ∈ quantum circuit. However, quantum circuits offer much more diversity in terms of the number of allowed opera- G = Φ(δ)Rz(α)Ry(θ)Rz(β) (8) tions. where  eiξ 0  3. Quantum circuits Φ(ξ) = , 0 eiξ The computational process of the quantum Turing ma- chine is complicated since data as well as control variables  cos(ξ/2) sin(ξ/2)  R (ξ) = , can be in a superposition of base states. To provide more y sin(ξ/2) cos(ξ/2) convenient method of describing quantum algorithms one − can use a quantum circuits model. This model is some- and times called a quantum gate array model. i ξ ! Quantum circuits model was first introduced by e 2 0 Rz(ξ) = −i ξ . Deutsch in [51] and it is the most commonly used nota- 0 e 2 tion for quantum algorithms. It is much easier to ima- gine than the quantum Turing machine since the control We introduce the definition of quantum gates as stated variables (executed steps and their number) are classical. in [50]. There are only quantum data (e.g. or qudits and Definition 16 A quantum gate U acting on m qubits is unitary gates) in a quantum circuit. m 2 2 a unitary mapping on C2 C ... C A quantum circuit consists of the following elements ≡ | ⊗ {z ⊗ } (see Table II): m times

2m 2m the finite sequence of wires representing qubits or U : C C , (9) • sequences of qubits (quantum registers), 7→ which operates on the fixed number of qubits. quantum gates representing elementary operations • from the particular set of operations implemented Formally, a quantum circuit is defined as the unitary on a quantum machine, mapping which can be decomposed into the sequence of elementary gates. measurement gates representing a measurement op- • Definition 17 A quantum circuit on m qubits is a unit- eration, which is usually executed as the final step m of a quantum algorithm. It is commonly assumed ary mapping on C2 , which can be represented as a con- that it is possible to perform the measurement on catenation of a finite set of quantum gates. each qubit in canonical basis 0 , 1 which cor- Any reversible classical gate is also a quantum gate. responds to the measurement of{| thei | Si} observable. z In particular logical gate (negation) is represented by ∼ The concept of a quantum circuit is the natural gener- quantum gate NOT , which is realized by σx Pauli matrix. alisation of acyclic logic circuits studied in classical com- As we know any Boolean circuit can be simulated by puter science. Quantum gates have the same number of a reversible circuit and thus any function computed by 9 a Boolean circuit can be computed using a quantum cir- q H S T cuit. Since a quantum circuit operates on a vector in | 0i × complex Hilbert space it allows for new operations typ- ical for this model. q1 H S The first example of quantum gate which has no clas- | i • sical counterpart is √NOT gate. It has the following q2 H property | i • • ×

√NOT √NOT = NOT, (10) Figure 6. Quantum circuit representing quantum Fourier which cannot be fulfilled by any classical Boolean func- transform for three qubits. Elementary gates used in this tion 0, 1 0, 1 . Gate √N is represented by the circuit are described in Table II. unitary{ matrix} 7→ { } ______L     q  1 1 + i 1 i 0 H  √NOT = . (11) | i • _____ ___ • 1 i 1 +− i 2 ______− L  q  Another example is Hadamard gate H. This gate is 1 H  | i • ⊕ _____ ___ • used to introduce the superposition of base states. It acts on the base state as q2 X Z 1 1 | i ⊕ H 0 = ( 0 + 1 ) ,H 1 = ( 0 1 ) . (12) | i √2 | i | i | i √2 | i − | i If the gate G is a quantum gate acting on one qubit it Figure 7. Circuit for . Double lines represent the operation which is executed depending on the is possible to construct the family of operators acting on classical data obtained after the measurement on a subsystem. many qubits. The particularly important class of mul- tiqubit operations is the class of controlled operations. Definition 19 Let G be a 2 2 unitary matrix. Quantum × Definition 18 (Controlled gate) Let G be a 2 2 gate defined as × unitary matrix representing a quantum gate. Operator X 1 ... 1 1 ... 1 G + l l I (15) | | {z }ih| {z } | ⊗ | ih | ⊗ 1 1 G + 0 0 I (13) n−1 n−1 l=6 1 ... 1 | ih | ⊗ | ih | ⊗ | {z } acting on two qubits, is called a controlled-G gate. n−1 is called (n 1)-controlled G gate. We denote this gate Here A B denotes the tensor product of gates (unitary − ⊗ by n− (G). operator) A and B, and I is an identity matrix. If in the ∧ 1 above definition we take G = NOT we get This gate n− (G) is sometimes referred to as a gen- ∧ 1  1 0 0 0  eralised Toffoli gate or a Toffoli gate with m controlled 0 1 0 0 qubits. Graphical representation of this gate is presented 1 1 σx + 0 0 I =   , (14) in Figure 8. | ih | ⊗ | ih | ⊗  0 0 0 1  0 0 1 0 The important feature of quantum circuits is expressed by the following universality property [54]. which is the definition of CNOT (controlled-NOT ) gate. Theorem 7 The set of gates consisting of all one-qubit This gate can be used to construct the universal set of gates U(2) and one two-qubit CNOT gate is universal in quantum gates. This gate also allows to introduce en- the sense that any n-qubit operation can be expressed as tangled states during computation the composition of these gates. 1 CNOT (H I) 00 = CNOT ( 00 + 10 ) ⊗ | i √2 | i | i x x x XOR x 1 1 2 1 2 = ( 00 + 11 ) 0 0 0 √2 | i | i 0 1 1 The classical counterpart of CNOT gate is XOR gate. 1 0 1 Other examples of single-qubit and two-qubit quantum 1 1 0 gates are presented in Table II. In Figure 6 a quantum circuit for quantum Fourier transform on three qubits is Table I. Logical values for XOR gate. Quantum CNOT gate presented. computes value of x1 XOR x2 in the first register and stores One can extend Definition 18 and introduce quantum values of x2 in the second register. gates with many controlled qubits. 10

The name of the gate Graphical representation Mathematical form

! 1 1 Hadamard √1 H 2 1 −1

! 0 1 Pauli X X 1 0

! 0 −i Pauli Y Y i 0

! 1 0 Pauli Z Z 0 −1

! 1 0 Phase S 0 i

! 1 0 π/8 T 0 eiπ/4

 1 0 0 0     0 1 0 0  CNOT •    0 0 0 1  0 0 1 0

 1 0 0 0      0 0 1 0  SWAP ×    0 1 0 0  × 0 0 0 1 ( ! !) 1 0 0 0 Measurement , 0 0 0 1

qubit wire ≡ single qubit FE n qubits / wire representing n qubits

classical bit double wire ≡ single bit

Table II. Basic gates used in quantum circuits with their graphical representation and mathematical form. Note that measure- ment gate is represented in Kraus form, since it is the example of non-unitary quantum evolution.

Note that, in contrast to the classical case, where one Let us assume that we have the set of gates containing needs at least three-bit gates to construct a universal set, only CNOT and one-qubit gates. In [56] theoretical lower quantum circuits can be simulated using one two-qubit bound for the number of gates required to simulate a cir- universal gate. cuit using these gates was derived. The efficient method of elementary gates sequence synthesis for an arbitrary In order to implement a quantum algorithm one has unitary gate was presented in [57]. to decompose many qubit quantum gates into element- ary gates. It has been shown that almost any n-qubit quantum gate (n 2) can be used to the build a univer- Theorem 8 (Shende-Markov-Bullock) Almost all sal set of gates [55]≥ in the sense that any unitary opera- n-qubit operators cannot be simulated by a circuit with fewer than 1 [4n 3n 1] CNOT gates. tion on the arbitrary number of qubits can be expressed d 4 − − e as the composition of gates from this set. In fact the set consisting of two-qubit exclusive-or (XOR) quantum In [58] the construction providing the efficient way of gate and all single-qubit gates is also universal [54]. implementing arbitrary quantum gates was described. 11

C. Random access machines • • • Quantum circuit model does not provide a mechan- ... ism for controlling with classical machine the operations • on . Usually quantum algorithms are described using mathematical representation, quantum G circuits and classical algorithms [60]. The model of quantum random access machine is built on an assump- Figure 8. Generalised quantum Toffoli gate acting on n tion that the quantum computer has to be controlled by qubits. Gate G is controlled by the state of n − 1 qubits a classical device [61]. Schematic presentation of such according to Definition 19. architecture is provided in Figure 9. Quantum random access machine is interesting for us since it provides a convenient model for developing The resulting circuit has complexity O(4n) which coin- quantum programming languages. However, these lan- cides with lower bound from Theorem 8. guages are our main area of interest. We see no point It is useful to provide more details about the special in providing the detailed description of this model as it case, when one uses gates with many controlled and one is given in [61] together with the description of hybrid target qubits. The following results were proved in [54]. architecture used in quantum programming. Theorem 9 For any single-qubit gate U the gate (U) can be simulated in terms of Θ(n2) basic op- n−1 1. Classical RAM model erations.∧

In many situations it is useful to construct a circuit The classical model of random access machine (RAM) which approximates the required circuit. We say that is the example of more general register machines [36, 37]. quantum circuits approximate other circuits with ac- The random access machine consists of an unboun- curacy ε if the distance (in terms of Euclidean norm) ded sequence of memory registers and a finite number of between unitary transformations associated with these arithmetic registers. Each register may hold an arbitrary circuits is at most ε [54]. integer number. The programme for the RAM is a finite sequence of instructions Π = (π , . . . , π ). At each step Theorem 10 For any single-qubit gate U and ε > 0 1 n of execution register i holds an integer r and the ma- gate (U) can be approximated with accuracy ε us- i n−1 chine executes instruction π , where κ is the value of the ing Θ(∧n log 1 ) basic operations. κ ε programme counter. Arithmetic operations are allowed Note that the efficient decomposition of a quantum to compute the address of a memory register. circuit is crucial in physical implementation of quantum Despite the difference in the construction between a information processing. In particular case decomposition Turing machine and RAM, it can be easily shown that can be optimised using the set of elementary gates spe- a Turing machine can simulate any RAM machine with cific for target architecture. CNOT gates are of big im- polynomial slow-down only [35]. portance since they allow to introduce entangled states It is worth noting that programming languages can during computation. It is also hard to physically realise be defined without using RAM model. Interesting pro- CNOT gate since one needs to control physical interac- gramming language for a Turing machine 00, providing P tion between qubits. the minimal set of instructions, was introduced by B¨ohm One should also note that for some classes of quantum in [43]. circuits it is possible to construct their classical counter- parts, which can be used to simulate quantum computa- tion performed by these circuits efficiently. The most not- 2. Quantum RAM model able class having this property is a class of circuits CHP class, which consists of stabilizer circuits, i.e. circuits con- Quantum random access machine (QRAM) model is sisting solely of CNOT, Hadamard and phase gates [59]. the extension of the classical RAM. QRAM can exploit This property is known as so called Gottesman-Knill the- quantum resources and, at the same time, can be used orem. to perform any kind of classical computation. It allows Theorem 11 (Gottesman-Knill) Any stabilizer cir- us to control operations performed on quantum registers cuit can be efficiently simulated on a classical machine. and provides the set of instructions for defining them. Recently a new model of sequential quantum random It is worth noting that gates used to construct sta- machine (SQRAM) has been proposed. Instruction set bilizer circuits do not provide an universal set of gates. for this model and compilation of high-level languages is Nevertheless, such circuits can produce highly entangled discussed in [62]. However, it is very similar to QRAM states. model. 12

the sequence of elementary gates the description of Procedure: Fourier(a, d) algorithm in abstract model Input: A quantum register a with d qubits. Qubits are- numbered from 0 to d − 1.

QCL Quantum Computation Language (32 qubits, seed Output: The amplitudes of a are Fourier transformed 1156322590) [0/32] 1 |0> qcl> qureg a[10]; qcl> H(a);[10/32] 0.03125 |0> + ... + 0.03125 |1023> (1024 terms) qcl> CNot(a[2],a[5]);[10/32] 0.03125 |0> + ... + 0.03125 |1023> (1024 terms) qcl> list a; over d . : global a = <0,1,2,3,4,5,6,7,8,9> Z2 qureg a[10] qcl> dump a[1]; qcl> : SPECTRUM a[1]: <1>0.5 |0>, 0.5 |1>qcl> C: assign value to classical variable d ω ← ei2π/2 Quantium III probability distribution C: perform sequence of gates classical controlling device quantum memory for futher analysis for i = d − 1 to i = 0 the outcome of measurement for j = d − 1 to j = i + 1 if a then R d−i−1+j (a ) j ω2 i C: number of loops executing phase Figure 9. The model of classically controlled quantum ma- C: depends on the required accuracy chine [61]. Classical computer is responsible for perform- C: of the procedure ing unitary operations on quantum memory. The results of H(ai) quantum computation are received in the form of measure- ment results. C: change the order of qubits d for j = 0 to j = 2 − 1 SWAP(aj , ad−a−j ) The quantum part of QRAM model is used to generate probability distribution. This is achieved by performing measurement on quantum registers. The obtained prob- Listing 1. Quantum pseudocode for quantum Fourier trans- form on d qubits. Quantum circuit for this operation with ability distribution has to be analysed using a classical d = 3 is presented in Figure 6. computer.

on a quantum register ai and (ai, aj) performs 3. Quantum pseudocode SWAP SWAP gate between ai and aj. Operation φ(ai) that R Quantum algorithms are, in most of the cases, de- executes a quantum gate R(φ) is defined as scribed using the mixture of quantum gates, mathemat- ! 1 0 ical formulas and classical algorithms. The first attempt R(φ) = , (16) to provide a uniform method of describing quantum al- 0 eiφ gorithms was made in [63], where the author introduced a high-level notation based on the notation known from on the quantum register ai. Using conditional contruc- computer science textbooks [64]. tion In [60] the first formalised language for description of if aj then Rφ(ai) quantum algorithms was introduced. Moreover, it was it is easy to define controlled phase shift gate (see Defin- tightly connected with the model of quantum machine ition 19). Similar construction exists in QCL quantum called quantum random access machine (QRAM). programming language described in Section III. Quantum pseudocode proposed by Knill [60] is based The measurement of a quantum register can be indic- on conventions for classical pseudocode proposed in [64, ated using an assignement aj ← aj . Chapter 1]. Classical pseudocode was designed to be readable by professional programmers, as well as people who had done a little programming. Quantum pseudo- 4. Quantum programming environment code introduces operations on quantum registers. It also allows to distinguish between classical and quantum re- gisters. Since the main aim of this paper is to present the ad- vantages and limitations of high-level quantum program- Quantum registers are distinguished by underlining ming languages, we need to explain how these languages them. They can be introduced by applying quantum op- are related to quantum random access machine. Thus erations to classical registers or by calling a subroutine as the summary of this section we present the overview which returns a . In order to convert a of an architecture for quantum programming, which is quantum register into a classical register measurement based on the QRAM model. operation has to be perfomed. The architecture proposed in [65, 66] is designed for The example of quantum pseudocode is presented in transforming a high-level quantum programming lan- Listing 1. It shows the main advantage of QRAM model guage into the technology-specific implementation set of over quantum circuits model – the ability to incorpor- operations. This architecture is composed of four layers: ate classical control into the description of quantum al- gorithm. High level programming language provid- • Operation (ai) executes a quantum Hadamard gate ing high-level mechanisms for performing useful H 13

quantum computation; this language should be in- and various quantum programming languages [61, 66, 74– dependent from particular physical implementation 77]. of quantum computing. Several languages and formal models were proposed for the description of quantum computation process. The Compiler of this language providing architec- • most popular of them is quantum circuit model [51], ture independent optimisation; also compilation which is tightly connected to the physical operations im- phase can be used to handle quantum error cor- plemented in the laboratory. On the other hand the rection required to perform useful quantum com- model of quantum Turing machine is used for analysing putation. the complexity of quantum algorithms [21]. Quantum assembly language (QASM) – as- Another model used to describe quantum computers • sembly language extended by the set of instructions is Quantum Random Access Machine (QRAM). In this used in the quantum circuit model. model we have strictly distinguished the quantum part performing computation and the classical part, which is Quantum physical operations language (QC- • used to control computation. This model is used as a POL), which describes the execution of quantum basis for most quantum programming languages [78–80]. programme in a hardware-dependent way; it in- Among high-level programming languages designed for cludes physical operations and it operates on the quantum computers we can distinguish imperative and universal set of gates optimal for a given physical functional languages. implementation. At the moment of writing this paper the most advanced The authors of [65, 66] do not define a specific high- imperative quantum programming language is Quantum level quantum programming language. They point out, Computation Language (QCL) designed and implemen- ¨ however, that existing languages, mostly based on Dirac ted by Omer [61, 81, 82]. QCL is based on the syntax notation, do not provide the sufficient level of abstrac- of C programming language and provides many elements tion. They also stress, following [67], that it should known from classical programming languages. The in- have the basic set of features. We will discuss these terpreter is implemented using simulation library for ex- basic requirements in detail in Section III. At the mo- ecuting quantum programmes on classical computer, but ment quantum assembly language (QASM) is the most it can be in principle used as a code generator for classical interesting part of this architecture, since it is tightly machine controlling a quantum circuit. connected to the QRAM model. Along with QCL several other imperative quantum QASM should be powerful enough for representing programming languages were proposed. Notably Q Lan- high level quantum programming language and it should guage developed by Betteli [67, 74] and [83] allow for describing any quantum circuit. At the same have the ability to simulate noisy environment. Thus, time it must be implementation-independent so that it they can be used to study decoherence and analyse the could be used to optimise the execution of the programme impact of imperfections in quantum systems on the ac- with respect to different architectures. curacy of quantum algorithms. QASM uses qubits and cbits (classical bit) as basic Q Language [84] is implemented as a class library for units of information. Quantum operations consist of C++ programming language and libquantum is imple- unitary operations and measurement. Moreover, each mented as a C programming language library. Q Lan- unitary operator is expressed in terms of single qubit guage provides classes for basic quantum operations like gates and CNOT gates. QHadamard, QFourier, QNot, QSwap, which are derived In the architecture proposed in [66] each single-qubit from the base class Qop. New operators can be defined operation is stored as the triple of rationals. Each ra- using C++ class mechanism. Both Q Language and tional multiplied by π represents one of three Euler- libquantum share some limitation with QCL, since it is angles, which are sufficient to specify one-qubit opera- possible to operate on single qubits or quantum registers tion. (i.e. arrays of qubits) only. Thus, they are similar to packages for computer algebra systems used to simulate quantum computation [85, 86]. III. QUANTUM PROGRAMMING Concerning problems with physical implementations LANGUAGES of quantum computers, it became clear that one needs to take quantum errors into account when modelling Quantum algorithms [12, 14, 68, 69] and communica- quantum computational process. Also quantum com- tion protocols [6, 70, 71] are described using a language munication has become very promising application of of quantum circuits [53]. While this method is conveni- quantum information theory over the last few years. ent in the case of simple algorithms, it is very hard to Both facts are reflected in the design of new quantum operate on compound or abstract data types like arrays programming languages. or integers using this notation [19, 72]. LanQ developed by Mlnaˇr´ık was defined in [77, 87]. This lack of data types and control structures motiv- It provides syntax based on C programming language. ated the development of quantum pseudocode [60, 73] LanQ provides several mechanisms such as the creation 14 of a new process by forking and interprocess communic- A. Requirements for quantum programming ation, which support the implementation of multi-party language protocols. Moreover, operational semantics of LanQ has been defined. Thus, it can be used for the formal reas- Taking into account QRAM model described in Section oning about quantum algorithms. II C 2 we can formulate basic requirements which have to be fulfilled by any quantum programming language [74]. It is also worth to mention new quantum program- ming languages based on functional paradigm. Research Completeness: Language must allow to express in functional quantum programming languages started • any quantum circuit and thus enable the program- by introducing quantum lambda calculus [88]. It was in- mer to code every valid quantum programme writ- troduced in a form of simulation library for Scheme pro- ten as a quantum circuit. gramming language. QPL [89] was the first functional quantum programming language. This language is stat- Extensibility: Language must include, as its sub- ically typed and allows to detect errors at compile-time • set, the language implementing some high level rather than run-time. classical computing paradigm. This is important since some parts of quantum algorithms (for ex- A more mature version of QPL is cQPL — communic- ample Shor’s algorithm) require nontrivial classical ation capable QPL [75]. cQPL was created to facilitate computation. the development of new quantum communication proto- cols. Its interpreter uses QCL as a backend language so Separability: Quantum and classical parts of the cQPL programmes are translated into C++ code using • language should be separated. This allows to ex- QCL simulation library. ecute any classical computation on purely classical machine without using any quantum resources. Table III contains the comparison of several quantum programming languages. It includes the most import- Expressivity: Language has to provide high level ant features of existing languages. In particular we list • elements for facilitating the quantum algorithms the underlying mathematical model (i.e. pure or mixed coding. states) and the support for quantum communication. Independence: The language must be independ- All languages listed in Table III are universal and thus • ent from any particular physical implementation of they can be used to compute any function computable on a quantum machine. It should be possible to com- a quantum Turing machine. Consequently, all these lan- pile a given programme for different architectures guage provide the model of quantum computation which without introducing any changes in its source code. is equivalent to the model of a quantum Turing machine. As we will see, the languages presented in this Section In this section we compare the selected quantum fulfil most of the above requirements. The main problem programming languages and provide some examples of is the expressivity requirement. quantum algorithms and protocols implemented in these languages. We also describe their main advantages and limitations. We introduce the basic syntax of three of the B. Imperative quantum programming languages listed in Table III – QCL, LanQ and cQPL. This is motivated by the fact that these languages have First we focus on quantum programming languages a working interpreter and can be used to perform simu- which are based on the imperative paradigm. They in- lations of quantum algorithms. We introduce basic ele- clude quantum pseudocode, discussed in Section II C 2, ments of QCL required to understand basic programmes. Quantum Computation Language (QCL) created by We also compare the main features of the presented lan- Omer¨ [61, 81, 82] and LanQ developed by Mlnaˇr´ık guages. [76, 77, 87] The main problem with current quantum programming Below we provide an introduction to QCL. It is one languages is that they tend to operate on very low-level of the most popular quantum programming languages. structures only. In QCL quantum memory can be ac- Next, we introduce the basic elements of LanQ. This lan- cessed using only qreg data type, which represents the guage provides the support for quantum protocols. This array of qubits. In the syntax of cQPL data type qint fact reflects the recent progress in quantum communica- has been introduced, but it is only synonymous for the tion theory. array of 16 qubits. Similar situation exists in LanQ [87], where quantum data types are introduced using qnit keyword, where n represents a dimension of elementary 1. Quantum Computation Language unit (e.g. for qubits n = 2, for n = 3). How- ever, only unitary evolution and measurement can be QCL (Quantum Computation Language) [61, 81, 82] is performed on variables defined using one of these types. the most advanced implemented quantum programming 15

QCL Q Language QPL cQPL LanQ reference [81] [84] [89] [75] [87] implemented XXXXX formal semantics –– XXX communication ––– XX universal XXXXX mixed states –– XXX Table III. The comparison of quantum programming languages with information about implementation and basic features. Based on information from [75] and [87]. language. Its syntax resembles the syntax of C program- Using dump command it is possible to inspect the in- ming language [90] and classical data types are similar to ternal state of a quantum computer. This can be help- data types in C or Pascal. ful for checking if our algorithm changes the state of The basic built-in quantum data type in QCL is qureg quantum computer in the requested way. (quantum register). It can be interpreted as the array of One should note that dump operation is different from qubits (quantum bits). measurement, since it does not influence the state of qureg x1 [ 2 ] ; // 2− qubit quantum register x1 quantum machine. This operation can be realised using qureg x2 [ 2 ] ; // 2− qubit quantum register x2 simulator only. H( x1 ) ; // Hadamard operation on x1 a. Quantum memory management Quantum H( x2 [ 1 ] ) ; // and on the second qubit of x2 memory can be controlled using quantum types qureg, Listing 2. Basic operations on quantum registers and subre- quconst, quvoid and quscratch. Type qureg is used as gisters in QCL. a base type for general quantum registers. Other types allow for the optimisation of generated quantum circuit. QCL standard library provides standard quantum op- The summary of types defined in QCL is presented in erators used in quantum algorithms, such as: Table IV. b. Classical and quantum procedures and functions Hadamard H and Not operations on many qubits, QCL supports user-defined operators and functions • known from languages like C or Pascal. Classical sub- controlled not (CNot) with many target qubits and • routines are defined using procedure keyword. Also Swap gate, standard elements, known from C programming lan- rotations: RotX, RotY and RotZ, guage, like looping (e.g. for i=1 to n { ... }) and con- • ditional structures (e.g. if x==0 { ... }), can be used to phase (Phase) and controlled phase (CPhase). control the execution of quantum and classical elements. • In addition to this, it provides two types of quantum Most of them are described in Table II in Section II C 2. subroutines. Since QCL interpreter uses qlib simulation library, it The first type is used for unitary operators. Using is possible to observe the internal state of the quantum it one can define new operations, which in turn can be machine during the execution of quantum programmes. used to manipulate quantum data. For example operator The following sequence of commands defines two-qubit diffuse defined in Listing 3 defines inverse about the mean registers a and b and executes H and CNot gates on these operator used in Grover’s algorithm [14]. This allows to registers. define algorithms on the higher level of abstraction and qcl > qureg a [ 2 ] ; extend the library of functions available for a program- qcl > qureg b [ 2 ] ; mer. qcl > H( a ) ; Using subroutines it is easy to describe quantum al- [ 4 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |1 ,0 > + gorithms. Figure 10 presents QCL implementation of 0 . 5 |2 ,0 > + 0 . 5 |3 ,0 > Deutsch’s algorithm, along with the quantum circuit for qcl > dump this algorithm. This simple algorithm uses all main ele- : STATE: 4 / 32 qubits allocated , ments of QCL. It also illustrates all main ingredients of 28 / 32 qubits free existing quantum algorithms. 0 . 5 |0> + 0 . 5 |1> + 0 . 5 |2> + 0 . 5 |3> The second type of quantum subroutine is called a qcl > CNot(a[1] ,b) [ 4 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |1 ,0 > + 0 . 5 |2 ,0 > quantum function. Quantum functions are also called + 0 . 5 |3 ,0 > pseudo-classic operators. It can be defined using qufunct qcl > dump keyword. The subroutine of type qufunct is used for all : STATE: 4 / 32 qubits allocated , transformations of the form 28 / 32 qubits free 0 . 5 |0> + 0 . 5 |1> + 0 . 5 |2> + 0 . 5 |3> n = f(n) , (17) | i | i 16

Type Description Usage qureg general quantum register basic type quvoid register which has to be empty when operator is called target register quconst must be invariant for all operators used in quantum conditions quantum conditions quscratch register which has to be empty before and after the operator is temporary registers called

Table IV. Types of quantum registers used for memory management in QCL. where n is a base state and f is a one-to-one Boolean // conditional phase gate function.| i The example of quantum function is presented extern cond operator Phase ( real phi ) ; in Listing 5. // conditional not gate c. Quantum conditions QCL introduces quantum extern cond qufunct Not ( qureg q ) ; conditional statements, i.e. conditional constructions where quantum state can be used as a condition. QCL, as well as many classical programming lan- guages, provides the conditional construction of the form x H H i f be then | i O block y H where be is a Boolean expression and block is a sequence | i of statements. QCL provides the means for using quantum variables operator U( qureg x , qureg y ) { as conditions. Instead of a classical Boolean variable, the H( x ) ; variable used in condition can be a quantum register. Oracle(x,y); H( x & y ) ; qureg a [ 2 ] ; } qureg b [ 2 ] ; // the sequence of statements // classical control structure //... procedure deutsch ( ) { // perform CNot if a=|1 ... 1i // allocate 2 qubits i f a { qureg x [ 1 ] ; CNot(b[0], b[1]); qureg y [ 1 ] ; } int m; Listing 4. Example of a quantum conditional statement in // evaluation loop QCL { // initialise machine state In this situation QCL interpreter builds and executes reset ; the sequence of CNOT gates equivalent to the above // do unitary computation condition. Here register a is called enable register. U( x , y ) ; In addition, quantum conditional structures can be // measure 2nd register used in quantum subroutines. Quantum operators and measure y ,m; functions can be declared as conditional using cond // value in 1st register valid? keyword. For example } until m==1; // measure 1st register which measure x ,m; operator d i f f u s e ( qureg q ) { // contains g(0) xor g(1) H( q ) ; // Hadamard Transform print ”g ( 0 ) xor g ( 1 ) =” ,m; Not ( q ) ; // I n v e r t q // c lean up CPhase(pi ,q); // Rotate if q=1111.. reset ; ! Not ( q ) ; // undo inversion } !H( q ) ; // undo Hadamard Transform } Listing 3. The implementation of the inverse about the mean Figure 10. Quantum circuit for Deutsch’s algorithm and QCL operation in QCL [61]. Constant pi represents number π. implementation of this algorithm (see [61] for more examples). Exclamation mark ! is used to indicate that the interpreter Evaluation loop is composed of preparation (performed by should use the inverse of a given operator. Operation diffuse reset instruction), unitary evolution (U(x,y) operator) and is used in the quantum search algorithm [14]. measurement. Subroutine Oracle() implements function used in Deutsch’s algorithm [42, 91]. 17 declares a conditional Phase gate and a controlled NOT situation enable register is empty and, as such, ignored. gate. Keyword extern indicates that the definition of Subroutine call is in this case unconditional. a subroutine is specified in an external file. The enable register (i.e. quantum condition) is passed as an implicit parameter if the operator is used within the body of a 2. LanQ quantum if-statement. Imperative language LanQ is the first quantum pro- // increment register gramming language with full operation semantics spe- cond qufunct i n c ( qureg x ) { cified [87]. int i ; Its main feature is the support for creating multipart- for i = #x−1 to 0 step −1 { ite quantum protocols. LanQ, as well as cQPL presented // apply controlled −not from MSB to LSB in the next section, are built with quantum communic- CNot(x[i],x[0:: i ]); } ation in mind. Thus, in contrast to QCL, they provide } the features for facilitating simulation of quantum com- munication. // equivalent implementation Syntax of the LanQ programming language is very sim- // with constant enable register ilar to the syntax of C programming language. In par- // conditional increment as selection operator ticular it supports: qufunct c i n c ( qureg x , quconst e ) { int i ; Classical data types: int and void. • for i = #x−1 to 0 step −1 { Conditional statements of the form CNot(x[i],x[0::i] & e); • } i f ( cond ) { } ... Listing 5. Operator for incrementing quantum state in QCL } else { defined as a conditional quantum function. Subroutine inc is ... defined using cond keyword and does not require the second } argument of type quconst. Subroutine cinc provides equi- valent implementation with explicit-declared enable register. Looping with while keyword • while ( cond ) { In the case of inc procedure, presented in Listing 5, the ... enable register is passed as an implicit argument. This } argument is set by a quantum if-statement and trans- parently passed on to all suboperators. As a result, all User-defined functions, for example suboperators have to be conditional. This is illustrated • by the following example [61] int fun ( int i ) { int r e s ; // counting and control registers ... qcl > qureg q [ 4 ] ; qureg e [ 1 ] ; return r e s ; // prepare test state } qcl > H( q [ 3 ] & e ) ; [ 5 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |8 ,0 > + 0 . 5 |0 ,1 > + 0 . 5 |8 ,1 > a. Process creation LanQ is built around the con- // conditional increment cepts of process and interprocess communication, known qcl > c i n c ( q , e ) ; for example from UNIX operating system. It provides the [ 5 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |8 ,0 > + 0 . 5 |1 ,1 > support for controlling quantum communication between + 0 . 5 |9 ,1 > many parties. The implementation of teleportation pro- // equivalent to cinc(q,e) tocol presented in Listing 6 provides an example of LanQ qcl > i f e { i n c ( q ) ; } features, which can be used to describe quantum commu- [ 5 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |8 ,0 > + 0 . 5 |2 ,1 > nication. + 0 . 5 |10 ,1 > Function main() in Listing 6 is responssible for con- // conditional decrement trolling quantum computation. The execution of pro- qcl > !cinc(q,e); [ 5 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |8 ,0 > + 0 . 5 |1 ,1 > tocol is divided into the following steps: + 0 . 5 |9 ,1 > 1. Creation of the classical channel for communicating // equivalent to !cinc(q,e); the results of measurement: qcl > i f e { ! i n c ( q ) ; } [ 5 / 3 2 ] 0 . 5 |0 ,0 > + 0 . 5 |8 ,0 > + 0 . 5 |0 ,1 > channel[int] c withends [c0,c1];. + 0 . 5 |8 ,1 > 2. Creation of Bell state used as a Finally we should note that a conditional subroutine for teleporting a quantum state can be called outside a quantum if-statement. In such (psiEPR aliasfor [psi1, psi2]); this is accomplished 18

by calling external function createEPR() creating an b. Communication Communication between parties entangled state. is supported by providing send and recv keywords. Com- munication is synchronous, i.e. recv delays programme 3. Instruction fork executes alice () function, which is execution until there is a value received from the channel used to implement sender; original process contin- and send delays a programme run until the sent value is ues to run. received. Processes can allocate channels. It should be stressed 4. In the last step function bob() implementing a re- that the notion of channels used in quantum program- ceiver is called. ming is different from the one used in quantum mech- anics. In quantum programming a channel refers to a variable shared between processes. In quantum mechan- void a l i c e (channelEnd [ int ] c0 , ics a channel refers to any quantum operation. qbit auxTeleportState) { Another feature used in quantum communication is int i ; variable aliasing. In the teleportation protocol presented qbit phi ; in Listing 6 the syntax for variable aliasing // prepare state to be teleported phi = computeSomething(); qbit psi1 , p s i 2 ; // Bell measurement psiEPR a l i a s f o r [psi1, psi2]; i = measure (BellBasis , phi, is used to create quantum state shared among two auxTeleportState ); parties. send ( c0 , i ) ; c. Types Types in LanQ are used to control the sep- } aration between classical and quantum computation. In void bob (channelEnd [ int ] c1 , particular they are used to prohibit copying of quantum qbit stateToTeleportOn) { registers. The language distinguishes two groups of vari- int i ; ables [87, Chapter 5]: i = recv ( c1 ) ; Duplicable or non-linear types for representing clas- // execute one of the Pauli gates • // according to the protocol sical values, e.g. bit, int, boolean. The value of a i f ( i == 1) { duplicable type can be exactly copied. Sigma z(stateToTeleportOn ); Non-duplicable or linear types for controlling } else i f ( i == 2) { • Sigma x(stateToTeleportOn ); quantum memory and quantum resources, e.g. } else i f ( i == 3) { qbit, qtrit channels and channel ends (see example Sigma x(stateToTeleportOn ); in Listing 6). Types from this group do not allow Sigma z(stateToTeleportOn ); for cloning [92]. } dump q(stateToTeleportOn ); One should note that quantum types defined in LanQ } are mainly used to check validity of the program before its run. However, such types do not help to define abstract void main ( ) { operations. As a result, even simple arithmetic opera- channel [ int ] c withends [ c0 , c1 ] ; tions have to be implemented using elementary quantum qbit psi1 , p s i 2 ; gates, e.g. using quantum circuits introduced in [93]. psiEPR a l i a s f o r [psi1, psi2];

psiEPR = createEPR(); C. Functional quantum programming – QPL and cQPL c = new channel [ int ](); fork alice(c0, psi1); bob(c1, psi2); During the last few years few quantum programming } languages based on functional programming paradigm have been proposed [94]. As we have already point out, Listing 6. Teleportation protocol implemented in LanQ [87]. Functions Sigma x(), Sigma y() and Sigma z() are respons- the lack of progress in creating new quantum algorithms ible for implementing Pauli matrices. Function createEPR() is caused by the problems with operating on complex (not defined in the listing) creates maximally entangled state quantum states. Classical functional programming lan- between parties — Alice and Bob. Quantum communication guages have many features which allow to clearly express is possible by using the state, which is stored in a global vari- algorithms [41]. In particular they allow for writing bet- able psiEPR. Function computeSomething() (not defined in ter modularised programmes than in the case of imperat- the listing) is responsible for preparing a state to be teleported ive programming languages [95]. This is important since by Alice. this allows to debug programmes more easily and re- use software components, especially in large and complex software projects. 19

Quantum functional programming attempts to merge Procedure call has to know the number of parameters re- the concepts known from classical function programming turned by the procedure. If, for example, procedure test with quantum mechanics. The program in functional is defined as above, it is possible to gather the calculated programming language is written as a function, which results is defined in terms of other functions. Classical func- new int a1 = 0 ; tional programming languages contain no assignment new int cv = 0 ; statements, and this allows to eliminate side-effects.[96] new int qv = 0 ; It means that function call can have no effect other than ( a1 ) := c a l l test(cv, qv); to compute its result [95]. In particular it cannot change the value of a global variable. or ignore them The first attempts to define a functional quantum pro- c a l l test(cv, qv); gramming language were made by using quantum lambda calculus [88], which was based on lambda calculus. For In the first case the procedure returns the values of input the sake of completeness we can also point out some re- variables calculated at the end of its execution. search on modelling quantum computation using Haskell Classical variables are passed by value i.e. their value programming language [97, 98]. However, here we focus is copied. This is impossible for quantum variable, since on high-level quantum programming languages. Below a quantum state cannot be cloned [92]. Thus, it is also we present recently proposed languages QPL and cQPL, impossible to assign the value of quantum variable cal- which are based on functional paradigm. They aim to culated by procedure. provide mechanisms known from programming languages Note that no cloning theorem requires quantum vari- like Haskell [99] to facilitate the modelling of quantum ables to be global. This shows that in quantum case it computation and quantum communication. is impossible to avoid some effects known from imperat- In [89] Quantum Programming Language (QPL) was ive programming and typically not present in functional described and in [75] its extension useful for modelling programming languages. of quantum communication was proposed. This exten- Global quantum variables are used in Listing 9 to ded language was name cQPL – communication capable create a maximally entangled state in a teleportation QPL. Since cQPL compiler is also QPL compiler, we will protocol. Procedure createEPR(epr1, epr2) operates on describe cQPL only. two quantum variables (subsystems) and produces a Bell The compiler for cQPL language described in [75] is state. built on the top of libqc simulation library used in QCL interpreter. As a result, cQPL provides some features known from QCL. Quantum elements Classical elements of cQPL are very similar to classical elements of QCL and LanQ. In particular cQPL provides Quantum memory can be accessed in cQPL using vari- conditional structures and loops introduced with while ables of type qbit or qint. Basic operations on quantum keyword. registers are presented in Listing 8. In particular, the new int loop := 1 0 ; execution of quantum gates is performed by using ∗= while ( loop > 5) do { operator. print loop ; new qbit q1 := 0 ; loop := loop − 1 ; new qbit q2 := 1 ; } ; // execute CNOT gate on both qubits i f ( loop = 3) then { q1 , q2 ∗= CNot ; print ” loop i s equal 3” ; // execute phase gate on the first qubit } else { q1 ∗= Phase 0 . 5 ; print ” loop i s not equal 3” ; } ; Listing 8. State initialisation and basic gates in cQPL. Data type qbit represents a single qubit. Listing 7. Classical control structures in cQPL. It should be pointed out that qint data type provides only a shortcut for accessing the table of qubits. Only a few elementary quantum gates are built into Procedures the language:

Single qubit gates H, Phase and NOT implementing Procedures can be defined to improve modularity of • basic gates listed in Table II in Section II C 2. programmes. proc t e s t : a : int , q : qbit { CNOT operator implementing controlled negation • ... and FT(n) operator for n-qubit quantum Fourier } transform. 20

This allows to simulate an arbitrary quantum computa- measurement results to Bob ∗/ tion. Besides, it is possible to define gates by specifying send m1, m2 to Bob ; their matrix elements. } ; Measurement is performed using measure/then keywords and print command allows to display the value module Bob { receive q : qbit from A l i c e ; of a variable. receive m1: bit , m2: bit from Bob ; measure a then { print ”a i s |0>”; i f (m1 = 1) then { q ∗= [[ 0,1,1,0 ]]; } else { /∗ Apply sigma x ∗/ } ; print ”a i s |1>”; } ; i f (m2 = 1) then { q ∗= [ [ 1 ,0 ,0 , −1 ] ] ; /∗ Apply sigma z ∗/ } ; In similar manner like in QCL, it is also possible to inspect the value of a state vector using dump command. /∗ The state is now teleported ∗/ dump q ; } ; Quantum communication Listing 9. Teleportation protocol implemented in cQPL (from [75]). Two parties – Alice and Bob – are described by The main feature of cQPL is its ability to build and modules. Modules in cQPL are introduced using module test quantum communication protocols easily. Commu- keyword. nicating parties are described using modules. In analogy to LanQ, cQPL introduces channels, which can be used to send quantum data. Once again we stress that notion of channels used in cQPL and LanQ is different from IV. SUMMARY that used in quantum theory. Quantum mechanics intro- duces channels to describe allowed physical transforma- The main goal of this paper is to acquaint the reader tions, while in quantum programming they are used to with quantum programming languages and computa- describe communication links. tional models used in quantum information theory. We Communicating parties are described by modules, in- have described a quantum Turing machine, quantum cir- troduced using module keyword. Modules can exchange cuits and QRAM models of quantum computation. We quantum data (states). This process is accomplished us- have also presented three quantum programming lan- ing send and receive keywords. guages – namely QCL, LanQ and cQPL. To compare cQPL and LanQ one can use the imple- First we should note that the languages presented in mentation of the teleportation protocol. The implement- this paper provide very similar set of basic quantum gates ation of teleportation protocol in cQPL is presented in and allow to operate only on the arrays of qubits. Most of Listing 9, while the implementation in LanQ is provided the gates provided by these languages correspond to the in Listing 6. basic quantum gates presented in Section II C 2. Thus, module A l i c e { one can conclude that the presented languages have the proc createEPR: a: qbit , b : qbit { ability to express quantum algorithms similar to the abil- a ∗= H; ities of a quantum circuit model. b , a ∗= CNot ; The biggest advantage of quantum programming lan- /∗ b: Control, a: Target ∗/ guages is their ability to use classical control structures } in { for controlling the execution of quantum operators. This new qbit teleport := 0; is hard to achieve in quantum circuits model and it re- new qbit epr1 := 0 ; new qbit epr2 := 0 ; quires the introduction of non-unitary operations to this model. In addition, LanQ and cQPL provide the syntax c a l l createEPR(epr1 , epr2); for clear description of communication protocols. send epr2 to Bob ; The syntax of presented languages resembles the syn- tax of popular classical programming languages from the /∗ teleport: Control, epr1: Target C programming language family [90]. As such, it can (see: Figure 7) ∗/ be easily mastered by programmers familiar with clas- teleport , epr1 ∗= CNot ; sical languages. Moreover, the description of quantum algorithms in quantum programming languages is bet- new bit m1 := 0 ; new bit m2 := 0 ; ter suited for people unfamiliar with the notion used in m1 := measure t e l e p o r t ; quantum mechanics. m2 := measure epr1 ; The main disadvantage of described languages is the lack of quantum data types. The types defined in de- /∗ Transmit the classical scribed languages are used mainly for two purposes: 21

To avoid compile-time errors caused by copying of acknowledge interesting discussions with P. Gawron, • quantum registers (cQPL and LanQ). B. Omer,¨ I. Glendinning and H. Mlnaˇr´ık. The author is also grateful to the anonymous referee for well formu- Optimisation of memory management (QCL). • lated and interested remarks concerning the functional Both reasons are important from the simulations point quantum programming languages. of view, since they facilitate writing of correct and op- timised quantum programmes. However, these features do not provide a mechanism for developing new quantum algorithms or protocols.

This work was supported by the Polish National Sci- ACKNOWLEDGMENTS ence Centre under the grants number N N516 475440, N N516 481840 and by the Polish Ministry of Science The author would like to thank W. Mauerer for and Higher Education under the grant number N N519 providing preliminary version of his cQPL compiler and 442339.

[1] D. Bouwmeester, A. Ekert, and A. Zeilinger (Eds.). bordy, S. Robyr, L. Salvail, A. W. Sharpe, A. J. Shields, The Physics of Quantum Information: Quantum Crypto- D. Stucki, M. Suda, C. Tamas, T. Themel, R. T. Thew, graphy, Quantum Teleportation, Quantum Computation. Y. Thoma, A. Treiber, P. Trinkler, R. Tualle-Brouri, Springer-Verlag, Berlin, Germany (2000). F. Vannel, N. Walenta, H. Weier, H. Weinfurter, I. Wim- [2] T. Ladd, F. Jelezko, R. Laflamme, Y. Nakamura, C. Mon- berger, Z. L. Yuan, H. Zbinden, and A. Zeilinger. “The roe, and J. O’Brien. “Quantum computers”. Nature 464, SECOQC network in Vienna”. 45–53 (2010). New Journal of Physics 11 (7), 075001 (2009). [3] G. E. Moore. “Cramming More Components Onto In- [12] P. W. Shor. “Algorithms for quantum computation: Dis- tegrated Circuits”. Electronics 38 (8), 114–117 (1965). crete logarithms and factoring”. In Proceedings of the [4] Intel Corporation. “Moores Law: Intel 35th Annual Symposium on Foundations of Computer Chart” (2005). URL http://intel. Science, pages 124–134. IEEE Computer Society Press com/pressroom/kits/events/moores_law_40th/. (1994). [5] R. P. Feynman. “Simulating Physics with Computers”. [13] P. Shor. “Polynomial-time algorithms for prime factoriz- Int. J. Theor. Phys. 21 (6/7), 467–488 (1982). ation and discrete logarithms on a quantum computers”. [6] C. H. Bennett and G. Brassard. “Quantum crypto- SIAM J. Computing 26, 1484–1509 (1997). graphy: public key distribution and coin tossing”. In Pro- [14] L. K. Grover. “Quantum Mechanics Helps in Searching ceedings of the IEEE International Conference on Com- for a Needle in a Haystack”. Phys. Rev. Lett. 79, 325–328 puters, Systems, and Signal Processing, Bangalore, In- (1997). dia, pages 175–179 (1984). [15] J. Eisert, M. Wilkens, and M. Lewenstein. “Quantum [7] A. Ekert. “ based on Bell’s the- Games and Quantum Strategies”. Phys. Rev. Lett. 83, orem”. Phys. Rev. Lett. 67, 661–663 (1991). 3077–3080 (1999). [8] A. Einstein, B. Podolsky, and N. Rosen. “Can Quantum- [16] D. Meyer. AMS Contemporary Mathematics: Quantum Mechanical Description of Physical Reality Be Con- Computation and Quantum Information Science, vol. sidered Complete?” Phys. Rev. 47 (10), 777–780 (1935). 305, chap. Quantum games and quantum algorithms. [9] J. Bouda. Encryption of Quantum Information and American Mathematical Society, Providence, Rhode Is- Quantum Cryptographic Protocols. Ph.D. thesis, Faculty land, U.S.A. (2000). of Informatics, Masaryk University (2004). [17] J. Kempe. “Quantum random walks: An introductory [10] R. Ursin, F. Tiefenbacher, T. Schmitt-Manderbach, overview”. Contemp. Phys. 44 (4), 307–327 (2003). H. Weier, T. Scheidl, M. Lindenthal, B. Blauensteiner, [18] J. Koˆs´ık.“Two models of quantum random walk”. Cent. T. Jennewein, J. Perdigues, P. Trojek, B. Omer,¨ Eur. J. Phys. 4, 556–573 (2003). M. F¨urst,M. Meyenburg, J. Rarity, Z. Sodnik, C. Bar- [19] P. W. Shor. “Progress in quantum algorithms”. Quantum bieri, H. Weinfurter, and A. Zeilinger. “Entanglement- Information Processing 3 (1-5) (2004). based quantum communication over 144 km”. Nature [20] S. J. Lomonaco and L. Kauffman. “Search for New Physics 3, 481–486 (2007). Quantum Algorithms”. Tech. Rep. F30602-01-2-0522, [11] M. Peev, C. Pacher, R. All´eaume,C. Barreiro, J. Bouda, Defense Advanced Research Projects Agency (DARPA) W. Boxleitner, T. Debuisschert, E. Diamanti, M. Dianati, and Air Force Research Laboratory, Air Force Materiel J. F. Dynes, S. Fasel, S. Fossier, M. F¨urst,J. D. Gautier, Command, USAF (2005). URL http://www.cs.umbc. O. Gay, N. Gisin, P. Grangier, A. Happe, Y. Hasani, edu/~lomonaco/qis/DARPA-FINAL-RPT.pdf. M. Hentschel, H. H¨ubel, G. Humer, T. L¨anger,M. Legr´e, [21] E. Bernstein and U. Vazirani. “Quantum Complexity R. Lieger, J. Lodewyck, T. Lor¨unser,N. L¨utkenhaus, Theory”. SIAM J. Computing 26 (5), 1411–1473 (1997). A. Marhold, T. Matyus, O. Maurhart, L. Monat, [22] L. Fortnow. “One complexity theorist’s view of quantum S. Nauerth, J. B. Page, A. Poppe, E. Querasser, G. Ri- computing”. Theor. Comput. Sci. 292 (3), 597–610 22

(2003). Press (1993). [23] E. Klarreich. “Playing by quantum rules”. Nature 414, [46] H. Nishimura and M. Ozawa. “Computational complex- 244–245 (2001). ity of uniform quantum circuit families and quantum Tur- [24] C. F. Lee and N. F. Johnson. “Game-theoretic discussion ing machines”. Theor. Comput. Sci. 276, 147–181 (2002). of quantum state estimation and cloning”. Phys. Lett. A [47] U. Vazirani. “A Survey of Quantum Complexity The- 319 (5-6), 429–433 (2003). ory”. Proc. Sympos. Appl. Math. 58 (2002). [25] A. Ambainis. “Quantum walk algorithm for element dis- [48] M. R. Garey and D. S. Johnson. Computers and Intract- tinctness”. SIAM Journal on Computing 37, 210–239 ability: A Guide to the Theory of NP-Completeness. W. (2007). H. Freeman (1979). [26] A. M. Childs and J. M. Eisenberg. “Quantum algorithms [49] U. Zwick. “Scribe notes of the course Boolean Circuit for subset finding”. Quantum. Inf. Comput. 5, 593 (2005). Complexity” (1995). URL http://www.cs.tau.ac.il/ [27] A. M. Childs and J. Goldstone. “Spatial search by ~zwick/scribe-boolean.html. quantum walk”. Phys. Rev. A 70 (2), 022314.1 (2004). [50] M. Hirvensalo. Quantum computing. Springer-Verlag, [28] A. M. Childs. “Universal Computation by Quantum Berlin, Germany (2001). Walk”. Phys. Rev. Lett. 102 (18), 180501 (2009). [51] D. Deutsch. “Quantum Computational Networks”. Proc. [29] A. P. Hines and P. C. E. Stamp. “Quantum walks, R. Soc. Lond. A 425, 73 (1989). quantum gates, and quantum computers”. Phys. Rev. [52] T. Toffoli. “Bicontinuous extension of reversible combin- A 75 (6), 062321 (2007). atorial functions”. Math. Syst. Theory 14, 13–23 (1981). [30] A. Ambainis. “Quantum walks and their algorithmic ap- [53] M. A. Nielsen and I. L. Chuang. Quantum Computation plications”. Int. J. Quant. Inf. 1, 507–518 (2003). and Quantum Information. Cambridge University Press, [31] M. Santha. “Quantum walk based search algorithms”. In Cambridge, U.K. (2000). 5th Theory and Applications of Models of Computation [54] A. Barenco, C. H. Bennett, R. Cleve, D. P. DiVincenzo, (TAMC08), Xian, April 2008, vol. 4978 of LNCS, pages N. Margolus, P. Shor, T. Sleator, J. Smolin, and H. Wein- 31–46 (2008). furter. “Elementary gates for quantum computation”. [32] S. E. Venegas-Andraca. “Introduction to special issue: Phys. Rev. A 52, 3457 (1995). Physics and computer science – quantum computation [55] D. Deutsch, A. Barenco, and A. Ekert. “Universality in and other approaches”. Math. Struct. Comp. Sci. 20 (6), Quantum Computation”. Proc. R. Soc. Lond. 449 (1937), 995–997 (2010). 669–677 (1995). [33] M. Mosca and J. Smith. “Algorithms for Quantum Com- [56] V. V. Shende, I. L. Markov, and S. S. Bullock. “Min- puters”. In Handbook of Natural Computing, Springer imal universal two-qubit controlled-NOT-based circuits”. Reference. Springer Verlag, Berlin, Germany (2011). Phys. Rev. A 69, 062321 (2004). [34] A. Childs and W. van Dam. “Quantum algorithms for [57] M. M¨ott¨onen,J. J. Vartiainen, V. Bergholm, and M. M. algebraic problems”. Rev. Mod. Phys. 82 (1), 1–52 (2010). Salomaa. “Quantum Circuits for General Multiqubit [35] C. H. Papadimitriou. Computational complexity. Gates”. Phys. Rev. Lett. 93 (13), 130502 (2004). Addison-Wesley Publishing Company (1994). [58] J. J. Vartiainen, M. Mottonen, and M. M. Salomaa. “Effi- [36] S. A. Cook and R. A. Reckhow. “Time-bounded Random cient decomposition of quantum gates”. Phys. Rev. Lett. Access Machines”. In Proceeedings of the forth Annual 92, 177902 (2004). ACM Symposium on Theory of Computing, pages 73–80 [59] S. Aaronson and D. Gottesman. “Improved simulation of (1973). stabilizer circuits”. Phys. Rev. A 70 (5), 052328 (2004). [37] J. C. Shepherdson and H. E. Strugis. “Computability of [60] E. Knill. “Conventions for quantum pseudocode”. Tech. Recursive Functions”. J. ACM 10 (2), 217–255 (1963). Rep. LAUR-96-2724, Los Alamos National Laboratory [38] H. Vollmer. Introduction to Circuit Complexity. Springer- (1996). Verlag, Berlin, Heidelberg, Germany (1999). [61] B. Omer.¨ Structured Quantum Programming. Ph.D. [39] A. Church. “An unsolvable problem of elementary num- thesis, Vienna University of Technology (2003). ber theory”. American Journal of Mathematics 58, 345– [62] R. Nagarajan, N. Papanikolaou, and D. Williams. “Sim- 363 (1936). ulating and Compiling Code for the Sequential Quantum [40] H. Abelson, G. J. Sussman, and J. Sussman. Structure Random Access Machine”. Electronic Notes in Theoret- and Interpretation of Computer Programs. MIT Press, ical Computer Science 170, 101–124 (2007). Cambridge, Massachusetts, U.S.A., 2nd ed. (1996). URL [63] R. Cleve and D. P. DiVincenzo. “Schumacher’s quantum http://mitpress.mit.edu/sicp/. data compression as a quantum computation”. Phys. [41] J. C. Mitchell. Concepts in programming languages. Cam- Rev. A 54 (4), 2636–2650 (1996). bridge University Press, Cambridge, U.K. (2003). [64] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. [42] D. Deutsch. “Quantum theory, the Church-Turing prin- Introduction to Algorithms. The MIT Press, 2nd ed. ciple and the universal quantum computer”. Proc. R. (2001). Soc. Lond. A 400, 97 (1985). [65] K. M. Svore, A. W. Cross, A. V. Aho, I. L. Chuang, [43] C. Bohm. “On a family of Turing machines and the and I. L. Markov. “Toward a Software Architecture related programming language”. ICC Bull. 3, 187–194 for Quantum Computing Design Tools”. In P. Selinger (1964). (Ed.), Proceedings of the 2nd International Workshop on [44] S. Aaronson and G. Kuperberg. “Complexity ZOO” Quantum Programming Languages (2004). (2010). URL http://qwiki.stanford.edu/index.php/ [66] K. M. Svore, A. W. Cross, I. L. Chuang, A. V. Aho, Complexity_Zoo. and I. L. Markov. “A Layered Software Architecture for [45] A. Yao. “Quantum Circuit Complexity”. In Proceedings Quantum Computing Design Tools”. Computer 39 (1), of the 34th IEEE Symposium on Foundations of Com- 74–83 (2006). puter Science, pages 352–360. IEEE Computer Society 23

[67] S. Bettelli. Toward an architecture for quantum program- [84] S. Bettelli, L. Serafini, and T. Calarco. “Toward an ar- ming. Ph.D. thesis, Universit`adi Trento (2002). chitecture for quantum programming”. Eur. Phys. J. D [68] L. K. Grover. “Quantum computers can search rapidly 25 (2), 181–200 (2003). by using almost any transformation”. Phys. Rev. Lett. [85] J. A. Miszczak and P. Gawron. “Numerical simulations 80, 4329–4332 (1998). of mixed states quantum computation”. Int. J. Quant. [69] M. Mosca. Quantum Computer Algorithms. Ph.D. thesis, Inf. 3 (1), 195–199 (2005). Wolfson College, University of Oxford (1999). [86] P. Gawron, J. Klamka, J. Miszczak, and R. Winiarczyk. [70] C. Bennett and S. Wiesner. “Communication via one- “Extending scientic computing system with structural and two-particle operators on Einstein-Podolsky-Rosen quantum programming capabilities”. Bull. Pol. Acad. states”. Phys. Rev. Lett. 69, 2881–2884 (1992). Sci.-Tech. Sci. 58 (1), 77–88 (2010). [71] G. Brassard, A. Broadbent, and A. Tapp. “Quantum [87] H. Mlnaˇr´ık.“LanQ – Operational Semantics of Quantum Pseudo-Telepathy”. Found. Phys. 35, 1877–1907 (2005). Programming Language LanQ”. Tech. Rep. FIMU-RS- [72] D. Bacon and W. van Dam. “Recent Progress in 2006-10, Masaryk University (2006). Quantum Algorithms”. Commun. ACM 53 (2), 84–93 [88] A. van Tonder. “A Lambda Calculus for Quantum Com- (2010). putation”. SIAM J. Comput. 33 (5), 1109–1135 (2004). [73] E. H. Knill and M. A. Nielsen. Encyclopedia of Mathem- [89] P. Selinger. “Towards a Quantum Programming Lan- atics, Supplement III, chap. Theory of quantum compu- guage”. Math. Struct. Comput. Sci. 14 (4), 527–586 tation. Kluwer (2002). (2004). [74] S. Bettelli, L. Serafini, and T. Calarco. “Toward an ar- [90] B. W. Kernighan and D. M. Ritchie. C Programming chitecture for quantum programming”. Eur. Phys. J. D Language. Prentice Hall, Upper Saddle River, N.J., 25 (2), 181–200 (2003). U.S.A., 2nd ed. (1988). [75] W. Mauerer. Semantics and Simulation of Communica- [91] D. Deutsch and R. Jozsa. “Rapid solution of problems tion in Quantum Programming. Master’s thesis, Univer- by quantum computation”. Proc Roy Soc Lond A 439, sity Erlangen-Nuremberg (2005). 553–558 (1992). [76] H. Mlnaˇr´ık. Operational Semantics and Type Soundness [92] W. K. Wootters and W. H. Zurek. “A single quantum of Quantum Programming Language LanQ. Ph.D. thesis, cannot be cloned”. Nature 299, 802–803 (1982). Masaryk University (2007). [93] V. Vedral, A. Barenco, and A. Ekert. “Quantum net- [77] H. Mlnaˇr´ık.“Semantics Of Quantum Programming Lan- works for elementary arithmetic operations”. Phys. Rev. guage LanQ”. Int. J. Quant. Inf. 6 (1, Supp.), 733–738 A 54, 147–153 (1996). (2008). [94] P. Selinger. “A Brief Survey of Quantum Programming [78] S. Gay. “Quantum Programming Languages: Survey and Languages”. In Proceedings of the 7th International Sym- Bibliography”. Math. Struct. Comput. Sci. 16 (4) (2006). posium on Functional and Logic Programming, vol. 2998 [79] D. Unruh. “Quantum programming languages”. Inform- of LNCS, pages 1–6 (2004). atik – Forschung und Entwicklung 21 (1–2), 55–63 (2006). [95] J. Hughes. “Why Functional Programming Matters”. [80] R. R¨udiger. “Quantum Programming Languages: An Comput. J. 32 (2), 98–107 (1989). Introductory Overview”. Comput. J 50 (2), 134–150 [96] This is true in pure functional programming languages (2007). like Haskell. [81] B. Omer.¨ A Procedural Formalism for Quantum Com- [97] A. Sabry. “Modeling quantum computing in Haskell”. In puting. Master’s thesis, Vienna University of Technology ACM SIGPLAN Haskell Workshop (2003). (1998). [98] J. Karczmarczuk. “Structure and interpretation of [82] B. Omer.¨ Quantum Programming in QCL. Master’s quantum mechanics: a functional framework.” In Pro- thesis, Vienna University of Technology (2000). ceedings of the ACM SIGPLAN workshop on Haskell, [83] H. Weimer. “The C library for quantum computing and pages 50–61. ACM Press (2003). quantum simulation version 1.1.0” (2010). URL http: [99] G. Hutton. Programming in Haskell. Cambridge Univer- //www.libquantum.de/. sity Press, Cambridge, U.K. (2007).