1 Introduction and motivation

Rank-metric codes were originally introduced by Delsarte [5] and later rediscovered by Gabidulin [6] and Roth [20]. Due to their application in network coding, the interest in these codes has intensified over the past years and many recent papers have been devoted to their study. While interest in these codes stems from practical applications, rank-metric codes also present interesting algebraic and combinatorial properties. Therefore, their mathematical structure has also been the object of several works. This paper belongs to the latter line of study. Our contributions are twofold: on the one side we study generalized weights of rank-metric codes, and on the other we establish a link with other combinatorial objects. More precisely, we associate with each rank-metric code a q-polymatroid, the q-analogue of a polymatroid, which we define here.

In Sect. 2, we define rank-metric codes and vector rank-metric codes. We recall how to associate a rank-metric code with a vector rank-metric code via the choice of a basis and establish a number of basic, but fundamental facts. In particular, we recall the notions of equivalence for rank-metric codes and vector rank-metric codes and we discuss in detail why these notions are compatible via the association mentioned above. We also explain that, while the choice of a basis affects the rank-metric code obtained via the association above, the equivalence class of the rank-metric code obtained does not depend on the choice of the basis.

Generalized weights have been defined and studied in different levels of generality by many researchers. Two of the first definitions of generalized weights for vector rank-metric codes are due to Kurihara, Matsumoto, and Uyematsu [12] and to Oggier and Sboui [14]. More definitions are due to Jurrius and Pellikaan [9] and Martínez-Peñas and Matsumoto [13], who also compared the various definitions. Using the theory of anticodes, Ravagnani [18] gave a definition of generalized weights for matrix rank-metric codes, which extends the one from [12].

In this paper, we develop further the theory of generalized weights for rank-metric codes, tying together several previously known results on the subject. We adopt the definition from [18] and, in Sect. 3, we show that it is invariant with respect to equivalence of rank-metric codes. We also show that the definition of generalized weights for rank-metric codes from [13], which generalizes definitions from [9, 11, 24], is not invariant with respect to code equivalence.

Given the well-known link between codes in the Hamming metric and matroids, it is a natural question to ask whether there is a q-analogue of this. Rank-metric codes can be viewed as the q-analogue of block-codes endowed with the Hamming metric. So it is natural to ask what is the q-analogue of a matroid. Crapo [3] already studied this combinatorial object from the point of view of geometric lattices. Recently, Jurrius and Pellikaan [10] rediscovered q-matroids and associated a q-matroid with every vector rank-metric code. One goal of the current paper is extending this association with rank-metric codes.

With this in mind, we define the q-analogue of a polymatroid, that we call a q-polymatroid. In Sect. 4, we develop basic properties of q-polymatroids, such as equivalence and duality. In Sect. 5, we associate with every rank-metric code a pair of q-polymatroids. We also show that the q-polymatroids arising from rank-metric codes are in general not q-matroids. We then show that several structural properties of rank-metric codes depend only on the associated q-polymatroid: In Sect. 6, we do this for the minimum distance and the property of being MRD, in Sect. 7 for the generalized weights and for the property of being an optimal anticode, and in Sect. 8 for duality. These results are q-analogues of classical results in coding theory.

While preparing this manuscript, we became aware that a slightly different definition of q-analogue of a polymatroid was given independently by Shiromoto [21]. While our paper applies this theory to equivalence of codes and to generalized weights, [21] focuses on the weight enumerator of rank-metric codes.

2 Rank-metric and vector rank-metric codes

We start by establishing the notation and the definitions used throughout the paper.

Notation 2.1

In the sequel, we fix integers \(n,m\ge 2\) and a prime power q. For an integer t, we let \([t]:=\{1,...,t\}\). We denote by \(\mathbb {F}_q\) the finite field with q elements. The space of \(n\times m\) matrices with entries in \(\mathbb {F}_q\) is denoted by \({\text {Mat}}\). Up to transposition, we assume without loss of generality that \(n\le m\). We let

$$\begin{aligned} {\text {Mat}}(J,c)= & {} \{M\in {\text {Mat}}\mid {\text {colsp}}(M)\subseteq J \} \quad \text{ and }\\&\quad {\text {Mat}}(J,r)=\{M\in {\text {Mat}}\mid {\text {rowsp}}(M)\subseteq J \}. \end{aligned}$$

Throughout the paper, we only consider linear codes. All dimensions are computed over \(\mathbb {F}_q\), unless otherwise stated.

Definition 2.2

A (matrix) rank-metric code is an \(\mathbb {F}_q\)-linear subspace \(\mathcal {C}\subseteq {\text {Mat}}\). The dual of \(\mathcal {C}\) is

$$\begin{aligned} \mathcal {C}^\perp =\left\{ M \in {\text {Mat}}\mid {\text {Tr}}(MN^t)=0 \text { for all }N\in \mathcal {C}\right\} , \end{aligned}$$

where \({\text {Tr}}(\cdot )\) denotes the trace. It is easy to check that \(\mathcal {C}^\perp \) is a code as well, i.e., that it is \(\mathbb {F}_q\)-linear. The minimum (rank) distance of a nonzero rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\) is the integer \(d(\mathcal {C}):=\min \{{\text {rk}}(M) \mid M \in \mathcal {C}, \ M \ne 0\}\).

The next bound relates the dimension of a code \(\mathcal {C}\subseteq {\text {Mat}}\) to its minimum distance. It is the analogue for the rank metric of the Singleton bound from classical coding theory.

Proposition 2.3

([5], Theorem 5.4). Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero rank-metric code with minimum distance d. Then \(\dim (\mathcal {C}) \le m (n-d+1)\).

Definition 2.4

A code that attains the bound of Proposition 2.3 is called a maximum rank distance (MRD) code.

We now introduce some transformations that preserve the dimension and the minimum rank distance of a rank-metric code. These will play a central role throughout the paper.

Notation 2.5

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code, let \(A\in \text{ GL }_n(\mathbb {F}_q)\) and \(B\in \text{ GL }_m(\mathbb {F}_q)\). Define

$$\begin{aligned} A\mathcal {C}B:=\{AMB\mid M\in \mathcal {C}\} \subseteq {\text {Mat}}. \end{aligned}$$

When \(n=m\), define the transpose of a rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\) as

$$\begin{aligned} \mathcal {C}^t:=\{M^t \mid M \in \mathcal {C}\} \subseteq {\text {Mat}}. \end{aligned}$$

As we are interested in structural properties of rank-metric codes, it is natural to study these objects up to equivalence. Linear isometries of the space of matrices of fixed size induce a natural notion of equivalence among rank-metric codes.

Definition 2.6

Two rank-metric codes \(\mathcal {C}_1,\mathcal {C}_2\subseteq {\text {Mat}}\) are equivalent if there exists an \(\mathbb {F}_q\)-linear isometry \(f:{\text {Mat}}\rightarrow {\text {Mat}}\) such that \(f(\mathcal {C}_1)=\mathcal {C}_2\). If this is the case, then we write \(\mathcal {C}_1 \sim \mathcal {C}_2\).

The next theorem gives a characterization of the linear isometries of \({\text {Mat}}\). It combines results by Hua and Wan, and it can be found in the form stated below in [23, Theorem 3.4].

Theorem 2.7

([8, 22]). Let \(f:{\text {Mat}}\rightarrow {\text {Mat}}\) be an \(\mathbb {F}_q\)-linear isometry with respect to the rank metric.

  1. (1)

    If \(m<n\), then there exist matrices \(A \in \text{ GL }_n(\mathbb {F}_q)\) and \(B\in \text{ GL }_m(\mathbb {F}_q)\) such that \(f(M)=AMB\) for all \(M \in {\text {Mat}}\).

  2. (2)

    If \(m=n\), then there exist matrices \(A,B \in \text{ GL }_m(\mathbb {F}_q)\) such that either \(f(M)=AMB\) for all \(M \in {\text {Mat}}\), or \(f(M)=AM^tB\) for all \(M \in {\text {Mat}}\).

A class of codes that has recently received a lot of attention is that of vector rank-metric codes, introduced independently by Gabidulin and Roth in [6] and [20], respectively.

Definition 2.8

The \(\mathbf rank weight \)\({\text {rk}}(v)\) of a vector \(v \in \mathbb {F}_{q^m}^n\) is the dimension of the \(\mathbb {F}_q\)-linear space generated by its entries. A vector rank-metric code is an \(\mathbb {F}_{q^m}\)-linear subspace \(C \subseteq \mathbb {F}_{q^m}^n\). The dual of C is the vector rank-metric code

where \(\langle \cdot , \cdot \rangle \) is the standard inner product of \(\mathbb {F}_{q^m}^n\). When \(C \ne \{0\}\) is a nonzero vector rank-metric code, the minimum (rank) distance of C is \(d(C)=\min \{{\text {rk}}(v) \mid v \in C, \ v\ne 0\}\).

Notation 2.9

Let \(C\subseteq \mathbb {F}_{q^m}^n\) be a vector rank-metric code and \(B\in \text{ GL }_n(\mathbb {F}_q)\). Define

