**Quantum Programming Language** is a programming language, which can be used to write programmes for quantum computer.

Since every quantum machine has to be controlled by classical device, existing quantum programming languages incorporate classical control structures such as loops and conditional execution and allow to operate on classical and quantum data.

### Imperative quantum programming

#### Quantum pseudocode

Quantum pseudocode proposed by E. Knill is the first formalised language for description of quantum algorithms was introduced and, moreover, it was tightly connected with model of quantum machine called Quantum Random Access Machine (QRAM).

#### Quantum Computing Language

QCL (Quantum Computer Language) is the most advanced implemented quantum programming language. Its syntax resambles syntax of the C programming language and classical data types are similar to data types in C.

The basic built-in quantum data type in QCL is qreg (quantum register). It can be interpreted as a an array of qubits (quantum bits).

```
qureg x1[2]; // 2-qubit quantum register x1
qureg x2[2]; // 2-qubit quantum register x2
H(x1); // Hadamard operation on x1
H(x2[1]); // Hadamard operation on the first qubit of the register x1
```

Since qcl interpreter uses qlib simulation library, it is possible to observe internal state of the quantum machine during execution of the quantum programme.

```
qcl> dump
: STATE: 4 / 32 qubits allocated, 28 / 32 qubits free
0.35355 |0> + 0.35355 |1> + 0.35355 |2> + 0.35355 |3>
+ 0.35355 |8> + 0.35355 |9> + 0.35355 |10> + 0.35355 |11>
```

Note that dump operation is diffrent from measurement, since it does not influence the state of the quantum machine and can be realised only using simulator.

QCL standard library provides standard quantum operators used in quantum algorithms such as:

- controlled-not with many target qubits,
- Hadamard operation on many qubits,
- parse and controlled phase.

But the most important feature of QCL is the support for used defined operators and functions. Like in modern programming languages, it is possible to define new operations which can be used to manipulate quantum data. For example

```
operator diffuse(qureg q) {
H(q); // Hadamard Transform
Not(q); // Invert q
CPhase(pi,q); // Rotate if q=1111..
!Not(q); // undo inversion
!H(q); // undo Hadamard Transform
}
```

defines inverse about the mean operator used in Grover's algorithm. This allows to define algorithms on higher level of abstraction and extend library of function available for programmer.

#### Q Language

Q Language is the second implemented imperative quantum programming language.

Q Language was implemented as an extension of C++ programming language. It provides classes for basic quantum operations like QHadamard, QFourier, QNot, QSwap and QSwap, which are derived from the base class Qop. New operators can be defined using C++ class mechanism.

Quantum memory is represented by class Qreg.

```
Qreg x1(); // 1-qubit quantum register with initial value 0
Qreg x2(2,0); // 2-qubit quantum register with initial value 0
```

Computation process is executed using provided simulator. Noisy environment can be simulated using parameters of the simulator.

#### qGCL

Quantum Guarded Command Language (qGCL) was defined by P. Zuliani in his PhD thesis. It is based on Guarded Command Language created by Edsger Dijkstra.

It can be described as a language of quantum programmes specification.

### Functional quantum programming

During the last few years many quantum programming languages based on functional programming paradigm where proposed. Classical functional programming languages have many adventages which allow to express algorithms clearly.

#### QPL and cQPL

Quantum Programming Language (QPL) was defined by Peter Selinger and cQPL is its extension some elements useful for modelling of quantum communications were proposed. This extended language was called cQPL -- communication capable QPL.

At the moment cQPL compiler generates C++ code for linking with libqc simulation library from QCL.

ExamplesQubit allocation and measurement: ```
new qbit q := 0;
q *= H;
measure q then {
print "Head!"
} else {
print "Tail:(";
};
```

cQPL provides support for modelling quantum communication protocols. For example communication between Alice and Bob can be describe as an exchange of the qubits between two modules

```
module Alice {
new qbit a := 0;
new qbit b := 0;
send qbit a to Bob;
send qbit b to Bob;
}
module Bob {
receive q1:qbit from Alice;
receive q2:qbit from Bob;
dump q1;
dump q2;
}
```

By executing dump one can observe internal state of the quantum machine.

#### Quantum Lambda Calculus

First attempt to define quantum lambda calculus was made by Philip Maymin in 1996. In 2003 André van Tonder has defined extension of lambda calculus suitable to prove correctness of quantum programmes. He also provided an implementation in Scheme programming language (see: 1).

Quantum Lambda Language is based on Lambda calculus introduced by Alonzo Church and Stephen Cole Kleene in 1930s. It is an alternative model of quantum computation but it can be proved, like in the classical case, that it has the same computational power.

### References

