quilc
quilc copied to clipboard
Prototype `DEFGATE .. AS GATE-SEQUENCE` or similar
There is currently no way to define a gate based off of a sequence of other gates. Let's prototype syntax and semantics for something like this:
DEFGATE HADAMARD q AS GATE-SEQUENCE:
RZ(pi/2) q
RX(pi/2) q
RZ(pi/2) q
Parameters could also be specified. The AS GATE-SEQUENCE is just a suggestion. Perhaps AS GATES instead?
The point of this feature is to define a gate, and not to define a circuit. While the compiler might decide to expand the given gates, it doesn't need to, and can treat it completely opaquely.
There are a couple questions that arise in implementing such a feature:
- What about mutually dependent definitions? (Non-self) recursive definitions?
- Should gate sequences be a more first-class definable concept? At some point we will want user-installable gate sequence expansions in QUILC, and maybe there's overlap here.
Note: This would require a change to the Quil spec.
Note: For prototyping, the syntax is pretty close to AS PAULI-SUM in terms of the declaration, and so that code path may be able to be used.