Documentation

CslibFrontier.Foundations.NumberTheory.CRTSign

Integer sign correctness from weighted CRT residues #

crtCircleApprox consumes only moduli, weighted residues and a precision. The integer being represented and the full modulus product occur only in correctness statements. For pairwise coprime positive moduli, numerical magnitude and cutoff bounds, and sufficient precision, crt_firstCircleFlag_sign proves that a nonzero integer has a first flag whose side of one half gives its sign. crtCircleApprox_not_flag_zero handles zero.

This is the mathematical sign-recovery layer of Section 2 of [OAI26f], used in Appendix A's sign step. The theorem is generic in moduli and all numerical parameters. It does not establish a prime-window product bound, certify computation of the weighted residues, or claim membership in a complexity class.

Main definitions #

Main results #

References #

def Cslib.crtCircleApprox {ι : Type u_1} [Fintype ι] (m : ι → ℤ) (B : ℕ) (c : ι → ℤ) :

Approximate the normalized weighted CRT residue sum modulo one. No represented integer or full product is an input to this operation.

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

A zero represented integer cannot produce a flag, for any valid weighted CRT residues.

theorem Cslib.crt_firstCircleFlag_sign {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m : ι → ℤ) (c : ℕ → ι → ℤ) (X : ℤ) (B K : ℕ) {a ε t : ℚ} (hm : ∀ (i : ι), 0 < m i) (hcop : Pairwise fun (i j : ι) => IsCoprime (m i) (m j)) (hc : ∀ k ≤ K, ∀ (i : ι), c k i * crtCofactor m i ≡ 2 ^ k * X [ZMOD m i]) (hX : X ≠ 0) (hmag : |↑X| < a * ↑(∏ i : ι, m i)) (hcut : a * ↑(∏ i : ι, m i) ≤ 2 ^ K) (hprec : ↑(Fintype.card ι) / 2 ^ B < ε) (ht : 0 < t) (hε : ε < t) (hlo : t + ε ≤ a) (hhi : 2 * a + ε ≤ 1 / 2) :
∃ k ≤ K, FirstCircleFlag t (fun (j : ℕ) => crtCircleApprox m B (c j)) k ∧ (0 < X ↔ crtCircleApprox m B (c k) < 1 / 2) ∧ (X < 0 ↔ 1 / 2 < crtCircleApprox m B (c k))

Integer first-flag correctness from local weighted CRT congruences. The magnitude bound is |X| < a Π, and the cutoff is a Π ≤ 2ᴷ; integrality of a nonzero X supplies the missing lower magnitude bound. Neither X nor Π is algorithm data. The local congruences can be supplied by crtCoefficient_modEq and modular multiplication.