Skip to content

User Guide Overview

Welcome to the AlgebraX User Guide. AlgebraX is organized deductively along the Pure Algebraic Hierarchy — starting from single-operation building blocks (Magma, Monoid, Group) and ascending through two-operation systems (Lattice, Semiring), additive inverses (Ring, Field), two-sorted linear actions (Module, VectorSpace, Algebra), and topological complexes (Homology, Cohomology, DEC, CellularSheaf).


1. The Axiom Staircase

Every step up the algebraic staircase adds a single operational mixin (Has*) and unlocks a new class of computational algorithms:

flowchart TD
    Magma["<b>Magma / Semigroup</b><br/>⟨V, ·⟩ — Parallel Reduction"] --> Monoid["<b>Monoid</b><br/>⟨V, 1, ·⟩ — Safe Empty Folding"]
    AddMagma["<b>AddMagma / AddSemigroup</b><br/>⟨V, +⟩ — Additive Reduction"] --> AddMonoid["<b>AddCommMonoid</b><br/>⟨V, 0, +⟩ — Sparse Accumulation"]
    Monoid --> Group["<b>Group</b><br/>⟨V, 1, ·, ⁻¹⟩ — Symmetries & Undo"]
    AddMonoid --> AddGroup["<b>AddCommGroup</b><br/>⟨V, 0, +, -⟩ — Reversible Deltas"]
    AddMonoid --> Semiring["<b>Semiring</b><br/>⟨V, 0, +, 1, ·⟩ — Shortest Paths & DP"]
    Monoid --> Semiring
    AddGroup --> Ring["<b>Ring / CommRing</b><br/>⟨V, 0, +, -, 1, ·⟩ — Polynomials & Laplacians"]
    Monoid --> Ring
    Ring --> Field["<b>DivisionRing / Field</b><br/>⟨V, 0, is_zero, +, -, 1, ·, ⁻¹⟩ — Exact LU & Solvers"]
    Ring --> Ideal["<b>Ideal & QuotientRing</b><br/>⟨R/I, contains, reduce⟩ — Modular & Taylor Quotients"]
    Ring --> Module["<b>Module / VectorSpace</b><br/>⟨R, M, ·ₛ, 0, +, -⟩ — Cochains & Linear Forms"]
    Module --> Algebra["<b>NonAssocAlgebra / Algebra</b><br/>⟨R, M, ·ₛ, 0, +, -, 1, ·⟩ — Clifford, Lie & Cohomology Rings"]
    Semiring --> MatCat["<b>MatrixCategory Mat(S)</b><br/>⟨Obj, SparseMatrix, id, dot⟩ — Enriched Categories & Lawvere Metrics"]

2. The Hacker's Translation Box (Jargon Decoder)

Abstract mathematical vocabulary exists to tell you what operations are legal and what optimizations are safe:

Mathematical Term Atomic Mixin Composition Concrete Analogy Computational Superpower
Magma (HasMul[V]) Mixing paints: mix(red, blue) -> purple. Basic closure: combining two items of type \(V\) into a \(V\).
Semigroup (HasMul[V]) String concatenation: ("a"+"b")+"c" == "a"+("b"+"c"). Parallel computing! Splitting and reducing across CPU cores (MapReduce).
Monoid (HasOne[V], HasMul[V]) Adding \(0\), multiplying by \(1\), empty string "". Safe reduction over empty streams (fold_mul) without if len == 0: guards.
Group (HasOne[V], HasMul[V], HasInv[V]) Permutation shuffles, Git revert patches, 3D rotations. Guaranteed undo! Every transformation has an exact inverse \(a^{-1}\).
Lattice (HasJoin[V], HasMeet[V]) Set union \(\cup\) and intersection \(\cap\), max and min. Conflict-free state merging (CRDTs, access-control security clearances).
Semiring (HasZero[V], HasAdd[V], HasOne[V], HasMul[V]) Matrix multiplication with custom \((\oplus, \otimes)\) aggregators. Polymorphic algebra! Pure rig foundations; every Ring is a Semiring.
StarSemiring (HasZero[V], HasAdd[V], HasOne[V], HasMul[V], HasStar[V]) Path aggregation with Kleene closure \(a^* = \mathbf{1} + a a^*\). Transitive paths & series! (Taylor derivatives, infinite reachability, Conway rigs).
KleeneAlgebra (HasZero[V], HasAdd[V], HasOne[V], HasMul[V], HasStar[V], LawIdempotent) Idempotent star semiring (\(a \oplus a = a\)) such as Tropical \((\min, +)\). Extremal path finding & automata! (Bellman-Ford, Viterbi, regex matching).
Ring (HasZero[V], HasAdd[V], HasNeg[V], HasOne[V], HasMul[V]) Integers \(\mathbb{Z}\), polynomials \(R[x]\), graph Laplacians \(L = D - W\). Cancellation! Subtracting terms (\(a - b\)) enables error codes and wave diffusion.
Ideal (HasContains[V], HasReduce[V]) Multiples of \(n\) (\(n\mathbb{Z}\)), Taylor tails \((x^k)\), polynomial Gröbner ideals \(I\). Canonical quotienting! Zero-overhead modular arithmetic & coordinate rings \(R/I\) via ideal.reduce(x).
Field (HasZero[V], HasZeroPred[V], HasAdd[V], HasNeg[V], HasOne[V], HasMul[V], HasInv[V]) Rationals \(\mathbb{Q}\), prime fields \(\mathbb{F}_p\), Galois \(\mathrm{GF}(p^m)\), \(p\)-adics \(\mathbb{Q}_p\). Exact Linear & Polynomial Algebra! Gaussian elimination, LU, Gröbner bases, and solvers with zero drift.
Module (HasScale[R, M], HasZero[M], HasAdd[M], HasNeg[M]) Sparse vectors scaled by integers or polynomials. Discrete differential forms, simplicial chains \(C_k(K; R)\), integer lattices.
Algebra (HasScale[R, M], HasZero[M], HasAdd[M], HasNeg[M], HasOne[M], HasMul[M]) Vectors that can also be multiplied together (rotors, Lie brackets). 3D/4D physics, rigid-body kinematics (\(\mathfrak{so}(3)\)), Dirac spinors, cup products.
Category Category[Obj, Mor] / MatrixCategory[K, V] Directed graphs where paths compose by matrix multiplication dot(f, g). Functorial duality & Lawvere metrics (\(\mathbf{Mat}(\mathcal{S})^{\mathrm{op}} \cong \mathbf{Mat}(\mathcal{S})\) via transpose).

