Zulip Chat Archive

Stream: new members

Topic: NNRat not countable?


Joris van Winden (Jan 08 2026 at 10:58):

I am writing a probability proof, and I want to use ae_all_iff on a statement of the form h : ∀ c : ℚ≥0, ∀ᵐ ω ∂P, M c where M is some predicate. In my case M essentially consists of a bunch of bounds formulated for ℝ≥0, so I would really like to have c range over a type which coerces nicely to ℝ≥0.

The problem that I encounter is that lean cannot synthesize Countable ℚ≥0, even though this intuitively seems like it should be true. Why is this happening, and is there a good way to work around this?

Ruben Van de Velde (Jan 08 2026 at 11:05):

Doesn't seem to be there, let me check if I can prove it in a few minutes

Aaron Liu (Jan 08 2026 at 11:06):

import Mathlib

theorem NNRat.countable : Countable NNRat :=
  Subtype.countable

Ruben Van de Velde (Jan 08 2026 at 11:07):

That's even shorter than mine

instance : Countable 0 :=
  (Function.invFun_surjective NNRat.coe_injective).countable

Ruben Van de Velde (Jan 08 2026 at 11:07):

Aaron, can you please PR yours?

Joris van Winden (Jan 08 2026 at 11:09):

Thanks! So I guess this is currently just missing from mathlib then?

Ruben Van de Velde (Jan 08 2026 at 11:13):

Yes

Ruben Van de Velde (Jan 08 2026 at 11:13):

I think NNRat hasn't seen that much use yet

Aaron Liu (Jan 08 2026 at 11:20):

#33749

Etienne Marion (Jan 08 2026 at 11:31):

I once got into this issue as well, I needed a countable dense subset of NNReal, but I realized that using an arbitrary one was just easier than using the range of the coercion NNRat -> NNReal.

Aaron Liu (Jan 08 2026 at 11:34):

do we have a TopologicalSpace.SeparableSpace instance?

Etienne Marion (Jan 08 2026 at 11:38):

Yes, I used TopologicalSpace.exists_countable_dense here.

Etienne Marion (Jan 08 2026 at 11:39):

NNReal.instSecondCountableTopology

Joris van Winden (Jan 08 2026 at 11:47):

Etienne Marion said:

I once got into this issue as well, I needed a countable dense subset of NNReal, but I realized that using an arbitrary one was just easier than using the range of the coercion NNRat -> NNReal.

Ah, thanks for this suggestion. I'm having some additional difficulty managing various coercions between , and their nonnegative variants, so I might try this approach instead.


Last updated: Feb 28 2026 at 14:05 UTC