* [29] Robert J. McEliece.  On periodic sequences from GF($q$).  J. Comb. Theory Ser. A., 10(1):80–91, 1971.  doi:10.1016/0097-3165(71)90066-5.
  * [30] Robert J. McEliece.  Weight congruences for p-ary cyclic codes.  Discrete Math, 3(1):177–192, 1972.  doi:10.1016/0012-365X(72)90032-5.
  * [31] Sepehr Nezami and Jeongwan Haah.  Classification of small triorthogonal codes.  Phys. Rev. A, 106:012437, Jul 2022.  doi:10.1103/PhysRevA.106.012437.
  * [32] Michael A. Nielsen and Isaac L. Chuang.  Quantum Computation and Quantum Information: 10th Anniversary Edition.  Cambridge University Press, 2011.
  * [33] Tefjol Pllaha, Narayanan Rengaswamy, Olav Tirkkonen, and Robert A. Calderbank.  Un-weyl-ing the Clifford hierarchy.  Quantum, 4:370, 2020.  doi:10.22331/q-2020-12-11-370.
  * [34] Ben W. Reichardt.  Quantum universality from magic states distillation applied to css codes.  Quantum Inf. Process., 4(3):251–264, 2005.  doi:10.1007/s11128-005-7654-8.
  * [35] Narayanan Rengaswamy, Robert A. Calderbank, Michael Newman, and Henry D. Pfister.  On optimality of CSS codes for transversal $T$.  IEEE J. Sel. Areas in Inf. Theory, 1(2):499–514, 2020.  doi:10.1109/jsait.2020.3012914.
  * [36] Narayanan Rengaswamy, Robert A. Calderbank, and Henry D. Pfister.  Unifying the Clifford hierarchy via symmetric matrices over rings.  Phys. Rev. A, 100(2):022304, 2019.  doi:10.1103/physreva.100.022304.
  * [37] A. M. Steane.  Simple quantum error-correcting codes.  Phys. Rev. A, 54(6):4741–4751, 1996.  doi:10.1103/PhysRevA.54.4741.
  * [38] Michael Vasmer and Aleksander Kubica.  Morphing quantum codes.  PRX Quantum, 3(3), Aug 2022.  doi:10.1103/prxquantum.3.030319.
  * [39] Christophe Vuillot and Nikolas P. Breuckmann.  Quantum pin codes.  IEEE Trans. Inf. Theory, 68(9):5955–5974, Sep 2022.  doi:10.1109/tit.2022.3170846.
  * [40] Mark M Wilde.  Quantum information theory.  Cambridge University Press, 2013.
  * [41] Paolo Zanardi and Mario Rasetti.  Noiseless quantum codes.  Phys. Rev. Lett., 79(17):3306, 1997.  doi:10.1103/PhysRevLett.79.3306.
  * [42] Bei Zeng, Xie Chen, and Isaac L. Chuang.  Semi-Clifford operations, structure of $\mathcal{C}_{k}$ hierarchy, and gate complexity for fault-tolerant quantum computation.  Phys. Rev. A, 77(4):042313, 2008.  doi:10.1103/physreva.77.042313.
  * [43] Bei Zeng, Andrew Cross, and Isaac L. Chuang.  Transversality versus universality for additive quantum codes.  IEEE Trans. Inf. Theory, 57(9):6272–6284, 2011.  doi:10.1109/tit.2011.2161917.

##  Appendix A Magic State Distillation Using the Steane Code

We use the Steane code as an example to show the trade-off between fidelity
and the probability of success in magic state distillation. Classical magic
state distillation post-selects on the trivial syndrome without considering
the error correction. If we follow this procedure, then the $[\\![7,1,3]\\!]$
Steane code can be used to distill the state with linear convergence as
described in Case 1. In Case 2, we try to increase the probability of success
by introducing error-correction instead of post-selecting on the trivial
syndrome. In Case 3, we consider only correcting one of non-trivial syndromes.

Case 1: Reichardt [34] calculated error rate by tracking evolution of code
states. The generator coefficient framework makes it possible to calculate the
output error rate by tracking operators.

  1. (i)

Encode to get the $|{\overline{+}}\rangle$ of the Steane codestate.

  2. (ii)

Given seven copies of
$|{A}\rangle:=T|+\rangle=(|0\rangle+e^{\imath\pi/4}|1\rangle)/\sqrt{2}$ and
ancillary qubits, we can realize the phsyical transversal $T^{\otimes
7}=[\exp(-\imath\frac{\pi}{8}Z)]^{\otimes 7}$ with the help of Clifford gates
and Pauli measurements. If the states $|{A}\rangle$ are exact, the probability
of observing the trivial syndrome is
$p^{e}_{\bm{\bm{\mu}=\bm{0}}}=\frac{9}{16}$ and the probability of observing
each non-trivial syndrome is $p^{e}_{\bm{\bm{\mu}\neq\bm{0}}}=\frac{1}{16}$
(Take $\theta=\frac{\pi}{4}$ in (114)). When the trivial syndrome is observed,
it follows from Example 1 that the induced logical operator is
$T^{\dagger}_{L}=\exp(\imath\frac{\pi}{8}Z_{L})$. We then apply a physical
representation of the logical $P$hase gate $\overline{P}$ to obtain
$|{\overline{A}}\rangle=P_{L}T^{\dagger}_{L}|{\overline{+}}\rangle$. In
practice, each of the input magic states $|{A}\rangle$ is noisy. We assume
dephasing noise: $\rho\to(1-p)\rho+pZ\rho Z$ with the same probability $p$ of
a Pauli $Z$ error for each of the seven physical qubits. The probability of
observing the trivial syndrome involves two terms. The first term captures the
event that upon observing the trivial syndrome $\bm{\mu}=\bm{0}$, the
dephasing error is undetectable. The second term captures the event that upon
observing the non-trivial syndrome $\bm{\mu}\neq\bm{0}$, the dephasing error
cancels the observed syndrome. The probability of success is given by

$\displaystyle P_{\bm{\mu}=\bm{0}}$
$\displaystyle=p^{e}_{\bm{\bm{\mu}=\bm{0}}}P(Z\text{-error in
}\mathcal{C}_{2}^{\perp})+\sum_{\bm{\mu}\neq\bm{0}}p^{e}_{\bm{\bm{\mu}}}P(Z\text{-error
in }\mathcal{C}_{2}^{\perp}+\bm{\mu})$ (166)
$\displaystyle=\frac{9}{16}\sum_{\bm{v}\in\mathcal{C}_{2}^{\perp}}(1-p)^{7-w_{H}(\bm{v})}p^{w_{H}(\bm{v})}+\sum_{\bm{\mu}\neq\bm{0}}\frac{1}{16}\sum_{\bm{v}\in\mathcal{C}_{2}^{\perp}+\bm{\mu}}(1-p)^{7-w_{H}(\bm{v})}p^{w_{H}(\bm{v})}$
(167)
$\displaystyle=\frac{9}{16}\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{v}\in\mathcal{C}_{2}}(1-2p)^{w_{H}(\bm{v})}+\frac{7}{16}\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{v}\in\mathcal{C}_{2}}(-1)^{\bm{v}\bm{e_{1}}^{T}}(1-2p)^{w_{H}(\bm{v})}$
(168) $\displaystyle=\frac{1}{16}\left(2+7(1-2p)^{4}\right).$ (169)