3. Fast-Track Elevators by Discipline

Jump directly to the guide matching your engineering domain:


4. Quick Tour of the 7 Guide Tiers

  1. Single-Operation Structures: Atomic operational mixins (Has*), magmas, semigroups, bands, monoids, and groups & permutation symmetries.
  2. Two-Operation Systems: Order-theoretic lattices & Boolean algebras and the 33 built-in semirings & algebras.
  3. Additive Inverses (Rings, Ideals, Varieties & Fields): Rings, Grothendieck completions, exact GaloisField & \(p\)-adic fields, homomorphisms, multivariate polynomials, exact Gröbner ideals & canonical quotients, classical & tropical algebraic varieties, Newton polytopes, coordinate rings & Stickelberger solvers, and exact sparse matrix solvers.
  4. Two-Sorted Systems (Modules, Algebras & Tensors): Semimodules, modules & vector spaces, Clifford geometric algebras, Lie algebras, Langlands duals & Hecke algebras, coalgebras & Hopf algebras, group representations & character tables, induced representations & Frobenius–Mackey theory, Lie representations & Clebsch–Gordan tensors, invariant theory, Molien series & cubic Casimir, quantum groups, Yang–Baxter & braids, quiver representations, path algebras & Gabriel's ADE theorem, and sparse tensors & einsum.
  5. Discrete Geometry & Topology: Simplicial homology, graded cohomology rings, persistent homology barcodes, Discrete Exterior Calculus (DEC), cellular sheaves & fiber bundles, and topological K-theory & characteristic Chern classes.
  6. Categories, Automata & Dynamics: Matrix categories \(\mathbf{Mat}(\mathcal{S})\), Lawvere metric spaces, Cartesian Closed Categories, semiring coeffects, path groupoids \(\Pi_1(K)\), Kleisli composition, weighted finite automata, information theory, spectral graph theory, Ramanujan expanders, and discrete graph calculus.
  7. Ecosystem Bridges & Decompositions: Matrix decompositions (LU, QR, SVD, Cholesky), CodSpeed micro-benchmarks, and academic reference operators.

5. Unified Structure Registry, Structure Cards & CLI

AlgebraX ships a read-only, pure-data structure catalog at algebrax.registry (ax.registry) covering all built-in concrete 0-cell algebraic structures (classes and canonical factory families) without introducing any nominal Structure base class:

import algebrax as ax

# Read-only MappingProxyType views
cat = ax.registry.catalog()           # All 100 concrete 0-cell structures
entry = ax.registry.get('GaloisField') # Case-insensitive key, class name, or alias
print(entry.domain, entry.kind, [p.__name__ for p in entry.protocols])

# Pure functional extension (never mutates the global catalog)
custom_cat = ax.registry.extend_catalog({'MyRing': my_entry})

# Introspect any registered or unregistered structure (key, class, factory, or instance)
info = ax.registry.describe(ax.semiring.TropicalSemiring())
html_card = ax.display.structure_card(info)  # HTML-escaped Jupyter structure card

Command-Line Interface (python -m algebrax)

The unified 4-subcommand CLI is backed directly by algebrax.registry and algebrax.verification:

  • python -m algebrax catalog [--domain ...] [--kind ...] [--protocol ...] [--law ...] [--verifiable] [--format text|json]: Browse and filter the full structure catalog or emit a machine-readable JSON manifest (--format json).
  • python -m algebrax describe <name> [--format text|json|html]: Inspect a structure's import path, AMDS signature, protocols, law witnesses, and constructor requirements (or render an HTML card via display.structure_card).
  • python -m algebrax inspect <file|-> [--semiring NAME] [--power N] [--dot FILE] [--format text|json|html]: Inspect and operate on sparse JSON matrices using any zero-arg semiring (parameterized semirings exit non-zero with required parameter diagnostics).
  • python -m algebrax verify [name] [--semiring NAME] [--all] [--domain ...] [--kind ...] [--format text|json]: Run protocol-aware axiom and law-witness verification (algebrax.verification.verify_structure) on one or all registered structures.