Where do categories() come from?

88 views
Skip to first unread message

Michael Orlitzky

unread,
Aug 5, 2019, 2:45:52 PM8/5/19
to sage-...@googlegroups.com
When I'm implementing an algebraic structure, for example,

sage: class HadamardR3(CombinatorialFreeModule):
....: def __init__(self):
....: cat = FiniteDimensionalAlgebrasWithBasis(QQ)
....: gens = range(3)
....: super(HadamardR3,self).__init__(QQ,
....: gens,
....: category=cat)
....: def product_on_basis(self,i,j):
....: ei = self.basis()[i].to_vector()
....: ej = self.basis()[j].to_vector()
....: Lei = ei.column()*ei.row()
....: return self.from_vector(Lei*ej)

I get a bunch of categories that I don't expect. These two are OK:

sage: J = HadamardR3()
sage: J.category()
Category of finite dimensional algebras with basis over Rational
Field
sage: J.category().super_categories()
[Category of algebras with basis over Rational Field,
Category of finite dimensional magmatic algebras with basis
over Rational Field]

But where do all these come from?

sage: J.categories()
[Category of finite dimensional algebras with basis over Rational
Field,
Category of algebras with basis over Rational Field,
Category of algebras over Rational Field,
Category of rings,
Category of associative algebras over Rational Field,
...

I'm particularly curious how "associative" gets in there for
non-associative algebras. This leads to things like "J in Rings()"
returning true when "J" isn't a ring, and probably a bunch of nonsense
methods being automatically implemented for the structure.

Vincent Delecroix

unread,
Aug 5, 2019, 3:15:43 PM8/5/19
to sage-...@googlegroups.com
sage: Rings().Commutative()
Category of commutative rings
sage: Rings()
Category of rings

Vincent Delecroix

unread,
Aug 5, 2019, 3:16:49 PM8/5/19
to sage-...@googlegroups.com
Though I think that associative is an assumption of algebras.
Indeed, from the documentation

"""
The category of associative and unital algebras over a given
base ring.

Vincent Delecroix

unread,
Aug 5, 2019, 3:17:26 PM8/5/19
to sage-...@googlegroups.com

Michael Orlitzky

unread,
Aug 6, 2019, 3:24:29 AM8/6/19
to sage-...@googlegroups.com
On 8/5/19 11:14 AM, Vincent Delecroix wrote:
> http://doc.sagemath.org/html/en/reference/categories/sage/categories/algebras.html
>
> Le 05/08/2019 à 17:14, Vincent Delecroix a écrit :
>> Though I think that associative is an assumption of algebras.
>> Indeed, from the documentation
>>
>> """
>> The category of associative and unital algebras over a given
>> base ring.
>> """

Algebras() is supposed to be deprecated in favor of MagmaticAlgebras()
that aren't necessarily associative... but that just brings me back to:

sage: J.category().super_categories()
[Category of algebras with basis over Rational Field,
Category of finite dimensional magmatic algebras with basis
over Rational Field]

I guess FiniteDimensionalAlgebrasWithBasis has both the old Algebras()
and the new MagmaticAlgebras() as supercategories? That would explain
why I'm seeing associativity and rings everywhere.

Michael Orlitzky

unread,
Aug 7, 2019, 8:56:59 PM8/7/19
to sage-...@googlegroups.com
On 8/5/19 11:24 PM, Michael Orlitzky wrote:
>
> I guess FiniteDimensionalAlgebrasWithBasis has both the old Algebras()
> and the new MagmaticAlgebras() as supercategories? That would explain
> why I'm seeing associativity and rings everywhere.
>

...and building up a pile of non-associative categories one-at-a-time
doesn't work either, of course =)

Hopefully-simple fixes in

https://trac.sagemath.org/ticket/28327

and

https://trac.sagemath.org/ticket/28328

if anyone has a minute.

Travis Scrimshaw

unread,
Aug 13, 2019, 3:45:58 AM8/13/19
to sage-devel

> I guess FiniteDimensionalAlgebrasWithBasis has both the old Algebras()
> and the new MagmaticAlgebras() as supercategories? That would explain
> why I'm seeing associativity and rings everywhere.
>

...and building up a pile of non-associative categories one-at-a-time
doesn't work either, of course =)

MagmaticAlgebras has been around for quite some time. At some point, there is a plan to make Algebras to not assume associativity in order to be more explicit. Also, Algebras is not "old" and not going away. However, as you said, FiniteDimensionalAlgebrasWithBasis has Algebras as a basis, and so it is associative. For the analogous thing, you want MagmaticAlgebras(R).FiniteDimensional().WithBasis() (maybe also .Unital() added too). However, this will be a more generic join category. If some of the methods currently in the associative version still apply, you should create the corresponding category and move those methods to this category. Does that clarify things?

Best,
Travis

Michael Orlitzky

unread,
Aug 13, 2019, 1:47:00 PM8/13/19
to sage-...@googlegroups.com
On 8/12/19 11:45 PM, Travis Scrimshaw wrote:
>
> > I guess FiniteDimensionalAlgebrasWithBasis has both the old
> Algebras()
> > and the new MagmaticAlgebras() as supercategories? That would explain
> > why I'm seeing associativity and rings everywhere.
> >
>
> ...and building up a pile of non-associative categories one-at-a-time
> doesn't work either, of course =)
>
> MagmaticAlgebras has been around for quite some time. At some point,
> there is a plan to make Algebras to not assume associativity in order to
> be more explicit. Also, Algebras is not "old" and not going away.

I was basing that on the comment in categories/algebras.py:

.. WARNING::

:class:`Algebras` will be eventually be replaced by
:class:`.magmatic_algebras.MagmaticAlgebras`
for consistency with e.g. :wikipedia:`Algebras` which assumes
neither associativity nor the existence of a unit (see
:trac:`15043`).

Although if Algebras becomes not-necessarily-associative, then
"Algebras" is a nicer name for the thing, much like FreeModule is nicer
than CombinatorialFreeModule.


> However, as you said, FiniteDimensionalAlgebrasWithBasis has Algebras as
> a basis, and so it is associative. For the analogous thing, you want
> MagmaticAlgebras(R).FiniteDimensional().WithBasis() (maybe also
> .Unital() added too). However, this will be a more generic join
> category. If some of the methods currently in the associative version
> still apply, you should create the corresponding category and move those
> methods to this category. Does that clarify things?

My main issue was just figuring out where the categories were coming
from. I didn't realize that FiniteDimensionalAlgebrasWithBasis had BOTH
Algebras and MagmaticAlgebras as super-categories. (Reading the source
in categories/finite_dimensional_algebras_with_basis.py, I still can't
figure out where those two come from). From the warning I quoted above,
I was probably thinking that they were mutually exclusive. Now that I
know they're both super-categories, the other super-categories sense.

I should be able to work out the hierarchy eventually. I'm sure that
many of the methods in the FDAWB class apply more generally to an e.g.
power-associative algebra, but I haven't gotten there yet. Thanks for
your help.
Reply all
Reply to author
Forward
0 new messages