Note that the $7$ cosets corresponding to non-trivial syndromes have identical
weight enumerators.

  3. (iii)

If we observe the non-trivial syndrome $\bm{\mu}\neq 0$, we declare failure
and restart. Upon observing the trivial syndrome, we decode and the output
mixed state is

$\rho_{out}=\frac{1}{P_{\bm{\mu}=\bm{0}}}(p_{out}^{0}|{A}\rangle\langle{A}|+p_{out}^{1}Z|{A}\rangle\langle{A}|Z)$
(170)

where

$\displaystyle p_{out}^{0}$
$\displaystyle=p^{e}_{\bm{\bm{\mu}=\bm{0}}}P(Z\text{-error in
}\mathcal{C}_{1}^{\perp})+\sum_{\bm{\mu}\neq\bm{0}}p^{e}_{\bm{\bm{\mu}}}P(Z\text{-error
in }\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}\text{ for
}\bm{\gamma}\neq\bm{0})$ (171)
$\displaystyle=\frac{9}{16}\sum_{\bm{v}\in{\mathcal{C}_{1}^{\perp}}}(1-p)^{n-w_{H}(\bm{v})}p^{w_{H}(\bm{v})}+\sum_{\bm{\mu}\neq
0}\frac{1}{16}\sum_{\bm{v}\in{\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{1}}}(1-p)^{n-w_{H}(\bm{v})}p^{w_{H}(\bm{v})}$
(172)
$\displaystyle=\frac{1}{32}\left(2+7(1-2p)^{3}+7(1-2p)^{4}+2(1-2p)^{7}\right).$
(173)

The first term captures the event that upon observing the the trivial syndrome
$\bm{\mu}=\bm{0}$, the dephasing error acts as a $Z$-stabilizer
($B_{\bm{\mu}=\bm{0}}=\frac{3}{4}\bar{T}^{\dagger}$). The second captures the
event that upon observing the the non-trivial syndrome $\bm{\mu}\neq\bm{0}$,
the dephasing error lies in $\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}$
($B_{\bm{\mu}\neq\bm{0}}=\frac{1}{4}\bar{T}^{\dagger}\bar{Z}$). In this case,
the dephasing error appears as the error correction that maps back to the code
space and results in a logical $T^{\dagger}$ gate. We now write the output
error rate $q$ as a function of the initial error rate $p$, and calculate its
Taylor expansion at $0$

$q(p)=1-\frac{p_{out}^{0}}{P_{\bm{\mu}=\bm{0}}}=\frac{7}{9}p+\frac{14}{81}p^{2}+O(p^{3}).$
(174)

This implies that the threshold for the initial error rate is $0.1464...$ (the
same as [34]), while that of the $[\\![15,1,3]\\!]$ code is $0.1415..$ [10].

Case 2: Note that probability of success in Case 1 is upper bounded by
$9/16=56.25\%$. It is natural to ask whether we may introduce error correction
to increase the probability of success. It follows from (102) that we can
choose proper corrections based on syndromes ($\bm{\gamma_{\mu}}=\bar{Z}$ for
$\bm{\mu}\neq\bm{0}$) to obtain the logical operator $T^{\dagger}$ with
probability $1$ if the physical transversal $T$ is exact. The output error-
rate now becomes

$\displaystyle q(p)=1-p^{0}_{out}=1-P(Z\text{-error in
}\mathcal{C}_{1}^{\perp})=\sum_{\bm{v}\in{\mathcal{C}_{1}^{\perp}}}(1-p)^{n-w_{H}(\bm{v})}p^{w_{H}(\bm{v})}=\frac{1}{8}\left(1+7(1-2p)^{4}\right).$
(175)

The output error rate does not fall below the line $y=x$ in the positive
orthant, and we say that the protocol does not converge.

Case 3: We balance Case 1 and Case 2 by implementing error correction for only
one of the seven non-trivial syndromes, say $\bm{\mu}=\bm{e_{1}}$. Although
the probability of success increases slightly to

$\displaystyle
P_{S}=P_{\bm{\mu}=\bm{0}}+P_{\bm{\mu}=\bm{e_{1}}}=\frac{1}{16}\left(2+7(1-2p)^{4}\right)+\frac{1}{16}\left(2-(1-2p)^{4}\right)=\frac{1}{8}\left(2+3(1-2p)^{4}\right),$
(176)

the prefactor of the linear term of the output error rate is greater than 1.
We conclude that the protocol does not converge.

The same analysis can be performed for a code that is perfectly preserved by
the transversal $T$ gate, such as the $[\\![15,1,3]\\!]$ code. The analysis
provides insight into the trade-off between the probability of success and the
fidelity of the output magic states.

##  Appendix B Generator Coefficient Framework for Stabilizer codes

We described the generator coefficient framework for CSS code and we now
extend it to arbitrary stabilizer codes. We consider a general stabilizer code
generated by the matrix

$\displaystyle G_{\mathcal{S}}=\left[\begin{array}[]{c c}K&0\\\ \hline\cr
0&J\\\ \hline\cr\lx@intercol\hfil D\hfil\lx@intercol\\\ \end{array}\right],$
(180)

where $D=(D_{x},D_{z})$ such that $D_{x}$ is the $X$-component of $D$ and
$D_{z}$ is the $Z$-component of $D$. We assume that the row space of $D$
contains no non-zero vector $\bm{c}=(\bm{c_{X}},\bm{c_{Z}})$ with
$\bm{c_{X}}=\bm{0}$ or $\bm{c_{Z}}=\bm{0}$. Assume the dimensions of $K$, $J$,
and $D$ are $n_{x},n_{z},n_{xz}$ respectively. Then, we have

$\displaystyle\Pi_{\mathcal{S}}=\Pi_{\mathcal{S}_{X}}\Pi_{\mathcal{S}_{Z}}\Pi_{\mathcal{S}_{XZ}},$
(181)

where

$\Pi_{\mathcal{S}_{X}}=\frac{1}{2^{n_{x}}}\sum_{\bm{a}\in\mathcal{K}=\langle
K\rangle}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0}),\leavevmode\nobreak\
\Pi_{\mathcal{S}_{Z}}=\frac{1}{2^{n_{z}}}\sum_{\bm{b}\in\mathcal{J}=\langle
J\rangle}\epsilon_{(\bm{0},\bm{b})}E(\bm{0},\bm{b}),\text{ and }$ (182)
$\Pi_{\mathcal{S}_{XZ}}=\frac{1}{2^{n_{xz}}}\sum_{(\bm{c},\bm{d})\in\mathcal{D}=\langle
D\rangle}\epsilon_{(\bm{c},\bm{d})}E(\bm{c},\bm{d}).$ (183)

Let $\mathcal{T}\coloneqq\langle K,D_{x}\rangle$. Then,
$\mathcal{J}\subset\mathcal{T}^{\perp}\subset\mathbb{F}_{2}^{n}$ as described
below.

