Zulip Chat Archive

Stream: general

Topic: notation for positive elements


Damiano Testa (Feb 03 2022 at 13:41):

Dear All,

I am trying to find a good notation for the type of positive elements of a type with 0 and <. Below are some suggestions: I have tested them a little, but I am not sure that they will not cause other problems. Feel free to vote for one of the existing ones or to add choices!

Thanks!

variables (α : Type*) [has_zero α] [has_lt α]

@[reducible]
def pos := {x : α // 0 < x}

notation ??? := pos α

Damiano Testa (Feb 03 2022 at 13:41):

/poll Notation for positive elements
α›0
α>0
α>₀
α₊₀
α₊

Floris van Doorn (Feb 03 2022 at 13:45):

What is wrong with {x : α // 0 < x}? I was happy with the corresponding notation in file#algebra/order/nonneg.

Alex J. Best (Feb 03 2022 at 13:47):

I would say the downside is its quite long. That's a lot of characters to represent a fairly simple idea

Damiano Testa (Feb 03 2022 at 13:49):

I agree with Alex: it works, but is long and not as catchy as, for instance, ℝ≥0.

Damiano Testa (Feb 03 2022 at 13:49):

Although it is a possibility: I will add it to the list! (I did not know that the backticks do not work in polls.)

Floris van Doorn (Feb 03 2022 at 13:54):

If the >0 in option 2 consists of two ASCII characters, I would like to note that that option implies that you are never able to write _ > 0 without space anymore (and Lean will give a cryptic error message if you do).

Yaël Dillies (Feb 03 2022 at 13:56):

What I really want is α\_>₀, but Unicode is lacking...

Damiano Testa (Feb 03 2022 at 13:59):

Floris van Doorn said:

If the >0 in option 2 consists of two ASCII characters, I would like to note that that option implies that you are never able to write _ > 0 without space anymore (and Lean will give a cryptic error message if you do).

Ok, so, even though I forgot the meaning of the symbol >, thanks to mathlib, this is probably a good reason to remove this one from the list.

Yaël Dillies (Feb 03 2022 at 14:01):

What Unicode has to offer (search for GREATER)

Shing Tak Lam (Feb 03 2022 at 15:40):

Yaël Dillies said:

What Unicode has to offer (search for GREATER)

There's also https://unicode-table.com/en/1433/ ()

("If you look closely, those aren't angle brackets, they're characters from the Canadian Aboriginal Syllabics block")

edit: also https://shapecatcher.com/ is good for finding things with the shape of a > but isn't >

Damiano Testa (Feb 03 2022 at 15:45):

Wow!! Thanks!

This means that this is also an option:

α˃⁰

Damiano Testa (Feb 03 2022 at 15:49):

(Added this choice above: it looks much better in the poll than here.)

Vincent Beffara (Feb 03 2022 at 15:59):

In the French tradition, R+\mathbb R_+ is {xR,0x}\{x \in \mathbb R, 0 \le x\} so α+\alpha_+ would be a little confusing as meaning the strict inequality

Eric Rodriguez (Feb 03 2022 at 16:01):

we have ℕ with zero, so sometimes these things have to be done

Vincent Beffara (Feb 03 2022 at 16:03):

Do there need to be a companion notation for le instead of lt?

Reid Barton (Feb 03 2022 at 16:04):

FWIW homotopy theorists also use X+{X}_{+} to mean basically option X, and I assume this notation is also popular in other fields with other meanings (like f+=max{f,0}f_+ = \max \{f, 0\}), so maybe better not to reserve a global meaning for it

Reid Barton (Feb 03 2022 at 16:06):

also in pretty much the next topic I clicked on I saw ⌊x⌋₊, which I don't know the meaning of but looks likely to conflict

Yaël Dillies (Feb 03 2022 at 16:15):

docs#nat.floor

Yury G. Kudryashov (Feb 03 2022 at 16:16):

I don't think that "ε>0 doesn't work" is really bad. I would say that "insert spaces around binary operations and relations, otherwise you may hit a notation" is not that bad.

Yury G. Kudryashov (Feb 03 2022 at 16:17):

Another option is to use

local notation `α>0` := {x : α // 0 < x}

(one line per relevant type variable) in files that deal with general theory and register, e.g., ℝ>0, ℚ>0 globally.

Yaël Dillies (Feb 03 2022 at 16:18):

I've added a bunch of spaces around notation myself, so i'm all in favor of enforcing it more.

Reid Barton (Feb 03 2022 at 16:29):

Yury G. Kudryashov said:

I don't think that "ε>0 doesn't work" is really bad. I would say that "insert spaces around binary operations and relations, otherwise you may hit a notation" is not that bad.

One downside is that maybe "we" all know that you need to put spaces in ε > 0, but a new user might write ∀ε>0 and get a totally baffling error message (I'm assuming).

Eric Wieser (Feb 03 2022 at 16:44):

if we put it in a locale, then such a user would have had to opt in first

Eric Wieser (Feb 03 2022 at 16:44):

It would be nice if we could attach docstrings to locales so that hovering over open_locale foo gave some information about what the effect it

Yaël Dillies (Feb 03 2022 at 16:46):

That's actually a great idea!

Damiano Testa (Feb 03 2022 at 18:59):

I'm tempted to go with Yuri's suggestion of local notation with the α embedded into the symbol.

I think that for this PR it is easier like this. Changing it in a subsequent one will be easy, if desired!

Damiano Testa (Feb 03 2022 at 20:50):

I've also just found this:

α˲₀

I think that I'm going to use this, with α hardcoded in the notation, as per Yuri's suggestion!

Eric Wieser (Feb 03 2022 at 21:01):

I think using regular >0 would be better to match ℝ≥0

Eric Wieser (Feb 03 2022 at 21:02):

Unless we change both

Damiano Testa (Feb 03 2022 at 21:02):

Fair enough: I like the consistency argument!


Last updated: Dec 20 2023 at 11:08 UTC