Qafny: A Quantum-Program Verifier
Liyi Li, Mingwei Zhu, Rance Cleaveland, Alexander Nicolellis, Yi Lee, Le Chang, Xiaodi Wu
TL;DR
Qafny provides a type-guided, locus-based framework for automatically verifying quantum programs by translating quantum operations to classical array reasoning within a separation-logic setting. It introduces a trio of core ideas—Locus, Type, and State—to statically track entanglement and qubit positions, enabling automated proofs of quantum conditionals and loops (via the F and U transformers) and proving type soundness and relative completeness. The system includes a Dafny-based compiler and a translation to Sep, enabling verification with classical tools, and demonstrates automated verification on key algorithms such as GHZ, quantum walk, Grover, and Shor, with case studies showing composability and rapid prototyping. Together, these contributions connect quantum program verification to classical Hoare/separation logic, delivering automation and scalability advantages for HCQ program verification with practical impact for algorithm design and correctness guarantees.
Abstract
Because of the probabilistic/nondeterministic behavior of quantum programs, it is highly advisable to verify them formally to ensure that they correctly implement their specifications. Formal verification, however, also traditionally requires significant effort. To address this challenge, we present Qafny, an automated proof system based on the program verifier Dafny and designed for verifying quantum programs. At its core, Qafny uses a type-guided quantum proof system that translates quantum operations to classical array operations modeled within a classical separation logic framework. We prove the soundness and completeness of our proof system and implement a prototype compiler that transforms Qafny programs and specifications into Dafny for automated verification purposes. We then illustrate the utility of Qafny's automated capabilities in efficiently verifying important quantum algorithms, including quantum-walk algorithms, Grover's algorithm, and Shor's algorithm.
