Skip to content

Commit 1eb3759

Browse files
committed
update READMEs
1 parent 44f5c11 commit 1eb3759

File tree

4 files changed

+56
-48
lines changed

4 files changed

+56
-48
lines changed

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AutoQ: An automata-based C++ tool for quantum program verification.
22

3-
AutoQ is a command-line utility written in C++ for verifying partial correctness of quantum programs automatically based on non-deterministic finite tree automata (NFTA) along with the concept of Hoare-style proof systems.
3+
AutoQ is a command-line utility written in C++ for verifying partial correctness of quantum programs automatically based on non-deterministic finite tree automata (NFTA) along with the concept of Hoare-style proof systems.
44

55
Consider a triple \{ $P$ \} $C$ \{ $Q$ \}, where $P$ and $Q$ are the pre- and post-condition recognizing sets of (pure) quantum states (represented by NFTA) and $C$ is a quantum program. Let $\mathcal L(.)$ denote the mapping from a condition $x$ to the set of all quantum states satisfying $x$ (characterized by $x$). Then AutoQ essentially checks whether all the quantum states in $\mathcal L(P)$ reach some state in $\mathcal L(Q)$ after the program $C$ is executed. If we further let $C(.)$ denote the mapping from a condition $x$ to the evolution of $x$ after a program segment $C$ is executed, then AutoQ simply checks whether $\mathcal L(C(P)) \subseteq \mathcal L(Q)$.
66

