Maximum Weight Spectrum Codes

In the recent work \cite{shi18}, a combinatorial problem concerning linear codes over a finite field $\F_q$ was introduced. In that work the authors studied the weight set of an $[n,k]_q$ linear code, that is the set of non-zero distinct Hamming weights, showing that its cardinality is upper bounded by $\frac{q^k-1}{q-1}$. They showed that this bound was sharp in the case $ q=2 $, and in the case $ k=2 $. They conjectured that the bound is sharp for every prime power $ q $ and every positive integer $ k $. In this work quickly establish the truth of this conjecture. We provide two proofs, each employing different construction techniques. The first relies on the geometric view of linear codes as systems of projective points. The second approach is purely algebraic. We establish some lower bounds on the length of codes that satisfy the conjecture, and the length of the new codes constructed here are discussed.


Introduction
In 1973 Delsarte studied the number of distinct distances for a code C. In the linear case, this reduces to studying the number of distinct weights of the given code [3]. In that work he underlines the importance of this parameter, analyzing its connections with the number of distinct weights of the dual code, and the minimum distance of the code and the minimum distance of the dual. These four parameters are studied in order to obtain various results on the distance properties, and, in particular, they are used to calculate the weight distributions of cosets of a code.
Discussions on set of distinct weights of a code can be traced in [5], where the author skirmishes with the following question. Given a set of positive integers, S, is it possible to construct a code whose set of non-zero weights is S? Partial solutions are presented, and necessary conditions are established.
Recently, in [7] the authors studied a combinatorial problem concerning the number of distinct weights of linear codes. For a code of dimension k over the finite field F q , they showed that the size of the weight set is bounded above by θ q (k − 1) = q k −1 q−1 . They proved this bound to be sharp for binary codes, and for all q-ary codes of dimension k = 2. They conjectured that the bound is sharp for all q and k. Codes meeting this bound are called maximum weight spectrum (MWS) codes.
In this work we first quickly establish the existence of MWS codes for all k, q. We provide two different constructions of [n, k] q MWS codes. In section 2 we give a brief recap on linear and projective codes, and define the basic tools needed for our constructions. In section 3 we give a short proof of the existence of MWS codes via a geometric construction. The construction is pleasingly simple, but provides codes of "large" length. A different approach is taken in Section 4. The construction presented there is inductive, for dimension k ≥ 1, and relies on algebraic tools. In section 5 we investigate lower bounds on the length of MWS codes. We provide a geometric construction of a new infinite family of "shorter" MWS codes, and we determine the asymptotic length of the codes arising from both our algebraic, and our geometric construction. Finally in Section 6 we summarize our work, and discuss some remaining questions.

Linear codes
Let q be a prime power and F q denote the finite field with q elements. Recall that there always exists α ∈ F q that is a primitive element, i.e. F q \ {0} = F * q = α . Throughout what follows, α shall denote a primitive element of F q .
Let n be a positive integer. The Hamming distance between two elements a, b ∈ F n q is defined as d H (a, b) = |{i ∈ {1, . . . , n} | a i = b i }|.
It is well-known that the Hamming distance induces a metric on F n q . The Hamming weight of a codeword c ∈ F n q is defined as Given two vectors a ∈ F n1 q , b ∈ F n2 q we will use the notation (a | b) to denote the vector in where a = (a 1 , . . . , a n1 ) and b = (b 1 , . . . , b n2 ). Definition 2.2. Let 0 < k ≤ n be two positive integers. An [n, k] q code C is a k-dimensional subspace of F n q equipped with the Hamming distance. A generator matrix G for C is a k × n matrix over F q whose row vectors generate C. The minimum distance d of C is the quantity An [n, k] q code C of dimension k ≥ 2 is said to be non-degenerate if no coordinate position is identically zero.
Throughout, by [n, k, d] q code we will denote an [n, k] q code C whose minimum distance is d. Moreover, unless specified otherwise, all codes discussed here are assumed to be non-degenerate. Definition 2.3. Let G be the subgroup of the group of linear automorphisms of F n q generated by the permutations of coordinates and by the multiplication of the i-th coordinate by elements in F * q . Two codes C and C ′ are said to be equivalent if there exists σ ∈ G such that C ′ = σ(C).
Definition 2.4. Let β ∈ F q and c ∈ F n q . We define the number c[β] = |{i ∈ {1, . . . , n} | c i = β}| . and the entries distribution vector for c as Some basic properties concerning the entries distribution vector V (c) are presented in the following. The proofs follow readily from the respective definitions.
Proposition 2.5. Let c ∈ F n q , β ∈ F * q and let e ∈ F n q be the vector whose entries are all equal to 1. The following hold: ). In particular, since β = α j for some j, then the vector consisting of the first q − 1 entries of V (βc) is the j-th shift of the vector formed by the first q − 1 entries of V (c).
where ·, · denotes the standard inner product.
Definition 2.6. Given an [n, k] q code C with generator matrix G and r = (r 1 , . . . , r q−1 ) ∈ N q−1 , we define the generalized r-repetition code of C as the code C(r) whose generator matrix is The next result explains some properties of the code C(r).

