Make the semantic of `gphase();` clearer.
Summary
Make the semantic of gphase(); clearer. See https://github.com/openqasm/openqasm/issues/383 .
This definition of gphase() also allows accumulation.
Details and comments
The semantic of gphase(); in Amazon Braket is just add a global phase gate to the containing scope. No matter which qubit is applied to, the result state of the circuit is the same. In this case, an n-qubits global phase gate is more reasonable.
If someone just want the state of a specific qubit, this design cannot distinguish which qubit gphase(); applies to.
The "scope" is also more specific. Only gate, subroutine, and global scope have qubits declaration/definition. If we only limit to the containing scope, for example, the for scope, the semantic can also be "do nothing" because no qubits declared/defined in the for scope.
From TSC meeting 2022-09-02: there is a question of what gphase would mean inside a subroutine, and whether it's worth needing to specify any special rules for it. In particular, it's not obvious what the behaviour would be if the same qubit is passed as different arguments.
There was approximate agreement (without a quorum) to:
- accept this PR as-is
- (Lev) largely rewrite
gates.rstto simplify all of its text, including this PR - (me) add a separate PR to explicitly forbid qubit references to alias the same qubit in subroutine calls
We need further assent/comment from @pschindler, @blakejohnson or @ajavadia before we can merge this, though.
Is this now subsumed by #393 ?
Is this now subsumed by #393 ? Yes my intention is that #393 morally includes this revision.
Closing in favour of #393.