A Polymatroid Approach to Generalized Weights of Rank Metric Codes

We consider the notion of a $(q,m)$-polymatroid, due to Shiromoto, and the more general notion of $(q,m)$-demi-polymatroid, and show how generalized weights can be defined for them. Further, we establish a duality for these weights analogous to Wei duality for generalized Hamming weights of linear codes. The corresponding results of Ravagnani for Delsarte rank metric codes, and Martinez-Penas and Matsumoto for relative generalized rank weights are derived as a consequence.


Introduction
Linear (block) codes are objects of basic importance in the theory of error correcting codes. A q-ary linear code of length n and dimension k, or in short, a [n, k] q -code C is simply a k-dimensional subspace of F n q , where F q denotes the finite field with q elements. A basic notion here is that of Hamming distance on the space F n q , which for two vectors x, y ∈ F n q is simply the number of nonzero coordinates in x − y. Rank metric codes are an important variant of linear codes, and they have gained prominence in the past few decades, partly due to myriad applications in network coding and cryptography, as also due to their intrinsic interest. Perhaps a more widely studied notion of rank metric codes is the one that goes back to Gabidulin's work [5] in 1985. A Gabidulin rank metric code, or simply, a Gabidulin code, of length n and dimension k may be defined as a k-dimensional subspace of the n-dimensional vector space F n q m over the extension field F q m of F q . By fixing a F q -basis of F q m , we can associate to any vector in F n q m an m × n matrix with entries in F q , and the rank distance between any x, y ∈ F n q m is defined as the rank of the difference of the matrices corresponding to x and y. The notion of a Delsarte rank metric code is in fact, older (it goes back to the work [3] of Delsarte in 1978) and more general. Indeed, a Delsarte rank metric code, or simply, a Delsarte code of dimension K is a K-dimensional subspace of the F q -linear space of all m × n matrices with entries in F q . As before, the rank distance between two m × n matrices is the rank of their difference. It is clear that a Gabidulin code of dimension k is a Delsarte code of dimension mk. But a Delsarte code need not be a Gabidulin code, even if its dimension is divisible by m. Generalized Hamming weights (GHW), also known as higher weights, of a linear code C are a natural and useful generalization of the basic notion of minimum distance of C. These were studied by Wei [22] who showed that the GHW d 1 , . . . , d k of a [n, k] q -code C satisfy nice properties such as monotonicity (d 1 < · · · < d k ) and more importantly, duality whereby the GHW of C and its dual C ⊥ determine each other. It was not immediately clear how an analogue of GHW for rank metric codes could be defined. But then three different definitions for the generalized rank weights (GRW) of a Gabidulin rank metric code were proposed by three sets of authors working in different parts of the globe, viz., Oggier and Sboui [18], Kurihara, Matsumoto and Uyematsu [13], and Jurrius and Pellikaan [11]. Thankfully, all three seemingly disparate definitions turn out to be equivalent (cf. [11]). Moreover, an analogue of Wei duality holds for the GRW; see, e.g., Ducoat [4]. For the more general class of Delsarte rank metric codes, Ravagnani [20] proposed an analogous definition of generalized weights (GW) and showed that in the special case of Gabidulin codes, the km GW of the corresponding Delsarte code are the same as the k GRW of the Gabidulin code (in accordance with the previous definitions), each repeated m times. Further, Ravagnani [20] established a duality for his GW of Delsarte rank metric codes. The notion of dual Delsarte codes is facilitated by the trace product, which associates to a pair (A, B) of m × n matrices with entries in F q the element Trace(AB t ) of F q . It is shown by Ravagnani [19] that for suitable choices of F q -bases of F q m , the notions of the (standard) dual of a Gabidulin code and of the (trace) dual of the corresponding Delsarte code are compatible.
In the classical case of linear codes, Britz et al [2] showed that Wei duality for generalized Hamming weights of linear codes is, in fact, a special case of Wei duality for matroids and also established Wei-type duality theorems for demi-matroids. It is natural, therefore, to ask if the notion of generalized (rank) weights for (Gabidulin or Delsarte) rank metric codes can be studied in the more general context of something like matroids, and if an analogue of Wei duality can be proved in this set-up. This is the question that we address in this paper. The notion that turns out to be relevant for us is that of a (q, m)-polymatroid, which has recently been introduced by Shiromoto [21]. (See also [8,7] for an essentially equivalent notion of a q-polymatroid.) Thus, we define generalized weights for (q, m)-polymatroids, and establish a Wei-type duality for them. As a corollary, we readily obtain the results of Ravagnani [20] for his GW of Delsarte codes and their duals, provided m > n. The cases m = n and m < n can also be covered, and these are addressed in Remark 30 and Proposition 40, respectively. To study the case m = n, and also for other purposes, we consider the more general class of (q, m)-demi-polymatroids and establish a duality result there. As another important application, we show how these general combinatorial objects can be applied to flags, or chains, of Delsarte rank metric codes. In particular, by considering pairs, i.e., flags of length 2 of Delsarte codes, we recover several results of Martínez-Peñas and Matsumoto [17] on the so called relative generalized rank weights of Delsarte codes. We remark that q-analogues of matroids, called q-matroids and q-polymatroids, have been considered by Jurrius and Pellikaan [12] and by Gorla, Jurrius, Lopez, and Ravagnani [8], respectively. However, as far as we can see, Wei-type duality for the generalised weights of these objects is not shown in these papers.
This paper is organized as follows. In Section 2 below, we review the definition of a (q, m)-polymatroid and outline some basic notions and results. Generalized weights of a (q, m)-polymatroid are defined and Wei-type duality for them is established in Section 3. These results are then applied to Delsarte rank metric codes in Section 4. In Section 5 we introduce (q, m)-demi-polymatroids, show Wei duality for these objects, and apply it to Delsarte rank metric codes consisting of square matrices. Flags of Delsarte rank metric codes, and their duality theory, are discussed in Section 6. Several examples and applications are also included here.

