sage icon indicating copy to clipboard operation
sage copied to clipboard

OS X with homebrew's singular: doctest failures in algebraic_scheme.py, algebraic_curve.py

Open jhpalmieri opened this issue 2 months ago • 7 comments

Steps To Reproduce

Doctest failure:

**********************************************************************
File "src/sage/schemes/generic/algebraic_scheme.py", line 1200, in sage.schemes.generic.algebraic_scheme.AlgebraicScheme_subscheme.irreducible_components
Failed example:
    V.irreducible_components()                                            # needs sage.libs.singular
Expected:
    [Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       w,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       x^2 - y^2 - z^2,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       x^2*z - v^3,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       w^5 - 2*z^3*v^2]
Got:
    [Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       -w^5 + 2*z^3*v^2,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       -x^2*z + v^3,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       -x^2 + y^2 + z^2,
     Closed subscheme of Projective Space of dimension 4 over Rational Field defined by:
       w]
**********************************************************************

Some signs are different, entries are in a different order.

Likely related:

**********************************************************************
File "src/sage/schemes/curves/affine_curve.py", line 1235, in sage.schemes.curves.affine_curve.AffineCurve_field.blowup
Failed example:
    C.blowup(Q)
Expected:
    ((Affine Plane Curve over Rational Field
       defined by x^3 - s1^3 + 7*x^2 + 16*x + 12,
      Affine Plane Curve over Rational Field
       defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5
                  + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8),
     ([Scheme endomorphism of Affine Plane Curve over Rational Field
        defined by x^3 - s1^3 + 7*x^2 + 16*x + 12
         Defn: Defined on coordinates by sending (x, s1) to (x, s1),
       Scheme morphism:
         From: Affine Plane Curve over Rational Field
               defined by x^3 - s1^3 + 7*x^2 + 16*x + 12
         To:   Affine Plane Curve over Rational Field
               defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5
                          + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         Defn: Defined on coordinates by sending (x, s1) to
               (x*s1 + 2*s1 + 3/2, 1/s1)],
      [Scheme morphism:
         From: Affine Plane Curve over Rational Field
               defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5
                          + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         To:   Affine Plane Curve over Rational Field
               defined by x^3 - s1^3 + 7*x^2 + 16*x + 12
         Defn: Defined on coordinates by sending (y, s0) to
               (y*s0 - 3/2*s0 - 2, 1/s0),
       Scheme endomorphism of Affine Plane Curve over Rational Field
        defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6
                   - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         Defn: Defined on coordinates by sending (y, s0) to (y, s0)]),
     (Scheme morphism:
        From: Affine Plane Curve over Rational Field
              defined by x^3 - s1^3 + 7*x^2 + 16*x + 12
        To:   Affine Plane Curve over Rational Field
              defined by -x^6 - 13*x^5 - 70*x^4 - 200*x^3 + y^3
                         - 320*x^2 - 9/2*y^2 - 272*x + 27/4*y - 795/8
        Defn: Defined on coordinates by sending (x, s1) to
              (x, x*s1 + 2*s1 + 3/2),
      Scheme morphism:
        From: Affine Plane Curve over Rational Field
              defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5
                         + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
        To:   Affine Plane Curve over Rational Field
              defined by -x^6 - 13*x^5 - 70*x^4 - 200*x^3 + y^3
                         - 320*x^2 - 9/2*y^2 - 272*x + 27/4*y - 795/8
        Defn: Defined on coordinates by sending (y, s0) to
              (y*s0 - 3/2*s0 - 2, y)))
