Zulip Chat Archive

Stream: maths

Topic: generalizing deriv to TVS


Yury G. Kudryashov (May 18 2023 at 00:14):

It seems that I've missed this thread in 2022. I suggest that we redefine docs#fderiv in similar terms. What do you think?

Yury G. Kudryashov (May 18 2023 at 00:35):

@Sebastien Gouezel @Heather Macbeth @Anatole Dedecker :up:

Yury G. Kudryashov (May 18 2023 at 00:40):

We can redefine has_fderiv_at f f' a as ∀ (U ∈ 𝓝 0) (r' ≠ 0) s, is_vonN_bounded 𝕜 s → ∀ᶠ r : 𝕜 in 𝓝[≠] 0, maps_to (λ x, f (a + x) - f a - f' x) (r • s) (r' • r • U) (not tested, may contain typos)

Yury G. Kudryashov (May 18 2023 at 00:57):

BTW, we can redefine topology on multilinear forms in a similar way.

Yury G. Kudryashov (May 18 2023 at 00:58):

Then many facts will work without norms.

Yury G. Kudryashov (May 18 2023 at 00:58):

(though proofs will be harder)

Moritz Doll (May 18 2023 at 01:00):

I think we had a similar discussion before. I am generally in favor of this, however there might be subtleties when it comes to higher derivatives. The only reference for something like this I know is Hamilton's 1982 paper on Nash-Moser theory and he uses directional derivatives and I don't know whether his smoothness is the same as your proposed smoothness (which would make mathlib's smooth Fréchet manifolds weaker).

Yury G. Kudryashov (May 18 2023 at 01:09):

I suggest that the following plan (each step is 1 or more PRs):

  1. Drop has_fderiv_at_filter, leave only has_fderiv_within_at and has_fderiv_at (defined as has_fderiv_within_at ... univ).
  2. Redefine has_fderiv_within_at for topological vector spaces. Prove equivalence to the old definition, leave all theorems as is.
  3. Gradually migrate theorems to topological vector spaces.

Sebastien Gouezel (May 18 2023 at 07:52):

Do you have an application in mind? I have no objection in theory, but I am not sure I see the point yet.

Eric Wieser (May 18 2023 at 08:00):

I have one; I can't talk about derivatives of matrix functions because to even state the results I have to choose a norm

Yury G. Kudryashov (May 18 2023 at 08:00):

This :up: and some other finite dimensional spaces.

Eric Wieser (May 18 2023 at 08:01):

So right now if I wanted to write down how derivatives (by a scalar) distribute across a matrix product, I need to repeat the lemma for every currently-available norm on matrices (I think we have 3 right now via local attribute [instance] and nothing globally)

Sebastien Gouezel (May 18 2023 at 08:05):

Your lemmas should be true for any norm on matrices, so why not write them right away in this generality?

Yury G. Kudryashov (May 18 2023 at 08:08):

What other examples of "canonical topology, no canonical norm" do we have?

Yury G. Kudryashov (May 18 2023 at 08:14):

This came up in a discussion with @Heather Macbeth about tensor products of vector bundles. But in that case there is no canonical topology either.

Eric Wieser (May 18 2023 at 08:25):

Sebastien Gouezel said:

Your lemmas should be true for any norm on matrices, so why not write them right away in this generality?

How do you suggest I state something like

lemma has_deriv_at.matrix_mul (X : R  matrix m n R) (Y : R  matrix n p R)
  (X' : matrix m n R) (Y' : matrix n p R) (r : R)
  (hX : has_deriv_at X X' r) (hY : has_deriv_at Y Y' r) :
  has_deriv_at (λ a, (X a)  (Y a)) (X'  Y r + X r  Y') r :=
begin

Sebastien Gouezel (May 18 2023 at 08:26):

Can you add some typeclasses here? You need some topology somewhere.

Eric Wieser (May 18 2023 at 08:27):

Sure, here's the #mwe, extracted from lean-matrix-cookbook

import analysis.matrix

variables {ι : Type*} {R : Type*} {m n p : Type*}
variables [fintype m] [fintype n] [fintype p]
variables [decidable_eq m] [decidable_eq n] [decidable_eq p]
variables [nontrivially_normed_field R]

open matrix
open_locale matrix

local attribute [instance] matrix.normed_add_comm_group matrix.normed_space

lemma has_deriv_at_matrix {f : R  matrix m n R} {r : R} {f' : matrix m n R} :
  has_deriv_at f f' r  ( i j, has_deriv_at (λ r, f r i j) (f' i j) r) :=
by simp_rw has_deriv_at_pi

lemma has_deriv_at.matrix_mul (X : R  matrix m n R) (Y : R  matrix n p R)
  (X' : matrix m n R) (Y' : matrix n p R) (r : R)
  (hX : has_deriv_at X X' r) (hY : has_deriv_at Y Y' r) :
  has_deriv_at (λ a, (X a)  (Y a)) (X'  Y r + X r  Y') r :=
begin
  rw has_deriv_at_matrix at  hX hY,
  intros i j,
  simp only [mul_apply, pi.add_apply, finset.sum_add_distrib],
  exact has_deriv_at.sum (λ k hk, (hX _ _).mul (hY _ _)),
end

Eric Wieser (May 18 2023 at 08:28):

But I cheated, this is only about matrix.normed_space and not the other norms

Anatole Dedecker (May 18 2023 at 08:28):

I’ve spent some time a year ago thinking about how to get meaningful differentiability (which really means a good notion of docs#is_o) without any norm, specifically for the case of finite dimensional vector spaces where we don’t want to impose the norm, but I didn’t think about using docs#is_vonN_bounded for that. This is interesting, do you have any reference ? (Or maybe this is well known and I’m just not aware of it)

Eric Wieser (May 18 2023 at 08:28):

I can't write [normed_add_comm_group (matrix m n R)] [normed_space R (matrix m n R)] because then I get a nonsense addition on the matrices that might not be elementwise

Sebastien Gouezel (May 18 2023 at 08:30):

In this generality, it's definitely not true for all norms (since norms are not all equivalent as you're not assuming your field is complete).

Sebastien Gouezel (May 18 2023 at 08:31):

But I agree I don't see a neat way to write it for all norms even if your field is nice, because normed_add_comm_group can't be expressed with a mixin.

Sebastien Gouezel (May 18 2023 at 08:32):

However, I wouldn't see a way to write it for all topologies either, for the same reason.

Anatole Dedecker (May 18 2023 at 08:33):

One case I’ve heard about a few weeks ago is when you have docs#with_seminorms, then it makes perfect sense to say that docs#is_o means "is_o with respect to each seminorm" and then I think that agrees with the version Yury gave

Sebastien Gouezel (May 18 2023 at 08:33):

Scratch that, for topologies we can definitely use mixins.

Anatole Dedecker (May 18 2023 at 08:34):

For matrices that’s no problem anyway, we have docs#matrix.topological_space

Yury G. Kudryashov (May 18 2023 at 08:44):

Anatole Dedecker said:

