1 Introduction

Rank-metric codes were first introduced by Delsarte [6] in 1978, and are referred to as Delsarte rank-metric codes. These codes are defined as \({\mathbb F}_q\)-subspaces of the space of \(m \times n\)-matrices over \({\mathbb F}_q\) (the field with q elements, for q a prime power) where the rank distance between two codewords (i.e. matrices) is given by the rank of their difference. These codes are important for their applications in network coding, public-key cryptography, and distributed storage, topics that thus stimulate the interest in studying the intrinsic properties of these codes. In this work we are interested in a particular case of Delsarte rank-metric codes, widely known as Gabidulin rank-metric codes, introduced independently by Gabidulin [7] in 1985 and Roth [28] in 1991. A Gabidulin rank-metric code \(\mathcal {C}\) of length n and dimension k may be defined as a k-dimensional subspace of the n-dimensional vector space \({\mathbb F}_{q^m}^n\) over \({\mathbb F}_{q^m}\). In this case, the rank-analogue of the Hamming metric is defined as follows. Fix a basis B of \(\mathbb {F}_{q^m}\) over \({\mathbb F}_q\) to interpret a vector \(\underline{v} \in {\mathbb F}_{q^m}^n\) as an \((m \times n)\)-matrix \({\mathbb A}_{\underline{v}}\) over \({\mathbb F}_q\). Now the rank distance between two codewords \(\underline{v}\) and \(\underline{w}\) is defined as \(d(\underline{v}, \underline{w}):= \mathop \text{rank}({\mathbb A}_{\underline{v}}-{\mathbb A}_{\underline{w}})\). For convenience we will set \(Q=q^m\). Hence the elements in \(\mathcal {C}\) are words in \(\mathbb {F}_{Q}^n\). In this paper we also consider the Gabidulin rank-metric code \(\mathcal {C}_r\), which is the set of all \(\mathbb {F}_{\tilde{Q}}\)-linear combination of words of \(\mathcal {C}\), where \(\tilde{Q}=Q^{r}\) for an arbitrary but fixed positive integer r, equipped with the rank metric. This code is referred to as the extension of \(\mathcal {C}\) to \(\mathbb {F}_{\tilde{Q}}\) and denoted by \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\) (or \(\tilde{\mathcal {C}}\), in short) analogous to the case of Hamming metric codes as considered in [16, 22]. These terms will be reintroduced in the beginning of Sect. 4, when they are used for the first time.

For a linear block code C over \({\mathbb F}_q\) and its extension \(C \otimes _{{\mathbb F}_q} \mathbb {F}_{Q}\) for some \(Q = q^m\) with any positive integer m, it is shown in [22] that the number \(A_{C,j}(Q)\) of codewords of Hamming weight j in the code \(C \otimes _{{\mathbb F}_q} \mathbb {F}_{Q}\) is a polynomial in Q. Later, in [16], one generalized the weight polynomials to matroids. Following the work on the connection between generalized weights of a Hamming metric code C and Betti numbers of certain associated matroid M as established in [18], an expression for \(A_{C,j}(Q)\) or more generally, for the generalized weight polymials \(P_{M,j}(Q)\) of a matroid M, is provided in terms of Betti numbers associated to the Stanley–Reisner ring of the matroid M and its elongations. On the other hand, recently a study on determining the singular homology of q-complexes associated to q-matroids has been initiated in [10]. This work is towards a topological approach to connect the generalized rank weights of a rank metric code with homological invariants of the associated q-matroid. This led us to study the q-matroids associated to Gabidulin rank metric codes and their lattices of cycles and flats with a view towards a combinatorial approach to express generalized rank weights and related polynomials in terms of homology of the associated q-matroids.

In this paper, we prove rank-analogues of some classical results for Gabidulin rank-metric codes. To each Gabidulin rank-metric code \(\mathcal {C}\), we associate q-matroids \({\mathcal {M}_{\mathcal {C}}}\) and \(\mathcal {M}_{\mathcal {C}}^*\) as introduced in [24]; which can be viewed as q-analogues of matroids derived from generator matrices and parity check matrices, respectively, for block codes with the Hamming metric. To \({\mathcal {M}_{\mathcal {C}}}\) we furthermore associate a classical matroid \(Cl({\mathcal {M}_{\mathcal {C}}})\) (also mentioned in [24]). We study resolutions of the Stanley–Reisner ring of the independence complexes of the dual classical matroid \(Cl({\mathcal {M}_{\mathcal {C}}})^*\), and the possible elongations of that matroid. We show how the rank-weight distribution of the code \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\) can be determined by the \(\mathbb {N}\)-graded Betti numbers of the Stanley–Reisner ring corresponding to these resolutions. Furthermore, we generalize the results for arbitrary q-matroids by introducing generalized weight polynomials \(P_{\mathcal {M},j}\) for a q-matroid \(\mathcal {M}\).

Moreover, we show that the following three pieces of information are equivalent: The weight distribution \(A_{\mathcal {C},j}(Q^r)\) for all jr, the higher weight spectra \(A^{(i)}_{Q,j}\) (the weight distributions for \(F_Q\)-subspaces of \(\mathcal {C}\) of dimension i) of \(\mathcal {C}\) for all ij, and all the \(\phi ^{(l)}_{j}\) (certain alternating functions for \(Cl({\mathcal {M}_{\mathcal {C}}})^*\) for all il). This result is a perfect analogue of a corresponding result for usual Hamming block codes and its associated matroids, see [20, Cor. 17]. In particular we like to emphasize how the higher rank-weight spectra (for subcodes of all dimensions) of \(\mathcal {C}\) follow from the rank-weight distribution of \(\tilde{C}\).

A key observation that plays an instrumental role throughout this article is the isomorphism between the lattice of q-flats of the q-matroid \({\mathcal {M}_{\mathcal {C}}}\) (resp. lattice of q-cycles of \(\mathcal {M}_{\mathcal {C}}^*\)) and the lattice of flats of the matroid \(Cl({\mathcal {M}_{\mathcal {C}}})\) (resp. lattice of cycles of \(Cl({\mathcal {M}_{\mathcal {C}}})^*\)). Moreover, it is well known (see for example [29, p. 57] and [17, p. 6]) that all the Betti numbers of the Stanley–Reisner rings of \(Cl({\mathcal {M}_{\mathcal {C}}})^*\) and its elongations can be given by concrete Möbius functions of the lattice of flats of \(Cl({\mathcal {M}_{\mathcal {C}}})\) and its various truncations and sublattices. We use this fact to show that sometimes it is more convenient to work directly with the lattice of q-flats of \({\mathcal {M}_{\mathcal {C}}}\) or the opposite lattice, i.e., of q-cycles of \(\mathcal {M}_{\mathcal {C}}^*\).

It is important to mention that alternative methods for determining weight distribution and higher weight spectra is given in [4, 5] for the more general notion of Delsarte rank-metric codes. Thus we get a variation of ways to retrieve the triple set of information described above for Gabidulin rank-metric codes; one from resolutions of Stanley–Reisner rings, and one from a direct study of lattices in addition to techniques described by the authors in [4, 5] using zeta functions.

The paper is organized as follows. In the next section, we collect some preliminaries and recall basic definitions regarding notions like (q-)matroids, (qm)-polymatroids, and Stanley–Reisner rings associated to matroids. In Sect. 3 we show how the generalized weights of Gabidulin rank-metric codes, more generally for q-matroids, can be expressed by invariants derived from the mentioned Stanley–Reisner rings. We consider the extended codes \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\) in Sect. 4 and give expressions for their rank-weight distributions using the classical matroids associated to the q-matroids corresponding to the codes. Our main results (Theorems 64 and 70 and Corollary 71) determining generalized rank weights and higher weight spectra of \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\), and more generally, the weight polynomials for q-matroids in terms of Betti numbers, are derived in Sect. 5. In Sect. 6 we demonstrate our main results with an example and also show how the weight distribution of uniform q-matroids can be determined directly from its lattice of q-flats. We end this article with a retrospective look in Sect. 7 where we define a new concept called virtual Betti numbers for lattices satisfying the Jordan–Dedekind property.

2 Preliminaries

Throughout this paper q denotes a power of a prime number and \({\mathbb F}_q\) the finite field with q elements. We fix a positive integer n, and denote by E the set \(\{1,\ldots ,n\}\) and by \(\mathcal {E}\) the n-dimensional vector space \({\mathbb {F}}_q^n\) over \({\mathbb F}_q\). By \(\Sigma (\mathcal {E})\) we denote the set of all subspaces of \(\mathcal {E}\). We use [j] to denote the quantity \( q^{n-1}+q^{n-2}+\cdots +q^{n-j}\) for any \(j=1,\ldots ,n\). We denote by \(\mathbb {N}_0\) the set of all nonnegative integers, and by \(\mathbb {N}\) the set of all positive integers.

In this section, we recall basic definitions and results concerning matroids, their associated Stanley–Reisner rings, and their q-analogues, i.e., (qm)-polymatroids and q-matroids.

2.1 Matroids

There are many cryptomorphic definitions of a matroid [32]. Here we record the one in terms of rank function:

Definition 1

A matroid is a pair \((E,\mathbf {r})\) where E is a finite set and \(\mathbf {r}: 2^E \rightarrow \mathbb {N}_0\) is a function satisfying:

  1. (R1)

    If \(X \subseteq E\), then \(0 \leqslant \mathbf {r}(X) \leqslant |X|\),

  2. (R2)

    If \(X \subseteq Y \subseteq E\), then \(\mathbf {r}(X) \leqslant \mathbf {r}(Y)\),

  3. (R3)

    If XY are subsets of E, then

    $$\begin{aligned}\mathbf {r}(X \cap Y) + \mathbf {r}(X \cup Y) \leqslant \mathbf {r}(X)+\mathbf {r}(Y).\end{aligned}$$

The function \(\mathbf {r}\) is called the rank function of the matroid. The rank of a matroid \(M=(E,\mathbf {r})\) is \(\mathbf {r}(E)\). The nullity function \({\textbf {n}}\) of the matroid is given by \({\textbf {n}}(X) = |X|-\mathbf {r}(X)\) for \(X \subseteq E\). By (R1), this is an integer-valued non-negative function on \(2^E\).

Next we recall the notions of flats and cycles of a matroid, which play a central role in this paper.

Definition 2

Let \(M=(E,\mathbf {r})\) be a matroid. A flat of the matroid is a subset \(F \subseteq E\) satisfying

$$\begin{aligned} \ \mathbf {r}(F \cup \{x\}) = \mathbf {r}(F) +1, \text { for all } x \in E\backslash F. \end{aligned}$$

From the definition, it follows easily that E is a flat itself. Also, for \(X \subseteq E\), the smallest flat containing X is the set \(Y=\{x \in E,\ \mathbf {r}(X \cup \{x\}) = \mathbf {r}(X)\}\) and moreover, \(\mathbf {r}(Y)=\mathbf {r}(X)\). The intersection of two flats is a flat.

Definition 3

Let \(M=(E,\mathbf {r})\) be a matroid, and \({\textbf {n}}\) be its nullity function. For \(0 \leqslant i \leqslant {\textbf {n}}(E)\), let

$$\begin{aligned}\mathcal {N}_i =\{X \subseteq E,\ {\textbf {n}}(X)=i\}\end{aligned}$$

and let \(N_i\) be the set of minimal elements of \(\mathcal {N}_i\) with respect to inclusion. Then the elements of \(N_i\) are called cycles of M of nullity i. Cycles of nullity 1 are called circuits.

It is proved in [18, Sect. 3] that the cycles of a matroid are union of circuits, and of course, by definition, \(\emptyset \) is a cycle (of nullity 0).

Definition 4

Let \(M=(E,\mathbf {r})\) be a matroid. The dual matroid of M is the matroid \(M^*=(E,\mathbf {r}^*)\) with

$$\begin{aligned} \mathbf {r}^*(X) := |X|+\mathbf {r}(E\setminus X)-\mathbf {r}(E). \end{aligned}$$

It is well known that there is a one to one correspondence between the flats of a matroid and the cycles of its dual, namely, F is a flat of M if and only if \(E \setminus F\) is a cycle of \(M^*\).

Definition 5

Let \(M=(E,\mathbf {r})\) be a matroid. The \(l{{\text {th}}}\) truncation of M is the matroid \(M_{(l)}=(E,\mathbf {r}_{(l)})\) where

$$\begin{aligned}\mathbf {r}_{(l)}(X):= \min \{\mathbf {r}(M)-l, \mathbf {r}(X)\},\end{aligned}$$

for any subset \(X \subseteq E\) and \(0 \le l \le \mathbf {r}(M),\) and the \(l{{\text {th}}}\) elongation of M is the matroid \(M^{(l)}=(E,\mathbf {r}^{(l)})\), where

$$\begin{aligned} \mathbf {r}^{(l)}(X) := \min \{|X|, \mathbf {r}(X)+ l\} \end{aligned}$$

for any subset \(X \subseteq E\) and \(0 \le l \le n- \mathbf {r}(M)\).

Note that \((M^*)^{(l)}=(M_{(l)})^*\), and \((M^*)_{(l)}=(M^{(l)})^*\), and that the flats of \(M_{(l)}\) are exactly the flats of M except those of rank \(\mathbf {r}(M)-1,\ldots ,\mathbf {r}(M)-l\), and that the cycles of \(M^{(l)}\) are those of M except those of nullity \(1,2,\ldots , l\).

2.2 Stanley–Reisner resolutions

Any matroid \(M=(E,\mathbf {r})\) gives rise to a simplicial complex \(\Delta _M\) of independent sets, i.e., the faces of the complex are given by

$$\begin{aligned} \mathcal {F} = \{ X \subseteq E,\ \mathbf {r}(X)=|X|\}. \end{aligned}$$

If \(\mathbb {K}\) is a field, we can associate to the underlying simplicial complex a monomial ideal \(I_M \subseteq S=\mathbb {K}[X_e, e \in E]\) defined by

$$\begin{aligned} I_M = <X^\sigma : \sigma \not \in \mathcal {F}>, \end{aligned}$$

where \(X^\sigma =\prod _{e \in \sigma }X_e\). We refer to [14] for the study of such ideals. The Stanley–Reisner ring of the matroid is then the quotient \(S_M=S/I_M\). This ring has minimal \(\mathbb {N}^{|E|}\) and \(\mathbb {N}\) graded free resolutions and as described in [18], they are of the form

