BB 码 · 高中数学版BB Codes · High-School Edition
互动教程 · 高中数学版 · BB 码Interactive tutorial · High-school edition · BB codes

两个多项式,
十二个逻辑比特
Two polynomials,
twelve logical qubits

表面码用 144 个数据比特存 1 个逻辑比特;同样 144 个比特,gross 码BB(双变量自行车)码是一套配方:选一个环面、两个多项式,就得到一个码;gross 码是其中一组具体取值(环面 l = 12、m = 6,A = x³ + y + y²,B = y³ + x + x²),参数 [[144, 12, 12]]。名字是 Bravyi 等人 2024 年起的:英文 gross 是「一罗」,十二打,正好 144,就是它的数据比特数。它是那篇论文和本教程的主角,第 5 章逐项拆解。存 12 个,码距还是 12。它没有网格图,只有两个三项的多项式 A = x³ + y + y² 和 B = y³ + x + x²,写在一个 12 × 6 的环面上。本教程把这件事从零推导出来:为什么单项式是平移、为什么 HX = [A | B] 与 HZ = [Bᵀ | Aᵀ](竖线与上标 ᵀ[A | B]:把两个矩阵左右并排拼成一个更宽的矩阵;上标 ᵀ 读「转置」,把矩阵的行与列互换。)必然对易、k = 12 从哪一个秩来、五个重要实例各自长什么样,以及这份「十二倍」在真实机器上要付出什么。所有 n、k 都由你的浏览器现场在 GF(2)只有 0 和 1 两个数、按 1 + 1 = 0 运算的数域;「mod 2 算术」的正式名字。 上重算。 A surface code spends 144 data qubits on 1 logical qubit; the gross codeBB (bivariate bicycle) codes are a recipe: pick a torus and two polynomials, and out comes a code. The gross code is one particular choice, a 12 × 6 torus with A = x³ + y + y² and B = y³ + x + x², and it comes out as [[144, 12, 12]]. Bravyi et al. named it in 2024: a gross is twelve dozen, 144, which is its number of data qubits. It is the star of their paper and of this tutorial; Chapter 5 takes it apart. spends the same 144 on 12, still at distance 12. It has no lattice picture, only two three-term polynomials A = x³ + y + y² and B = y³ + x + x² on a 12 × 6 torus. This tutorial derives all of it from scratch: why a monomial is a translation, why HX = [A | B] and HZ = [Bᵀ | Aᵀ] (the bar and the superscript ᵀ[A | B]: two matrices placed side by side into one wider matrix; the superscript ᵀ reads “transpose” and swaps rows with columns.) must commute, which rank produces k = 12, what each of the five important instances looks like, and what the “twelve-fold” costs on a real machine. Every n and k is recomputed live over GF(2)The number system with only 0 and 1, where 1 + 1 = 0; the formal name of mod-2 arithmetic. in your browser.

前置:《从高考数学到 Toric Code》与《Surface Code · 高中数学版》(环面码与表面码的账本、碰撞定理)。《译码器 · 高中数学版》与《格点手术 · 高中数学版》在第 6 章用到,可先不读。新增数学:矩阵乘法与置换矩阵、mod 运算、克罗内克积(现场现教)。 Prerequisites: “From High-School Math to the Toric Code” and “The Surface Code · High-School Edition” (toric and surface-code ledgers, the collision theorem). “Decoders · High-School Edition” and “Lattice Surgery · High-School Edition” are used in Chapter 6 and can wait. New mathematics: matrix multiplication and permutation matrices, modular arithmetic, the Kronecker product (taught on the spot).
开始 ↓Begin ↓ 全程约 60–80 分钟 · 7 个实验台 · 承接:《格点手术 · 高中数学版》→ · 接着读:《qLDPC 码 · 高中数学版》→About 60–80 minutes · 7 hands-on benches · builds on: “Lattice Surgery · High-School Edition” → · read next: “qLDPC Codes · High-School Edition” →
目录Contents
第 0 章Chapter 0

速查回顾:三条公式,一本旧账Express recap: three formulas and an old ledger

这里要用的旧知识只有三条:碰撞定理、用秩记账算 k、以及环面码「每格两个比特、两条恒等式、k = 2」的那本账。第一条要换一种新写法:把检查写成矩阵的行——这张表叫检查矩阵一张 0/1 表:每行是一条检查,每列是一个物理比特,检查碰到哪个比特,那一格就写 1;所以一行是一条检查的腿落在哪里,一列是哪些检查在盯着这个比特。CSS 码有两张:X 检查排成 HX,Z 检查排成 HZ;环面码里 HX 的每一行是一个星,HZ 的每一行是一个面。经典编码论里它叫「奇偶校验矩阵」(parity-check matrix)。——它就叫作 CSS 码一种稳定子码:它的检查分成两族,一族只由 X 组成,一族只由 Z 组成(星检查和面检查就是你见过的例子)。名字取自 Calderbank、Shor、Steane 三人;环面码、表面码和本教程里的每一个码都是 CSS 码。的对易条件。这种写法就在下面现教,底下的数学还是你认识的那条定理。任何一条觉得生疏,就回对应章节重修;橙色虚线点一下弹出定义卡片,浅灰点线的符号点一下告诉你怎么读。全页各处还放了橙色虚线框的「补课」折叠块,把检查、本征态、秩、逻辑算符这些基础从零讲一遍,需要时展开即可。 Only three old facts are needed: the collision theorem, the rank ledger for k, and the toric code's ledger of “two qubits per site, two identities, k = 2”. The first one comes in new clothes: write the checks as rows of a matrix — that table is called a check matrixA 0/1 table: one row per check, one column per physical qubit, and a 1 wherever that check touches that qubit; so a row shows where one check’s legs land, and a column shows which checks watch one qubit. A CSS code has two of them: the X checks form HX and the Z checks form HZ; for the toric code every row of HX is a star and every row of HZ is a plaquette. In classical coding theory it is called the parity-check matrix. — and it becomes the commutation condition of a CSS codeA stabilizer code whose checks split into two families: one made only of X's, one made only of Z's (stars and plaquettes are the example you know). Named after Calderbank, Shor and Steane; the toric code, the surface code and every code in this tutorial are CSS codes.. That way of writing is taught right below; the math underneath is the theorem you already know. Revisit any that feels rusty; amber dashed citations pop up a definition card, faint dotted symbols tell you how they are read. Amber dashed “Catch-up” fold-outs throughout the page explain the basics — checks, eigenstates, rank, logical operators — from scratch; open them when needed.

① CSS 码:X 检查矩阵 HX 与 Z 检查矩阵 HZ 两两对易CSS code: the X-check matrix HX and the Z-check matrix HZ commute pairwise ⇔ HXHZT = 0
(GF(2) 上:每一对行共享的 1 是偶数个over GF(2): every pair of rows shares an even number of 1s)
② k = n − rank HX − rank HZ
③ 环面码 L×L:n = 2L²,星面各 L² 条,∏A = ∏B = I,
独立检查 2L² − 2,k = 2
toric code L×L: n = 2L², L² stars and plaquettes, ∏A = ∏B = I,
2L² − 2 independent checks, k = 2

记号:n = 物理比特数,k = 逻辑比特数,r = 独立检查的条数,于是 k = n − r(与《从高考数学到 Toric Code》4.4 节的记法相同),d = 码距,即能骗过全部检查的最轻逻辑算符的重量(同一教程 5.8 节)。

Notation: n = number of physical qubits; k = number of logical qubits; r = number of independent checks, so k = n − r (the notation of “From High-School Math to the Toric Code”, §4.4); d = the code distance, the weight of the lightest logical operator that fools every check (§5.8 there).

第①条是《从高考数学到 Toric Code》4.2 节的碰撞定理在矩阵语言里的样子。HX 里每条 X 检查占一行,HZ 里每条 Z 检查占一行;每个比特占一列,检查碰到这个比特,那一格写 1,否则写 0。于是一条 X 行和一条 Z 行的点积(mod 2),数的正是这两条检查碰撞次数的奇偶。HXHZᵀ 第 i 行第 j 列的那一格,恰好是第 i 条 X 行与第 j 条 Z 行的点积,所以「两两对易」就是说这个乘积的每一格都是 0:这正是第①条。第②条是同一教程 4.4 节的「每条独立检查砍掉一半」,只是把「独立检查的条数」换成了它的正式名字:矩阵的秩。第③条的环面账本(同一教程 5.3 节)在本教程会以另一副面孔出现:环面码恰好是最简单的 BB 码。先到实验台上把那本账重算一遍:

Item ① is the collision theorem of “From High-School Math to the Toric Code”, §4.2 written in matrix language. HX has one row per X check and HZ one row per Z check; both have one column per qubit, with a 1 wherever the check touches that qubit. The dot product (mod 2) of an X-row and a Z-row then counts their collisions, mod 2. The entry in row i, column j of HXHZᵀ is exactly that dot product for X check i and Z check j, so “every pair commutes” says every entry is 0: that is formula ①. Item ② is §4.4's “every independent check halves the space”, with “number of independent checks” given its proper name: the rank of the matrix. Item ③, the toric ledger (§5.3 there), reappears in this tutorial wearing another face: the toric code is exactly the simplest BB code. Recompute that ledger on the bench first:

补课 · 「一条检查」到底是什么,HX 里的 1 是什么意思Catch-up · What exactly “a check” is, and what a 1 in HX means

先看经典码。三比特重复码把 0 编成 000、1 编成 111。要发现出错,不必读出每一位,只要问「第 1 位加第 2 位(mod 2)是不是 0」:000 和 111 都答 0,010 答 1,说明出错了。这个问题就是一条检查。它可以写成一行 0/1:(1, 1, 0),1 标出「哪几位参与相加」;「检查通过」= 参与位之和为偶数。

Start with a classical code. The three-bit repetition code encodes 0 as 000 and 1 as 111. To catch an error you need not read every bit: just ask “is bit 1 plus bit 2 (mod 2) equal to 0?” — 000 and 111 answer 0, 010 answers 1, so something went wrong. That question is one check. It can be written as a row of 0/1, (1, 1, 0), the 1s marking “which bits take part in the sum”; “the check passes” means the participating bits sum to an even number.

量子码不能直接读比特——读了叠加态就塌了。替代品是测一个算符,让测量结果只透露奇偶。Pauli Z 满足 Z|0⟩ = +|0⟩、Z|1⟩ = −|1⟩,所以在两个比特上各放一个 Z 再乘起来,算符 Z⊗Z 作用在 |b₁b₂⟩ 上给出符号 (−1)b₁+b₂:测得 +1 说明两位相同,−1 说明不同;而 |00⟩ + |11⟩ 这种叠加态测完仍是它自己——只问了奇偶,没问各位是几。这就是「一条 Z 检查」:在某几个比特上放 Z(其余放恒等 I),把它们乘成一个算符,测它,+1 是通过、−1 是警报。写成 0/1 行向量 v,1 标出放了 Z 的比特,和经典的 (1, 1, 0) 完全对应。

A quantum code cannot read its bits directly — reading collapses a superposition. The substitute is to measure an operator whose outcome reveals only a parity. Pauli Z satisfies Z|0⟩ = +|0⟩ and Z|1⟩ = −|1⟩, so placing a Z on each of two qubits and multiplying, the operator Z⊗Z acting on |b₁b₂⟩ gives the sign (−1)b₁+b₂: outcome +1 means the two bits agree, −1 that they differ; and a superposition such as |00⟩ + |11⟩ is left exactly as it was — only the parity was asked, never the individual bits. That is “one Z check”: put a Z on some qubits (identity I on the rest), multiply them into one operator, measure it, +1 is a pass, −1 an alarm. Written as a 0/1 row vector v, the 1s mark the qubits carrying a Z, exactly like the classical (1, 1, 0).

X 检查同理,只是换了一种「位」。X 的本征态是 |+⟩ = |0⟩ + |1⟩(本征值 +1)和 |−⟩ = |0⟩ − |1⟩(−1),在几个比特上放 X 再乘起来,测 X⊗X⊗…,得到的是这些比特「在 ± 基下」的奇偶。它有用,是因为一个 Z 错误会把 |+⟩ 变成 |−⟩——Z 错误在 ± 基下就是一次翻转。所以 X 检查抓 Z 错误,Z 检查抓 X 错误,量子码需要两类检查各管一半。「一条 X 检查是在某些比特上放 X」,说的就是算符 ∏q∈S Xq:S 是它碰到的比特集合,对应 0/1 行向量 u。把所有 X 检查的行叠起来就是 HX,所有 Z 检查叠起来就是 HZ。

X checks work the same way with a different kind of “bit”. The eigenstates of X are |+⟩ = |0⟩ + |1⟩ (eigenvalue +1) and |−⟩ = |0⟩ − |1⟩ (−1); placing X on a few qubits and measuring X⊗X⊗… reads the parity of those qubits “in the ± basis”. It is useful because a Z error turns |+⟩ into |−⟩ — in the ± basis a Z error is a flip. So X checks catch Z errors and Z checks catch X errors, and a quantum code needs both kinds, each minding half of the job. “An X check is X placed on some qubits” means the operator ∏q∈S Xq: S is the set of qubits it touches, encoded as the 0/1 row vector u. Stacking the rows of all X checks gives HX, stacking all Z checks gives HZ.

第 i 行第 j 列的 1 是什么意思What a 1 in row i, column j means

行是检查,列是比特。HX 第 i 行第 j 列为 1,意思是第 i 条 X 检查在第 j 个比特上放了一个 X;为 0 就是什么都不放。同一个 1 从两个方向读,各有一层含义。按行读,一行就是一条检查的「腿」:有 1 的那些列是它碰到的比特,1 的个数是检查重量(3.1);症状电路里每个 1 对应一个 CNOT——辅助比特 i 和数据比特 j 之间要连一根线——这就是6.1 Tanner 图里的一条边。按列读,一列就是一个比特的「归属」:有 1 的那些行是碰到它的检查,决定它出错时谁会报警。一个 X 错误翻转所有含它的 Z 检查的结果,所以 HZ 的第 j 列就是「比特 j 发生 X 错误时的症状」;一般地,错误向量 e(第 j 位为 1 表示比特 j 出了 X 错误)的症状是 s = HZ·e (mod 2),其第 i 个分量是「检查 i 里有多少个出错比特」的奇偶。列里 1 的个数叫比特度,gross 码每列 3 个,一个错误点亮三个警报——6.3 里匹配译码失效的原因。

Rows are checks, columns are qubits. A 1 in row i, column j of HX means check i places an X on qubit j; a 0 means it places nothing. The same 1 reads two ways. Along the row, a row is one check’s “legs”: the columns holding a 1 are the qubits it touches, and the number of 1s is the check weight (§3.1); in the syndrome circuit every 1 is one CNOT — a wire between ancilla i and data qubit j — which is one edge of the Tanner graph of §6.1. Down the column, a column is one qubit’s “membership”: the rows holding a 1 are the checks touching it, which decides who raises the alarm when it fails. An X error flips the outcome of every Z check containing it, so column j of HZ is “the syndrome of an X error on qubit j”; in general an error vector e (bit j set when qubit j suffers an X error) has syndrome s = HZ·e (mod 2), whose i-th entry is the parity of “how many faulty qubits check i contains”. The number of 1s in a column is the qubit degree; the gross code has 3 per column, so one error lights three alarms — the reason matching decoders fail in §6.3.

HX 与 HZ 的行数可以不同HX and HZ may have different numbers of rows

两个矩阵只有列数必须相同——列是物理比特,都是 n 列;行数分别是 X 检查和 Z 检查的条数,没有理由相等。乘积 HXHZᵀ 是 (X 检查数) × (Z 检查数) 的矩阵,照样能乘、照样要求全为 0。经典例子是 Shor 的九比特码,HZ 六行、HX 两行:

Only the number of columns must agree — columns are physical qubits, n of them in both; the numbers of rows count X checks and Z checks separately and need not be equal. The product HXHZᵀ is then an (X checks) × (Z checks) matrix, still well defined and still required to vanish. The classic example is Shor’s nine-qubit code, six rows in HZ and two in HX:

HZq1q2q3q4q5q6q7q8q9
Z₁Z₂110000000
Z₂Z₃011000000
Z₄Z₅000110000
Z₅Z₆000011000
Z₇Z₈000000110
Z₈Z₉000000011
HXq1q2q3q4q5q6q7q8q9
X₁X₂X₃X₄X₅X₆111111000
X₄X₅X₆X₇X₈X₉000111111

任取一条 X 检查和一条 Z 检查,共享的比特要么 0 个、要么 2 个(如 X₁…X₆ 与 Z₁Z₂ 共享 {1, 2}),2 × 6 的 HXHZᵀ 全是偶数,码合法,k = 9 − 6 − 2 = 1。这种不对称有实际含义:六条 Z 检查让它能纠每个三比特块里各一个 X 错误,两条 X 检查却只够纠总共一个 Z 错误。BB 码、环面码里两个矩阵行数恰好都等于 lm,是因为每个格子配了一条 X 检查和一条 Z 检查——这是这一族的对称性,不是 CSS 码的要求;4.1 特意论证 rank HX = rank HZ,正说明它需要证明。行数本身也不重要,重要的是秩(补课 0.D)。

Any X check shares either 0 or 2 qubits with any Z check (X₁…X₆ and Z₁Z₂ share {1, 2}), so the 2 × 6 product HXHZᵀ is all even, the code is legitimate, and k = 9 − 6 − 2 = 1. The asymmetry has a practical meaning: six Z checks let the code correct one X error in each three-qubit block, while two X checks only suffice for a single Z error overall. In BB and toric codes both matrices happen to have lm rows because every site carries one X check and one Z check — a symmetry of this family, not a requirement of CSS codes; §4.1 takes the trouble to prove rank HX = rank HZ precisely because it needs proof. Nor is the row count itself what matters — the rank is (Catch-up 0.D).

补课 · S|ψ⟩ = |ψ⟩ 是什么意思,测量会发生什么Catch-up · What S|ψ⟩ = |ψ⟩ means, and what a measurement does

|ψ⟩ 是一个列向量,ψ 是这个向量的名字,尖括号是物理学家的记法。一个量子比特的状态是二维向量,两个基向量记作 |0⟩ = (1, 0)ᵀ、|1⟩ = (0, 1)ᵀ,一般状态是它们的线性组合,例如 |0⟩ + |1⟩ = (1, 1)ᵀ(归一化系数先不管,不影响下面任何结论)。两个比特的状态是四维向量,基是 |00⟩、|01⟩、|10⟩、|11⟩,比如 |00⟩ + |11⟩ = (1, 0, 0, 1)ᵀ。

|ψ⟩ is a column vector; ψ is its name and the angle bracket is the physicists’ notation. The state of one qubit is a two-dimensional vector with basis vectors |0⟩ = (1, 0)ᵀ and |1⟩ = (0, 1)ᵀ; a general state is a linear combination such as |0⟩ + |1⟩ = (1, 1)ᵀ (normalisation is ignored here; it changes nothing below). Two qubits give a four-dimensional vector with basis |00⟩, |01⟩, |10⟩, |11⟩, e.g. |00⟩ + |11⟩ = (1, 0, 0, 1)ᵀ.

S 是一个矩阵,「S 作用在 |ψ⟩ 上」就是矩阵乘向量。单比特的 Z 和 X 是

S is a matrix, and “S acts on |ψ⟩” is matrix-times-vector. For one qubit,

Z = 100−1X = 0110Z|0⟩ = |0⟩,Z|1⟩ = −|1⟩X|+⟩ = |+⟩,X|−⟩ = −|−⟩

S|ψ⟩ = |ψ⟩ 的字面意思:矩阵 S 乘上向量 |ψ⟩,结果还是原来的向量,一点没变。更一般的形式 S|ψ⟩ = λ|ψ⟩ 说矩阵只把向量拉伸了 λ 倍、没改方向——这样的向量叫 S 的本征向量,λ 叫本征值。Pauli 算符的平方都是 I,所以本征值只能是 +1 或 −1:|0⟩ 是 Z 的 +1 本征向量、|1⟩ 是 −1 本征向量;|+⟩、|−⟩ 对 X 同理。

What S|ψ⟩ = |ψ⟩ says literally: multiply the vector |ψ⟩ by the matrix S and you get the very same vector back. The general form S|ψ⟩ = λ|ψ⟩ says S merely stretches the vector by λ without turning it — such a vector is an eigenvector of S and λ its eigenvalue. Every Pauli operator squares to I, so the eigenvalues can only be +1 or −1: |0⟩ is a +1 eigenvector of Z and |1⟩ a −1 eigenvector; likewise |+⟩ and |−⟩ for X.

为什么这和「检查通过」是一回事。量子力学里「测量一个算符 S」的规则是:结果一定是 S 的某个本征值,测完后状态落到对应的本征向量上。所以若 S|ψ⟩ = |ψ⟩,测 S 必然得 +1,而且状态原地不动——这就是「通过检查、且检查没有破坏状态」,检查之所以可以每一轮反复测而不损伤编码信息,靠的就是这一点。若 S|ψ⟩ = −|ψ⟩,必然得 −1,即警报。码空间的定义就是:所有检查 Si 都满足 Si|ψ⟩ = |ψ⟩ 的那些 |ψ⟩——每一条检查都稳稳答 +1、又不会被测量搅乱的状态,逻辑信息就存在它们的线性组合里。

Why this is the same as “passing the check”. The rule for “measuring an operator S” in quantum mechanics: the outcome is always one of S’s eigenvalues, and afterwards the state lies in the corresponding eigenvector. So if S|ψ⟩ = |ψ⟩, measuring S must give +1 and leaves the state untouched — “the check passes and does not disturb the state”, which is exactly why checks can be measured round after round without harming the encoded information. If S|ψ⟩ = −|ψ⟩ the outcome must be −1: an alarm. The code space is by definition the set of all |ψ⟩ with Si|ψ⟩ = |ψ⟩ for every check Si — states that answer +1 to every check with certainty and are not scrambled by the measurements; the logical information lives in their linear combinations.

diag(1, −1, −1, 1):Z⊗Z 长什么样diag(1, −1, −1, 1): what Z⊗Z looks like

diag 是「对角矩阵」的简写,括号里的数依次放在主对角线上,其余全是 0。对角矩阵乘向量就是把每个分量各乘对角线上对应的数。两比特的四个基向量按 |00⟩、|01⟩、|10⟩、|11⟩ 排序,Z⊗Z 表示「两个比特上都作用 Z」,对 |b₁b₂⟩ 给出符号 (−1)b₁·(−1)b₂,四个基向量各自只被乘了一个数,所以矩阵是对角的。用 2.2 节的克罗内克积算也一样:Z⊗Z = [1·Z, 0·Z; 0·Z, −1·Z]。

diag is short for “diagonal matrix”: the listed numbers sit on the main diagonal and everything else is 0, and such a matrix multiplies each component of a vector by the corresponding diagonal entry. Ordering the two-qubit basis as |00⟩, |01⟩, |10⟩, |11⟩, Z⊗Z means “Z on both qubits” and gives |b₁b₂⟩ the sign (−1)b₁·(−1)b₂; each basis vector is merely scaled, so the matrix is diagonal. The Kronecker product of §2.2 gives the same thing: Z⊗Z = [1·Z, 0·Z; 0·Z, −1·Z].

Z⊗Z = diag(1, −1, −1, 1) = 10000−10000−100001

例:|ψ⟩ = |00⟩ + |11⟩ = (1, 0, 0, 1)ᵀ,Z⊗Z|ψ⟩ = (1·1, −1·0, −1·0, 1·1)ᵀ = |ψ⟩,+1 本征向量,测必得 +1,「两位奇偶相同」通过,叠加态完好且我们仍不知道它是 00 还是 11。|01⟩ + |10⟩ = (0, 1, 1, 0)ᵀ 被送到 (0, −1, −1, 0)ᵀ = −(原向量),本征值 −1,警报。而 |00⟩ + |01⟩ = (1, 1, 0, 0)ᵀ 被送到 (1, −1, 0, 0)ᵀ,不是原向量的倍数——它没有确定的检查结果。

Example: |ψ⟩ = |00⟩ + |11⟩ = (1, 0, 0, 1)ᵀ gives Z⊗Z|ψ⟩ = (1·1, −1·0, −1·0, 1·1)ᵀ = |ψ⟩, a +1 eigenvector: the outcome is certainly +1, “equal parity” passes, the superposition survives and we still do not know whether it is 00 or 11. |01⟩ + |10⟩ = (0, 1, 1, 0)ᵀ is sent to (0, −1, −1, 0)ᵀ = −(itself), eigenvalue −1, alarm. But |00⟩ + |01⟩ = (1, 1, 0, 0)ᵀ is sent to (1, −1, 0, 0)ᵀ, not a multiple of itself — it has no definite check outcome.

两头不靠的态怎么办:测量一定落在 ±1 上States that are neither: measurement still lands on ±1

对任何满足 S² = I 的算符,定义 P₊ = (I + S)/2、P₋ = (I − S)/2。两者相加是 I,所以任何 |ψ⟩ = P₊|ψ⟩ + P₋|ψ⟩;又 S·P₊ = (S + S²)/2 = P₊,所以 P₊|ψ⟩ 是 +1 本征向量,同理 P₋|ψ⟩ 是 −1 本征向量。任何态都能唯一拆成「一份 +1 加一份 −1」,「S|ψ⟩ 既不等于 |ψ⟩ 也不等于 −|ψ⟩」只是说两份都不为零。测 S 得 +1 的概率是 ‖P₊|ψ⟩‖²,得 −1 的概率是 ‖P₋|ψ⟩‖²,测到哪个,状态就塌到那一份。对 Z⊗Z,P₊ 保留 |00⟩、|11⟩ 分量,P₋ 保留 |01⟩、|10⟩ 分量:|00⟩ + |01⟩ 各以 1/2 的概率给 +1(塌到 |00⟩)或 −1(塌到 |01⟩),测完之后 S|ψ′⟩ = ±|ψ′⟩ 就成立了。

For any operator with S² = I define P₊ = (I + S)/2 and P₋ = (I − S)/2. They add up to I, so every |ψ⟩ = P₊|ψ⟩ + P₋|ψ⟩; and S·P₊ = (S + S²)/2 = P₊, so P₊|ψ⟩ is a +1 eigenvector, and likewise P₋|ψ⟩ a −1 eigenvector. Every state splits uniquely into “a +1 part plus a −1 part”; “S|ψ⟩ is neither |ψ⟩ nor −|ψ⟩” just says both parts are nonzero. Measuring S gives +1 with probability ‖P₊|ψ⟩‖² and −1 with probability ‖P₋|ψ⟩‖², and the state collapses onto the part that was found. For Z⊗Z, P₊ keeps the |00⟩, |11⟩ components and P₋ the |01⟩, |10⟩ ones: |00⟩ + |01⟩ gives +1 (collapsing to |00⟩) or −1 (collapsing to |01⟩) with probability 1/2 each, and afterwards S|ψ′⟩ = ±|ψ′⟩ holds.

这件事在纠错里恰恰是关键。真实的错误往往不是干脆的「翻了/没翻」,而是一个小角度的转动 cos θ·|ψ⟩ + sin θ·X₁|ψ⟩。测检查时第一项落在 +1 份、第二项落在 −1 份,于是以 cos²θ 的概率回到 |ψ⟩(错误被测量抹掉),以 sin²θ 的概率变成 X₁|ψ⟩(再补一个 X₁ 纠回来)。连续的模拟错误被检查测量强行数字化成有限几种,量子纠错才能像经典纠错那样工作。物理上「测 Z⊗Z」由一个辅助比特加几个 CNOT 实现(6.2),读出 0 对应 +1、读出 1 对应 −1;它的数学效果就是上面的 P₊、P₋。

This is exactly what error correction relies on. Real errors are rarely a clean “flipped / not flipped” but a small rotation cos θ·|ψ⟩ + sin θ·X₁|ψ⟩. Measuring a check puts the first term in the +1 part and the second in the −1 part, so with probability cos²θ the state returns to |ψ⟩ (the error is erased by the measurement) and with probability sin²θ it becomes X₁|ψ⟩ (undone by applying X₁). Continuous, analogue errors are forcibly digitised into finitely many cases by the check measurements — which is why quantum error correction can work like classical error correction at all. Physically “measuring Z⊗Z” is done with one ancilla and a few CNOTs (§6.2), a readout of 0 meaning +1 and 1 meaning −1; its mathematical effect is precisely P₊ and P₋ above.

补课 · 为什么 HXHZᵀ = 0 就是「两两对易」Catch-up · Why HXHZᵀ = 0 is “pairwise commutation”

第一环:同一个比特上,XZ = −ZX。用 2 × 2 矩阵直接乘:

Link one: on a single qubit, XZ = −ZX. Multiply the 2 × 2 matrices directly:

X·Z = 0−110Z·X = 01−10= −X·Z

不同比特上的算符可以随意交换:X₁ 是 X⊗I⊗I⊗I,Z₂ 是 I⊗Z⊗I⊗I,(X⊗I)(I⊗Z) = X⊗Z = (I⊗Z)(X⊗I),交换不出符号。于是把 X 串 X(u) 从 Z 串 Z(v) 的左边挪到右边,每个共同踩到的比特付一个 −1,其余免费:

Operators on different qubits swap freely: X₁ is X⊗I⊗I⊗I, Z₂ is I⊗Z⊗I⊗I, and (X⊗I)(I⊗Z) = X⊗Z = (I⊗Z)(X⊗I) with no sign. So moving an X string X(u) from the left of a Z string Z(v) to its right costs one −1 per qubit they both touch and nothing elsewhere:

X(u)·Z(v) = (−1)共享比特数shared qubits · Z(v)·X(u)
X₁·Z₁Z₂Z₃Z₄ = (X₁Z₁)Z₂Z₃Z₄ = (−Z₁X₁)Z₂Z₃Z₄ = −Z₁Z₂Z₃Z₄·X₁
共享 1 个比特:反对易one shared qubit: anticommute
X₁X₂·Z₁Z₂Z₃Z₄ = (−1)²·Z₁Z₂Z₃Z₄·X₁X₂
共享 2 个比特:对易two shared qubits: commute

共享比特数怎么用 u、v 算?第 q 位同时为 1 的位置才算共享,所以共享数 = Σq uqvq,正是 u 与 v 的点积(按普通整数加)。于是:对易 ⇔ 点积是偶数 ⇔ u·v ≡ 0 (mod 2)。

How is the shared count computed from u and v? Position q counts only when both uq and vq are 1, so the count is Σq uqvq — the dot product of u and v as ordinary integers. Hence: commute ⇔ the dot product is even ⇔ u·v ≡ 0 (mod 2).

第二环:矩阵乘积的元素就是这些点积。按定义,(HXHZᵀ) 的第 (i, j) 元 = HX 的第 i 行 · HZᵀ 的第 j 列,而 HZᵀ 的第 j 列就是 HZ 的第 j 行竖过来——这正是要写 HZᵀ 而不是 HZ 的原因:矩阵乘法是「左边的行点右边的列」,要让两组检查的行互相点积,就得把 HZ 竖起来。所以 (HXHZᵀ)[i][j] = (第 i 条 X 检查) · (第 j 条 Z 检查) = 它们共享的比特数。

Link two: the entries of the matrix product are exactly these dot products. By definition, entry (i, j) of HXHZᵀ is row i of HX dotted with column j of HZᵀ, and column j of HZᵀ is row j of HZ stood upright — which is why one writes HZᵀ rather than HZ: matrix multiplication dots “rows of the left factor with columns of the right”, so to dot rows against rows, HZ must be turned on its side. Hence (HXHZᵀ)[i][j] = (X check i) · (Z check j) = the number of qubits they share.

第三环:整张表为零 = 每一对都对易。HXHZᵀ 是 (X 检查数) × (Z 检查数) 的一张表,第 (i, j) 格记着那一对共享几个比特。要求它在 mod 2 下等于零矩阵,就是要求每一格都是偶数,即每一对 X 检查、Z 检查都对易——一对都不能例外。为什么一对都不能例外?码空间是全部检查共同的 +1 本征空间;若 S₁S₂ = −S₂S₁ 而某个 |ψ⟩ 同时满足 S₁|ψ⟩ = |ψ⟩、S₂|ψ⟩ = |ψ⟩,则 |ψ⟩ = S₁S₂|ψ⟩ = −S₂S₁|ψ⟩ = −|ψ⟩,只能是零向量:码空间为空,一个态也编不进去。用测量的话说,每一轮要把全部检查都测一遍,不对易的观测量没有同时确定的值。gross 码 72 条 X 检查、72 条 Z 检查,5184 对全都得对易;BB 码的巧处是不必逐对核对,AB + BA = 2AB = 0 一行代数一次保证(3.2)。

Link three: the whole table vanishing = every pair commuting. HXHZᵀ is an (X checks) × (Z checks) table whose cell (i, j) records how many qubits that pair shares. Demanding that it equal the zero matrix mod 2 demands that every cell be even, i.e. that every pair of an X check and a Z check commute — no exception allowed. Why none? The code space is the +1 eigenspace common to all checks; if S₁S₂ = −S₂S₁ and some |ψ⟩ satisfied both S₁|ψ⟩ = |ψ⟩ and S₂|ψ⟩ = |ψ⟩, then |ψ⟩ = S₁S₂|ψ⟩ = −S₂S₁|ψ⟩ = −|ψ⟩, forcing |ψ⟩ = 0: an empty code space, no state can be encoded. In measurement terms, every round measures all the checks, and non-commuting observables have no simultaneous definite values. The gross code has 72 X checks and 72 Z checks, 5184 pairs that must all commute; the BB trick is that they need not be checked one by one — the single line AB + BA = 2AB = 0 guarantees all of them at once (§3.2).

两点澄清。同类检查之间永远对易(同类型 Pauli 相乘不出符号),所以 CSS 码只需管跨类型的这一张表。「对易」也不要求两条检查有交集:多数对根本不碰同一个比特(共享 0 个,0 是偶数),所以对易;条件真正约束的是那些有重叠的对——重叠必须是偶数个。gross 码里每条检查六条腿,绝大多数对是 0 重叠、少数是 2 重叠,没有一对是 1 或 3。