$$\begin{aligned} C B:=\{vB\mid v\in C\} \subseteq \mathbb {F}_{q^m}^n. \end{aligned}$$

Similarly to the case of rank-metric codes, the linear isometries of \(\mathbb {F}_{q^m}^n\) induce a notion of equivalence for vector rank-metric codes.

Definition 2.10

Two vector rank-metric codes \(C_1,C_2\subseteq \mathbb {F}_{q^m}^n\) are equivalent if there exists an \(\mathbb {F}_{q^m}\)-linear isometry \(f:\mathbb {F}_{q^m}^n\rightarrow \mathbb {F}_{q^m}^n\) such that \(f(C_1)=C_2\). If this is the case, then we write \(C_1 \sim C_2\).

The linear isometries of \(\mathbb {F}_{q^m}^n\) can be described as follows.

Theorem 2.11

([1]). Let \(f:\mathbb {F}_{q^m}^n \rightarrow \mathbb {F}_{q^m}^n\) be an \(\mathbb {F}_{q^m}^n\)-linear isometry with respect to the rank metric. Then there exist \(\alpha \in \mathbb {F}_{q^m}^*\) and \(B\in \text{ GL }_n(\mathbb {F}_q)\) such that \(f(v)=\alpha v B\) for all \(v\in \mathbb {F}_{q^m}^n\).

There is a natural way to associate a rank-metric code \(\mathcal {C}\) with a vector rank-metric code C, in such a way that the metric properties are preserved. Given an \(\mathbb {F}_{q}\)-basis \(\Gamma =\{\gamma _1,...,\gamma _m\}\) of \(\mathbb {F}_{q^m}\) and given a vector \(v \in \mathbb {F}_{q^m}^n\), let \(\Gamma (v)\) denote the unique \(n \times m\) matrix with entries in \(\mathbb {F}_q\) that satisfies

$$\begin{aligned} v_i=\sum _{j=1}^m \Gamma _{ij}(v) \gamma _j \quad \text{ for } \text{ all } 1 \le i \le n. \end{aligned}$$

Proposition 2.12

([7], Section 1). The map \(v \mapsto \Gamma (v)\) is an \(\mathbb {F}_q\)-linear isometry. In particular, if \(C \subseteq \mathbb {F}_{q^m}^n\) is a vector rank-metric code of dimension k over \(\mathbb {F}_{q^m}\), then \(\Gamma (C)\) is an \(\mathbb {F}_q\)-linear rank-metric code of dimension mk over \(\mathbb {F}_q\). Moreover, if \(C \ne \{0\}\), then C and \(\Gamma (C)\) have the same minimum rank distance.

As one expects, the rank-metric codes obtained from equivalent vector rank-metric codes using different bases \(\Gamma \) and \(\Gamma '\) are equivalent.

Proposition 2.13

Let \(C_1,C_2\subseteq \mathbb {F}_{q^m}^n\) be vector rank-metric codes. Let \(\Gamma \) and \(\Gamma '\) be bases of \(\mathbb {F}_{q^m}\) over \(\mathbb {F}_q\). If \(C_1\sim C_2\), then \(\Gamma (C_1)\sim \Gamma '(C_2)\).

Proof

By [18, Lemma 27.2], \(\Gamma (C)\sim \Gamma '(C)\). Hence we may assume without loss of generality that \(\Gamma =\Gamma '=\{\gamma _1,\ldots ,\gamma _m\}\). By definition of \(\Gamma \)

$$\begin{aligned} \gamma _k\gamma _j=\sum _{\ell =1}^m\Gamma (\gamma _k\gamma _1,\ldots ,\gamma _k\gamma _m)_{j\ell }\gamma _\ell \end{aligned}$$

If \(C_1\sim C_2\), then by Theorem 2.11 there exist \(\alpha \in \mathbb {F}_{q^m}^*\) and \(B=(b_{ij})\in \text{ GL }_n(\mathbb {F}_q)\) such that \(C_2=\alpha C_1 B\). If \(v=(v_1,\ldots ,v_n)\in \mathbb {F}_{q^m}^n\), then

$$\begin{aligned} \alpha v_i= & {} \sum _{h=1}^m \Gamma (v)_{ih}\alpha \gamma _h= \sum _{j=1}^m\sum _{h=1}^m \Gamma (v)_{ih}\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m)_{hj}\gamma _j\\= & {} \sum _{j=1}^m (\Gamma (v)\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m))_{ij}\gamma _j. \end{aligned}$$

Therefore,

$$\begin{aligned} \Gamma (\alpha v)=\Gamma (v)\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m). \end{aligned}$$

On the other side

$$\begin{aligned} vB= & {} \left( \sum _{k=1}^n b_{k1}v_k,\ldots ,\sum _{k=1}^n b_{kn}v_k\right) \\= & {} \left( \sum _{k=1}^n\sum _{j=1}^m b_{k1}\Gamma (v)_{kj}\gamma _j,\ldots ,\sum _{k=1}^n\sum _{j=1}^m b_{kn}\Gamma (v)_{kj}\gamma _j\right) , \end{aligned}$$

hence

$$\begin{aligned} \Gamma (vB)_{ij}=\sum _{k=1}^n b_{ki}\Gamma (v)_{kj}=(B^t\Gamma (v))_{ij}, \end{aligned}$$

that is

$$\begin{aligned} \Gamma (vB)=B^t\Gamma (v). \end{aligned}$$

Then for every \(v\in C_1\), we obtain \(\Gamma (\alpha vB)=B^t\Gamma (v)\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m)\), i.e.,

$$\begin{aligned} \Gamma (C_2)=\Gamma (\alpha C_1 B)=B^t\Gamma (C_1)\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m)\sim \Gamma (C_1) \end{aligned}$$

since \(B^t\in \text{ GL }_n(\mathbb {F}_q)\) and \({\text {rk}}(\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m))={\text {rk}}(\alpha \gamma _1,\ldots ,\alpha \gamma _m)={\text {rk}}(\gamma _1,\ldots ,\gamma _m)=m\), hence \(\Gamma (\alpha \gamma _1,\ldots ,\alpha \gamma _m)\in \text{ GL }_m(\mathbb {F}_q)\). \(\square \)

Proposition 2.13 suggests a natural definition of \(\mathbb {F}_{q^m}\)-linear rank-metric code in the \(\mathbb {F}_q\)-linear matrix space \({\text {Mat}}\).

Definition 2.14

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code. We say that \(\mathcal {C}\) is \(\mathbb {F}_{q^m}\)-linear if there exists a vector rank-metric code \(C \subseteq \mathbb {F}_{q^m}^n\) and a basis of \(\Gamma \) of \(\mathbb {F}_{q^m}\) over \(\mathbb {F}_q\) such that \(\mathcal {C}\sim \Gamma (C)\).

3 Optimal anticodes and generalized weights

Optimal linear anticodes were introduced in [18] with the purpose of studying generalized weights in the rank metric.

Definition 3.1

The maximum rank of a rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\) is

$$\begin{aligned} \text{ maxrk }(\mathcal {C}):=\max \{ {\text {rk}}(M) \mid M \in \mathcal {C}\}. \end{aligned}$$

A rank-metric code \(\mathcal {A}\subseteq {\text {Mat}}\) is an optimal anticode if \(\dim (\mathcal {A})=m \cdot \text{ maxrk }(\mathcal {A})\).

The class of optimal anticodes is closed with respect to duality [17, Theorem 54] and code equivalence. The properties of optimal anticodes were exploited in [18] to study a class of algebraic invariants of rank-metric codes, called (Delsarte) generalized weights.

Definition 3.2

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero code. For \(i\ge 1\), the i-th generalized weight of \(\mathcal {C}\) is

$$\begin{aligned} a_i(\mathcal {C}):= \frac{1}{m} \min \{\dim (\mathcal {A}) \mid \mathcal {A}\subseteq {\text {Mat}} \text{ is } \text{ an } \text{ optimal } \text{ anticode, } \dim (\mathcal {C}\cap \mathcal {A}) \ge i\}. \end{aligned}$$

Remark 3.3

\(a_1(\mathcal {C})\) is the minimum rank distance of \(\mathcal {C}\). See [18, Theorem 30] for details.

As one may expect, equivalent codes have the same generalized weights.

Proposition 3.4

Let \(\mathcal {C}_1,\mathcal {C}_2 \subseteq {\text {Mat}}\) be nonzero codes and assume \(\mathcal {C}_1 \sim \mathcal {C}_2\). Then

$$\begin{aligned} a_i(\mathcal {C}_1)=a_i(\mathcal {C}_2) \text{ for } \text{ every } \text{ integer } i \ge 1. \end{aligned}$$

Proof

Since \(\mathcal {C}_1 \sim \mathcal {C}_2\), there exist \(A \in \text{ GL }_n(\mathbb {F}_q)\) and \(B \in \text{ GL }_m(\mathbb {F}_q)\) such that either \(\mathcal {C}_2=A\mathcal {C}_1B\), or \(\mathcal {C}_2=A\mathcal {C}_1^tB\) and \(n=m\). We prove the proposition in the second case, as the proof in the first is similar.

