Tournaments: selecting a record with the least key #
Records made of a key of k bits, read as a number with the least significant bit first, and a
payload of p bits are compared by their keys. A tournament plays keyed minimums
(keyedMinCircuit k p) along a balanced binary tree (Circuit.balanced): the winner of each match,
the record with the smaller key, meets the winner of the neighbouring match. On m + 1 records it
outputs one of them whose key is the least (exists_eval_tournamentCircuit), with m keyed
minimums, that is m (8 k + 3 p + 2) gates beyond those computing the records
(size_tournamentCircuit), and depth at most (4 k + 4) ⌈log₂ (m + 1)⌉ above them
(depth_tournamentCircuit_le).
The records may be computed by any circuits on shared inputs, or read from the inputs, packed one
after the other (packedTournamentCircuit). There is always at least one record; m = 0
returns the sole leaf circuit, and the packed version uses wiring alone. The least-key theorem
does not specify which tied record wins.
Main definitions #
Cslib.Circuits.Boolean.tournamentCircuit: the tournament among records computed by circuits.Cslib.BitString.packRecords,Cslib.Circuits.Boolean.packedTournamentCircuit: the tournament among records given as inputs.
Main results #
Cslib.Circuits.Boolean.exists_eval_tournamentCircuit,Cslib.Circuits.Boolean.exists_eval_packedTournamentCircuit: the winner is a record with the least key.Cslib.Circuits.Boolean.size_tournamentCircuit,Cslib.Circuits.Boolean.size_packedTournamentCircuit:mkeyed minimums form + 1records.Cslib.Circuits.Boolean.depth_tournamentCircuit_le,Cslib.Circuits.Boolean.depth_packedTournamentCircuit_le: logarithmic depth.
References #
Adapted from Samuel Schlesinger's earlier Complexitylib module
Circuits/KeyedMinimumTournament.
The tournament selects a least key. Its output is the record computed by one of the circuits, whose key is at most the key of every record.
A tournament has logarithmic depth. Among m + 1 records computed by circuits of depth at
most D, it has depth at most D + (4 k + 4) ⌈log₂ (m + 1)⌉.
Records given as inputs #
The packed tournament selects a least key.