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%.
翻译:量子编程语言使开发者能够实施量子计算机的算法,这些算法有望在经典棘手的任务中实现计算上的突破。 编程量子计算机需要了解纠缠现象, Qubits的测量结果与此现象相关。 缠绕可以确定算法的正确性和编程模式的合适性。 在这项工作中, 我们正式确定纯度是量子程序内纠缠的推理自动化的核心工具。 纯度表达方式不受它所没有的量子的测量结果的影响, 意味着不受与计算中任何其他表达方式的纠缠绕。 我们展示Twist, 这是首种语言, 其类型系统是用于精确推理的系统。 类型系统使开发者能够使用类型说明来识别纯度表达方式。 Twitmist 还将纯度主张操作者确定在量子门输出中不存在纠缠的推理。 为了正确校验这些说法, Twist 使用了固定分析和运行时间校验的组合。 我们评估Twist 类型系统, 分析在模拟中的基准量方案中, 显示Twist 能够显示Twist 显示, listalma libal lical lical list list licald lical 。