A four-dimensional toric code on the D4 lattice: [[16L^4, 6, d]] with weight-4 X-stabilizers from the 16-cell honeycomb

A four-dimensional toric code on the D
4
lattice:
[[16L
4
, 6, d]] with weight-4 X-stabilizers
from the 16-cell honeycomb
Raghu Kulkarni
SSMTheory Group, IDrive Inc., Calabasas, CA 91302, USA
raghu@idrive.com
Abstract
We construct a four-dimensional toric code on the D
4
lattice, the densest lattice packing
in four dimensions. The construction uses the Delaunay decomposition of D
4
, which is a
honeycomb of regular 16-cells. Qubits sit on the 16L
4
triangular faces of a 4-torus of side L;
X-stabilizers act on tetrahedra with uniform weight 4, the smallest weight a face–cell check
can have, and Z-stabilizers act on edges with uniform weight 8. Computational verification
at L = 4 confirms CSS validity, k = 6 = b
2
(T
4
), and the full incidence structure of the
complex. Both sector distances are even by a parity argument. An exhaustive scan shows that
the weight-4 kernel of the X-sector consists of exactly the 3072 tetrahedron boundaries, all
stabilizers, and that the weight-4 kernel of the Z-sector is empty, so d 6; verified annealed
representatives give d 32 at L = 4, the best of them a wrapping membrane of the three-
dimensional section with weight exactly 2L
2
, and homology puts the expected scaling at Θ(L
2
).
Neither sector has point excitations: a single violated check is unachievable in the X-sector and
impossible identically in the Z-sector, so all excitations are closed loops. This is the excitation
structure behind the finite-temperature self-correction of the 4D toric code. The equal-time
sections of the code are exactly the FCC Delaunay (tetrahedral–octahedral) honeycomb, and
the 16-cell honeycomb is the alternated lattice through which Kubica and Vasmer connect the
four-dimensional subsystem toric code to the octaplex toric codes of Jochym-O’Connor and
Yoder; the face sector was not considered in that correspondence. Everything reported here
reproduces from the scripts in the appendices in minutes on a laptop.
Keywords: quantum error correction, 4D toric code, D
4
lattice, self-correcting memory,
single-shot codes
1 Introduction
The four-dimensional toric code is the canonical self-correcting quantum memory. Both of its
excitation types are extended loops, creating an excitation costs energy that grows with its length,
and thermal errors are confined instead of diffusing freely [1, 3]. On the hypercubic lattice the
code is [[6L
4
, 6, L
2
]]: qubits on square faces, weight-6 X-checks on edges, weight-6 Z-checks on
cubes [1, 4]. The known variants change the topology or the support: fractal subsets of the
hypercubic lattice [5], hyperbolic lattices, the tesseract color code [6]. Closest to this work,
Jochym-O’Connor and Yoder constructed four-dimensional stabilizer toric codes on the octaplex
(24-cell) tessellation, with qubits on 3-cells [7], and Kubica and Vasmer showed these to be gauge
fixings of their four-dimensional subsystem toric code, with the 16-cell honeycomb appearing as
the alternated lattice of that correspondence [2]. Here we construct a different sector of the same
1
geometry: qubits on the faces of the 16-cell honeycomb, so that both logical types are membranes
and all excitations are loops, which is the self-correcting (2, 2) structure of the 4D toric code. We
are not aware of a prior construction of this sector.
We build one here, on the lattice that four-dimensional geometry singles out. D
4
is the four-
dimensional checkerboard: the densest lattice packing in four dimensions, with kissing number 24
[9]. Its holes are all deep and all equivalent, which is special to D
4
, and its Delaunay decomposition
is a honeycomb of congruent regular 16-cells. Putting qubits on the faces of that honeycomb gives
a 4D toric code with three properties worth stating up front:
(i) Weight-4 X-stabilizers. The 3-cells of the complex are tetrahedra, so every X-check
touches exactly 4 qubits. A 3-cell has at least 4 facets, so weight 4 is the minimum any
face–cell stabilizer can have; this honeycomb reaches it at every check. The cost is a weight-8
Z-sector and more qubits than the hypercubic code at equal coordinate size (16L
4
versus
6L
4
); Section 8 tabulates the trade.
(ii) Loop-only excitations. Neither sector has point excitations. A single violated X-check is
unachievable by any error, because every tetrahedron borders exactly two 16-cells and the
resulting parity constraint forces syndromes onto closed dual loops. A single violated Z-
check is impossible identically, because edge syndromes are boundaries of 2-chains and hence
closed 1-cycles. This is exactly the mechanism behind self-correction in the hypercubic code
[1].
(iii) The slice property. The section D
4
{x
4
= 0} is the face-centered-cubic lattice, whose
Delaunay complex is the tetrahedral–octahedral honeycomb, and the in-slice cells and checks
of our code restrict exactly onto the three-dimensional face code of that complex (Section 7).
The time slices of this self-correcting-class memory are a three-dimensional toric code on
the FCC Delaunay complex, and the minimum-weight logical membrane we find is itself an
in-slice object.
Every claim below is verified computationally at L = 4; the scripts are reproduced in full in
Appendices A and B and run in minutes on a laptop. Structural claims (incidence counts, parity
arguments, homological counts) hold for all even L by the same arguments. The construction
came out of a program studying codes on close-packed lattices [11], but this paper stands on its
own and claims nothing beyond the code.
2 The D
4
lattice and the 16-cell honeycomb
Take D
4
= {x Z
4
:
P
i
x
i
0 mod 2} on a 4-torus of even side L. Nearest neighbors differ by
one of the 24 roots, the permutations of (±1, ±1, 0, 0); the kissing number 24 is the maximum
possible in four dimensions [9, 10]. The holes fall into three cosets—odd-sum integer points and
two classes of half-integer points—and every one is a deep hole at distance 1, surrounded by 8
lattice points forming a regular 16-cell (Fig. 1a). The Delaunay decomposition of D
4
is therefore
a honeycomb of 3L
4
/2 congruent 16-cells.
The chain complex C
4
C
3
C
2
C
1
C
0
of the honeycomb has, on the torus:
C
0
(vertices) C
1
(edges) C
2
(faces) C
3
(tets) C
4
(16-cells)
count L
4
/2 6L
4
16L
4
12L
4
3L
4
/2
L = 4 128 1536 4096 3072 384
2
The Euler characteristic vanishes, as it must on T
4
. The incidence structure, verified exhaustively
at L = 4 (Fig. 1d): every triangular face lies in exactly 3 tetrahedra and 3 16-cells; every
tetrahedron is a facet of exactly 2 16-cells; every edge lies in exactly 8 faces. Faces are codimension-
2 cells here, which is why their incidence number is 3 rather than the 2 familiar from codimension-1
facets. The facet number 2 is the one that matters below: it is what forces syndromes onto closed
loops.
(a) 16-cell Delaunay cell of
D
4
qubit = triangular face (blue);
X
-check = tetrahedral facet (orange)
x
4
=0
: FCC tetrahedral void
x
4
=1
: adjacent slice
(b) 16-cell at a half-integer hole, sectioned by
x
4
:
two regular tetrahedra, one per time slice
X
-check weight
Z
-check weight
0
2
4
6
8
minimum possible
for a face cell check
(c) Uniform stabilizer weights
hypercubic 4D toric code
D
4
face code
face
tetrahedra
tet
16-cells
edge
faces
0
1
2
3
4
5
6
7
8
9
3
2
8
=2
syndromes are closed dual loops:
no point excitations (Thm. 3)
(d) Incidence structure (verified at
L
=4
)
Figure 1: Structure of the code. (a) One 16-cell of the D
4
Delaunay honeycomb (projected to
3D): 8 vertices, 24 edges. A qubit lives on each triangular face (blue); each tetrahedral facet
carries a weight-4 X-check (orange). (b) A 16-cell centered at a half-integer hole, sectioned by
the coordinate x
4
: its 8 vertices split 4 + 4 into two regular tetrahedra, one per time slice. The
x
4
=0 tetrahedron is a tetrahedral void of the FCC lattice; this is the geometric content of the slice
property (Section 7). (c) Stabilizer weights against the hypercubic 4D toric code: the X-sector
reaches the weight-4 minimum; the Z-sector pays weight 8. (d) The verified incidence structure.
The value tet-in-2 cells is the source of the loop-only excitation structure (Theorem 3).
3
3 Code construction
Definition 1 (D
4
face code). Place one qubit on each triangular face of the 16-cell honeycomb.
Define:
X-stabilizers: for each tetrahedron t, apply X to its 4 faces (uniform weight 4);
Z-stabilizers: for each edge e, apply Z to the 8 faces containing e (uniform weight 8).
In chain-complex terms H
X
=
T
3
and H
Z
= δ
1
, so H
X
H
T
Z
= 0 over F
2
holds because = 0;
we verify it numerically anyway. Both check weights are uniform. This is the exact analogue of
the hypercubic construction with squares replaced by triangles and cubes by tetrahedra.
4 Computational verification
Theorem 1 (Parameters at L = 4). The D
4
face code at L = 4 is a valid CSS code with
n = 4096, rk(H
Z
) = 1405, rk(H
X
) = 2685, k = n rk(H
Z
) rk(H
X
) = 6.
The logical count is topological: k = b
2
(T
4
; F
2
) =
4
2
= 6, one logical qubit per independent
2-cycle of the 4-torus, at every L. The six X-type logical classes are wrapping 2-cycles of the
complex; the six Z-type classes are dual surfaces in the icositetrachoric (24-cell) honeycomb, the
dual of the 16-cell honeycomb. Both are membranes, as in the hypercubic case [1, 3]. Fig. 2a
collects the verified numbers.
5 Distance
Lemma 1 (Parity). Both sector distances are even.
Proof. Every face lies on 3 edges and in 3 tetrahedra. The all-ones functional over either check
set therefore assigns to an error S the parity 3|S| |S| mod 2, so kernel elements of either check
matrix have even weight.
Theorem 2 (Weight-4 classification). At L = 4, an exhaustive scan over all
4096
2
syndrome-pair
collisions gives:
(a) the X-sector kernel (ker H
Z
) contains exactly 3072 weight-4 elements, and they are precisely
the boundaries of the 3072 tetrahedra—the X-stabilizer generators themselves. None is a
logical operator.
(b) the Z-sector kernel (ker H
X
) contains no weight-4 elements.
Together with Lemma 1 and the verified absence of weight-2 kernel elements (Appendix A): d
X
6
and d
Z
6.
Part (a) has a direct geometric reading: the only closed 4-face surfaces in the honeycomb are
tetrahedron boundaries, so the smallest closed membranes are exactly the stabilizers.
For upper bounds we extracted the six logical coset representatives in each sector by F
2
lin-
ear algebra, verified each candidate directly (kernel membership and nontriviality against the
stabilizer group), and reduced weights by greedy descent over the stabilizer generators with ran-
domized restarts, including pairwise combinations of cosets. The generic four-dimensional search
4
n
(faces)
4096
rk
(
H
Z
)
1405
rk
(
H
X
)
2685
k
6=
b
2
(
T
4
)
X
/
Z
weight
4 / 8 (uniform)
CSS (
H
X
H
Z
=0
)
verified
point excitations none (both sectors)
(a) Verified parameters,
L
=4
wt-2
kernel
wt-4
kernel
wt-4
non-stabilizer
0
500
1000
1500
2000
2500
3000
3500
4000
3072 = all tet
boundaries
(stabilizers)
0 00 0 0
(b) Exhaustive low-weight classification
d
6
X
-sector (ker
H
Z
)
Z
-sector (ker
H
X
)
0 10 20 30 40 50 60 70
operator weight
excluded:
parity (odd) +
wt-2, wt-4 scans
d
6
(proven)
hypercubic
d
=
L
2
=16
d
X
32=2
L
2
(in-slice membrane)
d
Z
64
(c) Distance bounds at
L
=4
(annealed upper bounds)
D
4
face code
[[16
L
4
,6,
d
]]
loop-only excitations self-correcting class
x
4
=
const
section
tetrahedral octahedral lattice (FCC Delaunay)
carries the 3D toric codes of this complex;
the 16-cell honeycomb is the alternated lattice of the
4D subsystem-toric-code correspondence (KV; JOY)
(d) Time slices of the 4D memory are the
3D FCC-Delaunay toric code
Figure 2: Verification and distance. (a) Verified code parameters at L = 4. (b) Exhaustive
low-weight kernel classification: the X-sector has exactly 3072 weight-4 kernel elements, which
are precisely the tetrahedron boundaries (stabilizer generators), and none besides; the Z-sector
has none at all. With the parity lemma this proves d 6. (c) Distance bounds at L = 4:
weights 1–5 are excluded; verified annealed representatives give d
X
32 (an in-slice membrane
of weight 2L
2
) and d
Z
64; the hypercubic value L
2
= 16 is marked for reference. (d) The
slice property: sectioning the 4D code at constant x
4
produces the tetrahedral–octahedral (FCC
Delaunay) lattice; the 16-cell honeycomb is the alternated lattice of the 4D subsystem-toric-code
correspondence [2, 7].
(Appendix B) reaches d
X
48 and d
Z
64. Seeding the X-sector instead with a minimal
wrapping membrane of a time slice (Appendix C) improves the first bound to d
X
32 (Fig. 2c):
6 d 32 (L = 4).
The weight-32 X-representative lies entirely in a single time slice: it is a wrapping membrane
of the three-dimensional section (Section 7), with weight exactly 2L
2
. The annealer does not
guarantee minimum-weight representatives, so both upper bounds are probably loose, the Z-
sector especially. All logical operators are homologically nontrivial membranes, so we expect the
hypercubic scaling:
Conjecture 1. d = Θ(L
2
) for the D
4
face code family.
The exact distance is the minimal area of a wrapping surface in the 16-cell honeycomb. Flat
5
coordinate 2-planes contain no faces of the complex, so minimal wrapping membranes are neces-
sarily wrinkled, and the constant is not given by a naive area count. We leave it open.
6 Excitations: no point particles in either sector
Theorem 3 (Loop-only excitations). Neither sector of the D
4
face code has point excitations:
(a) a single violated X-check is unachievable: the linear system H
X
y = e
t
has no solution for
a single tetrahedron t (verified directly). Structurally, every tetrahedron is a facet of exactly
two 16-cells, so every reachable syndrome satisfies an even-parity constraint around each
16-cell and forms a closed loop in the dual 24-cell honeycomb;
(b) a single violated Z-check is impossible identically: the Z-syndrome of any error is the bound-
ary of a 2-chain, hence a closed 1-cycle, and a single edge is not a cycle.
Loop-only excitations in both sectors is the structural mechanism of finite-temperature self-
correction in the hypercubic 4D toric code: creating any excitation costs energy proportional to its
length [1, 3]. The D
4
face code inherits this structure exactly. We have established the excitation
structure, not the thermodynamics; a free-energy barrier analysis on this honeycomb, parallel to
the hypercubic treatments [1, 4], remains to be done. One more feature is worth recording for
decoder design: a single Pauli error excites checks in odd multiples (3 tetrahedra per face), a
color-code-like consequence of the triangular geometry.
7 The slice property
The section D
4
{x
4
= 0} is exactly the face-centered-cubic lattice, and the honeycomb sections
coherently with it. All of the following is verified at L = 4:
(a) in-slice vertices, edges, faces, and tetrahedra number L
3
/2, 3L
3
, 4L
3
, and L
3
: exactly the
cells of the three-dimensional tetrahedral–octahedral honeycomb, the Delaunay complex of
FCC;
(b) every in-slice edge lies in exactly 4 in-slice faces, the Z-check weight of the three-dimensional
face code on that lattice;
(c) the deep holes section coherently: 16-cells at in-slice (odd-integer) holes meet the slice
in octahedra (6 of 8 vertices), and 16-cells at between-slice (half-integer) holes meet it in
tetrahedra (4 of 8 vertices, the other 4 lying in the adjacent slice; Fig. 1b). Sixteen-cells one
integer layer from the slice meet it in a single vertex and contribute no cells to the section.
The three-dimensional lattice obtained this way is the tetrahedral–octahedral honeycomb, and
the restricted checks are those of the three-dimensional face code (stabilizer toric code) of that
complex. The minimum-weight logical membrane found in Section 5 lies entirely within one such
slice, so the best known logical representatives of the code are objects of its own three-dimensional
sections. The 16-cell honeycomb is also the alternated lattice through which Kubica and Vasmer
relate the four-dimensional subsystem toric code to the octaplex toric codes of Jochym-O’Connor
and Yoder [2, 7]; the three-dimensional subsystem toric code of the same correspondence is the
canonical single-shot code [2, 8]. The lattice is thus already present in the single-shot and self-
correction literature; the face sector is not. Making a dimension-jump protocol along a slice
explicit remains open.
6
8 Comparison with the hypercubic 4D toric code
hypercubic [1, 4] D
4
face code (this work)
lattice Z
4
D
4
(densest packing)
qubit cell square faces triangular faces
n 6L
4
16L
4
k 6 6
d L
2
6 d 32 at L=4; conj. Θ(L
2
)
X-check weight 6 4 (minimum possible)
Z-check weight 6 8
checks per qubit 4+4 3+3
point excitations none none (verified)
3D section cubic lattice tet–oct (FCC Delaunay) lattice
The trade is visible in the table. The D
4
code pays 8/3× more qubits at equal coordinate
size and a heavier Z-sector; it gains the minimal-weight X-sector, fewer checks per qubit (3+3
against 4+4), a denser and more symmetric lattice, and the single-shot slice property. Which
side of the trade wins depends on the architecture. Weight-4 checks matter where measurement
complexity is set by the largest check in one sector, as in measurement-based schemes built from
cell checks; total qubit count favors the hypercubic code. The point of this paper is that the 4D
toric-code phase has a realization on the densest four-dimensional lattice, and that this realization
has structural properties the hypercubic one does not.
9 Discussion
Three problems follow directly. Exact distance: the minimal wrapping membrane of the 16-
cell honeycomb is a well-posed combinatorial optimization, and even the L = 4 value would
sharpen the family. Thermal analysis: the loop-only excitation structure places the code in the
self-correcting class; the barrier constant and memory-time scaling deserve the treatment the
hypercubic code has received [1, 4]. Single-shot decoding through the slice: given the code’s place
in the subsystem-toric-code correspondence [2, 7], a dimension-jump protocol [8] in which the 4D
memory exchanges logical information with a 3D code along a slice looks natural. Making that
protocol explicit is, we think, the most interesting problem this construction poses.
10 Conclusion
The Delaunay honeycomb of the D
4
lattice carries a four-dimensional toric code: [[16L
4
, 6, d]]
with uniform weight-4 X-checks and weight-8 Z-checks, 6 d 32 at L = 4, no point excitations
in either sector, and equal-time sections equal to the lattice of the three-dimensional single-shot
subsystem toric code. Everything needed to reproduce these statements is in Appendices A and
B and runs in minutes on a laptop.
Data availability
The complete verification code is reproduced in Appendix A (construction, incidence structure,
CSS validity, parameters, the low-weight kernel scans, the slice property, and the absence of point
7
excitations; under one minute) and Appendix B (the weight-4 classification and the annealed dis-
tance upper bounds; about three minutes) and Appendix C (the slice-seeded search that improves
the X-sector bound to 32; seconds). The scripts require only numpy.
References
[1] E. Dennis, A. Kitaev, A. Landahl, and J. Preskill, “Topological quantum memory,” J. Math.
Phys. 43, 4452 (2002). doi:10.1063/1.1499754, arXiv:quant-ph/0110143.
[2] A. Kubica and M. Vasmer, “Single-shot quantum error correction with the three-dimensional
subsystem toric code,” Nat. Commun. 13, 6272 (2022). doi:10.1038/s41467-022-33923-4,
arXiv:2106.02621.
[3] Error Correction Zoo, “(2, 2) Loop toric code,” https://errorcorrectionzoo.org/c/4d_
surface.
[4] T. Bergamaschi, R. Gheissari, and Y. Liu, “Rapid mixing for Gibbs states within a logical
sector: a dynamical view of self-correcting quantum memories,” arXiv:2507.10976 (2025).
[5] C. G. Brell, “A proposal for self-correcting stabilizer quantum memories in 3 dimensions (or
slightly less),” New J. Phys. 18, 013050 (2016). doi:10.1088/1367-2630/18/1/013050.
[6] V. V. Albert and P. Faist, Handbook of Error-Correcting Codes, arXiv:2606.11484 (2026).
[7] T. Jochym-O’Connor and T. J. Yoder, “Four-dimensional toric code with
non-Clifford transversal gates,” Phys. Rev. Research 3, 013118 (2021).
doi:10.1103/PhysRevResearch.3.013118.
[8] H. Bomb´ın, “Single-shot fault-tolerant quantum error correction,” Phys. Rev. X 5, 031043
(2015). doi:10.1103/PhysRevX.5.031043, arXiv:1404.5504.
[9] J. H. Conway and N. J. A. Sloane, Sphere Packings, Lattices and Groups, 3rd ed. (Springer,
New York, 1999). doi:10.1007/978-1-4757-6568-7.
[10] O. R. Musin, “The kissing number in four dimensions,” Ann. Math. 168, 1 (2008).
arXiv:math/0309430.
[11] R. Kulkarni, “A 67%-rate CSS code on the FCC lattice: [[192, 130, 3]] from weight-12 stabi-
lizers,” arXiv:2603.20294 (2026).
A Construction and verification code
The following self-contained script builds the 16-cell honeycomb, checks the incidence structure,
verifies CSS validity, the parameters of Theorem 1, the absence of weight-1 and weight-2 kernel
elements in both sectors, the slice property of Section 7, and Theorem 3(a). Requires only numpy;
runs in under a minute at L = 4.
#!/usr/bin/env python3
"""D4 face code -- construction and verification"""
import numpy as np
from itertools import product, combinations
def rank(rows):
piv = {}; rk = 0
for r in rows:
8
while r:
h = r.bit_length()-1
if h in piv: r ^= piv[h]
else: piv[h] = r; rk += 1; break
return rk
def solvable(rows, rhs):
piv = {}
for i, r in enumerate(rows):
a = (r << 1) | rhs[i]
while a >> 1:
h = (a >> 1).bit_length()-1
if h in piv: a ^= piv[h]
else: piv[h] = a; break
else:
if a & 1: return False
return True
L = 4
vs = [v for v in product(range(L), repeat=4) if sum(v)%2 == 0]
add = lambda a,b: tuple((a[i]+b[i]) % L for i in range(4))
adj = lambda a,b: sorted(min((a[i]-b[i])%L,(b[i]-a[i])%L)
for i in range(4)) == [0,0,1,1]
NN = [v for v in product((-1,0,1), repeat=4) if sum(map(abs,v)) == 2]
nb = {v: [add(v,d) for d in NN] for v in vs}
E, F, T, C4 = {}, {}, {}, []
for v in vs:
for u in nb[v]:
k = frozenset((v,u))
if k not in E: E[k] = len(E)
for ek in list(E):
a, b = tuple(ek)
for c in nb[a]:
if c != b and adj(c,b):
fk = frozenset((a,b,c))
if fk not in F: F[fk] = len(F)
for fk in list(F):
a, b, c = tuple(fk)
for d in nb[a]:
if d not in fk and adj(d,b) and adj(d,c):
tk = frozenset((a,b,c,d))
if tk not in T: T[tk] = len(T)
for h in product(range(L), repeat=4): # odd-integer holes
if sum(h)%2 == 1:
C4.append([add(h, tuple(int(i==j)*s for j in range(4)))
for i in range(4) for s in (1,-1)])
for hb in product(range(L), repeat=4): # half-integer holes
h = tuple(x+.5 for x in hb)
want = 0 if sum(hb)%2 == 0 else 2
C4.append([tuple(int((h[i]+s[i]*.5)) % L for i in range(4))
for s in product((1,-1), repeat=4) if sum(s)%4 == want])
nV, nE, nF, nT, nC = len(vs), len(E), len(F), len(T), len(C4)
print("cells:", nV, nE, nF, nT, nC, "␣Euler:", nV-nE+nF-nT+nC)
# incidence structure
fin = [0]*nF
for tk in T:
9
for tri in combinations(tuple(tk),3): fin[F[frozenset(tri)]] += 1
tin = [0]*nT
for cv in C4:
prs = {frozenset(p) for p in combinations(cv,2) if adj(*p)}
for q in combinations(cv,4):
if all(frozenset(p) in prs for p in combinations(q,2)):
tin[T[frozenset(q)]] += 1
print("face-in-tets:", set(fin), "␣tet-in-cells:", set(tin))
# parity checks
HZ = [0]*nE
for fk, fi in F.items():
for pr in combinations(tuple(fk),2):
HZ[E[frozenset(pr)]] |= 1 << fi
HX = []
for tk in T:
r = 0
for tri in combinations(tuple(tk),3): r |= 1 << F[frozenset(tri)]
HX.append(r)
wz = {bin(r).count(’1’) for r in HZ}
wx = {bin(r).count(’1’) for r in HX}
css = all(bin(x & z).count(’1’)%2 == 0 for x in HX for z in HZ)
rz, rx = rank(HZ), rank(HX)
print("weights␣Z/X:", wz, wx, "␣CSS:", css)
print("n=%d␣rk(HZ)=%d␣rk(HX)=%d␣k=%d" % (nF, rz, rx, nF-rz-rx))
# no point excitations (Theorem 3a)
rhs = [1] + [0]*(nT-1)
print("single␣X-check␣syndrome␣solvable:", solvable(HX, rhs))
# weight-1/2 kernel scans (both sectors)
def cols(H):
c = [0]*nF
for i, r in enumerate(H):
m = r
while m:
b = (m & -m).bit_length()-1; c[b] |= 1 << i; m &= m-1
return c
for H, nm in ((HZ,’ker␣HZ’), (HX,’ker␣HX’)):
c = cols(H)
print(nm, "wt-1:", c.count(0), "␣wt-2:", len(c)-len(set(c)))
# face-in-16-cells incidence
fic = [0]*nF
for cv in C4:
for tri in combinations(cv,3):
fk = frozenset(tri)
if fk in F: fic[F[fk]] += 1
print("face-in-16-cells:", set(fic))
# slice property (Section 7): counts, weights, hole sections
sv = [v for v in vs if v[3] == 0]
se = [k for k in E if all(u[3] == 0 for u in k)]
sf = [k for k in F if all(u[3] == 0 for u in k)]
st = [k for k in T if all(u[3] == 0 for u in k)]
print("slice␣V,E,F,T:", len(sv), len(se), len(sf), len(st))
print("in-slice␣edge␣in␣4␣in-slice␣faces:",
all(sum(1 for fk in F if ek <= fk and
10
all(u[3] == 0 for u in fk)) == 4 for ek in se))
sec = sorted({sum(1 for u in cv if u[3] == 0)
for cv in C4 if 0 < sum(1 for u in cv if u[3] == 0) < 8})
print("16-cell␣slice␣sections:", sec) # [1, 4, 6]
B Distance verification code
The following script proves Theorem 2 (the weight-4 classification, hence d 6 with Lemma 1)
and computes the annealed upper bounds of Section 5; every candidate logical is verified for
kernel membership and nontriviality before its weight is reported. It reuses the complex built
in Appendix A (run in the same session, or paste the construction block above the code below).
Runs in about two minutes at L = 4.
#!/usr/bin/env python3
"""D4 face code -- distance: wt-4 classification + annealed bounds"""
import numpy as np, random
from itertools import combinations
random.seed(7)
pop = lambda x: bin(x).count(’1’)
# assumes HZ, HX, nF, nE, nT from Appendix A are in scope
colZ = [0]*nF; colX = [0]*nF # per-qubit syndromes
for e in range(nE):
m = HZ[e]
while m:
b = (m & -m).bit_length()-1; colZ[b] |= 1 << e; m &= m-1
for t in range(nT):
m = HX[t]
while m:
b = (m & -m).bit_length()-1; colX[b] |= 1 << t; m &= m-1
def fold(x): # XOR-linear 64-bit sketch
r = 0
while x: r ^= x & 0xFFFFFFFFFFFFFFFF; x >>= 64
return r
def pivots(rows):
piv = {}
for r in rows:
while r:
h = r.bit_length()-1
if h in piv: r ^= piv[h]
else: piv[h] = r; break
return piv
def instab(v, piv):
while v:
h = v.bit_length()-1
if h not in piv: return False
v ^= piv[h]
return True
def wt4(cols, stab, label):
piv = pivots(stab)
f = np.array([fold(c) for c in cols], dtype=np.uint64)
iu = np.triu_indices(nF, 1)
11
dv = (f[:,None] ^ f[None,:])[iu]
o = np.argsort(dv, kind=’stable’)
dv, ii, jj = dv[o], iu[0][o], iu[1][o]
quads, bad, k, N = set(), 0, 0, len(dv)
while k < N:
k2 = k
while k2+1 < N and dv[k2+1] == dv[k]: k2 += 1
if k2 > k:
idx = [(int(ii[m]), int(jj[m])) for m in range(k, k2+1)]
for (a,b),(c,d) in combinations(idx, 2):
if len({a,b,c,d}) == 4 and cols[a]^cols[b] == cols[c]^cols[d]:
q = frozenset((a,b,c,d))
if q not in quads:
quads.add(q)
v = (1<<a)|(1<<b)|(1<<c)|(1<<d)
if not instab(v, piv): bad += 1
k = k2 + 1
print(label, "wt-4␣kernel:", len(quads), "␣non-stabilizer:", bad)
return piv
pX = wt4(colZ, HX, "X-sector:") # 3072, 0 -> all tet boundaries
pZ = wt4(colX, HZ, "Z-sector:") # 0, 0
def kernel(rows, n=None):
piv = {}
for r in rows:
while r:
h = r.bit_length()-1
if h in piv: r ^= piv[h]
else: piv[h] = r; break
def clean(v): # strip every pivot bit, not just leading
out = 0
while v:
h = v.bit_length()-1
if h in piv: v ^= piv[h]
else: out |= 1 << h; v ^= 1 << h
return out
for h in list(piv): # full back-substitution to RREF
piv[h] = (1 << h) | clean(piv[h] ^ (1 << h))
free = [c for c in range(n or nF) if c not in piv]
out = []
for fc in free:
v = 1 << fc
for h, r in piv.items():
if (r>>fc)&1: v |= 1 << h
out.append(v)
return out
def reduce(v, piv):
while v:
h = v.bit_length()-1
if h not in piv: return v
v ^= piv[h]
return 0
def logicals(check, stabpiv, want=6):
reps, aug = [], dict(stabpiv)
for v in kernel(check):
12
r = reduce(v, aug)
if r:
reps.append(v); aug[r.bit_length()-1] = r
if len(reps) == want: break
return reps
def anneal(v, moves, kicks=40):
def greedy(x):
ok = True
while ok:
ok = False
for m in moves:
y = x ^ m
if pop(y) < pop(x): x, ok = y, True
return x
best = greedy(v)
for _ in range(kicks):
x = best
for _ in range(random.randint(1,3)): x ^= random.choice(moves)
x = greedy(x)
if pop(x) < pop(best): best = x
return best
LX = [anneal(v, HX, 120) for v in logicals(HZ, pX)]
LZ = [anneal(v, HZ, 150) for v in logicals(HX, pZ)]
for i, j in combinations(range(6), 2):
LX.append(anneal(LX[i]^LX[j], HX, 40))
LZ.append(anneal(LZ[i]^LZ[j], HZ, 50))
ink = lambda v, H: all((h & v).bit_count()%2 == 0 for h in H if h & v)
for v in LX: assert ink(v, HZ) and reduce(v, pX) # verified logicals
for v in LZ: assert ink(v, HX) and reduce(v, pZ)
print("d_X␣<=", min(pop(v) for v in LX)) # 48 (32 with slice seeding)
print("d_Z␣<=", min(pop(v) for v in LZ)) # 64
C Slice-seeded distance bound
The following script builds the three-dimensional slice complex (the tetrahedral–octahedral hon-
eycomb of Section 7), finds minimum-weight wrapping membranes of the three-dimensional face
code by the same annealer, lifts the best one into the x
4
= 0 slice of the four-dimensional com-
plex, and verifies it as a nontrivial logical. This reproduces the bound d
X
32 = 2L
2
quoted in
Section 5. It reuses the objects of Appendices A and B (run all three in the same session). Runs
in seconds.
#!/usr/bin/env python3
# D4 face code -- slice-seeded X-sector bound
random.seed(11)
vs3 = [v for v in product(range(L), repeat=3) if sum(v)%2 == 0]
add3 = lambda a,b: tuple((a[i]+b[i]) % L for i in range(3))
adj3 = lambda a,b: sorted(min((a[i]-b[i])%L,(b[i]-a[i])%L)
for i in range(3)) == [0,1,1]
NN3 = [v for v in product((-1,0,1), repeat=3) if sum(map(abs,v)) == 2]
nb3 = {v: [add3(v,d) for d in NN3] for v in vs3}
E3, F3 = {}, {}
for v in vs3:
for u in nb3[v]:
13
k = frozenset((v,u))
if k not in E3: E3[k] = len(E3)
for ek in list(E3):
a, b = tuple(ek)
for c in nb3[a]:
if c != b and adj3(c,b):
fk = frozenset((a,b,c))
if fk not in F3: F3[fk] = len(F3)
nF3 = len(F3)
HZ3 = [0]*len(E3)
for fk, fi in F3.items():
for pr in combinations(tuple(fk), 2):
HZ3[E3[frozenset(pr)]] |= 1 << fi
st3 = [] # 3D stabilizers: tets + octahedra
for t in product(range(L), repeat=3):
c = tuple(x + .5 for x in t)
near = [v for v in vs3
if sum(min(abs(v[i]-c[i]), L-abs(v[i]-c[i]))**2
for i in range(3)) < 0.751]
r = 0
for tri in combinations(near, 3): r |= 1 << F3[frozenset(tri)]
st3.append(r)
for h in product(range(L), repeat=3):
if sum(h)%2 == 1:
nbh = [add3(h, tuple(int(i==j)*s for j in range(3)))
for i in range(3) for s in (1,-1)]
r = 0
for tri in combinations(nbh, 3):
fk = frozenset(tri)
if fk in F3: r |= 1 << F3[fk]
st3.append(r)
pS3 = pivots(st3)
reps3, aug = [], dict(pS3)
for v in kernel(HZ3, nF3):
r = reduce(v, aug)
if r:
reps3.append(v); aug[r.bit_length()-1] = r
if len(reps3) == 3: break
mem = [anneal(v, st3, 800) for v in reps3]
for i, j in combinations(range(3), 2):
mem.append(anneal(mem[i]^mem[j], st3, 300))
for v in mem: assert ink(v, HZ3) and reduce(v, pS3)
print("slice␣membranes:", sorted(pop(v) for v in mem))
# [32, 32, 32, 32, 36, 48]
lift = {fi: F[frozenset(tuple(u)+(0,) for u in fk)] # x4 = 0
for fk, fi in F3.items()}
best, w = min(mem, key=pop), 0
for b in range(nF3):
if best >> b & 1: w |= 1 << lift[b]
assert ink(w, HZ) and reduce(w, pX) # nontrivial 4D logical
w = anneal(w, HX, 60)
assert ink(w, HZ) and reduce(w, pX)
print("lifted␣in-slice␣membrane:␣d_X␣<=", pop(w)) # 32
14