This file may contain multiple lines. Each line represents a quantum state. A quantum state is naturally described by a linear combination of computational basis states with complex coefficients. Coefficients here can be expressed in [addition +
], [subtraction -
], [multiplication *
] operations on [rationals], ^
] operation with "nonnegative" exponents. Operator precedence follows the standard convention. You can also do / sqrt2 ^ k
after the above operations are already done if you wish.
Here is one example.
Extended Dirac
(-1 + -1 * ei2pi(2/8) + -2 * ei2pi(3/8)) |10> + ei2pi(3/8) |11> - ei2pi(1/8) |01>
eipi(1/4) |00> + (1 + 1 * eipi(1/2) + -2 * eipi(3/4)) |11> - eipi(3/4) |10>
This file contains two quantum states
For simplicity, one can define some complex constants in the Constants section before the Extended Dirac section, and the example becomes
Constants
c1 := ei2pi(1/8)
c2 := ei2pi(2/8)
c3 := eipi(3/4)
Extended Dirac
(-1 + -1 * c2 + -2 * c3) |10> + c3 |11> - c1 |01>
c1 |00> + (1 + 1 * c2 + -2 * c3) |11> - c3 |10>
Nonconstant tokens not defined in the Constants section are automatically regarded as free symbolic variables. These variables may have some constraints such as not being zero. One can impose some constraints on these variables in the Constraints section after the Extended Dirac section. For instance,
Constants
c0 := 0
Extended Dirac
c0 |00> + c0 |11> + v |*>
Constraints
imag(v) = 0
the above file describes (at least) all quantum states which are linear combinations of
The Constraints section may contain multiple lines. Each line consists of a boolean formula that will be automatically conjoined (with the and operator) eventually. Each formula is expressed in logical operations [not !
], [and &
], [or |
] on boolean subformulae. These subformulae are expressed in comparison operations [greater than >
], [less than <
] on real numbers and the [equal =
] operation on complex numbers. Operator precedence follows the standard convention. AutoQ also supports two functions real(.)
and imag(.)
to extract the real part and the imaginary part of a complex number.
One may want to take the absolute value of a real number in some applications. Due to the branching nature of this operation, the SMT solver may not be able to solve constraints involving this operation. Please use (.) ^ 2
as an alternative instead.
We say a description file contains a quantum state
We use the logical |00> \/ |01>
means that V
in place of \/
to obtain the same result.
Many real-world sets of quantum states have some common patterns in qubits. In light of this, AutoQ supports the existentially quantified variable \/|i|=n:
over all i
and i'
(i.e., i
) appearing after this notation in a line. If there is some quantum state \/|i|=2: a|i0> + b|i'1>
describes the following four states
For convenience, AutoQ also supports the tensor product operator #
. The usage is very easy: just put #
between the two sets of quantum states
The tensor product operator #
has the lowest precedence. That is, they split a line into multiple units. In each unit, logical i
and i'
in different units are invisible to each other.
Finally, we should be noticed that not all strings described by *.hsl
are valid quantum states. For instance, the sum of absolute squares of amplitudes of all computational basis states may not be