$$\begin{aligned} 0 \leftarrow S_M \leftarrow S \leftarrow \bigoplus _{{\alpha \in N_1}}S(-\alpha )^{\beta _{1,\alpha }} \leftarrow \cdots \leftarrow \bigoplus _{\alpha \in N_{n-\mathbf {r}(M)}}S(-\alpha )^{\beta _{|E|-\mathbf {r}(M),\alpha }} \leftarrow 0 \end{aligned}$$

and

$$\begin{aligned} 0 \leftarrow S_M \leftarrow S \leftarrow \bigoplus _{j \in \mathbf {N}}S(-j)^{\beta _{1,j}} \leftarrow \cdots \leftarrow \bigoplus _{j \in \mathbf {N}}S(-j)^{\beta _{|E|-\mathbf {r}(M),j}} \leftarrow 0. \end{aligned}$$

It is known, in particular, that the numbers \(\beta _{i,\alpha }(M)=\beta _{i,\alpha }\) are independent of the minimal free resolution, and when the simplicial complex comes from a matroid (as in our case), also independent of the field \(\mathbb {K}\). As one sees \(\beta _{i,j}(M)=\beta _{i,j}=\Sigma _{|\alpha |=j}\beta _{i,\alpha },\) for all ij.

Such Betti numbers, for matroids being specified later, will be instrumental for our main results.

Definition 6

For ijl in question, given a matroid M, we let \(\beta ^{(l)}_{i,j}(M)\) be the \(\mathbb {N}\)-graded graded Betti number of the \(l{\text {th}}\) elongation matrix \(M^{(l)}\).

In particular, \(\beta ^{(0)}_{i,j}(M)=\beta _{i,j}(M) (\) If M is fixed, we just write \(\beta ^{(l)}_{i,j}\) for \(\beta ^{(l)}_{i,j}(M)\).)

2.3 q-Matroids and (qm)-polymatroids

For \(X\in \Sigma (\mathcal {E})\), we denote by \(X^{\perp }\) the dual of X (with respect to the standard dot product), i.e., \(X^{\perp } = \{\mathbf {x} \in \mathcal {E}: \mathbf {x} \cdot \mathbf {y} = 0 \text { for all } \mathbf {y} \in X\}\). It is elementary and well-known that \(X^{\perp }\in \Sigma (\mathcal {E})\) with \(\dim ~ X^{\perp } = n - \dim ~ X\) and \((X^{\perp })^{\perp } = X\), although \(X\cap X^{\perp }\) need not be equal to \(\{\mathbf {0}\}\), but of course \(\mathcal {E}^\perp = \{\mathbf {0}\}\).

The first part of the following key notion is due to [29, Definition 2].

Definition 7

A (qm)-polymatroid is an ordered pair \(\mathcal {M}= (\mathcal {E},\rho )\) consisting of the vector space \(\mathcal {E}=\mathbb {F}_q^n\) and a function \(\rho :\Sigma (\mathcal {E})\rightarrow \mathbb {N}_0\) satisfying (P1)–(P3) below:

  1. (P1)

    \(0\le \rho (X) \le m\dim X\) for all \(X \in \Sigma (\mathcal {E})\);

  2. (P2)

    \(\rho (X) \le \rho (Y)\) for all \(X,Y \in \Sigma (\mathcal {E})\) with \(X \subseteq Y\);

  3. (P3)

    \(\rho (X+Y)+\rho (X \cap Y) \le \rho (X)+\rho (Y)\), for all \(X,Y \in \Sigma (\mathcal {E})\).

The function \(\rho \) is called the rank function of the (qm)-polymatroid. The rank of a (qm)-polymatroid \(\mathcal {M}=(\mathcal {E},\rho )\) is \(rank(\mathcal {M}) = \rho (\mathcal {E})\). The nullity function \(\eta \) of the (qm)-polymatroid is given by \(\eta (X) = m \dim _{{\mathbb F}_q} X-\rho (X)\) for \(X \in \Sigma (\mathcal {E})\). By (P1), this is an integer-valued non-negative function on \(\Sigma (\mathcal {E})\).

To us the following special case will be the most important one:

Definition 8

A q-matroid is a (q, 1)-polymatroid.

Definition 9

Let \(\mathcal {M}=(\mathcal {E},\rho )\) be a (qm)-polymatroid. The dual (qm)-polymatroid of \(\mathcal {M}\) is the (qm)-polymatroid \(\mathcal {M}^*=(\mathcal {E},\rho ^*)\) with

$$\begin{aligned} \rho ^*(X) = m\dim X +\rho (X^{\perp })-\rho (\mathcal {E}). \end{aligned}$$

The dual of a q-matroid is obtained from the case \(m=1.\)

Definition 10

Let \(\mathcal {M}=(\mathcal {E},\rho )\) be a q-matroid. Then a subspace \(F \subseteq \mathcal {E}\) is called a q-flat if \(\rho (F \oplus \langle e \rangle ) > \rho (F)\) for all \(e \in E \backslash F\).

Definition 11

Let \(\mathcal {M}=(\mathcal {E},\rho )\) be a q-matroid, and \(\eta \) be its nullity function, i.e., \(\eta (X) = \dim _{{\mathbb F}_q}X-\rho (X)\) for all \(X \in \Sigma (\mathcal {E})\). For \(0 \leqslant i \leqslant \eta (\mathcal {E})\), a subspace \(X \subseteq \mathcal {E}\) of nullity i is called a q-cycle of \(\mathcal {M}\) if X is minimal in \(\mathcal {N}_i\) w.r.t. inclusion, where

$$\begin{aligned} \mathcal {N}_i =\{X \in \Sigma (\mathcal {E}),\ \eta (X)=i\}. \end{aligned}$$

The q-cycles of nullity 1 are called q-circuits.

Remark 12

(qm)-flats and (qm)-cycles can be defined in analogous ways for (qm)-polymatroids in general, but we will only treat the case \(m=1\) in what follows.

We then have:

Lemma 13

Let \(\mathcal {M} = (\mathcal {E},\rho )\) be a q-matroid. Then \(X \in \Sigma (\mathcal {E})\) is a q-flat (of rank r) of a q-matroid \(\mathcal {N}\) if and only if its orthogonal complement \(X^{\perp }\) is a q-cycle (of nullity \(\rho (\mathcal {M})-r\)) for \(\mathcal {M}^*\).

Proof

Let X be a q-flat of a q-matroid \(\mathcal {M}\) of rank r. From the definition of q-cycle, any subspace strictly contained in a q-cycle A have nullity strictly less the nullity of A, which we assume to be a.

Then from the identity, \( \rho ^*(X) = \dim ~ X + \rho (X^\perp ) - \rho (\mathcal {E})\), it is clear that if any space of the form \(X\oplus \langle v\rangle \) has rank strictly greater than that of X, the nullity of any subspace B of \(X^\perp \) of codimension 1 should be strictly one less than that of \(X^\perp \). So if X is a q-flat, then \(X^\perp \) is a q-cycle. Similar logic proves the converse also.

Since \(\eta ^*(X^\perp ) = \dim ~ X^\perp - \dim ~ X^\perp - \rho (X) + \rho (\mathcal {E}) = \rho (\mathcal {M}) - \rho (X)\), it shows that for a q-flat X of rank r its orthogonal complement \(X^\perp \) is a q-cycle of \(\mathcal {M}^*\) of nullity \(\rho (\mathcal {M}) - r\). \(\square \)

We now introduce an important definition, essentially taken from [24]:

Definition 14

For every q-matroid \(\mathcal {\mathcal {M}}=(\mathcal {E},\rho )\), we associate a pair

$$\begin{aligned} Cl(\mathcal {M})=(P(\mathcal {E}),\mathbf {r}_{\rho }), \end{aligned}$$

where \(P(\mathcal {E})\) is the set of all 1-dimensional subspaces of \(\mathcal {E}={\mathbb F}_q^n\), in other words, \(P(\mathcal {E})\) is the projectivization of \(\mathcal {E}\) with \( |P(\mathcal {E})| = \frac{q^n-1}{q-1}=q^{n-1}+q^{n-2}+\cdots +1.\) Moreover, for \(S \subseteq P(\mathcal {E})\), we set:

$$\begin{aligned} \mathbf {r}_{\rho }(S):= \rho (\langle S \rangle ), \end{aligned}$$

where \(\langle S \rangle \) is the (affine) subspace in \(\mathcal {E}={\mathbb F}_q^n\), spanned by the 1-dimensional subspaces of \(\mathcal {E}\) in S.

Proposition 15

For every q-matriod \(\mathcal {M}=(\mathcal {E},\rho )\), the pair \(Cl(\mathcal {M})=(P(\mathcal {E}),\mathbf {r}_{\rho })\) is a matroid.

Proof

Properties (R1) and (R2) follow directly from the properties (P1) and (P2) of Definition 7, respectively. To prove (R3), we take \(X,~Y \subseteq P(\mathcal {E})\) and verify:

