Zulip Chat Archive

Stream: mathlib4

Topic: RFC: Ditch WellFounded.min


Violeta Hernández (Aug 15 2024 at 16:42):

I've come to the opinion that docs#WellFounded.min is an antipattern we've been falling victim to, and should be removed in favor of docs#WellFounded.has_min

Violeta Hernández (Aug 15 2024 at 16:45):

Here's my reasoning:

  1. This is often not the correct spelling for what we want. If we have a well-order, we can define the stronger docs#ConditionallyCompleteLinearOrderBot instance, and use Inf instead.
  2. When we don't have a well-order, choosing an explicit but arbitrary minimal element is basically pointless.
  3. The arguments of min, min_mem, and not_lt_min are annoyingly duplicated. Using obtain on has_min solves this issue entirely.

Violeta Hernández (Aug 15 2024 at 16:45):

@Yaël Dillies what do you think?

Yaël Dillies (Aug 15 2024 at 16:50):

My biggest complaint is that it's completely unsearchable. Every time I look for it, I search for something like Set.Nonempty.exists_min

Violeta Hernández (Aug 15 2024 at 16:52):

That could very well be made into an alias

Violeta Hernández (Aug 15 2024 at 16:53):

I'm not sure if we have examples of theorems where two separate arguments allow for dot notation, though

Violeta Hernández (Aug 15 2024 at 18:59):

Hypothetically min could be useful in the following, very specific case:

  1. A well-founded order that isn't a well-order
  2. Under a relation other than <
  3. With a single minimal element
  4. That can't be defined explicitly

Violeta Hernández (Aug 15 2024 at 19:00):

The closest thing to that is ZFSet membership, but of course the empty set is perfectly definable

Violeta Hernández (Aug 15 2024 at 19:00):

If such a specific case did arose... Surely we could just use Classical.some <| WellFounded.has_mem explicitly

Violeta Hernández (Aug 15 2024 at 19:59):

I'll make the PR tonight if there's no objections

Violeta Hernández (Aug 15 2024 at 22:35):

Actually, we do have three other definitions depending on WellFounded.min. These are WellFounded.sup, WellFounded.succ, and Function.argmin.

Violeta Hernández (Aug 15 2024 at 22:35):

These... also have distinct problems

Violeta Hernández (Aug 15 2024 at 22:37):

WellFounded.sup is very misleading. It's only the supremum in a well-ordered type (in which case we almost definitely should be using Sup instead), and otherwise, it's just some random "minimal upper bound" for the set.

Violeta Hernández (Aug 15 2024 at 22:38):

Fortunately, it doesn't seem to be used anywhere (not even in the definition of docs#IsWellOrder.conditionallyCompleteLinearOrderBot) so we can just axe it

Violeta Hernández (Aug 15 2024 at 22:39):

WellFounded.succ has the same problem; it's only valid for a well-order, and a SuccOrder instance exists in the overwhelmingly common case where the order relation is <

Violeta Hernández (Aug 15 2024 at 22:40):

That one is actually used in another file, namely Order/IsWellOrderLimitElement

Violeta Hernández (Aug 15 2024 at 22:42):

That file proves theorems for LinearOrder α and IsWellOrder α (· < ·), which is completely equivalent to ConditionallyCompleteLinearOrder α + IsWellOrder α (· < ·)

Violeta Hernández (Aug 15 2024 at 22:43):

In my view, the "correct" notion of a limit element is that of a SuccOrder, namely a (non-minimal) element that is not a successor

Violeta Hernández (Aug 15 2024 at 22:44):

So really that whole file is problematic to me

Violeta Hernández (Aug 15 2024 at 22:48):

Looking at the discussion on #11584, it seems @Junyan Xu agrees with me

Violeta Hernández (Aug 15 2024 at 22:49):

As for Function.argmin, it does seem to get used a bit more throughout MathLib.

Violeta Hernández (Aug 15 2024 at 22:49):

(deleted)

Violeta Hernández (Aug 15 2024 at 23:23):

I'm not quite sure how I feel about it. I think it should probably be made specific to lattices, but it can stay for now, I guess

Violeta Hernández (Aug 16 2024 at 06:42):

I opened #15863, which should be an initial step towards getting rid of / refactoring IsWellOrderLimitElement.lean

Violeta Hernández (Aug 16 2024 at 22:07):

You know, I'm beginning to see how WellFounded.min is useful

Violeta Hernández (Aug 16 2024 at 22:09):

It serves some purpose within nonconstructive definitions, particularly when you're working not with < but with an arbitrary relation

Violeta Hernández (Aug 16 2024 at 22:09):

In that case, it's useful even in the well-order case

Violeta Hernández (Aug 16 2024 at 22:10):

Of course, we should avoid working with general well-orders like that, but this is simply how some parts of the library are set up. For instance, ordinals are defined as a quotient of well-ordered types under otherwise arbitrary relations.

Violeta Hernández (Aug 16 2024 at 22:40):

I think the actual thing to be doing is refactoring the uses of min out whenever possible, if they can be replaced by sInf or obtains _ := WellFounded.has_min. There's few legitimate uses, but that's not zero.


Last updated: May 02 2025 at 03:31 UTC