Let \(\mathrm{Ant}({\text {Mat}})\) denote the set of optimal anticodes in \({\text {Mat}}\), and fix a positive integer i. The chain of equalities

$$\begin{aligned} A(\mathcal {A}\cap \mathcal {C}_1)^tB = (A\mathcal {A}^tB) \cap (A \mathcal {C}_1^tB) =(A\mathcal {A}^tB) \cap \mathcal {C}_2 \end{aligned}$$

implies that the isometry \(f: \mathrm{Ant}({\text {Mat}}) \rightarrow \mathrm{Ant}({\text {Mat}})\) defined by \(f(\mathcal {A}):=A\mathcal {A}^tB\) gives a bijection between the anticodes \(\mathcal {A}\subseteq {\text {Mat}}\) such that \(\dim (\mathcal {A}\cap \mathcal {C}_1) \ge i\) and the anticodes \(\mathcal {B}\subseteq {\text {Mat}}\) such that \(\dim (\mathcal {B}\cap \mathcal {C}_2) \ge i\). Then \(\mathcal {C}_1\) and \(\mathcal {C}_2\) have the same generalized weights by definition. \(\square \)

The definition of generalized weights in terms of anticodes suggests the following natural questions. Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code, and let \(\mathcal {A}\) be an optimal anticode such that \(\dim (\mathcal {C}\cap \mathcal {A})\ge i\) and \(a_i(\mathcal {C})=\dim (\mathcal {A})/m\).

  1. (1)

    Can one find an optimal anticode \(\mathcal {A}^\prime \) such that \(\mathcal {A}\subseteq \mathcal {A}^\prime \), \(\dim (\mathcal {C}\cap \mathcal {A}^\prime )\ge i+1\), and \(a_{i+1}(\mathcal {C})=\dim (\mathcal {A}^\prime )/m\)?

  2. (2)

    Can one find an optimal anticode \(\mathcal {A}^{\prime \prime }\) such that \(\mathcal {A}^{\prime \prime }\subseteq \mathcal {A}\), \(\dim (\mathcal {C}\cap \mathcal {A}^{\prime \prime })\ge i-1\), and \(a_{i-1}(\mathcal {C})=\dim (\mathcal {A}^{\prime \prime })/m\)?

The following example shows that the answer to both questions is negative.

Example 3.5

Let \(q=2\) and \(n=m=3\). Let \(\mathcal {C}\) be the rank-metric code generated by the three independent matrices

$$\begin{aligned} M_1:=\begin{pmatrix} 1 &{}\quad 0 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad 0\\ 0 &{}\quad 0 &{}\quad 0\end{pmatrix}, \qquad M_2:=\begin{pmatrix} 0 &{}\quad 0 &{}\quad 0 \\ 0 &{}\quad 1 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad 1\end{pmatrix}, \qquad M_3:=\begin{pmatrix} 0 &{}\quad 0 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad 1 \\ 0 &{}\quad 1 &{}\quad 0\end{pmatrix}. \end{aligned}$$

