Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build/pkgs/singular: Upgrade to 4.3.2p7, reject system Singular without FLINT #35934

Merged
merged 6 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build/pkgs/singular/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=singular-VERSION.tar.gz
sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
md5=fc0a4f5720dadba45a52ee94324ce00c
cksum=1573851737
upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
sha1=df1997f412580f2073295aba569bb955ad227317
md5=50349213e206a18cdaa1bc410dde7ea4
cksum=376854707
upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/singular/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.1p3
4.3.2p7
29 changes: 21 additions & 8 deletions build/pkgs/singular/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
dnl Use pkg-config to ensure that Singular is new enough.
PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
AC_MSG_CHECKING([that Singular's help is working])
AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error occurred"` = x], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
sage_spkg_install_singular=yes
]
)], [
AC_MSG_CHECKING([whether Singular is built with FLINT])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <singular/singularconfig.h>
#if !defined(HAVE_FLINT)
# error "Need Singular compiled with FLINT"
Comment on lines +12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance that this program compiles?

It seems to be missing #endif and a main(){} although I'm not completely sure on the semantics of AC_LANG_PROGRAM. In any case, this test fails in void linux where singular is built with flint (and /usr/include/singular/singularconfig.h indeed does contain #define HAVE_FLINT 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #36212, I think

], [])
], [
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([that Singular's help is working])
AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error occurred"` = x], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
sage_spkg_install_singular=yes
])
], [
AC_MSG_RESULT([no])
sage_spkg_install_singular=yes
])
], [
dnl pkg-config version check failed
sage_spkg_install_singular=yes
])
Expand Down
23 changes: 3 additions & 20 deletions src/sage/interfaces/singular.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,24 +604,15 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
sage: i = singular.ideal(['x^2','y^2','z^2'])
sage: s = i.std()
sage: singular.eval('hilb(%s)'%(s.name()))
'// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
'...// dimension (affine) = 0\n//
degree (affine) = 8'

::

sage: from sage.misc.verbose import set_verbose
sage: set_verbose(1)
sage: o = singular.eval('hilb(%s)'%(s.name()))
// 1 t^0
// -3 t^2
// 3 t^4
// -1 t^6
// 1 t^0
// 3 t^1
// 3 t^2
// 1 t^3
// dimension (affine) = 0
...// dimension (affine) = 0
// degree (affine) = 8

This is mainly useful if this method is called implicitly. Because
Expand All @@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
::

sage: o = s.hilb()
// 1 t^0
// -3 t^2
// 3 t^4
// -1 t^6
// 1 t^0
// 3 t^1
// 3 t^2
// 1 t^3
// dimension (affine) = 0
...// dimension (affine) = 0
// degree (affine) = 8
// ** right side is not a datum, assignment ignored
...
Expand Down
36 changes: 13 additions & 23 deletions src/sage/libs/singular/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
sage: I = Ideal(I.groebner_basis())
sage: hilb = sage.libs.singular.function_factory.ff.hilb
sage: hilb(I) # Singular will print // ** _ is no standard basis
// ** _ is no standard basis
// 1 t^0
// -1 t^5
<BLANKLINE>
// 1 t^0
// 1 t^1
// 1 t^2
// 1 t^3
// 1 t^4
// dimension (proj.) = 1
// degree (proj.) = 5
sage: from sage.misc.sage_ostools import redirection
sage: out = tmp_filename()
sage: with redirection(sys.stdout, open(out, 'w')):
....: hilb(I) # Singular will print // ** _ is no standard basis
sage: with open(out) as f:
....: 'is no standard basis' in f.read()
True

So we tell Singular that ``I`` is indeed a Groebner basis::

sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
// 1 t^0
// -1 t^5
<BLANKLINE>
// 1 t^0
// 1 t^1
// 1 t^2
// 1 t^3
// 1 t^4
// dimension (proj.) = 1
// degree (proj.) = 5
sage: out = tmp_filename()
sage: with redirection(sys.stdout, open(out, 'w')):
....: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
sage: with open(out) as f:
....: 'is no standard basis' in f.read()
False


TESTS:
Expand Down
9 changes: 6 additions & 3 deletions src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
sage: I.hilbert_numerator() # needs sage.rings.number_field
-t^5 + 1

This example returns a wrong answer due to an integer overflow in Singular::
This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::

sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
sage: I = P.ideal(M.minors(2))
sage: J = P * [m.lm() for m in I.groebner_basis()]
sage: J.hilbert_numerator(algorithm='singular')
...120*t^33 - 3465*t^32 + 48180*t^31 - ...
sage: J.hilbert_numerator(algorithm='singular') # known bug
Traceback (most recent call last):
....
RuntimeError: error in Singular function call 'hilb':
overflow at t^22

Our two algorithms should always agree; not tested until
:trac:`33178` is fixed::
Expand Down
10 changes: 8 additions & 2 deletions src/sage/sandpiles/sandpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2493,9 +2493,15 @@ def _set_ideal(self):
sage: '_ideal' in S.__dict__
True
"""
from sage.libs.singular.function_factory import ff
try:
sat = ff.elim__lib.sat_with_exp
except NameError:
sat = ff.elim__lib.sat
R = self.ring()
I = self._unsaturated_ideal._singular_()
self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
I = self._unsaturated_ideal
I_sat_gens = sat(I, prod(R.gens()))[0]
self._ideal = R.ideal(I_sat_gens)

def unsaturated_ideal(self):
r"""
Expand Down
5 changes: 4 additions & 1 deletion src/sage/schemes/projective/projective_subscheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,10 @@ def dual(self):
for i in range(n + 1):
J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])

sat = ff.elim__lib.sat
try:
sat = ff.elim__lib.sat_with_exp
except NameError:
sat = ff.elim__lib.sat

max_ideal = S.ideal(z[n + 1: 2 * n + 2])
J_sat_gens = sat(J, max_ideal)[0]
Expand Down