EP-0192: Unifying Domain Objects with the Pure Algebraic Hierarchy¶
| Field | Value |
|---|---|
| EP | 0192 |
| Title | Unifying Domain Objects with the Pure Algebraic Hierarchy |
| Author | Eran Rivlis & Antigravity |
| Sponsor | Council Framework |
| Delegate | ⚖️ Noether (Algebraic Invariants) & 🧩 Russell (Taxonomy) |
| Status | Final |
| Type | Standards Track |
| Created | 2026-10-27 |
| Updated | 2026-10-28 |
Abstract¶
This proposal establishes a bridge between AlgebraX's domain-specific mathematical engines (Lie theory in
algebrax.lie, algebraic topology in algebrax.topology, geometric algebra in algebrax.clifford, and polynomials in
algebrax.semiring) and the pure algebraic protocol hierarchy established
in EP-0190
and EP-0191. By equipping domain objects—specifically LieAlgebra,
CliffordSemiring, PolynomialSemiring, DualNumberSemiring, and Cochain—with standard protocol methods (add,
sub, neg, smul, mul, zero, one), these structures become first-class algebraic typeclass operators while
preserving 100% of their existing capabilities, collaborator semiring compatibility, and unboxed sparse dictionary
representations.
Following unanimous Council review (Noether, Popper, Shannon, The Golem, Feynman, Russell, The Explorer), this proposal incorporates single-pass vector arithmetic, explicit simplicial complex anchoring for cochain unitality, dedicated non-associative and Lie algebra law verifiers, and tolerance-consistent zero-cleaning.
Motivation¶
AlgebraX has evolved across multiple developmental phases:
- Phase 1–2: Foundations and specialized domains (
homology,clifford,galois,category). - Phase 4: Continuous symmetries and higher topology (
lie,topology.cohomology,dec). - Phase 6: Pure algebraic protocols (
algebrax.algebra—magmas, monoids, groups, rings, fields, modules, algebras).
Because domain packages were built before the Phase 6 algebraic protocols existed, a significant structural disconnect emerged:
- Isolated Operator Interfaces:
LieAlgebraimplementsbracket(x, y)andadjoint_matrix(x), but has noadd(a, b),smul(r, m), ormul(a, b)methods. To add or scale Lie elements, users must manually locate and invoke external functions (vec_add,vec_scale). - Artificial Demotion of True Rings and Algebras:
PolynomialSemiringandCliffordSemiringmask as mereSemirings because they were written beforeRingandAlgebraexisted in AlgebraX. Neither exposes.neg()or.sub(), even though multivectors and polynomials natively admit additive inverses.- Dual numbers \(a + b\epsilon\) (\(\epsilon^2 = 0\)) form a commutative ring with nilpotents for automatic differentiation,
but are constrained to
DualNumberSemiring.
- Barriers to Generic Collaborators: Functions like
power(algebra, x, n)(logarithmic binary exponentiation),zsmul(module, r, x), andverify_algebra_lawscannot operate directly onLieAlgebraorCliffordSemiringbecause the objects do not expose the required protocol methods. - Under-formalized Topological Ring Structure: In simplicial cohomology, discrete \(k\)-forms (
Cochain) form a graded \(R\)-algebra under the Alexander–Whitney cup product (\(\smile\)). Currently,cup_productis an external standalone function, preventing cochains from participating in generic ring or module pipelines.
Binding these domain structures to algebrax.algebra protocols resolves these discrepancies, completing the unification
of AlgebraX.
The Mental Model (The Freshman Test)¶
- The Universal Arithmetic Rule: If an object represents mathematical entities that can be added, scaled, and
multiplied (like Lie algebra vectors, polynomials, or Clifford multivectors), the object itself should provide
.add(),.smul(),.mul(), and.zero. - Domain-Specific Multiplications:
- In
LieAlgebra,.mul(a, b)is the Lie bracket \([a, b] = ab - ba\) (alternating, non-associative, Jacobi-satisfying). - In
CliffordAlgebra,.mul(a, b)is the geometric product \(ab = a \cdot b + a \wedge b\). - In
CochainAlgebra,.mul(a, b)is the Alexander–Whitney cup product \(a \smile b\). - Generalization Without Loss: Upgrading
CliffordSemiringtoCliffordAlgebradoes not remove its ability to act as a semiring. BecauseCliffordAlgebraandPolynomialRinginherit fromQuotientMonoidAlgebraSemiring(which suppliesstar()), they satisfy both theAlgebra/Ringprotocol and theSemiringprotocol simultaneously. They are immediately usable anywhere a collaborator semiring is expected (e.g. in sparse matrix multiplicationdot(A, B, semiring=CliffordAlgebra())).
Rationale & Council Alignment¶
- ⚖️ Noether (Algebraic Invariants & Structural Conservation):
- Formally realizes Lie algebras as the canonical non-associative algebra (\(\mathfrak{g}\) satisfies bilinearity, antisymmetry, and the Jacobi identity).
- Ensures
PolynomialRing.negdelegates to the underlying coefficient ring's.neg()method, preserving canonical residues in finite modular fields \(\mathbb{Z}_p\). - Identifies that
CochainAlgebrarequires an underlyingSimplicialComplexto define the multiplicative unit \(\mathbf{1} \in C^0(K; R)\) evaluating to \(1_R\) on all 0-simplices.
- 🔬 Popper (Falsifiability & Empirical Invariants):
- Retracts the claim that
LieAlgebrasatisfiesverify_algebra_laws(which asserts unit \(\mathbf{1}\) and associativity, both of which Lie algebras lack). - Specifies dedicated verification engines:
verify_non_assoc_algebra_lawsandverify_lie_algebra_laws. - Eliminates "ghost blades" in floating-point multivector subtraction via uniform tolerance zero-cleaning (
tol=1e-14).
- Retracts the claim that
- ⚡ Shannon (Zero-Cost Delegation & Single-Pass Efficiency):
- Eliminates double-normalization and intermediate dictionary allocation by implementing single-pass
sub(a, b)viavec_axpy(a, b, -1.0)inLieAlgebra. - Implements direct elementwise subtraction in
CliffordAlgebraandPolynomialRingrather than chainingadd(a, neg(b)).\ - Preserves unboxed sparse dictionary carriers with zero heap overhead and zero-cost symbol aliases.
- Eliminates double-normalization and intermediate dictionary allocation by implementing single-pass
- 🛡️ The Golem (Type Safety & Invariant Containment):
- Corrects
CochainAlgebrato use nativeCochainoperator overloads (+,-,*) rather than non-existent helper functions. - Accurately demarcates the
Semiring.star()boundary under static type checking (mypy/pyright). - Enforces parameter contravariance and exact return types across all protocol implementations.
- Corrects
- 💡 Feynman (Freshman Test & Intuitive Demystification):
- Exposes the universal arithmetic interface (
.add(),.smul(),.mul()) while clearly documenting domain-specific meanings of.mul()(bracket, geometric product, cup product).
- Exposes the universal arithmetic interface (
- 🧩 Russell (Taxonomy & Deductive Consistency):
- Validates
LieAlgebraasNonAssocAlgebrawithout introducing redundant naming collisions. - Elevates
PolynomialAlgebraandDualNumberAlgebrato full algebras over their scalar bases with.smul(), while preserving single-sortedCommRingandSemiringcompatibility via exact aliases (*Ring,*Semiring). - Subclasses
DualNumberAlgebrafrom concreteDualNumberSemiringwhile declaringCommRingandAlgebra.
- Validates
- 🧭 The Explorer (Curiosity & Frontier Synthesis):
- Prepares the protocol substrate for Conformal Geometric Algebra (\(C\ell(4, 1)\)), Spacetime Algebra (\(C\ell(1, 3)\)), Jordan algebras, octonions, and Differential Graded Algebras (DGAs).
Specification¶
1. LieAlgebra as NonAssocAlgebra (src/algebrax/lie/core.py)¶
LieAlgebra inherits from NonAssocAlgebra[float | complex, LieElement]:
from collections.abc import Sequence
from algebrax.algebra import NonAssocAlgebra
from algebrax.matrix import vec_add, vec_axpy, vec_clean, vec_scale
LieElement = dict[int, float | complex]
class LieAlgebra(NonAssocAlgebra[float | complex, LieElement]):
...
@property
def zero(self) -> LieElement:
"""The additive zero element (empty sparse dictionary)."""
return {}
def add(
self,
a: Sequence[float | complex] | dict[int | str, float | complex],
b: Sequence[float | complex] | dict[int | str, float | complex],
) -> LieElement:
"""Vector addition: a + b."""
return vec_clean(vec_add(self._normalize_element(a), self._normalize_element(b)))
def neg(
self,
a: Sequence[float | complex] | dict[int | str, float | complex],
) -> LieElement:
"""Additive inverse (negation): -a."""
return vec_clean(vec_scale(self._normalize_element(a), -1.0))
def sub(
self,
a: Sequence[float | complex] | dict[int | str, float | complex],
b: Sequence[float | complex] | dict[int | str, float | complex],
) -> LieElement:
"""Vector difference: a - b (single-pass axpy, avoiding double normalization)."""
norm_a = self._normalize_element(a)
norm_b = self._normalize_element(b)
return vec_clean(vec_axpy(norm_a, norm_b, -1.0))
def smul(
self,
r: float | complex,
m: Sequence[float | complex] | dict[int | str, float | complex],
) -> LieElement:
"""Scalar multiplication: r * m."""
return vec_clean(vec_scale(self._normalize_element(m), r))
def mul(
self,
a: Sequence[float | complex] | dict[int | str, float | complex],
b: Sequence[float | complex] | dict[int | str, float | complex],
) -> LieElement:
"""Non-associative bilinear product [a, b]. Alias for self.bracket(a, b)."""
return self.bracket(a, b)
Type Conformance Guarantees:
- isinstance(lie, NonAssocAlgebra) \(\to\) True
- isinstance(lie, Module) \(\to\) True
- isinstance(lie, NonAssocRing) \(\to\) True
- isinstance(lie, Ring) \(\to\) False (Exact: Lie multiplication has no unit \(\mathbf{1}\))
- isinstance(lie, Algebra) \(\to\) False (Exact: Lie bracket is non-associative)
2. Generalizing CliffordSemiring to CliffordAlgebra (src/algebrax/clifford.py)¶
CliffordAlgebra is relocated to algebrax.clifford (with MonoidAlgebraSemiring and QuotientMonoidAlgebraSemiring in algebrax.algebra._monoid_algebra), inheriting cleanly from QuotientMonoidAlgebraSemiring[tuple[int, ...], float] and structurally satisfying Algebra[float, SparseVector[tuple[int, ...], float]] and Ring:
from algebrax.algebra._monoid_algebra import QuotientMonoidAlgebraSemiring
from algebrax.typing import SparseVector
class CliffordAlgebra(QuotientMonoidAlgebraSemiring[tuple[int, ...], float]):
r"""The Clifford Geometric Algebra $\mathcal{C}\ell(p, q, r)$ over $\mathbb{R}$."""
def neg(self, a: SparseVector[tuple[int, ...], float]) -> SparseVector[tuple[int, ...], float]:
"""Additive inverse of a multivector with zero-cleaning."""
return {k: -v for k, v in a.items() if abs(v) > 1e-14}
def sub(
self,
a: SparseVector[tuple[int, ...], float],
b: SparseVector[tuple[int, ...], float],
) -> SparseVector[tuple[int, ...], float]:
"""Direct elementwise difference: a - b (eliminates intermediate allocation)."""
result = dict(a)
for k, v in b.items():
diff = result.get(k, 0.0) - v
if abs(diff) > 1e-14:
result[k] = diff
elif k in result:
del result[k]
return result
def smul(self, r: float, m: SparseVector[tuple[int, ...], float]) -> SparseVector[tuple[int, ...], float]:
"""Scalar multiplication: r * m."""
if abs(r) <= 1e-14:
return {}
return {k: r * v for k, v in m.items() if abs(r * v) > 1e-14}
# Canonical backwards-compatible aliases (also re-exported in algebrax.semiring)
CliffordSemiring = CliffordAlgebra
GeneralizedCliffordSemiring = GeneralizedCliffordAlgebra
QuantumCliffordSemiring = QuantumCliffordAlgebra
3. Generalizing PolynomialSemiring to PolynomialAlgebra (src/algebrax/algebra/_polynomial.py)¶
Located in algebrax.algebra._polynomial, PolynomialAlgebra subclasses MonoidAlgebraSemiring[int, T] and implements coefficient-aware negation, subtraction, and scalar multiplication to structurally fulfill CommRing[SparseVector[int, T]] and Algebra[T, SparseVector[int, T]]:
from algebrax.algebra._monoid_algebra import MonoidAlgebraSemiring
from algebrax.typing import SparseVector
class PolynomialAlgebra(MonoidAlgebraSemiring[int, T]):
r"""The Univariate Polynomial Algebra and Commutative Ring $R[x]$ over coefficient ring $R$."""
def neg(self, a: SparseVector[int, T]) -> SparseVector[int, T]:
"""Negate coefficients, delegating to coefficient ring if available."""
neg_fn = getattr(self.coeff_semiring, 'neg', None)
zero = self.coeff_semiring.zero
if neg_fn is not None:
return {deg: neg_fn(c) for deg, c in a.items() if c != zero}
return {deg: -c for deg, c in a.items() if c != zero} # type: ignore[operator]
def sub(self, a: SparseVector[int, T], b: SparseVector[int, T]) -> SparseVector[int, T]:
"""Direct polynomial difference: a - b."""
neg_b = self.neg(b)
return self.add(a, neg_b)
def smul(self, r: T, m: SparseVector[int, T]) -> SparseVector[int, T]:
"""Scale polynomial by scalar r: r * (c0 + c1*x + ...) = (r*c0) + (r*c1)*x + ..."""
zero = self.coeff_semiring.zero
mul_fn = self.coeff_semiring.mul
if r == zero:
return {}
return {deg: prod for deg, c in m.items() if (prod := mul_fn(r, c)) != zero}
# Canonical backwards-compatible aliases (also re-exported in algebrax.semiring)
PolynomialRing = PolynomialAlgebra
PolynomialSemiring = PolynomialAlgebra
4. Generalizing DualNumberSemiring to DualNumberAlgebra (src/algebrax/algebra/_dual.py)¶
Located in algebrax.algebra._dual, DualNumberAlgebra subclasses Semiring[tuple[float, float]] and structurally implements both CommRing[tuple[float, float]] and Algebra[float, tuple[float, float]]:
from algebrax.algebra._semiring import Semiring
class DualNumberAlgebra(Semiring[tuple[float, float]]):
r"""The Dual Number Algebra $\mathbb{R}[\varepsilon] / (\varepsilon^2)$ over $\mathbb{R}$."""
def neg(self, a: tuple[float, float]) -> tuple[float, float]:
"""Additive inverse: -(u + v*eps) = -u - v*eps."""
return (-a[0], -a[1])
def sub(self, a: tuple[float, float], b: tuple[float, float]) -> tuple[float, float]:
"""Difference: (u1 - u2, v1 - v2)."""
return (a[0] - b[0], a[1] - b[1])
def smul(self, r: float, m: tuple[float, float]) -> tuple[float, float]:
"""Stretch dual number by real scalar r: r * (u, v) = (r*u, r*v)."""
return (r * m[0], r * m[1])
# Canonical backwards-compatible aliases (also re-exported in algebrax.semiring)
DualNumberRing = DualNumberAlgebra
DualNumberSemiring = DualNumberAlgebra
[!NOTE] Dual Multi-Protocol Conformance:
DualNumberAlgebrasimultaneously satisfiesSemiring[tuple[float, float]](preservingstar()for sparse matrix operations),CommRing[tuple[float, float]](providing additive inverses and cancellation), andAlgebra[float, tuple[float, float]](providing scalar scalingsmulover \(\mathbb{R}\)). Because \(\varepsilon^2 = 0\), dual numbers contain nilpotent zero divisors (\((0, b)^2 = (0, 0)\)) and therefore form a commutative ring and algebra, but not aDivisionRingorField.
5. CochainAlgebra over Simplicial Complexes (src/algebrax/topology/cohomology.py)¶
CochainAlgebra anchors to the underlying SimplicialComplex to construct the canonical multiplicative unit \(\mathbf{1}\):
from algebrax.algebra import Algebra, Ring
from algebrax.topology.cohomology import Cochain, cup_product
from algebrax.topology.homology import SimplicialComplex
class CochainAlgebra(Algebra[V, Cochain[K, V]]):
r"""Associative differential graded algebra of simplicial cochains under the
Alexander-Whitney cup product $\smile$.
"""
def __init__(self, complex: SimplicialComplex, coefficient_ring: Ring[V]):
self._complex = complex
self._ring = coefficient_ring
@property
def zero(self) -> Cochain[K, V]:
return Cochain({})
@property
def one(self) -> Cochain[K, V]:
"""Canonical 0-cochain assigning 1_R to every 0-simplex (vertex) in K_0."""
return Cochain({(v,): self._ring.one for v in self._complex.vertices})
def add(self, a: Cochain[K, V], b: Cochain[K, V]) -> Cochain[K, V]:
return a + b
def neg(self, a: Cochain[K, V]) -> Cochain[K, V]:
return -a
def sub(self, a: Cochain[K, V], b: Cochain[K, V]) -> Cochain[K, V]:
return a - b
def smul(self, r: V, m: Cochain[K, V]) -> Cochain[K, V]:
return m * r
def mul(self, a: Cochain[K, V], b: Cochain[K, V]) -> Cochain[K, V]:
r"""Alexander-Whitney cup product: a \smile b."""
return cup_product(a, b)
6. Verification Engine Additions (src/algebrax/verification.py)¶
Add dedicated verification functions tailored to non-unital and non-associative structures:
def verify_non_assoc_algebra_laws(
algebra: NonAssocAlgebra[R, M],
ring: Ring[R],
r_samples: Iterable[R],
m_samples: Iterable[M],
tol: float = 1e-7,
) -> dict[str, bool]:
"""Test Non-Associative Algebra laws:
- Module laws over ring R
- NonAssocRing laws on M (abelian group + two-sided distributivity)
- Scalar bilinearity: r * (a * b) == (r * a) * b == a * (r * b)
"""
...
def verify_lie_algebra_laws(
lie: NonAssocAlgebra[R, LieElement],
ring: Ring[R],
r_samples: Iterable[R],
m_samples: Iterable[LieElement],
tol: float = 1e-7,
) -> dict[str, bool]:
"""Test Lie Algebra axioms:
- NonAssocAlgebra laws (Module + distributivity + bilinearity)
- Skew-symmetry: [x, x] == 0 and [x, y] == -[y, x]
- Jacobi Identity: [x, [y, z]] + [y, [z, x]] + [z, [x, y]] == 0
"""
...
Backwards Compatibility¶
- 100% Symbol Preservation:
CliffordSemiring,PolynomialSemiring, andDualNumberSemiringremain available as exact aliases toCliffordAlgebra,PolynomialAlgebra, andDualNumberAlgebra.PolynomialRingandDualNumberRingare also provided as canonical aliases.- All existing methods (
bracket,adjoint_matrix,killing_form,bch,power,star) remain unmodified.
- Collaborator Semiring Interoperability:
CliffordAlgebra,PolynomialAlgebra, andDualNumberAlgebrainherit from their respective base semirings, which implementstar().- They pass all type checks for
Semiringand function seamlessly inmatrix.dot(..., semiring=...).
How to Teach This / Documentation Plan¶
- User Guide Integration:
- Add unified arithmetic examples across domain guides (
guide/algebra/clifford_geometric_algebra.md,guide/algebra/lie_algebras.md,guide/algebra/polynomials_and_quotients.md). - Explain domain
.mul()semantics (Lie bracket, geometric product, cup product) using Feynman's 4-Beat Arc.
- Add unified arithmetic examples across domain guides (
- The "Every Algebra is a Ring" Principle:
- Teach how upgrading from Semiring to Algebra unlocks additive cancellation and vector scaling without breaking sparse matrix multiplication pipelines.
Reference Implementation¶
A prototype verification test on LieAlgebra confirmed:
so3 = so_n(3)
assert isinstance(so3, NonAssocAlgebra)
assert isinstance(so3, Module)
assert isinstance(so3, NonAssocRing)
assert not isinstance(so3, Ring)
assert not isinstance(so3, Algebra)
Rejected Ideas¶
- Asserting
LieAlgebrasatisfiesverify_algebra_laws:- Rejected:
verify_algebra_lawsasserts a multiplicative identity \(\mathbf{1}\) and associativity, both of which Lie algebras lack. Corrected toverify_non_assoc_algebra_lawsandverify_lie_algebra_laws.
- Rejected:
- Instantiating
CochainAlgebrawithout aSimplicialComplex:- Rejected: Without the vertex set \(K_0\), the multiplicative identity \(\mathbf{1}\) under the cup product cannot
be constructed, violating the
Algebraprotocol.
- Rejected: Without the vertex set \(K_0\), the multiplicative identity \(\mathbf{1}\) under the cup product cannot
be constructed, violating the
- Chaining
add(a, neg(b))for vector subtraction:- Rejected: Generates intermediate dictionary allocations and double normalization passes. Replaced with single-pass
vec_axpy.
- Rejected: Generates intermediate dictionary allocations and double normalization passes. Replaced with single-pass
Open Questions¶
- [x] Should
GeneralizedCliffordSemiringandQuantumCliffordSemiringalso be aliased to*Algebra? (Resolved: Yes). - [x] Should
LieAlgebraexpose.bracketas primary withmul = bracket? (Resolved: Yes).
Change Log¶
- 2026-10-28:
- Implemented and transitioned to
Final. All domain algebraic protocol conformances, arithmetic methods,CochainAlgebra, and verification routines (verify_non_assoc_algebra_laws,verify_lie_algebra_laws) verified with 100% test coverage and full backwards compatibility.
- Implemented and transitioned to
- 2026-10-27:
- Initial Draft authored by Eran Rivlis & Antigravity following Grand Council review of EP-0191.
- Council Review Amendments: Single-pass
sub(a, b)usingvec_axpy, explicitSimplicialComplexanchoring forCochainAlgebra, dedicatedverify_lie_algebra_laws, coefficient-awarePolynomialAlgebra.neg, and multi-protocolAlgebra&CommRingelevation forDualNumberAlgebraandPolynomialAlgebra(with*Ringand*Semiringaliases).