semigroup

Semigroup

Mathematically a Semigroup is a set S along with an associative binary operation mult: S X S -> S.

Important

Contract: Semigroup initializer parameters must have

  • mult closed and associative on reps

class boring_math.abstract_algebra.algebras.semigroup.Semigroup(mult: ~collections.abc.Callable[[H, H], H], process: ~collections.abc.Callable[[H], H] = <function Semigroup.<lambda>>)
Parameters:

mult – Associative function H X H -> H on representations.

Returns:

A semigroup algebra.

__init__(mult: ~collections.abc.Callable[[H, H], H], process: ~collections.abc.Callable[[H], H] = <function Semigroup.<lambda>>) None
Parameters:

mult – Associative function H X H -> H on representations.

Returns:

A semigroup algebra.

__call__(rep: H) SemigroupElement

Add the unique element to the semigroup 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.semigroup.SemigroupElement(rep: H, algebra: Semigroup[H])
__init__(rep: H, algebra: Semigroup[H]) None
__mul__(other: object) Self

Multiply two elements of the same concrete semigroup together.

Parameters:

other – Another element within the same semigroup.

Returns:

The product self * other.

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

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

__rmul__(other: object) Self

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

Parameters:

other – Left side of the multiplication.

Returns:

NotImplemented, otherwise left.__mul__(right) would have worked.

Raises:

TypeError – When multiplying on left by an int.

__pow__(n: int) Self

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

Parameters:

n – Multiply semigroup element to itself n > 0 times.

Returns:

The product of the semigroup element n times.

Raises:
  • ValueError – When n <= 0.

  • ValueError – If for some reason a mult method was not defined on the semigroup.