Got:
    ((Affine Plane Curve over Rational Field defined by -x^3 + s1^3 - 7*x^2 - 16*x - 12,
      Affine Plane Curve over Rational Field defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8),
     ([Scheme endomorphism of Affine Plane Curve over Rational Field defined by -x^3 + s1^3 - 7*x^2 - 16*x - 12
         Defn: Defined on coordinates by sending (x, s1) to
               (x, s1),
       Scheme morphism:
         From: Affine Plane Curve over Rational Field defined by -x^3 + s1^3 - 7*x^2 - 16*x - 12
         To:   Affine Plane Curve over Rational Field defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         Defn: Defined on coordinates by sending (x, s1) to
               (x*s1 + 2*s1 + 3/2, 1/s1)],
      [Scheme morphism:
         From: Affine Plane Curve over Rational Field defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         To:   Affine Plane Curve over Rational Field defined by -x^3 + s1^3 - 7*x^2 - 16*x - 12
         Defn: Defined on coordinates by sending (y, s0) to
               (y*s0 - 3/2*s0 - 2, 1/s0),
       Scheme endomorphism of Affine Plane Curve over Rational Field defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
         Defn: Defined on coordinates by sending (y, s0) to
               (y, s0)]),
     (Scheme morphism:
        From: Affine Plane Curve over Rational Field defined by -x^3 + s1^3 - 7*x^2 - 16*x - 12
        To:   Affine Plane Curve over Rational Field defined by -x^6 - 13*x^5 - 70*x^4 - 200*x^3 + y^3 - 320*x^2 - 9/2*y^2 - 272*x + 27/4*y - 795/8
        Defn: Defined on coordinates by sending (x, s1) to
              (x, x*s1 + 2*s1 + 3/2),
      Scheme morphism:
        From: Affine Plane Curve over Rational Field defined by 8*y^3*s0^6 - 36*y^2*s0^6 + 8*y^2*s0^5 + 54*y*s0^6 - 24*y*s0^5 - 27*s0^6 + 18*s0^5 - 8
        To:   Affine Plane Curve over Rational Field defined by -x^6 - 13*x^5 - 70*x^4 - 200*x^3 + y^3 - 320*x^2 - 9/2*y^2 - 272*x + 27/4*y - 795/8
        Defn: Defined on coordinates by sending (y, s0) to
              (y*s0 - 3/2*s0 - 2, y)))
**********************************************************************
File "src/sage/schemes/curves/affine_curve.py", line 1486, in sage.schemes.curves.affine_curve.AffineCurve_field.resolution_of_singularities
Failed example:
    C.resolution_of_singularities(extend=True)[0]         # long time (2 s)
Expected:
    (Affine Plane Curve over Number Field in a0
      with defining polynomial y^4 - 4*y^2 + 16
      defined by 24*x^2*ss1^3 + 24*ss1^3 + (a0^3 - 8*a0),
     Affine Plane Curve over Number Field in a0
      with defining polynomial y^4 - 4*y^2 + 16
      defined by 24*s1^2*ss0 + (a0^3 - 8*a0)*ss0^2 + (-6*a0^3)*s1,
     Affine Plane Curve over Number Field in a0
      with defining polynomial y^4 - 4*y^2 + 16
      defined by 8*y^2*s0^4 + (4*a0^3)*y*s0^3 - 32*s0^2 + (a0^3 - 8*a0)*y)
Got:
    (Affine Plane Curve over Number Field in a0 with defining polynomial y^4 - 4*y^2 + 16 defined by x^2*ss1^3 + ss1^3 + (1/24*a0^3 - 1/3*a0),
     Affine Plane Curve over Number Field in a0 with defining polynomial y^4 - 4*y^2 + 16 defined by s1^2*ss0 + (1/24*a0^3 - 1/3*a0)*ss0^2 + (-1/4*a0^3)*s1,
     Affine Plane Curve over Number Field in a0 with defining polynomial y^4 - 4*y^2 + 16 defined by y^2*s0^4 + (1/2*a0^3)*y*s0^3 - 4*s0^2 + (1/8*a0^3 - a0)*y)
**********************************************************************

Other files had similar failures.

Expected Behavior

Doctests should pass.

Actual Behavior

Doctests fail.

Additional Information

This is somehow related to using the system version of Singular. If I use ./configure --with-system-singular=no, then doctests pass. The system version of Singular is installed via homebrew. singular --version says it's version 4.4.1, and homebrew calls it 4.4.1p3.

Environment

  • OS: OS X 15.6.1, Xcode 26.0, with various homebrew packages installed
  • Sage Version: 10.8.beta4

Checklist

  • [x] I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • [x] I have read the documentation and troubleshoot guide

jhpalmieri avatar Sep 22 '25 21:09 jhpalmieri

