Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctMicroChain

Per-Micro-Bucket Doubly-Linked Chains and Phase 1 Search in Memory.Prog #

This module implements the LocalMeta doubly-linked list primitives and Phase 1 micro-chain search in Memory.Prog, certified via the realize tactic:

Main definitions #

Main results #

Section 1: Functional views lmHead, lmPrev, lmNext and Memory.Prog accessors #

1-based head pointer (0 = empty, j + 1 = local slot j < effBucketCap n_max) of micro-bucket (b, m) in lm : ℕ × ℕ → ℕ.

1-based previous pointer (0 = head of chain, j_prev + 1 = predecessor j_prev) of local slot j < effBucketCap n_max in bucket b.

1-based next pointer (0 = tail of chain, j_next + 1 = successor j_next) of local slot j < effBucketCap n_max in bucket b.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.fits_of_le_totalMicroBuckets {U V w₀ n_max h_space w base x : ℕ} (h : DictEnvGen w (mkDictParams U V w₀ n_max h_space) base) (hw : 0 < w₀) (hnU : n_max ≤ U) (hU : U < 2 ^ w₀) (hx : x ≤ SuccinctBucket.totalMicroBuckets n_max) :
@[reducible, inline]

Base address base in a LocalMeta slot input ((base, b), idx).

@[reducible, inline]

Bucket index b in a LocalMeta slot input ((base, b), idx).

@[reducible, inline]

Base address base in a four-field LocalMeta entry/query input (((base, b), idx), val).

@[reducible, inline]

Bucket index b in a four-field LocalMeta entry/query input (((base, b), idx), val).

@[reducible, inline]

Slot, micro-bucket, or quotient field idx in (((base, b), idx), val).

@[reducible, inline]

Base address base in a LocalMeta read input (dp, ((base, b), idx)).

@[reducible, inline]

Bucket index b in a LocalMeta read input (dp, ((base, b), idx)).

@[reducible, inline]

Micro-bucket or slot index idx in a LocalMeta read input (dp, ((base, b), idx)).

@[reducible, inline]

Base address base in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

@[reducible, inline]

Bucket index b in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

@[reducible, inline]

Micro-bucket, slot index, or target quotient idx in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

@[reducible, inline]

Payload/trailing value val in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

@[reducible, inline]

Bucket location (base, b) in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

@[reducible, inline]

Three-field head/query prefix ((base, b), idx) in a LocalMeta write/chain input (dp, (((base, b), idx), val)).

Parameter-free Memory.Prog operation reading lmHead n_max lm b m at d = (dp, ((base, b), m)).

Read lmHead n_max lm b m at d = ((base, b), m) in Memory.Prog.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.readLMHeadGenProg_mk (U V w n_max h_space : ℕ) (d : (ℕ × ℕ) × ℕ) :
readLMHeadGenProg (mkDictParams U V w n_max h_space, d) = readLMHeadProg U V w n_max h_space d

Parameter-free Memory.Prog operation writing val = lmWriteVal d to lmHead n_max lm b m at d = (dp, (((base, b), m), val)).

Write val = d.2 to lmHead n_max lm b m at d = (((base, b), m), val) in Memory.Prog.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMHeadGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
writeLMHeadGenProg (mkDictParams U V w n_max h_space, d) = writeLMHeadProg U V w n_max h_space d
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_readLMHeadProg {U V w n_max h_space base b m : ℕ} (s : Memory.State) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) :
(Memory.spec 0).clientResult s (readLMHeadProg U V w n_max h_space ((base, b), m)) = lmHead n_max (lmAt base U V w n_max h_space s.mem) b m

Parameter-free Memory.Prog operation reading lmAt (c_base + j % 4, b * numMicroPerBucket n_max + j / 4) at d = (dp, ((base, b), j)).

