On Thu, Sep 17, 2015 at 8:00 AM, Nils Bruin <nbr...@sfu.ca> wrote:
> On Thursday, September 17, 2015 at 2:54:15 AM UTC-7, Simon King wrote:
>>
>> The real problem here is that *conversion* gives rise to an error
>> that mentions *coercion*.
>>
>>   sage: K.<x> = GF(25)
>>   sage: L.<y> = GF(25)
>>   sage: K(y)
>>   Traceback (most recent call last):
>>   ...
>>   TypeError: unable to coerce from a finite field other than the prime
>> subfield
>>
>> That's clearly a bug. Conversion should work, even if it isn't canonical
>> and thus doesn't qualify as coercion!
>
>
> I don't think it's "clearly a bug". Conversions are *allowed* to work when
> there is a non-canonical map (i.e., a section map back that's not a
> morphism, as for ZZ -> ZZ/p ) but I don't think conversions are *required*
> to work when such a map exists.

That's right.  Conversions are almost always dangerous and *not*
something you want to use.  It's much, much better to define an
explicit morphism and use that.  We have implemented conversions in
many cases, but if you use them, you're increasing the chances of a
very subtle bug by an order of magnitude.

Here's what you should do:

K.<x> = GF(25)
L.<y> = GF(25)
phi = K.hom([y])
phi(x + 3)

And this lets you do anything that makes sense, but protects you from
doing wrong stuff like this:

psi = K.hom([y^2])
[boom]

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2015-09-17-080944-conversions.sagews


> What would the condition be? That the minimal polynomials of x,y over GF(5)
> are identical? That the minimal poly of y has a root over K and then just
> choose a root (and let the conversion system try to keep things sane)?
>
> Do we expect for
> N.<a> = NumberField(x^5-x+1)
> M.<b> = NumberField(x^5 + 5*x^4 + 8*x^3 + 4*x^2 - 1)
>
> that
>
> N(b)
>
> should work? (there is actually less ambiguity there!)

Explicit is better than implicit.  Use hom.  If I were doing it all
over, I would very likely remove coercion entirely and make hom even
better than it already is.  Coercion is a bad idea and source of very
subtle bugs.

William

>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.



-- 
William (http://wstein.org)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to