Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
cyclic.cppm File Reference

Cyclic-morphology carriers and their concept witnesses. More...

#include <bit>
#include <compare>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <stdexcept>
#include <type_traits>
import dedekind.morphologies:archimedean;
import dedekind.algebra;
import dedekind.sets;
import dedekind.category;
Include dependency graph for cyclic.cppm:

Classes

class  dedekind::morphologies::CyclicRing< T, N >
 Minimal int-backed \(\mathbb{Z}/N\mathbb{Z}\) carrier from the experimental reintegration phase. Retained for parity with the existing test; Modular<N> below is the broader (auto-typed N) replacement. More...
struct  dedekind::morphologies::Modular< N >
 \(\mathbb{Z}/N\mathbb{Z}\) as a total finite cyclic ring. More...
struct  dedekind::morphologies::Congruence< N, R >
 The residue-class predicate \(x \equiv R \pmod N\): the characteristic map of the fiber of the reduction \(\mathbb{Z} \twoheadrightarrow \mathbb{Z}/N\mathbb{Z} =\) Modular<N> over the residue R. More...
struct  dedekind::morphologies::ModularCongruence< N >
 The binary congruence relation \(x \equiv y \pmod N\) on the integer carrier: the kernel of the reduction \(\mathbb{Z} \twoheadrightarrow \mathbb{Z}/N\mathbb{Z} =\) Modular<N>. More...
struct  dedekind::category::is_associative< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_commutative< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_associative< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_commutative< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_periodic< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_periodic< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::is_periodic< dedekind::morphologies::Modular< N >, std::minus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::unit_trait< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::unit_trait< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::SpeciesTraits< dedekind::morphologies::Modular< N > >
struct  dedekind::category::is_cyclic_group< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::cyclic_order< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > >
struct  dedekind::category::quotient_congruence< dedekind::morphologies::Modular< N > >
struct  dedekind::morphologies::first_iso_mod_2::mod_2_arrow
 The parity homomorphism mod_2: int → bool. More...
struct  dedekind::morphologies::first_iso_mod_2::connector
 Hand-rolled iso connector Modular<2> → bool. More...
struct  dedekind::morphologies::first_iso_mod_2::connector_inv
 Inverse direction: bool → Modular<2>. More...
struct  dedekind::category::kernel_quotient< dedekind::morphologies::first_iso_mod_2::mod_2_arrow >
struct  dedekind::category::image_carrier< dedekind::morphologies::first_iso_mod_2::mod_2_arrow >

Namespaces

namespace  dedekind::category
namespace  dedekind::morphologies::first_iso_mod_2

Typedefs

using dedekind::morphologies::𝔽ₚ = Modular<18446744073709551557ull>
 The largest prime field of a machine word: \(\mathbb{F}_p\) with \(p = 2^{64} - 59\), the largest prime below \(2^{64}\). The field beside the ring std::uint64_t \(= \mathbb{Z}/2^{64}\).

Functions

constexpr std::uint64_t dedekind::morphologies::detail_modular::mul_mod (std::uint64_t a, std::uint64_t b, std::uint64_t n)
 \(ab \bmod n\), through a 128-bit product.
constexpr std::uint64_t dedekind::morphologies::detail_modular::pow_mod (std::uint64_t b, std::uint64_t e, std::uint64_t n)
 \(b^e \bmod n\), by squaring.
constexpr bool dedekind::morphologies::detail_modular::witnesses_composite (std::uint64_t a, std::uint64_t d, unsigned s, std::uint64_t n)
 Whether a witnesses that the odd n is composite, with \(n - 1 = d \cdot 2^s\), d odd.
constexpr bool dedekind::morphologies::is_prime (std::uint64_t n)
 Whether n is prime: Miller–Rabin with the first twelve primes as witnesses, which decides every 64-bit n (J. Sorenson and J. Webster, "Strong pseudoprimes to twelve prime bases", Math. Comp. 86 (2017), 985–1003). constexpr, so a modulus in a type is certified by the compiler.