$\\{\bm{0}\\}$$\mathcal{C}_{2}$$\mathcal{C}_{1}$$\mathbb{F}_{2}^{n}$$\\{\bm{0}\\}$$\mathcal{C}_{1}^{\perp}$$\mathcal{C}_{2}^{\perp}$$\mathbb{F}_{2}^{n}$$\\{\bm{0}\\}$$\mathcal{K}$$\langle
J,D_{z}\rangle^{\perp}$$\mathbb{F}_{2}^{n}$$\\{\bm{0}\\}$$\mathcal{J}$$\mathcal{T}^{\perp}=\langle
K,D_{x}\rangle^{\perp}$$\mathbb{F}_{2}^{n}$StabilizerCSS$\bm{\mu}$$\bm{\gamma}$$\bm{\mu}$$\bm{\gamma}$

Then (60) becomes

$\displaystyle\Pi_{\mathcal{S}_{Z}}U_{Z}$
$\displaystyle=\left(\frac{1}{2^{n_{z}}}\sum_{\bm{b}\in\mathcal{J}}\epsilon_{(\bm{0},\bm{b})}E(\bm{0},\bm{b})\right)\left(\sum_{\bm{v}\in\mathbb{F}_{2}^{n}}f(\bm{v})E(\bm{0},\bm{v})\right)$
$\displaystyle=\frac{1}{2^{n_{z}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}}\left(\sum_{\bm{z}\in\mathcal{J}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{v})}f(\bm{z})\right)\sum_{\bm{u}\in\mathcal{J}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u}),$
(184)

and the generator coefficients of $U_{Z}$ for the stabilizer code
$\mathcal{S}$ are given by

$A_{\bm{\mu},\bm{\gamma}}^{\mathcal{S}}\coloneqq\sum_{\bm{z}\in\mathcal{J}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{z})}f(\bm{z}),$
(185)

where $\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}$ and
$\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}$. These generalized generator
coefficients inherit the properties described in Theorem 6, that is,

$\displaystyle\sum_{{\bm{\mu}}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}}\overline{A_{\bm{\mu},\bm{\gamma}}^{\mathcal{S}}}A_{\bm{\mu},\bm{\eta}\oplus\bm{\gamma}}^{\mathcal{S}}=\left\\{\begin{array}[]{lc}1\leavevmode\nobreak\
\leavevmode\nobreak\ \text{ if }{\bm{\eta}}=\mathbf{0},\\\
0\leavevmode\nobreak\ \leavevmode\nobreak\ \text{ if
}{\bm{\eta}}\neq\mathbf{0},\end{array}\right.$ (188)

for $\bm{\eta}\in\mathcal{T}^{\perp}/\mathcal{J}$. Grouping together the
projectors $\Pi_{\mathcal{S}_{X}}$ and $\Pi_{\mathcal{S}_{XZ}}$, we consider
the new family of projectors

$\displaystyle\mathcal{L}$
$\displaystyle\coloneqq\Pi_{\mathcal{S}_{X}}\Pi_{\mathcal{S}_{XZ}}$
$\displaystyle=\left(\frac{1}{2^{n_{x}}}\sum_{\bm{a}\in\mathcal{K}=\langle
K\rangle}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\right)\left(\frac{1}{2^{n_{xz}}}\sum_{(\bm{c},\bm{d})\in\mathcal{D}=\langle
D\rangle}\epsilon_{(\bm{c},\bm{d})}E(\bm{c},\bm{d})\right)$
$\displaystyle=\frac{1}{2^{n_{x}+n_{xz}}}\sum_{\begin{subarray}{c}\bm{a}\in\mathcal{K},\\\
(\bm{c},\bm{d})\in\mathcal{D}\end{subarray}}\epsilon_{(\bm{a}\oplus\bm{c})}\imath^{-\bm{a}\bm{d}^{T}}(-1)^{\bm{d}(\bm{a}*\bm{c})^{T}}E(\bm{a}\oplus\bm{c},\bm{d}).$
(189)

For $\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}$, we write

$\displaystyle\mathcal{L}_{(\bm{\mu})}\coloneqq\left(\frac{1}{2^{n_{x}}}\sum_{\bm{a}\in\mathcal{K}=\langle
K\rangle}(-1)^{\bm{\mu
a}^{T}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\right)\left(\frac{1}{2^{n_{xz}}}\sum_{(\bm{c},\bm{d})\in\mathcal{D}=\langle
D\rangle}(-1)^{\bm{\mu
c}^{T}}\epsilon_{(\bm{c},\bm{d})}E(\bm{c},\bm{d})\right),$ (190)

and note that
$\\{\mathcal{L}_{(\bm{\mu})}\\}_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}}$
is a resolution of identity.

Replacing the resolution of identity
$\\{\Pi_{\mathcal{S}_{X}(\bm{\mu})}\\}_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}$
by
$\\{\mathcal{L}_{(\bm{\mu})}\\}_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp}}$,
we conclude that the generator coefficients
$\\{A_{\bm{\mu},\bm{\gamma}}^{\mathcal{S}}\\}_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{T}^{\perp},\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}}$
describe the same average logical channel as in (93) and (94) since the
logical Pauli $Z$ for stabilizer codes can be chosen as
$\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}$ up to a sign. Based on the
description of the average logical channel, we study the conditions for the
invariance of a stabilizer code as below.

######  Theorem 22.

Consider a general stabilizer code defined by (180). Consider
$\mathcal{T}=\langle K,H_{x}\rangle$, and we have
$\mathcal{J}\subset\mathcal{T}^{\perp}\subset\mathbb{F}_{2}^{n}$. Then, a
$Z$-unitary gate
$U_{Z}=\sum_{\bm{v}\in\mathbb{F}_{2}^{n}}f(\bm{v})E(\bm{0},\bm{v})$ preserves
$\mathcal{V}(\mathcal{S})$ (i.e.
$U_{Z}\Pi_{\mathcal{S}}U_{Z}^{\dagger}=\Pi_{\mathcal{S}}$) if and only if

$\sum_{\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}}|A_{\bm{0},\bm{\gamma}}^{\mathcal{S}}|^{2}=1.$
(191)

###### Proof.

$\Leftarrow$: We assume (191) holds and derive
$U_{Z}\Pi_{\mathcal{S}}=\Pi_{\mathcal{S}}U_{Z}$. It follows from (188) that
$A_{\bm{\mu},\bm{\gamma}}^{\mathcal{S}}=0$ when $\bm{\mu}\neq\bm{0}$. Then, by
(184), we have

$U_{Z}\Pi_{\mathcal{S}_{Z}}=\Pi_{\mathcal{S}_{Z}}U_{Z}=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}}A_{\bm{0},\bm{\gamma}}^{\mathcal{S}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right).$
(192)

For any $\bm{\gamma}\in\mathcal{T}^{\perp}/\mathcal{J}$ and
$\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}\subset\mathcal{T}^{\perp}$, we
have $E(\bm{0},\bm{u})\mathcal{L}=\mathcal{L}E(\bm{0},\bm{u})$, where
$\mathcal{L}=\Pi_{\mathcal{S}_{X}}\Pi_{\mathcal{S}_{XZ}}$. Hence,

$\displaystyle U_{Z}\Pi_{\mathcal{S}}$
$\displaystyle=U_{Z}\Pi_{\mathcal{S}_{Z}}\mathcal{L}=\mathcal{L}U_{Z}\Pi_{\mathcal{S}_{Z}}=\mathcal{L}\Pi_{\mathcal{S}_{Z}}U_{Z}=\Pi_{\mathcal{S}}U_{Z}.$
(193)

