Abstract
In this paper, we propose quantum circuits to enable dynamic assertions
for classical values, entanglement, and superposition. This enables a
dynamic debugging primitive, driven by a programmer’s understanding of
the correct behavior of the quantum program. We show that besides
generating assertion errors, the assertion logic may also force the
qubits under test to be into the desired state. Besides debugging, our
proposed assertion logic can also be used in noisy intermediate scale
quantum (NISQ) systems to filter out erroneous results, as demonstrated
on a 20-qubit IBM Q quantum computer. Our proposed assertion circuits
have been implemented as functions in the open-source Qiskit tool.