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

Reject broken system PARI 2.11.3 and re-enable PARI library test in spkg-configure #29445

Closed
kliem opened this issue Apr 1, 2020 · 34 comments
Closed

Comments

@kliem
Copy link
Contributor

kliem commented Apr 1, 2020

There are several failing doctests depending on the PARI version of the system, e.g.

File "src/sage/rings/number_field/number_field_ideal.py", line 1829, in sage.rings.number_field.number_field_ideal.NumberFieldFractionalIdeal.factor
Failed example:
    fact = F.factor(2); fact
Expected:
    (Fractional ideal (2*a^2 + 1))^2 * (Fractional ideal (-2*a^2))
Got:
    (Fractional ideal (-2*a^2 - 1))^2 * (Fractional ideal (2*a^2))

see e.g.

https://github.com/mkoeppe/sage/runs/542655863

This is the case because debian bullseye uses pari 2.11.3 (instead of pari 2.11.3). Many instances seem to fail, just because the choice of generators has changed. However, there is at least one thing really strange when upgrading to pari 2.11.3:

sage: y = var('y')
sage: pK = pari.bnfinit(y^3+3)
sage: pK.bnfisunit(pK.bnfunit()[0])
[1, Mod(1, 2)]~

CC: @mkoeppe @jdemeyer @orlitzky @dimpase

Component: number fields

Keywords: PARI

Author: Jonathan Kliem, Matthias Koeppe

Branch: c4a0a22

Reviewer: Matthias Koeppe, Jonathan Kliem

Issue created by migration from https://trac.sagemath.org/ticket/29445

@kliem kliem added this to the sage-9.1 milestone Apr 1, 2020
@kliem
Copy link
Contributor Author

kliem commented Apr 1, 2020

comment:1

The following tests currently fail (depending on the PARI version):

sage -t src/sage/rings/number_field/number_field.py
**********************************************************************
File "src/sage/rings/number_field/number_field.py", line 3426, in sage.rings.number_field.number_field.NumberField_generic.ideals_of_bdd_norm
Failed example:
    for n in d:
        print(n)
        for I in d[n]:
            print(I)
Expected:
    1
    Fractional ideal (1)
    2
    Fractional ideal (2, 1/2*a - 1/2)
    Fractional ideal (2, 1/2*a + 1/2)
    3
    Fractional ideal (3, 1/2*a - 1/2)
    Fractional ideal (3, 1/2*a + 1/2)
    4
...
Got:
    1
    Fractional ideal (1)
    2
    Fractional ideal (2, 1/2*a - 1/2)
    Fractional ideal (2, 1/2*a + 1/2)
    3
    Fractional ideal (3, 1/2*a + 1/2)
    Fractional ideal (3, 1/2*a - 1/2)
...
 File "src/sage/rings/number_field/number_field.py", line 4547, in sage.rings.number_field.number_field.NumberField_generic._S_class_group_and_units
Failed example:
    K._S_class_group_and_units(tuple(K.primes_above(13)))
Expected:
    ([2/13*a^2 + 1/13*a - 677/13,
      1/13*a^2 + 7/13*a - 332/13,
      -1/13*a^2 + 6/13*a + 345/13,
      -1,
      2/13*a^2 + 1/13*a - 755/13,
      1/13*a^2 - 19/13*a - 7/13],
     [(Fractional ideal (11, a - 2), 2), (Fractional ideal (19, a + 7), 2)])
Got:
    ([2/13*a^2 + 1/13*a - 677/13,
      1/13*a^2 + 7/13*a - 332/13,
      -1/13*a^2 + 6/13*a + 345/13,
      -1,
      2/13*a^2 + 1/13*a - 755/13,
      1/13*a^2 + 20/13*a - 7/13],
     [(Fractional ideal (11, a - 2), 2), (Fractional ideal (19, a + 7), 2)])
File "src/sage/rings/number_field/number_field.py", line 4705, in sage.rings.number_field.number_field.NumberField_generic.selmer_group
Failed example:
    K.selmer_group(K.primes_above(13), 2)
Expected:
    [2/13*a^2 + 1/13*a - 677/13,
     1/13*a^2 + 7/13*a - 332/13,
     -1/13*a^2 + 6/13*a + 345/13,
     -1,
     2/13*a^2 + 1/13*a - 755/13,
     1/13*a^2 - 19/13*a - 7/13,
     -1/13*a^2 + 45/13*a - 97/13,
     2/13*a^2 + 40/13*a - 27/13]
Got:
    [2/13*a^2 + 1/13*a - 677/13,
     1/13*a^2 + 7/13*a - 332/13,
     -1/13*a^2 + 6/13*a + 345/13,
     -1,
     2/13*a^2 + 1/13*a - 755/13,
     1/13*a^2 + 20/13*a - 7/13,
     1/13*a^2 - 45/13*a + 97/13,
     -2/13*a^2 - 40/13*a + 27/13]