$\Rightarrow$: We assume $U_{Z}\Pi_{\mathcal{S}}=\Pi_{\mathcal{S}}U_{Z}$ and
show (191). The idea is the same as in the proof of Theorem 7, and it remains
to show that each term in (189) is distinct in order to use the independence
of Pauli matrices. Assume
$(\bm{a}\oplus\bm{c},\bm{d})=(\bm{a}^{\prime}\oplus\bm{c}^{\prime},\bm{d}^{\prime})$
for some $\bm{a},\bm{a}^{\prime}\in\mathcal{K}$ and
$(\bm{c},\bm{d}),(\bm{c}^{\prime},\bm{d}^{\prime})\in\mathcal{D}$. Then,
$\bm{d}=\bm{d}^{\prime}$ and
$\bm{a}\oplus\bm{c}=\bm{a}^{\prime}\oplus\bm{c}^{\prime}$. Note that
$(\bm{c},\bm{d})\oplus(\bm{c}^{\prime},\bm{d}^{\prime})=(\bm{c}\oplus\bm{c}^{\prime},\bm{0})\in\mathcal{D}$.
Since $J\cap D_{x}=\\{\bm{0}\\}$, we have
$\bm{c}\oplus\bm{c}^{\prime}=\bm{0}$, which means $\bm{c}=\bm{c}^{\prime}$ and
$\bm{a}=\bm{a}^{\prime}$. ∎

######  Theorem 23.

Consider an $[\\![n,k,d]\\!]$ stabilize code generated by the matrix
$G_{\mathcal{S}}=\left[\begin{array}[]{c c}K&0\\\ \hline\cr 0&J\\\
\hline\cr\lx@intercol\hfil D\hfil\lx@intercol\\\ \end{array}\right]$ that
satisfies Theorem 22. Let $\mathcal{J}$ be the space defined by the generator
matrix $J$. Assume the minimum weight in $\mathcal{J}$ is at least $d$ (i.e.
$\min_{\bm{z}\in\mathcal{J}}w_{H}(z)\geq d$). Then the CSS code generated by
$G_{\mathcal{S^{\prime}}}=\left[\begin{array}[]{c c}K&0\\\ \hline\cr 0&J\\\
\hline\cr D_{x}&0\\\ \end{array}\right]$ satisfies Theorem 7. Moreover, the
CSS code has parameters $n^{\prime}=n$, $k^{\prime}=k$, and the $Z$-distance
$d^{\prime}_{Z}=\min_{\bm{z}\in\langle
K,D_{x}\rangle^{\perp}\setminus\mathcal{J}}w_{H}(\bm{z})\geq d$.

###### Proof.

From the construction of $G_{\mathcal{S^{\prime}}}$, the number of physical
qubits does not change ($n^{\prime}=n$). Also, $k^{\prime}=k$ follows from the
fact that $D_{x}\cap K=\\{\bm{0}\\}$. It remains to show that the new
$Z$-distance $d^{\prime}_{Z}\geq d$.

Assume there exists
$(\bm{s},\bm{t})\in\mathcal{N}(\mathcal{S^{\prime}})\setminus\mathcal{S^{\prime}}$
such that $h(\bm{s},\bm{t})<d$ and $\bm{t}\neq\bm{0}$, where $h$ is the Pauli
weight (number of nontrivial Pauli matrices) defined by

$h(\bm{s},\bm{t})=w_{H}(\bm{s})+w_{H}(\bm{t})-w_{H}(\bm{s}*\bm{t}).$ (194)

Then, $h(\bm{0},\bm{t})<d$ and $\bm{t}\in M^{\perp}\cap D_{x}^{\perp}$, which
implies that $(\bm{0},\bm{t})\in\mathcal{N}(S)$. Also by definition, we have
$J\cap D_{z}=\\{\bm{0}\\}$ and thus
$(\bm{0},\bm{t})\in\mathcal{N}(\mathcal{S})\setminus\mathcal{S}$. However, by
assumption the distance of $\mathcal{V}(\mathcal{S})$ is $d$ and thus
$\mathcal{N}(\mathcal{S})\setminus\mathcal{S}$ has minimum weight $d$, which
is a contradiction. Therefore, $d^{\prime}_{Z}\geq d$. ∎

######  Remark 24.

Note that the values of generator coefficients are the same for the
$[\\![n,k,d]\\!]$ stabilizer code and the
$[\\![n^{\prime}=n,k^{\prime}=k,d^{\prime}_{Z}\geq d]\\!]$ CSS code. The
induced logical operator by $U_{Z}$ remains the same. It follows from Theorem
23 that given an $[\\![n,k,d]\\!]$ non-degenerate stabilizer code supporting a
physical $U_{Z}=\sum_{\bm{v}\in\mathbb{F}_{2}^{n}}f(\bm{v})E(\bm{0},\bm{v})$
quantum (unitary) gate, there exists an equivalent CSS code (since the Pauli
expansion of the physical gate $U_{Z}$ has support only on Pauli $Z$, we only
compare the distance $d$ of stabilizer code with the $Z$-distance of the
equivalent CSS code) supporting the same operation. Note that a similar
argument applies to
$U_{X}=\sum_{\bm{v}\in\mathbb{F}_{2}^{n}}f(\bm{v})E(\bm{v},\bm{0})$.

##  Appendix C Proofs for All Results

###  C.1 Proof of Lemma 4

Setting
$\mathcal{B}=\\{\bm{z}\in\mathcal{C}_{1}^{\perp}\mid\epsilon_{(\bm{0},\bm{z})}=1\\}$,
we have $\mathcal{B}^{\perp}=\langle\mathcal{C}_{1},\bm{y}\rangle$. Setting

$S_{p}=\sum_{\bm{z}\in\mathcal{B}+\bm{\mu}+\bm{\gamma}}\left(\cos\frac{\theta}{2}\right)^{n-w_{H}(\bm{z})}\left(-\imath\sin\frac{\theta}{2}\right)^{w_{H}(\bm{z})},$
(195)

and

$S_{n}=\sum_{\bm{z}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\left(\cos\frac{\theta}{2}\right)^{n-w_{H}(\bm{z})}\left(-\imath\sin\frac{\theta}{2}\right)^{w_{H}(\bm{z})},$
(196)

we may rewrite (3.1) as

$(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{y}^{T}}A_{\bm{\mu},\bm{\gamma}}(\theta)=2S_{p}-S_{n}.$
(197)

Since
$\mathcal{B}+\bm{\mu}+\bm{\gamma}=\langle\mathcal{B},\bm{\mu}\oplus\bm{\gamma}\rangle\setminus\mathcal{B}$
and
$\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}=\langle\mathcal{C}_{1}^{\perp},\bm{\mu}\oplus\bm{\gamma}\rangle\setminus\mathcal{C}_{1}^{\perp}$,
we have

$(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{y}^{T}}A_{\bm{\mu},\bm{\gamma}}(\theta)=2(P_{\theta}[\langle\mathcal{B},\bm{\mu}\oplus\bm{\gamma}\rangle]-P_{\theta}[\mathcal{B}])-(P_{\theta}[\langle\mathcal{C}_{1}^{\perp},\bm{\mu}\oplus\bm{\gamma}\rangle]-P_{\theta}[\mathcal{C}_{1}^{\perp}]).$
(198)

