John van de Wetering
SEFM, Aveiro 2024
the code that runs on a quantum computer
INIT 5 CNOT 1 0 H 2 Z 3 H 0 H 1 CNOT 4 2 ... |
↔ |
code that makes that code (better)
Optimisation | Simulation & Verification | Error Correction |
Note: quantum gates are just matrices...
\( \text{S} = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} \qquad \text{H} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \)
\( \text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix} \)
... but nobody wants to deal with these things directly.
X = NOT = = \(\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\)
CNOT = = \(\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\)
Hadamard = = \(\frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\)
\(R_Z(\alpha)\) = = \(\begin{pmatrix} 1 & 0 \\ 0 & e^{i\alpha} \end{pmatrix}\)
Z := \(R_Z(\pi)\) S := \(R_Z\left(\frac{\pi}{2}\right)\) T := \(R_Z\left(\frac{\pi}{4}\right)\)
An example quantum circuit:
A complete set of equations for qubit QC
What gates are to circuits, spiders are to ZX-diagrams.
\(\ket{0 \cdots 0}\!\bra{0 \cdots 0} + e^{i \alpha} \ket{1 \cdots 1}\!\bra{1 \cdots 1}\) | \(\ket{+ \cdots +}\!\bra{+ \cdots +} + e^{i \alpha} \ket{- \cdots -}\!\bra{- \cdots -}\) |
For example:
= \(\ket{0}\bra{0} + e^{i \alpha} \ket{1}\bra{1}\) = \(\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 0 & e^{i\alpha} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\alpha} \end{pmatrix}\)
= \(\ket{+}\bra{+} + e^{i \alpha} \ket{-}\bra{-}\) = \(\frac{1}{2} \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix} + \frac{1}{2} e^{i\alpha} \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix}\)
If \(\alpha=0\) we drop the label:
= \(\ket{0 \cdots 0}\bra{0 \cdots 0} + \ket{1 \cdots 1}\bra{1 \cdots 1}\)
= \(\ket{+ \cdots +}\bra{+ \cdots +} + \ket{- \cdots -}\bra{- \cdots -}\)
Example:
= \(\ket{+} + \ket{-} = \sqrt{2}\ket{0}\) = \(\ket{0} + \ket{1} = \sqrt{2}\ket{+}\)
= \(\ket{+} - \ket{-} = \sqrt{2}\ket{1}\) = \(\ket{0} - \ket{1} = \sqrt{2}\ket{-}\)
We ignore these non-zero scalar factors.
Spiders can be composed in two ways.
Vertical composition gives tensor product:
= \(\begin{pmatrix}1 & 0 \\ 0 & 0 \\ 0 & 0 \\ 0 & 1\end{pmatrix}\)
= \(\begin{pmatrix}1 & 0 \\ 0 & 0 \\ 0 & 0 \\ 0 & 1\end{pmatrix} \otimes \begin{pmatrix}1 & 0 \\ 0 & 1\end{pmatrix}\) = \(\begin{pmatrix}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{pmatrix}\)
= \(\begin{pmatrix}1 & 0 \\ 0 & 1\end{pmatrix} \otimes \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 0 & 0 & 1 \\ 0 & 1 & 1 & 0\end{pmatrix}\)
= \(\frac{1}{\sqrt{2}}\begin{pmatrix}1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0\end{pmatrix}\)
Horizontal composition is regular composition of linear maps:
=
Any ZX-diagram is built by simply iterating these vertical and horizontal compositions.
Note:
Hence, we may write:
In general: only connectivity matters
How powerful are ZX-diagrams as a representation?
Theorem:
ZX-diagrams are universal: any linear map between qubits can be represented as a ZX-diagram.
A complete set of equations for qubit QC
Connected spiders of same colour fuse
Definition of Hadamard in ZX:
Derived rule: commuting Hadamards changes colour
Consequence: Everything in ZX holds with colours reversed
Recall that the GHZ-state is \(\ket{000} + \ket{111}\).
The following circuit creates a GHZ-state:
Proof:
Let \( \ket{\Psi} \) represent a side of a Bell state.
Then this is the standard quantum teleportation protocol:
Proof:
≈ 30 spiders
≈ $10^3$ - $10^8$ spiders
$\Rightarrow$
...has 2 phases. First simplify...
...and extract:
→
# of qubits
tree width
T-count $\leftarrow$ stabilizer decompostion
Gottesman-Knill $\implies$ amplitudes can be computed in $N \cdot$ poly time.
$T|{+}\rangle = |0\rangle + e^{i\pi/4} |1\rangle$
gives $2^t$ terms.two main approaches:
$\quad \leadsto \quad$
$\quad = \quad$
Canonical forms for encoders give convenient expressions of equiv. classes of codes.
We can use ZX for...
2-year Master on theory of quantum computing