• No se han encontrado resultados

Coding theory exercises using GAP

N/A
N/A
Protected

Academic year: 2018

Share "Coding theory exercises using GAP"

Copied!
8
0
0

Texto completo

(1)

Coding theory exercises using GAP

GAP 4.2 and above has the GUAVA package which allows one to do some coding theory explorations.

David Joyner 2002-08-23

Background on …nite …elds

The …nite …elds in GAP are of the formFpk =GF(pk), wherepis a prime power and k 1 is an integer. Let’s start with something simple: enter F2 and F3 and print out all their elements.

gap> GF2:=GF(2); GF(2)

gap> gf2:=Elements(GF2); [ 0*Z(2), Z(2) ^0]

gap> GF3:=GF(3); GF(3)

gap> gf3:=Elements(GF3); [ 0*Z(3), Z(3)^0,Z(3)]

What are Z(2), Z(3)? In general, Fpk is a cyclic group. GAP uses this fact and lets Z(pk) denote a generator of this cyclic group. If k = 1 then giving a generator of Fp = (Z=pZ) is equivalent to giving a primitive root mod p. In fact, Z(p) is the smallest primitive root mod p, as is obtained from the PrimitiveRootMod function. Here’s how to verify this for p= 3;5:

gap> PrimitiveRootMod(3); 2

gap> 2*Z(3)^0=Z(3); true

gap> PrimitiveRootMod(5)*Z(5)^0=Z(5); true

Onto …eldsFpk with k >1.

gap> GF4:=GF(4); GF(2 ^2)

gap> gf4:=Elements(GF4);

[ 0*Z(2), Z(2)^0, Z(2^2), Z(2^2)^2] gap> GF7:=GF(7);

GF(7)

(2)

gap> gf8:=Elements(GF8);

[ 0*Z(2), Z(2)^0, Z(2^3), Z(2^3)^2, Z(2^3)^3, Z(2^3)^4,Z(2^3)^5,Z(2^3)^6]

gap> GF9:=GF(9); GF(3^2) gap> gf9:=Elements(GF9);

[ 0*Z(3), Z(3)^0, Z(3), Z(3^2), Z(3^2)^2, Z(3^2)^3, Z(3^2)^5, Z(3^2)^6,Z(3^2)^7]

Note thatGF(8) containsGF(2) but notGF(4). It is a general fact that

GF(pm)contains GF(pk) as a sub…eld if and only ifk

jm.

What are Z(2^2), Z(2^3), Z(3^2),. . . ? They are less easy to explicitly explain. Z(pk) is a root of a certain irreducible polynomial mod p called a Conway polynomial. We can check this in the case pk = 8 in GAP by

plugging this supposed root into the polynomial and see if we get 0 or not:

gap> R:=PolynomialRing(GF2,["x"]);

<algebra-with-one over GF(2), with 1 generators>

gap> p:=ConwayPolynomial(2,3); Z(2)^0+x+x^3

gap> Value(p,Z(8)); 0*Z(2)

This tells us that the generator of GF(8) is a root of the polynomial

x3+x+ 1 mod 2.

Next, let’s try adding, subtracting, and multiplying …eld elements in GAP.

gap> gf9[4]; gf9[5]; gf9[4]+gf9[5]; Z(3^2)

Z(3^2)^2 Z(3^2)^3

gap> gf9[3]; gf9[6]; gf9[3]+gf9[6]; Z(3)

Z(3^2)^3 Z(3^2)^5

gap> gf9[3]; gf9[6]; gf9[3]*gf9[6]; Z(3)

Z(3^2)^3 Z(3^2)^7

(3)

Z(3^2) Z(3)

gap> gf8[4]; gf8[6]; gf8[4]*gf8[6]; Z(2^3)

Z(2^3)^4 Z(2^3)^6

gap> gf8[4]; gf8[6]; gf8[4]+gf8[6]; Z(2^3)^2

Z(2^3)^4 Z(2^3)

Some vector spaces

The GAP code

vecs:=[[1,0,0],[1,1,1],[0,1,1]]; V:=VectorSpace(Rationals,vecs); GeneratorsOfVectorSpace(V); B:=Basis(V); dim:=Length(B);

constructs the vector space overQspanned by the vectors(1;0;0);(1;1;1);(0;1;1), …nds a basis, and computes its dimension.

Exercise 3.14.1Construct the vector space overQ spanned by the vec-tors (1;0;0);(1;1;1);(0; 1;1), …nd a basis, and compute its dimension. Do the same, but with Qreplaced by GF(3).