Read lmAt (c_base + j % 4, b * numMicroPerBucket n_max + j / 4) at d = ((base, b), j).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.readLMMod4GenProg_mk (U V w n_max h_space c_base : ℕ) (hc : c_base + 3 < 9) (d : (ℕ × ℕ) × ℕ) :
readLMMod4GenProg c_base hc (mkDictParams U V w n_max h_space, d) = readLMMod4Prog U V w n_max h_space c_base d

Parameter-free Memory.Prog operation writing val = lmWriteVal d to lmAt (c_base + j % 4, b * numMicroPerBucket n_max + j / 4) at d = (dp, (((base, b), j), val)).

Write val = d.2 to lmAt (c_base + j % 4, b * numMicroPerBucket n_max + j / 4) at d = (((base, b), j), val).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMMod4GenProg_mk (U V w n_max h_space c_base : ℕ) (hc : c_base + 3 < 9) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
writeLMMod4GenProg c_base hc (mkDictParams U V w n_max h_space, d) = writeLMMod4Prog U V w n_max h_space c_base d

Parameter-free Memory.Prog operation reading lmPrev n_max lm b j at d = (dp, ((base, b), j)).

Read lmPrev n_max lm b j at d = ((base, b), j).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.readLMPrevGenProg_mk (U V w n_max h_space : ℕ) (d : (ℕ × ℕ) × ℕ) :
readLMPrevGenProg (mkDictParams U V w n_max h_space, d) = readLMPrevProg U V w n_max h_space d

Parameter-free Memory.Prog operation writing val = d.2.2 to lmPrev n_max lm b j at d = (dp, (((base, b), j), val)).

Write val = d.2 to lmPrev n_max lm b j at d = (((base, b), j), val).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMPrevGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
writeLMPrevGenProg (mkDictParams U V w n_max h_space, d) = writeLMPrevProg U V w n_max h_space d

Parameter-free Memory.Prog operation reading lmNext n_max lm b j at d = (dp, ((base, b), j)).

Read lmNext n_max lm b j at d = ((base, b), j).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.readLMNextGenProg_mk (U V w n_max h_space : ℕ) (d : (ℕ × ℕ) × ℕ) :
readLMNextGenProg (mkDictParams U V w n_max h_space, d) = readLMNextProg U V w n_max h_space d

Parameter-free Memory.Prog operation writing val = d.2.2 to lmNext n_max lm b j at d = (dp, (((base, b), j), val)).

Write val = d.2 to lmNext n_max lm b j at d = (((base, b), j), val).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMNextGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
writeLMNextGenProg (mkDictParams U V w n_max h_space, d) = writeLMNextProg U V w n_max h_space d
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientState_readLMMod4Prog (U V w n_max h_space c_base : ℕ) (d : (ℕ × ℕ) × ℕ) (s : Memory.State) :
(Memory.spec 0).clientState s (readLMMod4Prog U V w n_max h_space c_base d) = s
@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.memoryCost_readLMMod4Prog (U V w n_max h_space c_base : ℕ) (d : (ℕ × ℕ) × ℕ) (s : Memory.State) :
WordRAM.Realization.memoryCost (readLMMod4Prog U V w n_max h_space c_base d) s = 2
@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.memoryCost_writeLMMod4Prog (U V w n_max h_space c_base : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
WordRAM.Realization.memoryCost (writeLMMod4Prog U V w n_max h_space c_base d) s = 4
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_readLMMod4Prog {U V w n_max h_space c_base base b j : ℕ} (s : Memory.State) (hc : c_base + 3 < 9) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) :
(Memory.spec 0).clientResult s (readLMMod4Prog U V w n_max h_space c_base ((base, b), j)) = lmAt base U V w n_max h_space s.mem (c_base + j % 4, b * SuccinctBucket.numMicroPerBucket n_max + j / 4)
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_readLMPrevProg {U V w n_max h_space base b j : ℕ} (s : Memory.State) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) :
(Memory.spec 0).clientResult s (readLMPrevProg U V w n_max h_space ((base, b), j)) = lmPrev n_max (lmAt base U V w n_max h_space s.mem) b j
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_readLMNextProg {U V w n_max h_space base b j : ℕ} (s : Memory.State) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) :
(Memory.spec 0).clientResult s (readLMNextProg U V w n_max h_space ((base, b), j)) = lmNext n_max (lmAt base U V w n_max h_space s.mem) b j

