1 Introduction

In his paper [32], Wei has introduced new parameters for linear block codes to characterize the performance of linear codes when such codes are used on the wiretap channel of type II. These parameters, called the Generalized Hamming Weights, were already studied earlier in [11] in a different context. Later, Cai and Yeung introduced in [2] an equivalent scheme for secure network coding. Silva et al. considered this problem where they introduced the use of rank metric codes. Several works on generalized weight of rank metric codes appeared after this [6, 13,14,15, 20, 22, 25]. In these works, multiple notions of generalized rank weights were proposed. And ultimately, these definitions appeared to be equivalent. Continuing with these works, we consider a newer but more natural definition of generalized rank weights for rank metric codes. Our definitions are analogous to the definitions given by Wei in [32] for Hamming metric. Furthermore, we consider a geometric approach analogous to the work of Tsfasman and Vladut in [31]. Such approach to study linear codes were already done in [12] and it was probably introduced much earlier. Many results in this paper are translation of the definitions and results from [31, 32] from the Hamming metric to the rank metric. This approach is done by using geometrical sets which we call q-system. It turns out that q-systems are the vectorial counterpart of linear sets [16, 24] and although we did not know about them, they appear to be well studied geometric objects, there are many works about them and recently, results about the connection between linear sets and rank metric codes were presented [3, 4, 19, 26, 29]. Going back to Hamming metric codes, in their work, [17], Liu and Chen give some properties of constant weight linear codes. Another result of Bonisoli [1] also gives a characterization of constant weight linear codes. These results give us a similar idea for the main result of this work, which is a complete classification of constant rank weight codes.

In Sect. 2, we first recall some results in the Hamming metric setting, for us to see the analogy when we present our results for rank metric codes. In Sect. 3, we introduce the notion of generalized rank weights for rank metric codes, both in analogy with the work in [31] and [32]. In Sect. 4, we follow the description of wiretap network codes from [22] to show why our definition of generalized rank weights is proper for applications. In Sect. 5, we will give some properties of the generalized rank weights. For instance we will see the monotonicity and the duality properties for these parameters. In Sect. 6, we recall the notion of linear sets and we explain why they are the projective version of the notion of q-system. We give a brief summary of the relations between linear rank metric codes and linear sets. In Sect. 7, we will give a classification of constant rank weight codes. In fact if the dimension is at least 2, then, up to equivalence, there is only one constant rank weight code. We give the construction for such constant rank weight codes.

Before we start let us define the following notations.

  • For a field \({\mathbb {F}}\), \({\mathbb {F}}^{m\times n}\) denotes the set of all \(m\times n\) matrices over \({\mathbb {F}}\).

  • For a matrix \(\mathbf {A}\), \(\mathbf {A}^T\) is its transpose.

  • For two matrices \(\mathbf {A}\) and \(\mathbf {B}\) of the appropriate size, \([\mathbf {A}|\mathbf {B}]\) is the concatenation of the two matrices columnwise.

  • For an \({\mathbb {F}}\)-linear code (resp. \({\mathbb {F}}\)-vector space) \(\mathcal {C}\), \(\mathcal {D}<\mathcal {C}\) means that \(\mathcal {D}\) is an \({\mathbb {F}}\)-subcode (resp. \({\mathbb {F}}\)-subspace) of \(\mathcal {C}\).

  • \(\dim _{\mathbb {F}}V\) is the dimension of V as an \({\mathbb {F}}\)-vector space.

  • If \(\mathbf {A}\) is a matrix over \({\mathbb {F}}\) with n columns, then for \(I\subset \{1,\ldots , n\}\), \(\mathbf {A}_I\) denotes the matrix obtained from \(\mathbf {A}\) by keeping only the i-th columns with \(i\in I\).

  • \(\{\mathbf {A}\}\) denotes the set of vectors formed by the columns of \(\mathbf {A}\).

  • For a field \({\mathbb {F}}\) and an \({\mathbb {F}}\)-vector space X, the matrix \(\mathbf {G}^X\) over \({\mathbb {F}}\) denotes a generator matrix of X i.e. its rows form an \({\mathbb {F}}\)-basis of X.

  • Conversely, for a field \({\mathbb {F}}\) and a matrix \(\mathbf {A}\), \(\left<\mathbf {A}\right>_{\mathbb {F}}\) denotes the \({\mathbb {F}}\)-vector space generated by the rows of \(\mathbf {A}\).

  • \(\{\mathbf {A}\}_{{\mathbb {F}}} = \left<\mathbf {A}^T\right>_{{\mathbb {F}}}\) denotes the \({\mathbb {F}}\)-vector space generated by the columns of \(\mathbf {A}\).

  • For a set of vectors of the same length X, [X] denotes a matrix with the elements of X as columns (after fixing their order).

  • For an n dimensional \(\mathbb {F}_q\)-subspace X of \(\mathbb {F}_{q^m}^k\) (considered as a vector space over \(\mathbb {F}_q\)), we choose an arbitrary basis \(\{P_1,\ldots ,P_n\}\) of X and \([X]_{\mathbb {F}_q}\) denotes the matrix with \(P_1,\ldots ,P_n\) as columns.

2 Hamming metric codes

Many results in this paper will use a generalization of the notion of projective system into the rank metric setting. So before we proceed to the rank metric codes, it is natural to recall the geometric approach for linear codes by Tsfasman and Vladut in [30]. First let us recall the definitions of generalized weights as it was introduced by Wei in [32].

Let \(\mathbb {F}_q\) be a finite field with q elements. Suppose \(\mathcal {C}\) is an [nk]-linear code over \(\mathbb {F}_q\). For a non-zero \(\mathcal {D}<\mathcal {C}\), we define the support \(\mathfrak {S}(D)\) of \(\mathcal {D}\) as

$$\begin{aligned} \mathfrak {S}(\mathcal {D}) = \left\{ i:\exists (x_1,\ldots ,x_n)\in \mathcal {D}, x_i\ne 0 \right\} . \end{aligned}$$

As we mentioned in the introduction, the notion of generalized Hamming weights were introduced by Wei in [32] and they have some applications in cryptography, with the use of codes in wire-tap channels of type II [23].

Definition 1

(Generalized Hamming weights) For an [nk]-linear code \(\mathcal {C}\) over \(\mathbb {F}_q\) and any integer r with \(1\le r\le k\), the r-th generalized weight of \(\mathcal {C}\), denoted by \(d_r(\mathcal {C})\), is

$$\begin{aligned} d_r(\mathcal {C}) = \min \left\{ |\mathfrak {S}(\mathcal {D})|:\mathcal {D}<\mathcal {C}, \dim _{\mathbb {F}_q} \mathcal {D}= r \right\} . \end{aligned}$$

It is easily seen that the minimum distance of a linear code \(\mathcal {C}\) is given by \(d_1(\mathcal {C})\). Namely, a non-zero codeword defines a subcode of dimension 1 and the size of the support is just the number of non-zero elements in the codeword.

An alternative description of the generalized Hamming weight was given in Theorem 2 of [32] by the next proposition. For us to see the application of the generalized rank weights, we will need a similar definition. For now, let us see it for the Hamming metric.

Proposition 1

Let \(\mathbf {H}\) be a parity check matrix of an [nk]-linear code \(\mathcal {C}\) over a field \(\mathbb {F}_q\). For a subset \(I\subseteq \lbrace 1,\ldots , n\rbrace \), let \(\mathbf {H}_I\) be the submatrix of \(\mathbf {H}\) corresponding to I. Then, for \(1\le r\le k\),

$$\begin{aligned} d_r(\mathcal {C}) = \min \left\{ |I|:|I| - \mathbf {rank}\;\mathbf {H}_I \ge r\right\} . \end{aligned}$$

Another definition of the generalized Hamming weight was also given by Tsfasman and Vladut in [31] using a geometric approach. Before that we need to translate the notion of linear code into some geometric terms. Furthermore, when we talk about linear code, we will always talk about non-degenerate linear codes i.e. no columns of any fixed generator matrix of the code is the zero column.

Definition 2

(Projective system) A projective system over \(\mathbb {F}_q\) with parameters [nkd] is a set X of n points (not necessarily distinct) in a \((k-1)\)-dimensional projective space \(\mathbb {P}= \mathbb {P}^{k-1}(\mathbb {F}_q)\) such that X is not contained in any hyperplane in \(\mathbb {P}\) and

$$\begin{aligned} n-d = n-d(X) := \max \left\{ |X\cap H|:H \text { a hyperplane in }\mathbb {P}\right\} , \end{aligned}$$

where the intersection is counted with multiplicity.

It was shown in [30] that, up to equivalence, [nkd]-projective systems are in one to one correspondence with non-degenerate [nkd]-linear codes. For the definition of the equivalence used in this correspondence, one can have a look at [30].

The definition of the minimum distance d can naturally be generalized to the generalized weights of a projective system:

$$\begin{aligned} n-d_r(X) := \max \left\{ |X\cap \Pi |:\Pi \text { a projective subspace of codimension } r \text { in } \mathbb {P}\right\} . \end{aligned}$$

Obviously, we have \(d_1(X) = d(X)\). As it was shown in [31], we have the following proposition.

Proposition 2

