# How to compute Z logical operators of a toric code using Kunneth theorem?

I'm going through pymatching tutorial on constructing a toric code using hypergraph product of two repetition codes. The hypergraph product code construction $$H G P\left(H_1, H_2\right)$$ takes as input the parity check matrices of two linear codes $$C_1:=\operatorname{ker} H_1$$ and $$C_2:=\operatorname{ker} H_2$$. The code $$H G P\left(H_1, H_2\right)$$ is a CSS code with the parity check matrix $$H_X$$ corresponding to the $$X$$-type stabilisers $$$$H_X=\left[H_1 \otimes I_{n_2}, I_{r_1} \otimes H_2^T\right]$$$$ and the parity check matrix $$H_Z$$ corresponding to the $$Z$$-type stabilisers is $$$$H_Z=\left[I_{n_1} \otimes H_2, H_1^T \otimes I_{r_2}\right]$$$$ where $$H_1$$ has dimensions $$r_1 \times n_1, H_2$$ has dimensions $$r_2 \times n_2$$ and $$I_l$$ denotes the $$l \times l$$ identity matrix.

So the full parity check matrix for the toric code is $$$$H=\left(\begin{array}{cc} H_X & 0 \\ 0 & H_Z \end{array}\right)$$$$

From the Künneth theorem, the logical $$X$$ operators of the toric code are given by $$$$L_X=\left(\begin{array}{cc} \mathcal{H}^1 \otimes \mathcal{H}^0 & 0 \\ 0 & \mathcal{H}^0 \otimes \mathcal{H}^1 \end{array}\right)$$$$ where $$\mathcal{H}^0$$ and $$\mathcal{H}^1$$ are the zeroth and first cohomology groups of the length-one chain complex that has the repetition code parity check matrix as its boundary operator.

Question: Is $$L_Z$$ simply $$$$L_Z=\left(\begin{array}{cc} \mathcal{H}_1 \otimes \mathcal{H}_0 & 0 \\ 0 & \mathcal{H}_0 \otimes \mathcal{H}_1 \end{array}\right)$$$$ where $$\mathcal{H}_0$$ and $$\mathcal{H}_1$$ are the zeroth and first homology groups? How can I compute them? The cohomology groups for $$L_X$$ in the tutorial are: $$\mathcal{H}^0$$ is a vector of all $$1$$'s and $$\mathcal{H}^1$$ is a vector of all $$0$$'s but the first entry which is $$1$$ but I don't underastand why and how to get $$\mathcal{H}_0$$ and $$\mathcal{H}_1$$.

I don't understand why and how to get $$\mathcal{H}_0$$ and $$\mathcal{H}_1$$

The repetition code can be written as a chain complex $$C_1 \xrightarrow{\partial_1} C_0,$$ For example for the distance 4 repetition code $$\partial_1= \pmatrix{1 & 1 & 0 & 0 \cr 0 & 1 & 1 & 0 \cr 0 & 0 & 1 & 1 \cr 1 & 0 & 0 & 1} ,$$ and $$C_1$$ is a vector space over $$\mathbb{Z}_2^{4\times 1}$$ and $$C_0$$ is a vector space over $$\mathbb{Z}_2^{4\times 1}$$

Elements in $$C_1$$ can be understood as a set of edges and elements in $$C_0$$ as sets of vertexes. The boundary operator $$d_1$$ is a map from a set of edges to a set of vertexes. For example for edges $$c_1 =\pmatrix{1 0 1 0}$$, $$\partial_1 c_1 = \pmatrix{1,1,1,1}$$. The graphical interpretation of this is:

The group $$H_n$$ is defined as the quotient group obtained by partitioning n-cycles $$Z_n$$ into equivalence classes under composition with elements of n-boundaries $$B_n$$.

Let's try to figure out what $$Z_0, Z_1, B_0$$ and $$B_1$$ are. $$B_1$$ is the trivial one-element group, because we're considering a length 1 chain complex. Every element in $$C_0$$ is in $$Z_0$$, because any set of vertexes is a cycle. A handwavy explanation of this is that if you take the boundary of a vertex you get nothing.

The boundary of every 1-chain is a 0-chain with an even number of non-zero vertices. Therefore $$H_0$$ can be represented as any vector with an odd number of $$1$$s (For example first entry one followed by all zeros). Because $$B_1$$ is trivial $$H_1 = Z_1$$. You can form a cycle using all edges, so $$H_1$$ can be represented using the all ones vector.

Is $$𝐿_𝑍$$ simply $$$$L_Z=\left(\begin{array}{cc} \mathcal{H}_1 \otimes \mathcal{H}_0 & 0 \\ 0 & \mathcal{H}_0 \otimes \mathcal{H}_1 \end{array}\right)$$$$

Yes this looks correct. You can check it by testing if it commutes with the parity check matrix and anticommutes with $$L_X$$