Documentation

Complexity.Algorithms.Lean.FusionTree.XorCorrection

Correction with one exclusive-or comparison #

Compare the two neighboring full keys by their exclusive or with the query, then compute the highest differing bit only for the chosen key. This avoids two highest-bit computations. The rank primitives remain mathematical specifications in this module.

Main definitions #

Main results #

References #

Compare only the two sketch neighbors, using a single full-word exclusive or per key.

Instances For
    theorem Cslib.Algorithms.Lean.FusionTree.xorSketchNeighbor_spec {n w q : ℕ} {keys : Fin n → ℕ} {j : Fin n} (h : xorSketchNeighbor w keys q = some j) :
    IsSketchNeighbor w keys q j ∧ ∀ (i : Fin n), IsSketchNeighbor w keys q i → keys j ^^^ q ≤ keys i ^^^ q
    theorem Cslib.Algorithms.Lean.FusionTree.miss_of_xorSketchNeighbor {n w q : ℕ} {keys : Fin n → ℕ} (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) {j : Fin n} (hj : xorSketchNeighbor w keys q = some j) (hmiss : keys j ≠ q) (i : Fin n) :
    keys i ≠ q
    theorem Cslib.Algorithms.Lean.FusionTree.xorSketchNeighbor_highestDiff_le {n w q : ℕ} {keys : Fin n → ℕ} (hq : q < 2 ^ w) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hmiss : ∀ (i : Fin n), keys i ≠ q) {j : Fin n} (hj : xorSketchNeighbor w keys q = some j) (i : Fin n) (hi : IsSketchNeighbor w keys q i) :

    Correction using an exclusive-or comparison to select the longest-prefix neighbor. Exact hits return the initial inclusive rank; misses use the sibling-boundary correction.

    Instances For
      theorem Cslib.Algorithms.Lean.FusionTree.xorCorrectedRank_eq_upperRank {n w q : ℕ} {keys : Fin n → ℕ} (hsorted : StrictMono keys) (hbound : ∀ (i : Fin n), keys i < 2 ^ w) (hq : q < 2 ^ w) :
      xorCorrectedRank w keys q = upperRank keys q

      Exclusive-or selection gives the true inclusive rank for all bounded queries. This establishes the selection rule's semantics; RAM execution is proved separately.