Top Banner
An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington
30

An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

An Algebraic Foundation for Quantum Programming Languages

Andrew Petersen &

Mark Oskin

Department of Computer Science

The University of Washington

Page 2: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

The Quantum Divide

Advances in Quantum Hardware

• 7-bit computers created• Silicon devices proposed• Solid-state bits entangled• Photons teleported

Stagnation in Quantum Software

• Few new algorithms discovered• Little discussion of higher level languages

Page 3: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

What is the Problem?

• No more quantum algorithms exist…?

• We’re just not smart enough…?

• No representation developed for computing– Traditional notations describe physical systems

• Dirac notation: describes system state

• Matrix notation: represents system evolution

– Enabling computation requires more• Assist in guiding systems to “interesting” states

• Support reasoning about system evolution

Page 4: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

ObjectiveDevelop an alternative notation for quantum computing

• Representation: dealing with groups of bits is hard– Ensure operations are insensitive to state space size– Introduce shorthand for common entangled states– Facilitate computation on large, highly entangled states

• Reasoning: interesting states are difficult to identify– Identify quantum properties explicitly– Define operations by the quantum properties they induce– Favor local transformations over global ones

• Not a language … yet

Page 5: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Qubits: Quantum BitsBits and qubits both have two states: 0 and 1

• Superposition:

A qubit may be in both states simultaneously

• Phase:

A qubit may have a negative quantity of a state

• Entanglement:

Multiple qubits may share a single state

Page 6: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Dirac Notation: a Qubit

|q> = |0> + |1>

Superposition

Probability AmplitudeState

Page 7: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Matrix Notation: a Qubit

Probability Amplitudefor State 0

Probability Amplitudefor State 1

Page 8: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Representing Qubit Systems

|p,q> = |00> + |01> + |10> + |11>

Amplitude for 00Amplitude for 01Amplitude for 10Amplitude for 11

Page 9: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

The New Algebra: a Qubit

10 qqq k

Name Weight

StateSuperposition

Unit of Phase

Page 10: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

The New Algebra: Operators

• Superposition: +– Identity exists: xy + 0 = xy

– Inverses exist: xy + (-1) xy = 0

• Association: *– Identity exists: 1 xy = xy xy = xy

– xy xz = 0 for y z

• Other axioms hold for both operators– Associativity and commutativity of + and *– Distributivity of * over +

10 qq

10qp

Page 11: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Association and Entanglement

Unentangled(a)

