Nemocas / Nemo.jl

Julia bindings for the FLINT number theory C library
http://nemocas.github.io/Nemo.jl/
Other
189 stars 58 forks source link

In non-euclidean `ZZ[:x]`, calls to `gcdx` result in infinite loop #1474

Open mgkurtz opened 1 year ago

mgkurtz commented 1 year ago

Accidentally somewhere in my code, I called gcdx for polynomials in ZZ[:x] instead of QQ[:x]. This led to my tests not terminating 😞 Here some example code:

ZZx, x = ZZ[:x]
gcdx(x, x+2) # does not terminate

Is this non-terminating behavior intended?

In AbstractAlgebra instead, the call to divrem(x, 2) in gcdx fails, while in Nemo it gives (0, x).

Confusingly, both AbstractAlgebra and Nemo compute gcd(x, x+2) as 1.

fieker commented 1 year ago

mathematically, the gcd is well defined in ZZx as it is a UFD, but the gcdx is not possible in ZZx for this example, we have <x, x+2> cap ZZ = <2> the gcd computation in Nemo is done in C (flint). Due to Gauss, this is "correct" This cannot be detected easily as we don't seem to have a euclidean function as part of the ring interface