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

Fixes and simplifications for .ramified_primes(), .discriminant() and .is_isomorphic of quaternion algebras #37164

Merged
merged 3 commits into from
Feb 2, 2024

Conversation

S17A05
Copy link
Member

@S17A05 S17A05 commented Jan 25, 2024

  1. Removed unnecessary product and factorization for .ramified_primes()
  2. Adapted is_isomorphic to reduce unnecessary calculations
  3. Fixed a bug in .discriminant() and .ramified_primes() where rational invariants caused errors
  4. Removed .hilbert_conductor from sage.arith.misc import list and added .hilbert_symbol
  5. Reduced restriction of .ramified_primes() to rational quaternion algebras in docstring in preparation for planned .ramified_places() function over number fields (currently being worked on)

In more detail:

  1. The original workflow for .ramified_primes() went as follows:

    • Call .discriminant(), which calls .hilbert_conductor
    • Inside .hilbert_conductor, the ramified primes are computed and their product (the discriminant of the quaternion algebra) is returned
    • Finally, factor the discriminant back into its prime factors

    Hence we have a redundant product and, more crucially, a redundant prime factorization. This fix modifies .ramified_primes() to instead directly build the list computed in .hilbert_conductor() (up to a bug fix described in 3.) and return it; the list might not always be sorted by magnitude of primes, so an optional argument sorted (set to False by default) allows to enforce this (small to large) sorting. Furthermore, .discriminant() has been adapted to directly take the product of the list returned by .ramified_primes() (only in the rational case, for now - see 5.)

  2. Since the .discriminant()-function needs to compute all (finite) ramified primes (this was also true before this PR, it was just hidden inside .hilbert_conductor() instead), the function .is_isomorphic() now compares the unsorted lists of finite ramified primes to decide whether two rational quaternion algebras are isomorphic.

  3. The function sage.arith.misc.hilbert_conductor requires its arguments to be integers (to create certain lists of prime divisors); since it was originally used to determine the discriminant (and, as explained in 1., the ramified primes), it raises an error when the invariants are proper rational numbers. To get around the analogous error for the method .hilbert_symbol, we instead look at the numerators and denominators of both invariants separately, using the fact that we can (purely on a mathematical level) rescale both invariants by the squares of their respective denominators without leaving the isomorphism class of the algebra.

  4. The only call to sage.arith.misc.hilbert_conductor in quaternion_algebra.py was given in the old computation of the discriminant (the other .hilbert_conductor in the code, also in .discriminant(), refers to the one in sage.rings.number_field), so it was removed from the import list. The new approach to .ramified_primes() requires sage.arith.misc.hilbert_symbol, which was added to the import list.

  5. As of now the .ramified_primes()-method is only supported for rational quaternion algebras. I'm currently working on a version over number fields, but once it works correctly this will be implemented as a new function .ramified_places (Update: see Implemented .ramified_places and modified further methods to extend quaternion algebra functionality to number fields #37173) to distinguish between different formats (prime numbers vs ideals) over $\mathbb{Q}$ (Update: this wasn't really feasible, see the issues discussed in QQ.number_field() does not behave like any other NumberField #7596; thanks to @yyyyx4 for pointing me towards this discussion) and, furthermore, to not cause confusion using the term "primes" for the Archimedean real places where a quaternion algebra might ramify. Hence the implementation restriction in the docstring of .ramified_primes() was removed, but the method still throws a ValueError if not called with a quaternion algebra defined over the rational numbers.

#sd123

- Fixed a bug in .discriminant() and .ramified_primes() for rational invariants
- Removed unnecessary product and factoring for .ramified_primes()
- Reduced description of .ramified_primes() to rational quaternion algebras in preparation of planned .ramified_places() methods over number fields
(Amended: Fixed trailing whitespaces)
@S17A05 S17A05 closed this Jan 25, 2024
@S17A05 S17A05 deleted the is_isomorphic branch January 25, 2024 15:33
@S17A05 S17A05 restored the is_isomorphic branch January 25, 2024 15:36
@S17A05 S17A05 reopened this Jan 25, 2024
@S17A05
Copy link
Member Author

