gh-36333: Revision of the knot theory colorings method
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->
The following issue has been reported by Chuck Livingston to me:
```
sage: K9_15 = Knots().from_table(9, 15)
sage: K9_15.colorings(13)
[]
sage: K9_15.determinant()
39
```
Since 13 divides the determinant of the knot 156 colorings are expected.
While analyzing this issue, I found that the implementation (done in
https://github.com/sagemath/sage/issues/21863) does not match the
definition of [Fox `n`-colorings](https://en.wikipedia.org/wiki/Fox_n-
coloring) given in the listed references on Wikipedia and in Chuck's
book.
The name coloring maybe misleading here: The number `n` does not refer
to the number of (arbitrary) colors to be used. It can be interpreted as
the size of a fixed color palette. Mathematically, the colors correspond
to elements of the `n`-th dihedral group `D_n` whose rotations
(multiplied with the generating transvection) form the color palette. A
coloring corresponds to a group homomorphism from the fundamental group
`F` of the knot to `D_n`. If one interprets the arcs of the knot as the
generators of `F`, their colors correspond to their images in `D_n`.
Here are some lines in the current code that do not meet this
definition:
1. Changing `n` to the next prime number:
```
p = next_prime(n - 1)
```
2. Restriction of `n` to the number of different colors used:
```
if len(colors) == p:
```
3. Change color values:
```
colors = {b: a for a, b in enumerate(colors)}
res.add(tuple(colors[c] for c in coloring))
```
This PR fixes these issues. Furthermore, a new method `coloring_maps` is
added to calculate the group homomorphisms explicitly. This can also be
used to verify the results of the method `colorings`. Finally, the
`plot` method is adapted to the changes.
Note that the definition does not restrict `n` to be a prime number.
However, if this is not the case, we cannot just take the next prime
number to work more comfortably over a field. It is still necessary to
work over the residue class ring modulo `n`. Although the method
`right_kernel_matrix` works well in this context the method
`right_kernel` does not work due to a failure in the `span` method of
the `FreeModule` class. Since I didn't find an easy fix for this I
worked around this issue.
### :memo: Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.
### :hourglass: Dependencies
<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
URL: https://github.com/sagemath/sage/pull/36333
Reported by: Sebastian Oehms
Reviewer(s): miguelmarco, Sebastian Oehms