Documentation

CslibFrontier.Foundations.NumberTheory.PrimeWindowSign

First-flag sign correctness at the manuscript's prime cutoff #

For magnitude bound m and excluded prime bound L, put Z = max 16 (max m L) and Y = 2 * Z ^ 4. The indices are exactly the primes L < p ≤ Y, with integer moduli p. Their positivity, pairwise coprimality, product bounds and the dyadic precision estimate discharge the numerical hypotheses of Cslib.crt_firstCircleFlag_sign at threshold 1/6, error 1/1024, flag margin 1/8, precision Y.size + 10 and cutoff Y * Y.size + 1.

This is a mathematical step of [OAI26f], Section 2, Proposition 2.6 (Sign from residues). The theorems assume local weighted-coefficient congruences. They do not compute the coefficients or prove the proposition's complexity-class bound. The represented integer and the full prime product are used only in correctness statements and proofs.

Main definitions #

Main results #

References #

The prime cutoff for the magnitude bound m and excluded prime bound L.

The prime window excludes L and includes the upper cutoff.

def Cslib.PrimeWindowSign.modulus (m L : ℕ) (p : ↥(primes m L)) :

A prime index, cast to the integer modulus required by the CRT API.

theorem Cslib.PrimeWindowSign.prime (m L : ℕ) (p : ↥(primes m L)) :

Every index of the sign-recovery window is a prime.

theorem Cslib.PrimeWindowSign.modulus_pos (m L : ℕ) (p : ↥(primes m L)) :
0 < modulus m L p

Every modulus in the sign-recovery window is positive.

theorem Cslib.PrimeWindowSign.moduli_pairwise_coprime (m L : ℕ) :
Pairwise fun (p q : ↥(primes m L)) => IsCoprime (modulus m L p) (modulus m L q)

Distinct prime indices give pairwise coprime integer moduli.

theorem Cslib.PrimeWindowSign.precision_error_lt (m L : ℕ) :
↑(Fintype.card ↥(primes m L)) / 2 ^ ((cutoff m L).size + 10) < 1 / 1024

Precision Y.size + 10 gives total rounding error strictly below 1/1024.

theorem Cslib.PrimeWindowSign.magnitude_lt (m L : ℕ) (X : ℤ) (hX : |X| ≤ 2 ^ m) :
|↑X| < 1 / 6 * ↑(∏ p : ↥(primes m L), modulus m L p)

The magnitude hypothesis implies the strict starting bound for the CRT doubling argument.

theorem Cslib.PrimeWindowSign.product_cutoff_le (m L : ℕ) :
1 / 6 * ↑(∏ p : ↥(primes m L), modulus m L p) ≤ 2 ^ (cutoff m L * (cutoff m L).size + 1)

The manuscript doubling limit is large enough to reach the magnitude window.

theorem Cslib.PrimeWindowSign.firstCircleFlag_sign_of_coefficients (m L : ℕ) (c : ℕ → ↥(primes m L) → ℤ) (X : ℤ) (hbound : |X| ≤ 2 ^ m) (hX : X ≠ 0) (hc : ∀ k ≤ cutoff m L * (cutoff m L).size + 1, ∀ (p : ↥(primes m L)), c k p * crtCofactor (modulus m L) p ≡ 2 ^ k * X [ZMOD modulus m L p]) :
∃ k ≤ cutoff m L * (cutoff m L).size + 1, FirstCircleFlag (1 / 8) (fun (j : ℕ) => crtCircleApprox (modulus m L) ((cutoff m L).size + 10) (c j)) k ∧ (0 < X ↔ crtCircleApprox (modulus m L) ((cutoff m L).size + 10) (c k) < 1 / 2) ∧ (X < 0 ↔ 1 / 2 < crtCircleApprox (modulus m L) ((cutoff m L).size + 10) (c k))

Mathematical first-flag correctness from supplied weighted coefficients. The local congruences are the sole component-specific premise: all prime-window, magnitude, precision and cutoff conditions are proved here. No computational bound is claimed.

theorem Cslib.PrimeWindowSign.not_flag_zero_of_coefficients (m L : ℕ) (c : ↥(primes m L) → ℤ) (hc : ∀ (p : ↥(primes m L)), c p * crtCofactor (modulus m L) p ≡ 0 [ZMOD modulus m L p]) :
¬CircleFlag (1 / 8) (crtCircleApprox (modulus m L) ((cutoff m L).size + 10) c)

Any supplied coefficients representing zero yield no flag, at the manuscript precision.