Zulip Chat Archive

Stream: new members

Topic: IsOpen vs. IsClosed


Ilkka Törmä (Jan 17 2024 at 20:27):

In Mathlib.Topology.Basic, the openness property IsOpen is implemented with def, while IsClosed is a class. What's the difference, why are they implemented this way, and why is neither of them a structure, which I thought would be the simplest way to wrap a property into a named object?

Eric Wieser (Jan 17 2024 at 21:36):

I'm very surprised to find out that docs#IsClosed is a class

Eric Wieser (Jan 17 2024 at 21:38):

The change was in !3#6552; where @Sébastien Gouëzel writes:

In lean-liquid, it would be useful that is_closed would be a class, to be able to infer a normed space structure on E/F when F is a closed subspace of a normed space E.

Sébastien Gouëzel (Jan 18 2024 at 07:37):

Yep, that's the reason: to infer nice behavior of quotient spaces G / H through typeclass inference, the typeclass inference mechanism needs to be able to see that H is closed, and this is only possible if IsClosed is a class.

Johan Commelin (Jan 18 2024 at 07:46):

fwiw, I think another option might have been to use [Fact (IsClosed H)].

Kevin Buzzard (Jan 18 2024 at 11:19):

We didn't have that option with things like [Fact (r < 1)] in LTE because making LT.lt a class would probably not have gone down well, but in this situation what are the advantages/disadvantages of the two choices (Fact / no Fact)? At the end of the day are they basically the same thing?

Eric Wieser (Jan 18 2024 at 11:34):

I think the main disadvantage is the weird asymmetry it creates between IsOpen and IsClosed

Eric Wieser (Jan 18 2024 at 11:35):

I think Fact would have a been a better choice here, as we use it already for things like ZMod.field

Sébastien Gouëzel (Jan 18 2024 at 11:56):

Maybe a good idea would be to also make IsOpena class, then, as quotienting by open subgroups also has very nice properties.

Kevin Buzzard (Jan 18 2024 at 12:06):

All open subgroups are closed though ;-) (consider a cover by cosets)

Kyle Miller (Jan 18 2024 at 12:13):

An idea I think would be very interesting is a new binder type that's like {...} binders, but which get solved for by assumption, especially if instances can use these binders.

It's like being able to use Fact with all local hypotheses without needing to create Fact instances.

Mario Carneiro (Jan 18 2024 at 12:14):

couldn't you just literally do (x : T := by assumption)?

Mario Carneiro (Jan 18 2024 at 12:14):

oh I missed the thing about instances

Mario Carneiro (Jan 18 2024 at 12:15):

I'm going to put another nickel in my jar of "reasons we should be allowed to have tactics in instance search"

Kyle Miller (Jan 18 2024 at 12:15):

Yeah, and it's also a bit different from default arguments because I'd want them to behave like implicit arguments (i.e., no passing them positionally)

Mario Carneiro (Jan 18 2024 at 12:16):

we could have {x : T := by assumption} too

Kyle Miller (Jan 18 2024 at 12:17):

An inspiration here is GHC's obscure implicit parameters feature, but it seems like it would see more use in Lean land, to help with passing facts around, rather than data.

Kyle Miller (Jan 18 2024 at 12:20):

Also, the feature I'm proposing is different in that the GHC one is by name, but mine is by type. Having some ability to try to capture variables by name would be interesting though -- we'd be able to recover parameter variables in some form.

Sébastien Gouëzel (Jan 18 2024 at 12:25):

Kevin Buzzard said:

All open subgroups are closed though ;-) (consider a cover by cosets)

Sure. But quotients by open subgroups are even better behaved than quotients by closed subgroups!


Last updated: May 02 2025 at 03:31 UTC