#11239: Incorrect coercion of polynomials over finite fields
-------------------------------------+-------------------------------------
       Reporter:  johanbosman        |        Owner:  robertwb
           Type:  defect             |       Status:  positive_review
       Priority:  major              |    Milestone:  sage-6.1
      Component:  coercion           |   Resolution:
       Keywords:  finite fields,     |    Merged in:
  polynomials, coercion, sd53        |    Reviewers:  Jean-Pierre Flori
        Authors:  Peter Bruin        |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  236effb6198c6192dce0cedc0e53423c68743e3e
  u/jpflori/ticket/11239             |     Stopgaps:
   Dependencies:  #8335              |
-------------------------------------+-------------------------------------
Changes (by jpflori):

 * status:  needs_review => positive_review
 * reviewer:   => Jean-Pierre Flori
 * branch:   => u/jpflori/ticket/11239
 * commit:   => 236effb6198c6192dce0cedc0e53423c68743e3e


Old description:

> Trying to coerce a polynomial over a finite field into a polynomial ring
> over a bigger field gives a bogus result:
>
> {{{
> sage: Fq.<a> = GF(5^2)
> sage: Fqq.<b> = GF(5^4)
> sage: f = Fq['x'].random_element(); f
> 3*x^2 + (a + 4)*x + 2*a + 4
> sage: Fqq['y'](f)
> 3*y^2 + (b + 4)*y + 2*b + 4
> }}}
> In this example, Sage simply replaces every ‘a’ with ‘b’, but a is not b.
> If we coerce directly from Fq to Fqq, we get a `NotImplementedError`,
> which is unfortunate but in any case not incorrect. ;).
>
> {{{
> sage: Fqq(a)
> …
> /usr/local/share/sage/sage/local/lib/python2.6/site-
> packages/sage/rings/finite_rings/finite_field_givaro.pyc in
> _coerce_map_from_(self, R)
>     348                 elif self.degree() % R.degree() == 0:
>     349                     # This is where we *would* do coercion from
> one nontrivial finite field to another...
> --> 350                     raise NotImplementedError
>     351
>     352     def gen(self, n=0):
>
> NotImplementedError:
> }}}
>
> Apply: [attachment:trac_11239-polynomial_coercion_preliminary.patch],
> [attachment:trac_11239-polynomial_zz_pex.patch]

New description:

 Trying to coerce a polynomial over a finite field into a polynomial ring
 over a bigger field gives a bogus result:

 {{{
 sage: Fq.<a> = GF(5^2)
 sage: Fqq.<b> = GF(5^4)
 sage: f = Fq['x'].random_element(); f
 3*x^2 + (a + 4)*x + 2*a + 4
 sage: Fqq['y'](f)
 3*y^2 + (b + 4)*y + 2*b + 4
 }}}
 In this example, Sage simply replaces every ‘a’ with ‘b’, but a is not b.
 If we coerce directly from Fq to Fqq, we get a `NotImplementedError`,
 which is unfortunate but in any case not incorrect. ;).

 {{{
 sage: Fqq(a)
 …
 /usr/local/share/sage/sage/local/lib/python2.6/site-
 packages/sage/rings/finite_rings/finite_field_givaro.pyc in
 _coerce_map_from_(self, R)
     348                 elif self.degree() % R.degree() == 0:
     349                     # This is where we *would* do coercion from
 one nontrivial finite field to another...
 --> 350                     raise NotImplementedError
     351
     352     def gen(self, n=0):

 NotImplementedError:
 }}}

 Use git branch.

--

Comment:

 Anyway, the coercion framework is already called in the previous test so
 efficiency is already potentially screwed up.

 I've just made a git branch from the patch.
 Otherwise looks good to me, positive review.
 ----
 New commits:
 ||[[http://git.sagemath.org/sage.git/commit/?id=236effb|236effb]]||{{{Trac
 11239: fix coercion of polynomials over finite fields}}}||
 ||[[http://git.sagemath.org/sage.git/commit/?id=e46d9bf|e46d9bf]]||{{{Trac
 11239: fix coercion of polynomials over finite fields, first step}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/11239#comment:18>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to