I am learning about the CSS construction in Nielsen and Chuang, and I'm trying to understand the effect of $\otimes_{i=1}^n H_i$ on a code with $X$ and $Z$ stabilizer generators on the same sites. (Such a code occurs when $C_1$ and $C_2$ in the CSS construction are dual codes, which requires $C_2$ to be weakly self-dual; the resulting CSS code is sometimes called self-dual.)

It's clear that $\otimes_{i=1}^n H_i$ implements a logical operation on such codes by virtue of sending the stabilizer subgroup to itself, but I'm interested in which logical operation it is.

According to this answer, $\otimes_{i=1}^n H_i$ implements a logical Hadamard on such codes.

However, according to this question and answer, $\otimes_{i=1}^n H_i$ is only guaranteed to implement a logical Hadamard on such codes when we can find an appropriate orthonormal basis for a subspace of codewords (this can always be done for the important special case of $k=1$ logical qubit).

In the examples in the above questions and answers, it seems that when our $X$ and $Z$ stabilizer generators are identical, $\otimes_{i=1}^n H_i$ implements $\otimes_{j=1}^k H^{(L)}_{j}$ up to a permutation of the logical qubits (some product of logical swap operators).

Is this always true? That is, if my $X$ and $Z$ stabilizer generators are identical, can $\otimes_{i=1}^n H_i$ always be identified with a product of logical Hadamards on all logical qubits followed by a permutation of the logical qubits? Or can it be a more general logical operation?


2 Answers 2


When you're looking at questions of the action of a unitary on a code, there are two very separate questions:

  1. Is the codespace preserved? (i.e. are all the stabilizers mapped to products of stabilizers)
  2. What is the logical operation implemented within the codespace?

The stabilizers can't tell you anything about the answer to the second question. In part, this is because they don't tell you anything about the structure of the qubit inside the codespace - the assignment of 0 logical and 1 logical are completely arbitrary. You have to resolve this ambiguity first.

When you want to decide what the logical operation looks like, you could look at the basis states, but that's often quite painful. Instead, it's better to look at the action on the logical operators. Now, consider the case that you're interested in, with identical $X$ and $Z$ stabilizers. Note that each of these stabilizers must have even weight (otherwise an identical $X$ and $Z$ pair would not commute). Also, let's assume that $n$ is odd. That it's easy to prove that $X^{\otimes n}$ and $Z^{\otimes n}$ commute with all the stabilizers but are not stabilizers themselves (they anti-commute with each other). Thus, these two are logical operators. What they are is an arbitrary choice, so long as we correspond them to two things that anti-commute. Thus, for an $[[n,1,d]]$ code, we'd usually associate them with $X_L$ and $Z_L$, but you could be perverse and call them $(X_L\pm Y_L)/\sqrt{2}$ if you really wanted to. For a more general $[[n,k,d]]$ code, you could certainly choose to associate those two operations with logical $X$ and $Z$ of one of your $k$ qubits.

