Skip to main content
QUICK REVIEW

[Paper Review] Qafny: A Quantum-Program Verifier

Liyi Li, Mingwei Zhu|arXiv (Cornell University)|Nov 11, 2022
Quantum Computing Algorithms and ArchitectureComputer Science2 citations
TL;DR

Qafny is a quantum program verifier that compiles quantum programs into Dafny for automated verification using a type-guided, array-based encoding of quantum states and operations. It enables formal verification of quantum algorithms like Grover’s and Shor’s with soundness and completeness guarantees, significantly reducing manual effort compared to prior interactive theorem proving approaches.

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.

Motivation & Objective

  • To address the high human effort required to formally verify quantum programs, especially given their probabilistic and non-deterministic nature.
  • To bridge classical automated verification frameworks with quantum program verification by leveraging Dafny’s separation logic.
  • To enable automated verification of quantum algorithms through a compilation pipeline from Qafny to Dafny.
  • To support verification of hybrid classical-quantum programs by compiling Qafny to executable languages like C# and Java.
  • To provide a sound and complete proof system for quantum programs by encoding quantum operations as classical array operations.

Proposed method

  • Represent quantum states as arrays of complex amplitudes paired with computational basis states (bitstrings), enabling classical array-based reasoning.
  • Model quantum operations—such as unitary gates and measurements—as aggregate array operations (e.g., map, filter) within a classical separation logic framework.
  • Translate Qafny programs and specifications (preconditions, postconditions, loop invariants) into Dafny code for automated verification.
  • Use a type-guided proof system to ensure correctness and enable local reasoning in the presence of quantum entanglement.
  • Compile Qafny programs to SQIR and then to OpenQASM 2.0 for execution on real quantum hardware.
  • Integrate with classical verification infrastructure by compiling to Dafny, leveraging its automated proof engine.

Experimental results

Research questions

  • RQ1Can quantum programs be formally verified using classical automated verification tools by encoding quantum states and operations as classical data structures?
  • RQ2How can quantum operations such as controlled gates and measurements be modeled as classical array operations to enable automated reasoning?
  • RQ3What is the soundness and completeness of a proof system that maps quantum program semantics to classical separation logic?
  • RQ4Can the compilation pipeline from Qafny to Dafny achieve efficient and scalable verification of complex quantum algorithms like Shor’s and Grover’s?
  • RQ5To what extent can Qafny support the verification of hybrid classical-quantum programs through integration with classical language back-ends?

Key findings

  • Qafny enables automated verification of quantum algorithms such as Grover’s and Shor’s by translating them into Dafny, reducing verification effort compared to interactive theorem proving.
  • The system achieves soundness and completeness of its proof system with respect to the semantics of well-typed Qafny programs.
  • The prototype compiler successfully transforms Qafny programs into Dafny, which is then verified automatically using Dafny’s built-in verification engine.
  • Qafny supports compilation to OpenQASM 2.0 via SQIR, enabling execution on real quantum hardware.
  • The framework supports hybrid classical-quantum programs by extracting compiled Dafny code to languages like C#, Java, and PHP for integration.
  • The approach reduces proof size significantly—e.g., 1018 LOC for Grover’s algorithm in Qafny versus 3184 LOC in prior SQIR-based verification.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.