We may apply the MacWilliams Identities to obtain

$\displaystyle
P_{\theta}[\langle\mathcal{B},\bm{\mu}\oplus\bm{\gamma}\rangle]$
$\displaystyle=\frac{1}{|\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}|}P_{\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(\cos\frac{\theta}{2}-\imath\sin\frac{\theta}{2},\cos\frac{\theta}{2}+\imath\sin\frac{\theta}{2}\right)$
$\displaystyle=\frac{1}{|\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(\cos\frac{\theta}{2}-\imath\sin\frac{\theta}{2}\right)^{n-2w_{H}(\bm{z})}$
$\displaystyle=\frac{2}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})},$
(199)

and similarly

$\displaystyle P_{\theta}[\mathcal{B}]$
$\displaystyle=\frac{1}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}.$
(200)

We combine (199) and (200) to obtain

$\displaystyle
P_{\theta}[\langle\mathcal{B},\bm{\mu}\oplus\bm{\gamma}\rangle]-P_{\theta}[\mathcal{B}]$
$\displaystyle=\frac{2}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}-\frac{1}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}$
$\displaystyle=\frac{1}{|\mathcal{B}^{\perp}|}\left(\sum_{\bm{z}\in\mathcal{B}^{\perp}\cap(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}-\sum_{\bm{z}\in\mathcal{B}^{\perp}\setminus(\bm{\mu}\oplus\bm{\gamma})^{\perp}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}\right)$
$\displaystyle=\frac{1}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}}(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{z}^{T}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}.$
(201)

Similarly,

$P_{\theta}[\langle\mathcal{C}_{1}^{\perp},\bm{\mu}\oplus\bm{\gamma}\rangle]-P_{\theta}[\mathcal{C}_{1}^{\perp}]=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{z}\in\mathcal{C}_{1}}(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{z}^{T}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}.$
(202)

Since $\mathcal{B}^{\perp}\setminus\mathcal{C}_{1}=\mathcal{C}_{1}+\bm{y}$, it
follows from (198), (201), (202) that

$\displaystyle(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{y}^{T}}A_{\bm{\mu},\bm{\gamma}}(\theta)$
$\displaystyle=\frac{2}{|\mathcal{B}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}^{\perp}}(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{z}^{T}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}-\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{z}\in\mathcal{C}_{1}}(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{z}^{T}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{z}\in\mathcal{C}_{1}+\bm{y}}(-1)^{(\bm{\mu}\oplus\bm{\gamma})\bm{z}^{T}}\left(e^{-\imath\frac{\theta}{2}}\right)^{n-2w_{H}(\bm{z})},$
(203)

which completes the proof.∎

###  C.2 Derivation of (88)

$\displaystyle U_{Z}\Pi_{\mathcal{S}}$
$\displaystyle=U_{Z}\Pi_{\mathcal{S}_{Z}}\Pi_{\mathcal{S}_{X}}$
$\displaystyle=\frac{1}{2^{n-k_{1}+k_{2}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)\left(\sum_{\bm{a}\in\mathcal{C}_{2}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\right)$
$\displaystyle=\frac{1}{2^{n-k_{1}+k_{2}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}\bm{\mu}^{T}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\right)\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\Pi_{\mathcal{S}_{X}(\bm{\mu})}\left(\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)\right),$
(204)

where
$\Pi_{\mathcal{S}_{X}(\bm{\mu})}=\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}\bm{\mu}^{T}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})$.
∎

###  C.3 Derivation of $\theta(\theta_{L})$

Since there is only one logical qubit, $\bm{\gamma}$ is either zero or non-
zero. It then follows from (76) and (77) that the effective physical operator
corresponding to the syndrome $\bm{\mu}=\bm{0}$ is

$\displaystyle
B_{\bm{\mu}=\bm{0}}=A_{\bm{\mu}=\bm{0},\bm{\gamma}=\bm{0}}E(\bm{0},\bm{0})+A_{\bm{\mu}=\bm{0},\bm{\gamma}\neq\bm{0}}E(\bm{0},\bm{\gamma}\neq\bm{0}).$
(205)

Thus, if we observe the trivial syndrome, then the induced logical portion is

$\displaystyle
U_{Z}^{L}(\bm{\mu}=\bm{0})=A_{\bm{\mu}=\bm{0},\bm{\gamma}=\bm{0}}I_{L}+A_{\bm{\mu}=\bm{0},\bm{\gamma}\neq\bm{0}}Z_{L}=\begin{bmatrix}A_{\bm{0},\bm{\gamma}=\bm{0}}+A_{\bm{0},\bm{\gamma}\neq\bm{0}}&0\\\
0&A_{\bm{0},\bm{\gamma}=\bm{0}}-A_{\bm{0},\bm{\gamma}\neq\bm{0}}\end{bmatrix}.$
(206)

Since we also assume that one of the pair
$(A_{\bm{\mu}=\bm{0},\bm{\gamma}=\bm{0}},A_{\bm{\mu}=\bm{0},\bm{\gamma}\neq\bm{0}})$
is real and the other is pure imaginary, we can consider
$U_{Z}^{L}(\bm{\mu}=\bm{0})$ as a $Z$-rotation with angle $\theta_{L}$ up to
some logical Pauli $Z_{L}$:

$\displaystyle
U_{Z}^{L}(\bm{\mu}=\bm{0})=\left\\{\begin{array}[]{lc}\cos(\theta_{L}/2)I_{L}+\imath\sin(\theta_{L}/2)Z_{L}=R_{Z}(\theta_{L})&\text{if
}A_{\bm{\mu}=\bm{0},\bm{\gamma}=\bm{0}}\text{ is real }\\\
\imath\sin(\theta_{L}/2)I_{L}+\cos(\theta_{L}/2)Z_{L}=Z_{L}R_{Z}(\theta_{L})&\text{if
}A_{\bm{\mu}=\bm{0},\bm{\gamma}\neq\bm{0}}\text{ is real }\end{array}\right.,$
(209)

with
$\theta_{L}/2=\tan^{-1}\left(\frac{\sin(\theta_{L}/2)}{\cos(\theta_{L}/2)}\right)=\tan^{-1}\left(\frac{\imath
A_{\bm{\mu}=\bm{0},\bm{\gamma}\neq\bm{0}}}{A_{\bm{\mu}=\bm{0},\bm{\gamma}=\bm{0}}}\right).$

###  C.4 Proof of Theorem 6

It follows from (3.1) that

$\displaystyle\overline{A_{\bm{\mu},\bm{\gamma}}}A_{\bm{\mu},\bm{\eta}\oplus\bm{\gamma}}$
$\displaystyle=\left(\sum_{\bm{z}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{z})}f(\bm{z})\right)\left(\sum_{\bm{z^{\prime}}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\eta}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{z^{\prime}})}f(n,\bm{z^{\prime}})\right)$
$\displaystyle=\sum_{\bm{w}\in\mathcal{C}_{1}^{\perp}+\bm{\eta}}\epsilon_{(\bm{0},\bm{w})}\left(\sum_{\bm{z}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}f(\bm{z})\overline{f(\bm{z}\oplus\bm{w})}\right).$
(210)

