Oblivious sorting-network layers #
This module lifts the verified two-record comparator to a full butterfly
layer on 2^(depth+1) records. The construction is explicit at the circuit
level and its cost is linear in the number of records times the local
comparator cost. Recursive Batcher merge and sort networks build on this
layer.
Recursive power-of-two record count.
Equations
Instances For
The record count doubles at successor depth.
Flat bit count of a power-of-two record array.
Equations
- Algebraic.MassProduction.Sorting.networkBits depth recordWidth = Algebraic.MassProduction.Sorting.networkRecords depth * recordWidth
Instances For
Embed a bit from the first half into the doubled record array.
Equations
- Algebraic.MassProduction.Sorting.firstHalfWire depth recordWidth input = Fin.cast ⋯ (Fin.castAdd (Algebraic.MassProduction.Sorting.networkBits depth recordWidth) input)
Instances For
Embed a bit from the second half into the doubled record array.
Equations
- Algebraic.MassProduction.Sorting.secondHalfWire depth recordWidth input = Fin.cast ⋯ (Fin.natAdd (Algebraic.MassProduction.Sorting.networkBits depth recordWidth) input)
Instances For
Restrict a flat record array to its first half.
Equations
- Algebraic.MassProduction.Sorting.firstHalfBits input = input ∘ Algebraic.MassProduction.Sorting.firstHalfWire depth recordWidth
Instances For
Restrict a flat record array to its second half.
Equations
- Algebraic.MassProduction.Sorting.secondHalfBits input = input ∘ Algebraic.MassProduction.Sorting.secondHalfWire depth recordWidth
Instances For
Concatenate two equal-depth flat record arrays.
Equations
- Algebraic.MassProduction.Sorting.joinHalfBits left right output = Fin.append left right (Fin.cast ⋯ output)
Instances For
Run one circuit on each half of a doubled flat record array.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Read one record from a flat row-major network array.
Equations
- Algebraic.MassProduction.Sorting.networkRecord input record bit = input (finProdFinEquiv (record, bit))
Instances For
Input wiring which gathers corresponding records from the two halves.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Ascending or descending local compare--exchange semantics.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Ascending or descending local compare--exchange circuit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One gathered pair comparator inside a butterfly layer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert the desired half-major output layout to the pair-major layout
emitted by parallelFinVector.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Semantic butterfly layer comparing corresponding records in the two halves.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Explicit circuit for one full butterfly compare layer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One layer is linear in its number of comparators.
Semantic bitonic merge on a power-of-two flat record array.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicMergeBits keyFits 0 x✝ input = input
Instances For
Semantic Batcher sorting network on a power-of-two record array.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicSortBits keyFits 0 x✝ input = input
Instances For
Gate count emitted by the recursive merge circuit.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicMergeGateCount keyFits 0 = 0
Instances For
Gate count emitted by the complete recursive sorter.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicSortGateCount keyFits 0 = 0
Instances For
Explicit recursive bitonic merge circuit.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicMergeCircuit keyFits 0 x✝ = Cslib.Circuits.Circuit.castCounts ⋯ ⋯ (Cslib.Circuits.Circuit.id Algebraic.DeMorgan.signature recordWidth)
Instances For
Explicit recursive Batcher sorting circuit.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicSortCircuit keyFits 0 x✝ = Cslib.Circuits.Circuit.castCounts ⋯ ⋯ (Cslib.Circuits.Circuit.id Algebraic.DeMorgan.signature recordWidth)
Instances For
Exact standard-cost recurrence for the recursive merge.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicMergeStandardCost keyFits 0 = 0
Instances For
Exact standard-cost recurrence for the complete sorter.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.MassProduction.Sorting.bitonicSortStandardCost keyFits 0 = 0
Instances For
The recursive merge emits exactly bitonicMergeGateCount gates.
The recursive sorter emits exactly bitonicSortGateCount gates.
At successor depth, the merge has one half-array of comparators at each recursive level.
Twice the exact sorter cost has a division-free closed form.
Standard-cost bound for Batcher sorting: number of records times the square of the recursion depth times one comparator cost.
Fully explicit polynomial gate-cost bound for the Boolean sorter.