I’ve spent some time a year ago thinking about how to get meaningful differentiability (which really means a good notion of docs#is_o) without any norm, specifically for the case of finite dimensional vector spaces where we don’t want to impose the norm, but I didn’t think about using docs#is_vonN_bounded for that. This is interesting, do you have any reference ? (Or maybe this is well known and I’m just not aware of it)

I don't know about references. I just made it up.

Yury G. Kudryashov (May 18 2023 at 08:44):

Possibly, there are better ways to generalize it to topological vector spaces - I don't know.

Eric Wieser (May 18 2023 at 08:51):

Sebastien Gouezel said:

But I agree I don't see a neat way to write it for all norms even if your field is nice, because normed_add_comm_group can't be expressed with a mixin.

I attempted to change it to be a mixin in #18462, but that's lost to the porting tide now (and wasn't looking promising performance-wise)

Oliver Nash (May 18 2023 at 09:01):

I've occasionally mused about generalising fderiv in another direction, where we weaken the module structure on the domain so that the axioms smul_add and add_smul are only required to hold for sufficiently small scalars. The motivation is that the circle (or tori) possess such scalar actions so we could speak of smooth functions on them without having to regard them as manifolds.

Oliver Nash (May 18 2023 at 09:01):

(I'm not seriously suggesting we actually do this.)

Tomas Skrivan (Jun 07 2023 at 16:52):

Why is deriv defined from a normed field to a normed vector space? For example this wiki article talks about well defined and well behaved derivative from finite dimensional spaces to a general topological vector space. Is this because deriv is defined through fderiv?


edit: this was originally the first post in this thread but earlier discussion from a different thread was moved here. Also those two threads got interleaved so it is a bit incoherent right now ...

Jireh Loreaux (Jun 07 2023 at 17:31):

I think there was a recent discussion about generalizing both, but I'm on mobile so I can't find it now.

Tomas Skrivan (Jun 07 2023 at 17:39):

A link to such discussion would be appreciated, I did some searching but I couldn't find any relevant discussions.

Eric Wieser (Jun 07 2023 at 17:53):

Maybe this thread?

Yury G. Kudryashov (Jun 07 2023 at 18:39):

Probably, we should generalize it but this can't be done before the port is over.

Tomas Skrivan (Jun 07 2023 at 20:06):

Waiting for the port to be done makes total sense. I was curious what are the thoughts on this topic as I need the generalization for my project.

Anatole Dedecker (Jun 07 2023 at 20:31):

Since this thread has been linked from somewhere else, I just want to add that the second part of this discussions is not really related to the original topic: unless I’m missing something obvious, the topology on continuous linear maps does not matter here

Tomas Skrivan (Jun 07 2023 at 20:46):

I initialized the other thread and my motivation for generalizing derivative and differentiability is to allow for isomorphism: C(R2,R)C(R,C(R,R))C^\infty(\mathbb{R}^2, \mathbb{R}) \cong C^\infty(\mathbb{R}, C^\infty(\mathbb{R}, \mathbb{R})) which requires to define suitable topology on C(R,R)C^\infty(\mathbb{R}, \mathbb{R}).

After this is done, I want to do some variational calculus calculations.

Kevin Buzzard (Jun 07 2023 at 20:49):

What topology are you proposing to put on C(R,R)C^\infty(\R,\R) to make that assertion true?

Tomas Skrivan (Jun 07 2023 at 20:56):

The topology of uniform convergence on compact sets of each derivative separately, see wiki on convenient vector spaces.

Tomas Skrivan (Jun 07 2023 at 20:58):

You can define such topology for any locally convex TVS with some mild completeness condition and you have a general isomoprhism C(X×Y,Z)C(X,C(Y,Z))C^\infty(X\times Y, Z) \cong C^\infty(X, C^\infty(Y, Z))

Kevin Buzzard (Jun 07 2023 at 21:02):

Oh nice! I could see that it would have to be subtle but I didn't know the answer.

Tomas Skrivan (Jun 07 2023 at 21:03):

It is kind of messed up because you end up with functions that are differentiable but not continuous.

Yury G. Kudryashov (Jun 07 2023 at 21:04):

What are your applications?

Tomas Skrivan (Jun 07 2023 at 21:04):

(deleted)

Yury G. Kudryashov (Jun 07 2023 at 21:05):

Let me move the second part of this thread to the new one.

Tomas Skrivan (Jun 07 2023 at 21:05):

I'm working on symbolic and automatic differentiation for SciLean and if I hope to have it verified I need this generalization of derivative.

Notification Bot (Jun 07 2023 at 21:05):

40 messages were moved here from #maths > Topology on continuous_maps without a norm by Yury G. Kudryashov.

Yury G. Kudryashov (Jun 07 2023 at 21:07):

Now the history looks a bit strange ;)

Tomas Skrivan (Jun 07 2023 at 21:09):

ohh well :man_shrugging: I added a small explanation to my first post at least.

Anatole Dedecker (Jun 07 2023 at 21:42):

To get back to your original question, I think the reason we don't have this easy generalization (talking about deriv here, not fderiv) is indeed because we tend to see deriv as the one-dimensional Fréchet derivative instead of the one-dimensional Gâteaux dérivative. Of course they give the same notion, but because we want the APIs of fderiv and deriv to be similar we probably miss some easy generalizations of deriv.

Yury G. Kudryashov (Jun 07 2023 at 22:39):

But we can generalize fderiv too (see above)

Yury G. Kudryashov (Jun 07 2023 at 22:40):

So, the answer is: at the time derivatives were added to mathlib (~4 years ago), nobody cared about this generality.

Anatole Dedecker (Jun 07 2023 at 22:47):

I agree, my point (and I think Tomas' original message too) was about the fact that the generalization to TVS of deriv is way easier: you can just take the usual limit of (f (x + h) - f x) / h and you don't need any more machinery. But if we make the generalization you suggest (and check that it is indeed a strict generalization of this) then that's even better.

Tomas Skrivan (Jun 07 2023 at 22:48):

@Yury G. Kudryashov I'm not familiar with von Neumann bounded sets. Do you know the relationship between your suggested generalization and differentiability between convenient vector spaces?

Yury G. Kudryashov (Jun 07 2023 at 22:56):

What definition are you talking about? I don't know any references on the subject. I made up the definition above in some conversation.

Yury G. Kudryashov (Jun 07 2023 at 22:57):

Wikipedia says that it is possible to generalize derivatives to TVS "in muliple ways" but doesn't give references.

Yury G. Kudryashov (Jun 07 2023 at 23:04):

I think that my definition should be equivalent to https://en.wikipedia.org/wiki/Fr%C3%A9chet_derivative#Generalization_to_topological_vector_spaces

Yury G. Kudryashov (Jun 07 2023 at 23:07):

UPD: my definition is a bit different but should be equivalent for "nice" TVS domains (probably, locally bounded).

Yury G. Kudryashov (Jun 07 2023 at 23:09):

I guess, we should use the one from Wikipedia instead. UPD: but we need to generalize it to any normed field instead of real numbers.

Yury G. Kudryashov (Jun 07 2023 at 23:11):

Should we add a version of docs4#Asymptotics.IsLittleO for TVS?

Yury G. Kudryashov (Jun 07 2023 at 23:12):

We can't generalize this definition becase it doesn't require a vector space structure; some properties work for a normed group.

Eric Wieser (Jun 07 2023 at 23:12):

image.png

:angry:

Eric Wieser (Jun 07 2023 at 23:13):

What would the TVS version look like?

Yury G. Kudryashov (Jun 07 2023 at 23:14):

We need special support for irreducible_def in doc-gen4

Reid Barton (Jun 07 2023 at 23:14):

Eric Wieser said:

What would the TVS version look like?

Probably it would look the same

Eric Wieser (Jun 07 2023 at 23:14):

I meant, what would the lean definition look like, not the docs!

Yury G. Kudryashov (Jun 07 2023 at 23:16):

/me is thinking

Yury G. Kudryashov (Jun 07 2023 at 23:29):

Not tested:

import Mathlib.Analysis.Asymptotics.Asymptotics

open Set Filter Topology Pointwise

def IsLittleOTVS (𝕜 : Type _) [NontriviallyNormedField 𝕜] {α E F : Type _}
    [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousSMul 𝕜 E]
    [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [TopologicalAddGroup F] [ContinuousSMul 𝕜 F]
    (f : α  E) (g : α  F) (l : Filter α) : Prop :=
     V  𝓝 (0 : F),  U  𝓝 (0 : E),  (φ : α  ), Tendsto φ l (𝓝[>] 0) 
      ∀ᶠ x in l,  a b : 𝕜, a  φ x * b  g x  b  V  f x  a  U

Yury G. Kudryashov (Jun 07 2023 at 23:32):

Trying to prove

theorem isLittleOTVS_iff_isLittleO (𝕜 : Type _) [NontriviallyNormedField 𝕜] {α E F : Type _}
    [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
    {f : α  E} {g : α  F} {l : Filter α} :
    IsLittleOTVS 𝕜 f g l  f =o[l] g := by

Yury G. Kudryashov (Jun 07 2023 at 23:41):

This :up: definition is wrong. Thinking.

Yury G. Kudryashov (Jun 07 2023 at 23:41):

You can always take U = univ

Yury G. Kudryashov (Jun 07 2023 at 23:41):

(no, you can almost always take a = 0 to fail the definition)

Tomas Skrivan (Jun 07 2023 at 23:56):

Yury G. Kudryashov said:

What definition are you talking about? I don't know any references on the subject. I made up the definition above in some conversation.

I would say that f : E → F is differentiable at x if for every curve γ : 𝕜 → E differentiable at 0 and γ 0 = x the curve f ∘ γ : 𝕜 → F is differentiable at 0.

Is that reasonable generalization? If you require smoothness in the definition then based on wiki this should recover any reasonable definition of smoothness for Frechet spaces.

Yury G. Kudryashov (Jun 08 2023 at 00:06):

This is not a generalization of Frechet derivative.

Yury G. Kudryashov (Jun 08 2023 at 00:07):

For a normed vector space, it is not equivalent to docs4#HasFDerivAt

Tomas Skrivan (Jun 08 2023 at 00:10):

I see, then I do not understand these things properly. Why is not equivalent? Is there a counter example?

Yury G. Kudryashov (Jun 08 2023 at 00:17):

The problem is with "if you require smoothness"

Yury G. Kudryashov (Jun 08 2023 at 00:17):

First of all, your definition does not involve any continuous linear map.

Yury G. Kudryashov (Jun 08 2023 at 00:21):

I think that f(x,y)=x3x2+y2f(x, y)=\frac{x^3}{x^2+y^2} is differentiable at zero in the sense of curves but it is not Frechet differentiable.

Tomas Skrivan (Jun 08 2023 at 00:27):

Ahh right, it is mentioned here https://ncatlab.org/nlab/show/Boman%27s+theorem

My final suggestion would be:
f : E → F is differentiable at x if for every γ : 𝕜×𝕜 → E differentiable at 0 and γ 0 = x the f ∘ γ : 𝕜×𝕜 → F is differentiable at 0.

but I really do not understand these things in depth, so I should stop suggesting anything further :)

Yury G. Kudryashov (Jun 08 2023 at 05:23):

I proved that the following:

import Mathlib.Analysis.Asymptotics.Asymptotics
import Mathlib.Analysis.SpecificLimits.Basic

open Set Filter Topology Pointwise Asymptotics Metric

section TVS

variable  (𝕜 : Type _) [NontriviallyNormedField 𝕜] {α E F : Type _}
    [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousSMul 𝕜 E]
    [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [TopologicalAddGroup F] [ContinuousSMul 𝕜 F]

def IsLittleOTVS (f : α  E) (g : α  F) (l : Filter α) : Prop :=
   U  𝓝 (0 : E),  V  𝓝 (0 : F),  c : , 0 < c 
    ∀ᶠ x in l,  b : 𝕜, b  0  g x  b  V   a : 𝕜, a  c * b  f x  a  U

end TVS

theorem isLittleOTVS_iff_isLittleO (𝕜 : Type _) [NontriviallyNormedField 𝕜] {α E F : Type _}
    [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
    {f : α  E} {g : α  F} {l : Filter α} :
    IsLittleOTVS 𝕜 f g l  f =o[l] g := by
  _

The proof is in branch4#YK-isO-TVS

Anatole Dedecker (Jun 08 2023 at 11:50):

@Tomas Skrivan We will definitely need to have different higher-dimensional-domain derivatives at some point (or rather of differentiability I guess, since when they are defined they all agree) anyway, the key point being that fderiv should keep being the usual one in the case of normed spaces. That said, I would guess and hope that we can stay with only one version in the case of one dimensional domain.

Tomas Skrivan (Jun 08 2023 at 12:16):

One thing I do not understand is what is the motivation to have Frechet derivative as the base definition? If a function has Frechet derivative then it has Gateaux derivative. Why not have Gateaux derivative as the basic definition and have theorem that on nice spaces and under nice differentiability conditions it is Frechet derivative.

Sebastien Gouezel (Jun 08 2023 at 12:22):

You want a notion that has nice properties, in the sense that it makes it possible to prove nice theorems. For instance the local inverse theorem, which says that if the derivative is invertible then the map is locally invertible. Or the implicit function theorem. These are true for the Fréchet derivative, but not for the Gateaux derivative. In a sense, Gateaux derivative is a nice gadget, but not useful to prove theorems. While Fréchet derivative is the fundamental notion.

Eric Wieser (Jun 08 2023 at 12:37):

Wikipedia says:

If F is Fréchet differentiable, then it is also Gateaux differentiable, and its Fréchet and Gateaux derivatives agree

If this is actually true in general and not just for the cases wikipedia cares about, then presumably the answer to "Why not have Gateaux derivative as the basic definition" is "it's convenient to have the derivative fderiv bundled as a multilinear map"?

Sebastien Gouezel (Jun 08 2023 at 12:49):

You could have a definition of a derivative as "if there is a continuous linear map which gives the directional derivative in every direction, then use it, and otherwise take 0". This would be the Gateaux derivative in mathlib conventions. And it would be essentially useless because it doesn't have nice properties without further assumptions which amount to saying that the function is in fact Fréchet-differentiable. For instance, a function which is Gateaux-differentiable at a point doesn't have to be continuous there. Or, the composition of two Gateaux-differentiable maps is not in general Gateaux-differentiable. It's just a bad notion from the mathematical point of view.

Yury G. Kudryashov (Jun 08 2023 at 13:11):

Inverse theorem needs strict differentiability, not only Fréchet.

Yury G. Kudryashov (Jun 08 2023 at 13:14):

You can define Gateaux derivative using Fréchet:

def HasDirDerivAt (f : E  F) (f' : F) (v x : E) : Prop :=
  HasDerivAt (f  lineMap x (v + x) : 𝕜  F) f' 0

def dirDeriv (f : E  F) (v x : E) : F :=
  deriv (f  lineMap x (v + x) : 𝕜  F) 0

def GateauxDifferentiableAt (f : E  F) (x : E) : Prop :=
   v, DifferentiableAt 𝕜 (f  lineMap x (v + x) : 𝕜  F) 0

Tomas Skrivan (Jun 08 2023 at 13:24):

I think the only thing I'm suggesting is to have deriv and it's bundled version fderiv as general as possible and then of course have theorems about them with different notions of differentiability.

I would like to formalize Convenient Vector spaces, define a new notion of differentiability and reuse mathlib's deriv but I can't do that as it is restricted to normed spaces.

Sebastien Gouezel (Jun 08 2023 at 13:32):

This is a very niche and exotic notion. Are you sure you really need that for your formalization, instead of sticking with more mainstream and established mathematics?

Tomas Skrivan (Jun 08 2023 at 14:29):

I want to formalize computations in variational calculus, in particular calculations commonly done by physicists in mechanics or thermodynamics.

Using lebesgue/sobolev spaces is annoying as you have to deal with integrability which is completely unrelated to why you would do those computations.

I really want to work with smooth functions, but they do not behave well w.r.t. standard notions of vector spaces.

That is why I want to use convenient vector spaces, I get smooth functions and cartesian closed category which simplifies lot of arguments.

Yury G. Kudryashov (Jun 08 2023 at 15:01):

@Tomas Skrivan Once we generalize Fréchet derivatives, you can define Gateaux derivatives as above, if you need them.

Yury G. Kudryashov (Jun 08 2023 at 15:59):

What do we need to assume about topology on the (co)domain to have IsLittleOTVS.add? The problem is that we can choose different as.

Jireh Loreaux (Jun 08 2023 at 16:15):

If 𝕜 were there would be no problem right? Because then if you get a₁ and a₂ for the individuals, you can take a := ∥a₁∥ + ∥a₂∥ for the sum. Just trying to make sure I understand the issue. (In my head the problem isn't that you have two as, it's that you don't know how to make them "point in the same direction")

Yury G. Kudryashov (Jun 08 2023 at 17:07):

Yes.

Yury G. Kudryashov (Jun 08 2023 at 17:15):

Probably, we should require that nhds of zero has a basis of docs4#Balanced sets.

Jireh Loreaux (Jun 08 2023 at 17:21):

It's still not clear how to pick a though.

Jireh Loreaux (Jun 08 2023 at 17:22):

Because you could have say a₁ = (1 : ℂ) and a₂ = Complex.I.

Yury G. Kudryashov (Jun 08 2023 at 20:13):

I think that Balanced should fix this but I don't have time now. Maybe, tomorrow.

Anatole Dedecker (Jun 08 2023 at 22:39):

Yury G. Kudryashov said:

Probably, we should require that nhds of zero has a basis of docs4#Balanced sets.

This is always true, see docs4#nhds_basis_balanced

Anatole Dedecker (Jun 08 2023 at 23:46):

I haven't spent enough times thinking about this to be sure about what I say, but I think that another reasonable definition would be the following:

import Mathlib.Analysis.Asymptotics.Asymptotics
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Analysis.Convex.Gauge

open Set Filter Topology Pointwise Asymptotics Metric
open scoped ENNReal

section TVS

variable  (𝕜 : Type _) [NontriviallyNormedField 𝕜] {α E F : Type _}
    [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousSMul 𝕜 E]
    [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [TopologicalAddGroup F] [ContinuousSMul 𝕜 F]

-- I would argue this should be the general replacement for `gauge`, but I could be wrong
noncomputable def gauge' (s : Set E) (x : E) : 0 := sInf ((↑‖·‖₊) '' {k : 𝕜 | x  k  s})

def IsLittleOTVS (f : α  E) (g : α  F) (l : Filter α) : Prop :=
   U  𝓝 (0 : E),  V  𝓝 (0 : F),  (c : 0), 0 < c  ∀ᶠ x in l, (gauge' 𝕜 U (f x))  c * (gauge' 𝕜 V (g x))

I am pretty confident that this gives the usual version in normed spaces, but not sure that it's the same notion as Wikipedia's or Yury's. The reason this feels natural is that, if topologies on E and F are generated by seminorms, I think you get a nice-looking characterization, but it's getting too late to even state it...

Anatole Dedecker (Jun 08 2023 at 23:49):

See docs4#gauge and the whole file around it. In particular, the gauge (or gauge’) of the unit ball of a normed space is exactly the norm

Yury G. Kudryashov (Jun 09 2023 at 00:20):

  1. I think that your gauge' should be added as egauge to the library, similar to edist. gauge should be redefined as (egauge _ _).toReal.
  2. I think that our definitions are equivalent. I didn't use docs#gauge in mine because it's not egauge.

Yaël Dillies (Jun 09 2023 at 05:10):

So you lose the fact that the gauge returns a scalar?

Kevin Buzzard (Jun 09 2023 at 06:29):

In the p-adic theory Frechet spaces are topological vector spaces whose topology is defined by a family of seminorms and they play a big role in the p-adic Langlands program. I'm assuming this is material that we stole from the real analysts...

Yury G. Kudryashov (Jun 09 2023 at 12:56):

Yaël Dillies said:

So you lose the fact that the gauge returns a scalar?

Currently, gauge is only defined for a real vector space.

Anatole Dedecker (Jun 09 2023 at 13:12):

I’m on mobile right now so I won’t develop all of my thoughts, but there are two distinct deviations from gauge at play.

  • The first one is indeed just a matter of taking values in ENNReal instead of Real. I would say we should definitely keep both
  • The other one is that, even where both the infimum is well defined, it’s not clear that the two agree for a non-symmetric set. On the other hand, I see no way to generalize gauge to arbitrary field that would preserve this property. This reminds me of the "real polar" VS "absolute polar" design choice, and iirc we chose the latter precisely because it works over other fields

Anatole Dedecker (Jun 09 2023 at 13:13):

Hence I have a question for people more familiar with convex analysis: do you care about the value of the gauge for non absorbent and balanced sets ?

Yury G. Kudryashov (Jun 09 2023 at 13:54):

@Brendan Seamas Murphy does to construct a homeomorphism with a ball.

Yury G. Kudryashov (May 16 2024 at 18:51):

#12852 is a step towards derivatives for functions between TVS

Eric Wieser (Sep 29 2024 at 12:41):

Just to check, are there any open PRs currently on the path to this?

Yury G. Kudryashov (Oct 01 2024 at 05:59):

There is a draft PR #9675 which defines IsLittleOTVS and proves both equivalences we care about (to IsLittleO for normed spaces and to "tends to zero" for domain = field).

Yury G. Kudryashov (Oct 01 2024 at 05:59):

The main issue with this PR is it has low priority for me. If you want to take over it, then you're welcome.

Yury G. Kudryashov (Oct 01 2024 at 06:00):

Once we have it, we can define HasFDerivAtFilter for a topological vector space, but prove everything for normed spaces.

Yury G. Kudryashov (Oct 01 2024 at 06:00):

Of course, later we may decide to generalize some proofs to TVS.

Yury G. Kudryashov (Oct 01 2024 at 06:03):

Also, #15217 is a bit related (it's used in WIP #13648 which generalized docs#ContinuousLinearMap.compSL to TVS, not 100% sure that we'll need it, but seems relevant).

Eric Wieser (Oct 01 2024 at 10:32):

Yury G. Kudryashov said:

The main issue with this PR is it has low priority for me. If you want to take over it, then you're welcome.

I've fixed the conflicts and new lint warnings, but it seems there is a gap in the proof

Yury G. Kudryashov (Oct 01 2024 at 13:38):

I'll fix it today. AFAIR, I wrote the proof w/o egauge, then partially migrated to egauge.

Yury G. Kudryashov (Oct 01 2024 at 13:48):

Fixed, pushed

Yury G. Kudryashov (Oct 19 2024 at 22:40):

#9675 is ready for review!

Eric Wieser (Oct 31 2024 at 02:00):

The details are slightly above my paygrade, but this seems clearly useful for generalizing HasDerivAt etc. Does anyone else more qualified (@Anatole Dedecker, @Sébastien Gouëzel?) want to review, or should we just put this in?

Eric Wieser (Nov 15 2024 at 19:29):

#19104 is the next piece towards generalizing the definitions

Eric Wieser (Nov 15 2024 at 22:26):

And now the very trivial #19114

Eric Wieser (Nov 15 2024 at 22:39):

#19108 is the main change, though bizarrely this fails because the elaborator now thinks it has to find NormedAddCommGroup (List 𝔸)

Eric Wieser (Dec 18 2024 at 22:16):

Any more thoughts on #19108?

Kevin Buzzard (Dec 23 2024 at 10:11):

My thoughts are "golly, lots of files are now slower"

Patrick Massot (Dec 23 2024 at 10:29):

Yes, this is really worrying. Do we know how much time this actually represents? Are those big files?

Junyan Xu (Dec 23 2024 at 10:55):

If you look at the bench results (unfortunately the bench summary bot is dead now), you see that build is 0.359% slower, which is equivalent to adding 20.6 files or 6k lines to mathlib. Lint is 0.394% slower but only costs ~5% instructions compared to build.

Junyan Xu (Dec 23 2024 at 10:58):

I see that Mathlib.Analysis.Calculus.Deriv.Prod got 102% slower though. Probably worth investigating ...

Eric Wieser (Dec 23 2024 at 11:43):

By wall clock, the total build is 0.6% or 6s slower, where the current build time is 17 minutes and 15 seconds

Eric Wieser (Dec 23 2024 at 11:50):

I investigated the file with the largest absolute slowdown using the firefox profiler; my takeaway is that statements like HasDerivAt f f' take longer to elaborate because before the process was:

  • I need NormedAddCommGroup F
  • Oh, it's in the context

and now its:

  • I need AddCommGroup F
  • I will do a typeclass search
  • Goose chasing ensues
  • Oh, it's NormedAddCommGroup.toAddCommGroup

and this happens for every single reference to these definitions.

Kevin Buzzard (Dec 23 2024 at 11:54):

I see! And we definitely don't want to increase the priority of NormedAddCommGroup.toAddCommGroup because 99% of the time this is a disastrous thing to try (leading us on a wild goose chase) and the right answer is probably Ring.toAddCommGroup.

Eric Wieser (Dec 23 2024 at 11:55):

A reasonable stance to hold would be "pick any priorities you like if mathlib becomes faster as a result" but this of course has unpredictable impact on code that hasn't been written yet

Eric Wieser (Dec 23 2024 at 11:56):

I think the performance hit for Prod specfically can be greatly reduced in future by generalizing the lemmas to also not need NormedAddCommGroup at all

Eric Wieser (Dec 23 2024 at 11:57):

But this a) is a massive scope creep, and b) probably just shifts the performance drop to the callers, where the game can maybe be repeated in exchange for even further scope creep

Eric Wieser (Dec 23 2024 at 12:08):

Kevin Buzzard said:

golly, lots of files are now slower"

Perhaps also worth considering that the push for file splits / the overall growth of mathlib is going to mean that performance issues increasingly impact "lots" of files

Junyan Xu (Dec 23 2024 at 16:29):

Maybe refreshing the NormedAddCommGroup.toAddCommGroup instance locally would help. I've noticed that once you import Nat.card etc. into the algebraic hierarchy (e.g. in Ideal/Quotient/Operations), the trace for synthesizing CommRing.toRing becomes this:

[Meta.synthInstance] :check: Ring R ▼
[] new goal Ring R ▶
[] :check: apply @StrictOrderedRing.toRing to Ring R ▶
[] :check: apply @LinearOrderedRing.toStrictOrderedRing to StrictOrderedRing R ▶
[] :check: apply @LinearOrderedCommRing.toLinearOrderedRing to LinearOrderedRing R ▶
[] :check: apply @LinearOrderedField.toLinearOrderedCommRing to LinearOrderedCommRing R ▶
[] :check: apply @StrictOrderedCommRing.toStrictOrderedRing to StrictOrderedRing R ▶
[] :check: apply @LinearOrderedCommRing.toStrictOrderedCommRing to StrictOrderedCommRing R ▶
[] :check: apply @OrderedRing.toRing to Ring R ▶
[] :check: apply @OrderedCommRing.toOrderedRing to OrderedRing R ▶
[] :check: apply @StrictOrderedCommRing.toOrderedCommRing to OrderedCommRing R ▶
[] :check: apply @StrictOrderedRing.toOrderedRing to OrderedRing R ▶
[] :check: apply @DivisionRing.toRing to Ring R ▶
[] :check: apply @Field.toDivisionRing to DivisionRing R ▶
[] :check: apply @LinearOrderedField.toField to Field R ▶
[] :check: apply @CommRing.toRing to Ring R ▶
[] :check: apply inst✝¹ to CommRing R ▶
[resume] propagating CommRing R to subgoal CommRing R of Ring R ▶
[] result CommRing.toRing

However, refreshing the CommRing.toRing instance has a mixed effect: it makes some decls in the file faster and some slower.

Kevin Buzzard (Dec 23 2024 at 16:45):

As you may well know, unfolding the new goal Ring R ▶ line in your trace shows the list of instances which Lean is about to apply in reverse order in order to try and solve Ring R. The list is ordered by priority, with things of equal priority being ordered by when Lean found them, so in particular out of all of the things with default priority, it tries the one it learnt last, first.

Eric Wieser (Dec 23 2024 at 16:49):

I'll use this as an opportunity to suggest people upvote lean4#6389, since without that the infoview doesn't reveal that LinearOrderedField.toField is a subgoal generated by DivisionRing.toRing

Kevin Buzzard (Dec 23 2024 at 16:52):

(I noticed that this had changed in the infoview, and just assumed that it was intentional because I barely ever look at the command line output)

Junyan Xu (Dec 23 2024 at 17:51):

so in particular out of all of the things with default priority, it tries the one it learnt last, first.

Yes I'm aware, and by "refreshing" I mean just reiterate an existing instance again to ensure it's fresh in Lean's memory (as if it just learnt it).

Junyan Xu (Dec 23 2024 at 17:54):

I also tried to lower the priority of StrictOrderedRing.toRing etc. here but then something in Mathlib/Tactic/Positivity/Core.lean times out.

Kevin Buzzard (Dec 23 2024 at 19:01):

Yes it seems to me that the moment you start globally goofing around, you break random unrelated files. One hack might be to locally fudge priorities in the files which are currently slower?

Michael Stoll (Dec 23 2024 at 19:02):

This is likely related to the order+algebra type class problem that I was trying to mitigate in #12778 ...

Kevin Buzzard (Dec 23 2024 at 19:08):

Yes, I guess this is the related norm+algebra typeclass problem :-/

Eric Wieser (Dec 23 2024 at 19:11):

The norm+algebra one is arguably worse because we inherited a weird mix of new- and old- style classes from Lean 3

Eric Wieser (Dec 23 2024 at 19:11):

But I'd rather that we not gate the titular generalization in #19108 that costs a 6s global slow down on a multi-month refactor!

Yury G. Kudryashov (Dec 23 2024 at 19:38):

BTW, we use very different approaches to topological groups and normed groups. For topological groups, it's [AddCommGroup G] [TopologicalGroup G], while normed groups are bundled.

Yury G. Kudryashov (Dec 23 2024 at 19:38):

Are pros and cons of these approaches described somewhere?

Yury G. Kudryashov (Dec 23 2024 at 19:39):

Also, we use NormedSpace K E, if K is a field but module+mixins in case K is a normed (division) ring.

Anatole Dedecker (Dec 23 2024 at 19:40):

Yes, I think that part of the library deserves some technical decisions to be re-evaluated

Yuyang Zhao (Dec 23 2024 at 20:31):

There was a relevant refactor !3#18462. But it was abandoned for porting.

Kevin Buzzard (Dec 23 2024 at 20:58):

I'm trying to make some sense of the slowdowns. The first thing to say is that this is nothing like the algebra slowdowns we've seen in the past, where Module \u A B is incredibly slow and you have to bump up max heartbeats to 400,000. These "30% slower files" are still compiling in just a few seconds, it's just that apparently they were compiling in one or two fewer seconds before. Having looked at a random sample of these files I am now far less concerned about merging this PR.

One thing I noticed when experimenting is that whilst it's difficult to put your finger on what is causing the slowdowns (everything is just a bit slower), a random typeclass instance trace in one file has this on master

 [Meta.synthInstance] [0.000128] 💥️ Semiring ?m.340822

and this (for the same search) on the branch

[Meta.synthInstance] [0.000128] 💥️ Semiring ?m.420469

So (looking at the numbers) Lean is is using 25% more metavariables in the branch. I have no idea if this is significant. But what I do know is that these huge percentage increases seem to be completely insignificant in terms of wall clock time so, as I said, I'm very happy to merge. Are there any dissenting voices?

Kevin Buzzard (Dec 23 2024 at 21:02):

Patrick Massot said:

Yes, this is really worrying. Do we know how much time this actually represents? Are those big files?

These are fast files and they're still fast after this PR. There seems to be little to worry about here.

Yury G. Kudryashov (Dec 23 2024 at 23:15):

Yuyang Zhao said:

There was a relevant refactor !3#18462. But it was abandoned for porting.

What's known about pros and cons of each approach?

Junyan Xu (Dec 24 2024 at 00:06):

The slowdown from #19046 and my #17930 are of a similar order (several seconds).

Any one knows why lint uses ~5% instructions as build but ~1/3 wall-clock time? Less parallelization?

Eric Wieser (Dec 24 2024 at 00:08):

I think lint has basically no parallelization?

Yury G. Kudryashov (Dec 24 2024 at 02:54):

Why linter can't run itself on all defs/theorems in parallel?

Yury G. Kudryashov (Dec 24 2024 at 02:55):

Is it "because nobody added this functionality" or there are some obstacles?

Johan Commelin (Dec 24 2024 at 05:39):

I think that if #17930 now has a slowdown in the range of several seconds, then that is a very acceptable price to pay for generalizing a bunch of stuff to two-sided ideals.

Junyan Xu (Dec 24 2024 at 13:03):

Thanks! Apparently the slowdown from #17930 is 6.562s (in this run), a bit higher than 5.861s for Eric's #19108, even though in terms of instructions it's 0.178% vs. 0.359%. I guess parallelization and fluctuation are playing a role here.
image.png
image.png

Eric Wieser (Dec 24 2024 at 14:06):

On the topic of the original thread, #20220 (edit: now depends on #20305) is a step towards generalizing more results to TVSs

Eric Wieser (Dec 26 2024 at 01:38):

Beyond that, I think the key missing piece is IsLittleOTVS.add, which I think will require something along the lines of

-- probably needs `Convex _ s` and `Absorbent _ s`
lemma egauge_add_le (x y : E) :
    egauge 𝕜 s (x + y)  egauge 𝕜 s x + egauge 𝕜 s y := by

to match docs#gauge_add_le. From there, I can prove (in #20250)

lemma IsLittleOTVS.add
    [TopologicalAddGroup F] [Module  F] [LocallyConvexSpace  F]
    [TopologicalAddGroup E] [Module  E] [LocallyConvexSpace  E]
    {f₁ f₂ : α  E} {g : α  F} {l : Filter α}
    (hf₁ : IsLittleOTVS 𝕜 f₁ g l) (hf₂ : IsLittleOTVS 𝕜 f₂ g l) :
    IsLittleOTVS 𝕜 (f₁ + f₂) g l := by

though having to assume that E is both a 𝕜-vector space and an -vector space is a little annoying

Yury G. Kudryashov (Dec 26 2024 at 03:20):

We definitely want HasDerivAt.add to work for fields that aren't RCLike.

Yury G. Kudryashov (Jan 21 2026 at 05:11):

#34127 generalizes most of the theory about tangentConeAt and UniqueDiffOn to topological vector spaces, changing the definition to

universe u v
variable (R : Type u) {E : Type v}

section TangentConeAt

variable [AddCommMonoid E] [SMul R E] [TopologicalSpace E] {s : Set E} {x y : E}

/-- The set of all tangent directions to the set `s` at the point `x`. -/
def tangentConeAt (s : Set E) (x : E) : Set E :=
  {y : E | ClusterPt y (( : Filter R)  𝓝[(x + ·) ⁻¹' s] 0)}

As a side effect, docs#posTangentConeAt becomes a special case of tangentConeAt. Suggestions are welcome. E.g., I'm not sure about 𝓝[(x + ·) ⁻¹' s] 0 vs (𝓝[s] x).comap (x + ·) vs (𝓝[s] x).map (· - x). All three are equivalent in a topological group, so this only affects [ContinuousAdd E] assumptions here and there. Also, should I use [AddCommMonoid E] in the definition and in lemmas that work with this assumption, or stick to at least AddCommGroup E everywhere?

Yury G. Kudryashov (Jan 21 2026 at 05:12):

I'm reviving an old thread. For those who didn't follow this refactor, we've already generalized HasFDerivAt etc to topological vector spaces, but lots of lemmas still assume NormedSpace.

Eric Wieser (Jan 21 2026 at 05:38):

Unless we're certain the generality is correct for AddCommMonoid, I'd be inclined to stick with groups for now; that is, focus on just one part of the generalization at a time

Yury G. Kudryashov (Jan 21 2026 at 06:01):

Which of the three spellings look more natural to you?

Eric Wieser (Jan 21 2026 at 06:20):

𝓝[(x + ·) ⁻¹' s] 0 has the advantage that when you unfold to it, you don't duplicate x

Eric Wieser (Jan 23 2026 at 21:42):

I'd like to let @Sébastien Gouëzel have one more look at #34127, but I think it's pretty much ready to go.

Eric Wieser (Jan 23 2026 at 21:43):

What's the next step after this; is it just mindless typeclass generalization, or is there more mathematical work to do?

Yury G. Kudryashov (Jan 23 2026 at 22:42):

I think that for fderiv, it's mostly typeclass generalization. If we want to generalize stuff like fderiv_mul to topological algebras over a normed field, then we should replace docs#IsBoundedBilinearMap with a version for topological spaces (a bilinear map that is continuous as a function on the product).

Yury G. Kudryashov (Jan 23 2026 at 22:43):

For iterated derivatives, the situation is more complicated, because uncurrying only works for normed spaces. Probably, we can generalize to the codomain being a TVS, but not for the domain.

Eric Wieser (Jan 23 2026 at 22:44):

Do you have a branch already with those generalizations (say, for add and sum), or do you want me to have a go once the above lands?

Yury G. Kudryashov (Jan 23 2026 at 22:44):

I would wait with this until we generalize enough of theorems about docs#fderiv.

Yury G. Kudryashov (Jan 23 2026 at 22:45):

I don't have a branch yet.

Yury G. Kudryashov (Jan 23 2026 at 22:46):

I've recently found out about this approach to CkC^k. I don't know how exactly it relates to our definition in case of real normed spaces.

Yury G. Kudryashov (Jan 23 2026 at 22:48):

Pros of this approach is that (a) it works for functions on topological vector fields over topological fields (do people really need topological fields w/o a norm? idk); (b) it gives, e.g., symmetry of derivatives over other fields.

Yury G. Kudryashov (Jan 23 2026 at 22:49):

(c) it looks similar to Whitney differentiability, not sure if it's exactly the same for, e.g., closed sets in finite dimensional spaces.

Yury G. Kudryashov (Jan 23 2026 at 22:50):

BTW, do you have any idea about why do we see so much red in the benchmark?

Yury G. Kudryashov (Jan 23 2026 at 22:55):

E.g., would it be better if I assume a stronger typeclass about the coefficients type everywhere? I doubt that we'll need it for anything less than a DivisionSemiring.

Yury G. Kudryashov (Jan 23 2026 at 22:56):

This will shorten the path in instance searches, but add more fields for defeq calls.

Yury G. Kudryashov (Jan 23 2026 at 22:57):

BTW, I would appreciate reviews of #34033 and #34074 (more API about asymptotics in TVS).

Eric Wieser (Jan 23 2026 at 22:57):

Does docs#HasFDerivAtFilter.tendsto_nhds generalize without much work?

Yury G. Kudryashov (Jan 23 2026 at 22:57):

I might have it in a branch.

Yury G. Kudryashov (Jan 23 2026 at 22:58):

Let me have a look later today.

Yury G. Kudryashov (Jan 23 2026 at 23:00):

As for the next few lemmas, I think that we should introduce IsEquivalentTVS. Before doing this, I would prefer to merge the two PRs above, then split the file while moving it to Topology/Algebra/Module/Asymptotics/*.

Yury G. Kudryashov (Jan 23 2026 at 23:05):

Then I would deprecate the *BigO_*_rev lemmas and replace them with more precise IsEquivalent + IsTheta lemmas.

Yury G. Kudryashov (Jan 23 2026 at 23:07):

One more unrelated generalization I was thinking about is to make docs#HasFDerivAtFilter take a filter on the product as an argument, so that it works for docs#HasStrictFDerivAt too.

Eric Wieser (Jan 23 2026 at 23:08):

Eric Wieser said:

Do you have a branch already with those generalizations (say, for add and sum), or do you want me to have a go once the above lands?

#34345 makes a start on basic; I've just commented things out for now to make conflicts easier to resolve

Eric Wieser (Jan 23 2026 at 23:10):

My guess would be that we should relocate all the commented out code to a new section or file, since the statements actually need a norm in their assumptions or conclusions

Yury G. Kudryashov (Jan 23 2026 at 23:49):

I can have a look tomorrow.

Stepan Nesterov (Jan 24 2026 at 00:28):

Yury G. Kudryashov said:

Pros of this approach is that (a) it works for functions on topological vector fields over topological fields (do people really need topological fields w/o a norm? idk); (b) it gives, e.g., symmetry of derivatives over other fields.

I don't think I know any application of talking about merely C^k functions over fields other than R or C. The only regularity class for functions over Q_p I see people work with is analytic functions, where things like symmetry of partials is completely obvious anyway.

Eric Wieser (Jan 24 2026 at 00:44):

Eric Wieser said:

Does docs#HasFDerivAtFilter.tendsto_nhds generalize without much work?

I worked this one out (edit: #34347)

Yury G. Kudryashov (Jan 24 2026 at 00:51):

Stepan Nesterov said:

Yury G. Kudryashov said:

Pros of this approach is that (a) it works for functions on topological vector fields over topological fields (do people really need topological fields w/o a norm? idk); (b) it gives, e.g., symmetry of derivatives over other fields.

I don't think I know any application of talking about merely C^k functions over fields other than R or C. The only regularity class for functions over Q_p I see people work with is analytic functions, where things like symmetry of partials is completely obvious anyway.

The paper I've linked shows that at least some people care about ways to define CkC^k over Qp\mathbb Q_p to get meaningful results. I have no idea how common is it. If this definition is equivalent to Whitney differentiability for closed subsets of Rn\mathbb R^n, then I would introduce it. Otherwise, I would wait until one of the people who care about this comes to us.

Stepan Nesterov (Jan 24 2026 at 01:08):

Sure some people will study it just because they find it intrinsically interesting. I'm just saying that from what I know, there isn't really any use for the C^k-differentiable p-adic functions in mainstream number theory. So if there are some complications with the definition because what if it doesn't work over some crazy fields, I would personally vote for restricting the theory to R or C over doing something very complicated.

Moritz Doll (Jan 24 2026 at 02:50):

Yury G. Kudryashov said:

For iterated derivatives, the situation is more complicated, because uncurrying only works for normed spaces. Probably, we can generalize to the codomain being a TVS, but not for the domain.

The iterated Frechet derivative for the codomain being a TVS would be amazing to have! I have a bunch of results that I could probably prove very easily, but not state because that is missing.

Yury G. Kudryashov (Jan 24 2026 at 02:53):

Do you know what definition is the right one in this context? I've misread "codomain" as "domain" :man_facepalming:

Eric Wieser (Jan 24 2026 at 04:17):

Eric Wieser said:

My guess would be that we should relocate all the commented out code to a new section or file, since the statements actually need a norm in their assumptions or conclusions

Done in #34348.

Robert Maxton (Jan 24 2026 at 04:49):

I'm someone who would care about "fields other than R\mathbb{R} or C\mathbb{C}"! Specifically I care about (continuous, nonanalytic but presumably smooth functions on) the field of unitary operators on Rn\mathbb{R}^n or Cn\mathbb{C}^n, where nn \to \infty; I'm interested in TVS's because they show up in some approaches to algebraic quantum field theory. I have no idea if that meaningfully changes your constraints any, but since it came up...

Yury G. Kudryashov (Jan 24 2026 at 05:02):

Are you interested in this field as a field of coefficients or as the domain/codomain of functions?

Yury G. Kudryashov (Jan 24 2026 at 05:04):

I know there are people here who do analysis with R\mathbb R, C\mathbb C, or Qp\mathbb Q_p as the field of scalars. I don't know if people are interested in other fields as fields of scalars. Also, I don't know if there are people here who care about CkC^k functions, k<ωk<\omega, in case of the pp-adic analysis.

Robert Maxton (Jan 24 2026 at 05:13):

Yury G. Kudryashov said:

Are you interested in this field as a field of coefficients or as the domain/codomain of functions?

Both, but particularly the latter.

Moritz Doll (Jan 24 2026 at 08:07):

Yury G. Kudryashov said:

Do you know what definition is the right one in this context? I've misread "codomain" as "domain" :man_facepalming:

There is something with derivatives in "tame" Fréchet spaces (grading of the seminorms and some additional condition)- it is some paper by Hamilton. It defines only directional derivatives and C^1 is all directional derivatives exist and the derivative built from the directional derivatives is continuous. I think there is something that the definition does not match up with the one for Banach spaces, so it might be very hard to generalize beyond Banach spaces as the domain and keep a useful derivative.

Moritz Doll (Jan 24 2026 at 09:02):

But the thing that I would like to have is way more simple (and IMO way more relevant): I would like to say that a function is smooth from the reals (or non-negative reals) to Schwartz functions, to be able to state regularity of something like the propagator of the wave/Schrödinger equation (or heat) and having all of the calculus library for codomain being a TVS is the main obstacle.

Sébastien Gouëzel (Jan 24 2026 at 11:15):

Yury G. Kudryashov said:

I've recently found out about this approach to CkC^k. I don't know how exactly it relates to our definition in case of real normed spaces.

I was aware of this approach when I developed C^k in Mathlib. The book by Schikhof (Ultrametric calculus) is a very nice reference for that. It is a little bit alien to what we usually do on R\R or C\mathbb{C} because it is not written in terms of a sequence of iterated derivatives all of a similar nature. It turns out to be equivalent to the usual definition on R\R or C\mathbb{C}, but the definitions and results are sufficiently different that it would be much harder to use in the usual situations. In fact, to me the main point of calculus, and the reason for its power, it that you can deduce properties of the function from properties of the derivative, and this doesn't really hold in this generalized context because there is no real notion of derivative. So, for practicality of use, I decided to go for a more classically-flavored definition.

If anyone has a use for the more exotic definition, I think it should be defined as a parallel hierarchy in Mathlib, not replacing the one we already have. But I don't know of applications beyond the theory itself, so I'm not sure there is a huge pressure or need for that in Mathlib.

Kevin Buzzard (Jan 24 2026 at 12:59):

I think that sometimes it is wise to bifurcate in the archimedean/nonarchimedean case even if it's strictly speaking possible to formalise everything in a universal way. For example, it's possible to define the adeles of Q\mathbb{Q} as a restricted product of the completions of Q\mathbb{Q}, but we have an essentially completely disjoint API for archimedean and nonarchimedean completions, so in mathlib the adeles of a number field is defined as the product of (the restricted product of the nonarchimedean completions) and (the product of the archimedean completions) and we severely stress-tested this design decision in the FLT project throughout 2025 and I was very happy with it.

The first section of the fundamental book by Jacquet and Langlands (which we'll need for FLT) talks about Schwarz functions on a completion of a number field, so this is either R\R or C\mathbb{C} or a pp-adic field, and I absolutely did not start screaming about pp-adic fields when people started developing the classical theory of Schwarz functions, because even though I knew that in theory one could develop the theory in such a way that a small part of it applied to the pp-adic case, in the pp-adic case it's just locally constant functions with compact support, and I could see absolutely no point at all in arguing that the theory should apply in the pp-adic case when it was simply far easier to just make the (far simpler) relevant definitions in the nonarchimedean case by hand.

There is an art to formalization -- you want your definitions to hold not in "the most generality" but in "the right generality". If we always went for the most generality then probably the bottom of our algebra hierarchy would be statements about objects of categories or something! We wouldn't have Zero and One, we'd have Element which unifies the two theories in a totally unhelpful way.

Eric Wieser (Jan 25 2026 at 17:47):

Eric Wieser said:

Done in #34348.

This should now be ready to go, which unblocks #34345 which generalizes Basic.lean to TVS. I had a quick go at generalizing Const.lean, but docs#hasFDerivWithinAt_singleton doesn't work without some thought

Yury G. Kudryashov (Jan 25 2026 at 19:19):

I will have some time tonight to review this and #34402 (unrelated)

Yury G. Kudryashov (Jan 26 2026 at 05:19):

Sent #34348 to bors. Please tell me when #34345 is ready for review.

Eric Wieser (Jan 26 2026 at 06:57):

@Yury G. Kudryashov, #34345 is ready

Yury G. Kudryashov (Feb 01 2026 at 19:49):

While thinking about generalizing more lemmas, I've found out that I don't know how to prove this lemma (and if it's true in a general TVS):

import Mathlib

open Asymptotics

theorem goal {α 𝕜 E : Type*} [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
    [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
    {l : Filter α} {f g : α  E} (h : f =o[𝕜; l] g) :
    g =O[𝕜; l] (f + g) := by
  sorry

It's a part of IsEquivalentTVS.isThetaTVS, where IsEquivalentTVS is defined in the same way as docs#Asymptotics.IsEquivalent, but for TVS.

Yury G. Kudryashov (Feb 01 2026 at 19:51):

A version of this lemma docs#Asymptotics.IsLittleO.right_isBigO_add for normed spaces is used in the proof of docs#HasFDerivAtFilter.isBigO_sub_rev

Anatole Dedecker (Feb 01 2026 at 20:30):

I think this should at least be true in the locally convex settings, using the results of #34472

Yury G. Kudryashov (Feb 01 2026 at 20:34):

This is not something that we can require for any field K.

Anatole Dedecker (Feb 01 2026 at 20:35):

We can thanks to docs#PolynormableSpace, which encompasses all normed spaces

Anatole Dedecker (Feb 01 2026 at 20:36):

But it would be nicer to not have this assumption I agree

Anatole Dedecker (Feb 01 2026 at 20:52):

Wait actually I retract my claim: even in the locally convex it's not clear if it's true

Anatole Dedecker (Feb 01 2026 at 21:00):

Am I right that, in RN\mathbb{R}^\mathbb{N} with the product topology, the function f:NRN,n(nk)kf : \mathbb{N} \to \mathbb{R}^\mathbb{N}, n \mapsto (n^k)_k satisfies f=o(f)f = o(f) at infinity? Because each coordinate is negligible compared to the next one. But then of course fO(ff)f \neq O(f - f) so your lemma would be false?

Yury G. Kudryashov (Feb 01 2026 at 21:01):

Does it mean that our definition of f = o(g) in a TVS is bad?

Anatole Dedecker (Feb 01 2026 at 21:17):

I'm not sure to be honest. My guess (purely based on the locally convex/polynormable setting) is it's the only sensible thing, and it should give some interesting generalization (typically, we could upgrade docs#hasFDerivAt_pi to arbitrary products, which would allow stating things in a convenient way), but probably there's too many pathologies to generalize everything.

Anatole Dedecker (Feb 01 2026 at 21:21):

For anyone following along: in the locally convex setting, the criterion for f=o(g)f = o(g) is: for any continuous seminorm pp, there exists a continuous seminorm qq such that pf=o(qg)p\circ f = o(q\circ g). The issue, IIUC, comes from this forall/exists asymmetry.

Anatole Dedecker (Feb 02 2026 at 00:25):

Aha, in fact this suggests a probably better behaved definition of asymptotic equivalents : for all continuous seminorm pp, p(fg)=o(p(g))p(f - g) = o(p(g)) (and in general you replace the "forall seminorm" by "for any gauge of a neighborhood of zero").

I haven’t thought about the details though, so take this with a grain of salt.

Yury G. Kudryashov (Feb 02 2026 at 00:34):

This won't be helpful for derivatives, since we can't get it from f=o(g).

Kevin Buzzard (Feb 02 2026 at 07:33):

Is this generalisation for its own sake or are people really using little-o notation in the wild in situations where there isn't a canonical fixed norm?

Yury G. Kudryashov (Feb 02 2026 at 15:20):

People use derivatives without a canonical fixed norm. E.g.,

  • derivative of a function f ⁣:RC(E,F)f\colon\mathbb R\to C^\infty(E, F);
  • matrix spaces have no canonical norm in Mathlib.

Yury G. Kudryashov (Feb 02 2026 at 16:36):

For growth estimates, docs#Asymptotics.IsLittleO etc are more convenient, as they have more API. docs#Asymptotics.IsLittleOTVS was introduced to generalize the derivatives.

Moritz Doll (Feb 22 2026 at 22:01):

Sorry for being late to this discussion, but would it be easier if we restrict to the co-domain of gg being a normed space? then there is no seminorm qq to choose. For the derivatives that is all we need, right?

Yury G. Kudryashov (Feb 22 2026 at 22:53):

That's what we have now in docs#HasFDerivAt.isEquivalent_sub now.

Yury G. Kudryashov (Feb 22 2026 at 22:54):

UPD: sorry, I've misread what you were answering. I'll look into this later today.

Moritz Doll (Feb 22 2026 at 22:55):

What I would expect the definition for IsLittleOTVS to be is: f=o(g)f = o(g) if for every continuous seminorm pp, we have that p(f)=o(g)p(f) = o(\|g\|)

Yury G. Kudryashov (Feb 22 2026 at 22:55):

I don't think that we should restrict this in the definition.

Yury G. Kudryashov (Feb 22 2026 at 22:56):

We have a definition that works for a function between two TVS, and it gives the right result for (semi)normed spaces. Why change it?

Moritz Doll (Feb 22 2026 at 23:36):

There is no need to change it, but maybe we want a characterisation in terms of the co-domain of f being polynormable and the co-domain of g being normable? And then it should be easy to prove the statement above. Or do you have a case where g maps into a locally convex space?


Last updated: Feb 28 2026 at 14:05 UTC