Then, we have

$\displaystyle\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\overline{A_{\bm{\mu},\bm{\gamma}}}A_{\bm{\mu},\bm{\eta}\oplus\bm{\gamma}}$
$\displaystyle=\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{{\bm{\gamma}}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\sum_{\bm{w}\in\mathcal{C}_{1}^{\perp}+\bm{\eta}}\epsilon_{(\bm{0},\bm{w})}\left(\sum_{\bm{z}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}f(\bm{z})\overline{f(\bm{z}\oplus\bm{w})}\right)$
$\displaystyle=\sum_{\bm{w}\in\mathcal{C}_{1}^{\perp}+\bm{\eta}}\epsilon_{(\bm{0},\bm{w})}\left(\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\sum_{\bm{z}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}f(\bm{z})\overline{f(\bm{z}\oplus\bm{w})}\right)$
$\displaystyle=\sum_{\bm{w}\in\mathcal{C}_{1}^{\perp}+\bm{\eta}}\epsilon_{(\bm{0},\bm{w})}\left(\sum_{\bm{z}\in\mathbb{F}_{2}^{n}}f(\bm{z})\overline{f(\bm{z}\oplus\bm{w})}\right)$
$\displaystyle=\left\\{\begin{array}[]{lc}\epsilon_{(\bm{0},\bm{0})}=1&\text{
if }\bm{\eta}=\bm{0}\\\ 0&\text{ if }\bm{\eta}\neq\bm{0}\end{array}\right.,$
(211)

where the last step follows from the fact that $U_{Z}$ is unitary (58). ∎

###  C.5 Derivation of (109)

$\displaystyle\Pi_{\mathcal{S}_{X}(\bm{\mu_{0}})}U_{Z}\Pi_{\mathcal{S}_{Z}}|{\phi}\rangle$
$\displaystyle=\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}\bm{\mu_{0}}^{T}}\epsilon_{(\bm{a},\bm{0)}}E(\bm{a},\bm{0})\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\epsilon_{(\bm{0},\bm{\mu}\oplus\bm{\gamma})}E(\bm{0},\bm{\mu}\oplus\bm{\gamma})|{\phi}\rangle$
$\displaystyle=\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{\mu}}\sum_{\bm{\gamma}}A_{\bm{\mu},\bm{\gamma}}\epsilon_{(\bm{0},\bm{\mu}\oplus\bm{\gamma})}E(\bm{0},\bm{\mu}\oplus\bm{\gamma})\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}(\bm{\mu}+\bm{\mu_{0}})^{T}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})|{\phi}\rangle$
$\displaystyle=\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{\mu}}\sum_{\bm{\gamma}}A_{\bm{\mu},\bm{\gamma}}\epsilon_{(\bm{0},\bm{\bm{\mu}\oplus\bm{\gamma}})}E(\bm{0},\bm{\mu}\oplus\bm{\gamma})\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}(\bm{\mu}\oplus\bm{\mu_{0}})^{T}}|{\phi}\rangle,$
(212)

where (212) follows from the fact
$\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\in\mathcal{S}$. ∎

###  C.6 Proof of Theorem 7

Recall from (60) that $U_{Z}\Pi_{S_{\mathcal{Z}}}=\Pi_{S_{\mathcal{Z}}}U_{Z}$
simplifies to

$\displaystyle U_{Z}\Pi_{\mathcal{S}_{Z}}$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\mu}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right).$
(213)

$\Leftarrow$: We assume (119) holds and derive
$U_{Z}\Pi_{\mathcal{S}}=\Pi_{\mathcal{S}}U_{Z}$. By Theorem 6, we have
$A_{\bm{\mu},\bm{\gamma}}=0$ when $\bm{\mu}\neq\bm{0}$. It follows from (60)
that

$U_{Z}\Pi_{\mathcal{S}_{Z}}=\Pi_{\mathcal{S}_{Z}}U_{Z}=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{0},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right).$
(214)

For any $\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}$ and
$\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}\subset\mathcal{C}_{2}^{\perp}$,
we have
$E(\bm{0},\bm{u})\Pi_{\mathcal{S}_{X}}=\Pi_{\mathcal{S}_{X}}E(\bm{0},\bm{u})$.
Hence,

$\displaystyle
U_{Z}\Pi_{\mathcal{S}}=U_{Z}\Pi_{\mathcal{S}_{Z}}\Pi_{\mathcal{S}_{X}}$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{0},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}}\epsilon_{(\bm{0},\bm{u})}\Pi_{\mathcal{S}_{X}}E(\bm{0},\bm{u})\right)$
$\displaystyle=\Pi_{\mathcal{S}_{X}}U_{Z}\Pi_{\mathcal{S}_{Z}}=\Pi_{\mathcal{S}_{X}}\Pi_{\mathcal{S}_{Z}}U_{Z}=\Pi_{\mathcal{S}}U_{Z}.$
(215)

$\Rightarrow$: We assume $U_{Z}\Pi_{\mathcal{S}}=\Pi_{\mathcal{S}}U_{Z}$ and
show (119). It follows from (88) that

$\displaystyle U_{Z}\Pi_{\mathcal{S}}$
$\displaystyle=U_{Z}\Pi_{\mathcal{S}_{Z}}\Pi_{\mathcal{S}_{X}}$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\left(\Pi_{\mathcal{S}_{X}(\bm{\mu})}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}+\bm{\mu}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)\right)=\Pi_{\mathcal{S}}U_{Z}.$
(216)

Pairwise orthogonality of projectors implies
$\Pi_{\mathcal{S}_{X}(\bm{\mu})}\Pi_{\mathcal{S}_{X}(\bm{\mu^{\prime}})}=0$
when $\bm{\mu}\neq\bm{\mu^{\prime}}$ in
$\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}$. Hence, for any
$\bm{\mu_{0}}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}\setminus\\{\bm{0}\\}$,
we have we have
$0=\Pi_{\mathcal{S}_{X}(\bm{\mu_{0}})}\Pi_{\mathcal{S}_{X}}\Pi_{\mathcal{S}_{Z}}U_{Z}=\Pi_{\mathcal{S}_{X}(\bm{\mu_{0}})}(\Pi_{\mathcal{S}}U_{Z})=\Pi_{\mathcal{S}_{X}(\bm{\mu_{0}})}(U_{Z}\Pi_{\mathcal{S}})$,
which implies that

