Amortized memory cost of the Fibonacci Dijkstra source #
The existing framed potential pays for the actual memory histories, and the existing Dijkstra operation counts retain the reachable-vertex bound. Dirty initialization is constant because the original input convention already makes the reserved cells zero. These are memory costs; the native flat-program proof must additionally charge its real prefix, arithmetic and control.
Main results #
run_spec: original admissibility and distance output, with the sharper reachable-vertex memory bound under the unchanged word-size envelope.
theorem Cslib.Algorithms.Lean.Dijkstra.Native.Fibonacci.run_spec (G : Dijkstra.ListInstance) {w : ℕ} (hfit : WordRAM.Fits w (8 * (G.n + G.m + 2) * (G.maxWeight + 2))) :
(DataStructure.Memory.spec w).ValidHistory (DataStructure.Memory.State.init G.encode)
((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init G.encode) run) ∧ (∀ (v : Fin G.n),
((DataStructure.Memory.spec w).clientState (DataStructure.Memory.State.init G.encode) run).mem (G.outAddr v) = WordRAM.Dijkstra.encodeDist (G.dist G.source v)) ∧ (DataStructure.Memory.spec w).totalCost DataStructure.Memory.charge (DataStructure.Memory.State.init G.encode)
((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init G.encode) run) ≤ 400 * (G.m + min G.n (G.m + 1) * (Nat.log 2 G.n + 1))
The actual Fibonacci memory program preserves the original admissibility and output contract. Its sharper bound includes the five header/allocation queries, and pays the heap's actual nonzero potential through the existing framed amortized telescope.