ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 12 Jan 2017 20:52:41 +0100Coercion between quotients of $\mathbb{Z}$https://ask.sagemath.org/question/36264/coercion-between-quotients-of-mathbbz/Hello,
It is said [here](http://doc.sagemath.org/html/en/tutorial/tour_coercion.html#conversion-versus-coercion) that "in general there is no coercion between two different finite fields". When testing equality between elements of $\mathbb{Z}/(n)$ and $\mathbb{Z}/(m)$, why is there coercion to $\mathbb{Z}/(\gcd(m,n))$ only if $\gcd(m,n) \neq 1$ ?
zz3, zz5, zz6, zz10 = (ZZ.quotient(n) for n in [3,5,6,10])
zz6(0) == zz10(0) # True
zz3(0) == zz5(0) # False
I understand that testing equality in the null ring is not "useful", but why is it so inhomogeneous ? If some automated procedure depends on that feature, it would surely need to consider `zz3(0) == zz5(0)` to be true.Thu, 12 Jan 2017 14:17:00 +0100https://ask.sagemath.org/question/36264/coercion-between-quotients-of-mathbbz/Comment by nbruin for <p>Hello,</p>
<p>It is said <a href="http://doc.sagemath.org/html/en/tutorial/tour_coercion.html#conversion-versus-coercion">here</a> that "in general there is no coercion between two different finite fields". When testing equality between elements of $\mathbb{Z}/(n)$ and $\mathbb{Z}/(m)$, why is there coercion to $\mathbb{Z}/(\gcd(m,n))$ only if $\gcd(m,n) \neq 1$ ?</p>
<pre><code>zz3, zz5, zz6, zz10 = (ZZ.quotient(n) for n in [3,5,6,10])
zz6(0) == zz10(0) # True
zz3(0) == zz5(0) # False
</code></pre>
<p>I understand that testing equality in the null ring is not "useful", but why is it so inhomogeneous ? If some automated procedure depends on that feature, it would surely need to consider <code>zz3(0) == zz5(0)</code> to be true.</p>
https://ask.sagemath.org/question/36264/coercion-between-quotients-of-mathbbz/?comment=36272#post-id-36272I agree that this design decision looks rather ill-conceived, If coercion between $\mathbb{Z}/(n)$ and $\mathbb{Z}/(m)$ should be defined at all, I'd say it should only be if one of $n,m$ divides the other. If you start allowing constructions of pushouts, it follows naturally the null ring should also be allowed.
One reason to disallow it is that it helps catching errors. However, by that argument one should probably not allow coercion between different quotients at all.
Automatic coercion to quotients is the most important source of nontransitivity of equality in sage, so that's another reason to limit it.Thu, 12 Jan 2017 20:52:41 +0100https://ask.sagemath.org/question/36264/coercion-between-quotients-of-mathbbz/?comment=36272#post-id-36272