PiGate: A gate for working exactly with multiples of pi #183
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces a gate which allows for working exactly with multiples of pi. This commit is the first step towards verifying circuits with rotations parameterized by multiples of pi.
Details
Currently, the parameterized equivalence checker in
src/python/verifier
does not support constant parameters. This is because, given an arbitrary real (or rational number) x, it is not possible to represent sin(x) exactly using only addition, multiplication, subtraction, division, and square roots (or even n-th roots). For special values of x, this is possible though.This pull request introduces a new named gate, called
pi(n)
, which corresponds to the constant anglepi/n
. The implementation in this pull request handles many values ofn
which appear in quantum computing, such as whenn
is a power of two. More precisely, the techniques in this pull request can be extended to anyn
such that the regularn
-gon is constructible (see the Gauss-Wantzel Theorem). The cases which I do not support (e.g., 17*2^k and 257*2^k) are unlikely to appear in real quantum algorithms and have horrendous formulas.Future Work
In a follow-up pull request, I plan to integrate this with the OpenQASM 2 parser.