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

ℚ — rationals as numerator/denominator pairs. More...

#include <bit>
#include <compare>
#include <concepts>
#include <cstdint>
#include <functional>
#include <limits>
#include <numeric>
#include <stdexcept>
#include <type_traits>
#include <utility>
import dedekind.sets;
import dedekind.order;
import dedekind.morphologies;
import dedekind.category;
import dedekind.numbers:integer;
import dedekind.algebra;
Include dependency graph for rational.cppm:

Classes

class  dedekind::numbers::Rational< Z >
 The Field of Fractions over an Integral Domain Z. More...
struct  dedekind::numbers::detail_rational::is_rational< typename >
struct  dedekind::numbers::detail_rational::is_rational< Rational< Z > >
struct  dedekind::numbers::PartialAddRational< I >
 Partial addition transform for Rational. More...
struct  dedekind::numbers::PartialMulRational< I >
 Partial multiplication transform for Rational. More...
struct  dedekind::numbers::HonestDivRational< I >
 Division transform for Rational. More...
struct  dedekind::numbers::PartialEmbedIntegerToRational< I >
 Identity and Associativity traits for Rational arithmetic. More...
struct  dedekind::category::is_exact_total< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
struct  dedekind::category::is_exact_total< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > > >
struct  dedekind::category::unit_trait< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
struct  dedekind::category::unit_trait< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > > >
struct  dedekind::category::is_linear_action< dedekind::numbers::Rational< I >, I, std::plus< dedekind::numbers::Rational< I > >, std::plus< I >, std::multiplies< I >, std::multiplies<> >
struct  dedekind::category::inverse_trait< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
struct  dedekind::algebra::is_translation_invariant_ordered< dedekind::numbers::Rational< I > >
struct  dedekind::algebra::is_scaling_invariant_ordered< dedekind::numbers::Rational< I > >
struct  dedekind::category::is_homomorphism< std::decay_t< decltype(dedekind::numbers::embed_ℤ_ℚ_)>, dedekind::numbers::default_integer, std::plus< dedekind::numbers::default_integer >, std::plus< dedekind::numbers::Rational< dedekind::numbers::default_integer > > >
 ℤ ↪ ℚ preserves \(+,\times,0,1\) — the field-of-fractions ring embedding, between two strict-total algebras: ℤ is category::IsRing (saturating totality, :cardinality) and ℚ is category::IsField (exact totality, registered in this partition). So the declarations here make a fully-certified ring homomorphism, not merely an operational declaration. More...
struct  dedekind::category::is_homomorphism< std::decay_t< decltype(dedekind::numbers::embed_ℤ_ℚ_)>, dedekind::numbers::default_integer, std::multiplies< dedekind::numbers::default_integer >, std::multiplies< dedekind::numbers::Rational< dedekind::numbers::default_integer > > >
struct  dedekind::category::SpeciesTraits< dedekind::numbers::Rational< Z > >

Namespaces

namespace  dedekind::numbers
namespace  dedekind::category

Concepts

concept  dedekind::numbers::RejectsNonFinite
 The rejection contract a saturating backing must offer ℚ's tripwire: is_finite(i), found by ADL, says whether i is a point of ℤ or a sentinel (±ℵ_0 / NaZ). Rational rejects a non-finite value wherever one can arise (construction, comparison); a saturating carrier without this hook would clamp silently and is not admitted as a backing (see FractionBacking).
concept  dedekind::numbers::IsRational
 Q is the rational field Rational<Z> — the canonical exact, dense, strongly-ordered coefficient carrier. Used to gate the real carriers (Cut, QuadraticReal): over \(\mathbb{Q}\) a nonsquare integer D has \(\sqrt D\notin\mathbb{Q}\) (a theorem), so those carriers are genuine (canonical representation, sound conjugate/norm) — which fails for a coefficient field that already contains \(\sqrt D\) (e.g. the degenerate QuadraticReal<2, QuadraticReal<2>>).
concept  dedekind::category::FractionBacking
 An integer backing over which fraction arithmetic obeys ℚ's laws under Op: it does not wrap, so a wrapped intermediate cross-product cannot silently break a law. Either it is exact, or it saturates and offers the is_finite hook (RejectsNonFinite) through which ℚ's tripwire rejects the saturated value instead of clamping.