It is easy to check that \(a_{1}(\mathcal {C})=1\) and \(a_{2}(\mathcal {C})=2\). By [4, Theorems 4 and 6], the optimal anticodes in \({\text {Mat}}_{3\times 3}(\mathbb {F}_2)\) are of the form \({\text {Mat}}(J,\mathrm{c})\) or \({\text {Mat}}(J,\mathrm{r})\) for some \(J\subseteq \mathbb {F}_2^3\). Let \(\mathcal {A}_1\) be an optimal anticode of dimension 3 with \(\dim (\mathcal {C}\cap \mathcal {A}_1)\ge 1\). Then we have \(\mathcal {A}_1={\text {Mat}}(\left\langle (1,0,0)\right\rangle ,\mathrm{c})\) or \(\mathcal {A}_1={\text {Mat}}((\left\langle (1,0,0)\right\rangle ,\mathrm{r})\). Let \(\mathcal {A}_2\) be an optimal anticode of dimension 6 with \(\dim (\mathcal {C}\cap \mathcal {A}_2)\ge 2\). Then we have \(\mathcal {A}_2={\text {Mat}}((\left\langle (0,1,0),(0,0,1)\right\rangle ,\mathrm{c})\) or \(\mathcal {A}_2={\text {Mat}}((\left\langle (0,1,0),(0,0,1)\right\rangle ,\mathrm{r}).\)

Notice that one could also define generalized weights for rank-metric codes following a support-based analogy with codes endowed with the Hamming metric. This naturally leads to generalizing the invariants proposed in [11, 24] and [9] as in the following Definition 3.6. This approach has been followed, e.g., in [13]. Notice that in [13] supports are defined as column spaces also in the case when \(n>m\).

Definition 3.6

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero code. The support of a subcode \(\mathcal {D}\subseteq \mathcal {C}\) is

$$\begin{aligned} {\text {supp}}(\mathcal {D}):=\sum _{M \in \mathcal {D}} {\text {colsp}}(M) \ \subseteq \mathbb {F}_q^n, \end{aligned}$$

where the sum is the sum of vector spaces. The i-th support weight of \(\mathcal {C}\) is

$$\begin{aligned} cs_i(\mathcal {C}):=\min \{\dim ({\text {supp}}(\mathcal {D})) \mid \mathcal {D}\subseteq \mathcal {C}, \ \dim (\mathcal {D})=i\}. \end{aligned}$$

Remark 3.7

Although Definition 3.6 produces an interesting and well-behaved algebraic invariant, we observe that the analogue of Proposition 3.4 does not hold for support weights. In other words, while equivalent codes always have the same generalized weights, they might not have the same support weights. We illustrate this in the following example.

Example 3.8

Let \(\mathcal {C}\) be the binary code defined by

$$\begin{aligned} \mathcal {C}:=\left\{ \begin{pmatrix} a &{}\quad a \\ b &{}\quad b \end{pmatrix} \mid a,b \in \mathbb {F}_2 \right\} . \end{aligned}$$

Then \(\mathcal {C}\) is an optimal anticode of dimension 2. Therefore, \(a_2(\mathcal {C})=1\). On the other hand, \({\text {supp}}(\mathcal {C})=\mathbb {F}_2^2\), hence \(cs_2(\mathcal {C})=2 \ne a_2(\mathcal {C})\). Now observe that \(\mathcal {C}\sim \mathcal {C}^t\). In particular, \(a_2(\mathcal {C})=a_2(\mathcal {C}^t)=1\). However, \(cs_2(\mathcal {C})=2\), while \(cs_2(\mathcal {C}^t)=1\).

Generalized weights and support weights relate to each other as follows.

Proposition 3.9

([13], Theorem 9). Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero code, and let \(i \ge 1\) be an integer. If \(m>n\), then \(a_i(\mathcal {C})=cs_i(\mathcal {C})\). If \(m=n\), then \(a_i(\mathcal {C}) \le cs_i(\mathcal {C})\).

We stress that there exist codes \(\mathcal {C}\subseteq {\text {Mat}}\) with \(m=n\) and \(a_i(\mathcal {C}) < cs_i(\mathcal {C})\), e.g., the code \(\mathcal {C}\) of Example 3.8.

4 The q-analogue of a polymatroid

This section introduces q-polymatroids, that are a q-analogue of polymatroids. For more on (poly)matroids, see the standard references [15, 25].

Definition 4.1

A q-polymatroid is a pair \(P=(\mathbb {F}_q^n,\rho )\) where \(n \ge 1\) and \(\rho \) is a function from the set of all subspaces of \(\mathbb {F}_q^n\) to \(\mathbb {R}\) such that, for all \(A,B\subseteq \mathbb {F}_q^n\):

  1. (P1)

    \(0\le \rho (A)\le \dim (A)\),

  2. (P2)

    if \(A\subseteq B\), then \(\rho (A)\le \rho (B)\),

  3. (P3)

    \(\rho (A+B)+\rho (A\cap B)\le \rho (A)+\rho (B)\).

Notice that a q-polymatroid such that \(\rho \) is integer-valued is a q-matroid according to [10, Definition 2.1].

Remark 4.2

Our definition of q-polymatroid is slightly different from that of (qr)-polymatroid given by Shiromoto in [21, Definition 2]. However, a (qr)-polymatroid \((E,\rho )\) as defined by Shiromoto corresponds to the q-polymatroid \((E,\rho /r)\) according to our definition. Moreover, a q-polymatroid whose rank function takes values in \(\mathbb {Q}\) corresponds to a (qr)-polymatroid as defined by Shiromoto up to multiplying the rank function for an r which clears denominators.

Remark 4.3

One could also define a q-polymatroid P as a pair \((\mathbb {F}_q^n,\rho )\) that satisfies \(\rho (A)\ge 0\) for all \(A\subseteq \mathbb {F}_q^n\), (P2), and (P3). Up to multiplying the rank function by a suitable constant, one may additionally assume that \(\rho (x)\le 1\) for all 1-dimensional subspaces \(x\subseteq \mathbb {F}_q^n\). It is easy to show that this is equivalent to Definition 4.1.

The definition of q-polymatroid that we propose is a direct q-analogue of the definition of an ordinary polymatroid, with the extra property that \(\rho (A)\le \dim (A)\) for all A. As in the ordinary case, a q-matroid is a q-polymatroid. At the end of Sect. 6 we give an example of a q-polymatroid that is not a q-matroid. One has the following natural notion of equivalence for q-polymatroids.

Definition 4.4

Let \((\mathbb {F}_q^n,\rho _1)\) and \((\mathbb {F}_q^n,\rho _2)\) be q-polymatroids. We say that \((\mathbb {F}_q^n,\rho _1)\) and \((\mathbb {F}_q^n,\rho _2)\) are equivalent if there exists an \(\mathbb {F}_q\)-linear isomorphism \(\varphi :\mathbb {F}_q^n\rightarrow \mathbb {F}_q^n\) such that \(\rho _1(A)=\rho _2(\varphi (A))\) for all \(A\subseteq \mathbb {F}_q^n\). In this case, we write \((\mathbb {F}_q^n,\rho _1) \sim (\mathbb {F}_q^n,\rho _2)\).

We start by introducing a notion of duality for q-polymatroids.

Definition 4.5

Let \(P=(\mathbb {F}_q^n,\rho )\) be a q-polymatroid. For all subspaces \(A \subseteq \mathbb {F}_q^n\) define

$$\begin{aligned} \rho ^*(A)=\dim (A)-\rho (\mathbb {F}_q^n)+\rho (A^\perp ), \end{aligned}$$

where \(A^\perp \) is the orthogonal complement of A with respect to the standard inner product on \(\mathbb {F}_q^n\). We call \(P^*=(\mathbb {F}_q^n,\rho ^*)\) the dual of the q-polymatroid P.

The proof of the next theorem is essentially the same as the proof of [10, Theorem 42].

Theorem 4.6

The dual \(P^*\) is a q-polymatroid.

We will need the following property of dual q-polymatroids.

Proposition 4.7

Let \(P_1=(\mathbb {F}_q^n,\rho _1)\) and \(P_2=(\mathbb {F}_q^n,\rho _2)\) be q-polymatroids. If \(P_1 \sim P_2\), then \(P_1^* \sim P_2^*\). Moreover, for every q-polymatroid P we have \(P^{**}=P\).

Proof

By definition, there exists an \(\mathbb {F}_q\)-isomorphism \(\varphi : \mathbb {F}_q^n \rightarrow \mathbb {F}_q^n\) with the property that \(\rho _1(A)=\rho _2(\varphi (A))\) for all \(A \subseteq \mathbb {F}_q^n\). In particular, \(\varphi (\mathbb {F}_q^n)=\mathbb {F}_q^n\). Therefore, by definition of \(\rho _1^*\), for all \(A \subseteq \mathbb {F}_q^n\) we have

$$\begin{aligned} \rho _1^*(A) = \dim (A) -\rho _2(\mathbb {F}_q^n) + \rho _2(\varphi (A^\perp )). \end{aligned}$$

Now let \(\psi : \mathbb {F}_q^n \rightarrow \mathbb {F}_q^n\) be the adjoint of \(\varphi \) with respect to the standard inner product of \(\mathbb {F}_q^n\). Then \(\varphi \) is an \(\mathbb {F}_q\)-isomorphism, and \(\varphi (A)^\perp =\psi (A)^\perp \) for all \(A \subseteq \mathbb {F}_q^n\). Therefore,

$$\begin{aligned} \rho _1^*(A) = \dim (A) -\rho _2(\mathbb {F}_q^n) + \rho _2(\psi (A)^\perp )=\rho _2^*(\psi (A)). \end{aligned}$$

If \(P=(\mathbb {F}_q^n,\rho )\) is a q-polymatroid, then it is straightforward to check that \(\rho ^{**}(A)=\rho (A)\). This implies \(P^{**}=P\). \(\square \)

5 Rank-metric codes and q-polymatroids

Starting from a rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\), in this section we construct two q-polymatroids: one associated with the column spaces, and the other to the row spaces. They will be denoted by \(P(\mathcal {C},\mathrm{c})\) and \(P(\mathcal {C},\mathrm{r})\), respectively. As the reader will see in the next sections, several structural properties of \(\mathcal {C}\) can be read off the associated q-polymatroids.

We start by studying subcodes of a given code, whose matrices are supported on a subspace \(J \subseteq \mathbb {F}_q^n\) or \(K \subseteq \mathbb {F}_q^m\). See [19] for a lattice-theoretic definition of support.

Notation 5.1

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code, and let \(J\subseteq \mathbb {F}_q^n\) and \(K \subseteq \mathbb {F}_q^m\) be subspaces. We define

$$\begin{aligned} \mathcal {C}(J,\mathrm{c}) := \{M\in \mathcal {C}\mid {\text {colsp}}(M)\subseteq J\} \qquad \text{ and } \qquad \mathcal {C}(K,\mathrm{r}) := \{M\in \mathcal {C}\mid {\text {rowsp}}(M)\subseteq K\}, \end{aligned}$$

where \({\text {colsp}}(M)\subseteq \mathbb {F}_q^n\) and \({\text {rowsp}}(M) \subseteq \mathbb {F}_q^m\) are the spaces generated over \(\mathbb {F}_q\) by the columns, respectively the rows, of M.

Notice that \(\mathcal {C}(J,\mathrm{c})\) and \(\mathcal {C}(K,\mathrm{r})\) are subcodes of \(\mathcal {C}\) for all \(J \subseteq \mathbb {F}_q^n\) and \(K \subseteq \mathbb {F}_q^m\). In the sequel, we denote by \(J^\perp \) the orthogonal of a space \(J \subseteq \mathbb {F}_q^n\) with respect to the standard inner product of \(\mathbb {F}_q^n\). We use the same notation for subspaces \(K \subseteq \mathbb {F}_q^m\). No confusion will arise with the trace-dual of a code \(\mathcal {C}\subseteq {\text {Mat}}\).

Notation 5.2

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code. For subspaces \(J \subseteq \mathbb {F}_q^n\) and \(K \subseteq \mathbb {F}_q^m\) define the rational numbers

$$\begin{aligned} \rho _\mathrm{c}(\mathcal {C},J):= & {} (\dim (\mathcal {C}) - \dim (\mathcal {C}(J^\perp ,\mathrm{c}))/m, \\ \rho _\mathrm{r}(\mathcal {C},K):= & {} (\dim (\mathcal {C}) - \dim (\mathcal {C}(K^\perp ,\mathrm{r}))/n. \end{aligned}$$

For simplicity of notation, in the sequel we sometimes drop the index \(\mathcal {C}\) and denote the rank functions simply by \(\rho _\mathrm{c}\) and \(\rho _\mathrm{r}\). The following result shows that a rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\) gives rise to a pair of q-polymatroids via \(\rho _\mathrm{c}\) and \(\rho _\mathrm{r}\).

Theorem 5.3

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code. The pairs \((\mathbb {F}_q^n,\rho _\mathrm{c})\) and \((\mathbb {F}_q^m,\rho _\mathrm{r})\) are q-polymatroids.

To prove the theorem we need a preliminary result, whose proof is left to the reader.

Lemma 5.4

Let \(I, J \subseteq \mathbb {F}_q^n\) be subspaces. We have:

$$\begin{aligned} {\text {Mat}}(I\cap J,\mathrm{c})={\text {Mat}}(I,\mathrm{c})\cap {\text {Mat}}(J,\mathrm{c}) \text{ and } {\text {Mat}}(I + J,\mathrm{c})={\text {Mat}}(I,\mathrm{c})+{\text {Mat}}(J,\mathrm{c}). \end{aligned}$$

Proof of Theorem 5.3

We prove that \((\mathbb {F}_q^n,\rho _\mathrm{c})\) is a q-polymatroid. The proof that \((\mathbb {F}_q^m,\rho _\mathrm{r})\) is a q-polymatroid is completely analogous, hence we omit it.

We start by proving (P1). It is clear from the definition that \(\rho _\mathrm{c}(J)\ge 0\). The other inequality follows from [17, Lemma 28]:

$$\begin{aligned} \rho _\mathrm{c}(J)=(\dim (\mathcal {C})-(\dim (\mathcal {C})-m(n-\dim J^\perp )+\dim (\mathcal {C}^\perp (J))))/m \le \dim (J). \end{aligned}$$

Now let \(I,J\subseteq \mathbb {F}_q^n\) such that \(I\subseteq J\). Then \(\mathcal {C}(J^\perp ,\mathrm{c})\subseteq \mathcal {C}(I^\perp ,\mathrm{c})\), thus \(\rho _\mathrm{c}(I)\le \rho _\mathrm{c}(J)\). This establishes (P2). For (P3), we have

$$\begin{aligned}&\dim \mathcal {C}((I+J)^\perp ,\mathrm{c})+\dim \mathcal {C}((I\cap J)^\perp ,\mathrm{c})\\&\quad =\dim (\mathcal {C}\cap {\text {Mat}}(I^\perp \cap J^\perp ,\mathrm{c}))+\dim (\mathcal {C}\cap {\text {Mat}}(I^\perp + J^\perp ,\mathrm{c}))\\&\quad \ge \dim (\mathcal {C}\cap {\text {Mat}}(I^\perp ,\mathrm{c})\cap {\text {Mat}}( J^\perp ,\mathrm{c}))+ \dim ((\mathcal {C}\cap ({\text {Mat}}(I^\perp ,\mathrm{c}))\\&\qquad +(\mathcal {C}\cap {\text {Mat}}(J^\perp ,\mathrm{c})))\\&\quad = \dim (\mathcal {C}\cap {\text {Mat}}(I^\perp ,\mathrm{c}))+ \dim (\mathcal {C}\cap {\text {Mat}}( J^\perp ,\mathrm{c})), \end{aligned}$$

where the first equality follows from [17, Lemma 27]. The inequality follows from combining Lemma 5.4 with \(\mathcal {C}\cap ({\text {Mat}}(I^\perp ,\mathrm{c})+{\text {Mat}}(J^\perp ,\mathrm{c}))\supseteq (\mathcal {C}\cap {\text {Mat}}(I^\perp ,\mathrm{c}))+(\mathcal {C}\cap {\text {Mat}}(J^\perp ,\mathrm{c})).\)\(\square \)

Notation 5.5

The q-polymatroids associated with a rank-metric code \(\mathcal {C}\subseteq {\text {Mat}}\) are denoted by \(P(\mathcal {C},\mathrm{c})\) and \(P(\mathcal {C},\mathrm{r})\), respectively.

6 Structural properties of codes via q-polymatroids

In this section, we investigate some connections between rank-metric codes and the associated q-polymatroids. We show that the q-polymatroids associated with a code \(\mathcal {C}\) determine the dimension of the code and its minimum distance, and characterize the property of being MRD.

Proposition 6.1

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a rank-metric code. Then

$$\begin{aligned}\dim (\mathcal {C})=m\cdot \rho _\mathrm{c}(\mathcal {C},\mathbb {F}_q^n)=n\cdot \rho _\mathrm{r}(\mathcal {C},\mathbb {F}_q^m).\end{aligned}$$

The above result follows directly from the definitions. We now relate the minimum distance of a code to the rank functions of the associated q-polymatroids.

Proposition 6.2

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero rank-metric code. The following are equivalent:

  1. (1)

    \(d(\mathcal {C}) \ge d\),

  2. (2)

    \(\rho _\mathrm{c}(J)= \dim (\mathcal {C})/m\) for all \(J \subseteq \mathbb {F}_q^n\) with \(\dim (J) \ge n-d+1\),

  3. (3)

    \(\rho _\mathrm{r}(K)= \dim (\mathcal {C})/n\) for all \(K \subseteq \mathbb {F}_q^m\) with \(\dim (K) \ge m-d+1\).

Proof

It is easy to see that the following are equivalent:

\(1^{\prime }\):

\(d(\mathcal {C}) \ge d\),

\(2^{\prime }\):

\(\mathcal {C}(J,\mathrm{c}) = \{0\}\) for all \(J \subseteq \mathbb {F}_q^n\) with \(\dim (J) \le d-1\),

\(3^{\prime }\):

\(\mathcal {C}(K,\mathrm{r}) = \{0\}\) for all \(K \subseteq \mathbb {F}_q^m\) with \(\dim (K) \le d-1\).

By definition, for all \(J \subseteq \mathbb {F}_q^n\) and \(K \subseteq \mathbb {F}_q^m\) we have \(m \rho _\mathrm{c}(J) =\dim (\mathcal {C}) - \dim (\mathcal {C}(J^\perp ,\mathrm{c}))\) and \(n \rho _\mathrm{r}(K) =\dim (\mathcal {C}) - \dim (\mathcal {C}(K^\perp ,\mathrm{r}))\). Hence \((2) \Leftrightarrow (2')\) and \((3) \Leftrightarrow (3')\). \(\square \)

Therefore, the minimum distance of a rank-metric code can be expressed in terms of the rank function of one of the associated q-polymatroids as follows.

Corollary 6.3

Let \(0\ne \mathcal {C}\subseteq {\text {Mat}}\). The minimum distance of \(\mathcal {C}\) is

$$\begin{aligned} d(\mathcal {C})= & {} n+1-\min \left\{ d \mid \rho _\mathrm{c}(J)=\frac{\dim (\mathcal {C})}{m} \text{ for } \text{ all } J \subseteq \mathbb {F}_q^n \text{ with } \dim (J)=d \right\} \\= & {} m+1-\min \left\{ d \mid \rho _\mathrm{r}(K)=\frac{\dim (\mathcal {C})}{n} \text{ for } \text{ all } K \subseteq \mathbb {F}_q^m \text{ with } \dim (K)=d \right\} . \end{aligned}$$

This allows us to characterize the property of being MRD in terms of the rank function of one of the associated q-polymatroids.

Theorem 6.4

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero code of minimum distance d. The following are equivalent:

  1. (1)

    \(\mathcal {C}\) is MRD,

  2. (2)

    \(\rho _\mathrm{c}(J)=\dim (J)\) for all \(J \subseteq \mathbb {F}_q^n\) with \(\dim (J) \le n-d+1\),

  3. (3)

    \(\rho _\mathrm{c}(J)=\dim (J)\) for some \(J \subseteq \mathbb {F}_q^n\) with \(\dim (J) = n-d+1\).

Proof

Assume that \(\mathcal {C}\) is MRD. We claim that

$$\begin{aligned} \dim (\mathcal {C}(J,\mathrm{c}))=\dim (\mathcal {C})-m(n-\dim (J)) \text{ for } \text{ all } J \subseteq \mathbb {F}_q^n \text{ with } \dim (J) \ge d-1. \end{aligned}$$

This is straightforward if \(\dim (J)=d-1\). When \(\dim (J) \ge d\), it follows from [19, Lemma 48]. Let \(J \subseteq \mathbb {F}_q^n\) be a subspace with \(\dim (J) \le n-d+1\). Since \(\dim (J^\perp ) \le d-1\) and \(\dim (\mathcal {C}(J,\mathrm{c}))=\dim (\mathcal {C})-m(n-\dim (J))\), we obtain

$$\begin{aligned} m\rho _\mathrm{c}(J)=\dim (\mathcal {C})-\dim (\mathcal {C}(J^\perp ,\mathrm{c})) = \dim (\mathcal {C}) - \dim (\mathcal {C}) +m \dim (J) =m\dim (J). \end{aligned}$$

This establishes \((1) \Rightarrow (2)\).

It is clear that (2) implies (3). So we assume that (3) holds and prove (1). Since \(\dim (J)=n-d+1\), then \(\dim (J^\perp )=d-1\), therefore \(\dim (\mathcal {C}(J^\perp ,\mathrm{c}))=0\). It follows that

$$\begin{aligned} m\dim (J) = m\rho _\mathrm{c}(J) =\dim (\mathcal {C}) - \dim (\mathcal {C}(J^\perp ,\mathrm{c}))=\dim (\mathcal {C}), \end{aligned}$$

from which we obtain \(\dim (\mathcal {C})=m\dim (J)=m(n-d+1)\). Hence \(\mathcal {C}\) is MRD. \(\square \)

Remark 6.5

If \(m=n\) and \(0\ne \mathcal {C}\subseteq {\text {Mat}}\), then the same proof as in Theorem 6.4 shows that the following are equivalent:

  • \(\mathcal {C}\) is MRD,

  • \(\rho _\mathrm{c}(K)=\dim (K)\) for all \(K\subseteq \mathbb {F}_q^m\) with \(\dim (K) = m-d+1\)

  • \(\rho _\mathrm{c}(K)=\dim (K)\) for some \(K\subseteq \mathbb {F}_q^m\) with \(\dim (K) = m-d+1\).

Combining Proposition 6.2 and Theorem 6.4, we obtain an explicit formula for the rank function of the (column) q-polymatroid associated with an MRD code.

Corollary 6.6

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero MRD code of minimum distance d. Then for all \(J \subseteq \mathbb {F}_q^n\) we have

$$\begin{aligned} \rho _\mathrm{c}(J)= \left\{ \begin{array}{ll} n-d+1 &{} \text{ if } \dim (J) \ge n-d+1, \\ \dim (J) &{} \text{ if } \dim (J) \le n-d+1.\end{array}\right. \end{aligned}$$
(1)

In particular, the q-polymatroid associated with an MRD code has an integer-valued rank function, i.e., it is a q-matroid. It is in fact the uniform q-matroid, as explained in [10, Example 4.16]

It is natural to expect that equivalent rank-metric codes give rise to equivalent q-polymatroids. This is true in the following precise sense.

Proposition 6.7

Let \(\mathcal {C}_1, \mathcal {C}_2 \subseteq {\text {Mat}}\) be rank-metric codes. Assume \(\mathcal {C}_1 \sim \mathcal {C}_2\). If \(m>n\), then \(P(\mathcal {C}_1,\mathrm{c}) \sim P(\mathcal {C}_2,\mathrm{c})\) and \(P(\mathcal {C}_1,\mathrm{r}) \sim P(\mathcal {C}_2,\mathrm{r})\). If \(n=m\), then one of the following holds:

  • \(P(\mathcal {C}_1,\mathrm{c}) \sim P(\mathcal {C}_2,\mathrm{c})\) and \(P(\mathcal {C}_1,\mathrm{r}) \sim P(\mathcal {C}_2,\mathrm{r})\),

  • \(P(\mathcal {C}_1,\mathrm{c}) \sim P(\mathcal {C}_2,\mathrm{r})\) and \(P(\mathcal {C}_1,\mathrm{r}) \sim P(\mathcal {C}_2,\mathrm{c})\).

Proof

Since \(\mathcal {C}_1\sim \mathcal {C}_2\), then either \(\mathcal {C}_2=A\mathcal {C}_1 B\) for some invertible AB, or \(\mathcal {C}_2=A\mathcal {C}_1^t B\) for some invertible AB and \(m=n\). Since the proofs are similar, we only treat the case when there exist invertible matrices AB such that \(\mathcal {C}_2=A\mathcal {C}_1 B\). Let \(\psi : \mathbb {F}_q^n \rightarrow \mathbb {F}_q^n\) be the \(\mathbb {F}_q\)-linear isomorphism associated with the matrix A with respect to the standard basis. Fix a subspace \(J \subseteq \mathbb {F}_q^n\). Multiplication by A on the left and B on the right induces a bijection

$$\begin{aligned} \mathcal {C}_1(J^\perp ,\mathrm{c}) \rightarrow \mathcal {C}_2(\psi (J^\perp ),\mathrm{c}). \end{aligned}$$
(2)

Let \(\varphi : \mathbb {F}_q^n \rightarrow \mathbb {F}_q^n\) denote the \(\mathbb {F}_q\)-linear isomorphism associated with the matrix \((A^{-1})^t\) with respect to the standard basis. Then we have \(\psi (J^\perp )=\varphi (J)^\perp \), hence bijection (2) can be thought of as a bijection

$$\begin{aligned} \mathcal {C}_1(J^\perp ,\mathrm{c}) \rightarrow \mathcal {C}_2(\varphi (J)^\perp ,\mathrm{c}). \end{aligned}$$
(3)

Therefore, for all subspaces \(J \subseteq \mathbb {F}_q^n\) we have \(\rho _\mathrm{c}(\mathcal {C}_1,J)= \rho _\mathrm{c}(\mathcal {C}_2,\varphi (J))\). This establishes the q-polymatroid equivalence \(P(\mathcal {C}_1,\mathrm{c}) \sim P(\mathcal {C}_2,\mathrm{c})\). The equivalence \(P(\mathcal {C}_1,\mathrm{r}) \sim P(\mathcal {C}_2,\mathrm{r})\) can be shown similarly. \(\square \)

Proposition 6.7 says that equivalent codes have equivalent associated q-polymatroids. The next example shows that the converse is false in general, i.e., that inequivalent codes may have equivalent (in fact, even identical) associated q-polymatroids.

Example 6.8

Let \(q=2\) and \(m=n=4\). Let \(\mathcal {C}_1\) be the code of [2, Example 7.2], i.e., the code generated by the four linearly independent binary matrices

$$\begin{aligned}\begin{pmatrix} 1 &{}\quad 0 &{}\quad 0 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad 0 &{}\quad 1 \\ 0 &{}\quad 0 &{}\quad 1 &{}\quad 0 \\ 0 &{}\quad 1 &{}\quad 0 &{}\quad 0 \end{pmatrix}, \ \ \ \ \ \begin{pmatrix} 0 &{}\quad 1 &{}\quad 0 &{}\quad 0 \\ 0 &{}\quad 0 &{}\quad 1 &{}\quad 1 \\ 0 &{}\quad 0 &{}\quad 0 &{}\quad 1 \\ 1 &{}\quad 1 &{}\quad 0 &{}\quad 0 \end{pmatrix}, \ \ \ \ \ \begin{pmatrix} 0 &{}\quad 0 &{}\quad 1 &{}\quad 0 \\ 0 &{}\quad 1 &{}\quad 1 &{}\quad 1 \\ 1 &{}\quad 0 &{}\quad 1 &{}\quad 0 \\ 1 &{}\quad 0 &{}\quad 0 &{}\quad 1 \end{pmatrix},\ \ \ \ \ \begin{pmatrix} 0 &{}\quad 0 &{}\quad 0 &{}\quad 1 \\ 1 &{}\quad 1 &{}\quad 1 &{}\quad 0 \\ 0 &{}\quad 1 &{}\quad 0 &{}\quad 1 \\ 0 &{}\quad 1 &{}\quad 1 &{}\quad 1 \end{pmatrix}. \end{aligned}$$

The code \(\mathcal {C}_1\) is MRD and has minimum distance \(d(\mathcal {C}_1)=4\). Let \(\mathcal {C}_2\) be a rank-metric code obtained from a Gabidulin code \(C \subseteq \mathbb {F}_{2^4}^4\) of minimum distance 4 via Proposition 2.12. By [2, Example 7.2], the code \(\mathcal {C}_1\) has covering radius \( cov (\mathcal {C}_1)=2\), while it is well known that \( cov (\mathcal {C}_2)=d(\mathcal {C})-1=3\). Since the covering radius of a code is preserved under isometries, we conclude that the codes \(\mathcal {C}_1\) and \(\mathcal {C}_2\) are not equivalent.

On the other hand, the four codes \(\mathcal {C}_1\), \(\mathcal {C}_2\), \(\mathcal {C}_1^t\) and \(\mathcal {C}_2^t\) are all MRD with the same parameters. Therefore, by Corollary 6.6 the rank function of their q-polymatroids is determined and given by the formula in (1). This shows that \(P(\mathcal {C}_1,\mathrm{c})=P(\mathcal {C}_1,\mathrm{r}) = P(\mathcal {C}_2,\mathrm{c})=P(\mathcal {C}_2,\mathrm{r})\), although \(\mathcal {C}_1 \not \sim \mathcal {C}_2\).

It is known from [10] that a vector rank-metric code \(C \subseteq \mathbb {F}_{q^m}^n\) gives rise to a q-matroid M(C) on \(\mathbb {F}_q^n\). In our notation, \(M(C)=P(\Gamma (C),\mathrm{c})\), where \(\Gamma \) is any \(\mathbb {F}_q\)-basis of \(\mathbb {F}_{q^m}\).

Proposition 6.9

Let \(C \subseteq \mathbb {F}_{q^m}^n\) be a vector rank-metric code, and let \(\Gamma ,\Gamma '\) be \(\mathbb {F}_q\)-bases of \(\mathbb {F}_{q^m}\). We have \(P(\Gamma (C),\mathrm{c}) = P(\Gamma '(C),\mathrm{c})\) and \(P(\Gamma (C),\mathrm{r}) \sim P(\Gamma '(C),\mathrm{r})\).

Proof

The statement that \(P(\Gamma (C),\mathrm{c}) = P(\Gamma '(C),\mathrm{c})\) follows from [10, Corollary 4.7]. The statement that \(P(\Gamma (C),\mathrm{r}) \sim P(\Gamma '(C),\mathrm{r})\) follows by Propositions 2.13 and 6.7. \(\square \)

We continue by showing that there exist rank-metric codes whose associated q-polymatroids are not q-matroids. Even more, in the next example we show that there are q-polymatroids such that no nonzero multiple of their rank function defines a q-matroid.

Example 6.10

Let \(q=3\) and \(n=m=2.\) Let \(\mathcal {C}\) be a rank-metric code generated by the matrices

$$\begin{aligned} M_1:=\begin{pmatrix}1 &{}\quad 0 \\ 0 &{}\quad 0\end{pmatrix},\qquad M_2:=\begin{pmatrix}0 &{}\quad 1 \\ 0 &{}\quad 0\end{pmatrix},\qquad M_3:=\begin{pmatrix}0 &{}\quad 0 \\ 1 &{}\quad 0\end{pmatrix}. \end{aligned}$$

Consider the subspaces \(J:=(\left\langle (1,0)\right\rangle \) and \(I:=(\left\langle (0,1)\right\rangle \). Since \(\mathcal {C}(J^\perp ,\mathrm{c})=(\left\langle M_3\right\rangle \), we have \(\rho _\mathrm{c}(\mathcal {C},J)=1.\) As \(\mathcal {C}(I^\perp ,\mathrm{c})=(\left\langle M_1,M_2\right\rangle ,\) then \( \rho _\mathrm{c}(\mathcal {C},I)=1/2\). Hence \(P(\mathcal {C},\mathrm{c})\) is a q-polymatroid which is not a q-matroid.

Let \(\alpha \in \mathbb {R}\) with \(\alpha \ne 0\), and consider the function \(\rho :=\alpha \rho _\mathrm{c}\). Since \(\rho (J)=\alpha \), in order for \(\rho \) to be the rank function of a q-polymatroid it must be \(0<\alpha \le 1\). Then \(\rho (I)=\alpha /2\) is not an integer, so \(\rho \) cannot be the rank function of a q-matroid.

7 Generalized weights as q-polymatroid invariants

In this section, we provide further evidence that the q-polymatroids associated with a rank-metric code adequately capture the structure of the code. More precisely, in the next theorem we show that the generalized rank-weights of the code are an invariant of the associated q-polymatroids. Later in the section, we show that the property of being an optimal anticode can be characterized in terms of the rank function of the associated q-polymatroids.

Theorem 7.1

Let \(\mathcal {C}\subseteq {\text {Mat}}\) be a nonzero rank-metric code and let \(1 \le i \le \dim (\mathcal {C})\) be an integer. If \(n>m\), we have

$$\begin{aligned} a_i(\mathcal {C}) = \min \{n-\dim (J) \mid J \subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C})-m \rho _\mathrm{c}(\mathcal {C},J) \ge i\}. \end{aligned}$$

If \(n=m\), we have

$$\begin{aligned} a_i(\mathcal {C})=\min \{a_i(\mathcal {C},\mathrm{c}), \ a_i(\mathcal {C},\mathrm{r})\}, \end{aligned}$$

where

$$\begin{aligned} a_i(\mathcal {C},\mathrm{c}):= & {} \min \{n-\dim (J) \mid J \subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C})-m \rho _\mathrm{c}(\mathcal {C},J) \ge i\}, \\ a_i(\mathcal {C},\mathrm{r}):= & {} \min \{m-\dim (K) \mid K \subseteq \mathbb {F}_q^m, \ \dim (\mathcal {C})-n \rho _\mathrm{r}(\mathcal {C},K) \ge i\}. \\ \end{aligned}$$

Proof

Let \(J\subseteq \mathbb {F}_q^n\), then by [17, Lemma 26]

$$\begin{aligned} \dim ({\text {Mat}}(J^\perp ,\mathrm{c}))=m\dim (J^\perp )=m(n-\dim (J)). \end{aligned}$$
(4)

Assume that \(m>n\). By [4, Theorem 6], the optimal anticodes in \({\text {Mat}}\) are the spaces of the form \({\text {Mat}}(J^\perp , \mathrm{c})\), where J ranges over the subspaces of \(\mathbb {F}_q^n\). Therefore,

$$\begin{aligned} m \cdot a_i(\mathcal {C})= & {} \min \{\dim ({\text {Mat}}(J^\perp ,\mathrm{c})) \mid J \subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C}\cap {\text {Mat}}(J^\perp ,\mathrm{c})) \ge i\}\\= & {} m \cdot \min \{n-\dim (J) \mid J \subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C})-m \rho _\mathrm{c}(\mathcal {C},J) \ge i\}, \end{aligned}$$

where the last equality follows from (4) and the definition of \(\rho _\mathrm{c}(\mathcal {C},J)\).

Now assume that \(n=m\). By [4, Theorem 4], the anticodes in \({\text {Mat}}\) are the spaces of the form \({\text {Mat}}(J^\perp , \mathrm{c})\) or \({\text {Mat}}(J^\perp , \mathrm{r})\), as J ranges over the subspaces of \(\mathbb {F}_q^n.\) Then

$$\begin{aligned} a_i(\mathcal {C})= & {} \frac{1}{n} \min \left\{ \dim ({\text {Mat}}(J^\perp ,\mathrm{c})) \mid J \subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C}\cap {\text {Mat}}(J^\perp ,\mathrm{c})) \ge i\right\} \\&\qquad \qquad \qquad \cup \left\{ \dim ({\text {Mat}}(J^\perp ,\mathrm{r})) \mid J\subseteq \mathbb {F}_q^n, \ \dim (\mathcal {C}\cap {\text {Mat}}(J^\perp ,\mathrm{r})) \ge i\right\} \\= & {} \min \{a_i(\mathcal {C},\mathrm{c}), \ a_i(\mathcal {C},\mathrm{r})\}, \end{aligned}$$

