An additive magma is a set endowed with a binary operation $$+$$.

EXAMPLES:

sage: AdditiveMagmas()
[Category of sets]
[Category of additive magmas, Category of sets, Category of sets with partial maps, Category of objects]


The following axioms are defined by this category:

sage: AdditiveMagmas().AdditiveAssociative()


TESTS:

sage: C = AdditiveMagmas()
sage: TestSuite(C).run()


TESTS:

sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>

sage: TestSuite(C).run()

class Algebras(category, *args)

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

extra_super_categories()

Implement the fact that the algebra of a commutative additive magmas is commutative.

EXAMPLES:

sage: AdditiveMagmas().AdditiveCommutative().Algebras(QQ).extra_super_categories()
[Category of commutative magmas]

[Category of additive magma algebras over Rational Field,
Category of commutative magmas]


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

extra_super_categories()

Implement the fact that a cartesian product of commutative additive magmas is a commutative additive magma.

EXAMPLES:

sage: C = AdditiveMagmas().AdditiveCommutative().CartesianProducts()
sage: C.extra_super_categories();
sage: C.axioms()


TESTS:

sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>

sage: TestSuite(C).run()


TESTS:

sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>

sage: TestSuite(C).run()

class CartesianProducts(category, *args)

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

extra_super_categories()

Implement the fact that a cartesian product of additive magmas with inverses is an additive magma with inverse.

EXAMPLES:

sage: C = AdditiveMagmas().AdditiveUnital().AdditiveInverse().CartesianProducts()
sage: C.extra_super_categories();
sage: sorted(C.axioms())


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ParentMethods
one_basis()

Return the zero of this additive magma, which index the one of this algebra, as per AlgebrasWithBasis.ParentMethods.one_basis().

EXAMPLES:

sage: S = CommutativeAdditiveMonoids().example(); S
An example of a commutative monoid: the free commutative monoid generated by ('a', 'b', 'c', 'd')
sage: A = S.algebra(ZZ)
sage: A.one_basis()
0
sage: A.one()
B[0]
sage: A(3)
3*B[0]


EXAMPLES:

sage: C = AdditiveMagmas().AdditiveUnital().Algebras(QQ)
sage: C.extra_super_categories()
[Category of unital magmas]

sage: C.super_categories()
[Category of unital algebras with basis over Rational Field, Category of additive magma algebras over Rational Field]


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ElementMethods
zero()

Returns the zero of this group

EXAMPLE:

sage: GF(8,'x').cartesian_product(GF(5)).zero()
(0, 0)


Implement the fact that a cartesian product of unital additive magmas is a unital additive magma.

EXAMPLES:

sage: C = AdditiveMagmas().AdditiveUnital().CartesianProducts()
sage: C.extra_super_categories();
sage: C.axioms()


Bases: sage.categories.homsets.HomsetsCategory

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ParentMethods
zero()

EXAMPLES:

sage: R = QQ['x']
sage: f = H.zero()
sage: f
Generic morphism:
From: Integer Ring
To:   Univariate Polynomial Ring in x over Rational Field
sage: f(3)
0
sage: f(3) is R.zero()
True


TESTS:

sage: TestSuite(f).run()

Implement the fact that a homset between two unital additive magmas is a unital additive magma.

EXAMPLES:

sage: AdditiveMagmas().AdditiveUnital().Homsets().extra_super_categories()

zero()

Return the zero of this additive magma, that is the unique neutral element for $$+$$.

The default implementation is to coerce 0 into self.

It is recommended to override this method because the coercion from the integers:

• is not always meaningful (except for $$0$$), and
• often uses self.zero() otherwise.

EXAMPLES:

sage: S = CommutativeAdditiveMonoids().example()
sage: S.zero()
0

zero_element()

Backward compatibility alias for self.zero().

TESTS:

sage: S = CommutativeAdditiveMonoids().example()
sage: S.zero_element()
0


Return the full subcategory of the additive inverse objects of self.

An inverse additive magma is a unital additive magma such that every element admits both an additive inverse on the left and on the right. Such an additive magma is also called an additive loop.

EXAMPLES:

sage: AdditiveMagmas().AdditiveUnital().AdditiveInverse()


TESTS:

sage: TestSuite(AdditiveMagmas().AdditiveUnital().AdditiveInverse()).run()


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ParentMethods
zero()

Return the zero of this unital additive magma.

This default implementation returns the zero of the realization of self given by a_realization().

EXAMPLES:

sage: A = Sets().WithRealizations().example(); A
The subset algebra of {1, 2, 3} over Rational Field
sage: A.zero.__module__
sage: A.zero()
0


TESTS:

