$ show Nemocas/AbstractAlgebra.jl
AbstractAlgebra.jl is a pure Julia library providing generic abstract algebra structures and algorithms. It serves as the foundational computational algebra layer for the Oscar/Nemocas ecosystem, used by downstream packages Nemo.jl, Hecke.jl, and Singular.jl. The library implements a comprehensive type hierarchy for rings, fields, modules, matrices, polynomials (univariate, multivariate, Laurent, Puiseux, power series), and groups, along with generic algorithms for arithmetic, GCD, factorization, linear algebra (LU, HNF, SNF, Popov forms), GrΓΆbner bases, and more. It is designed for extensibility: any ring implementing the fundamental interface (parent, elem_type, zero, one, +, *, etc.) can use the generic implementations. The codebase is well-tested with conformance tests that verify algebraic axioms for each type, and includes sophisticated infrastructure for attribute caching, map caching, pretty printing, and random element generation. While primarily a library for symbolic computation and research mathematics, it is not a data science or ETL tool.
The LLM identified 5 files worth highlighting for reuse:
Provides the `@attr` and `@attributes` macros for memoizing expensive computations on algebraic objects. The system supports internal/external storage, singleton objects, and return-type checking. It is widely used throughout the codebase to cache properties like characteristic, degree, and normal forms. The pattern is self-contained and could be extracted for any Julia project needing attribute-based caching with invalidation control.
A binary heap implementation of a priority queue, adapted from DataStructures.jl. Provides `enqueue!`, `dequeue!`, `peek`, and `change_priority!` operations. Used internally for GrΓΆbner basis computations and polynomial arithmetic. The implementation is standalone, well-documented, and could be reused in any Julia project requiring a mutable priority queue.
Implements a dictionary with weak values, allowing garbage collection of cached objects when no strong references remain. Used to cache parent algebraic structures (e.g., polynomial rings, matrix spaces) without preventing memory reclamation. The implementation is self-contained and demonstrates careful handling of Julia's weak reference API. Could be extracted for any caching scenario where value lifetimes should not be artificially extended.
Implements two strategies for evaluating multivariate polynomials: Horner evaluation with lexicographic ordering and a logarithmic caching method that reuses intermediate results. The module is self-contained, parameterized by coefficient ring, and demonstrates non-obvious optimization techniques for repeated evaluation. Could be extracted as a standalone utility for any multivariate polynomial evaluation task.
Provides a comprehensive suite of conformance tests for ring, field, and module interfaces. Functions like `test_Ring_interface`, `test_Field_interface`, and `test_Module_interface` verify that user-defined types satisfy algebraic axioms (associativity, distributivity, existence of inverses, etc.). The framework is extensible via `generate_element` hooks and is used throughout the test suite. It could be extracted and reused by any Julia package implementing algebraic structures to ensure interface compliance.