For every
Proof. 1-4. Follow from the definition.

5.
It is an easy calculation, that follows from part 1 and 3 of Proposition 2.5.

Projective systems
In this section we introduce the geometric view of linear codes, as detailed in [9] (or in [1] for codes that are equivalent to linear). We start with a short overview of the fundamentals of finite projective geometry. For a detailed introduction we refer to the recent book by Ball [2]. We let P G(k, q) represent the finite projective geometry of dimension k and order q. Due to a result of Veblen and Young [10], all finite projective spaces of dimension greater than two are isomorphic up to the order q. The space P G(k, q) can be modelled most easily with the vector space of dimension k + 1 over the finite field F q . In this model, the one-dimensional subspaces represent the points, two-dimensional subspaces represent lines, etc. Formally, we have Using this model, it is not hard to show by elementary counting that the number of points of P G(k, q) is given by Central to the geometric view of linear codes is the idea of a projective system.
, not all of which lie in a hyperplane, where n = |M| , and Note that the cardinalities above are counted with multiplicities in the case of a multiset. We denote by m(P ) the multiplicity of the point P in M. Two projective [n, k, d]-system M and M ′ are said to be equivalent if there exists a projective isomorphism of P G(k − 1, q) mapping M to M ′ .
Let C be an [n, k] q code with k × n generator matrix G. Note that multiplying any column of G by a non-zero field element yields a generator matrix for a code which is equivalent to C. Consider the (multi)set of one-dimensional subspaces of F n q spanned by the columns of G. In this way the columns may be considered as a (multi)set M of points of P G(k − 1, q).
For any non-zero vector v = (v 1 , v 2 , . . . , v k ) in F k q , it follows that the projective hyperplane

Maximum weight spectrum codes
The weight set of a code has been studied in many contexts of coding theory, and for different purposes. In [5], using the relation between the weight distributions of a code and its dual, the author investigated necessary conditions for the existence of a linear binary code with a given weight set. One of the first to study the cardinality of the weight set of a code was Delsarte [3]. He demonstrated its importance in computing the weight distributions of cosets of a code. Other problems concerning the weight set and its cardinality can be found in [8,4].
Recently in [7], Shi et. al. investigated the maximum cardinality of the weight set of a code, showing the following upper bound.
Motivated by Proposition 2.9, we define a new family of codes.
Remark 2.11. Observe that this definition is coherent with the existing literature. If C is an [n, k] q code, then the weight spectrum of C typically denotes the vector In this framework, the cardinality of the weight set of C coincides with the Hamming weight of the vector A(C), and C is MWS if and only if the Hamming weight of is actually the maximum possible value for the Hamming weight of A(C).
In [7] the authors conjectured, motivated by experimental results, that for every q and k, MWS codes exist.In the following section, we quickly establish the truth of this conjecture.

