Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpBTreeProg.LocateHit

Shared Leaf-Locate Prefix (btreeLocateHitGenProg) #

Shared leaf-descent and SWAR rank hit-detection subroutine for btreeLookupGenProg, btreeDeleteGenProg, and btreeUpdateGenProg.

@[irreducible]

Shared leaf-locate prefix for btreeLookupGenProg, btreeDeleteGenProg, and btreeUpdateGenProg: descends to the leaf for q, ranks q in keysWord, and returns (1, ((leafIdx, r), (mW, (kW, vW)))) on an exact key hit (k_r = q) or (0, ((0, 0), (0, (0, 0)))) on miss.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.btreeLocateHitGenProg_spec {c U V w n_max base sIdx insCount q : ℕ} {sl : SuccinctWhp.BTreeSlice} {mapFn : ℕ → Option ℕ} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hins : insCount ≤ 8 * FeistelQuotient.slabScale n_max ^ 12) (hrep : BTreeSliceMemRep base c U V w n_max sIdx sl s.mem) (hv : SuccinctWhp.ValidWhpSlice n_max insCount sl mapFn) (hq : q < 2 ^ SuccinctWhp.fpBitsWhp n_max) :
have prog := btreeLocateHitGenProg (((mkWhpCoreParams c U V w n_max, base), sIdx), q); (Memory.spec 0).clientState s prog = s ∧ WordRAM.Realization.memoryCost prog s ≤ 262 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ (((Memory.spec 0).clientResult s prog = (0, (0, 0), 0, 0, 0) ∧ mapFn q = none ∧ SuccinctWhp.btreeDelete (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) sl q = sl ∧ ∀ (newVal : ℕ), SuccinctWhp.btreeUpdate (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) sl q newVal = sl) ∨ ∃ (leafIdx : ℕ) (r : ℕ), have nd := sl.nodes leafIdx; have cnt := SuccinctWhp.metaCount nd.metaWord; (Memory.spec 0).clientResult s prog = (1, (leafIdx, r), nd.metaWord, nd.keysWord, nd.valsWord) ∧ leafIdx < sl.alloc ∧ r < cnt ∧ cnt ≤ 2 * SuccinctWhp.tMinWhp n_max - 1 ∧ nd.metaWord < 2 ^ SuccinctWhp.nodeMetaBitsWhp n_max ∧ nd.keysWord < 2 ^ SuccinctWhp.keysWordBitsWhp n_max ∧ nd.keysWord < 2 ^ (cnt * SuccinctWhp.keyLaneBitsWhp n_max) ∧ nd.valsWord < 2 ^ (cnt * SuccinctWhp.valLaneBitsWhp n_max) ∧ mapFn q = some (laneGet (SuccinctWhp.valLaneBitsWhp n_max) nd.valsWord r) ∧ SuccinctWhp.btreeDelete (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) sl q = { alloc := sl.alloc, root := sl.root, nodes := Function.update sl.nodes leafIdx { metaWord := SuccinctWhp.mkNodeMeta true (cnt - 1), keysWord := SuccinctWhp.wordDeleteAt (SuccinctWhp.fpBitsWhp n_max + 2) r nd.keysWord, valsWord := SuccinctWhp.wordDeleteAt (SuccinctWhp.valLaneBitsWhp n_max) r nd.valsWord } } ∧ ∀ (newVal : ℕ), SuccinctWhp.btreeUpdate (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) sl q newVal = { alloc := sl.alloc, root := sl.root, nodes := Function.update sl.nodes leafIdx { metaWord := nd.metaWord, keysWord := nd.keysWord, valsWord := SuccinctWhp.wordUpdateAt (SuccinctWhp.valLaneBitsWhp n_max) r newVal nd.valsWord } })