Let be a compact connected surface without boundary, divided into vertices , edges and faces (a cellulation). Over the binary field the cellulation defines a chain complex
where sends a face to the sum of the edges around it and sends an edge to the sum of its two endpoints. An element is a set of edges; it is a cycle if and a boundary if for some . A cocycle is a set of edges with (it meets every face in an even number of edges) and a coboundary is a set of the form with .
Put one qubit on every edge and write and . The homological code of the cellulation is the stabilizer code generated by
The generators commute because a vertex and a face share an even number of edges, which is the statement . The code is a CSS code with check matrices and , and its parameters are read from the topology:
- ;
- , which is for an orientable surface of genus ;
- commutes with every check exactly when is a cycle, and it is a product of the exactly when is a boundary; commutes with every check exactly when is a cocycle, and it is a product of the exactly when is a coboundary. The logical operators are therefore the cycles that are not boundaries and the cocycles that are not coboundaries;
- is the smaller of the minimum number of edges in a cycle that is not a boundary and the minimum number of edges in a cocycle that is not a coboundary.
For a surface with boundary the same construction with relative homology gives the planar codes of Bravyi and Kitaev and Freedman and Meyer. The construction on the torus is the toric code of Kitaev; the general homological formulation is developed by Bombin and Martin-Delgado and in section III of Dennis, Kitaev, Landahl and Preskill.