Documentation

Complexity.Computability.Circuit.Boolean.Iteration.RecordCircuit

Gate counts for sorting and detecting records #

A family of records is available when every bit of every encoded record is (Record.wireSet). Sorting an available array inserts one Batcher circuit (Record.synthesis_sorted); its native gate count is at most 18 * d ^ 2 * 2 ^ d per record bit and comparison layer. Testing every adjacent pair for a collision and selecting one costs linearly in the array (Record.synthesis_detect).

Main definitions #

Main results #

References #

The coordinate functions of a family of bit strings.

Instances For
    theorem Cslib.Circuits.Boolean.Iteration.synthesis_bits_eq {n m : ℕ} (s : Set (BooleanFunction n)) (a b : BitString n → BitString m) (ha : wires a ⊆ s) (hb : wires b ⊆ s) :
    Synthesis interpretation s {fun (x : BitString n) => decide (a x = b x)} (6 * m + 1)

    Equality of two available bit strings, by the native equality formula.

    theorem Cslib.Circuits.Boolean.Iteration.synthesis_bits_mux {n m : ℕ} (s : Set (BooleanFunction n)) (a b : BitString n → BitString m) (flag : BooleanFunction n) (ha : wires a ⊆ s) (hb : wires b ⊆ s) (hf : flag ∈ s) :
    Synthesis interpretation s (wires fun (x : BitString n) => if flag x = true then a x else b x) (4 * m)
    theorem Cslib.Circuits.Boolean.Iteration.synthesis_ite {n m A B F : ℕ} {s : Set (BooleanFunction n)} {a b : BitString n → BitString m} {flag : BooleanFunction n} (ha : Synthesis interpretation s (wires a) A) (hb : Synthesis interpretation s (wires b) B) (hf : Synthesis interpretation s {flag} F) :
    Synthesis interpretation s (wires fun (x : BitString n) => if flag x = true then a x else b x) (A + B + F + 4 * m)

    Choosing between two constructions by a third adds four gates per output bit.

    The bits of an available family of records.

    Instances For
      theorem Cslib.Circuits.Boolean.Iteration.Record.padding_mem {n w : ℕ} {s : Set (BooleanFunction n)} {a : BitString n → Record n w} (ha : wireSet a ⊆ s) :
      (fun (x : BitString n) => (a x).padding) ∈ s
      theorem Cslib.Circuits.Boolean.Iteration.Record.state_mem {n w : ℕ} {s : Set (BooleanFunction n)} {a : BitString n → Record n w} (ha : wireSet a ⊆ s) (i : Fin n) :
      (fun (x : BitString n) => (a x).state i) ∈ s
      theorem Cslib.Circuits.Boolean.Iteration.Record.checkpoint_mem {n w : ℕ} {s : Set (BooleanFunction n)} {a : BitString n → Record n w} (ha : wireSet a ⊆ s) :
      (fun (x : BitString n) => (a x).checkpoint) ∈ s
      theorem Cslib.Circuits.Boolean.Iteration.Record.index_mem {n w : ℕ} {s : Set (BooleanFunction n)} {a : BitString n → Record n w} (ha : wireSet a ⊆ s) (i : Fin w) :
      (fun (x : BitString n) => (a x).index.getLsbD ↑i) ∈ s
      theorem Cslib.Circuits.Boolean.Iteration.Record.payload_mem {n w : ℕ} {s : Set (BooleanFunction n)} {a : BitString n → Record n w} (ha : wireSet a ⊆ s) (i : Fin n) :
      (fun (x : BitString n) => (a x).payload i) ∈ s
      theorem Cslib.Circuits.Boolean.Iteration.Record.synthesis_collision {n w : ℕ} (s : Set (BooleanFunction n)) (a b : BitString n → Record n w) (ha : wireSet a ⊆ s) (hb : wireSet b ⊆ s) :
      Synthesis interpretation s {fun (x : BitString n) => (a x).collision (b x)} (20 * (width n w + 1))

      The bits of a pair of records, the first record first.

      Instances For

        The bits of an available family of pairs of records.

        Instances For
          theorem Cslib.Circuits.Boolean.Iteration.Record.synthesis_detect {n w R : ℕ} (s : Set (BooleanFunction n)) (records : BitString n → Fin R → Record n w) (hr : ∀ (j : Fin R), (wireSet fun (x : BitString n) => records x j) ⊆ s) (hconst : ∀ (b : Bool), (fun (x : BitString n) => b) ∈ s) :
          Synthesis interpretation s (pairWires fun (x : BitString n) => detect (records x)) (30 * R * (width n w + 1))

          Testing all adjacent pairs and selecting a colliding one.

          The bits of every record of an available array.

          Instances For
            theorem Cslib.Circuits.Boolean.Iteration.Record.wireSet_subset_recordsWires {n w R : ℕ} (records : BitString n → Fin R → Record n w) (j : Fin R) :
            (wireSet fun (x : BitString n) => records x j) ⊆ recordsWires records

            The native sorter has at most 18 * d ^ 2 * 2 ^ d * (width + 1) gates.

            theorem Cslib.Circuits.Boolean.Iteration.Record.synthesis_sorted {n w : ℕ} (s : Set (BooleanFunction n)) (d : ℕ) (records : BitString n → Fin (BitonicSort.arity d) → Record n w) (hr : recordsWires records ⊆ s) :
            Synthesis interpretation s (recordsWires fun (x : BitString n) => sorted d (records x)) (18 * d ^ 2 * 2 ^ d * (width n w + 1))

            Sorting an available array inserts one native sorting circuit.