Now consider the effect of transversal Hadamard on the two operators. They are converted into each other: $$ X^{\otimes n}\leftrightarrow Z^{\otimes n}. $$ (Remember that you have to calculate the effect by doing $H^{\otimes n}X^{\otimes n}H^{\otimes n}$.) If we're interpreting these in the standard way ($k=1$, or as a single qubit's logicals for $k>1$), that means $$ X_L\leftrightarrow Z_L $$ This is exactly what logical Hadamard does on that specific logical qubit. But, any other assignment that you might choose could correspond to something different.

  • $\begingroup$ +1 Thank you, this is a good perspective to keep in mind. Suppose I restricted my freedom in choosing logicals, so that logicals that are products of $X$ operators I always call $X$ logicals, and logicals that are products of $Z$ operators I always call $Z$ logicals. Given such a choice of $X$ and $Z$-type logical representatives, will $H^{\otimes n}$ necessarily act as a product of logical $H$ on all my logical qubits up to a permutation of the logical qubits? Or is there still enough wiggle room to avoid this? $\endgroup$
    – user196574
    Dec 14, 2023 at 8:43
  • $\begingroup$ If you assume that you always call the (odd weight) X operators logical X, AND the matching Z is the logical Z, then yes, $H^{\otimes n}$ is necessarily Hadamard on every logical qubit (because $Z_L\leftrightarrow X_L$). $\endgroup$
    – DaftWullie
    Dec 14, 2023 at 8:59
  • $\begingroup$ I guess I would have expected something a little different. Even if $n$ is odd, if $k>1$, it's not clear to me that we can always choose all of our logical representatives to have odd weight. For example, for $n$ odd, if we choose one of conjugate pairs to be $X^{\otimes n}$ and $Z^{\otimes n}$, that choice forces the remaining logicals to have even weight (and hence the remaining conjugate pairs of logicals can't be on the same location). Then it's tempting that we'll get something that's not quite logical Hadamard on everything. $\endgroup$
    – user196574
    Dec 14, 2023 at 9:12
  • $\begingroup$ But remember that if you have two candidate logical $X$ operators, $X_1$ and $X_2$, one of which is odd weight, and one of which is even weight, I can instead choose my logical operators to be $X_1$ and $X_1X_2$, which will both have odd weight. $\endgroup$
    – DaftWullie
    Dec 14, 2023 at 9:46
  • $\begingroup$ Thanks again. I want to find logical representatives such that the $X$ logical representatives are made of $X$'s, the $Z$ logical representatives are made of $Z$'s, $[X_L^{(i)}, Z_L^{(i)}]_+ =0 \,\,\forall i$, $[X_L^{(i)}, Z_L^{(j)}]_-=0 \,\,\forall i \,\neq j$, and $X_L^{(i)}$ and $Z_L^{(i)}$ have support on the same locations. Here $i$ and $j$ run from $1$ to $k$. This is not always possible when $n$ is even. Tabling the case of $n$ even, are you claiming that it is always possible for $n$ odd? $\endgroup$
    – user196574
    Dec 14, 2023 at 18:07

As pointed out by DaftWullie, to answer the effect of a logical operation on the logical subspace, it's important to make explicit the basis of the logical subspace.

I will do this in the following way. For any CSS code, I can pick logical representatives that are purely $X$ or purely $Z$, and I can choose them to be pairwise "conjugate", identifying one with an "$X$"-type logical and the other with a "$Z$"-type logical.

Explicitly, I will require that $X$ logical representatives are made of $X$'s, the $Z$ logical representatives are made of $Z$'s, $[X^{(i)}_L,Z^{(i)}_L]_+=0 \,\, \forall \, i$, $[X^{(i)}_L,Z^{(j)}_L]_-=0 \,\, \forall \, i \neq j$, where $i,j$ run from $1$ to $k$. Once these logical representatives have been constructed, I have a logical computational basis written in terms of the simultaneous eigenvalues of the $Z$ logicals.

I will call a set of pairs of conjugate logical representatives that satisfy the above (and the corresponding computational logical basis) "reasonable."

In my question, I noted $\otimes_{i=1}^n H_i$ was a logical operator in these "self-orthogonal" CSS codes. The spirit of my question was whether we could find a reasonable basis for which this logical operator always had the effect of product of logical Hadamards up to a permutation of the logical qubits.

In the following, I show that the answer is yes, and I give an iterative procedure for constructing this basis. In fact, I will show that the permutation of the logical qubits can be made into a depth-1 circuit of swaps (so that the permutation is a rather gentle one).

Our self-orthogonal CSS code is determined by a code $C$ for which $C \subset C^\perp$. Let's write a linearly independent basis for $C$ as $A=\{a_1,...,a_m\}$. We can then write a basis for $C^\perp$ as $\{a_1,...,a_m, b_1, ..., b_k\}$. I will use the $b$'s to construct a reasonable set of logical representatives that also ensures that $\otimes_{i=1}^n H_i$ behaves as a product of all logical Hadamards up to swapping some pairs of logical qubits.

The following is a sketch of my algorithm for constructing the desired basis. Note that I'll interchange the words "bitstring" and "vector" freely.

