monoid

Monoid

Mathematically a 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: 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(mult: ~collections.abc.Callable[[H, H], H], one: H, process: ~collections.abc.Callable[[H], H] = <function Monoid.<lambda>>)
Parameters:
  • mult – Associative function H X H -> H on representations.

  • one – Representation for multiplicative identity.

Returns:

A monoid algebra.

__init__(mult: ~collections.abc.Callable[[H, H], H], one: H, process: ~collections.abc.Callable[[H], H] = <function Monoid.<lambda>>)
Parameters:
  • mult – Associative function H X H -> H on representations.

  • one – Representation for multiplicative identity.

Returns:

A monoid algebra.

__call__(rep: H) MonoidElement

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.monoid.MonoidElement(rep: H, algebra: Monoid[H])
__init__(rep: H, algebra: Monoid[H]) None
__str__() str

Return str(self).

__pow__(n: int) Self

Raise the group 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 an int 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.