File "src/sage/rings/number_field/number_field.py", line 5357, in sage.rings.number_field.number_field.NumberField_generic.elements_of_norm
Failed example:
    K.elements_of_norm(7)
Expected:
    [7/225*a^2 - 7/75*a - 42/25]
Got:
    [28/225*a^2 + 77/75*a - 133/25]
File "src/sage/rings/number_field/number_field.py", line 5460, in sage.rings.number_field.number_field.NumberField_generic.factor
Failed example:
    f = L.factor(a + 1); f
Expected:
    (Fractional ideal (1/2*a*b - a + 1/2)) * (Fractional ideal (-1/2*a*b - a + 1/2))
Got:
    (Fractional ideal (-1/2*b + 1/2*a + 1)) * (Fractional ideal (-1/2*a*b - a + 1/2))
 File "src/sage/rings/number_field/number_field.py", line 6537, in sage.rings.number_field.number_field.NumberField_generic.uniformizer
Failed example:
    [K.uniformizer(P) for P,e in factor(K.ideal(7))]
Expected:
    [t^2 + 3*t + 1]
Got:
    [t^2 - 4*t + 1]
File "src/sage/rings/number_field/number_field.py", line 6793, in sage.rings.number_field.number_field.NumberField_generic.S_unit_group
Failed example:
    U.log(u)
Expected:
    (1, 1, 4, 1, 5)
Got:
    (0, 1, 4, 1, 5)
File "src/sage/rings/number_field/number_field.py", line 7803, in sage.rings.number_field.number_field.NumberField_absolute.optimized_representation
Failed example:
    K.optimized_representation()
Expected:
    (Number Field in a1 with defining polynomial x^3 - 7*x - 7,
     Ring morphism:
       From: Number Field in a1 with defining polynomial x^3 - 7*x - 7
       To:   Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123
       Defn: a1 |--> 7/225*a^2 - 7/75*a - 42/25,
     Ring morphism:
       From: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123
       To:   Number Field in a1 with defining polynomial x^3 - 7*x - 7
       Defn: a |--> -15/7*a1^2 + 9)
Got:
    (Number Field in a1 with defining polynomial x^3 - 7*x - 7, Ring morphism:
       From: Number Field in a1 with defining polynomial x^3 - 7*x - 7
       To:   Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123
       Defn: a1 |--> 28/225*a^2 + 77/75*a - 133/25, Ring morphism:
       From: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123
       To:   Number Field in a1 with defining polynomial x^3 - 7*x - 7
       Defn: a |--> -60/7*a1^2 + 15*a1 + 39)
 File "src/sage/rings/number_field/number_field_ideal.py", line 1829, in sage.rings.number_field.number_field_ideal.NumberFieldFractionalIdeal.factor
Failed example:
    fact = F.factor(2); fact
Expected:
    (Fractional ideal (2*a^2 + 1))^2 * (Fractional ideal (-2*a^2))
Got:
    (Fractional ideal (-2*a^2 - 1))^2 * (Fractional ideal (2*a^2))
 File "src/sage/rings/number_field/number_field_ideal.py", line 2420, in sage.rings.number_field.number_field_ideal.NumberFieldFractionalIdeal.idealcoprime
Failed example:
    lam = A.idealcoprime(B); lam
Expected:
    -1/6*a + 1/6
Got:
    1/6*a - 1/6
 File "src/sage/rings/number_field/unit_group.py", line 281, in sage.rings.number_field.unit_group.UnitGroup.__init__
Failed example:
    UnitGroup(K, S=tuple(K.primes_above(7)))
Expected:
    S-unit group with structure C2 x Z x Z x Z of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 with S = (Fractional ideal (7/225*a^2 - 7/75*a - 42/25),)
Got:
    S-unit group with structure C2 x Z x Z x Z of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 with S = (Fractional ideal (28/225*a^2 + 77/75*a - 133/25),)
File "src/sage/rings/polynomial/polynomial_quotient_ring.py", line 1284, in sage.rings.polynomial.polynomial_quotient_ring.PolynomialQuotientRing_generic.S_class_group
Failed example:
    S.S_class_group([])
