1 / 44

Modeling Quantum Computing in Haskell

Modeling Quantum Computing in Haskell. Amr Sabry عمرو صبرى Indiana University. Our Abstractions are Broken!. CS prides itself on the fact that it is insensitive to the changes in the hardware and its technology

faraji
Download Presentation

Modeling Quantum Computing in Haskell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Modeling Quantum Computing in Haskell Amr Sabry عمرو صبرى Indiana University

  2. Our 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 Haskell Workshop

  3. Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child’s arithmetic book…. If we regard a symbol as literally printed on a square we may suppose that the square is 0 < x < 1, 0 < y <1. The symbol is defined as a set of points in this square, viz. the set occupied by printers ink. Turing ‘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. Haskell Workshop

  4. Challenge 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 Haskell Workshop

  5. Outline • Quantum data • Operations/Functions • I/O or Measurement • Example --- Wave/Particle Duality • Conclusions and Related Work Haskell Workshop

  6. Quantum Data

  7. qT = qF = 0 1 False False 1 0 True True 1 False 1 True Bits and Qubits Examples of qubits qFT = or False True Haskell Workshop

  8. 1 C1 2 C2 … … n Cn Generalize Given a type a with constructors C1, C2, …, Cn Quantum values of type QV a Haskell Workshop

  9. Examples Haskell Workshop

  10. 1 q2 = False 1 2 q1 = False True 1 * 1 q1 &* q2 = (False,False) 2 True (False,True) 1 * 2 2 * 1 (True,False) (True,True) 2 * 2 Pairs • 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: Haskell Workshop

  11. Non 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. Haskell Workshop

  12. Functions / Operations

  13. What is hadamard qF? Two Simple Operations Haskell Workshop

  14. x c v y not ((False,False),(False,False)) 1 ((False, True),(False, True)) 1 ((True, False),(True, True)) 1 ((True, True),(True, False)) 1 Controlled-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 Haskell Workshop

  15. qF hadamard not qF Our First Circuit Haskell Workshop

  16. Measurement

  17. Probabilities • 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? Haskell Workshop

  18. Collapse • MUST return (True,True,True) or (False,False,False) • Not allowed to produce (True,False,True) or any other mixed values Haskell Workshop

  19. Observing 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 Haskell Workshop

  20. Observing Pairs Haskell Workshop

  21. Entangled particles Light-years apart The EPR Paradox observeLeft must affect the right particle Spooky action at a distance. HOW? Faster than light communication? Multiple universes? Signals back from the future? Hidden local state? Haskell Workshop

  22. Spooky Action at a Distance ) Side-effects Haskell Workshop

  23. Wave/Particle Duality

  24. Let’s 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. Haskell Workshop

  25. 1 (False,False,False) (True,True,True) 1 Virtual 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 Haskell Workshop

  26. ((False,False),(False,False)) 1 ((False, True),(False, True)) 1 ((True, False),(True, True)) 1 ((True, True),(True, False)) 1 Apply 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)) Haskell Workshop

  27. Example Haskell Workshop

  28. Conclusions and Related Work

  29. Summary • 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 Haskell Workshop

  30. A 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! Haskell Workshop

  31. And of course … Jerzy Karczmarczuk Haskell Workshop

  32. BBC World on SAS flight • It is a bizarre place … • … normal laws of physics break … • … the fastest machine today will seem like an abacus … Haskell Workshop

  33. Computer Science Functional Programming, lambda calculus, etc Assembly, C, etc Hardware Physics Haskell Workshop

  34. Matrix Representation Haskell Workshop

  35. Conventions in Physics • Quantum values represented by a vector of probability amplitudes (in some implicit order) • Quantum operations represented by matrices giving for each input constructor its contribution to each output constructor • Applying an operation to a value is multiplication Haskell Workshop

  36. Potential Rewards • Nature’s programming paradigm might be better than what we have. • Information flow in QM is a mystery (EPR paradox). An executable semantics for QC might help. • There are some appealing connections between quantum computing and functional programming (operations must be pure and reversible, evaluation is different from observation, quantum values cannot be cloned i.e. are linear, etc) • comp.lang.functional discussion about free will and predestination  Haskell Workshop

  37. Bits and Qubits Haskell Workshop

  38. Generalize Haskell Workshop

  39. Pairs • 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: Haskell Workshop

  40. Virtual Values & Adaptors Virtual Value 1 Adaptor 2 Quantum value with entangled subvalues Haskell Workshop

  41. Promote the function Function Applying Operations to Virtual Values Input Output Haskell Workshop

  42. Examples Haskell Workshop

  43. Observing Pairs (I) Haskell Workshop

  44. Accessing Substructures • In conventional programming: composable references, façade pattern, … • In quantum computing: virtual registers, shuffle wires, or our proposal of virtual values and adaptors Haskell Workshop

More Related