SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
Background Quantum Programming Languages Summary and Discussion
An Introduction to
Quantum Programming Languages
D. L. Yonge-Mallo
Programming Languages Group
University of Waterloo
April 20, 2006
Background Quantum Programming Languages Summary and Discussion
Motivation
Purpose of this talk:
• introduce programming languages for quantum computation,
• present a survey of developments in the field,
• try to answer some questions which programming language
researchers might have about the field.
How did this talk come about?
• the Quantum Information Processing course (CS 667),
• the Programming Languages Group (PLG),
• the PLG seminars1 organized by Prof. Ondřej Lhoták.
1
Schedule at http://plg.uwaterloo.ca/~olhotak/seminars.html.
Background Quantum Programming Languages Summary and Discussion
Motivation
Purpose of this talk:
• introduce programming languages for quantum computation,
• present a survey of developments in the field,
• try to answer some questions which programming language
researchers might have about the field.
How did this talk come about?
• the Quantum Information Processing course (CS 667),
• the Programming Languages Group (PLG),
• the PLG seminars1 organized by Prof. Ondřej Lhoták.
1
Schedule at http://plg.uwaterloo.ca/~olhotak/seminars.html.
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
A short history of quantum computation
Time line:
• 1982 – Feynman and Benioff independently suggest that
quantum mechanics can be harnessed to perform computation
• 1985 – Deutsch formulates quantum Turing machine
• 1994 – Shor shows that integer factorization and discrete
logarithm can be solved efficiently using a quantum computer
• 1995 – Grover speeds up database search
• . . .
At present:
• well-developed theory and many applications, but
• physical implementations still in early stages.
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
Basics of Quantum Computation
Classical computation:
• Boolean bit: either 0 or 1.
Quantum computation:
• Quantum bit: superposition of 0 and 1.
• Examples:
• photo polarization
• electron excitation levels
• Schrödinger’s cat
• . . .
• The computational model is an abstraction – the underlying
physical system doesn’t really matter.
Background Quantum Programming Languages Summary and Discussion
Quantum bits
A quantum bit (qubit) is:
|ψi = α0 |0i + α1 |1i
where:
• amplitudes α0 and α1 are complex numbers
• |αi|2 is the probability of measuring |ii
• measurement is “destructive”
• normalization constraint: |α0|2 + |α1|2 = 1
• |0i and |1i are the basis vectors in Dirac notation
Example
|ψi =
r
3
4
|0i +
r
1
4
|1i
Background Quantum Programming Languages Summary and Discussion
Multiple qubits
If we had 3 qubits:
|ψi = α000 |000i + . . . + α111 |111i
Quantum states:
• αi are complex and
P
i |αi|2 = 1.
• Basis vectors: |000i , |001i , . . . , |111i
• Vector: [α000, α001, . . . , α111]T
Compare to classical probabilistic states:
• pi ≥ 0 are real and
P
i pi = 1
• Vector: [p000, p001, . . . , p111]T
Background Quantum Programming Languages Summary and Discussion
Quantum states
Note the dimension of the vectors (and matrices) involved:
• |0i =

1
0

, |1i =

0
1

• |000i =












1
0
0
0
0
0
0
0












, |001i =












0
1
0
0
0
0
0
0












, . . . , |111i =












0
0
0
0
0
0
0
1












• The dimension is exponential in the size of the system.
Background Quantum Programming Languages Summary and Discussion
Measurement
Consider the 2-qubit system:
|ψi = α00 |00i + α01 |01i + α10 |10i + α11 |11i
If both qubits are measured:
• result is i ∈ {00, 01, 10, 11} with probability |αi|2
• the state collapses to |ii
If only the first qubit is measured:
• result is 0 with probability |α00|2 + |α01|2
• the state after the measurement becomes
|ψi =
α00 |00i + α01 |01i
p
|α00|2 + |α01|2
Background Quantum Programming Languages Summary and Discussion
Entanglement
If we had two non-interacting systems A and B, the state of the
composite system is:
|ψiA ⊗ |φiB
e.g.,
1
√
2
(|00i + |01i) = |0i ⊗
1
√
2
(|0i + |1i)
But consider the following state:
1
√
2
(|01i + |10i)
This state cannot be separated into the product form above. It is
said to be entangled2.
2
What does this do to a quantum type theory?
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
Quantum gates and circuits
Quantum algorithms are usually expressed using the formalism of
quantum gates. For example, we can define a quantum ‘not’ gate
as follows:
X ≡

0 1
1 0

It is not hard to see that:
X |0i =

0 1
1 0
 
1
0

=

0
1

= |1i
and
X |1i =

0 1
1 0
 
0
1

=

1
0

= |0i
Background Quantum Programming Languages Summary and Discussion
Quantum gates and circuits
Other examples of quantum gates include
1
l ≡

1 0
0 1

, H ≡
1
√
2

1 1
1 −1

,
Y ≡

0 −i
i 0

, Z ≡

1 0
0 −1

,
CNOT =




1 0 0 0
0 1 0 0
0 0 0 1
0 0 1 0




The three gates X, Y , and Z are known as the Pauli gates, while
1
l is the identity gate, H is the Hadamard gate, and CNOT is the
Controlled-NOT gate.
Background Quantum Programming Languages Summary and Discussion
Unitary matrices
Suppose |ψi =
P
i αi |ii, and we apply a gate U to |ψi to obtain:
ψ′
= U |ψi =
X
i
α′
i |ii
The normalization condition requires
P
i |α′
i|2 = 1. Quantum gates
also need to be reversible. In order to satisfy these conditions, the
matrix U needs to be unitary:
U†
U = 1
l
where U† is the adjoint of U.
Background Quantum Programming Languages Summary and Discussion
Quantum circuits
A quantum algorithm may be expressed by connecting quantum
gates together in the form of a quantum circuit.
|ψi • H
NM
✌
✌
✌ •
|0i 
 

