Documentation

CslibFrontier.Computability.Complexity.Classes.CountingHierarchy.ResidueSign

Integer signs from uniform modular residues #

The general window operations consume only a residue evaluator, short binary cutoffs and doubling limit, and a unary dyadic precision. Cofactors and weighted residues cost F_max(a,5), the rounded sum costs one more level, and first-flag classification costs two more. The represented integer, its magnitude bound 2^m, and the full prime product are never machine data. The same total evaluators serve every modulus and doubling index.

The IntegerResidueAccess application chooses the manuscript parameters and proves correctness from the access contract, including zero, negative integers and excluded small primes. The binary magnitude exponent and excluded-prime cutoff may have exponential values.

Main definitions #

Main results #

References #

noncomputable def Cslib.Complexity.residueWindowNumerator (Y L B : ℕ) (residue : ℕ → ℕ) (k : ℕ) :

Approximate weighted residues on the selected prime window using natural arithmetic. The zero-masked sum has no input containing a full integer or full modulus product.

noncomputable def Cslib.Complexity.residueWindowSign (Y L B K : ℕ) (residue : ℕ → ℕ) :

Total first-flag classifier with arbitrary window, precision and doubling limit. Correct integer-sign behavior requires the numerical CRT conditions; the computational certificate holds for all parameters. The endpoint includes K.

theorem Cslib.Complexity.residueWindowNumerator_eq_crt (Y L B k : ℕ) (residue : ℕ → ℕ) :
↑(residueWindowNumerator Y L B residue k) / 2 ^ B = crtCircleApprox (fun (p : ↥(Y.primesLE \ L.primesLE)) => ↑↑p) B fun (p : ↥(Y.primesLE \ L.primesLE)) => ↑(primeWindowCoefficient Y L (↑p) k (residue ↑p))

The natural approximation is exactly the rational CRT approximation of its coefficients.

Uniform residue access gives dyadic numerator access in F_(max(a,5)+1). The primary instance is paired with one binary doubling index; all moduli use one evaluator.

Uniform residue access, binary window/limit preparation and unary precision give the total window classifier in F_(max(a,5)+3). Correctness is independent of this cost certificate.

noncomputable def Cslib.Complexity.IntegerResidueAccess.primeWindowSign {α : Type} {X : α → ℤ} (R : IntegerResidueAccess X) (L : α → ℕ) (w : α) :

Recover a sign using the manuscript window derived from the access bound and an excluded prime cutoff. Only bound/residue operations are read from the access record.

The computed window classifier has the asserted level on every input, even before the residue correctness domain is checked. All query sizes follow from strict composition.

theorem Cslib.Complexity.IntegerResidueAccess.primeWindowSign_eq_sign {α : Type} {X : α → ℤ} (R : IntegerResidueAccess X) (L : α → ℕ) (w : α) (hcover : ∀ p ∈ PrimeWindowSign.primes (R.magnitudeExponent w) (L w), R.admissible w p) :
R.primeWindowSign L w = (X w).sign

Correctness for all signs, including zero. Only prime moduli in the stated window need belong to the access domain; no admissibility recognizer is used by the algorithm.

theorem Cslib.Complexity.IntegerResidueAccess.sign_mem_CountingFunction {α : Type} {X : α → ℤ} {enc : α ↪ List Bool} {a : ℕ} (D : Turing.MultiTapeTM.Decoder enc) (R : IntegerResidueAccess X) (hR : R.InCountingFunction a enc) {L : α → ℕ} (hL : Turing.MultiTapeTM.ComputableInPolyTime L enc Turing.MultiTapeTM.encNat) (hcover : ∀ (w : α), ∀ p ∈ PrimeWindowSign.primes (R.magnitudeExponent w) (L w), R.admissible w p) :
(fun (w : α) => (X w).sign) ∈ CountingFunction (max a 5 + 3) enc Turing.MultiTapeTM.encIntBin

Sign from modular residues, with the manuscript's F_(max(a,5)+3) bound. The bound exponent and excluded cutoff are polynomial-time binary values and may be exponentially large. Residues are supplied by one fixed F_a evaluator; every prime in the specified window must be admissible. No full integer or prime product is constructed.