Two clarifications. Checks of the same type always commute (Paulis of one type multiply without signs), so a CSS code only needs this one cross-type table. Nor does “commute” require the two checks to meet: most pairs touch no common qubit (0 shared, and 0 is even) and so commute; the condition really constrains the overlapping pairs, whose overlap must be even. In the gross code every check has six legs, most pairs overlap in 0 qubits, a few in 2, and none in 1 or 3.

数字例子与反例A numerical example and a counterexample

[[4,2,2]]:HX = HZ = (1 1 1 1),HXHZᵀ = 1·1 + 1·1 + 1·1 + 1·1 = 4,偶数,X₁X₂X₃X₄ 与 Z₁Z₂Z₃Z₄ 对易((−1)⁴ = +1)。改成 HX = (1 1 1 0):点积 = 3,奇数,X₁X₂X₃ 与 Z₁Z₂Z₃Z₄ 反对易((−1)³ = −1),码不合法——那个 3 就是共享比特 {1, 2, 3} 的个数。2.4.2 的 bicycle 码那张 3 × 3 的表 (4 2 2; 2 4 2; 2 2 4),每一格也都是「这两条检查共享几个比特」,全是偶数。

[[4,2,2]]: HX = HZ = (1 1 1 1), so HXHZᵀ = 1·1 + 1·1 + 1·1 + 1·1 = 4, even, and X₁X₂X₃X₄ commutes with Z₁Z₂Z₃Z₄ ((−1)⁴ = +1). Change to HX = (1 1 1 0): the dot product is 3, odd, X₁X₂X₃ anticommutes with Z₁Z₂Z₃Z₄ ((−1)³ = −1) and the code is illegitimate — that 3 is the size of the shared set {1, 2, 3}. The 3 × 3 table (4 2 2; 2 4 2; 2 2 4) of the bicycle code in §2.4.2 likewise records “how many qubits do these two checks share” in every cell, all even.

反对易的正面用途:错误被发现The useful side of anticommutation: errors get caught

检查之间要对易,但错误与检查之间恰恰要反对易,这才是发现错误的机制。仍用 [[4,2,2]],码态 |ψ⟩ = |0000⟩ + |1111⟩ 满足 S|ψ⟩ = |ψ⟩(S = Z₁Z₂Z₃Z₄,两个串都有偶数个 1)。比特 1 发生 X 错误后状态变为 X₁|ψ⟩ = |1000⟩ + |0111⟩,对它测 S:S·X₁|ψ⟩ = −X₁·S|ψ⟩ = −X₁|ψ⟩,新状态是 −1 本征态,测量必得 −1——警报。直接看也一样:1000 和 0111 各有奇数个 1,Z₁Z₂Z₃Z₄ 给每一项乘 (−1)奇 = −1。能被发现的错误恰恰是与至少一条检查反对易的错误;与所有检查都对易、却不是检查乘积的算符,则是骗过全部检查的逻辑算符(4.4、补课 4.C)。三种角色,三种关系:检查之间对易;错误与某些检查反对易;逻辑算符与全部检查对易但不是检查乘积。

Checks must commute with each other, but errors and checks are supposed to anticommute — that is the detection mechanism. In [[4,2,2]] again, the code state |ψ⟩ = |0000⟩ + |1111⟩ satisfies S|ψ⟩ = |ψ⟩ (S = Z₁Z₂Z₃Z₄; both strings have an even number of 1s). After an X error on qubit 1 the state is X₁|ψ⟩ = |1000⟩ + |0111⟩, and measuring S on it: S·X₁|ψ⟩ = −X₁·S|ψ⟩ = −X₁|ψ⟩, a −1 eigenstate, so the outcome is certainly −1 — an alarm. Seen directly: 1000 and 0111 each have an odd number of 1s, and Z₁Z₂Z₃Z₄ multiplies each term by (−1)odd = −1. The detectable errors are exactly those anticommuting with at least one check; an operator commuting with all checks yet not a product of checks is a logical operator that fools them all (§4.4, Catch-up 4.C). Three roles, three relations: checks commute with checks; errors anticommute with some checks; logical operators commute with all checks without being products of them.

补课 · 独立检查、秩,与 k = n − rank HX − rank HZCatch-up · Independent checks, rank, and k = n − rank HX − rank HZ
什么叫独立、什么叫不独立Independent versus dependent checks

三个比特上的三条奇偶检查:A「第 1 位 + 第 2 位是偶数」(1, 1, 0),B「第 2 位 + 第 3 位是偶数」(0, 1, 1),C「第 1 位 + 第 3 位是偶数」(1, 0, 1)。八个串里通过 A 的是 000、001、110、111(砍了一半),再通过 B 的只剩 000、111(又砍一半)。加上 C:000 和 111 都通过,一个也没砍掉——因为 b₁ + b₂ 与 b₂ + b₃ 都是偶数时,两式相加得 b₁ + 2b₂ + b₃ 是偶数,即 b₁ + b₃ 必然是偶数。C 的结论已经包含在 A、B 里,这就叫 C 不独立于 A、B。更强的说法是:对任何串,C 的答案永远等于 A 的答案 XOR B 的答案,测 C 不会带来任何新信息。矩阵上 (1, 0, 1) = (1, 1, 0) + (0, 1, 1) (mod 2),第三行是前两行之和,三行的秩只有 2。对比一条独立的第三条 C′「第 3 位是 0」(0, 0, 1):它把 {000, 111} 砍成 {000},无法由前两行相加得到,秩是 3。定义:一组检查里若某一条能写成其他几条的乘积(行向量是其他行 mod 2 之和),它就不独立;独立检查的条数 = 秩 = 真正砍了几次半。

Three parity checks on three bits: A “bit 1 + bit 2 is even” (1, 1, 0), B “bit 2 + bit 3 is even” (0, 1, 1), C “bit 1 + bit 3 is even” (1, 0, 1). Of the eight strings, A passes 000, 001, 110, 111 (halving the set) and B then leaves 000, 111 (halving again). Add C: 000 and 111 both pass, nothing is cut — because when b₁ + b₂ and b₂ + b₃ are both even, their sum b₁ + 2b₂ + b₃ is even, so b₁ + b₃ must be even. C’s verdict is already contained in A and B: C is dependent on them. Stronger still: for every string, C’s answer equals A’s answer XOR B’s answer, so measuring C never yields new information. In matrix terms (1, 0, 1) = (1, 1, 0) + (0, 1, 1) (mod 2), the third row is the sum of the first two, and the three rows have rank only 2. Compare an independent third check C′ “bit 3 is 0” (0, 0, 1): it cuts {000, 111} down to {000}, cannot be obtained by adding the first two rows, and the rank is 3. Definition: in a set of checks, one that can be written as a product of the others (its row is a mod-2 sum of other rows) is dependent; the number of independent checks = the rank = the number of genuine halvings.

量子版一模一样。三条 Z 检查 Z₁Z₂、Z₂Z₃、Z₁Z₃:因为 Z₂² = I,(Z₁Z₂)(Z₂Z₃) = Z₁Z₃,第三条是前两条的乘积,凡满足前两条的态自动满足第三条。8 维空间被 Z₁Z₂ 砍成 4 维(|000⟩、|001⟩、|110⟩、|111⟩ 张成),再被 Z₂Z₃ 砍成 2 维(|000⟩、|111⟩ 张成),Z₁Z₃ 对这两个态都给 (−1)⁰ = (−1)² = +1,什么都没砍。剩下 2 维 = 1 个逻辑比特:这就是三比特重复码,n = 3,rank HZ = 2,rank HX = 0,k = 3 − 2 − 0 = 1——若按行数算 3 − 3 = 0 就错了。多余的检查在码里天然会出现:把 4 个比特放在一个环的 4 条边上,4 个顶点各配一条检查 Z₁Z₂、Z₂Z₃、Z₃Z₄、Z₄Z₁,四条乘起来每个 Z 出现两次、乘积是 I,秩只有 3;环面码的 ∏A = I 是同一件事的二维版——每条边恰好属于两个顶点,所以 L² 条星形检查中必有一条多余。多余的检查并非「错」:它们仍是真命题,测出来的值可以用来核对测量本身有没有出错,只是在数码空间有多大时不能重复计数。

The quantum version is identical. Three Z checks Z₁Z₂, Z₂Z₃, Z₁Z₃: since Z₂² = I, (Z₁Z₂)(Z₂Z₃) = Z₁Z₃, the third is the product of the first two, and any state passing the first two passes the third for free. The 8-dimensional space is cut by Z₁Z₂ to 4 dimensions (spanned by |000⟩, |001⟩, |110⟩, |111⟩), then by Z₂Z₃ to 2 (|000⟩, |111⟩), and Z₁Z₃ gives both of these (−1)⁰ = (−1)² = +1, cutting nothing. The remaining 2 dimensions are one logical qubit: this is the three-qubit repetition code, n = 3, rank HZ = 2, rank HX = 0, k = 3 − 2 − 0 = 1 — counting rows instead, 3 − 3 = 0, would be wrong. Redundant checks arise naturally: put 4 qubits on the edges of a ring with a check Z₁Z₂, Z₂Z₃, Z₃Z₄, Z₄Z₁ at each of the 4 vertices; multiplying all four, every Z appears twice and the product is I, so the rank is only 3. The toric identity ∏A = I is the two-dimensional version — every edge belongs to exactly two vertices, so one of the L² star checks must be redundant. Redundant checks are not “wrong”: they are still true statements, and their outcomes can be used to cross-check the measurements themselves; they simply must not be double-counted when sizing the code space.

为什么 k = n − rank HX − rank HZWhy k = n − rank HX − rank HZ

n 个比特的状态空间是 2ⁿ 维。一条检查 S 的本征值 ±1 把空间分成 +1、−1 两半,各 2ⁿ⁻¹ 维(Pauli 算符的迹是 0,两半一样大);要求「通过检查」就是只保留 +1 那一半。r 条独立且两两对易的检查砍 r 次,剩 2ⁿ/2ʳ = 2ⁿ⁻ʳ 维,而 2ᵏ 维的空间恰好能存 k 个逻辑比特,所以 k = n − r。为什么 r = rank HX + rank HZ?两条 X 检查相乘,X(u)·X(v) = X(u + v)(同一比特上 X·X = I,对应 1 + 1 = 0),所以「若干检查的乘积」对应「若干行 mod 2 相加」,X 型独立检查的条数就是 rank HX,Z 型同理;而 X 型算符的乘积还是 X 型,不可能等于一个 Z 型乘积(除非两边都是 I),两类之间不会产生新的依赖,秩可以直接相加。

The state space of n qubits has 2ⁿ dimensions. One check S with eigenvalues ±1 splits it into a +1 half and a −1 half of 2ⁿ⁻¹ dimensions each (a Pauli operator has trace 0, so the halves are equal); demanding “pass” keeps only the +1 half. r independent, mutually commuting checks cut r times, leaving 2ⁿ/2ʳ = 2ⁿ⁻ʳ dimensions, and a 2ᵏ-dimensional space stores exactly k logical qubits, so k = n − r. Why is r = rank HX + rank HZ? Two X checks multiply as X(u)·X(v) = X(u + v) (X·X = I on a shared qubit, matching 1 + 1 = 0), so “a product of several checks” corresponds to “a mod-2 sum of several rows”, and the number of independent X checks is rank HX; likewise for Z. A product of X-type operators is again X-type and can never equal a product of Z-type operators (unless both are I), so the two kinds create no new dependencies and the ranks simply add.

更具体的数法(CSS 码专属)。在 |c⟩(c 是 n 位 0/1 串)这组基下,Z 检查是经典的奇偶校验:Z(v)|c⟩ = (−1)v·c|c⟩,|c⟩ 通过全部 Z 检查 ⇔ HZ·c = 0,这些 c 组成一个经典线性码 C₁,元素个数 2n − rank HZ。X 检查是平移:X(u)|c⟩ = |c + u⟩,要在全部 X 检查下不变,态必须对整个陪集 c + C₂ 均匀叠加,其中 C₂ = HX 的行空间(所有行的 mod 2 组合),元素个数 2rank HX。于是码态是 |c + C₂⟩ = Σw∈C₂|c + w⟩(c ∈ C₁),彼此独立的码态数 = C₁ 被切成多少个陪集 = 2n − rank HZ / 2rank HX,指数就是 k。这个构造成立需要 C₂ ⊂ C₁(平移不能把通过 Z 检查的串搬到不通过的串上),而这恰恰就是 HZHXᵀ = 0——对易条件在这里再次出现。

A more concrete count, special to CSS codes. In the basis |c⟩ (c an n-bit 0/1 string) the Z checks are classical parity checks: Z(v)|c⟩ = (−1)v·c|c⟩, so |c⟩ passes every Z check ⇔ HZ·c = 0, and these c form a classical linear code C₁ with 2n − rank HZ elements. The X checks are translations: X(u)|c⟩ = |c + u⟩, and to be invariant under all of them a state must be a uniform superposition over a whole coset c + C₂, where C₂ = the row space of HX (all mod-2 combinations of its rows), with 2rank HX elements. The code states are therefore |c + C₂⟩ = Σw∈C₂|c + w⟩ (c ∈ C₁), and the number of independent ones = the number of cosets C₁ splits into = 2n − rank HZ / 2rank HX, whose exponent is k. The construction needs C₂ ⊂ C₁ (a translation must not carry a string passing the Z checks onto one that fails), and that is exactly HZHXᵀ = 0 — the commutation condition again.

三个例子。[[4,2,2]],HX = HZ = (1 1 1 1):通过 Z₁Z₂Z₃Z₄ 的串是偶重量的 8 个(24−1),C₂ = {0000, 1111} 把它们两两配对成 4 个陪集,4 个码态 |0000⟩+|1111⟩、|0011⟩+|1100⟩、|0101⟩+|1010⟩、|0110⟩+|1001⟩,4 = 2²,k = 4 − 1 − 1 = 2。Shor 九比特码:通过 6 条 Z 检查的是每个三比特块都为 000 或 111 的 8 个串;C₂ = {000000000, 111111000, 000111111, 111000111},4 个元素;8 个串切成 2 个陪集,k = 9 − 6 − 2 = 1,而且能直接看出码态:含偶数个 111 块的四个串叠加是 |0̄⟩ = (|000⟩+|111⟩)⊗3,含奇数个的是 |1̄⟩。环面码 toric_L3:n = 18,HX、HZ 各 9 行但各只有 8 行独立(∏ = I),k = 18 − 8 − 8 = 2;错用行数会得到 18 − 18 = 0。

Three examples. [[4,2,2]], HX = HZ = (1 1 1 1): the strings passing Z₁Z₂Z₃Z₄ are the 8 even-weight ones (24−1); C₂ = {0000, 1111} pairs them into 4 cosets, giving the 4 code states |0000⟩+|1111⟩, |0011⟩+|1100⟩, |0101⟩+|1010⟩, |0110⟩+|1001⟩, 4 = 2², k = 4 − 1 − 1 = 2. Shor’s nine-qubit code: the strings passing the 6 Z checks are the 8 in which each three-qubit block is 000 or 111; C₂ = {000000000, 111111000, 000111111, 111000111} has 4 elements; the 8 strings split into 2 cosets, k = 9 − 6 − 2 = 1, and the code states can be read off: the superposition of the four strings with an even number of 111 blocks is |0̄⟩ = (|000⟩+|111⟩)⊗3, the odd ones give |1̄⟩. The toric code toric_L3: n = 18, HX and HZ have 9 rows each but only 8 independent (∏ = I), so k = 18 − 8 − 8 = 2; using row counts would give 18 − 18 = 0.

怎么算秩:GF(2) 上的高斯消元Computing the rank: Gaussian elimination over GF(2)

允许的操作只有两种——交换两行、把一行加到另一行上(加法是 XOR)——它们都不改变「这些行能组合出哪些向量」,所以不改变秩。目标是消成阶梯形:每个非零行有一个「打头的 1」,而这一列里其他行全是 0,这样的非零行互相独立:每一行在自己打头的那一列上是 1,别的行在这一列都是 0,所以不管挑哪几行相加,这些打头的 1 都消不掉,得不到零向量;它们的个数就是秩;被消成零行的,记录了一条依赖关系。步骤:从左往右逐列处理,在还没用过的行里找一个这一列为 1 的行当主元行(找不到就跳到下一列),把主元行加到其他所有这一列为 1 的行上,秩加一。

Only two operations are allowed — swapping two rows, and adding one row to another (addition is XOR) — and neither changes “which vectors these rows can combine into”, hence neither changes the rank. The goal is echelon form: every nonzero row has a “leading 1” whose column is 0 in all other rows; such nonzero rows are independent: each has a 1 in its own leading column, where every other row has 0, so no sum of some of them can cancel those leading 1s and reach the zero vector; their number is the rank, while any row reduced to zero records a dependency. Procedure: go through the columns left to right, pick among the unused rows one with a 1 in this column as pivot (skip the column if none), add the pivot row to every other row with a 1 in this column, and count one more for the rank.

r₁ = 1 1 0 r₂ = 0 1 1 r₃ = 1 0 1
第 1 列:r₁ 打头,r₃ ← r₃ + r₁ = 0 1 1;第 2 列:r₂ 打头,r₃ ← r₃ + r₂ = 0 0 0column 1: pivot r₁, r₃ ← r₃ + r₁ = 0 1 1; column 2: pivot r₂, r₃ ← r₃ + r₂ = 0 0 0
两个非零行,rank = 2;零行说的是 r₃ = r₁ + r₂two nonzero rows, rank = 2; the zero row says r₃ = r₁ + r₂

再看环上的四条检查 (1100), (0110), (0011), (1001):第 1 列 r₁ 打头,r₄ ← r₄ + r₁ = 0101;第 2 列 r₂ 打头,r₄ ← r₄ + r₂ = 0011;第 3 列 r₃ 打头,r₄ ← r₄ + r₃ = 0000。秩 = 3,清零对应 r₁ + r₂ + r₃ + r₄ = 0,即「所有检查乘起来是 I」。2.4.2 的 bicycle 码 H:第 1 列 r₁ 打头,r₃ ← r₃ + r₁ 后与 r₂ 相同,第 2 列再消掉,秩 = 2,于是 k = 6 − 2 − 2 = 2。反过来,Shor 码的 HZ 六行打头的 1 分别在第 1、2、4、5、7、8 列,已是阶梯形,直接读出秩 6。行秩等于列秩,所以 rank Mᵀ = rank M——4.1 证两个秩相等时用到它。计算机做的是同一套动作,本页「现场重算 n、k」跑的正是这个循环,写成代码十来行:

Next the four ring checks (1100), (0110), (0011), (1001): column 1, pivot r₁, r₄ ← r₄ + r₁ = 0101; column 2, pivot r₂, r₄ ← r₄ + r₂ = 0011; column 3, pivot r₃, r₄ ← r₄ + r₃ = 0000. Rank = 3, and the cleared row is r₁ + r₂ + r₃ + r₄ = 0, “all checks multiply to I”. For the bicycle H of §2.4.2: column 1, pivot r₁, and r₃ ← r₃ + r₁ becomes identical to r₂, which column 2 then clears; rank = 2, hence k = 6 − 2 − 2 = 2. Conversely Shor’s HZ has its six leading 1s in columns 1, 2, 4, 5, 7, 8, already echelon, rank 6 by inspection. Row rank equals column rank, so rank Mᵀ = rank M — used in §4.1 to show the two ranks agree. A computer performs the same moves; this page’s live recomputation of n and k runs exactly this loop, a dozen lines of code:

def rank_gf2(rows):                       # rows: 0/1 列表的列表 / lists of 0/1
    rows, rank = [r[:] for r in rows], 0
    for c in range(len(rows[0])):
        piv = next((i for i in range(rank, len(rows)) if rows[i][c]), None)
        if piv is None: continue
        rows[rank], rows[piv] = rows[piv], rows[rank]
        for i in range(len(rows)):
            if i != rank and rows[i][c]:
                rows[i] = [a ^ b for a, b in zip(rows[i], rows[rank])]
        rank += 1
    return rank

gross 码的 HX 是 72 × 144 的矩阵,手算不现实,但交给这个函数就是 66,秩亏损 72 − 66 = 6,k = 12。

The gross code’s HX is 72 × 144, hopeless by hand, but this function returns 66: a rank deficit of 72 − 66 = 6, so k = 12.

一句话总结In one sentence

环面码的检查是「画」在网格上的;BB 码的检查是「算」出来的:两个多项式各自变成一个稀疏矩阵,拼成 HX = [A | B]分块矩阵:一个中括号,竖线只标出分界。[A | B] 就是把 A、B 左右并排拼成一张宽矩阵——行数不变,列数相加。每列对应一个数据比特:左块管一半,右块管另一半。 与 HZ = [Bᵀ | Aᵀ],对易由代数自动保证(第 3 章),k 由秩的亏损给出(第 4 章)。搜索的自由度花在多项式的几个指数上,收获是 8 到 12 个逻辑比特挤在一块检查重量为 6 的码里(第 5 章);代价是每个比特要和 6 条检查相连,芯片必须有两层耦合(第 6 章)。

A toric code's checks are drawn on a grid; a BB code's checks are computed: two polynomials each become a sparse matrix, assembled into HX = [A | B]A block matrix: one bracket, the bar only marks the seam. [A | B] puts A and B side by side into one wide matrix — same rows, columns added. Each column is one data qubit: the left block covers half of them, the right block the other half. and HZ = [Bᵀ | Aᵀ], with commutation guaranteed by algebra (Ch. 3) and k given by a rank deficit (Ch. 4). The search freedom goes into a few polynomial exponents; the payoff is 8 to 12 logical qubits packed into a code with weight-6 checks (Ch. 5); the price is that every qubit couples to 6 checks, so the chip needs two coupling layers (Ch. 6).

第 1 章Chapter 1

为什么要 BB:一块贴片一个逻辑比特太贵Why BB: one patch per logical qubit is too dear

表面码把一个逻辑比特摊在 d² 个数据比特上,而且不管做多大都只存这一个。这不是设计失误,是二维局域码的定理。BB 码不推翻这条定理,而是把它里面的常数用到极致:检查从「最近邻」伸到几格之外并绕过环面,芯片多一层耦合,换来同样比特数下八到十二倍的逻辑比特。 A surface code spreads one logical qubit over d² data qubits, and stores only that one however large it grows. This is not a design flaw but a theorem about 2D local codes. BB codes do not overturn the theorem; they push its constant to the limit: checks reach a few sites away and wrap around a torus, the chip gains one coupling layer, and the same qubit count stores eight to twelve times as many logical qubits.

1.1一条定理:k·d² ≤ c·nA theorem: k·d² ≤ c·n

《Surface Code · 高中数学版》第 2 章算过,d = 11 的表面码要 221 个数据比特存 1 个逻辑比特。能不能在同一张网格上多存几个?2009 年 Bravyi、Poulin 与 Terhal 证明:只要检查是二维平面上的局域算符(每条检查只碰一个小方块里的比特),就有 k·d² ≤ c·n,c 是只与检查的大小和伸展范围有关的常数。对表面码,k = 1、n ≈ d²,这条不等式几乎是等号——它已经把二维局域码能做的事做到头了。常数 c 随检查的大小和伸展范围变大,所以在固定的 n 上还有不少余地;但想让 k 随 n 一起增长而 d 不塌,就必须放弃「局域」——那是《qLDPC 码 · 高中数学版》的事。

“The Surface Code · High-School Edition”, Chapter 2 counted 221 data qubits for one logical qubit at d = 11. Could the same grid store several? In 2009 Bravyi, Poulin and Terhal proved that as long as the checks are local operators in the plane (each touching only qubits inside a small square), k·d² ≤ c·n with c depending only on the size and reach of the checks. For the surface code, k = 1 and n ≈ d², so the inequality is nearly an equality — it has already exhausted what 2D local codes can do. The constant c grows with the size and reach of the checks, so at fixed n there is still room to gain; but to let k grow with n without d collapsing, locality must go — that is the business of “qLDPC Codes · High-School Edition”.

二维局域稳定子码2D local stabilizer codes: k·d² ≤ c·n · 表面码surface code: k = 1, n ≈ d² ⇒ k·d²/n ≈ 1

字母含义:k = 逻辑比特数,d = 码距,n = 物理比特数(三者的定义见第 0 章的记号说明);c = 一个只与检查的大小和伸展范围有关、与 n 无关的常数。

The letters: k = logical qubits, d = code distance, n = physical qubits (defined in the notation note of Chapter 0); c = a constant that depends only on the size and reach of the checks, not on n.

为什么局域性会锁死 k?(证明的骨架)Why does locality cap k? (the skeleton of the proof)

任何少于 d 个比特的区域都是「可纠正」的:抹掉它,剩下的部分能完整恢复编码信息,所以这块区域里不含任何逻辑信息。二维局域性让可纠正的区域可以拼大:一个边长约 d 的方块及其边界都可纠正时,方块能再长一圈。于是整张网格可以切成两张棋盘 A、B(各由许多边长约 d 的可纠正方块组成)加上方块角上的小碎片 C。A、B 都不含逻辑信息,k 个逻辑比特只能全部躲在 C 里;而 C 的面积只有 n/d² 的量级——这就是 k ≤ c·n/d²。证明的精确版本要用到量子信息的一条奇特性质:可纠正区域的条件熵是负的。完整推导见 QEC-Bank 的基础页 bravyi-poulin-terhal。

Any region of fewer than d qubits is “correctable”: erase it and the rest still recovers the encoded information, so the region holds no logical information. 2D locality lets correctable regions be enlarged: when a square of side about d and its boundary are both correctable, the square can grow by one more ring. So the whole grid can be cut into two checkerboards A and B (each made of many correctable squares of side about d) plus small corner pieces C. A and B hold no logical information, so all k logical qubits must hide in C — whose area is only of order n/d². That is k ≤ c·n/d². The precise proof uses a peculiar property of quantum information: a correctable region has negative conditional entropy. The full derivation is the QEC-Bank foundations page bravyi-poulin-terhal.

1.2放弃局域的最小代价The smallest price for giving up locality

在这条不等式里,BB 码动的是常数 c,不是定理:每条检查仍然只碰 6 个比特,每个比特仍然只被 6 条检查碰到(低密度LDPC = low-density parity check:检查矩阵每行、每列的 1 都不超过一个固定的小数目。BB 码每行 6 个、每列 6 个。,和表面码的 4 差得不多),只是这 6 个比特不再挤在一个小方块里,而是按两个多项式规定的方向伸到几格之外(gross 码是三格),并且绕过环面接回来。gross 码的 k·d² = 12·144 = 12n,是表面码的十二倍——与 BPT 不矛盾:检查伸得更远,常数 c 就更大。要把这样的线布到平面芯片上,Bravyi 等人 2024 年证明连接图可以画成两层平面图,每层每个比特最多连三根线——比起一层最近邻的表面码,多的只是一层。