NM
✌
✌
✌
|0i H • X Z |ψi
Figure: A quantum circuit, from [Nielsen and Chuang].
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
Typical quantum algorithms
A typical quantum algorithm has:
• quantum operations (usually specified by circuit diagrams)
• quantum data (qubits, quantum registers, scratch space)
• classical operations
• classical data
• control flow
What’s the best way to describe or specify such an algorithm?
• Traditionally: ad hoc manner using circuit diagrams
accompanied by a meta-level description of the high-level
control flow
• . . . ?
Background Quantum Programming Languages Summary and Discussion
Example: Shor’s factoring algorithm
Overall control flow of Shor’s factoring algorithm:
• read in an integer
• perform some classical tests and preparation
(turns factoring into order-finding)
• calls the quantum order-finding subroutine
• measures the result, and if successful, outputs the integer
The order-finding algorithm:
• circuit’s gates depend on size of the input
• uses the quantum Fourier transform
The quantum Fourier transform:
• is composed of smaller quantum gates
Background Quantum Programming Languages Summary and Discussion
Quantum Fourier transform
. . .
Rn−2 Rn−1
H R2
R2
H
H
Rn−1 Rn
H
.
.
.
.
.
.
|j1i
|j2i
|jni
|jn−1i
. . .
. . . . . . . . .
. . .
Figure: Circuit scheme for the quantum Fourier transform, from [Nielsen
and Chuang].
Background Quantum Programming Languages Summary and Discussion
Order-finding circuit
|0i FT†
|ji
xj
mod N
H
|1i
Figure: Quantum circuit for order-finding (and for Shor’s factoring
algorithm), from [Nielsen and Chuang].
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Shor’s factoring algorithm
Given a (composite) number N:
1. If N is even, return the factor 2.
2. Determine whether N = ab
for integers a ≥ 1 and b ≥ 2, and if so
return the factor a
3. Randomly choose x in the range 1 to N − 1. If gcd(x, N)  1 then
return the factor gcd(x, N).
4. Use the order-finding subroutine to find the order r of x modulo N.
5. If r is even and xr/2
6= −1(modN) then compute gcd(xr/2
− 1, N)
and gcd(xr/2
+ 1, N), and test to see if one of these is a non-trivial
factor, return that factor if so. Otherwise, the algorithm fails.
Background Quantum Programming Languages Summary and Discussion
Control flow of a quantum algorithm
classical
control
structure
machine state
reset
transformation
unitary
machine state
measure
measurement
evaluate
solution
found?
quantum
operations
yes
no
START
STOP
Figure: The basic outline of a simple quantum algorithm [Ömer 2002].
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
Classical vs. quantum computer programs
Classical programs:
• bits are 0s and 1s
• classical information can be copied
• code and data are both made of the same “stuff”
• programs are not (generally) reversible
Quantum operations:
• qubits are superpositions of 0s and 1s
• quantum information subject to “no cloning” property3
• unitaries (matrices) and states (vectors) are different things4
• quantum operations are reversible
3
What does this do to attempts at a quantum type theory?
4
What does this do to higher-order functions?
Background Quantum Programming Languages Summary and Discussion
Comparison of classical and quantum computation
classical concept quantum analog
classical machine model hybrid quantum architecture
variables quantum registers
subroutines unitary operators
argument and return types quantum data types
local variables scratch registers
dynamic memory scratch space management
boolean expressions quantum conditions
conditional execution conditional operators
selection quantum if-statement
conditional loops quantum forking
none inverse execution of operators
none quantum measurement
Table: A comparison between classical and quantum concepts related to
programming languages [Ömer 2002].
Background Quantum Programming Languages Summary and Discussion
Advantages of using a high-level language
Easy of use:
• easier to write code than to draw circuits
• both data and control flow expressed in one language
• natural to express both classical and quantum parts of
algorithm in the same way
• automatically handle resource allocation
• simulation becomes possible
• can manipulate data types other than qubits
Background Quantum Programming Languages Summary and Discussion
Advantages of using a high-level language
Extensibility:
• portable and hardware-independent
• encourages re-use and modularity
• library of routines for instances of the hidden subgroup
problem, such as order-finding and discrete logarithm
• frequently used subcircuits such as Fourier transform
• many quantum algorithms have blocks or steps which are
repeated
• facilitates the development and refinement of algorithms,
allows modifications and variants to be tested
Reliability:
• Error-checking, type-checking, model-checking, etc.
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
A survey of the field
Virtual hardware models:
• Quantum circuit model
• QRAM model of [Knill 1996], guidelines for pseudo-code
A QRAM machine consists of a classical RAM machine hooked up
to a quantum subsystem.
quantum operations
hardware and
Classical
software
resources
Quantum
measurement results
Figure: A simplified scheme of a QRAM machine. (Based on figures in
[Ömer 2002] and [Bettelli et al. 2001].)
Background Quantum Programming Languages Summary and Discussion
The QRAM model
The classical RAM machine:
• is general-purpose
• carries out purely classical operations
• handles program flow
• performs pre- and post-processing of data for the quantum
subsystem
The quantum subsystem:
• is treated as a black box
• is assumed to have an array of addressable quantum bits
• capable of only two operations
• unitary transformations
• measurements
Background Quantum Programming Languages Summary and Discussion
Imperative quantum programming languages
QCL (Quantum Computation Language) [Ömer 1998]:
• high-level hardware-independent procedural language
• interpreted, and has a simulator
• combines classical sublanguage with quantum features such as
quantum data types and scrap space management
Example
. . .
Rn−2 Rn−1
H R2
R2
H
H
Rn−1 Rn
H
.
.
.
.
.
.
|j1i
|j2i
|jni
|jn−1i
. . .
. . . . . . . . .
. . .
Figure: Recall the Quantum Fourier transform.
Background Quantum Programming Languages Summary and Discussion
Quantum Fourier transform in QCL
The rest of Shor’s factoring algorithm can likewise be programmed
in QCL. Simulation is possible once the algorithm has been coded.
operator dft(qureg q) { // main operator
const n=#q; // set n to length of input
int i; int j; // declare loop counters
for i=0 to n-1 {
for j=0 to i-1 { // apply conditional phase gates
CPhase(2*pi/2^(i-j+1),q[n-i-1]  q[n-j-1]);
}
Mix(q[n-i-1]); // qubit rotation
}
flip(q); // swap bit order of the output
}
Table: The quantum Fourier transform expressed in QCL [Ömer 1998].
Background Quantum Programming Languages Summary and Discussion
Imperative quantum programming languages
qGCL [Sanders and Zuliani 2000]:
• based on Dijsktra’s guarded command language
• has a formal semantics
• suitable for systematic program derivation and verification
Q (extension of C++) [Bettelli et al. 2001]
• combines general purpose classical language with a set of
quantum primitives: quantum operators, register
management, measurement, etc.
• treats quantum operators as objects which can be explicitly
constructed and manipulated at run-time
• implemented as a C++ library
• some details of a compilation scheme
Background Quantum Programming Languages Summary and Discussion
Functional quantum programming langauges
QFC (Quantum Flow Charts) [Selinger 2002]:
• statically typed with two basic data types, bits and qubits
• has high-level features such as loops, recursive procedures,
structured data types
• assigns an operator to each program fragment
• syntax and semantics described by means of flow charts
• flow charts connect physical and programming languages
views of quantum computation
• no run-time type checks or errors
• loops and recursion are interpreted as least fixpoints
Background Quantum Programming Languages Summary and Discussion
Quantum Flow Charts
0 1
Γ = A + B
measure q
q : qbit, Γ =