Let \(\mathbf {G}\) be the generator matrix of a linear code \(\mathcal {C}\) and let \(X = \{\mathbf {G}\}\) (i.e. the set of vectors formed by the columns of \(\mathbf {G})\) be its corresponding projective system. Then \(d_r(\mathcal {C}) = d_r(X)\).

Now the goal of the next section is to generalize these notions in the rank metric setting.

3 Rank metric codes

In this section, we give the analogy to the geometric approach of Tsfasman and Vladut. Rank metric codes were independently introduced by Delsarte [5] and Gabidulin [8]. This class of codes are very interesting as they have found applications in cryptography and network coding. Before we define the analogue of projective system let us briefly recall some properties of rank metric codes.

For a vector \(\mathbf {x}= (x_1,\ldots ,x_n) \in \mathbb {F}_{q^m}^n\) the rank weight, \(\mathbf {rank}\;\mathbf {x}\), of \(\mathbf {x}\) is the dimension of the \(\mathbb {F}_q\)-subspace of \(\mathbb {F}_{q^m}\) generated by \(\{ x_1,\ldots , x_n\}\). For two vectors \(\mathbf {x}= (x_1,\ldots ,x_n)\) and \(\mathbf {y}=(y_1,\ldots ,y_n)\) in \(\mathbb {F}_{q^m}^n\), the distance between \(\mathbf {x}\) and \(\mathbf {y}\) is

$$\begin{aligned} \mathbf {d}(\mathbf {x},\mathbf {y}) = \mathbf {rank}\;(\mathbf {x}-\mathbf {y}). \end{aligned}$$

An [nkd] \(\mathbb {F}_{q^m}\)-linear rank metric code \(\mathcal {C}\) over the extension \(\mathbb {F}_{q^m}/\mathbb {F}_q\) is an \(\mathbb {F}_{q^m}\)-subspace \(\mathcal {C}<\mathbb {F}_{q^m}^n\) of dimension k such that the minimum of the rank distance between two distinct codewords is d. The minimum rank distance of a rank metric code \(\mathcal {C}\) will be denoted by \(d^R(\mathcal {C})\). If \(\mathbf {G}\) is a generator matrix of a linear rank metric code \(\mathcal {C}\), then, as in [14], we say that \(\mathcal {C}\) is non-degenerate if the columns of \(\mathbf {G}\) are linearly independent over the field \(\mathbb {F}_q\).

For an [nkd] \(\mathbb {F}_{q^m}\)-linear rank metric code \(\mathcal {C}\) over the extension \(\mathbb {F}_{q^m}/\mathbb {F}_q\), the Singleton bound states that \(d\le n-k+1\) [5, 8]. If such bound is attained, i.e. \(d= n-k+1\), then we say that the code is a maximum rank distance (MRD) code. MRD codes are interesting because if we fix \(\mathbb {F}_{q^m},n,d\), then they are the codes with the largest possible size. That property allows cryptographers to use smaller key sizes when they use MRD codes in public key cryptosystems based on linear codes [9]. Many constructions of MRD codes exists. See for example [5, 8, 26, 28].

Remark 1

We defined rank metric codes as subspaces of \(\mathbb {F}_{q^m}^n\), however they can also be defined by subspaces of linearized polynomials as in [26, 28]. More generally, rank metric codes can be represented as a subspaces of quotient ring of a skew-polynomial ring [10, 27]. Furthermore, rank metric codes can also be considered to be linear over \(\mathbb {F}_q\) only, in this case codewords can also be represented by matrices in \(\mathbb {F}_q^{m\times n}\). If \(\mathcal {C}\subset \mathbb {F}_q^{m\times n}\) is linear over \(\mathbb {F}_q\) only and its minimum distance is d, then the Singleton bound is given by \(\dim _{\mathbb {F}_q} \mathcal {C}\le \max \{m,n\}(\min \{m,n\}-d+1)\). As usual, codes satisfying the equality is called maximum rank distance codes.

Remark 2

The reader should pay attention to the fact that the vector space \(\mathbb {F}_{q^m}^n\) can be equipped both with the rank metric and the Hamming metric. In fact, depending on the situation, we use both metrics on the same codeword.

From now on, we will only consider non-degenerate linear rank metric codes. We have the following equivalent definition of the rank weight of a codeword.

Proposition 3

Let \(\mathcal {C}\) be a non-degenerate linear rank metric code over the extension \(\mathbb {F}_{q^m}/\mathbb {F}_q\). The rank weight of a vector \(\mathbf {x}\in \mathcal {C}\) is equal to the minimum of the Hamming weight of \(\mathbf {x}\mathbf {M}\), where \(\mathbf {M}\) runs through \(GL_n(\mathbb {F}_q)\).

Proof

Suppose that \(\mathbf {x}\) is a codeword with minimum rank weight l and, up to permutation, we may assume that \(\mathbf {x}= (x_1,\ldots ,x_n)\), where \(\mathbf {rank}\;\mathbf {x}= \mathbf {rank}\;(x_1,\ldots ,x_l)\). Then we can find an invertible matrix \(\mathbf {M}\) such that \(\mathbf {x}\mathbf {M}= (x_1,\ldots ,x_l,0,\ldots ,0)\). \(\square \)

It is this fact that helps us to generalize all notions from Hamming metric codes to rank metric codes. For instance we can define the minimum distance of a rank metric code as follows.

For a linear code \(\mathcal {C}\) of length n and a matrix \(\mathbf {M}\in \mathbb {F}_q^{n\times n}\), \(\mathcal {C}\mathbf {M}\) denotes the linear code such that all codewords are products \(\mathbf {x}\mathbf {M}\) for some \(\mathbf {x}\in \mathcal {C}\).

Theorem 1

The minimum distance \(d^R(\mathcal {C})\) of a rank metric code \(\mathcal {C}\) is equal to

$$\begin{aligned} d^R(\mathcal {C}) = \min _{\mathbf {M}\in GL_n(\mathbb {F}_q)} d(\mathcal {C}\mathbf {M}), \end{aligned}$$

where on the right hand side we have the Hamming distance.

We call two [nkd]-linear rank metric codes \(\mathcal {C}_1\) and \(\mathcal {C}_2\) equivalent if there exists \(\mathbf {M}\in GL_n(\mathbb {F}_q)\) and \(a\in \mathbb {F}_{q^m}^*\) such that \(\mathcal {C}_2 = a\mathcal {C}_1\mathbf {M}\). This definition follows the notion of linear rank metric equivalence in [21, Proposition 1].

Using Definition 2 and Theorem 1, we can define the minimum rank distance of a code \(\mathcal {C}\) generated by a generator matrix \(\mathbf {G}^\mathcal {C}\) as

$$\begin{aligned} n - d^R(\mathcal {C}) = \max \left\{ |\{\mathbf {G}^\mathcal {C}M\}\cap H|:\mathbf {M}\in GL_n(\mathbb {F}_q),\;H \text { a hyperplane in }\mathbb {P}\right\} . \end{aligned}$$

The vectors in \(\{\mathbf {G}^\mathcal {C}M\}\) are now considered to be the corresponding class in \(\mathbb {P}= \mathbb {P}^{k-1}(\mathbb {F}_{q^m})\). We can do this because, since we only consider non-degenerate rank metric code, then \(\{\mathbf {G}^\mathcal {C}M\}\) does not contain the zero vector.

Now, in the above equation, if H is a hyperplane such that \(n-d^R(\mathcal {C}) = |\{\mathbf {G}^\mathcal {C}\mathbf {M}\}\cap H|=l\), then l columns of \(\mathbf {G}^\mathcal {C}\mathbf {M}\) are in H. Thus, working in the projective setting, the \(\mathbb {F}_q\)-projective subspace generated by these columns are in H since H is a hyperplane in \(\mathbb {P}\) and can also be considered as an \(\mathbb {F}_q\)-projective subspace of \(\mathbb {P}\). Since \(\mathbf {M}\) runs through all the possible invertible matrices over \(\mathbb {F}_q\), then this leads us to think of the minimum number of \(\mathbb {F}_q\)-linearly independent elements of \(\{\mathbf {G}^\mathcal {C}\}_{\mathbb {F}_q}\cap H\) instead of \(|\{\mathbf {G}^\mathcal {C}\mathbf {M}\}\cap H|\), for all \(\mathbf {M}\in GL_n(\mathbb {F}_q)\). In other words, we may think of the notion of dimension of some vector space over \(\mathbb {F}_q\). Recall that \(\{\mathbf {G}^\mathcal {C}\}_{\mathbb {F}_q}\) denotes the \(\mathbb {F}_q\)-vector space generated by the columns of \(\mathbf {G}^\mathcal {C}\).

Now, we are ready to formalize this generalization with the notion of projective system. However, for simplicity, there is no need for us to work in the projective space. We will work in the affine space. We will come back to the projective setting in a later section with the notion of linear sets.

Definition 3

Let \(\mathbb {F}_{q^m}/\mathbb {F}_q\) be an extension of finite degree m. An [nkd] q-system over \(\mathbb {F}_{q^m}\) is an n-dimensional \(\mathbb {F}_q\)-subspace X of the k-dimensional affine space \(\mathbb {A}= \mathbb {F}_{q^m}^k\) such that X is not contained in any hyperplane in \(\mathbb {A}\) and

