Linear scans for a least state and a first flagged position #
A linear scan keeps the least of a sequence of values (scanMin). For bit strings ordered
lexicographically with coordinate zero most significant (lexOrder), each step compares the next
state with the current minimum once and selects one of them, at 10 * n + 1 gates for n-bit
states (synthesis_scanMin). Scanning the records in reverse order selects the first flagged one
(chooseFirst), and the first flagged position, written in binary, costs four gates per
position and bit (synthesis_firstIndex).
All gates of the native De Morgan basis, including constants, are charged; wiring and fanout are free.
Main definitions #
Cslib.Circuits.Boolean.Iteration.lexOrder: the lexicographic order on bit strings.Cslib.Circuits.Boolean.Iteration.scanMin: the least of the first values and a fallback.Cslib.Circuits.Boolean.Iteration.chooseFirst: the first flagged record.Cslib.Circuits.Boolean.Iteration.firstIndex: the first flagged position as a word.
Main results #
Cslib.Circuits.Boolean.Iteration.scanMin_spec: the scan is a least value.Cslib.Circuits.Boolean.Iteration.chooseFirst_spec,firstIndex_spec: the first flagged record and position.Cslib.Circuits.Boolean.Iteration.synthesis_scanMin,Cslib.Circuits.Boolean.Iteration.synthesis_firstIndex: their gate counts.
References #
- Adapted from lean/Proofs/ScanSelection.lean in S. Schlesinger, Square-root circuit bounds for iterated functions.
The lexicographic order on bit strings, with coordinate zero most significant and false
below true.
Instances For
Least values #
The least of the values at positions below t and the fallback.
Instances For
The scan is the fallback or one of the scanned values, and below all of them.
Lexicographic comparison of two available bit strings, by the native comparison formula.
Minimum scan. The lexicographically least of R available states and a fallback costs
one comparison and one selection per state.
First flagged positions #
If position j is flagged and no later position below t is, the scan returns its record.
The first flagged position among R available flags costs four gates per position and
bit.