S17A05 commented Jan 25, 2024

Accidentally closed the pull request due to renaming the branch, so I'll delay the renaming to not open a new PR.

@S17A05 S17A05 changed the title Fixes and simplifications for .ramified_primes() and .discriminant() of quaternion algebras Fixes and simplifications for .ramified_primes(), .discriminant() and .is_isomorphic of quaternion algebras Jan 25, 2024
- Slightly modified description of `.discriminant()` to be more accurate
- Cached the method `.ramified_primes()`
- Removed optional parameter `sorted` in `.ramified_primes()`, sorting the primes by default instead.
- Removed `set()` functions in `.is_isomorphic` since the lists can be compared directly, as they are always sorted according to the above change.
- Made description of `.is_isomorphic` slightly more explicit.
@grhkm21
Copy link
Contributor

grhkm21 commented Jan 25, 2024

LGTM, wait for CI

- Added `.prime_divisors` to import list
- Modified product call in `.discriminant()`
Copy link

Documentation preview for this PR (built with commit f5fc230; changes) is ready! 🎉

@S17A05
Copy link
Member Author

S17A05 commented Jan 26, 2024

I had a look at the failed build & test, and the only issue I could find was related to stale files in sage/tests/books/judson-abstract-algebra; this seems unrelated to this PR, unless there is some connection / a different failure reason that I'm missing.

@grhkm21
Copy link
Contributor

grhkm21 commented Jan 26, 2024

Yeah ignore those, see devel. That's why I gave positive review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 27, 2024
… `.discriminant()` and `.is_isomorphic` of quaternion algebras

    
1. Removed unnecessary product and factorization for
`.ramified_primes()`
2. Adapted `is_isomorphic` to reduce unnecessary calculations
3. Fixed a bug in `.discriminant()` and `.ramified_primes()` where
rational invariants caused errors
4. Removed `.hilbert_conductor` from `sage.arith.misc` import list and
added `.hilbert_symbol`
5. Reduced restriction of `.ramified_primes()` to rational quaternion
algebras in docstring in preparation for planned `.ramified_places()`
function over number fields (currently being worked on)

In more detail:
1. The original workflow for `.ramified_primes()` went as follows:
    - Call `.discriminant()`, which calls `.hilbert_conductor`
    - Inside `.hilbert_conductor`, the ramified primes are computed and
their product (the discriminant of the quaternion algebra) is returned
    - Finally, factor the discriminant back into its prime factors

    Hence we have a redundant product and, more crucially, a redundant
prime factorization. This fix modifies `.ramified_primes()` to instead
directly build the list computed in `.hilbert_conductor()` (up to a bug
fix described in 3.) and return it; the list might not always be sorted
by magnitude of primes, so an optional argument `sorted` (set to `False`
by default) allows to enforce this (small to large) sorting.
Furthermore, `.discriminant()` has been adapted to directly take the
product of the list returned by `.ramified_primes()` (only in the
rational case, for now - see 5.)

2. Since the `.discriminant()`-function needs to compute all (finite)
ramified primes (this was also true before this PR, it was just hidden
inside `.hilbert_conductor()` instead), the function `.is_isomorphic()`
now compares the unsorted lists of finite ramified primes to decide
whether two rational quaternion algebras are isomorphic.

3. The function `sage.arith.misc.hilbert_conductor` requires its
arguments to be integers (to create certain lists of prime divisors);
since it was originally used to determine the discriminant (and, as
explained in 1., the ramified primes), it raises an error when the
invariants are proper rational numbers. To get around the analogous
error for the method `.hilbert_symbol`, we instead look at the
numerators and denominators of both invariants separately, using the
fact that we can (purely on a mathematical level) rescale both
invariants by the squares of their respective denominators without
leaving the isomorphism class of the algebra.

4. The only call to `sage.arith.misc.hilbert_conductor` in
quaternion_algebra.py was given in the old computation of the
discriminant (the other `.hilbert_conductor` in the code, also in
`.discriminant()`, refers to the one in `sage.rings.number_field`), so
it was removed from the import list. The new approach to
`.ramified_primes()` requires `sage.arith.misc.hilbert_symbol`, which
was added to the import list.

