Batched routing with one sort and saved swaps #
Sort by matching key and source/destination tag, broadcast source values along equal-key runs, then reverse the saved swaps on the values alone. Every destination receives its answer at its original input position. Neither request identifiers nor unique restoration keys are needed. False tags designate sources; true tags designate destinations. Multiple matching sources contribute their bitwise OR. A unique matching source is copied exactly.
The circuit returns value fields only. Header bits can be retained directly from the input by free wiring; they need not travel through the reverse circuit. Source-position outputs retain the broadcast's prefix accumulations, so destination correctness is a relational invariant, not a pointwise description of the entire broadcast.
All gate costs are charged, including constants and negations. Saved controls include their complements. Gate counts do not certify construction runtime or retained storage.
Main definitions #
Cslib.Circuits.Boolean.routeValuesCircuit: one sort, shared broadcast, and reverse routing.
Main results #
Cslib.Circuits.Boolean.eval_routeValuesCircuit_value_eq_true_iff: destination OR semantics at the original input position.Cslib.Circuits.Boolean.eval_routeValuesCircuit_of_unique_source: exact source copying.Cslib.Circuits.Boolean.cost_program_routeValuesCircuit: exact arbitrary weighted gate cost.Cslib.Circuits.Boolean.size_routeValuesCircuit: exact total gate count.
References #
Simplifies the batched routing construction in S. Schlesinger, Boolean circuit mass production formalization, using the saved decisions of K. E. Batcher, Sorting Networks and Their Applications.
Sort once, broadcast matching source values, and undo saved swaps on the value fields.
Instances For
Exact weighted cost: one traced sort, shared broadcast, and reversal of the values only.
Each original destination receives the OR of matching original sources. Requests may repeat; no restoration keys, identifiers, rank calculations or source uniqueness are needed.
Exact gate count for routing values back to the original record positions.
A destination receives its unique matching source at its literal original input position.