\documentclass[dvipsnames]{article}

\usepackage[a4paper,left=3cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mleftright}
\usepackage{bm}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{acro}
\usepackage{braket}
\usepackage[
    backend=biber,
    style=ieee,
    sorting=nty,
]{biblatex}
\usepackage{todonotes}

\usetikzlibrary{calc, positioning}

\title{A Brief Introduction to Quantum Error Correction}
\author{Andreas Tsouchlos}

\DeclareAcronym{qec}{
    short=QEC,
    long=quantum error correction
}

\addbibresource{src/intro/MA.bib}

\begin{document}

\maketitle

% TODO: Give context for why we need QC and QEC, introduce quantum
% gates, and the X,Z,Y operators

Much like in classical error correction, in \ac{qec} information
is protected by mapping it onto codewords in an expanded
Hilbert space, thereby introducing redundancy. Take, for example, the
two-qubit code \cite{roffe_quantum_2019}, where we map%
%
\begin{align*}
    \ket{\psi} = \underbrace{a \ket{0} + b \ket{1}}_{\in
    \mathcal{H}_2} \hspace*{3mm}
    \rightarrow
    \hspace*{3mm} \ket{\psi}_\text{L} = \underbrace{a \ket{00} + b
    \ket{11}}_{\in \mathcal{H}_4}
    .%
\end{align*}%
%
We call $\ket{\psi}_L$ the logical state.
We define the codespace as $\mathcal{C} := \text{span}\mleft\{
\ket{00}, \ket{11} \mright\}$ and the error subspace as $\mathcal{F} :=
\text{span} \mleft\{\ket{01}, \ket{10} \mright\}$.
To determine if an error occurred, we want to measure
whether a state belongs%
\footnote{
    It is possible for a state to not completely lie in either subspace.
    In this case, we can interpret it as being in
    $\mathcal{C}$ or $\mathcal{F}$ with a certain probability.
}
to $\mathcal{C}$ or $\mathcal{F}$.

In quantum mechanics, measurements of observable quantities are
described using operators \cite[Section
1.5]{griffiths_introduction_1995}. Because of the way these operators are
defined, their eigenvalues correspond to the possible outcomes of
measuring that observable, and the corresponding
eigenstates are the determinate states%
\todo{Explain determinate states?}
%
that yield those values as
measurements \cite[Section 3.3]{griffiths_introduction_1995}.
In our case, we need an operator with two eigenvalues, and the corresponding
eigenspaces should be $\mathcal{C}$ and $\mathcal{F}$ respectively.
For the two-qubit code, $Z_1Z_2$ is such an operator:%
%
\begin{align*}
    Z_1Z_2 E \ket{\psi}_\text{L} &= (+1) E \ket{\psi}_\text{L}
    \hspace*{3mm} \forall
    E \ket{\psi}_\text{L} \in \mathcal{C} \\
    Z_1Z_2 E \ket{\psi}_\text{L} &= (-1) E \ket{\psi}_\text{L}
    \hspace*{3mm} \forall
    E \ket{\psi}_\text{L} \in \mathcal{F}
    .%
\end{align*}%
%
Here, $E$ is an operator describing a possible error and $E
\ket{\psi}_\text{L}$ is the resulting state after that error.
By measuring the corresponding eigenvalue, we can determine if
$E\ket{\psi}_\text{L}$ lies in $\mathcal{C}$ or $\mathcal{F}$.
To do this without directly measuring (and thus disturbing) the
logical state $\ket{\psi}_\text{L}$, we prepare an ancilla
qubit with state $\ket{0}_\text{A}$ and we entangle it with
$\ket{\psi}_\text{L}$ in such a way that determining that instead
indicates the eigenvalue. More specifically, using a syndrome
extraction circuit as shown in Figure \ref{fig:syndrome extraction}, we
transform the state of the three-qubit system as%
%
\begin{align*}
    E\ket{\psi}_\text{L} \ket{0}_\text{A} \hspace*{3mm} \rightarrow
    \hspace*{3mm}
    \underbrace{\frac{1}{2} \mleft( I_1I_2 + Z_1Z_2 \mright)}_{=:
    P_\mathcal{C}} E\ket{\psi}_\text{L}
    \ket{0}_\text{A}
    + \underbrace{\frac{1}{2} \mleft( I_1I_2 - Z_1Z_2 \mright)}_{=:
    P_\mathcal{F}}
    E\ket{\psi}_\text{L} \ket{1}_\text{A}
    .%
