1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
//! The canonical embedding ℤ ↪ ℚ.
use crate::;
use PhantomData;
use ;
/// The canonical embedding **ℤ ↪ ℚ**, `n ↦ n/1`.
///
/// This is the map that motivated giving morphisms a home. It is injective and **not** surjective —
/// `1/2` has no integer preimage — so it can never be an isomorphism, and the pair-shaped
/// `*Iso` traits could not express it. The body already existed as
/// [`Rational::from_integer`](crate::Rational::from_integer); this states what it is.
///
/// # Why it is a `RingHom`
///
/// `(a + b)/1 = a/1 + b/1`, `(a·b)/1 = (a/1)·(b/1)`, and `1 ↦ 1/1`. Every rational built this way
/// is already in canonical form, so no normalisation step can perturb the laws.
///
/// ℚ is the field of fractions of ℤ, and this is the embedding that makes it so.
///
/// # Panics
///
/// [`apply`](Hom::apply) panics on `T::MIN`. A canonical `Rational<T>` excludes a numerator of
/// `T::MIN` so that negation stays total, so the domain this map covers is
/// `[T::MIN + 1, T::MAX]`. That is the fixed-width edge of the promise to ℤ, and
/// [`Rational::try_from_integer`](crate::Rational::try_from_integer) is the total form.
;
// Injective: `a/1 == b/1` forces `a == b`, since both sides are already canonical.
// Deliberately NOT `Surjective`: `1/2` is not `n/1` for any integer `n`.