Article and note
A Series Learning through the MacWilliams IdentityPart 3 of 12
An Introduction to Tensor Products through the MacWilliams Identity
- Published:
- Updated:
- Reading time:
- 23 min (about 4,875 words)
Introduction
In coding theory, one of the basic theorems is the MacWilliams identity. For a linear code over a finite field with coordinate set , the weight enumerator of its dual code
can be computed from the weight enumerator of as follows:
This is the MacWilliams identity.
In this series, I use proofs of the MacWilliams identity as a guide to an introduction to neighbouring areas and concepts. Accordingly, this series is aimed at readers who already know at least the following basic material:
We assume that the reader already knows, at least at a basic level, the following notions:
what a (finite) field is,
what a linear code over a finite field is,
what the Hamming weight is,
what the dual code is.
(There is no problem if you do not know a proof of the MacWilliams identity.)
In this series, I look at proof methods for the MacWilliams identity under the following five broad families.
Fourier, character, and Poisson methods.
Möbius inversion, lattice theory, and shortening/puncturing methods.
Orthogonal polynomials and association schemes.
Matroids and Tutte polynomials.
Moments and double-counting methods.
The proof in this note belongs to the first family: the Fourier, character-theoretic, and Poisson approach. However, character theory itself is not the main subject of this note. The aim of this note is to use a proof of the MacWilliams identity as a guide to an introduction to tensor products.
In a standard proof of the MacWilliams identity, one extends a transformation appearing in each coordinate to the whole space of words of length . The most natural language for this operation, “extending a one-coordinate transformation to all coordinates at once”, is the language of tensor products. Using tensor products, a word of length ,
can be treated as the product of one-coordinate basis vectors
Then a one-coordinate linear map acts on the space of length as
From this viewpoint, the MacWilliams identity can be read as follows.
Vectorise the code as the sum of the basis vectors corresponding to its words. When a one-coordinate Hadamard-type transformation is made to act on all coordinates by tensor product, that vector is sent to times the code vector of the dual code . Afterwards, reading each basis vector as a monomial produces the variable transformation in the weight enumerator.
The route in this note is as follows.
tensor product → tensor product linear map → tensor representation of words → code vector → complete weight enumerator → MacWilliams identity
Tensor products are a basic tool in multilinear algebra. For a standard reference on multilinear algebra, see Greub [Gre78]; for a more advanced textbook on linear algebra, see for instance Roman [Rom08]. Rather than developing the whole general theory, this note treats, concretely, tensor products of finite-dimensional vector spaces with chosen bases, restricting attention to the part needed for the proof of the MacWilliams identity.
From one-coordinate information to multi-coordinate information
Let us first see why tensor products arise naturally.
Consider a finite alphabet . Later we shall take , but for now think of it simply as a finite set. The value in one coordinate is an element of . A word of length is an element of
To handle one-coordinate information, prepare a basis vector for each alphabet symbol . In other words, consider the complex vector space as a vector space with basis . Here may be viewed as the space of complex-valued functions on the alphabet , but in this note we view it as “the vector space with a basis indexed by the elements of ”.
For a word of length , , we would like to write the corresponding basis vector as . The space needed for this is
Then we obtain the following correspondence.
word of length , ↔ tensor product of basis vectors .
Moreover, if a one-coordinate linear transformation is given, then the transformation which applies it to all coordinates at once is
On pure tensors it acts by
Tensor products provide the language for this operation of extending one-coordinate objects to coordinates. In the tensor-product proof of the MacWilliams identity, we take the -fold tensor product of a one-coordinate Hadamard-type transformation and apply it to a vector representing the whole code.
Definition of the tensor product: construction from bases
Tensor products are often defined abstractly, but in this note we start from a concrete definition using chosen bases of finite-dimensional vector spaces.
Definition 3.1.
Let and be finite-dimensional vector spaces over . Let be a basis of , and let be a basis of . The tensor product of and is the complex vector space whose basis consists of the symbols
It follows immediately from the definition that
Thus, taking the tensor product of an -dimensional space and an -dimensional space produces an -dimensional space.
For arbitrary vectors
define by
An element of this form is called a pure tensor.
From the definition, we have the following bilinearity:
Here . In other words, the tensor product is linear in each variable.
However, not every element of can be written as a single pure tensor . A general element can be written as a finite sum of pure tensors. For example,
usually cannot be decomposed as one pure tensor. This point is important when getting used to tensor products.
Example 3.2.
Let be a basis of , and let be a basis of . Then has the following six basis vectors:
Therefore .
The definition above appears to depend on the chosen bases. Indeed, the concrete construction used bases. However, if the bases are changed, the resulting tensor product is the same up to a natural isomorphism. The following universal property is the basis-free characterisation.
Definition 3.3.
Let , , and be complex vector spaces. A map is called bilinear if, when is fixed, the map is linear, and when is fixed, the map is linear.
Theorem 3.4 (Universal property of the tensor product).
Let and be finite-dimensional vector spaces constructed as above after choosing bases. Then, for any complex vector space and any bilinear map , there exists a unique linear map such that
Proof
Let be a basis of , and let be a basis of . Since has basis , it is enough, in order to define a linear map , to decide its values on the basis. Define
and extend linearly.
If and , then
In the last equality we used the bilinearity of .
Uniqueness follows from the fact that the elements form a basis of and are themselves pure tensors. In other words, must be .
This theorem is the basic principle behind viewing the tensor product as
a device which lets us treat bilinear operations as linear operations.
In the proof of the MacWilliams identity in this note, we treat the coordinatewise product
as a linear map on a tensor product. This feeling that products can be linearised is an important role of tensor products.
Tensor products of many vector spaces
To handle words of length , we need not only the tensor product of two spaces, but the tensor product of spaces.
When the same vector space is prepared times, we write its tensor product as
Suppose that has basis . Then has basis
Therefore
This basis is in one-to-one correspondence with words of length . For , we therefore abbreviate
Then is a basis of .
From now on, even when the coordinate set is an arbitrary finite set, we shall write, to keep the notation light,
Strictly speaking, to write a tensor product one chooses an order of the coordinates, but the calculations in this note do not depend on the ordering. The reader may safely read everything with in mind.
Tensor product linear maps and Kronecker products
What is important about tensor products is that not only vectors, but also linear maps, can be tensored.
Definition 5.1.
Let and be linear maps. Define the linear map
on pure tensors by
This is called the tensor product linear map of and .
This definition determines a unique linear map because the right-hand side is bilinear in , so Theorem 3.4 applies.
For the tensor product of copies of the same linear map , we write
On pure tensors,
In matrix form, a tensor product linear map becomes a Kronecker product. For example, if
then
That is,
Depending on the reference, this matrix is called the Kronecker product of .
For matrix computations with Kronecker products themselves, Horn–Johnson [HJ91, Chapter 4] is a standard reference. For a readable overview including applications, see also Van Loan [Van00]. What we need in this note is the single point that, when a tensor product linear map is written in bases, it becomes a Kronecker product.
Example 5.2 (The Hadamard matrix in the binary case).
As a one-coordinate transformation for , consider
If the rows and columns are indexed by and , this can be written as
The transformation on words of length two is . Order the words, both for rows and for columns, as , , , , and regard the rows as indexed by and the columns by .
The entry of this matrix is
Thus, taking the tensor square of a one-coordinate matrix produces the matrix corresponding to the inner product of length .
This example is the model for the proof in this note. For a general , too, we build a one-coordinate Hadamard-type matrix and take its tensor product to obtain a transformation acting on the whole space of length .
The one-coordinate Hadamard-type transformation over a finite field
We now return to the finite field . Write . The finite field can be viewed as an -dimensional vector space over its prime field .
Choose a basis of over . Then every can be written uniquely as
Put , and define
using the first coordinate of . Here is regarded as the representative when it is placed in the exponent.
The function has the following two properties:
In other words, is a non-constant function which turns addition into multiplication1. These two properties are all that we need in this note.
The property of characters needed for the tensor-product proof of the MacWilliams identity is the following.
Lemma 6.1.
For ,
holds.
Proof
If , then for all , so the sum is .
Suppose that . Then the map is a bijection of , and therefore
Put the right-hand side equal to .
As runs through all of , so does . Hence
Since , it follows that .
Let the one-coordinate complex vector space be , with basis . Define the one-coordinate Hadamard-type transformation on the basis by
In matrix form, this is the matrix
with rows and columns indexed by elements of .
This matrix is the Fourier matrix over the finite field. In this note, however, our focus is not Fourier analysis itself, but the process of extending this one-coordinate matrix to all coordinates by taking tensor products.
Proposition 6.2.
The columns of are mutually orthogonal, and
holds.
Proof
This proposition shows that is the finite-field analogue of a Hadamard matrix. After normalisation, is a unitary matrix. For the MacWilliams identity itself, however, what is important is not this unitarity, but the property, seen below, that the map sends code vectors to dual-code vectors.
Words and codes inside tensor products
From now on, let be a finite coordinate set, and put . For simplicity, when necessary, think of .
Starting from the one-coordinate space , form the multi-coordinate space
For a word , write
Then
is a basis of .
Definition 7.1.
For a code , define
We call this the code vector of .
The code vector is obtained by summing the basis vectors corresponding to all codewords. It may be regarded as the indicator function of the code , written as a sum of basis vectors. For example, if , then
Write the extension of the one-coordinate transformation to all coordinates as
Computing its action on a basis vector gives
Here .
This formula is the centre of the tensor-product proof. In one coordinate, a coefficient appeared. After taking the tensor product, the coordinatewise coefficients are multiplied, and by the additive-character property we obtain
Thus the tensor product multiplies the coordinatewise coefficients, and the property of then gathers that product into the coefficient involving the length- inner product .
The tensor product transformation sends a code to its dual code
Apply the calculation from the previous section to the code vector . Then
Thus the coefficient which appears is
This sum detects whether belongs to .
Lemma 8.1.
For every ,
holds.
Proof
If , then for every . Hence every term is , and the sum is .
Now suppose that . Then there exists some such that . Since , the map is a bijection of . Hence there exists such that . Therefore
Put . Since is a linear code, , and as runs through all of , the element also runs through all of exactly once. Hence
Since , we have .
Theorem 8.2.
For the code vector,
holds.
Proof
This theorem is the linear-algebraic core of the proof in this note. Before viewing the MacWilliams identity as a polynomial identity, we have the following simple equality inside the tensor product space:
In other words, when the one-coordinate Hadamard-type transformation acts on all coordinates by tensor product, the vector representing the code is sent to the vector representing the dual code .
Complete weight enumerators: reading tensors as monomials
So far, we have treated a code as a vector in a tensor product space. Next, we read this vector as a polynomial. The complete weight enumerator is what naturally appears here.
In the ordinary Hamming weight enumerator, for each coordinate one only distinguishes
In the complete weight enumerator, by contrast, we prepare a separate variable for each element of the finite field.
Definition 9.1.
For each , prepare a variable . The complete weight enumerator of a code is
For complete weight enumerators and the MacWilliams identity, MacWilliams–Sloane [MS77, Chapters 5 and 19] is the classical standard reference.
The ordinary Hamming weight enumerator is a specialisation of the complete weight enumerator. Indeed, if we put
then
Therefore
In the language of tensor products, the complete weight enumerator is very natural. Define the linear map from the one-coordinate space to the polynomial ring
by
and
Then, by the universal property of the tensor product, we can define the -coordinate version by
That is,
2 This linear map is the map which reads tensors as monomials.
With this notation,
Thus, when the code vector is read by the map which sends basis vectors to monomials, the complete weight enumerator appears.
The MacWilliams identity for complete weight enumerators
We translate Theorem 8.2 into the language of complete weight enumerators.
First define the one-coordinate change of variables. For , put
This is what we obtain by reading through . Indeed,
Since
expanding this and reading it through gives
Theorem 10.1 (MacWilliams identity for complete weight enumerators).
Let be a linear code. Then
holds, where
Proof
By Theorem 8.2,
Applying to both sides gives
On the other hand,
Hence
and it remains only to divide both sides by .
This is a slightly stronger form than the MacWilliams identity for the Hamming weight enumerator. The change of variables for the complete weight enumerator is obtained from the tensor product linear map .
Specialisation to the Hamming weight enumerator
We specialise the complete-weight-enumerator identity to the Hamming weight enumerator. Put
First compute the case .
Next suppose that . Then
By Lemma 6.1,
Therefore
Thus
Therefore, when we apply this specialisation to the complete-weight-enumerator MacWilliams identity
the left-hand side becomes
and the right-hand side becomes
We have obtained the usual MacWilliams identity for the Hamming weight enumerator:
A small example: the binary repetition code of length
Let us check what the tensor-product proof is doing using the binary repetition code of length . Let
The non-trivial additive character of is
The one-coordinate Hadamard-type matrix is
The code vector is
This code is self-dual, so . Indeed, the condition that be orthogonal to is
which means that or .
Apply to . First,
and
Therefore
This is a concrete example of Theorem 8.2.
The complete weight enumerator is
The one-coordinate change of variables is
Hence
Finally, setting and gives the MacWilliams identity for
What the tensor product was doing in this proof
Let us organise the roles played by the tensor product in the proof.
First, the tensor product represented words as basis vectors. If the one-coordinate basis is
then a word of length is represented as
This makes the code into a single vector
Second, the tensor product extended a one-coordinate transformation to all coordinates. The one-coordinate Hadamard-type transformation
was made to act on the length- space as
As a result, we obtained
When the coordinatewise coefficients are multiplied, the global inner product appears.
Third, the tensor product naturally produced the complete weight enumerator. If in one coordinate we read
then on the tensor product we read
This allowed us to read the code vector as the complete weight enumerator
In short, in the proof in this note the tensor product played three roles:
vectorising words,
lifting a one-coordinate transformation to a multi-coordinate transformation,
treating the product of coordinatewise monomials as a linear map.
Concepts covered in this note
In this note, while aiming at a proof of the MacWilliams identity, we introduced some basic tools of tensor product linear algebra. They may be summarised as follows.
- Tensor product
The vector space constructed from vector spaces . Once bases and are chosen, the elements form a basis.
- Pure tensor
An element formed from and . A general tensor can be written as a sum of pure tensors, but it need not be writable as a single pure tensor.
- Universal property
The tensor product is a device for treating bilinear maps as linear maps. A bilinear map corresponds to a unique linear map .
- Tensor product linear map
From linear maps and , one obtains a linear map . On pure tensors it acts by
- Kronecker product
A tensor product linear map written as a matrix after choosing bases. Taking the -fold Kronecker product of a one-coordinate matrix gives a matrix acting on all words of length .
- Code vector
The vector in the tensor product space which represents a code :
- Complete weight enumerator
A weight enumerator in which a variable is assigned to each element of the finite field. On the tensor product, it is obtained from the linear map sending to .
- Hadamard-type transformation
The one-coordinate linear transformation defined using a non-trivial additive character by
Its tensor product sends the code vector to times the dual-code vector.
Tensor products are often regarded as rather abstract tools, but in this proof they appeared quite concretely. We used the tensor product to extend the one-coordinate basis, the one-coordinate transformation, and the one-coordinate reading of variables to all coordinates at once.
Looking back at this proof family
As stated at the beginning, the proof in this note belongs to the family
Fourier, character-theoretic, and Poisson methods.
On the surface, it is a linear-algebraic proof using tensor products and Kronecker products. But at a deeper level, it uses the one-coordinate Hadamard-type transformation
which is the matrix representation of the Fourier transform over the finite field. For a more advanced perspective on the relation between finite Fourier transforms and weight-enumerator identities for codes, see Tolimieri [Tol85]. This note does not enter that whole picture, but extracts, in elementary form, only the part where a one-coordinate Fourier matrix is made multi-coordinate by taking tensor products.
The key point of the proof in this note can be summarised in one sentence:
When a one-coordinate Fourier matrix is made to act on all coordinates by tensor product, the code vector is sent to the dual-code vector .
From this viewpoint, the MacWilliams identity is obtained by reading the linear-algebraic equality
in the tensor product space as a complete weight enumerator. The identity for the ordinary Hamming weight enumerator is the result of specialising the complete-weight-enumerator identity by
Thus, the proof in this note is very close in spirit to the character-theoretic proof. The difference is that instead of directly computing character sums, we package the one-coordinate character sum as a matrix and then make it multi-coordinate using tensor products. Even though the underlying principle is the same Fourier principle, writing it in the language of tensor products makes the structure of “lifting a local transformation to the whole space” clearly visible.
Next time
Next time, we shall revisit the MacWilliams identity in the language of Krawtchouk polynomials.
In the tensor-product proof in this note, we used the complete weight enumerator. That is, we prepared a variable for each element of the finite field, and used the one-coordinate Fourier matrix itself as a change of variables.
On the other hand, in the ordinary Hamming weight enumerator, all non-zero elements are gathered into the same variable . As a result, the fine information in the complete weight enumerator is forgotten, and only the coefficients for the weights
remain. The Krawtchouk polynomials appear as the coefficient transformation obtained by looking only at these weights.
Next time, we shall view the MacWilliams identity as the coefficient-level transformation
and use it as an introduction to Krawtchouk polynomials.
Footnotes
- Here we have constructed concretely from the first coordinate with respect to the chosen basis. In the language of character theory, a non-constant function satisfying is called a non-trivial additive character of . In many textbooks, functions of the same kind are often constructed using the trace map. In this note, I want to see the role of the tensor product, so I do not go deeply into character theory itself. For a systematic treatment of additive characters and their orthogonality relations, see the second note. ↩
- If you are not yet used to the universal property of the tensor product, it may be clearer to define this directly on the basis. The basis of is (), so define on the basis and extend linearly. ↩
References
- [Gre78] Werner Greub. Multilinear algebra. Springer-Verlag, New York-Heidelberg, pp. vii+294, 1978 ↩
- [Rom08] Steven Roman. Advanced linear algebra. Springer, New York, vol. 135, pp. xviii+522, 2008 ↩
- [HJ91] Roger A. Horn and Charles R. Johnson. Topics in matrix analysis. Cambridge University Press, Cambridge, pp. viii+607, 1991. doi:10.1017/CBO9780511840371 ↩
- [Van00] Charles F. Van Loan. The ubiquitous Kronecker product. J. Comput. Appl. Math., vol. 123, no. 1-2, pp. 85–100, 2000. doi:10.1016/S0377-0427(00)00393-9 ↩
- [MS77] F. J. MacWilliams and N. J. A. Sloane. The theory of error-correcting codes. II. North-Holland Publishing Co., Amsterdam-New York-Oxford, vol. Vol. 16, pp. i–ix and 370–762, 1977 ↩
- [Tol85] R. Tolimieri. The algebra of the finite Fourier transform and coding theory. Trans. Amer. Math. Soc., vol. 287, no. 1, pp. 253–273, 1985. doi:10.2307/2000409 ↩
This series
A Series Learning through the MacWilliams Identity · Part 3 of 12
Disclaimer
Articles on this site are based on the operator's personal understanding, investigation, and research notes. I try to keep the content accurate, but it may contain errors or incomplete explanations. I do not guarantee its accuracy, completeness, usefulness, or currentness.
Please use the information on this site at your own judgment and responsibility. To the extent permitted by law, the operator is not liable for damages, losses, or disadvantages arising from using, or being unable to use, information on this site.
If you notice an error, unclear explanation, broken link, or insufficient citation, please contact the operator. I will review the content and, when appropriate, correct, update, or remove it.