Open a202b734-ed91-4b19-86b2-d3b6d5b55df3 opened 2 years ago
Interesting. This is coming from the fact that generic permutation groups are not unique parents:
sage: G2 = PermutationGroup([(1,2,3),(2,3,4)])
sage: Gfail is G2
False
sage: Gfail == G2
True
The quick fix would be making PermutationGroup
always return a UniqueRepresentation
subclass as my guess is it comes from this:
sage: R2 = GroupAlgebra(G2, QQ)
sage: R2 is Rfail
True
Now we could make the group algebra code only be unique if the input group is unique, but that would require some major modifications to how things are implemented I think.
I don't think we want PermutationGroup_generic
to be a subclass of UniqueRepresentation
because of the equality check. Could making it a subclass of CachedRepresentation
maybe fix this problem? Although I don't exactly understand why the code is failing in the first place...
Description changed:
---
+++
@@ -13,8 +13,103 @@
Rfail.center_basis()
+---------------------------------------------------------------------------
+RuntimeError Traceback (most recent call last)
+
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/categories/group_algebras.py in center_basis(self)
Monoids.Algebras.ElementMethods.is_central
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/categories/group_algebras.py in
Monoids.Algebras.ElementMethods.is_central
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/categories/poor_man_map.py in call(self, *args)
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/combinat/free_module.py in _sum_of_monomials(self, indices)
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/data_structures/blas_dict.pyx in sage.data_structures.blas_dict.sum_of_monomials (build/cythonized/sage/data_structures/blas_dict.c:3796)()
monomials
.+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/data_structures/blas_dict.pyx in sage.data_structures.blas_dict.sum_of_monomials (build/cythonized/sage/data_structures/blas_dict.c:3614)()
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/sets/recursively_enumerated_set.pyx in breadth_first_search_iterator (build/cythonized/sage/sets/recursively_enumerated_set.c:6352)()
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/structure/element.pyx in sage.structure.element.Element.richcmp (build/cythonized/sage/structure/element.c:10513)()
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.richcmp (build/cythonized/sage/structure/coerce.c:20599)()
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.canonical_coercion (build/cythonized/sage/structure/coerce.c:12619)()
+~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel._coercion_error (build/cythonized/sage/structure/coerce.c:21354)()
+RuntimeError: There is a bug in the coercion code in Sage. +Both x (=()) and y (=()) are supposed to have identical parents but they don't. +In fact, x has parent 'Permutation Group with generators [(2,3,4), (1,2,3)]' +whereas y has parent 'Permutation Group with generators [(2,3,4), (1,2,3)]' +Original elements () (parent Permutation Group with generators [(2,3,4), (1,2,3)]) and () (parent Permutation Group with generators [(2,3,4), (1,2,3)]) and maps +<class 'NoneType'> None +<class 'sage.structure.coerce_maps.DefaultConvertMap_unique'> (map internal to coercion system -- copy before use) +Coercion map:
-Pertinent part of error message: -RuntimeError: There is a bug in the coercion code in Sage.
Possibly related to
sage: p1 = PermutationGroup([(1,2),(1,2,3,4)]).an_element()
sage: p2 = SymmetricGroup(4).an_element()
sage: parent(coercion_model.canonical_coercion(p1, p2)[0])
Permutation Group with generators [(1,2), (1,2,3,4)]
sage: parent(coercion_model.canonical_coercion(p2, p1)[0])
Symmetric group of order 4! as a permutation group
See #28544
Quite likely. Non-unique-representation parents make coercion difficult, and from comment:2, likely even CachedRepresentation
won't improve the situation. We might have to explicitly convert some elements in the GroupAlgebra
code to fix this. It should at least fix the symptom, but that is likely just a hack solution with other issues popping up elsewhere...
Running sage 9.5.
This works:
This fails:
CC: @nbruin @videlec @fchapoton
Component: coercion
Issue created by migration from https://trac.sagemath.org/ticket/34005