Zulip Chat Archive
Stream: maths
Topic: Integer gcd issues
Neil Strickland (May 06 2019 at 22:00):
Suppose we have x,y : ℤ. If I understand correctly:
int.gcd x yhas typeℕ; in particularint.gcd 0 (-2) = 2.- There is an instance of
gcd_domainforℤwhich definesgcd_domain.gcd x y = int.of_nat (int.gcd x y). In particular, we havegcd_domain.gcd 0 (-2) = 2. This is more or less forced by the axioms forgcd_domain. - There is an instance of
euclidean_domainforℤ, and a functioneuclidean_domain.gcddefined using the euclidean algorithm. This always satisfieseuclidean_domain.gcd 0 y = y(independent of any choices about rounding up or down in the division algorithm). In particular, we haveeuclidean_domain.gcd 0 (-2) = -2 ≠ gcd_domain.gcd 0 (-2). - mathlib currently has no results about the compatibility of these
gcdfunctions. - Because of this, there is no immediate way to produce
aandbsuch thatint.gcd x y = a * x + b * y; we need to do some messing about with cases on the signs ofxandy.
I assume that we have essentially the same issues with gcd of polynomials over a field.
This does not seem very satisfactory. Some possible ways to improve the situation:
- Just add a bunch of compatibility lemmas specific to
ℤ - Add an instance to show that a normalization domain that is also a euclidean domain can be regarded as a gcd domain, with
gcd_domain.gcd x ybeing the normalization ofeuclidean_domain.gcd x y. Delete the directgcd_domaininstance forℤ. - Modify the definition of
euclidean_domainso as to include a normalization function that is allowed to be the identity. Defineeuclidean_domain.gcdto incorporate this function, so that it is possible foreuclidean_domain.gcdto be part of agcd_domainstructure.
The second of these seems most promising to me. Am I missing anything?
Kevin Buzzard (May 06 2019 at 22:27):
@Chris Hughes @Mario Carneiro does this accurately represent the current state of things?
Last updated: May 02 2025 at 03:31 UTC