Documentation

CslibFrontier.DataStructure.PriorityQueue.FibonacciHeap.Native.Initialize

Native reservation of an empty indexed Fibonacci heap #

One uniform exact-basis emitter reserves the original 9 n + 5 cells, returns their base and preserves every memory cell. Address arithmetic and result copies are charged through the existing realize rules. A scalar certificate uses repeated addition without materializing the literal nine: zero capacity can be admitted with three-bit words even though nine does not fit.

Reservation alone does not initialize arbitrary dirty storage. The existing framed empty heap follows under the explicit zero-above-input condition, through zeroAllocator; the method implementations and representation are unchanged. These results certify initialization, not the heap's other methods or either whole consumer migration.

Main results #

Reserve the original layout without a fitting-literal-nine hypothesis. All intermediate additions fit because the final frontier does; the one memory charge includes no clearing.

theorem Cslib.DataStructure.PriorityQueue.FibonacciHeap.Native.Initialize.reserve_exec {r : ℕ} (frontier : Fin r) (src : Fin 1 → Fin r) (tmp : Fin (1 + realizes_reserve.scratchSize + 1) → Fin r) (hi : Function.Injective tmp) (hd : ∀ (i : Fin 1) (j : Fin (1 + realizes_reserve.scratchSize + 1)), src i ≠ tmp j) (hf : ∀ (j : Fin (1 + realizes_reserve.scratchSize + 1)), tmp j ≠ frontier) (hs : ∀ (i : Fin 1), src i ≠ frontier) {w n : ℕ} (x : WordRAM.Data r) (hx : WordRAM.Data.Bounded w x) (hin : x.regs ∘ src = WordRAM.Realization.WordEncoding.encode n) (hfit : WordRAM.Fits w (x.regs frontier + (9 * n + 5))) :
∃ (y : WordRAM.Data r), WordRAM.ExecWithin w (realizes_reserve.code frontier src tmp) x y (2 * realizes_reserve.factor) ∧ WordRAM.Data.Bounded w y ∧ y.mem = x.mem ∧ y.regs frontier = x.regs frontier + (9 * n + 5) ∧ y.regs (tmp (Fin.castAdd (realizes_reserve.scratchSize + 1) 0)) = x.regs frontier ∧ ∀ (i : Fin r), i ≠ frontier → (∀ (j : Fin (1 + realizes_reserve.scratchSize + 1)), tmp j ≠ i) → y.regs i = x.regs i

One selected emitter returns the old frontier and reserves exactly the original span. The fixed exchange factor precedes capacity, width, memory and register layout; all memory and all registers outside the frontier and scratch bank are preserved.

theorem Cslib.DataStructure.PriorityQueue.FibonacciHeap.Native.Initialize.reserve_empty {r n w K : ℕ} (frontier : Fin r) {x y : WordRAM.Data r} (hn : WordRAM.Fits w n) (hK : WordRAM.Fits w K) (hm : y.mem = x.mem) (hfr : y.regs frontier = x.regs frontier + (9 * n + 5)) (hz : Memory.ZeroAbove (WordRAM.Realization.memoryState frontier x)) :
(framed hn hK (x.regs frontier)).inv (WordRAM.Realization.memoryState frontier y) ∧ (framed hn hK (x.regs frontier)).abs (WordRAM.Realization.memoryState frontier y) = IndexedMinPQ.empty n

At the reservation endpoint, the existing zero-above precondition establishes the exact empty indexed-queue abstraction. No fresh cells have been cleared or changed.