commutative semigroup¶
Commutative Semigroup¶
Commutative Semigroup
Mathematically a Commutative Semigroup is a set S along with an
associative binary operation + such that
(∀x ∈ S)(∀y ∈ S)(∀z ∈ S) => (x+(y+z)) = ((x+y)+z)
Important
Contract: Group initializer parameters must have
add closed, commutative and associative on reps
- class boring_math.abstract_algebra.algebras.commutative_semigroup.CommutativeSemigroup¶
- class boring_math.abstract_algebra.algebras.commutative_semigroup.CommutativeSemigroupElement¶
Bases:
BaseElement,Generic- __init__(rep: H, algebra: CommutativeSemigroup[H]) None¶
abstract base class for algebra element
- param rep:
Coset element to be narrowed to a representative.
- param algebra:
Algebra to which element belongs
- __str__() str¶
user string
Construct the string ‘CommutativeSemigroupElement<rep_str>’ where rep_str = str(rep).
- returns:
A string meaningful to an end user.
- __add__(right: Self) Self¶
add
Add two elements of the same concrete algebra together.
- param other:
Another element within the same algebra.
- returns:
The sum
self + other.- raises ValueError:
If
selfandotherare same type but different concrete algebras.- raises TypeError:
If Addition not defined on the algebra of the elements.
- raises TypeError:
If
selfandrightare different types.
- __radd__(left: Self) Self¶
radd
When left side of addition does not know how to add right side.
- param other:
Left side of the addition.
- returns:
Never returns, otherwise
left.__add__(right)would have worked.- raises TypeError:
When right side does not know how to add the left side to itself.
- __mul__(n: object) Self¶
mul
Repeatedly add an element to itself n > 0 times.
- param n:
Object, usually a positive int or action.
- returns:
If n: int then self added to itself n times else NotImplemented.
- raises ValueError:
When n <= 0.
- raises ValueError:
If self and other are same type but different concrete algebras.
- raises TypeError:
If an add method was not defined on the algebra.
- raises TypeError:
Element multiplication attempted but algebra is not multiplicative.