A B
C D

q : qbit, Γ =

0 0
0 D

Γ = 0
Γ = B
Unitary transformation:
Allocate qbit:
Γ = A
q : qbit, Γ =

A 0
0 0

Γ = A
q : qbit, Γ =

A 0
0 0

Initial: Permutation:
q1, . . . , qn : qbit = (aij)ij
qφ(1), . . . , qφ(n) : qbit = (a2φ(i),2φ(j))ij
permute φ
q : qbit, Γ = A
q ∗ = S
q : qbit, Γ = (S ⊗ 1
l)A(S ⊗ 1
l)†
discard q
q : qbit, Γ =

A B
C D

Γ = A + D
Discard qbit:
Measurement:
Merge:
new qbit q := |0i
Figure: Rules for quantum flow charts [Selinger 2002].
Background Quantum Programming Languages Summary and Discussion
Quantum Flow Charts
0 1
output p, q : qbit
p ∗ = N
q ∗ = N
measure p
p, q : qbit =

A B
C D

p, q : qbit =

0 0
0 D

p, q : qbit =

D 0
0 0

p, q : qbit =

NAN†
+ D 0
0 0

p, q : qbit =

NAN†
0
0 0

p, q : qbit =

A 0
0 0

input p, q : qbit
Figure: A simple quantum flow chart [Selinger 2002].
Background Quantum Programming Languages Summary and Discussion
Loops in Quantum Flow Charts
(*)
(**) · · ·
X
· · ·
Figure: A loop in a quantum flow chart [Selinger 2002].
In the above, X is an arbitrary flow chart fragment with n + 1
incoming edges and m + 1 outgoing edges. Thus, excluding the
loop, X has n incoming and n outgoing edges.
Background Quantum Programming Languages Summary and Discussion
Unwinding the loop
(*)
(**)
X
X
X
F21(A)
F22F21(A)
F22F22F21(A)
G(A)
A
F11(A) + F12F21(A)
F11(A)
.
.
.
.
.
.
Figure: Unwinding the loop [Selinger 2002].
The state at the edge (or tuple of edges) labeled (**) is given by
the infinite sum:
G(A) = F11(A) +
∞
X
i=0
F12(Fi
22(F21(A)))
Background Quantum Programming Languages Summary and Discussion
Extensions of the λ-calculus
Various extensions of the λ-calculus:
• λq-calculus [Maymin 1996]:
• incorporates distribution of terms
• terms may be represented negatively in distributions
• quantum λ-calculus [Van Tonder 2004]
• simulator written in Scheme
• QML [Altenkirch Grattage 2005]
• control, as well as data, may be quantum
• compiler written in Haskell
• typed quantum λ-calculus [Selinger and Valiron 2005]
• based on classical control and quantum data
There are other approaches, but I don’t have time in this talk to
discuss them.
Background Quantum Programming Languages Summary and Discussion
Compilation issues
Software architecture proposal [Svore, Cross, Aho, Chuang, Markov
2004]:
• defines a suite of tools
• proposal for compilation in two stages
• source high-level language translated into an intermediate
quantum assembly language
• high-level language has complex data and control structures
• intermediate language works on qubits and unitaries
QML [Altenkirch Grattage 2005]
• compiler for QML into a representation of quantum circuits
Background Quantum Programming Languages Summary and Discussion
Outline
Background
Motivation
Quantum states
Quantum gates and circuits
Quantum Programming Languages
Typical quantum algorithms
Comparison between classical and quantum programs
A survey of the field
Summary and Discussion
Some questions answered
Background Quantum Programming Languages Summary and Discussion
Summary: Recall the comparison
classical concept quantum analog
classical machine model hybrid quantum architecture
variables quantum registers
subroutines unitary operators
argument and return types quantum data types
local variables scratch registers
dynamic memory scratch space management
boolean expressions quantum conditions
conditional execution conditional operators
selection quantum if-statement
conditional loops quantum forking
none inverse execution of operators
none quantum measurement
Table: A comparison between classical and quantum concepts related to
programming languages [Ömer 2002].
Background Quantum Programming Languages Summary and Discussion
Discussion
Many aspects of quantum programming languages remain
unexplored:
• use of more complicated quantum data types
• development of high-level quantum control structures
• formal semantics for higher-order quantum programming
languages, including classical features and measurement
Limited access to hardware means:
• design of simulators and compilers
• need to anticipate and develop techniques that will work over
a range of technology
Background Quantum Programming Languages Summary and Discussion
Some questions answered. . . ?
Thanks!
Thanks to everyone who sent in their questions!
Questions about quantum programming language research:
1. What are quantum programming languages? How are they
different from conventional ones?
2. What are the hard problems to be solved in quantum
programming languages?
3. What is the difficulty in devising quantum algorithms?
4. And can specialized languages or tools (compilers or
simulators) alleviate the difficulty?
5. How can programming language expertise contribute to
quantum computing?
Background Quantum Programming Languages Summary and Discussion
Some questions answered. . . ?
Basic questions about quantum computation:
1. What are the quantum analogues of bits, tuples, arrays, lists,
trees, etc.?
2. What are the quantum versions of loops, if-statements, etc.?
3. What are the core primitives and abstraction mechanisms for
quantum computing?
4. Do qubits have types?
5. What kinds of functions on qubits can and cannot be written?
Background Quantum Programming Languages Summary and Discussion
Some questions answered. . . ?
Questions about quantum algorithms:
1. What is a typical quantum algorithm?
2. Is any particular conventional programming paradigm better
suited than others for quantum computing?
3. Are we likely to see very large quantum programs in the
future?
4. Or is quantum computing likely to consist of short pieces of
quantum operations for very specific tasks primarily controlled
by a non-quantum program?
Background Quantum Programming Languages Summary and Discussion
Some questions answered. . . ?
Questions about compilers and related issues:
1. Can we build libraries of quantum abstractions?
2. Is it possible to “link” a classical program with a quantum
program?
3. Does it make sense to talk about things like memory
allocation and garbage collection in reference to qubits?
Background Quantum Programming Languages Summary and Discussion
Looking towards the future
A major problem in quantum computing is a lack of unifying
principles for developing new quantum algorithms.
The promotion of abstractions and high-level concepts may reveal
new ways to analyze and view existing algorithms.
But it’s not yet clear which abstractions are useful. Hence the need
for research in quantum programming languages.
Background Quantum Programming Languages Summary and Discussion
Bibliography
The following two survey papers together give a thorough and
relatively up-to-date coverage of research in the field of quantum
programming languages:
Simon Gay.
Quantum programming languages: Survey and bibliography.
http://www.dcs.gla.ac.uk/~simon/quantum, 2005.
Accessed: 2006-04-20.
Peter Selinger.
A Brief Survey of Quantum Programming Languages.
In Proceedings of the 7th International Symposium on
Functional and Logic Programming (FLOPS ’04), Nara,
Japan, 2004.

