Fibonacci Heap: decreaseKey and Cascading Cuts #
This file proves the exact-Word-RAM specification decreaseKeyCode_exec (O(1) amortized time
under potential = 80 * (numRoots + 2 * numMarked)). The proofs step the machine code; the forest
reasoning is that of the record heap (Cslib.DataStructure.PriorityQueue.FibonacciHeap,
DecreaseKey.lean), applied to the machine state read as RawState.ofData n base x:
- Single-edge cut (
cutNodeCode_raw):cutNodeCoderuns in at most36instructions, and the state it leaves iscutState, so its effect isCutsNode(cutsNode_cutState). The potential drops by80whencurwas marked and grows by80otherwise. - Cascading cuts (
decreaseKeyCode_exec): the machine writes the new key first, so the forest is read with the old keys asCascading. Each cut isCutsNode.cascading, and the cascade ends withCascading.clear_rootorCascading.mark.Cascading.lowerRootKey(after a cut) orFibRawInv.lowerKey_noCut(without one) then stores the key.ExecWithin.loop_potential_retainpays every cascading-cut iteration (≤ 50instructions including the loop step) out of the-80drop inpotential; marking the stopping non-root ancestor costs+160, andFibInvis restored within amortized charge330(335 ≤ tDec nincluding dispatch).
Main definitions #
cutNodeCodeanddecreaseKeyCodeare defined inCslibFrontier/DataStructure/PriorityQueue/WordRAM/FibonacciHeap/Program.lean.
Main results #
Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.cutNodeCode_raw: a single-edge cut, asCutsNode.Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.decreaseKeyCode_exec:O(1)amortizeddecreaseKeyspecification with cascading cuts.
References #
Local framing and proof-only helpers #
evalCascGuard specification #
evalCascGuard sets iterCur ← 1 iff par[cur] ≠ 0 ∧ mark[cur] ≠ 0, and 0 otherwise, in
at most 8 instructions while preserving BaseRegs, RawState.ofData, and all registers other
than s0, s1, s2, iterCur.
cutNodeCode machine execution #
Raw machine specification of cutNodeCode: cuts cur (zReg) from p (pReg) and splices
cur after m (minRootReg = m.val + 1) in at most 36 instructions. Its effect is CutsNode,
as for the record program cut: the machine state after the cut is cutState, and
cutsNode_cutState does the list reasoning.
Final minRootReg update tail and decreaseKeyCode_exec #
decreaseKeyCode lowers key[v] to k ≤ k₀ (s v = some k₀), performs cascading cuts when
parent heap order is violated, updates minRootReg, and restores FibInv in amortized time
t + potential y ≤ 330 + potential x. The forest reasoning is the record heap's: the machine writes
the new key first, so the forest is read with the old keys ({ st with key := st₀.key }) as
Cascading, each cut is CutsNode.cascading, the cascade ends with Cascading.clear_root or
Cascading.mark, and Cascading.lowerRootKey or FibRawInv.lowerKey_noCut stores the key.