Concrete scatter and gather record packing #
This module supplies the record-layout layer omitted by the generic routing
primitive. A record is laid out as (key, tag, payload). Source records use
tag false, destination records use tag true, and padding records are
required to use keys outside the active destination-key image.
The key and payload encodings are explicit functions, not typeclass-driven serializers. This keeps all finite encodings visible in theorem hypotheses.
Pack one standalone (key, tag, payload) record.
Equations
- Algebraic.MassProduction.Routing.packRecord key tag payload = Fin.append (Fin.append key fun (x : Fin 1) => tag) payload
Instances For
Concatenate incidence/source records, slot/destination records, and padding records in a fixed initial layout.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Routing-namespace compatibility theorem for preserving a unique left match when a match-free right sequence is appended.
Routing-namespace compatibility theorem for the symmetric right-match append rule.
Routing-namespace compatibility theorem for reindexing a unique match along an equality of lengths.
Every active source key has exactly one source record and exactly one destination record in the complete initial routing layout. Injectivity is requested only of the two active key families; padding records may repeat one another, but their keys must avoid every active source key.
Every destination key is unique in the complete layout independently of whether a matching source with that key exists.
Every source key is unique in the complete layout whenever the source-key family is injective. Destination and padding keys are irrelevant because their tag is different.
Exact network-capacity padding #
Position occupied by a source record in the unpadded semantic layout.
Equations
- Algebraic.MassProduction.Routing.routingSourceIndex source = Fin.castAdd paddingCount (Fin.castAdd destinationCount source)
Instances For
Position occupied by a destination record in the unpadded semantic routing layout.
Equations
- Algebraic.MassProduction.Routing.routingDestinationIndex destination = Fin.castAdd paddingCount (Fin.natAdd sourceCount destination)
Instances For
Position occupied by a padding record in the semantic routing layout.
Equations
- Algebraic.MassProduction.Routing.routingPaddingIndex padding = Fin.natAdd (sourceCount + destinationCount) padding
Instances For
Reindex an exactly padded semantic routing layout to the power-of-two record count consumed by the sorting network.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The source's position after the exact-capacity cast.
Equations
- Algebraic.MassProduction.Routing.networkRoutingSourceIndex recordCount source = Fin.cast recordCount (Algebraic.MassProduction.Routing.routingSourceIndex source)
Instances For
The destination's position after the exact-capacity cast.
Equations
- Algebraic.MassProduction.Routing.networkRoutingDestinationIndex recordCount destination = Fin.cast recordCount (Algebraic.MassProduction.Routing.routingDestinationIndex destination)
Instances For
The padding record's position after the exact-capacity cast.
Equations
- Algebraic.MassProduction.Routing.networkRoutingPaddingIndex recordCount padding = Fin.cast recordCount (Algebraic.MassProduction.Routing.routingPaddingIndex padding)
Instances For
Flattening semantic records into sorter input wires #
Row-major bit packing of an already constructed record sequence.
Equations
- Algebraic.MassProduction.Routing.recordArrayBits records flat = records (finProdFinEquiv.symm flat).1 (finProdFinEquiv.symm flat).2
Instances For
Flattening and then reading by records is an exact round trip.
Fully packed bit input for one exactly padded routing network.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every packed destination remains uniquely identifiable after exact capacity padding and flattening, even when no source uses its key.
Exact-capacity packing retains uniqueness of every source record.
The packed sorter input retains the unique source/destination invariant proved for the semantic record layout.
End-to-end scatter correctness for the concrete record layout. For every active source, the actual sorting-and-predecessor-copy circuit produces the source payload at the uniquely keyed destination record.