Opened 8 years ago

Closed 8 years ago

#13770 closed defect (fixed)

bug in multivariate factorization over prime fields

Reported by: zimmerma Owned by: malb
Priority: critical Milestone: sage-5.12
Component: commutative algebra Keywords: sd53, singular, polynomial, factorization
Cc: malb, SimonKing, AlexanderDreyer Merged in: sage-5.12.rc0
Authors: Paul Zimmermann, Jeroen Demeyer Reviewers: Jean-Pierre Flori
Report Upstream: Fixed upstream, but not in a stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

after #11829, #11838, #12918, #12928, here is another bug in multivariate factorization over prime fields:

----------------------------------------------------------------------
| Sage Version 5.4.1, Release Date: 2012-11-15                       |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: U.<y,t> = GF(2)[]  
sage: f
y*t^8 + y^5*t^2 + y*t^6 + t^7 + y^6 + y^5*t + y^2*t^4 + y^2*t^2 + y^2*t + t^3 + y^2 + t^2
sage: f.factor()
y*t^8 + y^5*t^2 + y*t^6 + t^7 + y^6 + y^5*t + y^2*t^4 + y^2*t^2 + y^2*t + t^3 + y^2 + t^2
sage: f % (t^2+t+y+1)
0

When will Sage be usable for this kind of computation?

spkg: http://boxen.math.washington.edu/home/jdemeyer/spkg/singular-3-1-5.p9.spkg (spkg diff)

apply trac_13770.patch

See also upstream https://github.com/Singular/Sources/pull/215

Attachments (2)

trac_13770.patch (1.1 KB) - added by zimmerma 8 years ago.
singular-3-1-5.p9.diff (25.6 KB) - added by jdemeyer 8 years ago.

Download all attachments as: .zip

Change History (31)

comment:1 follow-up: Changed 8 years ago by zimmerma

  • Cc SimonKing added

maybe one should consider replacing Singular by another more reliable component?

Paul

comment:2 Changed 8 years ago by malb

Paul,

to be fair #13672 isn't a bug in Singular but an issue with Pari and how we use it. Also, I am not sure there is a component we could use besides Singular for factoring. In any case, I've forwarded your bug report.

comment:3 Changed 8 years ago by mderickx

  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

comment:4 Changed 8 years ago by zimmerma

  • Description modified (diff)

comment:5 in reply to: ↑ 1 Changed 8 years ago by AlexanderDreyer

Replying to zimmerma:

maybe one should consider replacing Singular by another more reliable component?

If there were any (for multivariate polynomials etc.), we would immediately use it in Singular. BTW: when reported upstream, the response time is quite good, I think.

comment:6 Changed 8 years ago by AlexanderDreyer

  • Cc AlexanderDreyer added

comment:7 Changed 8 years ago by zimmerma

  • Report Upstream changed from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.

from Martin Lee:

I have just committed a fix for this under 15453.

comment:8 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:9 Changed 8 years ago by zimmerma

Martin Lee tells me the bug is fixed by this commit: https://github.com/Singular/Sources/pull/215

Also it is fixed in Singular 3-1-6. Any plan to upgrade the Singular version?

Martin also tells me Singular 3-1-7 is planned within the next month.

Paul

Changed 8 years ago by zimmerma

comment:10 follow-up: Changed 8 years ago by zimmerma

  • Authors set to Paul Zimmermann
  • Status changed from new to needs_review

on http://www.loria.fr/~zimmerma/singular-3-1-5.p8.spkg I've put an updated Singular spkg which includes the first patch of https://github.com/Singular/Sources/pull/215. This seems to be enough to solve this bug.

The attached patch adds a non-regression test.

Paul

comment:11 in reply to: ↑ 10 Changed 8 years ago by jdemeyer

Replying to zimmerma:

on http://www.loria.fr/~zimmerma/singular-3-1-5.p8.spkg I've put an updated Singular spkg which includes the first patch of https://github.com/Singular/Sources/pull/215.

Wouldn't it be safer to include all four commits? Did you check whether this solves #14658?

comment:12 Changed 8 years ago by jdemeyer

  • Description modified (diff)

comment:13 Changed 8 years ago by jdemeyer

  • Description modified (diff)

comment:14 Changed 8 years ago by zimmerma

Jeroen,

Wouldn't it be safer to include all four commits?

indeed (maybe only the first three, since the last one only adds tests). But I didn't know how to extract the diff, thus I edited the Singular source file manually, it took then several hours on my laptop to recompile the spkg and rebuild Sage, thus I was quite happy it worked (currently running sage -t --long).

Did you check whether this solves #14658?

unfortunately not. The first example of #14658 does no longer produce an error (same with vanilla 5.11 btw) but the factorization is incomplete:

sage: R.<x1,x2,x3> = QQ['x1,x2,x3']                              
sage: f = (x1+x2+x3)*(2*x1-x2+x3+2)*(4*x1+x2+x3+2)*(8*x1-x2+x3+4)
sage: f.factor()                                                 
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)