Preliminaries about (q, m)-Polymatroids
Throughout this paper N 0 denotes the set of all nonnegative integers, m, n denote positive integers, q a prime power, and F q the finite field with q elements. We let E be the vector space F n q over F q and let Σ(E) = the set of all F q -linear subspaces of E.
For X ∈ Σ(E), we deonte by X ⊥ the dual of X (with respect to the standard "dot product"), i.e., X ⊥ = {x ∈ E : x · y = 0 for all y ∈ X}. It is elementary and well-known that The following key defnition is due to Shiromoto [21, Definition 2].
Definition 1. A (q, m)-polymatroid is an ordered pair P = (E, ρ) consisting of the vector space E = F n q and a function ρ : Σ(E) → N 0 satisfying the following three conditions for all X, Y ∈ Σ(E): The nonnegative integer ρ(E) is called the rank of P and is denoted by rank P . The function ρ may be called the rank function of P .
The following basic fact is proved in [21].
If P = (E, ρ) and ρ * are as in Proposition 3, then the (q, m)-polymatroid (E, ρ * ) is denoted by P * and called the dual of P . Note that ρ({0}) = 0 by (R1) and so Definition 4. Let P = (E, ρ) be a (q, m)-polymatroid. The nullity function of P is the map ν : Σ(E) −→ N 0 defined by The conullity function of P is the map ν * : Σ(E) −→ N 0 defined by By way of giving an example of a (q, m)-polymatroid, we describe below an important class of (q, m)-polymatroids.
Example 5. Let r be a nonnegative integer ≤ n. The uniform (q, m)-polymatroid U (r, n) is defined as (E, ρ), where E = F n q , and ρ(X) = m dim X, for all X ∈ Σ(E) with dim X ≤ r, while ρ(X) = mr for all X ∈ Σ(E) with dim X ≥ r. It is easy to see that U (r, n) is indeed a (q, m)-polymatroid and also that U (r, n) * = U (n − r, n).
Elementary properties of nullity and conullity functions are given below. The proof is analogous to [21,Lemma 4], but included for the convenience of the reader.
Proof. (a) By extending a basis of X to Y , we can find Z ∈ Σ(E) such that Thus, using (R3), we obtain On the other hand, by (R1), This proves that ν(X) ≤ ν(Y ). Replacing P by P * , we obtain ν * (X) ≤ ν * (Y ). (b) The desired upper bound for ν(Y ) − ν(X) follows by noting that by (R2), As in (a), the inequality for ν * follows from using P * in place of P .
Remark 7. Proposition 6 shows that if P = (E, ρ) is a (q, m)-polymatroid, then the conullity function ν * of P is a monotonically increasing function on Σ(E) (ordered by inclusion of subspaces of E) and it takes values ranging from ν * ({0}) = 0 to ν * (E) = ρ(E) − ρ(E ⊥ ) = ρ(E) − ρ({0}) = ρ(E) = rank P. However, unlike in the case of usual matroids, there is no "discrete intermediate value theorem" saying that every integer value between 0 and ρ(E) is attained as the conullity of some subspace of E. Moreover, although Proposition 6 shows that the pairs (E, ν) and (E, ν * ) satisfy the axioms (R1) and (R2) in the definition of a (q, m)-polymatroid, neither of these are, in general, (q, m)-polymatroids. To see these two assertions, it suffices to consider the uniform (q, m)-polymatroid U (1, 2). Indeed, in this case U (1, 2) = (E, ρ), where E = F 2 q , and it is easily seen that for any subspace X of E, Thus, a "discrete intermediate value theorem" does not hold for ν as well as for ν * if m > 1. Furthermore, if X, Y are distinct 1-dimensional subspaces of E = F 2 q , then X + Y = E and X + Y = {0}, and hence It follows that neither (E, ν) nor (E, ν * ) is a (q, m)-polymatroid.

