第 20 章
Reed–Solomon 码:多项式求值与错误定位
把消息写成次数小于 k 的多项式,在 n 个不同点上求值得到码字。多项式根数界立刻给出最小距离 n−k+1,可纠 (n−k)/2 个错误。解码化为解线性方程组:引入错误定位多项式 f 与 q=pf,解出后相除即可恢复消息。串接内码后,RS 码在 10% 误码率下把失败概率压到 10⁻⁶⁰ 量级。
Reed–Solomon Codes: Polynomial Evaluation and Error Location
Write the message as a polynomial of degree below k and evaluate it at n distinct points to obtain the codeword. The bound on the number of roots immediately gives minimum distance n−k+1 and correction of (n−k)/2 errors. Decoding becomes a linear system: introduce an error-locator f and q=pf, solve, then divide. Concatenated with an inner code, Reed–Solomon drives the failure probability at a 10% bit error rate to about 10⁻⁶⁰.
篇内目录
- From Hamming codes to polynomials
- Timeline
- Construction: the message as a polynomial
- Linearity and the generator matrix
- Minimum distance:
- How many errors can be corrected
- The decoding theorem
- Decoding by linear algebra
- When fewer than errors occur
- Concatenated codes: making RS practical
- Two layers
- Performance
- What this lecture establishes
- Comprehension check
- Relation to neighbouring lectures
从 Hamming 码到多项式
Hamming 码的最小距离只有 3,只能纠正 1 位错误。码块变长后,一块里出现两个错误的概率迅速上升,单错纠错就不够用了。需要一种距离随码长增长的码。
这一讲的思路来自一条古老的代数事实:
域上次数不超过 的非零多项式,至多有 个根。
把消息编码成多项式在若干点上的取值,两个不同多项式就不可能在很多点上相同——差值多项式的根数给出了距离的下界。这就是 Reed–Solomon 码。
时间轴
| 时间 | 内容 |
|---|---|
| 0:00 | 历史线:1948 Shannon、1950 Hamming、1960 Reed–Solomon |
| 1:05 | 1966 串接码;1969 Berlekamp–Massey 解码 |
| 2:02 | 1977 Voyager 使用 RS 码;1990 年代 turbo 码出现 |
| 4:54 | RS 码的构造:消息 → 多项式 → 求值 |
| 9:40 | 生成矩阵是 Vandermonde 矩阵 |
| 13:43 | 定理:最小距离为 |
| 17:09 | 纠错条件 |
| 20:16 | 解码定理:存在 、 使 |
| 24:31 | 定理的证明: 取错误位置, |
| 30:23 | 把解码化为线性方程组 |
| 36:28 | 变量数比方程数多一,归一化后唯一 |
| 45:02 | 串接码:RS 作外码、 作内码 |
| 59:07 | 10% 误码率下失败概率约 |
| 1:02:41 | 内码用查表解码 |
构造:把消息写成多项式
设有限域为 (本讲可用 ,实际应用多用 )。消息是一串系数
对应多项式
次数不超过 。
选 个互不相同的求值点 ,码字定义为
本讲取 ,即 。
两个前提不能省:
- ,否则域里没有 个不同元素;
- 求值点互不相同,否则两个不同多项式可能在同一点取同值,距离论证失效。
线性性与生成矩阵
求值对系数是线性的:若 对应 、 对应 ,则 对应 。所以 RS 码是线性码。
生成矩阵的第 行是「、其余为 0」对应的码字,即在各点上的 取值:
所有运算在 中进行。例如 时,,矩阵里的数不会无限增大。
这是一个 Vandermonde 矩阵:每列是求值点的幂次。由于求值点互不相同,它列满秩。消息 的码字就是 ,第 个分量正是 。
最小距离:
定理。 RS 码的最小距离为
证明。 码字是 ,其中 是次数不超过 的多项式。
若 不是零多项式,它至多有 个根,所以 中至多有 个等于 0。因此非零码字的 Hamming 重量至少是
这个下界可以达到(取适当的 使根恰好落在 个求值点上),所以 。
能纠多少错
由最小距离定理,可纠错误数为
等价地,要纠正 个错误,需要
例如 的 RS 码:,可纠 16 个符号错误。
这个距离达到了 Singleton 界 ,因此 RS 码是 MDS 码(maximum distance separable):在给定 、 下,距离已经最大,不可能更好。
注意这里的「错误」以符号为单位,不是比特。一个符号是 的一个元素,在 中就是一个字节。
解码定理
收到的是带有错误的向量
其中多数位置满足 ,少数不满足。
设错误位置为 ,。定义两个多项式:
- 错误定位多项式 ,次数为 ;
- ,次数不超过 。
定理。 对每个求值点 ,
证明。 分两种情况。
情况一: 是错误位置。 此时 ,右边 。左边 。等式成立。
情况二: 不是错误位置。 此时 ,于是
等式也成立。
这个定理看起来只是恒等式,但它把「哪些位置错了」这个离散问题,变成了「找一对多项式」的代数问题——而后者可以用线性代数求解。
用线性代数解码
把 与 按系数展开:
对每个 ,方程 写开是
把未知量移到同一边:
这是关于未知系数 的线性方程。未知量个数是
方程个数是 。取临界情形 ,于是未知量比方程多一个。
线性方程组有非零解(齐次方程组,变量多于方程)。由于生成矩阵是满秩的 Vandermonde 矩阵,可以证明这些方程也满秩,解空间是一维的。
为了定出唯一解,利用 的首项系数:若恰好有 个错误,,可以归一化 。代入后解唯一。
最后
做多项式除法就恢复出原始多项式,其系数就是消息。
实际错误的个数少于 时
上面的归一化假设了 。若实际错误更少, 的次数低于 ,,直接归一化会失败。
处理办法有两种:对 逐个尝试并检验;或使用更精巧的算法(Berlekamp–Massey、Euclid 算法),它们能自动确定实际次数。本讲的线性代数解法胜在概念简单,效率不是最优。
串接码:让 RS 真正实用
单用 RS 码有一个硬限制: 。在 中 ,且可纠错误数最多是 。若每个字节都可能出错,错误率超过一半就无法纠正。
具体算一下。设比特错误率 10%,一个字节(8 位)出错的概率是
而 RS 码最多容忍 的符号错误率。,外层 RS 码直接面对比特错误会失败。
两级编码
解决办法是串接两层码:先用内码把每个符号保护起来,再用 RS 码保护符号序列。
内码:查编码表,取 码——8 位消息编成 19 位,最小距离 7,可纠 3 位错误。
外码: 上的 RS 码,、、。
编码顺序:
- 消息按 8 位分组,得到 150 个字节,共 比特;
- 用 RS 外码编码成 256 个字节;
- 每个字节再用内码编成 19 位,共 比特。
解码顺序相反:先对每个 19 位块查表纠正至多 3 位错误,得到 256 个字节;再用 RS 解码纠正至多 53 个字节错误。
效果
一个 19 位块出现 4 个及以上错误的概率(即内码失败概率)约为
经过内码后,每个字节仍有约 11% 的概率是错的。256 个字节中错误数的期望约 29 个,远低于可纠的 53 个;由二项分布尾界,超过 53 个的概率约 。
代价是带宽:1200 比特变成 4864 比特,约 4 倍。由 Shannon 容量 ,理想码只需约 2 倍。相差不到一倍,在 1970 年代已经足够好,RS 码因此使用了三十多年——CD、DVD、深空通信、二维码里都能见到它。
本节结论
- RS 码把消息写成次数 的多项式,在 个不同点上求值作为码字。
- 它是线性码,生成矩阵是 Vandermonde 矩阵,列满秩。
- 非零多项式至多 个根,故最小距离 ,达到 Singleton 界,是 MDS 码。
- 可纠 个符号错误。
- 解码定理:取错误定位多项式 与 ,则对所有求值点 。
- 这些等式是系数的线性方程组,未知量比方程多一个,归一化 后唯一;解出后 。
- 与 的限制使单层 RS 无法应对高比特错误率;串接 内码后,10% 误码率下失败概率约 。
理解检验
1. 为什么「次数不超过 的多项式至多有 个根」能推出最小距离 ?
参考答案:两个不同码字对应两个不同多项式 。它们的差 是次数不超过 的非零多项式,至多有 个根。因此 在 个求值点中至多有 个为 0,也就是两个码字至多在 个位置上相同,至少在
个位置上不同。所以任意两个码字的 Hamming 距离至少是 。取 (零多项式也是合法码字),这个下界可以取到,故最小距离恰为 。
2. 的 RS 码能纠正多少个符号错误?为什么不能再多?
参考答案:,可纠
个符号错误。
不能再多的原因:若想纠 17 个错误,需要 ,但 Singleton 界给 ,矛盾。Singleton 界对任何码都成立,RS 码已经达到它,所以在给定的 、 下距离不可能更大。
3. 为什么生成矩阵是 Vandermonde 矩阵,它为什么满秩?
参考答案:第 行是各求值点上 的取值,即 (按本讲的取点)。把这些行竖排,每列是以求值点为底、幂次递增的向量,正是 Vandermonde 结构。
列满秩(前 行构成的方阵行列式非零)的原因是:Vandermonde 行列式
在求值点互不相同时不为零。因此任意 个求值点上的取值都线性无关,矩阵秩为 。这也是为什么求值点必须互不相同。
4. 在解码定理中, 与 是怎么定义的?为什么 对所有求值点都成立?
参考答案:,其中 是错误位置;。
分两种情况验证:
- 若 是错误位置,则 ,两边都是 0;
- 若 不是错误位置,则 ,于是 。
两种情况下等式都成立。这个恒等式的价值在于:右边 是已知的接收值,左边 、 是待求多项式,于是所有 上的等式组成一个关于系数的线性方程组。
5. 方程组有 个未知量、 个方程,变量比方程多,为什么还能唯一确定 与 ?
参考答案:齐次线性方程组在变量多于方程时必有非零解,且解空间维数至少为 1。可以证明这些方程满秩,所以解空间恰好一维——所有解都是某个非零解的整体倍数。
与 同时乘以常数不影响 ,所以需要额外条件定标。当实际错误数恰为 时,,首项系数 ,归一化 就把倍数固定住,得到唯一解。
若实际错误少于 ,则 ,这个归一化不成立,需要逐个尝试 或改用 Berlekamp–Massey 等算法。
6. 为什么单层 RS 码在 10% 比特误码率下会失败?串接码如何解决?
参考答案: 中一个符号是一个字节。比特错误率 10% 时,字节出错概率为
而 RS 码的可纠错误比例是 ;例如 。 远大于 ,外层码无法处理。
串接码先用 内码把每个字节编成 19 位、纠 3 位错误,把 19 位块失败的概率压到约 11%;这个失败率对应到字节层只有 11%,低于 的 RS 纠错能力,外层 RS 于是能够工作。
7. RS 码已经达到 Singleton 界(MDS),为什么还说它达不到 Shannon 容量?
参考答案:两个界针对的优化对象不同。Singleton 界 固定了 、,只问「在这个码长与维数下距离最大能到多少」;RS 码达到它,因此在这一意义下最优。
Shannon 容量回答的是另一件事:当 、字母表规模随之增长时,可靠传输能达到的最大速率。要达到容量,需要 随 增长并使用长码;而 RS 码受 限制,传统构造下 与 同阶,且解码复杂度随 上升,无法逼近容量。串接码把差距缩小到常数倍,真正接近容量要等 turbo、LDPC、极化码。
8. 串接码的内码为什么可以用查表解码?这在 1977 年的硬件上意味着什么?
参考答案: 内码只有 条码字,但收到的可能是任意 个 19 位串。可以预先把每个可能的接收串映射到最近的码字,做成一张约 50 万条的查找表;解码时直接查表,时间 。
代价是存储。现代计算机轻松容纳 50 万条表项,但 1977 年的 Voyager 探测器内存极为有限,不可能存下整张表。实际系统要么改用更小的内码(减少表项),要么改用解码极简的 Hamming 码(性能略差),要么采用其他结构化方案。课程没有给出 Voyager 的具体做法,只指出它必然在存储与性能之间做了折中。
与前后课的关系
上一讲 Hamming 码用校验矩阵实现单比特纠错,距离固定为 3;本讲用多项式求值把距离提高到 ,代价是运算搬到有限域、解码变成解线性方程组。
两讲合起来构成线性码的两条主线:校验(Hamming,综合解码)与代数构造(RS,错误定位多项式)。后续的 BCH 码、代数几何码都沿着后一条路走;串接码与迭代解码则通向 turbo 码与 LDPC 码。
本讲是编码理论单元的收尾。课程之后转向密码学与秘密共享——那里会再次看到有限域、多项式与线性代数,但目标从「对抗噪声」变成「对抗对手」。
From Hamming codes to polynomials
Hamming codes have minimum distance 3 and correct one bit. As blocks grow longer, the chance of two errors in one block rises quickly, so single-error correction is no longer enough. A code whose distance grows with the block length is needed.
The idea comes from an old algebraic fact:
A nonzero polynomial of degree at most over a field has at most roots.
Encode the message as the values of a polynomial at several points. Two different polynomials then cannot agree at many points — the root bound on their difference gives a distance lower bound. That is a Reed–Solomon code.
Timeline
| Time | Topic |
|---|---|
| 0:00 | History: Shannon 1948, Hamming 1950, Reed–Solomon 1960 |
| 1:05 | Concatenated codes 1966; Berlekamp–Massey decoding 1969 |
| 2:02 | Voyager 1977 uses RS codes; turbo codes in the 1990s |
| 4:54 | Construction: message → polynomial → evaluations |
| 9:40 | The generator matrix is Vandermonde |
| 13:43 | Theorem: minimum distance |
| 17:09 | Correction condition |
| 20:16 | Decoding theorem: exist , with |
| 24:31 | Proof: vanishes at error positions, |
| 30:23 | Decoding as a linear system |
| 36:28 | One more unknown than equations; normalization makes it unique |
| 45:02 | Concatenation: RS outer, inner |
| 59:07 | At a 10% bit error rate, failure about |
| 1:02:41 | Inner decoding by table lookup |
Construction: the message as a polynomial
Let the field be (any works; practice uses ). The message is a list of coefficients
defining
of degree at most .
Choose distinct evaluation points and define the codeword
This lecture takes , i.e. .
Two requirements cannot be dropped:
- , since a field with elements has no more than distinct points;
- the points must be distinct, otherwise two different polynomials could agree at a shared point and the distance argument collapses.
Linearity and the generator matrix
Evaluation is linear in the coefficients: if and , then . So RS codes are linear.
The -th row of the generator matrix is the codeword of "coefficient , all others zero", namely the values of at the points:
All arithmetic is in . For , for instance, , so entries never grow without bound.
This is a Vandermonde matrix: each column holds the powers of one evaluation point. Since the points are distinct, it has full column rank. The codeword of is , whose -th entry is exactly .
Minimum distance:
Theorem. The minimum distance of the RS code is
Proof. A codeword is with .
If is nonzero, it has at most roots, so at most of vanish. Hence every nonzero codeword has Hamming weight at least
The bound is attained (choose with roots at evaluation points), so .
How many errors can be corrected
By the minimum-distance theorem,
Equivalently, correcting errors requires
For a RS code, , so 16 symbol errors can be corrected.
This meets the Singleton bound , so RS codes are MDS (maximum distance separable): for fixed and , the distance cannot be larger.
Note that an "error" here is a symbol, an element of — one byte in — not a bit.
The decoding theorem
The received vector is
where most positions satisfy and a few do not.
Let the error positions be with , and define
- the error-locator polynomial , of degree ;
- , of degree at most .
Theorem. For every evaluation point ,
Proof. Two cases.
If is an error position, then , so the right side is ; the left side is . Equal.
If is not an error position, then , so
Equal again.
The identity looks trivial, but it converts a discrete question — which positions are wrong — into an algebraic one: find a pair of polynomials. The latter can be solved by linear algebra.
Decoding by linear algebra
Expand and by coefficients:
For each , the equation reads
Moving everything to one side:
This is linear in the unknown coefficients . There are
unknowns and equations. At the critical rate , there is one more unknown than equation.
A homogeneous system with more unknowns than equations has a nonzero solution. Because the generator matrix is a full-rank Vandermonde matrix, one shows these equations also have full rank, so the solution space is exactly one-dimensional.
To pin down the scale, use the leading coefficient of : if exactly errors occurred, , so normalize . The solution is then unique.
Finally,
and polynomial division recovers the message coefficients.
When fewer than errors occur
The normalization assumed . If fewer errors occurred, and , so normalizing fails.
One fix is to try in turn and check consistency; another is to use a more refined algorithm (Berlekamp–Massey or the Euclidean algorithm) that determines the actual degree. The linear-algebra method is conceptually simple but not the most efficient.
Concatenated codes: making RS practical
A single RS code has a hard limit: . Over , , and the correctable fraction . If every symbol may be wrong, an error rate above one half cannot be handled.
Concretely, let the bit error rate be 10%. A byte of eight bits is wrong with probability
An RS code tolerates at most symbol errors. Since , the outer RS code cannot face raw bit errors directly.
Two layers
Concatenate an inner code that protects each symbol with an outer RS code that protects the symbol sequence.
Inner code: from a code table, the code — eight message bits into nineteen, minimum distance 7, correcting three bit errors.
Outer code: an RS code over with , , .
Encoding proceeds as:
- split the message into bytes: 150 bytes, i.e. bits;
- encode with the RS outer code into 256 bytes;
- encode each byte with the inner code into 19 bits, giving bits.
Decoding reverses this: table-decode each 19-bit block (up to three bit errors), obtaining 256 bytes; then RS-decode up to 53 byte errors.
Performance
The probability that a 19-bit block has four or more errors — the inner-code failure probability — is about
After inner decoding, each byte is still wrong with probability about 11%. Among 256 bytes the expected number of errors is about 29, well below the correctable 53, and a binomial tail bound puts the probability of exceeding 53 at roughly .
The cost is bandwidth: 1200 bits become 4864, about a factor of four. Shannon's capacity says an ideal code would need only about a factor of two. Being within a factor of two was good enough in the 1970s, and RS codes stayed in service for decades — in CDs, DVDs, deep-space links, and QR codes.
What this lecture establishes
- An RS codeword is a degree- polynomial evaluated at distinct points.
- It is linear, with a full-column-rank Vandermonde generator matrix.
- A nonzero polynomial has at most roots, so ; RS codes meet the Singleton bound and are MDS.
- They correct symbol errors.
- The decoding theorem uses the error locator and , giving at every point.
- These identities are linear in the coefficients; with one more unknown than equation, normalizing yields a unique solution, and .
- The constraints and make a single layer insufficient at high bit error rates; concatenating the inner code brings the failure probability at 10% bit errors to about .
Comprehension check
1. How does "a polynomial of degree at most has at most roots" imply minimum distance ?
Reference answer: Two distinct codewords come from two distinct polynomials . Their difference is nonzero of degree at most , so it has at most roots. Hence among the evaluation points it vanishes at most times, meaning the two codewords agree in at most positions and differ in at least
So every pair of codewords has distance at least . Taking (the zero polynomial is a codeword) attains the bound, so the minimum distance is exactly .
2. How many symbol errors can a RS code correct, and why not more?
Reference answer: , so
symbol errors.
Correcting 17 would require , but the Singleton bound gives , a contradiction. The Singleton bound holds for every code, and RS codes attain it, so no code with these and can do better.
3. Why is the generator matrix Vandermonde, and why is it full rank?
Reference answer: Row lists the values of at the evaluation points, in this lecture's ordering. Stacking the rows, each column holds increasing powers of one point — the Vandermonde structure.
It has full column rank because the Vandermonde determinant of any distinct points is
Hence values at any distinct points are linearly independent and the rank is . This is precisely why the evaluation points must be distinct.
4. In the decoding theorem, how are and defined, and why does hold at every point?
Reference answer: where are the error positions, and .
Two cases:
- at an error position, , so both sides are zero;
- elsewhere , so .
The identity matters because the right side uses the known received values while the left side involves the unknown polynomials, so the equations over all form a linear system in their coefficients.
5. The system has unknowns but only equations. Why is the solution still unique?
Reference answer: A homogeneous system with more unknowns than equations always has a nonzero solution, and here the solution space has dimension at least one. The equations have full rank, so the space is exactly one-dimensional: every solution is a scalar multiple of one nonzero solution.
Multiplying both and by a constant leaves unchanged, so a scale must be fixed externally. When exactly errors occurred, and ; normalizing fixes the multiple and makes the solution unique.
If fewer than errors occurred, and this normalization fails, so one tries each or uses Berlekamp–Massey.
6. Why does a single RS code fail at a 10% bit error rate? How does concatenation fix it?
Reference answer: Over a symbol is a byte, and at a 10% bit error rate a byte is wrong with probability
An RS code corrects a fraction of symbols; for the example, . Since far exceeds , the outer code is overwhelmed.
Concatenation first encodes each byte with the inner code, correcting three bit errors and reducing the failure probability of a 19-bit block to about 11%. That 11% byte error rate is below the RS threshold of , so the outer code can finish the job.
7. RS codes attain the Singleton bound (MDS). Why do they still fall short of Shannon capacity?
Reference answer: The two bounds optimize different things. The Singleton bound fixes and and asks for the largest possible distance at that length and dimension; RS codes attain it and are optimal in that sense.
Shannon capacity asks a different question: as with a growing alphabet, what is the largest rate at which reliable communication is possible? Attaining capacity needs growing with and very long codes, while RS codes require ; in the classical construction and are comparable and decoding cost grows with , so capacity is out of reach. Concatenation narrows the gap to a constant factor; turbo, LDPC, and polar codes close it.
8. Why can the inner code be decoded by table lookup? What did that mean for 1977 hardware?
Reference answer: The inner code has only codewords, but a received block can be any of nineteen-bit strings. One can precompute a table mapping each possible received string to its nearest codeword; decoding is then a single lookup, time.
The cost is memory. A modern computer holds half a million entries trivially, but the 1977 Voyager hardware had very little memory and could not store the whole table. Real systems either used a smaller inner code (fewer entries), or a Hamming inner code (trivial decoding, slightly worse performance), or some other structured scheme. The lecture does not state Voyager's exact choice, only that it must have traded memory against performance.
Relation to neighbouring lectures
Hamming codes from the previous lecture use a parity-check matrix for single-bit correction with distance fixed at 3; this lecture uses polynomial evaluation to raise the distance to , at the cost of working over finite fields and decoding via a linear system.
Together they mark the two main lines of linear codes: checking (Hamming, syndrome decoding) and algebraic construction (RS, error-locator polynomials). BCH and algebraic-geometry codes follow the second line, while concatenation and iterative decoding lead to turbo and LDPC codes.
This closes the coding-theory unit. The course then turns to cryptography and secret sharing, where finite fields, polynomials, and linear algebra reappear — but the adversary is no longer noise, it is an opponent.