The other example still breaks with Floating point exception.

Paul

comment:15 Changed 8 years ago by zimmerma

my Singular spkg was corrupted. I made a new one (same url).

Paul

comment:16 Changed 8 years ago by jdemeyer

  • Authors changed from Paul Zimmermann to Paul ZImmermann, Jeroen Demeyer
  • Status changed from needs_review to needs_work

When updating a spkg, you should add a Changelog entry in SPKG.txt. Also, changes should be committed to the Mercurial repo (hg add patches/singular_13770.patch and hg commit).

I will make these changes and try to use the 3 commits from the upstream pull request.

comment:17 Changed 8 years ago by jdemeyer

To download patches from github, see http://stackoverflow.com/questions/6188591/download-github-pull-request-as-unified-diff (I agree it is hard to find out)

comment:18 Changed 8 years ago by jdemeyer

Also rebasing to #14737.

comment:19 Changed 8 years ago by zimmerma

thank you Jeroen for the pointers. I thus let you continue on this ticket.

Paul

comment:20 Changed 8 years ago by jdemeyer

  • Authors changed from Paul ZImmermann, Jeroen Demeyer to Paul Zimmermann, Jeroen Demeyer

comment:21 Changed 8 years ago by zimmerma

  • Authors changed from Paul Zimmermann, Jeroen Demeyer to Paul ZImmermann, Jeroen Demeyer

just answering to my own question:

Also it is fixed in Singular 3-1-6. Any plan to upgrade the Singular version?

this is planned in #14333

Paul

comment:22 Changed 8 years ago by jdemeyer

  • Authors changed from Paul ZImmermann, Jeroen Demeyer to Paul Zimmermann, Jeroen Demeyer

comment:23 Changed 8 years ago by jdemeyer

  • Description modified (diff)

Changed 8 years ago by jdemeyer

comment:24 Changed 8 years ago by jdemeyer

  • Description modified (diff)

comment:25 Changed 8 years ago by jdemeyer

  • Status changed from needs_work to needs_review

New spkg is up, but I still need to test it properly myself.

comment:26 Changed 8 years ago by zimmerma

#14658 is still not fixed:

sage: R.<x1,x2,x3> = QQ['x1,x2,x3']
sage: f = (x1+x2+x3)*(2*x1-x2+x3+2)*(4*x1+x2+x3+2)*(8*x1-x2+x3+4)
sage: f.factor()
(x1 + x2 + x3) * (2*x1 - x2 + x3 + 2) * (32*x1^2 + 4*x1*x2 - x2^2 + 12*x1*x3 + x3^2 + 32*x1 + 2*x2 + 6*x3 + 8)

Note that we do not even get deterministic answers:

sage: f.factor()
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)
sage: f.factor()
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)
sage: f.factor()
(x1 + x2 + x3) * (2*x1 - x2 + x3 + 2) * (32*x1^2 + 4*x1*x2 - x2^2 + 12*x1*x3 + x3^2 + 32*x1 + 2*x2 + 6*x3 + 8)
sage: f.factor()
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)
sage: f.factor()
(x1 + x2 + x3) * (8*x1 - x2 + x3 + 4) * (8*x1^2 - 2*x1*x2 - x2^2 + 6*x1*x3 + x3^2 + 12*x1 + 4*x3 + 4)
sage: f.factor()
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)
sage: f.factor()
(x1 + x2 + x3) * (8*x1 - x2 + x3 + 4) * (8*x1^2 - 2*x1*x2 - x2^2 + 6*x1*x3 + x3^2 + 12*x1 + 4*x3 + 4)
sage: f.factor()
(x1 + x2 + x3) * (64*x1^3 - 24*x1^2*x2 - 6*x1*x2^2 + x2^3 + 56*x1^2*x3 - 8*x1*x2*x3 - x2^2*x3 + 14*x1*x3^2 - x2*x3^2 + x3^3 + 128*x1^2 - 20*x1*x2 - 4*x2^2 + 68*x1*x3 - 4*x2*x3 + 8*x3^2 + 80*x1 - 4*x2 + 20*x3 + 16)
sage: f.factor()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-25-429743410e57> in <module>()
----> 1 f.factor()

/localdisk/tmp/sage-5.11/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_libsingular.so in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.factor (sage/rings/polynomial/multi_polynomial_libsingular.cpp:26013)()

RuntimeError: Segmentation fault

comment:27 Changed 8 years ago by jdemeyer

Passes all tests on the buildbot, so needs_review for real.

comment:28 Changed 8 years ago by jpflori

  • Keywords sd53 singular polynomial factorization added
  • Reviewers set to Jean-Pierre Flori
  • Status changed from needs_review to positive_review

Looks good. Lets get this in even though updating to Singular 3-1-6 or even 3-1-7 should supersede it, but needs more serious work. (Moreover singular website is down right now.)

comment:29 Changed 8 years ago by jdemeyer

  • Merged in set to sage-5.12.rc0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.