scieee AI-readable full text Open interactive document viewer

On the ideal associated to a linear code

Marquez Corbella, Irene,Martínez Moro, Edgar,Suárez Canedo, Emilio

Abstract

Producción Científica

Full text

doi:10.3934/amc.2016003 Manuscript submitted to AIMS’ Journals May 2016, 10(2): 229-254. ON THE IDEAL ASSOCIATED TO A LINEAR CODE Irene M´ arquez-Corbella INRIA Paris-Rocquencourt, SECRET Project-Team 78153 Le Chesnay Cedex, France. Edgar Mart´ ınez-Moro Mathematics Institute (IMUVa), University of Valladolid, Castilla, Spain. Vernon Wilson Chair, Eastern Kentucky University. Emilio Su´ arez-Canedo Departament d’Enginyeria de la Informaci´o i de les Comunicacions. Universitat Aut`onoma de Barcelona (UAB) (Communicated by the associate editor name) Abstract. This article aims to explore the bridge between the algebraic structure of a linear code and the complete decoding process. To this end, we associate a specific binomial ideal I+(C) to an arbitrary linear code. The binomials involved in the reduced Gr¨obner basis of such an ideal relative to a degreecompatible ordering induce a uniquely defined test-set for the code, and this allows the description of a Hamming metric decoding procedure. Moreover, the binomials involved in the Graver basis of I+(C) provide a universal test-set which turns out to be a set containing the set of codewords of minimal support of the code. 1. Introduction. In this paper, we associate a binomial ideal I+(C) to an arbitrary linear code Cover any finite field Fq. Several papers have been already devoted to the idea of associating the structure of a polynomial ideal to a linear code and thus, relate the reduction process on the first structure to the challenge of complete decoding on the second one. See [5,16] and the references therein. Unfortunately, so far, this approach has not yet been applied succesfully to the non-binary case. Recently, some of these techniques were also studied by Aliasgari et al. [1] for non-binary group block codes, but the developed decoding algorithm was for the G-norm and not for the Hamming metric, recall that the G-norm is equivalent to the Hamming distance for q= 2,3. Therefore, the main achievement of this article has been to find the right structure that allows us to perform a complete decoding method as a reduction procedure for monomials in a polynomial ring. The decoding procedure presented here is a complete decoding algorithm that is, the procedure always provides the closest codeword to the received vector. Indeed we are ensured that it will retrieve the 2010 Mathematics Subject Classification. Primary: 94B05, 13P25; Secondary: 13P10. Key words and phrases. Gr¨obner bases, Graver bases, Minimal support codewords. The first two authors are partially supported by Spanish MICINN under project MTM2007- 64704. The research of the first author is also supported by the FSMP postdoctoral program. The second author is also supported under project MTM2010-21580-C02-02 by Spanish MINCINN. 1 2 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO original sent codeword if the number of errors is smaller or equal to the errorcorrecting capability of the code. First, in Section 2we prove that I+(C) is finitely generated and the generators are provided by a basis of Cand the binomials attached to the additive table of the base field Fq. Or equivalently, I+(C) is generated by the binomials given by the Fq-kernel of an explicit matrix. Note that this approach is a non-trivial extension of that of [14] to solve linear integer programming problems with modulo arithmetic conditions, that is, related with matrices over any ring of integers Zs. Then, in Section 3, we show that a reduced Gr¨obner basis Gof I+(C) relative to a degree-compatible ordering give us a complete decoding algorithm. The proposed procedure has some resemblance with the two gradient descent decoding algorithms known for binary codes [15,2], note that both algorithms were unified in [6]. In our method, the test-set of Cis replaced by Gand addition is substituted for the reduction induced by G. However, the idea behind our algorithm can be stated without the use of Gr¨obner basis theory as a step by step decoding [18] algorithm, which is a classical but very useful technique. Next, in Section 4we discuss an alternative for the computation of G. A brief description of this technique as well as a complexity estimation can be found here. We can not expect that the algorithm runs in polynomial time since the complete decoding algorithm for general linear codes is an NP-hard problem [4], even if preprocessing is allowed (see [7]). However, the proposed algorithm is better suited for our case than the standard Buchberger’s algorithm. In Section 5, we consider the Graver basis associated to I+(C) which turns out to contain the set of codewords of minimal support of C. The interest of this set is due to its relationship with the complete decoding problem and its applications in cryptography. Finally, in Section 6we apply the above approach to other classes of codes such as modular codes, codes defined over multiple alphabets or additive codes. The set of codewords of minimal support for modular codes has already been discussed in [16,17] and in [1], where similar ideas are treated for a metric different from the Hamming. 1.1. Preliminaries. We begin with an introduction of basic definitions and some known results from coding theory over finite fields. By K,Z,Zs,Fqand F∗ q, where qis a prime power, we denote an arbitrary finite field, the ring of integers, the ring of integers modulo s, any representation of a finite field with qelements, and the multiplicative group of nonzero elements of Fq, respectively. For every finite field Fqthe multiplicative group F∗ qof nonzero elements of Fqis cyclic. A generator of the cyclic group F∗ qis called a primitive element of Fq. Therefore, Fqconsists of 0 and all powers from 1 to q−1 of that primitive element (see for instance [19]). An [n, k] linear code Cover Fqis a k-dimensional subspace of Fn q. We define a generator matrix of Cto be a k×nmatrix Gwhose row vectors span C, while a parity check matrix of Cis an (n−k)×nmatrix Hwhose null space is C. We denote by dH(·,·) and wH(·) the Hamming distance and the Hamming weight on Fn q, respectively. We write dfor the minimum distance of a linear code Cand this is equal to its minimum weight. This parameter determines the error-correction capability of Cwhich is given by t=d−1 2, where ⌊x⌋is the largest integer at most x. ON THE IDEAL ASSOCIATED TO A LINEAR CODE 3 Remark 1. Let tbe the error-correction capability of an [n, k, d] code Cover Fq. Then, d= 2t+ 1 if dis odd and d= 2t+ 2 if dis even. For a word x∈Fn q, its support, denoted by supp(x), is defined as the set of nonzero coordinate positions, i.e., supp(x) = {i|xi6= 0}. The Voronoi region of a codeword c∈ C, denoted by D(c), is defined as: D(c) = y∈Fn q|dH(y,c)≤dH(y,c′) for all c′∈ C \ {c}. The union of all Voronoi regions of Cis equal to Fn q. However, some points of Fn q may be contained in several regions. Moreover, note that the Voronoi region of the all-zero codeword D(0) coincides with the set of coset leaders of C. Atest-set TCfor Cis a set of codewords such that for every word y∈Fn q, either ylies in the Voronoi region D(0), or there exists an element t∈ TCsuch that wH(y−t)<wH(y). Recall that the general principle of Gradient Descend Decoding algorithms (GDDA) is to use a certain set of codewords TC(namely test-set, formally described above) which has been precomputed and stored in memory in advance. Then the algorithm can be accomplished by recursively inspecting the test-set for the existence of an adequate element which is subtracted from the current vector. The following algorithm describes a gradient-like decoding algorithm for binary codes, this algorithm (for the binary case) appears in [3]. The following version of the GDD algorithm allows to reduce the size of the test-set for the q-ary case since once a vector is stored we can omit its multiples. Algorithm 1: Gradient-like decoding Data: The received word y∈Fn q Result: A codeword c∈ C that minimized the Hamming distance dH(c,y) 1Set c=0;while y /∈D(0)do 2Look for z∈ TCsuch that wH(y−λz)<wH(y) with λ∈Fq; 3y←− y−z; 4c←− c+z 5end while 6Return c=y In order to achieve complete decoding over a linear code Cthe aim of this article is to use a Gradient-like decoding method with the minimal test-set provided by a reduced Gr¨obner basis Gof the ideal associated to the code I+(C) with respect to a degree compatible ordering. As we will see, we do not need to store all the binomials of such Gr¨obner basis but the codewords associated to the so-called minimal test-set. A non-zero codeword min Cis said to be a minimal support codeword if there are no other codewords c∈ C such that supp(c)⊂supp(m). We denote by MCthe set of codewords of minimal support of C. 2. The ideal associated to a linear code. In this section we associate a binomial ideal to an arbitrary linear code provided by the rows of a generator matrix and the relations given by the additive table of the defining field. Let Xdenote nvector variables X1,...,Xnsuch that each variable Xican be decomposed into q−1 components xi,1,...,xi,q−1with i= 1,...,n. A monomial in Xis a product of the form: 4 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO Xu=Xu1 1···Xun n=xu1,1 1,1···xu1,q−1 1,q−1 |{z } Xu1 1 ···xun,1 n,1···xun,q−1 n,q−1 |{z } Xun n , where u∈Zn(q−1) ≥0. The total degree of Xuis the sum deg(Xu) = Pn i=1 Pq−1 j=1 ui,j. When u= (0,...,0), note that Xu= 1. Then the polynomial ring K[X] is the set of all polynomials in Xwith coefficients in K. Let αbe a primitive element of Fq. We define by RXithe set of all the binomials on the variable Xiassociated to the relations given by the additive table of the field Fq=αj|j= 1, . . . , q −1∪ {0}, i.e., RXi={xi,uxi,v −xi,w |αu+αv=αw}S{xi,uxi,v −1|αu+αv= 0}, with i= 1,...,n. There are q 2different binomials in RXi. We define RXas the following binomial ideal in K[X]: RX=h∪n i=1RXii. We will use the following characteristic crossing functions. These applications aim at describing a one-to-one correspondence between the finite field Fqwith q elements and the standard basis of Zq−1, denoted as Eq={e1,...,eq−1}where ei is the unit vector with a 1 in the i-th coordinate and 0’s elsewhere. ∆ : Fq−→ Eq∪ {0} ⊆ Zq−1and ∇:Eq∪ {0} −→ Fq 1. The map ∆ replaces the element a=αi∈Fqby the vector eiand 0 ∈Fqby the zero vector 0∈Zq−1. 2. The map ∇recovers the element αj∈Fqfrom the unit vector ejand the zero element 0 ∈Fqfrom the zero vector 0∈Zq−1. These maps will be used with matrices and vectors acting coordinate-wise. Although ∆ is not a linear function. Note that we have X∆a·X∆b=X∆a+∆b=X∆(a+b)mod RXfor all a,b∈Fn q. That is, the characteristic crossing functions induce the following maps: ˜ ∆ : Fn q ∆ −→ (Eq∪ {0})n−→ K[X]/RX a7−→ ∆a7−→ X∆a and ˜ ∇:K[X]/RX−→ (Eq∪ {0})n∇ −→ K[X] Xu7−→ u7−→ ∇u Remark 2. Take into account that Fqcontains φ(q−1) primitive elements, where φis the Euler function (or equivalently, the number of integers less than and relative prime to q−1). Every primitive element of Fqcan serve as a defining element of the characteristic crossing functions. But they will lead to different permutations of the components of the vector variable Xi. Definition 2.1. The monomial Xais said to be in standard form if the exponents of each variable xi,j is 0 or 1, and two variables xi,j and xi,l do not appear in the same monomial. Therefore, a monomial is in standard form if it can be written as Qn i=1 xi,ji. Note that, any monomial modulo the additive relations {RXi}i=1,...,n is in standard form. Or equivalently, Xais in standard form if and only if there exists b∈Fn qsuch that Xa=X∆b. ON THE IDEAL ASSOCIATED TO A LINEAR CODE 5 Moreover, if we multiply standard monomials with disjoint support then, ∆ provides linearity in K[X], i.e. : X∆aX∆b=X∆(a+b)if supp(a)∩supp(b) = ∅ A polynomial f∈K[X] is said to be in standard form if each monomial in its decomposition is in standard form. Remark 3. The following property is crucial for the results achieved in this article: If Xais in standard form, then deg(Xa) = wH(∇a). Unless otherwise stated, we simply write Cfor an [n, k] linear code defined over the finite field Fq. We define the ideal associated to Cas the binomial ideal: I(C) = X∆a−X∆b|a−b∈ C⊆K[X]. For a fuller discussion of this algebraic structure see [6,5,16] and the references therein. Given the rows of a generator matrix of C, labelled by {w1,...,wk} ⊆ Fn q, we define the following ideal: I+(C) = nX∆(αjwi)−1oi=1,...,k j=1,...,q−1S{RXi}i=1,...,n ⊆K[X]. Remark 4. Note that we encode all the information of our ideal in the exponents, thus we can always take K=F2. Lemma 2.2. Let f(X)∈K[X]. Then, f(X)∈ RXif and only if f(X) = Pi∈IX∆aiX∆bi−X∆ci with ai+bi−ci=0in Fn q,∀i∈I Proof. Let f(X)∈ RX. Thus, f(X) can be written as a finite linear combination of elements in the set of generators of RXwith coefficients in K=F2, i.e. f(X) = n X j=1 X l∈Lj rjl where {rjl |l∈Lj}is a subset of generators of RXjfor all j= 1,...,n. Following the definition of RXj, the binomials rjl can take two different forms: 1. rjl =xjuxjv −xjw with αu+αv=αwin Fq. Or equivalently, rjl =X∆αu jX∆αv j−X∆αw j=X∆αuejX∆αvej−X∆αwej 2. rjl =xjuxjv −1 with αu+αv= 0 in Fq. Or equivalently, rjl =X∆αu jX∆αv j−1 = X∆αuejX∆αvej−1 Hence, f(X) = Pi∈IX∆aiX∆bi−X∆ciwith ai+bi−ci=αuei+αvei−αwei=0 in Fn qfor certain indices u, v, w, where {e1,...,en}denotes the standard basis of Fn q. To show the converse it suffices to show that each binomial X∆ajX∆bj−X∆cj in the decomposition of f(X) belongs to RXwith aj+bj−cj= (aj,1,...,aj,n)+(bj,1,...,bj,n)−(cj,1,...,cj,n) = 0in Fn qfor all j∈I 6 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO We have that: X∆ajX∆bj−X∆cj= n Y i=1 X∆aj,i iX∆bj,i i− n Y i=1 X∆cj,i i =X∆aj,1 1X∆bj,1 1−X∆cj,1 1 |{z } RX1 n Y i=2 X∆aj,i iX∆bj,i i+X∆cj,1 1 n Y i=2 X∆aj,i iX∆bj,i i− n Y i=2 X∆cj,i i! =···=X∆aj,1 1X∆bj,1 1−X∆cj,1 1 |{z } RX1 n Y i=2 X∆aj,i iX∆bj,i i +X∆aj,2 2X∆bj,2 2−X∆cj,2 1 |{z } RX2 X∆cj,1 1 n Y i=3 X∆aj,i iX∆bj,i i +. . . +X∆aj,n nX∆bj,n n−X∆cj,n n |{z } RXn n−1 Y i=1 X∆cj,i i Thus, X∆ajX∆bj−X∆cj∈ RXfor all j∈I. Theorem 2.3. I(C) = I+(C). Proof. It is clear that I+(C)⊆I(C) since all binomials in the generating set of I+(C) belong to I(C). Indeed: •X∆αjwi−1∈I(C) since αjwi∈ C for all i= 1,...,k and j= 1,...,q−1. •The set of binomials of RXiare elements of I(C) for all i= 1,...,nsince each binomial represents the zero codeword by Lemma 2.2. To show the converse it suffices to show that each binomial X∆a−X∆bof I(C) belongs to I+(C). By the definition of I(C) we have that a−b∈ C. Hence a−b=λ1w1+···+λkwkwith λ1,...,λk∈Fq. Note that, if the binomials z1−1 and z2−1 belong to the ideal I+(C) then z1z2−1 = (z1−1)z2+ (z2−1) also belongs to I+(C). On account of the previous line, we have: X∆(a−b)−1 = X∆λ1w1−1k Y i=2 X∆λiwi+ k Y i=2 X∆λiwi−1!mod RX =X∆λ1w1−1k Y i=2 X∆λiwi+X∆λ2w2−1k Y i=3 X∆λiwi+···+ +X∆λk−1wk−1−1X∆λkwk+X∆λkwk−1mod RX. The last equation forces that X∆(a−b)−1∈nX∆αjwi−1oi=1,...,k j=1,...,q−1 ∪ RX. We have actually proved that X∆a−X∆b∈I+(C) since X∆a−X∆b=X∆(a−b)−1X∆bmod RX, ON THE IDEAL ASSOCIATED TO A LINEAR CODE 7 which completes the proof. Example 1. Let us consider the [7,2] linear code Cover F3with generator matrix G=1012111 0122102∈F2×7 3, where the primitive element α= 2 generates the finite field F3=0, α = 2, α2= 1 which gives us the following additive table: T+α α2 α α20 α20α Or equivalently, α+α=α2, α2+α= 0, α2+α2=α. Therefore, we obtain the following binomials associated to the previous rules: RXi=x2 i,1−xi,2, xi,1xi,2−1, x2 i,2−xi,1with i= 1,...,7. Let us label the rows of Gby w1and w2. By Theorem 2.3, the ideal associated to the linear code Cmay be defined as the following binomial ideal: I+(C) = D nX∆αjwi−1oi=1,2 j=1,2S{RXi}i=1,...,7E =*       x1,2x3,2x4,1x5,2x6,2x7,2−1, x1,1x3,1x4,2x5,1x6,1x7,1−1, x2,2x3,1x4,1x5,2x7,1−1, x2,1x3,2x4,2x5,1x7,2−1       S{RXi}i=1,...,7+. Remark 5. Let B∈Fm×n qbe a matrix, B⊥be the matrix whose rows generate the null-space of Band {w1,...,wk}be a set of generators of the row space of the matrix B. We can define the following binomial ideal: I(B) = X∆a−X∆b|B⊥(a−b)T=0. Therefore, the construction presented above for linear codes can be generalized for any matrix defined over an arbitrary finite field, i.e. we have actually proved that I(B) = I+(C) = I(C). Thus, the definition of I+(C) is in fact independent of the choice of the matrix Band just depends on the subspace C, i.e. the subspace generated by the row-vectors of B. Let Bbe a m×nmatrix defined over Fqand let Bidenote the i-th column of the matrix B. Let Xdenote nvector variables X1,...,Xnsuch that Xi= (xi,1,...,xi,q−1) for 1 ≤i≤nand Ydenote mvector variables Y1,...,Ymsuch that Yj= (yj,1, . . . , yj,q−1) for 1 ≤j≤m. Let RYj⊆K[Yj] be the binomial ideal consisting of all the binomials on the variables Yj= (yj,1,...,yj,q−1) associated to the relations given by the additive table of the field Fq=αj|j= 1,...,q−1∪{0} with 1 ≤j≤m, we define RY=h∪m i=1RYii ⊆ K[Y]. We denote by K[X,Y]STD the set of polynomials in K[X,Y] in standard form, i.e. f∈K[X,Y]STD if each monomial in its decomposition is in standard form. The ring homomorphism ΘB:K[X,Y]STD −→ K[Y] is then defined by ΘB(X∆a) = Y∆(aBT)for every a∈Fn q, and ΘB(Y∆a) = Y∆a. Thus, ΘB(xi,j ) = ΘB(X∆αj i) = ΘB(X∆(αjei)) = Y∆(αjBT i)where {e1,...,en} denotes the standard basis of Fn q. 8 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO More generally, for every polynomial f=PcvX∆vxY∆vy∈K[X,Y]STD we have that ΘB(f) = f(ΘB(X),Y) = XcvΘBX∆vxY∆vy This function can be found in [9]. Remark 6. Note that the restriction of ΘBto RXis the function defined by: ΘB:RX−→ RY This assertion is a direct consequence of Lemma 2.2. Lemma 2.4. Let us consider the matrix B∈Fm×n qand the vectors a∈Fn qand b∈Fm q. The equality aBT=bholds if and only if ΘBX∆a≡Y∆bmod RY. Proof. This lemma is a straightforward consequence of Lemma 2.2. Another ideal associated to the matrix B∈Fm×n qis defined by IB=D{ΘB(xi,j )−xi,j }i=1,...,n j=1,...,q−1SRYjj=1,...,m E⊆K[X,Y]. Lemma 2.5. For a given polynomial f∈K[X,Y]STD. f∈IBif and only if ΘB(f)≡0 mod RY. Proof. For each j= 1,...,m we have q 2different binomials in RYj. We denote by rj,l(Yj) the polynomial at position lwith respect to certain order in RYjwith j= 1,...,m. Let f∈IB, by representing fwith the generators of IB, we have that f(X,Y) = n X i=1 q−1 X j=1 λi,j (ΘB(xi,j )−xi,j) + m X j=1 (q 2) X l=1 βj,lrj,l(Yj) with {λi,j}i=1,...,n j=1,...,q−1 and {βj,l}j=1,...,m l=1,...,(q 2) ∈K[X,Y]. Then, ΘB(f) = f(ΘB(X),Y) = n X i=1 q−1 X j=1 ΘB(λi,j ) (ΘB(xi,j )−ΘB(xi,j )) + m X j=1 (q 2) X l=1 ΘB(βj,l)rj,l(Yj) = m X j=1 (q 2) X l=1 ΘB(βj,l)rj,l(Yj)≡0 mod RY. To prove the converse, first note that given any vector a= (a1,...,an) = (αj1,...,αjn)∈Fn qthe monomial X∆acan be written as: X∆a1 1···X∆an n=x1,j1···xn,jn= n Y i=1 (ΘB(xi,ji) + (xi,ji−ΘB(xi,ji))) = n Y i=1 ΘB(xi,ji) + n X i=1 Ci,j (xi,ji−ΘB(xi,ji)) = ΘB(X∆a) + n X i=1 Ci,j (xi,ji−ΘB(xi,ji)) ON THE IDEAL ASSOCIATED TO A LINEAR CODE 9 for some {Ci,j }i=1,...,n j=1,...,q−1 ∈K[X,Y]. Note that, for all polynomial f∈K[X,Y]STD there exists polynomials gi(Y), h(Y)∈K[Y]STD and fi(X)∈K[X]STD such that f(X,Y) = X i∈I fi(X)gi(Y) + h(Y) We have already show that we can write each fi(X) as fi(ΘB(X))+ ˆ fiwith ˆ fi∈IB. Thus, f(X,Y) = X i∈I fi(ΘB(X))gi(Y) + h(Y) |{z } =ΘB(f)∈RY +X i∈I ˆ figi(Y) |{z } ∈IB ∈IB Remark 7. Lemmas 2.5 and 2.4 are technical findings valid for any matrix B. On the following theorem we applied the above lemmas to a matrix A⊥where Ais a generator matrix of the linear code C. Let us recall a well-known property of binomials ideals: Corollary 1. [10, Corollary 1.3] If I⊆K[X1,...,Xn]is a binomial ideal, then the elimination ideal I∩K[X1,...,Xr]is a binomial ideal for every r≤n. The following result shows how the ideal associated to the code Ccan also be defined as the ideal associated to a parity check matrix of Cand also as the kernel of a polynomial ring homomorphism. Note that the ideals I(A) and IAare independent of the matrix A, they just depend on the subspace generated by the row-vectors of matrix A. Theorem 2.6. I+(C) = I(A) = IA⊥∩K[X]. Proof. To prove that I+(C)⊆IA⊥∩K[X] it suffices to observe the following: •ΘA⊥X∆(αjwi)−1=Y∆(αjwi)(A⊥)T−1 is the zero binomial, since A·A⊥= 0, for j∈ {1,...,q−1}and i∈ {1,...k}. •By Remark 6we have that ΘA⊥(RX)⊆ RY. Therefore, applying Lemma 2.5 we conclude that the set of generators of I+(C) belongs to IA⊥∩K[X]. Conversely, let f=X∆a−X∆bbe any binomial of IA⊥∩K[X] with a,b∈Fn q. Note that Corollary 1allows us taking fas a binomial. Lemma 2.5 implies that ΘA⊥(f) = Y∆(A⊥aT)T−Y∆(A⊥bT)T≡0 mod RY. Hence, by Lemma 2.4 we have that A⊥aT=A⊥bT, thus by Theorem 2.3 f∈I(A) = I+(C). 3. Decoding linear codes using a reduced Gr¨obner basis. In this section we prove that the reduced Gr¨obner basis for the ideal I+(C) w.r.t. a degree compatible ordering on K[X] (see for example [8] for a definition of such orderings) provides an algebraic decoding algorithm associated to computing the reduction of a monomial modulo the binomial ideal I+(C). If we fix a term order ≺then the leading term of a polynomial fwith respect to ≺, denoted by LT≺(f), is the largest monomial among all monomials which occurs with non-zero coefficient in the expansion of f. Let Ibe an ideal in K[X], then the initial ideal in≺(I) is the monomial ideal generated by the leading term of all the polynomials in I, i.e. in≺(I) = {LT≺(f)|f∈I}.The monomials which do not lie in the ideal in≺(I) are called canonical monomials. The semigroup ideal generated 16 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO Remark 14. Note that the computation of Xaxi,j modulo the ideal RX, with a∈Zn(q−1), acts like the operation ∇a+αjeiin the finite field Fn qwhere {e1,...,en} denotes a standard basis of Fn q. Algorithm 2: Adapted FGLM algorithm for I+(C) Data: The rows {w1,...,wk} ⊆ Fn qof a generator matrix of an [n, k] linear code Cdefined over Fqand a degree compatible ordering ≺Ton K[X]. Result: A reduced Gr¨obner basis GTof the ideal I+(C) w.r.t. ≺T. 1List ←− "(1,1),n(1,X∆αjwi)oi=1,...,k j=1,...,q−1#; 2GT←− ∅;N ←− ∅;r←− 0; 3while List 6=∅do 4w←− NextTerm(List); 5if w[1] /∈LT≺T(GT)then 6j=Member(w[2],[v1[2],...,vr[2]]); 7if j6=false then 8GT←− GT∪ {w[1] −vj[1]}; 9else 10 r←− r+ 1; 11 vr←− w; 12 N ←− N ∪ {vr[1]}; 13 List =InsertNexts(w,List); 14 end if 15 end if 16 end while Theorem 4.2. Algorithm 2computes a reduced Gr¨obner basis of the ideal associated to a given linear code Cof parameters [n, k]defined over Fq. Proof. The proof of the algorithm is an extension of that in [12, Algorithm2.1] and therefore, is also a generalization of the FGLM algorithm [11]. Let G∈Fk×n qbe a generator matrix of C. We label the rows of Gby {w1,...,wk} ⊆ Fn q. By Theorem 2.3 the ideal associated to the linear code Cmay be defined as the following binomial ideal: I+(C) = nX∆αjwi−1oi=1,...,k j=1,...,q−1S{RXi}i=1,...,n  =D{fi,j}i=1,...,k j=1,...,q−1S{RXi}i=1,...,n E. We first show that GTis a subset of binomials of the ideal I+(C). The proof is based on the following observation: Xa−Xb∈GTif and only if it corresponds to the first component of a syzygy in the module M. In other words, Xa−Xb≡ k X i=1 q−1 X j=1 λ(i−1)(q−1)+jfi,j mod RXwith λ1,...,λr−1∈K[X], or equivalently, Xa−Xb∈I+(C). ON THE IDEAL ASSOCIATED TO A LINEAR CODE 17 Moreover, we claim that the initial ideal of I+(C) w.r.t. ≺Tis generated by the leading terms of polynomials in GT. Indeed, by Theorem 2.3, any binomial f(X) of I+(C) can be written uniquely as a linear combination of elements in the generator set F={fi,j}i=1,...,k j=1,...,q−1 modulo the ideal RX, i.e. f(X) = k X i=1 q−1 X j=1 λ(i−1)(q−1)+jfi,j mod RXwith λ1,...,λr−1∈K[X]. Therefore, LT≺T(f(X)) is a multiple of the leading term of an element of F that appears on its decomposition. But LT≺T(fi,j (X)) cannot be in Nfor all i= 1,...,k and j= 1,...,q−1. To see this, note that the first element introduced in the set Nis always 1 and 1 = X∆αjwi−fi,j i.e. Red≺TX∆αjwi, F= 1, which implies that X∆αjwi−1∈GT. By definition, GTis reduced since we only consider on the algorithm terms which are not divisible by any leading term of the Gr¨obner basis. Finally, since I+(C) has finite dimension, then the number of terms in Nis bounded. Note that at each iteration of the main loop either the size of List decreases or the size of Nincreases, thus there are only a finite number of iterations. This completes the proof of the algorithm. Remark 15. Recall that the dimension of the quotient vector space Fn q/Cis n−k. Moreover, if Ccan correct up to terrors, then every word eof weight wH(e)≤t is the unique coset leader (vectors of minimal weight in their cosets) of its coset modulo C. In other words, all monomials of degree less than tmodulo the ideal RX should be standard monomials for GT. Note that the writing rules given by the ideal RXimplies that “the exponent of each variable xi,j is 0 or 1” and “two different variables xi,j and xi,l can not appear in a monomial”. Thus, the number of standard monomials of a t-error correcting code is at least M= t X l=1 (q−1)ln l.(3) Accordingly, if qn−k=M, then all cosets have a unique coset leader of weight smaller or equal to t. Codes that achieve this equality are the so-called perfect codes. Also for perfect codes, their Voronoi regions are disjoints. Otherwise, there must appear some cosets leaders of weight at most ρ(C), where ρ(C) denotes the covering radius of C, but never as the unique leader, or equivalently there exists standard monomials of degree up to ρ(C). Recall that ρ(C) coincide with the largest weight among all the cosets leaders of C, so ρ(C) = tif Cis a perfect code. By Proposition 3in the worst case, a minimal generator of the initial ideal in<(I+(C)) has degree ρ(C) + 1 where <is a degree compatible ordering. Theorem 4.3. Let Cbe a linear code over Fqof length nand covering radius ρ(C). If the basis field operations need an unit time, then Algorithm 2needs a total time of ODn2(q−1) log(q), where D= ρ(C)+1 X i=1 (q−1)in i. 18 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO Proof. The main time of the algorithm is devoted to the management of InsertNexts. In each main loop iteration this function first introduces n(q−1) new elements to the list List, then compares all the elements and finally eliminates redundancy. Note that comparing two monomials in K[X] is equivalent to comparing vectors in Fn q, thus we need O(nlog(q)) field operations. At iteration i, after inserting the new elements in the list List we would have at most Dielements where Di= (q−1)k |{z } Elements that initialized List +i(n(q−1)) −i |{z } At each iteration the first element is removed and we add n(q-1)new elements . By Remark 15 we have an upper bound Dfor the number of times that InsertNexts should be called. This gives a total time of O(nlog(q) ((q−1)k+D(n(q−1)) −D)) ∼ O Dn2(q−1) log(q). Algorithm 3: Algorithm for computing a minimal Gr¨obner test-set for C Data: The rows {w1,...,wk} ⊆ Fn qof a generator matrix of the code Cand a degree compatible ordering ≺Ton K[X]. Result: A minimal Gr¨obner test-set Tfor C. // For each binomial g=Xa−Xbwe define g:= ∇a− ∇b∈Fn q // Add the following lines after Step 7 of Algorithm 2. 1g←− w[1] −vj[1]; 2if supp(g)6⊃ supp(gi)for all gi∈GT\ {g}then 3T ←− T ∪ {g} 4end if By Proposition 4, the set of codewords related with the exponents of a reduced Gr¨obner basis of the ideal associated with a linear code Cwith respect to a degree compatible ordering induces a test-set Tfor C. However, not all the codewords of this test-set are codewords of minimal support, i.e. this set is somehow redundant. We can reduce the number of codewords to the set T ∩ MC, which is still a test-set for the code C, using Algorithm 3. Moreover, once a vector is stored we can omit its multiples as proposed Algorithm 1. The obtained test-set is called a minimal Gr¨obner test-set. On the following example we compared the cost storage of the proposed GDDA with Complete Syndrome Decoding. Example 4. Consider Can [9,3,3] ternary code with generator matrix G=  100001020 010011101 001122110 ∈F3×9 3 This code has 33= 27 codewords. If we compute a reduced Gr¨obner basis Gof I+(C) we obtained a test-set consisting of 24 codewords. But for decoding we just need a minimal test-set (we can eliminate those elements which are multiples and those ON THE IDEAL ASSOCIATED TO A LINEAR CODE 19 codewords which are not of minimal support). That is, if we apply GDDA we just need to save in memory 12 elements: (1,2,1,1,1,2,0,0,2) (0,1,1,1,0,0,2,1,1) (1,2,0,0,2,0,2,2,2) (1,1,1,1,0,1,2,0,1) (0,1,2,2,2,2,0,2,1) (0,0,1,1,2,2,1,1,0) (1,1,0,0,1,2,1,2,1) (1,0,1,1,2,0,1,0,0) (1,1,2,2,2,0,0,1,1) (0,1,0,0,1,1,1,0,1) (2,0,0,0,0,2,0,1,0) But if we apply Complete Syndrome Decoding we need to store qn−k−1 (q−1) = 364 coset leaders (we use here the same trick, neither the zero vector nor the multiples of a coset leader are stored). Our experimental results are in good agreement with the following conjecture. Conjecture 1. Given an [n, k]linear code Cover Fq. Let TGbe a test-set for C induced by a reduced Gr¨obner basis Gof the ideal I(C)w.r.t. a degree compatible ordering. Then, |TG|<qn−k−1 (q−1) That is, the cost storage of GDDA is smaller than Complete Syndrome Decoding. 5. Set of codewords of minimal support. We define the Universal Gr¨obner basis of I+(C), denoted by UC, to be the union of all reduced Gr¨obner Bases G≺of I+(C) as ≺runs over all terms orders of K[X]. A binomial Xu1−Xu2in I+(C) is called primitive if there exists no other binomial Xv1−Xv2∈I+(C) such that Xv1 divides Xu1and Xv2divides Xu2. Lemma 5.1. Every binomial in UCis primitive. Proof. It is a straightforward generalization of [20, Lemma 4.6]. Let us fix an arbitrary term ordering ≺in K[X], and let G≺be the reduced Gr¨obner basis of I+(C) w.r.t. ≺. By definition, for any binomial Xu1−Xu2in G≺with Xu1≻Xu2, Xu1is a minimal generator of the initial ideal in≺(I+(C)) and Xu2is a canonical monomial. Now suppose that Xu1−Xu2is not primitive, or equivalently there exists another binomial Xv1−Xv2in I+(C) such that Xv1divides Xu1and Xv2 divides Xu2. We distinguish two cases: •If Xv1≻Xv2, then Xu1is not a minimal generator of the initial ideal in≺(I+(C)). •If Xv1≺Xv2, then Xu2is not in canonical form. Both cases contradicts our assumption. We call the set of all primitive binomials of I+(C) the Graver basis of I+(C) and denote it by GrC. Corollary 2. UC⊆GrC. Proof. The result is a direct consequence of Lemma 5.1. The following theorem suggests an algorithm for computing the Graver basis of the ideal I+(C). For this purpose we describe the Lawrence lifting of the ideal I+(C). Definition 5.2. We define the Lawrence lifting of the ideal I+(C) as the ideal IΛ(C)=X∆w1Z∆w2−X∆w2Z∆w1|w1−w2∈ C in the polynomial ring K[X,Z] where Xand Zdenote n(q−1) variables each. 20 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO Theorem 5.3. The Graver basis of IΛ(C)coincides with any reduced Gr¨obner basis of IΛ(C). Proof. The proof starts with the observation that a binomial X∆u1−X∆u2is primitive in the ideal I+(C) if and only if the corresponding binomial X∆u1Z∆u2− X∆u2Z∆u1in the lifting ideal IΛ(C)is primitive. Therefore, between the Graver basis of the ideals I+(C) and IΛ(C)there exists the following relation: GrΛ(C)=X∆u1Z∆u2−X∆u2Z∆u1|X∆u1−X∆u2∈GrC. Now, take any element g=X∆u1Z∆u2−X∆u2Z∆u1in GrΛ(C). Let Bbe the set of all binomials in IΛ(C)except gand assume that Bgenerates the ideal IΛ(C). Therefore gcan be written as a linear combination of the elements of B. In other words, there exists a binomial X∆v1Z∆v2−X∆v2Z∆v1in Bsuch that one of its terms divides the leading term of g. Replacing v= (v1,v2) by −v= (−v1,−v2) in Fn qif necessary, we may assume that X∆v1Z∆v2divides X∆u1Z∆u2, contrary to the fact that X∆u1−X∆u2is primitive in I+(C). So some non-zero scalar multiple of gmust appear in any reduced Gr¨obner basis of IΛ(C)which is also a minimal generating set of IΛ(C). This theorem gives us an algorithm to compute a Graver basis of the ideal I+(C), exposed as Algorithm 4. Note that Step 3 of Algorithm 4can be executed by applying Algorithm 2. Later in Theorem 5.4 we will give a set of generators of the lawrence lifting ideal IΛ(C)which will facilitate the implementation of this algorithm. Algorithm 4: Algorithm for computing the Graver basis of I+(C) Data: An [n, k] linear code Cdefined over Fq. Result: The Graver basis of the ideal I+(C), GrC. 1Choose any term order ≺on K[X,Z]; 2Compute the Lawrence lifting ideal IΛ(C); 3Compute a reduced Gr¨obner basis of IΛ(C)w.r.t. ≺; 4Substitute the variable Zby 1; Here is another way of defining the ideal IΛ(C). Theorem 5.4. Let Cbe an [n, k]linear code defined over Fqand {w1,...,wk}be the rows of a generator matrix of C. We define the ideal: I3=nX∆αjwi−Z∆αjwioi=1,...,k j=1,...,q−1S{RXi,RZi}i=1,...,n . Then IΛ(C)=I3. Proof. The following result may be proved in the same way as Theorem 2.3. It is easily seen that all the binomials of the generating set of I3belongs to IΛ(C). Indeed, the exponents of all the binomials of the sets RXiand RZicorrespond to the codeword 0∈ C. Conversely, we need to show that each binomial X∆aZ∆b−X∆bZ∆ain IΛ(C) belongs to I3. Applying the definition of the ideal IΛ(C)we can rewrite a−b∈ C as a−b=λ1w1+···+λkwkwith λ1,...,λk∈Fq. ON THE IDEAL ASSOCIATED TO A LINEAR CODE 21 We have that X∆(a−b)Z∆(b−a)−1 = X∆λ1w1Z∆−λ1w1−1k Y i=2 X∆λiwiZ∆−λiwi + k Y i=2 X∆λiwiZ∆−λiwi−1!mod {RX,RZ} =X∆λ1w1Z∆−λ1w1−1k Y i=2 X∆λiwiZ∆−λiwi+ +X∆λ2w2Z∆−λ2w2−1k Y i=3 X∆λiwiZ∆−λiwi+···+ +X∆λk−1wk−1Z∆−λk−1wk−1−1X∆λkwkZ∆−λkwk +X∆λkwkZ∆−λkwk−1mod {RX,RZ}. The last equation forces that X∆(a−b)Z∆(b−a)−1∈*nX∆αjwiZ∆−αjwi−1oi=1,...,k j=1,...,q−1 ∪ {RX,RZ}+. Note that we have actually proved that X∆aZ∆b−X∆bZ∆amod hRX,RZi=X∆(a−b)Z∆(b−a)−1∈I3, which completes the proof. The following result suggests an algorithm to compute the set MC. Note that given the set MCwe could deduce the minimum distance of C. Theorem 5.5. The set of codewords of minimal support of the code Cis a subset of the vectors related to the Graver basis of the ideal associated to C. Proof. Let m∈ MC. Suppose the theorem is false, then no binomial of type X∆a−X∆b∈I+(C) with a−b=mwould be primitive. We can always choose a binomial representation X∆a−X∆b(among all the possible) such that the following condition hold, labelled as necessary condition: •If xi,r ∈supp X∆aand xi,s ∈supp X∆b, then xi,rxi,s −1/∈ RXi. Otherwise we take xi,s X∆a−X∆b∈I+(C), with i= 1,...,n, instead. Let X∆v1−X∆v2be a primitive binomial of I+(C) such that X∆v1divides X∆a and X∆v2divides X∆b, or equivalently, supp(∆v1)⊂supp(∆a) and supp(∆v2)⊂supp(∆b) The necessary conditions defined above guarantee that if there exists a nonzero coordinate i∈supp(a)∩supp(b) then i∈supp(a−b). Therefore, we found v1−v2∈ C \ {m}such that supp(v1−v2)⊂supp(m), which contradicts the minimality of m. Remark 16. We could get rid of the leftover codewords from the set obtained by the above theorem using Algorithm 3. 22 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO Corollary 3. The set of codewords of minimal support of any linear code Ccan be computed from the ideal I3=nX∆αjwi−Z∆αjwioi=1,...,k j=1,...,q−1S{RXi,RZi}i=1,...,n . Proof. This result follows directly from Theorems 5.4 and 5.5. Algorithm 5describes step by step how to compute the set of codewords of minimal support of a linear code. Note that Step 2 of Algorithm 5can be executed by applying Algorithm 2. Moreover, Algorithm 5performs an incremental technique thus we can stop before the end, obtaining a partial result as for example a minimal codeword (with weight the minimum distance of the code). Algorithm 5: Algorithm for computing MC Data: An [n, k] linear code Cdefined over Fq. Result: The set of codewords of minimal support of C,MC 1Choose any term order ≺on K[X,Z]; 2Compute a reduced Gr¨obner basis of I3(defined in Theorem 5.4) w.r.t. ≺; // Recall that I3=IΛ(C), i.e. the Lawrence lifting ideal of I+(C). In other words, if we compute a reduced Gr¨obner basis of I3we are obtain the Graver basis of I+(C) 3Substitute the variable Zby 1; 4Get rid of the leftover codewords using Algorithm 3. In the following example we will see how to use Algorithm 5to obtain the set of codewords of minimal support of a linear code. Example 5. Consider Cthe [6,3] ternary code with generator matrix GC=  1 0 0 2 2 0 0 1 0 1 1 0 0 0 1 1 2 1  ∈F3×6 3. This code has 33= 27 codewords. •The zero codeword. •16 codewords of minimal support. It is easy to check that if a codeword cis a minimal support codeword, then all its multiples are also codewords of minimal support. So these 16 codewords represent 8different supports. 1.(1,0,0,2,2,0) (2,0,0,1,1,0) 5.(1,0,1,0,1,1) (2,0,2,0,2,2) 2.(0,1,0,1,1,0) (0,2,0,2,2,0) 6.(2,0,1,2,0,1) (1,0,2,1,0,2) 3.(1,1,0,0,0,0) (2,2,0,0,0,0) 7.(0,1,1,2,0,1) (0,2,2,1,0,2) 4.(0,0,1,1,2,1) (0,0,2,2,1,2) 8.(0,2,1,0,1,1) (0,1,2,0,2,2) •Another 10 codewords which do not have minimal support. (2,1,0,2,2,0) (1,2,0,1,1,0) (2,1,1,0,1,1) (1,2,2,0,2,2) (1,2,1,2,0,1) (2,1,2,1,0,2) (2,2,1,1,2,1) (1,1,2,2,1,2) (1,1,1,1,2,1) (2,2,2,2,1,2) ON THE IDEAL ASSOCIATED TO A LINEAR CODE 23 Let α= 2 be a primitive element of F3and let us label the rows of Gby w1,w2 and w3. By Theorem 2.3, the ideal associated to Cmay be defined as the following ideal: nX∆(αjwi)−1oi=1,...,3 j=1,2S{RXi}i=1,...,6, where RXiconsists of the following binomials RXi=x2 i,1−xi,2, xi,1xi,2−1, x2 i,2−xi,1with i= 1,...,6. If we compute a Gr¨obner basis of I+(C)w.r.t. a degrev ordering we get 41 binomials representing the following set of 10 codewords: (0,2,2,1,0,2) (0,1,1,2,0,1) (0,1,2,0,2,2) (0,2,1,0,1,1) (0,2,0,2,2,0) (0,1,0,1,1,0) (0,0,2,2,1,2) (0,0,1,1,2,1) (2,2,0,0,0,0) (1,1,0,0,0,0) From those 10 codewords we can remove vectors which are scalar multiples of another in the set, obtaining the following minimal test-set: (1,1,0,0,0,0),(0,0,1,1,2,1),(0,1,0,1,1,0),(0,1,2,0,2,2),(0,1,1,2,0,1) Again if we compare with Complete Syndrome Decoding (CSD) the cost storage of GDDA is much smaller. Indeed, for CSD we need to store 3n−k−1 2= 13 coset leaders. Note that all nonzero codewords are codewords of minimal support but not all codewords of minimal support are represented in the above set. Traditionally, if we compute a Graver basis of I+(C)we obtain 4212 binomials (following the techniques of [20]). However, Algorithm 5returns directly the following set of codewords: (2,1,2,1,0,2) (1,2,1,2,0,1) (1,2,2,0,2,2) (2,1,1,0,1,1) (1,0,2,1,0,2) (2,0,1,2,0,1) (2,0,2,0,2,2) (1,0,1,0,1,1) (0,2,2,1,0,2) (0,1,1,2,0,1) (0,1,2,0,2,2) (0,2,1,0,1,1) (0,0,2,2,1,2) (0,0,1,1,2,1) (2,1,0,2,2,0) (1,2,0,1,1,0) (2,0,0,1,1,0) (1,0,0,2,2,0) (0,1,0,1,1,0) (0,2,0,2,2,0) (1,1,0,0,0,0) (2,2,0,0,0,0) (0,0,0,0,0,0) Observe that the set MCis contained in the previous set. Conjecture 2. Example 5is just a toy example, but the difference between exhaustive search in the whole set of codewords and the set of codewords resulting from Algorithm 5will be higher if Cis chosen among a class of codes with a strong algebraic structure as for example: cyclic codes, Generalized Reed-Solomon codes ... 6. Applications to other types of codes. We will show that the results presented on this article could be generalized to other classes of codes such as modular codes, codes defined over multiple alphabets or additive codes. Modular codes were already discussed in [16] but this new approach allows the computation of a test-set for decoding. Other metrics could be more useful when dealing with group codes or codes over rings such as the Lee norm and G norm (see [1]) since they give us (via the Gray map isometry) nice descriptions of non-linear binary codes. 24 I. M´ ARQUEZ-CORBELLA, E. MART´ INEZ-MORO AND E. SU ´ AREZ-CANEDO 6.1. Modular codes. In [16] the authors were devoted to the study of modular codes Cdefined over the ring Zs. In other words, submodules of (Zn s,+). The important point in that article was the fact that a Graver basis of the lattice ideal associated with a modular code provides the set of codewords of minimal support of the code. Recall that the reduced Gr¨obner basis of the lattice ideal (defined as in [16]) does not allow decoding, see Example 5. However, we can adapt the ideas presented above for linear codes to modular codes. We will use the following characteristic crossing functions. ∆s:Zs−→ Es∪ {0} ⊆ Zs−1and ∇s:Es∪ {0} −→ Zs These applications aim at describing a one-to-one correspondence between the ring Zsand the standard basis of Zs−1, denoted as Es={e1,...,es−1}where ei denotes the unit vector with a 1 in the i-th coordinate and 0’s elsewhere. 1. The map ∆sreplaces the element i∈Zsby the vector eiand 0 ∈Zsby the zero vector 0∈Zs−1. 2. The map ∇recovers the element j∈Zsfrom the unit vector ejand the zero element 0 ∈Zsfrom the zero vector 0∈Zs−1. Now let Xdenote nvector variables X1,...,Xnsuch that each variable Xican be decomposed into s−1 components xi,1,...,xi,s−1with i= 1,...,n, representing the nonzero elements of Zs. Remark 17. Note that the degree of a monomial of type X∆sawith a∈Zn sis defined as the weight of the vector a. Given the rows of a generator matrix of the modular code C, labelled by w1,...,wk in Zn s, we define the ideal associated to Cas the binomial ideal I+(C) = DX∆swi−1i=1,...,k S{RXi}i=1,...,n E, where RXiconsists of all the binomials on the variable Xiassociated to the relations given by the additive table of the ring Zs, i.e. RXi={xi,uxi,v −xi,w |u+v≡wmod s} {xi,uxi,v −1|u+v≡0 mod s}with i= 1,...,n. Remark 18. Note that the main difference of the set of generators describing the ideal associated with a modular code, respect to the set of generators of the ideal related with a Fq-linear code, is its cardinality. That is, for linear codes we need to add all the multiples in Fqof each row wi, while for modular codes this is not necessary. Moreover, the previous result can be extended for codes over Fpwith p prime since Fp∼ =Zp. Taking into account the new definition of the ideal associated to a modular code we can apply all the results of this article to these types of codes. Therefore, now we are not only able to compute the set of codewords of minimal support of modular codes but also we provide a complete decoding algorithm for these codes. 6.2. Multiple Alphabets. Let Cbe a submodule of dimension kover the multiple alphabets Zs1× · · · × Zsn. For simplicity of notation we write es 1,...,es s−1for the canonical basis of Zs−1. Let Xstand for nvector variables X1,...,Xnsuch that each variable Xican be decomposed into si−1 components xi,1,...,xi,si−1with i= 1,...,n representing ON THE IDEAL ASSOCIATED TO A LINEAR CODE 25 the non zero element of Zsi. Let a= (a1,...,an)∈Zs1× · · · × Zsn. We will adopt the following notation: X∆a=X∆s1a1 1···X∆snan n= (x1,1···x1,s1−1)∆s1a1···(xn,1···xn,sn−1)∆snan. Similar to the modular case, given the rows of a generator matrix of C, labelled by w1,...,wk, we may define the ideal associated to Cas the following binomial ideal: I+(C) = DX∆wi−1i=1,...,k S{RXi}i=1,...,n E. Remark 19. The main difference with the modular case is that the relations RXi could be different for each i∈ {1,...,n}. With this new definition, all the results of this article are valid for these types of codes. 6.3. Additive codes. Let Fq1be an algebraic extension of Fq2, i.e. q1=pr1and q2=pr2where pis a prime number and r2divides r1. An Fq2-additive code Cof parameters [n, k] over Fq1is an Fq2-linear subspace of Fn q1. In other words, given the rows of a generator matrix of Clabelled by w1,...,wk∈ Fn q1, the set of codewords of Cmay be defined as: {α1w1+···+αkwk|αi∈Fq2for i= 1,...,k}. Let αbe a primitive element of Fq2. We check at once that the binomial ideal associated to Cis defined by the following binomial ideal I+(C) = nX∆αjwi−1oi=1,...,k j=1,...,q2−1S{RXi}i=1,...,n , where RXiconsist of all the binomials on the variable Xiassociated to the relations given by the additive table of the field Fq1. Of course, the results obtained for Fqlinear codes could be adapted to additive codes. Conclusions. Complete decoding for an arbitrary linear code is proved to be NP- hard. That is, from a computational point of view, our description could not provide a polynomial time algorithm. However, we present a new complete decoding algorithm using the concept of Gr¨obner basis. This proposal was already presented for the binary case before but the generalization to the non-binary case was not possible with the previous approach. It is outside the scope of this article but we are hopeful to achieve efficient methods using this approach for special types of codes like cyclic codes or some subclasses of cyclic codes such as Reed-Solomon codes and BCH codes since these codes have a rich algebraic structure and we can take advantage of existing efficient method to solve polynomial systems whose equations are left invariant by the action of a finite group. We would like to notice that during the (Google Summer of code of 2013) the student Ver´onica Suaste (CIMAT, M´exico) implemented Algorithm 2and also a decoding algorithm using a minimal test-set for inclusion in Sage. The code is published at http://trac.sagemath.org/ticket/14973 and it will be included in next releases of Sage. Note that in the project conclusions, there are some examples in which the new decoding algorithm is faster than the classical syndrome decoding of Sage.