algebras¶
Concrete representations of abstract algebras
Mathematically speaking, an Algebra is a set with a collection of closed n-ary operators. Usually 1 or 2 binary operations, 0 to 2 (partial) functions for inverses, and nullary functions for designated elements.
Element:
Elements know the concrete algebra to which they belong.
Each element wraps a hashable immutable representation, called a
rep.Binary operations like * and + can act on elements.
Not their representations.
Algebra:
Contains a dict of potential elements.
Can be used with potentially infinite or continuous algebras.
The dict is “quasi-immutable”.
Elements are added in a “natural” uniquely deterministic way.
Contain user defined functions and attributes to implement the algebra.
Functions take
refparameters and returnrefvalues.Attributes are
refvalued.
The idea is that
An element knows the concrete algebra to which it belongs.
Each element wraps a hashable representation, called a
rep.There is a one-to-one correspondence between
repvalues and elements.Algebra operations act on the elements themselves, not on the reps.
Algebras know how to manipulate the representations of their elements.