Wei duality of (q, m)-polymatroids
The following definition for the generalized weights of a (q, m)-polymatroid appears to be natural. Definition 8. Let P = (E, ρ) be a (q, m)-polymatroid and let K = rank P . For r = 1, . . . , K, the rth generalized weight of P is defined by Here are some simple properties of generalized weights of (q, m)-polymatroids.
Proposition 9. Let P = (E, ρ) be a (q, m)-polymatroid and let K = rank P . Then Unlike the generalized Hamming weights of linear codes, strict monotonicity may not hold for generalized weights of (q, m)-polymatroids, i.e., we may not have d r (P ) < d r+1 (P ) for 1 ≤ r < K. For example, if K > n, then Proposition 9 implies that d r (P ) = d r+1 (P ) for some r < K. However, we will show that d r (P ) < d s (P ) for 1 ≤ r < s ≤ K, provided s − r ≥ m. First, we need some preliminary results. Now fix a positive integer x ≤ n. Then h * (x − 1) ≤ h * (x) and for 1 ≤ r ≤ K, In particular, x is a generalized weight of P if and only if h * (x − 1) < h * (x). Also, h(x − 1) ≤ h(x) and if P * is the dual of P , then for 1 ≤ s ≤ rank P * = mn − K, In particular, x is a generalized weight of P * if and only if h(x − 1) < h(x).
The equivalence (2) follows by applying (1) to P * in place of P .
Here is a nice relation between the functions h and h * defined in Lemma 10.
Lemma 11. Let P = (E, ρ) be a (q, m)-polymatroid and let K = rank P . Then Consequently, Proof. Given any X ∈ Σ(E), note that ν( Taking maximum as X varies over elements of Σ(E) with dim X = x, we obtain (3).
Corollary 12. Let P = (E, ρ) be a (q, m)-polymatroid and let K = rank P . Then This contradicts the last assertion in Lemma 11. Thus d r (P ) < d r+m (P ). Replacing P by P * , we obtain the desired inequality for the generalized weights of P * .
We shall now proceed to establish a version of Wei duality for the generalized weights of (q, m)-polymatroids. Recall that if C is a [n, k] q -code, and d 1 , . . . , d k are the generalized Hamming weights (GHW) of C and d ⊥ 1 , . . . , d ⊥ n−k are the GHW of the dual of C, then Wei duality states that the values are all distinct and their union is precisely the set {1, . . . , n}. In the setting of a polymatroid P = (E, ρ) of rank K, the generalized weights of P and its dual P * lie between 1 and n, and we can similarly consider But these mn values would not constitute {1, . . . , mn} when m ≥ 2, since they lie between 1 and n. But one could ask for some "m-fold" version of Wei duality, and that is what we give in the next theorem and the corollary that follows. These results are inspired by the related results of Ravagnani [20] and also of Martínez-Peñas and Matsumoto [17] about generalized weights (GW) and relative GW of Delsarte rank metric codes.
Theorem 13. Let P = (E, ρ) be a (q, m)-polymatroid of rank K. Also, let p, i, j be integers such that 1 ≤ p + im ≤ mn − K and 1 ≤ p + K + jm ≤ K. Then Proof. Write r = p + K + jm, s = p + im, and x = d r (P ). Let h and h * be as in Lemma 10. In view of (4), let Then using (1), we see that Thus r ≤ h * (x) < r + m − g, and therefore by (3), we obtain The second inequality above implies that Combining this with the inequalities obtained earlier, we see that But this contradicts the fact that s ≡ p (mod m).
Also define W s (P * ) and W s (P * ) in a similar manner. Then where s + m K means the integer in {0, 1, · · · , m − 1} congruent to s + K modulo m.
Proof. By Theorem 13, the sets W s (P * ) and W s+ m K (P ) are disjoint, and by Proposition 9, they are subsets of {1, 2, · · · , n}. Thus it suffices to show that the sum of their cardinalities is at least n (and therefore exactly n). To this end, write s + K = Am + B for integers A, B with 0 ≤ B < m. Note that s + m K = B. Let us first consider the case s = 0. Here, by the definition of W s (P * ), and the frequent leaps, guaranteed by Corollary 12, of the d s+jm (P * ) as j increases, we see that: On the other hand, Corollary 12 also shows that Next, suppose s > 0. Here, in a similar manner, Corollary 12 shows that and also that So, once again |W s (P * )| + |W s+ m K (P )| ≥ n (and hence equal to n), as desired.
Remark 15. The above corollary shows that the generalized weights of a (q, m)polymatroid P and the generalized weights of its dual P * determine each other. Indeed, first we treat only the d r (P * ) and d r+ m K (P ), for r ≡ s, for a fixed value of s. By Corollary 14 they determine each other. Since this is true for each fixed s, as s varies in {0, 1, · · · , m − 1}, the assertion holds. We remark also that the proofs given here of Theorem 13 and the two preceding lemmas are motivated by the proofs of the corresponding results for usual matroids (see, e.g., [15,Proposisjon 5.18]). Further, our proof of Corollary 14 uses arguments that are analogous to those in the proof of [20, Corollary 38].

Generalized Weights of Delsarte Rank Metric Codes
In this and the subsequent sections, we will denote by M m×n (F q ), or simply by M the space of all m × n matrices with entries in the finite field F q . Note that M is a vector space over F q of dimension mn.
As stated in the Introduction, by a Delsarte rank metric code, or simply a Delsarte code, we mean a F q -linear subspace of M. We write dim Fq C, or simply dim C, to denote the dimension of a Delsarte code C.
Following Shiromoto [21], we associate to a Delsarte code C, a family of subcodes of C indexed by subspaces of E = F n q , and a (q, m)-polymatroid as follows.
Definition 16. Let C be a Delsarte code.
(a) Given any X ∈ Σ(E), we define C(X) to be the subspace of C consisting of all matrices in C whose row space is contained in X. (b) By ρ C we denote the function from Σ(E) to N 0 defined by Further, by P (C) we denote the (q, m)-polymatroid (E, ρ C ).

Remark 17.
It is shown in [21,Proposition 3] that P (C) = (E, ρ C ) does indeed satisfy all the axioms of a (q, m)-polymatroid. We note also that the conullity function ν * C of P (C) is given by Example 18. Assume, for simplicity, that m > n. Let C ⊆ M m×n (F q ) be a MRD code of dimension K. (See, for example, [19, § 2] for the definition and basic facts about MRD codes.) Then C is a Delsarte code such that K = dim C is divisible by m and C(X) = {0} for all subspaces X of E with dim X ≤ n − K m . The latter follows, for instance, from [8,Proposition 6.2]. This shows that ρ C (X) = K if X ∈ Σ(E) with dim X ≥ K/m. Further, in view of [8,Theorem 6.4], we see that In general we loosely think of X as (containing) the "support" of the code C(X), and C(X) as "the subcode of C supported on X". This gives rise to the idea of the rth generalized weight as the smallest dimension of a subspace that can support an r-dimensional subcode, in analogy with the smallest cardinality of a subset that can support an r-dimensional subcode, for a block code with Hamming metric. In other words we define: Definition 19. Let C be a Delsarte code and let K = dim C. For r = 1, · · · , K, the rth generalized weight of C is defined by Remark 20. This definition is in harmony with the one given by Martínez-Peñas and Matsumoto [17] of the rth relative generalized weight : ). See also their Appendix A, where duality theory for a single code is treated.
We then have defined generalized weights for (q, m)-polymatroids as well as Delsarte codes, in a way intended to give the following result as a consequence: Proof. Clearly, ρ C (E) = dim C. Thus dim C = rank P (C) and for any X ∈ Σ(E), where ν * denotes the conullity function of P (C). It follows that d r (C) = min{dim X : X ∈ Σ(E) with ν * (X) ≥ r} = d r (P (C)) for any r = 1, . . . , dim C.

4.1.
Duality of Delsarte rank metric codes. As indicated in the Introduction, the notion of dual for Delsarte reank metric codes is defined using the trace product. See for example [20,Definition 34]. We record the basic definition below.
Definition 22. Let C be a Delsarte code. The trace dual, or simply the dual, of C is the Delsarte code C ⊥ defined by where N t denotes the transpose of a m × n matrix N and, as usual, Trace(M N t ) is the trace of the square matrix M N t , i.e., the sum of all its diagonal entries.
There is a natural connection between duals of Delsarte codes and the duals of (q, m)-polymatroids. It is shown by Shiromoto [21] as well as Gorla, Jurrius, Lopez and Ravagnani [8], and we record it below. Example 25. Assume that m > n. Let C be an MRD code of dimension K = mK ′ . As we saw in Example 18, P (C) = U (K ′ , n). Then P (C ⊥ ) = P (C) * = U (n−K ′ , n), which translated back to the language of codes gives dim C(X) = {0}, for all subspaces X of E of dimension at most K ′ . Hence we obtain the well-known fact that if C is an MRD code of dimension K = mK ′ , then C ⊥ is an MRD-code of dimension mn − K = m(n − K ′ ).
Example 26. If C is a Delsarte code with dim C is divisible by m, as for example for a Gabidulin code, or an MRD-code, then the conclusion of Corollary 14 is Here is Ravagnani's definition of generalized weights of Delsarte codes.
Definition 28. Let C be a Delsarte code of dimension K. Define a r (C) = 1 m min dim Fq A : A an optimal anticode such that dim Fq (A ∩ C) ≥ r .
A relationship between the two notions (given in Definitions 19 and 28) is stated below. This result is given in [17,Theorem 9] as well as [8,Proposition 2.11], and we refer to the former for a proof of the following theorem.
Theorem 29. Let C be a Delsarte code. Then for each r = 1, . . . , dim C, Remark 30. Theorem 29 gives a second proof of Corollary 24 when m > n, since the corresponding result for the a r (C) and a r (C ⊥ ) is given by Ravagnani [20,Corollary 38]. Also, when m = n, both [20, Corollary 38] and Corollary 24 are still valid, but the a r and the d r are not necessarily the same. An example where they are different is given by Martínez-Peñas and Matsumoto [17, Section IX,C]. Another proof of Corollary 24 is given in [17, Lemma 66, Corollary 68]. We refer to [7, Theorem 5.14] and [7, Theorem 5.18] for a fuller treatment of the case m = n, and also for the cases where m < n. We will, however, based on that treatment, return to the case m = n in Subsection 5.1. Here we just remark briefly that if, on the other hand, m < n, then it will be more natural to work with the (q, n)-polymatroid P (C T ) (where C T is the set of transposes of matrices in C) than with the (q, m)-polymatroid P (C). In particular it follows from [7,Theorem 5.18] that the generalized weights given in [20] coincide with the generalized weights for the (q, n)-polymatroid P (C T ). Hence Wei duality for polymatroids gives a second proof for the Wei duality of Ravagnani's generalized weight also for m < n.
Remark 31. It is a main point in our exposition that we can prove our main results, Theorem 13, and Corollary 14, without even mentioning Delsarte rank metric codes, but at the same time, these results imply the "Wei duality" when the (q, m)polymatroid in question indeed comes from a Delsarte rank metric code. One might wonder whether there are (q, m)-polymatroids that do not come from Delsarte rank metric codes, but where our Wei duality may give interesting descriptions for other objects. For usual matroids, there are matroids that are non-representable, and thus do not come from linear codes. An example is the non-Pappus matroid M (say), with ground set of cardinality 9. The Wei duality of matroids, as described for example in [2] or [15,Proposisjon 5.18] without mentioning codes, is enjoyed by M as well. But for the non-Pappus matroid M, Wei duality can also be interpreted in a coding theoretic sense, except that instead of (linear block) codes, we have to consider the so called almost affine codes, which can be nonlinear and whose alphabet set need not even be a field; see [9, Example 1]. In analogy with this, we may ask the following. Is there a class of codes strictly bigger (or quite different) than that of Delsarte rank metric codes, such that the codes in this class give rise to (q, m)-polymatroids, and where duality of codes corresponds to duality of (q, m)-polymatroids, and moreover, "Wei duality" for (q, m)-polymatroids can be interpreted in a coding theoretic sense?
Example 32. We will describe a (q, m)-polymatroid P , which is not defined as a P (C) for a single Delsarte code C, but is derived from a collection of m codes.
Let C 1 , . . . , C m be m block codes of length n over F q . We will view the codewords as 1 × n matrices, and the C i as Delsarte rank metric codes. Let Note that for each i = 1, . . . , m, the space C i (X) coincides with C i ∩ X whenever X ∈ Σ(E) and thus the rank function ρ i = ρ Ci of P (C i ) is given by Also note that the trace dual C ⊥ i is simply the usual orthogonal complement of C i as a block code. Clearly, P (C i ) as well as P (C ⊥ i ) are (q, 1)-polymatroids. Since It is easy to see that P = (E, ρ) satisfies all the axioms for (q, m)-polymatroids. Moreover, as a (q, m)-polymatroid, for any X ∈ Σ(E), we obtain and hence if ν * denotes the conullity function of P , then, in view of (6), we find Thus the generalized weights of the (q, m)-polymatroid P are given by for r = 1, . . . , K, whereas the generalized weights of P * are given by for r = 1, . . . , mn − K. A relation between these two sets of generalized weights is described in Theorem 13 and Corollary 14. From the construction of P , we see that d 1 (P ) = 1, unless all C i are zero, since we may take some one dimensional X contained in some C i , and calculate dim C i ∩ X = 1. Analogously, d 1 (P * ) = 1 as well, unless C i = E, for all i. On the other hand d K (P ) = n, unless there is a strict subspace of E that contains all the codes C i . So, if C i = E, for some i, but the span of C 1 ∪ · · · ∪ C m is E, then d 1 (P * ) = 1 and d rank(P ) (P ) = n, a possibilty excluded if the "usual" Wei duality were applicable, but which indeed may occur, and in fact does occur, under the "revised" duality described in Theorem 13 and Corollary 14. Given that d 1 (P * ) = 1, Theorem 13 only prohibits that d r (P ) = n for all r congruent to K + 1 modulo m. But K is certainly not congruent to K + 1 modulo m, and so d K (P ) may very well be n.
In a certain sense this example is also associated to m × n matrices, since each element of C 1 × · · · × C m could be presented as m codewords of length n arranged as an m × n matrix. Our function ρ does however not "measure the behaviour" of the row space of the matrix, including all linear combinations of the rows, as a rank function of a P (C) of a Delsarte rank metric code C would have done; it only "measures the behaviour" of the individual rows. "Intermediate" examples could have been made by taking ρ(X) = ρ 1 (X)+· · ·+ρ s (X), where ρ i is the rank function of an m i × n Delsarte rank metric code, for 1 ≤ i ≤ s, and where m 1 , . . . , m s are nonnegative integers with m 1 + · · · + m s = m.