$\displaystyle 0$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\sum_{\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}}\left(\Pi_{\mathcal{S}_{X}(\bm{\mu_{0}})}\Pi_{\mathcal{S}_{X}(\bm{\mu})}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}+\bm{\mu}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)\right)$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\Pi_{S_{X}(\bm{\mu_{0}})}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu_{0}},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}+\bm{\mu_{0}}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)$
$\displaystyle=\frac{1}{2^{n-k_{1}}}\left(\frac{1}{2^{k_{2}}}\sum_{\bm{a}\in\mathcal{C}_{2}}(-1)^{\bm{a}\bm{\mu_{0}}^{T}}\epsilon_{(\bm{a},\bm{0})}E(\bm{a},\bm{0})\right)\left(\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}A_{\bm{\mu_{0}},\bm{\gamma}}\left(\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}+\bm{\mu_{0}}}\epsilon_{(\bm{0},\bm{u})}E(\bm{0},\bm{u})\right)\right)$
$\displaystyle=\frac{1}{2^{n-k_{1}+k_{2}}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\sum_{\bm{u}\in\mathcal{C}_{1}^{\perp}+\bm{\gamma}+\bm{\mu_{0}}}\sum_{\bm{a}\in\mathcal{C}_{2}}A_{\bm{\mu_{0}},\bm{\gamma}}(-1)^{\bm{a}\bm{\mu_{0}}^{T}}\imath^{\bm{a}\bm{\mu_{0}}^{T}}\epsilon_{(\bm{a},\bm{u})}E(\bm{a},\bm{u}).$
(217)

Since Pauli matrices are linear independent, we have
$A_{\bm{\mu_{0}},\bm{\gamma}}=0$ for all
$\bm{\mu}\in\mathbb{F}_{2}^{n}/\mathcal{C}_{2}^{\perp}\setminus\\{\bm{0}\\}$
and all $\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}$, and
$\eqref{eqn:preserved_by_Uz}$ holds. ∎

###  C.7 Proof of Lemma 11

$\Rightarrow$: Assume (122) holds for all
$\bm{v_{1}},\bm{v_{2}}\in\mathcal{C}_{1}+\bm{y}$ such that
$\bm{v_{1}}\oplus\bm{v_{2}}\in\mathcal{C}_{2}$. Then, (126) is satisfied. Let
$\bm{v_{1}},\bm{v_{2}}\in(\mathcal{C}_{1}+\bm{y})/(\mathcal{C}_{2}+\bm{y})$
and $\bm{v_{1}}\oplus\bm{v_{2}}\in\mathcal{C}_{2}$. Then we can write
$\bm{v_{1}}=\bm{u_{1}}+\bm{w}+\bm{y}$ and
$\bm{v_{2}}=\bm{u_{2}}+\bm{w}+\bm{y}$ for
$\bm{u_{1}},\bm{u_{2}}\in\mathcal{C}_{2}$ and
$\bm{w}\in\mathcal{C}_{1}/\mathcal{C}_{2}$. We simplify (122) as

$\displaystyle 2^{l}$
$\displaystyle\mid(\bm{u_{1}}+\bm{w}+\bm{y})R(\bm{u_{1}}+\bm{w}+\bm{y})^{T}-(\bm{u_{2}}+\bm{w}+\bm{y})R(\bm{u_{2}}+\bm{w}+\bm{y})^{T}$
(218) $\displaystyle 2^{l}$
$\displaystyle\mid\left((\bm{u_{1}}+\bm{y})R(\bm{u_{1}}+\bm{y})^{T}-(\bm{u_{2}}+\bm{y})R(\bm{u_{2}}+\bm{y})^{T}\right)+2\left((\bm{u_{1}}+\bm{y})R\bm{w}^{T}-(\bm{u_{1}}+\bm{y})R\bm{w}^{T}\right)$
(219) $\displaystyle 2^{l}$ $\displaystyle\mid
2(\bm{u_{1}}-\bm{u_{2}})R\bm{w}^{T},$ (220)

since $\bm{u_{1}}+\bm{y},\bm{u_{2}}+\bm{y}\in\mathcal{C}_{2}+\bm{y}$. Thus,
(127) is also satisfied.

$\Leftarrow$: We simply reverse (218), (219), and (220). ∎

###  C.8 Proof of Theorem 12

The proof idea is the same as that of Theorem 9 We take
$U_{Z}=R_{Z}\left(\frac{\pi}{p}\right)$ and simplify (4) using (119):

$\displaystyle 1$
$\displaystyle=\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\left|A_{\bm{0},\bm{\gamma}}\left(\frac{\pi}{p}\right)\right|^{2}$
$\displaystyle=\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\frac{1}{|\mathcal{C}_{1}|^{2}}\sum_{\bm{z_{1}},\bm{z_{2}}\in\mathcal{C}_{1}+\bm{y}}(-1)^{\bm{\gamma}(\bm{z_{1}}\oplus\bm{z_{2}})^{T}}\left(e^{\imath\frac{\pi}{p}}\right)^{w_{H}(\bm{z_{1}})-w_{H}(\bm{z_{2}})}.$
(221)

Setting $\bm{w}=\bm{z_{1}}\oplus\bm{z_{2}}$ and $\bm{z}=\bm{z_{2}}$, we obtain

$\displaystyle 1$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|^{2}}\sum_{\bm{w}\in\mathcal{C}_{1}}\sum_{\bm{z}\in\mathcal{C}_{1}+\bm{y}}\left(e^{\imath\frac{\pi}{p}}\right)^{w_{H}(\bm{w}\oplus\bm{z})-w_{H}(\bm{z})}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}(-1)^{\bm{\gamma}\bm{w}^{T}}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|^{2}}\frac{|\mathcal{C}_{1}|}{|\mathcal{C}_{2}|}\sum_{\bm{w}\in\mathcal{C}_{2}}\sum_{\bm{z}\in\mathcal{C}_{1}+\bm{y}}\left(e^{\imath\frac{\pi}{p}}\right)^{w_{H}(\bm{w}\oplus\bm{z})-w_{H}(\bm{z})}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}||\mathcal{C}_{2}|}\sum_{\bm{w}\in\mathcal{C}_{2}}\sum_{\bm{z}\in\mathcal{C}_{1}+\bm{y}}\left(e^{\imath\frac{\pi}{p}}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{w}*\bm{z})},$
(222)

Note that (222) implies every term in the double sum is equal to $1$, which
completes the proof.

###  C.9 Proof of Lemma 17

It follows from (4) that

$|A_{\bm{0},\bm{\gamma}}(\theta)|^{2}=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{w}\in\mathcal{C}_{1}}(-1)^{\bm{\gamma}\bm{w}^{T}}s_{\bm{w}},$
(223)

where

$s_{\bm{w}}\coloneqq\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{z}\in\mathcal{C}_{1}+\bm{y}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{w}*\bm{z})}.$
(224)

Then

$\displaystyle\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}|A_{\bm{0},\bm{\gamma}}(\theta)|^{2}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\left(\sum_{\bm{w}\in\mathcal{C}_{2}}(-1)^{\bm{\gamma}\bm{w}^{T}}s_{\bm{w}}+\sum_{\bm{w}\in\mathcal{C}_{1}\setminus\mathcal{C}_{2}}(-1)^{\bm{\gamma}\bm{w}^{T}}s_{\bm{w}}\right)$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\sum_{\bm{w}\in\mathcal{C}_{2}}s_{\bm{w}}+\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{w}\in\mathcal{C}_{1}\setminus\mathcal{C}_{2}}\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}(-1)^{\bm{\gamma}\bm{w}^{T}}s_{\bm{w}}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|}\frac{|\mathcal{C}_{1}|}{|\mathcal{C}_{2}|}\sum_{\bm{w}\in\mathcal{C}_{2}}s_{\bm{w}}=\frac{1}{|\mathcal{C}_{2}|}\sum_{\bm{w}\in\mathcal{C}_{2}}s_{\bm{w}},$
(225)

