Documentation

Complexity.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.Trees

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 #

Main results #

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 : Fin n → ℕ

    Key array key[v] (v < n).

  • par : Fin n → ℕ

    Nullable parent pointer array par[v] (0 = root, p + 1 = parent p).

  • child : Fin n → ℕ

    Nullable first-child pointer array child[v] (0 = leaf, c + 1 = child c).

  • left : Fin n → ℕ

    Circular doubly-linked sibling predecessor array left[v].

  • right : Fin n → ℕ

    Circular doubly-linked sibling successor array right[v].

  • deg : Fin n → ℕ

    Child-list degree array deg[v].

  • mark : Fin n → ℕ

    Cascading-cut mark array mark[v] (0 = unmarked, 1 = marked).

  • inHeap : Fin n → ℕ

    Heap membership array inHeap[v] (0 = absent, 1 = present).

  • cons : ℕ → ℕ

    Degree-consolidation scratch table A[d] (0 = empty, u + 1 = root u).

  • minRoot : ℕ

    Nullable minimum-root pointer minRoot (0 = empty, r + 1 = root r).

  • 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

    Set of currently live, marked handles.

    Instances For

      Number of currently live, marked handles.

      Instances For
        theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.markedCount_clear_one {n : ℕ} {st st' : RawState n} {u : Fin n} (hin : st.inHeap u ≠ 0) (hm : st.mark u ≠ 0) (hu : st'.mark u = 0) (hother : ∀ (x : Fin n), x ≠ u → (st'.inHeap x ≠ 0 ∧ st'.mark x ≠ 0 ↔ st.inHeap x ≠ 0 ∧ st.mark x ≠ 0)) :
        theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.markedCount_set_one {n : ℕ} {st st' : RawState n} {u : Fin n} (hin : st'.inHeap u ≠ 0) (hm0 : st.mark u = 0) (hm1 : st'.mark u ≠ 0) (hother : ∀ (x : Fin n), x ≠ u → (st'.inHeap x ≠ 0 ∧ st'.mark x ≠ 0 ↔ st.inHeap x ≠ 0 ∧ st.mark x ≠ 0)) :

        Forward pointer chains for consolidation traversal #

        One-way right-pointer chain through a remaining list of roots or children.

        Instances For
          theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.RightChain.frame {n : ℕ} {right right' : Fin n → ℕ} {L : List (Fin n)} (hL : RightChain right L) (heq : ∀ x ∈ L, right' x = right x) :
          RightChain right' L
          theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.IsCircList.rightChain {n : ℕ} {left right : Fin n → ℕ} {L : List (Fin n)} (hL : IsCircList left right L) :
          RightChain right L

          Every circular doubly-linked list forms a RightChain.

          Chronological rose-tree witnesses #

          Rose tree over Fin n whose children list is ordered chronologically by linking time.

          Instances For

            Chronological child list of T.

            Instances For

              Preorder list of all handles in T.

              Instances For

                Concatenated handle lists of a forest ts.

                Instances For

                  Number of nodes in T.

                  Instances For
                    theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.forestNodes_nodup_disjoint {n : ℕ} {ts : List (FHTree n)} (hnd : (forestNodes ts).Nodup) {T₁ T₂ : FHTree n} (h₁ : T₁ ∈ ts) (h₂ : T₂ ∈ ts) (hne : T₁ ≠ T₂) {x : Fin n} (hx₁ : x ∈ T₁.nodes) (hx₂ : x ∈ T₂.nodes) :

                    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).

                    Instances For

                      A valid root tree is a valid subtree whose root has par = 0 and mark = 0.

                      Instances For
                        theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.ValidSubtree.frame {n : ℕ} {st st' : RawState n} {pending pending' : Option (Fin n)} {T : FHTree n} (hT : ValidSubtree st pending T) (hnode : ∀ x ∈ T.nodes, st'.inHeap x = st.inHeap x ∧ st'.mark x = st.mark x ∧ st'.deg x = st.deg x ∧ st'.child x = st.child x ∧ st'.key x = st.key x) (hdesc : ∀ x ∈ forestNodes T.children, st'.par x = st.par x ∧ st'.left x = st.left x ∧ st'.right x = st.right x ∧ (some x = pending' ↔ some x = pending)) :
                        ValidSubtree st' pending' T

                        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.

                        Any valid subtree of size at most m has degree ≤ 2 * Nat.log 2 m + 1 and deg + 1 ≤ m.

                        Constructing and linking root trees #

                        theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.ValidRoot.singleton {n : ℕ} {st : RawState n} {v : Fin n} (hin : st.inHeap v ≠ 0) (hpar : st.par v = 0) (hchild : st.child v = 0) (hdeg : st.deg v = 0) (hmark : st.mark v = 0) :

                        Creating a singleton root tree .node v [].