Bucket-Level Dictionary Lookup and Insertion (query, insert) in Memory.Prog #
This module defines the bucket-level representation invariant BucketStateInv and realizes the
bucket-level lookup and insertion operations of the fixed-capacity succinct dictionary in
Memory.Prog via realize:
BucketStateInv: couplesSlotStoreInv,AllChainsValid, indexed micro-chain membership, per-bucket quotient uniqueness, and the abstract per-bucket quotient-to-value mapB;queryBodyProg_bucket_spec: lookup correctness and probe-excess cost bound underBucketStateInv;insertBodyProgandrealizes_insertBodyGen: bucket-levelinsert(update in-place if present, otherwise append to bucket and prepend to micro-chain if< effBucketCap n_max).
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.BucketStateInv: bucket-level representation invariant couplingSlotStoreInv,AllChainsValid, and the abstract per-bucket mapB.Cslib.DataStructure.Dictionary.WordRAM.Succinct.insertBodyProg:Memory.Progoperation for bucket-level insertion (updatein place if present, otherwisepushBackSlotProg+prependIfIndexedProg).
Main results #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.bucketStateInv_of_zero: an all-zero dictionary memory region satisfiesBucketStateInvwith empty buckets and zero potential.Cslib.DataStructure.Dictionary.WordRAM.Succinct.queryBodyProg_bucket_spec: lookup correctness and probe-excessmemoryCostbound forqueryBodyProgunderBucketStateInv.Cslib.DataStructure.Dictionary.WordRAM.Succinct.insertBodyProg_bucket_spec,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_insertBodyGen: insertion correctness,BucketStateInvpreservation, amortizedmemoryCostbound, andRealizescertificate forinsertBodyProg.
Section 1: BucketStateInv and queryBodyProg_bucket_spec #
Combined bucket-level state invariant at base with local micro-bucket mapping mOf : ℕ → ℕ,
per-bucket micro-chain lists L : ℕ → ℕ → List ℕ, and abstract per-bucket quotient-to-value map
B : ℕ → ℕ → Option ℕ.
- hchain_mem (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ m < SuccinctBucket.numMicroPerBucket n_max, ∀ (j : ℕ), j ∈ L b m ↔ j < bCount n_max (gmAt base U V w₀ n_max h_space s.mem) b ∧ j < SuccinctBucket.effBucketCap n_max ∧ mOf (quotAt base U w₀ n_max h_space s.mem (slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b j)) = m
- hnodup_q (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ j₁ < bCount n_max (gmAt base U V w₀ n_max h_space s.mem) b, ∀ j₂ < bCount n_max (gmAt base U V w₀ n_max h_space s.mem) b, quotAt base U w₀ n_max h_space s.mem (slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b j₁) = quotAt base U w₀ n_max h_space s.mem (slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b j₂) → j₁ = j₂
- hmap_some (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ j < bCount n_max (gmAt base U V w₀ n_max h_space s.mem) b, B b (quotAt base U w₀ n_max h_space s.mem (slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b j)) = some (valAt base U V w₀ n_max h_space s.mem (slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b j))
An all-zero dictionary memory region satisfies BucketStateInv with empty chains and empty
bucket maps.
BucketStateInv implies SearchMicroChainPre for any valid (b, q_target, m).
Under BucketStateInv and m = mOf q_target < numMicroPerBucket n_max, the two-phase search
condition in searchBucketProg_spec is equivalent to
∃ j < bCount b, quotAt (slotOf b j) = q_target.
Specification of searchBucketProg under BucketStateInv when m = mOf q_target.
Specification of queryBodyProg under BucketStateInv when m = mOf q_target:
returns B b q_target without modifying memory.
Section 2: insertBodyProg via realize #
Parameter-free helper Memory.Prog appending a new (q_target, v_new) entry to bucket b and
prepending its logical index j_new = bCount b to micro-chain (b, m) when totalSlots < n_max.
Input d = (dp, ((((base, b), q_target), v_new), m)).
Helper Memory.Prog appending a new (q_target, v_new) entry to bucket b and prepending
its logical index j_new = bCount b to micro-chain (b, m) when totalSlots < n_max.
Input d = ((((base, b), q_target), v_new), m).
Precondition for insertNewProg in Realizes.
Parameter-free precondition for insertNewGenProg in Realizes.
Parameter-free dictionary insert body insertBodyGenProg
(d = (dp, ((((base, b), q_target), v_new), m))).
Dictionary insert body insertBodyProg (d = ((((base, b), q_target), v_new), m)):
searches bucket b for q_target via searchBucketProg; if found, overwrites valAt in-place;
otherwise calls insertNewProg.
Precondition for insertBodyProg in Realizes.
Parameter-free precondition for insertBodyGenProg in Realizes.
Pure state effect, BucketStateInv preservation, and amortized memoryCost bound of
insertBodyProg when m = mOf q_target and (B b q_target).isSome ∨ totalSlots < n_max.