Fibonacci Heap: Static-Array Word-RAM Program and State Representation #
This file defines the uniform Basis.exact Word-RAM implementation (code : PQCode .exact rFib)
of a static-array Fibonacci heap on n handles (space n = 9 * n + 1 words at
[base, base + 9 * n + 1)), together with its concrete state projection (RawState.ofData),
representation invariant (FibInv), potential function (potential), per-operation amortized time
bounds, and memory/register framing lemmas.
Memory layout ([base, base + 9 * n + 1)) #
[base + 0 * n, base + 1 * n):key[0..n-1][base + 1 * n, base + 2 * n):par[0..n-1](0= root,p + 1= parentp)[base + 2 * n, base + 3 * n):child[0..n-1](0= leaf,c + 1= head childc)[base + 3 * n, base + 4 * n):left[0..n-1](circular sibling list predecessor)[base + 4 * n, base + 5 * n):right[0..n-1](circular sibling list successor)[base + 5 * n, base + 6 * n):deg[0..n-1](number of children)[base + 6 * n, base + 7 * n):mark[0..n-1](0or1, child-loss mark)[base + 7 * n, base + 8 * n):inHeap[0..n-1](0= absent,1= present)[base + 8 * n, base + 9 * n + 1):cons[0..n](degree-consolidation table,0= empty)
Main definitions #
Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.rFib,space,potential,charge: register count (42), memory footprint (9 * n + 1), integer potential, and per-operation amortized charges.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.code,dispatchCode: structuredPQCode .exact rFibbundle and unified operation dispatcher.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.FibInv: full machine-state invariant overData rFib.
Main results #
Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.FibInv.supported,potential_supported: register and memory framing forSubroutineDS.
References #
Total register count of the standalone/subroutine Fibonacci heap machine.
Instances For
Persistent register holding handle-universe size n.
Instances For
Persistent base address of key[0..n-1] (base).
Instances For
Persistent base address of par[0..n-1] (base + n).
Instances For
Persistent base address of child[0..n-1] (base + 2 * n).
Instances For
Persistent base address of left[0..n-1] (base + 3 * n).
Instances For
Persistent base address of right[0..n-1] (base + 4 * n).
Instances For
Persistent base address of deg[0..n-1] (base + 5 * n).
Instances For
Persistent base address of mark[0..n-1] (base + 6 * n).
Instances For
Persistent base address of inHeap[0..n-1] (base + 7 * n).
Instances For
Persistent base address of cons[0..n] (base + 8 * n).
Instances For
Persistent constant register 0.
Instances For
Persistent constant register 1.
Instances For
Persistent nullable minimum-root pointer (0 = empty, m + 1 = some m).
Instances For
Persistent root-list length counter (numRoots).
Instances For
Persistent marked-node counter (numMarked).
Instances For
Persistent live-element count (sz).
Instances For
Caller high tag bit (≠ 0 selects extractMin).
Instances For
Caller middle tag bit.
Instances For
Caller low tag bit.
Instances For
Caller handle argument register (v.val).
Instances For
Caller key argument register (k).
Instances For
Output handle register (u.val for non-empty extractMin).
Instances For
Output key register (k for present getKey and non-empty extractMin).
Instances For
Scratch pointer register for generic SubroutineCode.zeroFillCode.
Instances For
Scratch zero register for generic SubroutineCode.zeroFillCode.
Instances For
Scratch one register for generic SubroutineCode.zeroFillCode.
Instances For
Outer scratch register: extracted vertex z or cascading-cut target cur.
Instances For
Outer scratch register: parent p in decreaseKey or rStart in extractMin.
Instances For
Outer loop counter (rem) in extractMin Phase A.
Instances For
Maximum degree tracker (maxDeg / limit) in extractMin.
Instances For
Inner helper scratch register 0 (addresses).
Instances For
Inner helper scratch register 1.
Instances For
Inner helper scratch register 2.
Instances For
Inner helper scratch register 3.
Instances For
Inner helper scratch register 4.
Instances For
Inner helper scratch register 5.
Instances For
Inner helper scratch register 6.
Instances For
Persistent registers are 0..16 (false); caller/scratch registers are 17..41 (true).
Instances For
Static memory footprint on n handles: 9 * n + 1 words.
Instances For
Structured Basis.exact Fibonacci-heap subprograms #
Advance frontierReg from base to base + 9 * n + 1 using only + nReg and + #1,
avoiding constants > 1 so small word widths (w ≥ 1 when n = 0) never fault.
Instances For
Initialize array-base pointers and zero scalar heap counters (O(1) steps).
Instances For
Set flagReg ← 1 if (uReg, kuReg) strictly precedes (vReg, kvReg) lexicographically
(ku < kv ∨ (ku = kv ∧ u < v)), and flagReg ← 0 otherwise. Writes only flagReg.
Instances For
Splice fresh vertex uReg immediately after hReg in a non-empty circular doubly-linked list
(left[u] := h; left[right[h]] := u; right[u] := right[h]; right[h] := u). Writes only s0, s2.
Instances For
Insert root uReg into the root circular list, update minRootReg under
IndexedMinPQ.PrioLT, and increment numRootsReg. Writes only s0..s5, minRootReg, numRootsReg.
Instances For
isEmpty: sets outFlag ← 1 if minRootReg = 0, else 0.
Instances For
getKey v: loads outFlag ← inHeap[argV] and, if present, outK ← key[argV].
Instances For
insert v k: initializes singleton root argV with key argK, splices into root list, and
increments szReg.
Instances For
Cut child zReg from parent pReg (par[zReg] = pReg + 1, minRootReg ≥ 1), splicing zReg
into the root circular list, clearing par[zReg] and mark[zReg] (updating numMarkedReg if
needed), and incrementing numRootsReg. Writes only s0..s4, numMarkedReg, numRootsReg.
Instances For
Evaluate cascading-cut guard iterCur ← 1 iff par[zReg] ≠ 0 ∧ mark[zReg] ≠ 0, else 0.
Instances For
decreaseKey v k: lowers key[argV] ← argK, cuts argV and runs cascading cuts if parent
order under IndexedMinPQ.PrioLT is violated, and updates minRootReg.
Instances For
Scatter root iterCur into cons, linking equal-degree roots under IndexedMinPQ.PrioLT
until reaching an empty slot and updating maxDegReg. Writes only s0..s6, curDReg, maxDegReg.
Instances For
extractMin: returns 0 when empty, or removes z = minRootReg - 1, scatters z's children
and the numRoots - 1 remaining roots into cons, and scans 0 .. maxDeg to rebuild the root
circular list and minRootReg while restoring cons = 0 in O(log n) steps.
Instances For
Unified dispatcher over 1-bit tags (tag2, tag1, tag0).
Instances For
Uniform PQCode .exact rFib bundle for the static-array Fibonacci heap.
Instances For
Concrete state projection, representation invariant, and amortized bounds #
Project Data rFib at (n, base) to a logical RawState n.
Instances For
Persistent base-address and constant registers 0..12 hold their initialized values.
Instances For
Full Word-RAM representation invariant for FibonacciHeap at (n, K_max, w, base).
Instances For
Amortized credit per root (80 instructions; marked nodes carry 2 * unitCredit = 160).
Instances For
Internal consolidation-slot credit (50 instructions per occupied degree slot).
Instances For
Concrete integer potential 80 * (numRoots + 2 * numMarked).
Instances For
Instruction bound for isEmpty (including dispatch).
Instances For
Instruction bound for getKey (including dispatch).
Instances For
Amortized instruction bound for insert (including dispatch and +80 root potential).
Instances For
Amortized instruction bound for decreaseKey (including dispatch and cascading cuts).
Instances For
Amortized instruction bound for extractMin (O(log n)).
Instances For
Per-operation amortized instruction charge for FibonacciHeap.