Zulip Chat Archive
Stream: maths
Topic: IsCoprime is @[simp]?
Kyle Miller (May 15 2023 at 18:50):
Is the docs4#IsCoprime definition meant to be marked with the @[simp]
attribute? It seems like you would generally want to keep it in IsCoprime x y
form rather than immediately converting it to ∃ a b, a * x + b * y = 1
.
(It's also @[simp]
in mathlib3)
Ruben Van de Velde (May 15 2023 at 18:51):
I believe that was also annoying in mathlib 3
Yury G. Kudryashov (May 17 2023 at 06:43):
BTW, should we have both natural definitions (∃ a b, a * x + b * y = 1
and ∀ x, x ∣ a → x ∣ b → is_unit x
a.k.a. disjoint (associates.mk a) (associates.mk b)
)? If yes, then what should be the names?
Yaël Dillies (May 17 2023 at 07:10):
docs#is_coprime, docs#nat.is_coprime?
Kyle Miller (May 17 2023 at 08:49):
Fyi, docs4#IsCoprime is no longer @[simp]
, which was a change necessary to get a norm_num
extension to actually trigger. This didn't affect any proofs.
Kyle Miller (May 17 2023 at 08:57):
I was thinking about how the definition is very wrong for Nat
(the only way to get IsCoprime x y
is for x
or y
to be 1
if you use Bezout's identity as a definition).
Something that came to mind that would work for Nat
is to extend the notion of a GCD domain to commutative semirings. That is, you say and are coprime in the noncommutative semiring if , with the minimal principal ideal such that this is true, implies . (Or specialized a bit more, if then . No need for "minimal.")
With , while it's not the case that , at least if and are coprime you get almost all of .
Kevin Buzzard (May 17 2023 at 12:33):
Just to remark that for a general UFD of dimension 2 or more like , the two definitions aren't the same (eg X and Y don't have a common factor but don't generate the unit ideal either).
Kyle Miller (May 17 2023 at 12:37):
I guess at least this definition of IsCoprime would say and are coprime since the only principal ideal containing is .
Yaël Dillies (May 17 2023 at 12:48):
But and should not be coprime.
Kevin Buzzard (May 17 2023 at 13:01):
They're coprime in the sense of having no factors in common, so in a lattice-theoretic sense they're coprime.
Yury G. Kudryashov (May 17 2023 at 14:54):
Kyle Miller said:
I was thinking about how the definition is very wrong for
Nat
(the only way to getIsCoprime x y
is forx
ory
to be1
if you use Bezout's identity as a definition).Something that came to mind that would work for
Nat
is to extend the notion of a GCD domain to commutative semirings. That is, you say and are coprime in the noncommutative semiring if , with the minimal principal ideal such that this is true, implies . (Or specialized a bit more, if then . No need for "minimal.")With , while it's not the case that , at least if and are coprime you get almost all of .
Is this definition equivalent to ∀ x, x ∣ a → x ∣ b → is_unit x
?
Yury G. Kudryashov (May 17 2023 at 14:54):
Let me repeat my question: are there two names for these two notions?
Kevin Buzzard (May 17 2023 at 14:56):
It's not even clear to me in a general ring that there even exists a minimal principal ideal containing a general ideal. But one can avoid this issue by defining coprimality to simply mean "the only principal ideal containing the ideal $(x,y)$ is (1)". This is literally the same as "if d divides both x and y, then d divides 1" (just unravel the definitions).
Michael Stoll (May 17 2023 at 18:07):
In many applications, you really want the property that you can write 1
as a linear combination of x
and y
.
I'd be against changing the definition.
Michael Stoll (May 17 2023 at 18:08):
BTW, there is the notion of coprime ideals, which means that sum of the two ideals is the full ring (which specializes to coprimality of elements on principal ideals).
Michael Stoll (May 17 2023 at 18:08):
... and this is what you need, e.g., for the Chinese Remainder Theorem.
Michael Stoll (May 17 2023 at 18:09):
(In German, you can distinguish between "relativ prim" = coprime and "teilerfremd" = no common non-unit divisors.)
Yaël Dillies (May 17 2023 at 19:16):
I guess we could translate that by "coprime" and "factor-free"?
Yury G. Kudryashov (May 17 2023 at 22:26):
Michael Stoll said:
In many applications, you really want the property that you can write
1
as a linear combination ofx
andy
.
I'd be against changing the definition.
That's why I say that we need both definitions.
Kyle Miller (May 17 2023 at 23:13):
There are at least three possible definitions for " and are coprime" so far:
- The intersection of the sets of divisors for and consist of units. ("teilerfremd")
- That . (coprime in the ideal sense)
- That the GCD of the ideal is , where a principal ideal is the GCD of an ideal if it is the minimal principal ideal containing . Or, more simply, if then . (this is coprime in an ideal gcd sense)
The first two are not equivalent in general. Nat
shows that 2 and 3 are not equivalent when you allow commutative semirings (which is what the mathlib IsCoprime
is currently allowing), though the example also shows these are different (though 1 and 3 are equivalent for it I think). I'd think that 1 and 3 are not equivalent in general, but I do know that 1 => 3.
It would be nice if mathlib had at least one of the variants of IsCoprime
that for Nat
is equivalent to Nat.gcd x y = 1
(for example both 1 and 3). I'm not sure the current IsCoprime
makes any sense for general commutative semirings, and it seems like it should be restricted to commutative rings.
Kyle Miller (May 17 2023 at 23:14):
Are there other definitions of coprime?
Heather Macbeth (May 17 2023 at 23:14):
What about ? That works for too.
Kyle Miller (May 17 2023 at 23:16):
Yury G. Kudryashov said:
That's why I say that we need both definitions.
I think Michael might have been saying why 3 shouldn't replace 2. We should definitely have at least 1 and 2 in mathlib.
Kyle Miller (May 17 2023 at 23:19):
@Heather Macbeth Maybe to make it obviously symmetric it could be ?
Kevin Buzzard (May 17 2023 at 23:22):
There is no such thing as "the minimal principal ideal containing I" in general so 3 doesn't make sense as it stands. It should say "the only principal ideal continaing I is R" and then it's trivially the same as 1
Kyle Miller (May 17 2023 at 23:24):
I was careful to state it as "if R is the minimal principal ideal containing I", which doesn't assert that a minimal principal ideal exists
Kevin Buzzard (May 17 2023 at 23:25):
The proof is: (x,y) \subset (d) iff x \in (d) and y \in (d) iff d divides x and d divides y, and (d)=1 iff d divides 1 iff d is a unit.
Kevin Buzzard (May 17 2023 at 23:25):
Kyle Miller said:
I was careful to state it as "if R is the minimal principal ideal containing I", which doesn't assert that a minimal principal ideal exists
Oh OK, I can see that it can be interpreted differently to how I read it.
Kyle Miller (May 17 2023 at 23:27):
Good to know that 1 and 3 are equivalent, I see it's trivial now :smile:
Kevin Buzzard (May 17 2023 at 23:28):
Is Heather-coprime definitely symmetric in general? (on commutative semirings I mean)
Kyle Miller (May 17 2023 at 23:30):
I don't know, which is why I wanted to transform it into something that was symmetric
Kyle Miller (May 17 2023 at 23:31):
It's probably true for commutative semirings that embed in their enveloping commutative ring? I don't know my universal algebra well enough to know what characterizes this, but as we know this holds for Nat
and Int
.
Kevin Buzzard (May 17 2023 at 23:31):
I guess one considers the universal example, the quotient of by the smallest relation preserving + and * and satisfying AX ~ BY+1, and asks if Y is coprime to X. I have no idea how semirings work though, I have no idea what this quotient looks like
Kevin Buzzard (May 17 2023 at 23:33):
If one wants to remain sane one could just look at the semring generated by X,Y,A,B in Z[X,Y,A,B]/(AX-(BY+1)) (which is perhaps a bit smaller)
Kevin Buzzard (May 17 2023 at 23:35):
Basically if it's true in that one (comm) semiring then it's true in all semirings because the proof will turn into a proof valued in all semirings, and conversely if it's false in any semiring then it will be false in the universal semiring. The advantage of doing the computation in the universal semiring is that it might have more structure than an arbitrary counterexample, e.g. you can try proving things by induction on degree.
Kyle Miller (May 17 2023 at 23:38):
New list for coprime definitions, to summarize everything so far:
- The set of shared divisors for and are units. Equivalently, that the GCD of the ideal exists and is . (coprime in the divisors sense)
- That . (coprime in the ideal sense)
- That . (coprime in an ideal sense when you know you can extend your commutative semiring to a commutative ring)
Maybe 3 can still be tweaked if someone knows more about enveloping commutative rings of commutative semirings...
Kevin Buzzard (May 17 2023 at 23:48):
Aah, you can solve a1=b0+1 in nat but you can't solve a0=b1+1 so in fact they're not the same for nat after all
Yury G. Kudryashov (May 18 2023 at 00:06):
Do we ever need (2) as opposed to (3)?
Damiano Testa (May 18 2023 at 06:53):
Kevin Buzzard said:
There is no such thing as "the minimal principal ideal containing I" in general /- so 3 doesn't make sense as it stands. It should say "the only principal ideal continaing I is R" and then it's trivially the same as 1 -/
Maybe I am misunderstanding something, but this seems almost exactly the difference between Weil and Cartier divisors. So, even if this literal definition does not make it to mathlib, I hope that some form of it will!
Yury G. Kudryashov (May 18 2023 at 08:06):
Could you please give more information for those of us who are not algebraists?
Damiano Testa (May 18 2023 at 09:34):
Sure, but I just landed: I'll do it in the next couple of hours!
Damiano Testa (May 18 2023 at 11:01):
There is an algebraic theory of dimension
that works for most commutative rings with identity of interest. For instance, any finitely generated ring over a field.
This exploits the principle that generators for an ideal are "equations". You expect that each equation decreases the dimension by one, but of course there are issues of dependency that make this subtle. In particular, you would like that every ideal of codimension 1, is generated by a single relation. Even this cannot be the case and here is an example.
Damiano Testa (May 18 2023 at 11:05):
The ring is . Geometrically, you can think of this as the vanishing set of in : for each value of you get a parabola, except when (or also there, depending on your convention of what is a parabola). The dimension of is , probably not surprising.
Let be the ideal of all polynomials that vanish on the three lines
The three ideals are principal (i.e. generated by a single element) and they all contain the ideal :
- vanishes on the lines with direction and ;
- vanishes on the lines with direction and ;
- vanishes on the lines with direction and .
However, with some work you can show that any non-zero element of that vanishes on the three lines, must also vanish on another curve (including the possibility that it vanishes with multiplicity at least along one of those lines).
Thus, a principal ideal containing must contain at most two of the lines. It follows that each one of the three ideals
is minimal among the principal ideals vanishing on .
Damiano Testa (May 18 2023 at 12:04):
To connect with Weil and Cartier divisors: the three ideals , , vanish on the unique non-zero Cartier divisors contained in the Weil divisor that is vanishing set of .
Damiano Testa (May 18 2023 at 12:23):
[EDIT: Clarified the above.]Ok, what I deleted above is relevant, just the example is more complicated. I'll see if I can find a simpler example and will clarify the situation!
Damiano Testa (May 18 2023 at 14:38):
@Yury G. Kudryashov I updated the posts above with a more pertinent example. I hope that this is clearer, but let me know if you want more details!
The conclusion is that, as Kevin said, there are ideals that are not contained in a unique principal ideal. However, the set of the minimal principal ideals containing a given ideal is still a valuable notion: its elements roughly correspond to the largest Cartier divisors contained in a scheme.
Michael Stoll (May 18 2023 at 15:59):
Yury G. Kudryashov said:
Do we ever need (2) as opposed to (3)?
I would be strongly against replacing the standard definition of "coprime" (elements) by a more complicated one, just to be able to use semirings. I think the pain this causes for the vast majority of applications (which will be for rings) vastly outweighs any benefits here.
Michael Stoll (May 18 2023 at 16:00):
Yury G. Kudryashov said:
Michael Stoll said:
In many applications, you really want the property that you can write
1
as a linear combination ofx
andy
.
I'd be against changing the definition.That's why I say that we need both definitions.
I'm not against adding another definition, but it should not be called IsCoprime
.
Michael Stoll (May 18 2023 at 17:17):
Maybe it could be Semiring.IsCoprime
? (With a lemma that says that for a ring both are equivalent...)
Michael Stoll (May 18 2023 at 17:17):
BTW, is there any use case for a semiring other than Nat
(where Nat.IsCoprime
already exists)?
Johan Commelin (May 18 2023 at 17:58):
@Michael Stoll Ideal R
is a semiring that shows up now and then...
Michael Stoll (May 18 2023 at 17:59):
What does coprimality (in the sense discussed above for semirings, i.e. ax + by = cx + dy + 1
) correspond to there?
Michael Stoll (May 18 2023 at 18:00):
Is it different from coprimality of ideals?
Michael Stoll (May 18 2023 at 18:02):
(In mathlib(3), coprimality of ideals seems to be written as I ⊔ J = ⊤
, so maybe it does not exist as a definition of its own. E.g., docs#ideal.coprime_of_no_prime_ge .)
Johan Commelin (May 18 2023 at 18:03):
Michael Stoll said:
What does coprimality (in the sense discussed above for semirings, i.e.
ax + by = cx + dy + 1
) correspond to there?
Good question... and I haven't yet thought about it...
Michael Stoll (May 18 2023 at 18:05):
Michael Stoll said:
Is it different from coprimality of ideals?
I think it's the same: The right hand side simplifies to 1
(i.e., R
as an ideal of itself), and ax
is contained in x
and by
is contained in y
, so the statement is equivalent to x + y = 1
.
Yury G. Kudryashov (May 24 2023 at 03:56):
So, is there a good name for the "other" coprime (no common divisors)?
Kevin Buzzard (May 24 2023 at 05:12):
Is there a lattice name for them? "inf of these two things is bot"
Mario Carneiro (May 24 2023 at 05:12):
that's disjoint
Yury G. Kudryashov (May 24 2023 at 15:18):
But it is not disjoint
in nat
Yury G. Kudryashov (May 24 2023 at 15:18):
I mean, not w.r.t. the usual inf
.
Yaël Dillies (May 24 2023 at 15:26):
I would go for factor_free
Yury G. Kudryashov (May 24 2023 at 16:24):
disjoint_factors
?
Michael Stoll (May 24 2023 at 19:58):
without_common_factors
?
Reid Barton (May 24 2023 at 21:11):
or no_common_factors
Yury G. Kudryashov (May 25 2023 at 02:39):
/poll Which name should we use?
disjoint_factors
without_comon_factors
no_common_factors
Yury G. Kudryashov (May 25 2023 at 02:39):
Poll closes in 3 days from now, then I make a PR (possibly in Mathlib 4).
Yury G. Kudryashov (May 28 2023 at 02:09):
So, let it be no_common_factors
.
Yaël Dillies (May 28 2023 at 06:02):
Oh, looks like the mobile app didn't cast my vote :sad:
Timo Carlin-Burns (Nov 05 2023 at 18:07):
Michael Stoll said:
I would be strongly against replacing the standard definition of "coprime" (elements) by a more complicated one, just to be able to use semirings. I think the pain this causes for the vast majority of applications (which will be for rings) vastly outweighs any benefits here.
I'm surprised by this sentiment. Why does changing the definition cause pain in cases where it's provably equivalent to the old one? All of the same lemmas can apply, so it seems like it would only cause pain if you were using tactics like use a, b
or obtain ⟨a, b, h⟩ := ...
that work on existentials directly on proofs of IsCoprime x y
. I thought that kind of thing was considered defeq abuse and frowned upon.
Michael Stoll (Nov 05 2023 at 18:48):
I admit to defeq abuse in this context. It would probably be OK to replace that by an API lemma (that, if I have not overlooked something, currently does not exist).
Anyway, IIRC, nobody had a convincing use case for a semiring other than the naturals, so nothing was done.
(I think not even the promised PR introducing no_common_factors
has materialized.)
Last updated: Dec 20 2023 at 11:08 UTC