where the last equality follows from (4) and the definition of \(\rho _\mathrm{c}(\mathcal {C},J), \rho _\mathrm{r}(\mathcal {C},J)\). \(\square \)

In the next theorem, we prove that the property of being an optimal anticode is captured by the rank function of the associated q-polymatroids.

Theorem 7.2

Let \(\mathcal {C} \subseteq {\text {Mat}}\) be a rank-metric code and let \(t=\text{ maxrk }(\mathcal {C})\). The following are equivalent:

  1. 1.

    \(\mathcal {C}\) is an optimal anticode,

  2. 2.

    \(\left\{ \rho _\mathrm{c}(\mathcal {C},J)\mid J \subseteq \mathbb {F}_q^n\right\} =\left\{ 0,1,\ldots ,t\right\} \), or \(\left\{ \rho _\mathrm{r}(\mathcal {C},J)\mid J \subseteq \mathbb {F}_q^n\right\} =\left\{ 0,1,\ldots ,t\right\} \) and \(m=n\),

  3. 3.

    \(\rho _\mathrm{c}(\mathcal {C},\mathbb {F}_q^n)=t\), or \(\rho _\mathrm{r}(\mathcal {C},\mathbb {F}_q^n)=t\) and \(m=n\).

In particular, the q-polymatroid associated with an optimal anticode is a q-matroid.