Demi-polymatroids and their Generalized Weights
In this section, we discuss a generalization of the notion of (q, m)-polymatroids, and observe that most of the results in Section 2 can be extended in a more general context. In the next section we shall see how this generalization is relevant for Delsarte rank metric codes.
Definition 33. A (q, m)-demi-polymatroid is an ordered pair (E, ρ) consisting of the vector space E = F n q over F q and a function ρ : Σ(E) → N 0 satisfying the following three conditions: also satisfies (R1) and (R2).
The notion of dual is defined exactly as in the case of (q, m)-polymatroids and we have the following analogue of Proposition 3 or equivalently, [21,Proposition 5].
Example 36. If C ⊆ M m×n (F q ) is a Delsarte code and δ : Σ(E) → N 0 is defined by then Remark 17 and Proposition 35 shows that (E, δ) is a (q, m)-demi-polymatroid. Moreover, in view of Example 18 and Remark 7, we see that (E, δ) is, in general, not a (q, m)-polymatroid.
In general, if P = (E, ρ) is a (q, m)-demi-polymatroid, then the nullity function ν and the conullity function ν * of P are defined in exactly the same way as in the case of (q, m)-polymatroids, i.e., by equation (7). Our proof of Proposition 6 (a) used the property (R3), which is not available in the case of (q, m)-demi-polymatroids, but we will show below that the result is still valid in this case.
We define the generalized weights for (q, m)-demi-polymatroids in exactly the same way as in the case of (q, m)-polymatroids: Definition 38. Let P = (E, ρ) be a (q, m)-demi-polymatroid. For r = 1, . . . , ρ(E), the rth generalized weight of P is defined by We then have the following more general result about Wei-type duality.
Theorem 39. The results in Theorem 13 and Corollary 14 are valid also for (q, m)demi-polymatroids P .
Proof. Examining the proof of Theorem 13, we see that all arguments follows from axioms (R1), (R2), (R4), and there is no need for axiom (R3). One does use Proposition 6 whose proof depended on (R3), but we have established it for (q, m)demi-polymatroids in Proposition 37 above.

