Zulip Chat Archive
Stream: Is there code for X?
Topic: The finset of numerators of a finite set of fractions.
Yiming Fu (May 07 2025 at 16:27):
Can we take the numerators of a finite set of fractions (as a finset)?
I only found docs#IsLocalizedModule.finsetIntegerMultiple.
Any help or clarification would be appreciated!
Yury G. Kudryashov (May 07 2025 at 16:36):
Do you have a #mwe?
Yury G. Kudryashov (May 07 2025 at 16:36):
E.g., are you talking about Rat or something more general?
Kevin Buzzard (May 07 2025 at 16:36):
So you want {1/2, 1/3} |-> {1}? Just use Finset.image on Rat.num?
Yiming Fu (May 07 2025 at 16:39):
Sorry for missing some details. I want to use it for a set of LocalizedModule or IsLocalizedModule.
Yury G. Kudryashov (May 07 2025 at 16:42):
If you have a function for the numerator, then you can use Finset.image.
Yiming Fu (May 07 2025 at 16:51):
Do you mean something like this?
import Mathlib
variable {R : Type*} [CommSemiring R] (S : Submonoid R)
variable {M M' : Type*} [AddCommMonoid M] [AddCommMonoid M']
variable [Module R M] [Module R M'] [DecidableEq M] (f : M →ₗ[R] M') [IsLocalizedModule S f]
noncomputable def getNumerator (x : M') : M :=
(Classical.choose (IsLocalizedModule.surj S f x)).1
noncomputable def finsetNumerator (s : Finset M') : Finset M := Finset.image (getNumerator S f) s
Yiming Fu (May 07 2025 at 16:58):
If mathlib doesn’t have a better definition, I’ll just use this one.
Yiming Fu (May 07 2025 at 17:00):
Thank you all for your help — now I’ve learned how to use Finset.image.
Eric Wieser (May 07 2025 at 17:01):
It's not clear to me that getNumerator picks a particularly canonical numerator
Eric Wieser (May 07 2025 at 17:02):
IN particular, you might find that {1/2, 2/5} has numerators {2} if 1/2 ends up being treated as 2/4.
Yiming Fu (May 07 2025 at 17:04):
Well, that’s a problem. Let me think about how to choose the canonical numerator...
Kevin Buzzard (May 07 2025 at 17:16):
Mathematically you're not going to have a canonical numerator, even in the integral domain case. Having a canonical numerator is the same as having a canonical denominator in the integral domain case when M=R, and what you have instead is the ideal of denominators, which has no reason to be principal, so you don't even have a canonical numerator up to units in this generality.
Eric Wieser (May 07 2025 at 17:39):
Kevin, am I right in thinking this somehow featured in some Lean slides of yours long ago? I was expecting you to have something to say here :)
Kevin Buzzard (May 07 2025 at 22:38):
I don't know about slides, but mathematically the issue is that if is an integral domain with field of fractions , and if then you can consider and this is easily checked to be an ideal of , but if is not a PID then you can say very little about it, let alone choose a canonical element of it.
Kevin Buzzard (May 07 2025 at 22:39):
Example: if and then contains and so it's the nonprincipal ideal whose square is 2 and which generates the (nontrivial) class group of .
Kevin Buzzard (May 07 2025 at 22:40):
In more elementary terms, and both these fractions are in "lowest terms" (in the sense that there are no common factors than you can cancel other than ) but their numerators don't even differ by a unit.
Kevin Buzzard (May 07 2025 at 22:43):
What's going on here is that is two distinct factorizations of into irreducibles (the ring is an integral domain but not a UFD).
Kevin Buzzard (May 07 2025 at 22:50):
Historically it was known since Euclid that the greatest common divisor of two integers was a linear combination of the integers (if the gcd of and is then there are integers $$\lambda$4 anad such that ), so to try and "fix" this factorization of 6 you need some kind of gcd of 2 and , and you can start looking for it by looking at the linear combinations where (because that worked for ) and you're not sure which one to choose, so you let be the set of all of them, and then you realise that if is the analogous set for and for then and and so now and this factorization is unique, so these sets are behaving better than numbers, so they're like "ideal numbers" because things are factorizing uniquely again. Historically a lot of the basics of ring theory like ideals were invented in the mid-1800s by number theorists through the study of concrete subsets of the complexes, before abstract algebra was discovered around 1900.
Last updated: Dec 20 2025 at 21:32 UTC