Internal Path-Allocation Loop (bufEnsureLoopGenProg) #
Internal node-allocating path builder shared privately with Insert.
Main definitions #
Main results #
Precondition for one step of bufEnsurePath (p = (rt, (cur, r_cur))).
Parameter-free wrapper for iterate bufEnsureStepProg.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_bufEnsureLoopGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact bufEnsureLoopGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (BufRt × ℕ × ℕ) × ℕ) (s : Memory.State) =>
match x with
| ((rt, x), rem) => WordRAM.Realization.iterationSafe bufEnsureStepProg BufEnsureStepPre w rt rem x s)
fun (x : (BufRt × ℕ × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEnsureLoop_spec {c U V w n_max base ep : ℕ} (henv : WhpLargeEnv c U V w n_max w base) (hep : ep = 0 ∨ ep = 1) :
have rt := mkBufRt c U V w n_max base ep;
∀ (rem : ℕ) (tr : SuccinctWhp.BufTrie) (cur r_cur : ℕ) (s : Memory.State),
BufTrieMemRep base c U V w n_max ep tr s.mem →
1 ≤ tr.nodeAlloc →
tr.nodeAlloc + rem ≤ SuccinctWhp.maxTrieNodesWhp c n_max →
cur < tr.nodeAlloc →
(∀ (v ch : ℕ), tr.trieChild v ch < tr.nodeAlloc) →
(∀ w' < tr.nodeAlloc, tr.nodeLeafItem w' ≤ tr.itemAlloc) →
have prog := bufEnsureLoopGenProg ((rt, cur, r_cur), rem);
have pPure := SuccinctWhp.bufEnsurePath (SuccinctWhp.bCharWhp n_max) r_cur rem 0 tr cur;
have tr1 := pPure.1;
have leaf := pPure.2;
have s1 := (Memory.spec 0).clientState s prog;
WordRAM.Realization.iterationSafe bufEnsureStepProg BufEnsureStepPre w rt rem (cur, r_cur) s ∧ s1.frontier = s.frontier ∧ ((Memory.spec 0).clientResult s prog).1 = leaf ∧ WordRAM.Realization.memoryCost prog s ≤ 20 * rem ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ BufTrieMemRep base c U V w n_max ep tr1 s1.mem ∧ BufEpFrame base c U V w n_max ep s.mem s1.mem ∧ leaf < tr1.nodeAlloc ∧ tr1.itemAlloc = tr.itemAlloc ∧ tr1.nodeLeafItem leaf ≤ tr1.itemAlloc