Zulip Chat Archive

Stream: mathlib4

Topic: Generalizing the Hyperreal API


Violeta Hernández (Dec 18 2025 at 10:20):

Currently Mathlib does not have much of a development for the hyperreals, just a single 700 line file over at docs#Hyperreal. My proposal is to cut it down in half.

Most of the file is spent introducing such notions such as docs#Hyperreal.Infinite, docs#Hyperreal.Infinitesimal, and docs#Hyperreal.st. All of these can be generalized (and are useful! e.g. surreals) to the setting of a general (non-)Archimedean field. Specifically:

  • Hyperreal.Infinite x: ArchimedeanClass.mk x < 0
  • Hyperreal.Infinitesimal x: 0 < ArchimedeanClass.mk x
  • Hyperreal.st x: ArchimedeanClass.stdPart x (I added this just a few days ago)
  • Hyperreal.IsSt x r: 0 < ArchimedeanClass.mk (x - ↑r)
  • Hyperreal.InfinitePos x: 0 < x ∧ ArchimedeanClass.mk x < 0
  • Hyperreal.InfiniteNeg x: x < 0 ∧ ArchimedeanClass.mk x < 0

My idea is then to deprecate all of these predicates, and generalize whatever useful theorems exist about them to this broader setting of non-Archimedean fields. This would leave us with basically nothing about hyperreals proper, save for the definition and some very basic theorems about how these functions relate to the ultrafilters in their definition. Is this an ok thing to do?

Violeta Hernández (Dec 18 2025 at 10:22):

(Truthfully I'm skeptical on whether we even want hyperreals specifically in Mathlib, rather than more generally proving Łoś's theorem, but that's a separate discussion)

Ruben Van de Velde (Dec 18 2025 at 10:38):

That sounds sensible. It doesn't seem too bad to keep the definition and presumably the instance of ArchimedeanClass if it's not that much code

Violeta Hernández (Dec 18 2025 at 10:40):

Would the correct move be to just deprecate everything about these six predicates? Or do I also have to show that the API that exists on ArchimedeanClass is sufficient to prove all of the API that exists on Hyperreal?

Violeta Hernández (Dec 18 2025 at 10:41):

(after #33007, it basically should be)

Ruben Van de Velde (Dec 18 2025 at 10:46):

Well, picking a random example like docs#Hyperreal.isSt_iff_abs_sub_lt_delta - if you deprecate it in favour of a lemma about ArchimedeanClass.stdPart, ideally you'd replace the proof to be sure the replacement works as well as you expect

Violeta Hernández (Jan 06 2026 at 03:37):

I've opened #33650 for this deprecation. It depends on two other PRs which add some material to the file so that we don't end up losing anything of mathematical substance.

Violeta Hernández (Jan 06 2026 at 03:42):

I found that most of the file was just boilerplate which would not be very interesting to reprove. I claim that the lemmas in #33644 plus the existing API on stdPart and ArchimedeanClass well make up for the remainder.

Violeta Hernández (Jan 06 2026 at 05:07):

@Abhimanyu Pallavi Sudhir Figured that I should notify the original author about this refactor (though the account hasn't been active in three years)


Last updated: Feb 28 2026 at 14:05 UTC