template<auto N>
constexpr Modular< N > dedekind::morphologies::nth_value (std::type_identity< Modular< N > >, std::uint64_t i)
 The i-th element of Modular<N> for a bounded search (sets:spans' search_value): the symmetric representatives in order of size, 0, 1, −1, 2, −2, …
constexpr connector_inv dedekind::morphologies::first_iso_mod_2::inverse (connector) noexcept
 Free-function inverse hook satisfying :morphism::IsIsomorphism.
constexpr connector dedekind::morphologies::first_iso_mod_2::inverse (connector_inv) noexcept

Variables

template<auto N>
constexpr bool dedekind::category::is_distributive_v< dedekind::morphologies::Modular< N >, std::multiplies<>, std::plus<> > = true
template<auto N>
constexpr bool dedekind::category::is_distributive_v< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > >, std::plus< dedekind::morphologies::Modular< N > > > = true
template<auto N>
constexpr bool dedekind::category::is_invertible_v< dedekind::morphologies::Modular< N >, std::plus< dedekind::morphologies::Modular< N > > > = true
template<auto N>
constexpr bool dedekind::category::is_invertible_v< dedekind::morphologies::Modular< N >, std::plus<> > = true
template<auto N>
constexpr bool dedekind::category::is_invertible_v< dedekind::morphologies::Modular< N >, std::multiplies< dedekind::morphologies::Modular< N > > >
template<auto N>
constexpr bool dedekind::category::is_invertible_v< dedekind::morphologies::Modular< N >, std::multiplies<> >
template<auto N>
constexpr bool dedekind::category::is_reflexive_v< typename dedekind::morphologies::Modular< N >::machine_type, dedekind::morphologies::ModularCongruence< N > > = true
template<auto N>
constexpr bool dedekind::category::is_symmetric_v< typename dedekind::morphologies::Modular< N >::machine_type, dedekind::morphologies::ModularCongruence< N > > = true
template<auto N>
constexpr bool dedekind::category::is_transitive_v< typename dedekind::morphologies::Modular< N >::machine_type, dedekind::morphologies::ModularCongruence< N > > = true
template<auto N>
constexpr bool dedekind::category::is_congruence_v< dedekind::morphologies::ModularCongruence< N >, typename dedekind::morphologies::Modular< N >::machine_type, std::plus< typename dedekind::morphologies::Modular< N >::machine_type > >
template<auto N>
constexpr bool dedekind::category::is_congruence_v< dedekind::morphologies::ModularCongruence< N >, typename dedekind::morphologies::Modular< N >::machine_type, std::multiplies< typename dedekind::morphologies::Modular< N >::machine_type > > = true
constexpr auto dedekind::morphologies::GF_p
 GF_p — the universe over the field, 𝔸 <𝔽ₚ>{}: the twin of Python's GF_p (A(𝔽ₚ)), named for the Galois field GF(p).

Detailed Description

Cyclic-morphology carriers and their concept witnesses.

@partition :cyclic

cyclic__Scope

Hosts the concrete cyclic-morphology carriers:

  • CyclicRing<T, N> — minimal int-backed \(\mathbb{Z}/N\mathbb{Z}\) experiment (kept for the existing test).
  • Modular<N> — the canonical finite cyclic ring \(\mathbb{Z}/N\mathbb{Z}\) (relocated from category:species; see #378); a field exactly when is_prime(N), decided by the compiler.
  • 𝔽ₚ — Modular<2^64 - 59>, the largest prime field of a machine word (#1019).

Both carriers expose the operational morphologies::IsCyclic shape (Domain, generator(), successor()). Only Modular<N> is additionally registered with the axiomatic dedekind::category::IsCyclicGroup<Modular<N>, std::plus<Modular<N>>> via the trait specialisations below; the complementary pairing is documented in morphologies:archimedean alongside IsCyclic itself.

Note
"Matematik esas olarak sabır olayıdır. Belleyerek değil keşfederek anlamak gerekir." — Cahit Arf, Turkish Wikiquote. [Trans: "Mathematics is essentially a matter of patience. One must understand by discovering, not by memorizing."]

Function Documentation

◆ is_prime()

bool dedekind::morphologies::is_prime ( std::uint64_t n)
constexprexport

Whether n is prime: Miller–Rabin with the first twelve primes as witnesses, which decides every 64-bit n (J. Sorenson and J. Webster, "Strong pseudoprimes to twelve prime bases", Math. Comp. 86 (2017), 985–1003). constexpr, so a modulus in a type is certified by the compiler.

Parameters
nthe candidate.
Returns
whether n is prime.

◆ nth_value()

template<auto N>
Modular< N > dedekind::morphologies::nth_value ( std::type_identity< Modular< N > > ,
std::uint64_t i )
constexprexport

The i-th element of Modular<N> for a bounded search (sets:spans' search_value): the symmetric representatives in order of size, 0, 1, −1, 2, −2, …

Parameters
ithe index.

Variable Documentation

◆ GF_p

auto dedekind::morphologies::GF_p
inlineconstexprexport
Initial value:
=
The universal set over the carrier T: the terminal object ⊤ of Sub(T), the reified type constraint.
Definition boundaries.cppm:296

GF_p — the universe over the field, 𝔸 <𝔽ₚ>{}: the twin of Python's GF_p (A(𝔽ₚ)), named for the Galois field GF(p).