Zulip Chat Archive

Stream: maths

Topic: Topology of enat


Antoine Chambert-Loir (Jul 06 2023 at 16:28):

enat is the type nat extended with an element at infinity. As such, it is a canonically_ordered_comm_semiring, and it gets a topology from this. However, this topology is defined by set.Ici, namely intervals closed on the left and unbounded on the right, which means that the element at infinity is isolated. As a consequence, tending to infinity in enat is quite different from tending to infinity in nat

Am I missing a point ? Is this an intended property ?

Yaël Dillies (Jul 06 2023 at 16:29):

Wait, how does it get a topology from this?

Antoine Chambert-Loir (Jul 06 2023 at 16:30):

You're right, there's no topology, and I use filter.has_top — which precisely is generated by set.Ici.

Antoine Chambert-Loir (Jul 06 2023 at 16:31):

So I should use another filter in this case, generated by set.Ioi, I don't know whether it exists.

Yaël Dillies (Jul 06 2023 at 16:33):

docs3#order_topology?

Antoine Chambert-Loir (Jul 06 2023 at 16:37):

Thanks! That topology is the correct one (obviously, I was missing a point), I will use that one… (It's not an instance, apparently).

Sebastien Gouezel (Jul 06 2023 at 16:41):

It should probably be a global instance, in fact.

Antoine Chambert-Loir (Jul 06 2023 at 17:13):

Since docs#ereal.order_topology is already an instance, that would make sense.

(But what I need is lighter: just the other version of docs3#filter.at_top when the ordered set has a top element. I wonder why docs3#filter.at_top has been defined using closed intervals.)

Sebastien Gouezel (Jul 06 2023 at 17:26):

If you use open intervals, then when there is a top element the at_top filter is trivial (i.e., there is no way to tend to top).

Yury G. Kudryashov (Jul 06 2023 at 18:18):

What you need is ⨅ n : ℕ, 𝓟(Ioi (n : ℕ∞)) or, equivalently, ⨅ (n : ℕ∞) (_ : n < ⊤), 𝓟(Ioi n)

Antoine Chambert-Loir (Jul 06 2023 at 20:07):

Exactly, that's how I would naturally define filter.has_top.

Antoine Chambert-Loir (Jul 06 2023 at 20:08):

(Well, up to the precise Lean syntax which I hadn't sorted out yet.)

Yury G. Kudryashov (Jul 06 2023 at 20:14):

How would you define it if the type has no top element?

Yury G. Kudryashov (Jul 06 2023 at 20:15):

⨅ (n : α) (_ : ¬(IsTop n)), 𝓟(Ioi n)? ⨅ (n : α) (_ : ¬(IsMax n)), 𝓟(Ioi n)? Something else?

Yury G. Kudryashov (Jul 06 2023 at 20:16):

docs#IsTop docs#IsMax

Antoine Chambert-Loir (Jul 06 2023 at 21:05):

Yes, something mathematically equivalent to that. (Just because I had expected that docs3#filter.at_top would have coincided with the filter of neighborhoods at the top element…)

Yury G. Kudryashov (Jul 06 2023 at 21:07):

IsTop or IsMax?

Yury G. Kudryashov (Jul 06 2023 at 21:11):

Anyway, this discussion should wait till after the port.

Antoine Chambert-Loir (Jul 06 2023 at 21:11):

My only concern would be that the inclusion from the the type to its with_top version gives the same notion of limit at _top.

Antoine Chambert-Loir (Jul 06 2023 at 21:12):

Yury G. Kudryashov said:

Anyway, this discussion should wait till after the port.

I'm not even insisting that some modification be made. It was a genuine question that appeared when I had misinterpreted the function name and people who have implemented docs#filter.at_top like it is may have serious reasons for which it's done as it is.

Johan Commelin (Jul 07 2023 at 04:20):

If anything, this suggest that we should have more documentation on atTop

Antoine Chambert-Loir (Jul 07 2023 at 05:45):

You see, I had read the doc of docs3#filter.at_top, in particular the parenthesis:

(The preorder need not have a top element for this to be well defined, and indeed is trivial when a top element exists.)

However, when using it later on, I forgot about this and naïvely thought that it would be the filter of neighborhoods of .

(This led to a funny error, by the way, because I detected that error when trying to prove the converse of something I had proved: the proof didn't work out exactly because of this problem, which meant my direct proof proved something different from what I had in mind — converging to docs3#filter.at_top meant that the function was eventually , and I didn't realize I had made a too strong hypothesis.)

Kevin Buzzard (Jul 07 2023 at 07:09):

I guess this is a great example of "you're proving theorems about your definitions, so you had better make sure they're right" (what the computer scientists are always warning us about) plus also "if the definitions are wrong then you're going to find out pretty quickly" (which is what the mathematians say to reassure the computer scientists)

Anatole Dedecker (Jul 07 2023 at 08:35):

This new definition of docs#Filter.atTop would mess with our definition of docs#HasSum right? Because if the index type is finite then Finset \alpha has a top element. I think that with this new definition, a function would only have its (algebraic) sum as a topological sum if it’s zero at at least one point, which is very wrong.

Anatole Dedecker (Jul 07 2023 at 08:44):

Never mind, this is not true at all.

Anatole Dedecker (Jul 07 2023 at 08:56):

So I guess I’m in favor of this change then, probably with the IsTop version rather than IsMax because then we make sure to get back our original version in any NoTopOrder

Floris van Doorn (Jul 07 2023 at 10:21):

@Anatole Dedecker I think you're still right that this gives the wrong answer sometimes, at least for sums on a domain with 1 point (which under the new definition will always be 0) or 0 points (the sum doesn't exist under the new definition).

I think we shouldn't redefine Filter.atTop, but make a new definition (or just use the nhds filter in the order topology).

Kyle Miller (Jul 07 2023 at 10:27):

I wonder if Filter.atTop should be the inf over principal filters of order filters rather than over principal filters of Set.Ici? Then that would more directly be the filter at a top in the ideal completion of the type (for example, for Nat that's ENat), and I think it would be equivalent.

Then the ENat's infinity filter would be the pushforward of Nat's Filter.atTop

Kyle Miller (Jul 07 2023 at 10:40):

This suggests that having two different filters like Floris suggested is the right thing to do: there's the infinity filter on the original order and the infinity filter on the completed order.

Anatole Dedecker (Jul 07 2023 at 10:57):

Floris van Doorn said:

Anatole Dedecker I think you're still right that this gives the wrong answer sometimes, at least for sums on a domain with 1 point (which under the new definition will always be 0) or 0 points (the sum doesn't exist under the new definition).

I think it does still work for 1 point domain, but not for zero. Anyways, this does seem like a bad idea :sweat_smile:

Anatole Dedecker (Jul 07 2023 at 10:58):

@Kyle Miller What do you mean by "principal filters of order filters" ?

Kyle Miller (Jul 07 2023 at 10:58):

Filter.atTop = ⨅ (f : Order.PFilter α), Filter.principal f

Anatole Dedecker (Jul 07 2023 at 11:00):

Ooooooh that's interesting

Floris van Doorn (Jul 07 2023 at 11:01):

For the one point domain, there are two finsets, empty and univ, so I think the new proposal gives you the filter (⊤ : Filter (Finset Unit)), not 𝓟 (Finset.univ)

Floris van Doorn (Jul 07 2023 at 11:02):

I'm quite sure Kyle's definition is equivalent to the existing one.

Anatole Dedecker (Jul 07 2023 at 11:03):

Floris van Doorn said:

For the one point domain, there are two finsets, empty and univ, so I think the new proposal gives you the filter (⊤ : Filter (Finset Unit)), not 𝓟 (Finset.univ)

Yes there are two finsets but one of them is top, so you only consider the empty finset which gives you 𝓟 (Finset.univ), right?

Anatole Dedecker (Jul 07 2023 at 11:04):

Floris van Doorn said:

I'm quite sure Kyle's definition is equivalent to the existing one.

For ENat at least yes, that would give the current definition.

Floris van Doorn (Jul 07 2023 at 11:06):

One filter that gives the "right" notion in all the types I've considered so far (, Finset α, ENat, Nat, finite orders, ...) is

def Filter.atTop'' [Preorder α] : Filter α :=
   (n : α) (_ : ¬ IsSuccLimit n  ¬ IsMax n), 𝓟 (Ici n)

This should be the current atTop filter in most cases. Only if there is a maximal element that is not the successor of another element then this filter gives you the notion of "tending to this maximal element" (or all such maximal elements, if you have multiple).
However, this definition is quite ugly, and I don't propose adopting it as the default definition in mathlib.

Floris van Doorn (Jul 07 2023 at 11:09):

Oh wait, Yury's definition uses Ioi, not Ici, I missed that. You're right, Anatole... I think my suggestion in that case is equivalent to Yury's, and has the same defect for 1-element α's.

Peter Nelson (Jul 22 2023 at 15:17):

Has there been any progress on this? I've just found myself wanting to sum a function f : α → ℕ∞ over α in such a way that the sum is defined for all f, and has value in the infinitely supported case. If I'm not mistaken, this would require tsum with the topology begin talked about here.

Anatole Dedecker (Jul 23 2023 at 12:59):

Do you mean adding a TopologicalSpace instance on ENat (with the order topology)? I think the answer is no, but I can do that quickly if you need it.

Peter Nelson (Jul 23 2023 at 13:31):

I guess this would only be useful to me if there were also all the infrastructure would be needed to get tsum working smoothly. If I added the instance myself in Mathlib.Topology.Instances.ENat along with some of this API, would this be well-received?

Anatole Dedecker (Jul 23 2023 at 13:35):

Of course! Which kind of API specific to ENat do you need for tsum, only that it's a topological monoid or do you need more? But don't hesitate to open a PR in any case!

Peter Nelson (Jul 23 2023 at 13:40):

As a dyed-in-the-wool combinatorialist, I just want to be able to sum an arbitrary function f : α → ℕ∞so that it has the 'correct' value (ie. equal to iff some summand is or the support is infinite). In this case, every function should be Summable, so the API for tsum should be very clean. I'll have a tinker.

Anatole Dedecker (Jul 23 2023 at 13:42):

It's possible that we have to generalize some lemmas about docs#ENNReal to topological monoids with a top element, but apart from that I would naively guess that you don't need that much more API. Let's see how it goes!

Peter Nelson (Jul 23 2023 at 18:09):

I'm having a little trouble getting the right set of instances. For α to have the property that every function f: ι → α is summable, it seems I need a lemma like this:

import Mathlib.Topology.Algebra.InfiniteSum.Basic
import Mathlib.Topology.Order.Basic
import Mathlib.Data.Finset.Sum
import Mathlib.Topology.Instances.ENNReal

open scoped BigOperators

theorem hasSum {α ι : Type _} [CanonicallyLinearOrderedAddMonoid α] [CompleteLattice α]
    [TopologicalSpace α]  [OrderTopology α] {f : ι  α} :
    HasSum f ( s : Finset ι,  a in s, f a) := by
  sorry
  -- Proof should be
  -- exact tendsto_atTop_iSup fun _ _ => Finset.sum_le_sum_of_subset

The canonicality is needed because (for instance) this would fail for the extended reals, and the completeness is needed for the statement to even make sense. But the problem is that the first two instances contain orderings as data, so a mismatch occurs with the obvious proof. Is there a way around this?

Jireh Loreaux (Jul 23 2023 at 18:25):

You could phrase this in terms of docs3#with_top.complete_linear_order. It probably wouldn't apply directly to ENat or ENNReal, but these lemmas could be proven directly as a consequence of this one.

Jireh Loreaux (Jul 23 2023 at 18:29):

To be clear, you assume alpha is a ConditionallyCompleteLinearOrderBot, and then the lemma is that a function into WithTop alpha is summable. And you get the complete lattice structure for free from the instance mentioned above.

Jireh Loreaux (Jul 23 2023 at 18:30):

Oops, sorry, that doesn't work. There's no additive structure. Sorry!

Peter Nelson (Jul 23 2023 at 18:48):

Yeah, it’s the ‘additive order’ and the ‘completeness order’ that are clashing

Anatole Dedecker (Jul 23 2023 at 18:48):

I don't think the canonicity the right way to avoid problems here, what you really need is the fact that all elements are positive. Actually, I'm surprised we don't have this lemma for any summable and nonnegative f

Anatole Dedecker (Jul 23 2023 at 18:51):

I think what we could have is some ZeroLEClass or ZeroBotClass that would do that, but in the meantime you can (1) prove the general lemma I described above, using docs#Finset.sum_le_sum_of_subset and (2) specialize it to ENat without the nonnegativity assumption

Anatole Dedecker (Jul 23 2023 at 18:52):

Or maybe the right solution is to say that the nonnegativity argument of the general lemma should be solved by positivity, but I never remember the syntax for that.

Peter Nelson (Jul 23 2023 at 19:20):

Summability isn’t the hypothesis of the lemma above - it’s a lemma used to prove summability. A lemma needs to hold like that for every function (without hypotheses) to show that every function is summable.

Anatole Dedecker (Jul 23 2023 at 19:43):

Ah right sorry I mixed things up, indeed the first thing to prove is that everything is summable. I'd still say that it would be nice to have a lemma actually computing the sum that would work in any case, but that's orthogonal to what you want.

Anatole Dedecker (Jul 23 2023 at 19:44):

docs#hasSum_of_isLUB_of_nonneg seems like the perfect match here.

Anatole Dedecker (Jul 23 2023 at 19:59):

I'd say the simplest option is to just use this lemma to prove that any ENat-valued family is summable. I'm not sure if we can conveniently state this fact more generally atm.

Peter Nelson (Jul 23 2023 at 21:42):

My worry is that that involves duplicating a good amount of tsum API which is identical to the ENNreal case.

Peter Nelson (Jul 23 2023 at 21:43):

'Type where summing any function makes sense' feels like a good class to have, and it's a shame if the existing setup can't accommodate that.

Peter Nelson (Jul 23 2023 at 21:47):

(The reason the tsum API is so nice for ENNReal is that it none of it needs summability hypotheses.)

Jireh Loreaux (Jul 23 2023 at 21:50):

In what other situations does this come up besides ENNReal and ENat? I guess maybe functions into these types?

Peter Nelson (Jul 23 2023 at 21:51):

Yeah, I can't think of any others. Is n = 2 not still a good argument for abstraction?

Peter Nelson (Jul 23 2023 at 21:52):

What about a [Summable] typeclass, with instances for ENat and ENNReal? That would probably involve minimal refactoring.

Jireh Loreaux (Jul 23 2023 at 21:52):

It just depends on how much work it is to create a generic API versus duplicating the lemmas.

Eric Wieser (Jul 23 2023 at 22:31):

WithTop NNRat?

Anatole Dedecker (Jul 23 2023 at 23:16):

Peter Nelson said:

My worry is that that involves duplicating a good amount of tsum API which is identical to the ENNreal case.

In an ideal world there should be almost no lemma stated for ENNReal that is not a special case of the general theory (except of course those really specific to ENNReal), so if you have a "everything is summable" lemma you could use it to get basically everything you want.
Then, I get that it's even more convenient if we find a nice way to abstract it, but my claim was that it shouldn't be that annoying to just write ENat.summable wherever you need to provide a proof of summability, at least as a first solution.

Anatole Dedecker (Jul 23 2023 at 23:16):

(deleted)

Anatole Dedecker (Jul 23 2023 at 23:31):

E.g docs#ENNReal.tsum_le_tsum_comp_of_surjective (picked at random) should definitely be generalized in a way that requires summability and nonnegativity assumptions, and then we can discuss about wether we should have "convenient" versions in specific settings.

Jireh Loreaux (Jul 24 2023 at 05:06):

Eric, WithTop NNRat doesn't apply. Take a series whose coercion to ENNReal converges to an irrational. Such a series is not summable.

Mario Carneiro (Jul 24 2023 at 05:18):

the same property is shared with any closed additive subsemigroup of ENNReal IIRC, but that basically means scaled versions of ENat minus finitely many elements, and ENNReal

Yury G. Kudryashov (Jul 24 2023 at 05:21):

And products / pi types.

Peter Nelson (Jul 26 2023 at 20:07):

#6159 is my attempt at defining the appropriate typeclass

Peter Nelson (Jul 26 2023 at 20:28):

(A couple of things are still broken)

Peter Nelson (Jul 29 2023 at 12:40):

Ok, I believe I'm finished handling all those downstream errors.

The solution was to define a LEIffExistsMul mixin typeclass that relates an ordering to a monoid structure without extending any classes that contain le or mul as data. This can be used to define a 'complete canonically ordered add monoid', which should be the right structure so that tsums always exists. (CanonicallyOrderedMonoid is still a type, and just implements the new typeclass. )

More generally, LEIffExistsMul can be used to arbitrarily combine monoid and order structures canonically. I feel that I might not be aware of some of the tradeoffs, but this really feels more convenient, and could also be used to completely remove the need for CanonicallyLinearOrderedMonoid as well.

Eric Rodriguez (Jul 29 2023 at 13:28):

There is docs#ExistsMulOfLE yours is an iff, sorry!

Yuyang Zhao (Jul 31 2023 at 11:56):

I think there was a proposed refactor to make CanonicallyOrdered... mixin.

Peter Nelson (Nov 25 2023 at 19:51):

I'm looking at this again, and I'm not sure what to do.

I don't think that using the existing tsum API for ENat is an easy option. It's not just a matter of invokingSummable in a few places; there are quite a few pieces that don't fit. For instance, none of the existing versions of tsum_mul_leftwill work, because ENat isn't a topological semiring (at least, I don't think it is). So proving that needs mul_iSup-type lemmas, etc etc. The scope quickly creeps to cover a large chunk of what's in ENNReal.

But it didn't seem like there was much appetite for #6159 when I made it as an attempted fix - it eventually became buried and now has merge conflicts. Maybe someone with a better understanding of the tradeoffs in the hierarchy could have another look at this.

Yaël Dillies (Nov 26 2023 at 10:05):

Well, I think you could still define CompleteCanonicallyOrderedAddMonoid. I would be happy with that. I was mostly reluctant with the mixin design.

Peter Nelson (Nov 26 2023 at 13:55):

I'm not clear on how extends works here. If I write

class CompleteCanonicallyOrderedCommMonoid (α : Type*)
  extends CompleteLattice α, CanonicallyOrderedCommMonoid α

will le be the same for the two structures? Do the two examples below correspond to different sets of assumptions?

example {α : Type*} [CompleteLattice α] [CanonicallyOrderedCommMonoid α] : False := sorry

example {α : Type*} [CompleteCanonicallyOrderedCommMonoid α] : False := sorry

Yaël Dillies (Nov 26 2023 at 14:07):

First question: Yes, that's the entire point of extending.
Second question: Yes, the first one has two unrelated orders. The second one does not.

Yaël Dillies (Nov 26 2023 at 14:08):

Also it's worth considering whether you even need CompleteCanonicallyOrderedCommMonoid and not directly something stronger like CompleteCanonicallyOrderedSemiring.

Yaël Dillies (Nov 26 2023 at 14:11):

You're reaching a point where there's basically only three examples we could ever care about: extended nonnegative reals, extended natural numbers, extended nonnegative rationals. They all are semirings, so I think we do not care about CompleteCanonicallyOrderedCommMonoids that are not CompleteCanonicallyOrderedSemiring.

Yaël Dillies (Nov 26 2023 at 14:13):

Okay that's not quite right. Products and pi types thereof also are examples.

Yaël Dillies (Nov 26 2023 at 14:14):

But those would also be semirings, so I still think there's no harm in skipping the monoid version.

Yaël Dillies (Nov 26 2023 at 14:16):

Unrelated remark, but since you mentioned it earlier, the correct generality for mul_iSup is quantales.

Yaël Dillies (Nov 26 2023 at 14:17):

Annoyingly, there does not seem to be an infimum version of quantales in the literature.

Eric Wieser (Nov 26 2023 at 16:19):

Presumably we also care about the semifield version for ennrat/ennreal? Which is perhaps an argument for a mixing typeclass, since we need only one of those, vs two for "regular" typeclasses

Eric Wieser (Nov 26 2023 at 16:19):

Of course, 1 vs 2 isn't very significant; if it were more like 1 vs 5 I would feel more strongly

Eric Wieser (Nov 26 2023 at 16:20):

Are we likely to want lemmas about the interaction with norm? That would be another point in favor of a mixin.

Yaël Dillies (Nov 26 2023 at 16:27):

Currently, mathlib only talks about norms on groups, so this is mostly irrelevant.

Yaël Dillies (Nov 26 2023 at 16:30):

The problem I find with algebraic order mixins is that they are too easy to create and too hard to contextualise. I much prefer extending structures as a way to know which concrete structures we care about from the onset.

Eric Wieser (Nov 26 2023 at 16:57):

Just to be clear: is #6159 sufficient for your goals @Peter Nelson, or are you finding you need more things on top of it?

Peter Nelson (Nov 26 2023 at 18:21):

I don't know yet - What I want is a reasonable API for summations in ENat, and the scope of this isn't yet clear. @Yaël Dillies 's suggestion of using a semiring does make sense, though - both ENat and ENNReal are going to want mul_tsum`-type lemmas.

As @Jireh Loreaux commented earlier, ENNRat isn't an example, because of series with irrational sum. So it really is just two.

I think that, for summations to exist, one actually needs a linear order. The following works with Linear but
fails without, and I think the relevant missing typeclass (SupConvergenceClass α) fails without a linear order.

class CompleteCanonicallyLinearOrderedAddCommMonoid (α : Type*)
  extends CompleteLinearOrder α, CanonicallyOrderedAddCommMonoid α

variable {α : Type*} [CompleteCanonicallyLinearOrderedAddCommMonoid α]

theorem hasSum' (f : ι  α) : (HasSum f ( (s : Finset ι),  i in s, f i)) :=
  fun _ hn  tendsto_atTop_iSup (fun _ _  h  Finset.sum_le_sum_of_subset h) hn

theorem tsum_eq_iSup' (f : ι  α) : ∑' i, f i =  (s : Finset ι), ( i in s, f i) :=
  (hasSum' f).tsum_eq

I'll see how far this goes without additional assumptions being needed.


Last updated: Dec 20 2023 at 11:08 UTC