Homework 2

MTAT.05.082: Introduction to Coding Theory
University of Tartu
Homework 2
Solution
(partially based on solutions by Janno Siim and Tõnis Pool)
It is possible to collect up to 110 points in this homework.
1. Let C be a linear [n, k, d] code over the field F2 . Define the code C 0 by
(
)
n
X
0
C = (c1 , c2 , . . . , cn ,
ci ) (c1 , c2 , . . . , cn ) ∈ C ,
i=1
i.e. the code C 0 is derived from C by adding a parity bit.
(a) Show that C 0 is a linear [n0 , k 0 , d0 ] code over F2 with n0 = n + 1 and k 0 = k.
Solution. Since length of C is n and C 0 is obtained from C by adding one bit to every
codeword, the length of codeword in C 0 is obviously n + 1.
To show that P
k 0 = k, let us show that the function e : C → C 0 , e(c1 , c2 , . . . ,P
cn ) =
(c1 , c2 , . . . , cn , Pni=1 ci ), is injective1 . Indeed, from e(c̄) = e(c̄∗ ), i.e. (c1 , c2 , . . . , cn , ni=1 ci ) =
(c∗1 , c∗2 , . . . , c∗n , ni=1 c∗i ) it immediately follows that (c1 , c2 , . . . , cn ) = (c∗1 , c∗2 , . . . , c∗n ).
So |C| = |C 0 | and therefore their dimensions are the same.
(b) Show that if G is a generator matrix of C then a generator matrix of C 0 has the form


G0 = 
G
g ,
where g is a column vector equal to a sum in F2 of all columns of G.
Solution. Since every row of G is a vector of C and the last element of every row in G0
is a sum of previous elements in this row, then every row of G0 is a codeword from C 0 by
construction.
So to show that G0 is exactly a generator matrix of C 0 we need to show that it has correct
rank. But it is obvious: since G has a full rank (i.e. k), there are k columns in G that are
linearly independent. The same columns are linearly independent in G0 too – therefore
rank of G0 is at least k. But it cannot be more than k because size of G0 is k × (n + 1).
1
Injective function is a fancy synonym for “one-to-one function”.
(c) Show that if H is a parity-check matrix of C then a parity-check matrix of C 0 has the
form


0

.. 

H
. 

.

0 
1 ··· 1 1
Solution. Parity check matrix H 0 of C 0 is an r × n0 matrix such that:
c̄ ∈ C 0 ⇔ H 0 c̄−T = 0̄−T
Take any c̄ = (c1 , · · · , cn , cn0 ), c̄ ∈ C 0 . If



H0 = 

H
1 ···

0
.. 
. 

0 
1 1
Then



H 0 c̄−T = 

H
1 ···


0
c1
..   .. 


. 
 . 
0   cn 
cn0
1 1
As c1 , · · · , cn ∈ C then the first n rows will be 0-s, because H(c1 , · · · , cn )−T = 0̄−T and
0 ∗ cn0 = 0. The n + 1 row is also zero, because if cn0 = 0 then there are even number of
1s in (c1 , · · · , cn0 ). When an array of 1s is multiplied by a column that has even number
of 1s in F2 , the result will be 0. Conversely if cn0 = 1 then there are odd number of 1s
in (c1 , · · · , cn ) and as cn0 = 1 (c1 , · · · , cn0 ) has even number of 1s again. Therefore:

1 ···

c1
. 

 .. 
1 1 
=0
 cn 
cn0
Which means that H 0 c̄−T = 0̄−T
0
Now take any c̄ = (c1 , · · · , cn , cn0 ), c̄ ∈ Fn2 . If:
H 0 c̄−T = 0 means that (c1 , · · · , cn ) ∈ C and

1 ···

c1
. 

 . 
1 1  . =0
 cn 