Proof

\((1)\Rightarrow (2)\) By [4, Theorems 4 and 6], either \(\mathcal {C}={\text {Mat}}(K,\mathrm{c})\) for a t-dimensional subspace \(K \subseteq \mathbb {F}_q^n\), or \(\mathcal {C}={\text {Mat}}(K,\mathrm{r})\) for a t-dimensional subspace \(K \subseteq \mathbb {F}_q^m\), where the latter is only possible if \(m=n\). We assume that \(\mathcal {C}={\text {Mat}}(K,\mathrm{c})\), as the proof in the other situation is analogous. One has, for all \(J \subseteq \mathbb {F}_q^n\),

$$\begin{aligned} \rho _\mathrm{c}(\mathcal {C},J) = (mt - \dim ({\text {Mat}}(K,\mathrm{c})\cap {\text {Mat}}(J^\perp ,\mathrm{c}))/m = t-\dim (K \cap J^\perp ), \end{aligned}$$

where the second equality follows from Lemma 5.4 and [17, Lemma 26]. Hence we obtain

$$\begin{aligned} \left\{ \rho _\mathrm{c}(\mathcal {C},J)\mid J \subseteq \mathbb {F}_q^n\right\}= & {} \left\{ 0,1,\ldots ,t\right\} \text{ if } \mathcal {C}={\text {Mat}}(K,\mathrm{c}),\\ \left\{ \rho _\mathrm{r}(\mathcal {C},J)\mid J \subseteq \mathbb {F}_q^n\right\}= & {} \left\{ 0,1,\ldots ,t\right\} \text{ if } \mathcal {C}={\text {Mat}}(K,\mathrm{r}). \end{aligned}$$

\((3)\Rightarrow (1)\) We have

$$\begin{aligned}\rho _\mathrm{c}(\mathcal {C},\mathbb {F}_q^n)=\dim (\mathcal {C})/m \text{ and } \max \{\rho _\mathrm{r}(\mathcal {C},K)\mid K\subseteq \mathbb {F}_q^m\}=\rho _\mathrm{r}(\mathcal {C},\mathbb {F}_q^m)=\dim (\mathcal {C})/n. \end{aligned}$$

Then either \(\dim (\mathcal {C})/m\), or \(\dim (\mathcal {C})/n=t\) and \(m=n\). Either way one has \(\dim (\mathcal {C})=mt\), hence \(\mathcal {C}\) is an optimal anticode. \(\square \)

Corollary 7.3

Let \(\mathcal {C} \subseteq {\text {Mat}}\) be an optimal anticode and let \(t=\text{ maxrk }(\mathcal {C})\). If \(m>n\), then \(P(\mathcal {C},\mathrm{c})\sim (\mathbb {F}_q^n,\rho )\) where

$$\begin{aligned} \rho (J)=\dim (J+\langle e_1,\ldots ,e_{n-t}\rangle )-(n-t) \end{aligned}$$
(5)

and \(e_i\) denotes the i-th vector of the standard basis of \(\mathbb {F}_q^n\). If \(m=n\), then either \(P(\mathcal {C},\mathrm{c})\sim (\mathbb {F}_q^n,\rho )\) or \(P(\mathcal {C},\mathrm{r})\sim (\mathbb {F}_q^n,\rho )\).

Proof

If \(m>n\), then \(\mathcal {C}={\text {Mat}}(K,\mathrm{c})\) for some \(K\subseteq \mathbb {F}_q^n\) of \(\dim (K)=t\). If \(m=n\), then either \(\mathcal {C}={\text {Mat}}(K,\mathrm{c})\) or \(\mathcal {C}^t={\text {Mat}}(K,\mathrm{c})\), for some \(K\subseteq \mathbb {F}_q^n\) of \(\dim (K)=t\). Since \(P(\mathcal {C}^t,\mathrm{c})=P(\mathcal {C},\mathrm{r})\), it suffices to consider the case when \(\mathcal {C}={\text {Mat}}(K,\mathrm{c})\). Up to code equivalence, we may also assume without loss of generality that \(K=\langle e_{n-t+1},\ldots ,e_n\rangle \).

It follows from the proof of Theorem 7.2 that \(\rho _\mathrm{c}(\mathcal {C},J)=t-\dim (K \cap J^\perp )\). Therefore, \(\rho _\mathrm{c}(\mathcal {C},J)=t-(n-dim(\langle e_{n-t+1},\ldots ,e_n\rangle \cap J^\perp )^\perp )=\dim (J+\langle e_1,\ldots ,e_{n-t}\rangle )-(n-t).\)\(\square \)

Remark 7.4

One consequence of our results is that, in certain cases, the generalized weights of a code determine the associated q-polymatroid \(P(\mathcal {C},\mathrm{c})\) up to equivalence. This is the case, e.g., in the following situations:

  • if \(\mathcal {C}\) has the generalized weights of an MRD code, then \(\mathcal {C}\) is MRD and \(P(\mathcal {C},\mathrm{c})\) is the uniform q-matroid (see Corollary 6.6),

  • if \(\mathcal {C}\) has the generalized weights of an optimal anticode, then \(\mathcal {C}\) is an optimal anticode and \(P(\mathcal {C},\mathrm{c})\) is the q-matroid described in Corollary 7.3,

  • if \(\dim (\mathcal {C})=1\), then \(\mathcal {C}=\langle M\rangle \) and \(a_1(\mathcal {C})=d_{\min }(\mathcal {C})={\text {rk}}(M)\). Moreover, \(P(\mathcal {C},\mathrm{c})\) is given by

    $$\begin{aligned}\rho _\mathrm{c}(\mathcal {C},J)=\left\{ \begin{array}{ll} 0 &{}\quad \text{ if } {\text {colsp}}(M)\subseteq J^\perp \text{, }\\ \frac{1}{m} &{}\quad \text{ else. } \end{array}\right. \end{aligned}$$

    Notice that if \(\mathcal {C}_1=\langle M_1\rangle \) and \(\mathcal {C}_2=\langle M_2\rangle \) have the same minimum distance, then \(P(\mathcal {C}_1,\mathrm{c})\sim P(\mathcal {C}_2,\mathrm{c})\). In fact, \(\rho _\mathrm{c}(\mathcal {C}_1,J)=\rho _\mathrm{c}(\mathcal {C}_2,\varphi (J))\), where \(\varphi :\mathbb {F}_q^n\rightarrow \mathbb {F}_q^n\) is an \(\mathbb {F}_q\)-linear isomorphism such that \(\varphi ({\text {colsp}}(M_1))={\text {colsp}}(M_2)\).

One should, however, not expect this to be the case in general. In other words, the generalized weights of a rank-metric code \(\mathcal {C}\) are invariants of the associated q-polymatroid \(P(\mathcal {C},\mathrm{c})\), but they do not determine it, as the next example shows. Similar examples may be found for rectangular matrices.

Example 7.5

Let \(\mathcal {C}_1,\mathcal {C}_2\subseteq {\text {Mat}}_{2\times 2}(\mathbb {F}_2)\),

$$\begin{aligned} \mathcal {C}_1=\left\langle \begin{pmatrix} 1 &{}\quad 0 \\ 0 &{}\quad 1 \end{pmatrix}, \begin{pmatrix} 0 &{}\quad 1 \\ 0 &{}\quad 0 \end{pmatrix}\right\rangle , \;\;\; \mathcal {C}_2=\left\langle \begin{pmatrix} 0 &{}\quad 1 \\ 1 &{}\quad 0 \end{pmatrix}, \begin{pmatrix} 0 &{}\quad 1 \\ 0 &{}\quad 0 \end{pmatrix}\right\rangle . \end{aligned}$$

The codes \(\mathcal {C},\mathcal {D}\) have generalized weights \(a_1(\mathcal {C}_1)=a_1(\mathcal {C}_2)=1\) and \(a_2(\mathcal {C}_1)=a_2(\mathcal {C}_2)=2\). In fact, any rank-metric code of dimension 2 and minimum distance 1 which is not an optimal anticode has the same generalized weights as \(\mathcal {C}_1\) and \(\mathcal {C}_2\).

Let \(P(\mathcal {C}_1,\mathrm{c})=(\mathbb {F}_2^2,\rho _1)\) and \(P(\mathcal {C}_2,\mathrm{c})=(\mathbb {F}_2^2,\rho _2)\). Let \(J\subseteq \mathbb {F}_2^2\) be a 1-dimensional linear subspace. Then

$$\begin{aligned} \rho _1(J)=\left\{ \begin{array}{ll} \frac{1}{2} &{}\quad \text{ if } J=\langle (0,1)\rangle \\ 1 &{}\quad \text{ if } J=\langle (1,0)\rangle \text{ or } J=\langle (1,1)\rangle \end{array}\right. \end{aligned}$$

while

$$\begin{aligned} \rho _2(J)=\left\{ \begin{array}{ll} \frac{1}{2} &{}\quad \text{ if } J=\langle (0,1)\rangle \text{ or } J=\langle (1,0)\rangle ,\\ 1 &{}\quad \text{ if } J=\langle (1,1)\rangle \end{array}\right. \end{aligned}$$

Therefore, \(P(\mathcal {C}_1,\mathrm{c})\not \sim P(\mathcal {C}_2,\mathrm{c}).\) Notice moreover that \(P(\mathcal {C}_1,\mathrm{c})\sim P(\mathcal {C}_1,\mathrm{r})\) and \(P(\mathcal {C}_2,\mathrm{c})\sim P(\mathcal {C}_2,\mathrm{r})\).

8 Duality

In this last section of the paper, we establish a connection between the notions of code duality and q-polymatroid duality. We start by showing that the q-polymatroids associated with the dual code \(\mathcal {C}^\perp \) are the duals of the q-polymatroids associated with the original code \(\mathcal {C}\).

Theorem 8.1

Let \(\mathcal {C} \subseteq {\text {Mat}}\) be a rank-metric code. We have \(P(\mathcal {C},\mathrm{c})^*=P(\mathcal {C}^\perp ,\mathrm{c})\) and \(P(\mathcal {C},\mathrm{r})^*=P(\mathcal {C}^\perp ,\mathrm{r})\).

Proof

We only show the result for \(P(\mathcal {C},\mathrm{c})\). The proof for \(P(\mathcal {C},\mathrm{r})\) is analogous. Let \(J\subseteq \mathbb {F}_q^n\) be a subspace. Since \(\rho _\mathrm{c}(\mathcal {C},J) = (\dim (\mathcal {C}) - \dim (\mathcal {C}(J^\perp ,\mathrm{c})))/m\), then

$$\begin{aligned} \rho ^*_\mathrm{c}(\mathcal {C},J)= & {} \dim (J) - \dim (\mathcal {C})/m + (\dim (\mathcal {C})-\dim (\mathcal {C}(J,\mathrm{c})))/m\\= & {} \dim (J) - \dim (\mathcal {C}(J,\mathrm{c}))/m. \end{aligned}$$

Therefore, by [17, Lemma 28] one has

$$\begin{aligned} m\rho ^*_\mathrm{c}(\mathcal {C},J)-m\rho _\mathrm{c}(\mathcal {C}^\perp ,J)=m\dim (J)-\dim (\mathcal {C}^\perp )-\dim (\mathcal {C})+mn-m\dim (J)=0. \end{aligned}$$

\(\square \)

Finally, it is natural to ask how the q-polymatroids associated with the dual of a vector rank-metric code relate to the q-polymatroids associated with the original vector rank-metric code. It turns out that they are dual to each other, as the following result shows.

Corollary 8.2

Let \(C \subseteq \mathbb {F}_{q^m}^n\) be a vector rank-metric code, and let \(\Gamma \) be a basis of \(\mathbb {F}_{q^m}\) over \(\mathbb {F}_q\). We have

where \(\Gamma ^*\) is the dual of the basis \(\Gamma \).

Proof

Applying [17, Theorem 21] to C, we obtain , hence and . On the other hand, Theorem 8.1 gives \(P(\Gamma ^*(C)^\perp ,\mathrm{c})=P(\Gamma ^*(C),\mathrm{c})^*\) and \(P(\Gamma ^*(C)^\perp ,\mathrm{r})=P(\Gamma ^*(C),\mathrm{r})^*\). By Proposition 6.9 we have \(P(\Gamma ^*(C),\mathrm{c})=P(\Gamma (C),\mathrm{c})\) and \(P(\Gamma ^*(C),\mathrm{r})\sim P(\Gamma (C),\mathrm{r})\). Therefore, by Proposition 4.7 it follows that \(P(\Gamma ^*(C),\mathrm{c})^*=P(\Gamma (C),\mathrm{c})^*\) and \(P(\Gamma ^*(C),\mathrm{r})^*\sim P(\Gamma (C),\mathrm{r})^*\). \(\square \)