A geometric construction of MWS codes
In this section we are going to give a geometric construction of [n, k] q MWS codes for every prime power q and every k ≥ 2.
Given an [n, k, d] q code C, we can consider the associated projective [n, k, d] q -system M(C), whose points are given by the columns of the generator matrix. So Char M (A) is the number, including multiplicity, of points in M ∩ A. With a slight abuse of notation, we will write m(P ) = Char M (P ), for any point P .
The following follows directly from the definitions.  We now provide a construction of a projective system as required in the Lemma 3.3. Let Π = P G(k − 1, q), k ≥ 2 and let the points of Π be denoted P 0 , P 1 , . . . , P θq(k−1)−1 . For each i, include P i in M with multiplicity 2 i .
For k = 2, Π is the projective line, so clearly no two points will have the same character. Consider k ≥ 3. Each hyperplane in Π is incident with precisely θ q (k − 2) distinct points, and simple counting shows that every pair of distinct hyperplanes are incident with precisely θ q (k − 3) distinct points. For any particular hyperplane H, let us suppose that H is incident with P i1 , P i2 , . . . , P i θq (k−2) . It follows that It follows that no two hyperplanes have the same character (consider the binary expansion of the respective characters). We have therefore proved the following result. We note that the construction used in establishing the Theorem 3.4 involves codes of considerable length (asymptotically). A natural question is whether "short" MWS codes exist. We investigate this question in the sequel.

An algebraic construction of MWS codes
In this section we give a different construction of MWS codes that relies on algebraic properties of linear codes. This construction is inductive, where the inductive step is divided in two parts.
We now define two properties playing a central role in the next construction.
Proposition 4.1. Let q be a prime power, and let C be an [n, k] q MWS code.

