Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctChainOps

Micro-Chain Update Helpers and Bucket Metadata Readers in Memory.Prog #

This module defines and verifies the Memory.Prog building blocks used by the bucket-level dictionary operations (insertBodyProg, deletePrepProg, deleteFinishProg):

Main definitions #

Main results #

Section 1: AllChainsValid and micro-chain update preservation #

Global doubly-linked micro-bucket chain invariant across all buckets b < numBuckets n_max and local micro-buckets m < numMicroPerBucket n_max, together with pairwise disjointness of chains within each bucket b.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.allChainsValid_of_zero (n_max : ℕ) {lm : ℕ × ℕ → ℕ} (hzero : ∀ (p : ℕ × ℕ), lm p = 0) :
AllChainsValid n_max lm fun (x x_1 : ℕ) => []

An all-zero LocalMeta array satisfies AllChainsValid with empty chains L b m = [].

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.AllChainsValid.of_lm_eq {n_max : ℕ} {lm lm' : ℕ × ℕ → ℕ} {L : ℕ → ℕ → List ℕ} (h : AllChainsValid n_max lm L) (heq : lm' = lm) :
AllChainsValid n_max lm' L

AllChainsValid depends only on lm.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmPrependProg_allChainsValid {U V w n_max h_space base b m j_new : ℕ} {L : ℕ → ℕ → List ℕ} {s : Memory.State} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hj_cap : j_new < SuccinctBucket.effBucketCap n_max) (hj_n : j_new < n_max) (hvalid : AllChainsValid n_max (lmAt base U V w n_max h_space s.mem) L) (hj_not : ∀ m' < SuccinctBucket.numMicroPerBucket n_max, j_new ∉ L b m') :
have s' := (Memory.spec 0).clientState s (lmPrependProg U V w n_max h_space (((base, b), m), j_new)); have L' := fun (b' m' : ℕ) => if b' = b ∧ m' = m then j_new :: L b m else L b' m'; AllChainsValid n_max (lmAt base U V w n_max h_space s'.mem) L'

Prepending j_new < effBucketCap n_max (with j_new ∉ L b m' for all m') preserves AllChainsValid.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmUnlinkProg_allChainsValid {U V w n_max h_space base b m j_del : ℕ} {L : ℕ → ℕ → List ℕ} {s : Memory.State} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hvalid : AllChainsValid n_max (lmAt base U V w n_max h_space s.mem) L) (hmem : j_del ∈ L b m) :
have s' := (Memory.spec 0).clientState s (lmUnlinkProg U V w n_max h_space (((base, b), m), j_del)); have L' := fun (b' m' : ℕ) => if b' = b ∧ m' = m then (L b m).erase j_del else L b' m'; AllChainsValid n_max (lmAt base U V w n_max h_space s'.mem) L' ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, ∀ (j : ℕ), j ∈ L' b' m' ↔ j ∈ L b' m' ∧ ¬(b' = b ∧ j = j_del)

Unlinking j_del ∈ L b m preserves AllChainsValid and removes (b, j_del) from the chain family.

Section 2: prependIfIndexedProg, unlinkIfIndexedProg, and bucket readers #

Parameter-free Memory.Prog operation prepending j_new = d.2 to micro-bucket chain (b, m) = (d.1.2.1.2, d.1.2.2) at base = d.1.2.1.1 when j_new < min n_max (effBucketCap n_max).

Memory.Prog operation prepending j_new = d.2 to micro-bucket chain (b, m) = (d.1.1.2, d.1.2) at base = d.1.1.1 when j_new < min n_max (effBucketCap n_max).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.prependIfIndexedGenProg_mk (U V w n_max h_space : ℕ) (d1 : (ℕ × ℕ) × ℕ) (d2 : ℕ) :
prependIfIndexedGenProg ((mkDictParams U V w n_max h_space, d1), d2) = prependIfIndexedProg U V w n_max h_space (d1, d2)