5.1.
Wei duality for square matrices. In this subsection, we consider the case when m = n. In this case, if C ⊆ M m×n (F q ) is a Delsarte rank metric code, then so is C T := {M t : M ∈ C}, and thus, we obtain two (q, m)-polymatroids P (C) = (E, ρ C ) and P (C T ) = (E, ρ C T ), where E = F n q and ρ C , ρ C T are as in (5). Proposition 40. Assume that m = n. Let C ⊆ M m×n (F q ) be a Delsarte rank metric code. Consider E = F n q and define ρ : Σ(E) → N 0 by ρ(X) = min{ρ C (X), ρ C T (X)} for X ∈ Σ(E).
Then P = (E, ρ) is a (q, m)-demi-polymatroid and its conullity function is given by Moreover, the generalized weights of P are given by d r (P ) = min{d r (P (C)), d r (P C T } for r = 1, . . . , ρ(E).

Consequetly, the Wei duality holds for Ravagnani's generalized weights a r (C).
Proof. It is obvious that ρ satisfies (R1) and (R2) of Definition 33, since we know that each of ρ C and ρ C T satisfies these properties. So, in order to prove that P is a (q, m)-demi-polymatroid, it remains to show that (R4) is satisfied, which means that ρ * satisfies (R1) and (R2). To this end, let X ∈ Σ(E). Then This implies that ρ * (X) ≤ m dim X. Moreover, it also implies that ρ * (X) ≥ 0, because from (6) and Proposition 35 we see that both m dim X − dim C(X) and m dim X − dim C T (X) are nonnegative. Thus ρ * satisfies (R1). Next, we show that ρ * satisfies (R2). Fix X, Y ∈ Σ(E) with X ⊆ Y . In view of (8), the difference ρ * (Y ) − ρ * (X) can be written as Since the expression above is symmetric in C and C T , we may assume without loss of generality that max{dim C(Y ), dim C T (Y )} = dim C(Y ). Now, in case max{dim C(X), dim C T (X)} = dim C(X), we see that , which is nonnegative since ρ * C satisfies (R1), thanks to Proposition 3. In case max{dim C(X), dim C T (X)} = dim C T (X), then dim C T (X) ≥ dim C(X), and so , which is again nonnegative. Thus ρ * satisfies (R2). This proves that P = (E, ρ) is a (q, m)-demi-polymatroid. The desired formula for the conullity function of P is immediate from (8). This, in turn, shows that d r (P ) = min{d r (P (C)), d r (P C T } for r = 1, . . . , ρ(E).
Indeed, the inequality d r (P ) ≤ min{d r (P (C)), d r (P C T } is clear from the definition and equation (6). For the other inequality, it suffices to consider The last assertion about Wei duality for Ravagnani's generalized weights a r (C) is an immediate consequence of Theorem 39 because we know from [7, Theorem 38] that a r (C) = min{d r (P (C)), d r (P C T } for 1 ≤ r ≤ dim C = ρ(E).

Flags of Delsarte Rank Metric Codes
Definition 41. By a flag of Delsarte codes we shall mean a tuple F = (C 1 , . . . , C s ) of subspaces of M = M m×n (F q ) such that C s ⊆ C s−1 ⊆ · · · ⊆ C 1 . The rank function associated to a flag F = (C 1 , . . . , C s ) is the map ρ F : Σ(E) → Z given by (9) for i = 1, . . . , s and X ∈ Σ(E).
Observe that if F is the singleton flag (C), then ρ F coincides with the map ρ C introduced in Definition 16. We have noted in Remark 17 that P (C) = (E, ρ C ) is a (q, m)-polymatroid. We will show that P (F) = (E, ρ F ) is a (q, m)-demi-polymatroid for any flag F of Delsarte codes. The main components of the proof will be shown in the form of a couple of lemmas.
Proof. Note that the row space of any A ∈ M consists of vectors vA as v varies over F m q (elements of F m q and F n q are thought of as row vectors); also note that (vA) · u = u(vA) t = (uA) t v t for any u ∈ F n q . Now let X ∈ Σ(E) and define U = {A ∈ M m×n (F q ) : uA t = 0 for all u ∈ X}.
Clearly, U is a subspace of M and C(X ⊥ ) = C ∩ U for any Delsarte code C. Also, Proof. First observe that dim M(X) = m dim X. Indeed, any A ∈ M(X) uniquely determines a F q -linear map φ A : F m q → X given by v → vA, and A → φ A defines an isomorphism of M(X) with the space of all inear maps from F m q to X. Similarly, dim M(Y ) = m dim Y . Let B X , B Y and B be bases of M(X), M(Y ) and M such that B X ⊆ B Y ⊆ B. We can use the basis B to define a F q -linear isomorphism π : M → F mn q so that Delsarte codes C in M can be identified with linear block codes π(C) of length mn. Write generator matrices of π(C 1 ) and π(C 2 ) as where the blocks P and S correspond to coordinates with respect to B X while the blocks Q and T correspond to coordinates with respect to B Y \ B X . By removing from G 1 superfluous rows that may have become linearly dependent when restricted to coordinates w.r.t. B Y , we see that a generator matrix for π(C 1 (Y )) is of the form P ′ Q ′ S ′ T ′ and its submatrix P ′ Q ′ is a generator matrix for π(C 1 (X)). Consequently, On the other hand, This proves the desired inequality.
Here is the result that was alluded to earlier in this section. Proof. First, suppose s is even, say s = 2t. Then for any X ∈ Σ(E), By Lemma 42, each summand is nonnegative, and so ρ F (X) ≥ 0. In case s = 2t + 1, and once again ρ F (X) ≥ 0, thanks to Remark 17 and Lemma 42. Next, if s > 1 and if F ′ = (C 2 , . . . , C s ) denotes the flag obtained from F by dropping the first term, then by what is just shown ρ F ′ (X) ≥ 0 for any X ∈ Σ(E). Hence ρ . This shows that P (F) satisfies (R1). Next, let X, Y ∈ Σ(E) with X ⊆ Y . We will show that ρ F (X) ≤ ρ F (Y ). To this end, observe that since ρ F (X) (and likewise ρ F (Y )) can be expressed as in (10) or (11), and since ρ 2t+1 satisfies (R2), it suffices to show that the difference is nonnegative. But an easy calculation shows that this difference is equal to But since Y ⊥ ⊆ X ⊥ , by Lemma 43, the above difference is nonnegative. This shows that P (F) satisfies (R2). To prove that P (F) satisfies (R4), note that the case s = 1 is trivial. Thus suppose s > 1 and let F ′ = (C 2 , . . . , C s ). Also, let where ν 1 denotes the nullity function of (E, ρ 1 ). Thus, using Proposition 6 (a) and the fact that ρ ′ satisfies (R2), we see that ρ * satisfies (R4).
Using Theorem 44 and Definition 38, we can talk about generalized weights of flags of Delsarte codes. The following observation makes them explicit.
Proof. For i = 1, . . . , s, let ρ i be as in (9) and let ν * i be the conullity function of the (q, m)-polymatroid (E, ρ i ). Then in view of (6) in Remark 17 we see that for any X ∈ Σ(E).
We can now introduce the following generalization of Definition 19.
Definition 46. Let F = (C 1 , . . . , C s ) be a flag of Delsarte codes in M, and let Then for r = 1, . . . , K, the rth generalized weight of F is denoted by d r (F) or by d M,r (C 1 , · · · , C s ), and is defined by We remark that for s = 2, these generalized weights were already defined by Martínez-Peñas and Matsumoto [17,Definition 10], and are referred to as RGMW profiles, where RGMW stands for Relative Generalized Matrix Weights. In [17] one studies these and and related profiles, and the interplay between them, in a way that carries the ideas and results of Luo, Mitrpant, Han Vinck, and Chen [16] for pairs of block codes over to the world of Delsarte rank metric codes, in a way similar to the one, in which the relative profiles in [16] are generalizations of those "absolute ones" in the work of Forney [6] for single block codes. Now that we have associated a (q, m)-demi-polymatroid P (F) = (E, ρ F ) to a flag F of Delsarte codes, it seems natural to ask whether P (F) * is also a (q, m)-demipolymatroid associated to some flag of Delsarte codes. The answer is yes, and it involves, quite naturally, the dual flag defined as follows.
By the dual flag corresponding to a flag F = (C 1 , . . . , C s ) of Delsarte codes, we mean the flag Proof. A proof can be given, following word for word the proof of the corresponding result, [1, Theorem 10], for linear block codes.
Proposition 47 identifies the dual (q, m)-demi-polymatroid of P (F) as that associated to the dual flag, when F is a flag of odd length s, including the case s = 1 (a case which trivially follows from Theorem 23). But what about the cases when s is even, including s = 2, which perhaps are the most interesting ones? To this we remark that our study does not require the Delsarte codes in the flag to be distinct. Thus, whenever s is even, we can formally "add" a subspace C s+1 = {0}, (irrespective of whether or not C S = {0}) to obtain a longer flag G of odd length s + 1. Then it is easily seen that ρ G = ρ F , and using the duality for flags of even length, we obtain In particular, in the important case s = 2 studied in [17], Furthermore, if one wants to organize the set of flags, into disjoint subsets, selfdual both with respect to (q, m)-demi-polymatroid duality, and the duality F → F ⊥ of flags, we may as a convention first assume that all the Delsarte codes in each flag are distinct and nonzero. Then we get two cases, namely, flags of odd length and flags of even length. Now we modify our convention and add the zero code as the innermost code in all even length flags. After this is done, all flags have odd length 2t + 1, and all the Delsarte codes in each flag F = (C 1 , . . . , C 2t+1 ) are distinct, and the possibility that both C 2t+1 = {0}, and C 1 = M is perimitted. We call such flags as normalized flags. We can then deduce from Proposition 47 the following.
Proposition 48. Each (q, m)-demi-polymatroid associated to a flag (of Delsarte codes) in M comes from a unique normalized flag in M of odd length. For each t = 1, 2, · · · , ⌊ mn 2 ⌋, the class of flags of length 2t + 1, and also its associated class of (q, m)-demi-polymatroids, is self-dual, and further, P (F) * = P (F ⊥ ) for every normalized flag F.
Remark 49. If F is a normalized flag, then the longest possible length of F is clearly mn + 1. The longest flag (C 1 , . . . , C mn+1 ) of distinct Delsarte codes in M will necessarily have C mn+1 = {0}, Hence if mn is odd, then it is not normalized, but if we delete C mn+1 = {0} then it does become normalized and has odd length. Thus, the length of the longest normalized flag in M is 2t + 1, where t = ⌊ mn 2 ⌋. As an immediate consequence of Theorem 39 and Proposition 48, we obtain a duality for the generalized weights of (normalized) flags of Delsarte codes. In the special case s = 2 studied in [17], this duality can be stated as follows.
Corollary 50. Let C 1 , C 2 be distinct Delsarte codes in M m×n (F q ) with C 2 ⊂ C 1 . Then the relative generalized weights d r = min{dim X : X ∈ Σ(E) with dim C 1 (X) − dim C 2 (X) ≥ r} are related to the relative generalized weights We end this paper by giving some examples.
For a 1-dimensional J ∈ Σ(E), we see that ρ * (J) is s i=1 b i , where b i = m i whenever V ⊥ i contains J, and b i = 0 otherwise. So, if there exists at least one 1-dimensional J for which at least one V ⊥ i does not contain J, then we see that ν * (J) ≥ 1, and the first generalized weight of P is d 1 = 1. It follows that d 1 (P ) = 1, unless V ⊥ i = E for all i, or equivalently, ρ = 0. We remark that the functions ρ and ρ * are, in fact, the conullity and nullity functions of the (q, m)-polymatroid of Example 32 in disguise. Also, as noted in Proposition 35, the conullity and nullity functions of (q, m)-polymatroids give rise to (q, m)-demi-polymatroids, but not necessarily (q, m)-polymatroids.