@@ -15,31 +15,30 @@ Currently, for Linux (Ubuntu/Debian) and macOS, the dependency of AutoQ can be b
1515
make release
1616
make test
1717
```
18-
The first command compiles the source code with compiler optimizations enabled, while the second command runs several unit tests to verify the correctness of the implementation. If you need to compile the library for debugging, you can replace make release with `make debug`.
18+
The first command compiles the source code with compiler optimizations enabled, while the second command runs several unit tests to verify the correctness of the implementation. If you need to compile the library for debugging, you can replace `make release` with `make debug`.
1919

2020
---
2121

2222
## Command-Line
23-
There are 5 modes listed in the following help message, which can be accessed by typing their respective subcommands. Each mode (subcommand) also has its own usage instructions.
23+
There are 4 modes listed in the following help message, which can be accessed by typing their respective subcommands. Each mode (subcommand) also has its own usage instructions.
2424
```
2525
$ ./build/cli/autoq -h
2626
AutoQ: An automata-based C++ tool for quantum program verification.
2727
Usage: autoq [OPTIONS] [SUBCOMMAND]
2828
2929
Options:
30-
-h,--help Print this help message and exit
30+
-h,--help Print this help message and exit.
3131
3232
Subcommands:
33-
exC Concrete Execution
34-
verC Concrete Verification
35-
exS Symbolic Execution
36-
verS Symbolic Verification
37-
eq Equivalence Checking
33+
ex Execute a quantum circuit with a given precondition.
34+
ver Verify the execution result against a given postcondition.
35+
eq Check equivalence of two given quantum circuits.
36+
print Print the set of quantum states.
3837
```
3938
```
4039
$ ./build/cli/autoq ver benchmarks/all/Grover/03/pre.lsta benchmarks/all/Grover/03/circuit.qasm benchmarks/all/Grover/03/post.lsta
4140
The quantum program has [6] qubits and [54] gates.
42-
The verification process [passed] in [0.0s] with [16MB] memory usage.
41+
The verification process [passed] in [0.0s] with [7MB] memory usage.
4342
```
4443
AutoQ provides two file extensions, *.hsl and *.lsta, for users to indicate the format they use to describe a set of quantum states. The simpler format is *.hsl, which does not require users to have a background in NFTA. However, since our current implementation of *.hsl has not yet been optimized, we strongly recommend using *.lsta as the number of qubits increases. The detailed formats can be found in the following documents.
4544

docs/hsl_description.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
## How to describe a set of quantum states? `*.hsl`
22

3-
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], $[e^{i2\pi(r)}\ |\ r=k/8,\ k\in\mathbb Z]$ and the [exponentiation `^`] operation with "nonnegative" exponents. Operator precedence follows the standard convention. You can also do $/\sqrt2 ^ k$ by writing `/ sqrt2 ^ k` after the above operations are already done if you wish. Nevertheless, due to the automatic scaling in the verification process, users do not need $/\sqrt2 ^ k$.
3+
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], $[e^{i2\pi(r)}\ |\ r=k/8,\ k\in\mathbb Z]$, $[e^{i\pi(r)}\ |\ r=k/4,\ k\in\mathbb Z]$ and the [exponentiation `^`] operation with "nonnegative" exponents. Operator precedence follows the standard convention. You can also do $/\sqrt2 ^ k$ by writing `/ sqrt2 ^ k` after the above operations are already done if you wish. <!--Nevertheless, due to the automatic scaling in the verification process, users do not need $/\sqrt2 ^ k$.-->
44

55
### # Extended Dirac
66
Here is one example.
77
```
88
Extended Dirac
99
(-1 + -1 * ei2pi(2/8) + -2 * ei2pi(3/8)) |10> + ei2pi(3/8) |11> - ei2pi(1/8) |01>
10-
ei2pi(1/8) |00> + (1 + 1 * ei2pi(2/8) + -2 * ei2pi(3/8)) |11> - ei2pi(3/8) |10>
10+
eipi(1/4) |00> + (1 + 1 * eipi(1/2) + -2 * eipi(3/4)) |11> - eipi(3/4) |10>
1111
```
12-
This file describes two quantum states $-e^{i2\pi(1/8)}\ |01\rangle + (-1 - e^{i2\pi(2/8)} - 2\cdot e^{i2\pi(3/8)})\ |10\rangle + e^{i2\pi(3/8)}\ |11\rangle$ and $e^{i2\pi(1/8)}\ |00\rangle - e^{i2\pi(3/8)}\ |10\rangle + (1 + e^{i2\pi(2/8)} - 2\cdot e^{i2\pi(3/8)})\ |11\rangle$. If there are so many states having the same amplitude, you can also use the "wildcard state" $|\*\rangle$ at the end of a line to denote all other computational basis states whose amplitudes have not been specified so far. For instance, $0.5\ |00\rangle - 0.5\ |*\rangle = 0.5\ |00\rangle - 0.5\ |01\rangle - 0.5\ |10\rangle - 0.5\ |11\rangle$.
12+
This file contains two quantum states $-e^{i2\pi(1/8)}\ |01\rangle + (-1 - e^{i2\pi(2/8)} - 2\cdot e^{i2\pi(3/8)})\ |10\rangle + e^{i2\pi(3/8)}\ |11\rangle$ and $e^{i\pi(1/4)}\ |00\rangle - e^{i\pi(3/4)}\ |10\rangle + (1 + e^{i\pi(1/2)} - 2\cdot e^{i\pi(3/4)})\ |11\rangle$. If there are so many states having the same amplitude, you can also use the "wildcard state" $|\*\rangle$ at the end of a line to denote all other computational basis states whose amplitudes have not been specified so far. For instance, $0.5\ |00\rangle - 0.5\ |*\rangle = 0.5\ |00\rangle - 0.5\ |01\rangle - 0.5\ |10\rangle - 0.5\ |11\rangle$.
1313

1414
### # Constants
1515
For simplicity, one can define some complex constants in the *Constants* section before the *Extended Dirac* section, and the example becomes
1616
```
1717
Constants
1818
c1 := ei2pi(1/8)
1919
c2 := ei2pi(2/8)
20-
c3 := ei2pi(3/8)
20+
c3 := eipi(3/4)
2121
Extended Dirac
2222
(-1 + -1 * c2 + -2 * c3) |10> + c3 |11> - c1 |01>
2323
c1 |00> + (1 + 1 * c2 + -2 * c3) |11> - c3 |10>
2424
```
2525

2626
### # Variables and Constraints
27-
Nonconstant tokens not defined in the Constants section are automatically regarded as *free symbolic variables*. These variables may have some constraints such as being nonzero. One can impose some constraints on these variables in the *Constraints* section after the *Extended Dirac* section. For instance,
27+
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,
2828
```
2929
Constants
3030
c0 := 0
@@ -41,10 +41,19 @@ One may want to take the absolute value of a ***real*** number in some applicati
4141

4242
We say a description file contains a quantum state $|s\rangle$ only if $|s\rangle$ satisfies all the boolean formulae in the *Constraints* section.
4343

44-
### # Tensor Products and Existentially Quantified Variables
45-
For convenience, AutoQ also supports the ***tensor product operator*** `#`. The usage is very easy: just put `#` between two quantum states $|x\rangle$ and $|y\rangle$ in a line to denote the quantum state $|x\rangle \otimes |y\rangle$. AutoQ also supports the ***existentially quantified variable*** `\/ |i|=n :` over all $n$-bit binary strings. This variable is used to constrain all basis states $|i\rangle$ appearing after this notation in a line. If there is some quantum state $|s\rangle$ satisfying this line for some $i$, then we say $|s\rangle$ is described in this line.
44+
### # Logical $\lor$ Operator
45+
We use the logical $\lor$ operator to compute the union of the two sets of quantum states connected by this operator. For instance, `|00> \/ |01>` means that $|00\rangle$ and $|01\rangle$ are both included in the file. Please note that you can also use `V` in place of `\/` to obtain the same result.
4646