$$\begin{aligned}&\mathbf {r}_{\rho }(X \cap Y)+\mathbf {r}_{\rho }(X \cup Y)\\&\quad =\rho (\langle X \cap Y \rangle + \rho (\langle X \cup Y \rangle )\\&\quad =\rho (\langle X \rangle \cap \langle Y \rangle )+\rho (\langle X\rangle + \langle Y \rangle )\\&\quad \le \rho (\langle X \rangle ) +\rho (\langle Y \rangle ) \qquad (\text {by P3})\\&\quad \le \mathbf {r}_{\rho }(X)+\mathbf {r}_{\rho }(Y). \end{aligned}$$

\(\square \)

Furthermore, we observe:

Lemma 16

Let \(\mathcal {M} = (\mathcal {E},\rho )\) be a q-matroid and \(Cl(\mathcal {M}) = (P(\mathcal {E}), \mathbf {r}_{\rho })\) be the classical matroid associated to \(\mathcal {M}\). Then \(S \subseteq P(\mathcal {E})\) is a flat with rank \(\mathbf {r}(S)=r\) for \(Cl(\mathcal {M})\) if and only if it is of the form P(F) for some q-flat F of \(\mathcal {M}\) of q-rank \(\rho (F)=r\).

Proof

If \(X=P(F)\) for some q-flat F, and \(y \in P(\mathcal {E})-X\), then \(\mathbf {r}(X \cup \{y\}) = \rho (F \oplus \langle y \rangle )>\rho (F)=\mathbf {r}(X),\) so X is a flat.

If X is not of the form P(F) for F a q-flat, then \(X=P(G)\) for G not a q-flat, or X is not of the form P(H) for any \(G \in \Sigma (\mathcal {E})\). If \(X=P(G)\) for G not a q-flat, then there exists e such that \(\rho (G \oplus \langle e \rangle )=\rho (G)\). Then \(\mathbf {r}(P(G \oplus \langle e \rangle ))=\rho (G \oplus \langle e \rangle )=\rho (G)=\mathbf {r}(X)\), so X is not a flat.

If X is not of the form P(G) for any \(G\in \Sigma (\mathcal {E})\), then X is strictly contained in \(Y=Span(X)\) in \(P(\mathcal {E})\). Hence: \(\mathbf {r}(X)=\rho (\langle X \rangle )=\rho (\langle Y \rangle )=\mathbf {r}(Y)\), and so X is not a flat. \(\square \)

Definition 17

Let \((E,\mathcal {R})\) be a poset. The opposite of a poset \((E,\mathcal {R})\) is the poset \((E,\mathcal {S})\) where \(x \mathcal {S} y \Leftrightarrow y \mathcal {R} x.\)

Definition 18

  1. (i)

    Let \((E,\mathcal {R})\) be a finite poset. A chain C in E is a totally ordered subset of E (meaning \(a \mathcal {R} b\) or \(b \mathcal {R} a\) for ab in C).

  2. (ii)

    The length of a chain is equal to the cardinality of the chain minus 1. The length of a finite poset is the maximal length of chains in the poset.

  3. (iii)

    If the poset has the Jordan–Dedekind property (meaning: all maximal chains have the same length), then the rank of an element \(x \in E\) is the length of the poset \(([0,x],\mathcal {R})\).

Definition 19

A finite lattice is a finite poset \(P=(E,\mathcal {R})\), where there exists a maximal element, denoted by 1, a minimal element, denoted by 0, and for any two elements \(a,b \in E\), there exists a least upper bound (or join) \(a \vee b\) and a greatest lower bound (or meet) \(a \wedge b\). An atom is a minimal element of the subset \(E\backslash \{0\}\).

The opposite lattice \(P^*\) of a lattice P satisfies \(0_{P^*}=1_P\), \(1_{P^*}=0_P\), \(a \vee _{P^*} b = a \wedge _P b\) and \(a \wedge _{P^*} b = a \vee _P b\).

Let M be a matroid on the ground set E. It is well known that the set of flats of M is a lattice, where the order is the inclusion order. Moreover, it is well known that this lattice has the Jordan–Dedekind property, and therefore has a well-defined rank function. The minimal element of the lattice is the closure of \(\emptyset \), its maximal element is E, while the meet of two flats is their intersection, and the join is the closure of their union.

Definition 20

A geometric lattice is a finite lattice having the Jordan–Dedekind property, and where its rank function, say r, satisfies:

  • It is atomistic, i.e., every element is a supremum of a set of atoms.

  • It is semimodular, i.e.,\(r(x \wedge y) + r( x \vee y) \le r(x) + r(y).\)

It is well known that the flats of a matroid constitute a geometric lattice, where the rank function of the lattice corresponds to the rank function of the matroid, for each flat.

Lemma 16 has the following immediate, probably well known, consequence:

Proposition 21

  1. (a)

    As posets ordered by inclusion, the set of flats of \(Cl(\mathcal {M})\), and the set of q-flats of \(\mathcal {M}\) are isomorphic.

  2. (b)

    The posets of cycles of \(Cl(\mathcal {M})^*\) and q-cycles of \(\mathcal {M}^*\) are isomorphic.

  3. (c)

    The poset of q-flats of \(\mathcal {M}\) constitute a geometric lattice.

Proof

  1. (a)

    From Lemma 16 there is a bijection between the flats of \(Cl(\mathcal {M})\) and the flats of \(\mathcal {M}\). Since it is inclusion-preserving, the lattices are isomorphic.

  2. (b)

    This holds since by (a) their opposite lattices are isomorphic.

  3. (c)

    This holds by (a), since the flats of \(Cl(\mathcal {M})\) are well known to do so.

\(\square \)

3 Generalized weights of q-matroids and Betti numbers

In this section, we consider rank-metric codes and their corresponding (qm)-polymatroids and q-matroids. The main result of this section gives a relation between generalized rank weights of Gabidulin rank-metric codes with Betti numbers of certain classical matroids associated to the q-matroids corresponding to the codes.

Let \({\mathbb M}_{m\times n}({\mathbb F}_q)\), or simply \({\mathbb M}\), denote the space of all \(m\times n \) matrices with entries in the finite field \({\mathbb F}_q\). Note that \({\mathbb M}\) is a vector space over \({\mathbb F}_q\) of dimension mn.

Definition 22

  1. (a)

    By a Delsarte rank-metric code, or simply, a Delsarte code, we mean a \({\mathbb F}_q\)-linear subspace of \({\mathbb M}\).

  2. (b)

    By a Gabidulin rank-metric code, or a vector rank-metric code, we mean a k-dimensional \(\mathbb {F}_{q^m}\)-linear space \(\mathcal {C}\) in \(\mathbb {F}_{q^m}^n\).

A Gabidulin rank-metric code \(\mathcal {C}\) is also then a \(K=km\)-dimensional linear code over \({\mathbb F}_q\). This can be viewed as a special case of a Delsarte code in the following way: Fix once and for all an \({\mathbb F}_q\)-basis \(B=\{b_1,\ldots ,b_m\}\) of \(\mathbb {F}_{q^m}\). Therefore, any element \(a \in \mathbb {F}_{q^m}\) can be uniquely written as \(a_1b_1+\cdots a_mb_m\) and represented by a column vector \((a_1,\ldots ,a_m)^t\). In a similar way, any codeword \(c = (w_1,\ldots ,w_n)\in \mathbb {F}_{q^m}^n\) can be represented as an \(m \times n\)-matrix \(M_B(c)=\begin{pmatrix} w_{1,1} &{} \cdots &{} \cdots &{} w_{n,1} \\ \cdots &{} &{} \cdots &{}\cdots \cdots \\ \cdots &{} &{} \cdots &{}\cdots \cdots \\ w_{1,m} &{} \cdots &{} \cdots &{} w_{m,n} \end{pmatrix}\).

Following Shiromoto [29], we associate to a Delsarte code (resp. Gabidulin rank-metric code) \(\mathcal {C}\), a family \(\{\mathcal {C}(X):X \in \Sigma (\mathcal {E})\}\) of subcodes of \(\mathcal {C}\), and a (qm)-polymatroid (resp. q-matroid) as follows.

Definition 23

  1. (a)

    Let \(\mathcal {C}\subseteq {\mathbb M}_{m\times n}({\mathbb F}_q)\) be a Delsarte code. Given any \(X\in \Sigma (\mathcal {E})\), \(\mathcal {C}(X)\) is defined to be the subspace of \(\mathcal {C}\) consisting of all matrices in \(\mathcal {C}\) with row spaces contained in X. Let \(\rho ^{1}_\mathcal {C}\) : \(\Sigma (\mathcal {E}) \longrightarrow \mathbb {N}_0\) be the function defined as

    $$\begin{aligned} \rho ^{1 }_\mathcal {C}(X)=\dim _{\mathbb {F}_q}\mathcal {C}-\dim _{\mathbb {F}_q}\mathcal {C}(X^{\perp }) \quad \text { for } X \in \Sigma (\mathcal {E}). \end{aligned}$$
  2. (b)

    Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \({\mathbb F}_{q^m}/{\mathbb F}_q\). With respect to the fixed \({\mathbb F}_q\)-basis B of \({\mathbb F}_{q^m}\), we consider the respresentation of codewords by matrices. Then for any \(X \in \Sigma (\mathcal {E})\), \(\mathcal {C}(X)\) is defined similar to the case of Delsarte codes. Let \(\rho _\mathcal {C}\) : \(\Sigma (\mathcal {E}) \longrightarrow \mathbb {N}_0\) be the function defined as

    $$\begin{aligned} \rho _{\mathcal {C}}(X)=\dim _{\mathbb {F}_{q^m}}\mathcal {C}-\dim _{\mathbb {F}_{q^m}}\mathcal {C}(X^{\perp }). \end{aligned}$$

Proposition 24

The pair \((\mathcal {E},\rho ^{1}_\mathcal {C})\) is a (qm)-polymatroid, and the pair \((\mathcal {E},\rho _{\mathcal {C}})\) is a q-matroid.

Proof

The first statement is proved in [29], and the second one then follows automatically, since \(\rho _{\mathcal {C}}(X)=\frac{\rho ^1_\mathcal {C}(X)}{m}\). \(\square \)

It is important to note that q-matroids associated to Gabidulin rank-metric codes were first defined in [23, Definition 22 and Theorem 24] and the q-matroid in [23] is the same as \((\mathcal {E},\rho _{\mathcal {C}})\) in Proposition 24.

Remark 25

We note that the nullity function \((\eta _{\mathcal {C}}^1)^* \) of the dual (qm)-polymatroid of \((\mathcal {E},\rho _C^1)\) satisfies:

$$\begin{aligned} (\eta _{\mathcal {C}}^1)^* (X) = \dim _{F_{q}}\mathcal {C}(X) \quad \text {for } X \in \Sigma (\mathcal {E}). \end{aligned}$$
(1)

for a Delsarte code, and that the nullity function \((\eta _\mathcal {C})^*\) of the dual of the q-matroid \((\mathcal {E},\rho _{\mathcal {C}})\) then is given by

$$\begin{aligned} (\eta _\mathcal {C})^* (X) = \dim _{F_{q^m}}\mathcal {C}(X) \quad \text {for } X \in \Sigma (\mathcal {E}). \end{aligned}$$
(2)

for a Gabidulin rank-metric code.

Definition 26

Let \(\mathcal {C}\subseteq {\mathbb F}_{q^m}^n\) be a Gabidulin rank-metric code of length n and dimension k over the extension \({\mathbb F}_{q^m}/{\mathbb F}_q\). Let d be the minimum rank distance of \(\mathcal {C}\). If \(d = n-k+1\), then \(\mathcal {C}\) is called a maximum rank distance (MRD) code.

Next we recall the very first construction of MRD codes, independently given by Gabidulin [7] and Delsarte [6].

Example 27

Let mnk be positive integers such that \(m \ge n \ge k\). If we consider \(\mathbf {a} = (a_1, \ldots , a_n) \in {\mathbb F}_{q^m}^n\) such that \(\{a_i : i = 1, \ldots , n \}\) is a linearly independent set over \({\mathbb F}_q\), then \({\mathbb F}_{q^m}\)-linear code generated by the following matrix \(\mathbf {G}\) is an MRD code of length n and dimension k.

$$\begin{aligned} \mathbf {G} := \begin{pmatrix} a_1 &{} a_2 &{} \hdots &{} a_n \\ a_1^q &{} a_2^q &{} \hdots &{} a_n^q \\ \vdots &{} \vdots &{} \ddots &{} \vdots \\ \quad a_1^{q^{k-1}} &{} \quad a_2^{q^{k-1}} &{} \hdots &{}\quad a_n^{q^{k-1}} \\ \end{pmatrix}. \end{aligned}$$

(See, for example, [7] and [26, Sect.  2] for the definition and basic facts about MRD codes.)

Example 28

Assume for simplicity that \(m \ge n\). Let \(\mathcal {C}\subseteq {\mathbb M}_{m\times n}({\mathbb F}_q)\) be an MRD code of dimension K over \({\mathbb F}_q\). Such a \(\mathcal {C}\) is a Delsarte code such that \(K = \dim _{F_q}\mathcal {C}\) is divisible by m and \(\mathcal {C}(X)=\{0\}\) for all subspaces X of E with \(\dim _{F_q}X \le n-\frac{K}{m}\). The latter follows, for instance, from [11, Proposition 6.2]. Thus \(\rho ^{1}_\mathcal {C}(Y) =K\) if \(Y\in \Sigma (\mathcal {E})\) with \(\dim _{F_q}Y \ge K/m\), and hence \(\rho _\mathcal {C}(Y) =k.\) Further, in view of [11, Theorem 6.4], we see that \(\rho _\mathcal {C}(Y) =\dim _{F_q}Y\) if \(Y\in \Sigma (\mathcal {E})\) with \(\dim _{F_q}Y \le K/m\). It follows that \((\mathcal {E},\rho _{\mathcal {C}})\) is the uniform q-matroid U(kn) (i.e. the q-matroid with rank function \(\rho (X)=\min \{\dim (X),k\}.\)

Now we recall the definition of generalized rank weights of Gabidulin rank-metric codes in terms of nullity function of the corresponding (dual) q-matroids. The following definition is from [23] where the authors prove its equivalence with the other existing definitions.

Definition 29

[23, Definition 5] Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \({\mathbb F}_{q^m}/{\mathbb F}_q\).

  1. (a)

    The rank support Rsupp(c) of any codeword \(c \in \mathcal {C}\) is the \({\mathbb F}_q\)-linear row space of \(M_B(c)\) (the matrix representation of c, as in the text following Definition 22.) For a subcode \({\mathcal D}\) of \(\mathcal {C}\), its rank support \(Rsupp({\mathcal D})\) is the \(F_q\)-linear span of the set \(\{Rsupp(d) : d \in {\mathcal D}\}\).

  2. (b)

    Let \(\dim _{{\mathbb F}_{q^m}}{\mathcal {C}} = k\). Then for \(1 \le r \le k\), the r-th generalized rank weight of \(\mathcal {C}\) is defined as

    $$\begin{aligned}d_r(\mathcal {C})=\min \{\dim _{\mathbb {F}_{q}}Rsupp({\mathcal D}), {\mathcal D}\text { is a subcode of } \mathcal {C}\text { with } \dim _{{\mathbb F}_{q^m}}({\mathcal D})=r\}.\end{aligned}$$

Remark 30

In this article, we define the rank support using row spaces, irrespective of \(m \ge n\) or \(m<n.\) This is following the definition by Shiromoto in [29] (where one uses column spaces, but of the transposes of our matrices) and thereafter, in [8]. As proved in [8, Theorem 37], this \(d_r(\mathcal {C})\) matches with Ravagnani’s definition of generalized weights for Delsarte codes in [27] only if \(m > n\).

Then we express the generalized rank weights in terms of the nullity function of dual q-matroid associated to the code :

Proposition 31

For a Gabidulin rank-metric code \(\mathcal {C}\) over \({\mathbb F}_{q^m}/{\mathbb F}_q\), the r-th generalized rank weight is

$$\begin{aligned} {d}_r= \min \{\dim _{{\mathbb F}_q} X : X \in \Sigma \text { with } \eta _{\mathcal {C}}^*(X) \ge r \}. \end{aligned}$$

Proof

Following the definitions of \(\mathcal {C}(X)\) in Definition 23 and \(d_r\) in Definition 29(b), we have

$$\begin{aligned} d_r(\mathcal {C}) = \min \{\dim _{{\mathbb F}_q}X : X\in \Sigma (\mathcal {E}) \text { with } \dim _{{\mathbb F}_{q^m}}\mathcal {C}(X) \ge r\}. \end{aligned}$$

Therefore, the statement follows from Remark 25, since \(\eta _{\mathcal {C}}^*(X) =\dim _{{\mathbb F}_{q^m}}\mathcal {C}(X)\). \(\square \)

Inspired by Remark 25 and Proposition 31 we have:

Definition 32

For any q-matroid \(\mathcal {M}=(\mathcal {E},\rho )\) we set

$$\begin{aligned} d_r(\mathcal {M})= \min \{\dim _{{\mathbb F}_q} X : X \in \Sigma \text { with } \eta ^*(X) \ge r ,\} \end{aligned}$$

where \(\eta ^*\) is the nullity function of the dual q-matroid \({\mathcal {M}}^*\).

It is clear from the above description that, for a Gabidulin rank-metric code \(\mathcal {C}\) (or more generally, for a q-matroid), the r-th generalized weight is equal to the smallest \({\mathbb F}_q\)-dimension of any q-cycle of nullity r of \({\mathcal {M}_{\mathcal {C}}}^*\). As an immediate consequence, we obtain:

Lemma 33

Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \({\mathbb F}_{q^m}/{\mathbb F}_q\) of dimension k. Then for any \(1 \le r \le k\), \({d}_r=n-m_r\), where \(m_r\) is the largest dimension over \({\mathbb F}_q\) of any q-flat of rank \(k-r\) for \({\mathcal {M}_{\mathcal {C}}}\).

Proof

This follows from Definition 32 and Lemma 13. \(\square \)

The next result provides a relation between the generalized rank weights of a Gabidulin rank-metric code \(\mathcal {C}\) and the cycles of the associated dual matroid \(Cl({\mathcal {M}_{\mathcal {C}}})^*\) of the corresponding q-matroid \({\mathcal {M}_{\mathcal {C}}}\).

Corollary 34

Let \(Cl(\mathcal {M})\) be the classical matroid associated to a q-matroid \(\mathcal {M} = (\mathcal {E},\rho )\).

  1. (a)

    Any cycle X of \(Cl(\mathcal {M})^*\) is the complement of projective spaces (when interpreting \(P(\mathcal {E})\) as projective \((n-1)\)-space). Its cardinality is \(q^{n-1}+q^{n-2}+\cdots +q^m\), for m the dimension of the flat F for for which the X is the complement of Cl(F).

  2. (b)

    For a Gabidulin rank-metric code \(\mathcal {C}\) we have that \({d}_r\) is equal to the smallest j such that there exists a cycle of nullity r and cardinality [j] for the matroid \((Cl((\mathcal {E},\rho _\mathcal {C}))^*\).

Proof

Part (a): This follows from Lemma 16. Proof of (b)

$$\begin{aligned} {d}_r&= \min \{\dim _{{\mathbb F}_q}X | \eta ^*(X) = r\}\\&= \min \{\dim _{{\mathbb F}_q} X |X \text { is a { q}-cycle of } ({{\mathcal {M}_{\mathcal {C}}}})^* \text { of nullity } r\}\\&= \min \{j |X^{\perp } \text { is a { q}-flat of } {\mathcal {M}_{\mathcal {C}}}\text { of rank } k-r \text { and dimension } n-j\},\\&\text { and, using Lemma} 16\, \text {again:}\\&=\min \{j |P(X^{\perp }) \text { is a flat of } Cl({\mathcal {M}_{\mathcal {C}}}) \text { of rank } k-r \text { and cardinality } q^{n-j-1} +\cdots +1\}\\&=\min \{j |P(X^{\perp })^c \text { is a cycle of } Cl({\mathcal {M}_{\mathcal {C}}})^* \text { of nullity } r \text { and cardinality } [j]\}. \end{aligned}$$

\(\square \)

We use this relation and the following result from [18] about classical matroids to express the generalized rank weights in terms of certain Betti numbers.

Theorem 35

[17, Theorem 2] Let \(M = (E, \mathbf {r})\) be a matroid on a finite set E and \(N_i(M)\) the set of cycles of M of nullity i. Then

$$\begin{aligned} \beta _{i, \sigma }(M) \ne 0 \text { if and only if } \sigma \in N_i(M). \end{aligned}$$

Theorem 36

For a Gabidulin rank-metric code \(\mathcal {C}\) we have that:

  1. (a)
    $$\begin{aligned} {d}_r= \min \{j | \beta _{r,[j]} \ne 0\}, \end{aligned}$$

    for the \(\mathbb {N}-\)graded Betti numbers of the Stanley–Reisner ring associated to the independence complex of the classical matroid \(Cl({\mathcal {M}_{\mathcal {C}}})^*\).

  2. (b)

    These \(\mathbb {N}-\)graded Betti numbers satisfy \(\beta _{r,s}=0\), for all \(s \le \frac{q^n-1}{q-1}\) where s is not of the form [j] for some j.

Proof

From Corollary 34 we have, can write,

$$\begin{aligned} {d}_r =\min \{j | \sigma \in N_r(Cl(\mathcal {M})^*) \text { and } |\sigma |=q^{n-1}+\ldots +q^{n-j} \}. \end{aligned}$$
(3)

Now Theorem 35 implies that \(\sigma \) is a cycle of \(Cl({\mathcal {M}_{\mathcal {C}}})^*\) of nullity r and of cardinality [j], if and only if the \(\mathbb {N}\)-graded Betti number \(\beta _{r,[j]}\) of the associated Stanley–Reisner ring is nonzero. Thus (a) follows directly from the expression of \({d}_r\) in equation (3).

To prove (b), first we recall from Corollary 34 that all the cycles of \(Cl({\mathcal {M}_{\mathcal {C}}})^*\) are of cardinality [j] for some j with \(1 \le j \le n\). Now from Theorem 35, it is clear that the \(\mathbb {N}-\)graded Betti numbers \(\beta _{r,s}\) are zero if s is not of the form [j] for some positive j with \(j \le n\). \(\square \)

4 Number of codewords of each rank weight via classical matroids

For this section we introduce some notations and fix some parameters. Let mn be positive integers and \(\mathcal {C}\subseteq \mathbb {F}_{q^m}^n\) be a Gabidulin rank-metric code over \(\mathbb {F}_{q^m}/{\mathbb F}_q\) of dimension \(k \le \min \{m,n\}\) with a generator matrix \(G = [(g_{i,j})]\) (i.e. a \(k \times n\)-matrix, with entries in \(\mathbb {F}_{q^m}\), and whose row space over \(\mathbb {F}_{q^m}\) is \(\mathcal {C}\)) . Let \( Q = q^m\) and \(\tilde{Q} = Q^r\) for some \(r \in \mathbb {N}\). Let \(\tilde{\mathcal {C}}=\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{Q^r}\) denote the extension of \(\mathcal {C}\) and thus \(\tilde{\mathcal {C}}\) can be considered as a Gabidulin rank-metric code over \(\mathbb {F}_{\tilde{Q}}/{\mathbb F}_q\).

Definition 37

For \(0 \le s \le k,\) let \(A_{\mathcal {C},s}^{\tilde{Q}}\) denote the number of words of rank weight s in \(\tilde{\mathcal {C}}=\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{Q^r}\).

In this and the following section we will find expressions for \(A_{\mathcal {C},s}^{\tilde{Q}}\). First we fix bases for the field extensions considered in this section. Let \(\{g_1,g_2,\ldots ,g_r\}\) be an arbitrary but fixed basis for \( \mathbb {F}_{\tilde{Q}}\) over \(\mathbb {F}_{Q}\). Therefore combining the fixed \({\mathbb F}_q\)-basis \(\{b_1, \ldots , b_m\}\) of \(\mathbb {F}_{Q}\), we then once and for all use \(\{b_ig_j\}_{1 \le i \le m,1\le j \le r}\) as a basis for \(\mathbb {F}_{\tilde{Q}}\) over \({\mathbb F}_q\). We use the following ordering

$$\begin{aligned} B_r=\{g_1b_1,g_1b_2,\ldots ,g_1b_m,g_2b_1,g_2b_2, \ldots ,g_2b_m,\ldots ,g_rb_1,g_rb_2,\ldots ,g_rb_m\} \end{aligned}$$

of the \({\mathbb F}_q\)-basis of \(\mathbb {F}_{\tilde{Q}}\) and consider the representation of codewords in \(\tilde{\mathcal {C}}\) as \((mr \times n)\)-matrices with entries in \({\mathbb F}_q\) with respect to the ordered basis \(B_r\).

In this section we express \(A_{\mathcal {C},s}^{\tilde{Q}}\) in terms of the nullity function of a classical matroid associated to the q-matroid corresponding to the Gabidulin rank-metric code \(\mathcal {C}\).

Lemma 38

Let \(\mathcal {C}\subseteq \mathbb {F}_{Q}^n\) be a Gabidulin rank-metric code over \(\mathbb {F}_{Q}/{\mathbb F}_q\) and \(\tilde{\mathcal {C}} = \mathcal {C}\otimes _{\mathbb {F}_{Q}}\mathbb {F}_{\tilde{Q}},\) for \(\tilde{Q} = Q^r.\) Then we have

$$\begin{aligned} \dim _{\mathbb {F}_Q}\mathcal {C}(U) = \dim _{\mathbb {F}_{\tilde{Q}}}\tilde{\mathcal {C}}(U)= \frac{1}{r}\dim _{\mathbb {F}_Q}\tilde{\mathcal {C}}(U). \end{aligned}$$

Proof

The second equality is clear as \(\dim _{\mathbb {F}_Q}\mathbb {F}_{\tilde{Q}}= r\).

For the first equality, it is enough to show that \(\tilde{\mathcal {C}}(U)\) is isomorphic to \(\mathcal {C}(U)^{\oplus r}\) as \(\mathbb {F}_Q\)-vector spaces. We observe that \(\tilde{\mathcal {C}}\), which is given as a row space over \(\mathbb {F}_{\tilde{Q}}\) of a matrix with entries in \(\mathbb {F}_{Q}\), can be written as a direct sum \(Cg_1 \oplus Cg_2 \oplus \cdots \oplus Cg_r\). The way we have chosen our basis \(B_r\) to express codewords, it is clear that \(\tilde{\mathcal {C}}(U)\) is a direct sum of \(\mathcal {C}(U)g_1\oplus \mathcal {C}(U)g_2\oplus \cdots \oplus \mathcal {C}(U)g_r.\) Hence it is clear that \(\dim _{\mathbb {F}_{Q}}\tilde{\mathcal {C}}(U)=r \dim _{\mathbb {F}_{Q}}\mathcal {C}(U)\). \(\square \)

Remark 39

The above lemma implies that \(\dim _{\mathbb {F}_{\tilde{Q}}}\tilde{\mathcal {C}}(U)\) is independent of the choice of r so that \(\tilde{Q} = Q^r\).

Corollary 40

Let \(\mathcal {C}\subseteq \mathbb {F}_{Q}^n\) be a Gabidulin rank-metric code and \(\tilde{\mathcal {C}}\) be the extended code \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \tilde{Q}\) where \(\tilde{Q} = Q^r\) for some \(r \in \mathbb {N}\). Then the q-matroids \((\mathcal {E},\rho _{\tilde{\mathcal {C}}})\) corresponding to the codes \(\tilde{\mathcal {C}}\) are the same for any \(r \in \mathbb {N}\).

Proof

For any \(U \subseteq {\mathbb F}_q^n\), we have

$$\begin{aligned}&\rho _{\tilde{\mathcal {C}}}(U)=\dim _{\mathbb {F}_{\tilde{Q}}} \tilde{\mathcal {C}}- \dim _{\mathbb {F}_{\tilde{Q}}} \tilde{\mathcal {C}}(U^{\perp })= \\&\quad \dim _{\mathbb {F}_{\tilde{Q}}} \tilde{\mathcal {C}}(\mathcal {E})-\dim _{\mathbb {F}_{\tilde{Q}}} \tilde{\mathcal {C}}(U^{\perp }), \end{aligned}$$

which is independent of r by Lemma 38. \(\square \)

Remark 41

Corollary 40 is an obvious consequence if we consider the equivalent definition of rank function of the q-matroid associated to Gabidulin rank metric code as given in [23, Definition 22]. Indeed, \(\rho _{\tilde{\mathcal {C}}}(U)= rank (G Y^T)\) where G is a generator matrix of \(\mathcal {C}\) and \(Y^T\) is the transpose of a generator matrix of U. Since all codes \(\tilde{\mathcal {C}}\) defined as in Definition 37 have a common generator matrix, the q-matroids associated the codes are also same.

Now we move onto giving our main result of this section, i.e., an expression for \(A_{\mathcal {C},s}^{\tilde{Q}}\), the number of codewords with rank weight s for \(s \in \{1, \ldots , n\}\), using the classical matroids corresponding to the q-matroid \((\mathcal {E},\rho _C)\).

First we define the some notions associated to \(\tilde{\mathcal {C}}\).

Definition 42

Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \(\mathbb {F}_{Q}/{\mathbb F}_q\) of length n and \(\tilde{\mathcal {C}} = \mathcal {C}\otimes _{\mathbb {F}_{Q}}\tilde{Q}\). Then for any subspace \(U \subseteq {\mathbb F}_q^n\),

$$\begin{aligned} \tilde{\mathcal {C}}(U) := \{\underline{x} \in \tilde{\mathcal {C}}~|~ Rsupp(\underline{x}) \subseteq U\} \text { and } A_{\mathcal {C},U}^{\tilde{Q}} := |\{\underline{x} \in \tilde{\mathcal {C}} | Rsupp(\underline{x}) = U\}|. \end{aligned}$$

Then following Definitions 37 and 42, we have

$$\begin{aligned} A_{\mathcal {C},n}^{\tilde{Q}} = A_{\mathcal {C},E}^{\tilde{Q}} \text { and } A_{\mathcal {C},s}^{\tilde{Q}} = \sum \limits _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim U = s \end{array}} |A_{\mathcal {C},U}^{\tilde{Q}}|. \end{aligned}$$
(4)

Proposition 43

Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \(\mathbb {F}_{Q}/{\mathbb F}_q\) of length n. Let \({\mathcal {M}_{\mathcal {C}}}= ({\mathbb F}_q^n, \rho _{\mathcal {C}})\) be its corresponding q-matroid and \(cl({\mathcal {M}_{\mathcal {C}}})=(P({\mathbb F}_q^n), \mathbf {r})\) be the associated classical matroid. Then for \(\tilde{Q} = Q^r\),

$$\begin{aligned} A_{\mathcal {C},n}^{\tilde{Q}} = (-1)^{{\frac{q^n-1}{q-1}}}\sum \limits _{\gamma \subseteq P(\mathcal {E})} (-1)^{|\gamma |} \tilde{Q}^{{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*}(\gamma )}, \end{aligned}$$

where \({\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*\) denotes the nullity function of the dual matroid \(Cl({\mathcal {M}_{\mathcal {C}}})^*\).

Proof

We set \({\mathcal {M}_{\mathcal {C}}}\). Let \(U_1, \ldots , U_{\frac{q^n-1}{q-1}}\) be the codimension 1 subspaces of \(\mathcal {E}={\mathbb F}_q^n\). Therefore,

$$\begin{aligned} A_{\mathcal {C},E}^{\tilde{Q}}&=|\tilde{\mathcal {C}|}-|\{\underline{x} \in \mathcal {C}\otimes _{\mathbb {F}_{Q}}\tilde{Q} | Rsupp(\underline{x}) \subseteq U_i \text { for some }i\}| \end{aligned}$$
(5)
$$\begin{aligned}&=\tilde{Q}^k - |\cup _{i=1}^{\frac{q^n-1}{q-1}} \tilde{\mathcal {C}}(U_i)|. \end{aligned}$$
(6)

We use \(s_i\) to denote the 1 dimensional subspace \(U_i^{\perp }\) for \(1 \le i \le \frac{q^n-1}{q-1}\). Note that

$$\begin{aligned} \dim \tilde{\mathcal {C}}(U_i)&= \dim _{\mathbb {F}_{\tilde{Q}}}{\mathcal {C}} - \rho _\mathcal {C}({U_i}^{\perp })\\&= k - \mathbf {r}_{Cl(\mathcal {M}_{\mathcal {C}})}(s_i)\\&= {\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash s_i). \end{aligned}$$

Since \(\tilde{\mathcal {C}}(U_i) \cap \tilde{\mathcal {C}}(U_j) = \tilde{\mathcal {C}}(U_i \cap U_j)\), similarly as above we get,

$$\begin{aligned} \dim ~ \tilde{\mathcal {C}}(U_i) \cap \tilde{\mathcal {C}}(U_j)&= \dim _{\mathbb {F}_{\tilde{Q}}}{\tilde{\mathcal {C}}} - \rho _\mathcal {C}({U_i}^{\perp } \cup {U_j}^{\perp })\\&= k - \mathbf {r}_{Cl(\mathcal {M}_{\mathcal {C}})}(\{s_i,s_j\})\\&= {\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash \{s_i,s_j\}). \end{aligned}$$

Following the same argument, we can say

$$\begin{aligned} \dim ~ \tilde{\mathcal {C}}(\cap _{j=1}^{a} U_{i_j}) = {\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash \{s_{i_1},\ldots , s_{i_a}\}), \end{aligned}$$

for any positive integer a. Therefore

$$\begin{aligned}&\cup _{i=1}^{\frac{q^n-1}{q-1}} \tilde{\mathcal {C}}(U_i)| \\&\quad = \sum \limits _{i} |\tilde{\mathcal {C}}(U_i)| - \sum \limits _{i,j} |\tilde{\mathcal {C}}(U_i) \cap \tilde{\mathcal {C}}(U_j)| +\cdots + (-1)^{\frac{q^n-1}{q-1}-1} \sum |\cap _{j=1}^{\frac{q^n-1}{q-1}} \tilde{\mathcal {C}}(U_{i_j})|\\&\quad =\sum \limits _{i} \tilde{Q}^{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash s_i)} - \sum \limits _{i,j}\tilde{Q}^{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash \{s_i,s_j\})} +\cdots + \\&\qquad (-1)^{\frac{q^n-1}{q-1}-1} \tilde{Q}^{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(P(\mathcal {E})\backslash P(\mathcal {E}))} \\&\quad = (-1)^{{\frac{q^n-1}{q-1}-1}}(\sum \limits _{\gamma \subseteq P(\mathcal {E})}(-1)^{|\gamma |} \tilde{Q}^{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(\gamma )} \end{aligned}$$

Therefore \(A_{\mathcal {C},E}^{\tilde{Q}} = (-1)^{{\frac{q^n-1}{q-1}}} \sum \limits _{\gamma \subseteq P(\mathcal {E})}(-1)^{|\gamma |} \tilde{Q}^{{\textbf {n}}_{Cl(\mathcal {M}_{\mathcal {C}})}^*(\gamma )}.\) \(\square \)

Remark 44

\(A_{\mathcal {C},E}^{\tilde{Q}}\) is of course non-zero only if \(m \ge n\), since otherwise there cannot be any codeword of rank n in \(\tilde{\mathcal {C}}\).

Proposition 43 can be viewed as a variant of [16, Formula (10)], the proof of which was inspired by [24, Sect. 5.5.].

Using the result and procedure above we find expressions for the \(A_{\mathcal {C},s}^{\tilde{Q}}\) for \(s=0,1,\ldots ,n-1\). For that first we define the following q-matroid.

Definition 45

Let \(\mathcal {C}\) be a Gabidulin rank-metric code of length n over \(\mathbb {F}_{Q}/{\mathbb F}_q\) and let U be a subspace of \(\mathcal {E}={\mathbb F}_q^n\) with \(\dim _{{\mathbb F}_q} U =s\). By considering \(\mathcal {C}(U)\) to be a Gabidulin rank-metric code over \(\mathbb {F}_{Q}/{\mathbb F}_q\), its corresponding q-matroid is defined as \(\mathcal {M}_{\mathcal {C}(U)}:=(U,\rho _U)\), where U is identified with \({\mathbb F}_q^s\) and for any subspace \(V \subseteq U\),

$$\begin{aligned} \rho _U(V)=\dim ~\mathcal {C}(U)-\dim ~\mathcal {C}(U)(V_U^{\perp }), \end{aligned}$$

where \(V_U^{\perp }\) is the orthogonal complement of V in U w.r.t. some chosen basis of \(U={\mathbb F}_q^s\).

Lemma 46

For a Gabidulin rank-metric code \(\mathcal {C}\) over \(\mathbb {F}_{Q}/{\mathbb F}_q\) of length n and for any \({\mathbb F}_q\)-subspace U of \({\mathbb F}_q^n\), let \(\eta _U^*\) be the nullity function of the q-matroid \(\mathcal {M}_{\mathcal {C}(U)}^*\). Then \(\eta _U^* = \eta _{\mathcal {C}}^*\). In other words, the q-cycles of \(\mathcal {M}_\mathcal{C}^*\) contained in U and the q-cycles of \(\mathcal {M}_{\mathcal {C}(U)}^*\) are the same.

Proof

Since \(V \subseteq U\), whatever basis we pick, we obtain \(\eta _U^*(V)=\dim _{\mathbb {F}_q}C(U)(V)=\dim _{\mathbb {F}_q}C(V)=\eta _{\mathcal {C}}^*(V)\) and thus the statement of the lemma follows. \(\square \)

Definition 47

For any subspace \(U \subset \mathcal {E}={\mathbb F}_q^n\), with a fixed basis and dot product, and any q-matroid \(\mathcal {M}=(\mathcal {E},\rho )\) with conullity function \(\eta ^*\), we let \(\mathcal {M}_U=(U,\rho _U)\) be the q-matroid with ground space U and conullity function \(\eta _U^*\), such that \(\eta _U^*(V)=\eta ^*(V),\) for all subspaces \(V \subset U\).

From Lemma 46 it is then clear that \((\mathcal {M}_C)_U=\mathcal {M}_{C(U)}.\)

Using Proposition 43 we then obtain the following expression for \(A_{\mathcal {C},U}^{\tilde{Q}}\):

Proposition 48

Let \(\mathcal {C}\) be a Gabidulin rank-metric code over \(\mathbb {F}_{Q}/{\mathbb F}_q\) of length n. Let \(\mathcal {M}={\mathcal {M}_{\mathcal {C}}}= ({\mathbb F}_q^n, \rho _{\mathcal {C}})\) be its corresponding q-matroid and \(Cl({\mathcal {M}_{\mathcal {C}}})=(P({\mathbb F}_q^n), \mathbf {r})\) be the associated classical matroid. Then for \(\tilde{Q} = Q^r\) and \(U \subseteq {\mathbb F}_q^n\),

$$\begin{aligned} A_{\mathcal {C},U}^{\tilde{Q}}= (-1)^{{\frac{q^s-1}{q-1}}}\sum \limits _{\gamma \subseteq P(U)} (-1)^{|\gamma |} \tilde{Q}^{{{\textbf {n}}_{Cl(\mathcal {M}_U)}^*}(\gamma )}, \end{aligned}$$

where \({\textbf {n}}_{Cl(\mathcal {M}_U)}^*\) is the nullity function of the dual classical matroid \(Cl(\mathcal {M}_U)^*.\)

Proof

Recall that \(A_{\mathcal {C},U}^{\tilde{Q}}\) is the number of codewords in \(\mathcal {C}\otimes _{\mathbb {F}_{Q}}\tilde{Q}\), whose rank support is exactly U or the number of codewords in \(\tilde{\mathcal {C}}(U)\) whose rank support is exactly U. Since \(\tilde{\mathcal {C}}(U) = \mathcal {C}(U) \otimes _{\mathbb {F}_{Q}} {\mathbb {F}_{\tilde{Q}}}\), it is clear that \(A_{\mathcal {C},U}^{\tilde{Q}}=A_{\mathcal {C}(U),U}^{\tilde{Q}}\). Thus the result directly follows from Proposition 43. \(\square \)

Remark 49

In stark constrast to the statement in Lemma 46, \({\textbf {n}}_{Cl(\mathcal {M}_U)}^*(\gamma )\) is not in general equal to \({\textbf {n}}_{Cl(\mathcal {M})}^*(\gamma )\), for \(\gamma \) contained in P(U). We have \({\textbf {n}}_{Cl(\mathcal {M})}^*(\gamma )=0\) for all \(\gamma \in P(U)\) if \(U \ne E\) (all cycles of \(Cl(\mathcal {M})^*\) are to big to be contained in such a P(U)).

Nevertheless, as an immediate consequence of Proposition 48, we get:

Corollary 50

$$\begin{aligned} A_{\mathcal {C},s}^{\tilde{Q}} = (-1)^{{\frac{q^s-1}{q-1}}} \sum \limits _{U, \dim ~U=s}\sum \limits _{\gamma \subseteq P(U)} (-1)^{|\gamma |} \tilde{Q}^{{{\textbf {n}}_{Cl(\mathcal {M}_U)}^*}(\gamma )}, \end{aligned}$$

for \(s=0,1,\ldots ,n-1,n\).

Here the sum is over all U with \(\dim ~U =s\). Since the number of \(\gamma \) and U is finite for a fixed q, we conclude that:

Corollary 51

There exists a polynomial \(P \in \mathbb {Z}[X]\) of degree

$$\begin{aligned} \max \{ \dim ~\mathcal {C}(U) :U \subseteq {\mathbb F}_q^n \text { with } \dim ~U =s,\} \end{aligned}$$

such that \(P(Q^r)=A^{Q^r}_{C,s}\), for all \(r \in \mathbb {Z}.\)

Proof

The only thing left to prove is the statement about the degrees. All exponents occurring in the expression for \(A_{\mathcal {C},s}^{\tilde{Q}}\) are at most the maximum of the numbers \({\textbf {n}}_{U,Cl(\mathcal {M})}^*(U)\) for all U of dimension s. But these numbers are simply \(\dim ~ \mathcal {C}(U)\). \(\square \)

Remark 52

Corollary 51 can be easily derived from descriptions by other authors, and then typically from descriptions of Delsarte codes in general, but we have included it here for completeness of our own exposition. See for example [4, Remark 3.5 and Theorem 3.8].

5 Number of codewords of each rank weight and Betti numbers

We will briefly demonstrate another well known and more direct way to find the \(A_{\mathcal {C},s}^{\tilde{Q}}\), i.e. the number of words of rank weight s (for small s an integer) in \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\) for \(0 \le s \le n,\) where \(\tilde{Q} = Q^r\).

