Zulip Chat Archive

Stream: mathlib4

Topic: Matroid rank - naming poll


Peter Nelson (Jan 23 2025 at 20:03):

This stuff is on its way from my repo to mathlib, and so for the sake of planning ahead, I wanted to solicit a consensus.

A matroid M : Matroid α is a certain structure on a type α with a distinguished 'ground set' M.E : Set α.
For each X : Set α, there is a notion of the 'rank of X in M, which generalizes the usual rank in linear algebra. The 'rank of M' refers to the rank in M of the set M.E.

In various settings, it is reasonable for rank to take values in , ℕ∞ and Cardinal.
All three versions are useful. The version, in particular, is all that is used in 95% of the literature, the ℕ∞ version is far less common but is needed for formalizing infinite matroids, and the Cardinal version is even less common (and not well-defined for all matroids), but has some applications. It is also very helpful to refer to the 'rank of a matroid' separately from just saying 'rank of the ground set in the matroid'. This means, in practice, that the following things need names:

  • a term Matroid α → ℕ assigning each matroid its rank as a natural number.
  • a term Matroid α → ℕ∞ assigning each matroid its rank as an extended natural number.
  • a term Matroid α → Cardinal assigning each matroid its rank as a cardinal.
  • a term in Matroid α → Set α → ℕ assigning each set to its -valued rank in a matroid
  • a term in Matroid α → Set α → ℕ∞ assigning each set to its ℕ∞-valued rank in a matroid
  • a term in Matroid α → Set α → Cardinal assigning each set to its Cardinal-valued rank in a matroid.
  • certain typeclasses in Matroid α → Prop stating a matroid's rank is finite/infinite/positive.

The current terms in my repo are

  • Matroid.rk (M : Matroid α) : ℕ
  • Matroid.erk (M : Matroid α) : ℕ∞
  • nothing yet for cardinal rank
  • Matroid.r (M : Matroid α) (X : Set α) : ℕ
  • Matroid.er (M : Matroid α) (X : Set α) : ℕ∞
  • nothing yet for cardinal rank of sets
  • FiniteRk, RkPos, etc for typeclasses.
    (Also already in mathlib, but can be changed without too much hassle)

I've favoured short names here, especially for the functions on sets, because they are ubiquitous in calculations, and because r is the usual pen-and-paper notation for all notions of rank. But perhaps notation that terse is bad for other reasons. A poll follows with some options. (The Matroid namespace is assumed)

Peter Nelson (Jan 23 2025 at 20:03):

/poll How should matroid rank terms be named?
rk, erk, cardrk for the terms, r, er, cardr for the set functions, FiniteRk etc for the typeclasses
rank, erank, cardRank for the terms, rk, erk, cardRk for the set functions, FiniteRank etc for the typeclasses
Something else

Eric Wieser (Jan 23 2025 at 20:22):

I guess the closest comparison would be Module.rank and Module.finrank. I'm curious if you can make do without the ENat version, since we were able to make do without it for linear algebra. If both ENat and Cardinal are rare, then the slight pain of using the cardinal one for the enat case shouldn't come up enough to matter.

Eric Wieser (Jan 23 2025 at 20:22):

Is M.rk the same thing as M.r univ, using the names in your initial message?

Peter Nelson (Jan 23 2025 at 20:23):

Eric Wieser said:

Is M.rk the same thing as M.r univ, using the names in your initial message?

Yes, but also M.r M.E, which comes up more.

Peter Nelson (Jan 23 2025 at 20:24):

The ENat version is needed, because (for instance), it is consistent with ZFC that there are matroids having both a countable basis and an uncountable basis.

This means that cardinal rank, even if defined as a supremum or infimum of the cardinalities of bases, will not have nice properties at the full generality of matroids (as a concrete example, things like monotonicity, or the statement that r(X)=r(closure(X))r(X) = r(\mathrm{closure(X)}) will be unprovable in general).

Eric Wieser (Jan 23 2025 at 20:32):

If you have a cardinal-valued cardinality, you can always use toENat on the result

Peter Nelson (Jan 23 2025 at 20:33):

That's right - the cardinal expression is ok as a definition, but you can't prove anything nice about it, so all the proofs happen in ENat anyway.

Eric Wieser (Jan 23 2025 at 20:34):

It's ok to prove things about (rank M).toENat without creating a new definition though, especially given you claim the cases where this arises are rarer

Peter Nelson (Jan 23 2025 at 20:35):

I meant that they are rare in the literature. ENat-valued rank is all over the place when formalizing, to maintain generality.

Eric Wieser (Jan 23 2025 at 20:41):

I'm afraid through my own ignorance I don't understand the comment about why the cardinal-valued statements are poorly behaved; they work quite well for us in linear algebra. Is there some nice intuition for why this doesn't successfully generalize to matroids?

Peter Nelson (Jan 23 2025 at 20:44):

