-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
Constructor quaternion algebra over number fields from ramification #37189
base: develop
Are you sure you want to change the base?
Conversation
I've seen this other PR #37173 that implements |
8b4220c
to
44fc263
Compare
I'll review this once the necessary checks have completed. |
5be2ea6
to
d96f42e
Compare
Let me know (e.g. by commenting here) once you think this is ready for another full review; in the meantime, Lint recognized some whitespaces in the blank line 302. |
882ba53
to
55809f3
Compare
ready for review |
3be5ad7
to
0844c28
Compare
Great, I'll review it again when I find the time for it; this will probably not be before Friday though. |
0844c28
to
2657bae
Compare
Did you check that the real embeddings are treated in the same order as in .real_embeddings()? This does not seem automatic as the real embeddings are computed from the roots of the defining polynomial, not from PARI, but you are simply forwarding the second argument to PARI's alginit. Maybe this should be checked, documented, and tested (by checking the signs of the embeddings of a,b). |
Documentation preview for this PR (built with commit 6808417; changes) is ready! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. For the future, please don't force push big changes and instead put them into a new commit, otherwise it makes the review process a lot harder because everything has to be re-checked again.
if category(K) is not NumberFields(): | ||
raise ValueError("quaternion algbera must be defined over a number field") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check category(QQ) is not NumberFields()
returns True
; you should instead place this check after handling the case of the rational field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sage: category(QQ)
Join of Category of number fields and Category of quotient fields and Category of metric spaces
Is it possible to use this to check if K is QQ or a number field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be possible, but even then I would advise against it: You need to handle the rational field separately anyways (I ran into the same issue in #37173), and up to the check is_RationalField(K)
I don't see any code that doesn't work for either setting; hence it is probably easier to place the above category check in the else block after the treatment of the rational field case.
A = pari(K).alginit([2, [fin_places_pari, [QQ(1/2)] * len(fin_places_pari)], arg2], maxord=0) | ||
a = K(A.algsplittingfield().disc()[1]) | ||
b = K(A.algb()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there is a major issue here that @AurelPage correctly detected: The order in which the real embeddings are computed in PARI is indeed not the same as the order of embeddings given by .real_embeddings()
.
Here is an example:
sage: K.<v> = NumberField(-3x^5 - 11x^4 - 4x^3 + 1)
sage: A = QuaternionAlgebra(K, [], [1/2, 0, 1/2])
Quaternion Algebra (-3v^4 - 14v^3 - 15v^2 - 4v, -8) with base ring Number Field in v with defining polynomial -3x^5 - 11x^4 - 4x^3 + 1
Using the ramified_places
code from #37173, one can check that this algebra ramifies at the two embeddings sending K.real_embeddings()
these are the second and the third embeddings, respectively, but the desired output should be ramified at the third embedding as well as the first embedding sending
This could be fixed by first precomputing the order in which PARI lists the embeddings, and then permuting the list of local Archimedean invariants accordingly. I am not sure if this is feasible, and maybe @AurelPage has a better idea on how to work around this discrepancy between Sage and PARI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@S17A05 It is not difficult to find the bijection. Consider a generator of the field
However, this procedure should probably not be hard-coded in the middle of the quaternion algebras code, but should be put in a place that ensures it can be reused. Maybe it is already somewhere? I don't know where that should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@S17A05 It is not difficult to find the bijection. Consider a generator of the field K, and take an ε that separates its real embeddings. Consider the sequences of real embeddings computed by sage and pari respectively, at precision smaller than ε. Sort them both using indirect sort (with the permutations) and compose the permutations in the right way.
However, this procedure should probably not be hard-coded in the middle of the quaternion algebras code, but should be put in a place that ensures it can be reused. Maybe it is already somewhere? I don't know where that should be.
I don't think this is implemented yet. I'm not sure if this is the most elegant solution, but I would suggest adding an optional boolean parameter (e.g. called pari_perm
, set to False
by default) to the .real_embeddings()
-method of a number field such that, if the parameter is set to True, the method returns both the real embeddings and a permutation of the indices that correctly re-indexes the embeddings to be in the order they are computed in in PARI.
sage: QuaternionAlgebra(QQ, [(2), (3)], [0]) | ||
Quaternion Algebra (-1, 3) with base ring Rational Field | ||
sage: QuaternionAlgebra(QQ, [(2), (3)], [1/2]) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Quaternion algebra over the rationals must have an even number of ramified places | ||
sage: K.<w> = NumberField(x^2-x-1) | ||
sage: P = K.prime_above(2) | ||
sage: Q = K.prime_above(3) | ||
sage: A = QuaternionAlgebra(K, [P,Q], [0,0]) | ||
sage: A.discriminant() | ||
Fractional ideal (6) | ||
sage: A = QuaternionAlgebra(K, [P,Q], [1/2,0]) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Quaternion algebra over the rationals must have an even number of ramified places |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error warning in line 211 needs to be adapted, see the comment on line 314. Also, once #37173 has been reviewed and merged it would be nice to adapt the examples given here to show that the constructor gives an algebra with the desired ramification.
The modifications of the constructor also seem to mess up some examples according to the details of the Build & Test / build failure, and on certain inputs there seems to be a |
@Eloitor I have found a fix for the communication between Sage and PARI - the main problem is that PARI optimizes the defining polynomial, which mixes the embeddings up a bit. By mimicking this optimization in Sage, one can easily compute the permutation there with a simple sorting (since the real embeddings in Sage are sorted already), though. If you want to, I can implement the solution if you give me the necessary access to your branch (I could also fix the merge conflicts and the issue raised in the other review comment). |
This is great news!! Please go ahead. You should have access now :) |
118178d
to
d4bc980
Compare
Should be fixed; the new test examples aren't deterministic though (it can return different, but necessarily isomorphic algebras), so I've made sure that they are not actually tested right now - I'll make them into proper tests once #37173 has been merged. Also quickly mentioning myself here (@S17A05) so that the PR is a bit easier to find for me :) |
e56386d
to
2ae8288
Compare
d96b447
to
b025292
Compare
The errors in the tests seemed to be outdated, so I updated the branch to re-trigger the tests |
Whoops, turns out I was looking at the wrong thing - the new commit should fix the errors. |
The timeout in |
This PR adds a new input format for the constructor of quaternion algebras.
It uses PARI
alginit
function to construct one form the ramification information.Fixes #16948