monoid¶
Monoid¶
Monoid
Mathematically a Monoid is a Semigroup M such that
(∃u ∈ M) => (∀m ∈ M)(u*m = m*u = m)
When such an identity element u exists, it is necessarily unique.
Important
Contract: Monoid initializer parameters must have
mult closed and associative on reps
one an identity on reps,
rep*one == rep == one*rep
- class boring_math.abstract_algebra.algebras.monoid.Monoid¶
-
- __init__(mult: Callable[[H, H], H], one: H, narrow: Callable[[H], H] | None = None)¶
init
- param mult:
Associative function
H X H -> Hon representations.- param one:
Representation for multiplicative 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.monoid.MonoidElement¶
Bases:
SemigroupElement,Generic- __init__(rep: H, algebra: Monoid[H]) None¶
init
- param rep:
Representative to to narrow when adding element.
- param algebra:
Monoid to add element to.
- __str__() str¶
user string
Construct the string ‘MonoidElement<rep_str>’ where rep_str = str(rep>.
- returns:
A string meaningful to an end user.
- __pow__(n: int) Self¶
pow
Raise the element to power to the power of
n>=0.- param n:
The integer power to raise the element to.
- returns:
The element (or its inverse) raised to the integer
npower.- raises TypeError:
If
selfandotherare different types.- raises ValueError:
If
selfandotherare same type but different concrete monoids.- raises ValueError:
If algebra fails to have an identity element.