algebras

Abstract Algebras Representations

Infrastructure for implementing concrete representations for abstract algebras of various types.

Protocols

class boring_math.abstract_algebra.algebras.NaturalMapping

Bases: Sized, Iterable, Container, Protocol, Generic

natural mapping

Similar to the collections/abc.Mapping protocol, NaturalMapping supports read-only access to dict-like objects which can be extended in a “natural” deterministic way.

Abstract Base Classes

class boring_math.abstract_algebra.algebras.BaseSet

Bases: ABC, Generic

__init__(narrow: Callable[[H], H] | None = None) → None
abstractmethod __call__(rep: H) → BaseElement

add element

Add the unique element to the concrete algebra with the given, perhaps narrowed, rep in a uniquely deterministic way.

param rep:

Representation to add if not already present.

returns:

The unique element added.

__eq__(right: object) → bool

equality comparison

param right:

Object being compared to.

returns:

True only if right is the same concrete algebra.

narrow_rep_type(rep: H) → H

Narrow the rep with a concrete algebra’s many-to-one “narrowing” function.

param rep:

Hashable value of type H.

returns:

The narrowed coset representative.

class boring_math.abstract_algebra.algebras.BaseElement

Bases: ABC, Generic

__init__(rep: H, algebra: BaseSet[H]) → None

abstract base class for algebra element

param rep:

Coset element to be narrowed to a representative.

param algebra:

Algebra to which element belongs

abstractmethod __str__() → str

Return str(self).

__call__() → H

call

returns:

A reference to the element’s representation

Warning

A trade off is being made in favor of efficiency over encapsulation. An actual reference to the wrapped rep is returned to eliminate the overhead of a copy.

__eq__(right: object) → bool

equality comparison

param right:

Object to be compared with.

returns:

True if both are algebra elements and the reps compare as equal and are of the same invariant type.

Warning

Elements not necessarily from the same algebra.

Also, any sort of difference in rep narrowing is not taken into consideration.

algebra modules