5. As of now the `.ramified_primes()`-method is only supported for
rational quaternion algebras. I'm currently working on a version over
number fields, but once it works correctly this will be implemented as a
new function `.ramified_places()` to distinguish between different
formats (prime numbers vs ideals) over Q and, furthermore, to not cause
confusion using the term "primes" for the Archimedean real places where
a quaternion algebra might ramify. Hence the implementation restriction
in the docstring of `.ramified_primes()` was removed, but the method
still throws a ValueError if not called with a quaternion algebra
defined over the rational numbers.

#sd123
    
URL: sagemath#37164
Reported by: Sebastian Spindler
Reviewer(s): grhkm21, Sebastian Spindler
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 29, 2024
… `.discriminant()` and `.is_isomorphic` of quaternion algebras

    
1. Removed unnecessary product and factorization for
`.ramified_primes()`
2. Adapted `is_isomorphic` to reduce unnecessary calculations
3. Fixed a bug in `.discriminant()` and `.ramified_primes()` where
rational invariants caused errors
4. Removed `.hilbert_conductor` from `sage.arith.misc` import list and
added `.hilbert_symbol`
5. Reduced restriction of `.ramified_primes()` to rational quaternion
algebras in docstring in preparation for planned `.ramified_places()`
function over number fields (currently being worked on)

In more detail:
1. The original workflow for `.ramified_primes()` went as follows:
    - Call `.discriminant()`, which calls `.hilbert_conductor`
    - Inside `.hilbert_conductor`, the ramified primes are computed and
their product (the discriminant of the quaternion algebra) is returned
    - Finally, factor the discriminant back into its prime factors

    Hence we have a redundant product and, more crucially, a redundant
prime factorization. This fix modifies `.ramified_primes()` to instead
directly build the list computed in `.hilbert_conductor()` (up to a bug
fix described in 3.) and return it; the list might not always be sorted
by magnitude of primes, so an optional argument `sorted` (set to `False`
by default) allows to enforce this (small to large) sorting.
Furthermore, `.discriminant()` has been adapted to directly take the
product of the list returned by `.ramified_primes()` (only in the
rational case, for now - see 5.)

2. Since the `.discriminant()`-function needs to compute all (finite)
ramified primes (this was also true before this PR, it was just hidden
inside `.hilbert_conductor()` instead), the function `.is_isomorphic()`
now compares the unsorted lists of finite ramified primes to decide
whether two rational quaternion algebras are isomorphic.

3. The function `sage.arith.misc.hilbert_conductor` requires its
arguments to be integers (to create certain lists of prime divisors);
since it was originally used to determine the discriminant (and, as
explained in 1., the ramified primes), it raises an error when the
invariants are proper rational numbers. To get around the analogous
error for the method `.hilbert_symbol`, we instead look at the
numerators and denominators of both invariants separately, using the
fact that we can (purely on a mathematical level) rescale both
invariants by the squares of their respective denominators without
leaving the isomorphism class of the algebra.

4. The only call to `sage.arith.misc.hilbert_conductor` in
quaternion_algebra.py was given in the old computation of the
discriminant (the other `.hilbert_conductor` in the code, also in
`.discriminant()`, refers to the one in `sage.rings.number_field`), so
it was removed from the import list. The new approach to
`.ramified_primes()` requires `sage.arith.misc.hilbert_symbol`, which
was added to the import list.

