commutative monoid¶
Commutative Monoid¶
Commutative Monoid
Mathematically a commutative Monoid is a Semigroup M along with
an identity element u, such that
(∃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¶
Bases:
CommutativeSemigroup,Generic- __init__(add: Callable[[H, H], H], zero: H, narrow: Callable[[H], H] | None = None)¶
init
- param add:
Closed commutative and associative function reps.
- param zero:
Representation for additive identity.
- param narrow:
Narrow the rep type, many-to-one function. Like choosing an element from a coset of a group.
- class boring_math.abstract_algebra.algebras.commutative_monoid.CommutativeMonoidElement¶
Bases:
CommutativeSemigroupElement,Generic- __init__(rep: H, algebra: CommutativeMonoid[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 string ‘CommutativeMonoidElement<rep_str>’ where rep_str = str(rep).
- returns:
A string meaningful to an end user.
- __mul__(n: object) Self¶
mul
Repeatedly add an element to itself
n >= 0times.- param n:
Object, usually a non-negative
intor action.- returns:
If
n: intthen self added to itself n times else NotImplemented.- raises ValueError:
When
n < 0.- raises ValueError:
If
selfandotherare same type but different concrete algebras.- raises TypeError:
If algebra fails to have an additive identity element or an addition method.