Zulip Chat Archive
Stream: general
Topic: naming defs
Jireh Loreaux (Feb 09 2022 at 04:07):
So here is something that isn't really addressed in the naming convention. Let's say I'm making a def
. Obviously the name should describe what it "is". As a typical example, let's say that we have a particular function foo : α → β
that we want to bundle into some bar
. Natural candidates for the name would be foo_bar
or bar_foo
, but which one is preferred in mathlib? As explicit example, how should the bundling of the map λ x : ℝ≥0∞, x⁻¹
into an order isomorphism ℝ≥0∞ ≃o order_dual ℝ≥0∞
be called?
Jireh Loreaux (Feb 09 2022 at 04:08):
/poll Naming bundles
order_iso_inv_dual
order_iso_dual_inv
inv_order_iso_dual
?
Yaël Dillies (Feb 09 2022 at 04:09):
Yours is a bit specific, so maybe it will inherit a trailing _ennreal
Jireh Loreaux (Feb 09 2022 at 04:09):
yes, it's in the ennreal
namespace
Jireh Loreaux (Feb 09 2022 at 04:09):
why the .
? It won't allow for projection notation.
Yaël Dillies (Feb 09 2022 at 04:09):
Ah, I think it should be in the order_iso
namespace
Jireh Loreaux (Feb 09 2022 at 04:10):
Interesting, why there over ennreal
? I can't see using it specifically while I have order_iso
open, but I can imagine using it when I have ennreal
open.
Yaël Dillies (Feb 09 2022 at 04:12):
I'm not against reconsidering it, but that's how mathlib already works for the most part.
Jireh Loreaux (Feb 09 2022 at 04:14):
To make sure I understand, def
s of a bundle of type bar
belong in the bar
namespace, and not in the namespace of the type on which the underlying function is defined?
Yaël Dillies (Feb 09 2022 at 04:15):
Exactly. In particular because most bundled homs aren't defined on a concrete type, or (more rarely) are defined on two (different) concrete type. They are homs after all!
Yaël Dillies (Feb 09 2022 at 04:16):
and also because there are usually many strengthenings to be had. For example, I'm fairly sure yours is actually an order homeomorphism.
Jireh Loreaux (Feb 09 2022 at 04:18):
Sure, it is. Do we have a bundle that does both? If so, I'll add it in my PR.
Mario Carneiro (Feb 09 2022 at 04:18):
I think the inv
should come first, since it is inv
with some stuff
Mario Carneiro (Feb 09 2022 at 04:19):
I don't think you need the _dual
unless there is another inv order iso that isn't going to the dual
Jireh Loreaux (Feb 09 2022 at 04:23):
ah, I see, docs#order_iso.to_homeomorph, the homeomorphism comes for free because the topology on ℝ≥0∞
is the order topology.
Eric Wieser (Feb 09 2022 at 08:58):
In this case, the order_iso namespace matches docs#order_iso.mul_left
Anne Baanen (Feb 09 2022 at 10:16):
Also the family of maps named docs#monoid_hom.id, that are id
bundled into a monoid_hom
.
Eric Rodriguez (Feb 09 2022 at 10:32):
I would say inv_order_iso
, a la docs#polynonial.map_ring_hom, docs#polynomial.eval_ring_hom. But more than anything, why not replace the current definition with the bundled definition?
Yaël Dillies (Feb 09 2022 at 11:16):
You want to replace inv
? :rofl:
Eric Rodriguez (Feb 09 2022 at 11:33):
Why can't it be made an order_iso from the get go? I'm not sure how notation interfaces with coetofun but we've certainly been bundling more stuff...
Yaël Dillies (Feb 09 2022 at 11:40):
Well, some div_inv_monoid
are not ordered.
Eric Rodriguez (Feb 09 2022 at 11:49):
the inv
is defined separately, it's not defined automatically
Yaël Dillies (Feb 09 2022 at 11:51):
Still, I don't see how that makes sense. It's like asking "Why is id
not an homeomorphism?"
Eric Rodriguez (Feb 09 2022 at 11:53):
I mean, it is when it can be defined in such a way. Just define inv := the whole shebang
, then has_inv := inv
, and it should all work out. a mathematician would treat it as an order_iso, why not lean?
Yaël Dillies (Feb 09 2022 at 11:54):
The inv
notation comes from docs#has_inv. You can't put an order_iso
in has_inv
.
Eric Rodriguez (Feb 09 2022 at 11:55):
yeah you can, just put the coe_to_fun. and if the name inv
isn't taken already, why not just use that?
Yaël Dillies (Feb 09 2022 at 11:55):
Also, I don't see why the order structure would get priority. There are many other bundlings.
Eric Rodriguez (Feb 09 2022 at 11:58):
that I can see, but we haven't seemed to need inv
as a ring_hom
or such like and I don't see any other bundling that is needed (as pointed out above, the homeomorphism is free)
Yaël Dillies (Feb 09 2022 at 12:00):
This also causes a bootstrap problem. You'll have to prove many properties of inv
as you're defining it.
Yaël Dillies (Feb 09 2022 at 12:00):
and I didn't even mention that if you want to define own inv
, you'll have to get it off the algebraic hierarchy. meaning for example that fields won't have an inv
anymore.
Yaël Dillies (Feb 09 2022 at 12:02):
For the record, I tried this with docs#convex_hull and docs#closure_operator, and I regret.
Eric Rodriguez (Feb 09 2022 at 12:09):
I'm not suggesting to remove it in general. I'm suggesting that ennreal
's inv, specifically, can be designed as an order_iso
. yea there's bootstrapping stuff, but it shouldn't be too bad considering it's defined as an Inf
.
Jireh Loreaux (Feb 09 2022 at 14:55):
I don't think you want it bundled anyway most of the time anyway. inv
goes from ennreal
to itself. The bundle goes to it's order_dual
.
Jireh Loreaux (Feb 09 2022 at 17:46):
Eric Rodriguez said:
a mathematician would treat it as an order_iso, why not lean?
I think the key thing here is that mathematicians continuously re-bundle their objects as they prove new things, but you can't really do this formally, because it just means you have to redefine everything all the time. So, in general it's better to provide a separation of concerns, which is why has_inv
is just a notation. And when you want the order isomorphism you appeal to the bundle. But As Yaël said, why prefer one bundle over another?
Frédéric Dupuis (Feb 10 2022 at 03:36):
@Jireh Loreaux I just changed my vote to order_iso.inv_ennreal
because I just noticed that order_iso.inv
already exists, and is basically the same thing but for groups, so it would be strange for this one to have a very different name.
Jireh Loreaux (Feb 10 2022 at 08:43):
it just got put on the queue. If someone wants to stop it I'll switch the name. Or can I stop it?
Eric Wieser (Feb 10 2022 at 09:28):
Can you link the PR? I don't see it mentioned anywhere in this thread
Rémy Degenne (Feb 10 2022 at 10:04):
Is that a PR I put on the queue? There was a comment about names pointing to a zulip discussion, but it was marked as resolved, so I thought a conclusion had been reached
Rémy Degenne (Feb 10 2022 at 10:05):
#11869 ?
Jireh Loreaux (Feb 10 2022 at 15:17):
It was resolved, and then last minute became unresolved. No one's fault. Yes, it was #11869. I'll just submit another PR to change the name.
Jireh Loreaux (Feb 10 2022 at 15:23):
For future reference, if a PR isn't delegated to me, is it even possible for me to pull it off the queue with bors r-
?
Riccardo Brasca (Feb 10 2022 at 15:35):
I don't think so (but I am not sure). Btw pushing a commit will do.
Frédéric Dupuis (Feb 10 2022 at 15:36):
Sorry, this is my fault, I should have made it clear in the PR that there was one last thing to do.
Jireh Loreaux (Feb 10 2022 at 16:33):
#11958
Jireh Loreaux (Feb 10 2022 at 16:34):
Whoops, sorry, something is off. I used the same branch and I think that's not good.
Jireh Loreaux (Feb 10 2022 at 16:49):
Okay, this looks correct: #11959
Last updated: Dec 20 2023 at 11:08 UTC