Preprints are manuscripts made publicly available before they have been submitted for formal peer review and publication. They might contain new research findings or data. Preprints can be a draft or final version of an author's research but must not have been accepted for publication at the time of submission.
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.