|
Dedekind 0.0.0
A structuralist C++23 Module Library
|
The Reified Machine (The Taxonomic Bricks). More...
#include <algorithm>#include <concepts>#include <functional>#include <limits>#include <type_traits>
Namespaces | |
| namespace | dedekind::category |
Concepts | |
| concept | dedekind::category::IsSpecies |
| Formal verification that a type has been registered in the Atlas. | |
| concept | dedekind::category::HasTotalProduct |
Whether T's product is defined on all of T: a word narrower than int multiplies after promotion to int, and the largest product must fit it. unsigned char's does (255 · 255); unsigned short's does not (65535 · 65535 overflows int, undefined as -INT_MIN is), so it is refused as int is. Decided by the compiler: undefined behaviour is no constant expression. Unsigned words only: there the product grows with its factors, so the largest is the one that may overflow, and numeric_limits names it (a type without limits has max() == T{}, and the probe would check only 0 · 0). | |
| concept | dedekind::category::IsTransfinite |
| concept | dedekind::category::IsFinite |
| concept | dedekind::category::IsAssociative |
| concept | dedekind::category::IsCommutative |
| concept | dedekind::category::IsDistributive |
| The "Glue" of the Ring: a * (b + c) = a*b + a*c. | |
| concept | dedekind::category::IsIdempotent |
Functions | |
| template<typename T, typename Op> requires requires { unit_trait<T, Op>::value; } | |
| constexpr T | dedekind::category::unit (Op) |
The unit of Op at the carrier T, read as unit<T>(Op{}). | |
| template<std::integral 𝒯> | |
| constexpr 𝒯 | dedekind::category::inverse (𝒯 a, std::bit_xor< 𝒯 >) |
| In XOR, every element is its own inverse (Involutive). | |
| template<std::integral 𝒯> | |
| constexpr 𝒯 | dedekind::category::inverse (𝒯 a, std::plus< 𝒯 >) |
| In Addition, negation is the inverse (Two's Complement wrapping). | |
|
template<typename T, typename Op> requires requires(T a) { { inverse(a, Op{}) } -> std::same_as<T>; } | |
| constexpr T | dedekind::category::inverse_v (T a) |
| The Master Bridge: Routes the request to specific implementations. | |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::associative (Op) |
The laws as functions of the operation: associative<T>(Op{}), commutative<T>(Op{}), idempotent<T>(Op{}) and distributive<T>(Mul{}, Add{}). | |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::commutative (Op) |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::idempotent (Op) |
| template<typename T, typename Mul, typename Add> | |
| constexpr bool | dedekind::category::distributive (Mul, Add) |
Variables | |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::is_associative_v = is_associative<T, Op>::value |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::is_commutative_v = is_commutative<T, Op>::value |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::is_idempotent_v = is_idempotent<T, Op>::value |
| Helper for shorthand access in concepts. | |
| template<typename T> | |
| constexpr size_t | dedekind::category::characteristic_v |
| The Characteristic of the Species. | |
| template<> | |
| constexpr size_t | dedekind::category::characteristic_v< unsigned char > = 256 |
|
template<typename Op> requires std::same_as<Op, std::logical_and<bool>> || std::same_as<Op, std::logical_and<void>> | |
| constexpr bool | dedekind::category::is_commutative_v< bool, Op > = true |
|
template<typename Op> requires std::same_as<Op, std::logical_or<bool>> || std::same_as<Op, std::logical_or<void>> | |
| constexpr bool | dedekind::category::is_associative_v< bool, Op > = true |
| template<typename T, typename Mult, typename Add> | |
| constexpr bool | dedekind::category::is_distributive_v = false |
| Trait to mark the structural glue between two operators. axiom: a * (b + c) = (a * b) + (a * c). | |
| template<typename T, typename Op> | |
| constexpr bool | dedekind::category::is_invertible_v = inverse_trait<T, Op>::exists |
| The Shorthand for the Registry. | |
| template<> | |
| constexpr bool | dedekind::category::is_associative_v< bool, std::bit_xor< bool > > = true |
| XOR on bool is the additive composition of the Boolean Ring. It is bit-perfect, associative, and total. | |
| template<> | |
| constexpr bool | dedekind::category::is_invertible_v< bool, std::bit_xor< bool > > = true |
| Every boolean is its own inverse (x ^ x = false). There is no Lipschitz boundary breach here. | |
| template<std::unsigned_integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::plus<> > = true |
| Associativity is only total for unsigned types (modular arithmetic). For signed types, it is REJECTED here due to the re-ordering hazard (UB). | |
| template<std::unsigned_integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::plus< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::plus<> > = true |
| Commutativity remains a total property (order-independence). | |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::plus< T > > = true |
| template<std::unsigned_integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::multiplies< T > > = true |
Multiplication is ONLY associative for types with defined (modular) overflow. Signed integers fail this at Level 0 due to the UB hazard, and so does a word whose product overflows int after promotion (HasTotalProduct). | |
| template<std::unsigned_integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::multiplies< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::modulus< T > > = false |
| Modulus is NOT associative nor commutative, and has no identity. | |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::modulus< T > > = false |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::bit_xor< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::bit_xor< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::bit_and< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::bit_and< T > > = true |
| template<> | |
| constexpr bool | dedekind::category::is_associative_v< bool, std::bit_and< bool > > = true |
| template<> | |
| constexpr bool | dedekind::category::is_commutative_v< bool, std::bit_and< bool > > = true |
| template<> | |
| constexpr bool | dedekind::category::is_invertible_v< bool, std::bit_and< bool > > = true |
On the multiplicative group \(\mathbb{F}_2^\times =
\{\mathtt{true}\}\), the only non-zero element is self-inverse: true & true = true (the registered operator is std::bit_and<bool>, the bitwise AND). Zero (i.e. false) is excluded by convention on is_invertible_v, so the trait can be declared at the type level without quantifying over values. Together with the XOR additive group, this witnesses dedekind::category::IsField<bool, std::bit_xor<bool>, std::bit_and<bool>>: bool is the Galois field \(\mathbb{F}_2\) under its natural bitwise operators. | |
| template<> | |
| constexpr bool | dedekind::category::is_distributive_v< bool, std::bit_and< bool >, std::bit_xor< bool > > = true |
| AND distributes over XOR on bool: the field distributivity axiom. | |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_idempotent_v< T, std::bit_or<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::bit_or<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::bit_or<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_idempotent_v< T, std::bit_and<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::bit_and<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_commutative_v< T, std::bit_and<> > = true |
| template<std::unsigned_integral T> | |
| constexpr bool | dedekind::category::is_associative_v< T, std::multiplies<> > = true |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::bit_and<>, std::bit_or<> > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::bit_or<>, std::bit_and<> > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::bit_and< T >, std::bit_or< T > > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::bit_or< T >, std::bit_and< T > > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_distributive_v< T, std::multiplies<>, std::plus<> > |
| Self-verifying the structural integrity of the reified species. | |
| template<> | |
| constexpr bool | dedekind::category::is_distributive_v< bool, std::logical_or< bool >, std::logical_and< bool > > |
| template<> | |
| constexpr bool | dedekind::category::is_distributive_v< bool, std::logical_and< bool >, std::logical_or< bool > > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_transfinite_v = is_transfinite<T>::value |
| Shorthand helper. | |
| template<typename T, typename Op1, typename Op2> | |
| constexpr bool | dedekind::category::is_absorptive_v = false |
| The Absorber Trait (Axiom: a ∨ (a ∧ b) = a). Represents the structural tethering between two dual operations. | |
| template<typename T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::logical_or< T >, std::logical_and< T > > = true |
| template<typename T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::logical_and< T >, std::logical_or< T > > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::bit_or<>, std::bit_and<> > = true |
| template<std::integral T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::bit_and<>, std::bit_or<> > = true |
| template<typename T> | |
| constexpr bool | dedekind::category::is_idempotent_v< T, std::bit_xor< T > > = false |
| template<typename T> | |
| constexpr bool | dedekind::category::is_idempotent_v< T, std::bit_and< T > > = true |
| template<typename T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::bit_xor< T >, std::bit_and< T > > |
| template<typename T> | |
| constexpr bool | dedekind::category::is_absorptive_v< T, std::bit_and< T >, std::bit_xor< T > > |
The Reified Machine (The Taxonomic Bricks).
@partition :species
This partition performs the formal reification of C++ machine types. Following Joyal’s Theory of Species, we treat each fundamental type not as a set of values, but as a rule for generating structure.
Raw types (bool, int, double) are elevated to "Species" by attaching algebraic metadata. This ensures that a species carries its own "laws of nature" (associativity, identity) as static constants.
To satisfy the Stroustrupian ideal, all species definitions must resolve to their underlying machine primitives at compile-time. Categorification here is an act of reasoning, not an act of allocation.
Defines the skeletal signature of an Arrow (Domain -> Codomain). This provides the mapping metadata required for the Functorial discovery in Level 0b (:category).
Wikipedia: Combinatorial species, Type theory, Generic programming