Two-sort batched routing #
The first sort groups matching keys and places false-tagged sources before true-tagged requests. Shared broadcast replaces values while retaining every header bit. The second sort computes an arbitrary restoration key from each retained header. It does not rewrite headers or depend on the broadcast values.
Correctness is stated directly against the original unsorted input. Destination keys may repeat. Without source uniqueness, each destination receives the bitwise OR of all matching sources. A unique source is copied exactly. To recover a fixed output position, the client identifies a unique restoration key and counts the smaller keys in the original input.
Both sorts have 2 ^ depth records; padding is supplied by the caller. Keys and values may be
empty, selectors may repeat, and computed restoration keys are charged once per record.
Constants, negations and unused gates are included. The circuit constructor is executable;
these gate bounds do not certify its running time. Concrete table layout and padding bounds
for batched lookup are separate clients.
Main definitions #
Cslib.Circuits.Boolean.routeCircuit: the complete two-sort router.Cslib.Circuits.Boolean.routeCircuit.broadcast: matching sort and shared broadcast.
Main results #
Cslib.Circuits.Boolean.routeCircuit_headers_perm: all headers are retained.Cslib.Circuits.Boolean.eval_routeCircuit_value_eq_true_iff: destination OR semantics.Cslib.Circuits.Boolean.eval_routeCircuit_value_of_unique_source: fixed-position copying.Cslib.Circuits.Boolean.four_mul_cost_program_routeCircuit: exact weighted gate cost.Cslib.Circuits.Boolean.four_mul_size_routeCircuit: exact gate count.
References #
Adapts MassProduction/Nonuniform/BatchRouting.lean from S. Schlesinger, Boolean circuit mass production formalization. The computed-key sorting API preserves the original headers without a separate complementing pass.
Sort by matching key and tag, then broadcast values while retaining every header.
Instances For
Matching and broadcast preserve the multiset of complete headers.
Each destination after matching receives the OR of its original matching sources.
Sort, broadcast, then sort by a computed header key. Both sorts retain the original header.
Instances For
The complete router preserves the multiset of headers, including all routing metadata.
The final headers are ordered by the computed restoration key.
A destination receives the OR of matching original sources, even with repeated source keys.
A uniquely keyed destination header is restored to its rank in the original input.
At a fixed restored position, destination values are the OR of matching original sources.
A uniquely keyed destination copies its unique matching source to a fixed position.
Exact additive weighted cost of the two sorting circuits and shared broadcast.
Exact weighted cost, charging restoration keys once per record and all broadcast gates.