Documentation

CslibFrontier.Computability.Circuit.Boolean.ThresholdReconstruction

Exact thresholds from approximate thresholds and a residue #

The reconstruction step in [Ser25b], §2, equation (2), printed p. 10, combines two approximate comparisons with a modular interval test. The first comparison is false at weights w + 2 * t ≤ k and true at weights k ≤ w; the second is false at w ≤ k and true at k + 2 * t ≤ w. Values between the respective boundaries are unrestricted. A majority of the two comparisons and the modular test recovers the exact threshold k ≤ w when 4 * t ≤ R.

The modular test uses the image of the integer interval [k, k + 2 * t] modulo R. It therefore works when that interval crosses a multiple of R. The lower-zero condition uses w + 2 * t ≤ k, so it also handles k < 2 * t without interpreting a negative endpoint as truncated subtraction.

ThresholdReconstruction.circuit composes native De Morgan circuits for the three input bits with the existing five-gate majority formula. The composition costs exactly five additional gates and at most three additional levels. This is the reconstruction step of Claim 2, not its Chinese-remainder conversion or the full asymptotic formula bounds; those remain in issue #7708.

Main definitions #

Main results #

References #

The weight residue belongs to the image of [k, k + 2 * t] modulo R.

theorem Cslib.Circuits.Boolean.ThresholdReconstruction.maj3_eq_threshold_of_approx {k t R w : ℕ} (lower upper : Bool) (hR : 4 * t ≤ R) (hlower_zero : w + 2 * t ≤ k → lower = false) (hlower_one : k ≤ w → lower = true) (hupper_zero : w ≤ k → upper = false) (hupper_one : k + 2 * t ≤ w → upper = true) :
maj3 lower upper (residueTest k t R w) = decide (k ≤ w)

The majority reconstruction step of [Ser25b], §2, equation (2). It is a finite composition identity, not the paper's asymptotic depth bound. The approximation promises are stated only at this weight, and place no conditions on either bit inside its uncertainty interval.

Run the two approximate comparisons and the residue test, then take their majority. All three component circuits run on the same n input bits.

@[simp]
theorem Cslib.Circuits.Boolean.ThresholdReconstruction.eval_circuit {n : ℕ} (lower upper residue : Circuit signature n 1) (x : BitString n) (o : Fin 1) :
(circuit lower upper residue).eval interpretation x o = maj3 (lower.eval interpretation x 0) (upper.eval interpretation x 0) (residue.eval interpretation x 0)

The reconstruction circuit takes the majority of the three component outputs.

@[simp]
theorem Cslib.Circuits.Boolean.ThresholdReconstruction.size_circuit {n : ℕ} (lower upper residue : Circuit signature n 1) :
(circuit lower upper residue).size = lower.size + upper.size + residue.size + 5

Reconstruction adds exactly five De Morgan gates to the three component circuits.

theorem Cslib.Circuits.Boolean.ThresholdReconstruction.depth_circuit_le {n : ℕ} (lower upper residue : Circuit signature n 1) :
(circuit lower upper residue).depth ≤ max (max lower.depth upper.depth) residue.depth + 3

Reconstruction adds at most three levels to the largest component depth.

theorem Cslib.Circuits.Boolean.ThresholdReconstruction.computes_threshold_of_approx {n : ℕ} (lower upper residue : Circuit signature n 1) {k t R : ℕ} (hR : 4 * t ≤ R) (hlower_zero : ∀ (x : Fin n → Bool), BitString.weight x + 2 * t ≤ k → lower.eval interpretation x 0 = false) (hlower_one : ∀ (x : Fin n → Bool), k ≤ BitString.weight x → lower.eval interpretation x 0 = true) (hupper_zero : ∀ (x : Fin n → Bool), BitString.weight x ≤ k → upper.eval interpretation x 0 = false) (hupper_one : ∀ (x : Fin n → Bool), k + 2 * t ≤ BitString.weight x → upper.eval interpretation x 0 = true) (hresidue : ∀ (x : Fin n → Bool), residue.eval interpretation x 0 = residueTest k t R (BitString.weight x)) :
(circuit lower upper residue).Computes interpretation (single (threshold n k))

Correctness of the native reconstruction step. The supplied circuits may behave arbitrarily inside their uncertainty intervals; the resulting circuit computes the total exact threshold. The residue circuit must compute the modular interval test, including wraparound. This is the finite composition step of Claim 2, not construction of its three prerequisite circuits.