Opened 7 years ago
Closed 11 months ago
#16492 closed defect (duplicate)
Unital non-associative algebras can't be created
Reported by: | tscrim | Owned by: | tscrim |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | categories | Keywords: | unital nonassociative algebras, coercion |
Cc: | nthiery, SimonKing | Merged in: | |
Authors: | Reviewers: | Travis Scrimshaw | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
In #16055, I was trying to create a unital "magmatic" algebra A
and pass a base ring to Parent
. This then tries to setup the default coercion from the base ring to A
, which fails because A
is not in Rings()
.
sage: from sage.categories.magmatic_algebras import MagmaticAlgebras sage: class A(Parent): ....: def __init__(self, R): ....: Parent.__init__(self, base=R, category=MagmaticAlgebras(R).Unital()) ....: sage: A(QQ) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-15-88fb3480ad86> in <module>() ----> 1 A(QQ) <ipython-input-14-60fb77c01127> in __init__(self, R) 1 class A(Parent): 2 def __init__(self, R): ----> 3 Parent.__init__(self, base=R, category=MagmaticAlgebras(R).Unital()) 4 /home/travis/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__init__ (sage/structure/parent.c:4594)() /home/travis/sage/local/lib/python2.7/site-packages/sage/categories/unital_algebras.pyc in __init_extra__(self) 105 mor = None 106 # This could be a morphism of Algebras(self.base_ring()); however, e.g., QQ is not in Algebras(QQ) --> 107 H = Hom(base_ring, self, Rings()) # TODO: non associative ring! 108 109 # Idea: There is a generic method "from_base_ring", that just does multiplication with /home/travis/sage/local/lib/python2.7/site-packages/sage/categories/homset.pyc in Hom(X, Y, category, check) 391 # available for the following error message. It simply 392 # belongs to the wrong category. --> 393 raise ValueError("{} is not in {}".format(O, category)) 394 395 # Construct H ValueError: <class '__main__.A_with_category'> is not in Category of rings
Change History (10)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
Ah, interesting: there can be situations where it's perfectly legitimate to want to define a morphism in a category C with a codomain that does not belong to C. Maybe we just want to add a "force=True" argument to reduce the sanity checks in those cases where the caller knows what he is doing. And reciprocally, we should better take into account the axioms of the domain in the case at hand.
Fun topic for an upcoming brainstorm in any cases!
comment:3 Changed 6 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:4 Changed 3 years ago by
It looks like this may be solved by #19225.
comment:5 follow-up: ↓ 6 Changed 3 years ago by
comment:6 in reply to: ↑ 5 Changed 3 years ago by
Replying to tscrim:
I do not think #19225 is the solution. I think the problem is the lack of a proper category for nonassociative rings and rngs for the corresponding
Hom
, which is still a problem even with #19225.
Why is it a problem? The change in #19225 that fixes this particular error is replacing Rings()
by Sets()
; this doesn't break anything as far as I can see.
Of course, if you really want you can use something like MagmasAndAdditiveMagmas().Distributive().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().AdditiveInverse().Unital()
for the Hom
set, but then perhaps the next type of object someone wants to create may not have additive inverses, for example.
comment:7 Changed 11 months ago by
There is no error anymore in SageMath 9.1.beta6:
sage: from sage.categories.magmatic_algebras import MagmaticAlgebras ....: class A(Parent): ....: def __init__(self, R): ....: Parent.__init__(self, base=R, category=MagmaticAlgebras(R).Unital()) ....: B = A(QQ); B ....: B.coerce_map_from(QQ) ....: <__main__.A_with_category object at 0x7ee3bdc39408> Generic morphism: From: Rational Field To: <__main__.A_with_category object at 0x7ee3bdc39408>
comment:8 Changed 11 months ago by
- Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
- Reviewers set to Travis Scrimshaw
- Status changed from new to needs_review
Seems like you were right. Thus works-for-me.
comment:9 Changed 11 months ago by
- Status changed from needs_review to positive_review
Actually it was already fixed in SageMath 9.0 or earlier, most likely by #28328. I guess we can regard this ticket as a duplicate.
comment:10 Changed 11 months ago by
- Resolution set to duplicate
- Status changed from positive_review to closed
So I'm thinking we should have a new category for unital associative algebras which sets up this coercion and the non-associative variety not. Comments?