Balanced sums of carry-save pairs #
The existing half-split circuit tree reduces any list of carry-save pairs. Its value is their
sum modulo 2 ^ w, including the empty list. One carry-lookahead addition finishes the result.
These are the arithmetic reductions used by modular multiplication and GSW's selected-row product.
Main definitions #
Cslib.Circuits.Boolean.reducePairs: balanced four-to-two reduction on shared inputs.Cslib.Circuits.Boolean.sumPairs: reduction followed by logarithmic-depth addition.
Main results #
Cslib.Circuits.Boolean.pairVal_eval_reducePairs_mod: the sum of the supplied pair values.Cslib.Circuits.Boolean.val_eval_sumPairs: the resulting modular word.Cslib.Circuits.Boolean.depth_reducePairs_le: depth is logarithmic in the number of pairs.
References #
The underlying carry-save construction and source credit are in Boolean.CarrySave;
parallel-prefix finishing follows Ladner and Fischer.
@[simp]
theorem Cslib.Circuits.Boolean.eval_pairWithZero {n w : ℕ} (C : Circuit signature n w) (x : BitString n) :
(pairWithZero C).eval interpretation x = Fin.append (C.eval interpretation x) fun (x : Fin w) => false
theorem Cslib.Circuits.Boolean.pairVal_eval_pairWithZero {n w : ℕ} (C : Circuit signature n w) (x : BitString n) :
pairVal ((pairWithZero C).eval interpretation x) = ↑((BitString.equivFin w) (C.eval interpretation x))
@[simp]
Finishing a carry-save word computes its value modulo 2 ^ w.