Section 2: Pure state effects and frame lemmas for lmHead, lmPrev, lmNext #

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMHeadProg_effect {U V w n_max h_space base b m val : ℕ} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hval_lt : val < 2 ^ SuccinctBucket.effBucketPosBits n_max) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (writeLMHeadProg U V w n_max h_space (((base, b), m), val)); have lm := lmAt base U V w n_max h_space s.mem; have lm' := lmAt base U V w n_max h_space s'.mem; 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 ∧ lmHead n_max lm' b m = val ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, b' ≠ b ∨ m' ≠ m → lmHead n_max lm' b' m' = lmHead n_max lm b' m') ∧ lmPrev n_max lm' = lmPrev n_max lm ∧ lmNext n_max lm' = lmNext n_max lm

Pure state effect of writeLMHeadProg.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMMod4Prog_effect {U V w n_max h_space c_base base b j val : ℕ} (hw : 0 < w) (hc : c_base + 3 < 9) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) (hval_lt : val < 2 ^ SuccinctBucket.effBucketPosBits n_max) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (writeLMMod4Prog U V w n_max h_space c_base (((base, b), j), val)); 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 ∧ lmAt base U V w n_max h_space s'.mem = Function.update (lmAt base U V w n_max h_space s.mem) (c_base + j % 4, b * SuccinctBucket.numMicroPerBucket n_max + j / 4) val ∧ 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 writeLMMod4Prog.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMPrevProg_effect {U V w n_max h_space base b j val : ℕ} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) (hval_lt : val < 2 ^ SuccinctBucket.effBucketPosBits n_max) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (writeLMPrevProg U V w n_max h_space (((base, b), j), val)); have lm := lmAt base U V w n_max h_space s.mem; have lm' := lmAt base U V w n_max h_space s'.mem; 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 ∧ lmHead n_max lm' = lmHead n_max lm ∧ lmPrev n_max lm' b j = val ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, b' ≠ b ∨ j' ≠ j → lmPrev n_max lm' b' j' = lmPrev n_max lm b' j') ∧ lmNext n_max lm' = lmNext n_max lm

Pure state effect of writeLMPrevProg.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.writeLMNextProg_effect {U V w n_max h_space base b j val : ℕ} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hj : j < SuccinctBucket.effBucketCap n_max) (hval_lt : val < 2 ^ SuccinctBucket.effBucketPosBits n_max) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (writeLMNextProg U V w n_max h_space (((base, b), j), val)); have lm := lmAt base U V w n_max h_space s.mem; have lm' := lmAt base U V w n_max h_space s'.mem; 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 ∧ lmHead n_max lm' = lmHead n_max lm ∧ lmPrev n_max lm' = lmPrev n_max lm ∧ lmNext n_max lm' b j = val ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, b' ≠ b ∨ j' ≠ j → lmNext n_max lm' b' j' = lmNext n_max lm b' j'

Pure state effect of writeLMNextProg.

Section 3: Doubly-linked chain invariant (IsDLChain) and lmPrependProg / lmUnlinkProg #

Auxiliary doubly-linked chain invariant starting with expected previous pointer prev_ptr (0 for the head node, j_prev + 1 after node j_prev).