cn0
2
Which means that cn0 must be have the properties of the parity bit and in fact c̄ ∈ C 0
(d) Show that
• if d is even, then d0 = d;
• if d is odd, then d0 = d + 1.
Solution. From theorem proved in class, we know that d = minc̄∈C\0̄ ω(c̄) where ω(c̄) is
the Hamming weight of the vector c̄.
Hamming weight means the number of non-zero elements. As we are working in F2 , this
means number of ones. If d is even then that means that there are even number of ones
in the code word c̄ ∈ C with the minimum hamming weight. This means that the parity bit of c̄ ∈ C 0 will be 0 and we don’t add any 1-s to c̄. Therefore if d is even then d0 = d.
If d is odd then this means that c̄ has odd number of 1s and the parity bit of c̄ ∈ C 0
will be 1. That means we add a one to the code word with minimum distance in C.
Therefore if d is odd the d0 = d + 1.
2. Let F be a finite field. Show that if the vectors c̄1 , c̄2 , · · · , c̄k ∈ Fn are linearly independent,
then the linear mapping
E : Fk → Fn
defined as
k
X
E (x1 , x2 , · · · , xk ) 7→
xi c̄i
i=1
is one-to-one. In other words, if x̄1 , x̄2 ∈
Fk ,
x̄1 6= x̄2 , then E(x̄1 ) 6= E(x̄2 ).
Solution. Let’s assume by contradiction that ε is not one-to-one. This would mean that
∃x̄, ȳ ∈ Fk , x̄ 6= ȳ but ε(x̄) = ε(ȳ). Then by definition of ε:
Pk
i=1 xi c¯i
⇔
Pk
⇔
Pk
=
i=1 xi c¯i
i=1 (xi
Pk
i=1 yi c¯i
−
Pk
i=1 yi c¯i
= (0, · · · , 0)
− yi )c¯i = (0, · · · , 0)
⇔ ε(xi − yi ) = (0, · · · , 0)
But this is a contradiction P
with the assumption that c¯i are linearly independent. If c¯i are
k
linearly independent then
i=1 yi c¯i = 0 if yi is 0. But we assumed x̄ 6= ȳ which means
x̄ − ȳ 6= 0
3
3. For each pair of the polynomials a(x) and b(x) over finite field F:
(i) find gcd(a(x), b(x)) by using Euclid’s algorithm over F;
(ii) Find polynomials s(x) and t(x) over F such that
s(x) · a(x) + t(x) · b(x) = gcd(a(x), b(x)) ,
when
(a) a(x) = x4 + x3 + x2 + 1, b(x) = x5 + x + 1, and F = F2 (field of integer residues modulo
2).
Solution. Lets first find the greatest common divisor by Euclid’s algorithm. We will
divide x5 + x + 1 by x4 + x3 + x2 + 1.
x4 + x3 + x2 + 1
x + 1
x5
+ x + 1
5
4
3
x + x + x +
+ x
x4
x3
+ 1
x4 + x3 + x2
+ 1
x2
We find that residue is x2 . Next we will divide x4 + x3 + x2 + 1 by x2 .
x2
2
x4 + x3 + 12
x + x + x
x4
x3 + x2
x3
x2
x2
+ 1
+ 1
+ 1
1
We find that residue is 1. Next we will divide x2 by 1.
2
x2
1 x
x2
0
We find that residue is 0 and thus gcd(x5 + x + 1, x4 + x3 + x2 + 1) = 1.
We can find s(x) and t(x) as follows
1 = (x4 + x3 + x2 + 1) − (x2 + x + 1)x2 =
= (x4 + x3 + x2 + 1) + (x2 + x + 1)((x5 + x + 1) − (x + 1)(x4 + x3 + x2 + 1)) =
4
= (x4 + x3 + x2 + 1) + (x2 + x + 1)(x5 + x + 1) + (x3 + 1)(x4 + x3 + x2 + 1) =
= x3 (x4 + x3 + x2 + 1) + (x2 + x + 1)(x5 + x + 1)
Here we simply used the remainders and quotients that we gathered from the long
divisions. Now we can read out that s(x) = x3 and t(x) = x2 + x + 1.
(b) a(x) = 2x3 + x2 + x + 2, b(x) = x4 + x3 + 2x2 + x + 1, and F = F3 (field of integer residues
modulo 3).
Solution. First lets divide x4 + x3 + 2x2 + x + 1 by 2x3 + x2 + x + 2.
2x3 + x2 + x + 2
2x4 + 13
x + x
+ 2x2
x4 + 2x3 + 2x2
2x3
2x3 + 2x2
2x2
+
+
x
x
+ 1
+ 1
+ x + 2
+ 2x + 2
Next lets divide 2x3 + x2 + x + 2 by 2x2 + 2x + 2.
2x2
+ 2x + 2
x + 1
2x3 + x2
2x3 + 2x2
2x2
2x2
+ x + 2
+ 2x
+ 2x
2
+ 2x
2
0
We find that gcd(x4 + x3 + 2x2 + x + 1, 2x3 + x2 + x + 2) = 2x2 + 2x + 2.
From the first long division we get that
2x2 + 2x + 2 = (x4 + x3 + 2x2 + x + 1) − (2x + 1)(2x3 + x2 + x + 2) =
= (x4 + x3 + 2x2 + x + 1) + (x + 2)(2x3 + x2 + x + 2)
We can read out that t(x) = 1 and s(x) = x + 2.
4. (a) Let a be a non-zero element in the finite field F with q elements, and consider the
mapping f : F → F defined by f (x) = a · x. Show that each element of F is the image
under f of exactly one x ∈ F.
5
Solution. First lets show that for every element y ∈ F there exists an x such that
f (x) = y. Let y be an arbitrary element in F. Notice that a is invertible because every
nonzero element in a field has an inverse. Lets choose x = a−1 y. Then
f (a−1 y) = a(a−1 y) = (aa−1 )y = 1 · y = y.
Thus f is onto.
Suppose that for some elements x, y ∈ F we have that f (x) = f (y). Then
ax = ay
a−1 (ax) = a−1 (ay)
(a−1 a)x = (a−1 a)y
1x = 1y
x=y
Therefore f is one-to-one.
(b) Now, (a1 , a2 , · · · , ak ) isP
a non-zero vector over F, and the mapping g : Fk → F is defined
by g(x1 , x2 , · · · , xk ) = ki=1 ai xi . Show, that each element of F is the image under g of
exactly q k−1 vectors in Fk .
Solution. Lets pick an arbitrary element z ∈ F. and lets define Az = {x ∈ Fk | g(x) = z}.
We need to show that |Az | = q k−1 .
First we will show that mapping g is linear. Let x = (x1 , . . . , xk ) and y = (y1 , . . . , yk )
be arbitrary elements from Fk then
g(x) + g(y) =
k
X
k
X
ai xi +
i=1
ai yi =
k
X
i=1
ai (xi + yi ) = g(x + y)
i=1
Let x be an arbitrary element from Fk and λ an arbitrary element from F. Then
λg(x) = λ
k
X
ai xi =
i=1
k
X
ai λxi = g(λx)
i=1
Therefore g is a linear mapping.
There exist ai where i ∈ {1, . . . , k} such that ai 6= 0 because we said that (a1 , . . . , ak ) is
−1
a nonzero vector. Therefore if we pick b = (0, . . . , 0, a−1
i z, 0, . . . , 0) where ai z is on the
−1
i-th coordinate then g(b) = ai (ai z) = z.
Lets define a function w : Ker(g) → Az such that w(x) = x + b. We should confirm that
x + b ∈ Az always. This is true because g(x + b) = g(x) + g(b) = 0 + z = z. Mapping w
is one-to-one because for any x, y ∈ Ker(g) if g(x) = g(y) then x + b = y + b and x = y.
6
Mapping w is also onto. Let y be an arbitrary element from set Az . Then element
y − b ∈ Ker(g) because
g(y − b) = g(y) − g(b) = z − z = 0.
Now we can see that g(y − b) = y − b + b = y and therefore w is onto and also bijective.
This tells us that |Az | = |Ker(g)|. Now we just need to find the size of the kernel.
Notice that (a1 , . . . , ak ) is really the transformation matrix of g. As it only has one
row its rank must be one. By the Rank-Nullity theorem we know that dim(Ker(g)) =
k − rank(g) = k − 1. Therefore basis of Ker(g) has k − 1 vectors and there are as
many different vectors in Ker(g) as there are different linear combinations of k − 1 basis
vectors (up to the ordering). Every basis vector can have any of the q elements of F as
its coefficient and thus the number of different vectors is q · q · . . . q = q k−1 . It follows
that |Az | = |Ker(g)| = q k−1 and we have proved the statement.
(c) Let C be a linear [n, k, d] code over Fq and let T be a q k × n matrix whose rows are the
codewords of C. Show that each element of Fq appears in every nonzero column in T
exactly q k−1 times.
Hint: use 4b. You can use it even if you haven’t proved it.
Solution. Lets choose an arbitrary nonzero column from matrix T . Let it be the i-th
column. Also lets choose an arbitrary element y ∈ F. We have to show that y appears
in i-th column exactly q k−1 times.
Let a = (a1 , . . . , an ) where only the i-th coordinate is 1 and rest of the vector
P contains
only zeros. We will define a mapping gi : C → F such that gi (c1 , . . . , cn ) = ni=1 ai ci =
ci . Now we can ask how many codewords of C map to y by gi . Maybe it is fine to say
here that because C ∼
= Fk this function satisfies the assumptions in 4b and thus there
k−1
are q
codewords that map to y. This would also imply that because gi pick only the
elements from the i-th column it must mean that i-th column has q k−1 occurrences of
y. For me it is not entirely obvious that C ∼
= Fk is sufficient condition here so I guess I
keep going on.
We know that C ∼
= Fk because all vector spaces with equal finite dimensions are isomorphic. Then there also exists some isomorphism f : C → Fk between those two vector
spaces. Lets define a mapping h : Fk → F such that h(x) = gi (f −1 (x)) for every x ∈ Fk .
It is easy(tedious) to confirm that h is a linear mapping. Let x, y be arbitrary elements
from Fk . Then
h(x) + h(y) = gi (f −1 (x)) + gi (f −1 (y)) = gi (f −1 (x) + f −1 (y)) =
= gi (f −1 (x + y)) = h(x + y)
Let x be an arbitrary element from Fk and λ an arbitrary element from F. Then
λh(x) = λgi (f −1 (x)) = gi (λf −1 (x)) = gi (f −1 (λx)) = h(λx).
7
We may also notice that h is not a zero mapping. We know that i-th column of the
matrix T is nonzero thus there exists an element c̄ ∈ C such that gi (c̄) 6= 0. Then also
h(f (c̄)) = gi (f −1 (f (c̄))) = gi (c̄) 6= 0.
Let e = (ē1 , . . . , ēk ) be some basis for Fk . From linear algebra we know that B =
(h(ē1 ), . . . , h(ē1 )) is a linear transformation
matrix for the linear mapping h. In other
P
word we may write h(x1 , . . . , xk ) = ki=1 h(ēi )xi . Also B 6= 0 because otherwise for any
x = l1 ē1 + . . . lk ēk where l1 , . . . , lk ∈ F it would hold that
h(x) = l1 h(ē1 ) + · · · + lk h(ēk ) = 0
But we previously showed that h is not a zero mapping. Now we can ask for how many
elements x ∈ Fk we have that h(x) = y. Based on the statement in 4b the answer is
q k−1 .
Finally we can define two sets Ay = {c̄ ∈ C|gi (c) = y} and A∗y = {x ∈ Fk |h(x) = y}.
Restriction of f to Ay is one-to-one because f is one-to-one. We show that Im(f |Ay ) =
A∗y . Lets pick an arbitrary element x ∈ A∗y . Then h(x) = g(f −1 (x)) = y which means
that f −1 (x) ∈ Ay and f (f −1 (x)) = x ∈ Im(f |Ay ). Similarly if take any element x from
Im(f |Ay ) then there exists c̄ ∈ Ay such that f (c̄) = x. Then also h(x) = h(f (c̄)) = y
and therefore x ∈ A∗y . This implies that f |Ay : Ay → A∗y is a bijection and that
|Ay | = |A∗y | = q k−1 .
8