Reed Muller Codes Sebastian Raaphorst
Reed Muller Codes Sebastian Raaphorst
Sebastian Raaphorst
Carleton University
May 9, 2003
Abstract
This paper examines the family of codes known as Reed-Muller codes. We begin by briefly
introducing the codes and their history before delving in and examining how they are used in
practice. We investigate one particular representation of generator matrices for these codes,
and then discuss the encoding and the decoding process.
After the basics have been covered, we examine the recursive nature of Reed-Muller
codes, and touch on their links to design theory and affine geometries.
Contents
1 Introduction and history 2
1
1 Introduction and history
Reed-Muller codes are amongst the oldest and most well-known of codes. They were discov-
ered and proposed by D. E. Muller and I. S. Reed in 1954.
Reed-Muller codes have many interesting properties that are worth examination; they
form an infinite family of codes, and larger Reed-Muller codes can be constructed from
smaller ones. This particular observation leads us to show that Reed-Muller codes can be
defined recursively.
Unfortunately, Reed-Muller codes become weaker as their length increases. However,
they are often used as building blocks in other codes.
One of the major advantages of Reed-Muller codes is their relative simplicity to encode
messages and decode received transmissions. We examine encoding using generator matrices
and decoding using one form of a process known as majority logic.
Reed-Muller codes, like many other codes, have tight links to design theory; we briefly
investigate this link between Reed-Muller codes and the designs resulting from affine geome-
tries.
Finally, we present the reader with an implementation of the Reed-Muller encoding and
decoding process, written in ANSI C.
Notation: Assume that x and y are vectors over our vector space Fn2 (with x = (x1 , x2 , . . . , xn ),
and y = (y1 , y2 , . . . , yn )). Let a be an element of F2 , where we call a a scalar. Then, we
have the standard operations of addition and scalar multiplication for vectors (these are not
described here, and we assume that the reader is familiar with them). However, we also
extend the set of operations in the following way:
• Scalar addition
a + x = (a + x1 , a + x2 , . . . , a + xn )
• Vector complement
x = 1 + x = (1 + x1 , 1 + x2 , . . . , 1 + xn )
• Vector multiplication
x ∗ y = (x1 ∗ y1 , x2 ∗ y2 , . . . , xn ∗ yn )
2
Note that (Fn2 , +, ∗) forms a commutative ring.
m
Assume that we are given a vector space F22 . Then we consider the ring Rm =
F2 [x0 , x1 , . . . , xm−1 ]. We will see shortly that there exists a bijection between elements of
m m
Rm and F22 (in fact, an isomorphism of rings between (Rm , +, ∗) and (F22 , +, ∗)).
Example: Say we have the Boolean polynomial p = 1 + x1 + x50 x22 + x0 x41 x101
2 ∈ R3 . Then,
by applying the above rules, we can get its reduced form, p′ :
p′ = 1 + x1 + x0 x2 + x0 x1 x2
m
Consider the mapping ψ : Rm → F22 , defined as follows:
3
For any monomial p ∈ Rm , to calculate ψ(p), we find the reduced form:
q = m1 + m2 + . . . + mr
Definition: The r th order Reed-Muller code, denoted RM(r, m), is the set of all polyno-
mials of degree at most r in the ring Rm , as defined in the previous section. Alternatively,
m
through the isomorphism ψ, it may be thought of as a subspace of F22 .
Observation: The 0th order Reed-Muller code RM(0, m) consists of the monomials {0, 1},
which is equivalent to the following vectors:
4
3.1 Encoding and the generator matrix
For the Reed-Muller code RM(r, m), we define the generator matrix as follows:
⎡ ⎤
ψ(1)
⎢ ψ(x0 ) ⎥
⎢ ⎥
⎢ ψ(x ) ⎥
⎢ 1 ⎥
⎢ .. ⎥
⎢ . ⎥
⎢ ⎥
⎢ ψ(xm−1 ) ⎥
⎢ ⎥
⎢ ψ(x0 x1 ) ⎥
GRM(r,m) = ⎢
⎢ ψ(x0 x2 )
⎥
⎥
⎢ . ⎥
⎢ .
. ⎥
⎢ ⎥
⎢ ψ(xm−2 xm−1 ) ⎥
⎢ ⎥
⎢ ψ(x0 x1 x2 ) ⎥
⎢ ⎥
⎢ . ⎥
⎣ .
. ⎦
ψ(xm−r xm−r+1 . . .xm−1 )
5
Example: The generator matrix for RM(2, 4) is:
⎡ ⎤ ⎡ ⎤
ψ(1) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
⎢ ψ(x0 ) ⎥ ⎢ 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ψ(x1 ) ⎥ ⎢ 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ψ(x2 ) ⎥ ⎢ 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ψ(x3 ) ⎥ ⎢ 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ⎥
⎢ ⎥ ⎢ ⎥
GRM(2,4) = ⎢
⎢ ψ(x0 x1 )
⎥=⎢ 1 1 1 1 0
⎥ ⎢ 0 0 0 0 0 0 0 0 0 0 0 ⎥
⎥
⎢ ψ(x0 x2 ) ⎥ ⎢ 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ψ(x0 x3 ) ⎥ ⎢ 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ψ(x1 x2 ) ⎥ ⎢ 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 ⎥
⎢ ⎥ ⎢ ⎥
⎣ ψ(x1 x3 ) ⎦ ⎣ 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 ⎦
ψ(x2 x3 ) 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0
n = 2m
The dimension of the code is hence k.
Encoding is then easy; we are given a message m ∈ Fk2 and we simply perform the
multiplication m ∗ GRM(r,m) to get our codeword c.
Example: Assume we want to encode the message m = 01101001010 using RM(2, 4).
We have:
c = m ∗ GRM(2,4) = 1010111111111010
6
3.2 Decoding using majority logic
There are different techniques available for decoding Reed-Muller codes, but one of the most
common and most easily implementable is majority logic decoding. We will investigate one
form of this technique here.
Before we begin, we will give mention to the error-correcting capabilities of Reed-Muller
codes. Given the code RM(r, m), the distance between any two codewords is 2m−r . This
is not proven here; interested readers can refer to theorem 2 in section 4.2 of this document
for a detailed proof of this fact that relies on the recursive definition of Reed-Muller codes.
To correct ϵ errors, we must have a distance strictly greater than 2ϵ. Thus, in the case of
Reed-Muller codes, since we have distance 2m−r , we can correct max(0, 2m−r−1 − 1) errors.
We now look at a basic algorithm for decoding using majority logic. The essential idea
behind this technique is that, for each row of the generator matrix, we attempt to determine
through a majority vote whether or not that row was employed in the formation of the
codeword corresponding to our message.
Definition: Let p be any monomial of degree d in Rm with reduced form p′ . Then we form
the set J of variables not in p′ and their complements. The characteristic vectors of p are
all vectors corresponding to monomials of degree m − d over the variables of J . Note: Any
monomial containing a variable and its complement corresponds to the 0 vector (through ψ:
ψ(xi xi ) = ψ(xi ) ∗ ψ(xi ) = 0). Since ψ is a bijection and ψ −1 (0) = 0, this implies that any
monomial containing both a variable and its complement is equivalent to the monomial of
degree 0. Thus, without loss of generality, we only consider monomials where the variables
are distinct (i.e. no variable and its complement appears).
Example: If we are working over RM(3, 4), the characteristic vectors of x0 x1 x3 are the
vectors corresponding to the monomials {x2 , x2 }. The characteristic vectors of x0 x2 are the
vectors corresponding to the monomials {x1 x3 , x1 x3 , x1 x3 , x1 x3 }.
The way in which we accomplish this is that we begin at the bottom of our generator
matrix and work our way upwards. Our algorithm starts by examining the rows with mono-
mials of degree r. We begin by calculating 2m−r characteristic vectors for the row, and then
we take the dot product of each of these vectors with our received message. If the majority
of the dot products are 1, we assume that this row was used in constructing our codeword,
and we set the position in our original message vector corresponding to this row to 1. If the
majority of the dot products are 0, then we assume that this row was not used in forming
our message, and hence, we set the corresponding entry in the original message vector to 0.
After we have run this technique
.m/ for all rows corresponding to monomials of degree r,
we take the vector of length r corresponding
. / to the portion of the message we have just
calculated, and we multiply it by the mr rows of our generator matrix that we have just
considered. This gives us a vector s of length n. We add s to our received message, and
proceed recursively on the rows corresponding to monomials of degree r − 1.
This is best clarified by an example.
Example: We decode the message u = 00110110 in RM(2, 3). The generator matrix for
this code can be found in the preceeding subsection.
7
As per the algorithm, we begin from the bottom of the matrix up, first considering the
rows corresponding to monomials of degree r = 2.
Row x1 x2 has characteristic vectors x0 , x0 .
0
u · ψ(x0 ) = 0
→m= 0
u · ψ(x0 ) = 0
We continue to proceed in this fashion, to discover that the original message was v =
0111010 (we can trivially check that this is correct by verifying that v · GRM(2,3) = u). In
this case, u had no errors (indeed, RM(2, 3) can correct 0 errors, which makes it a poor
choice of code, but it will suffice for the purposes of this example).
8
4.1 An alternate view of ψ
Another way that we can think of ψ is as follows. Consider the ring Rm and the vector space
Fm
2 . We can consider the vectors in F2 simply as binary representations of the elements in
m
Z2m , and thus we can derive a natural ordering from this observation.
Example: Suppose we are considering F32 . Our natural ordering for the vectors in this
vector space is as follows:
Let S be the set of all monomials in Rm . Let p ∈ S be a Boolean monomial with reduced
form p′ with the form p′ = xi1 xi2 . . .xir (ij ∈ Zm , ij = ik → j = k, 0 ≤ r ≤ m). We consider
the function α, defined as follows (where P(X ) is the power set of X ):
α : S → P(Zm )
7
′ ∅ : if r = 0
p ≡ p = xi1 xi2 . . .xir )→
{i1 , i2 , . . . , ir } : otherwise
We then define a class of certain functions. Given T ∈ P(Zm ), we define the following
function:
fT : Fm
2 → F2
7 8
(x0 , x1 , . . . , xm−1 ) )→ i∈T (xi + 1) : if T ̸= ∅
1 : if T = ∅
f{0,2} (1011) = (1 + 1) · (0 + 1) = 0 · 1 = 0
f{0,2} (0101) = (0 + 1) · (0 + 1) = 1 · 1 = 1
9
7
β(0) : x=0
x = m1 + m2 + . . . + mr )→
β(m1 ) + β(m2 ) + . . . + β(mr ) : x ∈ Rm \ {0}
This more precise definition of ψ is consistent with our previous definition of ψ, and this
is best shown with an example.
Example: Using ψ as defined above, we construct GRM(2,3) . The rows of GRM(2,3) corre-
spond to the monomials {1, x0 , x1 , x2 , x0 x1 , x0 x2 , x1 x2 }, and to get each row, we evaluate ψ
for each monomial.
ψ(1) = β(1) = (f∅ (000), f∅(001), . . . , f∅ (111)) = 11111111
ψ(x0 ) = β(x0 ) = (f{0} (000), f{0} (001), . . . , f{0} (111)) = 11110000
ψ(x1 ) = β(x1 ) = (f{1} (000), f{1} (001), . . . , f{1} (111)) = 11001100
ψ(x2 ) = β(x2 ) = (f{2} (000), f{2} (001), . . . , f{2} (111)) = 10101010
ψ(x0 x1 ) = β(x0 x1 ) = (f{0,1} (000), f{0,1} (001), . . . , f{0,1} (111)) = 11000000
ψ(x0 x2 ) = β(x0 x2 ) = (f{0,2} (000), f{0,2} (001), . . . , f{0,2} (111)) = 10100000
ψ(x1 x2 ) = β(x1 x2 ) = (f{1,2} (000), f{1,2} (001), . . . , f{1,2} (111)) = 10001000
As we can see, these vectors form the rows of GRM(2,3) as defined in section 2.
1. RM(0, m) = {00.
! "#. .0$}
2m
m
2. RM(m, m) = F22
Example: Using the recursive definition of Reed-Muller codes, we find RM(1, 2):
This recursive definition of the codes translates to a recursive definition of the generator
matrix, as follows: 9 :
GRM(r−1,m) GRM(r−1,m)
GRM(r,m) =
0 GRM(r−1,m−1)
where we consider the following base cases:
10
GRM(0,m) = {11.
! "#. .1$}
2m
⎡ ⎤
GRM(m−1,m)
GRM(m,m) = ⎣ 00.
! "#. .0$ 1
⎦
2m −1
Example: Using the recursive definition of generator matrices for Reed-Muller codes, we
construct GRM(2,3) :
9 :
GRM(2,2) GRM(2,2)
GRM(2,3) =
⎡ 0 GRM(1,2) ⎤
GRM (1, 2) GRM (1, 2)
⎢ 0 0 0 1 0 0 0 1 ⎥
= ⎢ ⎣ 0 0 0 0 GRM(1,1) GRM(1,1) ⎦
⎥
⎡ 0 0 0 0 0 0 GRM(0,1) ⎤
GRM(1,1) GRM(1,1) GRM(1,1) GRM(1,1)
⎢ 0 0 GRM(0,1) 0 0 GRM(0,1) ⎥
⎢ ⎥
⎢
= ⎢ 0 0 0 1 0 0 0 1 ⎥ ⎥
⎣ 0 0 0 0 GRM(1,1) GRM(1,1) ⎦
⎡ 0 0 0 0 0 ⎤ 0 GRM(0,1)
1 1 1 1 1 1 1 1
⎢ 0 1 0 1 0 1 0 1 ⎥
⎢ ⎥
⎢ 0 0 1 1 0 0 1 1 ⎥
⎢ ⎥
= ⎢ ⎢ 0 0 0 1 0 0 0 1 ⎥
⎥
⎢ 0 0 0 0 1 1 1 1 ⎥
⎢ ⎥
⎣ 0 0 0 0 0 1 0 1 ⎦
0 0 0 0 0 0 1 1
One interesting property of the recursive definition is that it facilitates proving certain
properties of Reed-Muller codes; recursion allows us to derive inductive proofs that are, in
these cases, much simpler than non-inductive proofs.
Proof. (from [4]) Let wt(x) denote the weight of x in the code.
We proceed by induction on r. By definition:
11
1. x ̸= y
By the inductive hypothesis, the weight of x + y must be at least 2(m−1)−r . We also
have that the weight of x is at least 2(m−1)−r . Thus:
2. x = y
We then have that (x, x+y) = (x, 0) = (y, 0), and we know that y ∈ RM(r −1, m−1),
so we have that:
In AG(V), the points correspond to the 0-flats. The 1-flats are the lines and the 2-flats
the planes, with incidence defined by containment, as we will see in an example in a moment.
Example: We consider the field F = F2 and the vector space V = F32 . We then determine
the subspaces of V, partition them by dimension, and derive the cosets. For brevity, we
write vectors of V as 0-1 strings.
The subspace of dimension 0 is:
{000}
The cosets over this subspace give us the 0-flats, or the points, of our geometry:
12
The subspaces of dimension 1 are:
The cosets over these subspaces give us the 1-flats, or lines, of our geometry:
{000, 001, 010, 011} {000, 001, 100, 101} {000, 001, 110, 111} {000, 010, 100, 110}
{000, 010, 101, 111} {000, 011, 100, 111} {000, 011, 101, 110}
The cosets over these subspaces give us the 2-flats, or planes, of our geometry:
{000, 001, 010, 011} {000, 001, 100, 101} {000, 001, 110, 111} {000, 010, 100, 110}
{000, 010, 101, 111} {000, 011, 100, 111} {000, 011, 101, 110} {100, 101, 110, 111}
{010, 011, 110, 111} {010, 011, 100, 101} {011, 011, 101, 111} {001, 011, 100, 110}
{001, 010, 101, 110} {001, 010, 100, 111}
Trivially, the only subspace of V of dimension 3 is V, and the only coset derivable from this
subspace is V.
We also note that if, for an affine geometry AG(V), we take the set of 0-flats and the set
of s-flats (with s > 0) together, they form a balanced incomplete block design, with the set
of 0-flats as the points, and the set of s-flats as the blocks.
Example: In the previous example, we notice that the set of 0-flats as the points with
the set of 1-flats as the blocks forms a 2-(8, 2, 1)-BIBD. If we take the set of 0-flats as our
points and the set of 2-flats as our blocks, we have a 3-(8, 4, 1)-BIBD.
In the next section, we briefly examine the links between these designs and Reed-Muller
codes.
13
Theorem 3. RM(r, m) is the binary code of the design of points and (m − r)-flats of
AG(Fm
2 ).
We do not prove this theorem, but it simply requires showing that the incidence vectors
of the (m − r)-flats of AG(Fm
2 ) span RM(r, m). A detailed proof may be found in [1].
Example: We demonstrate how RM(1, 3) is the binary code of the design of points and
2-flats of AG(F32 ). We have already investigated AG(F32 ) in the previous section, and we will
rely on the results we obtained there.
We examine how the incidence vectors of the plane equations corresponding to the 2-flats
of AG(Fm 2 ) are actually codewords in our design. Recall that GRM(1,3) , using the isomorphism
ψ, is as follows: ⎡ ⎤
ψ(1)
⎢ ψ(x0 ) ⎥
GRM(1,3) = ⎢⎣ ψ(x1 ) ⎦
⎥
ψ(x2 )
Then it is easy to see that the 16 messages over F42 correspond to the codeword vectors
associated with the following equations:
Now we examine our design; each block corresponds to a plane, and each plane has an
14
incidence vector, as per the following table:
The vectors 0000 and 1111 in F42 do not have planes associated with their codewords;
however, their associated geometric structures may be formed by linear combinations of the
planes of the others.
Thus, Reed-Muller codes can be associated with the designs of affine geometries, and
indeed, several majority-logic decoding techniques have arisen because of this association.
15
A Implementation of Reed-Muller encoding and de-
coding
Using the techniques found in section 3, I have implemented two command-line applications
to perform encoding and decoding of Reed-Muller codes.
These applications have been coded in ANSI C and hence, should compile on any platform
that has an available C compiler. The source code is available on my personal web page, at
http://www.site.uottawa.ca/~raaphors
16
~ -> ./rmencode 2 5 1111111111111111
01111110111010001110100010000001
~ -> ./rmdecode 2 4 1010111111111010
01101001010
~ -> ./rmdecode 2 4 1010111011111010
01101001010
~ -> ./rmdecode 2 4 1011111111111010
01101001010
~ -> ./rmdecode 2 5 01111110111010001110100010000001
1111111111111111
~ -> ./rmdecode 2 5 01101110101010001110101010000001
1111111111111111
~ ->
Note that in the final example, we add an error vector of length 3 to the encoding of
1111111111111111 (namely 00010000010000000000001000000000), and the program decodes
the correct message. This is as we expect in RM(2, 5), which can correct at most 25−2−1 −1 =
3 errors.
17
References
[1] Assmus, Jr., E. F. and Key, J. D. Designs and their Codes. Press Syndicate of the
University of Cambridge, Cambridge, 1992.
[2] Cameron, P. J. and Van Lint, J. H. Designs, Graphs, Codes, and their Links. Cambridge
University Press, Cambridge, 1991.
[3] Cooke, Ben. Reed-Muller Error Correcting Codes. MIT Undergraduate Journal of Math-
ematics Volume 1, MIT Department of Mathematics, 1999.
[4] Hankerson, D. R. et al. Coding Theory and Cryptography: The Essentials. Marcel
Dekker, New York, 1991.
[5] MacWilliams, F. J. and Sloane, N. J. A. The Theory of Error Correcting Codes. North-
Holland Mathematical Library Volume 16, Elsevier Science B. V., Amsterdam, 1977.
18