Sage: Ticket #16492: Unital non-associative algebras can't be created
https://trac.sagemath.org/ticket/16492
<p>
In <a class="closed ticket" href="https://trac.sagemath.org/ticket/16055" title="enhancement: Implement Jordan algebras (closed: fixed)">#16055</a>, I was trying to create a unital "magmatic" algebra <code>A</code> and pass a base ring to <code>Parent</code>. This then tries to setup the default coercion from the base ring to <code>A</code>, which fails because <code>A</code> is not in <code>Rings()</code>.
</p>
<pre class="wiki">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
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/16492
Trac 1.1.6tscrimTue, 17 Jun 2014 17:32:56 GMT
https://trac.sagemath.org/ticket/16492#comment:1
https://trac.sagemath.org/ticket/16492#comment:1
<p>
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?
</p>
TicketnthieryFri, 20 Jun 2014 23:00:01 GMT
https://trac.sagemath.org/ticket/16492#comment:2
https://trac.sagemath.org/ticket/16492#comment:2
<p>
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.
</p>
<p>
Fun topic for an upcoming brainstorm in any cases!
</p>
Ticketvbraun_spamSun, 10 Aug 2014 16:51:03 GMTmilestone changed
https://trac.sagemath.org/ticket/16492#comment:3
https://trac.sagemath.org/ticket/16492#comment:3
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.3</em> to <em>sage-6.4</em>
</li>
</ul>
TicketpbruinFri, 04 Aug 2017 12:34:32 GMT
https://trac.sagemath.org/ticket/16492#comment:4
https://trac.sagemath.org/ticket/16492#comment:4
<p>
It looks like this may be solved by <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a>.
</p>
TickettscrimSun, 06 Aug 2017 14:57:56 GMT
https://trac.sagemath.org/ticket/16492#comment:5
https://trac.sagemath.org/ticket/16492#comment:5
<p>
I do not think <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a> is the solution. I think the problem is the lack of a proper category for nonassociative rings and rngs for the corresponding <code>Hom</code>, which is still a problem even with <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a>.
</p>
TicketpbruinMon, 07 Aug 2017 05:54:07 GMT
https://trac.sagemath.org/ticket/16492#comment:6
https://trac.sagemath.org/ticket/16492#comment:6
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/16492#comment:5" title="Comment 5">tscrim</a>:
</p>
<blockquote class="citation">
<p>
I do not think <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a> is the solution. I think the problem is the lack of a proper category for nonassociative rings and rngs for the corresponding <code>Hom</code>, which is still a problem even with <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a>.
</p>
</blockquote>
<p>
Why is it a problem? The change in <a class="closed ticket" href="https://trac.sagemath.org/ticket/19225" title="defect: cartesian product of algebra has troubles with base_ring (closed: fixed)">#19225</a> that fixes this particular error is replacing <code>Rings()</code> by <code>Sets()</code>; this doesn't break anything as far as I can see.
</p>
<p>
Of course, if you really want you can use something like <code>MagmasAndAdditiveMagmas().Distributive().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().AdditiveInverse().Unital()</code> for the <code>Hom</code> set, but then perhaps the next type of object someone wants to create may not have additive inverses, for example.
</p>
TicketpbruinMon, 02 Mar 2020 07:54:05 GMT
https://trac.sagemath.org/ticket/16492#comment:7
https://trac.sagemath.org/ticket/16492#comment:7
<p>
There is no error anymore in SageMath 9.1.beta6:
</p>
<pre class="wiki">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>
</pre>
TickettscrimMon, 02 Mar 2020 23:40:23 GMTstatus, milestone changed; reviewer set
https://trac.sagemath.org/ticket/16492#comment:8
https://trac.sagemath.org/ticket/16492#comment:8
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>reviewer</strong>
set to <em>Travis Scrimshaw</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-6.4</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
<p>
Seems like you were right. Thus works-for-me.
</p>
TicketpbruinTue, 03 Mar 2020 07:37:28 GMTstatus changed
https://trac.sagemath.org/ticket/16492#comment:9
https://trac.sagemath.org/ticket/16492#comment:9
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
<p>
Actually it was already fixed in SageMath 9.0 or earlier, most likely by <a class="closed ticket" href="https://trac.sagemath.org/ticket/28328" title="defect: Fix base ring conversion of non-associative unital algebras (closed: fixed)">#28328</a>. I guess we can regard this ticket as a duplicate.
</p>
TicketchapotonFri, 06 Mar 2020 19:29:57 GMTstatus changed; resolution set
https://trac.sagemath.org/ticket/16492#comment:10
https://trac.sagemath.org/ticket/16492#comment:10
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
</ul>
Ticket