Chronological heap-tree model for a static-array Fibonacci heap #
This file defines the raw field view RawState n of a static-array Fibonacci heap together with an
inductive rose-tree witness FHTree n whose children lists record the chronological linking order
used in Fredman and Tarjan's child-loss rank invariant Fredman and Tarjan.
Representing trees inductively rather than by pointer reachability makes framing across disjoint
subtrees structural: ValidSubtree inspects par, left, and right only at strict descendants
of a subtree's root, so linking roots, rotating or splicing root lists, and updating the degree
consolidation table leave existing subtrees valid by direct structural induction.
Main definitions #
Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.RawState: abstract view of the eightn-word node arrays,(n + 1)-word consolidation array, and four scalar heap counters.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.FHTree: rose tree overFin nwith chronological child lists.Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.ValidSubtree,ValidRoot: heap-order, pointer-realization, and Fredman–Tarjan chronological rank invariants (allowing at most one transientpendingnode during cascading cuts).
Main results #
ValidSubtree.fib_le_size,ValidSubtree.deg_bounds:fib (T.deg + 2) ≤ T.size, yielding bothT.deg ≤ 2 * Nat.log 2 m + 1andT.deg + 1 ≤ mwheneverT.size ≤ m.ValidRoot.singleton,ValidRoot.link: creation of singleton root trees and degree-preserving root linking during consolidation.
References #
Raw array/scalar state and marked-node counting #
Decoded view of the static arrays and persistent scalar registers of a Fibonacci heap on n
handles.
Key array
key[v](v < n).Nullable parent pointer array
par[v](0= root,p + 1= parentp).Nullable first-child pointer array
child[v](0= leaf,c + 1= childc).Circular doubly-linked sibling predecessor array
left[v].Circular doubly-linked sibling successor array
right[v].Child-list degree array
deg[v].Cascading-cut mark array
mark[v](0= unmarked,1= marked).Heap membership array
inHeap[v](0= absent,1= present).Degree-consolidation scratch table
A[d](0= empty,u + 1= rootu).- minRoot : ℕ
Nullable minimum-root pointer
minRoot(0= empty,r + 1= rootr). - numRoots : ℕ
Number of trees in the root list.
- numMarked : ℕ
Number of currently live, marked handles.
- sz : ℕ
Total number of live handles in the heap.
Instances For
Number of currently live, marked handles.
Instances For
Forward pointer chains for consolidation traversal #
Every circular doubly-linked list forms a RightChain.
Chronological rose-tree witnesses #
Root handle of T.
Instances For
Root degree of T.
Instances For
Number of nodes in T.
Instances For
Subtree and root invariants #
Structural heap-order, child-list, and chronological rank invariant on a subtree T
(hrank, a strengthening of Fredman and Tarjan, Lemma 1, p. 604;
Cormen et al., Lemma 19.1).
When pending = some w, w has just lost a child during cascading cuts and is permitted one extra
unit of slack before either being cut itself (mark w = 1) or becoming marked (mark w = 0).
- mk {n : ℕ} {st : RawState n} {pending : Option (Fin n)} {u : Fin n} {cs : List (FHTree n)} (hin : st.inHeap u ≠ 0) (hmark : st.mark u ≤ 1) (hdeg : st.deg u = cs.length) (hchild : cs = [] ∧ st.child u = 0 ∨ ∃ (h : Fin n) (tail : List (Fin n)), st.child u = ↑h + 1 ∧ IsCircList st.left st.right (h :: tail) ∧ (h :: tail).Perm (List.map FHTree.root cs)) (hpar : ∀ T ∈ cs, st.par T.root = ↑u + 1) (hprio : ∀ T ∈ cs, Lean.IndexedMinPQ.PrioLT (u, st.key u) (T.root, st.key T.root)) (hrank : ∀ (i : ℕ) (hi : i < cs.length), i ≤ st.deg cs[i].root + st.mark cs[i].root + if some cs[i].root = pending then 1 else 0) (hsub : ∀ T ∈ cs, ValidSubtree st pending T) : ValidSubtree st pending (FHTree.node u cs)
Instances For
ValidSubtree inspects par, left, right, and pending only on strict descendants
forestNodes T.children, never on T.root itself.
Fibonacci subtree-size and degree bounds #
Fredman–Tarjan subtree size lower bound (Fredman and Tarjan, Corollary 1,
p. 604; Cormen et al., Lemma 19.4): in any subtree with no pending cascading cut,
Nat.fib (T.deg + 2) ≤ T.size.
Constructing and linking root trees #
Creating a singleton root tree .node v [].
Linking an equal-degree root tree T₂ as the newest child of T₁ preserves ValidRoot
when (T₁.root, key₁) strictly precedes (T₂.root, key₂) under IndexedMinPQ.PrioLT.