Non-Full Leaf Update or Sorted Lane Insertion (finishLeafInsertGenProg) #
Implements and certifies phase 3 of btreeInsertGenProg: ranking q in a guaranteed non-full leaf
and either updating the value lane in place on a key hit or inserting (q, val) into the packed
key/value words.
Precondition for finishLeafInsertGenProg
(d = (((((cp, base), sIdx), leafIdx), q), val)).
Parameter-free finishLeafInsert (d = (((((cp, base), sIdx), leafIdx), q), val)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.finishLeafInsertGenProg_spec {isR : Bool} {c U V w n_max base sIdx leafIdx cntL loL hiL q val : ℕ} {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) (hrep : BTreeSliceMemRep base c U V w n_max sIdx sl s.mem) (hcntL : cntL < 2 * SuccinctWhp.tMinWhp n_max - 1) (_hqlo : loL ≤ q) (hqhi : q ≤ hiL) (hhi : hiL < 2 ^ SuccinctWhp.fpBitsWhp n_max) (hval : val < 2 ^ SuccinctWhp.valLaneBitsWhp n_max) (hv_leaf :
SuccinctWhp.ValidSubtree isR (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max)
(SuccinctWhp.tMinWhp n_max) sl.alloc sl.nodes loL hiL mapFn (SuccinctWhp.BTreeTree.leaf leafIdx cntL)) :
have prog := finishLeafInsertGenProg (((((mkWhpCoreParams c U V w n_max, base), sIdx), leafIdx), q), val);
have sl' :=
SuccinctWhp.finishLeafInsert (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max)
(SuccinctWhp.tMinWhp n_max) sl leafIdx q val;
have s' := (Memory.spec 0).clientState s prog;
s'.frontier = s.frontier ∧ WordRAM.Realization.memoryCost prog s = 18 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ BTreeSliceMemRep base c U V w n_max sIdx sl' s'.mem ∧ (∀ sIdx' < 3 * SuccinctWhp.numBucketsWhp n_max,
sIdx' ≠ sIdx →
∀ (sl₂ : SuccinctWhp.BTreeSlice),
BTreeSliceMemRep base c U V w n_max sIdx' sl₂ s.mem →
BTreeSliceMemRep base c U V w n_max sIdx' sl₂ s'.mem) ∧ ∀ (a : ℕ), a < base + offBtMeta c U V w n_max ∨ base + offTrieChild0 c U V w n_max ≤ a → s'.mem a = s.mem a