MacWilliams identity 2026-10-05
For a binary linear code of dimension and its dual code, the weight enumerator convention gives
To prove it, insert into the enumerator sum. Summing independently over each coordinate of yields a factor if and if .
A linear code of length and rank is a -dimensional linear subspace of . The Hamming weight of a vector counts its nonzero coordinates. Thus the sum of the coefficients of the weight enumerator is the number of codewords:
Since the zero vector is the unique word of weight zero, . Symmetry of the enumerator therefore implies . Conversely means that the all-one vector belongs to . Translation is then a bijection of which replaces weight by , proving the polynomial symmetry. For length zero the same conclusion holds with the unique empty vector.
The dual code is , using the standard bilinear form over . If , each summand of the character sum equals one. Otherwise choose with ; replacing by permutes the summands and reverses their sign. The sum equals its own negative and must be zero. Consequently
This is character orthogonality for the additive group of the code.
Let and let be the parity-check matrix whose columns are the distinct nonzero vectors of the finite field vector space . The binary Hamming code is
A perfect code has Hamming balls of radius about its codewords partitioning the whole ambient space, where is its minimum Hamming distance of a linear code.
No column of is zero and no two columns agree, so has no word of Hamming weight one or two. Three suitable columns sum to zero, so . For any received word , its syndrome is either zero or is the unique column of equal to that syndrome. In the first case ; in the second,
so is at Hamming distance one from a codeword. Uniqueness follows from . Thus the radius-one balls partition , and the code is perfect.
For , the dual code is the binary simplex code of length seven. Every nonzero dual word evaluates a nonzero linear functional on the seven nonzero vectors of , and exactly four of those evaluations are one. Hence every nonzero word of has weight
Write for the all-one column vector. The parity-check extension of a linear code is
The defining map is linear, so is a binary linear code. If is a generator matrix and a parity-check matrix for , then one may take
The punctured code in, say, the last coordinate is
Coordinate deletion is a linear map, so is linear. Its generator matrix is obtained by deleting the last column of . If the minimum distance is at least two, deletion is injective on , and hence has the same dimension as .
For its parity-check matrix, first use invertible row operations on to make its nonzero last column a coordinate vector. The last column is nonzero because otherwise the weight-one word supported there would belong to , contrary to . Delete the pivot row and the last column; the resulting matrix is a parity-check matrix for . Equivalently, is obtained by shortening the dual code at the deleted coordinate.
Finally, the shortened code in the last coordinate is
It is linear whenever is linear, because it is the puncture of the subspace .
For the standard dot product on , the dual code is
It is an intersection of kernels of linear functions, and is therefore a linear code.
Let denote cyclic right shift. If and , then
A cyclic code is closed under both and , so and the right-hand side vanishes. Hence , proving directly that the dual of a cyclic code is cyclic.
Identify words with polynomials in . If the generator polynomial of a cyclic code is the monic divisor and
then the generator polynomial of is the monic reciprocal
Equivalently, the parity-check polynomial of one code becomes, after reversal, the generator polynomial of its dual.