Doubly-linked chain invariant for a single micro-bucket chain L : List ℕ with head pointer head, prev map, and next map.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.isDLChain_nil (n_max : ℕ) (prev next : ℕ → ℕ) :
IsDLChain n_max 0 prev next []
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.congr {n_max prev_ptr : ℕ} {prev prev' next next' : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) (hp : ∀ x ∈ L, prev' x = prev x) (hn : ∀ x ∈ L, next' x = next x) :
IsDLChainAux n_max prev_ptr prev' next' L
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.congr {n_max head head' : ℕ} {prev prev' next next' : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) (hh : head' = head) (hp : ∀ x ∈ L, prev' x = prev x) (hn : ∀ x ∈ L, next' x = next x) :
IsDLChain n_max head' prev' next' L
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.lt_cap_of_mem {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) {x : ℕ} (hx : x ∈ L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.lt_cap_of_mem {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) {x : ℕ} (hx : x ∈ L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.nodup {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.nodup {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.head_le_cap {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.head_sub_one_mem {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) (hpos : 0 < head) :
head - 1 ∈ L ∧ head - 1 < SuccinctBucket.effBucketCap n_max
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.prev_pos_of_mem {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) (hpos : 0 < prev_ptr) {x : ℕ} (hx : x ∈ L) :
0 < prev x ∧ (prev x = prev_ptr ∨ prev x - 1 ∈ L)
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.prev_sub_one_mem {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) {x : ℕ} (hx : x ∈ L) (_hpos : 0 < prev x) :
prev x = prev_ptr ∨ prev x - 1 ∈ L
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.next_sub_one_mem {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) {x : ℕ} (hx : x ∈ L) (hpos : 0 < next x) :
next x - 1 ∈ L ∧ next x - 1 ≠ x
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.prev_le_cap {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) {x : ℕ} (hx : x ∈ L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.next_le_cap {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) {x : ℕ} (hx : x ∈ L) :
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.isDLChain_prepend {n_max head j_new : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) (hj_cap : j_new < SuccinctBucket.effBucketCap n_max) (hj_not : j_new ∉ L) :
have prev₁ := Function.update prev j_new 0; have next' := Function.update next j_new head; have prev' := if 0 < head then Function.update prev₁ (head - 1) (j_new + 1) else prev₁; IsDLChain n_max (j_new + 1) prev' next' (j_new :: L)

Prepending j_new ∉ L establishes IsDLChain on j_new :: L.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.isDLChainAux_erase {n_max prev_ptr j_del : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) (hmem : j_del ∈ L) (hprev_not : ∀ x ∈ L, x + 1 ≠ prev_ptr) :
have p := prev j_del; have n := next j_del; have next' := if 0 < p then Function.update next (p - 1) n else next; have prev' := if 0 < n then Function.update prev (n - 1) p else prev; IsDLChainAux n_max prev_ptr prev' next' (L.erase j_del)

Unlinking j_del ∈ L establishes IsDLChainAux on L.erase j_del.

Parameter-free Memory.Prog operation prepending local slot j_new = lmWriteVal d to micro-bucket chain (b, m) = (lmWriteBucket d, lmWriteIdx d) at base = lmWriteBase d.

Memory.Prog operation prepending local slot j_new = d.2 to micro-bucket chain (b, m) = (d.1.1.2, d.1.2) at base = d.1.1.1.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmPrependGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
lmPrependGenProg (mkDictParams U V w n_max h_space, d) = lmPrependProg U V w n_max h_space d

Precondition for lmPrependProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmPrependGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
LMPrependGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ LMPrependPre U V w₀ n_max h_space w d s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChainAux.length_le {n_max prev_ptr : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChainAux n_max prev_ptr prev next L) :

The length of any chain satisfying IsDLChainAux is at most effBucketCap n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.IsDLChain.length_le {n_max head : ℕ} {prev next : ℕ → ℕ} {L : List ℕ} (h : IsDLChain n_max head prev next L) :

The length of any chain satisfying IsDLChain is at most effBucketCap n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmPrependProg_effect {U V w n_max h_space base b m j_new : ℕ} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hj : j_new < SuccinctBucket.effBucketCap n_max) (hj_n : j_new < n_max) {s : Memory.State} (hold : lmHead n_max (lmAt base U V w n_max h_space s.mem) b m ≤ SuccinctBucket.effBucketCap n_max) :
have old_h := lmHead n_max (lmAt base U V w n_max h_space s.mem) b m; have s' := (Memory.spec 0).clientState s (lmPrependProg U V w n_max h_space (((base, b), m), j_new)); 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 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, lmHead n_max (lmAt base U V w n_max h_space s'.mem) b' m' = if b' = b ∧ m' = m then j_new + 1 else lmHead n_max (lmAt base U V w n_max h_space s.mem) b' m') ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, lmNext n_max (lmAt base U V w n_max h_space s'.mem) b' j' = if b' = b then Function.update (lmNext n_max (lmAt base U V w n_max h_space s.mem) b) j_new old_h j' else lmNext n_max (lmAt base U V w n_max h_space s.mem) b' j') ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, lmPrev n_max (lmAt base U V w n_max h_space s'.mem) b' j' = if b' = b then (if 0 < old_h then Function.update (Function.update (lmPrev n_max (lmAt base U V w n_max h_space s.mem) b) j_new 0) (old_h - 1) (j_new + 1) else Function.update (lmPrev n_max (lmAt base U V w n_max h_space s.mem) b) j_new 0) j' else lmPrev n_max (lmAt base U V w n_max h_space s.mem) b' j'

Pure state effect of lmPrependProg.

Parameter-free Memory.Prog operation unlinking local slot j_del = lmWriteVal d from micro-bucket chain (b, m) = (lmWriteBucket d, lmWriteIdx d) at base = lmWriteBase d.

Memory.Prog operation unlinking local slot j_del = d.2 from micro-bucket chain (b, m) = (d.1.1.2, d.1.2) at base = d.1.1.1.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmUnlinkGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
lmUnlinkGenProg (mkDictParams U V w n_max h_space, d) = lmUnlinkProg U V w n_max h_space d

Precondition for lmUnlinkProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmUnlinkGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
LMUnlinkGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ LMUnlinkPre U V w₀ n_max h_space w d s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmUnlinkProg_effect {U V w n_max h_space base b m j_del : ℕ} (hw : 0 < w) (hb : b < FeistelQuotient.numBuckets n_max) (hm : m < SuccinctBucket.numMicroPerBucket n_max) (hj : j_del < SuccinctBucket.effBucketCap n_max) {s : Memory.State} (hp_le : lmPrev n_max (lmAt base U V w n_max h_space s.mem) b j_del ≤ SuccinctBucket.effBucketCap n_max) (hn_le : lmNext n_max (lmAt base U V w n_max h_space s.mem) b j_del ≤ SuccinctBucket.effBucketCap n_max) :
have p := lmPrev n_max (lmAt base U V w n_max h_space s.mem) b j_del; have n := lmNext n_max (lmAt base U V w n_max h_space s.mem) b j_del; have s' := (Memory.spec 0).clientState s (lmUnlinkProg U V w n_max h_space (((base, b), m), j_del)); 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 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ m' < SuccinctBucket.numMicroPerBucket n_max, lmHead n_max (lmAt base U V w n_max h_space s'.mem) b' m' = if b' = b ∧ m' = m then if 0 < p then lmHead n_max (lmAt base U V w n_max h_space s.mem) b m else n else lmHead n_max (lmAt base U V w n_max h_space s.mem) b' m') ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, lmNext n_max (lmAt base U V w n_max h_space s'.mem) b' j' = if b' = b then (if 0 < p then Function.update (lmNext n_max (lmAt base U V w n_max h_space s.mem) b) (p - 1) n else lmNext n_max (lmAt base U V w n_max h_space s.mem) b) j' else lmNext n_max (lmAt base U V w n_max h_space s.mem) b' j') ∧ ∀ b' < FeistelQuotient.numBuckets n_max, ∀ j' < SuccinctBucket.effBucketCap n_max, lmPrev n_max (lmAt base U V w n_max h_space s'.mem) b' j' = if b' = b then (if 0 < n then Function.update (lmPrev n_max (lmAt base U V w n_max h_space s.mem) b) (n - 1) p else lmPrev n_max (lmAt base U V w n_max h_space s.mem) b) j' else lmPrev n_max (lmAt base U V w n_max h_space s.mem) b' j'

Pure state effect of lmUnlinkProg.

Section 4: Phase 1 micro-chain search (searchMicroChainProg) #

@[reducible, inline]

1-based cursor pointer ptr in a Phase 1 micro-chain accumulator (((ptr, found), j_found), phys_found).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.microAccPtr_mk (ptr found j_found phys_found : ℕ) :
microAccPtr (((ptr, found), j_found), phys_found) = ptr
@[reducible, inline]

Status pair (ptr, found) in a Phase 1 micro-chain accumulator / result (((ptr, found), j_found), phys_found).

@[reducible, inline]

Matched slot index j_found in a Phase 1 micro-chain accumulator / result (((ptr, found), j_found), phys_found).

@[reducible, inline]

Dictionary parameters dp in a parameter-free Phase 1 loop input (((dp, ((base, b), q_target)), z0), extra).

@[reducible, inline]

Bucket location (base, b) in a parameter-free Phase 1 step input (((dp, ((base, b), q_target)), z0), extra).

@[reducible, inline]

Base address base in a parameter-free Phase 1 step input (((dp, ((base, b), q_target)), z0), extra).

@[reducible, inline]

Bucket index b in a parameter-free Phase 1 step input (((dp, ((base, b), q_target)), z0), extra).

@[reducible, inline]

Target quotient q_target in a parameter-free Phase 1 step input (((dp, ((base, b), q_target)), z0), extra).

@[reducible, inline]

Query tuple ((base, b), q_target) in a specialized Phase 1 step/loop input ((((base, b), q_target), z0), extra).

@[reducible, inline]

Sentinel word z0 in a specialized Phase 1 step/loop input ((((base, b), q_target), z0), extra).

@[reducible, inline]

Base address base in a specialized Phase 1 step input ((((base, b), q_target), z0), extra).

@[reducible, inline]

Bucket index b in a specialized Phase 1 step input ((((base, b), q_target), z0), extra).

@[reducible, inline]

Target quotient q_target in a specialized Phase 1 step input ((((base, b), q_target), z0), extra).

@[reducible, inline]

1-based cursor pointer ptr inside the accumulator of a Phase 1 step input (env, (((ptr, found), j_found), phys_found)).

@[reducible, inline]

Previously recorded match index j_found inside the accumulator of a Phase 1 step input (env, (((ptr, found), j_found), phys_found)).

@[reducible, inline]

Previously recorded physical slot phys_found inside the accumulator of a Phase 1 step input (env, (((ptr, found), j_found), phys_found)).

Parameter-free single step of Phase 1 micro-chain traversal: given dp = microLoopCtxParams x, (base, b) = microStepGenLoc x, q_target = microStepGenQuot x, and accumulator pointer ptr = microStepPtr x with 0 < ptr, inspects j = ptr - 1, resolves its physical slot phys, reads quotAt phys, and either stops with (((0, 1), j), phys) on match or advances to next_ptr.

Single step of Phase 1 micro-chain traversal: given x.1 = (((base, b), q_target), z0) and x.2 = (((ptr, found), j_found), phys_found) with 0 < ptr, inspects j = ptr - 1, resolves its physical slot phys, reads quotAt phys, and either stops with (((0, 1), j), phys) on match or advances to next_ptr.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.microStepGenProg_mk (U V w n_max h_space : ℕ) (d1 : (ℕ × ℕ) × ℕ) (z0 : ℕ) (a : ((ℕ × ℕ) × ℕ) × ℕ) :
microStepGenProg (((mkDictParams U V w n_max h_space, d1), z0), a) = microStepProg U V w n_max h_space ((d1, z0), a)
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.clientResult_microStepProg {U V w n_max h_space : ℕ} {x : (((ℕ × ℕ) × ℕ) × ℕ) × ((ℕ × ℕ) × ℕ) × ℕ} (s : Memory.State) (hinv : SlotStoreInv n_max (gmAt (microStepBase x) U V w n_max h_space s.mem)) (hb : microStepBucket x < FeistelQuotient.numBuckets n_max) (hj_bc : microStepPtr x - 1 < bCount n_max (gmAt (microStepBase x) U V w n_max h_space s.mem) (microStepBucket x)) (hj_cap : microStepPtr x - 1 < SuccinctBucket.effBucketCap n_max) :
(Memory.spec 0).clientResult s (microStepProg U V w n_max h_space x) = have j := microStepPtr x - 1; have next_ptr := lmNext n_max (lmAt (microStepBase x) U V w n_max h_space s.mem) (microStepBucket x) j; have phys := slotOf n_max (gmAt (microStepBase x) U V w n_max h_space s.mem) (microStepBucket x) j; have q_val := quotAt (microStepBase x) U w n_max h_space s.mem phys; if q_val = microStepQuot x then (((0, 1), j), phys) else (((next_ptr, 0), microStepMatchIdx x), microStepPhys x)

Step precondition for microStepProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.microStepGenPre_mk (U V w₀ n_max h_space w : ℕ) (d1 : (ℕ × ℕ) × ℕ) (z0 : ℕ) (a : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
MicroStepGenPre w (((mkDictParams U V w₀ n_max h_space, d1), z0), a) s ↔ MicroStepPre U V w₀ n_max h_space w ((d1, z0), a) s

Native loop guard for microLoopGenProg: tests d.2 < a.1.1.1 (z0 < ptr).

Instances For

    Native loop guard for microLoopProg: tests d.2 < a.1.1.1 (z0 < ptr).

    Instances For

      Parameter-free Phase 1 bounded while loop over a micro-bucket chain with ghost cutoff effBucketCap (dpNMax (microLoopCtxParams x)).

      Phase 1 bounded while loop over a micro-bucket chain with ghost cutoff effBucketCap n_max.

      @[simp]
      theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.microLoopGenProg_mk (U V w n_max h_space : ℕ) (d1 : (ℕ × ℕ) × ℕ) (z0 : ℕ) (a : ((ℕ × ℕ) × ℕ) × ℕ) :
      microLoopGenProg (((mkDictParams U V w n_max h_space, d1), z0), a) = microLoopProg U V w n_max h_space ((d1, z0), a)
      @[simp]
      theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.whileSafe_microStepGenProg_mk (U V w₀ n_max h_space w : ℕ) (d1 : (ℕ × ℕ) × ℕ) (z0 k : ℕ) (a : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
      theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.boundedWhile_microStep_spec {U V w₀ n_max h_space w base b q_target prev_ptr : ℕ} {L : List ℕ} {n ptr found j_found phys_found : ℕ} {s : Memory.State} (henv : DictEnvGen w (mkDictParams U V w₀ n_max h_space) base) (hb : b < FeistelQuotient.numBuckets n_max) (hinv : SlotStoreInv n_max (gmAt base U V w₀ n_max h_space s.mem)) (hchain : IsDLChainAux n_max prev_ptr (lmPrev n_max (lmAt base U V w₀ n_max h_space s.mem) b) (lmNext n_max (lmAt base U V w₀ n_max h_space s.mem) b) L) (hc_lt : ∀ j ∈ L, j < bCount n_max (gmAt base U V w₀ n_max h_space s.mem) b) (hn : L.length ≤ n) (hptr : ptr = (Option.map (fun (x : ℕ) => x + 1) L.head?).getD 0) :
      have d := (((base, b), q_target), 0); have a := (((ptr, found), j_found), phys_found); have prog := WordRAM.Realization.boundedWhile microLoopGuard (microStepProg U V w₀ n_max h_space) d n a; (Memory.spec 0).clientState s prog = s ∧ WordRAM.Realization.memoryCost prog s ≤ 8 * L.length ∧ WordRAM.Realization.whileSafe microLoopGuard (microStepProg U V w₀ n_max h_space) (MicroStepPre U V w₀ n_max h_space) w d n a s ∧ have res := (Memory.spec 0).clientResult s prog; if ∃ j ∈ L, 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) = q_target then microAccStatus res = (0, 1) ∧ microAccIdx res ∈ L ∧ 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 (microAccIdx res)) = q_target ∧ res.2 = slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b (microAccIdx res) else microAccStatus res = (0, if L = [] then found else 0)

      Structural induction lemma for boundedWhile microLoopGuard (microStepProg ...) along a valid doubly-linked chain suffix L.

      Parameter-free Phase 1 micro-chain search searchMicroChainGenProg: reads h0 = lmHead b m (d = (dp, (((base, b), q_target), m))) and runs microLoopGenProg from h0.

      Phase 1 micro-chain search searchMicroChainProg: reads h0 = lmHead b m (d = (((base, b), q_target), m)) and runs microLoopProg from h0.

      Precondition for searchMicroChainProg: d = (((base, b), q_target), m) with a valid doubly-linked micro-bucket chain L at (b, m) whose slots are all < bCount b.

      @[simp]
      theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchMicroChainGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) (s : Memory.State) :
      SearchMicroChainGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ SearchMicroChainPre U V w₀ n_max h_space w d s
      theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.searchMicroChainProg_spec {U V w₀ n_max h_space w : ℕ} {d : ((ℕ × ℕ) × ℕ) × ℕ} {s : Memory.State} {L : List ℕ} (henv : DictEnvGen w (mkDictParams U V w₀ n_max h_space) (lmEntryBase d)) (hb : lmEntryBucket d < FeistelQuotient.numBuckets n_max) (hm : d.2 < SuccinctBucket.numMicroPerBucket n_max) (hinv : SlotStoreInv n_max (gmAt (lmEntryBase d) U V w₀ n_max h_space s.mem)) (hchain : IsDLChain n_max (lmHead n_max (lmAt (lmEntryBase d) U V w₀ n_max h_space s.mem) (lmEntryBucket d) d.2) (lmPrev n_max (lmAt (lmEntryBase d) U V w₀ n_max h_space s.mem) (lmEntryBucket d)) (lmNext n_max (lmAt (lmEntryBase d) U V w₀ n_max h_space s.mem) (lmEntryBucket d)) L) (hc_lt : ∀ j ∈ L, j < bCount n_max (gmAt (lmEntryBase d) U V w₀ n_max h_space s.mem) (lmEntryBucket d)) :
      have prog := searchMicroChainProg U V w₀ n_max h_space d; have base := lmEntryBase d; have b := lmEntryBucket d; have q_target := lmEntryIdx d; (Memory.spec 0).clientState s prog = s ∧ WordRAM.Realization.memoryCost prog s ≤ 2 + 8 * L.length ∧ WordRAM.Realization.whileSafe microLoopGuard (microStepProg U V w₀ n_max h_space) (MicroStepPre U V w₀ n_max h_space) w (d.1, 0) (SuccinctBucket.effBucketCap n_max) (((lmHead n_max (lmAt base U V w₀ n_max h_space s.mem) b d.2, 0), 0), 0) s ∧ have res := (Memory.spec 0).clientResult s prog; if ∃ j ∈ L, 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) = q_target then microAccStatus res = (0, 1) ∧ microAccIdx res ∈ L ∧ 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 (microAccIdx res)) = q_target ∧ res.2 = slotOf n_max (gmAt base U V w₀ n_max h_space s.mem) b (microAccIdx res) else microAccStatus res = (0, 0)