Rational reconstruction, height bounds, and Chinese-remainder recovery #
Implements Wang's extended-Euclidean rational reconstruction Rat.reconstruct over ℤ / Mℤ,
rational height bounds (Rat.height), uniqueness modulo M below the 2 * N * D < M threshold,
completeness of Euclidean reconstruction under height/denominator bounds, and multi-modulus
Chinese-remainder rational recovery (Rat.reconstructPi) across pairwise coprime moduli (such as
finite-field primes ZMod pᵢ).
Main definitions #
Rat.height: multiplicative rational heightmax q.num.natAbs q.den.Rat.reconstruct: extended-Euclidean rational reconstruction moduloMwith numerator boundNand denominator boundD.Rat.reconstructPi: Chinese-remainder rational reconstruction from residues modulo pairwise coprime modulim : Fin k → ℕ.
Main results #
Rat.eq_of_modEq_of_bounds,Rat.eq_of_modEq_of_height_mul_lt: modular uniqueness of rationals with bounded numerator/denominator or bounded height product.Rat.height_add_le,Rat.height_mul_le,Rat.height_inv: arithmetic height bounds.Rat.reconstruct_eq_some: soundness (numerator, denominator, coprimality, and modular congruence invariants of every reconstructed rational).Rat.reconstruct_of_eq: completeness (recoveringsome qwhenever2 * N * D < Mandq.den.Coprime M).Rat.reconstructPi_of_eq: exact recovery from residues in∀ i, ZMod (m i).
References #
Uniqueness of modular rational recovery: if a₁ * b₂ ≡ a₂ * b₁ [ZMOD M] with
|aᵢ| ≤ N, 0 < bᵢ ≤ D, and 2 * N * D < M, then (a₁ : ℚ) / b₁ = (a₂ : ℚ) / b₂.
Modular uniqueness stated directly in terms of rational heights: if p, q : ℚ satisfy
(p.num : ZMod M) * (q.den : ZMod M) = (q.num : ZMod M) * (p.den : ZMod M) and
2 * height p * height q < M, then p = q.
Wang's extended-Euclidean rational reconstruction modulo M. Returns some q when the
Euclidean sequence first reaches remainder r ≤ N with cofactor t satisfying |t| ≤ D and
Nat.Coprime t.natAbs M.
Soundness of Rat.reconstruct: every output q satisfies |q.num| ≤ N, q.den ≤ D,
Nat.Coprime q.den M, and q.num ≡ u * q.den [ZMOD M].
Completeness of Rat.reconstruct: if q : ℚ satisfies |q.num| ≤ N, q.den ≤ D,
2 * N * D < M, Nat.Coprime q.den M, and (u : ZMod M) represents q, then reconstruct
returns some q.
Chinese-remainder rational reconstruction from residues in ∀ i, ZMod (m i) across pairwise
coprime moduli m : Fin k → ℕ.
Completeness of Rat.reconstructPi: if ∏ i, m i > 2 * N * D, each m i is coprime to
q.den, and res i equals (q.num : ZMod (m i)) * (q.den : ZMod (m i))⁻¹ for every i, then
Rat.reconstructPi recovers some q.