|
Dedekind 0.0.0
A structuralist C++23 Module Library
|
Registration helpers for field-shaped carriers. More...
#include <concepts>#include <cstddef>#include <functional>#include <type_traits>
Classes | |
| struct | RigRegistration< T, Zero, One, Add, Mult > |
Base class for SpeciesTraits<T> of carriers forming a \emph{rig} (semiring) under (Add, Mult) with identities Zero (additive) and One (multiplicative). More... | |
| struct | RingRegistration< T, Zero, One, Add, Mult > |
A rig whose additive monoid is an abelian group (i.e. has additive inverses). Mult is not required to commute here; see CommutativeRingRegistration for that. More... | |
| struct | CommutativeRingRegistration< T, Zero, One, Add, Mult > |
| A ring whose multiplication is also commutative. More... | |
| struct | FieldRegistration< T, Zero, One, Add, Mult > |
| A commutative ring in which every non-zero multiplicative element is also invertible. More... | |
| struct | GaloisFieldRegistration< T, Zero, One, Order, Add, Mult > |
Extends FieldRegistration with the Galois-specific opt-ins: the carrier is declared a finite field of a given order. More... | |
| struct | dedekind::category::is_associative< T, Op > |
| struct | dedekind::category::is_commutative< T, Op > |
| struct | dedekind::category::is_periodic< T, Op > |
| struct | dedekind::category::inverse_trait< T, Op > |
| struct | dedekind::category::unit_trait< T, Op, void > |
Namespaces | |
| namespace | dedekind::category |
Variables | |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::multiplies< T >, std::plus< T > > |
Registration helpers for field-shaped carriers.
@partition :registration
Closes #382. When a concrete carrier T is registered as a field under some (Add, Mult), the per-carrier trait block has historically been ~40 lines of boilerplate (identity, associativity, commutativity, distributivity, periodicity, invertibility on each operation — all written out per (T, Op)).
This partition replaces that block with a single base-class inheritance into SpeciesTraits<T>:
The mechanism has two pieces:
(1) FieldRegistration<T, Zero, One, Add, Mult> (and the derived GaloisFieldRegistration<..., Order>) — CRTP-ish base classes that expose member templates is_associative_v<Op>, is_commutative_v<Op>, is_invertible_v<Op>, is_periodic_v<Op>, unit_v<Op>, is_distributive_v<MultOp, AddOp>, with the obvious per-op conditions baked in.
(2) SpeciesTraits-based \emph{discovery} partial specialisations for each of the corresponding free-standing traits in dedekind.category (is_associative, is_commutative, \ldots, unit_trait, is_invertible_v, \ldots). Each one has the shape ``if SpeciesTraits<T> exposes member template is_foo_v, then is_foo<T, Op>::value is that''.
The discovery layer lives here (not in category:species), so :species stays a pure trait-definition layer. Carriers that do not inherit from a Registration helper are unaffected: the discovery only fires when the member template is actually present. The dedekind.algebra umbrella re-exports this partition, so any translation unit that uses a Registration- retargeted carrier already sees the discovery specs.
for std::same_as for std::size_t for std::plus, std::multiplies for std::bool_constant
export module dedekind.algebra:registration;
import dedekind.category;
namespace dedekind::algebra {
The Registration chain. Each level derives from the previous and adds the incremental axioms that define its algebraic species:
RigRegistration — additive commutative monoid + multiplicative monoid + distributive (no additive inverse) ↓ RingRegistration — + additive invertibility ↓ CommutativeRingRegistration — + multiplicative commutativity ↓ FieldRegistration — + multiplicative invertibility ↓ GaloisFieldRegistration — + finite-cardinality opt-in (Galois field)
A carrier picks the appropriate level for its species and the SpeciesTraits-based discovery below lifts the member templates
/**