Some simple codes

Now we start to investigate codes in GAP. This requires the package GUAVA. To load GUAVA, type RequirePackage(“guava”);. GAP 4.3 will then display the GUAVA banner:

____ j

/ n / –+–Version 1.5

/ j j jnn //j j

j _ j j j nn //j Jasper Cramwinckel j n j j j–nn //–j Erik Roijackers n j j j j nn // j Reinald Baart

n___/ n___/ j nn// j Eric Minkes Lea Ruscio true

(4)

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — Loading GUAVA 1.9 (GUAVA Coding Theory Package) by Jasper Cramwinckel, Erik Roijackers, Reinald Baart, Eric Minkes, Lea Ruscio, and David Joyner (http://cadigweb.ew.usna.edu/ wdj/homepage.html).

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — true

How do you enter a code it using only the list of codes words? Easy, here’s an example:

gap> C:=ElementsCode(["0000","1111"], "repetition code",GF(2));

a (4,2,1..4)2 repetition code over GF(2)

This notation(4,2,1..4)2is GUAVA shorthand for: the length is 4, the size is 2, the minimum distance in the Hamming metric is between 1 and 4, and the covering radius in the Hamming metric is 2.

Here’s how to check all this is correct:

gap> Elements(C); [ [ 0 0 0 0 ], [ 1 1 1 1 ] ] gap> MinimumDistance(C);

4

gap> Dimension(C); 1

GUAVA didn’t know the minimum distance before, but once you type the MinimumDistance(C); command it modi…es the GAP record for C.

gap> C;

a cyclic [4,1,4]2 repetition code over GF(2)

Let us not enter a code using a generator matrixG:

gap> G := Z(2)*[ [1,0,0,1,1,0], [0,1,0,1,1,0], [0,0,1,0,1,1] ];

[ [ Z(2)^0,0*Z(2), 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2) ], [ 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0,Z(2)^0,0*Z(2)], [ 0*Z(2), 0*Z(2), Z(2)^0,0*Z(2),Z(2)^0,Z(2)^0] ]

(5)

a linear [6,3,1..3]2..3 code defined by generator matrix over GF(2)

gap> MinimumDistance(C); 2

gap> IsLinearCode(C); true

gap> Elements(C);

[ [ 0 0 0 0 0 0 ], [ 0 0 1 0 1 1 ], [ 0 1 0 1 1 0 ], [ 0 1 1 1 0 1 ], [ 1 0 0 1 1 0 ], [ 1 0 1 1 0 1 ], [ 1 1 0 0 0 0 ], [ 1 1 1 0 1 1 ] ]

gap> Dimension(C); 3

This is not 1 error correcting (try correcting [ 1 1 0 1 1 0 ]). Here’s another example,

gap> G := Z(2)*[ [1,0,0,1,1,0], [0,1,0,1,0,1], [0,0,1,0,1,1] ]; [ [ Z(2)^0,0*Z(2), 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2) ], [ 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0,0*Z(2),Z(2)^0],

[ 0*Z(2), 0*Z(2), Z(2)^0,0*Z(2),Z(2)^0,Z(2)^0] ]

gap> C:=GeneratorMatCode(G,GF(2)); a linear [6,3,1..3]2 code defined by generator matrix over GF(2) gap> MinimumDistance(C); 3

gap> Dimension(C); 3 gap> Elements(C); [ [ 0 0 0 0 0 0 ], [ 0 0 1 0 1 1 ], [ 0 1 0 1 0 1 ], [ 0 1 1 1 1 0 ], [ 1 0 0 1 1 0 ], [ 1 0 1 1 0 1 ], [ 1 1 0 0 1 1 ], [ 1 1 1 0 0 0 ] ]

This is 1 error correcting.

Hamming codes

The [7;4;3]-Hamming code overGF(2) having generator matrix

0 B B @

1 0 0 0 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 1 1 1 1

1 C C A

(6)

C:=HammingCode(3,GF(2)); G:=GeneratorMat(C); Display(G);

Encoding a message wusing G, is simply the map w7 !wG. Type

Elements(C);

Size(Elements(C));

From this, you see all the codewords of C and how many there are. To get the parity check matrix, type

H:=CheckMat(C); Display(H);

Note all the columns ofH are distinct and non-zero. To see if a vector in F7 is a codeword, simply computeHv and check if it is zero or not. Here’s a GAP example:

