Forest invariants and pure state transitions for a Fibonacci heap #
This file lifts the single-tree model of Trees.lean to the full multi-root forest invariant
FibRawInv and proves the structural transitions required by all priority-queue operations:
- Subtree cutting (
exists_parent_info,ValidSubtree.exists_cut): Severing a non-root nodecurfrom its parentpsplitsTinto a new valid root treeT_cutrooted atcurand a modified treeT'withpending = some pwhile preserving the multiset of tree nodes. - Full heap invariant (
FibRawInv): Relatess : IndexedMinPQ.State ntost : RawState nwith exact domain, key, size, root-count, marked-count,minRoot, andcons-zeroing invariants, provingIndexedMinPQ.findMinagreement (FibRawInv.findMin_eq_some) and scalar bounds. - Transient cut invariant (
CutInv): Loop invariant for cascading cuts duringdecreaseKey, allowing a singlependingancestor whose child was just severed.
Main definitions #
Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.FibRawInv: full multi-root forest representation invariant relatingIndexedMinPQ.State ntoRawState n.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.CutInv: transient forest invariant during cascading cuts indecreaseKey.
Main results #
Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.ValidSubtree.exists_cut: severing a non-root node splits its enclosing tree into a valid root tree and apending-parent tree.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.FibRawInv.findMin_eq_some:minRootidentifies the exactIndexedMinPQ.findMinelement.
References #
List surgery lemmas for child removal and replacement #
Parent witnesses and subtree cutting #
Every strict descendant x of T has st.par x = q.val + 1 for some q ∈ T.nodes.
Updating only the root's mark to a value ≤ 1 while keeping all other subtree fields fixed
preserves ValidSubtree.
Pre-cut structural properties of cur and its parent p inside any valid subtree containing
cur as a strict descendant.
Cutting a strict descendant cur (with st.par cur = p.val + 1) from T splits T into a
new root tree T_cut (T_cut.root = cur) and a pruned tree T' (T'.root = T.root,
p ∈ T'.nodes) satisfying ValidRoot st' none T_cut and ValidSubtree st' (some p) T'.
Marking an unmarked pending = some z node (st.mark z = 0, st'.mark z = 1) absorbs the
transient rank slack and restores ValidSubtree st' none T.
Full heap representation invariant and core consequences #
Full structural, key, counter, and root-list invariant relating s : IndexedMinPQ.State n to
st : RawState n.
Instances For
Transient forest invariant during decreaseKey v k while cascading cuts propagate from
pending.
Instances For
FibRawInv holds on the empty priority queue whenever inHeap and cons[0..n] are zeroed and
the four scalar counters are 0.
All scalar counters of a valid Fibonacci heap are bounded by n.
Concrete state uniquely determines the represented IndexedMinPQ.State n.
When st.minRoot = 0, dom s = ∅ and IndexedMinPQ.findMin s = none.
When st.minRoot = z.val + 1, IndexedMinPQ.findMin s = some (z, st.key z).