I guess 'infinite matroids are too wild' is the only real answer. Higgs proved that if the generalized continuum hypothesis holds, then cardinal-valued rank is well-behaved (i.e. all bases are equicardinal), and it is known that bases are equicardinal for certain classes, such as the finitary matroids - and this last result is now in mathlib!

Because of the GCH result, the constructions that show the bad behaviour necessarily involve exotic set-theoretic assumptions like Martin's axiom. I don't have any intuition.

Peter Nelson (Jan 23 2025 at 20:47):

This is one of the ways that infinite matroids are terrible. But they are surprisingly nice in most ways.

Kevin Buzzard (Jan 24 2025 at 07:23):

Note that we have docs#Polynomial.degree and docs#Polynomial.natDegree

Junyan Xu (Jan 24 2025 at 11:38):

@Johan Commelin seems to think we should change docs#Module.finrank, docs#Subfield.relrank, docs#Subfield.relfinrank, and docs#Subgroup.relindex (anything else?) to finRank, relRank, relFinRank, and redIndex according to his vote. Field.finSepDegree already follows this convention. I don't think we're going to change Finset and Fintype though ...

Yaël Dillies (Jan 24 2025 at 11:50):

Note that I've opened #19872 for a similar rename

Peter Nelson (Jan 24 2025 at 12:03):

I think I like the extra option that was added (rank, eRank cRank, for the terms, rk, eRk, cRk for the functions).

I would rather not use nat_, fin_ or such variants for the Nat versions, because this will make the statements of real theorems involving the rank function less readable in exactly the setting that they are most common.

Peter Nelson (Jan 24 2025 at 13:41):

Junyan Xu said:

Johan Commelin seems to think we should change docs#Module.finrank, docs#Subfield.relrank, docs#Subfield.relfinrank, and docs#Subgroup.relindex (anything else?) to finRank, relRank, relFinRank, and redIndex according to his vote. Field.finSepDegree already follows this convention. I don't think we're going to change Finset and Fintype though ...

Would this mean ncard -> nCard and encard -> eCard would be good ideas? @Johan Commelin

Eric Wieser (Jan 24 2025 at 13:46):

Isn't the argument for encard vs enCard the same as the argument for ennreal vs ennReal in theorem names?

Edward van de Meent (Jan 24 2025 at 13:50):

or eNNReal? :upside_down:

Peter Nelson (Jan 24 2025 at 13:54):

I don't think there was much of a naming discussion about encard when I made the PR. But would it be enCard or eNCard according to the new rules?

Eric Wieser (Jan 24 2025 at 13:54):

I don't think the rules are clear here

Edward van de Meent (Jan 24 2025 at 13:56):

i'd say that since we're abbreviating Nat, the n becomes lowercase? (compare to eNatCard).

Eric Wieser (Jan 24 2025 at 13:56):

Agreed, but I think the rules ought to spell that out

Peter Nelson (Jan 24 2025 at 13:56):

But the c should still become C, I guess.

Eric Wieser (Jan 24 2025 at 13:58):

If the rule were "name in CamelCase then lowercase with the normal rules", then you'd have ENCard lowercased to encard.

Peter Nelson (Jan 24 2025 at 13:59):

Well that's easy, then!

Yaël Dillies (Jan 24 2025 at 14:02):

Note that some lemmas lower-case AEStronglyMeasurable to aeStronglyMeasurable. Not sure how to feel about those

Edward van de Meent (Jan 24 2025 at 14:03):

Eric Wieser said:

If the rule were "name in CamelCase then lowercase with the normal rules", then you'd have ENCard lowercased to encard.

i believe actually it is more common for just the first character to become lowercase?

Edward van de Meent (Jan 24 2025 at 14:04):

see docs#natCast for an example

Edward van de Meent (Jan 24 2025 at 14:05):

i could also be wrong about that, though...

Yaël Dillies (Jan 24 2025 at 14:06):

but it's not called NATCast in upper-case?

Edward van de Meent (Jan 24 2025 at 14:06):

ah, i get what you mean now...

Peter Nelson (Jan 24 2025 at 14:08):

Can I suggest that those involved in this discussion provide an opinion in the poll at the top? It seems we're heading in the direction of a consensus. (The encard issue is orthogonal)

Johan Commelin (Jan 24 2025 at 19:13):

Whatever the rules are, we should make sure that we don't end up with crank. I don't care about the rest (-;

Junyan Xu (Jan 24 2025 at 19:33):

They'll come sooner or later!

Peter Nelson (Jan 24 2025 at 19:58):

I'll leave this for the weekend, but it doesn't seem like there's much disagreement (a vote or two more would be nice!).

Junyan Xu (Jan 24 2025 at 20:37):

Yaël Dillies said:

Note that I've opened #19872 for a similar rename

Worth noting there's an objection to such renaming in the PR.


Last updated: May 02 2025 at 03:31 UTC