Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::category::IsHashFunction Concept Referenceexport

A callable h on T whose codomain is std::size_t — i.e. an arrow T → size_t. More...

Concept definition

template<typename H, typename T>
concept dedekind::category::IsHashFunction = requires(const H& h, const T& x) {
{ h(x) } -> std::convertible_to<std::size_t>;
}
A callable h on T whose codomain is std::size_t — i.e. an arrow T → size_t.
Definition equivalence.cppm:366

Detailed Description

A callable h on T whose codomain is std::size_t — i.e. an arrow T → size_t.

A hash function induces a canonical equivalence relation on its domain:

\[ x \,\sim_h\, y \iff h(x) \,=\, h(y), \]

the kernel of h read as a binary relation. This relation is automatically reflexive / symmetric / transitive as a consequence of size_t equality being so on std::size_t — i.e. every IsHashFunction structurally induces an IsEquivalence. The partition is the fibres \(h^{-1}(s)\) for \(s \in \mathrm{im}(h)\), grouping inputs that collide under h.

The concept lives next to IsEquivalence because the equivalence relation is the hash's mathematical content; the size_t codomain is a representation choice (the arithmetic-friendly fibre index, used by std::unordered_set / std::unordered_map for bucket dispatch).

Template Parameters
HThe hash callable (e.g. std::hash<T>).
TThe carrier the hash is defined on.

Recommendation (per Gemini correspondence, 2026-05-06): the home of the base concept is the equivalence-relation layer; algebra- specific refinements (rolling hashes as Monoid → Ring homomorphisms, etc.) belong further downstream once they materialise.