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

Bases: Semigroup, Generic

Parameters:
  • mult – Associative function H X H -> H on representations.

  • one – Representation for multiplicative identity.

  • narrow – Narrow the rep type, many-to-one function. Like choosing an element from a coset of a group.

__init__(mult: Callable[[H, H], H], one: H, narrow: Callable[[H], H] | None = None)
Parameters:
  • mult – Associative function H X H -> H on representations.

  • one – Representation for multiplicative identity.

  • 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
__str__() str
Returns:

str(self) = MonoidElement<rep>

__pow__(n: int) Self

Raise the element to power to the power of n>=0.

Parameters:

n – The int power to raise the element to.

Returns:

The element (or its inverse) raised to the integer n power.

Raises:
  • TypeError – If self and other are different types.

  • ValueError – If self and other are same type but different concrete groups.

  • ValueError – If algebra fails to have an identity element.

__mul__(right: object) Self

Multiply two elements of the same concrete algebra together.

Parameters:

right – An element within the same concrete algebra or a right action.

Returns:

The product self * right otherwise NotImplemented.

Raises:

ValueError – If self and right are same type but different concrete algebras.

__rmul__(left: object) Self

When left side of multiplication does not know how to multiply right side.

Parameters:

left – Left side of the multiplication.

Returns:

Never returns, otherwise left.__mul__(right) would have worked.

Raises:

TypeError – When multiplying on left by an int.