v := Codeword([0,0,1,1,0,1,0]); v in C;

(Here v = [ 1 0 1 1 0 1 0 ]+[1,0,0,0,0,0,0]. which is the code word obtained by encoding (1;0;1;0) plus the error vector(1;0;0;0;0;0;0). Since this last vector is non-zero, v is not a codeword. If it was a vector received in transmission (with at least one error) then to decode it, hence to …nd the most likely codeword sent, type

Decode(C,v);

Exercise 3.11.2(a) For the parity check matrix H of the binary Ham-ming code of length 23 1 = 7, verifyHc = 0 for three or four codewords c. Decode (1;1;0;0;0;0;0).

(b) Find a parity check matrix of the 3-ary Hamming code of length (33 1)=(3 1) = 13. Verify Hc = 0for three or four codewords c. Decode (1;2;1;2;1;2;1;2;1;2;1;2;1).

To get the dimension of the code, type Dimension(C); To get its mini-mum distance, type MinimumDistance(C);

Exercise 3.11.3Find the dimension and minimum distance of (a) the binary Hamming code of length15,

(7)

Reed-Muller codes

Reed-Muller shall be abbreviated RM.

The [8;4;4]RM code over GF(2) having generator matrix

0 B B @

1 0 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1

1 C C A

is obtained by typing

C:=ReedMullerCode(1,3); G:=GeneratorMat(C);

(UseDisplay(G);to seeG if necessary.) Encoding a messagewusingG, is simply the map w7 !wG. Type

Elements(C);

Size(Elements(C));

From this, you see all the codewords of C and how many there are. To get the parity check matrix, type

H:=CheckMat(C);

To see if a vector in F8 is a codeword, simply compute Hv and check if it is zero or not. Here’s a GAP example:

v:=Codeword([1,0,0,0,0,0,0,0]); v in C;

Since this last vector is non-zero,v is not a codeword. If it was a vector received in transmission (with at least one error) then to decode it, hence to …nd the most likely codeword sent, type

Decode(C,v);

Exercise 3.11.4 (a) For the parity check matrix H of the RM code of length8, verifyHc= 0for three or four codewords c. Decode(1;1;0;0;0;0;0;0).

(8)

To get the dimension of the code, type Dimension(C); To get its mini-mum distance, type MinimumDistance(C);

Exercise 3.11.5 Find the dimension and minimum distance of the RM code of length 16.

Cyclic codes

A cyclic code is associated to an irreducible polynomial over F which divides xn 1.

For example, to get the[7;4;3]cyclic code over GF(2) having generator matrix

0 B B @

1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1

1 C C A

R:=PolynomialRing(GF(2),["x"]);; x:=Indeterminate(GF(2),"x");; g:=x^3+x+1;

Factors(x^7-1);

C:=GeneratorPolCode(g,7,GF(2)); G:=GeneratorMat(C);

To get the parity check matrix, typeH:=CheckMat(C);TryIsCyclicCode(C);

To get the dimension of the code, type Dimension(C); To get its mini-mum distance, type MinimumDistance(C);

Referencias

Documento similar

a) Ao alumnado que teña superado polo menos 60 créditos do plan de estudos da licenciatura que inclúan materias troncais e obrigatorias do primeiro curso recoñeceráselles o

La solución que se ha planteado, es que el paso o bien se hiciese exclusivamente por el adarve de la muralla, o que una escalera diese acceso por la RM evitando la estancia (De

Imparte docencia en el Grado en Historia del Arte (Universidad de Málaga) en las asignaturas: Poéticas del arte español de los siglos XX y XXI, Picasso y el arte español del

De esta manera, ocupar, resistir y subvertir puede oponerse al afrojuvenicidio, que impregna, sobre todo, los barrios más vulnerables, co-construir afrojuvenicidio, la apuesta

We analyze N = 2, 1, 0 vacua of type IIB string theory on K3 × T 2 /Z 2 in presence of three-form fluxes from a four dimensional su- pergravity viewpoint.. The quaternionic geometry

de se convertir en chaux par la calcination- L a formation de ces pierres nous paroît due, en grande partie , au détritus des coquillages : Tidentité des

Lo más característico es la aparición de feldespatos alcalinos y alcalino térreos de tamaño centimétrico y cristales alotriomorfos de cuarzo, a menudo en agregados policristalinos,

For calculating of the shallow geothermal potential with G.POT method for location 1 and 2, the BHE length required for heating and cooling modes to cover the H&amp;C energy