Succinct Dictionary Bucket Search and Query in Memory.Prog via realize #
This module implements Phase 2 overflow search (resolveOvfStepProg, ovfStepProg,
ovfLoopProg, searchOverflowProg), the combined two-phase bucket search (searchBucketProg),
and the dictionary lookup body (queryBodyProg) in the Memory.Prog monad, certifying each via
Realizes .exact and the realize tactic.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.resolveOvfStepProg: single-step overflow slot resolver advancing alongslabAboveacross slab boundaries.Cslib.DataStructure.Dictionary.WordRAM.Succinct.ovfStepProg,Cslib.DataStructure.Dictionary.WordRAM.Succinct.ovfLoopProg,Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchOverflowProg: Phase 2 overflow scan overj ∈ [effBucketCap n_max, bCount n_max gm b).Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchBucketProg: combined two-phase bucket search (searchMicroChainProgfollowed bysearchOverflowProg).Cslib.DataStructure.Dictionary.WordRAM.Succinct.queryBodyProg:Memory.Proglookup body returningOption ℕ.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchOverflowProg_spec,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_searchOverflowGen: specification andRealizescertificate forsearchOverflowProg.Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchBucketProg_spec,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_searchBucketGen: specification andRealizescertificate forsearchBucketProg.Cslib.DataStructure.Dictionary.WordRAM.Succinct.queryBodyProg_spec,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_queryBodyGen: specification andRealizescertificate forqueryBodyProg.
Section 1: Overflow Slot Resolution (resolveOvfStepProg) #
Dictionary parameters x.1.1 in a parameter-free step input ((dp, arg), state).
Base address base in a parameter-free overflow-resolver input
((dp, (base, b)), extra).
Bucket index b in a parameter-free overflow-resolver input
((dp, (base, b)), extra).
Parameter-free single-step overflow slot resolver (d = ((dp, (base, b)), (j, p_cur))),
returning (slotOf n_max gm b j, p_next) where p_next advances along slabAbove at the end of
each full slab (off = 0 and j + 1 < q_b * slabSize n_max).
Single-step overflow slot resolver (d = ((base, b), (j, p_cur))), returning
(slotOf n_max gm b j, p_next) where p_next advances along slabAbove at the end of each
full slab (off = 0 and j + 1 < q_b * slabSize n_max).
Precondition for resolveOvfStepProg (d = ((base, b), (j, p_cur))).
Parameter-free precondition for resolveOvfStepGenProg.
Section 2: Phase 2 Overflow Search (ovfStepProg, ovfLoopProg, searchOverflowProg) #
One step of Phase 2 overflow search (x = (((base, b), q_target), ((((j, p_cur), found), j_found), phys_found))). Resolves (phys, p_next) ← resolveOvfStepProg and reads q_val at
phys, recording the first matching slot (1, j, phys) when found = 0 ∧ q_val = q_target.
Structural induction lemma for iterate (ovfStepProg ...) over m overflow slots
j .. j + m - 1.
Base address d.2.1 in an overflow-init call (dp, (base, b)).
Bucket index d.2.2 in an overflow-init call (dp, (base, b)).
Parameter-free helper initializing (p_init, fuel) for Phase 2 overflow search
(d = (dp, (base, b))).
Helper initializing (p_init, fuel) for Phase 2 overflow search (d = (base, b)).
In a bucket whose full slabs hold at least effBucketCap items, the last directory slot is
in range of GlobalMeta, it stores the bucket's last directory slab, and that slab is below the
slab-pool capacity. The slot index is stated unfolded, as the overflow search reads it.
Base address base in a parameter-free overflow-search call
(dp, ((base, b), q_target)).
Bucket index b in a parameter-free overflow-search call
(dp, ((base, b), q_target)).
Parameter-free Phase 2 overflow search searchOverflowGenProg: scans overflow slots
j ∈ [effBucketCap n_max, bCount n_max gm b) in bucket b = ovfSearchBucket d for
quotient q_target = d.2.2, returning ((found, j_found), phys_found).
Phase 2 overflow search searchOverflowProg: scans overflow slots
j ∈ [effBucketCap n_max, bCount n_max gm b) in bucket b = d.1.2 for quotient q_target = d.2,
returning ((found, j_found), phys_found).
Precondition for searchOverflowProg (d = ((base, b), q_target)).
Parameter-free precondition for searchOverflowGenProg.
Section 3: Combined Two-Phase Bucket Search (searchBucketProg) and queryBodyProg #
Parameter-free two-phase bucket search searchBucketGenProg
(d = (dp, (((base, b), q_target), m))):
first searches the micro-bucket chain (b, m) via searchMicroChainGenProg; if not found,
searches any overflow slots j ∈ [effBucketCap n_max, bCount n_max gm b) via
searchOverflowGenProg. Returns ((found, j_found), phys_found).
Two-phase bucket search searchBucketProg (d = (((base, b), q_target), m)):
first searches the micro-bucket chain (b, m) via searchMicroChainProg; if not found,
searches any overflow slots j ∈ [effBucketCap n_max, bCount n_max gm b) via
searchOverflowProg. Returns ((found, j_found), phys_found).
Parameter-free dictionary lookup body queryBodyGenProg
(d = (dp, (((base, b), q_target), m))):
calls searchBucketGenProg and, if found (ovfSearchFound res = 1), reads and returns some v
from Values at physical slot res.2, otherwise returns none.
Dictionary lookup body queryBodyProg (d = (((base, b), q_target), m)):
calls searchBucketProg and, if found (ovfSearchFound res = 1), reads and returns some v
from Values at physical slot res.2, otherwise returns none.