$$\begin{aligned} n-d := \max \left\{ \dim _{\mathbb {F}_q} X\cap H:H \text { a hyperplane in }\mathbb {A}\right\} . \end{aligned}$$

d is called the minimum distance of X and it is usually denoted by \(d^R(X)\).

Remark 3

Note that in the above definition, the affine space \(\mathbb {A}= \mathbb {F}_{q^m}^k\) is defined over \(\mathbb {F}_{q^m}\) whereas X is considered to be only an \(\mathbb {F}_q\)-subspace.

We can see that an [nkd] q-system over \(\mathbb {F}_{q^m}\) can be defined as a set X of n points in a \((k-1)\)-dimensional projective space \(\mathbb {P}= \mathbb {P}^{k-1}(\mathbb {F}_{q^m})\) over \(\mathbb {F}_{q^m}\) such that for any \(\mathbf {M}\in GL_n(\mathbb {F}_q)\), \(\{[X]\mathbf {M}\}\) is a projective system over \(\mathbb {F}_{q^m}\).

Two q-systems \(X_1\) and \(X_2\) are called equivalent if there is a vector space automorphism \(\phi \) of \(\mathbb {A}\) such that \(\phi (X_1)=X_2\).

Similarly to linear Hamming metric codes, [nkd] q-systems are in one to one correspondence with non-degenerate [nkd]-linear rank metric codes.

Namely we have the following proposition.

Theorem 2

Let \(\mathbb {F}_{q^m}/\mathbb {F}_q\) be an extension of degree m. The equivalence classes of [nkd] q-systems are in one to one correspondence with the equivalence classes of non-degenerate [nkd]-linear rank metric codes via the correspondence

$$\begin{aligned} X \leftrightarrow \mathcal {C}= \left<[X]_{\mathbb {F}_q}\right>_{\mathbb {F}_{q^m}}, \end{aligned}$$

or equivalently

$$\begin{aligned} X = \{\mathbf {G}\}_{\mathbb {F}_q}\leftrightarrow \mathcal {C}= \left<\mathbf {G}\right>_{\mathbb {F}_{q^m}}. \end{aligned}$$

Proof

It is easy to see that equivalent q-systems give equivalent linear rank metric codes. Let us check the parameters.

Let \(X = \left< P_1,\ldots ,P_n \right>_{\mathbb {F}_q}\) be an [nkd] q-system. Let \(\mathcal {C}\) be the linear code such that the columns of the generator matrix \(\mathbf {G}\) are the \(P_i\)’s. It is obvious that the length of the code is n. For any \(\mathbf {x}\in \mathbb {A}\), \(x P_i^T\ne 0\) for some i with \(1\le i\le n\). Otherwise such x defines a hyperplane which contains all the \(P_i\)’s. Therefore the rows of \(\mathbf {G}\) are linearly independent over \(\mathbb {F}_{q^m}\), thus the dimension of the code is k. The equality of the minimum distance comes from the definition of d for the q-system and from Theorem 1 for the rank metric codes. Since the \(P_i\)’s are linearly independent over \(\mathbb {F}_q\), then \(\mathcal {C}\) is non-degenerate.

One can easily check that this map is surjective by taking X as the vector space generated over \(\mathbb {F}_q\) by the columns of the generator matrix \(\mathbf {G}\) of a rank metric code. \(\square \)

We are now ready to define the generalized weights of a q-system.

Definition 4

(Generalized rank weight) Let X be a q-system over \(\mathbb {F}_{q^m}\). The generalized weights of a q-system is given by

$$\begin{aligned} n-d^R_r(X)&:= \max \left\{ \right. \dim _{\mathbb {F}_q} X \cap \Pi : \\&\left. \Pi \text { an } \mathbb {F}_{q^m}\text {-subspace of codimension } r \text { in } \mathbb {A}\right\} . \end{aligned}$$

We easily see that the minimum distance \(d^R(X)\) of a q-system X is given by \(d^R_1(X)\).

Definition 5

Let \(\mathcal {C}\) be an [nkd]-linear rank metric code with generator matrix \(\mathbf {G}\). We define the generalized rank weights of \(\mathcal {C}\) as the generalized rank weights of the q-system X generated over \(\mathbb {F}_q\) by the columns of X, i.e., \(X = \{\mathbf {G}\}_{\mathbb {F}_q}\).

In fact, this definition of generalized weights of \(\mathcal {C}\) has an analogous version from Definition 1. First let us define the notion of q-support for rank metric code.

Definition 6

(q-Support) Let Y be a vector space with generator matrix \(\mathbf {G}^Y\) over \(\mathbb {F}_{q^m}\). The q-support \(\mathfrak {S}_q(\mathbf {G}^Y)\) of the matrix \(\mathbf {G}^Y\) is the \(\mathbb {F}_q\)-vector space generated by the columns of \(\mathbf {G}^Y\). A q-support \(\mathfrak {S}_q(Y)\) of Y with respect to \(\mathbf {G}^Y\) is \(\mathfrak {S}_q(Y):= \mathfrak {S}_q(\mathbf {G}^Y)\).

Remark 4

In Definition 6, since there are multiple choices for the generator matrix \(\mathbf {G}^Y\), then there are also multiple choices for the q-support of Y. However, it is not difficult to show that \(\dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathbf {G}^Y)\) does not depend on the choice of the generator matrix. Therefore \(\dim _{\mathbb {F}_q} \mathfrak {S}_q(Y)\) is uniquely defined and this also does not affect the notion of generalized weight as we define in the following theorems.

The first theorem is the analogue of Definition 1 whereas the second theorem is the analogue of Proposition 1.

Theorem 3

Let \(\mathcal {C}\) be an [nkd]-linear rank metric code with generator matrix \(\mathbf {G}\), then the generalized rank weights of \(\mathcal {C}\) are equal to

$$\begin{aligned} d^R_r(\mathcal {C}) = \min \left\{ \dim _{\mathbb {F}_q}\mathfrak {S}_q(\mathcal {D}):\quad \mathcal {D}<\mathcal {C}, \dim _{\mathbb {F}_{q^m}} \mathcal {D}= r \right\} . \end{aligned}$$

Proof

Suppose that the generalized rank weight in Definition 4 is equal to d and the generalized rank weight in Theorem 3 is equal to \(d'\). Our goal is to show that \(d=d'\). We assume that X is the q-system generated by the columns of \(\mathbf {G}\).

From Definition 4, suppose that \(X_1=X \cap \Pi \), \(X=X_1\oplus _{\mathbb {F}_q} X_2\) with \(n-d = \dim _{\mathbb {F}_q} X_1\) and \(d=\dim _{\mathbb {F}_q} X_2\). Assume that \(\Pi ^\perp \) is the orthogonal complement of \(\Pi \) in \(\mathbb {A}\) with generator matrix \(\mathbf {G}^{\Pi ^\perp }\), and therefore it has dimension r. \(\mathcal {D}= \mathbf {G}^{\Pi ^\perp }\mathcal {C}\) is a subcode of \(\mathcal {C}\) of dimension r. Then we have a q-support of \(\mathcal {D}\) given by \(\mathfrak {S}_q(\mathcal {D}) = \mathfrak {S}_q\left( \mathbf {G}^{\Pi ^\perp }X_1 \oplus _{\mathbb {F}_q} \mathbf {G}^{\Pi ^\perp } X_2 \right) \). Therefore \(\mathfrak {S}_q(\mathcal {D}) = \mathfrak {S}_q\left( \mathbf {G}^{\Pi ^\perp }X_2 \right) \), since \(\mathbf {G}^{\Pi ^\perp } X_1= \{\mathbf {0}\}\). Since \(X_2\) does not contain any element of \(\Pi \), then we have \(\dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D}) = \dim _{\mathbb {F}_q} \mathfrak {S}_q(X_2) = d\). By definition of \(d'\), we must have \(d'\le d\).

