Zulip Chat Archive

Stream: lean4

Topic: sup/Sup


Kevin Buzzard (Mar 23 2021 at 15:56):

In Lean 3 we have things like conditionally complete lattices which have a sup (the least upper bound of two things) and a Sup (the least upper bound of a set of things). I've been idly making some lattice theory because I'm thinking about making Lean 4 teaching material for mathematicians. I wrote this:

class HasSup (P : Type u) where
    sup : P  P  P

and now I realise that the capitalisation might cause confusion. Does anyone have advice or suggestions on what I should be doing here?

Of course later on we might well have the same question for group (the structure) and Group (the category).

Eric Wieser (Mar 25 2021 at 19:39):

For binary/nary, perhaps Sup and NSup, where N means n-ary?

Eric Wieser (Mar 25 2021 at 19:46):

Then we could even distinguish docs#sum from a generalization of docs#finset.sum by calling the latter HasNAdd. Surely no one will be confused by that /s.

Gabriel Ebner (Mar 25 2021 at 20:02):

n-ary can (and probably should) be defined in terms of binary. (As much as I'd like to suggest FinSup as the type class for n-ary suprema.) Similarly, indexed suprema can be defined from the set suprema.
Productively speaking, maybe sups (supremum of set) could be an unambigous analogy to supr (supremum of range).

Mario Carneiro (Mar 25 2021 at 21:05):

I think supS and supR would be better for such an abbreviation, since supr and infi seem to suggest that it's not actually "supremum of range" but rather a slightly different abbreviation of "supremum"

Patrick Massot (Dec 15 2022 at 16:42):

We need to decide the names of docs#sup, docs#Sup and docs#supr in mathlib4. We can't use capitalization tricks because there are too many capitalization rules that would interfere. There are notations for those three functions of course, but their name will appear in lemma names. How about: sup, setSup, rgSup where rg is the abbreviation of "range"?. Or maybe funSup?

Patrick Massot (Dec 15 2022 at 16:43):

Note that I wrote something to get the ball running but I don't have any strong feeling (except for the strong filling that order.complete_lattice should be ported).

Patrick Massot (Dec 15 2022 at 16:49):

Or iSup and iInf where i stands for indexed, but iInf is painful to read.

Mario Carneiro (Dec 15 2022 at 17:16):

my preference is for sup/sSup/iSup and inf/sInf/iInf , although I don't mind swapping the last pair for supr/infi if it reads better and is more backward compatible

Patrick Massot (Dec 15 2022 at 17:18):

It took me a very long time to get used to the mathlib3 name so I won't insist on backwards compatibility.

Mario Carneiro (Dec 15 2022 at 17:19):

if we wanted to chuck backwards compatibility we could also consider meet / join

Mario Carneiro (Dec 15 2022 at 17:19):

that's probably too much of a change though, and the names are famously hard to keep straight

Mario Carneiro (Dec 15 2022 at 17:20):

(not sure if sup and inf are much better on that axis though)

Eric Wieser (Dec 15 2022 at 17:22):

What did we call docs#set.Union in mathlib4?

Adam Topaz (Dec 15 2022 at 17:23):

docs4#Set.sUnion

Eric Wieser (Dec 15 2022 at 17:23):

That's docs#set.sUnion

Eric Wieser (Dec 15 2022 at 17:24):

set.Union is the indexed version, which Patrick's convention would rename to iUnion (and similiary for iInter)

Mario Carneiro (Dec 15 2022 at 17:24):

I don't think we made it that far @Eric Wieser

Mario Carneiro (Dec 15 2022 at 17:24):

we have the binary stuff but the indexed operators pull in all of lattice theory

Eric Wieser (Dec 15 2022 at 17:53):

Much further down the line we have the same naming issue with probability_theory.Indep vs probability_theory.indep

Eric Wieser (Dec 15 2022 at 20:56):

@Heather Macbeth mentions docs#filter.coprod vs docs#filter.Coprod

Eric Wieser (Dec 15 2022 at 20:59):

(the other thread is here)

Patrick Massot (Dec 15 2022 at 21:06):

/poll operator names
sup sSup iSup inf sInf iIinf
sup supS supI inf infS infI
sup supₛ supᵢ inf infₛ infᵢ
join sup iSup meet inf iInf
join sup supI meet inf infI

Eric Wieser (Dec 15 2022 at 21:09):

@Heather Macbeth, I think your sup sup2 is backwards compared to the other suggestions; you want the 2 subscript for the binary one right?

Heather Macbeth (Dec 15 2022 at 21:10):

Sorry, yes!

Adam Topaz (Dec 15 2022 at 21:10):

maybe I got meet/join backwards :)