Precondition for prependIfIndexedProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.prependIfIndexedGenPre_mk (U V w₀ n_max h_space w : ℕ) (d1 : (ℕ × ℕ) × ℕ) (d2 : ℕ) (s : Memory.State) :
PrependIfIndexedGenPre w ((mkDictParams U V w₀ n_max h_space, d1), d2) s ↔ PrependIfIndexedPre U V w₀ n_max h_space w (d1, d2) s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.prependIfIndexedProg_allChainsValid {U V w n_max h_space base b m j_new : ℕ} {L : ℕ → ℕ → List ℕ} {s : Memory.State} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hj_n : j_new < n_max) (hvalid : AllChainsValid n_max (lmAt base U V w n_max h_space s.mem) L) (hj_not : ∀ m' < SuccinctBucket.numMicroPerBucket n_max, j_new ∉ L b m') :
have d := (((base, b), m), j_new); have s' := (Memory.spec 0).clientState s (prependIfIndexedProg U V w n_max h_space d); s'.frontier = s.frontier ∧ (∀ (a : ℕ), ¬(base + offLM U V w n_max h_space ≤ a ∧ a < base + offGM U V w n_max h_space) → s'.mem a = s.mem a) ∧ quotAt base U w n_max h_space s'.mem = quotAt base U w n_max h_space s.mem ∧ valAt base U V w n_max h_space s'.mem = valAt base U V w n_max h_space s.mem ∧ gmAt base U V w n_max h_space s'.mem = gmAt base U V w n_max h_space s.mem ∧ ∃ (L' : ℕ → ℕ → List ℕ), AllChainsValid n_max (lmAt base U V w n_max h_space s'.mem) L' ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, ∀ (j : ℕ), j ∈ L' b' m' ↔ j ∈ L b' m' ∨ b' = b ∧ m' = m ∧ j = j_new ∧ j_new < SuccinctBucket.effBucketCap n_max

Pure state effect and AllChainsValid preservation of prependIfIndexedProg.

Parameter-free Memory.Prog operation unlinking j_del = d.2 from micro-bucket chain (b, m) = (d.1.2.1.2, d.1.2.2) at base = d.1.2.1.1 when j_del < min n_max (effBucketCap n_max).

Memory.Prog operation unlinking j_del = d.2 from micro-bucket chain (b, m) = (d.1.1.2, d.1.2) at base = d.1.1.1 when j_del < min n_max (effBucketCap n_max).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.unlinkIfIndexedGenProg_mk (U V w n_max h_space : ℕ) (d1 : (ℕ × ℕ) × ℕ) (d2 : ℕ) :
unlinkIfIndexedGenProg ((mkDictParams U V w n_max h_space, d1), d2) = unlinkIfIndexedProg U V w n_max h_space (d1, d2)

Precondition for unlinkIfIndexedProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.unlinkIfIndexedGenPre_mk (U V w₀ n_max h_space w : ℕ) (d1 : (ℕ × ℕ) × ℕ) (d2 : ℕ) (s : Memory.State) :
UnlinkIfIndexedGenPre w ((mkDictParams U V w₀ n_max h_space, d1), d2) s ↔ UnlinkIfIndexedPre U V w₀ n_max h_space w (d1, d2) s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.unlinkIfIndexedProg_allChainsValid {U V w n_max h_space base b m j_del : ℕ} {L : ℕ → ℕ → List ℕ} {s : Memory.State} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hj_n : j_del < n_max) (hvalid : AllChainsValid n_max (lmAt base U V w n_max h_space s.mem) L) (hmem_if : j_del < SuccinctBucket.effBucketCap n_max → j_del ∈ L b m) :
have d := (((base, b), m), j_del); have s' := (Memory.spec 0).clientState s (unlinkIfIndexedProg U V w n_max h_space d); s'.frontier = s.frontier ∧ (∀ (a : ℕ), ¬(base + offLM U V w n_max h_space ≤ a ∧ a < base + offGM U V w n_max h_space) → s'.mem a = s.mem a) ∧ quotAt base U w n_max h_space s'.mem = quotAt base U w n_max h_space s.mem ∧ valAt base U V w n_max h_space s'.mem = valAt base U V w n_max h_space s.mem ∧ gmAt base U V w n_max h_space s'.mem = gmAt base U V w n_max h_space s.mem ∧ ∃ (L' : ℕ → ℕ → List ℕ), AllChainsValid n_max (lmAt base U V w n_max h_space s'.mem) L' ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, ∀ (j : ℕ), j ∈ L' b' m' ↔ j ∈ L b' m' ∧ ¬(b' = b ∧ j = j_del)

Pure state effect and AllChainsValid preservation of unlinkIfIndexedProg.

Parameter-free Memory.Prog reader returning totalSlots n_max gm at base = d.2.

Memory.Prog reader returning totalSlots n_max gm at base.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.readTotalSlotsGenProg_mk (U V w n_max h_space base : ℕ) :
readTotalSlotsGenProg (mkDictParams U V w n_max h_space, base) = readTotalSlotsProg U V w n_max h_space base
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_readTotalSlotsProg (U V w n_max h_space base : ℕ) (s : Memory.State) :
(Memory.spec 0).clientResult s (readTotalSlotsProg U V w n_max h_space base) = totalSlots n_max (gmAt base U V w n_max h_space s.mem)

Parameter-free Memory.Prog helper copying (quotAt, valAt) from the last logical slot lastSlotOfGenProg (dp, (base, b)) of bucket b = d.2.1.2 (base = d.2.1.1) into phys_del = d.2.2.

Memory.Prog helper copying (quotAt, valAt) from the last logical slot lastSlotOfProg (base, b) of bucket b = d.1.2 (base = d.1.1) into phys_del = d.2.

@[simp]

Precondition for copyLastPayloadProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.copyLastPayloadGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : (ℕ × ℕ) × ℕ) (s : Memory.State) :
CopyLastPayloadGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ CopyLastPayloadPre U V w₀ n_max h_space w d s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.copyLastPayloadProg_effect {U V w n_max h_space base b phys_del : ℕ} (hw : 0 < w) {s : Memory.State} (hinv : SlotStoreInv n_max (gmAt base U V w n_max h_space s.mem)) (hb : b < FeistelQuotient.numBuckets n_max) (hbc : 1 ≤ bCount n_max (gmAt base U V w n_max h_space s.mem) b) (hphys_del : phys_del < n_max) :
have gm := gmAt base U V w n_max h_space s.mem; have phys_last := slotOf n_max gm b (bCount n_max gm b - 1); have q_last := quotAt base U w n_max h_space s.mem phys_last; have v_last := valAt base U V w n_max h_space s.mem phys_last; have s' := (Memory.spec 0).clientState s (copyLastPayloadProg U V w n_max h_space ((base, b), phys_del)); s'.frontier = s.frontier ∧ (∀ (a : ℕ), ¬(base + offQuot h_space ≤ a ∧ a < base + totalSpace U V w n_max h_space) → s'.mem a = s.mem a) ∧ quotAt base U w n_max h_space s'.mem = Function.update (quotAt base U w n_max h_space s.mem) phys_del q_last ∧ valAt base U V w n_max h_space s'.mem = Function.update (valAt base U V w n_max h_space s.mem) phys_del v_last ∧ lmAt base U V w n_max h_space s'.mem = lmAt base U V w n_max h_space s.mem ∧ gmAt base U V w n_max h_space s'.mem = gmAt base U V w n_max h_space s.mem

Pure state effect of copyLastPayloadProg.