Recall that \(A_{\mathcal {C},W}^{\tilde{Q}}\) for a subspace \(W \subseteq {\mathbb F}_q^n\), we mean the number of words in \(\mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\) with rank support W. From the definition, it follows that

$$\begin{aligned} |\tilde{\mathcal {C}}(U)|= \sum _{V \subseteq U}A_{\mathcal {C},V}^{\tilde{Q}}. \end{aligned}$$

Möbius inversion (See for example [31, 23, Proposition 3.7.1] and how it used in [4, Formula(7)]) gives:

$$\begin{aligned} A_{\mathcal {C},U}^{\tilde{Q}}=\sum _{V \subseteq U}(-1)^{\dim U - \dim V}q^{{\dim U - \dim V \atopwithdelims ()\ 2 }}|\tilde{\mathcal {C}}(V)|. \end{aligned}$$

But following Lemma 38, we have

$$\begin{aligned}&|\tilde{\mathcal {C}}(V)|=\tilde{Q}^{\dim _{F_{\tilde{Q}}}(\tilde{\mathcal {C}}(V))} =\tilde{Q}^{\dim _{\mathbb {F}_{Q}}\mathcal {C}(V)}, \text { and } \\&\quad {\dim _{\mathbb {F}_{Q}}\mathcal {C}(V)}=\dim _{\mathbb {F}_{Q}}\mathcal {C}- \rho _{\mathcal {C}}(V^{\perp })=k - \rho _{\mathcal {C}}(V^{\perp })= \dim ~U - \rho _{\mathcal {C}}^*(V)= \eta _{\mathcal {C}}^*(V). \end{aligned}$$

