ring

Ring

Ring

Mathematically a Ring is an abelian group under addition and a Monoid under multiplication. The additive and multiplicative identities are denoted one and zero respectfully.

By convention one != zero, otherwise the algebra consists of just one unique element.

Important

Contract: Ring initializer parameters must have

  • add closed, commutative and associative on reps

  • mult closed and associative on reps

  • one an identity on reps, rep*one == rep == one*rep

  • zero an identity on reps, rep+zero == rep == zero+rep

  • negate maps rep -> -rep, rep + negate(rep) == zero

  • zero != one

class boring_math.abstract_algebra.algebras.ring.Ring

Bases: AbelianGroup, Generic

__init__(add: Callable[[H, H], H], mult: Callable[[H, H], H], one: H, zero: H, negate: Callable[[H], H], narrow: Callable[[H], H] | None = None)
Parameters:
  • add – Closed commutative and associative function reps.

  • mult – Closed associative function reps.

  • one – Representation for multiplicative identity.

  • zero – Representation for additive identity.

  • negate – Function mapping element representation to the representation of corresponding negated element.

  • 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.ring.RingElement

Bases: AbelianGroupElement, Generic

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

str(self) = RingElement<rep>

__mul__(right: object) → Self

Left multiplication for * operator.

Parameters:

right – Object left should be an element of same concrete algebra or an int.

Returns:

Algebra product, the sum of the element right times, or NotImplemented.

Raises:
  • ValueError – If either right not an element of the same concrete algebra or right: int < 0.

  • TypeError – Multiplication nor defined on the algebra that self is a member of.

__rmul__(left: object) → Self

Right multiplication for * operator.

Parameters:

left – Object left should be an int.

Returns:

The sum of the element left times.

Raises:

TypeError – If object on left does not act on object on right

__pow__(n: int) → Self

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

Parameters:

n – The int power to raise the element to.

Returns:

The element raised to the non-negative integer n power.

Raises:
  • ValueError – If algebra is not multiplicative.

  • ValueError – If algebra does not have a multiplicative identity element.

  • ValueError – If n < 0.