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%.
Supplemental Material
Available for Download
Appendices of paper.
- Héctor Abraham. 2019. Qiskit: An Open-source Framework for Quantum Computing.Google Scholar
- 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 Scholar
Digital Library
- Matthew Amy, Martin Roetteler, and Krysta M. Svore. 2017. Verified Compilation of Space-Efficient Reversible Circuits. In Computer Aided Verification.Google Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- J. S. Bell. 1964. On the Einstein Podolsky Rosen paradox. Physics, 1 (1964), Nov, https://doi.org/10.1103/PhysicsPhysiqueFizika.1.195 Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- D. Coppersmith. 1994. An approximate Fourier transform useful in quantum factoring.Google Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- A. Haar. 1933. Der Massbegriff in der Theorie der Kontinuierlichen Gruppen. Annals of Mathematics, 34 (1933), https://doi.org/10.2307/1968346 Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- K. Honda. 2015. Analysis of Quantum Entanglement in Quantum Programs using Stabilizer Formalism. In QPL. https://doi.org/10.4204/EPTCS.195.19 Google Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- A. Yu. Kitaev. 1997. Quantum computations: algorithms and error correction. Russian Mathematical Surveys, 52, 6 (1997), dec, https://doi.org/10.1070/RM1997V052N06ABEH002155 Google Scholar
Cross Ref
- E Knill. 1996. Conventions for quantum pseudocode.Google Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- Michael A. Nielsen and Isaac L. Chuang. 2010. Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- A. Pati and S. Braunstein. 2000. Impossibility of deleting an unknown quantum state. Nature, 404 (2000), https://doi.org/10.1038/404130b0 Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
- Robert Rand, Aarthi Sundaram, Kartik Singhal, and Brad Lackey. 2021. Static Analysis of Quantum Programs via Gottesman Types. arxiv:2101.08939.Google Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- E. Schmidt. 1907. Zur Theorie der linearen und nichtlinearen Integralgleichungen. Math. Ann., 63 (1907), https://doi.org/10.1007/BF01449770 Google Scholar
Cross Ref
- Peter Selinger. 2004. Towards a quantum programming language. Mathematical Structures in Computer Science, 14 (2004), 08, https://doi.org/10.1017/S0960129504004256 Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- Kartik Singhal. 2020. Quantum Hoare Type Theory. arxiv:2012.02154.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- Dave Wecker, Krysta M. Svore, and Krysta M. Svore. 2014. LIQUi|>: A Software Design Architecture and Domain-Specific Language for Quantum Computing. February.Google Scholar
- W. Wootters and W. Zurek. 1982. A single quantum cannot be cloned. Nature, 299 (1982), https://doi.org/10.1038/299802a0 Google Scholar
Cross Ref
- Mingsheng Ying. 2016. Foundations of Quantum Programming (1st ed.). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA. isbn:0128023066Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Twist: sound reasoning for purity and entanglement in Quantum programs
Recommendations
Relations between quantum correlations, purity and teleportation fidelity for the two-qubit Heisenberg XYZ system
Quantifying and understanding quantum correlations may give a direct reply for many issues regarding the interesting behaviors of quantum system. To explore the quantum correlations in quantum teleportation, we have used a two-qubit Heisenberg XYZ ...
Coherent state quantum key distribution based on entanglement sudden death
A method for quantum key distribution (QKD) using entangled coherent states is discussed which is designed to provide key distribution rates and transmission distances surpassing those of traditional entangled photon pair QKD by exploiting entanglement ...
Efficient entanglement purification via quantum communication bus
A scheme is proposed to implement entanglement purification for two remote less entangled photons using robust continuous variable coherent modes, called as quantum communication bus (qubus), rather than consuming expensive ancilla single-photon ...






Comments