#### Related articles

- General papers
- P. Selinger,
*A brief survey of quantum programming languages*, Proceedings of the 7th International Symposium on Functional and Logic Programming, Nara, Japan. Springer LNCS 2998, pp. 1-6, 2004. - S. Gay,
*Quantum Programming Languages: Survey and Bibliography*, Bulletin of the European Association for Theoretical Computer, June 2005.

- P. Selinger,

- Quantum pseudocode
- E. Knill,
*Conventions for quantum pseudocode*, Los Alamos National Laboratory technical report, LAUR-96-2724, 1996.

- E. Knill,

- QCL (Quantum Computation Language) 2
- B. Ömer,
*A Procedural Formalism for Quantum Computing*, Master thesis (computing science), Technical University of Vienna, 1998. - B. Ömer,
*Quantum Programming in QCL*, Master thesis (technical physics), Technical University of Vienna, 2001. - B. Ömer.
*Classical Concepts in Quantum Programming*, Proceedings of the Quantum Structures 2002, Vienna, Austria, July 1-7, 2002. - B. Ömer,
*Structured Quantum Programming*, PhD Thesis, Technical University of Vienna, 2003. - I. Glendinning, B. Ömer,
*Parallelization of the QC-lib Quantum Computer Simulator Library*, Springer LNCS 3019, pp. 461-468, 2004.

- B. Ömer,

- Q Language 3 and 4
- S. Bettelli,
*Toward an architecture for quantum programming*PhD Thesis, Universita di Trento, 2002 - S. Bettelli, L. Serafini, T. Calarco,
*Toward an architecture for quantum programming*, Eur. Phys. J. D, Vol. 25, No. 2, pp. 181-200, 2003.

- S. Bettelli,

- qGCL (quantum Guarded-Command Language)
- P. Zuliani,
*Quantum Programming*, PhD Thesis, University of Oxford, 2001. - P. Zuliani,
*Logical reversibility*, IBM J. Research and Development, 45(6), pp. 807-818, 2001. - P. Zuliani,
*Non-deterministic quantum programming*, Proceedings of the 2nd International Workshop on Quantum Programming Languages, July 12-13, 2004, Turku (Finland), pp. 179-195. - P. Zuliani,
*Quantum programming with mixed states*, Proceedings of the 3rd International Workshop on Quantum Programming Languages, June 30 - July 1, 2005, Chicago (USA), pp. 169-179, 2005.

- P. Zuliani,

- QPL (Quantum Programming Language) and cQPL (communication capable QPL)
- P. Selinger,
*Towards a quantum programming language*, Mathematical Structures in Computer Science 14(4):527-586, 2004. - W. Mauerer,
*Semantics and Simulation of Communication in Quantum Programming*, Master thesis, University Erlangen-Nuremberg, 2005. quant-ph/0511145

- P. Selinger,

- Quantum Lambda Calculus 5
- A. van Tonder,
*A Lambda Calculus for Quantum Computation*, SIAM J. Comput. 33, 1109-1135, 2004. - A. van Tonder,
*Quantum Computation, Categorical Semantics and Linear Logic*. quant-ph/0312174 - P. Maymin,
*Extending the Lambda Calculus to Express Randomized and Quantumized Algorithms*, 1996. - P. Maymin,
*The lambda-q calculus can efficiently simulate quantum computers*, 1997. - P. Selinger, B. Valiron,
*A lambda calculus for quantum computation with classical control*, 2004, - P. Arrighi, G. Dowek,
*Linear-algebraic lambda-calculus: higher-order, encodings and confluence*, LNCS 5117, 17-31, 2008.

- A. van Tonder,

- LanQ
*LanQ Online Documentation*- H. Mlnařík,
*Operational Semantics of Quantum Programming Language LanQ*, The most current document about LanQ semantics; updated version of the following one: - H. Mlnařík,
*Operational Semantics of Quantum Programming Language LanQ*, Masaryk University Technical Reports. FIMU-RS-2006-10 (outdated, see previous entry)

- Other
- Y. Feng, R. Duan, Z. Ji, M. Ying,
*Semantics of a purely quantum programming language*, 2005.

- Y. Feng, R. Duan, Z. Ji, M. Ying,

#### Books

- Edsger Wybe Dijkstra,
*A Discipline of Programming*, Prentice Hall PTR; 1st edition (October 28, 1997)

### See also

### External links

*Programming language*in Wikipedia*Random access machine*in Wikipedia- 3rd International Workshop on Quantum Programming Languages
- 2rd International Workshop on Quantum Programming Languages
- Bibliography on Quantum Programming Languages

Category:Resources for the QIP Community Category:Models of Quantum Computation