\end{align*}%
%
If $E \ket{\psi}_\text{L} \in \mathcal{C}$, the second term will
cancel and we will deterministically measure $\ket{0}_\text{A}$ for
the ancilla qubit. Similarly, if $E \ket{\psi}_\text{L} \in
\mathcal{F}$, we will deterministically measure $\ket{1}_\text{A}$.
In general, however, the resulting state of the three-qubit system will be a
superposition of the two cases.

Note that the expressions $P_\mathcal{C}$ and $P_\mathcal{F}$ above
essentially constitute projection operators onto $\mathcal{C}$ and
$\mathcal{F}$. E.g., $P_\mathcal{C}$ will eliminate all
components of a superposition state $E \ket{\psi}_\text{L}$ that lie
in $\mathcal{F}$.
By measuring the ancilla qubit, we collapse the overall state
into one of two configurations. In each of those configurations, $E
\ket{\psi}_\text{L}$ is projected back onto either $\mathcal{C}$ or
$\mathcal{F}$. At the same time, because $Z_1Z_2 \ket{\psi}_\text{L}
= \ket{\psi}_\text{L}$, the projections leave the logical state
$\ket{\psi}_\text{L}$ untouched.
\todo{Explain that the collapse of the error superposition enables
    the digitization of arbitrary error operations \cite[p.
434]{nielsen_quantum_2010}}
We have thus managed to determine
whether an error occurred without disturbing the encoded
quantum information.

\begin{figure}[H]
    \centering

    \tikzset{
        meter/.append style={
            draw, rectangle,
            font=\vphantom{A}, minimum width=8mm, minimum height=8mm,
            path picture={
                \draw[black]
                ([shift={(.1,.3)}]path picture bounding box.south west)
                to[bend left=50]
                ([shift={(-.1,.3)}]path picture bounding box.south east);
                \draw[black,-latex]
                ([shift={(0,.1)}]path picture bounding box.south)
                -- ([shift={(.3,-.1)}]path picture bounding box.north);
            }
        }
    }

    \begin{tikzpicture}
        \node[rectangle, minimum width=2cm, minimum height=3cm, draw]
        (ZZ) {$Z_1Z_2$};

        \coordinate (qi1) at (-3, 1);
        \coordinate (qi2) at (-3, -1);
        \coordinate (qi3) at (-3, -3);

        \coordinate (qo1) at (4, 1);
        \coordinate (qo2) at (4, -1);
        \coordinate (qo3) at (4, -3);

        \node[rectangle, minimum width=8mm, minimum height=8mm, draw]
        (H1) at ($(qo3 -| ZZ) + (-2, 0)$) {H};
        \node[rectangle, minimum width=8mm, minimum height=8mm, draw]
        (H2) at ($(qo3 -| ZZ) + (2, 0)$) {H};
        \node[circle, fill] (not) at (H1 -| ZZ) {};
        \node[meter, right=5mm of H2] (mes) {};

        \draw (qi1) -- (ZZ.west |- qi1);
        \draw (qi2) -- (ZZ.west |- qi2);

        \draw (qo1) -- (ZZ.east |- qo1);
        \draw (qo2) -- (ZZ.east |- qo2);

        \draw (qi3) -- (H1) -- (not) -- (H2) -- (mes);

        \draw (not) -- (ZZ);

        \coordinate (qo3u) at ($(qo3) + (0, .5mm)$);
        \coordinate (qo3d) at ($(qo3) + (0, -.5mm)$);

        \draw (mes.east |- qo3u) -- (qo3u);
        \draw (mes.east |- qo3d) -- (qo3d);

        \node[left] at (qi3) {$\ket{0}_\text{A}$};
        \node[left] at ($(qi1)!.5!(qi2)$) {$E\ket{\psi}_\text{L}$};
        \node[right] at ($(qo1)!.5!(qo2)$) {$E\ket{\psi}_\text{L}$};

    \end{tikzpicture}

    \caption{Syndrome extraction circuit for the two-qubit repetition code}
    \label{fig:syndrome extraction}
\end{figure}

\printbibliography

\end{document}