Conversely, suppose that \(d' = \dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D})\) such that \(\mathcal {D}<\mathcal {C}\) of dimension r. We can write \(\mathcal {D}= \mathbf {G}^{\Pi }\mathcal {C}\) and define \(\Pi \) to be the \(\mathbb {F}_{q^m}\)-subspace of dimension r in \(\mathbb {A}\) with generator matrix is \(\mathbf {G}^{\Pi }\). By the definition of q-support, for the \(\mathbb {F}_q\)-subspace \(\mathbf {G}^{\Pi } X<X\), \(\dim _{\mathbb {F}_q} \mathbf {G}^{\Pi } X = d'\). Suppose that \(\Pi ^\perp \) is the orthogonal complement of \(\Pi \) in \(\mathbb {A}\). Then, \(\Pi ^\perp \) is of codimension r. We claim that \(\dim _{\mathbb {F}_q}\Pi ^\perp \cap X = n-d'\) so that \(n-d'\le n-d\) i.e. \(d\le d'\), which will conclude the proof. But by hypothesis \(d' = \dim _{\mathbb {F}_q} \mathbf {G}^{\Pi } X\) and X is of dimension n, therefore there is \(X_1<_{\mathbb {F}_q} X\) such that \(\mathbf {G}^{\Pi } X_1 = \left<\mathbf {0}\right>\) and \(\dim _{\mathbb {F}_q} X_1 = n-d'\). But obviously, \(X_1 = \Pi ^\perp \cap X\). \(\square \)

Theorem 4

Let \(\mathcal {C}\) be an [nkd]-linear rank metric code with parity check matrix \(\mathbf {H}\), then the generalized rank weights of \(\mathcal {C}\) are equal to

$$\begin{aligned} d^R_r(\mathcal {C})&= \min \left\{ \right. i:\quad 1\le i\le n,\\&\left. \exists \mathbf {M}\in \mathbb {F}_q^{n\times i},\; \mathbf {rank}\;\mathbf {M}= i,\; i - r \ge \mathbf {rank}\;\mathbf {H}\mathbf {M}\right\} . \end{aligned}$$

Proof

Suppose that the generalized rank weight in Theorem 3 is equal to d and the generalized rank weight in Theorem 4 is equal to \(d'\). Our goal is again to show that \(d=d'\).

Suppose that \(\mathbf {M}\in \mathbb {F}_q^{n\times d'}\) and \(d'=\mathbf {rank}\;\mathbf {H}\mathbf {M}\) such that \(d'-r\ge \mathbf {rank}\;\mathbf {H}\mathbf {M}\). We may assume that \(\mathbf {M}\in \mathbb {F}_q^{n\times d'}\) such that \(\mathbf {rank}\;\mathbf {M}= d'\) and \(d'-r =\mathbf {rank}\;\mathbf {H}\mathbf {M}\). Indeed, if \(\mathbf {M}\in \mathbb {F}_q^{n\times d'}\) such that \(\mathbf {rank}\;\mathbf {M}= d'\) and \(d'-r >\mathbf {rank}\;\mathbf {H}\mathbf {M}\), then we may remove a column of \(\mathbf {M}\) to get a matrix \(\mathbf {A}\) of rank \(d'-1\) in \(\mathbb {F}_q^{n\times (d'-1)}\) and \(d'-1-r \ge \mathbf {rank}\;\mathbf {H}\mathbf {M}\ge \mathbf {rank}\;\mathbf {H}\mathbf {A}\). This is in contradiction with the definition of \(d'\) as being the minimum.

Consider the \(\mathbb {F}_{q^m}\)-linear map

$$\begin{aligned} (\mathbf {H}\mathbf {M})^T:\mathbb {F}_{q^m}^{d'}&\rightarrow \mathbb {F}_{q^m}^{n-k}\\ (x_1,\ldots ,x_{d'})&\mapsto (x_1,\ldots ,x_{d'})(\mathbf {H}\mathbf {M})^T. \end{aligned}$$

Let U be the kernel of the above map. Since, \(\mathbf {rank}\;\mathbf {H}\mathbf {M}= d'-r\), by the rank nullity theorem, \(\dim _{\mathbb {F}_{q^m}} U = r\). Now, let \(\mathcal {D}\) be the subspace of \(\mathbb {F}_{q^m}^n\) defined by

$$\begin{aligned} \mathcal {D}= \left\{ \mathbf {x}\in \mathbb {F}_{q^m}^n, x_{d'+1} = \cdots = x_n = 0 \text { and } (x_1,\ldots ,x_{d'})\in U \right\} . \end{aligned}$$

Thus, \(\dim _{\mathbb {F}_q}\mathfrak {S}_q(\mathcal {D})\le d'\) and \(\mathcal {D}\) has dimension r. Furthermore \(\mathcal {D}[\mathbf {M}|\mathbf {N}]^T\) has dimension r, where \(\mathbf {N}\) is some matrix to concatenate with \(\mathbf {M}\) so that \([\mathbf {M}|\mathbf {N}]\) is invertible. \(\mathcal {D}[\mathbf {M}|\mathbf {N}]^T\) is also a subcode of the code \(\mathcal {C}\) since \(\mathcal {D}[\mathbf {M}|\mathbf {N}]^T \mathbf {H}^T = U\mathbf {M}^T \mathbf {H}^T = U(\mathbf {H}\mathbf {M})^T = \{\mathbf {0}\}\). By the definition of d in Theorem 3, we have \(d\le \dim _{\mathbb {F}_q}\mathfrak {S}_q(\mathcal {D})\le d'\).

Conversely, let \(\mathcal {D}\) be a subcode of dimension r of \(\mathcal {C}\) with \(\dim _{\mathbb {F}_q}\mathfrak {S}_q(\mathcal {D})=d\). Thus there is an invertible matrix \(\mathbf {M}\) such that \(\mathfrak {S}(\mathcal {D}\mathbf {M}) = \{1,\ldots ,d\}\) (notice that here we have the classical support in the Hamming metric setting). Let \(\mathbf {M}_s\) be the matrix consisting of all the first d columns of \(\mathbf {M}\). \(\mathbf {M}_s\) is of rank d. By the definition of the support, \(\mathcal {D}\mathbf {M}_s\) has dimension r. If \(\mathbf {G}^\mathcal {D}\) is the generator matrix of the subcode \(\mathcal {D}\), then \(\mathbf {G}^\mathcal {D}\mathbf {M}\mathbf {M}^{-1} \mathbf {H}^T = \mathbf {0}\), where \(\mathbf {H}\) is the parity check matrix of the code. Therefore, if we write \(\mathbf {M}=[\mathbf {M}_s|\mathbf {N}]\), then

$$\begin{aligned} \mathbf {G}^\mathcal {D}[\mathbf {M}_s|\mathbf {N}] \mathbf {M}^{-1} \mathbf {H}^T = \mathbf {0}, \text {where } \mathbf {M}= [\mathbf {M}_s|\mathbf {N}]. \end{aligned}$$

However, \(\mathbf {G}^\mathcal {D}\mathbf {N}=\mathbf {0}\) so that

$$\begin{aligned}{}[\mathbf {G}^\mathcal {D}\mathbf {M}_s|\mathbf {0}] \mathbf {M}^{-1} \mathbf {H}^T = \mathbf {0}. \end{aligned}$$

Set \(\mathbf {M}'\) to be the matrix consisting of the first d rows of \(\mathbf {M}^{-1}\). Therefore \(\mathbf {G}^\mathcal {D}\mathbf {M}_s \mathbf {M}' \mathbf {H}^T = \mathbf {0}\). Since \(\mathbf {G}^\mathcal {D}\mathbf {M}_s\) is of rank r, then its kernel (as a linear map \(\mathbb {F}_{q^m}^d\rightarrow \mathbb {F}_{q^m}^r\)) has dimension \(d-r\). Therefore \(\mathbf {rank}\;\mathbf {M}'\mathbf {H}^T\le d-r\), since the column space of \(\mathbf {M}'\mathbf {H}^T\) is in the previous kernel. Hence \(d-r \ge \mathbf {rank}\;\mathbf {H}(\mathbf {M}')^T\), and \(\mathbf {rank}\;(\mathbf {M}')^T = d\). Thus, by the definition of \(d'\), \(d'\le d\). This concludes the proof. \(\square \)

We can also check that \(d^R_1(\mathcal {C})\) corresponds to the original definition of the minimum rank distance of a code.

The definition using the q-system notion is very helpful in computing the generalized rank weights of some linear codes. For instance, we will see in a later section that the generalized weights of a constant rank weight code can be easily computed. Theorem 3 is especially useful to obtain the definition of generalized rank weights with Theorem 4. Theorem 4 in turn is needed to see why our notion of generalized rank weight characterizes the performance of codes when used in wiretap network codes as we will see in a later section. There are several approaches for the notion of generalized weights for rank metric codes [6, 14, 15, 22, 25]. These existing definitions were shown to be equivalent in [14].

For the remaining part of this paper, we will switch between these three definitions of generalized rank weights depending on the situation. We will use both the notions of q-systems and rank metric codes interchangeably, depending on which notion we find easy to write down a proof.

A natural question to us is whether our definition of generalized rank weights is equivalent to the other known definitions in [6, 14, 15, 22, 25]. Indeed we show that our definition is equivalent to the definition in [14].

We fix a basis \(\{b_1,\ldots ,b_n\}\) of \(\mathbb {F}_{q^m}/\mathbb {F}_q\) and for \(x=\sum _{i=1}^n l_i b_i \in \mathbb {F}_{q^m}\), let \(\overline{x} = (l_1,\ldots ,l_n)\in \mathbb {F}_q^n\). For a codeword \(\mathbf {x}= (x_1,\ldots ,x_n)\) in \(\mathbb {F}_{q^m}^n\), Let \(\mathbf {M}_B(\mathbf {x})\) be the matrix such that the i-th column of \(\mathbf {M}_B(\mathbf {x})\) is the \(\overline{x_i}\). We define the matrix support of \(\mathbf {x}\) as the rowspace of \(\mathbf {M}_B(\mathbf {x})\). For a subspace \(\mathcal {D}\) of a linear code \(\mathcal {C}\), the matrix support \(\mathfrak {S}_M(\mathcal {D})\) of \(\mathcal {D}\) is defined to be the \(\mathbb {F}_q\)-vector space generated by the matrix support of each element of a basis of \(\mathcal {D}\). Then, in [14], we have the following definition of generalized rank weight.

Definition 7

Let \(\mathcal {C}\) be a linear rank metric code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\). Then the generalized rank weight is defined as

$$\begin{aligned} d^R_r(\mathcal {C}) = \min \left\{ \dim _{\mathbb {F}_q}\mathfrak {S}_M(\mathcal {D}):\quad \mathcal {D}<\mathcal {C}, \dim _{\mathbb {F}_{q^m}} \mathcal {D}= r \right\} \end{aligned}$$

If we fix a basis \(\{\mathbf {x}_1,\ldots ,\mathbf {x}_r\}\) of \(\mathcal {D}\), then \(\dim _{\mathbb {F}_q}\mathfrak {S}_M(\mathcal {D})\) is also equal to the dimension of the columnspace of

$$\begin{aligned} \begin{bmatrix} \mathbf {M}_B(\mathbf {x}_1) \\ \vdots \\ \mathbf {M}_B(\mathbf {x}_n) \end{bmatrix}. \end{aligned}$$

But this later dimension is also equal to the dimension of the vector space generated over \(\mathbb {F}_q\) by the columns of

$$\begin{aligned} \begin{bmatrix} \mathbf {x}_1 \\ \vdots \\ \mathbf {x}_n \end{bmatrix}. \end{aligned}$$

And therefore \(\dim _{\mathbb {F}_q}\mathfrak {S}_M(\mathcal {D}) = \dim _{\mathbb {F}_q}\mathfrak {S}_q(\mathcal {D})\). Thus the definition of generalized weight in Definition 7 is equal to the definition of generalized weight in Theorem 3.

4 Wiretap network codes

We briefly explain the scheme as it was shown in [22]. Let \(\mathcal {C}\) be a non-zero [nkd]-linear code with parity check matrix \(\mathbf {H}\). The secret message is a vector \(\mathbf {s}\in \mathbb {F}_{q^m}^k\). The message which is sent across the network is \(\mathbf {x}= (x_1,\ldots ,x_n)\in \mathbb {F}_{q^m}^n\) randomly chosen in the coset with syndrome \(\mathbf {s}=\mathbf {H}\mathbf {x}^T\). \(\mathbb {F}_q\)-linear combinations of the \(x_i\)’s will be spread across the network via known encoding. We assume that the eavesdropper, Eve, can observe u edges. So, we can say that Eve knows \(\mathbf {w}= \mathbf {B}\mathbf {x}^T\), with \(\mathbf {B}\in \mathbb {F}_q^{u\times n}\). We assume that \(\mathbf {B}\) is also of full rank u. We want to minimize the information Eve can know about \(\mathbf {s}\). The information Eve knows are \(\mathbf {B},\mathbf {w},\mathbf {H}\). We will not go into the details of the information theoretical properties of the scheme but rather we give a simple algebraic argument. For more details one can have a look at [7, 22].

Let \(\left<\mathbf {B}\right>\) and \(\left<\mathbf {H}\right>\) respectively be the \(\mathbb {F}_{q^m}\)-subspaces of \(\mathbb {F}_{q^m}^n\) generated by the rows of \(\mathbf {B}\) and \(\mathbf {H}\). Suppose that \(\mathbf {y}\in \left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\). Thus we can write \(\mathbf {y}= \varvec{\lambda }\mathbf {B}=\varvec{\mu }\mathbf {H}\), for some \(\varvec{\lambda }\in \mathbb {F}_{q^m}^u\) and \(\varvec{\mu }\in \mathbb {F}_{q^m}^{n-k}\). Multiplying by \(\mathbf {x}^T\) , we get a relation

$$\begin{aligned} \varvec{\mu }\mathbf {s}= \varvec{\lambda }\mathbf {w}, \end{aligned}$$

where \(\mathbf {s}\) is the syndrome defined earlier and \(\mathbf {w}\) is known by Eve.

Thus an element of the intersection \(\left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\) gives a linear relation between the entries of \(\mathbf {s}\). The more the size of the intersection \(\left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\) is, the more the linear relations about the elements of \(\mathbf {s}\) are and therefore the more we know about \(\mathbf {s}\). Thus to minimize the information accessed by Eve about \(\mathbf {s}\), we want to minimize the intersection \(\left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\) for any \(\mathbf {B}\in \mathbb {F}_q^{u\times n}\). So, an important parameter to look at is

$$\begin{aligned} \delta _u = \max _{\begin{array}{c} \mathbf {B}\in \mathbb {F}_q^{u\times n} \mathbf {rank}\;\mathbf {B}=u \end{array}} \dim \left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>. \end{aligned}$$

We want to look at the largest possible \(\delta _u\) for a particular \(\mathbf {H}\) in order to decide if \(\mathbf {H}\) defines the best code.

For \(\mathbf {B}\in \mathbb {F}_q^{u\times n}\), let \(\mathbf {M}\in \mathbb {F}_q^{(n-u)\times n}\) be a generator matrix of the orthogonal complement of \(\left<\mathbf {B}\right>\) as a subspace of \(\mathbb {F}_{q^m}^n\). Thus \(\mathbf {y}\in \left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\) is equivalent to \(\mathbf {y}\mathbf {M}^T = \mathbf {0}\) and \(\mathbf {y}\in \left<\mathbf {H}\right>\). So the dimension of \(\left<\mathbf {B}\right>\cap \left<\mathbf {H}\right>\), is equal to the dimension of the kernel of the map \(\left<\mathbf {H}\right> \rightarrow \mathbb {F}_{q^m}^{n}\) where \(\mathbf {y}\mapsto \mathbf {y}\mathbf {M}^T\). By the rank nullity theorem, the later dimension is equal to \((n-k)-\mathbf {rank}\;\mathbf {H}\mathbf {M}^T\). Therefore our task is equivalent to finding the minimum

$$\begin{aligned} \Delta _u = \min _{\begin{array}{c} \mathbf {M}\in \mathbb {F}_q^{(n-u)\times n}\\ \mathbf {rank}\;\mathbf {M}=n-u \end{array}} \mathbf {rank}\;\mathbf {H}\mathbf {M}^T. \end{aligned}$$

For such \(\Delta _u\), there is \(\mathbf {M}^T\in \mathbb {F}_q^{n\times (n-u)}\) of rank \(n-u\) such that \(\mathbf {rank}\;\mathbf {H}\mathbf {M}^T\le \Delta _u\). Therefore, by Theorem 4, we have

$$\begin{aligned} d^R_{n-u-\Delta _u}(\mathcal {C})\le n-u. \end{aligned}$$
(1)

Furthermore, by Theorem 4 (and as we saw in its proof), there exists \(\mathbf {M}_1\in \mathbb {F}_q^{n\times d^R_{n-u-\Delta _u+1}(\mathcal {C})}\) such that \(\mathbf {rank}\;\mathbf {M}_1 = d^R_{n-u-\Delta _u+1}(\mathcal {C})\) and \(d^R_{n-u-\Delta _u+1}(\mathcal {C}) - n+u+\Delta _u-1 = \mathbf {rank}\;\mathbf {H}\mathbf {M}_1\). If we suppose that \(n-u\ge d^R_{n-u-\Delta _u+1}(\mathcal {C})\), then \(d^R_{n-u-\Delta _u+1}(\mathcal {C}) = n-u-\epsilon \), \(\epsilon \ge 0\). Therefore, \(\mathbf {M}_1\in \mathbb {F}_q^{n\times (n-u-e)}\) with \(\mathbf {rank}\;\mathbf {M}_1 = n-u-e\) and \(\mathbf {rank}\;\mathbf {H}\mathbf {M}_1= \Delta _u-e-1\).

Now choose a matrix \(\mathbf {N}\) over \(\mathbb {F}_q\) such that \(\mathbf {M}_2^T = [\mathbf {M}_1|\mathbf {N}] \in {\mathbb {F}}_q^{n\times (n-u)}\) and \(\mathbf {rank}\;\mathbf {M}_2^T = n-u\). Since we added e columns from \(\mathbf {M}_1\) to get \(\mathbf {M}_2^T\), then \(\mathbf {rank}\;\mathbf {H}\mathbf {M}_2^T\le \Delta _u-1\). Hence, by definition we have \(\Delta _u\le \Delta _u - 1\) which is a contradiction. Therefore

$$\begin{aligned} n-u< d^R_{n-u-\Delta _u+1}(\mathcal {C}). \end{aligned}$$
(2)

Equations (1) and (2) give us the following theorem.

Theorem 5

$$\begin{aligned} d^R_{n-u-\Delta _u}(\mathcal {C})\le n-u< d^R_{n-u-\Delta _u+1}(\mathcal {C}). \end{aligned}$$

The above proof is largely inspired by a proof of the same statement in the context of Hamming code in [32]. This theorem implies that the gain of information for the eavesdropper exactly occurs at the generalized weights. This makes them as interesting parameters for a code. The use of \(\delta _u\) to describe the security parameters is suggested in [22]. However I have not seen the statement of Theorem 5 as I wrote it here. A different expression of the use of generalized weights as parameters for the security of wiretap network codes can also be found in [15].

Since our scheme is the same as the scheme in [22], this confirms the fact that our definition of generalized rank weights is equivalent to existing definitions.

In the next sections, we will have a look at the properties of the generalized rank weights.

5 Properties of generalized rank weights

The first important properties of generalized rank weights is the monotonicity. The proof uses the geometric property in analogy with [31]. Since our definition is equivalent to existing definitions, there is not really a need to present the proofs of the following properties. In fact, the monotonicity, duality of the generalized rank weights and the generalized Singleton bound were already proved but using different definitions [6, 15]. However, we still think that it is nice to give the proof of the monotonicity and duality using our definitions. Our proofs are different and they are largely inspired by [32]. We adapt the method therein to the context of rank metric codes.

Theorem 6

(Monotonicity) Let \(\mathcal {C}\) be a [nk]-linear rank metric code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\). Let \(d^R_r(\mathcal {C})\) be the generalized weight of \(\mathcal {C}\), then

$$\begin{aligned} 0<d^R_1<\cdots <d^R_k = n. \end{aligned}$$

Proof

First, we show that \(d_r>0\) for any \(r\le k-1\), i.e.

$$\begin{aligned}&\max \left\{ \right. \dim _{\mathbb {F}_q} X \cap \Pi : \\&\left. \Pi \text { a subspace of codimension } r \text { in } \mathbb {A}\right\} < n. \end{aligned}$$

By definition of q-system, X is not contained in any hyperplane and thus not in any subspaces of codimension \(i>0\). Therefore \(\dim _{\mathbb {F}_q} X\cap \Pi <n\) for any \(\Pi \) and \(\mathbf {M}\).

Now, we want to show that for \(1\le r\le k-1\), \(d^R_r<d^R_{r+1}\). Suppose that \(\dim _{\mathbb {F}_q} X\cap \Pi _{r+1}=n-d^R_{r+1}\), \(\Pi _{r+1}\) of codimension \(r+1\ne k\). By the first part of the proof, \(n-d^R_{r+1}<n\). So, there is P such that \(X=\left<P\right>_{\mathbb {F}_q}\oplus _{\mathbb {F}_q} X_1\) such that \(P\notin \Pi _{r+1}\). Now, take \(\Pi _r = \left<\Pi _{r+1},P\right>_{\mathbb {F}_{q^m}}\). Since the codimension of \(\Pi _{r+1}\) is \(r+1\), then the codimension of \(\Pi _r\) is r. If

$$\begin{aligned} X\cap \Pi _{r+1} = \left< P_1,\ldots ,P_{n-d^R_{r+1}}\right>_{\mathbb {F}_q}, \end{aligned}$$

and \(P\notin X\cap \Pi _{r+1}\), then

$$\begin{aligned} X\cap \Pi _{r} = \left< P_1,\ldots ,P_{n-d^R_{r+1}},P\right>_{\mathbb {F}_q}. \end{aligned}$$

Therefore \(n-d^R_{r+1}<n-d^R_r\).

Finally, since having a codimension equal to k means that the subspace is the zero space, then \(d^R_k = n\). \(\square \)

As a consequence of the monotonicity and the Singleton bound, we have the following corollary.

Corollary 1

(Generalized Singleton bound) Let \(\mathcal {C}\) be a [nk]-linear rank metric code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\). Let \(d^R_r(\mathcal {C})\) be the generalized weight of \(\mathcal {C}\), then

$$\begin{aligned} d^R_r(\mathcal {C})\le n-k+r. \end{aligned}$$

The next property is the duality theorem. The proof will follow the method in [32].

Theorem 7

(Duality) Let \(\mathcal {C}\) be an [nk]-linear rank metric code and let \(\mathcal {C}^\perp \) be its dual code. Then

$$\begin{aligned} \{d^R_1(\mathcal {C}),\ldots ,d^R_k(\mathcal {C})\}\cup \{n+1-d^R_1(\mathcal {C}^\perp ),\ldots , n+1-d^R_{n-k}(\mathcal {C}^\perp ) \} = \{1,2,\ldots ,n\}. \end{aligned}$$

Proof

We claim that for \(t = k+r-d^R_r(\mathcal {C}^\perp )\), \(d^R_t(\mathcal {C})\le n-d^R_r(\mathcal {C}^\perp )\). To prove this claim, suppose that \(d^R_r(\mathcal {C}^\perp ) = \dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D})\) such that \(\mathcal {D}<\mathcal {C}^\perp \) and \(\dim \mathcal {D}= r\). If \(\mathbf {G}^\mathcal {D}\) is the generator matrix of \(\mathcal {D}\) and \(\mathbf {H}\) is the parity check matrix of \(\mathcal {C}\), then

$$\begin{aligned} \mathbf {H}= \left[ \begin{array}{c} \mathbf {G}^\mathcal {D}\\ \hline \mathbf {H}' \end{array} \right] \end{aligned}$$

By the definition of \(\mathfrak {S}_q(\mathcal {D})\), there is an invertible matrix \(\mathbf {M}\) over \(\mathbb {F}_q\) such that

$$\begin{aligned} \mathbf {H}\mathbf {M}= \left[ \begin{array}{c|c} \mathbf {G}_1 &{} \mathbf {0} \\ \hline \mathbf {H}_1 &{} \mathbf {H}_2 \end{array} \right] , \end{aligned}$$

where \(\mathbf {G}_1 \in \mathbb {F}_{q^m}^{r\times d^R_r(\mathcal {C}^\perp )}\). Indeed, we can choose \(\mathbf {G}_1\) so that \(\mathfrak {S}_q(\mathcal {D}) = \{\mathbf {G}_1\}_{\mathbb {F}_q}\) and hence we can find \(\mathbf {M}\) such that \(\mathbf {G}^\mathcal {D}\mathbf {M}= [\mathbf {G}_1|\mathbf {0}]\).

If we define \(\mathbf {M}_s\) as the matrix obtained with the last \(n-d^R_r(\mathcal {C}^\perp )\) columns of \(\mathbf {M}\), then \(n-k-r \ge \mathbf {rank}\;\mathbf {H}_2= \mathbf {rank}\;\mathbf {H}\mathbf {M}_s\) and \(\mathbf {M}_s\in \mathbb {F}_q^{n\times (n-d^R_r(\mathcal {C}^\perp ))}\) has rank \(n-d^R_r(\mathcal {C}^\perp )\). Therefore, by Theorem 4, \(d^R_t(\mathcal {C})\le n-d^R_r(\mathcal {C}^\perp )\).

Next we prove that \(n+1-d^R_r(\mathcal {C}^\perp )\ne d^R_i(\mathcal {C})\) for all ir where these generalized rank weights are defined. Suppose the contrary. By the first part we have \(d^R_t(\mathcal {C})\le n-d^R_r(\mathcal {C}^\perp )\). Thus \(n+1-d^R_r(\mathcal {C}^\perp ) = d^R_{t+j}(\mathcal {C})\), \(j>0\). By, Theorem 3, there is a subcode \(\mathcal {D}\) of \(\mathcal {C}\) of dimension \(t+j\) such that \(\dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D}) = n+1-d^R_r(\mathcal {C}^\perp )\). Thus, if \(\mathbf {G}\) is the generator matrix of \(\mathcal {C}\), then there is an invertible matrix \(\mathbf {M}\) over \(\mathbb {F}_q\) such that

