Path: blob/master/sage/categories/commutative_algebras.py
4097 views
r"""1Commutative algebras2"""3#*****************************************************************************4# Copyright (C) 2005 David Kohel <[email protected]>5# William Stein <[email protected]>6# 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>7#8# Distributed under the terms of the GNU General Public License (GPL)9# http://www.gnu.org/licenses/10#******************************************************************************1112from sage.misc.cachefunc import cached_method13from category_types import Category_over_base_ring14from algebras import Algebras15from commutative_rings import CommutativeRings1617class CommutativeAlgebras(Category_over_base_ring):18"""19The category of commutative algebras with unit over a given base ring.2021EXAMPLES::2223sage: M = CommutativeAlgebras(GF(19))24sage: M25Category of commutative algebras over Finite Field of size 192627TESTS::2829sage: TestSuite(CommutativeAlgebras(ZZ)).run()3031Todo:3233- product ( = cartesian product)34- coproduct ( = tensor product over base ring)35"""363738def __contains__(self, A):39"""40EXAMPLES::4142sage: QQ['a'] in CommutativeAlgebras(QQ)43True44sage: QQ['a,b'] in CommutativeAlgebras(QQ)45True46sage: FreeAlgebra(QQ,2,'a,b') in CommutativeAlgebras(QQ)47False4849TODO: get rid of this method once all commutative algebras in50Sage declare themselves in this category51"""52return super(CommutativeAlgebras, self).__contains__(A) or \53(A in Algebras(self.base_ring()) and hasattr(A, "is_commutative") and A.is_commutative())5455@cached_method56def super_categories(self):57"""58EXAMPLES::5960sage: CommutativeAlgebras(QQ).super_categories()61[Category of algebras over Rational Field, Category of commutative rings]62"""63R = self.base_ring()64return [Algebras(R), CommutativeRings()]656667