Documentation

CslibFrontier.Foundations.NumberTheory.CRTCircle

Chinese remaindering on the rational circle #

For pairwise coprime positive integer moduli, normalized CRT coefficients sum to the represented integer divided by the product, modulo one. The product is a mathematical quantity in the correctness proof. The rounding operation only receives the coefficient fractions and its precision, and never constructs the represented integer or product.

This generalizes the mathematical CRT and rounding steps of Section 2 of [OAI26f]. Moduli need not be prime. The local inverse congruences are an access interface for modular arithmetic; the circle identity is proved here.

Main definitions #

Main results #

References #

def Cslib.crtCofactor {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m : ι → ℤ) (i : ι) :

The mathematical CRT cofactor, the product of all moduli except at index i.

theorem Cslib.mul_crtCofactor {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m : ι → ℤ) (i : ι) :
m i * crtCofactor m i = ∏ j : ι, m j

Multiplying the omitted modulus back into its cofactor recovers the full product.

Canonical CRT coefficient. The argument u is an inverse of the cofactor modulo m; its computation is deliberately separate from this residue operation.

theorem Cslib.crtCoefficient_mem {m : ℤ} (hm : 0 < m) (u n : ℤ) :

CRT coefficients lie in the canonical residue interval for positive moduli.

theorem Cslib.crtCoefficient_modEq (m u n a : ℤ) (hu : a * u ≡ 1 [ZMOD m]) :

A supplied modular inverse yields the local CRT congruence for the coefficient.

theorem Cslib.crt_circle_identity {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m c : ι → ℤ) (n : ℤ) (hm : ∀ (i : ι), 0 < m i) (hcop : Pairwise fun (i j : ι) => IsCoprime (m i) (m j)) (hc : ∀ (i : ι), c i * crtCofactor m i ≡ n [ZMOD m i]) :
∃ (z : ℤ), ∑ i : ι, ↑(c i) / ↑(m i) - ↑n / ↑(∏ i : ι, m i) = ↑z

CRT circle identity for arbitrary pairwise coprime positive integer moduli. Only the individual coefficient congruences are supplied; divisibility by the entire product and the identity modulo one are conclusions of the proof.

theorem Cslib.crt_dyadicCircleApprox_close {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m c : ι → ℤ) (n : ℤ) (B : ℕ) (hm : ∀ (i : ι), 0 < m i) (hcop : Pairwise fun (i j : ι) => IsCoprime (m i) (m j)) (hc : ∀ (i : ι), c i * crtCofactor m i ≡ n [ZMOD m i]) {ε : ℚ} (hε : ↑(Fintype.card ι) / 2 ^ B < ε) :
CircleClose ε (dyadicCircleApprox B fun (i : ι) => ↑(c i) / ↑(m i)) (↑n / ↑(∏ i : ι, m i))

Dyadic rounding of normalized CRT coefficients approximates the represented integer modulo the product, for every sign of the integer. The precision condition is explicit.