sage: A.zero() is A.a_realization().zero()
True
sage: A._test_zero()


Return whether self is a structure category.

The category of unital additive magmas defines the zero as additional structure, and this zero shall be preserved by morphisms.

EXAMPLES:

sage: AdditiveMagmas().AdditiveUnital().additional_structure()


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ParentMethods
algebra_generators()

The generators of this algebra, as per MagmaticAlgebras.ParentMethods.algebra_generators().

They correspond to the generators of the additive semigroup.

EXAMPLES:

sage: S = CommutativeAdditiveSemigroups().example(); S
An example of a commutative monoid: the free commutative monoid generated by ('a', 'b', 'c', 'd')
sage: A = S.algebra(QQ)
sage: A.algebra_generators()
Finite family {0: B[a], 1: B[b], 2: B[c], 3: B[d]}

product_on_basis(g1, g2)

Product, on basis elements, as per MagmaticAlgebras.WithBasis.ParentMethods.product_on_basis().

The product of two basis elements is induced by the addition of the corresponding elements of the group.

EXAMPLES:

sage: S = CommutativeAdditiveSemigroups().example(); S
An example of a commutative monoid: the free commutative monoid generated by ('a', 'b', 'c', 'd')
sage: A = S.algebra(QQ)
sage: a,b,c,d = A.algebra_generators()
sage: a * b + b * d * c
B[c + b + d] + B[a + b]


EXAMPLES:

sage: AdditiveMagmas().Algebras(QQ).extra_super_categories()
[Category of magmatic algebras with basis over Rational Field]

[Category of magmatic algebras with basis over Rational Field, Category of set algebras over Rational Field]


TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

class ElementMethods

Implement the fact that a cartesian product of additive magmas is an additive magma.

EXAMPLES:

sage: C = AdditiveMagmas().CartesianProducts()
sage: C.extra_super_categories()
sage: C.super_categories()
[Category of additive magmas, Category of Cartesian products of sets]
sage: C.axioms()
frozenset()


Bases: sage.categories.homsets.HomsetsCategory

TESTS:

sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
...       _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()

extra_super_categories()

Implement the fact that a homset between two magmas is a magma.

EXAMPLES:

sage: AdditiveMagmas().Homsets().extra_super_categories()


Return a table describing the addition operation.

Note

The order of the elements in the row and column headings is equal to the order given by the table’s column_keys() method. The association can also be retrieved with the translation() method.

INPUT:

• names – the type of names used:
• 'letters' - lowercase ASCII letters are used for a base 26 representation of the elements’ positions in the list given by column_keys(), padded to a common width with leading ‘a’s.
• 'digits' - base 10 representation of the elements’ positions in the list given by column_keys(), padded to a common width with leading zeros.
• 'elements' - the string representations of the elements themselves.
• a list - a list of strings, where the length of the list equals the number of elements.
• elements – (default: None) A list of elements of the additive magma, in forms that can be coerced into the structure, eg. their string representations. This may be used to impose an alternate ordering on the elements, perhaps when this is used in the context of a particular structure. The default is to use whatever ordering the S.list method returns. Or the elements can be a subset which is closed under the operation. In particular, this can be used when the base set is infinite.

OUTPUT:

The addition table as an object of the class OperationTable which defines several methods for manipulating and displaying the table. See the documentation there for full details to supplement the documentation here.

EXAMPLES:

All that is required is that an algebraic structure has an addition defined.The default is to represent elements as lowercase ASCII letters.

sage: R=IntegerModRing(5)
+  a b c d e
+----------
a| a b c d e
b| b c d e a
c| c d e a b
d| d e a b c
e| e a b c d


The names argument allows displaying the elements in different ways. Requesting elements will use the representation of the elements of the set. Requesting digits will include leading zeros as padding.

sage: R=IntegerModRing(11)
sage: P
+   0  1  2  3  4  5  6  7  8  9 10
+---------------------------------
0|  0  1  2  3  4  5  6  7  8  9 10
1|  1  2  3  4  5  6  7  8  9 10  0
2|  2  3  4  5  6  7  8  9 10  0  1
3|  3  4  5  6  7  8  9 10  0  1  2
4|  4  5  6  7  8  9 10  0  1  2  3
5|  5  6  7  8  9 10  0  1  2  3  4
6|  6  7  8  9 10  0  1  2  3  4  5
7|  7  8  9 10  0  1  2  3  4  5  6
8|  8  9 10  0  1  2  3  4  5  6  7
9|  9 10  0  1  2  3  4  5  6  7  8
10| 10  0  1  2  3  4  5  6  7  8  9