Expected:
    [((1/4*xbar^2 + 31/4,
       (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8,
       1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16,
       -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8),
      6),
      ((-1/4*xbar^2 - 23/4,
       (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
       -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16,
       1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8),
      6),
     ((-5/4*xbar^2 - 115/4,
       1/4*a*xbar^2 + 23/4*a,
       -1/16*xbar^3 - 7/16*xbar^2 - 23/16*xbar - 161/16,
       1/16*a*xbar^3 - 1/16*a*xbar^2 + 23/16*a*xbar - 23/16*a),
      2)]
Got:
     [((1/4*xbar^2 + 31/4,
       (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8,
       1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16,
       -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8),
      6),
     ((-1/4*xbar^2 - 23/4,
       (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
       -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16,
       1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8),
      6),
     ((-5/4*xbar^2 - 115/4,
       (1/8*a - 5/8)*xbar^2 + 23/8*a - 115/8,
       -1/16*xbar^3 - 17/16*xbar^2 - 23/16*xbar - 391/16,
       1/16*a*xbar^3 + (-1/16*a - 5/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 115/8),
      2)]
File "src/sage/rings/polynomial/polynomial_quotient_ring.py", line 1416, in sage.rings.polynomial.polynomial_quotient_ring.PolynomialQuotientRing_generic.class_group
Failed example:
    S.class_group()
Expected:
    [((1/4*xbar^2 + 31/4,
       (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8,
       1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16,
       -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8),
      6),
     ((-1/4*xbar^2 - 23/4,
       (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
       -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16,
       1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8),
      6),
     ((-5/4*xbar^2 - 115/4,
       1/4*a*xbar^2 + 23/4*a,
       -1/16*xbar^3 - 7/16*xbar^2 - 23/16*xbar - 161/16,
       1/16*a*xbar^3 - 1/16*a*xbar^2 + 23/16*a*xbar - 23/16*a),
      2)]
Got:
    [((1/4*xbar^2 + 31/4,
       (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8,
       1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16,
       -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8),
      6),
     ((-1/4*xbar^2 - 23/4,
       (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
       -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16,
       1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8),
      6),
     ((-5/4*xbar^2 - 115/4,
       (1/8*a - 5/8)*xbar^2 + 23/8*a - 115/8,
       -1/16*xbar^3 - 17/16*xbar^2 - 23/16*xbar - 391/16,
       1/16*a*xbar^3 + (-1/16*a - 5/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 115/8),
      2)]

There are some other tests that seem PARI related, e.g.

File "src/sage/lfunctions/dokchitser.py", line 112, in sage.lfunctions.dokchitser.Dokchitser
Failed example:
    L.check_functional_equation()
Expected:
    6.04442711160669e-18                            
Got:
    6.11218974738703e-18

and

 File "src/sage/lfunctions/dokchitser.py", line 671, in sage.lfunctions.dokchitser.Dokchitser.check_functional_equation
Failed example:
    L.check_functional_equation()
Expected:
    -2.71050543121376e-20                        
Got:
    -1.35525271560688e-20
File "src/sage/lfunctions/pari.py", line 425, in sage.lfunctions.pari.LFunction
Failed example:
    L.check_functional_equation()
Expected:
    1.08420217248550e-19
Got:
    4.33680868994202e-19

Those tests could be repaired by just checking that the numerical noise is reasonable.

@kliem

This comment has been minimized.

@kliem
Copy link
Contributor Author

kliem commented Apr 2, 2020

comment:3

I have upgraded to pari 2.11.3 and that reproduces the problems. So I confirm that this is the problem.

@kliem
Copy link
Contributor Author

kliem commented Apr 2, 2020

comment:4

Something seems to be messed up when installing PARI 2.11.3

sage: y = var('y')
sage: pK = pari.bnfinit(y^3+3)
sage: pK.bnfisunit(pK.bnfunit()[0])
[1, Mod(1, 2)]~

But the expected output is [1, Mod(0, 2)].

@kliem
Copy link
Contributor Author

kliem commented Apr 2, 2020

Changed author from Jonathan Kliem to none

@kliem

This comment has been minimized.

@kliem
Copy link
Contributor Author

kliem commented Apr 2, 2020

comment:5

Maybe cypari 2.1.1 just cannot deal with pari 2.11.3, but maybe there is also a bug in pari 2.11.3.

@kliem
Copy link
Contributor Author

kliem commented Apr 2, 2020

comment:6

Before I forget,

this also looks serious

File "src/sage/rings/number_field/number_field.py", line 5357, in sage.rings.number_field.number_field.NumberField_generic.elements_of_norm
Failed example:
    K.elements_of_norm(7)
Expected:
    [7/225*a^2 - 7/75*a - 42/25]
Got:
    [28/225*a^2 + 77/75*a - 133/25]

I don't think this element has norm 7 in K.<a> = NumberField(7/9*x^3 + 7/3*x^2 - 56*x + 123).

@antonio-rojas
Copy link
Contributor

comment:7

pari 2.11.3 is broken, see #29313. The test in the previous comment is ok though, both elements have norm 7.

@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:8

Ok, I'm stupid. I redifined a and than parsed 28/225*a^2 + 77/75*a - 133/25. This did of course produce nonsense.

So what do we do. Reject pari 2.11.3 from system until this is fixed?

Replying to @antonio-rojas:

pari 2.11.3 is broken, see #29313. The test in the previous comment is ok though, both elements have norm 7.

@antonio-rojas
Copy link
Contributor

comment:9

Replying to @kliem:

So what do we do. Reject pari 2.11.3 from system until this is fixed?

Yes, IMO that's what we should do - unpatched 2.11.3 gives incorrect answers which is not acceptable.

@orlitzky
Copy link
Contributor

orlitzky commented Apr 3, 2020

comment:12

Devil's advocate: we shouldn't be in the business of detecting system versions down to the backported-commit-patch level. Distros should be in charge of not shipping broken software to their users, who probably don't want to be using a PARI that gives the wrong answer outside of Sage, either. If people hit this, they should complain to their distro to either backport the patch or mask the busted version.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

comment:13

spkg-configure is exactly this business, by definition

But it shouldn't detect versions. It should detect absence of known bugs.

@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:14

As far as I understand, the patch in the branch #29313 also includes a small doctest.

Can we include this in spkg-configure?

This is probably wrong syntax, but something like this might work:

    AC_MSG_CHECKING([does pari have known bug? ])
    bug_check=`echo "bnf = bnfinit(y^4-y-1); bnfisunit(bnf,-y^3+2*y^2-1)" | $GP -qf 2>> config.log`
    expected="[0, 2, Mod(0, 2)]~"
    if test x$bug_check=x$expected; then
        AC_MSG_RESULT([no])
    else
        AC_MSG_RESULT([yes; cannot use system pari/GP with known bug])
        AC_MSG_NOTICE([Patch/upgrade yoour package and reconfigure.])
        AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
        sage_spkg_install_pari=yes
    fi

@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:15

On the broken pari the output of this is [0, 2, Mod(1, 2)]~. On the working pari the output is as above.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

comment:16

yes, that's the right way to fix it. Careful with the brackets - they are m4 quoting characters

@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:17

Can you are someone put it in the right place? I can try to, but I'm really guessing here.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

comment:18

OK, will do

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

New commits:

f6341dbbuild/pkgs/pari/spkg-configure.m4: Add test for bnfisunit bug
c4a0a22build/pkgs/pari/spkg-configure.m4: Re-enable main PARI test (lost in SAGE_SPKG_CONFIGURE macro change); remove duplicate AC_MSG

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

Commit: c4a0a22

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

Author: Jonathan Kliem, Matthias Koeppe

@mkoeppe mkoeppe changed the title Fix failing doctests because of representation depending on PARI version Reject broken system PARI 2.11.3 Apr 3, 2020
@mkoeppe mkoeppe changed the title Reject broken system PARI 2.11.3 Reject broken system PARI 2.11.3 and re-enable PARI library test in spkg-configure Apr 3, 2020
@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:24

@mkoeppe: Thanks. Should I start a github workflow? Are you already doing it?

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

comment:25

Please do. #29417 has the latest version

@antonio-rojas
Copy link
Contributor

comment:26

What about the original aim of this ticket (make tests pass regardless of the system pari version)? When using a patched 2.11.3 you'd still get many doctest failures (but correct nevertheless)

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2020

comment:27

Should probably be taken care of in the same ticket

@kliem
Copy link
Contributor Author

kliem commented Apr 3, 2020

comment:28

I would wait and see.

I'm still willing to change the doctests such that both pari versions work, but I guess on a new ticket once this problem occurs.

(I also wasn't sure how many of those things would disappear once this is patched, e.g. the +/- failures.)

@antonio-rojas
Copy link
Contributor

comment:29

You can see the exact failures in the patch for #29313 (but that patch only changes them to the 2.11.3 answer, so they would fail with <2.11.3)

@kliem
Copy link
Contributor Author

kliem commented Apr 4, 2020

comment:30

Ok, seems to work

https://github.com/kliem/sage-test-27122/actions

Specifically for debian bulleye standard it detects the bug and doesn't use system pari (and those failures are gone).
For debian buster it checks for the bug and detects that the system pari is fine to use.

@kliem
Copy link
Contributor Author

kliem commented Apr 4, 2020

Reviewer: Jonathan Kliem

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 4, 2020

Changed reviewer from Jonathan Kliem to Matthias Koeppe, Jonathan Kliem

@vbraun
Copy link
Member

vbraun commented Apr 9, 2020

@dimpase
Copy link
Member

dimpase commented Apr 23, 2020

Changed commit from c4a0a22 to none

@dimpase
Copy link
Member

dimpase commented Apr 23, 2020

comment:34

it is a buggy test

configure:17249: checking whether hyperellcharpoly bug is fixed
  ***   too many arguments: ...lcharpoly(x^10+x^9+x^8+x,0*Mod(1,3))
  ***                                                   ^-----------
configure:17257: result: no; cannot use system pari/GP with known bug

Don't mix up AS_IF and shell if :-(

See #29554 for a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants