EP-0206: Coalgebras, Bialgebras & Hopf Algebras — Duality & Quantum Symmetries¶
| Field | Value |
|---|---|
| EP | 0206 |
| Title | Coalgebras, Bialgebras & Hopf Algebras — Duality & Quantum Symmetries |
| Author | Eran Rivlis eran@rivlis.info, Antigravity |
| Sponsor | Core Maintainers |
| Delegate | ⚖️ Noether (Antipodes & Conserved Duality) & ⚡ Shannon (Sparse Coproducts) |
| Status | Final |
| Type | Standards Track |
| Created | 2026-10-28 |
| Updated | 2026-11-13 |
| Replaces | — |
| Superseded-By | — |
Abstract¶
This proposal establishes Coalgebras, Bialgebras, and Hopf Algebras in algebrax.algebra, completing the
categorical arrow-reversal duality of algebraic structures. While an algebra formalizes combining elements
(\(A \otimes A \to A\)), a coalgebra formalizes splitting and decomposing elements (\(C \to C \otimes C\)). EP-0206
introduces:
- The Coalgebra Protocol (
Coalgebra[K, C]): Formalizing comultiplication \(\Delta: C \to C \otimes C\) and counit \(\epsilon: C \to K\) satisfying coassociativity and counitality. - The Bialgebra Protocol (
Bialgebra[K, B]): Combining algebra and coalgebra structures such that \(\Delta\) and \(\epsilon\) are algebra homomorphisms. - The Hopf Algebra Protocol (
HopfAlgebra[K, H]): Bialgebras equipped with an Antipode \(S: H \to H\) (the "quantum inverse") satisfying \(\mu \circ (S \otimes \mathrm{id}) \circ \Delta = \eta \circ \epsilon\). - Concrete Domain Realizations:
- The Alexander–Whitney Topological Coalgebra on simplicial chains \(C_*(K)\), whose linear dual is the cohomology
cup product \(\smile\) in
algebrax.topology. - The Divided Power Coalgebra governing binomial convolution moments in
algebrax.semiring.moment. - The Group Hopf Algebra \(K[G]\) (\(\Delta (g) = g \otimes g\), \(S (g) = g^{-1}\)).
- The Lie Universal Enveloping Hopf Algebra \(U (\mathfrak{g})\) with primitive elements (\(\Delta (x) = x \otimes 1 + 1 \otimes x\)).
- The Alexander–Whitney Topological Coalgebra on simplicial chains \(C_*(K)\), whose linear dual is the cohomology
cup product \(\smile\) in
- Property-Based Verification: Executable axiom testing in
algebrax.verification:verify_coassociativity,verify_counitality, andverify_antipode_axiom.
All tensor products \(C \otimes C\) are represented using AlgebraX's native unboxed sparse tuple keys (k1, k2), ensuring
zero heap wrapping overhead.
Motivation¶
AlgebraX contains several advanced mathematical capabilities that secretly rely on coalgebraic comultiplication without formalizing the underlying structure:
- The Alexander–Whitney Coproduct (
EP-0165): The cohomology cup product \(\alpha \smile \beta\) on simplicial cochains is defined as the dual evaluation of the Alexander–Whitney diagonal approximation: $\((\alpha \smile \beta)(\sigma) = (\alpha \otimes \beta)(\Delta (\sigma)) \quad \text{where} \quad \Delta (\sigma) = \sum_{i=0}^n \sigma|_{[v_0 \dots v_i]} \otimes \sigma|_{[v_i \dots v_n]}\)$ Currently, this coproduct is computed procedurally without formalizing that \(C_*(K)\) is a coalgebra. - Divided Power Moment Semirings (
EP-0149): Binomial convolution moments \((X+Y)^n = \sum \binom{n}{k} X^k Y^{n-k}\) are the exact counital divided-power coalgebra \(\Delta (x^{[n]}) = \sum x^{[k]} \otimes x^{[n-k]}\). - Quantum Groups and Symmetries: In quantum mechanics, multi-particle systems require a coproduct to define how symmetry generators act on composite states (\(\Delta (J) = J \otimes 1 + 1 \otimes J\)). The Antipode \(S\) formalizes time-reversal and charge conjugation.
By establishing Coalgebra, Bialgebra, and HopfAlgebra, AlgebraX connects these disparate modules under a single,
elegant categorical duality.
Rationale & Council Alignment¶
- ⚖️ Noether (Conserved Symmetries, Antipodes & Duality): The Antipode \(S\) represents fundamental physical dualities (time-reversal, anti-particles). The coproduct \(\Delta\) defines conservation laws across composite quantum subsystems.
- ⚡ Shannon (Zero Bloat & Sparse Tensor Pairs):
Rejects heavy object wrappers
class TensorProduct. An element of \(C \otimes C\) is simply an unboxed sparse vectordict[tuple[K, K], float]. - 🔬 Popper (Falsifiability & Coassociative Invariants):
Axiomatic tests verify:
- Coassociativity: \((\Delta \otimes \mathrm{id})\Delta (x) == (\mathrm{id} \otimes \Delta)\Delta (x)\).
- Counitality: \(\sum c_{ (1)} \epsilon (c_{ (2)}) == c\).
- Antipode Inversion: \(\sum S (c_{ (1)}) c_{ (2)} == \epsilon (c) \mathbf{1}\).
- 🧩 Russell (Taxonomy & Categorical Arrow-Reversal): Completes the duality triangle: a Coalgebra is strictly an Algebra in the opposite category \(\mathbf{Vect}^{\text{op}}\).
- 💡 Feynman (Freshman Test & Intuitive Demystification): "An algebra is like glue: you take two pieces and make one. A coalgebra is like glass: you drop one piece, and it tells you all the possible ways it can shatter into two pieces."
Specification¶
1. Atomic Mixins & Flat Coalgebra / Hopf Algebra Protocols (src/algebrax/algebra/_mixins.py & src/algebrax/algebra/_hopf.py)¶
In strict compliance with EP-0194 (Law of Flat Protocol Composition), we define three Layer 1 atomic mixins (HasCoproduct[V], HasCounit[R, V], HasAntipode[V]) in algebrax.algebra._mixins, and compose Coalgebra, Bialgebra, and HopfAlgebra flatly from Layer 1 mixins and Protocol (avoiding the diamond inheritance crash between Algebra and Coalgebra):
from typing import Any, Generic, Protocol, TypeVar, runtime_checkable
from algebrax.algebra._mixins import HasAdd, HasMul, HasNeg, HasOne, HasScale, HasZero
from algebrax.typing import SparseVector
R = TypeVar("R")
C = TypeVar("C")
TensorKey = tuple[Any, Any]
SparseTensor = dict[TensorKey, Any]
class HasCoproduct(Protocol[C]):
"""Atomic operational mixin for structures equipped with a coproduct Delta: C -> C (x) C."""
def coproduct(self, c: C) -> SparseTensor:
r"""Compute comultiplication $\Delta(c) = \sum c_{(1)} \otimes c_{(2)}$."""
...
class HasCounit(Protocol[R, C]):
"""Atomic operational mixin for structures equipped with a counit epsilon: C -> R."""
def counit(self, c: C) -> R:
r"""Compute counit $\epsilon(c) \in R$."""
...
class HasAntipode(Protocol[C]):
"""Atomic operational mixin for structures equipped with an antipode S: H -> H."""
def antipode(self, h: C) -> C:
r"""Compute antipode $S(h)$."""
...
@runtime_checkable
class Coalgebra(
HasZero[C], HasAdd[C], HasNeg[C], HasScale[R, C], HasCoproduct[C], HasCounit[R, C], Protocol
):
r"""A coalgebra $\langle R, C, \cdot_s, \mathbf{0}, +, -, \Delta, \epsilon \rangle$ over ring/field $R$."""
def sub(self, a: C, b: C) -> C:
return self.add(a, self.neg(b))
@runtime_checkable
class Bialgebra(
HasZero[C], HasAdd[C], HasNeg[C], HasOne[C], HasMul[C], HasScale[R, C],
HasCoproduct[C], HasCounit[R, C], Protocol
):
r"""A bialgebra: flat composition of Algebra and Coalgebra atomic mixins."""
def sub(self, a: C, b: C) -> C:
return self.add(a, self.neg(b))
@runtime_checkable
class HopfAlgebra(
HasZero[C], HasAdd[C], HasNeg[C], HasOne[C], HasMul[C], HasScale[R, C],
HasCoproduct[C], HasCounit[R, C], HasAntipode[C], Protocol
):
r"""A Hopf algebra: flat composition of Bialgebra mixins plus `HasAntipode[C]`."""
def sub(self, a: C, b: C) -> C:
return self.add(a, self.neg(b))
2. Concrete Group Hopf Algebra (src/algebrax/algebra/_hopf.py)¶
In accordance with EP-0194, concrete Layer 3 class GroupHopfAlgebra subclasses MonoidAlgebra[K, T] and HopfAlgebra[T, SparseVector[K, T]]:
from algebrax.algebra._group import Group
from algebrax.algebra._monoid_algebra import MonoidAlgebra
from algebrax.algebra._semiring import Semiring
class GroupHopfAlgebra(MonoidAlgebra[Any, float], HopfAlgebra[float, SparseVector[Any, float]]):
r"""Group Hopf algebra $R[G]$ over unboxed sparse group combinations `dict[G, float]`.
- Multiplication: Group convolution $g \cdot h$ (inherited from `MonoidAlgebra`)
- Coproduct: $\Delta(\sum c_g g) = \sum c_g (g \otimes g)$ (group-like elements)
- Counit: $\epsilon(\sum c_g g) = \sum c_g$
- Antipode: $S(\sum c_g g) = \sum c_g g^{-1}$
"""
def __init__(self, group: Group[Any], coeff_semiring: Semiring[float]) -> None:
super().__init__(coeff_semiring, key_op=group.op, zero_key=group.identity)
self.group = group
def coproduct(self, x: SparseVector[Any, float]) -> SparseTensor:
return {(g, g): coeff for g, coeff in x.items() if coeff != 0.0}
def counit(self, x: SparseVector[Any, float]) -> float:
return float(sum(x.values()))
def antipode(self, x: SparseVector[Any, float]) -> SparseVector[Any, float]:
result: dict[Any, float] = {}
for g, coeff in x.items():
inv_g = self.group.inv(g)
result[inv_g] = result.get(inv_g, 0.0) + coeff
return {g: c for g, c in result.items() if c != 0.0}
3. Alexander–Whitney Simplicial Coalgebra (src/algebrax/topology/coalgebra.py)¶
class SimplicialChainCoalgebra(Coalgebra[float, SparseVector[tuple[int, ...], float]]):
r"""Simplicial chain complex $C_*(K)$ with the Alexander–Whitney coproduct."""
def coproduct(self, chain: SparseVector[tuple[int, ...], float]) -> SparseTensor:
r"""Compute $\Delta([v_0, \dots, v_n]) = \sum_{i=0}^n [v_0, \dots, v_i] \otimes [v_i, \dots, v_n]$."""
tensor: SparseTensor = {}
for simplex, coeff in chain.items():
n = len(simplex)
for i in range(1, n + 1):
front_face = simplex[:i]
back_face = simplex[i - 1 :]
key = (front_face, back_face)
tensor[key] = tensor.get(key, 0.0) + coeff
return {k: v for k, v in tensor.items() if v != 0.0}
def counit(self, chain: SparseVector[tuple[int, ...], float]) -> float:
return sum(coeff for simplex, coeff in chain.items() if len(simplex) == 1)
4. Verification Suite (src/algebrax/verification.py)¶
def verify_coassociativity(coalgebra: Coalgebra[R, C], samples: list[C]) -> bool:
r"""Verify that $(\Delta \otimes \mathrm{id})\Delta(c) == (\mathrm{id} \otimes \Delta)\Delta(c)$."""
...
def verify_antipode_axiom(hopf: HopfAlgebra[R, C], samples: list[C]) -> bool:
r"""Verify that $\sum S(c_{(1)}) c_{(2)} == \epsilon(c) \mathbf{1}$."""
...
Backwards Compatibility¶
- Non-Breaking Addition:
Coalgebra,Bialgebra, andHopfAlgebraare purely additive. - Enhancement of Topology & Semirings:
algebrax.topologyandalgebrax.semiring.momentexpose explicit coalgebra view methods (.as_coalgebra()) without modifying existing return types.
How to Teach This / Documentation Plan¶
- Applied Guide (
docs/guides/coalgebras-and-hopf-algebras.md):- The duality between algebras (merging) and coalgebras (splitting).
- How the Alexander-Whitney coproduct generates the cohomology cup product.
- Quantum groups and the Antipode as time-reversal symmetry.
Reference Implementation¶
A reference implementation was evaluated under Council review in
references/explorations/EXP-0005-categorical-foundations-and-enriched-mechanics/README.md.
Rejected Ideas¶
- Boxing Sweedler Sums into Heavy AST Objects:
Rejected: Sweedler expansions are represented directly as flat dictionary sparse vectors
dict[tuple[K, K], float].
Open Questions¶
- Braided Bialgebras: Should we formalize braided tensor categories for non-cocommutative Hopf algebras (\(R\)-matrices)? Recommendation: Defer braided R-matrices to quantum knot invariant exploration.
Change Log¶
- 2026-10-28: Initial draft authored following Council consensus.