47-
One more example to get a closer look at `*.hsl`.
47+
### # Existentially Quantified Variables
48+
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 $n$-bit binary strings. This variable is used to constrain all substrings `i` and `i'` (i.e., $1$'s complement of `i`) appearing after this notation in a line. If there is some quantum state $|s\rangle$ matches the pattern in this line for some $\\{i\in\\{0,1\\}^n\\}$, then we say $|s\rangle$ is contained in this line. For instance, `\/|i|=2: a|i0> + b|i'1>` describes the following four states $\\{a|000\rangle+b|111\rangle,\ a|010\rangle+b|101\rangle,\ a|100\rangle+b|011\rangle,\ a|110\rangle+b|001\rangle\\}$.
49+
50+
### # Tensor Products
51+
For convenience, AutoQ also supports the ***tensor product operator*** `#`. The usage is very easy: just put `#` between the two sets of quantum states $S_1$ and $S_2$ in a line to denote the resulting set of quantum states $\\{|x\rangle \otimes |y\rangle\ |\ |x\rangle\in S_1,\ |y\rangle\in S_2\\}$.
52+
53+
### # Operator Precedence
54+
The ***tensor product operator*** `#` has the lowest precedence. That is, they split a line into multiple units. In each unit, logical $\lor$ operators and existentially quantified variables cannot be used at the same time. Besides, substrings `i` and `i'` in different units are invisible to each other.
55+
56+
<!--One more example to get a closer look at `*.hsl`.
4857
```
4958
Extended Dirac
5059
\/ |i|=3 : |i> # vH |i> + vL |*> # |000>
@@ -56,6 +65,6 @@ vL > 0
5665
```
5766
describes the set of states<br>
5867
<img width="315" alt="image" src="https://user-images.githubusercontent.com/10044077/217997027-4dec8f23-811d-4747-86b3-e95d37b9ec69.png">
59-
<br>where $v_h > v_\ell > 0$.
68+
<br>where $v_h > v_\ell > 0$.-->
6069

6170
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 $1$.

docs/lsta_description.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## NFTA Format `*.lsta`
2+
3+
Since the underlying structure of a set of quantum states is still an NFTA in AutoQ, we reserve the `*.lsta` format for users to describe a set of quantum states with an NFTA. The *Constants* and *Constraints* sections remain, but the *Extended Dirac* section should be replaced with two new sections *Root States* and *Transitions* now. (Unary) states in an NFTA can be arbitrary strings (no need to enclose with double quotation marks).
4+
5+
### # Root States
6+
This section is responsible for specifying a set of root states. It should contain only one line starting with "Root States" and ending with a set of root states separated by whitespaces.
7+
8+
### # Transitions
9+
This section is responsible for specifying a set of transitions. One transition per line. Notice that the extension name `*.lsta` stands for Level-Synchronized (Nondeterministic Finite) Tree Automata which means that each transition is associated with a nonnegative integer denoting a set of choices in AutoQ. A (bottom-up) transition $f(q_1, q_2, ..., q_n) \to q$ associated with a set of choices $C$ is written as `[f,C](q1, q2, ..., qn) -> q`. Each pair of transitions `[f1,C1](...) -> q` and `[f2,C2](...) -> q` with the same `q` must satisfy $C_1 \\& C_2 = 0$. In each layer of all used transitions for an accepted quantum state, the bitwise $\\&$ of all used $C$'s must be positive. In this tool, a symbol can only be a positive integer $i$ with arity $2$ for specifying the $i$-th qubit or any expression describing a complex number with arity $0$ for specifying the amplitude of some computational basis states.
10+
11+
We close this section with the following example.
12+
```
13+
Constants
14+
c0 := 0
15+
Root States aR bR
16+
Transitions
17+
[1,1](aL1, aL1) -> aR
18+
[2,1](qLow, q0) -> aL1
19+
[1,1](bL1, bL1) -> bR
20+
[2,1](q0, qHigh) -> bL1
21+
[c0,1] -> q0
22+
[p1,1] -> qLow
23+
[p2,1] -> qHigh
24+
Constraints
25+
imag(p1) = 0
26+
p1 ^ 2 < 1/8
27+
imag(p2) = 0
28+
p2 ^ 2 > 7/8
29+
```

docs/spec_description.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)