$$\begin{aligned} \mathbf {G}\mathbf {M}= \left[ \begin{array}{c|c} \mathbf {G}_1 &{} \mathbf {0} \\ \hline \mathbf {G}_2 &{} \mathbf {G}_3 \end{array} \right] , \end{aligned}$$

where \(\mathbf {G}_1 \in \mathbb {F}_{q^m}^{(t+j)\times (n+1-d^R_r(\mathcal {C}^\perp ))}\). Now define \(\mathbf {M}_s\) to be from the last \(d^R_r(\mathcal {C}^\perp )-1\) columns of \(\mathbf {M}\). Thus \(\mathbf {rank}\;\mathbf {G}\mathbf {M}_s=\mathbf {rank}\;\mathbf {G}_3\le k-t-j\) such that \(\mathbf {M}_s\in \mathbb {F}_q^{n\times (d^R_r(\mathcal {C}^\perp )-1)}\) and \(\mathbf {M}_s\) has rank \(d^R_r(\mathcal {C}^\perp )-1\). Again, by Theorem 4,

$$\begin{aligned} d^R_{d^R_r(\mathcal {C}^\perp )-k+t+j-1}(\mathcal {C}^\perp )\le d^R_r(\mathcal {C}^\perp )-1, \end{aligned}$$

i.e.

