Quantum programming

Quantum programming is a set of computer programming languages that allow the expression of quantum algorithms using high-level constructs.[1] The point of many quantum languages is not so much to provide a tool for programmers, but to provide tools for researchers to understand better how quantum computation works and how to reason formally about quantum algorithms. However, recent developments in quantum computer prototypes have led to the emergence of quantum instruction sets that are more focused on programming hardware.

One can single out two main groups of quantum programming languages: imperative quantum programming languages and functional quantum programming languages.

The most prominent representatives of the first group are QCL[2], LanQ [3] and Q|SI>[4].

Efforts are underway to develop functional programming languages for quantum computing. Examples include Selinger's QPL,[5] and the Haskell-like language QML by Altenkirch and Grattage.[6][7] Higher-order quantum programming languages, based on lambda calculus, have been proposed by van Tonder,[8] Selinger and Valiron [9] and by Arrighi and Dowek.[10]

Simon Gay's Quantum Programming Languages Survey provides information on the state of research and a comprehensive bibliography of resources about quantum programming as of 2007. Recent book Foundations of Quantum Programming[11] provides a systematic exposition for the research of semantics of quantum programming languages, analysis and verification of quantum programs as well as a comprehensive bibliograph as of 2016.

Quantum Instruction Sets and Intermediate Representations

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.

OpenQASM

OpenQASM[12] is the intermediate representation introduced by IBM for use with their Quantum Experience.

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.[13] Many quantum algorithms (including quantum teleportation, quantum error correction, simulation[14][15], and optimization algorithms[16]) require a shared memory architecture. The following example demonstrates the classical control flow needed to do quantum teleportation of the qubit in register 0 to register 2:

# Create Bell Pair
H 0
CNOT 0 1
# Teleport
CNOT 2 0
H 2
MEASURE 2 [0]
MEASURE 0 [1]
# Classically communicate measurements
JUMP-UNLESS @SKIP [1]
X 1
LABEL @SKIP
JUMP-UNLESS @END [0]
Z 1
LABEL @END

Quil is being developed for the superconducting quantum processors developed by Rigetti Computing through the Forest quantum programming API.[17][18] A Python library called pyQuil was introduced to develop Quil programs with higher level constructs. A Quil backend is also supported by other quantum programming environments.[19][20]

Imperative quantum programming languages

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).

Quantum computing language

Quantum Computation Language (QCL) is one of the first implemented quantum programming languages.[21] 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.

The basic built-in quantum data type in QCL is the qureg (quantum register). It can be interpreted as 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 x2

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

   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 the dump operation is different from measurement, since it does not influence the state of the quantum machine and can be realized only using a simulator.

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

The most important feature of QCL is the support for user-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 one to define algorithms on a higher level of abstraction and extend the library of functions available for programmers.

Syntax

Q|SI>

Q|SI>[4] is a platform embedded in .Net language supporting quantum programming in a quantum extension of while-language[22] [11]. This platform includes a compiler of the quantum while-language[23] and a chain of tools for the simulation of quantum computation, optimisation of quantum circuits, termination analysis of quantum programs[24], and verification of quantum programs[25][26].

A complete quantum teleportation example can be illustrated as the following code segment in Q|SI>,

 class TestQuantMulti1 : QEnv //Quantum Teleportation
    {
        public Reg r3 = new Reg("r3");
        public Quantum Alice = MakeQBit("{[1/sqrt(5); sqrt(4)/sqrt(5)]}");
        public Quantum Bob1 = MakeDensityOperator("{[0.5 0.5;0.5 0.5]}");//|0>+|1>
        public Quantum Bob2 = MakeDensityOperator("{[1 0;0 0]}");
        U.Emit hGate = MakeU("{[1/sqrt(2) 1/sqrt(2); 1 / sqrt(2)  -1 / sqrt(2)]}");
        U.Emit CNot = MakeU("{[1 0 0 0;0 1 0 0;0 0 0 1;0 0 1 0]}");//1->2 Cnot
        U.Emit xGate = MakeU("{[0 1; 1 0]}");
        U.Emit zGate = MakeU("{[1 0;0 -1]}");
        M.Emit m = MakeM("{[1 0;0 0],[0 0;0 1]}");
        protected override void run()
        {
            CNot(Bob1, Bob2); //Prepare |00>+|11> for Bob
            CNot(Alice, Bob1);
            hGate(Alice);
            QIf(m(Bob1),
                () =>
                { },
                () =>
                {
                    xGate(Bob2);
                });
            QIf(m(Alice),
              () =>
              { },
              () =>
              {
                  zGate(Bob2);
              });

            Register(r3, m(Bob2));
        }
    }  