This gives:

Proposition 53

$$\begin{aligned} A_{\mathcal {C},s}^{\tilde{Q}} = \sum _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim ~ U = s \end{array}}\sum _{V \subseteq U}(-1)^{\dim ~U - \dim ~V}q^{{\dim ~U - \dim ~V \atopwithdelims ()\ 2 }}\tilde{Q}^{\eta _{\mathcal {C}}^*(V)}, \end{aligned}$$

for \(s=1,\ldots ,n.\)

An advantage with this expression, compared with that in Corollary 50, is that the conullity \(\eta _{\mathcal {C}}^*\) refers to the same q-matroid \({\mathcal {M}_{\mathcal {C}}}\), for all the U appearing in the formula.

Comparing the two expressions of \(A_{\mathcal {C},s}^{\tilde{Q}}\) in Corollary 50 and Proposition 53, we have the following result.

Corollary 54

Let \(\mathcal {M}={\mathcal {M}_{\mathcal {C}}}= (\mathcal {E}= {\mathbb F}_q^n, \rho )\) for a Gabidulin rank-metric code \(\mathcal {C}\) and let \(Cl(\mathcal {M}_U)\) be the classical matroid corresponding to the q-matroid \(\mathcal {M}_U\) for a subspace U of \(\mathcal {E}\). Then as formal polynomials in \(\mathbb {Z}[X]\) we have:

$$\begin{aligned}&(-1)^{{\frac{q^s-1}{q-1}}} \sum _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim U = s \end{array}}\sum \limits _{\gamma \subseteq P(U)} (-1)^{|\gamma |}X^{{{\textbf {n}}_{Cl(\mathcal {M}_U)}^*}(\gamma )}\\&\quad = \sum _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim U = s \end{array}}\sum _{V \subseteq U}(-1)^{\dim U - \dim V}q^{{\dim U - \dim V \atopwithdelims ()\ 2 }}X^{\eta _{\mathcal {M}}^*(V)}, \end{aligned}$$

for \(s=0,1,\ldots ,n-1,n.\)

Proof

These are both polynomials, and the difference between them has zeroes for \(Q^r\), for infinitely many r. But any non-zero polynomial over any field (in this case \(\mathbb {Q}\) or \(\mathbb {R}\)) has only finitely many zeroes. Hence the difference between the two polynomials appearing in the corollary is the zero polynomial. \(\square \)

Definition 55

For a Gabidulin rank-metric code \(\mathcal {C}\), we use \(A_{\mathcal {C},s}(X)\) to denote the polynomial(s) in Corollary 54. This is called the s-th generalized rank weight polynomial of the code \(\mathcal {C}\).

Definition 56

For any q-matroid \(\mathcal {M}\), let \(P_{\mathcal {M},s}(X)\) denote the polynomial appearing on the left side in Corollary 54. We call the \(P_{\mathcal {M},s}(X)\) the s-th generalized rank weight polynomial of a q-matroid \(\mathcal {M}\).

Remark 57

Note that \(A_{\mathcal {C},s}(\tilde{Q})=P_{\mathcal {M}_{\mathcal {C}},s}(\tilde{Q}) =A^{\tilde{Q}}_{\mathcal {C},s}\) for \(\tilde{Q} = Q^r\) for any \(r \in \mathbb {N}\) for any Gabidulin rank-metric code \(\mathcal {C}\).