Entangled(b)

)( 1000100 ppqqpqp

0

1

0

1

2

1

1

0

0

1

2

1

qpqpqp |1100

Unentangled(a)

Entangled(b)

00011011

Distributivity reveals the lack of entanglement.

Page 12: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Weight and Phase in the Algebra

• Concepts of weight and phase separated– Weights are positive real values– Phases are complex values

• State probabilities are easy to compute120 31 qqq

n

Page 13: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Phase and Interference

• Fundamental unit of phase introduced– Phase is manipulated in discrete increments– –

• Addition simulates phase interactions01010 2))1(()( qqqqqq

1,1 2*202 nn

nikk e 2/*

Page 14: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Matrix Notation: Procedures

Procedures are represented as matrices• Larger state spaces require larger matrices• The effect of the matrix may not be apparent

11

11H

1010

0101

1010

0101

1H

1100

1100

0011

0011

2H

Page 15: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

The New Algebra: Procedures

newstateoldstate

definitionparametersname

on

)(

||: 11 newpatternoldpatterndefinition

Computation is performed via pattern matching:

A procedure has four parts:

...||: 22 newpatternoldpattern

Page 16: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Example: The Hadamard Gate

)( pHadamard 101100 :||: pppppp

Name Parameter Definition

Initial State Transformed State

Page 17: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Computation in the New Algebra

1. ConsolidateAssociate the states of all arguments

2. MatchFind affected patterns and replace them

3. Simplify

101100 :||:)( pppppppH 1100 qpqpon

110010 )()( qppqpp

Page 18: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Example: Controlled Not

• Expressions can contain wild-cards

• Patterns can call other procedures

0110

1100

:||:)(

)(:||:),(

pppppNot

qNotpqpqpqpqpCNot xxxx

Page 19: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

An Example: EPR PairsIn matrix notation:

qpqpqp

qpponqpCNot

ppponpH

qqqubit

pqubit p

|

)(),(

)(

1100

010

100

0

0

1

0

0

1

2

1

0

1

0

1

2

1

0100

1000

0010

0001

0

1

0

1

2

1

0

1

1

1

2

1

0

1,

1

1

2

1

0

1

11

11

2

1

0

1,

0

1

In the algebra:

Page 20: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Universality and Illegal States

The algebra is complete and expressive– All legal operations can be defined (Boykin et al.)

– All legal states can be expressed

– Illegal states cannot be reached using legal gates

1100

1100

101100

n

:||:)(

)(:||:),(

:||:)(

qqqqqT

qNotpqpqpqpqpCNot

qqqqqqqHxxxx

Page 21: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Negation

Represents all states not present

xUx x

111000

0

qpqpqpy

px

01

1

qpy

px

111101111011

0011110101010001

1110011010100010

1100010010000000

trqptrqptrqp

trqptrqptrqptrqp

trqptrqptrqptrqp

trqptrqptrqptrqpz

1001 trqpz

Page 22: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Computing on Negations

Computation may be performed directly1. Add all the cases of the gate being applied

2. Apply the gate to the negated state

3. Subtract the result from 2) from 1)

11)( qponpH

0100

11101000 22

qpqp

qpqpqpqp

)))(()(( 101010 qqpppp 110 )( qpp

Page 23: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Example: Grover’s Algorithm

• Fast search algorithm

• The desired solution is designated with a hat

• An Oracle is required– Adds a negative phase to the desired solutions

• A PhaseFlip operation is needed– Adds a negative phase to all non-zero states

Page 24: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Example: Grover Iteration

)...()1()...))(1(2(

)1()...(2 }

)(

{

ˆ)1(ˆˆ)(

{ )ˆˆ1 ][(

01

001

0

ˆ01

0

pprppr

Urpp

pH

pforall

prUprppOracle

prpasnpationGroverIter

nnn

Pn

n

i

i

P

Page 25: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Example: Grover Iteration

pr

rpr

prUr

pH

pforall

Urppr

pprpprpPhaseFlip

nn

nPn

i

i

Pn

n

nnn

ˆ)2

12(ˆ)

2

11(}

ˆ)1(2))1(22(}

)(

{

)1()...))(1(22(

)...()1()...))(1(2( )(

11

ˆ01

0

01

001

0

Page 26: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Summary

• Explicit indicators of quantum properties– Superposition operator +– Basic unit of phase – Entanglement via distributivity

• Support for computing on large systems– Size-independent procedures– Focus on local transformations

• Methods for reasoning about entangled states– Symmetric entanglement operator |– Computation on negations

Page 27: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Future Work

• Reasoning about phase is still difficult– A compact representation for complex phases is needed– Weight and phase interactions may be further formalized

• Types could be used to enforce constraints– Separate quantum and classical types would properly

restrict interactions– Linear types would prevent copying of state

• User studies will indicate problem areas• Our final goal is a language implementation

Page 28: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Questions?

Page 29: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Previous Work• Quantum circuits (Deutsch, Yao)

Circuit representation with state annotations

• QCL (Ömer) Imperative language based on defining matrices

• qGCL (Sanders and Zuliani)Probabilistic language featuring a refinement calculus

• Quantum C++ (Bertelli)C++ with quantum operations defined as data structures

• Block-QPL (Selinger)A functional, graph-based computational model

Page 30: An Algebraic Foundation for Quantum Programming Languages Andrew Petersen & Mark Oskin Department of Computer Science The University of Washington.

Grover’s Algorithm

)1(2 ,ˆˆ}

)1(2 ,ˆˆ

)1(2 ,ˆˆ}

ˆ)2

12(ˆ)

2

11()(

{ 1)n( 1

ˆˆ))...((}

:||:)(

{

...][

{ ) (

n

n

n

11

10

00

10

101100

01

0

rprp

rprpMeasure(p)

rprp

pr

rpr

pationGroverIter

toifor

ppUpppp

pppppppH

pforall

ppnpqubit

nvalGrover

nn

pnn

iiiiiii

i

n