\section{The Graph Simulator} \subsection{Mathematical Prerequisites} The following definitions and lemmata are required to understand both how the graph formalism works and how the simulator handles gates. \begin{definition} \begin{equation} p \in P_n \Rightarrow p = \bigotimes\limits_{i=0}^n p_i \\ \forall i: p_i \in P := \{\pm 1, \pm i\} \cdot \{I, X, Y, Z\} \end{equation} Where $X = \left(\begin{array}{cc} 0 & 1 \\ 1 & 0\end{array}\right)$, $Y = \left(\begin{array}{cc} 0 & i \\ -i & 0\end{array}\right)$ and $Z = \left(\begin{array}{cc} 1 & 0 \\ 0 & -1\end{array}\right)$ are the Pauli matrices and $I$ is the identity. \end{definition} \begin{definition} Let $p_i \in P_n \forall i = 1, ..., n$, $[p_i, p_j] = 0 \forall i,j$ be commuting multi-local Pauli operators. Then a $n$ qbit state $\ket{\psi}$ is called a stabilizer state iff \begin{equation} \forall i: p_i\ket{\psi} = +1\ket{\psi} \end{equation} \end{definition} %A $n$ qbit graph or stabilizer state is a $+1$ eigenstate of some $ p \in P_n$ where $P_n$ is the Pauli group\cite{andersbriegel2005}. \begin{definition} \begin{equation} C_n := \{U \in SU(2) | UpU^\dagger \in P_n \forall p \in P_n\} \end{equation} is called the Clifford group on $n$ qbits. $C_1$ is called the local Clifford group. \end{definition} One can show that the Clifford group $C_n$ can be generated using the elements of $C_1$ acting on all qbits and the controlled phase gate $CZ$ between all qbits\cite{andersbriegel2005}. It is worth noting that the $CX$ gate can be generated using $CZ$ and $C_1$ gates. \begin{lemma} Let $a \in C_1$ then $\forall \phi \in [0, 2\pi)$ also $\exp(i\phi)a \in C_1$. \textbf{Note}: This is also true for $C_n \forall n >= 1$. \end{lemma} \begin{proof} Let $a' := \exp(i\phi)a$. $a' \in C_1$ iff $a'pa^{\prime\dagger} \in P \forall p \in P$. \begin{equation} \begin{aligned} a'pa^{\prime\dagger} &= (\exp(i\phi)a)p(\exp(i\phi)a)^\dagger \\ & = \exp(i\phi)ap\exp(-i\phi)a^\dagger \\ & = \exp(i\phi)\exp(-i\phi) apa^\dagger \\ & = apa^\dagger \in P \end{aligned} \end{equation} \end{proof} \begin{lemma} One cannot measure phases by projecting states. \end{lemma} \begin{proof} Let $\ket{\psi}$ be a state, $\ket{\varphi}\bra{\varphi}$ a projector. $\ket{\psi'} := \exp(i\phi)\ket{\psi}$ for some $\phi \in [0, 2\pi)$. \begin{equation} \begin{aligned} \bra{\psi'}\ket{\varphi}\bra{\varphi}\ket{\psi'} &= \exp(-i\phi)\bra{\psi}\ket{\varphi}\bra{\varphi}\exp(i\phi)\ket{\psi} \\ & = \exp(-i\phi)\exp(i\phi)\bra{\psi}\ket{\varphi}\bra{\varphi}\ket{\psi} \\ & = \bra{\psi}\ket{\varphi}\bra{\varphi}\ket{\psi} \end{aligned} \end{equation} \end{proof} \begin{definition} A phase $\phi \in [0, 2\pi)$ is called qbit-global, if for some qbit states $\ket{\psi}, \ket{\varphi}$ $\ket{\psi} = \exp(i\phi)\ket{\varphi}$. \end{definition} \begin{lemma} When entangling qbits via projections one can disregard qbit-global phases. Two qbits are entangled via projection, if for some single qbit gates $M,N$ and two orthonormal states $\ket{a}, \ket{b}$ \begin{equation} C^{M,N}(i,j) = \ket{a}\bra{a}_j \otimes M_i + \ket{b}\bra{b}_j \otimes N_i \end{equation} \textbf{Remark.} In particular when entangling states using $CX$ and $CZ$ one can disregard qbit-global phases. This is immideatly clear when recalling \eqref{eq:CX_pr} and \eqref{eq:CZ_pr}. \end{lemma} \begin{proof} Let $\alpha, \beta \in [0, 2\pi)$ be some phases, $\ket{\psi}, \ket{\varphi}, \ket{\psi'} := \exp(i\alpha)\ket{\psi}, \ket{\varphi'} := \exp(i\beta)\ket{\varphi}$ some single qbit states, $M, N, \ket{a}, \ket{b}, C^{M,N}(i,j)$ as defined above. \begin{equation} \begin{aligned} C^{M,N}(1, 0) (\ket{\psi'}\otimes\ket{\varphi'}) & = \ket{a}\braket{a}{\varphi'}\otimes M\ket{\psi'} + \ket{b}\braket{b}{\varphi'} \otimes N\ket{\psi'} \\ & = \exp(i\beta)\ket{a}\braket{a}{\varphi}\otimes\exp(i\alpha)M\ket{\phi} + \exp(i\beta)\ket{b}\braket{b}{\varphi}\otimes\exp(i\alpha)N\ket{\phi}\\ & = \exp(i(\beta + \alpha))(\ket{a}\braket{a}{\varphi}\otimes M\ket{\psi} + \ket{b}\braket{b}{\varphi} \otimes N\ket{\psi})\\ & = \exp(i(\beta + \alpha))C^{M,N}(1, 0) (\ket{\psi}\otimes\ket{\varphi}) \end{aligned} \end{equation} Where $\exp(i(\beta + \alpha))$ is a multi-qbit-global phase which can be (following the above argumentation) disregarded. \end{proof} \begin{corrolary} One can disregard global phases of elements of the $C_1$ group. \end{corrolary} \begin{proof} As it has been shown above a quantum computer cannot measure global phases. Also the entanglement gates $CX, CZ$ map qbit-global phases to multi-qbit-global phases which cannot be measured. It has been shown above that one can choose the $C_1$ operators such that they do not yield a phase. \end{proof} \begin{definition} \begin{equation} C_L := \{a \in C_1 | \nexists \phi \in [0, 2\pi), b \in C_L : a = \exp(i\phi)b\} \end{equation} Is called the non-trivial local Clifford group. \end{definition} \textbf{Remark.} When computing the elements of $C_L$ and their products one will realize that $C_L$ is not a group. If one however disregards a global phase the product of two $C_L$ elements will be in $C_L$ again. Because the global phases can be disregarded as discussed above $C_L$ will be used from now on instead of $C_1$. \begin{theorem} \begin{equation} | C_L | = 24 \end{equation} \end{theorem} \begin{proof} It is clear that $\forall a \in C_L$ a is a group isomorphism $P \circlearrowleft$: $apa^\dagger a p' a^\dagger = a pp'a^\dagger$. Therefore $a$ will preserve the (anti-)commutator relations of $P$. Also $P$ is generated by $X,Z$ when disregarding a phase wich does not matter for anticommutator relations. This means that $X$ can be mapped to any $p \in P$ which are six elements disregarding FIXME \end{proof} \subsection{Introduction to the Graph Formalism} The first step towards the simulation in the graph formalism has been the discovery of the stabilizer states and stabilizer circuits \cite{gottesman2009}\cite{gottesman1997}. They led to the faster simulation using stabilizer tableaux\cite{gottesman_aaronson2008} and later to the graph formalism\cite{schlingenmann2001}\cite{andersbriegel2005}\cite{vandennest_ea2004}. The following discussion eludicates the graph formalism and explains how the graph simulator works. Some parts will be kept short as they can be looked up in \cite{andersbriegel2005}. A naive state is just a vector containing the coefficients $c_i$ as defined in \ref{ref:nqbitsystems}. It is a quite straight forward approach and gates are applied by updating the coefficients according to the gate's matrix representation. A naive state has the time and space complexity $\mathcal{O}(2^n)$ which limits the number of qbits drastically. \\ The stabilizer tableaux represent the state by its stabilizers i.e. by those Pauli operators of which the state is a $+1$ eigenstate. This has a space complexity of $\mathcal{O}(n^2)$ while updating the tableaux has a time complexity of $\mathcal{O}(n)$ for unitary gates and $mathcal{O}(n^2)$ for measurements. A graph state now represents the state by the gates that have been applied to it starting from the $\ket{+}$ state: \begin{equation} \ket{+} := \bigotimes\limits_{i=0}^{n-1} H_i \ket{0} \end{equation} \begin{definition} \label{def:graph_state} A graph state $\ket{G}$ is a 3-tuple $(V, E, O)$ where $(V = \{0, ..., n-1\}, E)$ is a graph with the vertices $V$, edges $E$ and vertex operators $O = \{o_i | i = 0, ..., n-1; o_i \in C_L \forall i\}$. The vertex operators and edges are defined by the following relation: \begin{equation} \label{eq:g_state} \ket{G} = \left(\bigotimes\limits_{i=0}^{n-1} o_i \right)\left(\bigotimes\limits_{\{i, j\} \in E} CZ_{i,j} \right) \ket{+} \end{equation} \end{definition} Where every $o_i$ acts on the $i$-th qbit. One can show that any stabilizer state can be realized as a graph state (for instance in \cite{schlingenmann2001}). \subsubsection{The Vertex Operator-Free Graph States} In order to understand some essential transformations of graph states it is necessary to study the vertex operator-free graph states first, partially because the graph states as used in this paper were derived from the vertex operator-free graph states. \begin{definition} \label{def:vop_free_g_state} A $n$ qbit vertex operator-free graph state $\ket{\overline{G}}$ is associated with a graph $(V, E)$ by the $n$ operators \begin{equation} K^{(i)}_G := X_i \left(\prod\limits_{\{i, j\} \in E} Z_j\right) \end{equation} for all $i \in V$ where for some operator $O$ $O_i$ indicates that it acts on the $i$-th qbit. A state $\ket{\overline{G}}$ is a $+1$ eigenstate of all $n$ $K^{(i)}_G$. \end{definition} \begin{corrolary} All $K^{(i)}_G$ commute and are hermitian. Therefore they have a common set of eigen states (in particular definition \ref{def:vop_free_g_state} is well defined). In terms of quantum mechanics $K^{(i)}_G$ are observables. Further as $\ket{\overline{G}}$ is a $+1$ eigenstate of all $n$ $K^{(i)}_G$ which are multi-local Pauli operators, $\{K^{(i)}_G | i \in \{0, ..., n-1\}\}$ is the stabilizer of $\ket{\overline{G}}$ and $\ket{\overline{G}}$ is a stabilizer state. \end{corrolary} \begin{proof} As $X_i$ and $Z_i$ are hermitian their product is hermitian. Consider the case $\{i,j\} \notin E$ first: \begin{equation} \begin{aligned} \left[K^{(i)}_G, K^{(j)}_G\right] = \left[X_i \prod\limits_{\{i, n\} \in E} Z_n, X_j \prod\limits_{\{j, m\} \in E} Z_m\right] = 0 \end{aligned} \end{equation} As operators acting on different qbits commute. The case $\{i,j\} \in E$ is slightly less trivial: \begin{equation} \begin{aligned} \left[K^{(i)}_G, K^{(j)}_G\right] &= \left[X_i \left(\prod\limits_{\{i, n\} \in E, n \neq j} Z_n\right) Z_j, X_j \left(\prod\limits_{\{j, m\} \in E, m \neq i} Z_m\right) Z_i\right] \\ &= \left[X_i Z_j \prod\limits_n Z_n, X_j Z_i \prod\limits_m Z_m\right]\\ &= \left(X_i Z_j X_j Z_i - X_j Z_i X_i Z_j\right) \prod\limits_n Z_n \prod\limits_m Z_m \\ &= \left(Z_j X_j X_i Z_i - X_j Z_j Z_i X_i\right) \prod\limits_n Z_n \prod\limits_m Z_m \\ &= \left((-1)^2X_j Z_j Z_i X_i - X_j Z_j Z_i X_i\right) \prod\limits_n Z_n \prod\limits_m Z_m \\ &= 0 \end{aligned} \end{equation} as $X$, $Z$ anticommute. \end{proof} \begin{lemma} \begin{equation} \ket{\overline{G}} = \left(\prod\limits_{\{i,j\} \in E} CZ_{i,j} \right) \left(\prod\limits_{l \in V} H_l\right) \ket{0} \end{equation} In particular definitions \ref{def:vop_free_g_state} and \ref{def:graph_state} are consistent, when there are no vertex operators on the graph state $\ket{G}$. \end{lemma} \begin{proof} Let $\ket{+} := \left(\prod\limits_{l \in V} H_l\right) \ket{0}$ as before. Note that for any $X_i$ $X_i \ket{+} = +1 \ket{+}$. Set $\ket{\tilde{G}} := \left(\prod\limits_{\{i,j\} \in E} CZ_{i,j} \right)\ket{+}$. \begin{equation} \begin{aligned} K_G^{(i)} \ket{\tilde{G}} & = X_i \left(\prod\limits_{\{i,j\} \in E} Z_j\right)\left(\prod\limits_{\{l,j\} \in E} CZ_{l,j} \right) \ket{+} \\ & = \left(\prod\limits_{\{i,j\} \in E} Z_j\right)X_i\prod\limits_{\{l,j\} \in E}\left( \ket{0}\bra{0}_j \otimes I_l + \ket{1}\bra{1}_j \otimes Z_l\right) \ket{+} \\ & = \left(\prod\limits_{\{i,j\} \in E} Z_j\right)\prod\limits_{\{l,j\} \in E}\left( \ket{0}\bra{0}_j \otimes I_l + (-1)^{\delta_{i,l}}\ket{1}\bra{1}_j \otimes Z_l\right) X_i \ket{+} \\ & = \prod\limits_{\{l,j\} \in E}\left( \ket{0}\bra{0}_j \otimes I_l + (-1)^{2\delta_{i,l}}\ket{1}\bra{1}_j \otimes Z_l\right) \ket{+} \\ & = \prod\limits_{\{l,j\} \in E}\left( \ket{0}\bra{0}_j \otimes I_l + \ket{1}\bra{1}_j \otimes Z_l\right) \ket{+} \\ & = +1 \ket{\tilde{G}} \end{aligned} \end{equation} as $X, Z$ anticommute and $Z\ket{1} = -1\ket{1}$. \end{proof} These insights can be used to understand how measurement works on the vop-free graph state \cite{nielsen_chuang_2010}: Consider a state $\ket{\psi}$ that is stabilized by $g_1, ... g_n$ and a hermitian $g$ that is to be measured. \subsection{Operations on the Graph State} \subsubsection{Single Qbit Gates} Recalling \eqref{eq:g_state} Makes it clear that for any single qbit gate $g \in C_L$ with $g_k$ being the gate acting on qbit $k$ the state changes according to \begin{equation} \begin{aligned} g_k \ket{G} &= g_k \left(\bigotimes\limits_{i=0}^{n-1} o_{i} \right)\left(\bigotimes\limits_{\{i, j\} \in E} CZ_{i,j} \right) \ket{+} \\ &= \left(\bigotimes\limits_{i=0}^{n-1} g_k^{\delta_{i,k}}o_{i} \right)\left(\bigotimes\limits_{\{i, j\} \in E} CZ_{i,j} \right)\ket{+} \end{aligned} \end{equation} meaning that the graph state $(V, E, O)$ changes to $(V, E, \{o_0, ..., o_{k-1}, go_k, o_{k+1}, ..., o_{n-1}\})$ as $C_L$ is almost a group the element $go_k \in C_L$ up to a global phase that is disregarded. All the results of $C_L \times C_L \rightarrow C_L, a,b \mapsto ab$ have been precomputed in a lookup table and the vertex operators are updated according to that lookup table. \subsubsection{Controlled Phase Gate} Recalling \eqref{eq:g_state} it is clear that some $CZ$ application is less trivial than a single qbit gate. %\begin{struktogramm}(100, 50) % \ifthenelse[10]{1, 4} % {Both Vertex operators Commute with CZ}{\sTrue}{\sFalse} % \change % \ifend %\end{struktogramm} \subsubsection{Measurement of a Qbit} Note that the $Z$ gate is diagonal in the $\{\ket{1}_s,\ket{0}_s\}$ basis with eigen values $1, -1$. This gives a simple expression for the projector on the $\ket{0}_s$ and $\ket{1}_s$ state of qbit $k$: \begin{equation} \tilde{P^{v}_{k}} := \frac{I_k + (-1)^vZ_k}{2}, v \in {0, 1} \end{equation} This projector trivially commutes with any non-operand vertex operator yielding for a state \begin{equation} \begin{aligned} \ket{\psi} := \left(\bigotimes\limits_{\{i,j\} \in E} CZ_{i,j}\right) \ket{+} \\ \tilde{P^{v}_{k}} \left(\bigotimes\limits_{i=0}{n-1} o_i\right)\ket{\psi} &= \left(\bigotimes\limits_{i=0,i \ne k}{n-1} o_i\right) \tilde{P^{v}_{k}} o_k \ket{\psi} \\ &= \left(\bigotimes\limits_{i=0,i \ne k}{n-1} o_i\right) o_ko_k^\dagger \tilde{P^{v}_{k}} o_k \ket{\psi} \\ &= \left(\bigotimes\limits_{i=0,i \ne k}{n-1} o_i\right) o_k = \frac{I_k + (-1)^v o_k^\dagger Z_ko_k}{2} \ket{\psi} \end{aligned} \end{equation} Now $o_k$ stabilizes $P$, as it is an element of $C_L$, meaning that $o_k^\dagger Z_k o_k \in \{-1,1\}\{X_k, Y_k, Z_k\}$ Which gives a new projector on a Pauli matrix: $P_k := o_k^\dagger Z_ko_k$ \subsection{Graph Storage} One of the gread advantages of simulating in the graph formalism is a great increase in simulation performance and a lower memory requirement. The simulation of at least $10^6$ qbits on a common desktop computer should be possible\cite{andersbriegel2005}. Therefore one has to take care when choosing a representation of the graph state. The following FIXME \subsection{Usage} FIXME \subsection{Performance} FIXME