A formalization of the Quipper quantum programming language Henri - - PowerPoint PPT Presentation

a formalization of the quipper quantum programming
SMART_READER_LITE
LIVE PREVIEW

A formalization of the Quipper quantum programming language Henri - - PowerPoint PPT Presentation

A formalization of the Quipper quantum programming language Henri Chataing, Neil J. Ross & Peter Selinger Dalhousie University & Ecole Polytechnique 2014 TYPES Meeting 1 Quantum computing is computing based on the laws of quantum


slide-1
SLIDE 1

A formalization of the Quipper quantum programming language

Henri Chataing, Neil J. Ross & Peter Selinger

Dalhousie University & ´ Ecole Polytechnique

2014 TYPES Meeting

1

slide-2
SLIDE 2

Quantum computing is computing based on the laws of quantum physics. The standard model of quantum computing is Knill’s Qram model, in which a classical computer is connected to a quantum device. Classical Quantum Measurement results Instructions

2

slide-3
SLIDE 3

The instructions for the quantum device are arranged in a quantum circuit. The gates that compose quantum circuits can be unitaries, which are reversible operations, or measurements, which are probabilistic

  • perations.

G1 G2 G3 G4

3

slide-4
SLIDE 4

Quipper is a programming language for quantum computing, implemented as an embedded language within Haskell. Several non-trivial algorithms from the quantum computing literature have been implemented in Quipper. Quipper is a circuit description language.

4

slide-5
SLIDE 5

Quipper’s circuit as data paradigm.

H 1 1 1 1 H

circuit :: [Qubit] -> Circ ([Qubit], [Qubit]) circuit qs = do y <- with_computed subcircuit $ \subcircuit -> do qc_copy subcircuit return (qs, y)

5

slide-6
SLIDE 6

Quipper’s type system does not guarantee that quantum programs are physically meaningful. self_control :: Qubit -> Circ Qubit self_control q = do qnot_at q ‘controlled‘ q return q

6

slide-7
SLIDE 7

Goals:

◮ Define a type-safe language, Proto-Quipper, that will serve as

a basis for the development of Quipper as a stand-alone language. Chosen features for Proto-Quipper:

◮ Have a type system to enforce the physics

(draw inspiration from the quantum lambda calculus).

◮ Capture Quipper’s circuits as data paradigm.

Simplifying assumption:

◮ No measurements (all circuits are therefore reversible).

7

slide-8
SLIDE 8

The Proto-Quipper language: Type A, B ::= 1 bool A ⊗ B A ⊸ B !A qubit Circ(T, U) QDataType T, U ::= qubit 1 T ⊗ U Term a, b, c ::= . . . q (t, C, a) boxT unbox rev QDataTerm t, u ::= q ∗ t, u

8

slide-9
SLIDE 9

Some basic built-in gates:

◮ HAD := unbox(q, HAD, q) ◮ CNOT := unbox(q1, q2, CNOT, q1, q2) ◮ INIT0 := unbox(∗, 0, q)

A Proto-Quipper term (not quite) for subcircuit: subcircuit := boxqubit(λx.CNOT(HAD x, INIT0 ∗)) (q,

H

, q, q′)

9

slide-10
SLIDE 10

Proto-Quipper’s operational semantics supposes a circuit constructor. The circuit constructor is assumed to be able to perform some basic operations: appending gates, reversing circuits, . . . The reduction will be defined on closures [C, t] consisting of a term t of the language and a circuit state C representing the circuit currently being built.

10

slide-11
SLIDE 11

The operational semantics of Proto-Quipper (a selection): SpecFQ(v)(T) = t new(FQ(t)) = D [C, boxT(v)] → [C, (t, D, vt)] [D, a] → [D′, a′] [C, (t, D, a)] → [C, (t, D′, a′)] bind(v, u) = b Append(C, D, b) = (C ′, b′) FQ(u′) ⊆ dom(b′) [C, (unbox (u, D, u′))v] → [C ′, b′(u′)]

11

slide-12
SLIDE 12

subcircuit := boxqubit(λx.CNOT(INIT0 ∗, HAD x)) [ · , subcircuit] ։ [ , CNOT(INIT0 ∗, HAD q))] ։ [

H

, CNOT(INIT0 ∗, q))] ։ [

H

, CNOT(q′, q))] ։ [

H

, q′, q] ։ [ · , (q, C, q′, q)]

12

slide-13
SLIDE 13

For each of the constants boxT, unbox, and rev, we introduce a type:

◮ AboxT (T, U) = !(T ⊸ U) ⊸ ! Circ(T, U), ◮ Aunbox(T, U) = Circ(T, U) ⊸ !(T ⊸ U), and ◮ Arev(T, U) = Circ(T, U) ⊸ ! Circ(U, T).

And a typing rule, for c ∈ {boxT, unbox, rev}: !Ac(T, U) <: B !∆; ∅ ⊢ c : B

13

slide-14
SLIDE 14

The type system of Proto-Quipper (a selection): A <: B !∆, x : A; ∅ ⊢ x : B (axc) !∆; {q} ⊢ q : qubit (axq) Γ, x : A; Q ⊢ b : B Γ; Q ⊢ λx.b : A ⊸ B (λ1) !∆, x : A; ∅ ⊢ b : B !∆; ∅ ⊢ λx.b : !n+1(A ⊸ B) (λ2) Γ1, !∆; Q1 ⊢ a : !nA Γ2, !∆; Q2 ⊢ b : !nB Γ1, Γ2, !∆; Q1, Q2 ⊢ a, b : !n(A ⊗ B) (⊗-i) Q1 ⊢ t : T !∆; Q2 ⊢ a : U In(C) = Q1 Out(C) = Q2 !∆; ∅ ⊢ (t, C, a) : !n Circ(T, U) (circ)

14

slide-15
SLIDE 15

Proto-Quipper is a type-safe language, It enjoys subject reduction and progress. Subject reduction: If Γ; FQ(a) ⊢ [C, a] : A, (Q′|Q′′) is a valid typed closure and [C, a] → [C ′, a′], then Γ; FQ(a′) ⊢ [C ′, a′] : A, (Q′|Q′′) is a valid typed closure.

15

slide-16
SLIDE 16

References:

◮ A.S. Green, P. Lefanu Lumsdaine, N.J. Ross, P. Selinger, and

  • B. Valiron. An introduction to quantum programming in

quipper.

◮ A.S. Green, P. Lefanu Lumsdaine, N.J. Ross, P. Selinger, and

  • B. Valiron. Quipper: A scalable quantum programming

language.

◮ P. Selinger and B. Valiron. Quantum lambda calculus.

16