semigroup

Semigroup

Semigroup

Mathematically a Semigroup is a set S along with an associative binary operation * such that

(∀x S)(∀y S)(∀z S) => (x*(y*z)) = ((x*y)*z)

Important

Contract: Semigroup initializer parameters must have

  • mult closed and associative on reps

class boring_math.abstract_algebra.algebras.semigroup.Semigroup

Bases: BaseSet, Generic

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

  • 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], narrow: Callable[[H], H] | None = None) None
Parameters:
  • mult – Associative function H X H -> H on reps.

  • 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.semigroup.SemigroupElement

Bases: BaseElement, Generic

__init__(rep: H, algebra: Semigroup[H]) None
__str__() str
Returns:

str(self) = SemigroupElement<rep>

__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.

__pow__(n: int) Self

Raising element to a positive int power is the same as repeated multiplication.

Parameters:

n – Multiply element to itself n > 0 times.

Returns:

The product of the element n times.

Raises:
  • ValueError – When n <= 0.

  • ValueError – If algebra does not have a mult attribute.