Compiling a functional quantum programming language - - PowerPoint PPT Presentation

compiling a functional quantum programming language
SMART_READER_LITE
LIVE PREVIEW

Compiling a functional quantum programming language - - PowerPoint PPT Presentation

Compiling a functional quantum programming language www.cs.nott.ac.uk/ jjg/qml Jonathan Grattage with Thorsten Altenkirch School of Computer Science & IT, University of Nottingham Compiling a functional quantum programming language


slide-1
SLIDE 1

Compiling a functional quantum programming language

Jonathan Grattage with Thorsten Altenkirch www.cs.nott.ac.uk/ jjg/qml School of Computer Science & IT, University of Nottingham

Compiling a functional quantum programming language – p.1/15

slide-2
SLIDE 2

Motivation

  • The “Quantum Software Crisis”
  • Quantum algorithms are usually presented using the circuit

model

  • Nielsen and Chuang, p.7, ‘Coming up with good quantum

algorithms is hard’

  • Richard Josza, QPL 2004: “We need to develop quantum thinking!”
  • Our Solution:

A high-level quantum programming language with a structure familiar to functional programmers, which supports reasoning and and algorithm design

Compiling a functional quantum programming language – p.2/15

slide-3
SLIDE 3

Quantum Languages

  • P

. Zuliani, PhD 2001, Quantum Programming (qGCL)

  • P

. Selinger, MSCS 2003, Towards a Quantum Programming Language (QPL)

  • A. van Tonder, SIAM 2003, A Lambda Calculus for Quantum

Computation

  • A. Sabry, Haskell 2003, Modeling quantum computing in Haskell
  • P

. Selinger and B. Valiron, TLCA 2005, A lambda calculus for quantum computation with classical control

  • :
: :
  • All based on “Quantum data, Classical control”

Compiling a functional quantum programming language – p.3/15

slide-4
SLIDE 4

QML

  • A first-order functional language for quantum computations on

finite types

  • “Quantum Data and Control”
  • Based on strict linear logic - controlled, explicit, weakening
  • Types:
  • =
1 j
  • j
  • Terms:
t = x j let x = t in u j x ~ y j () j let (x ; y ) = t in u j (t ; u ) j if t then u else u j if Æ t then u else u j f () qfalse j () qtrue g ,
  • 2
C

Compiling a functional quantum programming language – p.4/15

slide-5
SLIDE 5

Deutsch algorithm

deuts h : 2 ( 2 ( Q 2 deuts h a b = let (x ; y ) = if Æ f qfalse j qtrue g then (qtrue ; if a then f qfalse j (1) qtrue g else f (1) qfalse j qtrue g else (qfalse ; if b then f (1) qfalse j qtrue g else f qfalse j (1) qtrue g in H x

Compiling a functional quantum programming language – p.5/15

slide-6
SLIDE 6

Control of Decoherence

  • Projection Function
  • 1
2 (2; 2) ! 2
  • 1
(x ; y ) = x 2 2 2
  • 1
  • Diagonal Function
Æ 2 2 ! (2; 2) Æ x = (x ; x ) x : 2
  • x
: 2 : 2
  • x
: 2

Compiling a functional quantum programming language – p.6/15

slide-7
SLIDE 7

Control of Decoherence

  • 1
:Æ : 2 ! 2 x : 2
  • x
: 2 : 2
  • Æ
  • 1
  • Classical Case:
2 2
  • Quantum Case:

Input =

f 1 p 2 j0i + 1 p 2 j1ig (equal superposition)

Output =

1 2 fj0ig + 1 2 fj1ig (probability distribution)

Decoherence! Not the identity function

Compiling a functional quantum programming language – p.7/15

slide-8
SLIDE 8

More Decoherence

  • for
get mentions x for get : 2 ( 2 for get x = if x then qtrue else qtrue
  • but doesn’t use it.
  • Hence, it has to measure it!
  • if always measures the conditional, returning only one branch

Compiling a functional quantum programming language – p.8/15

slide-9
SLIDE 9 if Æ
  • for
get : 2 ( 2 for get x = if Æ x then qtrue else qtrue
  • This program has a type error, because
qtrue 6? qtrue.
  • qnot
: 2 ( 2 qnot x = if Æ x then qfalse else qtrue
  • This program typechecks, because
qfalse ? qtrue.

Compiling a functional quantum programming language – p.9/15

slide-10
SLIDE 10

Compiler Design

  • Takes in QML expressions
  • Compiled into
F QC (Finite Quantum Computation) objects
  • a
b
  • h
g
  • = quantum circuit
  • Circuit represented as simple combinators
  • Can be directly simulated, or passed to any standard simulator
  • :
: : or a real quantum computer

Compiling a functional quantum programming language – p.10/15

slide-11
SLIDE 11

Quantum Machine Code

  • Quantum circuits of size
a 2 N , defined inductively
  • Sequential Composition (
Æ ) a
  • Parallel Composition (
  • )
a
  • b
  • Permutations (rewiring)
a
  • b
b
  • a

Compiling a functional quantum programming language – p.11/15

slide-12
SLIDE 12

Quantum Machine Code

  • Conditional Application (
j ) Q 2
  • X
  • X
a
  • Rotation ( rot
u, where u 2 2 ! 2 ! C is a unitary matrix) Q 2 r
  • t
u

Compiling a functional quantum programming language – p.12/15

slide-13
SLIDE 13

Compiling the let-rule

  • `
t :
  • ;
x :
  • `
u :
  • let
  • `
let x = t in u :
  • C
  • u
  • t
  • Compiling a functional quantum programming language – p.13/15
slide-14
SLIDE 14

Summary

  • QML is a first-order functional language for quantum

computations on finite types, with quantum control structures ( if

Æ)
  • Compiler into quantum circuits gives the operational semantics
  • Denotational semantics is given as ‘density matrices’ and ‘super
  • perators’
  • Future work:
  • Define equational theory, and show this conicides with

denotational sematics

  • Only small programs currently; we need bigger and better

examples

  • :
: :

Compiling a functional quantum programming language – p.14/15

slide-15
SLIDE 15

Thanks

  • Papers on QML can be found at:
  • www.cs.nott.ac.uk/ jjg/qml
  • Jonathan Grattage (jjg@cs.nott.ac.uk)

Compiling a functional quantum programming language – p.15/15