Finding and selecting a colliding pair #
After sorting, two different records with equal keys force an adjacent pair of different records
with that key, even when complete records repeat (adjacent_distinct_collision). A linear scan
then retains the last flagged record (chooseRecord), at four gates per record bit
(synthesis_chooseRecord). The scan works with any number of flagged records and avoids an
all-pairs priority test.
Main definitions #
Cslib.Circuits.Boolean.Iteration.chooseRecord: the last flagged record, or a fallback.
Main results #
Cslib.Circuits.Boolean.Iteration.adjacent_distinct_collision: sorting makes a collision between different records adjacent.Cslib.Circuits.Boolean.Iteration.chooseRecord_spec: a flagged record is selected if any.Cslib.Circuits.Boolean.Iteration.synthesis_chooseRecord: the cost of the scan.Cslib.Circuits.Boolean.Iteration.synthesis_flaggedRecords: construct and select records, sharing each flag across the output bits.
References #
- Adapted from lean/Proofs/{Collisions,Selection}.lean in S. Schlesinger, Square-root circuit bounds for iterated functions.
Adjacent collisions #
A sorter preserving complete records makes some collision between different records adjacent, with the original key. Identical adjacent records can therefore be rejected safely.
Selecting a flagged record #
If no record is flagged, the scan returns the fallback.
Selecting among available records costs four gates per record bit.
Construct all flagged records and select one, sharing every flag across its output bits. The all-false fallback is an already available constant.