skip to main content

Twist: sound reasoning for purity and entanglement in Quantum programs

Published:12 January 2022Publication History
Skip Abstract Section

Abstract

Quantum programming languages enable developers to implement algorithms for quantum computers that promise computational breakthroughs in classically intractable tasks. Programming quantum computers requires awareness of entanglement, the phenomenon in which measurement outcomes of qubits are correlated. Entanglement can determine the correctness of algorithms and suitability of programming patterns.

In this work, we formalize purity as a central tool for automating reasoning about entanglement in quantum programs. A pure expression is one whose evaluation is unaffected by the measurement outcomes of qubits that it does not own, implying freedom from entanglement with any other expression in the computation.

We present Twist, the first language that features a type system for sound reasoning about purity. The type system enables the developer to identify pure expressions using type annotations. Twist also features purity assertion operators that state the absence of entanglement in the output of quantum gates. To soundly check these assertions, Twist uses a combination of static analysis and runtime verification.

We evaluate Twist’s type system and analyses on a benchmark suite of quantum programs in simulation, demonstrating that Twist can express quantum algorithms, catch programming errors in them, and support programs that existing languages disallow, while incurring runtime verification overhead of less than 3.5%.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

Appendices of paper.

References

  1. Héctor Abraham. 2019. Qiskit: An Open-source Framework for Quantum Computing.Google ScholarGoogle Scholar
  2. T. Altenkirch and J. Grattage. 2005. A Functional Quantum Programming Language. In IEEE Symposium on Logic in Computer Science. https://doi.org/10.1109/LICS.2005.1 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Matthew Amy, Martin Roetteler, and Krysta M. Svore. 2017. Verified Compilation of Space-Efficient Reversible Circuits. In Computer Aided Verification.Google ScholarGoogle Scholar
  4. Hiroo Azuma. 2017. An entangling-probe attack on Shor’s algorithm for factorization. Journal of Modern Optics, 65, 4 (2017), Nov, https://doi.org/10.1080/09500340.2017.1397221 Google ScholarGoogle ScholarCross RefCross Ref
  5. Gilles Barthe, Justin Hsu, and Kevin Liao. 2020. A Probabilistic Separation Logic. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3371123 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Gilles Barthe, Justin Hsu, Mingsheng Ying, Nengkun Yu, and Li Zhou. 2019. Relational Proofs for Quantum Programs. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3371089 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. S. Bell. 1964. On the Einstein Podolsky Rosen paradox. Physics, 1 (1964), Nov, https://doi.org/10.1103/PhysicsPhysiqueFizika.1.195 Google ScholarGoogle ScholarCross RefCross Ref
  8. Charles H. Bennett and Gilles Brassard. 2014. Quantum cryptography: Public key distribution and coin tossing. Theoretical Computer Science, 560 (2014), https://doi.org/10.1016/j.tcs.2014.05.025 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Charles H. Bennett, Gilles Brassard, Claude Crépeau, Richard Jozsa, Asher Peres, and William K. Wootters. 1993. Teleporting an unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels. Phys. Rev. Lett., 70 (1993), Mar, https://doi.org/10.1103/PhysRevLett.70.1895 Google ScholarGoogle ScholarCross RefCross Ref
  10. Jacob Biamonte, Peter Wittek, Nicola Pancotti, Patrick Rebentrost, Nathan Wiebe, and Seth Lloyd. 2017. Quantum machine learning. Nature, 549, 7671 (2017), Sep, https://doi.org/10.1038/nature23474 Google ScholarGoogle Scholar
  11. Benjamin Bichsel, Maximilian Baader, Timon Gehr, and Martin Vechev. 2020. Silq: A High-Level Quantum Language with Safe Uncomputation and Intuitive Semantics. In ACM SIGPLAN Conference on Programming Language Design and Implementation. https://doi.org/10.1145/3385412.3386007 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Richard Bornat, Cristiano Calcagno, Peter O’Hearn, and Matthew Parkinson. 2005. Permission Accounting in Separation Logic. In Symposium on Principles of Programming Languages. https://doi.org/10.1145/1047659.1040327 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. John Boyland. 2003. Checking Interference with Fractional Permissions. In International Symposium on Static Analysis. https://doi.org/10.1007/3-540-44898-5_4 Google ScholarGoogle ScholarCross RefCross Ref
  14. Harry Buhrman, Richard Cleve, John Watrous, and Ronald de Wolf. 2001. Quantum Fingerprinting. Phys. Rev. Lett., 87 (2001), Sep, https://doi.org/10.1103/PhysRevLett.87.167902 Google ScholarGoogle ScholarCross RefCross Ref
  15. A. R. Calderbank and Peter W. Shor. 1996. Good quantum error-correcting codes exist. Physical Review A, 54, 2 (1996), Aug, https://doi.org/10.1103/PhysRevA.54.1098 Google ScholarGoogle ScholarCross RefCross Ref
  16. Andrew M. Childs, Dmitri Maslov, Yunseong Nam, Neil J. Ross, and Yuan Su. 2018. Toward the first quantum simulation with quantum speedup. Proceedings of the National Academy of Sciences, 115, 38 (2018), https://doi.org/10.1073/pnas.1801723115 Google ScholarGoogle ScholarCross RefCross Ref
  17. Pierre Clairambault and Marc de Visme. 2019. Full Abstraction for the Quantum Lambda-Calculus. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3371131 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. D. Coppersmith. 1994. An approximate Fourier transform useful in quantum factoring.Google ScholarGoogle Scholar
  19. David Deutsch. 1992. Rapid Solution of Problems by Quantum Computation. Proceedings of the Royal Society of London: Mathematical and Physical Sciences, 439, 1907 (1992), https://doi.org/10.1098/rspa.1992.0167 Google ScholarGoogle ScholarCross RefCross Ref
  20. Simon J. Gay, Rajagopal Nagarajan, and Nikolaos Papanikolaou. 2008. QMC: A Model Checker for Quantum Systems. In International Conference on Computer Aided Verification. https://doi.org/10.1007/978-3-540-70545-1_51 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Vlad Gheorghiu. 2018. Quantum++: A modern C++ quantum computing library. PLOS ONE, 13, 12 (2018), Dec, https://doi.org/10.1371/journal.pone.0208073 Google ScholarGoogle ScholarCross RefCross Ref
  22. Olivier Giraud. 2007. Distribution of Bipartite Entanglement for Random Pure States. Journal of Physics A: Mathematical and Theoretical, 40, 11 (2007), Feb., https://doi.org/10.1088/1751-8113/40/11/014 Google ScholarGoogle ScholarCross RefCross Ref
  23. G. H. Golub and C. Reinsch. 1970. Singular Value Decomposition and Least Squares Solutions. Numer. Math., 14, 5 (1970), April, https://doi.org/10.1007/BF02163027 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Daniel Gottesman and Isaac L. Chuang. 1999. Demonstrating the viability of universal quantum computation using teleportation and single-qubit operations. Nature, 402, 6760 (1999), Nov, https://doi.org/10.1038/46503 Google ScholarGoogle ScholarCross RefCross Ref
  25. Alexander S. Green, Peter LeFanu Lumsdaine, Neil J. Ross, Peter Selinger, and Benoît Valiron. 2013. Quipper: A Scalable Quantum Programming Language. In ACM SIGPLAN Conference on Programming Language Design and Implementation. https://doi.org/10.1145/2491956.2462177 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Daniel M. Greenberger, Michael A. Horne, and Anton Zeilinger. 1989. Going Beyond Bell’s Theorem. Springer Netherlands, Dordrecht. https://doi.org/10.1007/978-94-017-0849-4_10 Google ScholarGoogle ScholarCross RefCross Ref
  27. Lov K. Grover. 1996. A Fast Quantum Mechanical Algorithm for Database Search. In ACM Symposium on Theory of Computing. https://doi.org/10.1145/237814.237866 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Leonid Gurvits. 2003. Classical deterministic complexity of Edmonds’ problem and Quantum Entanglement. In ACM Symposium on Theory of Computing. https://doi.org/10.1145/780542.780545 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. A. Haar. 1933. Der Massbegriff in der Theorie der Kontinuierlichen Gruppen. Annals of Mathematics, 34 (1933), https://doi.org/10.2307/1968346 Google ScholarGoogle ScholarCross RefCross Ref
  30. Thomas Häner, Torsten Hoefler, and Matthias Troyer. 2020. Assertion-based Optimization of Quantum Programs. In ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications. https://doi.org/10.1145/3428201 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Aram W. Harrow and Ashley Montanaro. 2013. Testing Product States, Quantum Merlin-Arthur Games and Tensor Optimization. J. ACM, 60, 1 (2013), Article 3, Feb., https://doi.org/10.1145/2432622.2432625 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Patrick Hayden, Kevin Milner, and Mark M. Wilde. 2014. Two-Message Quantum Interactive Proofs and the Quantum Separability Problem. Quantum Info. Comput., 14, 5-6 (2014), April, https://doi.org/10.5555/2638661.2638663Google ScholarGoogle Scholar
  33. Stefan Heule, K. Rustan M. Leino, Peter Müller, and Alexander J. Summers. 2011. Fractional Permissions without the Fractions. In Workshop on Formal Techniques for Java-Like Programs. https://doi.org/10.1145/2076674.2076675 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Kesha Hietala, Robert Rand, Shih-Han Hung, Xiaodi Wu, and Michael Hicks. 2021. A Verified Optimizer for Quantum Circuits. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3434318 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. K. Honda. 2015. Analysis of Quantum Entanglement in Quantum Programs using Stabilizer Formalism. In QPL. https://doi.org/10.4204/EPTCS.195.19 Google ScholarGoogle ScholarCross RefCross Ref
  36. Michał Horodecki, Paweł Horodecki, and Ryszard Horodecki. 1996. Separability of mixed states: necessary and sufficient conditions. Physics Letters A, 223, 1-2 (1996), Nov, https://doi.org/10.1016/S0375-9601(96)00706-2 Google ScholarGoogle ScholarCross RefCross Ref
  37. Yipeng Huang and Margaret Martonosi. 2019. Statistical Assertions for Validating Patterns and Finding Bugs in Quantum Programs. In International Symposium on Computer Architecture. https://doi.org/10.1145/3307650.3322213 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Shih-Han Hung, Kesha Hietala, Shaopeng Zhu, Mingsheng Ying, Michael Hicks, and Xiaodi Wu. 2019. Quantitative Robustness Analysis of Quantum Programs. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3290344 Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Ali JavadiAbhari, Shruti Patil, Daniel Kudrow, Jeff Heckey, Alexey Lvov, Frederic T. Chong, and Margaret Martonosi. 2014. ScaffCC: A Framework for Compilation and Analysis of Quantum Computing Programs. In ACM Conference on Computing Frontiers. https://doi.org/10.1145/2597917.2597939 Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Richard Jozsa and Noah Linden. 2003. On the role of entanglement in quantum-computational speed-up. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 459, 2036 (2003), Aug, https://doi.org/10.1098/rspa.2002.1097 Google ScholarGoogle ScholarCross RefCross Ref
  41. Ivan Kassal, James D. Whitfield, Alejandro Perdomo-Ortiz, Man-Hong Yung, and Alán Aspuru-Guzik. 2011. Simulating Chemistry Using Quantum Computers. Annual Review of Physical Chemistry, 62, 1 (2011), https://doi.org/10.1146/annurev-physchem-032210-103512 Google ScholarGoogle ScholarCross RefCross Ref
  42. A. Yu. Kitaev. 1997. Quantum computations: algorithms and error correction. Russian Mathematical Surveys, 52, 6 (1997), dec, https://doi.org/10.1070/RM1997V052N06ABEH002155 Google ScholarGoogle ScholarCross RefCross Ref
  43. E Knill. 1996. Conventions for quantum pseudocode.Google ScholarGoogle ScholarCross RefCross Ref
  44. Abhijeet Kumar, Saeed Haddadi, Mohammad Pourkarimi, Bikash Behera, and Prasanta Panigrahi. 2020. Experimental realization of controlled quantum teleportation of arbitrary qubit states via cluster states. Scientific Reports, 10 (2020), 08, https://doi.org/10.1038/s41598-020-70446-8 Google ScholarGoogle ScholarCross RefCross Ref
  45. Gushu Li, Li Zhou, Nengkun Yu, Yufei Ding, Mingsheng Ying, and Yuan Xie. 2020. Projection-Based Runtime Assertions for Testing and Debugging Quantum Programs. In ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications. https://doi.org/10.1145/3428218 Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Ji Liu and Huiyang Zhou. 2021. Systematic Approaches for Precise and Approximate Quantum State Runtime Assertion. In IEEE International Symposium on High-Performance Computer Architecture. https://doi.org/10.1109/HPCA51647.2021.00025 Google ScholarGoogle ScholarCross RefCross Ref
  47. Hoi-Kwong Lo and H.F. Chau. 1998. Why quantum bit commitment and ideal quantum coin tossing are impossible. Physica D: Nonlinear Phenomena, 120, 1-2 (1998), Sep, https://doi.org/10.1016/S0167-2789(98)00053-0 Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Igor L. Markov and Mehdi Saeedi. 2012. Constant-Optimized Quantum Circuits for Modular Multiplication and Exponentiation. Quantum Info. Comput., 12, 5-6 (2012), May.Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Warner A. Miller, Grigoriy Kreymerman, Christopher Tison, P. Alsing, and Jonathan McDonald. 2011. Quantum computing in a piece of glass. In SPIE - The International Society for Optical Engineering. https://doi.org/10.1117/12.883332 Google ScholarGoogle ScholarCross RefCross Ref
  50. Michael A. Nielsen and Isaac L. Chuang. 2010. Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Anouk Paradis, Benjamin Bichsel, Samuel Steffen, and Martin Vechev. 2021. Unqomp: Synthesizing Uncomputation in Quantum Circuits. In ACM SIGPLAN Conference on Programming Language Design and Implementation. https://doi.org/10.1145/3453483.3454040 Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. A. Pati and S. Braunstein. 2000. Impossibility of deleting an unknown quantum state. Nature, 404 (2000), https://doi.org/10.1038/404130b0 Google ScholarGoogle ScholarCross RefCross Ref
  53. Jennifer Paykin, Robert Rand, and Steve Zdancewic. 2017. QWIRE: A Core Language for Quantum Circuits. In ACM SIGPLAN Symposium on Principles of Programming Languages. https://doi.org/10.1145/3009837.3009894 Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Simon Perdrix. 2005. Quantum Patterns and Types for Entanglement and Separability. In International Workshop on Quantum Programming Languages. https://doi.org/10.1016/j.entcs.2006.12.015 Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Simon Perdrix. 2008. Quantum Entanglement Analysis Based on Abstract Interpretation. In International Symposium on Static Analysis. https://doi.org/10.1007/978-3-540-69166-2_18 Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Frédéric Prost and Chaouki Zerrari. 2009. Reasoning about Entanglement and Separability in Quantum Higher-Order Functions. Unconventional Computation, https://doi.org/10.1007/978-3-642-03745-0_25 Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Robert Rand, Jennifer Paykin, Dong-Ho Lee, and Steve Zdancewic. 2019. ReQWIRE: Reasoning about Reversible Quantum Circuits. Electronic Proceedings in Theoretical Computer Science, 287 (2019), Jan, https://doi.org/10.4204/EPTCS.287.17 Google ScholarGoogle ScholarCross RefCross Ref
  58. Robert Rand, Aarthi Sundaram, Kartik Singhal, and Brad Lackey. 2021. Extending Gottesman Types Beyond the Clifford Group. In Workshop on Programming Languages for Quantum Computing.Google ScholarGoogle Scholar
  59. Robert Rand, Aarthi Sundaram, Kartik Singhal, and Brad Lackey. 2021. Static Analysis of Quantum Programs via Gottesman Types. arxiv:2101.08939.Google ScholarGoogle Scholar
  60. Mathys Rennela and Sam Staton. 2017. Classical Control, Quantum Circuits and Linear Logic in Enriched Category Theory. In Conference on Mathematical Foundations of Programming Semantics. https://doi.org/10.23638/LMCS-16(1:30)2020 Google ScholarGoogle ScholarCross RefCross Ref
  61. J.C. Reynolds. 2002. Separation logic: a logic for shared mutable data structures. In IEEE Symposium on Logic in Computer Science. https://doi.org/10.1109/LICS.2002.1029817 Google ScholarGoogle ScholarCross RefCross Ref
  62. E. Schmidt. 1907. Zur Theorie der linearen und nichtlinearen Integralgleichungen. Math. Ann., 63 (1907), https://doi.org/10.1007/BF01449770 Google ScholarGoogle ScholarCross RefCross Ref
  63. Peter Selinger. 2004. Towards a quantum programming language. Mathematical Structures in Computer Science, 14 (2004), 08, https://doi.org/10.1017/S0960129504004256 Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Peter Selinger and Benoît Valiron. 2005. A Lambda Calculus for Quantum Computation with Classical Control. Typed Lambda Calculi and Applications, https://doi.org/10.1017/S0960129506005238 Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. Yunong Shi, Runzhou Tao, Xupeng Li, Ali Javadi-Abhari, Andrew W. Cross, Frederic T. Chong, and Ronghui Gu. 2020. CertiQ: A Mostly-automated Verification of a Realistic Quantum Compiler. arxiv:1908.08963.Google ScholarGoogle Scholar
  66. Peter W. Shor. 1997. Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. SIAM J. Comput., 26, 5 (1997), Oct, https://doi.org/10.1137/S0097539795293172 Google ScholarGoogle ScholarDigital LibraryDigital Library
  67. Kartik Singhal. 2020. Quantum Hoare Type Theory. arxiv:2012.02154.Google ScholarGoogle Scholar
  68. Kohei Suenaga and Naoki Kobayashi. 2009. Fractional Ownerships for Safe Memory Deallocation. In Asian Symposium on Programming Languages and Systems. https://doi.org/10.1007/978-3-642-10672-9_11 Google ScholarGoogle ScholarDigital LibraryDigital Library
  69. Krysta Svore, Martin Roetteler, Alan Geller, Matthias Troyer, John Azariah, Christopher Granade, Bettina Heim, Vadym Kliuchnikov, Mariia Mykhailova, and Andres Paz. 2018. Q#: Enabling Scalable Quantum Computing and Development with a High-level DSL. In Real World Domain Specific Languages Workshop. https://doi.org/10.1145/3183895.3183901 Google ScholarGoogle ScholarDigital LibraryDigital Library
  70. Runzhou Tao, Yunong Shi, Jianan Yao, John Hui, Frederic T. Chong, and Ronghui Gu. 2021. Gleipnir: Toward Practical Error Analysis for Quantum Programs. In ACM SIGPLAN Conference on Programming Language Design and Implementation. https://doi.org/10.1145/3453483.3454029 Google ScholarGoogle ScholarDigital LibraryDigital Library
  71. Dominique Unruh. 2019. Quantum Hoare Logic with Ghost Variables. In IEEE Symposium on Logic in Computer Science. https://doi.org/10.1109/LICS.2019.8785779 Google ScholarGoogle ScholarCross RefCross Ref
  72. K Vogel and H Risken. 1989. Determination of quasiprobability distributions in terms of probability distributions for the rotated quadrature phase. Physical Review A, 40, 5 (1989), September, https://doi.org/10.1103/PhysRevA.40.2847 Google ScholarGoogle ScholarCross RefCross Ref
  73. S. P. Walborn, P. H. Souto Ribeiro, L. Davidovich, F. Mintert, and A. Buchleitner. 2006. Experimental Determination of Entanglement with a Single Measurement. Nature, 440, 7087 (2006), April, https://doi.org/10.1038/nature04627 Google ScholarGoogle ScholarCross RefCross Ref
  74. Dave Wecker, Krysta M. Svore, and Krysta M. Svore. 2014. LIQUi|>: A Software Design Architecture and Domain-Specific Language for Quantum Computing. February.Google ScholarGoogle Scholar
  75. W. Wootters and W. Zurek. 1982. A single quantum cannot be cloned. Nature, 299 (1982), https://doi.org/10.1038/299802a0 Google ScholarGoogle ScholarCross RefCross Ref
  76. Mingsheng Ying. 2016. Foundations of Quantum Programming (1st ed.). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA. isbn:0128023066Google ScholarGoogle Scholar
  77. Nengkun Yu and Jens Palsberg. 2021. Quantum Abstract Interpretation. In ACM SIGPLAN Conference on Programming Language Design and Implementation. https://doi.org/10.1145/3453483.3454061 Google ScholarGoogle ScholarDigital LibraryDigital Library
  78. Li Zhou, Gilles Barthe, Justin Hsu, Mingsheng Ying, and Nengkun Yu. 2021. A Quantum Interpretation of Bunched Logic amp; Quantum Separation Logic. In 2021 36th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). https://doi.org/10.1109/LICS52264.2021.9470673 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Twist: sound reasoning for purity and entanglement in Quantum programs

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!