-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
_S_class_group_and_units is mathematically incorrect #14489
Comments
Author: Robert Harron |
comment:1
Note: technically this depends on #14391, but that ticket has already been merged into 5.9beta4, so I haven't listed it. Also, I doctested the number field module with this patch applied, but haven't done the full long doctesting. I'll do that overnight. |
comment:2
Some things on the docstrings and code from looking at the patch file:
I can't do the mathematical review. Thanks, Travis |
comment:3
Thanks, Travis, I'll try to get around to those changes tonight. One comment and one question: (1) Re the doctests: the first doctest (which was already there) is an example of the case len(S) == 0. The second doctest (which was already there) is when S contains only principal ideals and so the J you come across is necessarily already principal. Also, in the doctest I added, for the second ideal (namely (19, 1/13a2 - 45/13a - 332/13)) the J you get is principal. So, your second point is already covered. Should I add comments to this effect in the docs? (2) Re import: So, I have no real idea when to import in the module and when to import in the function. Is there somewhere to read about that. I guess you're saying that in the case of the two functions at hand, these are imported by sage when you boot it and so really are already loaded and so I might as well import them at the module level? Thanks! |
comment:4
Hey Robert, Replying to @rharron:
No, this is likely clear to those in the field.
It's a matter of when the module with the class/function is loaded into sage. If it's at the module level, it is imported when the module is imported (which is anytime any part of a module is imported [at startup, this is in an
I don't know of a specific place offhand to read on this...
Correct, this will make the function (marginally) faster each time it's called. Best, Travis |
comment:5
That would explain why I was having some trouble. I was able to load prod at the module level, but whenever I put Matrix in sage wouldn't start. |
comment:6
Running the long tests, I got a doctest failure in polynomial_quotient_ring.py (since it has a function _S_class_group_and_units that uses the function I changed to compute such things for quotients of polynomial rings over number fields by not necessarily irreducible polynomials):
It is understandable that the output has changed given that it uses a my new version of the function for number fields. However(!) when I open sage and run the code in the doctest, I get the expected output of the doctest, not the new one. Why is the doctest giving a different result than running the same commands in sage? |
comment:7
Ugh, my comment was just swallowed by trac. Try again, but quicker: I figured out the problems. Line 984: Both answers are correct. At some point, my code returns -pr whereas the old code returns pr. The discrepancy between the doctest illustrates the subtlety in this: if I open sage and enter all the commands in the doctest for S_class_group in order, then I get the same answer the doctest got; whereas just entering the commands from line 981 to 984 gives the answer the doctest expected. Anyway, I'm just going to update the doctest. (Is there an issue with the difference between 32 and 64 bit, I'm on a 64 bit machine). Line 990: The expected answer is incorrect. The ideal in question when squared is not principal (in fact, the line 984 example says that the order is 6 not 2). So, I'll update the doctest with the new answer. |
comment:8
Attachment: trac_14489_fix_S_class_group_and_units.patch.gz Alright, new patch uploaded. |
comment:9
The patch applies cleanly against 5.9 and passes long tests. |
comment:10
Hey Robert, one more comment about the doc, I think it might be better to use a LaTeX (single-letter) variable for the gen/order since they are used so much in an exponential form. Otherwise I'd suggest |
Reviewer: Peter Bruin |
comment:12
I would tend to give this a positive review. The patch fixes the problem, I believe the code is correct, all tests pass, and the documentation builds correctly. I have a few comments, though:
I made a patch on top of this one to address these issues. An additional reviewer would probably be needed, but I think it should not be too hard to review. The two patches together have a net effect of simplifying the Selmer group code somewhat. Alternatively, I could file a new ticket for the additional changes, if the second patch would delay closing this ticket too long. Any opinions about which option would be better? |
This comment has been minimized.
This comment has been minimized.
Attachment: trac_14489_simplify_S_class_group_and_units.patch.gz suggested enhancements; apply after trac_14489_fix_S_class_group_and_units.patch |
comment:13
Thanks for reviewing this, Peter. In instances where sage is silently returning a mathematically incorrect answer, I try to create a minimal patch that fixes the problem to speed up the review process and get the fix in quickly. So, I'd suggest that since you think the patch I've written works properly, then you should accept this ticket and open a new ticket (which would be an enhancement ticket rather than a defect ticket) to clean up the code. My rationale is that the patch I wrote only changed a couple dozen lines of code and is fairly simple and yet has taken almost 2 months to be reviewed, so who knows how long this new patch would take to review? Makes sense? (Also, note that the long sentences in the docstrings and the term "principal generator" were already present before my patch. My philosophy of minimal changes made me leave them in.) |
comment:14
OK, let's do it like that. |
This comment has been minimized.
This comment has been minimized.
comment:16
On 32-bit systems:
|
comment:17
I don't have access to a 32-bit machine on which to test this. The expected output and the actual output differ only in the third element of each triple, and they differ by a unit (which is -1 in the second case; I haven't checked in the first case). This is consistent with the fact that this element is a somewhat arbitrary generator of a principal ideal. This doctest failure should go away when applying both this patch and #14746, which eliminates this third element, among other things. Perhaps the quickest fix would be to mark the output of these doctests as random in this patch and revert to non-random in the patch of #14746? |
comment:18
Or better: instead of |
correct results for doctests on 32-bit machines |
comment:19
Attachment: trac_14489_doctests_32_64_bit.patch.gz Hopefully the fact that I submitted a simple patch to fix the 32-bit/64-bit doctest issue does not preclude me from giving a positive review again. |
This comment has been minimized.
This comment has been minimized.
comment:20
For patchbot: Apply trac_14489_fix_S_class_group_and_units.patch, trac_14489_doctests_32_64_bit.patch |
comment:21
Test failure in my 32-bit VM:
|
comment:22
The doctest failure seems to be fixed in the follow-up #14746, however that introduces another 32-bit failure. |
Dependencies: #14746 |
comment:24
Sorry, just noticed that I was one off in my patch queue. Never mind, all tests pass. |
Changed dependencies from #14746 to none |
Merged: sage-5.11.rc0 |
The output of _S_class_group_and_units is incorrect, and hence the output of selmer_group as well, in some cases where S contains non-principal ideals. Here's an example:
It's fairly easy, using Sage, to see that the S-2-Selmer group of K is an 8-dimensional F_2-vector space. The list of length 8 that is returned is supposed to be a basis of this (or rather a set of representatives in K×). But the S-2-Selmer group is a subgroup of K× mod squares, so 121 is the zero vector and hence the output is not linearly independent. The problem lies in the following:
The 121 in there is supposed to be such that (11, a-2)2 = (121). But (11, a-2)2 is not principal (in fact, (11, a-2) is a generator of the cyclic subgroup of order 6). It is just in the subgroup of the class group generated by the primes in S.
I'll shortly upload a patch that fixes this (partially suggested to me by Zev Klagsbrun).
Apply: attachment: trac_14489_fix_S_class_group_and_units.patch, attachment: trac_14489_doctests_32_64_bit.patch
Component: number fields
Keywords: S-class group
Author: Robert Harron
Reviewer: Peter Bruin
Merged: sage-5.11.rc0
Issue created by migration from https://trac.sagemath.org/ticket/14489
The text was updated successfully, but these errors were encountered: