Opened 6 years ago

Closed 5 years ago

#16043 closed task (fixed)

Hilbert Symbol introduces bugs from Pari

Reported by: annahaensch Owned by:
Priority: minor Milestone: sage-6.4
Component: number fields Keywords:
Cc: Merged in:
Authors: Anna Haensch, Peter Bruin Reviewers: Peter Bruin, Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: eca6ff7 (Commits) Commit: eca6ff7cf8e5e49c733791f6574254cb89c43f27
Dependencies: #15767 Stopgaps:

Description (last modified by jdemeyer)

For a field F and for a prime p, ( , )_p denotes the Hilbert Symbol over F localized at p. It is well known that (a,b)_p*(a,c)_p=(a,bc)_p for any a, b in F (cf O'meara 63:12). But I'm getting:

sage: K.<a>=NumberField(x^2+5)
sage: p=K.primes_above(2)[0];p
Fractional ideal (2, a + 1)
sage: K.hilbert_symbol(2*a,-1,p)
1
sage: K.hilbert_symbol(2*a,2,p)
1
sage: K.hilbert_symbol(2*a,-2,p)
-1

This is an upstream problem: http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1561 and the follow-up http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1569

Attachments (2)

trac_16043.patch (939 bytes) - added by annahaensch 6 years ago.
Adds incorrect hilbert_symbol outputs to doctest
trac_16043_v2.patch (1.0 KB) - added by annahaensch 6 years ago.
Use instead of trac_16043.patch

Download all attachments as: .zip

Change History (18)

comment:1 Changed 6 years ago by pbruin

By the basic properties of the Hilbert symbol, (2, -1)p = (2, 2)p = (2, -2)p = 1 for any p. Hence if p is the unique prime dividing 2 in K, some other correct values are

  • (a, 2)p = -1
  • (a, -2)p = -1
  • (a, -1)p = 1

PARI also computes (a, 2)p incorrectly. In the latest version of PARI/GP (2.7.0, not yet in Sage), one has

gp > K=nfinit(x^2+5);
gp > p=idealfactor(K,2)[1,1];
gp > a=Mod(x,K.pol);
gp > nfhilbert(K,a,2,p)
%4 = 1  # should be -1
gp > nfhilbert(K,a,-2,p)
%5 = -1
gp > nfhilbert(K,a,-1,p)
%6 = 1

Have you reported the bug to the PARI developers? (See http://pari.math.u-bordeaux.fr/Bugs/Reporting.html for how to do this.)

comment:2 Changed 6 years ago by annahaensch

I reported the bug to pari and it has been fixed. So I guess now we just have to wait for the next pari update in sage.

comment:3 Changed 6 years ago by annahaensch

  • Status changed from new to needs_review

comment:4 Changed 6 years ago by pbruin

  • Dependencies set to #15767
  • Report Upstream changed from N/A to Fixed upstream, but not in a stable release.
  • Reviewers set to Peter Bruin
  • Status changed from needs_review to needs_work
  • Work issues set to add doctest

It would be good to add this example as a doctest to NumberField.hilbert_symbol(). A PARI upgrade is done in #15767, but we may have to add the fix as a patch depending on whether it will be fixed in the version used there.

comment:5 Changed 6 years ago by annahaensch

The fix won't be implemented into the pari until the release of 2.8 (I confirmed this with Bill Allombert), so it will take some time for this piece to work it's way into Sage. And so I agree, the best thing to do is to build a patch to fix the bug, but I'm not sure how to do that.

In the meantime, I will add my example as a doctest to the current NumberField?.py file. That patch will be forthcoming.

Changed 6 years ago by annahaensch

Adds incorrect hilbert_symbol outputs to doctest

comment:6 Changed 6 years ago by pbruin

Sorry, my last comment wasn't very clear. I meant to say that this ticket should stay open until the bug is fixed (either directly in a PARI release, via a patch in the PARI package that Sage uses, or via a workaround in the Sage library), and that the doctest should check that the bug is fixed, i.e. that the output of hilbert_symbol() is mathematically correct.

I read Bill Allombert's reply at http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1561; I would interpret it as saying that automatically it is only guaranteed to be fixed in 2.8, but if it is considered serious enough (which would be logical given that it is a mathematical error) it might also be included in the next stable bugfix release, which is 2.7.1. In the latter case, Sage should be able to profit from it soon.

comment:7 Changed 6 years ago by annahaensch

I see. That makes a lot of sense. I wasn't sure if Sage only updated PARI at major releases or along the way. In that case, maybe there is not such a great urgency to patch a fix into sage since we should see it reflected soon enough.

Then just to be clear, should I change the current doctest to reflect the mathematically correct answer, i.e.,

sage: K.<a>=NumberField(x^2+5)
sage: p=K.primes_above(2)[0];p
Fractional ideal (2, a + 1)
sage: K.hilbert_symbol(2*a,-1,p)
1
sage: K.hilbert_symbol(2*a,2,p)
-1
sage: K.hilbert_symbol(2*a,-2,p)
-1

So that doctests return errors only until the bug is fixed? And after that point it will just be another nice correct example? Thanks for the helpful comments!

comment:8 Changed 6 years ago by jdemeyer

  • Description modified (diff)

Changed 6 years ago by annahaensch

Use instead of trac_16043.patch

comment:9 Changed 6 years ago by pbruin

The bug will be fixed in PARI 2.7.1, which is scheduled to be released on 12 May (see http://pari.math.u-bordeaux.fr/archives/pari-dev-1405/msg00000.html).

comment:10 follow-up: Changed 6 years ago by jdemeyer

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

comment:11 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:12 in reply to: ↑ 10 Changed 6 years ago by pbruin

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

Replying to jdemeyer:

Follow-up upstream bug: http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1569

This one is also fixed in PARI 2.7.1, which was released last week. (The log entry in the CHANGES file seems to have been inadvertently omitted, though.)

comment:13 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:14 Changed 6 years ago by pbruin

  • Authors changed from Anna Haensch to Anna Haensch, Peter Bruin
  • Branch set to u/pbruin/16043-hilbert_symbol
  • Commit set to eca6ff7cf8e5e49c733791f6574254cb89c43f27
  • Priority changed from major to minor
  • Report Upstream changed from Fixed upstream, in a later stable release. to N/A
  • Status changed from needs_work to needs_review
  • Type changed from defect to task
  • Work issues add doctest deleted

Here is a Git branch, with doctests checking that both of the above PARI bugs have been fixed.

Note: this is based on 6.4.beta1, #15767 needs to be merged separately until the next beta is out.

comment:15 Changed 5 years ago by jdemeyer

  • Reviewers changed from Peter Bruin to Peter Bruin, Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:16 Changed 5 years ago by vbraun

  • Branch changed from u/pbruin/16043-hilbert_symbol to eca6ff7cf8e5e49c733791f6574254cb89c43f27
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.