Documentation

CslibFrontier.DataStructure.PriorityQueue.WordRAM.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 both:

Over capacity n (n_max) 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.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.dispatchCode_exec {n K_max w base : ℕ} {s : IndexedMinPQ.State n} {x : WordRAM.Data rFib} (o : IndexedMinPQ.Op n) (hinv : FibInv n K_max w base s x) (hval : (indexedMinPQSpec 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 ((indexedMinPQSpec n K_max).stepFn s o).2 ∧ FibInv n K_max w base ((indexedMinPQSpec n K_max).stepFn 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.

WordRAM.StateTransitionImpl certificate and PQPackage bundles #

@[reducible, inline]

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

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

@[reducible, inline]

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

Standalone Basis.standard DynamicProgram and Amortized implementations #

Native conversion normalizes the presence flag and copies lookup keys to the canonical payload slot. Its eight-instruction allowance is charged on every standalone call.

theorem Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.resultRecoding_ready {n K_max w base : ℕ} (hS : WordRAM.Fits w (base + space n)) (hK : WordRAM.Fits w K_max) {s : (indexedMinPQSpec n K_max).State} {x : WordRAM.Data rFib} {o : (indexedMinPQSpec n K_max).Op} {y : WordRAM.Data rFib} {m : ℕ} (_hr : (impl hS hK).toStandard.rep s x) (_hv : (indexedMinPQSpec n K_max).valid s o) (harg : (impl hS hK).toStandard.argMatch o x.regs) (he : WordRAM.Exec w code.toStandard.code x y m) :
(resultRecoding hS hK).ready o y

The source body preserves the opcode bits consumed by native result conversion.

Standalone DynamicProgram implementation of FibonacciHeap over Basis.standard.

Standalone DynamicCertificate for FibonacciHeap over Basis.standard.

Standalone Amortized certificate for FibonacciHeap over Basis.standard, charging eight conversion instructions and one trailing halt per operation.

theorem Cslib.DataStructure.PriorityQueue.WordRAM.FibonacciHeap.run_client_amortized {n K_max w base : ℕ} (hS : WordRAM.Fits w (base + space n)) (hK : WordRAM.Fits w K_max) {α : Type u_1} (p : (indexedMinPQSpec n K_max).Client α) {s : IndexedMinPQ.State n} {x : WordRAM.Data rFib} (hr : FibInv n K_max w base s x) (hv : (indexedMinPQSpec n K_max).ValidHistory s ((indexedMinPQSpec n K_max).runClient s p).2.2) :
∃ (y : WordRAM.Data rFib) (traces : List WordRAM.DynamicProgram.OperationTrace), Executes ((dynamicProgram hS hK).ExecOp w) p x ((indexedMinPQSpec n K_max).runClient s p).1 y traces ∧ FibInv n K_max w base ((indexedMinPQSpec n K_max).runClient s p).2.1 y ∧ total WordRAM.DynamicProgram.OperationTrace.instructions traces + potential y ≤ (indexedMinPQSpec n K_max).totalCost (fun (s : (indexedMinPQSpec n K_max).State) (o : (indexedMinPQSpec n K_max).Op) => charge n s o + 9) s ((indexedMinPQSpec n K_max).runClient s p).2.2 + potential x

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 #

theorem Cslib.DataStructure.PriorityQueue.WordRAM.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 (IndexedMinPQ.Op n)) (hv : (indexedMinPQSpec n K_max).ValidHistory (IndexedMinPQ.empty n) ops) :
∃ (pc₀ : ℕ) (x₀ : WordRAM.Data rFib) (t_init : ℕ) (z : WordRAM.Data rFib) (t_ops : ℕ), WordRAM.Runs w code.initFreshProg { pc := 0, data := { regs := code.initRegs n base, mem := mem₀ } } { pc := pc₀, data := x₀ } t_init ∧ (∃ (out : ℕ), WordRAM.step w code.initFreshProg { pc := pc₀, data := x₀ } = WordRAM.Outcome.halt out) ∧ WordRAM.Modifies { base := base, length := space n }.footprint mem₀ x₀.mem ∧ code.RunsOps (space n) w base (IndexedMinPQ.empty n) x₀ ops z t_ops ∧ t_init + 1 ≤ 421 ∧ t_ops ≤ 421 * (IndexedMinPQ.numQueries ops + IndexedMinPQ.numInserts ops + IndexedMinPQ.numDecreaseKeys ops + IndexedMinPQ.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.DataStructure.PriorityQueue.WordRAM.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 (IndexedMinPQ.Op n)) (hv : (indexedMinPQSpec n K_max).ValidHistory (IndexedMinPQ.empty n) ops) :
∃ (pc₀ : ℕ) (x₀ : WordRAM.Data rFib) (t_init : ℕ) (z : WordRAM.Data rFib) (t_ops : ℕ), WordRAM.Runs w code.initClearProg { pc := 0, data := { regs := code.initRegs n base, mem := mem₀ } } { pc := pc₀, data := x₀ } t_init ∧ (∃ (out : ℕ), WordRAM.step w code.initClearProg { pc := pc₀, data := x₀ } = WordRAM.Outcome.halt out) ∧ WordRAM.Modifies { base := base, length := space n }.footprint mem₀ x₀.mem ∧ code.RunsOps (space n) w base (IndexedMinPQ.empty n) x₀ ops z t_ops ∧ t_init + 1 ≤ 421 * (n + 1) ∧ t_ops ≤ 421 * (IndexedMinPQ.numQueries ops + IndexedMinPQ.numInserts ops + IndexedMinPQ.numDecreaseKeys ops + IndexedMinPQ.numExtractMins ops * (Nat.log 2 n + 1))

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