From this result we obtain:

Corollary 58

For a Gabidulin rank-metric code we have: \({d}_i = \min \{s| \deg P_{\mathcal {M}_{\mathcal {C}},s}(X) = i\}\), for \(i=1,\ldots ,k\), and \(P_{\mathcal {M}_{\mathcal {C}},s}\) the s-th generalized rank weight polynomial of the q-matroid \({\mathcal {M}_{\mathcal {C}}}\).

Proof

From Definition 32, valid for any q-matroid \(\mathcal {M}\): \({d}_i(\mathcal {M})= \min \{\dim ~ U| \eta ^*(U)=i\}\) for any q-matroid \(\mathcal {M}\). Compare with the right side of Corollory 54. \(\square \)

We now have:

Proposition 59

For a q-matroid \(\mathcal {M} = (\mathcal {E}={\mathbb F}_q^n, \rho )\), let \(N=Cl(\mathcal {M})^*\). Then we have:

$$\begin{aligned}&P_{\mathcal {M},n}(X)=\sum _{l=0}^{k}\sum _{i=0}^{k}(-1)^i({\beta ^{(l)}_{i,\frac{q^n-1}{q-1}}}(N)-\beta ^{(l-1)}_{i,\frac{q^n-1}{q-1}}(N))X^l= \\&\sum _{l=0}^{k}\sum _{i=0}^{k}(-1)^i({\beta ^{(l)}_{i,P(\mathcal {E})}}(N)-\beta ^{(l-1)}_{i,P(\mathcal {E})}(N))X^l. \end{aligned}$$

Proof

This is a special case of [16, Theorem 5.1] which (in the relevant case) says that for any classical matroid \(M=(E,\mathbf {r})\) of rank k: the polynomial

$$\begin{aligned} (-1)^{|E|}\sum _{\gamma \subset E}(-1)^{|\gamma |} X^{{\textbf {n}}_{M^*}(\gamma )}. \end{aligned}$$

is equal to

$$\begin{aligned} \sum _{l=0}^{k}\sum _{i=0}^{k}(-1)^i({\beta ^{(l)}_{i,E}(M^*)-\beta ^{(l-1)}_{i,E}}(M^*))X^l. \end{aligned}$$

Comparing with the left version of \(P_{\mathcal {M},n}\) in Corollary 54, or the expression in Proposition 48, one obtains the result. \(\square \)

Let U be a cycle of dimension \(s \in \{1,\ldots ,n\}\) for a q-matroid \(\mathcal {M}\). Then Proposition 59 immediately gives:

$$\begin{aligned} P_U(X)= \sum _{l=0}^{k_U}\sum _{i=0}^{k_U}(-1)^i(\beta ^{(l)}_{i,P(U)}(N_U)-\beta ^{(l-1)}_{i,P(U)}(N_U))X^l, \end{aligned}$$

where \(\beta ^{(l)}_{i,P(U)}(N_U)\) and \(\beta ^{(l-1)}_{i,P(U)}(N_U)\) refer to Betti numbers of the classical matroid \(N_U=Cl(\mathcal {M}_U)^*\), and \(k_U=\dim ~ M_U\). Hence we obtain that \(P_{\mathcal {M},s}(X)\) is the sum of all such expressions for all U of dimension s. We recall that for a Gabidulin rank-metric code \(\mathcal {C}\) then \(P_U(\tilde{Q})\) is the number of codewords of rank support U in \(\tilde{\mathcal {C}}\). We would like to relate the Betti numbers appearing in these expressions, and which refer to different matroids \((Cl(M_{U}))^*\) to Betti numbers of one single matroid \(Cl(\mathcal {M})^*\) (which \(P_{\mathcal {M},n}(X)\)) already does, but none of the other \(P_{\mathcal {M},s}\) so far). To remedy this lack of simplicity we refer to the Corollary 61 below, given in [17, Corollary 2], and using the exposition on p. 59 in [30]. But first we recall the following classical definition:

Definition 60

Let L be a lattice. The Möbius function \(\mu _L(a,b)\) is defined recursively by \(\mu _L(a,a)=1\), and \(\mu (a,b)=-\Sigma _{a \le c < b} \mu (a,c)\).

Corollary 61

[17, Corollary 21] For a matroid \(M=(E,\mathbf {r})\) and a subset \(X \subset E\) we have

$$\begin{aligned}\beta _{{\textbf {n}}(X),X} = (-1)^{{\textbf {n}}(X)}\mu _{L_F(M^*)}(E\backslash {X},E) = (-1)^{{\textbf {n}}(X)}\mu _{L_C(M)}(\emptyset ,X), \end{aligned}$$

where \(L_F(M^*)\) and \(L_C(M)\) refer to the lattices of flats of \(M^*\) and cycles of M, respectively.

Since we know that \(\beta _{i,X}=0\) for all i different from the nullity \({\textbf {n}}(X)\), Corollary 61 implies that the Betti numbers of a classical matroid, and also of all of its elongation matroids, are entirely determined by the lattice of cycles of the matroid. This makes the following result important:

Proposition 62

Let \(\mathcal {M}\) be a q-matroid on \(\mathcal {E}={\mathbb F}_q^n\) and U be a q-cycle of the dual q-matroid \(\mathcal {M}^*\). Then the following 4 lattices are isomorphic

  • The sublattice of q-cycles of \(\mathcal {M}^*\) contained in U.

  • The lattice of q-cycles of \(\mathcal {M}_U^*\).

  • The lattice of cycles of \(Cl(\mathcal {M}_{U})^*\).

  • The sublattice of cycles of \(Cl(\mathcal {M})^*\) contained in the cycle \(R(U)=P(\mathcal {E})- P(U^{\perp }).\)

Proof

From Definition 47, it follows directly that the two first lattices are identical. The second and third lattices are isomorphic, by Proposition 21(b). Thus it is sufficient to show that the fourth lattice is isomorphic to any of the three lattices above.

Note that, since U is a q-cycle of \(\mathcal {M}^*\), then \(R(U)=P(\mathcal {E})- P(U^{\perp })\) is a cycle of \(Cl(\mathcal {M})^*\). Furthermore, if VW are q-cycles contained in the q-cycle U, then \(V \subseteq W\) if and only if \(P(V) \subseteq P(W)\) if and only if \(R(V) \subseteq R(W)\)). Hence the first and fourth lattices are isomorphic and we get the desired result. \(\square \)

By Corollary 61 and Proposition 62 the Möbius functions of all these lattices can be expressed by Betti numbers relating to the single classical matroid \(N=Cl(\mathcal {M}_{\mathcal {C}}^*).\) In particular the isomorphism between the third and fourth lattices above gives that

$$\begin{aligned} \beta ^{(l)}_{i,P(U)}(N_U)=\beta ^{(l)}_{i,R(U)}(N|_{R(U)})= \beta ^{(l)}_{i,R(U)}(N). \end{aligned}$$

For the rightmost equality we have used that in general \(\beta _{i,\sigma }(M)= \beta _{i,\sigma }(M|_{\sigma })\) for a matroid M. We then obtain:

Proposition 63

Given a q-matroid \(\mathcal {M}\). Then

$$\begin{aligned} P_{\mathcal {M},s}(X)= \sum _{\dim U =s}\sum _{l=0}^k \sum _{i=0}^{k}(-1)^i(\beta ^{(l)}_{i,R(U)}(N)-\beta ^{(l-1)}_{i,R(U)})(N))X^l, \end{aligned}$$

for the classical matroid \(N=Cl(\mathcal {M})^*\).

Since we know that there are no other cycles of \(Cl(\mathcal {M})^*\) than those of the form R(U), we also know that \(\beta ^{(l-1)}_{i,X}=0\) for all \(X \subseteq P(\mathcal {E})\) not of this form. Hence we obtain

Theorem 64

Let \(\mathcal {M}\) be a q-matroid. Then the s-th generalized weight polynomial of \(\mathcal {M}\) is given by

$$\begin{aligned} P_{\mathcal {M},s}(X)=\sum _{l=0}^{k} \sum _{i=0}^{k}(-1)^i(\beta ^{(l)}_{i,[s]}(N)-\beta ^{(l-1)}_{i,[s]}(N))X^l, \end{aligned}$$

where \(N=Cl(\mathcal {M})^*\), the dual classical matroid corresponding to \(\mathcal {M}\). Consequently, the number of codewords of rank weight s in \(\tilde{\mathcal {C}}\) is

$$\begin{aligned} A_{\mathcal {C},s}(\tilde{Q})=\sum _{l=0}^{k} \sum _{i=0}^{k}(-1)^i(\beta ^{(l)}_{i,[s]}(N)-\beta ^{(l-1)}_{i,[s]}(N))\tilde{Q}^l. \end{aligned}$$

We recall the definition: \({d}_i(\mathcal {M})= \min \{\dim ~ U| \eta ^*(U)=i\})\), valid for all q-matroids \(\mathcal {M}\). From Proposition 62 we also obtain the following generalization of Corollary 54:

Corollary 65

For any q-matroid \(\mathcal {M}\) we have: \({d}_i(\mathcal {M}) = \min \{s| \deg P_{\mathcal {M},s}(X) = i\}.\)

Proof

We recall the definition:

$$\begin{aligned} P_{\mathcal {M},s}(X)=(-1)^{{\frac{q^s-1}{q-1}}} \sum _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim U = s \end{array}}\sum \limits _{\gamma \subseteq P(U)} (-1)^{|\gamma |}X^{{{\textbf {n}}_{Cl(\mathcal {M}_U)}^*}(\gamma )}. \end{aligned}$$

But by Proposition 62 (the isomorphism between the first and the third lattice there), even the third equality below holds:

$$\begin{aligned}&\min \{s| \deg P_{\mathcal {M},s}(X) = i\}\\&\quad =\min \{s|\text { there exist } \gamma ,U \text { with }\dim (U)=s \text { and } \gamma \subset P(U) \text { and } {\textbf {n}}_{Cl(\mathcal {M}_U)}^*(\gamma )=i\}\\&\quad =\min \{s|\text { there exists }U \text { with }\dim (U)=s \text { and } {\textbf {n}}_{Cl(\mathcal {M}_U)}^*(P(U))=i\}\\&\quad =\min \{s|\text { there exists }U \text { with }\dim (U)=s\text { and } \eta ^*_{\mathcal {M}}(U)=i\}\\&\quad =d_i. \end{aligned}$$

This proves the corollary. \(\square \)

Definition 66

Given a Gabidulin rank-metric code \(\mathcal {C}\). Then the i-th generalized rank weight distribution of \(\mathcal {C}\) is the integer vector whose u-th component, \(0 \le u \le n\), is defined by

$$\begin{aligned} A_{\mathcal {C},u}^{(i)}:= \sum _{\begin{array}{c} U \subseteq \mathcal {E}\\ \dim ~ U = u \end{array}} A_{\mathcal {C},U}^{(i)}, \end{aligned}$$

where, for any \(U \subseteq \mathcal {E}\),

$$\begin{aligned} A_{\mathcal {C},U}^{(i)}:=|\{\mathcal {D} \subseteq \mathcal {C}: \dim (\mathcal {D}) = i, Rsupp(\mathcal {D})=U \}|. \end{aligned}$$

The following two results can be viewed as an adaptation to the rank-metric situation of the arguments given in [22, Lemma 5.4, Prop. 5.28].

Lemma 67

For an element \(\mathbf {c} \in \tilde{\mathcal {C}}\), let M be the corresponding \((r \times n)\) matrix, referring to our fixed basis \(\{g_1,\ldots ,g_r\}\) of \(\mathbb {F}_{Q^r}\) over \(\mathbb {F}_{Q}.\) Let D be the subspace of \(\mathcal {C}\) generated by the rows of the matrix M. Then \(wt(\mathbf {c}) = wt(D):= \dim _{{\mathbb F}_q} Rsupp(D)\), where \(wt(\mathbf {c})\) denotes the rank weight of \(\mathbf {c}\).

Proof

Let \(\mathbf {c}=(c_1,\ldots , c_n) \in \tilde{\mathcal {C}},\) and \(c_j = \sum \limits _{i=0}^{r-1}c_{i,j}g_i\), so that the ijth entry of \({\mathbb A}\) is \(c_{i,j}\). From definitions of rank weight and rank support, it follows that \(wt(\mathbf {c}) = wt(D)\). \(\square \)

Proposition 68

Let \(\mathcal {C}\) be a \([n,k]_{q^m}\) Gabidulin rank-metric code.

Then

$$\begin{aligned} A_{\mathcal {C},w}(q^{mr}) = \sum \limits _{s = 0}^{k} [r,s]_{q^m} A^{(s)}_{\mathcal {C},w}, \end{aligned}$$

where \([r,s]_{q^m}\) is the number of \(F_{q^m}\)-linear subspaces of dimension s contained in \(F_{q^m}^r.\)

Proof

Here \(A_{\mathcal {C},w}(q^{mr})\) is the number of codewords of \(\tilde{\mathcal {C}}=\mathcal {C}\otimes _{\mathbb {F}_{q^m}} \mathbb {F}_{q^{mr}}\) of rank weight w, which we get by substituting \(T = q^{mr}\) in the polynomial \(A_{\mathcal {C},w}(T)\). Now we do the counting in another way. Let \(\mathbf {c}\) be an element of \(\tilde{\mathcal {C}}\) which corresponds to a \((r \times n)\)-matrix \({\mathbb A}\) with rows in \(\mathcal {C}\). Let D be the subcode of \(\mathcal {C}\) generated by the rows of \({\mathbb A}\) and it has rank weight w and dimension s. On the other hand, for any subcode \(D_1 \subseteq \mathcal {C}\) of dimension s and rank weight w, we consider \({\mathbb A}_1\) to be a generator matrix of \(D_1\). Then left multiplication of a \(r \times s\) matrix of rank s with \({\mathbb A}_1\) gives an element of \(\mathcal {C}^r\), which has the same rank weight w. The number of \(r \times s\) matrices in \(\mathbb {F}_{q^m}\) of rank s is equal to \([r,s]_{q^m} = \Pi _{i=0}^{s-1} ({q^m}^r - {q^m}^i)\). Therefore, the number of codewords of \(\tilde{\mathcal {C}}\) of rank weight w is equal \(\sum \limits _{s = 0}^{k}[r,s]_{q^m}A^{(s)}_w\). \(\square \)