Eric Wieser (Dec 15 2022 at 21:12):

Wikipedia says Patrick's interpretatio (meet = inf) is correct, but also says those names are the nary operators!

Yaël Dillies (Dec 15 2022 at 21:34):

I have a strong preference for the indices versions over the trailing cap ones because capitalisation is a headache in Lean 4.

Patrick Massot (Dec 15 2022 at 21:58):

One problem with the indices version is that we will also need to solve the bUnion case (in lemma names, this isn't a new operator) and I think there is no subscript b in unicode

Patrick Massot (Dec 15 2022 at 21:58):

I don't understand Heather sup₂. We need three variants, right?

Yaël Dillies (Dec 15 2022 at 21:59):

bUnion has mostly been replaced by Union₂ nowadays anyway.

Yaël Dillies (Dec 15 2022 at 21:59):

There's some remnants that make sense, but it wouldn't be such a loss (as opposed to the situation a year ago, say).

Eric Wieser (Dec 15 2022 at 22:00):

docs#bUnion still has plenty of results

Eric Wieser (Dec 15 2022 at 22:00):

docs#bsupr does too

Eric Wieser (Dec 15 2022 at 22:02):

Patrick Massot said:

One problem with the indices version is that we will also need to solve the bUnion case (in lemma names, this isn't a new operator) and I think there is no subscript b in unicode

Arguably the convention for bounded / conditional operations should use a different convention anyway to the binary/set/indexed naming, since this is a property of the lemma not of the operator

Yaël Dillies (Dec 15 2022 at 22:02):

#11516 is where the convention changed drastically.

Eric Wieser (Dec 15 2022 at 22:03):

I think this is a problem for @Heather's sup₂ suggestion for the binary sup, since lemmas about the n-ary one applied twice are certainly common.

Floris van Doorn (Dec 15 2022 at 22:08):

I prefer it if declaration names are written with ASCII characters, since I sometimes want to type them outside VSCode , where I don't have easy unicode input (e.g. on the mathlib docs website)

Patrick Massot (Dec 15 2022 at 22:09):

Now that capitalization can no longer be used I think we need extra flexibility so you should take the opportunity to configure your computer to type those everywhere.

Eric Wieser (Dec 15 2022 at 22:13):

Or we should configure the docs to behave like vscode

Patrick Massot (Dec 16 2022 at 09:58):

I went with sup supₛ supᵢ inf infₛ infᵢ

Eric Wieser (Dec 16 2022 at 10:04):

Then we should rename docs4#Set.sUnion to match

Scott Morrison (Dec 16 2022 at 10:56):

We now run into the problem that Lean 4 doesn't have extends ... renaming ..., but we want to write

class CompleteLinearOrder (α : Type _) extends CompleteLattice α, LinearOrder α
    renaming max  sup min  inf

Yaël Dillies (Dec 16 2022 at 11:02):

We should just rename min and max in LinearOrder

Yaël Dillies (Dec 16 2022 at 11:02):

I wanted to do that in Lean 3, but everything was slowed down because linear_order is in core.

Floris van Doorn (Dec 16 2022 at 11:03):

I like the names min and max.

Floris van Doorn (Dec 16 2022 at 11:04):

For the renaming of fields: I recommend for now to just add the missing fields of LinearOrder manually, and then to declare the instance manually.

Yaël Dillies (Dec 16 2022 at 11:13):

Renaming the fields has nothing to do with renaming the functions.

Yaël Dillies (Dec 16 2022 at 11:14):

But independently we should make LinearOrder extend Lattice

Scott Morrison (Dec 16 2022 at 11:22):

Okay, I've done CompleteLinearOrder per Floris' suggestion.

Eric Wieser (Dec 16 2022 at 11:45):

Is docs4#LinearOrder in core/Std4?

Yaël Dillies (Dec 16 2022 at 11:54):

It moved to mathlib.

Notification Bot (May 17 2023 at 11:58):

This topic was moved to #mathlib4 > sup/Sup by Eric Wieser.

Eric Wieser (May 17 2023 at 12:01):

(this was really a question about what to name things in mathlib)


Last updated: Dec 20 2023 at 11:08 UTC