Contenu connexe

Similaire à An Introduction to Quantum Programming Languages

Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsGanesh Solanke
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptxShaistaRiaz4
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)Antonin Hoskovec
 
QX Simulator and quantum programming - 2020-04-28
QX Simulator and quantum programming - 2020-04-28QX Simulator and quantum programming - 2020-04-28
QX Simulator and quantum programming - 2020-04-28Aritra Sarkar
 
support-vector-machines.ppt
support-vector-machines.pptsupport-vector-machines.ppt
support-vector-machines.pptshyedshahriar
 
An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)ananth
 
Multimodal Learning Analytics
Multimodal Learning AnalyticsMultimodal Learning Analytics
Multimodal Learning AnalyticsXavier Ochoa
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesSreedhar Chowdam
 
Queuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depthQueuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depthIdcIdk1
 
Computability and Complexity
Computability and ComplexityComputability and Complexity
Computability and ComplexityEdward Blurock
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 

Similaire à An Introduction to Quantum Programming Languages (20)

Lecture1
Lecture1Lecture1
Lecture1
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
 
QC-UNIT 2.ppt
QC-UNIT 2.pptQC-UNIT 2.ppt
QC-UNIT 2.ppt
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)
 
QX Simulator and quantum programming - 2020-04-28
QX Simulator and quantum programming - 2020-04-28QX Simulator and quantum programming - 2020-04-28
QX Simulator and quantum programming - 2020-04-28
 
Quantum Computation For AI
Quantum Computation For AIQuantum Computation For AI
Quantum Computation For AI
 
support-vector-machines.ppt
support-vector-machines.pptsupport-vector-machines.ppt
support-vector-machines.ppt
 
An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)
 
Analysis.ppt
Analysis.pptAnalysis.ppt
Analysis.ppt
 
Calculus
CalculusCalculus
Calculus
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Chap12 slides
Chap12 slidesChap12 slides
Chap12 slides
 
Multimodal Learning Analytics
Multimodal Learning AnalyticsMultimodal Learning Analytics
Multimodal Learning Analytics
 
Lecture 1 (bce-7)
Lecture   1 (bce-7)Lecture   1 (bce-7)
Lecture 1 (bce-7)
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
Queuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depthQueuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depth
 
Computability and Complexity
Computability and ComplexityComputability and Complexity
Computability and Complexity
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 

Dernier

dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...
dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...
dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...dkNET
 
In-pond Race way systems for Aquaculture (IPRS).pptx
In-pond Race way systems for Aquaculture (IPRS).pptxIn-pond Race way systems for Aquaculture (IPRS).pptx
In-pond Race way systems for Aquaculture (IPRS).pptxMAGOTI ERNEST
 
Continuum emission from within the plunging region of black hole discs
Continuum emission from within the plunging region of black hole discsContinuum emission from within the plunging region of black hole discs
Continuum emission from within the plunging region of black hole discsSérgio Sacani
 
GBSN - Microbiology (Unit 6) Human and Microbial interaction
GBSN - Microbiology (Unit 6) Human and Microbial interactionGBSN - Microbiology (Unit 6) Human and Microbial interaction
GBSN - Microbiology (Unit 6) Human and Microbial interactionAreesha Ahmad
 
The Scientific names of some important families of Industrial plants .pdf
The Scientific names of some important families of Industrial plants .pdfThe Scientific names of some important families of Industrial plants .pdf
The Scientific names of some important families of Industrial plants .pdfMohamed Said
 
Mining Activity and Investment Opportunity in Myanmar.pptx
Mining Activity and Investment Opportunity in Myanmar.pptxMining Activity and Investment Opportunity in Myanmar.pptx
Mining Activity and Investment Opportunity in Myanmar.pptxKyawThanTint
 
Isolation of AMF by wet sieving and decantation method pptx
Isolation of AMF by wet sieving and decantation method pptxIsolation of AMF by wet sieving and decantation method pptx
Isolation of AMF by wet sieving and decantation method pptxGOWTHAMIM22
 
MODERN PHYSICS_REPORTING_QUANTA_.....pdf
MODERN PHYSICS_REPORTING_QUANTA_.....pdfMODERN PHYSICS_REPORTING_QUANTA_.....pdf
MODERN PHYSICS_REPORTING_QUANTA_.....pdfRevenJadePalma
 
Lubrication System in forced feed system
Lubrication System in forced feed systemLubrication System in forced feed system
Lubrication System in forced feed systemADB online India
 
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...Sahil Suleman
 
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptx
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptxSaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptx
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptxPat (JS) Heslop-Harrison
 
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 Rp
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 RpWASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 Rp
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 RpSérgio Sacani
 
Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloChristian Robert
 
Tuberculosis (TB)-Notes.pdf microbiology notes
Tuberculosis (TB)-Notes.pdf microbiology notesTuberculosis (TB)-Notes.pdf microbiology notes
Tuberculosis (TB)-Notes.pdf microbiology notesjyothisaisri
 
EU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfEU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfStart Project
 
NUMERICAL Proof Of TIme Electron Theory.
NUMERICAL Proof Of TIme Electron Theory.NUMERICAL Proof Of TIme Electron Theory.
NUMERICAL Proof Of TIme Electron Theory.syedmuneemqadri
 
RACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxRACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxArunLakshmiMeenakshi
 
Plasma proteins_ Dr.Muralinath_Dr.c. kalyan
Plasma proteins_ Dr.Muralinath_Dr.c. kalyanPlasma proteins_ Dr.Muralinath_Dr.c. kalyan
Plasma proteins_ Dr.Muralinath_Dr.c. kalyanmuralinath2
 
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)kushbuR
 

Dernier (20)

dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...
dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...
dkNET Webinar: The 4DN Data Portal - Data, Resources and Tools to Help Elucid...
 
In-pond Race way systems for Aquaculture (IPRS).pptx
In-pond Race way systems for Aquaculture (IPRS).pptxIn-pond Race way systems for Aquaculture (IPRS).pptx
In-pond Race way systems for Aquaculture (IPRS).pptx
 
Continuum emission from within the plunging region of black hole discs
Continuum emission from within the plunging region of black hole discsContinuum emission from within the plunging region of black hole discs
Continuum emission from within the plunging region of black hole discs
 
GBSN - Microbiology (Unit 6) Human and Microbial interaction
GBSN - Microbiology (Unit 6) Human and Microbial interactionGBSN - Microbiology (Unit 6) Human and Microbial interaction
GBSN - Microbiology (Unit 6) Human and Microbial interaction
 
The Scientific names of some important families of Industrial plants .pdf
The Scientific names of some important families of Industrial plants .pdfThe Scientific names of some important families of Industrial plants .pdf
The Scientific names of some important families of Industrial plants .pdf
 
Mining Activity and Investment Opportunity in Myanmar.pptx
Mining Activity and Investment Opportunity in Myanmar.pptxMining Activity and Investment Opportunity in Myanmar.pptx
Mining Activity and Investment Opportunity in Myanmar.pptx
 
Isolation of AMF by wet sieving and decantation method pptx
Isolation of AMF by wet sieving and decantation method pptxIsolation of AMF by wet sieving and decantation method pptx
Isolation of AMF by wet sieving and decantation method pptx
 
MODERN PHYSICS_REPORTING_QUANTA_.....pdf
MODERN PHYSICS_REPORTING_QUANTA_.....pdfMODERN PHYSICS_REPORTING_QUANTA_.....pdf
MODERN PHYSICS_REPORTING_QUANTA_.....pdf
 
Lubrication System in forced feed system
Lubrication System in forced feed systemLubrication System in forced feed system
Lubrication System in forced feed system
 
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...
Alternative method of dissolution in-vitro in-vivo correlation and dissolutio...
 
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptx
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptxSaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptx
SaffronCrocusGenomicsThessalonikiOnlineMay2024TalkOnline.pptx
 
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 Rp
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 RpWASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 Rp
WASP-69b’s Escaping Envelope Is Confined to a Tail Extending at Least 7 Rp
 
Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte Carlo
 
Tuberculosis (TB)-Notes.pdf microbiology notes
Tuberculosis (TB)-Notes.pdf microbiology notesTuberculosis (TB)-Notes.pdf microbiology notes
Tuberculosis (TB)-Notes.pdf microbiology notes
 
EU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfEU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdf
 
NUMERICAL Proof Of TIme Electron Theory.
NUMERICAL Proof Of TIme Electron Theory.NUMERICAL Proof Of TIme Electron Theory.
NUMERICAL Proof Of TIme Electron Theory.
 
RACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxRACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptx
 
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
Chemistry Data Delivery from the US-EPA Center for Computational Toxicology a...
 
Plasma proteins_ Dr.Muralinath_Dr.c. kalyan
Plasma proteins_ Dr.Muralinath_Dr.c. kalyanPlasma proteins_ Dr.Muralinath_Dr.c. kalyan
Plasma proteins_ Dr.Muralinath_Dr.c. kalyan
 
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
 

