Title: Modeling Quantum Computing in Haskell
1Modeling Quantum Computing in Haskell
- Amr Sabry
- ???? ????
- Indiana University
2Our Abstractions are Broken!
- CS prides itself on the fact that it is
insensitive to the changes in the hardware and
its technology - Turing Machines, complexity classes, lambda
calculus, etc, were supposed to be perfect
abstractions - Changes in the model of physics (classical vs.
quantum) broke through our abstractions
3Turing 36 Deutsch 97
- Turing hoped that his abstracted-paper-tape
model was so simple, so transparent and well
defined, that it would not depend on any
assumptions about physics that could conceivably
be falsified, and therefore that it could become
the basis of an abstract theory of computation
that was independent of the underlying physics. - 'He thought,' as Feynman once put it,
'that he understood paper.' But he was mistaken.
Real, quantum-mechanical paper is wildly
different from the abstract stuff that the Turing
machine uses. The Turing machine is entirely
classical, and does not allow for the possibility
the paper might have different symbols written on
it in different universes, and that those might
interfere with one another.
-
- Computing is normally done by writing
certain symbols on paper. We may suppose this
paper is divided into squares like a childs
arithmetic book. - If we regard a symbol as literally printed
on a square we may suppose that the square is 0 lt
x lt 1, 0 lt y lt1. The symbol is defined as a set
of points in this square, viz. the set occupied
by printers ink.
4Challenge to PL Research
- Quantum physics is affecting hardware design,
complexity theory, and propagates all the way to
our high level programming languages - Develop a new appropriate programming
paradigm
5Outline
- Quantum data
- Operations/Functions
- I/O or Measurement
- Example --- Wave/Particle Duality
- Conclusions and Related Work
6Quantum Data
7Bits and Qubits
Examples of qubits
qFT
or
False
True
8Generalize
Given a type a with constructors C1, C2, ,
Cn Quantum values of type QV a
9Examples
10Pairs
- Pairs of type (QV a, QV b) No surprises
- Pairs of type QV (a, b) can be assembled from two
quantum values using a tensor product
11Non Compositionality and Entanglement
- There is no way to describe the state of the
pair p2 in terms of the state of its two
components. The values are ENTANGLED.
12Functions / Operations
13Two Simple Operations
14Controlled-Not (cnot)
cnot(c,v) (x,y) where x is always the same as
c if c is False, y v if c is True, y not v
cnotM
What is cnot (qFT,qF) ?
cnot(qFT,qF) the pair p2
15Our First Circuit
16Measurement
17Probabilities
- observe qFT should produce False with 50
probability and produce True with 50 probability - What happens if we observe a quantum value qFT
more than once?
18Collapse
- MUST return (True,True,True) or
(False,False,False) - Not allowed to produce (True,False,True) or any
other mixed values
19Observing Pairs
- Given a pair of type QV (a,b) we can make three
observations - Observe the state of the pair itself
- Observe the left component only
- Observe the right component only
20Observing Pairs
21The EPR Paradox
observeLeft must affect the right particle
Faster than light communication? Multiple
universes? Signals back from the future? Hidden
local state?
Spooky action at a distance. HOW?
22Spooky Action at a Distance ) Side-effects
23Wave/Particle Duality
24Lets Implement a Simple Example
- The individual operations are easy H is
hadamard, V and VT are phase-shifting operations - But given a generally entangled triple QV
(a,b,c), how can we conveniently apply an
operation on the first component, or the second
and third, or the first and third, etc given that
we cannot decompose the tuple into its three
components.
25Virtual Values Adaptors
Pointer to the real value
Adaptor
(c,a)
(a,b,c)
b
A quantum value with entangled subvalues
A virtual value to operate on the third and first
components
26Apply cnot to our virtual value
cnotM
- Promote cnotM to work on the full quantum value
as follows - Extract the required components using the
adaptor, apply cnot - Other components are left unchanged
Promoted cnotM
((a,b,c),(x,b,z)) cnotM((c,a),(z,x))
27Example
28Conclusions and Related Work
29Summary
- Quantum values are maps from classical values to
probability amplitudes (complex numbers) - Functions are matrices
- Observation causes collapse (modeled by
side-effects) - Programming without destructors
30A Lambda Calculus for QC by André van Tonder
- ?-calculus with (quantum) constants
- Uses sequences of terms (history) to make
reductions reversible - State a superposition of sequences
- To avoid having history terms entangled with
computational terms, functions are linear (cannot
discard superpositions) - No observation
- No datatypes still talks about qubits and gates
- Can use pattern-matching on entangled values!
31And of course