Documentation

CslibFrontier.Computability.Circuit.Boolean.Selection

Selecting and packing bit-string records #

A record has a prefix key of k bits followed by a payload of p bits. Keys are unsigned numbers with the least significant bit first. Pairwise minimum selection retains the first record on equal keys, including empty keys. Packing places records in consecutive blocks.

Main definitions #

Main results #

References #

Adapted from Samuel Schlesinger's earlier Complexitylib modules Circuits/{KeyedMinimum,KeyedMinimumTournament}.

The key of a record: its first k bits.

def Cslib.BitString.keyedMinFn {k p : ℕ} (r s : BitString (k + p)) :
BitString (k + p)

Of two records, the one with the smaller key, the first on ties.

theorem Cslib.BitString.keyedMinFn_eq_or_eq {k p : ℕ} (r s : BitString (k + p)) :

The selected record is one of the two inputs.

The key of the selected record is at most the key of the first record.

The key of the selected record is at most the key of the second record.

def Cslib.BitString.packRecords {m r : ℕ} (records : Fin m → BitString r) :
BitString (m * r)

m records of r bits packed one after the other: bit j of record i is input finProdFinEquiv (i, j), that is i r + j.

theorem Cslib.BitString.packRecords_comp {m r : ℕ} (records : Fin m → BitString r) (i : Fin m) :
(packRecords records ∘ fun (j : Fin r) => finProdFinEquiv (i, j)) = records i

Reading block i of the packed records recovers record i.