Fast-Mode Coordinate Lookup (fastFindLocBqGenProg) and Value Query (fastQueryGenProg) #
This module implements worst-case O_c(1) fast-mode coordinate lookup and value query
Memory.Prog subroutines and their Realizes .exact certificates on FastMemRep, probing
buf curEp, buf oldEp (when rebStage ≤ 3), and liveSlice[b] with key verification via
matchesKeyGenProg.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.ValidFastMemPre: shared memory-state precondition for foreground fast-mode operations underValidFastState.Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fastFindLocBqGenProg,fastQueryGenProg: parameter-freeO_c(1)lookup and query subroutines.
Main results #
Read-only program specifications #
Section 1: Key Verification and Candidate Probe Helpers #
Section 2: ValidFastMemPre, fastFindLocBqGenProg, and fastQueryGenProg #
def Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.ValidFastMemPre (w : ℕ) (wp : WhpParams) (base : ℕ) (s : Memory.State) :
Shared memory-state precondition for foreground fast-mode operations under ValidFastState.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_fastFindLocBqGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact fastFindLocBqGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpParams × ℕ) × ℕ × ℕ) × ℕ) (s : Memory.State) =>
match x with
| (((wp, base), b, snd), snd_1) => ValidFastMemPre w wp base s ∧ b < wpM wp.1)
fun (x : ((WhpParams × ℕ) × ℕ × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fastFindLocBqGenProg_spec {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {dict : State U} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) (hv : SuccinctWhp.ValidFastState c U V n_max θ fs dict) (u : Fin U) :
have b := FeistelQuotient.feistelBucket (SuccinctWhp.bWhp n_max) (SuccinctWhp.bktHash c U n_max θ.1) ↑u;
have q_val := FeistelQuotient.keyQuotient (SuccinctWhp.bWhp n_max) ↑u;
have prog := fastFindLocBqGenProg (((mkWhpParams c U V w n_max, base), b, q_val), ↑u);
(Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = match SuccinctWhp.fastFindLoc c U n_max θ fs u with
| some loc => (1, loc)
| none => (0, 0)) ∧ WordRAM.Realization.memoryCost prog s ≤ 4 * SuccinctWhp.cTabWhp c + hashEvalCostWhp c + 304 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]
Fast-mode value query fastQueryGenProg (d = ((wp, base), u_val)), returning (1, val) or
(0, 0) in O_c(1) worst-case memory operations without mutating memory.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_fastQueryGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact fastQueryGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (WhpParams × ℕ) × ℕ) (s : Memory.State) =>
match x with
| ((wp, base), u_val) => ValidFastMemPre w wp base s ∧ u_val < wpU wp.1)
fun (x : (WhpParams × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fastQueryGenProg_spec {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {dict : State U} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) (hv : SuccinctWhp.ValidFastState c U V n_max θ fs dict) (u : Fin U) :
have prog := fastQueryGenProg ((mkWhpParams c U V w n_max, base), ↑u);
(Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = match SuccinctWhp.fastQuery c U n_max θ fs u with
| some v => (1, v)
| none => (0, 0)) ∧ WordRAM.Realization.memoryCost prog s ≤ 4 * SuccinctWhp.cTabWhp c + 2 * hashEvalCostWhp c + 308 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog