Mixing Local Impurity and Pure-state Specification in Automated Quantum Program Verification
Quantum programming is a challenging endeavour, and developers are in need of tools which can help them program correct code and develop and use library code effectively. To address these issues, we present veriQASM, a lightweight extension of the openQASM quantum programming language that allows the integration of formal specification and verification into existing workflows. We devise a locally impure model of verification where specifications are given on pure states, but programs may be impure locally within the specification. By ensuring valid specifications extend linearly to superpositions over states, specifications of impure computations can be expressed intuitively by just transformations on the computational basis. We further give a method of symbolically executing hybrid quantum/classical programs using path sums, and of checking verification conditions generated by program specifications. We implement our methods on openQASM 3.0 and perform the fully automated verification of a number of non-trivial quantum programs and components, including Repeat-Until-Success loops, error correction circuitry, and the deterministic case of Shor’s period finding algorithm where the period divides 2^n.