Quantum programming
Programming paradigms 


Quantum programming is the process of assembling sequences of instructions, called quantum programs, that are capable of running on a quantum computer. Quantum programming languages help express quantum algorithms using highlevel constructs.^{[1]}
Quantum instruction sets
Quantum instruction sets are used to turn higher level algorithms into physical instructions that can be executed on quantum processors. Sometimes these instructions are specific to a given hardware platform, e.g. ion traps or superconducting qubits.
Quil
Quil is an instruction set architecture for quantum computing that first introduced a shared quantum/classical memory model. It was introduced by Robert Smith, Michael Curtis, and William Zeng in A Practical Quantum Instruction Set Architecture.^{[2]} Many quantum algorithms (including quantum teleportation, quantum error correction, simulation,^{[3]}^{[4]} and optimization algorithms^{[5]}) require a shared memory architecture.
OpenQASM
OpenQASM^{[6]} is the intermediate representation introduced by IBM for use with Qiskit and the IBM Q Experience.
Quantum software development kits
Quantum software development kits provide collections of tools to create and manipulate quantum programs. They also provide the means to simulate the quantum programs, or prepare them to be run using cloudbased quantum devices.
SDKs with access to quantum processors
The following software development kits can be used to run quantum circuits on prototype quantum devices, as well as on simulators.
ProjectQ
An Open Source project developed at the Institute for Theoretical Physics at ETH, which uses the Python programming language to create and manipulate quantum circuits.^{[7]} Results are obtained either using a simulator, or by sending jobs to IBM quantum devices.
Qiskit
An Open Source project developed by IBM.^{[8]} Quantum circuits are created and manipulated using Python, Swift or Java. Results are obtained either using simulators that run on the user's own device, simulators provided by IBM or prototype quantum devices provided by IBM. As well as the ability to create programs using basic quantum operations, higher level algorithms are available within the Qiskit Aqua package.^{[9]} Qiskit is based on the OpenQASM standard for representing quantum circuits, and will support pulse level control of quantum systems as specified by the OpenPulse standard.^{[10]}
Forest
An Open Source project developed by Rigetti, which uses the Python programming language to create and manipulate quantum circuits. Results are obtained either using simulators or prototype quantum devices provided by Rigetti. As well as the ability to create programs using basic quantum operations, higher level algorithms are available within the Grove package.^{[11]} Forest is based on the Quil instruction set.
SDKs based on simulators
Public access to quantum devices is currently planned for the following SDKs, but not yet implemented.
Q#
A project developed by Microsoft^{[12]} as part of the .NET Framework. Quantum programs can be written and run within Visual Studio and VSCode.
Cirq
An Open Source project developed by Google, which uses the Python programming language to create and manipulate quantum circuits. Results are obtained using simulators that run on the user's own device.
Strawberry Fields
An opensource Python library developed by Xanadu for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.^{[13]}^{[14]} Three simulators are provided  one in the Fock basis, one using the Gaussian formulation of quantum optics,^{[15]} and one using the TensorFlow machine learning library.
SDKs in development
tket>
A quantum programming environment developed by Cambridge Quantum Computing, that will target simulators and quantum hardware.^{[16]} It is planned for use with the hardware produced by the NQIT hub, as well as Oxford Quantum Circuits. Full release is expected in September 2018.
Quantum programming languages
There are two main groups of quantum programming languages: imperative quantum programming languages and functional quantum programming languages.
Imperative languages
The most prominent representatives of the imperative languages are QCL,^{[17]} LanQ^{[18]} and QSI>.^{[19]}
QCL
Quantum Computation Language (QCL) is one of the first implemented quantum programming languages.^{[20]} The most important feature of QCL is the support for userdefined operators and functions. Its syntax resembles the syntax of the C programming language and its classical data types are similar to primitive data types in C. One can combine classical code and quantum code in the same program.
Quantum pseudocode
Quantum pseudocode proposed by E. Knill is the first formalized language for description of quantum algorithms. It was introduced and, moreover, was tightly connected with a model of quantum machine called Quantum Random Access Machine (QRAM).
QSI>
QSI> is a platform embedded in .Net language supporting quantum programming in a quantum extension of whilelanguage.^{[19]}^{[21]} This platform includes a compiler of the quantum whilelanguage^{[22]} and a chain of tools for the simulation of quantum computation, optimisation of quantum circuits, termination analysis of quantum programs,^{[23]} and verification of quantum programs.^{[24]}^{[25]}
Q language
Q Language is the second implemented imperative quantum programming language.^{[26]} Q Language was implemented as an extension of C++ programming language. It provides classes for basic quantum operations like QHadamard, QFourier, QNot, 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; // 1qubit quantum register with initial value 0
Qreg x2(2,0); // 2qubit quantum register with initial value 0
The computation process is executed using a provided simulator. Noisy environments 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 programs specification.
QMASM
Quantum Macro Assembler (QMASM) is a lowlevel language specific to quantum annealers such as the DWave.^{[27]}
Functional languages
Efforts are underway to develop functional programming languages for quantum computing. Functional programming languages are wellsuited for reasoning about programs. Examples include Selinger's QPL,^{[28]} and the Haskelllike language QML by Altenkirch and Grattage.^{[29]}^{[30]} Higherorder quantum programming languages, based on lambda calculus, have been proposed by van Tonder,^{[31]} Selinger and Valiron^{[32]} and by Arrighi and Dowek.^{[33]}
QFC and QPL
QFC and QPL are two closely related quantum programming languages defined by Peter Selinger. They differ only in their syntax: QFC uses a flow chart syntax, whereas QPL uses a textual syntax. These languages have classical control flow but can operate on quantum or classical data. Selinger gives a denotational semantics for these languages in a category of superoperators.
QML
QML is a Haskelllike quantum programming language by Altenkirch and Grattage.^{[34]}^{[29]} Unlike Selinger's QPL, this language takes duplication, rather than discarding, of quantum information as a primitive operation. Duplication in this context is understood to be the operation that maps to , and is not to be confused with the impossible operation of cloning; the authors claim it is akin to how sharing is modeled in classical languages. QML also introduces both classical and quantum control operators, whereas most other languages rely on classical control.
An operational semantics for QML is given in terms of quantum circuits, while a denotational semantics is presented in terms of superoperators, and these are shown to agree. Both the operational and denotational semantics have been implemented (classically) in Haskell.^{[35]}
LIQUi>
LIQUi> (pronounced liquid) is a quantum simulation extension on the F# programming language.^{[36]} It is currently being developed by the Quantum Architectures and Computation Group (QuArC)^{[37]} part of the StationQ efforts at Microsoft Research. LIQUi> seeks to allow theorists to experiment with quantum algorithm design before physical quantum computers are available for use.^{[38]}
It includes a programming language, optimization and scheduling algorithms, and quantum simulators. LIQUi> can be used to translate a quantum algorithm written in the form of a highlevel program into the lowlevel machine instructions for a quantum device.^{[39]}
Quantum lambda calculi
Quantum lambda calculi are extensions of the classical lambda calculus introduced by Alonzo Church and Stephen Cole Kleene in the 1930s. The purpose of quantum lambda calculi is to extend quantum programming languages with a theory of higherorder functions.
The first attempt to define a quantum lambda calculus was made by Philip Maymin in 1996.^{[40]} His lambdaq calculus is powerful enough to express any quantum computation. However, this language can efficiently solve NPcomplete problems, and therefore appears to be strictly stronger than the standard quantum computational models (such as the quantum Turing machine or the quantum circuit model). Therefore, Maymin's lambdaq calculus is probably not implementable on a physical device.
In 2003, André van Tonder defined an extension of the lambda calculus suitable for proving correctness of quantum programs. He also provided an implementation in the Scheme programming language.^{[41]}
In 2004, Selinger and Valiron defined a strongly typed lambda calculus for quantum computation with a type system based on linear logic.
Quipper
Quipper was published in 2013.^{[42]}^{[43]} It is implemented as an embedded language, using Haskell as the host language.^{[44]} For this reason, quantum programs written in Quipper are written in Haskell using provided libraries. For example, the following code implements preparation of a superposition
import Quipper
spos :: Bool > Circ Qubit
spos b = do q < qinit b
r < hadamard q
return r
References
 ↑ Jarosław Adam Miszczak (2012). Highlevel Structures in Quantum Computing. ISBN 9781608458516.
 ↑ Smith, Robert S.; Curtis, Michael J.; Zeng, William J. (2016). "A Practical Quantum Instruction Set Architecture". arXiv:1608.03355 [quantph].
 ↑ McClean, Jarrod R.; Romero, Jonathan; Babbush, Ryan; AspuruGuzik, Alán (20160204). "The theory of variational hybrid quantumclassical algorithms". New Journal of Physics. 18 (2): 023023. arXiv:1509.04279. Bibcode:2016NJPh...18b3023M. doi:10.1088/13672630/18/2/023023. ISSN 13672630.
 ↑ Rubin, Nicholas C.; Curtis, Michael J.; Zeng, William J. (2016). "A Hybrid Classical/Quantum Approach for LargeScale Studies of Quantum Systems with Density Matrix Embedding Theory". arXiv:1610.06910 [quantph].
 ↑ Farhi, Edward; Goldstone, Jeffrey; Gutmann, Sam (2014). "A Quantum Approximate Optimization Algorithm". arXiv:1411.4028 [quantph].
 ↑ qiskitopenqasm: OpenQASM specification, International Business Machines, 20170704, retrieved 20170706
 ↑ "ProjectQ homepage".
 ↑ "Qiskit homepage".
 ↑ "Qiskit Aqua homepage".
 ↑ McKay, David C.; Alexander, Thomas; Bello, Luciano; Biercuk, Michael J.; Bishop, Lev; Chen, Jiayin; Chow, Jerry M.; Córcoles, Antonio D.; Egger, Daniel; Filipp, Stefan; Gomez, Juan; Hush, Michael; JavadiAbhari, Ali; Moreda, Diego; Nation, Paul; Paulovicks, Brent; Winston, Erick; Wood, Christopher J.; Wootton, James; Gambetta, Jay M. (2018). "Qiskit Backend Specifications for OpenQASM and OpenPulse Experiments". arXiv:1809.03452 [quantph].
 ↑ "Grove documentation".
 ↑ "Q# documentation".
 ↑ "Strawberry Fields — Strawberry Fields 0.8.0 documentation". strawberryfields.readthedocs.io. Retrieved 20180925.
 ↑ Killoran, Nathan; Izaac, Josh; Quesada, Nicolás; Bergholm, Ville; Amy, Matthew; Weedbrook, Christian (2018). "Strawberry Fields: A Software Platform for Photonic Quantum Computing". arXiv:1804.03159 [quantph].
 ↑ Weedbrook, Christian; Pirandola, Stefano; GarcíaPatrón, Raúl; Cerf, Nicolas J.; Ralph, Timothy C.; Shapiro, Jeffrey H.; Lloyd, Seth (20120501). "Gaussian quantum information". Reviews of Modern Physics. 84 (2): 621–669. arXiv:1110.3234. Bibcode:2012RvMP...84..621W. doi:10.1103/RevModPhys.84.621.
 ↑ "t ket> flyer" (PDF).
 ↑ Bernhard Omer. "The QCL Programming Language".
 ↑ Hynek Mlnařík. "LanQ – a quantum imperative programming language".
 1 2 Liu, Shusen; Zhou, li; Guan, Ji; He, Yang; Duan, Runyao; Ying, Mingsheng (20170509). "QSI>: A Quantum Programming Language". SCIENTIA Sinica Information. 47 (10): 1300. arXiv:1710.09500. doi:10.1360/N11201700095.
 ↑ "QCL  A Programming Language for Quantum Computers". tuwien.ac.at. Retrieved 20170720.
 ↑ Ying, Mingsheng (January 2012). "Floyd–hoare Logic for Quantum Programs". ACM Trans. Program. Lang. Syst. 33 (6): 19:1–19:49. doi:10.1145/2049706.2049708. ISSN 01640925.
 ↑ Ying, Mingsheng; Feng, Yuan (2010). "A Flowchart Language for Quantum Programming". IEEE Transactions on Software Engineering. 37 (4): 466–485. doi:10.1109/TSE.2010.94. ISSN 00985589.
 ↑ Ying, Mingsheng; Yu, Nengkun; Feng, Yuan; Duan, Runyao (2013). "Verification of quantum programs". Science of Computer Programming. 78 (9): 1679–1700. arXiv:1106.4063. doi:10.1016/j.scico.2013.03.016.
 ↑ Ying, Mingsheng; Ying, Shenggang; Wu, Xiaodi (2017). Invariants of Quantum Programs: Characterisations and Generation. Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. POPL 2017. 52. New York, NY, USA: ACM. pp. 818–832. doi:10.1145/3093333.3009840. hdl:10453/127333. ISBN 9781450346603.
 ↑ Liu, Tao; Li, Yangjia; Wang, Shuling; Ying, Mingsheng; Zhan, Naijun (2016). "A Theorem Prover for Quantum Hoare Logic and its Applications". arXiv:1601.03835 [cs.LO].
 ↑ "Software for the Q language". 20011123. Archived from the original on 20090620. Retrieved 20170720.
 ↑ Scott Pakin, "A Quantum Macro Assembler", Proceedings of the 20th Annual IEEE High Performance Extreme Computing Conference 2016
 ↑ Peter Selinger, "Towards a quantum programming language", Mathematical Structures in Computer Science 14(4):527586, 2004.
 1 2 Jonathan Grattage: QML Research (website)
 ↑ T. Altenkirch, V. Belavkin, J. Grattage, A. Green, A. Sabry, J. K. Vizzotto, QML: A Functional Quantum Programming Language Archived 20060710 at the Wayback Machine. (website)
 ↑ Andre van Tonder, "A Lambda Calculus for Quantum Computation", SIAM J. Comput., 33(5), 1109–1135. (27 pages), 2004. Also available from arXiv:quantph/0307150
 ↑ Peter Selinger and Benoît Valiron, "A lambda calculus for quantum computation with classical control", Mathematical Structures in Computer Science 16(3):527552, 2006.
 ↑ Pablo Arrighi, Gilles Dowek, "Linearalgebraic lambdacalculus: higherorder, encodings and confluence", 2006
 ↑ "QML: A Functional Quantum Programming Language". 20070926.
 ↑ Jonathan Grattage, QML: A Functional Quantum Programming Language (compiler), 2005–2008
 ↑ "The Language Integrated Quantum Operations Simulator". github.io. Retrieved 20170720.
 ↑ Quantum Architectures and Computation Group (QuArC), https://www.microsoft.com/enus/research/group/quantumarchitecturesandcomputationgroupquarc/, 2011
 ↑ "StationQ". microsoft.com. Retrieved 20170720.
 ↑ "LanguageIntegrated Quantum Operations: LIQUi>". 2016.
 ↑ Philip Maymin, "Extending the Lambda Calculus to Express Randomized and Quantumized Algorithms", 1996
 ↑ André van Tonder. "A lambda calculus for quantum computation (website)".
 ↑ "The Quipper Language".
 ↑ Alexander S. Green; Peter LeFanu Lumsdaine; Neil J. Ross; Peter Selinger; Benoît Valiron. "The Quipper Language (website)".
 ↑ Alexander S. Green; Peter LeFanu Lumsdaine; Neil J. Ross; Peter Selinger; Benoît Valiron (2013). An Introduction to Quantum Programming in Quipper. Lecture Notes in Computer Science. 7948. pp. 110–124. arXiv:1304.5485. doi:10.1007/9783642389863_10. ISBN 9783642389856.
Further reading
External links
 Bibliography on Quantum Programming Languages (updated in May 2007)
 5th International Workshop on Quantum Physics and Logic
 4th International Workshop on Quantum Programming Languages
 3rd International Workshop on Quantum Programming Languages
 2nd International Workshop on Quantum Programming Languages
 Quantum programming language in Quantiki
 QMASM documentation
 pyQuil documentation including introduction to quantum programming
 Curated list of all opensource quantum software projects