Week 8 The MacWilliams identity. The Average Weight Equation. Plotkin bound. Simplex codes

Version 2023-11-07. To PDF of this week only Open the whole set of notes in PDF

Synopsis. Remarkably, the weights of codevectors of the dual code C are completely determined by weights of codevectors of C. This was proved by Florence Jessie MacWilliams (1917–1990), an English-born American mathematician who spent most of her career at Bell Labs and Harvard in the United States. We state the general case of the MacWilliams identity. We give a proof (not examinable) for codes over Fp with prime p, and apply the identity to deduce a formula called the Average Weight Equation, as well as the Plotkin bound. We can use the MacWilliams identity to study Hamming codes by analysing their dual codes, called simplex codes.

Theorem 8.1: the MacWilliams identity

If C is a q-ary linear code, WC(x,y)=1#CWC(x+(q1)y,xy).

  • Proof for prime q=p. This proof is not examinable.

    Since p is a prime, the field Fp consists of elements 0,1,,p1 (residues of integers modulo p). Being able to explicitly list the field elements — not possible for a general prime power q — simplifies the proof.

    Let CFpn be linear. We fix the complex number ω=e2πi/p, a primitive pth root of 1. We have ωp=1 and ω,ω2,,ωp11. We can write ωa if aFp — this complex number is well-defined, even though a is only defined modulo p.

    Given cC, vFpn, denote

    Φ(c,v)=ωcvxnw(v)yw(v).

    We will compute cC, vFpnΦ(c,v) in two different ways.

    Way 1. If vC, then cv=0 for all cC, so Φ(c,v)=xnw(v)yw(v).

    If, however, vC, there is a codevector dC such that dv=a0 in Fp. Observe that Φ(d+c,v)=ωdvΦ(c,v)=ωaΦ(c,v). We know that d+C=C, so

    cCΦ(c,v)=cCΦ(d+c,v)=ωacCΦ(c,v)(ωa1)cCΦ(c,v)=0.

    Since ωa1, we have

    cCΦ(c,v)=0for vC.

    We conclude that

    cC, vFpnΦ(c,v)=cC, vCΦ(c,v)=#CvCxnw(v)yw(v)=(#C)WC(x,y).

    Way 2. If v is a symbol, vFp, we introduce the “weight of v”, w(v), as follows: w(v)=1 if v0 and w(v)=0 if v=0. Surely, for a vector vFpn we have w(v)=w(v1)++w(vn). We then rewrite

    Φ(c,v)=ωc1v1++cnvnx1w(v1)yw(v1)x1w(vn)yw(vn)=ωc1v1x1w(v1)yw(v1)ωcnvnx1w(vn)yw(vn). We now sum over vFpn first: each coordinate of v runs over Fp={0,1,,p1}. So, for a fixed cC,

    vFpnΦ(c,v)=v1=0p1vn=0p1Φ(c,v)(*)=v1=0p1ωc1v1x1w(v1)yw(v1)vn=0p1ωcnvnx1w(vn)yw(vn). Let us analyse the first factor in the product on the right-hand side of (*):

    v1=0p1ωc1v1x1w(v1)yw(v1)=x+(v1=1p1ωc1v1)y.

    If c1=0, the coefficient of y is clearly 1+1++1=p1, whereas if c10, the coefficient of y is the sum of a geometric progression

    v1=1p1ωc1v1=1+v1=0p1ωc1v1=1+1(ωc1)p1ωc1=1+01ωc1=1

    since (ωc1)p=1. Hence the first factor on the right-hand side of (*) is

    {x+(p1)y, if c1=0,xy, if c10.

    The same applies to the second, ..., nth factor in (*), hence (*) has w(c) factors equal to xy and nw(c) factors equal to x+(p1)y. In other words, (*) evaluates as (x+(p1)y)nw(c)(xy)w(c). Therefore,

    cCvFpnΦ(c,v)=cC(x+(p1)y)nw(c)(xy)w(c)=WC(x+(p1)y,xy).

    Comparing Way 2 and Way 1, we conclude that WC(x+(p1)y,xy)=(#C)WC(x,y). This is the MacWilliams identity for q=p.

Simple examples where the MacWilliams identity is used

Let us obtain a short formula for the weight enumerator of the trivial code Fqn by writing Fqn as the dual code of the null code Null={0}. Of course, every vector in Fqn is orthogonal to 0 which explains why Fqn=Null.

Clearly, #Null=1 and WNull(x,y)=xn because N has only one codevector, which is of weight 0. Now use the MacWilliams identity:

Example: the weight enumerator of the trivial code Fqn

WFqn(x,y)=1#NullWNull(x+(q1)y,xy)=(x+(q1)y)n.

We can obtain the same formula for the weight enumerator of the trivial code Fqn without the use of MacWilliams identity, see earlier exercises.

The binary (q=2) MacWilliams identity allows us to immediately obtain a short formula for the weight enumerator of the even weight code En. Indeed, En=Rep(n,F2), and the binary repetition code has weight enumerator WRep(n,F2)(x,y)=xn+yn (see example sheets). Also, #Rep(n,F2)=2. Hence

Example: the weight enumerator of En

WEn(x,y)=1#Rep(n,F2)WRep(n,F2)(x+y,xy)=12((x+y)n+(xy)n).

Using the binomial formula, we can expand this sum as xn+(n2)xn2y2+(n4)xn4y4+ In particular, this proves that w(En)=d(En)=2 as the lowest positive power of x in this polynomial is two.

The Average Weight Equation for linear codes

The proof of the following result involves a surprising use of the MacWilliams identity.

Theorem 8.2: the Average Weight Equation

If C is a q-ary linear code of length n, the average of the weights of all the codevectors of C is (nz)(1q1), where z is the number of zero columns in a generator matrix of C.

  • Proof. We count codevectors of weight 1 in the dual code C. By Theorem 5.1, vC iff vGT=0 where G is a generator matrix of C. If v is of weight 1 with vi0, then the ith column of G is zero. The non-zero vi can be chosen in q1 ways, so each zero column of G gives rise to q1 vectors of weight 1 in C, and there are z(q1) such vectors in total.

    We must get the same number as the coefficient of xn1y in the weight enumerator WC(x,y), which by the MacWilliams identity equals

    (8.1)1#CWC(x+(q1)y,xy)=1#CvC(x+(q1)y)nw(v)(xy)w(v).

    We put x=1 and work out the coefficient of y. By the Binomial Theorem,

    (1+(q1)y)nw(v)=1+(nw(v))(q1)y+higher powers of y,(1y)w(v)=1w(v)y+higher powers of y, and so the coefficient of y in the product of these two expressions is

    (nw(v))(q1)w(v)=n(q1)qw(v).

    Summing over vC then dividing by #C gives the coefficient of y in (8.1) as n(q1)q1#CvCw(v). We thus get the equation

    z(q1)=n(q1)q1#CvCw(v),

    hence the average of all weights, 1#CvCw(v), is (nz)q1q as claimed.

A simple example where we verify the Average Weight Equation

The easiest case where we can explicitly verify the Average Weight Equation is C=Rep(n,Fq), the q-ary repetition code of length n. The code consists of the zero vector and q1 vectors of the form aaa where aFq{0}, of weight n. The total number of codevectors is q. The one-row generator matrix [111] of the code does not contain a zero column, so z=0. We arrive at the following

Example: average weight of a codevector of Rep(n,Fq)

The average weight of a codevector of Rep(n,Fq) is

1×0+(q1)×nq=n(1q1),

which agrees with the Average Weight Equation.

  • Exercise. Verify the Average Weight Equation by explicit calculation for the trivial code Fqn.

Simplex codes

What is the weight enumerator of Ham(r,q)? This question can be answered using the MacWilliams identity. In the particular case q=2, the answer can be explored further to give the probability Pundetect for the binary Hamming code (we do not pursue this here).

Recall from the previous chapter that the Hamming codes are defined via an interesting check matrix whose columns form a maximal set of columns where no two columns are proportional. What is the code generated by this matrix? We analyse these codes in the rest of this chapter.

Definition: simplex code

A simplex code Σ(r,q) is defined as Ham(r,q).

Remark: recall that a regular simplex in an n-dimensional euclidean space Rn is a convex polytope whose vertices are n+1 points with the same distance between each pair of points. Thus, a 2-dimensional regular simplex is an equilateral triangle, and a 3-dimensional regular simplex is a regular tetrahedron. The following result motivates our terminology.

Theorem 8.3: properties of a simplex code

The simplex code Σ(r,q) has length n=(qr1)/(q1) and dimension r. The Hamming distance between each pair of codevectors is qr1.

  • Proof. The length and dimension of Σ(r,q)=Ham(r,q) are dictated by the parameters of the Hamming code, see Theorem 7.3. It remains to calculate the distances.

    Since Σ(r,q) is linear, it suffices to show that every non-zero vΣ(r,q) has weight qr1.

    By linear algebra, there is a basis of Σ(r,q) which contains v, hence v is the first row of some generator matrix H of Σ(r,q).

    Since H is a check matrix for Ham(r,q) and d(Ham(r,q))=3, by Distance Theorem 7.2 no two columns of H are proportional, hence the columns of H represent distinct lines in Fqr. Therefore, the weight of v (the first row of H) is the number of lines where the first entry of a representative vector is not zero.

    The total number of possible columns of size r with non-zero top entry is (q1) (choices for the top entry) ×qr1 (choices for the other entries which are unrestricted). But (q1) non-zero columns form a line, hence the number of required lines is (q1)qr1/(q1)=qr1. Hence w(v)=qr1 as claimed.

The weight enumerator of a binary Hamming code

By Theorem 8.3, the weight enumerator of the simplex code Σ(r,q) is

WΣ(r,q)(x,y)=xn+(qr1)xnqr1yqr1

where n=qr1q1. This formula reflects the fact that there is one codevector of weight 0 and qr1 codevectors of weight qr1 in Σ(r,q).

The weight enumerator of Ham(r,q)=Σ(r,q) can then be obtained using the MacWilliams identity. We do this for a binary Hamming code.

Proposition 8.4: the weight enumerator of Ham(r,2)

WHam(r,2)(x,y)=1n+1((x+y)n+n(x+y)n12(xy)n+12) where n=2r1.

  • Proof. The MacWilliams identity, Theorem 8.1, in the case of binary codes gives WC(x,y)=1#CWC(x+y,xy). We put C=Σ(r,2) so that C=Ham(r,2). By Theorem 7.3, n=2r1 so that #C=2r=n+1 and the weight of each non-zero codevector in Σ(r,2) is qr1=2r1=n+12. We also have nqr1=nn+12=n12.

    Substituting these in the MacWilliams identity, we obtain WHam(r,2) as stated.

Example: weight enumerator of the “original” Hamming code

WHam(3,2)=18((x+y)7+7(x+y)3(xy)4)=x7+7x4y3+7x3y4+y7.

Exercise: explicitly expand the left-hand side in the formula for WHam(3,2).

Exercise: Use Proposition 8.4 to show that every binary Hamming code contains the vector 1111 (all bits equal to 1).

The Plotkin Bound

The Plotkin bound was obtained by Morris Plotkin in 1960 for arbitrary (not necessarily linear) binary codes. It applies to codes with very large minimum distance: d>n/2 where n is the length of the code. A proof of the general case of the bound by a direct counting argument can be found in the literature. We will only prove the statement for linear codes, which will serve as an example of the power of the MacWilliams identity and its corollary, the Average Weight Equation. (Historical note: the MacWilliams identity was proved in 1961, i.e., after the Plotkin bound.)

Proposition 8.5: The Plotkin bound for binary linear codes

If CF2n is a linear code such that d=d(C)>n/2, then #Cddn/2.

  • Proof. Let M=#C. The code C contains the zero vector, 0, and M1 vectors of weight at least d. Then the average weight of a codevector of C is at least

    1×0+(M1)×dM=(11M)d.

    So from the Average Weight Equation (where z is the number of zero columns in a generator matrix of C) we obtain

    (nz)(112)(11M)dn2(11M)dn2d11M

    so that 1/M1n/(2d)=(2dn)/(2d) and M2d/(2dn), as claimed.