TEACHING ERROR-CORRECTING CODES, DISCRETE MATHEMATICS AND MODERN
ALGEBRA WITH COMPUTER ALGEBRA
Igor Guchkov {Karlstads University, Sweden. E-mail: [email protected]}
The author (with Kenneth Hulth) got the idea to develop a non-standard, inelhodical-oriented course where hands-on sessions could add substantial understanding in the introduction of mentioned mathematical concepts. The package in MATHEMATICA in the field «Coding Theory» was developed at the School of Engineering Jonkoping, Sweden, and the first course was given autumn 1994 for students of advanced undergraduate level. The first results of our courses were presented at the International IMACS Conference on Applications on Computer Algebra in University of New Mexico in 1995, along with a short presentation of the package «Coding Theory», written in MATHEMATICA where opportunities of package to illustrate the prove of complicated theorems with example of the Theorem (Sidelnikov): Let K be an binary code, and let d>3 be the minimal distance of the dual code K. Then the weight distribution of the code K is asymptotically normal were demonstrated.
Apart from the mentioned course modules, the students at School of Engineering can choose to write a (limited) scientific project in Coding Theory using computer algebra, as the final project of the undergraduate programme. Also from this field the authors have positive experiences.
As one of the project was choosen a project about effective search and changing of the basis of the Galois field GF[2"] over GF[2) which reproduces RS (Reed-Solomon) code to binary code with maximal code distance. The results were presented at the IMACS conference in Wailea, Maui, Hawaii. USA 1997.
We will also outline how we with the help of our package have recently found a solution of a research problem. This result gives an indication of how Computer .Algebra can be used to create new knowledge, hardly achievable without computers. By using of possibilities of the package we have an opportunity to give a simple description of the Wagner code with parameters to calculate weight polynomial and to prove that the code is quasi-perfect.
The package ” Coding Theory”
The package ” Coding Theory” is a file written in MATHEMATICA Version 3.0 and will be read into MATHEMATICA with the commands.
In[l] : = <<CodingTl.m In[2] : = <<CodingT2.m The package consists of two parts: purposes.
GeneratorMatrix Parity CheckMatrix DimensionCode DistanceCode Syndrome EquivalentCode DualCode
McWilliamsIdentity ExtendedCode PuncturedCode AugmentedCode ExpurgatingCode SingletonBound HammingBound Gilbert VarshamovBound ErrorTrappingDecodeHammingCode
one part with illustrative explanations, and one for scientific
RectangularCode
DecRectangularCode
MeggittDecode
SystematicEncode
WeightPolynomial
HammingMatrix
HammingCode
DecHammingCode
GeneratorPolynomials
CyclicCode
NonsystematicEncodeCyclicCode
SystematicEncodeCyclicCode
VEC
Binary IrreduciblePolynomials BinaxyGaloisField ErrorTrappingDecodeB CHCode
'Karlstads University, Sweden. E-mail: [email protected]
The illustrative part (commands starting with Show.,.) is considered to visualise the theoretical aspects of encoding / decoding, construct shiffc-register circuits etc.
ShowHammingCode ShowDecHammingCode
ShowBinaryGaloisField ShowStandardArrays
ShowMeggittDecoder ShowDecRectangularCode
ShowBurstRectangularCodeVector ShowSystematicEncode
ShowNonsystematicEncoderCyclicCode ShowErrTrappDecBCHCode
ShowCorrectBurstRectangularCode ShowSystEncCyclicCode
ShowReconstructlnformRectangularCode ShowTablePlus ShowCyclicCode ShowTableMult
The first opportunities of package were demonstrated at the International IMACS Conference on Applications on Computer Algebra in University of New Mexico in 1995, along with a short presentation of the package ’’Coding Theory”.[1]
Reed-Solomon codes
We continue researching of the codes, which get from RS codes by appropriate change of the basis.[2]
A Reed-Solomon (RS) code over the Galois Field GF (q) is a special BCH - code having the length of the code words equal to the number of nonzero elements in the ground field. The RS - codes are cyclic and have as generator polynomial g (x) = (x -b)(x -b2) ... (x -b2*), where b is a primitive element of GF(q), whereas t is the number of errors the designed code corrects.
The elements of GF(q) can be represented as m-tuples of elements from GF(p). Choosing p = 2 we get the binary codes by substituting for each symbol in GF(2m) the corresponding binary m - tuple. The received code with length nm has found great practical importance due to its capability to correct burst errors of length (t - 1) m + 1.
In[3]~
r=BinaryIrreduciblePolynomials[3,x][[2]]
Out[3] =
1 + x + x3 In[4] :=
ShowBinaryGaloisFieldfrjc.a.al Out [4]:=
The Galois Field GF(8) with the irreducible polynomial x3 + x + 1
Log Vector pr.el. polynomial min polynomial
000 0 0 0
0 100 1 1 x +1
1 010 a a X3 +1+1
2 001 a2 a r X3 + X + 1
3 110 a3 a+1 X3 + X2 + 1
4 011 a4 a+a2 X3 + X + 1
5 111 a5 1-t-a+a- X3 + X2 + 1
6 101 a6 1+a2 X3 + X2 + 1
We next construct the generator polynomial for the RS-
code distance 4.
In [5] :=
GF8=Binary GaloisField[r.x.a,a]; b=l; d=4: g=Product[x-GF8[[2+b+i,3]],{i,0,d-2}] Out [5]=
(-a + x) (-a2 + x) (-a3 + x)
In [6] :=
g=Collect [PolynomialMod[PolynomialMod [Expand [g] ,r/.x->a] ,2] ,x]
Out [6]=
1 + a2 + a x + (1 + a2 ) x2 4- x3
We have got the RS - code with the generator polynomial g with parameters [7, 4, 4,] over the field GF (8), with 4 information bits our RS - code has 84 = 212 = 4096 code words.
A change of the basis (the representation of the elements of the field GF(8) as binary vector ) may change the minimum weight of the code. If we take the standard basis : 1->(0,0,1); a->(0,l,0),
a2 ->(1,0,0) we get the binary code with parameters [ 3*7=21,3*4=12, 4] with the same code distance. The basis ei = {0,1,1}, e2 = {0,1,0}, e3 = {1,1,0} which we get in [2] gives the increase of the code
distance from 4 to 5 and causes the code with parameters [21,12,5].
Finally we have obtained the weight polynomial of the code: l+21x5+168x6+360x7+210x8+280x9-+ 1008x10+1008xn+280x12+210x13+360x14+168x15+21x16+x21.
However the investigation of cyclic code of length 21 (namely the weight distribution) leads to the conclusion that those two codes are equivalent (the latter is BCH code).
In[7] :=
Factor [x * 21-1,Modulus- >2]
Out [7] =
(1 + x)*(l + x + x2)*(l + x + x3)* (1 + x2 + x3)* (1 + x + x2 + x4 + x6)*
(1 + x2 + x4 + x5 + x6)
In[8] :=
g= (1 + x~2 + x~3)* (1 + x + x"2 4- x~4 + x~6)
Out [8] =
(1 + x2 + x3)* (1 + x + x2 + x4 + x6)
In[9] :=
H=CyclicCode[g,21,x][[l]]; Print[Length[H[[l]]]]; Print[DimensionCode[H]]; Print[DistanceCode[H]] Out [9] =
21
12
5
In[10] :=
WeightPolynomial [H pc]
0ut[10] =
l+21x5-f-168x6+360x7+210x8+280x9+1008x1°+1008x11+280x12+210x13+360x14+
168x15+21x16+x21
Changing of the entire possible non-trivial basis which increase the code distance and the investigation of the weight distribution justifies the statement about the equivalency between those codes and the BCH code.
Double -Error-Correcting Codes
As distinct example of package usage let us look at a simple method of building of codes with 9 correcting bits which correct two errors.
In[ll] :=
GF=Table[VEC[i,9],i,l,2*9-l];
In[12] :=
< <DiscreteMath‘Combinatorica‘
In[13] :=
ML={0,0,0} ;H= IdentityMatrix[9];Do[Do[L=KSubsets[Hj];
ML[[j]]=Table[Mod[Apply[Plus,L[[i]]] ,2] ,i, 1 ,Length[L]] j, 1,3];
FM=Union[Flatten[ML,l]];Res=Complement[GF,FM];HS=H;v=Res[[l]];
Do[If[Apply[Plus,Ees[[i]]]==6,v=Res[[i]]],i,l,Length[Res]];AppendTo[H,v],14];H
Out[13] =
{{1, 0, 0, 0, 0, 0, 0, 0, 0}, {0,1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 0}, {1, 1, 1, 1, 0, 0, 1, 1, 0}, {1, 1, 1, 0, 1, 0, 1, 0, 1},
{1, 1, 0, 1, 1, 0, 0, 1, 1}, {1, 1, 0, 0, 0, 1, 1, 1, 1}, {1, 0, 1, 1, 0, 1, 1, 0, 1}, {1, 0, 1, 0, 1, 1, 0, 1, 1},
{1, 0, 0, 1, 1, 1, 1, 1, 0}, {0, 0, 0, 0, 1, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 1, 0, 0, 1}, {0, 0, 1, 1, 1, 0, 1, 0, 0},
{0, 1, 0, 1, 0, 0, 1, 0, 1}, {0, 1, 1, 0, 0, 1, 0, 1, 0}, {1, 0, 0, 1, 1, 0, 1, 0, 1}}
We get the parity-check matrix of code.
In[14] :=
PM=Transpose[H]
Out[14] =
10000000011111111000001 01000000011111000000110 00100000011100110001010 00010000011010101011101 00001000010110011111001 00000100010001111010010 00000010001101101101101 00000001001011011100010 00000000100111110110101 The calculations of the parameters of code proceeds immediately.
In[15] :=
Print[Length[PM[[l]]]];Print[DimensionCode[PM]];Print[DistanceCode[PM]]
Out[15] =
23
14
o
The found code is to be classified as a Wagner quasi-perfect code. [5] Indeed, by presenting this code we have solved a research problem, described in MacWilliams and Sloane.(page586 viii [4])
The following calculations prove that the code is quasi-perfect.
In[16] :=
LL=Flatten[KSubsets[H,3],KSubsets[H,2],KSubsets[H,l],l];
GFU=Union[Table[Mod[Apply [Plus, LL[[i]]] ,2] ,i,l, Length [LL]]] ;Length[GFU]
Out[16] =
511
Finally we determine weight polynomial of the code with demonstration that the weight distribution is asymptotically normal.
In[17] :=
WP=WeightPolynomial [PM, x];WPCoeff=CoeffidentList[WP,x]
Out[17] =
{1,0,0,0,0,84,252,445,890,1620,2268,2632, 2632,2268,1620,890,445,252,84,0,0,0,0,1}
In[18] :=
ListP lot [WP Coeff/2 '‘kj;
In[19] :=
lpl=ListPlot[WPCoeff/2"k,PlotJoined->True];
In[20] :=
<<Statistics‘NormalDistribution‘
In[21] :=
<<Statistics‘Common‘DistributionsCommon‘
In[22] :=
m=N[Sum[( WPCoeff[[i]]*i)/(2 *k) ,i,l ,23]]
Out [22] =
12.49853515624999 In[23] :=
dsp=Sqrt [Sum [((m-i)~ 2) * (WP Coe2[[i]] /2" k) ,i, 1,23]] //N Out[23] =
2.396232081802999 In[24] :=
ndb=NormalDistribution[m,dsp]
Out [24] =
NormalDistribution[12.498535156249\par 99, 2.396232081802999]
In[25] := nf=PDF[ndb,x]
Out [25] =
0.1664873296000845/ E"(0.0870787623019755* (-12.49853515624999 -I- x)~2)
In[26] :=
lp2=Plot[nfpc,0,23];
In[27] :=
Show[lpl,lp2];
Bibliography.
1. Gachkov I. Hulth K. Coding Theory in Mathematica ( in proceedings of IMACS conference, University of New Mexico, USA, 1995).
2. Gachkov I. Hulth K. Teaching Discrete Mathematics with Computer Algebra: A new approach to Modern Algebra and Error-Correcting Codes ( in proceedings of IMACS conference in Wailea, Maui, Hawaii, USA 1997).
3. Adamek J. Foundations of Coding. John Wiley & Sons Inc 1991
4. MacWilliams F.J. and Sloane N.J.A. (1977) The Theory of Error - Correcting Codes. North-Holland. Amsterdam.
5. Wagner T.J. A search technique for quasi-perfect codes, Info.and Control. 9 (1966) 94-99 [18,A].