Skip to content

Assertion error on valid-standalone measurement #139

@ryanhill1

Description

@ryanhill1

In OpenQASM grammar, it seems that it might not be required that measurement statements make reference to a classical (target) qubit.

The openqasm3.ast.QuantumMeasurementStatement is documented as:

Stand-alone statement of a quantum measurement, potentially assigning the result to a classical variable.

and specifies field target of type Optional[Union[IndexedIdentifier, Identifier]].

This makes me think that specifying a target (classical) bit might not be semantically necessary.

If this is true, the following should be valid:

OPENQASM 3.0;
include "stdgates.inc";

qubit[3] q;
bit[3] b;

h q[0];
cx q[0], q[1];
measure q;

However, in pyqasm.unroll(), it raises an AssertionError:

source = statement.measure.qubit
target = statement.target
assert source and target

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions