Flat Program .standard Batch Driver for the Parametric Word-RAM Soft Heap #
Single-heap Word-RAM batch driver step toward #8624, after [Cha00], Theorem 1.1 and
Section 5.1, Lemmas 5.1–5.2 (NECI TR 99-097 preprint, pp. 2, 12–13), and [PR02],
Section 2.4, p. 19, Lemma 2.2 and Section 3.2, pp. 21–22, Figure 1 and Lemma 3.3. Packages
shInsert, shExtractMin, and batch shCollectCorrupted (without
meld or arbitrary-handle delete) into a single flat deterministic width-blind standard-basis
program (Program .standard r, ¬prog.ReadsWidth, prog.IsRandFree) operating directly on
State.init I.encode under Fits w I.wordBound, hiding shFuelBound internally and certifying
O(N * (r + 1) + M + 1) (and O(N * (rankThresholdForEps ε + 1) + M + 1) for arbitrary
0 < ε : ℚ, where rankThresholdForEps ε = Nat.log 2 (Nat.ceil (12 / ε)) + 1) native Word-RAM
step counts alongside per-step corruption bounds and multiset-coupled ckey monotonicity.
Main definitions #
Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.SHOp,SHBatchInput: batch operation type and flat input encoding ([rankThreshold, ops.length] ++ ops.flatMap SHOp.encode) with fit envelopeSHBatchInput.wordBound.Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.SHBatchResult,SHBatchExtract,SHBatchEntry,SHBatchStepRel,SHBatchTrace: named output/trace structures (SHBatchResult.equiv), single-step transition relation, and trace witness.Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.shBatchProg,SHBatchProgSafe: self-containedMemory.Progbatch driver hidingshFuelBoundinternally.
Main results #
Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.realizes_shBatchProg: uniformRealizes .exact(work := 0) certificate forshBatchProg.Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.shBatchProg_spec: end-to-end correctness, exact extract/corrupted output array layout, trace minimality/permutation/ckeymonotonicity, per-step corruption bound, and amortizedmemoryCostbound forshBatchProg.Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.exists_singleSoftHeap_batch_standard_programandexists_singleSoftHeap_batch_standard_program_eps: single-heap batch stepProgram .standard rfor arbitraryrankThreshold : ℕor0 < ε : ℚ(extending PR02 Lemma 2.2's0 < ε < 1 / 2) withO(N * (r + 1) + M + 1)native steps and per-step bounds.
References #
- B. Chazelle, The Soft Heap: An Approximate Priority Queue with Optimal Error Rate, Journal of the ACM 47(6), 2000, Theorem 1.1 and Section 5.1, Lemmas 5.1–5.2 (NECI TR 99-097 preprint, pp. 2, 12–13).
- S. Pettie and V. Ramachandran, An Optimal Minimum Spanning Tree Algorithm, Journal of the ACM 49(1), 2002, Section 2.4, p. 19, Lemma 2.2 and Section 3.2, pp. 21–22, Figure 1 and Lemma 3.3.
Batch Input and Output Types #
3-word flat encoding of a batch operation ([0, val, origKey] or [1, 0, 0]).
true iff the operation is an insertion.
true iff the operation is a minimum extraction.
Batch Soft-Heap problem instance with corruption rank threshold rankThreshold and operation
list ops.
- rankThreshold : ℕ
Corruption rank threshold
r(corrupted items bounded by12 / 2 ^ rtimes inserts). Sequence of
insertandextractMinoperations.
Number of insert operations in I.ops.
Number of extract-min operations in I.ops.
Sequence of (val, origKey) pairs inserted by I.ops.
Flat Word-RAM input word list [rankThreshold, ops.length] ++ ops.flatMap SHOp.encode.
Maximum payload value or original key occurring in I.ops.
Insert count plus extract count equals total operation count.
Number of inserted items equals I.numInserts.
Every inserted (val, origKey) in I.ops is bounded by I.maxWord.
Every word and length of I.encode fits in w bits when Fits w I.wordBound.
Output summary returned by shBatchProg: base address extBase of the numExtracts
3-word extract records (found, val, key), base address corBase of the harvested corrupted
payload array, and its length corCount.
- extBase : ℕ
Base address of the extract records array (
(found, val, key)of stride3). - corBase : ℕ
Base address of the harvested corrupted item payloads array.
- corCount : ℕ
Number of corrupted items written to
corBase[0..corCount).
Instances For
Canonical 3-word tuple equivalence for SHBatchResult.
Single extraction outcome (found, val, key) stored at extBase + 3 * j.
Read the j-th 3-word extraction record from mem at base address base.
Single-step algebraic transition relation for I.ops[j]? from heap state st to st',
with extraction sequence extracts. Enforces multiset-coupled ckey non-decrease
(List.Forall₂ on a permutation) across both .insert and .extractMin, non-degradation
(origKey ≤ ckey), and minimum-ckey extraction.
Full algebraic execution trace for I : SHBatchInput, certifying extract-min minimality,
key non-degradation (origKey ≤ ckey), multiset-coupled ckey monotonicity (SHBatchStepRel),
item conservation (Perm I.insertedItems), and the per-step corruption bound
2 ^ I.rankThreshold * #corrupted ≤ 12 * #inserts.
- extracts : List SHBatchExtract
Sequence of extraction outcomes in operation order.
- extractedEntries : List SHBatchEntry
Items returned by non-empty extractions (
found = 1). - remaining : List SHBatchEntry
Surviving items remaining in the soft heap after all operations.
Step-by-step heap entry states of length
I.ops.length + 1.Extract list length equals
I.numExtracts.- extracts_found : List.map (fun (ex : SHBatchExtract) => (ex.val, ex.key)) (List.filter (fun (ex : SHBatchExtract) => decide (ex.found = 1)) self.extracts) = List.map (fun (e : SHBatchEntry) => (e.val, e.ckey)) self.extractedEntries
Non-empty extract records match
extractedEntriesin order. - corrupted_eq : self.corrupted = List.map SHBatchEntry.val (List.filter (fun (e : SHBatchEntry) => decide (e.origKey < e.ckey)) self.remaining)
- items_perm : (List.map (fun (e : SHBatchEntry) => (e.val, e.origKey)) (self.extractedEntries ++ self.remaining)).Perm I.insertedItems
All extracted and surviving
(val, origKey)pairs form a permutation ofI.insertedItems. Final corruption bound after all operations.
State trace length equals
I.ops.length + 1.Initial heap state is empty.
Final heap state equals
remaining.- states_corrupted_bound (j : ℕ) : j ≤ I.ops.length → ∀ (st : List SHBatchEntry), self.states[j]? = some st → 2 ^ I.rankThreshold * (List.filter (fun (e : SHBatchEntry) => decide (e.origKey < e.ckey)) st).length ≤ 12 * List.countP SHOp.isInsert (List.take j I.ops)
Per-step corruption bound at every step
j ≤ I.ops.length.
Rational per-step corruption bound when I.rankThreshold = rankThresholdForEps ε
with 0 < ε.
Private Batch Driver and realize Certificates #
Public Batch Program and Certificates #
Self-contained Memory.Prog batch Soft-Heap driver (d = (rankThreshold, ops.length)),
hiding shFuelBound internally and returning (extBase, corBase, corCount).
Native safety domain for shBatchProg.
shBatchProg admits a uniform Realizes .exact compilation certificate (work := 0).
Framing and Proof Helpers for shBatchProg_spec #
Full end-to-end specification of shBatchProg on Memory.State.init I.encode whenever
Fits w I.wordBound: proves SHBatchProgSafe, ValidHistory, output array bounds, exact trace
existence (SHBatchTrace I), per-step corruption bounds and ckey monotonicity, and
O(N * (r + 1) + M + 1) amortized memoryCost.
Uniform Standard-Basis Lowered Theorems #
Single-heap batch step toward #8624 (supporting insert, extractMin, and
collectCorrupted, without meld or arbitrary-handle delete, matching
[PettieRamachandran2002], Section 3.2, pp. 21–22, Figure 1 and the remark after Lemma 3.3 on
p. 22), after [Chazelle2000], Theorem 1.1 and Section 5.1, Lemmas 5.1–5.2 (NECI TR 99-097
preprint, pp. 2, 12–13), and [PettieRamachandran2002], Section 2.4, p. 19, Lemma 2.2. There is a
fixed deterministic width-blind standard-basis program
(¬prog.ReadsWidth, prog.IsRandFree) that, given State.init I.encode for any
I : SHBatchInput and any word width w satisfying Fits w I.wordBound, executes I.ops in
n + 1 ≤ C * (I.numInserts * (I.rankThreshold + 1) + I.numExtracts + 1) native instructions,
producing the exact extraction array at res.extBase, harvested corrupted array at
res.corBase[0..res.corCount) in memoryState frontier y, and trace witness trace with per-step
corruption bounds (12 / 2 ^ r self-contained sizeCap recurrence) and ckey monotonicity.
Single-heap batch step toward #8624 (supporting insert, extractMin, and
collectCorrupted, without meld or arbitrary-handle delete, matching
[PettieRamachandran2002], Section 3.2, pp. 21–22, Figure 1 and the remark after Lemma 3.3 on
p. 22), after [Chazelle2000], Theorem 1.1 and Section 5.1, Lemmas 5.1–5.2 (NECI TR 99-097
preprint, pp. 2, 12–13), and [PettieRamachandran2002], Section 2.4, p. 19, Lemma 2.2.
Specializes exists_singleSoftHeap_batch_standard_program to any rational 0 < ε (extending
Chazelle Theorem 1.1's 0 < ε ≤ 1 / 2 and PR02 Lemma 2.2's 0 < ε < 1 / 2 via this module's
self-contained rankThresholdForEps ε parameterization), guaranteeing at most ε * #inserts
corrupted items at every step and
O(I.numInserts * (rankThresholdForEps ε + 1) + I.numExtracts + 1) instructions.