$$\begin{aligned} d^R_{r+j-1}(\mathcal {C}^\perp )\le d^R_r(\mathcal {C}^\perp )-1. \end{aligned}$$

This is in contradiction with the monotonicity in Theorem 6. \(\square \)

6 Linear sets

Linear sets are well known sets in the area of geometry. They generalize the concept of subgeometry of a projective space. They were used to construct blocking sets [18] and they were extensively studied. One can for example see [16, 24] and the references therein. Recently, relations between rank metric codes and linear sets were studied, especially for MRD codes. In this section we give a summary of the notion of linear sets and we give relations between them and rank metric codes.

Definition 8

Let \(\Omega = PG(V,\mathbb {F}_{q^m}) = \mathbb {P}^{r-1}(\mathbb {F}_{q^m})\) be a projective space. A set L of points in \(\Omega \) is called an \(\mathbb {F}_q\)-linear set of \(\Omega \) of rank n if it is given by all the non-zero vectors of an n-dimensional \(\mathbb {F}_q\)-vector subspace X of V i.e.

$$\begin{aligned} L = L_X:= \{\left<\mathbf {x}\right>_{\mathbb {F}_{q^m}}:\mathbf {x}\in X\backslash \{\mathbf {0}\}. \end{aligned}$$

Hence a linear set is just a set of points defined by a q-system X. This already allows us to construct a linear set from a rank metric code. If X has dimension n over \(\mathbb {F}_q\) then \(L_X\) is said to have rank n. If \(\Lambda = PG(W,\mathbb {F}_{q^m})\) is a subspace of \(\Omega \) then \(L_X\cap \Lambda = L_{W\cap X}\) is also a linear set.

Definition 9

Let \(L_X\) be an \(\mathbb {F}_q\)-linear set of \(\Omega \) of rank n and define \(\Lambda = PG(W,\mathbb {F}_{q^m})\) as a subspace of \(\Omega \) of dimension r. We say that \(\Lambda \) has weight \(w_{L_X}(\Lambda )\) with respect to \(L_X\) if \(\dim _{\mathbb {F}_q}(W\cap X)=w_{L_X}(\Lambda )\) i.e. if \(L_{W\cap X}= \Lambda \cap L_X\) has rank \(w_{L_X}(\Lambda )\).

The weight of a linear set can be used to define the generalized weights of a rank metric code.

Theorem 8

Let \(\mathcal {C}\) be an [nk]-linear code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\) and suppose that \(\mathbf {G}\) is a generator matrix of \(\mathcal {C}\). Let X be the q-system defined by the columns of \(\mathbf {G}\) and define the \({\mathbb {F}}_q\)-linear set \(L_X\) in \(\Omega = PG(V,\mathbb {F}_{q^m}) = PG(k-1,\mathbb {F}_{q^m})\). Then the r-th generalized weights of \(\mathcal {C}\) satisfy