An Introduction to Quantum Programming Languages

  • 1. Background Quantum Programming Languages Summary and Discussion An Introduction to Quantum Programming Languages D. L. Yonge-Mallo Programming Languages Group University of Waterloo April 20, 2006
  • 2. Background Quantum Programming Languages Summary and Discussion Motivation Purpose of this talk: • introduce programming languages for quantum computation, • present a survey of developments in the field, • try to answer some questions which programming language researchers might have about the field. How did this talk come about? • the Quantum Information Processing course (CS 667), • the Programming Languages Group (PLG), • the PLG seminars1 organized by Prof. Ondřej Lhoták. 1 Schedule at http://plg.uwaterloo.ca/~olhotak/seminars.html.
  • 3. Background Quantum Programming Languages Summary and Discussion Motivation Purpose of this talk: • introduce programming languages for quantum computation, • present a survey of developments in the field, • try to answer some questions which programming language researchers might have about the field. How did this talk come about? • the Quantum Information Processing course (CS 667), • the Programming Languages Group (PLG), • the PLG seminars1 organized by Prof. Ondřej Lhoták. 1 Schedule at http://plg.uwaterloo.ca/~olhotak/seminars.html.
  • 4. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 5. Background Quantum Programming Languages Summary and Discussion A short history of quantum computation Time line: • 1982 – Feynman and Benioff independently suggest that quantum mechanics can be harnessed to perform computation • 1985 – Deutsch formulates quantum Turing machine • 1994 – Shor shows that integer factorization and discrete logarithm can be solved efficiently using a quantum computer • 1995 – Grover speeds up database search • . . . At present: • well-developed theory and many applications, but • physical implementations still in early stages.
  • 6. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 7. Background Quantum Programming Languages Summary and Discussion Basics of Quantum Computation Classical computation: • Boolean bit: either 0 or 1. Quantum computation: • Quantum bit: superposition of 0 and 1. • Examples: • photo polarization • electron excitation levels • Schrödinger’s cat • . . . • The computational model is an abstraction – the underlying physical system doesn’t really matter.
  • 8. Background Quantum Programming Languages Summary and Discussion Quantum bits A quantum bit (qubit) is: |ψi = α0 |0i + α1 |1i where: • amplitudes α0 and α1 are complex numbers • |αi|2 is the probability of measuring |ii • measurement is “destructive” • normalization constraint: |α0|2 + |α1|2 = 1 • |0i and |1i are the basis vectors in Dirac notation Example |ψi = r 3 4 |0i + r 1 4 |1i
  • 9. Background Quantum Programming Languages Summary and Discussion Multiple qubits If we had 3 qubits: |ψi = α000 |000i + . . . + α111 |111i Quantum states: • αi are complex and P i |αi|2 = 1. • Basis vectors: |000i , |001i , . . . , |111i • Vector: [α000, α001, . . . , α111]T Compare to classical probabilistic states: • pi ≥ 0 are real and P i pi = 1 • Vector: [p000, p001, . . . , p111]T
  • 10. Background Quantum Programming Languages Summary and Discussion Quantum states Note the dimension of the vectors (and matrices) involved: • |0i = 1 0 , |1i = 0 1 • |000i =             1 0 0 0 0 0 0 0             , |001i =             0 1 0 0 0 0 0 0             , . . . , |111i =             0 0 0 0 0 0 0 1             • The dimension is exponential in the size of the system.
  • 11. Background Quantum Programming Languages Summary and Discussion Measurement Consider the 2-qubit system: |ψi = α00 |00i + α01 |01i + α10 |10i + α11 |11i If both qubits are measured: • result is i ∈ {00, 01, 10, 11} with probability |αi|2 • the state collapses to |ii If only the first qubit is measured: • result is 0 with probability |α00|2 + |α01|2 • the state after the measurement becomes |ψi = α00 |00i + α01 |01i p |α00|2 + |α01|2
  • 12. Background Quantum Programming Languages Summary and Discussion Entanglement If we had two non-interacting systems A and B, the state of the composite system is: |ψiA ⊗ |φiB e.g., 1 √ 2 (|00i + |01i) = |0i ⊗ 1 √ 2 (|0i + |1i) But consider the following state: 1 √ 2 (|01i + |10i) This state cannot be separated into the product form above. It is said to be entangled2. 2 What does this do to a quantum type theory?
  • 13. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 14. Background Quantum Programming Languages Summary and Discussion Quantum gates and circuits Quantum algorithms are usually expressed using the formalism of quantum gates. For example, we can define a quantum ‘not’ gate as follows: X ≡ 0 1 1 0 It is not hard to see that: X |0i = 0 1 1 0 1 0 = 0 1 = |1i and X |1i = 0 1 1 0 0 1 = 1 0 = |0i
  • 15. Background Quantum Programming Languages Summary and Discussion Quantum gates and circuits Other examples of quantum gates include 1 l ≡ 1 0 0 1 , H ≡ 1 √ 2 1 1 1 −1 , Y ≡ 0 −i i 0 , Z ≡ 1 0 0 −1 , CNOT =     1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0     The three gates X, Y , and Z are known as the Pauli gates, while 1 l is the identity gate, H is the Hadamard gate, and CNOT is the Controlled-NOT gate.
  • 16. Background Quantum Programming Languages Summary and Discussion Unitary matrices Suppose |ψi = P i αi |ii, and we apply a gate U to |ψi to obtain: ψ′ = U |ψi = X i α′ i |ii The normalization condition requires P i |α′ i|2 = 1. Quantum gates also need to be reversible. In order to satisfy these conditions, the matrix U needs to be unitary: U† U = 1 l where U† is the adjoint of U.
  • 17. Background Quantum Programming Languages Summary and Discussion Quantum circuits A quantum algorithm may be expressed by connecting quantum gates together in the form of a quantum circuit. |ψi • H NM ✌ ✌ ✌ • |0i NM ✌ ✌ ✌ |0i H • X Z |ψi Figure: A quantum circuit, from [Nielsen and Chuang].
  • 18. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 19. Background Quantum Programming Languages Summary and Discussion Typical quantum algorithms A typical quantum algorithm has: • quantum operations (usually specified by circuit diagrams) • quantum data (qubits, quantum registers, scratch space) • classical operations • classical data • control flow What’s the best way to describe or specify such an algorithm? • Traditionally: ad hoc manner using circuit diagrams accompanied by a meta-level description of the high-level control flow • . . . ?
  • 20. Background Quantum Programming Languages Summary and Discussion Example: Shor’s factoring algorithm Overall control flow of Shor’s factoring algorithm: • read in an integer • perform some classical tests and preparation (turns factoring into order-finding) • calls the quantum order-finding subroutine • measures the result, and if successful, outputs the integer The order-finding algorithm: • circuit’s gates depend on size of the input • uses the quantum Fourier transform The quantum Fourier transform: • is composed of smaller quantum gates
  • 21. Background Quantum Programming Languages Summary and Discussion Quantum Fourier transform . . . Rn−2 Rn−1 H R2 R2 H H Rn−1 Rn H . . . . . . |j1i |j2i |jni |jn−1i . . . . . . . . . . . . . . . Figure: Circuit scheme for the quantum Fourier transform, from [Nielsen and Chuang].
  • 22. Background Quantum Programming Languages Summary and Discussion Order-finding circuit |0i FT† |ji xj mod N H |1i Figure: Quantum circuit for order-finding (and for Shor’s factoring algorithm), from [Nielsen and Chuang].
  • 23. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 24. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 25. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 26. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 27. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 28. Background Quantum Programming Languages Summary and Discussion Shor’s factoring algorithm Given a (composite) number N: 1. If N is even, return the factor 2. 2. Determine whether N = ab for integers a ≥ 1 and b ≥ 2, and if so return the factor a 3. Randomly choose x in the range 1 to N − 1. If gcd(x, N) 1 then return the factor gcd(x, N). 4. Use the order-finding subroutine to find the order r of x modulo N. 5. If r is even and xr/2 6= −1(modN) then compute gcd(xr/2 − 1, N) and gcd(xr/2 + 1, N), and test to see if one of these is a non-trivial factor, return that factor if so. Otherwise, the algorithm fails.
  • 29. Background Quantum Programming Languages Summary and Discussion Control flow of a quantum algorithm classical control structure machine state reset transformation unitary machine state measure measurement evaluate solution found? quantum operations yes no START STOP Figure: The basic outline of a simple quantum algorithm [Ömer 2002].
  • 30. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 31. Background Quantum Programming Languages Summary and Discussion Classical vs. quantum computer programs Classical programs: • bits are 0s and 1s • classical information can be copied • code and data are both made of the same “stuff” • programs are not (generally) reversible Quantum operations: • qubits are superpositions of 0s and 1s • quantum information subject to “no cloning” property3 • unitaries (matrices) and states (vectors) are different things4 • quantum operations are reversible 3 What does this do to attempts at a quantum type theory? 4 What does this do to higher-order functions?
  • 32. Background Quantum Programming Languages Summary and Discussion Comparison of classical and quantum computation classical concept quantum analog classical machine model hybrid quantum architecture variables quantum registers subroutines unitary operators argument and return types quantum data types local variables scratch registers dynamic memory scratch space management boolean expressions quantum conditions conditional execution conditional operators selection quantum if-statement conditional loops quantum forking none inverse execution of operators none quantum measurement Table: A comparison between classical and quantum concepts related to programming languages [Ömer 2002].
  • 33. Background Quantum Programming Languages Summary and Discussion Advantages of using a high-level language Easy of use: • easier to write code than to draw circuits • both data and control flow expressed in one language • natural to express both classical and quantum parts of algorithm in the same way • automatically handle resource allocation • simulation becomes possible • can manipulate data types other than qubits
  • 34. Background Quantum Programming Languages Summary and Discussion Advantages of using a high-level language Extensibility: • portable and hardware-independent • encourages re-use and modularity • library of routines for instances of the hidden subgroup problem, such as order-finding and discrete logarithm • frequently used subcircuits such as Fourier transform • many quantum algorithms have blocks or steps which are repeated • facilitates the development and refinement of algorithms, allows modifications and variants to be tested Reliability: • Error-checking, type-checking, model-checking, etc.
  • 35. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 36. Background Quantum Programming Languages Summary and Discussion A survey of the field Virtual hardware models: • Quantum circuit model • QRAM model of [Knill 1996], guidelines for pseudo-code A QRAM machine consists of a classical RAM machine hooked up to a quantum subsystem. quantum operations hardware and Classical software resources Quantum measurement results Figure: A simplified scheme of a QRAM machine. (Based on figures in [Ömer 2002] and [Bettelli et al. 2001].)
  • 37. Background Quantum Programming Languages Summary and Discussion The QRAM model The classical RAM machine: • is general-purpose • carries out purely classical operations • handles program flow • performs pre- and post-processing of data for the quantum subsystem The quantum subsystem: • is treated as a black box • is assumed to have an array of addressable quantum bits • capable of only two operations • unitary transformations • measurements
  • 38. Background Quantum Programming Languages Summary and Discussion Imperative quantum programming languages QCL (Quantum Computation Language) [Ömer 1998]: • high-level hardware-independent procedural language • interpreted, and has a simulator • combines classical sublanguage with quantum features such as quantum data types and scrap space management Example . . . Rn−2 Rn−1 H R2 R2 H H Rn−1 Rn H . . . . . . |j1i |j2i |jni |jn−1i . . . . . . . . . . . . . . . Figure: Recall the Quantum Fourier transform.
  • 39. Background Quantum Programming Languages Summary and Discussion Quantum Fourier transform in QCL The rest of Shor’s factoring algorithm can likewise be programmed in QCL. Simulation is possible once the algorithm has been coded. operator dft(qureg q) { // main operator const n=#q; // set n to length of input int i; int j; // declare loop counters for i=0 to n-1 { for j=0 to i-1 { // apply conditional phase gates CPhase(2*pi/2^(i-j+1),q[n-i-1] q[n-j-1]); } Mix(q[n-i-1]); // qubit rotation } flip(q); // swap bit order of the output } Table: The quantum Fourier transform expressed in QCL [Ömer 1998].
  • 40. Background Quantum Programming Languages Summary and Discussion Imperative quantum programming languages qGCL [Sanders and Zuliani 2000]: • based on Dijsktra’s guarded command language • has a formal semantics • suitable for systematic program derivation and verification Q (extension of C++) [Bettelli et al. 2001] • combines general purpose classical language with a set of quantum primitives: quantum operators, register management, measurement, etc. • treats quantum operators as objects which can be explicitly constructed and manipulated at run-time • implemented as a C++ library • some details of a compilation scheme
  • 41. Background Quantum Programming Languages Summary and Discussion Functional quantum programming langauges QFC (Quantum Flow Charts) [Selinger 2002]: • statically typed with two basic data types, bits and qubits • has high-level features such as loops, recursive procedures, structured data types • assigns an operator to each program fragment • syntax and semantics described by means of flow charts • flow charts connect physical and programming languages views of quantum computation • no run-time type checks or errors • loops and recursion are interpreted as least fixpoints
  • 42. Background Quantum Programming Languages Summary and Discussion Quantum Flow Charts 0 1 Γ = A + B measure q q : qbit, Γ = A B C D q : qbit, Γ = 0 0 0 D Γ = 0 Γ = B Unitary transformation: Allocate qbit: Γ = A q : qbit, Γ = A 0 0 0 Γ = A q : qbit, Γ = A 0 0 0 Initial: Permutation: q1, . . . , qn : qbit = (aij)ij qφ(1), . . . , qφ(n) : qbit = (a2φ(i),2φ(j))ij permute φ q : qbit, Γ = A q ∗ = S q : qbit, Γ = (S ⊗ 1 l)A(S ⊗ 1 l)† discard q q : qbit, Γ = A B C D Γ = A + D Discard qbit: Measurement: Merge: new qbit q := |0i Figure: Rules for quantum flow charts [Selinger 2002].
  • 43. Background Quantum Programming Languages Summary and Discussion Quantum Flow Charts 0 1 output p, q : qbit p ∗ = N q ∗ = N measure p p, q : qbit = A B C D p, q : qbit = 0 0 0 D p, q : qbit = D 0 0 0 p, q : qbit = NAN† + D 0 0 0 p, q : qbit = NAN† 0 0 0 p, q : qbit = A 0 0 0 input p, q : qbit Figure: A simple quantum flow chart [Selinger 2002].
  • 44. Background Quantum Programming Languages Summary and Discussion Loops in Quantum Flow Charts (*) (**) · · · X · · · Figure: A loop in a quantum flow chart [Selinger 2002]. In the above, X is an arbitrary flow chart fragment with n + 1 incoming edges and m + 1 outgoing edges. Thus, excluding the loop, X has n incoming and n outgoing edges.
  • 45. Background Quantum Programming Languages Summary and Discussion Unwinding the loop (*) (**) X X X F21(A) F22F21(A) F22F22F21(A) G(A) A F11(A) + F12F21(A) F11(A) . . . . . . Figure: Unwinding the loop [Selinger 2002]. The state at the edge (or tuple of edges) labeled (**) is given by the infinite sum: G(A) = F11(A) + ∞ X i=0 F12(Fi 22(F21(A)))
  • 46. Background Quantum Programming Languages Summary and Discussion Extensions of the λ-calculus Various extensions of the λ-calculus: • λq-calculus [Maymin 1996]: • incorporates distribution of terms • terms may be represented negatively in distributions • quantum λ-calculus [Van Tonder 2004] • simulator written in Scheme • QML [Altenkirch Grattage 2005] • control, as well as data, may be quantum • compiler written in Haskell • typed quantum λ-calculus [Selinger and Valiron 2005] • based on classical control and quantum data There are other approaches, but I don’t have time in this talk to discuss them.
  • 47. Background Quantum Programming Languages Summary and Discussion Compilation issues Software architecture proposal [Svore, Cross, Aho, Chuang, Markov 2004]: • defines a suite of tools • proposal for compilation in two stages • source high-level language translated into an intermediate quantum assembly language • high-level language has complex data and control structures • intermediate language works on qubits and unitaries QML [Altenkirch Grattage 2005] • compiler for QML into a representation of quantum circuits
  • 48. Background Quantum Programming Languages Summary and Discussion Outline Background Motivation Quantum states Quantum gates and circuits Quantum Programming Languages Typical quantum algorithms Comparison between classical and quantum programs A survey of the field Summary and Discussion Some questions answered
  • 49. Background Quantum Programming Languages Summary and Discussion Summary: Recall the comparison classical concept quantum analog classical machine model hybrid quantum architecture variables quantum registers subroutines unitary operators argument and return types quantum data types local variables scratch registers dynamic memory scratch space management boolean expressions quantum conditions conditional execution conditional operators selection quantum if-statement conditional loops quantum forking none inverse execution of operators none quantum measurement Table: A comparison between classical and quantum concepts related to programming languages [Ömer 2002].
  • 50. Background Quantum Programming Languages Summary and Discussion Discussion Many aspects of quantum programming languages remain unexplored: • use of more complicated quantum data types • development of high-level quantum control structures • formal semantics for higher-order quantum programming languages, including classical features and measurement Limited access to hardware means: • design of simulators and compilers • need to anticipate and develop techniques that will work over a range of technology
  • 51. Background Quantum Programming Languages Summary and Discussion Some questions answered. . . ? Thanks! Thanks to everyone who sent in their questions! Questions about quantum programming language research: 1. What are quantum programming languages? How are they different from conventional ones? 2. What are the hard problems to be solved in quantum programming languages? 3. What is the difficulty in devising quantum algorithms? 4. And can specialized languages or tools (compilers or simulators) alleviate the difficulty? 5. How can programming language expertise contribute to quantum computing?
  • 52. Background Quantum Programming Languages Summary and Discussion Some questions answered. . . ? Basic questions about quantum computation: 1. What are the quantum analogues of bits, tuples, arrays, lists, trees, etc.? 2. What are the quantum versions of loops, if-statements, etc.? 3. What are the core primitives and abstraction mechanisms for quantum computing? 4. Do qubits have types? 5. What kinds of functions on qubits can and cannot be written?
  • 53. Background Quantum Programming Languages Summary and Discussion Some questions answered. . . ? Questions about quantum algorithms: 1. What is a typical quantum algorithm? 2. Is any particular conventional programming paradigm better suited than others for quantum computing? 3. Are we likely to see very large quantum programs in the future? 4. Or is quantum computing likely to consist of short pieces of quantum operations for very specific tasks primarily controlled by a non-quantum program?
  • 54. Background Quantum Programming Languages Summary and Discussion Some questions answered. . . ? Questions about compilers and related issues: 1. Can we build libraries of quantum abstractions? 2. Is it possible to “link” a classical program with a quantum program? 3. Does it make sense to talk about things like memory allocation and garbage collection in reference to qubits?
  • 55. Background Quantum Programming Languages Summary and Discussion Looking towards the future A major problem in quantum computing is a lack of unifying principles for developing new quantum algorithms. The promotion of abstractions and high-level concepts may reveal new ways to analyze and view existing algorithms. But it’s not yet clear which abstractions are useful. Hence the need for research in quantum programming languages.
  • 56. Background Quantum Programming Languages Summary and Discussion Bibliography The following two survey papers together give a thorough and relatively up-to-date coverage of research in the field of quantum programming languages: Simon Gay. Quantum programming languages: Survey and bibliography. http://www.dcs.gla.ac.uk/~simon/quantum, 2005. Accessed: 2006-04-20. Peter Selinger. A Brief Survey of Quantum Programming Languages. In Proceedings of the 7th International Symposium on Functional and Logic Programming (FLOPS ’04), Nara, Japan, 2004.