Q language

Q Language is the second implemented imperative quantum programming language.[27] 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; // 1-qubit quantum register with initial value 0
   Qreg x2(2,0); // 2-qubit 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 low-level language specific to quantum annealers such as the D-Wave. [28]

Functional quantum programming languages

During the last few years many quantum programming languages based on the functional programming paradigm were proposed. Functional programming languages are well-suited for reasoning about programs.

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 Haskell-like quantum programming language by Altenkirch and Grattage.[6] 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.[29]

LIQUi|>

LIQUi|> (pronounced 'liquid') is a quantum simulation extension on the F# programming language.[30] It is currently being developed by the Quantum Architectures and Computation Group (QuArC) [31] 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.[32]

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 high-level program into the low-level machine instructions for a quantum device. [33]

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 higher-order functions.

The first attempt to define a quantum lambda calculus was made by Philip Maymin in 1996.[34] His lambda-q calculus is powerful enough to express any quantum computation. However, this language can efficiently solve NP-complete 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 lambda-q 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.[35]

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.[36] It is implemented as an embedded language, using Haskell as the host language.[37] 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

  1. Jarosław Adam Miszczak. "High-level Structures in Quantum Computing". Retrieved 12 December 2015.
  2. Bernhard Omer. "The QCL Programming Language".
  3. Hynek Mlnařík. "LanQ – a quantum imperative programming language".
  4. 1 2 Liu, Shusen; Zhou, li; Guan, Ji; He, Yang; Duan, Runyao; Ying, Mingsheng (2017-05-09). "Q|SI>: A Quantum Programming Language". SCIENTIA Sinica Information. doi:10.1360/N112017-00095.
  5. Peter Selinger, "Towards a quantum programming language", Mathematical Structures in Computer Science 14(4):527-586, 2004.
  6. 1 2 Jonathan Grattage: QML Research (website)
  7. T. Altenkirch, V. Belavkin, J. Grattage, A. Green, A. Sabry, J. K. Vizzotto, QML: A Functional Quantum Programming Language (website)
  8. Andre van Tonder, "A Lambda Calculus for Quantum Computation", SIAM J. Comput., 33(5), 1109–1135. (27 pages), 2004. Also available from arXiv:quant-ph/0307150
  9. Peter Selinger and Benoît Valiron, "A lambda calculus for quantum computation with classical control", Mathematical Structures in Computer Science 16(3):527-552, 2006.
  10. Pablo Arrighi, Gilles Dowek, "Linear-algebraic lambda-calculus: higher-order, encodings and confluence", 2006
  11. 1 2 Mingsheng, Ying. Foundations of quantum programming. Cambridge, MA. ISBN 9780128025468. OCLC 945735387.
  12. qiskit-openqasm: OpenQASM specification, International Business Machines, 2017-07-04, retrieved 2017-07-06
  13. Smith, Robert S.; Curtis, Michael J.; Zeng, William J. (2016-08-10). "A Practical Quantum Instruction Set Architecture". arXiv:1608.03355 [quant-ph].
  14. McClean, Jarrod R.; Romero, Jonathan; Babbush, Ryan; Aspuru-Guzik, Alán (2016-02-04). "The theory of variational hybrid quantum-classical algorithms". New Journal of Physics. 18 (2): 023023. ISSN 1367-2630. doi:10.1088/1367-2630/18/2/023023.
  15. Rubin, Nicholas C. (2016-10-21). "A Hybrid Classical/Quantum Approach for Large-Scale Studies of Quantum Systems with Density Matrix Embedding Theory". arXiv:1610.06910 [cond-mat, physics:quant-ph].
  16. Farhi, Edward; Goldstone, Jeffrey; Gutmann, Sam (2014-11-14). "A Quantum Approximate Optimization Algorithm". arXiv:1411.4028 [quant-ph].
  17. "Rigetti Launches Full-Stack Quantum Computing Service and Quantum IC Fab". IEEE Spectrum: Technology, Engineering, and Science News. Retrieved 2017-07-06.
  18. "Rigetti Quietly Releases Beta of Forest Platform for Quantum Programming in the Cloud | Quantum Computing Report". quantumcomputingreport.com. Retrieved 2017-07-06.
  19. "XACC Rigetti Accelerator". ornl-qci.github.io. Retrieved 2017-07-06.
  20. Doiron, Nick (2017-03-07), jsquil: Quantum computer instructions for JavaScript developers, retrieved 2017-07-06
  21. "QCL - A Programming Language for Quantum Computers". tuwien.ac.at. Retrieved 2017-07-20.
  22. Ying, Mingsheng (January 2012). "Floyd–hoare Logic for Quantum Programs". ACM Trans. Program. Lang. Syst. 33 (6): 19:1–19:49. ISSN 0164-0925. doi:10.1145/2049706.2049708.
  23. Ying, Mingsheng; Feng, Yuan (2010). "A Flowchart Language for Quantum Programming". IEEE Transactions on Software Engineering. 37 (4): 466–485. ISSN 0098-5589. doi:10.1109/TSE.2010.94.
  24. Ying, Mingsheng; Yu, Nengkun; Feng, Yuan; Duan, Runyao. "Verification of quantum programs". Science of Computer Programming. 78 (9): 1679–1700. doi:10.1016/j.scico.2013.03.016.
  25. 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. New York, NY, USA: ACM: 818–832. ISBN 9781450346603. doi:10.1145/3093333.3009840.
  26. Liu, Tao; Li, Yangjia; Wang, Shuling; Ying, Mingsheng; Zhan, Naijun (2016-01-15). "A Theorem Prover for Quantum Hoare Logic and Its Applications". arXiv:1601.03835 [cs].
  27. "Software for the Q language". archive.org. 2001-11-23. Retrieved 2017-07-20.
  28. Scott Pakin, "A Quantum Macro Assembler", Proceedings of the 20th Annual IEEE High Performance Extreme Computing Conference 2016
  29. Jonathan Grattage, QML: A Functional Quantum Programming Language (compiler), 2005–2008
  30. "The Language Integrated Quantum Operations Simulator". github.io. Retrieved 2017-07-20.
  31. Quantum Architectures and Computation Group (QuArC), https://www.microsoft.com/en-us/research/group/quantum-architectures-and-computation-group-quarc/, 2011
  32. "StationQ". microsoft.com. Retrieved 2017-07-20.
  33. Language-Integrated Quantum Operations: LIQUi|>, , 2016
  34. Philip Maymin, "Extending the Lambda Calculus to Express Randomized and Quantumized Algorithms", 1996
  35. André van Tonder. "A lambda calculus for quantum computation (website)".
  36. Alexander S. Green; Peter LeFanu Lumsdaine; Neil J. Ross; Peter Selinger; Benoît Valiron. "The Quipper Language (website)".
  37. Alexander S. Green; Peter LeFanu Lumsdaine; Neil J. Ross; Peter Selinger; Benoît Valiron (2013). "An Introduction to Quantum Programming in Quipper". arXiv:1304.5485Freely accessible.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.