$$\begin{aligned} n - d_r(\mathcal {C}) = \max \{ w_{L_X}(\Lambda ):\Lambda \text { is a subspace of codimension } r \text { of } \Omega \}. \end{aligned}$$

Proof

This follows directly from the definition of generalized weights in Definition 4 and the notion of weight of subspaces in Definition 9. \(\square \)

Remark 5

In the first version of this paper, we were not aware of the notion of linear sets. Only after a reviewer told us about this notion, we believe that it is worth it to give the above relation between rank metric codes and linear sets. In fact, following the approach of Tsfasman and Vladut, linear sets are the q-analogue of the projective systems. In this regards, we may also call linear sets as projective q-systems.

As we mentioned at the beginning of this section, linear sets and rank metric codes were already shown to be related [3, 4, 19, 26, 29]. We give some of this correspondence.

Definition 10

An \(\mathbb {F}_q\)-linear set \(L_X\) of \(\Omega \) or rank n is scattered if all of its points have weight 1. It is called a maximum scattered \(\mathbb {F}_q\)-linear set if it is of highest possible rank.

In [26], it was shown that maximum scattered \(\mathbb {F}_q\)-linear sets of \(PG(1,q^n)\) correspond to \(\mathbb {F}_{q^m}\)-linear MRD code. Furthermore, [3] shows that MRD codes can be constructed from every scattered linear set of rank rm/2 of \(PG(r-1,q^m)\) where rm is even. In fact, the equivalence extends to \(\mathbb {F}_q\)-linear rank metric codes.

The construction from [3] is as follows.

Let X be an (rm/2)-dimensional \(\mathbb {F}_q\)-subspace of \(V=V(r,q^m)\), r even, and let \(i=\max \{\dim _{\mathbb {F}_q}(X\cap \left<v\right>_{\mathbb {F}_{q^m}}:v\in V\}\). Let \(G:V\rightarrow W\) be an \(\mathbb {F}_q\)-linear function , with \(W=V(rm/2,q)\) such that \(\mathrm {Ker}\,G = U\).

Define \(\mathcal {C}(X,G) = \{G\circ \tau _v:v\in V\}\), where \(\tau _v:\lambda \in \mathbb {F}_{q^m}\mapsto \lambda v\in V\).

Theorem 9

([3]) If \(i<n\), then \(\mathcal {C}(X,G)\) is an \(\mathbb {F}_q\)-linear rank metric code of dimension rm, dimension m and minimum distance \(m-i\). Moreover, \(\mathcal {C}(X,G)\) is an MRD-code if and only if \(L_X\) is a maximum scattered \(\mathbb {F}_q\)-linear set.

A further study of this correspondence can be found in [29], where they give a geometric interpretation. We would like to point out that the correspondence, in Lemma 2.2 of that paper, between linear sets and rank metric codes is similar to the relation between linear sets from a q-system and the corresponding rank metric code at the beginning of this section. The equivalence classes of rank metric codes and linear sets were studied in [29]. The connection between the rank weight of a linear code and weight of hyperplanes with respect to a linear set were also given. With the q-system approach, we describe the higher rank weights, i.e. the generalized rank weights of a linear codes. And as we will see in the next section, the q-system approach allows us classify constant weight rank metric codes.

7 Constant rank weight codes

In this section, we show that the geometric approach helps studying rank metric codes. In particular we can easily classify constant rank weight codes. First we want to show the following lemma which is useful to characterize constant rank weight codes.

Lemma 1

Let \(X\subset \mathbb {F}_{q^m}^k\) be a q-system of parameters [nkd]. Suppose that there is an integer l such that for any \(\mathbb {F}_{q^m}\)-subspace S of \(\mathbb {F}_{q^m}^k\) of dimension r, \(\dim _{\mathbb {F}_q} S\cap X = l\). Then

$$\begin{aligned} q^n = \left| \mathbb {F}_{q^m}^k\cap X\right| = (q^l-1)\frac{q^{mk}-1}{q^{mr}-1} + 1. \end{aligned}$$

Proof

We follow a method in [17]. Define a value function on \(\mathbb {F}_{q^m}^k\) by

$$\begin{aligned} v(\mathbf {x}) = {\left\{ \begin{array}{ll} 1&{} \text {if } \mathbf {x}\in X,\\ 0&{} \text {else}. \end{array}\right. } \end{aligned}$$

and extend it to any subset \(S\subset \mathbb {F}_{q^m}^k\) by \(v(S) = \sum _{x\in S}v(S)\). Notice that \(v(\mathbf {0})=1\). Let \(L_r\) be the number of r-dimensional \(\mathbb {F}_{q^m}\)-subspaces of \(\mathbb {F}_{q^m}^k\). Finally, for any fixed point \(p\in \mathbb {F}_{q^m}^k\backslash \{\mathbf {0}\}\), let \(L_{r,1}\) be the number of r-dimensional \(\mathbb {F}_{q^m}\)-subspaces of \(\mathbb {F}_{q^m}^k\) containing p. Then, it is easy to show that

$$\begin{aligned} L_r = \frac{(q^{mk}-1)(q^{mk}-q^m)\cdots (q^{mk}-q^{m(r-1)})}{(q^{mr}-1)(q^{mr}-q^m)\cdots (q^{mr}-q^{m(r-1)})}, \end{aligned}$$

and

$$\begin{aligned} L_{r,1} = \frac{(q^{mk}-q^m)(q^{mk}-q^{2m})\cdots (q^{mk}-q^{m(r-1)})}{q^{m(r-1)}(q^{m(r-1)}-1)(q^{m(r-1)}-q^m)\cdots (q^{m(r-1)}-q^{m(r-2)})}. \end{aligned}$$

Let \(S_1,\ldots ,S_{L_r}\) be all the r-dimensional \(\mathbb {F}_{q^m}\)-subspaces of \(\mathbb {F}_{q^m}^k\). Then

$$\begin{aligned} \sum _{i=1}^{L_r} v(S_i) = q^l L_r. \end{aligned}$$
(3)

Since any non-zero elements of \(\mathbb {F}_{q^m}^k\) appears exactly in \(L_{r,1}\)\(\mathbb {F}_{q^m}\)-subspaces of dimension r and \(\mathbf {0}\) appears in each subspaces, then

$$\begin{aligned} \sum _{i=1}^{L_r} v(S_i) =L_{r,1} v\left( \mathbb {F}_{q^m}^k\backslash \{\mathbf {0}\}\right) + L_r. \end{aligned}$$

Therefore,

$$\begin{aligned} \sum _{i=1}^{L_r} v(S_i) =L_{r,1} v\left( \mathbb {F}_{q^m}^k\right) + L_r - L_{r,1}. \end{aligned}$$
(4)

Combining Eqs. (3) and (4), we get our result. \(\square \)

Let \(\mathcal {C}\) be an [nkd]-linear rank metric code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\). Recall that a constant rank weight code is a linear code such that all non-zero codewords have the same rank weight. If \(k=1\), then it is obvious that \(\mathcal {C}\) is a constant rank weight code. Thus for the remaining part of this section, we assume that \(k>1\). Suppose that the generator matrix of \(\mathcal {C}\) is \(\mathbf {G}\). Let X be the q-system corresponding to \(\mathcal {C}\), i.e. X is an \(\mathbb {F}_q\)-subspace of \(\mathbb {A}=\mathbb {F}_{q^m}^k\). Suppose that \(\mathbf {G}^\mathcal {D}\) is a generator matrix of an r-dimensional subcode \(\mathcal {D}<\mathcal {C}\). Then a generator matrix for \(\mathcal {D}\) is \(\mathbf {G}^\mathcal {D}= \mathbf {M}_D \mathbf {G}\), with \(\mathbf {M}_\mathcal {D}\in \mathbb {F}_{q^m}^{r\times k}\). Define

$$\begin{aligned} S_\mathcal {D}= \{ \mathbf {x}\in \mathbb {A}:\quad \mathbf {M}_\mathcal {D}\mathbf {x}= \mathbf {0}\}. \end{aligned}$$

Then \(\dim _{\mathbb {F}_{q^m}} S_\mathcal {D}= k-r\). In fact this relation gives a one-to-one correspondence between subspaces of \(\mathbb {A}\) of dimension \(k-r\) and subcodes of \(\mathcal {C}\) of dimension r. Moreover,

$$\begin{aligned} n-\dim _{\mathbb {F}_q} S_\mathcal {D}\cap X= \dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D}). \end{aligned}$$

