#13609: symbolic arithmetic errors
----------------------------------+-----------------------------------------
Reporter: llpamies | Owner: burcin
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.11
Component: symbolics | Resolution:
Keywords: pynac segfault | Work issues:
Report Upstream: N/A | Reviewers: Jean-Pierre Flori
Authors: Burcin Erocal | Merged in:
Dependencies: #13729, #13736 | Stopgaps:
----------------------------------+-----------------------------------------
Description changed by kcrisman:
Old description:
> Consider the following code:
>
> {{{
> ff.<z> = GF(2**8, 'z')
> poly.<c1,c2,c3> = PolynomialRing(ff, 3, 'c')
> r1,r2 = var('r1,r2')
> expression = -(c1*r2 - c2*r1)/c3
> print expression.substitute(r1=z, r2=z)
> }}}
>
> This produces a TypeError: unsupported operand parent(s) for '*': 'Finite
> Field in z of size 2pow8' and 'Rational Field'. I know that 'expression'
> is not an element of the ring 'poly', but using a PolynomialRing is the
> only way I found to achieve symbolic arithmetic on finite fields.
>
> However, the interesting story is that if I replace the expression by
>
> {{{
> expression = -(r2 - c2*r1)/c3
> }}}
>
> it work perfectly well, but if instead the expression is
>
> {{{
> expression = -(c1 + r2 - c2*r1)/c3
> }}}
>
> then I get a segmentation fault.
>
> To make things a little bit more interesting I can rename r1 and r2 to a
> and b:
>
> {{{
> ff.<z> = GF(2**8, 'z')
> poly.<c1,c2,c3> = PolynomialRing(ff, 3, 'c')
> a,b = var('a,b')
> expression = -(c1*b - c2*a)/c3
> print expression.substitute(a=z, b=z)
> }}}
>
> Then it works fine, but produces a segmentation fault for,
>
> {{{
> expression = -(c1 + b - c2*a)/c3
> }}}
>
> so you can think that it might be a problem with the use of the names r1
> and r2. But this is not the case, if I rename the PolynomialRing
> variables instead, from c's to x's:
>
> {{{
> ff.<z> = GF(2**8, 'z')
> poly.<x1,x2,x3> = PolynomialRing(ff, 3, 'x')
> r1,r2 = var('r1,r2')
> expression = -(x1*r2 - x2*r1)/x3
> print expression.substitute(r1=z, r2=z)
> }}}
>
> Then it works again for the first two expressions but produces a
> segmentation fault for the third too.
>
> Any idea of what is going wrong here?
>
> Apply [attachment:trac_13609-gf2_content.take2.patch]
New description:
Consider the following code:
{{{
ff.<z> = GF(2**8, 'z')
poly.<c1,c2,c3> = PolynomialRing(ff, 3, 'c')
r1,r2 = var('r1,r2')
expression = -(c1*r2 - c2*r1)/c3
print expression.substitute(r1=z, r2=z)
}}}
This produces a TypeError: unsupported operand parent(s) for '*': 'Finite
Field in z of size 2pow8' and 'Rational Field'. I know that 'expression'
is not an element of the ring 'poly', but using a PolynomialRing is the
only way I found to achieve symbolic arithmetic on finite fields.
However, the interesting story is that if I replace the expression by
{{{
expression = -(r2 - c2*r1)/c3
}}}
it work perfectly well, but if instead the expression is
{{{
expression = -(c1 + r2 - c2*r1)/c3
}}}
then I get a segmentation fault.
To make things a little bit more interesting I can rename r1 and r2 to a
and b:
{{{
ff.<z> = GF(2**8, 'z')
poly.<c1,c2,c3> = PolynomialRing(ff, 3, 'c')
a,b = var('a,b')
expression = -(c1*b - c2*a)/c3
print expression.substitute(a=z, b=z)
}}}
Then it works fine, but produces a segmentation fault for,
{{{
expression = -(c1 + b - c2*a)/c3
}}}
so you can think that it might be a problem with the use of the names r1
and r2. But this is not the case, if I rename the PolynomialRing variables
instead, from c's to x's:
{{{
ff.<z> = GF(2**8, 'z')
poly.<x1,x2,x3> = PolynomialRing(ff, 3, 'x')
r1,r2 = var('r1,r2')
expression = -(x1*r2 - x2*r1)/x3
print expression.substitute(r1=z, r2=z)
}}}
Then it works again for the first two expressions but produces a
segmentation fault for the third too.
Any idea of what is going wrong here?
Apply [attachment:trac_13609-rebase.patch]
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13609#comment:8>
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.