Documentation

CslibFrontier.DataStructure.FusionTree.WordRAM.Parameters

Concrete fusion-node preprocessing parameters #

Static preprocessing chooses collision-free shifts and three half-word multiplier digits. All other stored constants are explicit arithmetic expressions in these witnesses and the stored keys. The choices have no preprocessing-time certificate. Arithmetic compression agrees with perfect-sketch comparisons on all inputs; full-key query correction and the complete fusion-tree query remain separate.

Main definitions #

Main results #

References #

Number of selected source positions.

Source positions enumerated in increasing significance order.

Explicit compression witnesses. Correctness and word bounds below are derived from the collision, ordering and span properties supplied by the constructive shift theorem.

@[reducible, inline]

Selected-bit count, at most one per adjacent pair.

Compressed payload width.

Input position mask.

Full multiplier, represented in storage by three digits.

Retained output mask.

Arithmetic compressed sketch, for any natural input.

Stored sketches, extended by the sketch of zero outside the node.

Query replication multiplier.

Guarded original sketches.

Guarded complemented sketches.

Guard mask for packed comparisons.

Divisor selecting the middle count digit.

Packed-field radix, distinct from the half-word multiplication radix.

Largest compressed payload.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.D_lt {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) :
p.D < 2 ^ p.b

The retained output mask fits in p.b bits.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.M_lt {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) :
p.M < 2 ^ (w + p.b)

The entire multiplier may exceed one word but fits in w + b bits.

Every compressed sketch fits in p.b bits.

The arithmetic sketch and the perfect sketch compare identically for all inputs, including inputs outside the stored key set and outside the physical word range.

Weak comparisons agree too, including equality queries.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.strictMono_compressed {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) :
StrictMono fun (i : Fin n) => p.compressed (keys i)

The concrete stored arithmetic sketches remain strictly increasing.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.packed_width {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) :
2 * ((p.b + 1) * n) ≤ w

Capacity supplies the full packed-count multiplication bound.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.window {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hn : 0 < n) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) :
p.b + (w - 2 * (w / 2)) ≤ w / 2

Capacity also supplies the odd-width-aware half-word extraction bound.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.sketches_lt {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (i : ℕ) :
p.sketches i < 2 ^ p.b

Every stored sketch fits in p.b bits.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.count_lt_radix {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) :
n < 2 ^ (p.b + 1)

Distinct perfect sketches give a numerical bound on the number of stored keys.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.count_fit {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hn : 0 < n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) :

In particular the separately stored occupancy is a physical word.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.upperRank_eq {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hn : 0 < n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (q : ℕ) :
upperRankExpr p.b n p.sketches (p.compressed q) = {i ∈ Finset.range n | BitString.sketch (relevantBits w keys) (if hi : i < n then keys ⟨i, hi⟩ else 0) ≤ BitString.sketch (relevantBits w keys) q}.card

The inclusive arithmetic rank counts perfect sketches at or below every query. This is a sketch rank, not the predecessor rank of the original keys.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.lowerRank_eq {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hn : 0 < n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (q : ℕ) :
n - countGuards p.b n p.sketches (p.compressed q) = {i ∈ Finset.range n | BitString.sketch (relevantBits w keys) (if hi : i < n then keys ⟨i, hi⟩ else 0) < BitString.sketch (relevantBits w keys) q}.card

Strict arithmetic rank agrees with the perfect-sketch strict rank for every query, including zero and queries with the same sketch as a stored key.

Slot order: input mask, three multiplier digits, retained mask, copies, complemented packed sketches, original packed sketches, guards, payload width, middle divisor, field radix, maximum payload, odd-width offset, selected-bit count. The node tag, occupancy and minimum belong to the separate three-word header.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.words_fit {w n : ℕ} {keys : Fin n → ℕ} (p : NodeParameters w keys) (hn : 2 ≤ n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) (i : Fin 15) :

Every actual stored parameter is a physical word. The full multiplier is stored only as three digits, because its unbounded numeric value may exceed a physical word.

theorem Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.exists_parameters {w n : ℕ} {keys : Fin n → ℕ} (hn : 2 ≤ n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) :

Real preprocessing witnesses exist; no correctness or timing oracle is assumed.

noncomputable def Cslib.DataStructure.FusionTree.WordRAM.NodeParameters.choose {w n : ℕ} {keys : Fin n → ℕ} (hn : 2 ≤ n) (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hnB : n ≤ branching w) (hw : 9 ≤ Nat.log 2 w) :

Static preprocessing explicitly uses classical choice; no preprocessing-time bound.