where the last step follows from the fact for any
$\bm{w}\in\mathcal{C}_{1}\setminus\mathcal{C}_{2}$,
$\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}(-1)^{\bm{\gamma}\bm{w}^{T}}=0$.
Thus, (225) equals $1$ if and only if $s_{\bm{w}}=1$ for all
$\bm{w}\in\mathcal{C}_{2}$. Note that $s_{\bm{0}}=1$, and for all non-zero
$\bm{w}$, we have

$\displaystyle s_{\bm{w}}$
$\displaystyle=\frac{1}{|\mathcal{C}_{1}|}\sum_{\bm{z}\in\mathcal{C}_{1}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{w}*(\bm{z}\oplus\bm{y}))}$
$\displaystyle=\frac{1}{|\mathcal{D}_{\bm{w}}|}\sum_{\bm{v}\in\mathcal{D}_{\bm{w}}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w}*(\bm{v}\oplus\bm{y}))}$
$\displaystyle=\frac{1}{|\mathcal{D}_{\bm{w}}|}\sum_{\bm{x}\in\mathcal{D}_{\bm{w}}+\bm{w}*\bm{y}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{x})}.$
(226)

Thus,
$\sum_{\bm{\gamma}\in\mathcal{C}_{2}^{\perp}/\mathcal{C}_{1}^{\perp}}\left|A_{\bm{0},\bm{\gamma}}(\theta)\right|^{2}=1$
if and only if (161) holds for all non-zero $\bm{w}\in\mathcal{C}_{2}$. ∎

###  C.10 Proof of Lemma 18

We first show that
$\mathcal{D}_{\bm{w}}+\bm{w}*\bm{y}\subseteq\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})+\bm{y}^{\prime}$.
Let $\bm{z}\in\mathcal{C}_{1}$. Then,
$\bm{w}*\bm{z}\oplus\bm{w}*\bm{y}\in\mathcal{D}_{\bm{w}}+\bm{w}*\bm{y}$. Let
$\bm{v}\in\mathcal{Z}_{\bm{w}}\subseteq\mathcal{C}_{1}^{\perp}$. We observe

$\left(\bm{w}*(\bm{z}\oplus\bm{y})\oplus\bm{y}^{\prime}\right)*\bm{v}=\bm{z}*\bm{w}*\bm{v}\oplus\bm{y}*\bm{w}*\bm{v}\oplus\bm{y}^{\prime}*\bm{v}=\bm{z}*\bm{v}\oplus\bm{y}*\bm{v}\oplus\bm{y}^{\prime}*\bm{v},$
(227)

where the last step follows from
$\mathrm{supp}(\bm{x})\subseteq\mathrm{supp}(\bm{w})$. Since
$\bm{x}\in\mathcal{C}_{1}^{\perp}$ and $\bm{z}\in\mathcal{C}_{1}$,
$w_{H}(\bm{z}*\bm{v})=0\bmod 2$. We consider two cases. If
$\bm{v}\in\mathcal{B}_{\bm{w}}\subseteq\mathcal{Z}_{\bm{w}}$, then
$w_{H}(\bm{y}*\bm{v})=0\bmod 2$ and $w_{H}(\bm{y}^{\prime}*\bm{v})=0\bmod 2$.
Otherwise, $\bm{v}\in\mathcal{Z}_{\bm{w}}\setminus\mathcal{B}_{\bm{w}}$. Then
$w_{H}(\bm{y}*\bm{v})=1\bmod 2$ and $w_{H}(\bm{y}^{\prime}*\bm{v})=1\bmod 2$.
For both cases,
$w_{H}(\left(\bm{w}*(\bm{z}\oplus\bm{y})\oplus\bm{y}^{\prime}\right)*\bm{v})=0\bmod
2$. Thus,
$\bm{w}*(\bm{z}\oplus\bm{y})\oplus\bm{y}^{\prime}\in\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})$,
which implies that
$\bm{w}*(\bm{z}\oplus\bm{y})\in\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})+\bm{y}^{\prime}$.
Then, we have
$\mathcal{D}_{\bm{w}}+\bm{w}*\bm{y}\subseteq\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})+\bm{y}^{\prime}$.

It remains to show that
$|\mathcal{D}_{\bm{w}}|=|\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})|$.
We observe that
$\mathcal{D}_{\bm{w}}=\mathcal{C}_{1}\big{|}_{\bm{1}-\bm{w}}=(\mathcal{C}_{1}^{\perp}\big{|}_{\bm{1}-\bm{w}})^{\perp}$.
Thus,
$\dim(\mathcal{D}_{\bm{w}})=w_{H}(\bm{w})-d_{\bm{w}}=\dim(\mathcal{Z}_{\bm{w}}^{\perp})=\dim(\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})),$
which completes the proof. ∎

###  C.11 Proof of Lemma 19

We rewrite (164) as

$2\sum_{\bm{v}\in\mathcal{B}_{\bm{w}}}\left(\imath\tan\theta\right)^{w_{H}(\bm{v})}-\sum_{\bm{v}\in\mathcal{Z}_{\bm{w}}}\left(\imath\tan\theta\right)^{w_{H}(\bm{v})}=\left(\sec\theta\right)^{w_{H}(\bm{w})},$
(228)

and rearrange to obtain

$2\sum_{\bm{v}\in\mathcal{B}_{\bm{w}}}\left(\cos\theta\right)^{w_{H}(\bm{w})-w_{H}(\bm{v})}\left(\sin\theta\right)^{w_{H}(\bm{v})}-\sum_{\bm{v}\in\mathcal{Z}_{\bm{w}}}\left(\cos\theta\right)^{w_{H}(\bm{w})-w_{H}(\bm{v})}\left(\sin\theta\right)^{w_{H}(\bm{v})}=1.$
(229)

We apply the MacWilliams Identities to $P_{2\theta}[\mathcal{B}_{\bm{w}}]$ and
$P_{2\theta}[\mathcal{Z}_{\bm{w}}]$ ($P_{\theta}[\mathcal{C}]$ is deifned in
(4) for any angle $\theta$ and linear code $\mathcal{C}$) to obtain

$\frac{2}{|\mathcal{B}_{\bm{w}}^{\perp}|}\sum_{\bm{z}\in\mathcal{B}_{\bm{w}}^{\perp}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{z})}-\frac{1}{|\mathcal{Z}_{\bm{w}}^{\perp}|}\sum_{\bm{z}\in\mathcal{Z}_{\bm{w}}^{\perp}}\left(e^{\imath\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{z})}=1.$
(230)

Since $|\mathcal{B}_{\bm{w}}^{\perp}|=2|\mathcal{Z}_{\bm{w}}^{\perp}|$,
$\mathcal{B}_{\bm{w}}^{\perp}=\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{B}}_{\bm{w}}^{\perp})$,
and
$\mathcal{Z}_{\bm{w}}^{\perp}=\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})$,
we obtain

$\frac{1}{\left|\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})\right|}\sum_{\bm{v}\in\mathrm{proj}_{\bm{w}}(\tilde{\mathcal{Z}}_{\bm{w}}^{\perp})+\bm{y^{\prime}}}\left(e^{i\theta}\right)^{w_{H}(\bm{w})-2w_{H}(\bm{v})}=1,$
(231)

which completes the proof. ∎