Since we have a constant rank weight code, then \(\dim _{\mathbb {F}_q} \mathfrak {S}_q(\mathcal {D})=d\), for any subcode of dimension 1 of \(\mathcal {C}\). Therefore, by the above correspondence, \(\dim _{\mathbb {F}_q} S \cap X = n-d\) for any hyperplane S of \(\mathbb {F}_{q^m}^k\). Now, we choose \(l=n-d\) and \(r=k-1\). By Lemma 1,

$$\begin{aligned} q^n\left( q^{m(k-1)}-1\right) = q^{mk+l}-q^l-q^{mk}+q^{m(k-1)}. \end{aligned}$$
(5)

We have the following properties.

  • \(1<k\le n\le mk\),

  • \(0<l = n-d< n\).

If \(l<m(k-1)\), then \(l< mk\) and Equation (5) gives

$$\begin{aligned} q^{n-l}\left( q^{m(k-1)}-1\right) = q^{mk}-1-q^{mk-l}+q^{m(k-1)-l}. \end{aligned}$$

But then q divides the LHS but not the RHS of the equation. Thus by contradiction, \(l\ge m(k-1)\). However, if \(l> m(k-1)\), then

$$\begin{aligned} q^{n-m(k-1)}\left( q^{m(k-1)}-1\right) = q^{m+l}-q^{l-m(k-1)}-q^{m}+1. \end{aligned}$$

Since q does not divide the RHS, then \(n=m(k-1)\). But then \(l>n\) which is contrary to \(l< n\). So at the end

$$\begin{aligned} l=m(k-1). \end{aligned}$$

But with Eq. (5), this implies that

$$\begin{aligned} q^n(q^l-1) = q^{mk}(q^l - 1). \end{aligned}$$

Since \(l>0\), then \(n=mk\). So, in fact \(X = \mathbb {A}=\mathbb {F}_{q^m}^k\). In the following, we show that we indeed have a constant rank weight code for which some parameters are studied.

A particular class of linear codes in the Hamming metric are the class of Hadamard codes. These codes, for a particular dimension k over \(\mathbb {F}_q\), are constructed in such a way that all elements of \(\mathbb {F}_q^k\) make the columns of the generator matrix. Taking \(X=\mathbb {A}=\mathbb {F}_{q^m}^k\) generalize this construction in the rank metric setting and using the geometric approach we can easily compute the generalized weight of such code.

Let \(\mathbb {F}_{q^m}/\mathbb {F}_q\) be field extension of degree m. Let k be a positive integer and Let \(X=\mathbb {F}_{q^m}^k\). Since X is a vector space of dimension k over \(\mathbb {F}_{q^m}\), then it is also a vector space of dimension mk over \(\mathbb {F}_q\). Let \(n=mk\), then X defines an [nkd] q-system, which is given in the next theorem.

Theorem 10

Let \(X=\mathbb {F}_{q^m}^k\) be an [nkd] q-system defined as above. The generalized rank weights of X are given by

$$\begin{aligned} d^R_r(X) = mr. \end{aligned}$$

In other words, \(d = m\).

Proof

By definition

$$\begin{aligned} n-d^R_r(X)&:= \max \left\{ \right. \dim _{\mathbb {F}_q} X \cap \Pi : \\&\quad \left. \Pi \text { an } \mathbb {F}_{q^m}\text {-subspace of codimension } r \text { in } \mathbb {A}\right\} . \end{aligned}$$

Notice that \(\mathbb {A}= X\) and therefore,

$$\begin{aligned} n-d^R_r(X) = (k-r)m. \end{aligned}$$

Therefore \(d^R_r(X) = mr\). \(\square \)

Definition 11

The linear code corresponding to the projective system \(X=\mathbb {F}_{q^m}^k\) is called the Hadamard rank metric code which we denote by \(\mathcal {H}_1(q,m,k)\). It has parameters [mkkm] and it has generalized weights \(d^R_r(X) = mr\).

Corollary 2

The Hadamard rank metric code \(\mathcal {H}_1(q,m,k)\) is a constant rank weight code i.e. all the codewords have rank weight m.

Proof

We have seen that \(d^R(\mathcal {H}_1(q,m,k))=m\). So, \(\forall \mathbf {x}\in \mathcal {H}_1,\; \mathbf {rank}\;\mathbf {x}\ge m\). But since the alphabet is over \(\mathbb {F}_{q^m}\), then \(\mathbf {rank}\;\mathbf {x}\le m\). Thus \(\forall \mathbf {x}\in \mathcal {H}_1,\; \mathbf {rank}\;\mathbf {x}= m\). \(\square \)

It is interesting that this code is optimal in the sense that it reaches the bound for rank metric codes with such parameters. Namely for an [nkd]-linear code over \(\mathbb {F}_{q^m}\) with have \(k\le (n/m)(m-d+1)\) and here we have an equality. For a proof of such bound, one can view the code as \(\mathbb {F}_q\)-linear code where the codewords are matrices (see [5] for example). Notice also that this code is linear over \(\mathbb {F}_{q^m}\) but not only over \(\mathbb {F}_q\).

Taking the dual, we have the following.

Definition 12

The Hamming rank metric code \(\mathcal {H}_2(q,m,k)\) is the dual of \(\mathcal {H}_1(q,m,k)\).

Using the duality from Theorem 7, we get the following property of Hamming rank metric codes.

Theorem 11

The Hamming rank metric code \(\mathcal {H}_2(q,m,k)\) has parameters \([mk,(m-1)k,2]\). Moreover the generalized weight hierarchy is given by

$$\begin{aligned} \left\{ n+1-i:1\le i<km,\; m \not \mid i \right\} . \end{aligned}$$

Having a minimum distance 2, the code \(\mathcal {H}_2(q,m,k)\) is not really of a particular interest for error correcting as it can only detect error of rank 1. However, the generalized weights can be useful.

To conclude this section, we present the following classification of non-degenerate constant weight linear rank metric codes.

Theorem 12

Let \(\mathcal {C}\) be an [nkd]-non degenerate linear code over \(\mathbb {F}_{q^m}/\mathbb {F}_q\).

  1. 1.

    If \(k=1\), then \(\mathcal {C}=\left<(a_1,\ldots ,a_n)\right>_{\mathbb {F}_{q^m}}\) such that \(\mathbf {rank}\;(a_1,\ldots ,a_n) = d\).

  2. 2.

    If \(k>1\), then \(n=mk\), \(d^R_r(\mathcal {C}) = mr\) and the columns of the generator matrix \(\mathbf {G}\) of \(\mathcal {C}\) is made of a basis of \(\mathbb {F}_{q^m}^k\) as a vector space over \(\mathbb {F}_q\).

Remark 6

If the linear code \(\mathcal {C}\) is degenerate i.e. the columns of its generator matrix \({\mathbb {F}}\) are linearly independent, then the code is equivalent to a linear code with generator matrix of the form \([\mathbf {G}'|\mathbf {0}]\) where, \(\mathbf {G}'\) defines a non-degenerate rank metric code \(\mathcal {C}'\). Thus we can also use Theorem 12 on \(\mathcal {C}'\) in order to classify degenerate constant weight linear rank metric code \(\mathcal {C}\).

8 Conclusion

In this work, we considered a geometric approach of linear rank metric codes via the notion of q-systems which are similar to linear sets. We have redefined the notion of generalized rank weight and we gave new proofs of some of their properties. The method also helps us to completely classify constant rank weight codes. We give a construction of such codes. These codes are analogous to the Hadamard codes in the Hamming metric setting. As a future work, we want to explore the properties of rank metric codes using this geometric approach. For instance we want to study the generalized weight of q-cyclic rank metric codes as it was similarly studied for cyclic Hamming metric codes. We want to use the projective setting with linear sets to find linear codes whose generalized weights can be easily computed using the geometric approach. We also want to generalize this geometric approach into rank metric codes in the Delsarte setting [5] i.e. we want to consider rank metric codes as subspaces of matrices. Finally, an interesting problem is to give a correspondence between h-scattered linear sets introduced in [4] and the rank metric codes using our geometric approach.