Twist: sound reasoning for purity and entanglement in Quantum programs
Charles Yuan, Christopher McNally, Michael Carbin
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 several languages disallow, while incurring runtime verification overhead of less than 3.5%.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext a6427e17-41f4-4e96-9616-9a9981648b81Cited by top-tier papers7
- CoqQ: Foundational Verification of Quantum ProgramsLi Zhou, Gilles Barthe, Pierre-Yves Strub, Junyi Liu et al.POPL 2023 · 33 citations
- Quantum Control Machine: The Limits of Control Flow in Quantum ProgrammingCharles Yuan, Agnes Villanyi, Michael CarbinOOPSLA 2024 · 9 citations
- Combining Hard and Soft Constraints in Quantum Constraint-Satisfaction SystemsEllis Wilson, Frank Mueller, Scott PakinSC 2022 · 5 citations
- MorphQPV: Exploiting Isomorphism in Quantum Programs to Facilitate Confident VerificationSiwei Tan, Debin Xiang, Liqiang Lu, Junlin Lu et al.ASPLOS 2024 · 5 citations
- Charter: Identifying the Most-Critical Gate Operations in Quantum Circuits via Amplified Gate ReversibilityTirthak Patel, Daniel Silver, Devesh TiwariSC 2022 · 4 citations
Builds on12
- Silq: a high-level quantum language with safe uncomputation and intuitive semanticsBenjamin Bichsel, Maximilian Baader, Timon Gehr, Martin T. VechevPLDI 2020 · 145 citations
- Projection-based runtime assertions for testing and debugging Quantum programsGushu Li, Li Zhou, Nengkun Yu, Yufei Ding et al.OOPSLA 2020 · 120 citations
- A verified optimizer for Quantum circuitsKesha Hietala, Robert Rand, Shih-Han Hung, Xiaodi Wu et al.POPL 2021 · 111 citations
- Quantum abstract interpretationNengkun Yu, Jens PalsbergPLDI 2021 · 69 citations
- A probabilistic separation logicGilles Barthe, Justin Hsu, Kevin LiaoPOPL 2020 · 35 citations
Related papers
- RapunSL: Untangling Quantum Computing with Separation, Linear Combination and MixingYusuke Matsushita, Kengo Hirata, Ryo Wakizaka, Emanuele D'OsualdoPOPL 2026 · 1 citation
- QbC: Quantum Correctness by ConstructionAnurudh Peduri, Ina Schaefer, Michael WalterOOPSLA 2025 · 3 citations
- Analyzing Quantum Programs with LintQ: A Static Analysis Framework for QiskitMatteo Paltenghi, Michael PradelFSE 2024 · 19 citations
- Qunity: A Unified Language for Quantum and Classical ComputingFinn Voichick, Liyi Li, Robert Rand, Michael HicksPOPL 2023 · 35 citations
- Embedding Quantum Program Verification into DafnyFeifei Cheng, Sushen Vangeepuram, Henry Allard, Seyed Mohammad Reza Jafari et al.OOPSLA 2025 · 2 citations
