|
Dedekind 0.0.0
A structuralist C++23 Module Library
|
The Functorial Spine (Structure Preservation). More...
#include <algorithm>#include <concepts>#include <cstddef>#include <functional>#include <optional>#include <ranges>#include <string>#include <tuple>#include <type_traits>#include <utility>import dedekind.category:small;
Classes | |
| struct | dedekind::category::is_functorial< F > |
Trait: F preserves identities and composition, \(F(\mathrm{id})
= \mathrm{id}\) and \(F(f \gg g) = F(f) \gg F(g)\): the functor laws, a certificate as is_involutive and commutes are, primary std::false_type. A type cannot show them, since \(F(f \gg g)\) and \(F(f) \gg F(g)\) are different types that denote one arrow; a functor that lifts each arrow letterwise, elementwise or not at all declares it, and a composite of functors derives it. More... | |
| struct | dedekind::category::MaybeMap< T, F > |
f on the value an optional holds, none where it holds none: the optional functor's action on an arrow. Its codomain is stated, so an arrow into optionals lifts to one into optionals of optionals, as a Kleisli extension needs, and is never collapsed by deduction. More... | |
| struct | dedekind::category::TupleMap< T, F > |
f on the one element of a one-tuple: the one-tuple functor's action on an arrow. More... | |
| struct | dedekind::category::maybe_functor< T > |
| The Intensional Functor for Optional (Maybe) values. More... | |
| struct | dedekind::category::tuple_functor< T > |
| The Intensional Functor for 1-tuple values. More... | |
| struct | dedekind::category::is_functorial< maybe_functor< T > > |
| The container functors map their one slot or none elementwise: the functor laws hold by construction. More... | |
| struct | dedekind::category::is_functorial< tuple_functor< T > > |
| struct | dedekind::category::composite_functor< F, G > |
| Composite Functor G . F (Maps CatS -> CatT -> CatU). More... | |
| struct | dedekind::category::is_functorial< composite_functor< F, G > > |
| A composite of functors is a functor: its laws derived from its legs'. More... | |
| struct | dedekind::category::has_one_value< composite_functor< F, G > > |
| A composite of two functors with one value each has one value: its legs leave nothing to choose, although its two members keep it from being an empty type. More... | |
| struct | dedekind::category::f_algebra< Carrier, Functor, Structure > |
| A concrete witness for an F-algebra. More... | |
| struct | dedekind::category::f_coalgebra< Carrier, Functor, Structure > |
| A concrete witness for an F-coalgebra. More... | |
| struct | dedekind::category::identity_functor< Cat > |
| struct | dedekind::category::is_functorial< identity_functor< Cat > > |
| The identity functor returns each arrow itself: the functor laws hold by construction. More... | |
| struct | dedekind::category::Element< T, Op > |
| A monoid as a category with one object, its delooping, and an action of it as a functor out of that category (Mac Lane, CWM Β§I.2): the action's laws are the functor's. More... | |
| struct | dedekind::category::Delooping< T, Op > |
The delooping \(\mathbf{B}(T, \cdot)\): one object, an arrow per element, composition the operation, the identity its unit. Of the opposite operation, Opposite<Op>, it is the opposite category. More... | |
| struct | dedekind::category::Acting< H, V, S > |
| An element acting: the arrow \(v \mapsto h(v, s)\) on the set the monoid acts on. More... | |
| struct | dedekind::category::ActingOn< H, V, S > |
The arrows by which a monoid acts on V, as a category: the image of the delooping under the action. More... | |
| struct | dedekind::category::ActionFunctor< H, V, S > |
A right action as a functor out of the delooping of the monoid it acts by: the one object to V, an element s to \(v \mapsto h(v,
s)\). Its functor laws are the action's, \(h(v, 1) = v\) and \(h(h(v, a), b) = h(v, a \cdot b)\), which acting_monoid declares, so they are derived and not declared again. A left action registers the opposite operation, so it is a functor out of the opposite category. More... | |
| struct | dedekind::category::is_functorial< ActionFunctor< H, V, S > > |
An action's functor laws come with the action: derived from acting_monoid, which IsRightAction reads. More... | |
| struct | dedekind::category::LeftActing< Act, M, S > |
| A scalar acting on the left: the arrow \(m \mapsto s \cdot m\) of a semimodule. More... | |
| struct | dedekind::category::LeftActingOn< M, S, AddM, AddS, MultS, Act > |
| The arrows by which the scalars act on a semimodule, as a category: certified by the semimodule's laws, so its identity is the scalars' unit. More... | |
| struct | dedekind::category::LeftActionFunctor< M, S, AddM, AddS, MultS, Act > |
A semimodule's left action as a functor out of the opposite of the delooping of its scalars' product: \((s t) m = s (t m)\), so s then t along the walk acts as \(t s\), the opposite product, and \(1 m = m\) keeps the identity. Those laws are the semimodule's, which is_linear_action declares, so the functor laws are derived. A left action of a monoid is a right action of its opposite: the right actions are ActionFunctor. More... | |
| struct | dedekind::category::is_functorial< LeftActionFunctor< M, S, AddM, AddS, MultS, Act > > |
A semimodule's functor laws come with it: derived from IsSemimodule. More... | |
| struct | dedekind::category::DaggerFunctor< Dagger, T, Op > |
A dagger as a functor: from the delooping of (T, Op) to that of its opposite, each element to its dagger. The functor laws are the dagger's, \((a b)^\dagger = b^\dagger a^\dagger\), the composition law into the opposite category, and \(1^\dagger = 1\), which an involutive anti-homomorphism keeps; so they are derived from IsDagger and not declared again. Contravariant on the one object, and its own inverse. More... | |
| struct | dedekind::category::is_functorial< DaggerFunctor< Dagger, T, Op > > |
A dagger's functor laws come with the dagger: derived from IsDagger, its involution and its reversal of products. More... | |
Namespaces | |
| namespace | dedekind::category |
Concepts | |
| concept | dedekind::category::IsFunctor |
The textbook functor (#633): an IsArrow whose Domain and Codomain are (small) categories — a 1-morphism in Cat, Mac Lane Β§I.3 — carrying a morphism map. | |
| concept | dedekind::category::IsShapedFunctor |
A 1-morphism mapping CatS -> CatT, refined with the container shape: an IsFunctor that additionally exposes a type-level object map Shape and the action on arrows, F(f). | |
| concept | dedekind::category::IsIdentityFunctor |
| concept | dedekind::category::IsEndofunctor |
| A structure-preserving mapping from a Category back to itself (F : π β π). | |
| concept | dedekind::category::IsIterativeEndomorphism |
| A stabilizing step function on a carrier species. | |
| concept | dedekind::category::IsFAlgebra |
| A carrier A equipped with a structure map F<A> -> A. | |
| concept | dedekind::category::IsFCoalgebra |
| A carrier A equipped with a structure map A -> F<A>. | |
| concept | dedekind::category::IsEmbeddingFunctor |
A functor that is fully faithful + injective on objects (Mac Lane CWM Β§IV.4 strong reading; the Yoneda-embedding flavour). | |
| concept | dedekind::category::IsQuotientFunctor |
| A functor that is a regular epi / coequalizer presentation (Borceux Handbook Β§4.3). | |
Typedefs | |
| template<typename T> | |
| using | dedekind::category::Maybe = std::optional<T> |
| The Maybe endofunctor T, implemented via std::optional. | |
| using | dedekind::category::detail_functor_actions::Plus = std::plus<std::size_t> |
| using | dedekind::category::detail_functor_actions::Adding = ActionFunctor<Plus, std::size_t, std::size_t> |
| using | dedekind::category::detail_functor_actions::Sum = Element<std::size_t, Plus> |
| using | dedekind::category::detail_functor_actions::Scaling = LeftActionFunctor<std::size_t, std::size_t> |
| using | dedekind::category::detail_functor_actions::Scalar = Element<std::size_t, Opposite<std::multiplies<std::size_t>>> |
| using | dedekind::category::detail_functor_actions::Scalars = Delooping<std::size_t, Opposite<std::multiplies<std::size_t>>> |
Functions | |
|
template<typename π, typename π> requires IsArrow<std::decay_t<π>> && IsArrow<std::decay_t<π>> && std::same_as<typename std::decay_t<π>::Codomain, typename std::decay_t<π>::Domain> && IsShapedFunctor<π> && IsShapedFunctor<π> && std::same_as<typename std::remove_cvref_t<π>::Ξ€_cat, typename std::remove_cvref_t<π>::Ξ£_cat> | |
| constexpr auto | dedekind::category::operator>> (π f, π g) |
|
template<typename π, typename π> requires IsArrow<std::decay_t<π>> && IsArrow<std::decay_t<π>> && std::same_as<typename std::decay_t<π>::Codomain, typename std::decay_t<π>::Domain> && IsShapedFunctor<π> && IsShapedFunctor<π> && std::same_as<typename std::remove_cvref_t<π>::Ξ€_cat, typename std::remove_cvref_t<π>::Ξ£_cat> && IsIdentityFunctor<π> | |
| constexpr auto | dedekind::category::operator>> (π, π g) |
|
template<typename π, typename π> requires IsArrow<std::decay_t<π>> && IsArrow<std::decay_t<π>> && std::same_as<typename std::decay_t<π>::Codomain, typename std::decay_t<π>::Domain> && IsShapedFunctor<π> && IsShapedFunctor<π> && std::same_as<typename std::remove_cvref_t<π>::Ξ€_cat, typename std::remove_cvref_t<π>::Ξ£_cat> && IsIdentityFunctor<π> | |
| constexpr auto | dedekind::category::operator>> (π f, π) |
|
template<typename π, typename π> requires IsArrow<std::decay_t<π>> && IsArrow<std::decay_t<π>> && std::same_as<typename std::decay_t<π>::Codomain, typename std::decay_t<π>::Domain> && IsShapedFunctor<π> && IsShapedFunctor<π> && std::same_as<typename std::remove_cvref_t<π>::Ξ€_cat, typename std::remove_cvref_t<π>::Ξ£_cat> && IsIdentityFunctor<π> && IsIdentityFunctor<π> | |
| constexpr auto | dedekind::category::operator>> (π f, π) |
|
template<typename π, typename π> requires IsShapedFunctor<π> && IsShapedFunctor<π> && std::same_as<typename std::remove_cvref_t<π>::Ξ€_cat, typename std::remove_cvref_t<π>::Ξ£_cat> | |
| constexpr auto | dedekind::category::operator<< (π f, π g) |
| The "Upstream Fish" (Optional Composition Sugar) g << f => g β f. | |
|
template<typename Functor, typename Structure> requires IsEndofunctor<std::remove_cvref_t<Functor>> && IsArrow<std::remove_cvref_t<Structure>> | |
| constexpr auto | dedekind::category::make_f_algebra (Functor functor, Structure structure) |
| Factory for F-algebra witnesses. | |
|
template<typename Functor, typename Structure> requires IsEndofunctor<std::remove_cvref_t<Functor>> && IsArrow<std::remove_cvref_t<Structure>> | |
| constexpr auto | dedekind::category::make_f_coalgebra (Functor functor, Structure structure) |
| Factory for F-coalgebra witnesses. | |
| template<typename T, typename Step, typename Equal = std::equal_to<>> requires IsIterativeEndomorphism<T, Step> && std::predicate<const Equal&, const T&, const T&> | |
| constexpr T | dedekind::category::fixed_point (T seed, Step step, Equal equal={}, std::size_t max_iterations=1024) |
| Iteratively compute a fixed point of an endomorphism. | |
|
template<typename T, typename Step, typename Equal = std::equal_to<>> requires IsIterativeEndomorphism<T, Step> && std::predicate<const Equal&, const T&, const T&> | |
| constexpr T | dedekind::category::least_fixpoint (T seed, Step step, Equal equal={}, std::size_t max_iterations=1024) |
| Alias emphasizing order-theoretic reading of the fixed point. | |
| template<typename T, typename Expand, typename Join, typename Equal = std::equal_to<>> requires std::predicate<const Equal&, const T&, const T&> | |
| constexpr T | dedekind::category::closure (const T &x, Expand expand, Join join, Equal equal={}, std::size_t max_iterations=1024) |
The closure of x under expand: the textbook "closure of @c X
under @c Y". It is the least fixpoint of S β¦ x β expand(S) — the smallest element β x closed under the one-step expansion expand — equivalently the Kleene join β¨β expandβΏ(x). | |
Variables | |
| template<typename F> | |
| constexpr bool | dedekind::category::is_functorial_v |
| template<typename F> | |
| constexpr bool | dedekind::category::is_identity_functor_v = false |
The unit laws of Cat, decided at the type: an identity functor composes to the other leg itself, \(\mathrm{id} \gg F = F = F \gg
\mathrm{id}\), not to a composite around it, as an identity arrow does (:morphism). The overloads repeat the generic one's constraints and add one, so resolution orders them by subsumption (Jlt paper, Listing 1). | |
| template<typename Cat> | |
| constexpr bool | dedekind::category::is_identity_functor_v< identity_functor< Cat > > = true |
| template<typename F> | |
| constexpr bool | dedekind::category::is_embedding_functor_v = false |
| Trait registry for the IsEmbeddingFunctor concept. | |
| template<typename F> | |
| constexpr bool | dedekind::category::is_quotient_functor_v = false |
| Trait registry for the IsQuotientFunctor concept. | |
The Functorial Spine (Structure Preservation).
@partition :functor
@quote "ΰ€ΰ€ΰ€ ΰ€Έΰ€¦ΰ₯ ΰ€΅ΰ€Ώΰ€ͺΰ₯ΰ€°ΰ€Ύ ΰ€¬ΰ€Ήΰ₯ΰ€§ΰ€Ύ ΰ€΅ΰ€¦ΰ€¨ΰ₯ΰ€€ΰ€Ώ" (Truth is One, though the sages speak of it as many.) β ΰ€ΰ€ΰ₯ΰ€΅ΰ₯ΰ€¦ (Rig Veda)
A Functor is a bridge between categories that preserves the "Grammar" of the source. In our skeletal framework, a Functor F: T -> U ensures that:
Represents a Functor as a morphism between categories (Ξ£_cat -> Ξ€_cat). In this library's hierarchy, a Functor is an "arrow between species" that maps morphisms from the source category to the target category while strictly preserving identity and composition laws.
(Extensional Matter)
With a view to interoperability with primitive types and the std::library, Dedekind distinguishes between the mathematical rule of transformation and the data instances that undergo it. This separation ensures that categorical laws are verified at the structural level before they are applied to values.
Partition
The following types in this partition model IsShapedFunctor:
Notes: