Documentation

Complexity.Algorithms.WordRAM.PriorityQueue.FibonacciHeap

Static-array Word-RAM Fibonacci heap #

This file assembles the standalone static-array Word-RAM Fibonacci heap Fredman and Tarjan Cormen et al., Chapter 19 over Cslib.WordRAM.Basis.exact (and lifted to Basis.standard) for Cslib.Algorithms.Lean.IndexedMinPQ.spec.

Over n vertex handles in a contiguous memory block [base, base + 9 * n + 1) with concrete integer potential potential x = 80 * (numRoots + 2 * numMarked) (initPotential = 0, Fredman and Tarjan, Section 2, p. 604 (the potential defined before Theorem 1); Cormen et al., Section 19.1, eq. (19.1)):

Main definitions #

Main results #

References #

Unified dispatcher #

theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.dispatchCode_exec {n K_max w base : ℕ} {s : Lean.IndexedMinPQ.State n} {x : WordRAM.Data rFib} (o : Lean.IndexedMinPQ.Op n) (hinv : FibInv n K_max w base s x) (hval : (Lean.IndexedMinPQ.spec n K_max).valid s o) (harg : code.argMatch o x.regs) :
∃ (y : WordRAM.Data rFib) (m : ℕ), WordRAM.Exec w dispatchCode x y m ∧ code.decode o y.regs = some ((Lean.IndexedMinPQ.spec n K_max).step s o).2 ∧ FibInv n K_max w base ((Lean.IndexedMinPQ.spec n K_max).step s o).1 y ∧ WordRAM.Modifies { base := base, length := space n }.footprint x.mem y.mem ∧ m + potential y ≤ charge n s o + potential x

Unified dispatcher dispatchCode implements all five IndexedMinPQ operations within charge n s o amortized instructions over Basis.exact.

SubroutineDS certificate and PQPackage bundles #

Unified standalone and inline-subroutine specification/resource certificate for FibonacciHeap over Basis.exact.

Instances For

    Parametric PQPackage .exact rFib bundle for plug-and-play graph algorithms over Basis.exact.

    Instances For
      @[reducible, inline]

      Parametric PQPackage .standard rFib bundle lifted to Basis.standard.

      Instances For

        Standalone Basis.standard DynamicProgram and Stateful.Amortized realizations #

        Standalone DynamicProgram realization of FibonacciHeap over Basis.standard.

        Instances For

          Standalone DynamicCertificate for FibonacciHeap over Basis.standard.

          Instances For

            Standalone Stateful.Amortized certificate for FibonacciHeap over Basis.standard, charging + 1 per operation for the trailing halt instruction.

            Adaptive-client amortized execution bound for any admissible IndexedMinPQ client p over Basis.standard.

            Standalone end-to-end Basis.exact flat-program operation-sequence theorems #

            Compiled flat Program .exact rFib for O(1) fresh zeroed-memory initialization.

            Instances For

              Compiled flat Program .exact rFib for O(n) dirty-memory reusable initialization.

              Instances For

                Compiled flat Program .exact rFib serving all five priority-queue operations.

                Instances For

                  Initial register assignment supplying n in nReg (R[0]), base in frontierReg (R[1]), and 0 elsewhere.

                  Instances For

                    Deliver operation o's 3-bit tag into tag2..tag0 (R[17..19]) and its handle/key arguments into argV, argK (R[20..21]), leaving all other registers unchanged.

                    Instances For

                      Count isEmpty and getKey queries in an operation sequence.

                      Instances For

                        Count insert operations in an operation sequence.

                        Instances For

                          Count decreaseKey operations in an operation sequence.

                          Instances For

                            Count extractMin operations in an operation sequence.

                            Instances For

                              Sequential flat-program execution of ops by repeated calls to opProg: each call prepares input registers via prepareRegs, runs opProg from pc = 0 to halt, decodes the exact IndexedMinPQ result, modifies memory only within [base, base + space n), and accumulates total instructions executed (each final halt included).

                              Instances For
                                theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.run_ops_exact_fresh {n K_max w base : ℕ} (hS : WordRAM.Fits w (base + space n)) (hK : WordRAM.Fits w K_max) {mem₀ : ℕ → ℕ} (hmem : ∀ (a : ℕ), WordRAM.Fits w (mem₀ a)) (hzero : ∀ a ∈ { base := base, length := space n }.footprint, mem₀ a = 0) (ops : List (Lean.IndexedMinPQ.Op n)) (hv : (Lean.IndexedMinPQ.spec n K_max).ValidHistory (Lean.IndexedMinPQ.empty n) ops) :
                                ∃ (pc₀ : ℕ) (x₀ : WordRAM.Data rFib) (t_init : ℕ) (z : WordRAM.Data rFib) (t_ops : ℕ), WordRAM.Runs w initFreshProg { pc := 0, data := { regs := initRegs n base, mem := mem₀ } } { pc := pc₀, data := x₀ } t_init ∧ (∃ (out : ℕ), WordRAM.step w initFreshProg { pc := pc₀, data := x₀ } = WordRAM.Outcome.halt out) ∧ WordRAM.Modifies { base := base, length := space n }.footprint mem₀ x₀.mem ∧ RunsOps w base (Lean.IndexedMinPQ.empty n) x₀ ops z t_ops ∧ t_init + 1 ≤ 421 ∧ t_ops ≤ 421 * (numQueries ops + numInserts ops + numDecreaseKeys ops + numExtractMins ops * (Nat.log 2 n + 1))

                                Standalone Basis.exact operation-sequence theorem with O(1) fresh initialization on zeroed [base, base + 9 * n + 1).

                                theorem Cslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.run_ops_exact_reusable {n K_max w base : ℕ} (hS : WordRAM.Fits w (base + space n)) (hK : WordRAM.Fits w K_max) {mem₀ : ℕ → ℕ} (hmem : ∀ (a : ℕ), WordRAM.Fits w (mem₀ a)) (ops : List (Lean.IndexedMinPQ.Op n)) (hv : (Lean.IndexedMinPQ.spec n K_max).ValidHistory (Lean.IndexedMinPQ.empty n) ops) :
                                ∃ (pc₀ : ℕ) (x₀ : WordRAM.Data rFib) (t_init : ℕ) (z : WordRAM.Data rFib) (t_ops : ℕ), WordRAM.Runs w initClearProg { pc := 0, data := { regs := initRegs n base, mem := mem₀ } } { pc := pc₀, data := x₀ } t_init ∧ (∃ (out : ℕ), WordRAM.step w initClearProg { pc := pc₀, data := x₀ } = WordRAM.Outcome.halt out) ∧ WordRAM.Modifies { base := base, length := space n }.footprint mem₀ x₀.mem ∧ RunsOps w base (Lean.IndexedMinPQ.empty n) x₀ ops z t_ops ∧ t_init + 1 ≤ 421 * (n + 1) ∧ t_ops ≤ 421 * (numQueries ops + numInserts ops + numDecreaseKeys ops + numExtractMins ops * (Nat.log 2 n + 1))

                                Standalone Basis.exact operation-sequence theorem with O(n) reusable initialization on arbitrary w-bounded memory mem₀.