Definition 69

Given a q-matroid \(\mathcal {M}\). For each \(j \in \{0,1,\ldots ,\frac{q^n-1}{q-1}\}\) and \(l \in \{0,1,\ldots ,k\}\) we set

$$\begin{aligned} \phi ^{(l)}_j=\sum _{i=0}^{k} (-1)^i \beta ^{(l)}_{i,j}, \end{aligned}$$

referring to Betti numbers of \(Cl(\mathcal {M})^*\) and its elongations. We set \(\phi _j=\phi ^{(0)}_j\).

Theorem 70

The following 4 sets of data are equivalent for a Gabidulin rank-metric code \(\mathcal {C}\) with the associated q-matroid \(\mathcal {M}\):

  • The s-th generalized weight polynomial \(P_{\mathcal {M},s}(X)\) of \(\mathcal {M}\) for all s,

  • The s-th generalized weight polynomial \(A_{\mathcal {C},s}(X)\) of \(\mathcal {C}\) for all s,

  • The j-th generalized weight distribution (\(A_{\mathcal {C},s}^{(j)}\)) of \(\mathcal {C}\) for all j,

  • The alternative sum of (elongated) Betti numbers \(\phi _{j}^{(l)}\) of \(Cl(\mathcal {M})^*\) for all jl.

Proof

By definition, the two polynomials \(P_{\mathcal {M},s}(X)\) and \(A_{\mathcal {C},s}(X)\) of \(\mathcal {C}\) are same. The equivalence between the \(A_{\mathcal {C},s}(X)\) and the \(A_{\mathcal {C},s}^{(j)}\) is given by Proposition 68. By Theorem 64 the \(P_{\mathcal {M},s}(X)\) are determined by the \(\phi _{j}^{(l)}\). Moreover, Theorem 64 shows that one, starting with \(l=0\), can determine the \(\phi _{j}^{(l)}\) recursively for all l if one knows the \(P_{\mathcal {M},s}(X)\). \(\square \)

We also obtain:

Corollary 71

For a q-matroid \(\mathcal {M}\) in general the following are equivalent:

  • The \(P_{\mathcal {M},s}(X)\) for all s.

  • The \(\phi _{j}^{(l)}\) for all jl.

Proof

In the part of the proof of Theorem 70 which is relevant here, we use Theorem 64, which is valid for all q-matroids. \(\square \)

Remark 72

One is sometimes interested in q-matroids \(\mathcal {M}\), such that all q-flats of the same rank have the same dimension, for all fixed ranks. These are called q-perfect matroid designs (q-PMD), e.g., see [3]. This is the same as \(Cl(\mathcal {M})\) having all flats of a given fixed rank the same cardinality, and the same as \(N=Cl(\mathcal {M})^*\) having all its cycles of each fixed nullity the same cardinality. This is equivalent to saying that in the resolution of the Stanley–Reisner ring of N, we have \(\beta _{i,j} \ne 0\) for only if one j (say \(j=d_i\)) for each \(i=1,\ldots ,rk(\mathcal {M})\) (and then \(\phi _{d_i}=\beta _{i,d_i}\)). Hence the resolution is pure in this sense if and only all q-flats of the same rank of \(\mathcal {M}\) have the same dimension. In this case all Stanley–Reisner rings of the elongations of N also have pure resolutions, and it is particularly easy to find all \(\phi ^{(l)}_j\) in terms of the \(d_i\), due to the Herzog-Kühl equations, see, for example, [15] or [1, Def. 3.1 and Remark 3.2]

Remark 73

  • Theorem 70 is a q-analogue of [20, Corollary 17], which applies to Hamming codes and associated matroids. In both [20] and [21] one found all the \(\phi _{j}^{(l)}\), and using this corollary, one found all the weight spectra, i.e. all the \(A_s^{(j)}\) for two kinds of Veronese codes. It is unclear whether such techniques are useful for Gabidulin rank-metric codes, as it is for Veronese Hamming codes.

  • Corollary 71 indicates an extended range of applications for the reasoning above, including an extension of Theorem 70. One could imagine q-matroids coming from a wider class of objects than that of Gabidulin rank-metric codes. An example could be any subset \(\mathcal {C}\) of the space of \((m \times n)\)-matrices over \(\mathbb {F}^q\), such that the subset \(\mathcal {C}(U)\) had cardinality \(q^{ms}=Q^s\) for some \(s=s(U)\) for all \(\mathbb {F}_q\)-subspaces U of \(\mathbb {F}_q^n\). And \(\tilde{\mathcal {C}}\) could be defined as just \(\mathcal {C}^r\). The rank function \(log_Q|\mathcal {C}|-log_Q|\mathcal {C}(U^{\perp })|\) could then be used to give results like Corollary 71 and possibly to Theorem 70 also, for such “almost affine Gabidulin rank-metric codes”, as one could call them. To obtain a full extension of Theorem 70 to such codes, one must also then define, and successfully treat, some hierarchy of natural “almost affine Gabidulin subcodes” from which one could define the \(A_s^{(j)}\). Generalizations from linear Hamming codes to almost affine codes were treated in [2] and [19]. It is not clear to us how interesting it will be to extend the class of linear (usual), rank-metric Gabidulin rank-metric codes to such an analogous, bigger class of codes.

  • One may wonder whether the same or similar techniques can be used to express generalized weights and weight spectra for Delsarte rank-metric code by Betti numbers. This is in general difficult, since then we must then handle (qm)-polymatroids \(\mathcal {M}\) instead of q-matroids. The axiom (P1)

    $$\begin{aligned} 0 \le \rho (X) \le m\dim X, \end{aligned}$$

    for subspaces \(X \subset \mathcal {E}={\mathbb F}_q^n,\) for (qm)-polymatroids does not imply (R1) of Definition 1: \( 0 \le {\textbf {r}}(S) \le |S|\) then, but only \(0 \le r(S) \le m|S|\), for \(\mathbf {r}= \mathbf {r}_{\rho }\) defined as in Definition 14. So, in order to have some hope to get a classical matroid, one is led to redefine:

    $$\begin{aligned} {\textbf {r}}_{\rho }(S)= \frac{1}{m}\rho (<S>), \end{aligned}$$

    for any set S of 1-dimensional subspaces of E. Then axiom (R1) holds. But we have no guarantee that \(\rho (<S>)\) is a multiple of m for all X for an arbitrary (qm)-matroid, and then \({\textbf {r}}\) \(_{\rho }(S)= \frac{1}{m}\rho (<S>)\) may not be an integer, and then \(Cl(\mathcal {M})\) defined via Definition 1 is not a matroid even if \(\mathbf {r}_{\rho }\) would satisfy the three axioms (R1),(R2),(R3).

    Example: For (qm)-polymatroids coming from Delsarte rank-metric codes C we have \(\rho (X) = \dim C - \dim C(X^{\perp })\), and the values \(\dim C\) and \(\dim C(X^{\perp })\), which are dimensions over \(\mathbb {F}_q\), could very well give a \(\rho \)-value, that is not divisible by m. They are on the other hand guaranteed to be multiples of m if C is a Gabidulin rank-metric code.

    On the other hand, it is shown in [9, Theorem 3.9] how a q-matroid can be associated to a (qm)-polymatroid so that certain sets of independent spaces coincide. We do not rule out the possibility that this can be useful also in a setting like ours.

  • For classical matroids the \(\phi _j\) play a role as certain coefficients of the two-variable coboundary polynomials, as is shown in [17, Proposition 5]. It is conceivable that they may play a similar role for q-matroids. One may raise the question whether the MacWilliams identities (See [12, Theorem 1]) in the case of Gabidulin rank-metric codes can be formulated in terms of Betti numbers. It is possible by writing the weight distributions of a code and its dual in terms of Betti numbers. But at the present stage it is unclear if doing it, using Betti numbers connected to matroids derived from two dual q-matroids will give any new insight. So we leave it for further investigation.

6 Two different ways of determining rank-weight spectra

In this section, we demonstrate with concrete examples how to determine (generalized) rank-weight spectra of Gabidulin rank-metric codes. While in the first example we use the expression in Theorem 64 to determine the rank-weight distribution and Proposition 68 to determine the higher weight spectra, in the second example we consider the class of MRD codes and determine the weight spectra directly from the corresponding (uniform) q-matroids.

Example 74

Consider the field extension \(\mathbb {F}_{2^4}/\mathbb {F}_{2}\) of degree 4, and let a be a root in \(\mathbb {F}_{2^4}\) of the irreducible polynomial \(X^4 + X+ 1\) in \(\mathbb {F}_{2}[X]\) so that \(\mathbb {F}_{2^4} = \mathbb {F}_{2}(a)\). Let \(\mathcal {C}\) be the rank-metric code of length 4 over the extension \(\mathbb {F}_{2^4}\) of \(\mathbb {F}_{2}\) such that a generator matrix of \(\mathcal {C}\) is given by

$$\begin{aligned} G:= \begin{pmatrix} a^{2} + a + 1 \ &{}\quad a^{2} &{}\quad a^{3} + a + 1 \ &{}\quad a^{3} + a^{2} + a + 1 \\ a^{2} + a + 1 &{}\quad a^{3} + 1 \ &{}\quad a &{}\quad a + 1 \\ a^{2} + 1 &{}\quad 1 &{}\quad a^{2} + 1 &{}\quad a^{3} + 1 \end{pmatrix}. \end{aligned}$$

Let \({\mathcal {M}_{\mathcal {C}}}\) be the q-matroid over \(\mathbb {F}_2^4\) corresponding to the rank-metric code \(\mathcal {C}\) and let N be the classical matroid \(Cl({\mathcal {M}_{\mathcal {C}}})^*\). We consider the simplicial complex \(\Delta _N\) associated to the matroid N.

We remark that this is a case, where \(m=n(=4),\) but we are not making any considerations here, about what happens if we look at column spaces instead of row spaces. We just follow the recipe described above and find the weight spectrum of the code, as described, using row spaces as supports. Here we list the (elongated) Betti numbers of the Stanley–Reisner ring associated to the simplicial complex \(\Delta _{\mathcal {C}}\).

$$\begin{aligned} \beta _{0,0}&=1&\quad&\quad&\quad \\ \beta _{1,8}&=1&\quad&\quad&\quad \\ \beta _{1,12}&=28&\quad&\quad&\quad \\ \beta _{2,14}&=76&\beta _{1,14}^{(1)}=15&\quad&\quad \\ \beta _{3,15}&=48 ,&\beta _{2,15}^{(1)}=14&\quad&\beta _{1,15}^{(2)}=1 \end{aligned}$$

The Betti numbers here are computed using Magma [25], and a program code where one finds the numbers via a certain adaptation of Hochster’s formula [13], which here may be used to express these numbers in terms of relevant homological invariants.

We use \(\beta _{i,[j]}\) to denote the Betti number \(\beta _{i, {q^{n-1}+ q^{n-2} + \cdots + q^{n-j}}}\). By Theorem 36, the minimum weight of \(\mathcal {C}\) is 1 as \(\min \{j \;|\; \beta _{1,[j]} \ne 0\} = 1\). Now we determine the weight spectrum \((A_0, A_1, A_2, A_3, A_4)\) of \(\mathcal {C}\) by substituting the values of the Betti numbers in the expression of \(A_{\mathcal {C},s}(q^m)\) as proved in Theorem 64.

For ease of calculation we expand the expression for \(A_{\mathcal {C},s}(q^m)\) as follows.

$$\begin{aligned} A_s(q^m)&= (-\beta _{1,[s]}^{(0)} + \beta _{2,[s]}^{(0)} - \beta _{3,[s]}^{(0)})+q^m(-\beta _{1,[s]}^{(1)} + \beta _{2,[s]}^{(1)}\\&\qquad - \beta _{3,[s]}^{(1)})-q^m(-\beta _{1,[s]}^{(0)} + \beta _{2,[s]}^{(0)} - \beta _{3,[s]}^{(0)})\\&\qquad +q^{2m}(-\beta _{1,[s]}^{(2)} + \beta _{2,[s]}^{(2)} - \beta _{3,[s]}^{(2)}) -q^{2m}(-\beta _{1,[s]}^{(1)} + \beta _{2,[s]}^{(1)} - \beta _{3,[s]}^{(1)}). \end{aligned}$$

\(A_0(2^4)= 1,\; A_1(2^4)= 15,\; A_2(2^4)= 420,\; A_3(2^4)= 2460,\; \text {and} \;A_4(2^4) = 1200\).

Example 75

Let \(\mathcal {C}\) be an [nkd] MRD code over \({\mathbb F}_{q^m}= \mathbb {F}_{Q}\) and let \(\tilde{\mathcal {C}}\) be its extended code \(\tilde{\mathcal {C}}= \mathcal {C}\otimes _{\mathbb {F}_{Q}} \mathbb {F}_{\tilde{Q}}\). Let the q-matroid associated to the MRD code \(\mathcal {C}\) is the uniform q-matroid \(\mathcal {M}\).

Step 1

Recall that the s-th generalized rank-weight polynomial of \(\mathcal {M}\) is

$$\begin{aligned}P_{\mathcal {M},s}(X) = \sum \limits _{\dim ~ U =s} \sum _{l=0}^k\sum \limits _{i=0}^k (-1)^i (\beta ^{(l)}_{i,R(U)}(N)-\beta ^{(l-1)}_{i,R(U)})(N))X^l.\end{aligned}$$

Note that for a subspace \(U\subseteq \mathcal {E}={\mathbb F}_q^n\), we have \(|R(U)|= |P(\mathcal {E}) - P(U^{\perp })|=q^{n-1} + q^{n-2} + \cdots + q^{n-s}\). Therefore,

