Correcting overlapping approximate counts #
This module proves the arithmetic correction step in the proof of Lemma 1 of [Ser25b], §3, pp. 12–13, and correctness of an explicit sequential reconstruction from independently rounded high parts. Each supplied approximation is either the true high part or its successor. Comparing two overlap bits determines whether to borrow from the previous high part or replace the new low block by the largest digit.
The arithmetic is stated for any positive radix; the paper uses radix 2 ^ s, with s ≥ 2.
The reconstruction computes from the supplied approximations alone: it does not inspect the true
value appearing in the correctness theorem. These are steps toward the paper's approximate
counting construction, not its parallel per-block depth bound. The remaining construction and
depth estimates are tracked in issue #7708.
Main definitions #
Cslib.Circuits.Boolean.ApproximateCount.correctBlock: the overlap correction rule.Cslib.Circuits.Boolean.ApproximateCount.reconstruct: sequential reconstruction from rounded high parts, most significant first.Cslib.Circuits.Boolean.ApproximateCount.borrowFormula: a constant-size De Morgan formula for the correction bit, with the low two bits of each overlap as inputs.
Main results #
Cslib.Circuits.Boolean.ApproximateCount.extend_correctBlock_of_rounding: one correction step preserves the one-sided error of at most one.Cslib.Circuits.Boolean.ApproximateCount.reconstruct_of_rounding: the same invariant for any number of blocks, with outputs tied to the supplied approximations.Cslib.Circuits.Boolean.ApproximateCount.eval_borrowFormula_overlap: the native formula computes exactly the correction bit chosen bycorrectBlock.
References #
One low radix digit and a borrow to apply to the already reconstructed high part.
Instances For
Append a corrected low digit to a high part, using natural subtraction for the borrow.
The arithmetic rule in Sergeev's proof of Lemma 1: compare the residues modulo four of
high and estimate / radix. Borrow when the former is one ahead; replace the low digit by
radix - 1 when the latter is one ahead.
Boolean semantics of the overlap comparison. The word order is low bit first.
The correction-bit formula has twenty-two De Morgan operation nodes.
The correction-bit formula has depth at most eight, independently of the block width.
Feeding the actual two-bit overlaps to the native formula computes the borrow selected by
correctBlock; this links the Boolean realization to the arithmetic correction.
The corrected low digit is a radix digit, even without the approximation invariant.
An arithmetic step in Sergeev's approximate-count construction, not its depth bound.
If high approximates value / radix and estimate approximates value, both by rounding
up by at most one, the explicitly corrected extension still equals value or value + 1.
No approximation or correction is selected by the conclusion.
Reconstruct the low value from levels + 1 rounded high-part estimates. estimate i
approximates the value divided by radix ^ i; the highest estimate initializes the recursion.
The algorithm has no access to the true value.
Sequential correctness of the block reconstruction, an arithmetic step toward Sergeev's Lemma 1. This does not assert that the sequential reconstruction has the paper's parallel depth. Every approximation used by the algorithm is constrained, including the initial high part.