Let q ≥ 3. If C satisfies both (A) and (B), then there exists an
Proof. Let t = q k −1 q−1 and let 1 ≤ w 1 < w 2 < . . . < w t ≤ n be the distinct weights of the code C. For N > 0 consider the embedding For part 1 take N = 2n + 1 and letC be the [N, k + 1] q code generated by φ(C) and e, where e is the vector whose entries are all equal to 1. For every c ∈ C we have w(φ(c)) = w(c), and , and take the [N, k + 1] q codeC generated by φ(C) and x, where x is the vector defined as The proof that this code is MWS is analogous to part 1, so we shall show that (B) is satisfied.
C satisfies (b), and each entry in V (c) is strictly less than N − n (q ≥ 3). It follows that the entries of V (φ(c)) are pairwise distinct. Now, for some α j ∈ F * q , and c ∈ C we consider the entries By part 2 of Proposition 2.5, V (c + α j e) is a permutation of the vector V (c) and hence the entries are pairwise distinct. This gives We want to use this result for an inductive construction of [n, k] q MWS codes. However, starting with an [n, k] q MWS code, this construction gives a new [N, k+1] q MWS codeC that does not satisfy (A). In fact, for every j = 1, . . . , q − 1, if we take z 1 = α j x + φ(c) and z 2 = α j x + φ(λc) as in the proof above, for some 1 = λ ∈ F * q , then z 1 = z 2 , and z 1 [α j ] = c[0] = (λc)[0] = z 2 [α j ]. Starting from this codeC, we need to construct another MWS code that satisfies (A). This can be done using the generalized r-repetition code of C with a suitable vector r, as we will see in the following. We first need an auxiliary result. Proof. Let s ∈ N and H = ∪ s j=1 H j , where i 's not all zeros. We take a vector of the form v = (1, t, . . . , t m−1 ) and show that it cannot be in H for every t ∈ N. In fact, v ∈ H if and only if there exist an ℓ such that Since F (T ) is a non-zero polynomial in Q[T ] of degree at most s(m − 1), it can not vanish on the whole N.
We now wish to show a r [α i ] = b r [α i ] for every a, b ∈ C such that a = b, for some i = 1, . . . , q − 1. Using part 5 of Proposition 2.7, this equates to showing or, equivalently, This is equivalent to the condition where which is not possible.
The following Lemma gives necessary and sufficient conditions for the existence of a vector r = (r 1 , . . . , r q−1 ) ∈ N q−1 that satisfies (⋆).  Proof. For a, b ∈ C \ {0}, if a = λb for any λ ∈ F * q , then, since C is a MWS code, w(a) = w(b), and this implies V (a) = V (b). This condition can be reformulated as If we do this for every c ∈ C \ {0}, we get r = (r 1 , . . . , As we did for (⋆), we now find conditions such that (⋆⋆) has solutions. Proof. If V (c) has all distinct elements it is clear that H c i,ℓ is an hyperplane for every i < ℓ. Therefore, we conclude using Lemma 4.2.
The following theorem summarizes this part on the generalized r-repetition code C(r), fundamental tool for this construction of MWS codes. Proof. Consider r = (r 1 , . . . , r q−1 ) ∈ N q−1 not identically zero such that both (⋆) and (⋆⋆) are satisfied. Such a vector r exists, since we can always find, by Lemmas 4.2 and 4.7 and Corollary 4.6, a non-zero vector in N q−1 that is not in  Proof. We prove by induction that there exists an [n (k) , k] q MWS code C k that satisfies (B).

2
. It is easy to see that C 1 is MWS and satisfies (B). Suppose now that we have an [n (k) , k] q MWS code C k satisfying (B). We want to show that we can build an [n (k+1) , k + 1] q code C k+1 that satisfies the same property. By Theorem 4.8, we can find r ∈ N q−1 such that C k (r) is an [Rn, k] q MWS code satisfying (A) and (B). Therefore, by part 2 of Proposition 4.1 we get an [n (k+1) , k + 1] q MWS code C k+1 with property (B).

Example 4.10.
Here we see what happens in the easiest case that was not covered in [7], i.e. when q = k = 3. We consider the finite field F 3 = {0, 1, 2}. The code C 1 ⊆ F 3 3 is {(0, 0, 0), (1, 2, 2)} and the inductive construction gives a [7, 2] 3 code C 2 whose generator matrix is At this point we can choose r = (1, 6) that is not contained in any of those hyperplanes, and consider the code C 2 (r). Such a code is a [49, 2] 3 code over F 3 whose generator matrix is given by Here the vectors V (c), for 0 = c ∈ C 2 (r), are given by The code C 2 (r) satisfies (B). Moreover, a[1] = b [1] for all a, b ∈ C 2 (r) with a = b. Hence it satisfies also (A) and we can use part 1 of Proposition 4.1 and then construct the [99, 3] q code as described in the proof of that result. We first embed the code C 2 (r) into F 99 3 , by concatenating every codeword to the 0 vector of length 50. Finally we add to the resulting code the codeword whose entries are all equal to 1, and we consider the subspace generated. The obtained code C 3 will have 13 distinct non-zero weights, given by {21, 49, 35, 42, 99, 91, 86, 77, 72, 94, 69, 63, 93}, i.e. it is a [99, 3] q MWS code.

Length of MWS codes
In this section we investigate lower bounds on the lengths of [n, k] q MWS codes. A trivial lower bound is of course given by n ≥ θ q (k − 1).
In the case q = 2 this bound is sharp, in the sense that it is possible to construct a [θ 2 (k−1), k] 2 MWS code for each k ≥ 1 [7, Theorem 1]. This lower bound is not optimal when q ≥ 3. Indeed, we have the following result.
Proof. Let C be an [n, k] q MWS code with k ≥ 2. Let the columns of a generator matrix correspond to the [n, k, d] q projective system M in Π = P G(k − 1, q). Consider the set S of incident point-hyperplane pairs (P, Λ), where P ∈ M. Summing over all members of M we obtain |S| = On the other hand, summing over all hyperplanes of Π we obtain where the inequality is a consequence of Lemma 3.3. The result follows from (1) and (2).
As we have seen in Theorem 3.4, there exist [n, k] q MWS codes of length n = O(2 q k−1 ). We are therefore motivated to determine values of n for which [n, k] q MWS codes exist with Corollary 5.2. If C is an [n, k] q MWS code satisfying property (A), then Proof. By Proposition 4.1, C gives rise to an [2n + 1, k + 1] q MWS codeC. The result follows by applying the bound in Lemma 5.1 toC Remark 5.3. Observe that in the case q = 2, the bound (3) becomes which coincides with the bound in Lemma 5.1. For q ≥ 3 the two bounds diverge, so the question remains as to whether the bound in Lemma 5.1 may be sharp for some q ≥ 3. For k = 2 we have an answer. Proof. For the first part, pick a triangle of points P 0 , P 1 , P 2 in the (Fano) plane Π = P G(2, 2). Construct a projective system M, whereby m(P i ) = 2 i . One easily verifies that the characters of the seven lines in Π are 0, 1, 2, . . . , 6 respectively. Hence, the corresponding code is MWS. For the second part, let Π = P G (2, 3), and define the projective system M with point multiplicities as indicated in the diagram. Note that the existence of a [7, 3] 2 -MWS code is also shown in [7]. Proposition 5.6. For each q, there exists an [n, 3] q MWS code with n ≤ q−1 2 (q 3 + q 2 + q). Proof. For q = 2, 3, the result follows from Proposition 5.5, so assume q > 3. Let Π = P G(2, q) and consider a set T = {P, Q, R} of three non-collinear points, and the three lines that are their joins, ℓ 0 = P, R , ℓ 1 = P, Q , and ℓ 2 = Q, R . Let ℓ 0 \ T = {P 1 , P 2 , . . . , P q−1 },

Figure 2:
Next, we assign multiplicities to points to construct the projective system M. Consider first the case that q > 2 is even. Let m(P i ) = i, m(Q i ) = iq, and m(R i ) = iq 2 , 1 ≤ i ≤ q − 1. We claim that no two lines of Π have the same character. For each line, ℓ, Char M (ℓ) may be written uniquely as a + bq Consider the following cases.
t=0: In this case, 1 ≤ a, b, c ≤ q − 1, and d = 0. Moreover, as two points uniquely determine a line, no two such lines agree in as many as two of a, b, c.
t=1: In this case, exactly one of a, b, c are non-zero, and d = 0. That no two such lines have the same character follows from the fact that two points determine an unique line, and that no two (distinct) points in {ℓ 0 ∪ ℓ 1 ∪ ℓ 2 } \ T have the same multiplicity.
t=0: In this case, 1 ≤ a, b ≤ q − 1, 0 ≤ c ≤ q − 1, c = q−1 2 , and d = 0. As two points uniquely determine a line, no two such lines agree in both a and b.
No two such lines have the same character follows from the fact that two points determine an unique line, and that no two (distinct) points in {ℓ 0 ∪ ℓ 1 ∪ ℓ 2 } \ T have the same multiplicity. Consequently, for q > 3 we arrive at an [n, 3] q MWS code C, where Proof. The result clearly holds for k = 2, where M must contain at least q > 2 distinct points. Consider k > 2, and suppose λ is an hyperplane of Π with M ⊂ Π. Let σ be any (k − 2)flat within λ. Through σ there are q hyperplanes distinct from λ, each of which has character Char M (σ). Since q > 2 we have a contradiction. . Note that such a set may always be chosen. Embed Π in Σ = P G(k + 1, q), and distinguish a point P ∈ Σ * = Σ \ Π. : . . , Q i,q−1 }. Define the projective system M ′ by letting Char M ′ (R) = Char M (R) for each point R ∈ Π, and by letting Char M ′ (Q i,j ) = jq t+1 . We claim that M ′ is a projective system of an MWS code. Suppose λ is an hyperplane, with Char M ′ (λ) = Char M ′ (Π). Each hyperplane must meet each ℓ i in at least one point. For each i, j, we have m(Q i,j ) > n = Char M ′ (Π). If λ = Π, then it must be the case that λ ∩ ℓ i = {P } for i = 0, 1, . . . , k − 1, and therefore Char M ′ (λ) = Char M (λ) = n, contradicting Lemma 5.7. It follows that if λ = Π is an hyperplane of Σ, then Char M ′ (λ) = Char M ′ (Π). It therefore suffices to consider hyperplanes distinct from Π. Let λ 1 , λ 2 be hyperplanes with Char M ′ (λ 1 ) = a 0 +a 1 q +a 2 q 2 +· · ·+a k+t q k+t , and Char M ′ (λ 2 ) = b 0 +b 1 q+b 2 q 2 +· · ·+b k+t q k+t . If λ 1 ∩Π = λ 2 ∩Π, then (a 0 , a 1 , a 2 , . . . , a t−1 ) = (b 0 , b 1 , b 2 , . . . , b t−1 ) ( Char M ′ (λ 1 ∩ Π) = Char M ′ (λ 2 ∩ Π) since C is MWS). It therefore suffices to consider the case that λ 1 ∩ Π = λ 2 ∩ Π. Let σ be a (k − 2)-flat in Π. Since the points of T are in general position, there exists at least one j with T j / ∈ σ. A dimension argument shows the hyperplanes containing σ must meet ℓ j in mutually distinct points. By considering σ = λ 1 ∩ λ 2 , it follows that b j = a j , and whence Char M ′ (λ 1 ) = Char M ′ (λ 2 ). Therefore, M ′ is a projective system of an [n, k + 1] q -MWS code, where Remark 5.10. The bound in Lemma 5.1 is rather optimistic in the following sense: The only way a code can achieve this bound is if there is an hyperplane of every character, from 0 to θ q (k − 1) − 1. For k > 2, constructions for codes meeting the bounds in Lemma 5.1, even asymptotically, seem quite elusive.

