Documentation

CslibFrontier.Computability.Complexity.Classes.CountingHierarchy.PrimeCofactor

Prime-window cofactors and weighted CRT residues #

primeCofactor Y L p computes the product of primes L < q ≤ Y, omitting p, modulo p. Its certificate is uniform F_5 for polynomial-time binary cutoffs and modulus. Weighted CRT coefficients additionally use a supplied residue and a binary exponent; an F_a residue gives an F_max(a,5) coefficient. Neither operation constructs a full prime product or represented integer. Nonprime moduli, including zero and one, return zero.

Main definitions #

Main results #

References #

Total test for membership in the prime window L < p ≤ Y, shared by cofactor factors and weighted-residue summation. All three arguments use their ordinary binary values.

The Boolean window test is exactly membership in the finite mathematical prime window.

noncomputable def Cslib.Complexity.primeCofactor (Y L p : ℕ) :

Product modulo p of the primes L < q ≤ Y other than p. Only binary-width indices are passed to the factor evaluator. Every nonprime modulus has the total default zero.

noncomputable def Cslib.Complexity.primeWindowCoefficient (Y L p k r : ℕ) :

Weighted CRT coefficient for the supplied natural residue r and doubling exponent k. All powering is modular. Its inputs contain neither an implicit integer nor a full cofactor.

theorem Cslib.Complexity.primeCofactor_cast {p : ℕ} [Fact (Nat.Prime p)] (Y L : ℕ) :
↑(primeCofactor Y L p) = ∏ q ∈ (Y.primesLE \ L.primesLE).erase p, ↑q

On a prime modulus, the computed residue casts to the mathematical erased-window product. No order between the cutoffs or membership of the modulus in the window is required.

theorem Cslib.Complexity.primeCofactor_lt {p : ℕ} (hp : 0 < p) (Y L : ℕ) :

Cofactor residues are canonical at every positive modulus.

Nonprime and malformed moduli have cofactor default zero.

A cofactor is nonzero in every prime field: all its prime factors differ from the modulus.

theorem Cslib.Complexity.primeCofactor_eq_val {p : ℕ} [Fact (Nat.Prime p)] (Y L : ℕ) :
primeCofactor Y L p = (∏ q ∈ (Y.primesLE \ L.primesLE).erase p, ↑q).val

The natural cofactor output is the canonical representative of the mathematical product.

Weighted coefficients have the total default zero at every nonprime modulus.

theorem Cslib.Complexity.primeWindowCoefficient_lt {p : ℕ} (hp : 0 < p) (Y L k r : ℕ) :

Weighted coefficients are canonical natural residues at every positive modulus.

theorem Cslib.Complexity.primeWindowCoefficient_cast {p : ℕ} [Fact (Nat.Prime p)] (Y L k r : ℕ) :
↑(primeWindowCoefficient Y L p k r) = 2 ^ k * ↑r * (↑(primeCofactor Y L p))⁻¹

The weighted coefficient represents the modular power times the supplied residue, divided by the nonzero cofactor residue.

theorem Cslib.Complexity.primeWindowCoefficient_eq_val {p : ℕ} [Fact (Nat.Prime p)] (Y L k r : ℕ) :
primeWindowCoefficient Y L p k r = (2 ^ k * ↑r * (↑(primeCofactor Y L p))⁻¹).val

The natural coefficient is the canonical representative of its field formula.

@[simp]

A zero supplied residue gives a zero weighted coefficient at every modulus.

theorem Cslib.Complexity.primeWindowCoefficient_modEq {Y L p k r : ℕ} {X : ℤ} (hp : Nat.Prime p) (hr : ↑r ≡ X [ZMOD ↑p]) :
↑(primeWindowCoefficient Y L p k r) * ∏ q ∈ (Y.primesLE \ L.primesLE).erase p, ↑q ≡ 2 ^ k * X [ZMOD ↑p]

A supplied residue of any integer yields the weighted local CRT congruence. The integer, the full omitted-prime product and the full power occur only in this statement. The premise is exactly the shape of IntegerResidueAccess.residue_modEq.

theorem Cslib.Complexity.primeWindowCoefficient_modEq_subtype (Y L k r : ℕ) (p : ↥(Y.primesLE \ L.primesLE)) {X : ℤ} (hr : ↑r ≡ X [ZMOD ↑↑p]) :
↑(primeWindowCoefficient Y L (↑p) k r) * crtCofactor (fun (q : ↥(Y.primesLE \ L.primesLE)) => ↑↑q) p ≡ 2 ^ k * X [ZMOD ↑↑p]

Subtype-indexed local congruence, ready for crt_circle_identity and its sign callers. Every modulus in the prime window is prime; only the supplied residue's congruence is needed.

Uniform prime-window membership is F_1 for polynomial-time binary parameters. This certificate is shared by cofactor products and the final masked residue sum.

The uniform cofactor algorithm lies in F_5. The primality factor test is F_1 and the conservative product rule adds four levels. All three parameters have binary PT certificates.

An F_a supplied residue and PT binary cutoffs, modulus and exponent give a total weighted coefficient in F_max(a,5). Strict certificates charge intermediate residues, queries and outputs; no implicit integer or large mathematical product is supplied as machine data.