sage: T
+  00 01 02 03 04 05 06 07 08 09 10
+---------------------------------
00| 00 01 02 03 04 05 06 07 08 09 10
01| 01 02 03 04 05 06 07 08 09 10 00
02| 02 03 04 05 06 07 08 09 10 00 01
03| 03 04 05 06 07 08 09 10 00 01 02
04| 04 05 06 07 08 09 10 00 01 02 03
05| 05 06 07 08 09 10 00 01 02 03 04
06| 06 07 08 09 10 00 01 02 03 04 05
07| 07 08 09 10 00 01 02 03 04 05 06
08| 08 09 10 00 01 02 03 04 05 06 07
09| 09 10 00 01 02 03 04 05 06 07 08
10| 10 00 01 02 03 04 05 06 07 08 09


Specifying the elements in an alternative order can provide more insight into how the operation behaves.

sage: S=IntegerModRing(7)
sage: elts = [0, 3, 6, 2, 5, 1, 4]
+  a b c d e f g
+--------------
a| a b c d e f g
b| b c d e f g a
c| c d e f g a b
d| d e f g a b c
e| e f g a b c d
f| f g a b c d e
g| g a b c d e f


The elements argument can be used to provide a subset of the elements of the structure. The subset must be closed under the operation. Elements need only be in a form that can be coerced into the set. The names argument can also be used to request that the elements be represented with their usual string representation.

sage: T=IntegerModRing(12)
sage: elts=[0, 3, 6, 9]
+  0 3 6 9
+--------
0| 0 3 6 9
3| 3 6 9 0
6| 6 9 0 3
9| 9 0 3 6


The table returned can be manipulated in various ways. See the documentation for OperationTable for more comprehensive documentation.

sage: R=IntegerModRing(3)
sage: T.column_keys()
(0, 1, 2)
sage: sorted(T.translation().items())
[('a', 0), ('b', 1), ('c', 2)]
sage: T.change_names(['x', 'y', 'z'])
sage: sorted(T.translation().items())
[('x', 0), ('y', 1), ('z', 2)]
sage: T
+  x y z
+------
x| x y z
y| y z x
z| z x y

summation(x, y)

Return the sum of x and y.

INPUT:

• x, y – elements of this additive magma

EXAMPLES:

sage: S = CommutativeAdditiveSemigroups().example()
sage: S.summation(a, b)
a + b


A parent in AdditiveMagmas() must either implement summation() in the parent class or _add_ in the element class. By default, the addition method on elements x._add_(y) calls S.summation(x,y), and reciprocally.

As a bonus effect, S.summation by itself models the binary function from S to S:

sage: bin = S.summation
sage: bin(a,b)
a + b


Here, S.summation is just a bound method. Whenever possible, it is recommended to enrich S.summation with extra mathematical structure. Lazy attributes can come handy for this.

Todo

Return the sum of x and y.

INPUT:

• x, y – elements of this additive magma

EXAMPLES:

sage: S = CommutativeAdditiveSemigroups().example()
sage: S.summation(a, b)
a + b


A parent in AdditiveMagmas() must either implement summation() in the parent class or _add_ in the element class. By default, the addition method on elements x._add_(y) calls S.summation(x,y), and reciprocally.

As a bonus effect, S.summation by itself models the binary function from S to S:

sage: bin = S.summation
sage: bin(a,b)
a + b


Here, S.summation is just a bound method. Whenever possible, it is recommended to enrich S.summation with extra mathematical structure. Lazy attributes can come handy for this.

Todo

Return the full subcategory of the additive associative objects of self.

An additive magma $$M$$ is associative if, for all $$x,y,z \in M$$,

$x + (y + z) = (x + y) + z$

EXAMPLES:

sage: AdditiveMagmas().AdditiveAssociative()


TESTS:

sage: TestSuite(AdditiveMagmas().AdditiveAssociative()).run()


Return the full subcategory of the commutative objects of self.

An additive magma $$M$$ is commutative if, for all $$x,y \in M$$,

$x + y = y + x$

EXAMPLES:

sage: AdditiveMagmas().AdditiveCommutative()
True


TESTS:

sage: TestSuite(AdditiveMagmas().AdditiveCommutative()).run()


Return the subcategory of the unital objects of self.

An additive magma $$M$$ is unital if it admits an element $$0$$, called neutral element, such that for all $$x \in M$$,

$0 + x = x + 0 = x$

This element is necessarily unique, and should be provided as M.zero().

EXAMPLES:

sage: AdditiveMagmas().AdditiveUnital()


TESTS:

sage: TestSuite(AdditiveMagmas().AdditiveUnital()).run()


EXAMPLES:

sage: AdditiveMagmas().super_categories()
[Category of sets]