Open appleby opened 5 years ago
I am almost certain that this is already tested, though maybe not directly. The express intent of the compiler is to produce output that is matrix-equals-dwim
with the input. I would say (philosophically?) the entirety of the test suite amounts to testing that very condition.
I am almost certain that this is already tested, though maybe not directly. The express intent of the compiler is to produce output that is
matrix-equals-dwim
with the input. I would say (philosophically?) the entirety of the test suite amounts to testing that very condition.
There do exist a lot of tests where it's checked that the output of compilation is matrix-equal-dwim
to the uncompiled input. What I'm suggesting is that given two programs whose sources differ but which conceptually "do the same thing" (scare quotes because I don't really understand what this means for a quantum program), check that their resulting logical matrices are matrix-equals-dwim
. But maybe this not really a separate concept, and I am just too much of a quantum ignoramus to notice it :).
If people who know what they're talking about feel this is a low-value test, I'm happy to close this issue.
Thinking about this a bit more, I think I'm beginning to see the point that you and @ecpeterson have been trying to explain to me, albeit still dimly!
Based on my limited understanding, I guess any quantum program encodes some unitary matrix that acts on the initial state? So to say that two quantum programs "do the same thing" necessarily implies that they encode the same unitary, and therefore the fact that they have different Quil sources is maybe not that interesting of a distinction?
I still feel like there is something there that might be worth testing, but maybe I am just confused and trying to apply classical compiler/computing concepts in a quantum context where it doesn't make sense.
As discussed in #257, it might be useful to add some tests that pass two programs with different Quil sources but the same "meaning" through the compiler or at least
parse-quil
and check that the matrices returned bymake-matrix-from-quil
orparsed-program-to-logical-matrix
for the two programs satisfymatrix-equals-dwim
.Something like
or else
See the last couple of comments by @ecpeterson in this thread for more context, as well as a hint to look in
rewriting-rules.lisp
for examples of equivalent-but-different Quil snippets.@ecpeterson also says in the linked thread that testing
make-matrix-from-quil
"... is certainly in the critical path, but it's also pretty low-risk."