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.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.rFib,space,potential,charge: register count (42), memory footprint (9 * n + 1), integer potential, and per-operation amortized charges.Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.code,dispatchCode: structuredPQCode .exact rFibbundle and unified operation dispatcher.Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.FibInv: full machine-state invariant overData rFib.
Main results #
Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.FibInv.supported,potential_supported: register and memory framing forStateTransitionImpl.
References #
Total register count of the standalone/subroutine Fibonacci heap machine.
Persistent register holding handle-universe size n.
Persistent base address of key[0..n-1] (base).
Persistent base address of par[0..n-1] (base + n).
Persistent base address of child[0..n-1] (base + 2 * n).
Persistent base address of left[0..n-1] (base + 3 * n).
Persistent base address of right[0..n-1] (base + 4 * n).
Persistent base address of deg[0..n-1] (base + 5 * n).
Persistent base address of mark[0..n-1] (base + 6 * n).
Persistent base address of inHeap[0..n-1] (base + 7 * n).
Persistent base address of cons[0..n] (base + 8 * n).
Persistent constant register 0.
Persistent constant register 1.
Persistent nullable minimum-root pointer (0 = empty, m + 1 = some m).
Persistent root-list length counter (numRoots).
Persistent marked-node counter (numMarked).
Persistent live-element count (sz).
Caller high tag bit (≠ 0 selects extractMin).
Caller middle tag bit.
Caller low tag bit.
Caller handle argument register (v.val).
Caller key argument register (k).
Output flag register (output = outFlag).
Output handle register (u.val for non-empty extractMin).
Output key register (k for present getKey and non-empty extractMin).
Scratch pointer register for generic SubroutineCode.zeroFillCode.
Scratch zero register for generic SubroutineCode.zeroFillCode.
Scratch one register for generic SubroutineCode.zeroFillCode.
Outer scratch register: extracted vertex z or cascading-cut target cur.
Outer scratch register: parent p in decreaseKey or rStart in extractMin.
Outer loop counter (rem) in extractMin Phase A.
Outer current-node register (iterCur) or cascading-cut loop guard.
Outer saved-next-node register (iterNxt) in extractMin Phase A.
Maximum degree tracker (maxDeg / limit) in extractMin.
Degree index (d / curD) in scatterRootCode and extractMin Phase B.
Inner helper scratch register 0 (addresses).
Inner helper scratch register 1.
Inner helper scratch register 2.
Inner helper scratch register 3.
Inner helper scratch register 4.
Inner helper scratch register 5.
Inner helper scratch register 6.
Persistent registers are 0..16 (false); caller/scratch registers are 17..41 (true).
Static memory footprint on n handles: 9 * n + 1 words.
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.
Initialize array-base pointers and zero scalar heap counters (O(1) steps).
Set flagReg ← 1 if (uReg, kuReg) strictly precedes (vReg, kvReg) lexicographically
(ku < kv ∨ (ku = kv ∧ u < v)), and flagReg ← 0 otherwise. Writes only flagReg.
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.
Insert root uReg into the root circular list, update minRootReg under
IndexedMinPQ.PrioLT, and increment numRootsReg. Writes only s0..s5, minRootReg, numRootsReg.
isEmpty: sets outFlag ← 1 if minRootReg = 0, else 0.
getKey v: loads outFlag ← inHeap[argV] and, if present, outK ← key[argV].
insert v k: initializes singleton root argV with key argK, splices into root list, and
increments szReg.
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.
Evaluate cascading-cut guard iterCur ← 1 iff par[zReg] ≠ 0 ∧ mark[zReg] ≠ 0, else 0.
decreaseKey v k: lowers key[argV] ← argK, cuts argV and runs cascading cuts if parent
order under IndexedMinPQ.PrioLT is violated, and updates minRootReg.
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.
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.
Unified dispatcher over 1-bit tags (tag2, tag1, tag0).
Uniform PQCode .exact rFib bundle for the static-array Fibonacci heap.
Concrete state projection, representation invariant, and amortized bounds #
Project Data rFib at (n, base) to a logical RawState n.
Persistent base-address and constant registers 0..12 hold their initialized values.
nRegholds the handle-universe sizen.frontierRegholds the end of the footprint.baseRegholds the base address ofkey.parBaseholds the base address ofpar.childBaseholds the base address ofchild.leftBaseholds the base address ofleft.rightBaseholds the base address ofright.degBaseholds the base address ofdeg.markBaseholds the base address ofmark.inBaseholds the base address ofinHeap.consBaseholds the base address ofcons.zeroPholds0.onePholds1.
Full Word-RAM representation invariant for FibonacciHeap at (n, K_max, w, base).
Amortized credit per root (80 instructions; marked nodes carry 2 * unitCredit = 160).
Internal consolidation-slot credit (50 instructions per occupied degree slot).
Concrete integer potential 80 * (numRoots + 2 * numMarked).
Instruction bound for isEmpty (including dispatch).
Instruction bound for getKey (including dispatch).
Amortized instruction bound for insert (including dispatch and +80 root potential).
Amortized instruction bound for decreaseKey (including dispatch and cascading cuts).
Amortized instruction bound for extractMin (O(log n + 1)).
Per-operation amortized instruction charge for FibonacciHeap, charging
tExt (IndexedMinPQ.dom s).card on .extractMin in terms of the current number of stored
elements (IndexedMinPQ.dom s).card.
The current number of stored elements (IndexedMinPQ.dom s).card is at most n, so
charge n s .extractMin ≤ tExt n.
Footprint framing and RawState.ofData update lemmas #
A value at most base + 9 * n, such as an address in one of the nine arrays, fits a word.
The ofData_write_* lemmas: a write into one of the nine arrays updates that field of
RawState.ofData and leaves the other eight arrays alone, because the arrays occupy disjoint
address ranges. Each proof unfolds RawState.ofData, clears the eight untouched fields with
Function.update_of_ne (omega), and splits once on the written index for the updated field.
Writing memory keeps the potential.
Setting the marked-node counter.