commutative monoid¶
Commutative Monoid
Mathematically a commutative Monoid is a Semigroup M along with an identity element u, that is (∃u ∈ M) => (∀m ∈ M)(u+m = m+u = m).
When such an identity element u exists, it is necessarily unique.
Important
Contract: Commutative Monoid initializer parameters must have
add closed commutative and associative on reps
zero an identity on reps,
rep+zero == rep == zero+rep
- class boring_math.abstract_algebra.algebras.commutative_monoid.CommutativeMonoid(add: ~collections.abc.Callable[[H, H], H], zero: H, process: ~collections.abc.Callable[[H], H] = <function CommutativeMonoid.<lambda>>)¶
- Parameters:
add – Closed commutative and associative function reps.
zero – Representation for additive identity.
- Returns:
A commutative monoid algebra.
- __init__(add: ~collections.abc.Callable[[H, H], H], zero: H, process: ~collections.abc.Callable[[H], H] = <function CommutativeMonoid.<lambda>>)¶
- Parameters:
add – Closed commutative and associative function reps.
zero – Representation for additive identity.
- Returns:
A commutative monoid algebra.
- __call__(rep: H) CommutativeMonoidElement¶
Add the unique element to the monoid with a given rep.
- Parameters:
rep – Representation to add if not already present.
- Returns:
The unique element with that representation.
- class boring_math.abstract_algebra.algebras.commutative_monoid.CommutativeMonoidElement(rep: H, algebra: CommutativeMonoid[H])¶
- __init__(rep: H, algebra: CommutativeMonoid[H]) None¶
- __str__() str¶
Return str(self).
- __mul__(n: int | Self) Self¶
Repeatedly add a commutative monoid element
n>=0times.- Parameters:
n – The number of times to add the element to itself.
- Returns:
The element added to its additive identity
ntimes.- Raises:
TypeError – If
selfandotherare different types.ValueError – If
selfandotherare same type but different concrete algebras.ValueError – If algebra fails to have an additive identity element.