Algebraic Effects, Linearity, and Quantum Programming Languages

Algebraic Effects, Linearity, and Quantum Programming Languages

Algebraic Effects, Linearity, and Quantum Programming Languages Sam Staton Radboud University Nijmegen Abstract rotating it by 180◦ around the X axis, taking the top of the We develop a new framework of algebraic theories with linear pa- sphere to the bottom; this unitary rotation is notated X, and rameters, and use it to analyze the equational reasoning principles so the function that applies the rotation is notated applyX. of quantum computing and quantum programming languages. We measure: make a random boolean choice, with the probabil- use the framework as follows: ity of returning either 0 or 1 depending on the Z co-ordinate of the qubit (this is called the standard basis). For example, • we present a new elementary algebraic theory of quantum com- if the qubit was on the X axis, the result of measuring will putation, built from unitary gates and measurement; be 0 or 1 with equal probability, like tossing a fair coin; if • we provide a completeness theorem for the elementary alge- it was at the very top of the sphere, the result of measur- braic theory by relating it with a model from operator algebra; ing will be 0 with certainty; if it was at the very bottom of • we extract an equational theory for a quantum programming the sphere, the result of measuring will be 1 with certainty. language from the algebraic theory; Measuring a qubit destroys it: all that remains is the result of the measurement. • we compare quantum computation with other local notions of computation by investigating variations on the algebraic theory. • For types A and B, there is a type A ⊗ B of entangled pairs. For instance the type qubit ⊗ qubit is a type of pairs of pos- sibly entangled qubits. Entanglement is achieved by controlled 1. Introduction unitary rotations. For example, the controlled-X unitary, cX, af- Quantum programming languages test many of the challenges of fects two qubits, and if t is an expression of type qubit ⊗ qubit modern programming language theory: linear use of resources, sep- then also applycX(t) is an expression of type qubit⊗qubit. The aration, locality. A good way to understand a programming lan- computation applycX(a; b) is like ‘if a is 1 then return (a; :b) guage is to understand equality of programs. In this paper we de- else return (a; b)’, so that the second value returned depends velop a general algebraic framework for computational effects in- on the first value input. The entanglement occurs because this volving linear resources. We use it to give a complete axiomatiza- controlled rotation happens without actually measuring a, and tion of equality of quantum programs. indeed it is reversible. Yet if a is subsequently measured then the controlled rotation appears to have behaved in this way. What is quantum computing? From a programming language perspective, quantum computing involves qubits and entanglement: The main contribution of this paper is the fact that the relationship between unitary rotations and measurement can be completely de- • There is a type qubit of qubits. Viewed as an abstract type, we scribed by three simple axioms (Theorem 9), and allocation by two can imagine a qubit as having an internal state that is a position simple axioms (Theorem 11). This simple axiomatization (com- on the surface of a sphere (called the Bloch sphere), but the bined with the unitary groups and commutativity laws) completely accessor functions do not actually permit us to read its position characterizes earlier models that are built from operator algebra and on the surface. The three accessor functions are, informally, as functional analysis. follows. (Notation: we underline them.) In the remainder of this introduction, we give an informal new: allocate a new qubit, with initial position at the top of overview of these results. To express the equations, we need to the Z axis (called j0i). first discuss the syntax. applyU: apply a rotation to the qubit on the sphere around Quantum programming languages and quantum programs. A a given axis by a given angle, as specified by a unitary quantum programming language captures the ideas of quantum matrix U. For example, we can kind-of negate a qubit by computation in a linear type theory. For example, we can write a program of type qubit ! qubit: Permission to make digital or hard copies of all or part of this work for personal or fn a : qubit ) if measure a = 0 then new() else apply (new()) classroom use is granted without fee provided that copies are not made or distributed X for profit or commercial advantage and that copies bear this notice and the full citation (1) on the first page. Copyrights for components of this work owned by others than the which measures a qubit and returns a new qubit initialized either author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or to j0i or j1i, depending on the outcome. In other words, the input republish, to post on servers or to redistribute to lists, requires prior specific permission qubit is collapsed on to the Z axis. and/or a fee. Request permissions from [email protected]. For another example of a program, we recall the Hadamard POPL ’15, January 15–17 2015, Mumbai, India. Copyright is held by the owner/author(s). Publication rights licensed to ACM. rotation, Had, which maps the Z axis onto the X axis by rotating ◦ ACM 978-1-4503-3300-9/15/01. $15.00. 180 around the axis that lies between the X and Z axes. We can http://dx.doi.org/10.1145/2676726.2676999 use this to define a coin toss operation: first initialize a qubit to the top of the sphere, and then rotate by Hadamard, and then measure: Here x is a variable standing for the continuation of the computa- the program tion (as yet unspecified) which is parameterized by the result qubit. measure(applyHad(new())) : bit Diagrammatic notation. Informal diagrams are often helpful. returns 0 or 1 with equal probability. We can use this to randomly Our notion of quantum computation is very similar to the notion rotate a qubit around the Z axis: writing Z for the rotation of 180◦ described by quantum circuits, for instance in the book by Nielsen around the Z axis, and Chuang [31]. The two programs above ((1), (2)) could be writ- ten as the following circuits: fn a : qubit ) if measure(applyHad(new())) = 0 j0i b X a Z a then a else applyZ(a): qubit ! qubit (2) a • j0i Had • It turns out that this program (2) is actually equal to the first b program (1): projecting onto the Z axis is the same as randomly The circuits should be read from left to right. The single wires flipping around the Z axis. This fact, perhaps counter-intuitive at carry qubits, the double wires carry classical bits. The boxes are first, is a consequence of our simple intuitive axiomatization of the unitary rotations, and the meter device is measurement, which quantum computation. takes a quantum wire to a classical one. The vertical lines indicate control: the outcome of the measurement determines whether the Notions of computation and algebraic theories. In programming gate is applied. language theory it is often useful to analyze different features Aside: Just as we wanted to isolate notions of quantum compu- of a programming language separately. In the quantum programs tation from other aspects of programming languages, so we ought above there are standard features such as sequencing, if-then-else, to isolate the quantum parts of quantum circuits (qubits, unitaries, functions, as well as the aspects specific to quantum computing. measurement) from the classical wires. This leads us to a 3-d nota- One way of distinguishing the specific ‘notions of computation’ tion like from the other standard features of programming languages is by using algebraic effects [36]. A key contribution of this paper (x2) is a new algebraic framework for analyzing the effects of a linear-use resource. A useful step towards the algebraic analysis is to step away a from booleans, if-then-else and sums by writing measure(a; t; u) a for the program (if measure(a) = 0 then t else u). By working b Had with expressions such as measure(a; t; u), which are in a kind-of continuation-passing normal form, we can forget about structural aspects and typing issues. Indeed to analyze the algebraic theory of quantum computation, we need only distinguish between two kinds of thing: qubits and computations. in which measurement causes a branch in the circuit instead of a Notice our typographic convention: we underline programming- classical wire. These kinds of diagram are very similar to Mellies’` language-style commands (measure(a)) but not the corresponding notation for storage of classical bits [28], but they are also common algebraic operations (measure(a; t; u)). We make this correspon- in the many-worlds interpretation of quantum mechanics. In this dence precise in Section 5. paper we will only use diagrams in an informal way, and so we will write 2-d circuit diagrams for simplicity. We return to the Algebraic structure of quantum computation. We are now in a relationship with classical bits in Section 6.2. position to postulate the algebraic structure of quantum computa- tion. It supports four constructions: Axioms of quantum computation. We are now in a position to summarize the algebraic laws of quantum computation. A full • t a if is a computation involving a qubit then there is a compu- account is in Section 3. In brief, the laws of measurement are: tation new(a:t) that allocates that qubit, initialized to j0i, and continues as t; • after measurement, quantum negation is like classical negation: • 0 0 if t is a computation involving qubits b1 : : : bn and U is a uni- applyX(a; a :measure(a ; x; y)) = measure(a; y; x) tary matrix over n qubits then there is a quantum computa- tion apply (a : : : a ; b : : : b :t) that first performs the uni- = U 1 n 1 n X tary U to the qubits a1 : : : an and then binds the resulting qubits b : : : b t 1 n in the continuation ; • after measurement, quantum control is like classical control: • if t and u are computations and a is a qubit then there is a 0 0 0 0 0 computation measure(a; t; u) that measures a and continues as applycU(a; b; a b :measure(a ; x(b ); y(b ))) either t or u depending on the result of the measurement.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us