these don't look like maths errors, they just assume a particular text being outputted. There is of course no difference mathematically if you multiply an equation for $-1$. 😃

dimpase avatar Oct 29 '25 23:10 dimpase

One confusing thing is that homebrew's version of Singular is 4.4.1, the same as the Sage installs, but the output appears to be different. Maybe homebrew's version is configured differently somehow, and that changes the output.

jhpalmieri avatar Oct 30 '25 02:10 jhpalmieri

you can see in https://github.com/Homebrew/homebrew-core/blob/38f66fe3f15e5c43128f5f5c6bb35e4f672ca9a1/Formula/s/singular.rb that they basically use the default options, with std=c++11. And we pass quite a long list.

dimpase avatar Oct 30 '25 07:10 dimpase

This is because after 4.4.1 p2, it changes the output format. It regards as 0 as the last element in free resolution

cxzhong avatar Nov 19 '25 08:11 cxzhong

This is because after 4.4.1 p2, it changes the output format. It regards as 0 as the last element in free resolution

I don't understand what you mean. It sounds like you are suggesting that #41138 should fix these problems, but as discussed there, that PR only fixes a few of these problems.

jhpalmieri avatar Nov 19 '25 18:11 jhpalmieri

This is because after 4.4.1 p2, it changes the output format. It regards as 0 as the last element in free resolution

I don't understand what you mean. It sounds like you are suggesting that #41138 should fix these problems, but as discussed there, that PR only fixes a few of these problems.

It just fix the problem caused by

sage -t --long --warn-long 30.0 --random-seed=286735480429121101562228604801325644303 src/doc/en/thematic_tutorials/sandpile.rst
**********************************************************************
Failed example:: Got: 'R^1 <-- R^7 <-- R^19 <-- R^25 <-- R^16 <-- R^4 <-- R^0'
                                                                                                                                                                                                                                                                                                                                                                                                                                   
    S.resolution() # long time
Expected:
    'R^1 <-- R^7 <-- R^19 <-- R^25 <-- R^16 <-- R^4'
Got:
    'R^1 <-- R^7 <-- R^19 <-- R^25 <-- R^16 <-- R^4 <-- R^0'
**********************************************************************
Failed example:: Got: 'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'
                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    S.resolution()
Expected:
    'R^1 <-- R^5 <-- R^5 <-- R^1'
Got:
    'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'
**********************************************************************
Failed example:: Got: [1, 6, 9, 4, 0]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    S.betti(False)
Expected:
    [1, 6, 9, 4]
Got:
    [1, 6, 9, 4, 0]
**********************************************************************
Failed example:: Got: 'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'
                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    S.resolution()
Expected:
    'R^1 <-- R^5 <-- R^5 <-- R^1'
Got:
    'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'
**********************************************************************
Failed example:: Got: 'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'
                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    S.resolution()  # a Gorenstein sandpile graph
Expected:
    'R^1 <-- R^5 <-- R^5 <-- R^1'
Got:
    'R^1 <-- R^5 <-- R^5 <-- R^1 <-- R^0'

Because output format changes, the is_free method outputs a wrong output False instead True in this example. and is_free method just justice the length of chain is less than 2 or not. But now singular lets 0 to be considered as the last element in a free resolution. So we need to justice it with 3, but I need to preserve the compatibility, so let the is_free method to check the size of last element is 0 or not.

sage: W = WeylGroup(['A', 3], prefix='s')                     # needs sage.combinat sage.groups
sage: for x in W:                                                           # needs sage.combinat sage.groups
....:    A = x.inversion_arrangement()
....:    assert A.matroid().is_chordal() == A.is_free()

I think it is wrong mathematically. But others doctest fails is caused by the change of output format. I think it is not a mathematical issue. We may change it to a more compatible test for singular <=4.4.1 and for newer version

cxzhong avatar Nov 20 '25 07:11 cxzhong

for the version things, you just need to see the source https://www.singular.uni-kl.de/ftp/pub/Math/Singular/src/4-4-1/ You can see there are many patch version of Singular 4.4.1

cxzhong avatar Nov 20 '25 07:11 cxzhong