Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/categories/commutative_algebras.py
4097 views
1
r"""
2
Commutative algebras
3
"""
4
#*****************************************************************************
5
# Copyright (C) 2005 David Kohel <[email protected]>
6
# William Stein <[email protected]>
7
# 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
8
#
9
# Distributed under the terms of the GNU General Public License (GPL)
10
# http://www.gnu.org/licenses/
11
#******************************************************************************
12
13
from sage.misc.cachefunc import cached_method
14
from category_types import Category_over_base_ring
15
from algebras import Algebras
16
from commutative_rings import CommutativeRings
17
18
class CommutativeAlgebras(Category_over_base_ring):
19
"""
20
The category of commutative algebras with unit over a given base ring.
21
22
EXAMPLES::
23
24
sage: M = CommutativeAlgebras(GF(19))
25
sage: M
26
Category of commutative algebras over Finite Field of size 19
27
28
TESTS::
29
30
sage: TestSuite(CommutativeAlgebras(ZZ)).run()
31
32
Todo:
33
34
- product ( = cartesian product)
35
- coproduct ( = tensor product over base ring)
36
"""
37
38
39
def __contains__(self, A):
40
"""
41
EXAMPLES::
42
43
sage: QQ['a'] in CommutativeAlgebras(QQ)
44
True
45
sage: QQ['a,b'] in CommutativeAlgebras(QQ)
46
True
47
sage: FreeAlgebra(QQ,2,'a,b') in CommutativeAlgebras(QQ)
48
False
49
50
TODO: get rid of this method once all commutative algebras in
51
Sage declare themselves in this category
52
"""
53
return super(CommutativeAlgebras, self).__contains__(A) or \
54
(A in Algebras(self.base_ring()) and hasattr(A, "is_commutative") and A.is_commutative())
55
56
@cached_method
57
def super_categories(self):
58
"""
59
EXAMPLES::
60
61
sage: CommutativeAlgebras(QQ).super_categories()
62
[Category of algebras over Rational Field, Category of commutative rings]
63
"""
64
R = self.base_ring()
65
return [Algebras(R), CommutativeRings()]
66
67