Within that inequality, BB codes move the constant c, not the theorem: every check still touches only 6 qubits and every qubit is touched by only 6 checks (low densityLDPC = low-density parity check: every row and column of the check matrix has at most a fixed small number of 1s. BB codes have 6 per row and 6 per column., not far from the surface code's 4), except that those 6 qubits no longer crowd into one small square but reach a few sites away in directions set by two polynomials (three for the gross code) and wrap around the torus. The gross code's k·d² = 12·144 = 12n is twelve times the surface code's — no contradiction with BPT: longer-reaching checks mean a larger constant c. To wire this on a planar chip, Bravyi et al. showed in 2024 that the connection graph can be drawn as two planar layers with at most three wires per qubit per layer — one layer more than the nearest-neighbour surface code.

(a) 表面码:一层(a) Surface code: one layer 每个比特 4 根线,全是近邻4 short wires per qubit (b) BB 码:每个比特 6 根线(b) BB code: 6 wires per qubit 4 根近邻 + 2 根伸到三格外 · 一层画不平4 short + 2 long wires · not planar 上层:3 根top: 3 wires 下层:3 根bottom: 3 wires (c) 拆成两个平面耦合层(c) Split into two planar coupling layers 6 = 3 + 3 · 每层都是平面图6 = 3 + 3 · each layer planar
图 1.1 这是示意图,不是 gross 码的真实布线。(a) 表面码:每个比特连 4 根线,都通向紧挨着的检查,一层网格就放得下。(b) BB 码:每个比特连 6 根线(3 条 X 检查、3 条 Z 检查),其中 4 根仍是近邻,另外 2 根伸到三格之外(橙色虚线);这样的图没法在一层里画平而不交叉。(c) 但它能拆成两个耦合层,每层都是平面图。把 A、B 各写成三项之和,A = A₁ + A₂ + A₃、B = B₁ + B₂ + B₃(第 3 章会看到 A、B 是什么):一个耦合层放 A₂、A₃、B₃ 的线,另一个放 A₁、B₁、B₂ 的线。同一个比特在每个耦合层恰好 3 根线,3 + 3 = 6——这就是 Bravyi 等人 2024 年论文里的引理 2。 Fig. 1.1 A schematic, not the real wiring of the gross code. (a) Surface code: each qubit has 4 wires, all to the checks right next to it, and one flat layer holds them. (b) BB code: each qubit has 6 wires (3 to X-checks, 3 to Z-checks); 4 are still short, but 2 reach three cells away (dashed amber), and a graph like this cannot be drawn flat in one layer without crossings. (c) It can, though, be split into two planar coupling layers. Write A and B as sums of three terms each, A = A₁ + A₂ + A₃ and B = B₁ + B₂ + B₃ (Chapter 3 says what A and B are): one coupling layer carries the wires of A₂, A₃ and B₃, the other those of A₁, B₁ and B₂. Every qubit ends up with exactly 3 wires in each coupling layer, and 3 + 3 = 6 — that is Lemma 2 of Bravyi et al. (2024).

代价与收获的账在下一张图里:

The ledger of price and payoff is in the next picture:

图里的红点是 Bravyi 等人 2024 年论文 Table 3 的五个码加上两个小锚点。gross 码 [[144,12,12]] 用 144 个数据比特存 12 个逻辑比特,码距 12;同样 144 个数据比特的旋转表面码只存 1 个(d = 12)。这就是论文里「十二倍」的来源——注意它比的只是数据比特,辅助比特、译码器、逻辑门的代价都要另算(第 6 章)。

The red dots are the five codes of Table 3 in Bravyi et al.'s 2024 paper plus two small anchors. The gross code [[144,12,12]] stores 12 logical qubits in 144 data qubits at distance 12; a rotated surface code with the same 144 data qubits stores 1 (d = 12). That is the paper's “twelve-fold” — a comparison of data qubits only; ancillas, the decoder and logical gates are charged separately (Ch. 6).

关键想法Key idea

表面码的 k = 1 不是懒,是定理:二维局域必然 k·d² ≤ c·n。BB 码保留了「每条检查只碰 6 个比特」的稀疏性,把「这 6 个比特必须挨着」放宽成「伸到几格之外并绕过环面」,于是吃满了常数 c:代价是芯片多一层耦合,收获是同样的 n 下 k 从 1 变成 8 到 12。它没有推翻定理——把 gross 的两个多项式固定、只放大环面,作用范围有界,k 也有界——具体值随环面尺寸而变(第 6 章)。

The surface code's k = 1 is not laziness but a theorem: 2D locality forces k·d² ≤ c·n. BB codes keep the sparsity of “each check touches only 6 qubits”, relax “those 6 must be adjacent” to “a few sites away, wrapping around the torus”, and so use up the constant c: the price is one more coupling layer on the chip, the payoff k rising from 1 to 8–12 at the same n. The theorem is not overturned — keep the gross polynomials fixed and grow the torus: the interaction range and k both stay bounded, with k depending on the torus dimensions (Ch. 6).

检查站Checkpoint第 1 章Chapter 1
有人提出一族二维最近邻的稳定子码,声称 n 每翻 4 倍,k 和 d 都翻一倍(k ∝ √n、d ∝ √n)。按 BPT 界,这可能吗?Someone proposes a family of 2D nearest-neighbour stabilizer codes claiming that whenever n quadruples, both k and d double (k ∝ √n, d ∝ √n). Is that possible under the BPT bound?

对。BPT 界允许常数 c 随检查的大小和伸展范围变大,但不允许 k·d²/n 随 n 增长。要么它的检查并不局域,要么它的 k 或 d 被高估了。BB 码正是靠更大的 c 在固定 n 上取胜(第 6 章讲它的渐近)。

Right. The BPT bound lets the constant c grow with the size and reach of the checks, but never lets k·d²/n grow with n. Either the checks are not local, or k or d is overstated. BB codes win at fixed n through a larger c (Chapter 6 covers their asymptotics).

算一下 k·d² 随 n 怎么变。

Work out how k·d² scales with n.

第 2 章Chapter 2

单项式是一步平移,多项式是一枚印章A monomial is a step, a polynomial is a stamp

第 1 章说 BB 码的检查要「伸到几格之外」。怎么描述这样的检查?借环面码的做法:每个格子上的检查长得一模一样,只是平移到了不同位置,所以只需说清一个形状——它的腿落在哪几个偏移 (a, b) 上。每个偏移是一次平移,记作 xayb;几个偏移加起来就是多项式。gross 码的 A = x³ + y + y² 记下的就是三条腿「右 3、上 1、上 2」,另外三条由 B 给出。于是 BB 码的全部输入是四个东西:环面的尺寸 l、m 和两个多项式 A、B。这一章教你像专家那样读多项式:不写矩阵,直接在格子上走。词典只有三条——1 是原地不动,x 是往右走一格,y 是往上走一格,走出边界就从对面绕回来。有了它,一个多项式就是一枚「印章」:盖在哪个格子上,就碰到哪几个格子;两枚印章重叠几格,把两个多项式乘一下就知道(2.3.2)。平移还白送一个性质:先右后上与先上后右到达同一处,第 3 章的对易定理就靠它。矩阵只是把同一件事交给计算机的记账方式,每节末尾再讲。最后一节(2.4)把这些工具第一次用来造码:暂时拿掉 y,在一圈格子上搭出 BB 码的一维祖先 bicycle 码——两层比特、[C | Cᵀ]、对易与 k 都先在 6 个比特上演一遍,第 3 章再原样搬到环面上。 Chapter 1 said a BB code's checks “reach a few sites away”. How do we describe such a check? Borrow the toric code's habit: the check on every site has the same shape, merely translated to a different place, so it is enough to state one shape — the offsets (a, b) where its legs land. Each offset is a translation, written xayb; add a few offsets and you have a polynomial. The gross code's A = x³ + y + y² records three legs, “right 3, up 1, up 2”; B supplies the other three. So a BB code's entire input is four things: the torus size l, m and two polynomials A, B. This chapter teaches you to read a polynomial the way experts do: no matrices, just walking on a grid. The dictionary has three entries — 1 means stay put, x means one step right, y means one step up, and walking off an edge brings you back on the opposite side. With it a polynomial becomes a stamp: press it on a site and it touches a few sites; how many sites two stamps share, one polynomial product tells you (§2.3.2). Translations also come with a free gift: right-then-up and up-then-right land on the same site, which is all Chapter 3's commutation theorem needs. Matrices are merely the bookkeeping that hands the same thing to a computer, and they come at the end of each section. The last section (§2.4) puts these tools to work on a code for the first time: drop y for a moment and build, on a single ring, the one-variable ancestor of BB codes, the bicycle code — two layers of qubits, [C | Cᵀ], commutation and k all rehearsed on 6 qubits before Chapter 3 moves them unchanged onto the torus.

2.1一步平移:走一格,走满一圈回原地One step: move one site, and a full turn brings you home

先只看一个方向。把 l 个格子排成一圈,编号 0 到 l−1(图 2.1,l = 6)。记号 x 表示一个动作:每个格子都往右走一格,第 l−1 格再往右一步就回到第 0 格,像表针走过 12 点又回到 1 点。两个动作「相乘」就是一个接一个地做:x·x = x² 是走两格,xa 是走 a 格,xa·xb = xa+b;1 是走 0 格,也就是原地不动。

Look at one direction first. Arrange l sites in a ring numbered 0 to l−1 (Fig. 2.1, l = 6). The symbol x stands for a move: every site steps one place to the right, and one more step from site l−1 lands back on site 0, like a clock hand passing 12 and coming round to 1. “Multiplying” two moves means doing one after the other: x·x = x² is two steps, xa is a steps, xa·xb = xa+b; and 1 is zero steps, i.e. staying put.

由此有两条规则,本章反复用到。第一,xl = 1:走满一圈回到原地,所以指数只看它除以 l 的余数(mod l「模 l」:数到 l 就绕回 0,所以 (l−1)+1 ≡ 0 (mod l)。);l = 6 时 x⁸ = x²。第二,x−1 = xl−1:向左走一格,和向右走 l−1 格落在同一个格子上。最要紧的是第三件事:走法可以随意交换次序——先走 a 格再走 b 格,与先走 b 格再走 a 格,都是走 a + b 格,归根结底是 a + b = b + a。

Two rules follow, used again and again in this chapter. First, xl = 1: a full turn brings you home, so an exponent matters only through its remainder on division by l (mod l“modulo l”: counting wraps back to 0 at l, so (l−1)+1 ≡ 0 (mod l).); for l = 6, x⁸ = x². Second, x−1 = xl−1: one step left lands on the same site as l−1 steps right. The third fact matters most: moves can be done in any order — a steps then b steps, or b steps then a steps, is a + b steps either way; at bottom, a + b = b + a.

0 1 2 3 4 5 x x² x⁻¹ 从格子 4 出发(l = 6,走法按顺时针算「向右」):Start at site 4 (l = 6; “right” means clockwise): x:向右一格,到 5x: one step right, to 5 x²:向右两格,走过 5 绕回,到 0x²: two steps right, past 5 and round, to 0 x⁻¹:向左一格,到 3(与 x⁵ 相同)x⁻¹: one step left, to 3 (the same as x⁵) x⁶ = 1:走满一圈,回到 4x⁶ = 1: a full turn brings you back to 4
图 2.1Fig. 2.1 一圈 l = 6 个格子。平移 x 让每个格子向右(这里画成顺时针)走一格;从格子 4 出发,x 到 5,x² 到 0,x⁻¹ 到 3。 A ring of l = 6 sites. The step x moves every site one place right (drawn clockwise here); from site 4, x reaches 5, x² reaches 0 and x⁻¹ reaches 3.

记账:交给计算机的写法。计算机不会「走格子」,它存一张 l × l 的表 S:第 i 行只在第 i+1 列(mod l)写 1,意思是「从格子 i 出发,落在格子 i+1」(图 2.2 画出 l = 2、3 的两张)。这样每行每列恰有一个 1 的表叫置换矩阵permutation matrix:每行每列恰有一个 1 的方阵;它作用在向量上只是重排分量的顺序。置换矩阵的转置是它的逆。。上面的规则逐条翻译过来:S² 是走两格,Sl = I 是转一整圈(I 是单位矩阵,对应「原地不动」的 1),Sᵀ 的 1 在第 i 行第 i−1 列,即向左一格:Sᵀ = S−1。矩阵乘法怎么算、为什么 Sl = I,补课 2.A 一格一格算给你看。

Bookkeeping: how a computer writes it. A computer does not “walk”; it stores an l × l table S whose row i has a single 1, in column i+1 (mod l), meaning “start at site i, land on site i+1” (Fig. 2.2 draws the two for l = 2 and 3). A table with exactly one 1 per row and column is a permutation matrixA square matrix with exactly one 1 in each row and column; acting on a vector it merely reorders the components. Its transpose is its inverse.. The rules above translate one by one: S² is two steps, Sl = I a full turn (I is the identity matrix, the matrix of “stay put”, 1), and Sᵀ has its 1 in column i−1 of row i, one step left: Sᵀ = S−1. How matrix multiplication works, and why Sl = I, Catch-up 2.A computes entry by entry.

Sl[i][(i+1) mod l] = 1
Sl = I
Sᵀ = S−1
l = 3 时for l = 3: S = [0 1 0; 0 0 1; 1 0 0]
(a) l = 2:两个格子(a) l = 2: two sites 绕回wraps 0 1 S2(2 × 2)S2 (2 × 2) 0 1 1 0 0 0 1 1 2 个格子 → 2 × 2 的矩阵2 sites → a 2 × 2 matrix (b) l = 3:三个格子(b) l = 3: three sites 绕回wraps 0 1 2 S3(3 × 3)S3 (3 × 3) 0 1 0 0 0 1 1 0 0 0 0 1 1 2 2 3 个格子 → 3 × 3 的矩阵3 sites → a 3 × 3 matrix 行号 = 出发的格子,列号 = 到达的格子;第 i 行的 1 在第 i+1 列row = the site you start from, column = the site you land on; row i has its 1 in column i+1
图 2.2 循环移位的尺寸由格子数决定:l 个格子就是 l × l 的方阵,因为每一行对应一个出发的格子,每一列对应一个到达的格子。蓝色的 1 是「往右挪一格」,粉色的 1 是最后一格绕回第 0 格。这两个就是下一节图 2.4 那个 2 × 3 小例子的零件:S2 管第一个坐标,S3 管第二个。 Fig. 2.2 The size of a cyclic shift is set by the number of sites: l sites give an l × l square matrix, because each row is a starting site and each column a landing site. Blue 1s are “step right”; the pink 1 is the last site wrapping to site 0. These two are the parts for the 2 × 3 example of Fig. 2.4 in the next section: S2 for the first coordinate, S3 for the second.
补课 · 矩阵乘法怎么算:S·S 与 Sl = I 的演算Catch-up · How matrix multiplication works: computing S·S and Sl = I

矩阵乘法的规则只有一句话:结果的第 i 行第 j 列 = 左矩阵的第 i 行与右矩阵的第 j 列逐项相乘再相加(点积)。左矩阵 a × b、右矩阵 b × c,结果 a × c。把 S 的行和列分别写出来(c₀ 是第一列从上往下读):

Matrix multiplication is one sentence: entry (i, j) of the product = row i of the left factor dotted with column j of the right factor (multiply termwise, add up). An a × b matrix times a b × c matrix gives a × c. Write out the rows and columns of S (c₀ is the first column read top to bottom):

S = 010001100行rows: r₀ = (0 1 0), r₁ = (0 0 1), r₂ = (1 0 0)列columns: c₀ = (0 0 1)ᵀ, c₁ = (1 0 0)ᵀ, c₂ = (0 1 0)ᵀ
第 0 行row 0: r₀·c₀ = 0·0 + 1·0 + 0·1 = 0, r₀·c₁ = 0·1 + 1·0 + 0·0 = 0, r₀·c₂ = 0·0 + 1·1 + 0·0 = 1
第 1 行row 1: r₁·c₀ = 0·0 + 0·0 + 1·1 = 1, r₁·c₁ = 0, r₁·c₂ = 0
第 2 行row 2: r₂·c₀ = 0, r₂·c₁ = 1·1 + 0·0 + 0·0 = 1, r₂·c₂ = 0
S·S = S² = 001100010第 i 行的 1 在第 i+2 列:挪两格row i has its 1 in column i+2: two steps

省力读法。看第 0 行的三个点积:r₀ = (0 1 0) 只有中间是 1,所以 r₀·cj 等于每个 cj 的第 1 个分量,即右矩阵第 1 行的各元素——「结果的第 0 行 = 右矩阵的第 1 行」。一般地,若左矩阵第 i 行只有第 k 列是 1,结果的第 i 行就是右矩阵的第 k 行,整行照抄。置换矩阵每行恰好一个 1,乘法退化成「抄行」。于是 S³ = S²·S 的各行是 S 的第 2、0、1 行,正好是 I。对一般的 l 同理:Sᵏ 的第 i 行的 1 在第 i+k (mod l) 列,取 k = l 便回到第 i 列,Sl = I——绕一整圈回原地。用向量看:S(v₀, v₁, v₂)ᵀ = (v₁, v₂, v₀)ᵀ,三个分量循环转一位,转三次复原。把 S 的行列互换得 Sᵀ,它恰好是 S²,所以 Sᵀ·S = S³ = I,Sᵀ = S−1:转置就是反向挪一格。

The shortcut. Look at the three dot products of row 0: r₀ = (0 1 0) has its only 1 in the middle, so r₀·cj equals the second component of each cj, i.e. the entries of row 1 of the right factor — “row 0 of the product = row 1 of the right factor”. In general, if row i of the left factor has its only 1 in column k, row i of the product is row k of the right factor, copied whole. A permutation matrix has exactly one 1 per row, so multiplication degenerates into copying rows. Hence the rows of S³ = S²·S are rows 2, 0, 1 of S — exactly I. For general l likewise: row i of Sᵏ has its 1 in column i+k (mod l), and k = l brings it back to column i, Sl = I — one full turn round the ring. As vectors: S(v₀, v₁, v₂)ᵀ = (v₁, v₂, v₀)ᵀ, a cyclic rotation of the three components, and three rotations restore them. Swapping rows and columns of S gives Sᵀ, which is precisely S², so Sᵀ·S = S³ = I and Sᵀ = S−1: the transpose is one step backwards.

关于 mod 2。上面每个和最多只有一项非零,取不取奇偶无所谓。但一般的 0/1 矩阵相乘会出现 2、3、4,这时在 GF(2) 上要再取奇偶:例如 (C·Cᵀ) 的第 0 行第 0 列 = (1 1 0)·(1 1 0)ᵀ = 2 ≡ 0(2.4.3);2.4.2 里 H·Hᵀ 算出的 (4 2 2; 2 4 2; 2 2 4) 每个元素都是这样的点积,取奇偶后全为 0,那就是「对易」的矩阵表达。

On mod 2. Each sum above has at most one nonzero term, so reducing mod 2 changes nothing. But products of general 0/1 matrices produce 2s, 3s and 4s, and over GF(2) these are then reduced to their parity: e.g. entry (0, 0) of C·Cᵀ is (1 1 0)·(1 1 0)ᵀ = 2 ≡ 0 (§2.4.3), and every entry of the H·Hᵀ = (4 2 2; 2 4 2; 2 2 4) of §2.4.2 is such a dot product, all 0 after reduction — the matrix form of “commute”.

2.2两个方向:x 管横、y 管竖,先走哪个都一样Two directions: x across, y up, and the order never matters

BB 码的格子排成 l 列 × m 行的长方形,而且四边都绕回:走出右边从左边回来,走出上边从下边回来,像贪吃蛇游戏的屏幕。这样的格子叫环面torus:把长方形的左右两边粘起来、上下两边也粘起来得到的「甜甜圈」表面。格子上任何方向都没有尽头,走出去总会从对面回来。。格子用一对坐标 (i, j) 标记:i 是横坐标,从 0 数到 l−1;j 是纵坐标,从 0 数到 m−1,向上增大。两个基本动作:x 把 (i, j) 送到 (i+1, j),向右一格;y 把 (i, j) 送到 (i, j+1),向上一格。

A BB code's sites form a rectangle of l columns by m rows that wraps on all four sides: walk off the right edge and you re-enter on the left, off the top and you re-enter at the bottom, like the screen of the game Snake. Such a grid is a torusThe doughnut surface obtained by gluing a rectangle's left edge to its right edge and its top to its bottom. It has no end in any direction: whatever leaves comes back from the opposite side.. A site is labelled by a pair of coordinates (i, j): i across, counted 0 to l−1; j up, counted 0 to m−1. Two basic moves: x sends (i, j) to (i+1, j), one step right; y sends (i, j) to (i, j+1), one step up.

于是 xayb 就是「向右 a 格、向上 b 格」:(i, j) → (i+a, j+b),横坐标按 mod l、纵坐标按 mod m 绕回。2.1 的规则现在各有两份:xl = 1,ym = 1;x−1 是向左一格,y−1 是向下一格。新添的一条最重要:xy = yx,先右后上与先上后右,到达同一个格子(图 2.3)。这不是理所当然的:并不是所有动作都能交换次序,补课 2.B 里就有一对不能交换的例子;x 和 y 能交换,是因为它们各管一个坐标,互不干扰。

So xayb means “a steps right and b steps up”: (i, j) → (i+a, j+b), the first coordinate wrapping mod l and the second mod m. The rules of §2.1 now come in pairs: xl = 1 and ym = 1; x−1 is one step left and y−1 one step down. One new rule matters most: xy = yx — right-then-up and up-then-right land on the same site (Fig. 2.3). That is not automatic: not every pair of moves can be swapped, and Catch-up 2.B shows a pair that cannot; x and y can, because each minds its own coordinate and they never interfere.

这三条就是本节的全部内容。它们保证 x、y 的式子可以像中学里的多项式一样展开、合并、随意交换因子的次序,下一节马上要用。

These three rules are the whole content of the section. They guarantee that expressions in x and y can be expanded, collected and have their factors reordered exactly like the polynomials of school algebra, which the next section uses at once.

(0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2) (3,0) (3,1) (3,2) i →(横向,mod 4 绕回)i → (across, wraps mod 4) j ↑(纵向,mod 3 绕回)j ↑ (up, wraps mod 3) 从 (1,0) 出发(红点),两条路:From (1,0) (red dot), two routes: 实线:先 x 后 y,(1,0) → (2,0) → (2,1)solid: x then y, (1,0) → (2,0) → (2,1) 虚线:先 y 后 x,(1,0) → (1,1) → (2,1)dashed: y then x, (1,0) → (1,1) → (2,1) 终点相同,所以 xy = yxSame end point, so xy = yx 右边的点线:从 (3,1) 再走一步 x,Dotted on the right: one more x from (3,1) 从左边绕回,到 (0,1)wraps round to (0,1) on the left
图 2.3Fig. 2.3 l = 4、m = 3 的环面,坐标 (i, j)。从 (1, 0) 出发,先 x 后 y(实线)与先 y 后 x(虚线)都到 (2, 1):xy = yx。点线:从 (3, 1) 再走一步 x,从左边绕回 (0, 1)。 An l = 4, m = 3 torus with coordinates (i, j). From (1, 0), x then y (solid) and y then x (dashed) both reach (2, 1): xy = yx. Dotted: one more x from (3, 1) wraps round to (0, 1) on the left.

记账:计算机把 lm 个格子排成一列编号,格子 (i, j) 编为 i·m + j(先按 i、再按 j)。于是 x 记成一张 lm × lm 的置换矩阵 x ≔ Sl ⊗ Im,y 记成 y ≔ Il ⊗ Sm。这里的 ⊗ 是克罗内克积Kronecker product:A ⊗ B 把 A 的每个元素 a 换成整块 a·B。(A ⊗ B)(C ⊗ D) = AC ⊗ BD,所以只动不同坐标的两个平移一定对易。:把 Sl 的每个元素放大成一整块 Im(或 0)。公式不必记,只记意思:x 让 (i, j) 变成 (i+1, j)。图 2.4 用 l = 2、m = 3 把 x、y 和 x + y 三张 6 × 6 的矩阵整张画出来。补课 2.B 用 l = m = 2 把两张矩阵逐格写出来,并给出 xy = yx 的三种证法。

Bookkeeping: a computer numbers the lm sites in a single list, site (i, j) becoming number i·m + j (counting through i first, then j). Then x is stored as an lm × lm permutation matrix x ≔ Sl ⊗ Im, and y as y ≔ Il ⊗ Sm. Here ⊗ is the Kronecker productA ⊗ B replaces every entry a of A by the whole block a·B. (A ⊗ B)(C ⊗ D) = AC ⊗ BD, so two translations moving different coordinates must commute.: every entry of Sl blown up into a block Im (or 0). No need to memorise the formula, only its meaning: x turns (i, j) into (i+1, j). Fig. 2.4 draws x, y and x + y in full for l = 2, m = 3: three 6 × 6 matrices. Catch-up 2.B writes both matrices out cell by cell for l = m = 2 and gives three proofs of xy = yx.

xayb: (i, j) ⇒ (i+a, j+b)
xl = ym = 1
xy = yx
(a) x:每个格子往右一格(a) x: every site steps right 0 (0,0) 1 (0,1) 2 (0,2) 3 (1,0) 4 (1,1) 5 (1,2) (b) y:每个格子往上一格(b) y: every site steps up 0 (0,0) 1 (0,1) 2 (0,2) 3 (1,0) 4 (1,1) 5 (1,2) 格子:l × m = 2 × 3 = 6 个sites: l × m = 2 × 3 = 6 编号:(i, j) → 3i + jnumbering: (i, j) → 3i + j 平移:6 个格子各搬一次家a translation moves all 6 sites 行 = 出发格子,6 行rows = starting sites: 6 列 = 到达格子,6 列columns = landing sites: 6 ⇒ 单项式是 6 × 6,不是 2 × 3⇒ a monomial is 6 × 6, not 2 × 3 (c) x = S2 ⊗ I3 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 × 6 每行 1 个 1one 1 per row (d) y = I2 ⊗ S3 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 × 6 每行 1 个 1one 1 per row (e) x + y 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 × 6 每行 2 个 1 · 仍是 6 × 6two 1s per row · still 6 × 6 + = 粗线把矩阵切成 3 × 3 的块:x 的块是 I3(放在 S2 的 1 处),y 的块是 S3(放在 I2 的 1 处)Thick lines cut each matrix into 3 × 3 blocks: x has blocks I3 where S2 has 1s; y has blocks S3 where I2 has 1s
图 2.4 l = 2、m = 3 的小例子。容易混的一点:l × m 是格子的排法,不是矩阵的尺寸。2 × 3 的环面上有 6 个格子,一次平移要说清这 6 个格子各自搬到哪里,所以 x、y 以及任何单项式 xayb 都是 6 × 6 的置换矩阵(一般地是 lm × lm)。(a)(b) 虚线箭头是绕回:从右边出去从左边进来,从上边出去从下边进来。(c)(d) 格子 r 那一行的 1 落在它被搬到的格子那一列,例如 x 把 1 = (0,1) 搬到 4 = (1,1),y 把它搬到 2 = (0,2)。(e) 尺寸相同的矩阵才能相加;x + y 仍是 6 × 6,只是每行多了一个 1——这就是 2.3.3 节的「一枚印章就是一张稀疏矩阵」。 Fig. 2.4 The small example l = 2, m = 3. The point that is easy to mix up: l × m is how the sites are laid out, not the size of the matrix. A 2 × 3 torus has 6 sites, and a translation must say where each of those 6 sites goes, so x, y and every monomial xayb are 6 × 6 permutation matrices (lm × lm in general). (a)(b) Dashed arrows wrap around: out on the right and in on the left, out at the top and in at the bottom. (c)(d) Row r has its 1 in the column of the site r is moved to; e.g. x moves 1 = (0,1) to 4 = (1,1), y moves it to 2 = (0,2). (e) Only matrices of the same size can be added; x + y is still 6 × 6, just with one more 1 per row — which is §2.3.3's “a stamp is a sparse matrix”.
补课 · 把 x、y 写成矩阵,并证明 xy = yxCatch-up · x and y as matrices, and the proof of xy = yx

用最小的例子:l = m = 2,环面只有 4 个格子。按 2.2 的约定,把第一个坐标 i 画成横轴、第二个坐标 j 画成纵轴(向上增大),格子 (i, j) 的编号是 i·m + j = 2i + j:

Take the smallest example, l = m = 2, a torus of only 4 sites. Following §2.2, draw the first coordinate i horizontally and the second coordinate j vertically (increasing upward); site (i, j) gets number i·m + j = 2i + j:

j = 113
j = 002
i = 0i = 1

在这种画法里 x 是往右挪一格、y 是往上挪一格。要是你把 i 当作行号、j 当作列号画成一张矩阵式的表,x 就变成「往下走一行」——这只是画法问题:x 的定义只有「第一个坐标加一」这一句,矩阵的每个元素由它决定,与格子画在纸上的哪个方向无关。

In this picture x steps right and y steps up. If instead you tabulate i as a row index and j as a column index, matrix style, x becomes “one row down” — a matter of drawing only: x is defined by the single phrase “add one to the first coordinate”, every matrix entry follows from it, and the direction in which the sites are drawn on paper is irrelevant.

矩阵的读法和循环移位 S 一样:行 = 出发的格子,那一行的 1 落在到达的格子那一列。x:(i, j) → (i+1 mod 2, j),逐格看它去哪——格子 0 = (0,0) → (1,0) = 格子 2,第 0 行的 1 在第 2 列;格子 1 = (0,1) → (1,1) = 3;格子 2 = (1,0) → (0,0) = 0(1 + 1 ≡ 0,绕回去);格子 3 = (1,1) → (0,1) = 1。y:(i, j) → (i, j+1 mod 2),格子 0 → 1,1 → 0,2 → 3,3 → 2。于是

The matrices are read like the cyclic shift S: row = the site you start from, and that row’s 1 sits in the column of the site you land on. x: (i, j) → (i+1 mod 2, j); site by site — site 0 = (0,0) → (1,0) = site 2, so row 0 has its 1 in column 2; site 1 = (0,1) → (1,1) = 3; site 2 = (1,0) → (0,0) = 0 (1 + 1 ≡ 0, wrapping round); site 3 = (1,1) → (0,1) = 1. y: (i, j) → (i, j+1 mod 2), sites 0 → 1, 1 → 0, 2 → 3, 3 → 2. Hence

x = 0010000110000100y = 01001000000100101 = I = 1000010000100001

在编号表上看,x 是把两列整体互换(i = 0 的一列去 i = 1),y 是把两行整体互换。用克罗内克积再算一遍,结果一样。l = 2 的循环移位是 S₂ = [0 1; 1 0]。教程写 x = S₂ ⊗ I₂、y = I₂ ⊗ S₂,⊗ 的规则是「把左边矩阵的每个元素 a 换成整块 a·(右边矩阵)」:

On the numbering table x swaps the two columns bodily (the i = 0 column goes to i = 1) and y swaps the two rows. Recomputing with the Kronecker product gives the same matrices. The cyclic shift for l = 2 is S₂ = [0 1; 1 0]. The tutorial writes x = S₂ ⊗ I₂ and y = I₂ ⊗ S₂, where ⊗ means “replace every entry a of the left matrix by the whole block a·(right matrix)”:

x = S₂ ⊗ I₂ = 0·I₂1·I₂1·I₂0·I₂y = I₂ ⊗ S₂ = 1·S₂0·S₂0·S₂1·S₂

S₂ 在外层管第一个坐标(整块搬动),I₂ 在内层保持第二个坐标不变;y 反过来——这就是 2.2 说「不必记公式、只记意思」的原因。然后 A、B 就是矩阵相加(mod 2):

S₂ on the outside moves the first coordinate (whole blocks at a time) while I₂ inside leaves the second alone; y the other way round — which is why §2.2 says to remember the meaning rather than the formula. A and B are then matrix sums (mod 2):

A = 1 + x = I + x = 1010010110100101B = 1 + y = I + y = 1100110000110011

读 A 的第 0 行 (1 0 1 0):站在格子 (0,0) 的检查,「1」这一项碰自己 (0,0),「x」这一项碰 (1,0) = 格子 2,所以第 0 列和第 2 列是 1。这里没有一格出现 1 + 1,mod 2 没用上;若某个多项式有两项把同一格搬到同一处(如 l = 2 上的 x + x³),它们会相消为 0。还有一处 l = 2 的特殊性:圈上只有两个格子,「往右一格」和「往左一格」是同一件事,x² = I,x−1 = x,所以 A 是对称矩阵、Aᵀ = A,B 也一样,HZ = [Bᵀ | Aᵀ] = [B | A]。l = 3 起就不再如此——2.4.1 里 C = 1 + x 与 Cᵀ = 1 + x² 不同,就是这个区别。

Read row 0 of A, (1 0 1 0): the check standing at site (0,0) touches itself, (0,0), through the term “1” and site (1,0) = site 2 through the term “x”, so columns 0 and 2 are 1. No cell here receives 1 + 1, so mod 2 never bites; a polynomial with two terms carrying the same site to the same place (x + x³ on l = 2, say) would cancel them to 0. One more peculiarity of l = 2: with only two sites on the ring, “one step right” and “one step left” coincide, x² = I and x−1 = x, so A is symmetric, Aᵀ = A, likewise B, and HZ = [Bᵀ | Aᵀ] = [B | A]. From l = 3 on this fails — in §2.4.1 C = 1 + x and Cᵀ = 1 + x² differ, and that is the difference.

xy = yx 的三种证法Three proofs of xy = yx

一、看每个格子去哪里。置换矩阵相乘就是「先做一个动作,再做另一个」:x·y 的第 s 行的 1 落在「s 先被 x 送到哪、再被 y 送到哪」那一列。x·y:(i, j) →x→ (i+1, j) →y→ (i+1, j+1);y·x:(i, j) →y→ (i, j+1) →x→ (i+1, j+1)。每个起点的终点都相同,两个矩阵每一行的 1 都落在同一列,所以 x·y = y·x。原因只有一个:x 只改第一个坐标、y 只改第二个,两件事互不干扰,说到底还是加法可交换。这不是理所当然的——三个格子上,p =「交换 0 和 1」,q =「交换 1 和 2」,先 p 再 q 把 0 送到 2,先 q 再 p 把 0 送到 1,pq ≠ qp。x、y 能对易,靠的正是「各管一个坐标」。

One: follow every site. Multiplying permutation matrices is “do one move, then the other”: row s of x·y has its 1 in the column of “where s goes under x, then under y”. x·y: (i, j) →x→ (i+1, j) →y→ (i+1, j+1); y·x: (i, j) →y→ (i, j+1) →x→ (i+1, j+1). Every start reaches the same end, so every row of the two matrices has its 1 in the same column: x·y = y·x. The only reason is that x touches the first coordinate alone and y the second alone, so the two never interfere — at bottom, addition commutes. This is not automatic: on three sites, with p = “swap 0 and 1” and q = “swap 1 and 2”, p then q sends 0 to 2 while q then p sends 0 to 1, so pq ≠ qp. x and y commute precisely because each minds its own coordinate.

二、克罗内克积的混合乘积律 (A ⊗ B)(C ⊗ D) = (AC) ⊗ (BD)——左因子乘左因子、右因子乘右因子。于是 x·y = (Sl·Il) ⊗ (Im·Sm) = Sl ⊗ Sm,y·x = (Il·Sl) ⊗ (Sm·Im) = Sl ⊗ Sm,两边都是「两个坐标同时各加一」。混合乘积律本身就是分块乘法:A ⊗ B 的第 (i, k) 块是 aik·B,两个分块矩阵相乘时第 (i, k) 块 = Σj(aijB)(cjkD) = (Σj aijcjk)·BD = (AC)ik·BD。这条证法不依赖画法,还顺带给出 xayb = Sla ⊗ Smb。

Two: the mixed-product rule of the Kronecker product, (A ⊗ B)(C ⊗ D) = (AC) ⊗ (BD) — left factors multiply left factors, right factors right. So x·y = (Sl·Il) ⊗ (Im·Sm) = Sl ⊗ Sm and y·x = (Il·Sl) ⊗ (Sm·Im) = Sl ⊗ Sm, both “add one to both coordinates at once”. The rule itself is block multiplication: block (i, k) of A ⊗ B is aik·B, and multiplying two such block matrices gives block (i, k) = Σj(aijB)(cjkD) = (Σj aijcjk)·BD = (AC)ik·BD. This proof is independent of any picture and yields xayb = Sla ⊗ Smb for free.

三、把 2 × 2 的例子算出来。用「x 的第 s 行只有第 t 列是 1,则 x·M 的第 s 行 = M 的第 t 行」:x 第 0 行的 1 在第 2 列 → x·y 第 0 行抄 y 的第 2 行 (0 0 0 1);第 1 行 → 抄 y 第 3 行 (0 0 1 0);第 2 行 → 抄 y 第 0 行 (0 1 0 0);第 3 行 → 抄 y 第 1 行 (1 0 0 0)。反过来 y·x:y 第 0 行的 1 在第 1 列 → 抄 x 第 1 行 (0 0 0 1);第 1 行 → 抄 x 第 0 行 (0 0 1 0);第 2 行 → 抄 x 第 3 行 (0 1 0 0);第 3 行 → 抄 x 第 2 行 (1 0 0 0)。

Three: compute the 2 × 2 example. Using “if row s of x has its only 1 in column t, then row s of x·M is row t of M”: row 0 of x has its 1 in column 2 → row 0 of x·y copies row 2 of y, (0 0 0 1); row 1 → row 3 of y, (0 0 1 0); row 2 → row 0 of y, (0 1 0 0); row 3 → row 1 of y, (1 0 0 0). Conversely y·x: row 0 of y has its 1 in column 1 → row 1 of x, (0 0 0 1); row 1 → row 0 of x, (0 0 1 0); row 2 → row 3 of x, (0 1 0 0); row 3 → row 2 of x, (1 0 0 0).

x·y = y·x = 0001001001001000反对角线:(i, j) → (i+1, j+1),格子 0 → 3、1 → 2the anti-diagonal: (i, j) → (i+1, j+1), sites 0 → 3, 1 → 2

它为什么足够推出 AB = BA。有了 xy = yx,再加上同一个矩阵的幂彼此可交换,任意两个单项式就可交换:xayb·xcyd = xa+cyb+d = xcyd·xayb(把 y 和 x 一步步换位,每次用一遍 xy = yx)。A、B 是单项式的和,用分配律展开后逐项换位,就是 2.4.3 里「三层论证」的第二层,只是变量从一个换成两个。这就是 3.2 那一行证明里 AB = BA 的全部依据。

Why this suffices for AB = BA. Given xy = yx, and that powers of one matrix commute among themselves, any two monomials commute: xayb·xcyd = xa+cyb+d = xcyd·xayb (swap y past x one step at a time, using xy = yx each time). A and B are sums of monomials; expand by the distributive law and swap term by term — the second layer of the “three-layer argument” of §2.4.3, with two variables instead of one. That is the entire basis of AB = BA in the one-line proof of §3.2.

2.3多项式 = 一枚印章:几步平移盖在一起A polynomial is a stamp: several steps pressed at once

把几个单项式加起来,就得到一枚「印章」。A = x³ + y + y² 的意思是:从一个格子出发,同时走三种走法——向右 3 格、向上 1 格、向上 2 格——落在三个格子上。把这枚印章盖在格子 s 上,它碰到的就是这三个格子。多项式有几项,印章上就有几个点。

Add a few monomials and you get a “stamp”. A = x³ + y + y² means: from a site, take three moves at once — 3 right, 1 up, 2 up — landing on three sites. Press this stamp on a site s and those three sites are what it touches. A polynomial with w terms is a stamp with w dots.

2.3.1 · 读印章:一条检查的腿,直接从多项式读出来2.3.1 · Reading a stamp: a check's legs straight off the polynomial

第 3 章会看到,BB 码的一条检查就是两枚这样的印章各盖一次:A 盖在一层比特上,B 盖在另一层上;印章碰到的比特,就是这条检查的「腿」(它在哪些比特上放 X 或 Z)。所以读 BB 码根本用不着矩阵:看多项式的每一项指向哪里,腿就在哪里。gross 码的 A = x³ + y + y² 盖在 (i, j) 上,三条腿落在 (i+3, j)、(i, j+1)、(i, j+2)(图 2.5 左)。

Chapter 3 will show that a BB check is exactly two such stamps pressed once each: A on one layer of qubits and B on the other; the qubits a stamp touches are the check's “legs” (the qubits on which it places an X or a Z). So reading a BB code needs no matrix at all: wherever a term of the polynomial points, there is a leg. The gross code's A = x³ + y + y² pressed on (i, j) puts its three legs on (i+3, j), (i, j+1) and (i, j+2) (Fig. 2.5, left).

两条细则。① 系数只有 0 和 1,1 + 1 = 0。两项若落在同一个格子,就互相抵消,那个格子不算腿。例如 m = 6 时 y⁷ = y(向上 7 格就是向上 1 格),所以 y + y⁷ = 0:两条腿踩在同一个比特上,等于没踩,因为在同一个比特上放两次 X,X·X = I。这就是「系数在 GF(2) 里」的意思。② 反向印章。把每一项倒着走,得到 A 的反向印章,记作 Aᵀ = x−3 + y−1 + y−2(为什么借用转置的记号 ᵀ,2.3.3 的记账会说明)。它盖在 t 上,碰到 t − (3, 0)、t − (0, 1)、t − (0, 2)(图 2.5 右)。第 3 章里 Z 检查用的就是反向印章。

Two fine points. ① Coefficients are only 0 and 1, and 1 + 1 = 0. If two terms land on the same site they cancel and that site is not a leg. For m = 6, y⁷ = y (7 steps up is 1 step up), so y + y⁷ = 0: two legs on the same qubit amount to none, because placing X twice on a qubit gives X·X = I. That is what “coefficients in GF(2)” means. ② The reversed stamp. Walk every term backwards and you get A's reversed stamp, written Aᵀ = x−3 + y−1 + y−2 (why it borrows the transpose sign ᵀ, the bookkeeping of §2.3.3 explains). Pressed on t it touches t − (3, 0), t − (0, 1) and t − (0, 2) (Fig. 2.5, right). In Chapter 3 the Z checks use reversed stamps.

x³ y y² 印章 A 盖在 s(红点):三个点 = 三条腿Stamp A pressed at s (red dot): three dots, three legs x⁻³ y⁻¹ y⁻² 反向印章 Aᵀ 盖在 t:每一步倒着走Reversed stamp Aᵀ pressed at t: every step walked backwards A = x³ + y + y²:向右 3 格、向上 1 格、向上 2 格。Aᵀ = x⁻³ + y⁻¹ + y⁻²:向左 3 格、向下 1 格、向下 2 格。A = x³ + y + y²: 3 right, 1 up, 2 up. Aᵀ = x⁻³ + y⁻¹ + y⁻²: 3 left, 1 down, 2 down.
图 2.5Fig. 2.5 gross 码的印章 A = x³ + y + y²。左:盖在 s(红点)上,三项各落一点,就是一条检查在这一层的三条腿。右:反向印章 Aᵀ 盖在 t 上,每一步倒着走。 The gross code’s stamp A = x³ + y + y². Left: pressed on s (red dot), each term lands one dot, a check’s three legs on this layer. Right: the reversed stamp Aᵀ pressed on t, every step walked backwards.

2.3.2 · 多项式的第一个用处:一次乘法,算出所有重叠2.3.2 · What polynomials are for: one multiplication gives every overlap

为什么不直接列出「向右三格、向上一格……」,非要写成多项式?因为多项式能乘,而乘法恰好回答纠错里最常问的一个问题:两条检查共同碰到几个比特?第 0 章①说过,一条 X 检查和一条 Z 检查必须共享偶数个比特,否则两者不对易,码就不成立。gross 码有 72 条 X 检查和 72 条 Z 检查,逐对去数要数 5184 次;用多项式,一次乘法全部数完。

Why not simply list “3 right, 1 up, …” instead of writing a polynomial? Because polynomials can be multiplied, and multiplication answers precisely the question error correction asks most often: how many qubits do two checks share? Chapter 0’s ① says an X check and a Z check must share an even number of qubits, or they fail to commute and the code falls apart. The gross code has 72 X checks and 72 Z checks; counting pair by pair takes 5184 counts, while one polynomial multiplication does them all.

道理只有一步。印章 P 盖在 s、印章 Q 盖在 t。P 的某一项 xp 和 Q 的某一项 xq 落在同一个格子,意思是 s + p = t + q,也就是 p − q = t − s。所以两枚印章的重叠格数,就是「差为 t − s 的项对 (p, q) 有几对」。把 P 和反向印章 Qᵀ 相乘时,P 的每一项 xp 乘 Qᵀ 的每一项 x−q,恰好得到 xp−q,每一对项贡献一次。于是:

The reason takes one step. Press stamp P on s and stamp Q on t. A term xp of P and a term xq of Q land on the same site exactly when s + p = t + q, i.e. p − q = t − s. So the number of shared sites is the number of term pairs (p, q) whose difference is t − s. Multiplying P by the reversed stamp Qᵀ, every term xp of P times every term x−q of Qᵀ gives exactly xp−q, one contribution per pair. Hence:

P 盖在 s、Q 盖在 t 时共享的格数 = P·Qᵀ 中 xt−s 这一项的系数
(按普通整数相乘,先不把 2 约成 0)
sites shared by P on s and Q on t = the coefficient of xt−s in P·Qᵀ
(multiply with ordinary integers; do not reduce 2 to 0 yet)

一个前提:印章要先化简。指数按 mod l、mod m 约好,重合的项按 1 + 1 = 0 消掉(2.3.1 的细则①),每个格子在印章里最多出现一次,然后才按整数相乘。例如一圈 6 格上的 1 + x⁶:x⁶ = 1,所以它是 1 + 1 = 0,这枚印章什么也不碰;不先化简就按整数乘,会数出并不存在的重叠。

One prerequisite: reduce the stamps first. Reduce exponents mod l and mod m and cancel coinciding terms by 1 + 1 = 0 (fine point ① of §2.3.1), so that each site appears at most once in a stamp; only then multiply with integers. For example, on a ring of 6 sites, 1 + x⁶ has x⁶ = 1 and so equals 1 + 1 = 0, a stamp that touches nothing; multiplying it with integers before reducing would count overlaps that do not exist.

乘积一次性列出了所有相对位置的答案:P·Qᵀ 里的每一项 xd 都在说「相隔 d 的两枚印章重叠几格」,没出现的项就是不重叠。在二维环面上把 xd 读成 xayb、「相隔 d」读成「相隔 (a, b)」,道理一字不改。

The product lists the answer for every relative position at once: each term xd of P·Qᵀ says “two stamps d apart share this many sites”, and a missing term means they share none. On the two-dimensional torus read xd as xayb and “d apart” as “(a, b) apart”; the argument does not change by a word.

算一个例子。一圈 l = 6 个格子,P = Q = 1 + x(「自己和右邻」两个点),反向印章 Qᵀ = 1 + x−1(「自己和左邻」)。相乘:(1 + x)(1 + x−1) = 1 + x−1 + x + x·x−1 = 2 + x + x−1。逐项读出:两枚印章盖在同一格(相隔 0)时重叠 2 格,就是它们的两个点;相隔 1(t = s + 1,对应 x 那一项)或相隔 −1(x−1 那一项)时重叠 1 格,例如 {s, s+1} 与 {s+1, s+2} 只共享 s+1;相隔更远的项没有出现,不重叠。在下面的实验台上把第二枚印章点到不同位置核对。

A worked example. A ring of l = 6 sites with P = Q = 1 + x (“yourself and your right neighbour”, two dots); the reversed stamp is Qᵀ = 1 + x−1 (“yourself and your left neighbour”). Multiply: (1 + x)(1 + x−1) = 1 + x−1 + x + x·x−1 = 2 + x + x−1. Read it term by term: two stamps on the same site (0 apart) share 2 sites, namely both dots; 1 apart (t = s + 1, the term x) or −1 apart (the term x−1) they share 1, as {s, s+1} and {s+1, s+2} share only s+1; any farther separation has no term, so no overlap. On the bench below, click the second stamp to different sites and check.

为什么先按普通整数乘、不马上 mod 2?因为我们要的是「重叠几格」这个整数,而对易与否只看它的奇偶:重叠 2 格(偶数)的一对 X、Z 检查对易,重叠 1 格(奇数)的反对易。所以先数出整数,最后问「对不对易」时再取奇偶;取奇偶之后,就是 GF(2) 上的乘法。

Why multiply with ordinary integers first, not mod 2 straight away? Because what we want is the integer “how many shared sites”, and whether two checks commute depends only on its parity: an X–Z pair sharing 2 sites (even) commutes, one sharing 1 site (odd) anticommutes. So count the integer first and take its parity only when you ask “do they commute?”; after taking parities, this is exactly multiplication over GF(2).

第二个用处:找出多余的检查(第 4 章展开)。检查之间常有依赖,比如环面码教程里「所有星形检查乘起来是 I」,所以它们不全独立,k 才会是 2。用多项式问这件事只要一行。在一圈 l 个格子上,令 u = 1 + x + x² + … + xl−1(「每个格子各盖一次」),则

A second use: spotting redundant checks (developed in Chapter 4). Checks are often dependent — in the toric-code tutorial, “the product of all star checks is I” — so they are not all independent, which is why k comes out as 2. Asking about this with polynomials takes one line. On a ring of l sites let u = 1 + x + x² + … + xl−1 (“press once on every site”); then

(1 + x)·u = 1 + 2x + 2x² + … + 2xl−1 + xl
= 2 + 2x + … + 2xl−1 ≡ 0 (mod 2)

每一项都出现两次:把印章 1 + x 在每个格子各盖一次,每个格子恰好被碰两次(被自己的「1」和左邻的「x」),全部抵消。翻译成检查:把这一圈上所有的检查乘起来,得到 I。补课 0.D 里环上四条检查的乘积是 I,就是 l = 4 的这一行。环面上的星形检查同理,u 换成「整张环面每格一次」;第 4 章把「这样的 u 有多少个」变成 k 的公式。

Every term appears twice: pressing the stamp 1 + x once on every site touches each site exactly twice (through its own “1” and its left neighbour’s “x”), and everything cancels. In terms of checks: the product of all the checks round the ring is I. Catch-up 0.D’s four checks on a ring multiplying to I is this line for l = 4. The star checks on a torus work the same way, with u = “once on every site of the torus”; Chapter 4 turns “how many such u are there” into a formula for k.

2.3.3 · 记账:一枚印章就是一张稀疏矩阵2.3.3 · Bookkeeping: a stamp is a sparse matrix

交给计算机时,单项式 xayb 记成一张置换矩阵(2.2 的记账)。几个单项式相加(系数在 GF(2)只有 0 和 1 两个数、按 1 + 1 = 0 运算的数域;「mod 2 算术」的正式名字。 里,1 + 1 = 0),得到一个 lm × lm 的矩阵 A:第 (i, j) 行在 (i+a, j+b) 那些列上写 1,每项一个,这一行记的就是「印章盖在 (i, j) 上碰到哪些格子」。所以一个有 w 项的多项式,就是一个每行每列恰有 w 个 1 的稀疏矩阵,这正是「低密度」的来源。反向印章在矩阵里恰好是转置:Aᵀ 的第 t 行在 t − (a, b) 那些列上是 1,记的是「谁的印章会碰到 t」,也就是每一步倒着走,所以记作 Aᵀ。2.3.2 的重叠数,在矩阵里是 P 的第 s 行与 Q 的第 t 行的点积;整张矩阵 P·Qᵀ 列出全部 (lm)² 对位置,可它的每一行都只是上一行的平移,多项式 P·Qᵀ 只记一行就够了。到实验台上点一个起点,看箭头落在哪里,再看右边矩阵里这一行的 1:

For a computer, a monomial xayb is stored as a permutation matrix (the bookkeeping of §2.2). Add a few monomials (coefficients in GF(2)The number system with only 0 and 1, in which 1 + 1 = 0; the formal name of “mod-2 arithmetic”., 1 + 1 = 0) and you get an lm × lm matrix A: row (i, j) has a 1 in each column (i+a, j+b), one per term, and that row records “which sites the stamp touches when pressed on (i, j)”. So a polynomial with w terms is a sparse matrix with exactly w ones per row and column, the origin of “low density”. The reversed stamp is precisely the transpose in the matrix: row t of Aᵀ has its 1s in the columns t − (a, b), recording “whose stamps touch t”, every step walked backwards, hence the name Aᵀ. The overlap count of §2.3.2 is, in matrices, the dot product of row s of P with row t of Q; the whole matrix P·Qᵀ lists all (lm)² pairs of positions, yet every row is merely a shift of the previous one, so the polynomial P·Qᵀ need keep only one row. On the bench, click a source site, watch where the arrows land, then find the 1s in that row of the matrix on the right:

补课 · 什么是稀疏矩阵、什么是 LDPCCatch-up · What a sparse matrix is, and what LDPC means

稀疏矩阵就是「绝大多数元素是 0、只有零星几个非零元」的矩阵;非零元占相当比例的叫稠密矩阵。这个词本身没有精确门槛,但在编码里有一个很具体的用法。先看尺寸感:gross 码的 HX 是 72 行 × 144 列,共 10368 个格子,每行只有 6 个 1,总共 432 个 1,约 4%——一张几乎全白、点着零星几个 1 的大表。这些 1 从哪来,2.3 已经说了:一个单项式是置换矩阵,每行每列恰好一个 1;A = x³ + y + y² 三项相加,每行每列恰好三个 1;[A | B] 并排,每行恰好 |A| + |B| = 6 个 1。「多项式项数少」直接等于「矩阵稀疏」。

A sparse matrix is one in which “almost every entry is 0 and only a scattering are nonzero”; one with a sizeable share of nonzero entries is dense. The word has no precise threshold, but in coding it has a very specific use. First a sense of scale: the gross code’s HX has 72 rows × 144 columns, 10 368 cells, only 6 ones per row, 432 ones in all, about 4% — a large, almost blank table dotted with a few 1s. Where they come from was said in §2.3: a monomial is a permutation matrix with exactly one 1 per row and column; A = x³ + y + y² adds three of them, exactly three 1s per row and column; [A | B] side by side has exactly |A| + |B| = 6 ones per row. “Few terms in the polynomial” is the same as “sparse matrix”.

编码里真正在意的不是某个百分比,而是每行、每列的 1 有没有一个不随 n 增长的上界。这就是 LDPC(low-density parity check,低密度奇偶检查)的定义:行重(检查重量,一条检查碰几个比特)和列重(比特度,一个比特被几条检查碰到)都被一个固定的小数字限住。表面码不管做多大,每行至多 4 个 1(边界上的检查只有 2 或 3 条腿),每列也至多 4 个;BB 码是 6 和 3 + 3;把环面放大到 288 或 756 个比特,仍然是 6,1 的比例越来越低。相反,[[4,2,2]] 的检查 (1 1 1 1) 一行全是 1,Shor 码的 X 检查九个比特碰六个——这些小码无所谓,但如果一族码随 n 增长检查重量也跟着涨(比如永远碰一半比特),它就是稠密的、不是 LDPC。

What coding really cares about is not a percentage but whether the number of 1s per row and per column is bounded by a constant that does not grow with n. That is the definition of LDPC (low-density parity check): the row weight (check weight, how many qubits a check touches) and the column weight (qubit degree, how many checks touch a qubit) are both capped by a fixed small number. The surface code has at most 4 ones per row (boundary checks have only 2 or 3 legs) and at most 4 per column at any size; BB codes have 6 and 3 + 3; enlarge the torus to 288 or 756 qubits and it is still 6, the fraction of 1s falling ever lower. By contrast the [[4,2,2]] check (1 1 1 1) is all ones and Shor’s X checks touch six of nine qubits — harmless in tiny codes, but a family whose check weight grew with n (always touching half the qubits, say) would be dense, not LDPC.

为什么非要稀疏,有三层原因,都在第 6 章出现。第一,物理上一条检查要用一个辅助比特加「重量个」CNOT 来测:重量 6 就是 6 个 CNOT,芯片上每个比特只需连 6 根线,两层平面图能布下;重量 n/2 的检查代价极高:若仍用一个辅助比特依次做 n/2 个 CNOT,辅助比特上一个错误就会沿 CNOT 传到大量数据比特上(hook 错误的放大版);要容错地测它,就得换用猫态、旗标比特之类的专门电路,开销随重量一起增长。第二,列稀疏意味着一个比特出错只点亮少数几个警报(gross 里一个 X 错误点亮 3 条 Z 检查,一个 Y 错误点亮 3 + 3 = 6 条),症状才有局部性可供译码器利用。第三,BP 译码在 Tanner 图上传消息,图的每个点度数有界(就是行重和列重有界),每一轮的计算量与 n 成正比,而且短圈少时 BP 才准。最后一点是存储和描述:稀疏矩阵不用把整张表存下来,只需列出 1 的位置;BB 码把这一点做到极致——两个三项多项式加上 l、m,四个数据就完全确定了一个 72 × 144 乃至 378 × 756 的检查矩阵。「多项式是稀疏矩阵」,就是这个意思。

Why sparsity is non-negotiable has three layers, all of which surface in Chapter 6. First, physically a check is measured with one ancilla and “weight-many” CNOTs: weight 6 means 6 CNOTs, every qubit on the chip needs only 6 wires, and two planar layers suffice; a check of weight n/2 is very expensive: measured the same way, with one ancilla and n/2 CNOTs in turn, a single fault on the ancilla would spread along the CNOTs to many data qubits (a hook error writ large), and measuring it fault-tolerantly needs special circuits such as cat states or flag qubits, whose cost grows with the weight. Second, sparse columns mean a faulty qubit lights only a few alarms (in gross an X error lights 3 Z checks and a Y error 3 + 3 = 6), giving the syndrome the locality a decoder can exploit. Third, BP decoding passes messages on the Tanner graph; bounded degree (i.e. bounded row and column weight) keeps each round’s work proportional to n, and BP is only accurate when short cycles are scarce. Finally, storage and description: a sparse matrix need not be stored as a full table, only as the positions of its 1s — and BB codes take this to the extreme: two three-term polynomials plus l and m, four pieces of data, completely determine a 72 × 144 or even 378 × 756 check matrix. That is what “a polynomial is a sparse matrix” means.

学名一瞥:这个矩阵住在哪个环里A glimpse of the scholarly name: which ring these matrices live in

所有形如 Σ求和号,读「西格玛」:把若干项加起来。 xayb(系数 0/1)的表达式,加上 xl = 1、ym = 1 这两条规则,构成一个「环」,记作 R = GF(2)[x, y]/(xl − 1, ym − 1)。它里面加法是逐项 XOR,乘法是多项式乘法再按两条规则约化。多项式到矩阵的翻译保持加法与乘法(这叫「正则表示」),所以我们可以在多项式里做代数、在矩阵里做线性代数,两边说的是同一件事。特征 2characteristic 2:1 + 1 = 0 的数系;于是 −1 = +1,减号与加号可以互换。意味着 xl − 1 与 xl + 1 是同一个东西,文献里两种写法并存。

All expressions ΣThe summation sign, read “sigma”: add up several terms. xayb (coefficients 0/1) together with the rules xl = 1, ym = 1 form a “ring”, written R = GF(2)[x, y]/(xl − 1, ym − 1). Addition is termwise XOR, multiplication is polynomial multiplication reduced by the two rules. The polynomial-to-matrix translation preserves both operations (the “regular representation”), so we may do algebra with polynomials and linear algebra with matrices and be talking about the same thing. Characteristic 2A number system where 1 + 1 = 0; hence −1 = +1 and minus may be written as plus. makes xl − 1 and xl + 1 identical, which is why both spellings appear in the literature.

2.4一个变量的祖先:bicycle 码The one-variable ancestor: bicycle codes

工具齐了,先用它们造一个码。第 3 章的构造要在环面上同时处理 x 和 y,这里先把 2.2 的 y 暂时拿掉,退回一个方向,在最小的例子上把整套构造走一遍。这一节只有 x,没有 y:格子只排成一圈(2.1),不是环面,所以一个变量就够了。BB 码名字里的第一个 B 是 bivariate(二元),指的正是把这里的一个方向扩成 2.2 的两个方向。

The tools are in hand; now build a code with them. Chapter 3's construction handles x and y together on a torus, so here we set aside the y of §2.2 for a moment, step back to one direction, and walk the whole construction through on the smallest example. This section has x but no y: the sites form just a ring (§2.1), not a torus, so one variable suffices. The first B of “BB” stands for bivariate — two variables — which is exactly the step from the one direction here to the two of §2.2.

做法是:一圈 l 个位置,每个位置放两个比特,一个在「左轮」上、一个在「右轮」上,共 n = 2l 个(图 2.6,l = 3:左轮 L0、L1、L2,右轮 R0、R1、R2)。每个位置 i 配一条检查:把印章 C 盖在左轮的 i 上,把反向印章 Cᵀ 盖在右轮的 i 上,碰到的比特就是它的腿。X 检查和 Z 检查用同一个配方。取 C = 1 + x:位置 i 的检查在左轮碰 i 和右邻 i+1,在右轮碰 i 和左邻 i−1——一只轮子向右伸腿、一只向左伸腿,这就是名字里的「自行车」(bicycle)。

The recipe: a ring of l positions with two qubits at each position, one on the “left wheel” and one on the “right wheel”, n = 2l in all (Fig. 2.6, l = 3: left wheel L0, L1, L2; right wheel R0, R1, R2). Each position i gets one check: press the stamp C on position i of the left wheel and the reversed stamp Cᵀ on position i of the right wheel; the qubits touched are its legs. X checks and Z checks follow the same recipe. Take C = 1 + x: the check at position i touches i and its right neighbour i+1 on the left wheel, and i and its left neighbour i−1 on the right wheel — one wheel reaches right, the other left, hence the “bicycle”.

L0 L1 L2 R0 R1 R2 1:原地1: stay x:右移一格x: one step right 1:原地1: stay x² = x⁻¹:左移一格x² = x⁻¹: one step left 检查 0(位置 0)check 0 (position 0) 左轮:印章 C = 1 + x 盖在 L0 上 → L0、L1left wheel: stamp C = 1 + x at L0 → L0, L1 右轮:反向印章 Cᵀ = 1 + x² 盖在 R0 上 → R0、R2right wheel: reversed stamp Cᵀ = 1 + x² at R0 → R0, R2 圆 = 左轮比特,顺时针 = 「向右」circles = left-wheel qubits; clockwise = “right” 菱形 = 右轮比特diamonds = right-wheel qubits
图 2.6Fig. 2.6 l = 3 的 bicycle 码:每个位置 i 有左轮比特 Li(圆)和右轮比特 Ri(菱形)。位置 0 的检查(橙色):印章 C = 1 + x 盖在左轮的 0 上 → L0、L1;反向印章 Cᵀ = 1 + x² 盖在右轮的 0 上 → R0、R2。四条腿,写成算符就是 XL0XL1XR0XR2。 The bicycle code with l = 3: position i holds a left-wheel qubit Li (circle) and a right-wheel qubit Ri (diamond). The check at position 0 (orange): stamp C = 1 + x pressed on left-wheel position 0 → L0, L1; reversed stamp Cᵀ = 1 + x² pressed on right-wheel position 0 → R0, R2. Four legs; as an operator, XL0XL1XR0XR2.

这类码是 2004 年 MacKay、Mitchison 与 McFadden 提出的;QEC-Bank 里的 bicycle 见证实例用的就是 C = 1 + x、l = 3,得到 [[6,2,2]]。下面先把它的矩阵写出来(2.4.1、2.4.2),再用 2.3.2 的乘法一次证明它的检查两两对易,最后说明那一步乘法为什么可以交换次序(2.4.3)。

Codes of this kind were introduced by MacKay, Mitchison and McFadden in 2004; the QEC-Bank's bicycle witness uses exactly C = 1 + x with l = 3, giving [[6,2,2]]. Below we first write out its matrices (§2.4.1, §2.4.2), then prove with one multiplication from §2.3.2 that its checks commute pairwise, and finally explain why that multiplication may be done in either order (§2.4.3).

2.4.1 · C = 1 + x(l = 3)记成矩阵2.4.1 · C = 1 + x (l = 3) written as a matrix

按 2.1 的记账,l = 3 时 x 记成循环移位 S:第 i 行的 1 在第 i+1 列,最后一格绕回第 0 格;1 记成单位矩阵 I。多项式相加就是矩阵相加(mod 2),所以 C = 1 + x = I + S 的第 i 行有两个 1,在第 i 列和第 i+1 列,正是「位置 i 的检查碰 i 和右邻」。每一行都是上一行右移一格,这样的方阵叫循环矩阵circulant matrix:每一行都是上一行右移一格的方阵,等价于一圈格子上的一个多项式。任意两个循环矩阵对易。。

By the bookkeeping of §2.1, for l = 3 x is stored as the cyclic shift S: row i has its 1 in column i+1, the last site wrapping to site 0; 1 is stored as the identity I. Adding polynomials is adding matrices (mod 2), so row i of C = 1 + x = I + S has two 1s, in columns i and i+1: exactly “the check at position i touches i and its right neighbour”. Every row is the previous one shifted right by one; such a square matrix is a circulant matrixA square matrix whose every row is the previous row shifted right by one, equivalently a polynomial on a ring of sites. Any two circulants commute..

x = S = 010001100 1 = I = 100010001 C = 1 + x = 110011101

顺手验证 x³ = 1。置换矩阵相乘有个省力读法:S 的第 i 行只有第 i+1 列是 1,所以 S·M 的第 i 行就是 M 的第 i+1 行(整行照抄)。于是 S² 的各行是 S 的第 1、2、0 行,1 落在第 i+2 列——挪两格;S³ 的各行是 S 的第 2、0、1 行,正好是 I——绕三步回到原地。把 S 的行列互换得到 Sᵀ,它恰好等于 S²,所以 Sᵀ = S−1 = S²:在三个格子的圈上,「反向挪一格」和「正向挪两格」是同一件事,即 x−1 = x²。于是 Cᵀ = 1 + x−1 = 1 + x²,第 i 行的 1 在第 i 列和第 i−1 列:「碰自己和左边的邻居」。

Verify x³ = 1 while we are here. Multiplying permutation matrices has a shortcut: row i of S has its only 1 in column i+1, so row i of S·M is simply row i+1 of M, copied whole. Hence the rows of S² are rows 1, 2, 0 of S, with the 1 in column i+2 — two steps; the rows of S³ are rows 2, 0, 1 of S — exactly I, three steps round the ring and home. Swapping rows and columns of S gives Sᵀ, which is precisely S², so Sᵀ = S−1 = S²: on a ring of three, “one step back” and “two steps forward” are the same move, i.e. x−1 = x². Therefore Cᵀ = 1 + x−1 = 1 + x², whose row i has its 1s in columns i and i−1: “touch yourself and your left-hand neighbour”.

S² = 001100010 S³ = I Sᵀ = S² = S−1 Cᵀ = 1 + x² = 101110011

2.4.2 · 两只轮子:把 H = [C | Cᵀ] 写出来2.4.2 · The two wheels: H = [C | Cᵀ] written out

先用比特名把三条检查写出来。位置 i 的检查在左轮盖 C = 1 + x,碰「自己 i 和右邻 i+1」;在右轮盖 Cᵀ = 1 + x−1,碰「自己 i 和左邻 i−1」;三格的圈上,0 的左邻是 2,2 的右邻是 0。于是检查 0 碰 L0、L1 和 R0、R2,检查 1 碰 L1、L2 和 R1、R0,检查 2 碰 L2、L0 和 R2、R1。注意一条检查同时横跨两只轮子:检查 0 是一个四条腿的算符 XL0XL1XR0XR2,一次测出四个 X 的乘积,不是「左轮一条加右轮一条」。

First write the three checks out by qubit name. The check at position i presses C = 1 + x on the left wheel, touching “itself i and its right neighbour i+1”, and Cᵀ = 1 + x−1 on the right wheel, touching “itself i and its left neighbour i−1”; on a three-site ring the left neighbour of 0 is 2 and the right neighbour of 2 is 0. So check 0 touches L0, L1 and R0, R2; check 1 touches L1, L2 and R1, R0; check 2 touches L2, L0 and R2, R1. Note that one check spans both wheels: check 0 is a single four-legged operator XL0XL1XR0XR2, measuring the product of all four X at once, not “one check on the left plus one on the right”.

写成 第 0 章那样的 0/1 表:行是检查,列是比特,1 表示这条检查在这个比特上放一个 X 或 Z。前 3 列是左轮的 L0、L1、L2,后 3 列是右轮的 R0、R1、R2;左块记每条检查在左轮上的腿,就是 C 的矩阵,右块记它在右轮上的腿,就是 Cᵀ 的矩阵。整张表写作 H = [C | Cᵀ],竖线表示左右并排。X 检查和 Z 检查用同一张表,HX = HZ = H:一共 3 条 X 检查、3 条 Z 检查,第 i 条 Z 检查与第 i 条 X 检查碰同一组比特,只是放的是 Z。

As a 0/1 table in the manner of Chapter 0: rows are checks, columns are qubits, and a 1 means the check places an X or a Z on that qubit. The first 3 columns are the left wheel’s L0, L1, L2 and the last 3 the right wheel’s R0, R1, R2; the left block records each check’s legs on the left wheel, which is the matrix of C, and the right block its legs on the right wheel, the matrix of Cᵀ. The whole table is written H = [C | Cᵀ], the bar meaning “side by side”. X and Z checks share one table, HX = HZ = H: 3 X checks and 3 Z checks in all, Z check i touching the same qubits as X check i, only with Z in place of X.

左轮 (C)left wheel (C)右轮 (Cᵀ)right wheel (Cᵀ)算符(X 型;Z 型把 X 换成 Z)operator (X type; Z type swaps X for Z)
H = [C | Cᵀ]L0L1L2R0R1R2
检查 0check 0110101XL0XL1XR0XR2
检查 1check 1011110XL1XL2XR0XR1
检查 2check 2101011XL0XL2XR1XR2

第一步:直接数重叠。第 0 章的规则:X 检查 i 与 Z 检查 j 对易,当且仅当它们共享偶数个比特。逐对对着上表数:

Step one: count the overlaps directly. The rule of Chapter 0: X check i and Z check j commute exactly when they share an even number of qubits. Count pair by pair from the table above:

X 检查 \ Z 检查X check \ Z check012
04(全部)4 (all)2: L1, R02: L0, R2
12: L1, R04(全部)4 (all)2: L2, R1
22: L0, R22: L2, R14(全部)4 (all)

九对全是偶数,所以全部 X、Z 检查两两对易。偶数是两只轮子合力凑出来的。看检查 0 与检查 1:左轮上 0 的右邻就是 1 自己,共享 L1;右轮上 1 的左邻就是 0 自己,共享 R0。每只轮子各贡献 1 个,合起来 2 个。如果只有左轮,XL0XL1 与 ZL1ZL2 只共享 L1 一个,奇数,反对易,码就不成立;右轮用反向印章 Cᵀ,正是为了在另一边补上同样多的重叠。这张表写成矩阵就是 H Hᵀ:它的每个元素是两行的点积,也就是两条检查共享的比特数(第 0 章①):

All nine counts are even, so every X check commutes with every Z check. The evenness comes from the two wheels working together. Take checks 0 and 1: on the left wheel, 0’s right neighbour is 1 itself, so they share L1; on the right wheel, 1’s left neighbour is 0 itself, so they share R0. Each wheel contributes 1, making 2. With the left wheel alone, XL0XL1 and ZL1ZL2 would share only L1, an odd count; they would anticommute and there would be no code. The right wheel presses the reversed stamp Cᵀ precisely to add an equal overlap on the other side. As a matrix this table is H Hᵀ: each entry is the dot product of two rows, which is the number of qubits two checks share (Chapter 0’s ①):

H Hᵀ = C Cᵀ + Cᵀ C = 422242224 ≡ 0 (mod 2)

第二步:用多项式一次数完。l = 3 时九对可以手数,l = 1000 就有一百万对。2.3.2 的公式把「数」变成一次乘法,两只轮子分开算。左轮上 X 检查 i 和 Z 检查 j 盖的都是 C,重叠数是 C·Cᵀ 中 xj−i 的系数:C·Cᵀ = (1 + x)(1 + x−1) = 2 + x + x−1,即同一位置重叠 2 个,相隔 ±1 重叠 1 个——单看左轮,相邻检查的重叠是奇数。右轮上两者盖的都是 Cᵀ,重叠数是 Cᵀ·(Cᵀ)ᵀ = Cᵀ·C 中同一项的系数。Cᵀ·C 与 C·Cᵀ 只是乘的次序不同;走格子时先走哪一步终点都一样,所以两者相等(写成矩阵后为什么仍然成立,见 2.4.3)。于是右轮的重叠数总是左轮的复制,总重叠数 = 2 × (2 + x + x−1) = 4 + 2x + 2x−1:同一位置 4 个,相邻位置 2 个。l = 3 时 x−1 = x²,这正是上面 H Hᵀ 的每一行 (4 2 2)。所有系数都是偶数,对易得证;换成 l = 1000,也还是这一次乘法。

Step two: let polynomials count it all at once. At l = 3 the nine pairs can be counted by hand; at l = 1000 there are a million. The formula of §2.3.2 turns the counting into one multiplication, done wheel by wheel. On the left wheel X check i and Z check j both press C, so their overlap is the coefficient of xj−i in C·Cᵀ: C·Cᵀ = (1 + x)(1 + x−1) = 2 + x + x−1, i.e. 2 at the same position and 1 at a distance of ±1 — on the left wheel alone, neighbouring checks overlap an odd number of times. On the right wheel both press Cᵀ, so the overlap is the same coefficient of Cᵀ·(Cᵀ)ᵀ = Cᵀ·C. Cᵀ·C differs from C·Cᵀ only in the order of the factors; walking on the grid, the order of the steps never changes where you land, so the two are equal (why this still holds once written as matrices is §2.4.3). Hence the right wheel’s overlaps always copy the left wheel’s, and the total overlap is 2 × (2 + x + x−1) = 4 + 2x + 2x−1: 4 at the same position, 2 between neighbours. For l = 3, x−1 = x², which is exactly every row (4 2 2) of H Hᵀ above. Every coefficient is even, which proves commutation; for l = 1000 it would still be this one multiplication.

第三步:[[6,2,2]] 三个数的来历。

Step three: where the three numbers of [[6,2,2]] come from.

n = 6:两只轮子各 3 个数据比特。

n = 6: 3 data qubits on each wheel.

k = 2:把检查 0 与检查 1 相加(mod 2,同一个比特出现两次就抵消):{L0, L1, R0, R2} + {L1, L2, R0, R1} = {L0, L2, R1, R2},正好是检查 2。三条检查里只有两条独立,rank H = 2,k = n − rank HX − rank HZ = 6 − 2 − 2 = 2。

k = 2: add checks 0 and 1 (mod 2, a qubit appearing twice cancels): {L0, L1, R0, R2} + {L1, L2, R0, R1} = {L0, L2, R1, R2}, which is exactly check 2. Only two of the three checks are independent, rank H = 2, and k = n − rank HX − rank HZ = 6 − 2 − 2 = 2.

d = 2:L0 与 R2 出现在完全相同的两条检查(0 和 2)里,从不分开(L1 与 R0、L2 与 R1 同理)。所以 ZL0ZR2 与每条 X 检查共享 0 或 2 个比特,与它们全部对易,却不是 Z 检查的乘积——一个重量 2 的逻辑算符,d = 2。直观地说:任何单比特错误都会触发警报,但 L0 出错和 R2 出错亮的是同一组警报,分不清是谁。5.2 还会回到它。

d = 2: L0 and R2 sit in exactly the same two checks (0 and 2) and never apart (likewise L1 with R0 and L2 with R1). So ZL0ZR2 shares 0 or 2 qubits with every X check and commutes with all of them without being a product of Z checks — a weight-2 logical operator, so d = 2. Intuitively: every single-qubit error trips an alarm, but an error on L0 and one on R2 trip the same alarms, so they cannot be told apart. §5.2 returns to it.

2.4.3 · 为什么 C 与 Cᵀ 可以交换2.4.3 · Why C and Cᵀ commute

2.4.2 用走格子的一句话带过了 C·Cᵀ = Cᵀ·C。在走格子的语言里它确实不费力:C·Cᵀ 的每一项都是「先走 C 的一步、再走 Cᵀ 的一步」,换个次序终点不变(2.1 的第三条)。可一旦写成矩阵,这句话就需要理由,因为矩阵乘法一般不可交换。随手一对 2 × 2 的例子(mod 2):

§2.4.2 passed over C·Cᵀ = Cᵀ·C with one sentence about walking. In the language of walking it really costs nothing: every term of C·Cᵀ is “one step of C, then one step of Cᵀ”, and swapping the order does not change where you end (the third rule of §2.1). Written as matrices, though, the sentence needs a reason, because matrix multiplication in general does not commute. A random 2 × 2 pair (mod 2):

A = 1101B = 1011 A·B = 0111≠B·A = 1110

所以「C 与 Cᵀ 可以交换」要有理由,理由分三层。第一层,同一个矩阵的幂次之间一定可交换:Sa·Sb = Sa+b = Sb·Sa——先挪 a 格再挪 b 格,和先挪 b 格再挪 a 格,都是挪 a + b 格,归根结底是 a + b = b + a。第二层,同一个矩阵的幂次之和(也就是「x 的多项式」)之间也可交换:把 (Σ aiSi)(Σ bjSj) 用分配律展开成 Σ aibj SiSj,每一项都能由第一层调换顺序,整体自然也能——它们都是由同一种动作「挪格子」拼出来的,只是各挪几格、拼几项不同。第三层,Cᵀ 也是 x 的多项式:置换矩阵的转置是它的逆,而 S−1 = Sl−1 仍是 S 的幂(l = 3 时 Sᵀ = S²),所以 Cᵀ = 1 + x−1 = 1 + x² 落回第二层。转置没有把我们带出「x 的世界」,这就是 C Cᵀ = Cᵀ C 的全部理由。

So “C commutes with Cᵀ” needs a reason, and the reason has three layers. First, powers of one matrix always commute: Sa·Sb = Sa+b = Sb·Sa — a steps then b, or b then a, is a + b steps either way; at bottom it is a + b = b + a. Second, sums of powers of one matrix (“polynomials in x”) commute too: expand (Σ aiSi)(Σ bjSj) by the distributive law into Σ aibj SiSj; every term may be reordered by the first layer, so the whole may — all of them are built from the single move “step along the ring”, differing only in how many steps and how many terms. Third, Cᵀ is itself a polynomial in x: a permutation matrix’s transpose is its inverse, and S−1 = Sl−1 is still a power of S (Sᵀ = S² for l = 3), so Cᵀ = 1 + x−1 = 1 + x² falls under the second layer. Transposing never left the “world of x”, and that is the whole reason C Cᵀ = Cᵀ C.

把它算出来看看。先用多项式算,两种顺序都得 x + x²:

Now compute it. First with polynomials; both orders give x + x²:

C·Cᵀ = (1 + x)(1 + x²) = 1 + x² + x + x³ = 1 + x + x² + 1 = x + x²
Cᵀ·C = (1 + x²)(1 + x) = 1 + x + x² + x³ = x + x²
(x³ = 1,1 + 1 = 0)

再用矩阵算。乘积的第 (i, j) 元 = 左矩阵的第 i 行 · 右矩阵的第 j 列(逐项相乘再相加),和超过 1 的取奇偶。Cᵀ 的第 j 列就是 C 的第 j 行竖过来,所以 C·Cᵀ 的九个元素是 C 的行与行的点积;同理 Cᵀ·C 的九个元素是 C 的列与列的点积:

Then with matrices. Entry (i, j) of a product is row i of the left factor dotted with column j of the right factor (multiply termwise, add up), sums above 1 reduced mod 2. Column j of Cᵀ is row j of C stood upright, so the nine entries of C·Cᵀ are dot products of rows of C with rows of C; likewise the entries of Cᵀ·C are dot products of columns of C with columns of C:

C · Cᵀ第 0 列column 0第 1 列column 1第 2 列column 2
第 0 行row 0(1 1 0)·(1 1 0) = 2 → 0(1 1 0)·(0 1 1) = 1(1 1 0)·(1 0 1) = 1
第 1 行row 1(0 1 1)·(1 1 0) = 1(0 1 1)·(0 1 1) = 2 → 0(0 1 1)·(1 0 1) = 1
第 2 行row 2(1 0 1)·(1 1 0) = 1(1 0 1)·(0 1 1) = 1(1 0 1)·(1 0 1) = 2 → 0
Cᵀ · C第 0 列column 0第 1 列column 1第 2 列column 2
第 0 行row 0(1 0 1)·(1 0 1) = 2 → 0(1 0 1)·(1 1 0) = 1(1 0 1)·(0 1 1) = 1
第 1 行row 1(1 1 0)·(1 0 1) = 1(1 1 0)·(1 1 0) = 2 → 0(1 1 0)·(0 1 1) = 1
第 2 行row 2(0 1 1)·(1 0 1) = 1(0 1 1)·(1 1 0) = 1(0 1 1)·(0 1 1) = 2 → 0
C·Cᵀ = Cᵀ·C = 011101110 = S + S² = x + x²

两边一模一样,而且正好等于 S + S²:S 的 1 在第 i+1 列、S² 的 1 在第 i+2 列,相加后每行除对角线外全是 1。于是 H Hᵀ = C Cᵀ + Cᵀ C = 2(x + x²) = 0,bicycle 码的对易性就是这么来的。

Both sides agree, and equal S + S²: S has its 1 in column i+1, S² in column i+2, and their sum is 1 everywhere off the diagonal. Hence H Hᵀ = C Cᵀ + Cᵀ C = 2(x + x²) = 0 — that is where the bicycle code’s commutation comes from.

到 BB 码只多一步:两个变量 x 与 y 之间也可交换(2.2 的 xy = yx),所以任何 x、y 的多项式都是「若干次平移」的和,三层论证原样成立,A·B = B·A。3.2 那一行 AB + BA = 2AB = 0 里的第一个等号,说的就是这件事。

BB codes add one step: the two variables x and y also commute (xy = yx, §2.2), so any polynomial in x and y is a sum of translations, the three-layer argument goes through verbatim, and A·B = B·A. The first equality in §3.2’s one-liner AB + BA = 2AB = 0 is exactly this.

关键想法Key idea

读法:1 不动,x 横走一格,y 竖走一格;一个多项式是一枚印章,每一项是一条腿;反向印章 Aᵀ 把每一步倒着走。用处:两枚印章的重叠格数 = P·Qᵀ 的系数,所以一次乘法就能判定所有检查对是否对易;而多项式乘法可以交换次序,下一章的对易定理只用这一条。记账:单项式是置换矩阵,w 项的多项式是每行 w 个 1 的稀疏矩阵,反向印章是转置。

Reading: 1 stays, x steps across, y steps up; a polynomial is a stamp and each term a leg; the reversed stamp Aᵀ walks every step backwards. Use: the number of sites two stamps share is a coefficient of P·Qᵀ, so one multiplication decides whether every pair of checks commutes; and polynomial multiplication commutes, which is all the next chapter’s commutation theorem needs. Bookkeeping: a monomial is a permutation matrix, a w-term polynomial a sparse matrix with w ones per row, and the reversed stamp the transpose.

检查站Checkpoint第 2 章Chapter 2
在 12 × 6 的环面上,多项式 B = y³ + x + x² 对应的矩阵有多大、每行几个 1、(B)ᵀ 对应哪个多项式?On a 12 × 6 torus, how large is the matrix of B = y³ + x + x², how many 1s per row, and which polynomial is Bᵀ?

对。lm = 72 个格子,所以矩阵 72 × 72;三项就是每行三个 1;转置把 y³ 倒成 y−3,而 m = 6 时 y−3 = y³(转半圈再转半圈),x−1 = x11。注意 Bᵀ 不是 A:A 与 B 是两个独立选择的多项式。

Right. lm = 72 sites, so the matrix is 72 × 72; three terms means three 1s per row; the transpose turns y³ into y−3, and with m = 6, y−3 = y³ (half a turn either way), x−1 = x11. Note Bᵀ is not A: A and B are two independently chosen polynomials.

矩阵的边长是格子数 lm;每项贡献每行一个 1;转置把每个指数取负,再按 mod l、mod m 约化。

The matrix side is the number of sites lm; each term contributes one 1 per row; the transpose negates every exponent, then reduce mod l and mod m.

检查站Checkpoint第 2 章 · 重叠Chapter 2 · Overlaps
一圈 6 个格子,印章 P = 1 + x 盖在格子 0,印章 Q = 1 + x 盖在格子 1。两者共享几个格子?P·Qᵀ 的哪一项告诉你?On a ring of 6 sites, the stamp P = 1 + x is pressed on site 0 and Q = 1 + x on site 1. How many sites do they share, and which term of P·Qᵀ says so?

对。P 碰 {0, 1},Q 碰 {1, 2},只共享格子 1;相隔 t − s = 1,看 x¹ 的系数,正是 1。

Right. P touches {0, 1} and Q touches {1, 2}; they share only site 1. The separation is t − s = 1, so read the coefficient of x¹: it is 1.

重叠数看的是 P·Qᵀ 中 xt−s 的系数;这里 t − s = 1。常数项 2 说的是两枚印章盖在同一格的情形。

The overlap is the coefficient of xt−s in P·Qᵀ, and here t − s = 1. The constant term 2 describes two stamps pressed on the same site.

第 3 章Chapter 3

构造与对易定理Construction and the commutation theorem

两层比特、两个多项式、一次交换转置:HX = [A | B],HZ = [Bᵀ | Aᵀ]。对易性不需要逐条检查,是一行代数:AB + BA = 2AB = 0。最简单的选择 A = 1 + x、B = 1 + y 给出的正是《从高考数学到 Toric Code》里的环面码——BB 码是环面码的直系后代。 Two layers of qubits, two polynomials, one swapped transpose: HX = [A | B], HZ = [Bᵀ | Aᵀ]. Commutation needs no check-by-check audit; it is one line of algebra: AB + BA = 2AB = 0. The simplest choice A = 1 + x, B = 1 + y gives exactly the toric code of “From High-School Math to the Toric Code” — BB codes are its direct descendants.

3.1两层比特,一张配方Two layers of qubits, one recipe

把 2.4 的两只轮子升级成两张环面:l × m 环面的每个格子 (i, j) 上放两个数据比特,一个属于左层 L,一个属于右层 R,共 n = 2lm 个。可以想成两张一模一样的方格纸上下叠放,每张纸每格一个比特。每个格子再配一条 X 检查和一条 Z 检查(各 lm 条)。配方就是两次盖印章:

Upgrade the two wheels of §2.4 to two tori: on every site (i, j) of the l × m torus place two data qubits, one in the left layer L and one in the right layer R, n = 2lm in all. Picture two identical sheets of squared paper stacked one on the other, one qubit per square on each sheet. Each site also carries one X check and one Z check (lm of each). The recipe is two stamp presses:

X 检查 (i, j):A 盖在左层,B 盖在右层
Z 检查 (i, j):Bᵀ 盖在左层,Aᵀ 盖在右层
(每一枚印章都盖在格子 (i, j) 上)
X check (i, j): A on layer L, B on layer R
Z check (i, j): Bᵀ on layer L, Aᵀ on layer R
(every stamp is pressed on site (i, j))

一条检查的腿数是 |A| + |B|(|A| 是 A 的项数)。为什么 Z 检查要「交换 A、B 再反向」,3.2 一行算给你看。先在下面的动画里把这句配方看成图:左右两张图是同一个环面的两层,选一个格子,逐步看 A 的每一项在左层落下一条腿、B 的每一项在右层落下一条腿,再看一条 Z 检查和它共享哪两个比特。环面码预设的最后一步把两层画回环面码教程的样子。

A check has |A| + |B| legs (|A| is the number of terms of A). Why a Z check must “swap A and B and reverse them”, §3.2 computes in one line. First, see the recipe as a picture in the animation below: the two panels are the two layers of one torus; pick a site and watch each term of A drop a leg in the left layer and each term of B a leg in the right layer, then see which two qubits a Z check shares with it. The last step of the toric preset redraws the two layers the way the toric-code tutorial drew them.

记账:用矩阵写,就是把两枚印章的矩阵左右并排:HX = [A | B],前 lm 列是左层、后 lm 列是右层;HZ = [Bᵀ | Aᵀ]。补课 3.A 把这两张表的每一行、每一列是什么逐格摆出来。

Bookkeeping: in matrices, the two stamps’ matrices sit side by side: HX = [A | B], the first lm columns the left layer and the last lm the right; HZ = [Bᵀ | Aᵀ]. Catch-up 3.A lays out what every row and column of the two tables means, cell by cell.

HX = [ A | B ], HZ = [ Bᵀ | Aᵀ ]
n = 2lm
检查重量check weight = |A| + |B| (|A| = A 的项数|A| = number of terms of A)
每个比特被 |A| 条 X 检查和 |B| 条 Z 检查碰到(或反之)each qubit meets |A| X checks and |B| Z checks (or vice versa)
补课 · 左层、右层,以及 A、B、HX 的尺寸Catch-up · Left layer, right layer, and the sizes of A, B and HX

A 和 B 是两个同样大小的方阵,都是 lm × lm(第 2 章的翻译:多项式有 w 项,矩阵每行每列恰好 w 个 1)。把它们左右并排,HX = [A | B] 就是 lm 行、2lm 列。关键是行和列各自代表什么。行 = 检查。环面有 lm 个格子,每个格子 (i, j) 配一条 X 检查,所以 HX 有 lm 行,A 的第 (i, j) 行和 B 的第 (i, j) 行说的是同一条检查——A 那一半记它在左层伸出的腿,B 那一半记它在右层伸出的腿。列 = 比特。每个格子上放两个数据比特,共 n = 2lm 个;HX 的前 lm 列对应第一份比特(每格一个,按格子编号),后 lm 列对应第二份。所谓「左层」「右层」,只是给这两份比特起的名字:落在 [A | B] 左半块的那一份叫左层 L,右半块的叫右层 R。可以想成两张一模一样的环面上下叠着、每张上每格一个比特——或者就是 2.4.2 bicycle 码里的两只轮子,那里的「环面」退化成一圈 l 个格子。

A and B are two square matrices of the same size, both lm × lm (the translation of Chapter 2: a polynomial with w terms is a matrix with exactly w ones per row and column). Placed side by side, HX = [A | B] has lm rows and 2lm columns. The point is what rows and columns stand for. Rows = checks. The torus has lm sites and each site (i, j) carries one X check, so HX has lm rows, and row (i, j) of A and row (i, j) of B describe the same check — the A half records its legs on the left layer, the B half its legs on the right layer. Columns = qubits. Every site holds two data qubits, n = 2lm in all; the first lm columns of HX are the first copy (one per site, in site order), the last lm the second copy. “Left layer” and “right layer” are merely the names of these two copies: the copy addressed by the left block of [A | B] is the left layer L, the other the right layer R. Picture two identical tori stacked, one qubit per site on each — or simply the two wheels of the bicycle code in §2.4.2, where the “torus” degenerates to a ring of l sites.

于是 3.1 那句话的意思是:A 的第 (i, j) 行在第 (i+a, j+b) 列有 1(每项 xayb 一个),这些列属于左半块,所以是左层比特 L(i+a, j+b);B 的第 (i, j) 行的 1 落在右半块,是右层比特 R(i+a′, j+b′)。一条检查共 |A| + |B| 条腿。用 l = m = 2、A = 1 + x、B = 1 + y(补课 2.B 算出的 4 × 4 矩阵)把布局摆出来,HX 是 4 行 8 列:

So the sentence in §3.1 means: row (i, j) of A has a 1 in column (i+a, j+b) for each term xayb, and those columns belong to the left block, hence left-layer qubits L(i+a, j+b); the 1s in row (i, j) of B fall in the right block, right-layer qubits R(i+a′, j+b′). One check has |A| + |B| legs in all. Laying it out with l = m = 2, A = 1 + x, B = 1 + y (the 4 × 4 matrices of Catch-up 2.B), HX is 4 rows by 8 columns:

HX = [A | B]L00L01L10L11R00R01R10R11X 检查的算符the X-check operator
检查 (0,0)check (0,0)10101100XL00XL10XR00XR01
检查 (0,1)check (0,1)01011100XL01XL11XR01XR00
检查 (1,0)check (1,0)10100011XL10XL00XR10XR11
检查 (1,1)check (1,1)01010011XL11XL01XR11XR10

对照原话:格子 (0,0) 的 X 检查作用于 A 的两项指向的左层比特 L(0,0)、L(1,0),以及 B 的两项指向的右层比特 R(0,0)、R(0,1)。四条腿,正是环面码教程里的星形检查——那里把左层比特画在横边上、右层比特画在竖边上,「层」就有了几何形象;一般的 BB 码没有边的图像,「层」只剩「哪一半列」这个含义。Z 检查同理:HZ = [Bᵀ | Aᵀ] 也是 lm 行 2lm 列,格子 (i, j) 的 Z 检查在左层碰 Bᵀ 指向的比特(B 的每项反向平移,(i−a′, j−b′)),在右层碰 Aᵀ 指向的比特。最后核对尺寸,也顺带看清 3.2 那行证明的形状:HX 是 lm × 2lm,HZᵀ 是 2lm × lm(上半块 B、下半块 A,各 lm × lm),乘积 HXHZᵀ = AB + BA 是 lm × lm 的方阵,第 (i, j) 元就是「格子 i 的 X 检查与格子 j 的 Z 检查共同踩到的比特数」。gross 码 lm = 72,A、B 都是 72 × 72,HX 是 72 × 144。

Against the original sentence: the X check at site (0,0) acts on the left-layer qubits L(0,0), L(1,0) pointed to by the two terms of A and on the right-layer qubits R(0,0), R(0,1) pointed to by the two terms of B. Four legs — exactly the star check of the toric tutorial, which draws left-layer qubits on horizontal edges and right-layer qubits on vertical ones, giving “layer” a geometric face; a general BB code has no edge picture, and “layer” keeps only the meaning “which half of the columns”. Z checks likewise: HZ = [Bᵀ | Aᵀ] also has lm rows and 2lm columns, and the Z check at (i, j) touches on the left layer the qubits pointed to by Bᵀ (each term of B translated backwards, (i−a′, j−b′)) and on the right layer those pointed to by Aᵀ. Finally the sizes, which also show the shape of the one-line proof in §3.2: HX is lm × 2lm, HZᵀ is 2lm × lm (B on top, A below, each lm × lm), and the product HXHZᵀ = AB + BA is an lm × lm square whose (i, j) entry is “the number of qubits shared by the X check at site i and the Z check at site j”. For gross, lm = 72, A and B are 72 × 72, and HX is 72 × 144.

补课 · 检查重量是什么Catch-up · What the check weight is

检查重量(check weight)就是一条检查碰到多少个比特——那条检查的算符里有多少个 X(或 Z),等价地,检查矩阵那一行里 1 的个数。「重量」(weight)在这套语言里永远是同一个意思:一个 Pauli 算符在多少个比特上不是恒等 I。用在检查上叫检查重量,用在错误上叫错误重量(翻了几个比特),用在逻辑算符上就是码距 d 的定义(最轻的逻辑算符的重量)。它只数位置,不管类型。

The check weight is how many qubits one check touches — how many X (or Z) factors its operator contains, equivalently how many 1s its row of the check matrix has. “Weight” always means the same thing in this language: the number of qubits on which a Pauli operator is not the identity I. Applied to a check it is the check weight, applied to an error the error weight (how many qubits flipped), applied to a logical operator it defines the distance d (the weight of the lightest logical operator). It counts positions only, not types.

对 BB 码,格子 (i, j) 的 X 检查在左层伸出 |A| 条腿(A 每一项一条),在右层伸出 |B| 条腿,所以重量 = |A| + |B|。这里 |A| 表示多项式 A 的项数——不是绝对值、不是行列式,词汇表里专门列了这个记号。环面码 A = 1 + x、B = 1 + y:2 + 2 = 4,星形检查的四条腿,补课 3.A 那张表每行恰好四个 1。bicycle 码 H = [C | Cᵀ]、C = 1 + x:2 + 2 = 4。gross 码 A = x³ + y + y²、B = y³ + x + x²:3 + 3 = 6,「六腿检查」,X 检查在 (i, j) 上的六条腿是 L(i+3, j)、L(i, j+1)、L(i, j+2)、R(i, j+3)、R(i+1, j)、R(i+2, j);Z 检查用 HZ = [Bᵀ | Aᵀ],项数不变,重量同样是 6。BB 码里所有检查重量都一样;一般的码不必如此,Shor 码的 X 检查重量 6、Z 检查重量 2。

For a BB code the X check at site (i, j) puts |A| legs on the left layer (one per term of A) and |B| legs on the right, so the weight is |A| + |B|. Here |A| is the number of terms of the polynomial A — not an absolute value or a determinant; the glossary lists the symbol. Toric code, A = 1 + x, B = 1 + y: 2 + 2 = 4, the four legs of a star, and every row of the table in Catch-up 3.A has exactly four 1s. Bicycle code, H = [C | Cᵀ] with C = 1 + x: 2 + 2 = 4. Gross code, A = x³ + y + y², B = y³ + x + x²: 3 + 3 = 6, the “six-leg check”, whose legs at (i, j) are L(i+3, j), L(i, j+1), L(i, j+2), R(i, j+3), R(i+1, j), R(i+2, j); the Z checks use HZ = [Bᵀ | Aᵀ], the term counts are unchanged, weight 6 as well. In BB codes every check has the same weight; in general codes it need not — Shor’s X checks have weight 6 and its Z checks weight 2.

为什么要单独给它起名字:重量直接等于测这条检查要用几个 CNOT——一个辅助比特依次和每条腿上的数据比特做一次门,重量 6 就是 6 个 CNOT,多一条腿就多一个门、多一个出错的机会,也多一条 hook 错误传播的路径;它同时决定了芯片上每个辅助比特要连几根线。LDPC 里的「低密度」就是「检查重量有上界、不随 n 增长」(补课 2.C)。要和它区分的是比特度(qubit degree):一个比特被几条检查碰到,对应检查矩阵的列里 1 的个数。BB 码里一个左层比特被 |A| 条 X 检查和 |B| 条 Z 检查碰到,右层比特反之;gross 码是 3 + 3。行重是检查的账,列重是比特的账,6.1 的 Tanner 图里两者分别是检查节点和比特节点的度数。

Why it deserves a name of its own: the weight is exactly the number of CNOTs needed to measure the check — one ancilla interacts in turn with the data qubit on each leg, so weight 6 means 6 CNOTs; every extra leg is an extra gate, an extra chance of failure and an extra path for hook errors to spread, and it also fixes how many wires each ancilla needs on the chip. The “low density” of LDPC means “the check weight is bounded and does not grow with n” (Catch-up 2.C). Distinguish it from the qubit degree: how many checks touch a qubit, the number of 1s in a column of the check matrix. In a BB code a left-layer qubit meets |A| X checks and |B| Z checks and a right-layer qubit the reverse; for gross, 3 + 3. Row weight is the checks’ ledger, column weight the qubits’; in the Tanner graph of §6.1 they are the degrees of the check nodes and the qubit nodes respectively.

先看最简单的例子。取 A = 1 + x,B = 1 + y:X 检查在 (i, j) 碰左层的 (i, j)、(i+1, j) 和右层的 (i, j)、(i, j+1),共四腿。把左层比特画在横边上、右层比特画在竖边上,这恰好是环面码教程里的星形检查;Z 检查同理是面检查。所以 BB(1 + x, 1 + y) 就是 L × L 环面码:本页对 l = m = 3 算出 [[18,2,3]],和那里的账本一致。在实验台上把预设切到 toric_L3,点一条检查看它的四条腿:

Start with the simplest example. Take A = 1 + x, B = 1 + y: the X check at (i, j) touches left-layer (i, j), (i+1, j) and right-layer (i, j), (i, j+1), four legs. Draw left-layer qubits on horizontal edges and right-layer qubits on vertical edges and this is exactly the toric tutorial's star check; the Z check is likewise a plaquette. So BB(1 + x, 1 + y) is the L × L toric code: this page computes [[18,2,3]] for l = m = 3, matching that ledger. Switch the bench's preset to toric_L3 and click a check to see its four legs:

3.2对易定理:一行证明The commutation theorem: a one-line proof

CSS 条件要求 HXHZᵀ = 0(第 0 章①)。分块相乘:

The CSS condition demands HXHZᵀ = 0 (Ch. 0, ①). Multiply block by block:

HXHZT = [A | B]
[B ; A] = AB + BA = AB + AB = 2AB = 0 (用 AB = BA,再用 1 + 1 = 0using AB = BA, then 1 + 1 = 0)

两步各用一条事实。第一步 AB = BA:A 与 B 都是 x、y 的多项式,而 xy = yx(2.2),所以任意两个这样的多项式相乘顺序无关——这是把检查「算」在阿贝尔(可交换)的环上的全部回报。第二步 AB + AB = 0 是 GF(2) 的 1 + 1 = 0。于是任何 l、m、A、B 都给出一个合法的 CSS 码,不需要像环面码教程那样逐对数碰撞。

Each step uses one fact. Step one, AB = BA: A and B are polynomials in x and y, and xy = yx (§2.2), so any two such polynomials multiply in either order — the entire reward for computing checks over an abelian (commutative) ring. Step two, AB + AB = 0, is GF(2)'s 1 + 1 = 0. Hence every l, m, A, B yields a legitimate CSS code, with no pairwise collision count as in the toric tutorial.

这一行在图上说什么。用 2.3.2 的重叠公式分层数:X 检查 s 与 Z 检查 t 在左层盖的是 A 和 Bᵀ,左层重叠数 = A·(Bᵀ)ᵀ = AB 中 t − s 那一项的系数;在右层盖的是 B 和 Aᵀ,右层重叠数 = BA 中同一项的系数。AB = BA,所以两层的重叠数永远相等,合起来必是偶数:AB + BA = 2AB = 0 说的就是这件事。gross 码的 AB 恰有 9 项、系数都是 1,所以每条 X 检查恰好与 9 条 Z 检查各共享 2 个比特(左右层各 1 个),与其余 63 条 Z 检查一个比特都不共享。

What this line says in the picture. Count layer by layer with the overlap formula of §2.3.2: X check s and Z check t press A and Bᵀ on the left layer, so their left overlap is the coefficient of the t − s term in A·(Bᵀ)ᵀ = AB; on the right layer they press B and Aᵀ, so the right overlap is the same coefficient of BA. AB = BA, so the two layers always contribute equal overlaps and the total is even: that is all AB + BA = 2AB = 0 says. The gross code’s AB has exactly 9 terms, each with coefficient 1, so every X check shares exactly 2 qubits (one per layer) with each of 9 Z checks and none at all with the other 63.

补课 · [A | B]·[B ; A] = AB + BA 这一步怎么来Catch-up · Where [A | B]·[B ; A] = AB + BA comes from

记号:[P | Q] 是把两个矩阵左右并排,[P ; Q] 是上下堆叠。分三步。

Notation: [P | Q] places two matrices side by side, [P ; Q] stacks them. Three steps.

第一步:HZᵀ = [B ; A]。HZ = [Bᵀ | Aᵀ] 是 lm 行、2lm 列。转置就是行列互换。并排矩阵 [P | Q] 的列是「P 的各列,接着 Q 的各列」,转置后这些列变成行,就成了「Pᵀ 的各行,接着 Qᵀ 的各行」,也就是上下堆叠:[P | Q]ᵀ = [Pᵀ ; Qᵀ]。再用「转置两次回到自己」(Mᵀ)ᵀ = M:HZᵀ = [Bᵀ | Aᵀ]ᵀ = [(Bᵀ)ᵀ ; (Aᵀ)ᵀ] = [B ; A],一个 2lm 行、lm 列的矩阵,上半块 B、下半块 A。尺寸对得上:HX 是 lm × 2lm,HZᵀ 是 2lm × lm,乘积 lm × lm。

Step one: HZᵀ = [B ; A]. HZ = [Bᵀ | Aᵀ] has lm rows and 2lm columns. Transposing swaps rows and columns. The columns of [P | Q] are “the columns of P, then the columns of Q”; after transposition these become rows, “the rows of Pᵀ, then the rows of Qᵀ”, which is a stack: [P | Q]ᵀ = [Pᵀ ; Qᵀ]. With “transposing twice gives the original”, (Mᵀ)ᵀ = M: HZᵀ = [Bᵀ | Aᵀ]ᵀ = [(Bᵀ)ᵀ ; (Aᵀ)ᵀ] = [B ; A], a matrix of 2lm rows and lm columns, B on top and A below. The sizes fit: HX is lm × 2lm, HZᵀ is 2lm × lm, the product lm × lm.

第二步:[A | B]·[B ; A] = AB + BA。回到乘法的定义:乘积的第 (i, j) 元 = HX 的第 i 行 · HZᵀ 的第 j 列 = 对全部 2lm 个位置 q 求和 HX[i][q]·HZᵀ[q][j]。这个 2lm 项的和从中间切成两半:前 lm 个 q 是左层的列,那里 HX 的元素是 A 的元素、HZᵀ 的元素是 B 的元素;后 lm 个 q 是右层,那里是 B 和 A。于是

Step two: [A | B]·[B ; A] = AB + BA. Back to the definition: entry (i, j) of the product = row i of HX · column j of HZᵀ = the sum over all 2lm positions q of HX[i][q]·HZᵀ[q][j]. Cut this 2lm-term sum in the middle: the first lm values of q are the left-layer columns, where the entries of HX come from A and those of HZᵀ from B; the last lm are the right layer, with B and A. Hence

(HXHZᵀ)[i][j] = Σ左层 qleft-layer q A[i][q]·B[q][j] + Σ右层 qright-layer q B[i][q]·A[q][j] = (AB)[i][j] + (BA)[i][j]

第一个和正是矩阵乘积 AB 的第 (i, j) 元的定义(A 的第 i 行点 B 的第 j 列),第二个和是 BA 的。每个 (i, j) 都如此,所以整个矩阵 HXHZᵀ = AB + BA。用数字打个比方:(1 2 | 3 4) 点 (5 ; 6 ; 7 ; 8) = (1·5 + 2·6) + (3·7 + 4·8),「前半段点前半段」加「后半段点后半段」。分块乘法的口诀:只要块的尺寸对得上,把每个块当成一个数来乘就行——(A, B) 这一「行」点 (B, A) 这一「列」得 A·B + B·A,只是块之间的乘法要保持左右顺序。这一步有个很好的物理读法:(AB)[i][j] 是 A 的第 i 行与 B 的第 j 列的点积,而 B 的第 j 列就是 Bᵀ 的第 j 行,即 Z 检查 j 在左层的腿,所以 (AB)[i][j] = X 检查 i 与 Z 检查 j 在左层共同踩到的比特数,(BA)[i][j] 是它们在右层共同踩到的比特数,AB + BA 是总重叠数——和 bicycle 码的「左轮重叠 + 右轮重叠」一模一样。

The first sum is by definition entry (i, j) of the matrix product AB (row i of A dotted with column j of B), the second that of BA. This holds for every (i, j), so the whole matrix is HXHZᵀ = AB + BA. A numerical analogy: (1 2 | 3 4) dotted with (5 ; 6 ; 7 ; 8) = (1·5 + 2·6) + (3·7 + 4·8), “first half dotted with first half” plus “second half with second half”. The rule of block multiplication: as long as the block sizes fit, treat each block as a number — the “row” (A, B) dotted with the “column” (B, A) gives A·B + B·A — keeping the left-to-right order of the blocks. There is a good physical reading: (AB)[i][j] is row i of A dotted with column j of B, and column j of B is row j of Bᵀ, the legs of Z check j on the left layer, so (AB)[i][j] = the number of qubits X check i and Z check j share on the left layer, (BA)[i][j] the number they share on the right layer, and AB + BA the total overlap — exactly the bicycle code’s “left-wheel overlap + right-wheel overlap”.

第三步:2 × 2 的例子算一遍。用补课 2.B 的 A = 1 + x、B = 1 + y(4 × 4)。这个例子里 l = m = 2,恰好 Aᵀ = A、Bᵀ = B,所以 HZ = [B | A],HZᵀ = [B ; A](8 行 4 列):

Step three: the 2 × 2 example. Take A = 1 + x and B = 1 + y (4 × 4) from Catch-up 2.B. Here l = m = 2, so it happens that Aᵀ = A and Bᵀ = B, whence HZ = [B | A] and HZᵀ = [B ; A] (8 rows, 4 columns):

HZᵀ = [B ; A](0,0)(0,1)(1,0)(1,1)
B 第 0 行row 01100
B 第 1 行row 11100
B 第 2 行row 20011
B 第 3 行row 30011
A 第 0 行row 01010
A 第 1 行row 10101
A 第 2 行row 21010
A 第 3 行row 30101

先算 AB:A 的第 0 行 (1 0 1 0) 分别点 B 的四列 (1 1 0 0)ᵀ、(1 1 0 0)ᵀ、(0 0 1 1)ᵀ、(0 0 1 1)ᵀ,得 1、1、1、1;其余三行同样全是 1。再算 BA:B 的第 0 行 (1 1 0 0) 点 A 的四列 (1 0 1 0)ᵀ、(0 1 0 1)ᵀ、(1 0 1 0)ᵀ、(0 1 0 1)ᵀ,也是 1、1、1、1。于是

First AB: row 0 of A, (1 0 1 0), dotted with the four columns of B, (1 1 0 0)ᵀ, (1 1 0 0)ᵀ, (0 0 1 1)ᵀ, (0 0 1 1)ᵀ, gives 1, 1, 1, 1; the other three rows are all 1s as well. Then BA: row 0 of B, (1 1 0 0), dotted with the columns of A, (1 0 1 0)ᵀ, (0 1 0 1)ᵀ, (1 0 1 0)ᵀ, (0 1 0 1)ᵀ, again 1, 1, 1, 1. Hence

AB = BA = 1111111111111111HXHZᵀ = AB + BA = 2222222222222222 ≡ 0 (mod 2)

用多项式验证同一件事:AB = (1 + x)(1 + y) = 1 + x + y + xy,四个单项式把每个起点送到四个不同的格子,所以矩阵每行四个 1;BA = (1 + y)(1 + x) = 1 + y + x + yx,因 xy = yx 而完全相同。物理读法:这个小环面码里任何一条 X 检查和任何一条 Z 检查,在左层恰好共享 1 个比特、在右层也恰好共享 1 个,总共 2 个,偶数,对易。拿补课 3.A 的表核对:X 检查 (0,0) 碰 L00、L10、R00、R01,Z 检查 (1,1) 碰 L10、L11、R01、R11,共享 L10 和 R01。收尾:有了 HXHZᵀ = AB + BA,3.2 剩下两步——AB = BA(补课 2.B),所以 AB + BA = AB + AB = 2AB;GF(2) 里 2 = 0,所以等于零矩阵。也可以不走代数、直接用物理读法:左层重叠数 (AB)[i][j] 与右层重叠数 (BA)[i][j] 永远相等,总数必然是偶数。

The polynomials say the same: AB = (1 + x)(1 + y) = 1 + x + y + xy, four monomials carrying every start to four different sites, so four 1s per row; BA = (1 + y)(1 + x) = 1 + y + x + yx, identical because xy = yx. Physically: in this little toric code any X check and any Z check share exactly 1 qubit on the left layer and exactly 1 on the right, 2 in all, even, commuting. Check against the table of Catch-up 3.A: X check (0,0) touches L00, L10, R00, R01; Z check (1,1) touches L10, L11, R01, R11; shared: L10 and R01. To finish: with HXHZᵀ = AB + BA in hand, §3.2 has two steps left — AB = BA (Catch-up 2.B), so AB + BA = AB + AB = 2AB, and in GF(2) 2 = 0, the zero matrix. Or skip the algebra and use the physical reading: the left-layer overlap (AB)[i][j] always equals the right-layer overlap (BA)[i][j], so the total is necessarily even.

为什么必须「交换」再「转置」?Why must one swap and transpose?

转置的任务是让 Z 检查成为 X 检查的「对偶」:Bᵀ 把 B 的每个平移倒过来,这样 X 检查沿某方向伸出去的腿,Z 检查沿反方向收回来,两者在几何上才能配对。交换的任务是把乘积路由成 AB + BA。若不交换,取 HZ = [Aᵀ | Bᵀ],则 HXHZᵀ = A·A + B·B = A² + B²。它只在特殊的 A、B 下才碰巧为零(比如 A = B);一般不为零,例如 l = 3、A = 1 + x、B = 1:A² + B² = (1 + x²) + 1 = x² ≠ 0,码就不成立。交换之后,对易对任何 A、B 都成立,所以「交换 + 转置」不是审美选择,而是让对易定理对所有输入都成立的做法。在实验台上把 A 或 B 换成任何多项式,读数里的 HXHZᵀ = 0 ✓ 永远亮着。

The transpose makes the Z checks the “dual” of the X checks: Bᵀ reverses every translation of B, so where an X check reaches out in one direction a Z check reaches back, and the two can pair geometrically. The swap routes the product into AB + BA. Without it, HZ = [Aᵀ | Bᵀ] gives HXHZᵀ = A·A + B·B = A² + B², which vanishes only for special A, B (A = B, say); in general it does not: l = 3, A = 1 + x, B = 1 give A² + B² = (1 + x²) + 1 = x² ≠ 0, and the code falls apart. With the swap, commutation holds for every A and B, so “swap and transpose” is not an aesthetic choice but what makes the theorem hold for all inputs. Change A or B on the bench to anything you like; the readout's HXHZᵀ = 0 ✓ never goes out.

3.3从四腿到六腿:gross 码的检查From four legs to six: the gross code's checks

现在把 3.1 实验台的预设切到 gross:l = 12、m = 6,A = x³ + y + y²,B = y³ + x + x²。每条检查六腿:A 的三项指向左层三个比特(往右三格、往上一格、往上两格),B 的三项指向右层三个(往上三格、往右一格、往右两格)。这六个比特不再挤在一个小方块里——「往右三格」和「往上三格」把检查伸到了远处——第 1 章说的「动的是常数 c」就在这里。每个数据比特反过来被 3 条 X 检查和 3 条 Z 检查碰到(在那个实验台切到「看一个比特」)。下面的动画用 gross 码把一条检查的六条腿逐条盖出来,最后再看它和一条 Z 检查共享的两个比特。

Now switch the preset of the §3.1 bench to gross: l = 12, m = 6, A = x³ + y + y², B = y³ + x + x². Every check has six legs: A's three terms point to three left-layer qubits (three right, one up, two up), B's three terms to three right-layer qubits (three up, one right, two right). The six no longer crowd into a small square — “three right” and “three up” stretch the check far away — this is where Chapter 1’s “moving the constant c” happens. Conversely every data qubit is touched by 3 X checks and 3 Z checks (switch that bench to “one qubit”). The animation below stamps out the six legs of one gross check one by one, and ends with the two qubits it shares with a Z check.

关键想法Key idea

环面码里「所有检查两两对易」靠几何(角连两边);BB 码里靠代数(AB = BA 与 1 + 1 = 0)。代数不要求检查在空间上挨着,所以我们可以自由选择平移的方向和距离,把搜索的力气全花在 k 与 d 上。这一章证明了任何选择都合法;它们好不好,是下一章的事。

In the toric code “all checks commute” rests on geometry (a corner touches two edges); in BB codes it rests on algebra (AB = BA and 1 + 1 = 0). Algebra does not require checks to be spatially adjacent, so we may choose the translations' directions and distances freely and spend all the search effort on k and d. This chapter showed that every choice is legitimate; whether it is good is the next chapter's business.

检查站Checkpoint第 3 章Chapter 3
若把 Z 检查改成 HZ = [Aᵀ | Bᵀ](不交换),HXHZᵀ 等于什么?If the Z checks were HZ = [Aᵀ | Bᵀ] (no swap), what is HXHZᵀ?

对。[A | B]·[A ; B] = AA + BB = A² + B²。它一般不为零:l = 3、A = 1 + x、B = 1 时,A² + B² = (1 + 2x + x²) + 1 = x²(2x 在 GF(2) 里是 0)。只有特殊的选择(例如 A = B)才碰巧为零;要对任何 A、B 都对易,就得交换。

Right. [A | B]·[A ; B] = AA + BB = A² + B², which in general is not zero: for l = 3, A = 1 + x, B = 1 it is (1 + 2x + x²) + 1 = x² (2x is 0 in GF(2)). Only special choices such as A = B make it vanish by accident; to commute for every A and B, the swap is needed.

分块相乘:左块乘左块,右块乘右块,再相加。

Block multiplication: left block times left block, right times right, then add.

第 4 章Chapter 4

k 从哪里来:秩的亏损Where k comes from: the rank deficit

上一章保证了任何 A、B 都给出合法的码。可 gross 码的 k = 12 不是多项式项数的函数——同样的 A、B 换一个环面,k 会变成 8。这一章把 k 算清楚:它等于秩的亏损的两倍,而秩的亏损是一个商空间的维数。距离则要两份证书才算数。 The last chapter guaranteed that any A, B give a legitimate code. But the gross code's k = 12 is not a function of the number of terms — the same A, B on another torus give k = 8. This chapter pins k down: it is twice a rank deficit, and the rank deficit is the dimension of a quotient space. Distance, meanwhile, needs two certificates to count.

4.1两个秩相等,所以 k = 2 × 亏损The two ranks are equal, so k = 2 × deficit

按第 0 章②,k = n − rank HX − rank HZ = 2lm − rank[A | B] − rank[Bᵀ | Aᵀ]。两个秩其实相等:转置不改变秩,而 [Bᵀ | Aᵀ] 只是把所有平移倒过来的 [B | A]——把 x 换成 x−1、y 换成 y−1 是环上的一个「改名」,不改变任何维数;再把两块交换位置也不改变秩。所以 rank HZ = rank HX ≕ r,k = 2(lm − r)。lm − r 叫秩的亏损:lm 条 X 检查里有多少条是多余的。

By Chapter 0, ②, k = n − rank HX − rank HZ = 2lm − rank[A | B] − rank[Bᵀ | Aᵀ]. The two ranks are actually equal: transposition preserves rank, and [Bᵀ | Aᵀ] is just [B | A] with every translation reversed — replacing x by x−1 and y by y−1 is a “renaming” on the ring that changes no dimension; swapping the two blocks changes no rank either. So rank HZ = rank HX ≕ r and k = 2(lm − r). The number lm − r is the rank deficit: how many of the lm X checks are redundant.

k = 2lm − 2r = 2(lm − r)
gross: lm = 72, r = 66 ⇒ k = 2 × 6 = 12
toric_L3: lm = 9, r = 8 ⇒ k = 2

4.2亏损是一个商空间的维数The deficit is the dimension of a quotient

rank[A | B] 是什么?矩阵 [A | B] 把一对多项式 (u, v) 送到 uA + vB;它的像是所有能写成 uA + vB 的多项式,记作理想ideal:环里所有形如 uA + vB 的元素组成的集合;对加法封闭,乘任何环元素仍在其中。 (A, B),秩就是这个像的维数。剩下的那 lm − r 个维度,就是「把所有 uA + vB 当作零之后还剩什么」,记作R/(A,B)。gross 码里这个商空间是 6 维的。环面码 A = 1 + x、B = 1 + y 里它是 1 维的(只剩常数),对应环面码教程那条「∏A = I」的恒等式。于是 BB 码的设计问题变成了代数问题:选 A、B,让 (A, B) 尽量不占满整个环——占得越少,k 越大。

What is rank[A | B]? The matrix [A | B] sends a pair of polynomials (u, v) to uA + vB; its image is every polynomial expressible as uA + vB, written as the idealThe set of all ring elements of the form uA + vB; closed under addition and under multiplication by any ring element. (A, B), and the rank is this image's dimension. The remaining lm − r dimensions are “what is left after every uA + vB is declared zero”, written R/(A,B). For the gross code this quotient is 6-dimensional. For the toric code A = 1 + x, B = 1 + y it is 1-dimensional (only the constants survive), matching the toric tutorial's identity “∏A = I”. So the BB design problem becomes algebra: choose A, B so that (A, B) fills as little of the ring as possible — the less it fills, the larger k.

补课 · 理想、商空间与 dim,用例子讲Catch-up · Ideals, quotients and dim, by example
一、整数版的比方One: an analogy with integers

取两个整数 6 和 10,考虑所有能写成 6u + 10v 的数(u、v 任意整数):6, 10, 12, 16, 4 = 10 − 6, 2 = 16 − 14, …,结果是全体偶数。这个集合就叫 6 和 10 生成的理想,记 (6, 10)。「把所有 6u + 10v 当作零之后还剩什么」——就是 mod 2 的世界:所有偶数都算 0,整数只剩「奇/偶」两类,Z/(6, 10) 只有 2 个元素。换成 (3, 5):3u + 5v 能凑出 1 = 6 − 5,于是能凑出一切,理想占满整个 Z,商里只剩 1 个元素。「占得越少,剩的越多」——这就是那句「让 (A, B) 尽量不占满整个环」。

Take the integers 6 and 10 and consider every number of the form 6u + 10v (u, v any integers): 6, 10, 12, 16, 4 = 10 − 6, 2 = 16 − 14, … — all the even numbers. This set is the ideal generated by 6 and 10, written (6, 10). “What is left after every 6u + 10v is declared zero” is the world of mod 2: all even numbers count as 0, and the integers collapse to two classes, odd and even; Z/(6, 10) has 2 elements. Take (3, 5) instead: 3u + 5v reaches 1 = 6 − 5 and hence everything, the ideal fills all of Z, and the quotient has a single element. “The less it fills, the more is left” — that is the sentence “choose A, B so that (A, B) fills as little of the ring as possible”.

二、矩阵版:[A | B] 的像Two: the matrix version — the image of [A | B]

把 lm × 2lm 的矩阵 [A | B] 右乘一个长 2lm 的列向量,切成上下两半 (u ; v)(各长 lm),按分块乘法得 A·u + B·v。让 u、v 跑遍所有 0/1 向量,得到的全部结果叫这个矩阵的像,也就是它 2lm 根列向量的所有组合;像的维数就是秩(列秩 = 行秩)。用 2 × 2 的环面码算:HX = [A | B] 的 8 根列竖着读是 A 的列 (1 0 1 0)、(0 1 0 1)、(1 0 1 0)、(0 1 0 1) 和 B 的列 (1 1 0 0)、(1 1 0 0)、(0 0 1 1)、(0 0 1 1)。不同的只有四根:1010、0101、1100、0011,而 1010 + 0101 = 1111 = 1100 + 0011,有一条依赖,所以秩 = 3。把它们组合出来的向量全部列出:0000, 1010, 0101, 1100, 0011, 1111, 1001, 0110——恰好是长度 4 的全部 8 个偶重量向量;任何奇重量向量(如 1000)永远到不了。4 维空间里像占了 3 维,差的那 1 维就是「商空间」:lm − r = 4 − 3 = 1,k = 2 × 1 = 2,正是 [[8,2,2]]。

Multiply the lm × 2lm matrix [A | B] on the right by a column vector of length 2lm, cut into halves (u ; v) (each of length lm); block multiplication gives A·u + B·v. Letting u and v range over all 0/1 vectors, the set of results is the matrix’s image, i.e. all combinations of its 2lm columns; the dimension of the image is the rank (column rank = row rank). For the 2 × 2 toric code: the 8 columns of HX = [A | B], read downward, are the columns of A, (1 0 1 0), (0 1 0 1), (1 0 1 0), (0 1 0 1), and of B, (1 1 0 0), (1 1 0 0), (0 0 1 1), (0 0 1 1). Only four are distinct — 1010, 0101, 1100, 0011 — and 1010 + 0101 = 1111 = 1100 + 0011, one dependency, so the rank is 3. Listing every combination: 0000, 1010, 0101, 1100, 0011, 1111, 1001, 0110 — exactly the 8 even-weight vectors of length 4; no odd-weight vector (such as 1000) is ever reached. The image fills 3 of the 4 dimensions, and the missing one is the “quotient”: lm − r = 4 − 3 = 1, k = 2 × 1 = 2, which is [[8,2,2]].

三、翻译成多项式,就是 4.2 那段话Three: translated into polynomials, this is §4.2

长 lm 的向量和多项式一一对应:格子 (i, j) 上的分量就是 xiyj 的系数,(1 0 1 0) ↔ 1 + x,(1 1 1 1) ↔ 1 + x + y + xy。2.3 说过这套翻译保持乘法,所以矩阵乘向量 A·u 就是多项式乘法 A·u,「像 = 所有 Au + Bv」翻译成「理想 (A, B) = 所有 uA + vB」。对 A = 1 + x、B = 1 + y 它是什么?u(1 + x) = u + xu,项数是偶数(相消也是成对消),所以理想里全是偶数项的多项式——和上面的偶重量向量完全对应。再看商 R/(A, B):「把所有 uA + vB 当作零」,最起码 1 + x ≡ 0、1 + y ≡ 0,即 x ≡ 1、y ≡ 1。那么任何单项式 xayb ≡ 1,任何多项式 ≡ 它的项数 mod 2,只可能是 0 或 1。整个 lm 维的环被压成了 {0, 1}:只剩常数,维数 1。它和 ∏A = I 的联系:像里全是偶重量 ⇔ 存在一个对所有列都成立的奇偶约束 ⇔ HX 的所有行加起来是零行 ⇔ 全部星形检查乘起来是 I。lm 条检查里恰有 1 条多余,秩亏损 1,商空间 1 维——同一件事的三种口气。

Vectors of length lm correspond one-to-one to polynomials: the component at site (i, j) is the coefficient of xiyj, so (1 0 1 0) ↔ 1 + x and (1 1 1 1) ↔ 1 + x + y + xy. Since §2.3 showed the translation respects multiplication, the matrix–vector product A·u is the polynomial product A·u, and “image = all Au + Bv” becomes “the ideal (A, B) = all uA + vB”. What is it for A = 1 + x, B = 1 + y? u(1 + x) = u + xu has an even number of terms (cancellations come in pairs), so the ideal consists of the even-term polynomials — matching the even-weight vectors above. Now the quotient R/(A, B): “declare every uA + vB zero”, so at the least 1 + x ≡ 0 and 1 + y ≡ 0, i.e. x ≡ 1 and y ≡ 1. Then every monomial xayb ≡ 1 and every polynomial ≡ its number of terms mod 2, either 0 or 1. The whole lm-dimensional ring is squeezed to {0, 1}: only the constants remain, dimension 1. Its link to ∏A = I: the image is all even-weight ⇔ one parity constraint holds for every column ⇔ the rows of HX sum to the zero row ⇔ all the star checks multiply to I. Exactly 1 of the lm checks is redundant, rank deficit 1, quotient of dimension 1 — three ways of saying one thing.

四、一个「占得更少」的例子Four: an example that fills less

用一维的环 x⁴ = 1(4 个格子),比较两个生成元。(1 + x):u(1 + x) 是全部偶数项多项式,4 维里占 3 维,商 1 维;矩阵上 I + S 的四行 1100、0110、0011、1001 秩为 3。(1 + x²):因为 (1 + x²)² = 1 + x⁴ = 1 + 1 = 0,倍数只有 {0, 1 + x², x + x³, 1 + x + x² + x³},占 2 维,商 2 维;矩阵上 I + S² 的四行是 1010、0101、1010、0101,秩只有 2。同样是两项的多项式,一个占 3 维、一个占 2 维——项数决定检查重量,不决定秩,正是 4.3 那句「三项不决定 k」。回到 gross:环 R 是 72 维(12 × 6 个格子),理想 (A, B) 占 66 维(rank HX = 66),商 R/(A, B) 是 6 维:把所有 uA + vB 当作零后,72 维的多项式空间被压成 2⁶ = 64 个「剩余类」,而不是环面码的 2 个。对应地,72 条 X 检查里有 6 条多余(6 组乘起来等于 I 的组合),秩亏损 6,k = 2 × 6 = 12。「设计 BB 码」就是在挑 A、B,让 uA + vB 凑不出的东西尽量多——但也不能多到 d 塌掉,那是 4.3、4.4 的另一半故事。

On the one-dimensional ring x⁴ = 1 (4 sites), compare two generators. (1 + x): u(1 + x) runs over all even-term polynomials, filling 3 of 4 dimensions, quotient of dimension 1; the four rows 1100, 0110, 0011, 1001 of I + S have rank 3. (1 + x²): since (1 + x²)² = 1 + x⁴ = 1 + 1 = 0, its multiples are only {0, 1 + x², x + x³, 1 + x + x² + x³}, filling 2 dimensions, quotient of dimension 2; the rows 1010, 0101, 1010, 0101 of I + S² have rank only 2. Two two-term polynomials, one filling 3 dimensions and the other 2 — the number of terms fixes the check weight, not the rank, which is the “three terms do not determine k” of §4.3. Back to gross: the ring R has 72 dimensions (12 × 6 sites), the ideal (A, B) fills 66 (rank HX = 66), and the quotient R/(A, B) has 6: once every uA + vB is declared zero, the 72-dimensional space of polynomials is squeezed to 2⁶ = 64 “residue classes”, not the toric code’s 2. Correspondingly 6 of the 72 X checks are redundant (6 combinations multiplying to I), rank deficit 6, k = 2 × 6 = 12. “Designing a BB code” means choosing A and B so that as much as possible cannot be assembled from uA + vB — but not so much that d collapses, the other half of the story in §4.3 and §4.4.

五、dim 是什么,它和 rank 有什么区别Five: what dim is, and how it differs from rank

dim 读作「维数」,dim V 是线性空间 V 的维数:里面最多能挑出几个线性独立的向量,或者说,需要几个独立的 0/1 坐标才能唯一确定一个元素。在 GF(2) 上有一个很直接的数法:d 维空间恰好有 2d 个元素——d 维就是「d 个比特能存的东西」。对号:GF(2)⁴ 有 16 个元素,dim = 4;其中偶重量向量 8 个,dim = 3,一组基是 1100、0110、0011;商空间 GF(2)⁴/(偶重量) 把相差偶重量向量的两个向量算作同一个,16 个只剩「偶」「奇」两类,2 = 2¹,dim = 1。商的维数不用真的构造商,一减就行:dim(商) = dim(整体) − dim(被当作零的子空间),这就是「秩亏损」dim R/(A, B) = lm − rank[A | B]。

dim is read “dimension”; dim V is the dimension of a linear space V: the largest number of linearly independent vectors it contains, or equivalently how many independent 0/1 coordinates are needed to pin down an element. Over GF(2) there is a direct way to count: a d-dimensional space has exactly 2d elements — d dimensions is “what d bits can store”. Matching up: GF(2)⁴ has 16 elements, dim = 4; its even-weight vectors number 8, dim = 3, with basis 1100, 0110, 0011 for instance; the quotient GF(2)⁴/(even weight) identifies two vectors that differ by an even-weight vector, leaving only the classes “even” and “odd”, 2 = 2¹, dim = 1. The dimension of a quotient needs no construction, just a subtraction: dim(quotient) = dim(whole) − dim(subspace declared zero), which is the “rank deficit” dim R/(A, B) = lm − rank[A | B].

dim 和 rank 很接近,但不是一回事:rank 是矩阵的属性,dim 是空间的属性。rank M 定义为 M 的行空间(= 列空间 = 像)的维数,所以秩是「某一个特定空间的 dim」;反过来,很多空间的 dim 不是哪个矩阵的秩——整个空间 GF(2)⁴ 的 dim 是 4,这里没有矩阵;核 {v : Mv = 0} 的 dim = 列数 − rank M(秩–零化度定理);商空间的 dim = 4 − 秩。公式 k = 2·dim R/(A, B) 里的 dim 恰恰不是秩,而是秩亏损 lm − rank[A | B];用秩写同一件事就是 4.1 的 k = 2(lm − r)。一个数「占了多少」(秩),一个数「剩了多少」(商的维数)。一句话记法:dim 是通用词,问任何一个线性空间「你有几维」;rank 是把这个问题专门问矩阵的像时的专用名词。

dim and rank are close but not the same: rank is a property of a matrix, dim a property of a space. rank M is defined as the dimension of M’s row space (= column space = image), so a rank is “the dim of one particular space”; conversely many dims are not the rank of anything — the whole space GF(2)⁴ has dim 4 with no matrix in sight; the kernel {v : Mv = 0} has dim = number of columns − rank M (rank–nullity); the quotient has dim = 4 − rank. The dim in k = 2·dim R/(A, B) is precisely not a rank but the deficit lm − rank[A | B]; written with ranks, the same statement is the k = 2(lm − r) of §4.1. One counts “how much is taken” (rank), the other “how much is left” (the quotient’s dimension). A mnemonic: dim is the general word, asking any linear space “how many dimensions have you”; rank is that question asked specifically of a matrix’s image.

4.3三项不决定 kThree terms do not determine k

项数只决定检查重量,不决定秩。最直接的证据:gross 与 [[108,8,10]] 用完全相同的 A = x³ + y + y²、B = y³ + x + x²,前者在 12 × 6 的环面上 k = 12,后者在 9 × 6 上 k = 8(第 5 章)。指数的选择也一样敏感。下面的实验台预设为 [[72,12,6]],按「随机改一个指数」几次,看 k 怎样跳动——大多数扰动会让 k 掉到 0 或 2,偶尔跳到更大的值但距离通常塌掉。Bravyi 等人的 Table 3 是在这片崎岖的地形上搜出来的几个高点。

The number of terms fixes the check weight, not the rank. The most direct evidence: gross and [[108,8,10]] use exactly the same A = x³ + y + y², B = y³ + x + x², yet the former has k = 12 on a 12 × 6 torus and the latter k = 8 on 9 × 6 (Ch. 5). The choice of exponents is just as sensitive. The bench below is preset to [[72,12,6]]; press “Perturb one exponent” a few times and watch k jump — most perturbations drop k to 0 or 2, some jump higher while the distance usually collapses. Bravyi et al.'s Table 3 is a handful of peaks found by searching this rugged terrain.

4.4距离:两份证书Distance: two certificates

n 和 k 由秩一算便知,d 难得多。按环面码教程的定义,X 逻辑算符是「与所有 Z 检查对易、但不是 X 检查乘积」的 X 串:矩阵语言里,就是 HZv = 0 的解 v 里不属于 HX 行空间的那些;d 是其中最轻者的重量(Z 一侧同理)。要说 d = 12 需要两件事:下界——证明重量小于 12 的逻辑算符不存在;上界——找出一个重量恰为 12 的逻辑算符。对 gross 码,下界来自 Bravyi 等人的论文,上界由 QEC-Bank 的随机搜索(种子 5,2000 次)复现;两者相符,所以记 d = 12,证据等级标为「bounded」而不是「verified」——因为下界那一半 QEC-Bank 没有自己重算。本页的搜索更弱:几秒钟只能把 gross 压到 16 左右,但对 toric_L3、bb5 这样的小码可以穷举出精确值。回到上面的实验台按「搜索低重逻辑算符」:预设 [[72,12,6]] 通常能找到重量 6,与文献的 d = 6 相符——这也只是上界与声称相符,不是证明。

n and k fall out of a rank; d is much harder. By the toric tutorial's definition an X-logical is an X-string that commutes with every Z check yet is not a product of X checks: in matrix language, a solution v of HZv = 0 outside the row space of HX; d is the weight of the lightest such v (likewise on the Z side). Asserting d = 12 needs two things: a lower bound — a proof that no logical of weight below 12 exists — and an upper bound — an explicit logical of weight exactly 12. For gross, the lower bound comes from Bravyi et al.'s paper and the upper bound is reproduced by the QEC-Bank's random search (seed 5, 2000 iterations); they meet, so d = 12 is recorded with evidence grade “bounded” rather than “verified”, because the QEC-Bank has not recomputed the lower half itself. This page's search is weaker: in a few seconds it only pushes gross down to about 16, though for small codes such as toric_L3 and bb5 it enumerates the exact value. Return to the bench above and press “Search a low-weight logical”: the [[72,12,6]] preset usually finds weight 6, agreeing with the literature's d = 6 — which is again an upper bound matching a claim, not a proof.

补课 · 逻辑算符是什么、码距 d 是什么,以及「测」与「作用」的区别Catch-up · What a logical operator is, what d is, and measuring versus applying

把定义拆成三块:「X 串」「与所有 Z 检查对易」「不是 X 检查乘积」。X 串就是在若干比特上各放一个 X 再乘起来的算符 X(v),v 是标出哪些比特的 0/1 向量——和 X 检查是同一种形状的东西,只是不一定是检查。「与所有 Z 检查对易」= 不触发任何警报。若 X(v) 与某条 Z 检查 S 反对易,则对任何码态 |ψ⟩(S|ψ⟩ = |ψ⟩)有 S·X(v)|ψ⟩ = −X(v)·S|ψ⟩ = −X(v)|ψ⟩:作用之后的态在 S 上测出 −1,警报响了,这是一个能被发现的错误。反过来,若 X(v) 与所有 Z 检查都对易,作用后所有检查仍给 +1——它把码态送到码态,纠错系统对它完全无感(X 串与 X 检查永远对易,所以只需看 Z 检查)。矩阵语言:HZ·v = 0 (mod 2),v 在 HZ 的核里。「不是 X 检查乘积」= 排除白干的。若 X(v) 恰好等于几条 X 检查的乘积(v 是 HX 若干行 mod 2 之和,在行空间里),它对每个码态什么都不做:每条检查 S 都有 S|ψ⟩ = |ψ⟩,乘积也一样。它「不被发现」,但也没改动任何编码信息——是稳定子,不算逻辑算符。两条合起来:X 逻辑算符 = 不被任何检查发现、却真的把某个码态变成了另一个码态的 X 串。这正是「骗过全部检查的错误」,同时也是我们操作逻辑比特的工具——同一个东西的两张面孔。

Split the definition into three pieces: “X string”, “commutes with every Z check”, “not a product of X checks”. An X string is an operator X(v) made by placing an X on each of some qubits and multiplying, v the 0/1 vector marking which — the same shape of object as an X check, just not necessarily a check. “Commutes with every Z check” = raises no alarm. If X(v) anticommuted with some Z check S, then for every code state |ψ⟩ (S|ψ⟩ = |ψ⟩) we would have S·X(v)|ψ⟩ = −X(v)·S|ψ⟩ = −X(v)|ψ⟩: the state after the operation reads −1 on S, an alarm, a detectable error. Conversely, if X(v) commutes with every Z check, all checks still read +1 afterwards — it maps code states to code states and the correction system is blind to it (X strings always commute with X checks, so only the Z checks matter). In matrix terms HZ·v = 0 (mod 2): v lies in the kernel of HZ. “Not a product of X checks” = excluding the do-nothings. If X(v) happens to equal a product of X checks (v a mod-2 sum of rows of HX, in its row space), it does nothing to any code state: every check S has S|ψ⟩ = |ψ⟩ and so does the product. It “goes undetected” but also alters no encoded information — a stabilizer, not a logical operator. Together: an X logical operator is an X string that no check detects yet which really turns some code state into another. That is exactly “an error that fools every check”, and at the same time the tool with which we manipulate logical qubits — two faces of one object.

用 [[4,2,2]] 把三类 X 串各举一个Three kinds of X string in [[4,2,2]]

HX = HZ = (1 1 1 1),码空间由四个态张成:|0000⟩+|1111⟩、|0011⟩+|1100⟩、|0101⟩+|1010⟩、|0110⟩+|1001⟩(补课 0.D)。X₁(v = 1000):与 Z₁Z₂Z₃Z₄ 共享 1 个比特,反对易。它把 |0000⟩+|1111⟩ 变成 |1000⟩+|0111⟩,每个串奇数个 1,Z 检查测出 −1。可发现的错误。X₁X₂X₃X₄(v = 1111):对易,但它本身就是 X 检查,把 |0000⟩+|1111⟩ 变成 |1111⟩+|0000⟩——同一个态。白干,是稳定子。X₁X₂(v = 1100):与 Z₁Z₂Z₃Z₄ 共享 2 个比特,对易;1100 不是 (1111) 的倍数,不在行空间里。它把 |0000⟩+|1111⟩ 变成 |1100⟩+|0011⟩——第二个码态。没有任何警报,编码信息却被改写了。这就是一个 X 逻辑算符,重量 2。

HX = HZ = (1 1 1 1); the code space is spanned by |0000⟩+|1111⟩, |0011⟩+|1100⟩, |0101⟩+|1010⟩, |0110⟩+|1001⟩ (Catch-up 0.D). X₁ (v = 1000): shares 1 qubit with Z₁Z₂Z₃Z₄, anticommutes. It turns |0000⟩+|1111⟩ into |1000⟩+|0111⟩, each string with an odd number of 1s, and the Z check reads −1. A detectable error. X₁X₂X₃X₄ (v = 1111): commutes, but it is the X check itself; it turns |0000⟩+|1111⟩ into |1111⟩+|0000⟩ — the same state. A do-nothing, a stabilizer. X₁X₂ (v = 1100): shares 2 qubits with Z₁Z₂Z₃Z₄, commutes; 1100 is not a multiple of (1111), so it is outside the row space. It turns |0000⟩+|1111⟩ into |1100⟩+|0011⟩ — the second code state. No alarm anywhere, yet the encoded information has been rewritten. That is an X logical operator, of weight 2.

用向量说:HZ 的核是全部 8 个偶重量向量;HX 的行空间是 {0000, 1111};逻辑 X 就是核里去掉行空间剩下的 6 个:1100, 0011, 1010, 0101, 1001, 0110。X₃X₄ 把 |0000⟩+|1111⟩ 也变成 |0011⟩+|1100⟩,和 X₁X₂ 效果相同——两者只差一个稳定子 X₁X₂X₃X₄。所以逻辑算符是「按稳定子分类」来数的:6 个向量分成 3 类 {1100, 0011}、{1010, 0101}、{1001, 0110},正好是 2 个逻辑比特上非平凡 X 型算符的个数 2² − 1 = 3;核的维数 3 减去行空间的维数 1,等于 k = 2。4.4「学名一瞥」里的「核减去像 = 同调」,说的就是「对易的减去白干的」。

In vectors: the kernel of HZ is all 8 even-weight vectors; the row space of HX is {0000, 1111}; the logical Xs are the 6 left when the row space is removed from the kernel: 1100, 0011, 1010, 0101, 1001, 0110. X₃X₄ also turns |0000⟩+|1111⟩ into |0011⟩+|1100⟩, the same effect as X₁X₂ — the two differ only by the stabilizer X₁X₂X₃X₄. Logical operators are therefore counted “up to stabilizers”: the 6 vectors fall into 3 classes {1100, 0011}, {1010, 0101}, {1001, 0110}, exactly the 2² − 1 = 3 nontrivial X-type operators on 2 logical qubits; the kernel’s dimension 3 minus the row space’s dimension 1 equals k = 2. The “kernel minus image = homology” of the scholarly aside in §4.4 is “the commuting ones minus the do-nothings”.

「X(v) 是检查的乘积」的三种读法Three readings of “X(v) is a product of checks”

数学条件只有一句:v 在 HX 的行空间里。看你把 X(v) 当作什么,它有三种读法。当作一条检查去测:它的结果一定等于那几条检查结果的乘积(Z₁Z₃ 的值 = Z₁Z₂ 的值 × Z₂Z₃ 的值),在码态上必然是 +1;把它加进检查表,秩不增加,它就是一条不独立的检查——「可以由其他检查的结果算出来」。当作一个操作施加在码态上:X(v)|ψ⟩ = |ψ⟩,对编码信息什么都没做,这是 4.4 排除它的理由。当作一个错误:发生了等于没发生,不用纠;两个只差一个稳定子的错误(X₁X₂ 与 X₃X₄)症状相同、效果相同,译码器不必分辨——这就是 6.3 说的量子码的「退化」。所以「检查不独立」和「X 串是检查乘积」是同一个代数事实的两张脸;只有一点措辞要小心:4.4 里的 X(v) 本来不是一条检查,而是任意一个候选的 X 串,「它恰好等于几条检查的乘积」是在判定它平凡。

The mathematical condition is one sentence: v lies in the row space of HX. Depending on what you take X(v) to be, it reads three ways. As a check to measure: its outcome always equals the product of those checks’ outcomes (the value of Z₁Z₃ = the value of Z₁Z₂ × that of Z₂Z₃), necessarily +1 on a code state; adding it to the check table leaves the rank unchanged, so it is a dependent check — “computable from the other checks’ results”. As an operation applied to a code state: X(v)|ψ⟩ = |ψ⟩, it does nothing to the encoded information, which is why §4.4 excludes it. As an error: it might as well not have happened and needs no correction; two errors differing by a stabilizer (X₁X₂ and X₃X₄) have the same syndrome and the same effect, and the decoder need not tell them apart — the “degeneracy” of quantum codes mentioned in §6.3. So “a dependent check” and “an X string that is a product of checks” are two faces of one algebraic fact; the only care needed is in wording: the X(v) of §4.4 is not a check to begin with but an arbitrary candidate X string, and “it happens to equal a product of checks” is the verdict that it is trivial.

X₁·Z₁Z₂Z₃Z₄ = Z₁Z₂Z₃Z₄·X₁ 成立吗?Does X₁·Z₁Z₂Z₃Z₄ = Z₁Z₂Z₃Z₄·X₁ hold?

不成立,差一个负号:X₁Z₁Z₂Z₃Z₄ = −Z₁Z₂Z₃Z₄X₁。把 X₁ 从左边挪到右边:越过 Z₂、Z₃、Z₄ 免费(不同比特),越过 Z₁ 付一个 −1(同一比特上 XZ = −ZX,补课 0.C 的 2 × 2 矩阵)。这个负号就是「可发现」的全部内容:S = Z₁Z₂Z₃Z₄,|ψ⟩ = |0000⟩ + |1111⟩,S|ψ⟩ = |ψ⟩;出错后 X₁|ψ⟩ = |1000⟩ + |0111⟩,S·X₁|ψ⟩ = −X₁·S|ψ⟩ = −X₁|ψ⟩,新状态是 S 的 −1 本征态,测量必然得 −1。对比 X₁X₂:越过 Z₁、Z₂ 各付一个 −1,(−1)² = +1,对易;作用后得到 |1100⟩ + |0011⟩,每个串仍是偶数个 1,S 测出 +1,没有警报。

It does not — there is a sign: X₁Z₁Z₂Z₃Z₄ = −Z₁Z₂Z₃Z₄X₁. Move X₁ from the left to the right: passing Z₂, Z₃, Z₄ is free (different qubits), passing Z₁ costs one −1 (XZ = −ZX on the same qubit, the 2 × 2 matrices of Catch-up 0.C). That sign is the whole content of “detectable”: with S = Z₁Z₂Z₃Z₄ and |ψ⟩ = |0000⟩ + |1111⟩, S|ψ⟩ = |ψ⟩; after the error, X₁|ψ⟩ = |1000⟩ + |0111⟩ and S·X₁|ψ⟩ = −X₁·S|ψ⟩ = −X₁|ψ⟩, a −1 eigenstate of S, so the measurement must give −1. Compare X₁X₂: passing Z₁ and Z₂ costs −1 each, (−1)² = +1, commuting; the result |1100⟩ + |0011⟩ still has an even number of 1s in each string, S reads +1, no alarm.

「测」一个算符与「作用」一个算符不是一回事Measuring an operator and applying it are different things

测检查 Z₁Z₂Z₃Z₄:码态不变。码态是它的 +1 本征态,−1 分支为零(P₋|ψ⟩ = 0),结果必然 +1,测完的状态还是 |ψ⟩——这是检查这个设计的全部意义:每一轮都测、反复测,编码信息毫发无损;只有错误已经发生时,测量才把态投影到「没错」或「错了」两种干脆的情形之一(补课 0.B)。X₁X₂ 不是检查,纠错过程中没有人去「做」它。它以两种身份出现:错误——比特 1、2 碰巧同时翻了,Z 检查毫无察觉而信息被改写,这正是 d = 2 的码脆弱的地方;或有意施加的逻辑门——我们想对逻辑比特做一次 X̄,就故意在比特 1、2 上各做一个 X。即便把检查算符当作门去作用,码态也不变:S|ψ⟩ = |ψ⟩ 说的就是这个。反过来若去测 X₁X₂:它与所有检查对易,不会把态踢出码空间,但它是逻辑算符,测它就是读出逻辑比特的值,会把逻辑叠加 α|0̄⟩ + β|1̄⟩ 塌到一边——这是逻辑测量,不是检查。

Measuring the check Z₁Z₂Z₃Z₄ leaves the code state alone. The code state is a +1 eigenstate, its −1 part is zero (P₋|ψ⟩ = 0), the outcome is certainly +1 and the state afterwards is still |ψ⟩ — the whole point of the design: measure every round, over and over, and the encoded information is untouched; only once an error has occurred does the measurement project the state onto one of the clean cases “no error” or “error” (Catch-up 0.B). X₁X₂ is not a check, and nobody “performs” it during error correction. It appears in two guises: as an error — qubits 1 and 2 happen to flip together, the Z checks notice nothing and the information is rewritten, exactly the weakness of a d = 2 code; or as a deliberate logical gate — to apply X̄ to the logical qubit, one applies an X to qubits 1 and 2 on purpose. Even applying a check operator as a gate leaves the code state unchanged: that is what S|ψ⟩ = |ψ⟩ says. Conversely, measuring X₁X₂: it commutes with every check, so it does not kick the state out of the code space, but it is a logical operator, and measuring it reads out the logical value, collapsing a logical superposition α|0̄⟩ + β|1̄⟩ to one side — a logical measurement, not a check.

对象object测量它measure it作用它(当作门或错误)apply it (as a gate or an error)
检查 S(如 Z₁Z₂Z₃Z₄)a check S (e.g. Z₁Z₂Z₃Z₄)码态不变,结果 +1;有错时给 −1 并投影code state unchanged, outcome +1; after an error, −1 and a projection码态不变code state unchanged
逻辑算符(如 X₁X₂)a logical operator (e.g. X₁X₂)读出逻辑值,破坏逻辑叠加reads out the logical value, destroys logical superposition码态 → 另一个码态,检查无感code state → another code state, checks see nothing
可发现的错误(如 X₁)a detectable error (e.g. X₁)—跳出码空间,下一轮检查报警leaves the code space; the next round of checks alarms
码距 d:最少动几个比特能骗过全部检查The distance d: the fewest qubits that fool every check

把上面的话倒过来问:最少在几个比特上放 X,能让所有 Z 检查查不出来、却改变了码态?这就是 X 码距 dX——满足 HZ·v = 0 且 v 不在 HX 行空间里的 X 串中重量最小者的重量。「不是检查乘积」这一条不能省,因为有些查不出来的 X 串根本没改码态(X₁X₂X₃X₄)。同样定义 Z 码距 dZ:最少放几个 Z,X 检查查不出来却改了码态。整个码的 d = min(dX, dZ)。几个数字:[[4,2,2]] 里 X₁X₂ 就够,d = 2;L × L 环面码要沿环面绕一整圈放 L 个 X(一条不可收缩的闭合回路),d = L;gross 码 d = 12:任何 11 个以内的 X(或 Z)要么触发警报、要么白干,静悄悄地改写信息至少得动 12 个比特。

Turn the statement around: what is the smallest number of qubits on which one can place Xs so that no Z check notices, yet the code state changes? That is the X distance dX — the least weight of an X string with HZ·v = 0 and v outside the row space of HX. The clause “not a product of checks” cannot be dropped, because some undetectable X strings change nothing at all (X₁X₂X₃X₄). The Z distance dZ is defined the same way: the fewest Zs that the X checks miss yet which alter the code state. The code’s distance is d = min(dX, dZ). Some numbers: in [[4,2,2]] X₁X₂ suffices, d = 2; the L × L toric code needs L Xs all the way round the torus (a non-contractible closed loop), d = L; the gross code has d = 12: any 11 or fewer Xs (or Zs) either trip an alarm or do nothing, and rewriting the information silently takes at least 12 qubits.

d 直接换算成纠错能力。能发现的错误重量上限是 d − 1(任何更轻的错误都会报警或无害);能纠正的上限是 ⌊(d − 1)/2⌋:两个重量 ≤ t 的错误若症状相同,它们的「差」是一个重量 ≤ 2t 的、不被发现的算符,只要 2t < d,这个差就只能是无害的稳定子,译码器猜哪一个都对。所以 d = 2 的 [[4,2,2]] 能发现 1 个错误、纠正 0 个(L0 与 R2 那类孪生比特上的错误症状相同,猜错就成了逻辑算符——2.4.2);d = 12 的 gross 能发现 11 个、保证纠正任意 5 个(实际译码器平均能纠更多,保证值是 5)。

d converts directly into correcting power. The largest error weight that is always detected is d − 1 (anything lighter either alarms or is harmless); the largest always corrected is ⌊(d − 1)/2⌋: if two errors of weight ≤ t have the same syndrome, their “difference” is an undetected operator of weight ≤ 2t, and as long as 2t < d that difference can only be a harmless stabilizer, so the decoder is right whichever it guesses. Hence [[4,2,2]] with d = 2 detects 1 error and corrects 0 (errors on twin qubits such as L0 and R2 share a syndrome, and a wrong guess becomes a logical operator — §2.4.2); gross with d = 12 detects 11 and is guaranteed to correct any 5 (real decoders correct more on average; 5 is the guarantee).

补课 · 为什么 d 的下界难算(10¹⁶ 是怎么来的)Catch-up · Why the lower bound on d is hard (where the 10¹⁶ comes from)

因为上界和下界是两种不同类型的命题,难度天差地别。上界是「存在」命题。要证 d ≤ 12,只需拿出一个重量 12 的合格 X 串(或 Z 串):验证它很便宜——一次矩阵乘向量看 HZ·v = 0,一次高斯消元看 v 不在 HX 的行空间里,几毫秒。找这个见证可以用任何启发式:随机搜,或者把 BP-OSD 当作「找最轻解」的工具去跑(Bravyi 等人对大码就是这么给上界的)。运气好就找到,找到就算数。下界是「全称」命题。要证 d ≥ 12,得证明重量 1 到 11 的所有 X 串和 Z 串里没有一个合格——不是找一个东西,而是排除所有东西。

Because the two bounds are different kinds of statement, worlds apart in difficulty. An upper bound is an “exists” statement. To show d ≤ 12 one need only produce one qualifying X string (or Z string) of weight 12, and checking it is cheap — one matrix–vector product to see HZ·v = 0, one Gaussian elimination to see that v is outside the row space of HX, milliseconds. Finding the witness may use any heuristic: random search, or BP-OSD run as a “find the lightest solution” tool (which is how Bravyi et al. bound the larger codes). Luck helps, and a find counts. A lower bound is a “for all” statement. To show d ≥ 12 one must prove that among all X and Z strings of weight 1 through 11 none qualifies — not finding one thing but excluding everything.

排除多少东西?144 个位置里挑 w 个放 1,有 C(144, w) = 144!/(w!·(144−w)!) 种挑法,把 w = 1 到 11 加起来:

How much must be excluded? Choosing w of 144 positions for the 1s can be done in C(144, w) = 144!/(w!·(144−w)!) ways; summing w = 1 to 11:

重量weight组合数binomial精确值exact
w = 1C(144, 1)144≈ 1.44e+02
w = 2C(144, 2)10 296≈ 1.03e+04
w = 3C(144, 3)487 344≈ 4.87e+05
w = 4C(144, 4)17 178 876≈ 1.72e+07
w = 5C(144, 5)481 008 528≈ 4.81e+08
w = 6C(144, 6)11 143 364 232≈ 1.11e+10
w = 7C(144, 7)219 683 466 288≈ 2.20e+11
w = 8C(144, 8)3 762 079 360 182≈ 3.76e+12
w = 9C(144, 9)56 849 199 220 528≈ 5.68e+13
w = 10C(144, 10)767 464 189 477 128≈ 7.67e+14
w = 11C(144, 11)9 349 109 217 266 832≈ 9.35e+15
合计totalΣw=1..1110 177 416 010 840 378≈ 1.02e+16

每往上一格重量,个数约乘 (144 − w)/w ≈ 12 倍,总和几乎全由最后一项贡献。不用计算器也能估:C(144, 11) ≈ 144¹¹/11! 再乘一个修正——144¹¹ = 1.44¹¹ × 10²² ≈ 55 × 10²²,11! ≈ 4.0 × 10⁷,相除约 1.4 × 10¹⁶,修正因子 ∏(1 − i/144)(i = 0…10)≈ e−55/144 ≈ 0.68,得约 9 × 10¹⁵,与精确值吻合。换个思路只在 HZ 的核里找也不行:核的维数是 144 − 66 = 78,共 2⁷⁸ ≈ 3 × 10²³ 个向量,比按重量枚举还糟,因为核里绝大多数向量重量很大、根本不是候选。bb5 之所以能「穷举验证」,是因为它的核只有 2¹⁷ = 131 072 个向量,几秒扫完;gross 差了 18 个数量级。换成时间感受:就算每秒校验 10⁹ 个串,10¹⁶ 个也要三百多年;13 万个不到一毫秒。这就是「小码能穷举、gross 不能」的分界线。

Each step up in weight multiplies the count by about (144 − w)/w ≈ 12, so the sum is almost all the last term. It can be estimated without a calculator: C(144, 11) ≈ 144¹¹/11! times a correction — 144¹¹ = 1.44¹¹ × 10²² ≈ 55 × 10²², 11! ≈ 4.0 × 10⁷, quotient about 1.4 × 10¹⁶, correction factor ∏(1 − i/144) (i = 0…10) ≈ e−55/144 ≈ 0.68, giving about 9 × 10¹⁵, matching the exact value. Searching only inside the kernel of HZ is no better: the kernel has dimension 144 − 66 = 78, hence 2⁷⁸ ≈ 3 × 10²³ vectors — worse than enumerating by weight, since most kernel vectors are heavy and no candidates at all. bb5 can be “verified by exhaustion” because its kernel has only 2¹⁷ = 131 072 vectors, scanned in seconds; gross is 18 orders of magnitude away. As a feeling for time: even at 10⁹ string checks per second, 10¹⁶ strings take over three hundred years; 130 thousand take under a millisecond. That is the line between “small codes can be exhausted” and “gross cannot”.

量子码还多一层麻烦:退化。我们要的不是「核里最轻的向量」,而是「核里不在行空间中的最轻向量」。核里最轻的往往就是稳定子本身——gross 的检查重量只有 6,比 d = 12 轻得多,随手找到的轻向量全是白干的检查乘积,必须在每个非平凡的类里去找最轻代表,经典编码里的最小距离算法要为此改造。它本质上是困难问题。经典线性码的最小距离问题是 NP 困难的(Vardy, 1997);量子码把经典情形当特例包含在内——取 HX = 0 的 CSS 码,X 码距就等于 ker HZ 这个经典码的最小距离——所以至少一样难。这不是「算法还不够聪明」,而是目前没有理由相信存在多项式时间的通用算法。对比 n 和 k:一次高斯消元,n³ 级别,秒出。

Quantum codes add a further nuisance: degeneracy. What is wanted is not “the lightest vector in the kernel” but “the lightest vector in the kernel outside the row space”. The lightest kernel vectors are usually the stabilizers themselves — gross’s checks have weight only 6, far below d = 12, so any light vector found casually is a do-nothing product of checks, and one must look for the lightest representative inside each nontrivial class; classical minimum-distance algorithms have to be adapted for this. The problem is intrinsically hard. Computing the minimum distance of a classical linear code is NP-hard (Vardy, 1997), and quantum codes contain the classical case as a special case — a CSS code with HX = 0 has X distance equal to the minimum distance of the classical code ker HZ — so they are at least as hard. It is not that the algorithms are not clever enough; there is currently no reason to believe a general polynomial-time algorithm exists. Compare n and k: one Gaussian elimination, of order n³, done in a second.

那下界实际是怎么来的?三条路。其一,小码穷举(bb5 的 verified)。其二,几何论证:环面码的逻辑算符必须绕环面一整圈,长度自然 ≥ L,一句话就是下界——但 BB 码的检查伸到几格之外又绕过环面,没有这样的图像可用。其三,精确的组合搜索:Bravyi 等人在论文里说明,Table 3 的码距是用混合整数规划(MIP)算出来的——把「最小重量」写成整数优化问题,交给求解器做带剪枝的穷举;对 [[144,12,12]] 这个规模能算完,对 [[360,12,≤24]] 和 [[756,16,≤34]] 就算不完了,所以表里只留下「≤」,只有 BP-OSD 找到的上界。那两个 ≤ 号,就是「下界难算」留在论文里的痕迹。最后一点是本页给 d 标证据等级的原因:随机搜索跑一整天没找到比 12 更轻的,只是证据,不是证明——它永远不能排除第 10¹⁶ 个候选恰好合格。所以 QEC-Bank 把「文献下界 + 机器找到的上界相符」记为 bounded,只有自己穷举过的才敢写 verified。

So where do lower bounds actually come from? Three routes. One, exhaustion for small codes (bb5’s “verified”). Two, geometric arguments: a toric-code logical operator must wind once around the torus, so its length is ≥ L and the bound is one sentence — but BB checks reach several sites away and wrap around the torus, and no such picture is available. Three, exact combinatorial search: Bravyi et al. state that the distances in Table 3 were computed by mixed integer programming (MIP) — “minimum weight” written as an integer optimisation and handed to a solver that exhausts with pruning; feasible at the scale of [[144,12,12]], infeasible for [[360,12,≤24]] and [[756,16,≤34]], which is why those rows carry only a “≤” and the upper bound BP-OSD found. Those two ≤ signs are the trace “lower bounds are hard” left in the paper. This is also why this page grades the evidence behind every d: a random search that runs all day without finding anything lighter than 12 is evidence, not proof — it can never rule out that the 10¹⁶-th candidate happens to qualify. Hence the QEC-Bank records “literature lower bound + machine-found upper bound agreeing” as bounded, and writes verified only where it exhausted the search itself.

学名一瞥:R → R² → R 的链复形A glimpse of the scholarly name: the chain complex R → R² → R

《Surface Code · 高中数学版》第 3 章用「链、边界、同调类」描述表面码;BB 码有同一套语言的代数版本。把 ∂₂ ≔ [B ; A](R → R²)和 ∂₁ ≔ [A | B](R² → R)串起来,∂₁∂₂ = AB + BA = 0 正是「边界的边界为零」。X 逻辑算符是 ∂₁ᵀ 的核kernel:被矩阵送到零向量的全部向量;这里即「与所有检查对易」的算符。里不在 ∂₂ᵀ 像里的部分——「与检查对易」减去「是检查的乘积」,也就是中间那一项的同调。那一章说逻辑信息藏在「横跨不横跨」里,这里它藏在「商空间 R/(A,B)」里:k = 2·dimdimension,维数:一个线性空间里线性独立向量的最大个数。 R/(A,B)。同一个想法,一个用几何说,一个用代数说。

“The Surface Code · High-School Edition”, Chapter 3 described the surface code with “chains, boundaries, homology classes”; BB codes carry the algebraic edition of the same language. Chain ∂₂ ≔ [B ; A] (R → R²) with ∂₁ ≔ [A | B] (R² → R): ∂₁∂₂ = AB + BA = 0 is exactly “the boundary of a boundary is zero”. X-logicals are the part of the kernelAll vectors a matrix sends to zero; here, the operators that commute with every check. of ∂₁ᵀ outside the image of ∂₂ᵀ — “commutes with the checks” minus “is a product of checks”, the homology of the middle term. That chapter hid logical information in “spanning or not”; here it hides in the quotient R/(A,B): k = 2·dimDimension: the largest number of linearly independent vectors in a linear space. R/(A,B). One idea, told once in geometry and once in algebra.

关键想法Key idea

k 不是设计出来的,是算出来的:k = 2·dim R/(A,B),多项式的项数只定检查重量,指数和环面尺寸才定秩。d 更难:n、k 一次高斯消元Gaussian elimination:逐行消去求矩阵秩(或解线性方程组)的标准算法;本页算秩用的就是它的 GF(2) 版本。就能验证,d 需要下界与上界两份证书,QEC-Bank 对每个数字都标明证据等级。读任何一篇 qLDPC 论文的参数表时,先问「这个 d 是证明的、搜索的,还是声称的」。

k is not designed but computed: k = 2·dim R/(A,B); the number of terms fixes only the check weight, while exponents and torus size fix the rank. d is harder still: n and k are verified by one Gaussian eliminationThe standard row-reduction algorithm for the rank of a matrix (or for solving linear equations); this page's ranks use its GF(2) version., but d needs two certificates, a lower and an upper bound, and the QEC-Bank grades the evidence behind every number. When reading a qLDPC paper's parameter table, ask first: “is this d proved, searched, or claimed?”

检查站Checkpoint第 4 章Chapter 4
某 BB 码 l × m = 15 × 3,本页算出 rank HX = 41。它的 k 是多少?A BB code has l × m = 15 × 3 and this page computes rank HX = 41. What is its k?

对,这正是 [[90,8,10]]。秩亏损 45 − 41 = 4,k 是它的两倍。

Right — this is [[90,8,10]]. The rank deficit is 45 − 41 = 4, and k is twice that.

n = 2lm;两个秩相等;k = n − 2r。

n = 2lm; the two ranks are equal; k = n − 2r.

第 5 章Chapter 5

重要条目逐个讲The important entries, one by one

QEC-Bank 里 BB 家族有八个可执行条目。这一章按从小到大的顺序,给每一个写一份短教程:环面、多项式、秩与 k、d 的证据等级、它为什么值得存在。所有 n、k 都在本页的账本里现场重算;每个小节都有独立锚点,可以直接链接。 The QEC-Bank holds eight executable BB-family entries. This chapter gives each a short tutorial, smallest first: torus, polynomials, rank and k, the evidence grade of d, and why it deserves to exist. Every n and k is recomputed live in this page's ledger; each subsection has its own anchor for direct linking.

5.1toric_L3 [[18,2,3]]:检验约定的锚点toric_L3 [[18,2,3]]: the anchor that tests the conventions

l = m = 3,A = 1 + x,B = 1 + y。每条检查四腿,两个秩各 8,k = 18 − 16 = 2,穷举得 d = 3——环面码教程里的环面码原封不动。它在 QEC-Bank 的 bivariate_bicycle 条目里作为第二个实例存在,用途是「校准」:任何关于移位方向、转置约定、两块顺序的疏忽,都会在这个小例子上立刻露馅(例如把转置忘掉,检查就不再两两对易)。它也是 BB 码「与环面码同源」这句话的字面证明。

l = m = 3, A = 1 + x, B = 1 + y. Four-leg checks, both ranks 8, k = 18 − 16 = 2, exhaustive d = 3 — the toric tutorial's toric code verbatim. It lives in the QEC-Bank's bivariate_bicycle entry as the second instance, serving as calibration: any slip in shift direction, transpose convention or block order shows up at once on this tiny example (forget the transpose and the checks stop commuting). It is also the literal proof that BB codes descend from the toric code.

5.2bicycle [[6,2,2]] 与 bb5 [[30,4,5]]:两个能穷举的小码bicycle [[6,2,2]] and bb5 [[30,4,5]]: two small codes that can be enumerated

bicycle 是一变量的祖先(2.4):l = 3 上取 C = 1 + x,HX = HZ = [C | Cᵀ]。n = 6,两个秩各 2,k = 2,d = 2——只能探测、不能纠正单个错误,但它把「同一个环上的多项式自动对易」这个想法压缩到了六个比特里。bb5 是 QEC-Bank 里最小的双变量见证:l = 5、m = 3,A = 1 + x,B = 1 + y + x²y²。检查重量 2 + 3 = 5(因此叫 bb5),两个秩各 13,k = 30 − 26 = 4;本页穷举 217 个核向量得 dX = 5(X 型逻辑算符的最小重量),QEC-Bank 的验证器给出同样的 d = 5,证据等级「verified」。它是这一家里唯一一个 k > 2 且 d 被穷举证明的成员。

bicycle is the one-variable ancestor (§2.4): on l = 3 take C = 1 + x and HX = HZ = [C | Cᵀ]. n = 6, both ranks 2, k = 2, d = 2 — it detects but cannot correct a single error, yet it compresses “polynomials on one ring commute automatically” into six qubits. bb5 is the QEC-Bank's smallest two-variable witness: l = 5, m = 3, A = 1 + x, B = 1 + y + x²y². Check weight 2 + 3 = 5 (hence the name), both ranks 13, k = 30 − 26 = 4; this page enumerates 217 kernel vectors to get dX = 5 (the minimum weight of an X-type logical), and the QEC-Bank verifier reports the same d = 5, grade “verified”. It is the only family member with k > 2 whose d is proved by exhaustion.

5.3[[72,12,6]]:Table 3 的第一行[[72,12,6]]: the first row of Table 3

l = m = 6,A = x³ + y + y²,B = y³ + x + x²。每条检查六腿,每个比特 3 + 3 条检查。两个秩各 30,k = 72 − 60 = 12:72 个数据比特存 12 个逻辑比特,n/k = 6。d = 6 是 Bravyi 等人 2024 年 Table 3 的声称值,QEC-Bank 标「claimed」;本页的随机搜索几秒内能找到重量 6 的逻辑算符,与声称相符(上界)。它是这一家里数据比特最少、码率最高的成员,代价是 d 只有 6——大约等于一块 d = 6 的表面码,却存了 12 个。

l = m = 6, A = x³ + y + y², B = y³ + x + x². Six-leg checks, 3 + 3 checks per qubit. Both ranks 30, k = 72 − 60 = 12: 72 data qubits store 12 logical qubits, n/k = 6. d = 6 is the claimed value in Bravyi et al.'s 2024 Table 3, graded “claimed” by the QEC-Bank; this page's random search finds a weight-6 logical within seconds, agreeing with the claim (an upper bound). It is the family's smallest and highest-rate member, at the price of d = 6 — about one d = 6 surface patch's protection, but for 12 qubits.

5.4[[90,8,10]]:细长的环面[[90,8,10]]: a long thin torus

l = 15、m = 3,A = x⁹ + y + y²,B = 1 + x² + x⁷。这个环面只有 3 格高,B 甚至不含 y——它的三项 1、x²、x⁷ 全在 x 方向上。两个秩各 41,k = 90 − 82 = 8,d = 10(claimed)。它说明 BB 的搜索空间不只是「方形环面上的对称多项式」:拉长一边、让一个多项式只沿一个方向走,同样能得到好的常数。n/k = 11.25。

l = 15, m = 3, A = x⁹ + y + y², B = 1 + x² + x⁷. This torus is only 3 sites tall, and B contains no y at all — its three terms 1, x², x⁷ all run along x. Both ranks 41, k = 90 − 82 = 8, d = 10 (claimed). It shows that the BB search space is not just “symmetric polynomials on a square torus”: stretching one side and letting one polynomial move in a single direction also yields good constants. n/k = 11.25.

5.5[[108,8,10]]:同样的多项式,不同的环面[[108,8,10]]: the same polynomials, a different torus

l = 9、m = 6,多项式与 [[72,12,6]] 和 gross 完全相同。两个秩各 50,k = 108 − 100 = 8——比 6 × 6 上的 12 还少,而 d 从 6 升到 10。这是第 4 章「三项不决定 k」的活例子:商空间 R/(A,B) 的维数从 6 掉到 4,是因为 x9 = 1 与 x6 = 1、x12 = 1 给出的环不同,同一个理想 (A, B) 在不同的环里「占」的比例不同。n/k = 13.5。

l = 9, m = 6, with polynomials identical to [[72,12,6]] and gross. Both ranks 50, k = 108 − 100 = 8 — fewer than the 12 on 6 × 6, while d rises from 6 to 10. It is Chapter 4's living example of “three terms do not determine k”: the quotient R/(A,B) drops from dimension 6 to 4 because the rings defined by x9 = 1, x6 = 1 and x12 = 1 differ, and the same ideal (A, B) “fills” a different fraction of each. n/k = 13.5.

5.6gross [[144,12,12]]:一罗gross [[144,12,12]]: a gross

l = 12、m = 6,A = x³ + y + y²,B = y³ + x + x²。名字来自 144 = 一罗(12 打)。两个秩各 66,商空间 6 维,k = 12;每条检查六腿,每个比特 3 条 X 检查加 3 条 Z 检查。d = 12:下界由 Bravyi 等人给出,上界由 QEC-Bank 的随机搜索(种子 5,2000 次)找到重量 12 的逻辑算符,两者相符,证据等级「bounded」。它是这一家的旗舰:144 个数据比特、144 个辅助比特共 288 个物理比特,存 12 个 d = 12 的逻辑比特;同样的 144 个数据比特做旋转表面码只存 1 个 d = 12 的——这就是「十二倍」。QEC-Bank 的 bivariate_bicycle 条目以它为主实例,是本教程全部推导的原型。

l = 12, m = 6, A = x³ + y + y², B = y³ + x + x². The name comes from 144 = one gross (twelve dozen). Both ranks 66, a 6-dimensional quotient, k = 12; six-leg checks, 3 X checks plus 3 Z checks per qubit. d = 12: the lower bound is Bravyi et al.'s, the upper bound the QEC-Bank's random search (seed 5, 2000 iterations) finding a weight-12 logical; they meet, grade “bounded”. It is the family's flagship: 144 data plus 144 ancilla qubits, 288 physical in all, storing 12 logical qubits at d = 12, where the same 144 data qubits as a rotated surface code store a single d = 12 qubit — the “twelve-fold”. The QEC-Bank's bivariate_bicycle entry takes it as the primary instance, and it is the prototype behind every derivation in this tutorial.

5.7[[288,12,18]]:把码距推到 18[[288,12,18]]: distance pushed to 18

l = m = 12,A = x³ + y² + y⁷,B = y³ + x + x²。注意 A 的第三项变成了 y⁷——在 m = 12 的环面上这是一次「往上七格」的长程平移。两个秩各 138,k = 288 − 276 = 12,d = 18(claimed)。它的 k 与 gross 相同,比特数翻倍,换来 d 从 12 到 18:正是《Surface Code · 高中数学版》的压制律里「d 每加 6、逻辑错误率再乘三次 p/pth」的那一档。Yoder 等人 2025 年的模块化架构以 d = 12 与 d = 18 这两个块为基本单元。

l = m = 12, A = x³ + y² + y⁷, B = y³ + x + x². Note A's third term is now y⁷ — on an m = 12 torus a long-range “seven up”. Both ranks 138, k = 288 − 276 = 12, d = 18 (claimed). Same k as gross with twice the qubits, buying d from 12 to 18: exactly the notch in the surface-code tutorial's suppression law where “d + 6 multiplies the logical error rate by three more factors of p/pth”. Yoder et al.'s 2025 modular architecture uses the d = 12 and d = 18 blocks as its basic units.

关键想法Key idea

八个条目讲同一个故事的不同段落:环面码是 BB 的起点(5.1),bicycle 与 bb5 是能穷举验证的小样本(5.2),Table 3 的五个码是在秩与距离之间搜出来的高点(5.3–5.7)。读它们的参数表时,n 与 k 可以立刻复算,d 则要看证据等级:verified、bounded、claimed 是三种不同强度的话。

The eight entries are paragraphs of one story: the toric code is BB's starting point (5.1), bicycle and bb5 are small samples that can be verified exhaustively (5.2), and Table 3's five codes are peaks found between rank and distance (5.3–5.7). Reading their parameter tables, n and k can be recomputed at once, while d must be read with its evidence grade: verified, bounded and claimed are three statements of different strength.

检查站Checkpoint第 5 章Chapter 5
哪两个 Table 3 的码用完全相同的多项式 A、B,却有不同的 k?Which two Table 3 codes use identical polynomials A, B yet have different k?

对([[72,12,6]] 也用同一对多项式,在 6 × 6 上 k = 12)。同一个理想在不同的环里商维数不同:6、6、4。

Right ([[72,12,6]] uses the same pair too, with k = 12 on 6 × 6). The same ideal has different quotient dimensions in different rings: 6, 6, 4.

对照 5.3、5.5、5.6 的多项式。

Compare the polynomials in §5.3, §5.5 and §5.6.

第 6 章Chapter 6

从矩阵到机器:耦合、电路、译码、阈值、门From matrix to machine: couplers, circuits, decoding, thresholds, gates

一对 [[n,k,d]] 只描述一个静态的检查矩阵。要变成存储器,还得回答:芯片怎么连线、症状怎么测、译码器怎么算、0.8% 是哪一种阈值、逻辑门从哪里来、真机做到了哪一步。这一章逐项把 gross 码从矩阵推到机器,并在每一项上标出「已证明」与「只是声称」的边界。 An [[n,k,d]] triple describes only a static check matrix. To become a memory it must answer: how is the chip wired, how are syndromes measured, how does the decoder compute, what kind of threshold is 0.8%, where do logical gates come from, and how far have real devices got. This chapter pushes the gross code from matrix to machine item by item, marking on each the line between “proved” and “claimed”.

6.1Tanner 图:度 6,两层平面The Tanner graph: degree 6, two planar layers

把每个比特和每条检查画成点,检查碰到比特就连一条边,得到的二分图bipartite graph:顶点分成两侧,每条边都连接一侧的一个点与另一侧的一个点。叫Tanner 图Tanner graph:检查矩阵的图形版,一侧是比特、一侧是检查,H 的每个 1 是一条边。它决定芯片需要哪些耦合器,但不决定 CNOT 的顺序。。表面码的 Tanner 图可以画在一层平面上,每个比特连 4 条边、只连邻居。gross 码每个比特连 6 条边,且有的边跨越三格——一层平面画不下。Bravyi 等人证明它能分成两层平面图,每层每个比特最多三根线;两层之间靠跨层耦合器。这就是「多要一层」的精确含义,也是芯片工艺要为 BB 码新解决的题。

Draw every qubit and every check as a point, with an edge wherever a check touches a qubit, and you get a bipartite graphA graph whose vertices split into two sides, every edge joining one vertex from each side. called the Tanner graphThe graphical form of the check matrix: qubits on one side, checks on the other, one edge per 1 in H. It determines which couplers the chip needs, but not the order of the CNOTs.. The surface code's Tanner graph fits in one planar layer, 4 edges per qubit, neighbours only. The gross code has 6 edges per qubit, some spanning three sites — it does not fit in one layer. Bravyi et al. showed it splits into two planar layers, at most three wires per qubit per layer, joined by cross-layer couplers. That is the precise meaning of “one more layer”, and the new fabrication problem BB codes pose.

6.2症状电路:深度 7,顺序有讲究The syndrome circuit: depth 7, order matters

每条六腿检查用一个辅助比特和六个 CNOT 测量(《Surface Code · 高中数学版》第 4 章的四腿版放大)。gross 码有 144 条检查、144 个辅助比特,Bravyi 等人给出一个把全部 CNOT 排进 7 层的调度:每一层里所有比特同时各做一个门,7 层后 144 个读数同时到手。顺序不是随便排的:那一章提过,一个辅助比特中途出错会沿后续 CNOT 传播成两个数据比特的关联错误(hook),排错顺序会让电路的实际码距低于静态的 12。所以「d = 12」和「电路码距」是两个不同的量——QEC-Bank 的条目只导出静态矩阵,明确说明它不包含调度、辅助比特坐标和探测器定义。

Each six-leg check is measured with one ancilla and six CNOTs (the four-leg version of “The Surface Code · High-School Edition”, Chapter 4, enlarged). The gross code has 144 checks and 144 ancillas, and Bravyi et al. give a schedule packing every CNOT into 7 layers: in each layer every qubit performs one gate, and after 7 layers all 144 readouts arrive together. The order is not arbitrary: as that chapter noted, an ancilla error midway propagates through later CNOTs into a correlated two-qubit data error (a hook), and a bad order lowers the circuit's effective distance below the static 12. So “d = 12” and “circuit distance” are different quantities — the QEC-Bank entry exports only the static matrix and states explicitly that it does not include the schedule, ancilla coordinates or detector definitions.

6.3译码:为什么不是匹配,而是 BP-OSDDecoding: why not matching, but BP-OSD

《译码器 · 高中数学版》的匹配译码依赖一个事实:表面码上每个错误恰好点亮两个警报,警报可以两两配对。BB 码里每个比特属于 3 条 X 检查,一个 Z 错误点亮三个警报,「配对」失去了意义。取而代之的是置信传播belief propagation, BP:在 Tanner 图上让比特与检查反复交换「你有多可能出错」的消息,几轮后对每个比特做硬判决。在无圈的图上精确,在有短圈的图上可能卡住或摇摆。:让每个比特和每条检查在 Tanner 图上来回传递「出错的可能性有多大」,几轮后各自表态。BP 在树状图上是精确的,但 BB 的 Tanner 图满是短圈,加上量子码的退化(许多错误等价),BP 常常卡住。补救是OSDordered-statistics decoding:BP 卡住时,按 BP 给出的可靠度排序,在最可能出错的一组比特上解线性方程组 H e = s,保证得到一个清零症状的修复。Panteleev 与 Kalachev 2019 年引入。:把 BP 的可靠度当作排序,在最可能出错的比特上解线性方程,保证给出一个合法修复。到实验台上对 [[72,12,6]] 亲手跑:先看 BP 的消息如何演化、何时卡住,再按 OSD。

The matching decoder of “Decoders · High-School Edition” rests on one fact: on the surface code every error lights exactly two alarms, so alarms pair up. In a BB code each qubit belongs to 3 X checks, so a Z error lights three alarms and “pairing” loses its meaning. Its replacement is belief propagationBP: qubits and checks on the Tanner graph repeatedly exchange messages about “how likely are you to be in error”; after a few rounds each qubit is given a hard decision. Exact on cycle-free graphs, liable to stall or oscillate on graphs with short cycles.: let every qubit and every check pass “how likely is an error here” back and forth across the Tanner graph, then vote. BP is exact on trees, but BB Tanner graphs are full of short cycles, and quantum degeneracy (many equivalent errors) makes BP stall often. The remedy is OSDOrdered-statistics decoding: when BP stalls, sort qubits by BP's reliabilities and solve the linear system H e = s on the most-likely-error set, guaranteeing a repair that clears the syndrome. Introduced by Panteleev and Kalachev in 2019.: use BP's reliabilities as an ordering and solve a linear system on the most-likely-error qubits, guaranteeing a valid repair. Run it on [[72,12,6]] at the bench: watch BP's messages evolve and stall, then press OSD.

6.40.8%:五个限定项0.8%: five qualifiers

论文里最常被引用的一个数字是「BB 码的阈值 0.8%」。按《译码器 · 高中数学版》第 6 章的账本规则,它的五个限定项是:① 电路级噪声:每个 CNOT 后以概率 p 出现 15 种非恒等双比特 Pauli 之一(均匀随机),空闲比特以概率 p 出现 X、Y、Z 之一,制备与读出各以概率 p 翻转结果,四类位置共用一个 p;② 症状由上面那个深度 7 的电路提取,探测器按论文的构造定义;③ 噪声按每个电路位置归一化;④ 译码器是 BP-OSD,参数照论文;⑤ 数字怎样算出来:论文对每一块码单独解收支平衡方程 pL(p) = kp,其中 pL 是整块码(k 个逻辑比特里任一个出错)每轮的失败率,kp 近似 k 个不编码的比特至少一个出错的概率;解出的 p0 就是这块码的伪阈值pseudo-threshold:一块固定尺寸的码的收支平衡点,即整块每轮失败率 pL(k 个逻辑比特任一个出错)等于 kp 时的 p;kp 近似 k 个不编码的比特至少一个出错的概率(各比特独立出错时,精确值是 1 − (1 − p)k)。它是一块码的数,不是一族码的阈值。。pL 在 p ≥ 10−3 处由模拟算出,更小的 p 用拟合公式外推。论文 v1(2023 年 8 月)表 1 给五块码的 p0 印作 0.007(3) 到 0.008(3)(括号里那一位数字是什么意思,论文没有说明),正文说「close to 0.008」,摘要写成 0.8%;v2(2024 年 2 月)的表 1 改为 0.0048 到 0.0069,摘要仍写 0.8%;Nature 发表版(2024)的摘要写 0.7%。所以它不是码容量阈值,不是任意 BB 码的性质,不是 BP-OSD 独立于电路的性质,也不是把几个不同尺寸的码的曲线画在一起、从曲线交叉finite-size scaling(有限尺寸标度):在几个不同尺寸的码上画「逻辑错误率对 p」的曲线,曲线的交点可用来估计一族码的阈值。这篇论文没有做这一步。读出的阈值:它是单块、有限尺寸的估计,不是渐近定理(细节见 BB 译码器页 3.3 节)。换掉任何一项,就是另一个实验。

The most-quoted number in the paper is “the BB threshold of 0.8%”. By the ledger rules of “Decoders · High-School Edition”, Chapter 6, its five qualifiers are: ① circuit-level noise: after every CNOT one of the 15 non-identity two-qubit Paulis, uniformly at random, with probability p; on every idle qubit one of X, Y, Z with probability p; preparation and readout each flipping their outcome with probability p — one p for all four kinds of location; ② syndromes extracted by the depth-7 circuit above, detectors defined by the paper's construction; ③ noise normalised per circuit location; ④ the decoder is BP-OSD with the paper's settings; ⑤ how the number is computed: for each code separately the paper solves the break-even equation pL(p) = kp, where pL is the per-round failure rate of the whole block (any of its k logical qubits) and kp approximates the chance that at least one of k unencoded qubits fails; the solution p0 is that block's pseudo-thresholdThe break-even point of one fixed-size block: the p at which its per-round failure rate pL (any of its k logical qubits) equals kp, approximately the chance that at least one of k unencoded qubits fails (exactly 1 − (1 − p)k when they fail independently). A number for one block, not the threshold of a family.. pL is simulated for p ≥ 10−3 and extrapolated below with a fitted formula. Table 1 of the paper's v1 (August 2023) prints p0 = 0.007(3) to 0.008(3) for its five codes (the paper does not say what the parenthesized digit means), the text says “close to 0.008”, and the abstract says 0.8%; Table 1 of v2 (February 2024) gives 0.0048 to 0.0069 while its abstract still says 0.8%; the abstract of the Nature version (2024) says 0.7%. So it is not a code-capacity threshold, not a property of an arbitrary BB code, not a property of BP-OSD independent of the circuit, and not a threshold read off a crossing of curvesFinite-size scaling: plot the logical error rate against p for several code sizes; the p where the curves cross estimates the threshold of the family. This paper does not do that step. for several code sizes: it is a per-block, finite-size estimate, not an asymptotic theorem (details in §3.3 of the BB decoders page). Change any item and it is a different experiment.

6.5逻辑门:什么已经有,什么还没有Logical gates: what exists and what does not

两块相同的 BB 码逐对做物理 CNOT,是逻辑上的 12 个并行 CNOT——《格点手术 · 高中数学版》1.2 节说过的横向 CNOT 对任何两块相同的 CSS 码成立。环面平移 x、y 与 A、B、Aᵀ、Bᵀ 都对易,所以同时平移两层是码的自同构automorphism:把稳定子群映到自身的物理操作。它保证码空间不变,但对逻辑比特的具体作用需要另外计算与认证。。光凭「与 A、B 可交换」这个论证,看不出它对 12 个逻辑比特做了什么(QEC-Bank 的原话:「It does not identify its action on the twelve logical qubits」)。Bravyi 等人在论文 v2 的补充材料里给出了这一作用:平移 s 把标号为 n 的逻辑算符 X̄n 换成标号为 s·n 的 X̄s·n,Z̄ 同理(带撇和不带撇的两族逻辑算符都这样变);在选定的逻辑比特基下,换过去的那个算符可能是几个逻辑比特上算符的乘积。作者据此指出:每个平移都是逻辑 CNOT 线路(最多差一个逻辑 Pauli 修正),合起来构成一个阿贝尔子群;他们还写道,除 s = 1 外没有哪个平移会作用成逻辑恒等。对 gross 这后一句并不成立:本篇对 72 个平移逐一检验了它们对全部逻辑 X̄、Z̄ 的作用(看 P u − u 是否落在稳定子张成的空间里,每个平移在 GF(2) 上做两次秩比较,X 型、Z 型各一次),结果 x⁶(沿长为 12 的方向平移半圈)作用成逻辑恒等,其余 70 个非恒等平移都作用非平凡,所以 72 个平移只给出 36 种不同的逻辑作用。形如 AjAkT 或 BjBkT 的平移各有一条 CNOT 深度为 4 的容错线路(数据要途经检查比特,那些比特的初始化与重置不计入这个深度);Tanner 图连通时,这些平移生成全部平移,其余平移由它们组合而成,深度各不相同。作者也写明,还看不出怎样用这些 CNOT 做有用的计算;它们的主要用途是在各自的逻辑块内搬动算符,再配合一个辅助测量探针和交换两块的 ZX 对偶,就能测到任何一个逻辑比特。要对 12 个比特中的某几个做门,需要格点手术那样的乘积算符测量:Yoder 等人 2025 年的「Tour de gross」为 d = 12 与 d = 18 两个块给出了完整的指令集、编译方案与资源估计,靠辅助系统测乘积算符。非 Clifford 门仍需魔法态。结论:BB 码是好的存储器;把它变成计算机的工作正在进行,尚无普适的横向门集。

Pairwise physical CNOT between two identical BB blocks is 12 logical CNOTs in parallel — the transversal CNOT of “Lattice Surgery · High-School Edition”, §1.2 holds for any two identical CSS codes. The torus translations x, y commute with A, B, Aᵀ, Bᵀ, so translating both layers is an automorphismA physical operation mapping the stabilizer group to itself. It preserves the code space, but its specific action on the logical qubits must be computed and certified separately. of the code. The commutation argument alone does not say what it does to the 12 logical qubits (the QEC-Bank: “It does not identify its action on the twelve logical qubits”). The supplement of Bravyi et al.'s v2 gives it: a translation s maps the logical operator X̄n labelled n to X̄s·n, likewise for Z̄ (both the primed and the unprimed families); in a chosen logical-qubit basis the image can be a product of operators on several logical qubits. From this the authors conclude that every translation is a logical CNOT circuit (up to a logical Pauli correction) and that together they form an Abelian subgroup; they also write that no translation other than s = 1 acts as the logical identity. For gross that last claim does not hold: checking the action of all 72 translations on every logical X̄ and Z̄ (whether P u − u lies in the span of the stabilizers: two GF(2) rank comparisons per translation, one for each Pauli type) shows that x⁶, a half-turn along the direction of length 12, acts as the logical identity, while the other 70 nonidentity translations have a nontrivial logical action; so the 72 translations give only 36 distinct logical actions. Translations of the form AjAkT or BjBkT each have a fault-tolerant circuit of CNOT depth 4 (the data pass through check qubits, whose initializations and resets are not counted in that depth); when the Tanner graph is connected these generate all translations, and the others are compositions of varying depth. The authors add that it is not clear how to use these CNOTs for useful computation; their main use is moving operators within each logical block, which, together with an ancilla measurement probe and the ZX duality that exchanges the two blocks, gives access to every logical qubit. To gate some of the 12 qubits one needs lattice-surgery-style product measurements: Yoder et al.'s 2025 “Tour de gross” gives complete instruction sets, a compilation scheme and resource estimates for the d = 12 and d = 18 blocks, measuring product operators through ancilla systems. Non-Clifford gates still need magic states. Conclusion: BB codes are a good memory; turning them into a computer is work in progress, with no universal transversal gate set yet.

6.6现实与渐近Reality and asymptotics

2025 年,Wang 等人在 32 个长程耦合超导比特的「昆仑」处理器上运行了一个 [[18,4,4]] 的 BB 码:18 个数据比特加 14 个辅助比特,同时测量所有非局域的六腿检查并重复多轮,报告每个逻辑比特每轮的逻辑错误率 (8.91 ± 0.17)%。这是第一次真机上的 BB 码,它证明了「两层耦合、六腿检查」在硬件上可行;它没有运行 gross 码,也没有展示「码距加大、错误率下降」的标度——那需要至少两个码距在同一电路与译码器下比较。另一头,Postema 与 Kokkelmans 2025 年用环的结构预测了 BB 码的维数与存在条件,并指出所研究的 BB 子类渐近是坏的:固定项数、无限放大环面时,码率与相对距离不能同时保持非零。所以正确的说法是「有限尺寸下的优秀常数」,而不是「二维局域的好 qLDPC 码」。真正渐近好的码要走另一条路(《qLDPC 码 · 高中数学版》4.4 节)。

In 2025 Wang et al. ran an [[18,4,4]] BB code on “Kunlun”, a processor of 32 long-range-coupled superconducting qubits: 18 data plus 14 ancilla qubits, all nonlocal six-leg checks measured simultaneously over repeated rounds, reporting a logical error rate per logical qubit per cycle of (8.91 ± 0.17)%. It was the first BB code on real hardware and proved that “two coupling layers, six-leg checks” is feasible; it did not run the gross code, nor show “larger distance, lower error” scaling — that needs at least two distances compared under the same circuit and decoder. At the other end, Postema and Kokkelmans in 2025 used the ring structure to predict BB dimensions and existence conditions and showed that the studied BB subclass is asymptotically bad: with a fixed number of terms and an ever-larger torus, rate and relative distance cannot both stay nonzero. So the correct statement is “excellent constants at finite size”, not “good 2D-local qLDPC codes”. Truly good codes take another road (“qLDPC Codes · High-School Edition”, §4.4).

关键想法Key idea

[[144,12,12]] 是矿石,机器是另外五件事:两层耦合的芯片、深度 7 的调度、BP-OSD 译码器、带五个限定项的 0.8%、以及仍在建设中的逻辑门。第一个真机实验是 [[18,4,4]];渐近分析说这条路在有限尺寸最有价值。把这五件事和矿石分开说,才是对 BB 码诚实的评价。

[[144,12,12]] is the ore; the machine is five more things: a two-layer chip, a depth-7 schedule, a BP-OSD decoder, a 0.8% with five qualifiers, and logical gates still under construction. The first hardware run was [[18,4,4]]; asymptotic analysis says this road is most valuable at finite size. Keeping those five things apart from the ore is what an honest appraisal of BB codes looks like.

检查站Checkpoint第 6 章Chapter 6

对。匹配需要「症状图」里每个错误是一条边(两个端点);BB 的错误是一个三端点的超边。BP 不依赖这个结构,代价是短圈与退化会让它卡住,因此配上 OSD。

Right. Matching needs each error to be an edge (two endpoints) in the syndrome graph; a BB error is a three-endpoint hyperedge. BP does not depend on that structure, at the cost of stalling on short cycles and degeneracy, hence OSD.

回看 6.3:匹配依赖「一个错误恰好两个警报」。

See §6.3: matching relies on “one error, exactly two alarms”.

尾声Epilogue

从环面到一罗,与三条继续走的路From the torus to a gross, and three roads onward

复盘整条推理链:二维局域码被 k·d² ≤ c·n 锁死,BB 在固定的 n 上吃满常数 c,而不是推翻定理(第 1 章)→ 循环移位是置换矩阵,x、y 是两个对易的平移,多项式是每行 w 个 1 的稀疏矩阵,转置是反向平移(第 2 章)→ HX = [A | B]、HZ = [Bᵀ | Aᵀ],AB + BA = 2AB = 0 让任何选择都合法,A = 1 + x、B = 1 + y 就是环面码(第 3 章)→ k = 2·dim R/(A,B),项数不定 k,d 要两份证书(第 4 章)→ 八个条目从 [[6,2,2]] 到 [[288,12,18]],n、k 现场复算,d 分三个证据等级(第 5 章)→ 两层耦合、深度 7、BP-OSD、五限定项的 0.8%、尚缺的逻辑门、昆仑的 [[18,4,4]]、渐近的坏(第 6 章)。读到这里,Bravyi 等人 2024 年论文的每一张表你都能自己复算 n 与 k,并说清哪些数字是证明、哪些是搜索、哪些是声称。

Replaying the chain: 2D local codes are locked by k·d² ≤ c·n, and BB uses up the constant c at fixed n rather than overturning the theorem (Ch. 1) → the cyclic shift is a permutation matrix, x and y two commuting translations, a polynomial a sparse matrix with w ones per row, the transpose a reversed translation (Ch. 2) → HX = [A | B], HZ = [Bᵀ | Aᵀ], and AB + BA = 2AB = 0 makes every choice legitimate, with A = 1 + x, B = 1 + y the toric code (Ch. 3) → k = 2·dim R/(A,B), term count does not fix k, and d needs two certificates (Ch. 4) → eight entries from [[6,2,2]] to [[288,12,18]], n and k recomputed live, d in three evidence grades (Ch. 5) → two coupling layers, depth 7, BP-OSD, a five-qualifier 0.8%, missing logical gates, Kunlun's [[18,4,4]], asymptotic badness (Ch. 6). By now you can recompute n and k for every table in Bravyi et al.'s 2024 paper yourself, and say which numbers are proofs, which searches, which claims.

三条继续走的路。其一,把 BB 放回大家族:BB 是「提升积」与「两块群代数码」的特例,把阿贝尔的 Zl × Zm环面格点在平移 x、y 下构成的群:两个循环群的直积,元素 xayb,运算可交换(阿贝尔)。 换成非阿贝尔群,才能得到渐近好的码——《qLDPC 码 · 高中数学版》的主题。其二,让 12 个逻辑比特可寻址:手术、自同构门、折叠横向门、模块化架构,都在把存储器变成计算机。其三,变体:开边界的平面 BB、自对偶 BB(带横向 Clifford 门)、多变量与 quditd 能级的量子数字,量子比特(2 能级)的推广;系数从 GF(2) 换成更大的数系。 版本、以及电路中途变形的 morphing——每一种都改变了 k、d 或电路,需要各自的账本。入口文献见下。

Three roads onward. One, put BB back in its family: BB is a special case of “lifted products” and “two-block group-algebra codes”, and only replacing the abelian Zl × ZmThe group of torus sites under the translations x, y: a direct product of two cyclic groups, elements xayb, commutative (abelian). by non-abelian groups yields asymptotically good codes — the theme of “qLDPC Codes · High-School Edition”. Two, make the 12 logical qubits addressable: surgery, automorphism gates, fold-transversal gates and modular architectures are turning the memory into a computer. Three, variants: planar BB with open boundaries, self-dual BB (with transversal Cliffords), multivariate and quditA d-level quantum digit, generalising the two-level qubit; coefficients move from GF(2) to a larger number system. versions, and morphing that changes the code mid-circuit — each alters k, d or the circuit and needs its own ledger. Entry points below.

符号与读法Symbols & how to read them

符号Symbol名称与读法Name & how to read it在本教程中的含义Meaning in this tutorial
Sl读「循环移位」Read “cyclic shift”l × l 置换矩阵,把第 i 格送到第 i+1 格(mod l);Sl = I,Sᵀ = S−1。The l × l permutation matrix sending site i to i+1 (mod l); Sl = I, Sᵀ = S−1.
x, y读「两个平移」Read “the two translations”x = Sl ⊗ Im 只动第一个坐标,y = Il ⊗ Sm 只动第二个;xy = yx。x = Sl ⊗ Im moves the first coordinate, y = Il ⊗ Sm the second; xy = yx.
⊗圆圈乘,读「克罗内克积 / 张量积」A circled times, read “Kronecker / tensor product”A ⊗ B:把 A 的每个元素 a 换成整块 a·B。(A⊗B)(C⊗D) = AC ⊗ BD。A ⊗ B: replace every entry a of A by the block a·B. (A⊗B)(C⊗D) = AC ⊗ BD.
xayb读「单项式」Read “monomial”把 (i,j) 平移到 (i+a, j+b) 的置换矩阵;转置是 x−ay−b。The permutation translating (i,j) to (i+a, j+b); its transpose is x−ay−b.
R读「环」Read “the ring”GF(2)[x,y]/(xl−1, ym−1):系数 0/1 的多项式,加上 xl = ym = 1 的约定。GF(2)[x,y]/(xl−1, ym−1): polynomials with 0/1 coefficients under xl = ym = 1.
R/(A,B)读「R 模 (A,B)」Read “R mod (A,B)”把所有 uA + vB 当作零后剩下的空间;维数 = 秩亏损 = k/2。What remains after every uA + vB is set to zero; its dimension = the rank deficit = k/2.
rank读「秩」Read “rank”线性独立的行的最大个数;k = n − rank HX − rank HZ。The largest number of linearly independent rows; k = n − rank HX − rank HZ.
≔ ≕读「定义为」Read “is defined as”A ≔ B 用 B 定义 A;B ≕ A 用 A 命名左边的量。A ≔ B defines A as B; B ≕ A names the left-hand quantity A.
[A | B], [B ; A]读「并排 / 上下堆叠」Read “side by side / stacked”竖线把两个矩阵左右拼接;分号把它们上下堆叠。[A | B]·[B ; A] = AB + BA。The bar concatenates two matrices horizontally; the semicolon stacks them. [A | B]·[B ; A] = AB + BA.
∏大写希腊字母 π,读「派」Capital Greek π, read “pie”连乘:∏A = I 是环面码的一条恒等式。Product: ∏A = I is one of the toric code's identities.
GF(2)读「二元域」Read “the binary field”只有 0、1 两个数,1 + 1 = 0;所有秩、对易性都在它上面计算。Only 0 and 1, with 1 + 1 = 0; every rank and commutation is computed over it.
mod l读「模 l」Read “modulo l”数到 l 就绕回 0:环面坐标与循环移位的算术。Counting wraps to 0 at l: the arithmetic of torus coordinates and cyclic shifts.
ᵀ上标 T,读「转置」Superscript T, read “transpose”把矩阵的行与列互换;对置换矩阵等于逆;对单项式等于反向平移。Swap rows and columns; for a permutation matrix it is the inverse, for a monomial the reversed translation.
|A|读「A 的项数」Read “number of terms of A”多项式 A 含多少个单项式;检查重量 = |A| + |B|。How many monomials A contains; check weight = |A| + |B|.
Σ大写希腊字母 sigma,读「西格玛」Capital sigma求和:把若干项加起来。Summation: add up several terms.
dim 核 像读「维数」「核」「像」Read “dimension”, “kernel”, “image”维数 = 线性独立向量的最大个数;核 = 被送到零的向量;像 = 能被到达的向量。k = 2·dim R/(A,B)。Dimension = the largest number of independent vectors; kernel = vectors sent to zero; image = vectors that can be reached. k = 2·dim R/(A,B).
∂₁, ∂₂读「边界算符」Read “boundary maps”链复形 R → R² → R 的两个映射,∂₁∂₂ = 0 即 CSS 条件。The two maps of the chain complex R → R² → R; ∂₁∂₂ = 0 is the CSS condition.
∝读「正比于」Read “proportional to”k ∝ √n:k 与 √n 按固定比例一起增长。k ∝ √n: k grows in a fixed ratio to √n.
⇒ ⇔ ≈ ≤读「推出」「当且仅当」「约等于」「小于等于」Read “implies”, “iff”, “approximately”, “at most”逻辑推导与比较。Implication and comparison.

本教程新增词汇New terms in this tutorial

术语Term定义Definition
BB 码(双变量自行车码)BB code (bivariate bicycle)两层各 lm 个比特,HX = [A | B]、HZ = [Bᵀ | Aᵀ],A、B 为环面上的二元多项式。Two layers of lm qubits, HX = [A | B], HZ = [Bᵀ | Aᵀ], with A, B binary polynomials on a torus.
BPT 界BPT bound二维局域码 k·d² ≤ c·n;表面码 k = 1 的原因。k·d² ≤ c·n for 2D local codes; why the surface code has k = 1.
置换矩阵 / 循环矩阵permutation / circulant matrix每行每列一个 1 的方阵 / 每行是上一行右移一格的方阵(= Zl 上的多项式)。A square matrix with one 1 per row and column / one whose each row is the previous shifted right (= a polynomial on Zl).
LDPC / 检查重量 / 比特度LDPC / check weight / qubit degree检查矩阵行列 1 的个数有界 / 一条检查碰几个比特 / 一个比特被几条检查碰。gross:6 与 3 + 3。Bounded ones per row and column / qubits per check / checks per qubit. gross: 6 and 3 + 3.
秩亏损 / 商空间rank deficit / quotientlm − rank[A|B] = dim R/(A,B);k 是它的两倍。lm − rank[A|B] = dim R/(A,B); k is twice it.
证据等级 verified / bounded / claimedevidence grades verified / bounded / claimed穷举证明 / 文献下界与机器上界相符 / 仅文献声称。Exhaustively proved / literature lower bound meets a machine upper witness / literature claim only.
grossgross[[144,12,12]],l = 12、m = 6;名字来自 144 = 一罗。[[144,12,12]], l = 12, m = 6; named after 144 = one gross.
Tanner 图 / 两层耦合Tanner graph / two coupling layers比特与检查的二分图;gross 的度 6 图分成两层度 3 的平面图。The bipartite graph of qubits and checks; gross's degree-6 graph splits into two planar degree-3 layers.
BP-OSDBP-OSDTanner 图上的消息传递,卡住时按可靠度排序解线性方程收尾。Message passing on the Tanner graph, finished by solving a linear system in reliability order when it stalls.
协议阈值protocol thresholdQEC-Bank 对 0.8% 的称呼:只在指定的噪声模型、电路、探测器、归一化与译码器下成立的阈值读数。论文实际算的是每块码的伪阈值(pL(p) = kp 的解),0.8% 是 v1 里这些值的约数(6.4 节)。The QEC-Bank's name for 0.8%: a threshold reading valid only under a specified noise model, circuit, detectors, normalisation and decoder. What the paper actually computes is each block's pseudo-threshold (the solution of pL(p) = kp); 0.8% is a round figure for these values in v1 (§6.4).
自同构automorphism把稳定子群映到自身的物理操作;环面平移是 BB 的自同构,但不是已认证的逻辑门。A physical operation mapping the stabilizer group to itself; torus translations are BB automorphisms but not certified logical gates.

延伸阅读Further reading

  • D. J. C. MacKay, G. Mitchison, P. L. McFadden, “Sparse-graph codes for quantum error correction” (2004)
    bicycle 码的出生地:一变量循环矩阵与 [C | Cᵀ]。arXiv: quant-ph/0304161Birthplace of bicycle codes: one-variable circulants and [C | Cᵀ]. arXiv: quant-ph/0304161
  • P. Panteleev, G. Kalachev, “Degenerate quantum LDPC codes with good finite length performance” (2019/2021)
    广义 bicycle 码的有限长搜索与 BP-OSD 译码器。arXiv: 1904.02703Finite-length searches of generalized bicycle codes and the BP-OSD decoder. arXiv: 1904.02703
  • S. Bravyi, A. W. Cross, J. M. Gambetta, D. Maslov, P. Rall, T. J. Yoder, “High-threshold and low-overhead fault-tolerant quantum memory”, Nature (2024)
    本教程的原始论文:Table 3 的五个码、两层耦合、深度 7 电路、0.8%。arXiv: 2308.07915This tutorial's source paper: Table 3's five codes, two coupling layers, the depth-7 circuit, 0.8%. arXiv: 2308.07915
  • R. Wang, H.-K. Lin, L. P. Pryadko, “Abelian and non-abelian quantum two-block codes” (2023); H.-K. Lin, L. P. Pryadko, “Quantum two-block group algebra codes” (2023)
    BB 的父家族:两块群代数码,阿贝尔与非阿贝尔。arXiv: 2305.06890;2306.16400BB's parent family: two-block group-algebra codes, abelian and non-abelian. arXiv: 2305.06890; 2306.16400
  • J. J. Postema, S. J. J. M. F. Kokkelmans, “Existence and characterisation of bivariate bicycle codes” (2025)
    用环的结构预测维数与存在性,并证明所研究子类渐近是坏的。arXiv: 2502.17052Ring structure predicts dimension and existence, and the studied subclass is shown asymptotically bad. arXiv: 2502.17052
  • Wang et al., “Demonstration of low-overhead quantum error correction codes” (2025)
    昆仑处理器上的 [[18,4,4]] BB 码:32 个长程耦合超导比特,每逻辑比特每轮 8.91%。arXiv: 2505.09684The [[18,4,4]] BB code on the Kunlun processor: 32 long-range-coupled superconducting qubits, 8.91% per logical qubit per cycle. arXiv: 2505.09684
  • T. J. Yoder et al., “Tour de gross: A modular quantum computer based on bivariate bicycle codes” (2025)
    以 d = 12、18 的 BB 块为单元的模块化架构、指令集与资源估计。arXiv: 2506.03094A modular architecture, instruction set and resource estimates built on the d = 12 and 18 BB blocks. arXiv: 2506.03094
  • N. P. Breuckmann, J. N. Eberhardt, “Quantum low-density parity-check codes” (2021)
    qLDPC 综述;《qLDPC 码 · 高中数学版》的入口。arXiv: 2103.06309The qLDPC review; the entrance to “qLDPC Codes · High-School Edition”. arXiv: 2103.06309
诚实总账The honesty ledger

全篇简化六项,一次结清:① [[72,12,6]]、[[90,8,10]]、[[108,8,10]]、[[288,12,18]] 的 d 是文献声称,本页只复算 n、k 并给出上界;② gross 的 d = 12 是「文献下界 + QEC-Bank 机器上界」,本页几秒的搜索只到 16 左右;③ 实验台把两层比特画在一张环面上,只是示意,真实芯片用两层平面图;④ 本教程没有模拟深度 7 的症状电路,电路码距与 0.8% 均为文献值;⑤ BP 演示是码容量模型(完美测量、只有 X 错误),OSD 只用 0 阶;⑥ 「十二倍」只比数据比特。以上不影响任何定性结论。

Six simplifications, settled in one bill: ① the d of [[72,12,6]], [[90,8,10]], [[108,8,10]] and [[288,12,18]] are literature claims; this page recomputes only n, k and gives upper bounds; ② gross's d = 12 is “literature lower bound + QEC-Bank machine upper witness”, and this page's few-second search reaches only about 16; ③ the bench draws both qubit layers on one torus as a schematic, whereas real chips use two planar layers; ④ this tutorial does not simulate the depth-7 syndrome circuit; circuit distance and 0.8% are literature values; ⑤ the BP demo is a code-capacity model (perfect measurement, X errors only) with order-0 OSD; ⑥ “twelve-fold” compares data qubits only. None of this touches any qualitative conclusion.