The initial input is the linearly independent set $B=\{b_1, ..., b_k\}$ and $B' = \{\}$. The algorithm works by moving vectors from $B$ to $B'$, and then making the remaining vectors in $B$ orthogonal to the ones in $B'$ by adding the just-moved vectors to some appropriate remaining ones in $B$. The purpose of the moving and adding steps is to passively and actively maintain the linear independence of each of the sets $A,B,B'$, maintain $C^\perp = \text{span}\{A\cup B\cup B'\}$, and maintain the orthogonality of the bitstrings in each of $A,B,B'$ to those in the other two sets.

The above rules have an important consequence that allows the algorithm to continue running until $B$ is empty. So long as $B$ is not-empty, there will be at least one vector $c \in B$ such that $c \cdot c =1$ or at least one pair of vectors $f,g$ for which $f \cdot g =1$. This follows from the fact that the bitstrings in $B$ are not in $C=\left( C^\perp \right)^\perp$, so each bitstring in $B$ must have a product of $1$ with some bitstring in $C^\perp$. Since $B \in C^\perp$, but the vectors in $B$ are made orthogonal to the ones in $B'$ and $A$, this means that each vector in $B$ must have a nonvanishing product with at least one vector in $B$.

  1. Check if the set $B$ is empty. If it is, return $B'$. Otherwise, go to step 2.
  2. Check whether there is a bitstring $c$ in $B$ for which $c \cdot c = 1$. If there is not, go to step 3. If there is such a bitstring $c$, append $c$ to $B'$ and remove $c$ from $B$. For every bitstring $b$ in $B$ for which $c \cdot b = 1$, update $B$ by adding $c$ to that bitstring $b$. Return to step 1.
  3. Find a pair of bitstrings $f,g$ in $B$ such that $f \cdot g = 1$. Append $f$ and $g$ to $B'$, and remove them from $B$. Now consider the remaining vectors in $B$. Add $f$ to the bitstrings $b$ for which $g \cdot b = 1$, and add $g$ to the bitstrings $b$ for which $f \cdot b =1$. Return to step 1.

At the end, we have that $B'$ is a linearly independent set of $k$ vectors such that $C^\perp = \text{span}\{A\cup B'\}$. $B'$ can be partitioned into sets containing either one or two vectors: the sets with one vector $c$ have $c\cdot c =1$ and $c$ orthogonal to the rest of the vectors in $B'$; the sets with two vectors $f,g$ have $f \cdot g = 1$ and $f,g$ orthogonal to themselves and to the rest of the vectors in $B'$.

From this set of bitstrings, we can construct our logical representatives. Note that I'll use $X^b$ to mean the product of $X$ on the sites where the bitstring $b$ is $1$ and the identity otherwise.

For the singleton $c$'s, we construct the conjugate $X$ and $Z$ logicals $X^c$ and $Z^c$. For the pair $f,g$'s, we construct conjugate $X^f$ and $Z^g$, and conjugate $X^g$ and $Z^f$. By virtue of our construction, the $X$ and $Z$ logicals within a given conjugate pair anticommute, and the $X$ and $Z$ logicals in different conjugate pairs commute, so this is indeed a reasonable basis.

Let's consider the effect of a product of physical Hadamards $\otimes_{i=1}^n H_i$. For each singleton $c$, the conjugate $X$ and $Z$ logicals exchange, giving a logical Hadamard on that logical qubit. For each pair $f,g$, an $X$ logical of one conjugate pair exchanges with the $Z$ logical of the other conjugate pair (and vice-versa), so this gives logical Hadamards on these logical qubits followed by a logical swap gate.

The above shows that for these self-orthogonal CSS codes, we can always construct a reasonable basis where a product of physical Hadamards behaves as a product of logical Hadamards up to some logical swaps. This answers my question in the affirmative.

As an aside, note that for some self-orthogonal CSS codes, we cannot always construct a reasonable basis where a product of physical Hadamards behaves as a product of logical Hadamards without any swaps.

For example, this question noted that the CSS code generated from the classical codes $$C = \langle (111001), (000110) \rangle$$ $$C^\perp = \langle (111001), (000110), (010001), (001001) \rangle $$ suffers from a logical swap after performing $\otimes_{i=1}^n H_i$.

I also noted in a comment that the CSS code generated from $$C = \langle(11110)\rangle$$ $$C^\perp = \langle(11110), (11000),(01100), (00001)\rangle$$ with any reasonable basis also suffers from a swap on two of the three logical qubits after performing $\otimes_{i=1}^n H_i$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.