Typedefs

using dedekind::numbers::machine_integer = int
template<IsInteger I = default_integer>
using dedekind::numbers::RationalPolynomial = dedekind::algebra::Polynomial<Rational<I>>
 The polynomial ring over the rationals in one variable, ℚ[x]: algebra::Polynomial over the quotient field of the integer carrier I.

Variables

template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_kleene_associative_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialAddRational< I > >
 Kleene traits for rational arithmetic.
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_kleene_commutative_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialAddRational< I > >
template<dedekind::morphologies::IsInteger I>
constexpr dedekind::numbers::Rational< I > dedekind::category::partial_unit_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialAddRational< I > >
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_kleene_associative_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialMulRational< I > >
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_kleene_commutative_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialMulRational< I > >
template<dedekind::morphologies::IsInteger I>
constexpr dedekind::numbers::Rational< I > dedekind::category::partial_unit_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialMulRational< I > >
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_kleene_associative_v< dedekind::numbers::Rational< I >, dedekind::numbers::PartialEmbedIntegerToRational< I > > = true
 Kleene traits for integer→rational embedding (exact).
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_reflexive_v< dedekind::numbers::Rational< I >, std::less_equal<> > = true
 Ordering traits: Rational is a total order (ℚ ≤ is a chain).
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_transitive_v< dedekind::numbers::Rational< I >, std::less_equal<> > = true
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_antisymmetric_v< dedekind::numbers::Rational< I >, std::less_equal<> >
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_connex_v< dedekind::numbers::Rational< I >, std::less_equal<> > = true
template<typename I>
constexpr bool dedekind::category::is_associative_v< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
template<typename I>
constexpr bool dedekind::category::is_associative_v< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > > > = true
template<typename I>
constexpr bool dedekind::category::is_commutative_v< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
template<typename I>
constexpr bool dedekind::category::is_commutative_v< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > > > = true
template<typename I>
constexpr bool dedekind::category::is_distributive_v< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > >, std::plus< dedekind::numbers::Rational< I > > > = true
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_invertible_v< dedekind::numbers::Rational< I >, std::plus< dedekind::numbers::Rational< I > > >
template<dedekind::morphologies::IsInteger I>
constexpr bool dedekind::category::is_invertible_v< dedekind::numbers::Rational< I >, std::multiplies< dedekind::numbers::Rational< I > > > = true
constexpr 𝔸< Rational< default_integer >, Boole, ℵ_0 > dedekind::numbers::ℚ
 The canonical rational-number universe ℚ = 𝔸<Rational<default_integer>> (post-#559).
constexpr auto dedekind::numbers::embed_ℤ_ℚ_
 Restored variant-layer subalgebra embedding ℤ ↪ ℚ: SignedCardinality → Rational<default_integer>, \(n\mapsto n/1\).
template<>
constexpr bool dedekind::category::is_monic_arrow_v< std::decay_t< decltype(dedekind::numbers::embed_ℤ_ℚ_)> >
 ℤ ↪ ℚ is monic: \(n/1 = m/1 \iff n = m\).
template<>
constexpr bool dedekind::category::is_monotone_v< std::decay_t< decltype(dedekind::numbers::embed_ℤ_ℚ_)>, std::less_equal<> >
 ℤ ↪ ℚ preserves order — the monotonicity the strength-reduction pullback rests on.
template<IsInteger I = default_integer>
constexpr auto dedekind::numbers::embed_𝕃_ℚ
 Exact dyadic embedding of the finite doubles into ℚ: 𝕃<double> → Rational.
template<>
constexpr bool dedekind::category::is_monic_arrow_v< std::decay_t< decltype(dedekind::numbers::embed_𝕃_ℚ<>)> >
 The finite doubles embed injectively into ℚ: distinct finite doubles have distinct dyadic values (-0.0 and +0.0 are one element of 𝕃).

Detailed Description

ℚ — rationals as numerator/denominator pairs.

@partition :rational

Note
"Lectio mathematica nihil aliud est, quam meditatio cum calamo coniuncta." — Leonhard Euler, paraphrase from the preface of Introductio in analysin infinitorum (1748). [Trans: "Reading mathematics is nothing other than meditation conjoined with the pen."]