Length of the codes arising from the algebraic construction
In order to give a partial answer to the question above about the length of MWS codes, we will try to estimate the length n (k) of the code C k obtained using the construction given in Section 4. We will show indeed that asymptotically the algebraic construction provides codes of considerably smaller length with respect to those given in Theorem 3.4. For this purpose we need to understand how the length increases after each of the two partial steps. We will denote by C k the k-dimensional MWS code, by n (k) its length and by r (k) ∈ N q−1 the vector that minimize the quantity R (k) = r (k) 1 + . . . + r (k) q−1 , obtained in Theorem 4.8. We want to find some recurrence relation or upper bound for n (k) , and this certainly involves also R (k) and T (k) = max{c r [β] | c r ∈ C k (r (k) ) \ {0}, β ∈ F * q }. Since we want to minimize the length of our MWS codes, at each step the vector r (k) is chosen as a vector that minimizes R (k) among all the vectors that satisfy both (⋆) and (⋆⋆).
Proof. There are q k 2 hyperplanes of the form H a,b i with a, b ∈ C k and a = b. Moreover, for 1 ≤ i < ℓ, we have that the linear hyperplanes H c i,ℓ = H c,α ℓ−i c i . Therefore, we already counted them. Finally, the hyperplanes of the form H c 0,ℓ , for 1 ≤ ℓ ≤ q − 1, c ∈ C k \ {0}, are exactly (q k − 1)(q − 1) many.
Corollary 5.13. For k ≥ 2, there exists an r (k) ∈ N q−1 satisfying Theorem 4.8 such that Proof. Equation (7) with m = D (k) implies that there exists a non-zero r (k) = (r where the last inequality follows from Lemma 5.12. Now we estimate the asymptotic order of the parameters n (k) and T (k) .
Proof. We prove it by induction. Recall that n (1) = 1, T (1) = q − 1 and R (1) = q(q−1) Suppose that the result holds for n (k) and T (k) . By (4)  At this point we can conclude our estimate of the length of MWS codes obtained via the algebraic construction.
Theorem 5.15. Using the construction given in Section 4 we can obtain an [n, k] q MWS codes with length n = O(q k(k+1)−4 ).
Remark 5.16. Observe that the asymptotic estimate of the length of an MWS given in Theorem 5.15 is done considering the worst-case scenario, and therefore the algebraic construction could give a shorter code in practice. Indeed it could be possible to improve the asymptotic estimate of R (k) that we computed with a worst-case argument.

Conclusions and open questions
In this paper we have introduced the concept of [n, k] q maximum weight spectrum (MWS) codes. We provided two different constructions for MWS codes, showing that they exist for all dimensions, and over every finite field. In Lemma 5.1 we provide a lower bound on the length of MWS codes, which is shown to be sharp for k = 2. The infinite families of [n, k] q -MWS codes provided here have lengths n ≥ O(q k 2 +k− 4 2 ). This raises the natural question: How short may an MWS code be? In other words, the general problem for fixed k, and q, is to determine the least value n such that an [n, k] q -MWS code exists. It is with some trepidation that we refer to such codes as optimal MWS codes (the term optimal is over used, but seems most appropriate here). Rather than pose a conjecture on the length of optimal MWS codes, the authors invite investigation into the existence of infinite families of [n, k] q -MWS codes with O(q k ) ≤ n ≤ O(q k 2 +k− 4 2 ).