$$\begin{aligned} P_{\mathcal {M},d}(X)&= \beta _{1,[d]}^{(0)} X - \beta _{1,[d]}^{(0)},\\ P_{\mathcal {M},d+1}(X)&=\beta _{1,[d+1]}^{(1)} X^2 - (\beta _{1,[d+1]}^{(1)}+\beta _{2,[d+1]}^{(0)})X + \beta _{2,[d+1]}^{(0)},\\ P_{\mathcal {M},d+2}(X)&=\beta _{1,[d+2]}^{(2)} X^3 - (\beta _{1,[d+2]}^{(2)}+\beta _{2,[d+2]}^{(1)})X^2 + (\beta _{2,[d+2]}^{(1)}+\beta _{3,[d+2]}^{(0)})X-\beta _{3,[d+2]}^{(0)},\\&\vdots \quad \quad \quad \quad \vdots \\ P_{\mathcal {M},n}(X)&=\beta _{1,[n]}^{(k-1)} X^k - (\beta _{1,[n]}^{(k-1)}+\beta _{2,[n]}^{(k-2)})X^{k-1} +\cdots +(-1)^{k-2}(\beta _{k-1,[n]}^{(1)} +\beta _{k,[n]}^{(0)})X\\&\quad \quad \quad +(-1)^{k-1} \beta _{k,[n]}^{(0)}. \end{aligned}$$

Step 2 Now we compute the (elongated) Betti numbers of \(Cl(\mathcal {M})^*\), the dual of the classical matroid associated to the q-matroid.

Consider the lattice of cycles of \(Cl(\mathcal {M})^*\), say, \(L^*\). We use the following formula for computing Betti numbers: \(\beta _{\mathbf {n}^*(X),X}= |\mu _{L^*}(\phi ,X)|,\) where \(\mathbf {n}^*\) is the nullity function of \(Cl(\mathcal {M})^*\).

Note that, if \(\mathcal {M}\) is a q-matroid of rank k, then the cycles of \(Cl(\mathcal {M})^*\) with nullity i have cardinalities \(q^{n-1}+ q^{n-2}+ \cdots + q^{k-i}\) for \(1 \le i \le k\). Let \(c_i\) denote a cycle of cardinality \(q^{n-1}+ q^{n-2}+ \cdots + q^{k-i}\) with nullity i. Note that there are \({{n} \brack {k-i}}\) cycles \(c_i\) of nullity i in the lattice \(L^*\) and there are \({{k-j} \brack {k-i}} = {{k-j} \brack {i-j}}\) many cycles \(c_j\) of nullity j contained in \(c_i\).

$$\begin{aligned} \text {Then }h_i:=\mu (\emptyset , c_i)&= - \mu (\emptyset , \emptyset ) - \sum \limits _{c_j \subsetneq c_i} \mu (\emptyset , c_j) \end{aligned}$$
(7)
$$\begin{aligned}&= -1 - {{k-1} \brack {i-1}}\mu (\emptyset , c_{1}) - \cdots - {{k-i+1} \brack {1}}\mu (\emptyset , c_{i-1})\end{aligned}$$
(8)
$$\begin{aligned}&= -1 -{{k-1} \brack {i-1}}h_1 -\cdots - {{k-i+1} \brack {1}} h_{i-1}. \end{aligned}$$
(9)

Here \(d=n-k+1\). As we know that \(\beta _{i,\sigma } \ne 0 \) if and only if \(\sigma \in N_i\) (the cycles of nullity i), by Corollary 34, the nonzero \(\mathbb {N}^{P(\mathcal {E})}\)-graded Betti numbers of \(Cl(\mathcal {M})^*\) are of the form \(\beta _{i,{q^{n-1}+ \cdots + q^{k-i}}}\) for \(1 \le i \le k\). Thus using the recursive formula for the Möbius function of \(L^*\), we get the expression for the non-zero Betti numbers as follows,

$$\begin{aligned} \beta _{i,[n-k+i]}&= {{n} \brack {n-k+i}}_q h_i.\\ \beta _{1,{[n-k+1]}}&= {{n} \brack {n-k+1}}_q|\mu _{L^*}(\emptyset ,X)|, \text { where } X \text { is a cycle of cardinality }[n-k+1]. \\ \beta _{2, {[n-k+2]}}&= {{n} \brack {n-k+2}}_q|\mu _{L^*}(\emptyset ,X)|, \text { where } X \text { is a cycle of cardinality }[n-k+2] \\&= {{n} \brack {n-k+2}}_q |\sum \limits _{X \subsetneq Y} \mu _{L^*}(\emptyset ,X) + \mu (\emptyset , \emptyset )| \\&= {{n} \brack {n-k+2}}_q ({{d+1} \brack {1}}_q -1).\\ \beta _{i, {[n-k+i]}}&= {{n} \brack {n-k+i}}_q|\mu _{L^*}(\emptyset ,X)|, \text { where } X \text { is a cycle of cardinality }[n-k+i]. \\ \end{aligned}$$

We determine the l-th elongated Betti numbers of \(Cl(\mathcal {M})^*\) for a fixed \(0 \le l \le k\).

$$\begin{aligned}&\beta ^{(l)}_{1,c_1} = 1&\beta ^{(l)}_{1,[d+l]}= {{n} \brack {d+l}}_q \beta ^{(l)}_{1,c_1}\\&\beta ^{(l)}_{2,c_2} = {{d+l+1}\brack {1}}_q -1&\beta ^{(l)}_{2,[d+l+1]}= {{n} \brack {d+l+1}}_q \beta ^{(l)}_{2,c_2}\\&\beta ^{(l)}_{3,c_3} ={{d+l+2} \brack {1}}_q \beta ^{(l)}_{2,c_2} - {{d+l+2} \brack {2}}_q \beta ^{(l)}_{1,c_1}&\beta ^{(l)}_{3,[d+l+2]}= {{n} \brack {d+l+2}}_q \beta ^{(l)}_{3,c_3}\\ \quad&\vdots \quad \quad&\vdots \quad \quad \quad \\ \end{aligned}$$

\(\beta ^{(l)}_{k-l,[n]} = {{n} \brack {n}}_q ({{n} \brack {1}}_q \beta ^{(l)}_{k-l-1,c_{k-l-1}} - {{n} \brack {2}}_q \beta ^{(l)}_{k-l-2,c_{k-l-2}} + \cdots + (-1)^{n-d-l} {{n} \brack {n-l}}_q \beta ^{(l)}_{1,c_1}).\) Step 3

We determine the weight spectra \((A_{\mathcal {C},w})\) from the weight enumerator polynomials by determining these values for some particular values of w. Since \( A_{\mathcal {C},w}(Q) = P_{\mathcal {M},w}(Q) \), thus

$$\begin{aligned} A_{\mathcal {C},d} = P_{\mathcal {M},d}(X)|_{X = {q^m}}&= \beta _{1,[d]}^{(0)} q^m - \beta _{1,[d]}^{(0)}\\&= {{n} \brack {d}}(q^m -1).\\ A_{\mathcal {C},d+1}= P_{\mathcal {M},d+1}(X)|_{X = {q^m}}&= \beta _{1,[d+1]}^{(1)} q^{2m} -( \beta _{1,[d+1]}^{(1)}+\beta _{2,[d+1]}^{(0)})q^m+\beta _{2,[d+1]}^{(0)}\\&= {{n} \brack {d+1}}(q^{2m} -{{d+1} \brack {1}}q^m+{{d+1} \brack {1}}-1). \end{aligned}$$

and so on. The weight spectra of MRD codes is determined in [4] as follows

$$\begin{aligned} A_{\mathcal {C},r} = {{n} \brack {r}} \sum \limits _{i=0}^{r-d} (-1)^i q^{i \atopwithdelims ()2}{{r}\brack {i}}(q^{mk - m(n+i-r)} -1). \end{aligned}$$

For \(r=d,d+1\), this gives us

$$\begin{aligned} A_{\mathcal {C},d}&= {{n} \brack {d}}(q^{mk - m(n-d)} -1)={{n} \brack {d}} (q^m -1). \\ A_{\mathcal {C},d+1}&= {{n} \brack {d+1}}(q^{2m} -{{d+1} \brack {1}}q^m+{{d+1} \brack {1}}-1) \end{aligned}$$

as expected.

Step 4 The higher weight spectra \(\{A_w^{(s)}\}\), for \(s\ge 2\) can be easily obtained by combining Proposition 68 with the knowledge of the \(A_{\mathcal {C},w}(Q).\) For example we determine the value \(A_{d+1}^{(2)}\).

$$\begin{aligned} A_{d+1}(q^{2m})&=\sum \limits _{s = 0}^{k}[r,s]_{q^m}A^{(s)}_{d+1}\\&=\sum \limits _{s = 0}^{k}\Pi _{i=0}^{s-1} ({q^m}^r - {q^m}^i) A^{(s)}_{d+1}\\&= (q^{2m} - 1) A^{(1)}_{d+1} + (q^{2m} - 1)(q^{2m}-q^m) A^{(2)}_{d+1}\\&= (q^m+1)A^{(0)}_{d+1} + (q^{2m} - 1)(q^{2m}-q^m) A^{(2)}_{d+1}\\&=(q^m+1){{n} \brack {d+1}}(q^{2m} -{{d+1} \brack {1}}q^m+{{d+1} \brack {1}}-1)\\&\qquad \qquad \qquad +(q^{2m} - 1)(q^{2m}-q^m) A^{(2)}_{d+1}\\ \end{aligned}$$

Since \(A_{d+1}(q^{2m}) = {{n} \brack {d+1}}(q^{4m} -{{d+1} \brack {1}}q^{2m}+{{d+1} \brack {1}}-1)\), after extending and simplifying the above equation we get,

$$\begin{aligned} {{n} \brack {d+1}} (q^{4m} - q^{3m} -q^{2m} + q^m)&= (q^{2m} - 1)(q^{2m}-q^m) A^{(2)}_{d+1}\\\ {{n} \brack {d+1}} (q^{2m} -1)(q^{2m} - q^m)&= (q^{2m} - 1)(q^{2m}-q^m) A^{(2)}_{d+1}\\ A^{(2)}_{d+1}&= {{n} \brack {d+1}}. \end{aligned}$$

7 Virtual Betti numbers

The two examples in Sect. 6 are really different, in the sense that in Example 74 we work with the Stanley–Reisner ring of the classical matroid \(N=Cl(\mathcal {M})^*,\) find its independence complex, and cycles, and treat it as any classical matroid, regardless of the fact that it “comes from” a q-matroid. In Example 75, however, we do not touch any classical matroid at all, in our concrete computations. The classical matroid basically just serves as a justification there, to work with Möbius functions of the lattice of q-cycles of \(\mathcal {M}^*\). We only know how to associate Stanley–Reisner rings to the independence complex of classical matroids and their elongations. From those rings we have seen that we can derive the Betti numbers of minimal resolutions as modules over polynomial rings. Moreover, it is clear that, via Corollary 61, we can associate well-defined Möbius-numbers to each such Betti number, where these numbers are defined in terms of the lattice of cycles of the matroid in question. Equivalently, it can be defined in terms of the inverted lattice, in this case the geometric lattice of flats of the dual matroid. We now define:

Definition 76

Let L be a lattice with rank function r. For \(l \in \{0,1,\ldots ,r(L)\},\) let \(L^{(l)}\) be the lattice obtained by replacing all the points of L of rank at most l by a single point, which then becomes the zero of \(L^{(l)}\). Then the rank function of \(L^{(l)}\) is given by \(r^{(l)}(P)=r(P)-l\) for any \(P \in L\) with \(r(P) \ge l\) and 0, otherwise. We set

$$\begin{aligned} V^{(l)}_{i,P}= {\left\{ \begin{array}{ll}(-1)^{r(P)-l}\mu ^{(l)}(0,P) &{}\text { if }r(P)=l+i, \\ 0 &{}\text { otherwise}, \end{array}\right. } \text { and }V_{i,P}=V^{(0)}_{i,P}. \end{aligned}$$

Here \(\mu ^{(l)}\) is the Möbius function of the lattice \(L^{(l)}\).

Definition 77

Let L be a lattice with rank function r. Then for a given non-negative function \(f:L \rightarrow \ \mathbb {N}_{0},\) we set

$$\begin{aligned} V_{i,j}^{(l),f}=\sum _{r(P)=l+i,f(P)=j}V^{(l)}_{i,P}\text {, and } V_{i,j}^f=V_{i,j}^{(0),f}\text {, and }V_{i}^f=\sum _jV_{i,j}^f. \end{aligned}$$

We call \(V_{i,j}^{(l),f}\) the l-th elongated virtual \(\mathbb {N}\)-graded Betti numbers and \(V_{i}^f\) the ungraded virtual Betti numbers.

For a Gabidulin rank-metric code \(\mathcal {C}\), we have already seen that the lattice of q-cycles of \(\mathcal {M}_{\mathcal {C}}^*\) and the lattice of cycles of \(N^*=Cl(\mathcal {M}_{\mathcal {C}})^*\) are isomorphic and if U be a q-cycle with \(dim~ U=j\), then the cardinality of its corresponding cycle R(U) of \(N^*\) is \(q^{n-1}+q^{n-2}+\cdots +q^{n-j}\). We then associate the functions \(f_1\) and \(f_2\) to these lattices, respectively, where \(f_1(U)=\dim ~ U\), and \(f_2(X)=|X|\) if X is of the form R(U) for U a q-cycle of dimension j, and 0 otherwise (or just \(f_2=|X|\) for all \(X \subseteq P(\mathcal {E})\)). It is then evident that:

$$\begin{aligned} \beta ^{(l)}_{i,R(U)}=V_{i,U}^{(l),f_1}, \end{aligned}$$

for each q-cycle U, and that:

$$\begin{aligned} \beta ^{(l)}_{i,[j]}=V_{i,j}^{(l),f_1}. \end{aligned}$$

So in Example 74, we really did use the “virtual Betti numbers” \(V_{i,j}^{(l)}=V_{i,j}^{(l),f_1}\) to determine \(A_{\mathcal {C},w}(Q)\) (or \(A_{\mathcal {C},w}(\tilde{Q})\) if one prefers). It is clear in that all results in the previous sections, involving the \(\beta _{i,R(U)}^{(l)}\) or the \(\beta ^{(l)}_{[j]}\) one can replace these invariants with the virtual Betti numbers, and thus reformulate all these results, only referring directly to the lattice of q-cycles of \(\mathcal {M}_{\mathcal {C}}^*\). In practical situations, one might prefer to use different lattices depending on the tools one has at hand, as explained in Examples 75 and 74.