5. As of now the `.ramified_primes()`-method is only supported for
rational quaternion algebras. I'm currently working on a version over
number fields, but once it works correctly this will be implemented as a
new function `.ramified_places` (Update: see sagemath#37173) ~~to distinguish
between different formats (prime numbers vs ideals) over $\mathbb{Q}$~~
(Update: this wasn't really feasible, see the issues discussed in sagemath#7596;
thanks to @yyyyx4 for pointing me towards this discussion) ~~and,
furthermore,~~ to not cause confusion using the term "primes" for the
Archimedean real places where a quaternion algebra might ramify. Hence
the implementation restriction in the docstring of `.ramified_primes()`
was removed, but the method still throws a ValueError if not called with
a quaternion algebra defined over the rational numbers.

#sd123
    
URL: sagemath#37164
Reported by: Sebastian Spindler
Reviewer(s): grhkm21, Sebastian Spindler
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 30, 2024
… `.discriminant()` and `.is_isomorphic` of quaternion algebras

    
1. Removed unnecessary product and factorization for
`.ramified_primes()`
2. Adapted `is_isomorphic` to reduce unnecessary calculations
3. Fixed a bug in `.discriminant()` and `.ramified_primes()` where
rational invariants caused errors
4. Removed `.hilbert_conductor` from `sage.arith.misc` import list and
added `.hilbert_symbol`
5. Reduced restriction of `.ramified_primes()` to rational quaternion
algebras in docstring in preparation for planned `.ramified_places()`
function over number fields (currently being worked on)

In more detail:
1. The original workflow for `.ramified_primes()` went as follows:
    - Call `.discriminant()`, which calls `.hilbert_conductor`
    - Inside `.hilbert_conductor`, the ramified primes are computed and
their product (the discriminant of the quaternion algebra) is returned
    - Finally, factor the discriminant back into its prime factors

    Hence we have a redundant product and, more crucially, a redundant
prime factorization. This fix modifies `.ramified_primes()` to instead
directly build the list computed in `.hilbert_conductor()` (up to a bug
fix described in 3.) and return it; the list might not always be sorted
by magnitude of primes, so an optional argument `sorted` (set to `False`
by default) allows to enforce this (small to large) sorting.
Furthermore, `.discriminant()` has been adapted to directly take the
product of the list returned by `.ramified_primes()` (only in the
rational case, for now - see 5.)

2. Since the `.discriminant()`-function needs to compute all (finite)
ramified primes (this was also true before this PR, it was just hidden
inside `.hilbert_conductor()` instead), the function `.is_isomorphic()`
now compares the unsorted lists of finite ramified primes to decide
whether two rational quaternion algebras are isomorphic.

3. The function `sage.arith.misc.hilbert_conductor` requires its
arguments to be integers (to create certain lists of prime divisors);
since it was originally used to determine the discriminant (and, as
explained in 1., the ramified primes), it raises an error when the
invariants are proper rational numbers. To get around the analogous
error for the method `.hilbert_symbol`, we instead look at the
numerators and denominators of both invariants separately, using the
fact that we can (purely on a mathematical level) rescale both
invariants by the squares of their respective denominators without
leaving the isomorphism class of the algebra.

4. The only call to `sage.arith.misc.hilbert_conductor` in
quaternion_algebra.py was given in the old computation of the
discriminant (the other `.hilbert_conductor` in the code, also in
`.discriminant()`, refers to the one in `sage.rings.number_field`), so
it was removed from the import list. The new approach to
`.ramified_primes()` requires `sage.arith.misc.hilbert_symbol`, which
was added to the import list.

5. As of now the `.ramified_primes()`-method is only supported for
rational quaternion algebras. I'm currently working on a version over
number fields, but once it works correctly this will be implemented as a
new function `.ramified_places` (Update: see sagemath#37173) ~~to distinguish
between different formats (prime numbers vs ideals) over $\mathbb{Q}$~~
(Update: this wasn't really feasible, see the issues discussed in sagemath#7596;
thanks to @yyyyx4 for pointing me towards this discussion) ~~and,
furthermore,~~ to not cause confusion using the term "primes" for the
Archimedean real places where a quaternion algebra might ramify. Hence
the implementation restriction in the docstring of `.ramified_primes()`
was removed, but the method still throws a ValueError if not called with
a quaternion algebra defined over the rational numbers.

#sd123
    
URL: sagemath#37164
Reported by: Sebastian Spindler
Reviewer(s): grhkm21, Sebastian Spindler
@vbraun vbraun merged commit f40ab15 into sagemath:develop Feb 2, 2024
14 of 15 checks passed
@S17A05 S17A05 deleted the is_isomorphic branch February 2, 2024 21:37
@mkoeppe mkoeppe added this to the sage-10.3 milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants