Documentation

CslibFrontier.DataStructure.PriorityQueue.WordRAM.SoftHeap.Standard

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 #

Main results #

References #

Batch Input and Output Types #

Batch operation for a Word-RAM soft heap: insert (val, origKey) or extract minimum.

  • insert (val origKey : ℕ) : SHOp

    Insert payload val with original key origKey.

  • extractMin : SHOp

    Extract an item with minimum corrupted key.

3-word flat encoding of a batch operation ([0, val, origKey] or [1, 0, 0]).

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 by 12 / 2 ^ r times inserts).

  • ops : List SHOp

    Sequence of insert and extractMin operations.

Flat Word-RAM input word list [rankThreshold, ops.length] ++ ops.flatMap SHOp.encode.

Maximum payload value or original key occurring in I.ops.

Word-value envelope sufficient for I.encode, internal pools, shFuelBound, and output arrays (w = O(log maxWord + log (r + 1) + log (ops.length + 1))).

Every inserted (val, origKey) in I.ops is bounded by I.maxWord.

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 stride 3).

  • corBase : ℕ

    Base address of the harvested corrupted item payloads array.

  • corCount : ℕ

    Number of corrupted items written to corBase[0..corCount).

Instances For

    Single extraction outcome (found, val, key) stored at extBase + 3 * j.

    • found : ℕ

      1 if an item was extracted, 0 if the heap was empty at that operation.

    • val : ℕ

      Extracted payload value (0 if empty).

    • key : ℕ

      Extracted corrupted key (0 if empty).

    Read the j-th 3-word extraction record from mem at base address base.

    Surviving or extracted soft-heap entry (val, origKey, ckey).

    • val : ℕ

      Item payload value.

    • origKey : ℕ

      Original key at insertion time.

    • ckey : ℕ

      Current (possibly corrupted) upper-bound key.

    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.

    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).

    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 #

    theorem Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.exists_singleSoftHeap_batch_standard_program :
    ∃ (r : ℕ) (C : ℕ) (pc : ℕ) (prog : WordRAM.Program WordRAM.Basis.standard r), ¬prog.ReadsWidth ∧ prog.IsRandFree ∧ ∃ (frontier : Fin r) (out : Fin 3 → Fin r), ∀ {w : ℕ} (I : SHBatchInput), WordRAM.Fits w I.wordBound → ∃ (y : WordRAM.Data r) (n : ℕ), WordRAM.Runs w prog (WordRAM.State.init I.encode) { pc := pc, data := y } n ∧ have res := { extBase := y.regs (out 0), corBase := y.regs (out 1), corCount := y.regs (out 2) }; WordRAM.step w prog { pc := pc, data := y } = WordRAM.Outcome.halt res.extBase ∧ Memory.WellFormed w (WordRAM.Realization.memoryState frontier y) ∧ res.extBase + 3 * I.numExtracts ≤ (WordRAM.Realization.memoryState frontier y).frontier ∧ res.corBase + res.corCount ≤ (WordRAM.Realization.memoryState frontier y).frontier ∧ (∃ (trace : SHBatchTrace I), List.map (SHBatchExtract.readFrom (WordRAM.Realization.memoryState frontier y).mem res.extBase) (List.range I.numExtracts) = trace.extracts ∧ (List.map (fun (i : ℕ) => (WordRAM.Realization.memoryState frontier y).mem (res.corBase + i)) (List.range res.corCount)).Perm trace.corrupted ∧ res.corCount = trace.corrupted.length ∧ 2 ^ I.rankThreshold * res.corCount ≤ 12 * I.numInserts) ∧ n + 1 ≤ C * (I.numInserts * (I.rankThreshold + 1) + I.numExtracts + 1)

    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.

    theorem Cslib.DataStructure.PriorityQueue.WordRAM.SoftHeap.exists_singleSoftHeap_batch_standard_program_eps :
    ∃ (r : ℕ) (C : ℕ) (pc : ℕ) (prog : WordRAM.Program WordRAM.Basis.standard r), ¬prog.ReadsWidth ∧ prog.IsRandFree ∧ ∃ (frontier : Fin r) (out : Fin 3 → Fin r), ∀ (ε : ℚ), 0 < ε → ∀ {w : ℕ} (I : SHBatchInput), I.rankThreshold = rankThresholdForEps ε → WordRAM.Fits w I.wordBound → ∃ (y : WordRAM.Data r) (n : ℕ), WordRAM.Runs w prog (WordRAM.State.init I.encode) { pc := pc, data := y } n ∧ have res := { extBase := y.regs (out 0), corBase := y.regs (out 1), corCount := y.regs (out 2) }; WordRAM.step w prog { pc := pc, data := y } = WordRAM.Outcome.halt res.extBase ∧ Memory.WellFormed w (WordRAM.Realization.memoryState frontier y) ∧ res.extBase + 3 * I.numExtracts ≤ (WordRAM.Realization.memoryState frontier y).frontier ∧ res.corBase + res.corCount ≤ (WordRAM.Realization.memoryState frontier y).frontier ∧ (∃ (trace : SHBatchTrace I), List.map (SHBatchExtract.readFrom (WordRAM.Realization.memoryState frontier y).mem res.extBase) (List.range I.numExtracts) = trace.extracts ∧ (List.map (fun (i : ℕ) => (WordRAM.Realization.memoryState frontier y).mem (res.corBase + i)) (List.range res.corCount)).Perm trace.corrupted ∧ res.corCount = trace.corrupted.length ∧ ↑res.corCount ≤ ε * ↑I.numInserts ∧ ∀ j ≤ I.ops.length, ∀ (st : List SHBatchEntry), trace.states[j]? = some st → ↑(List.filter (fun (e : SHBatchEntry) => decide (e.origKey < e.ckey)) st).length ≤ ε * ↑(List.countP SHOp.isInsert (List.take j I.ops))) ∧ n + 1 ≤ C * (I.numInserts * (rankThresholdForEps ε + 1) + I.numExtracts + 1)

    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.