Black-Box Dijkstra's Algorithm Parameterized by Any Word-RAM Priority Queue #
This file implements the outer graph-traversal layer of Dijkstra's single-source shortest-path
algorithm once (Cslib.Algorithms.WordRAM.Dijkstra.dijkstraCode) on 15 + r_pq registers over
Basis.exact, parameterized only by a Cslib.Algorithms.WordRAM.PriorityQueue.PQCode subroutine,
and proves its black-box correctness and amortized instruction-count specification
(Cslib.Algorithms.WordRAM.Dijkstra.dijkstra_of_pq_spec) for any
Cslib.Algorithms.WordRAM.PriorityQueue.PQPackage (supporting arbitrary concrete potentials
potential : Data r_pq → ℕ).
Instantiating dijkstra_of_pq_spec with:
PriorityQueue.BinaryHeap.pkg(potential = 0) yieldsLogLinearSpecandLogLinearStatement(O((m + 1) (⌊log₂ n⌋ + 1)));- any amortized
PQPackagewithO(1)insert/decreaseKeyandO(log n + 1)extractMin(such as a Fibonacci heap) directly yieldsO(m + min(n, m + 1) (⌊log₂ n⌋ + 1))andO(m + n (⌊log₂ n⌋ + 1))with zero duplication of Dijkstra's graph logic.
Main definitions #
Cslib.Algorithms.WordRAM.Dijkstra.pqMap: register relocationFin.natAdd 15placing the priority-queue registers at15 .. 15 + r_pq - 1.Cslib.Algorithms.WordRAM.Dijkstra.dijkstraCode: structured word-RAM code for Dijkstra's algorithm calling a black-boxPQCode .exact r_pq.
Main results #
Cslib.Algorithms.WordRAM.Dijkstra.dijkstraCode_exec: structuredExecWithincorrectness and amortized running-time bound fordijkstraCode pkg.code.Cslib.Algorithms.WordRAM.Dijkstra.dijkstra_of_pq_spec: flat-programRuns+halttheorem for(dijkstraCode pkg.code).program OuterReg.zero.
References #
Register relocation pqMap is injective.
Outer caller registers (0 .. 14) of dijkstraCode #
Constant 0.
Instances For
Constant 1.
Instances For
Constant 3.
Instances For
Number of vertices n.
Instances For
Base address n + 4 of the edge array.
Instances For
Base address G.dbase = n + 2 * m + 4 of the n output distance words.
Instances For
Current distance word d[tv] (inside relaxEdges) and emptiness flag (in outer loop).
Instances For
Scratch address register.
Instances For
Structured Word-RAM Code of Black-Box Dijkstra #
Straight-line outer header: loads n, source, db = G.dbase, eb = n + 4, sets
mem[db + source] := 1, and places pqBase = db + n in t.
Instances For
Full setup of dijkstraCode: runs outerHeader, initializes the relocated priority queue at
pqBase = G.dbase + G.n via initFresh, inserts (source, 1), and sets dv := 0 (non-empty).
Instances For
Straight-line start of one edge relaxation: loads (tv, tc) for edge j, advances j, forms
cand := best + tc, and loads dv := mem[db + tv].
Instances For
Body of relaxEdges for a single outgoing edge.
Instances For
Inner loop scanning all outgoing edges [j, jend) of vertex u.
Instances For
Offset-loading block for u: sets j := offset u and jend := offset (u + 1).
Instances For
One outer round of dijkstraCode: extracts minimum (u, best), loads u's edge range, scans
its outgoing edges via relaxEdges, and refreshes the emptiness flag dv via callIsEmpty.
Instances For
Complete structured word-RAM code for Dijkstra's algorithm calling P : PQCode .exact r_pq.
Instances For
Input Boundedness and Framing Helpers #
Maximum priority-queue key ever inserted or decreased on instance G.
Instances For
Base address G.dbase + G.n of the priority-queue memory block.
Instances For
Inner Edge-Scan Specification (relaxEdges_spec) #
Discovered vertices (mem[dbase + v] ≠ 0) that are no longer in dom s.
Instances For
Total outgoing edges of vertices outside S.
Instances For
Tentative distances decoded from y.mem (G.dbase + ·).
Instances For
Synchronization between abstract PQ state s and distance array y.mem (G.dbase + ·): every
handle in dom s has a nonzero distance word equal to its PQ key.
Instances For
Outer Round Invariant, Setup, Round Step, and Main Black-Box Theorems #
Black-box structured Dijkstra theorem. For any exact-basis PQPackage, dijkstraCode
computes all encoded shortest-path distances within
initTime + insertTime + 28 + min(n, m + 1) * (extractTime + emptyTime + 20) +
min(n, m) * (insertTime + 20) + m * (decreaseTime + 20) instructions.
Black-box flat-program Dijkstra theorem. Compiling dijkstraCode pkg.code produces a flat
word-RAM program over Basis.exact that computes all single-source shortest-path distances and
halts within the parameterized priority-queue instruction bound.