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 Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
7 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Projection-based runtime assertions for testing and debugging Quantum programs cites A verified optimizer for Quantum circuits
- Combining Hard and Soft Constraints in Quantum Constraint-Satisfaction Systems cites Silq: a high-level quantum language with safe uncomputation and intuitive semantics
- CoqQ: Foundational Verification of Quantum Programs cites Quantum abstract interpretation
- CoqQ: Foundational Verification of Quantum Programs cites A verified optimizer for Quantum circuits
- CoqQ: Foundational Verification of Quantum Programs cites Silq: a high-level quantum language with safe uncomputation and intuitive semantics
- A verified optimizer for Quantum circuits cites Silq: a high-level quantum language with safe uncomputation and intuitive semantics
- Quantum Control Machine: The Limits of Control Flow in Quantum Programming cites Projection-based runtime assertions for testing and debugging Quantum programs
- Quantum Control Machine: The Limits of Control Flow in Quantum Programming cites Quantum abstract interpretation
- Quantum Control Machine: The Limits of Control Flow in Quantum Programming cites A verified optimizer for Quantum circuits
- Quantum Control Machine: The Limits of Control Flow in Quantum Programming cites Silq: a high-level quantum language with safe uncomputation and intuitive semantics
- MorphQPV: Exploiting Isomorphism in Quantum Programs to Facilitate Confident Verification cites Projection-based runtime assertions for testing and debugging Quantum programs
- MorphQPV: Exploiting Isomorphism in Quantum Programs to Facilitate Confident Verification cites Quantum abstract interpretation
Cited 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
