Shared native IndexedMinPQ realization kernel for Dijkstra's algorithm #
Both the binary-heap and Fibonacci-heap native Dijkstra endpoints execute the exact same word-level
relaxation (relaxTarget, relaxWord), out-edge scan (scanWord), early-exit main loop
(loopWord), and header/allocation entry (runWord) from Dijkstra.Native.Word. They differ
only in the priority queue's runtime register layout, framed memory refinement, dirty allocator,
and uniform Realizes certificates for insert, decreaseKey and erased extractMin.
NativeMethods packages a priority queue's explicit register layout encoding
handleWords : Handle ↪ (Fin width → ℕ), framed refinement framed, and method certificates,
without hidden WordEncoding defaults or fixed-width specialization. Its per-stage argument
bundles (UpdateArgs, TargetData, RelaxData, ScanData, StepData) are named structures
encoded with word_enc_structure. NativeAllocator extends NativeMethods with a dirty
reservation primitive in the graph input's zero tail to yield realizes_runWord.
Main definitions #
UpdateArgs,updateArgsWords: vertex and key words passed toinsertanddecreaseKey.TargetData,targetDataWords: table, target vertex, source distance and weight for one relaxation.RelaxData,relaxDataWords: graph/table context and edge coordinates forrelaxWord.ScanData,scanDataWords: graph/table context and source vertex/distance forscanWord.StepData,stepDataWords: graph/table context and remaining round count forloopWord.NativeMethods: heap-parametric nativeIndexedMinPQmethod bundle and certificates.NativeMethods.dijkstraFramed: composite framed refinement pairing the heap with the distance table and input adjacency arrays.NativeAllocator: dirty-allocation bundle forrunWordonListInstance.encode.
Main results #
NativeMethods.target_realizes: uniform native realization ofrelaxTarget.NativeMethods.relax_realizes: uniform native realization ofrelaxWord.NativeMethods.scan_realizes: uniform native realization ofscanWord.NativeMethods.loop_realizes: uniform native realization ofloopWord.NativeAllocator.realizes_runWord: uniform native realization ofrunWord.
word_enc_structure argument records #
Vertex handle word and tentative distance key passed to insert or decreaseKey.
The tuple word encoding of the fields of updateArgsWords.
Faithful two-word encoding of UpdateArgs.
Distance table, target vertex, source distance and edge weight for relaxTarget.
- table : WordRAM.Block
Direct-address tentative-distance table.
- vertex : ℕ
Target vertex index.
- dist : ℕ
Distance of the current source vertex.
- weight : ℕ
Edge weight.
Faithful five-word encoding of TargetData.
Table, graph dimensions and edge coordinates for relaxWord.
Table, graph dimensions and extracted vertex/distance for scanWord.
- table : WordRAM.Block
Direct-address tentative-distance table.
- n : ℕ
Vertex count of the input graph.
- m : ℕ
Edge count of the input graph.
- vertex : ℕ
Extracted vertex index.
- dist : ℕ
Extracted vertex distance.
Table, graph dimensions and remaining round budget for loopWord.
- table : WordRAM.Block
Direct-address tentative-distance table.
- n : ℕ
Vertex count of the input graph.
- m : ℕ
Edge count of the input graph.
- rounds : ℕ
Remaining extraction rounds.
Left-handle polymorphic realization combinators #
NativeMethods: shared realization of relaxTarget, relaxWord, scanWord, loopWord #
A uniform native IndexedMinPQ method family over Memory.Prog for Dijkstra's algorithm,
parameterized by an explicit register layout encoding handleWords, static validity Valid, a
framed memory refinement framed, and zero-local-work Realizes certificates for insert,
decreaseKey, and handle-erased extractMin.
- Handle : Type
Runtime heap handle carried in registers across the client.
- width : ℕ
Number of register words encoding a runtime heap handle.
Explicit faithful register encoding of a runtime heap handle.
Static handle validity predicate at word width
w, capacityn, and key boundK.- framed {w n K : ℕ} {e : self.Handle} : self.Valid w n K e → DataStructure.Memory.Framed (DataStructure.PriorityQueue.indexedMinPQSpec n K) w
Framed refinement of
indexedMinPQSpec n KoverMemory.spec w. Word-argument
insertprogram.Word-argument
decreaseKeyprogram.Erased
extractMinprogram returningOption (ℕ × ℕ).- decreaseKey_eq {w n K : ℕ} {e : self.Handle} (hV : self.Valid w n K e) (v : Fin n) (k : ℕ) : self.decreaseKey e (↑v) k = (self.framed hV).methods (DataStructure.PriorityQueue.IndexedMinPQ.Op.decreaseKey v k)
Typed
decreaseKeyagrees with the framed refinement's.decreaseKeymethod. - extractMin_eq {w n K : ℕ} {e : self.Handle} (hV : self.Valid w n K e) : self.extractMin e = PFunctor.FreeM.map (Option.map fun (p : Fin n × ℕ) => (↑p.1, p.2)) ((self.framed hV).methods DataStructure.PriorityQueue.IndexedMinPQ.Op.extractMin)
Erased
extractMinagrees with handle-proof erasure of the framed.extractMinmethod. - extractMin_query (e : self.Handle) (s : DataStructure.Memory.State) : 1 ≤ WordRAM.Realization.memoryCost (self.extractMin e) s
Every
extractMincall charges at least one memory unit, paying main-loop control. - realizes_insert : WordRAM.Realization.Realizes WordRAM.Basis.exact (fun (d : self.Handle × UpdateArgs) => self.insert d.1 d.2.vertex d.2.key) (WordRAM.Realization.appendWords self.handleWords updateArgsWords) WordRAM.Realization.WordEncoding.encode (fun (w : ℕ) (d : self.Handle × UpdateArgs) (s : DataStructure.Memory.State) => ∃ (n : ℕ) (hv : d.2.vertex < n) (K : ℕ) (hV : self.Valid w n K d.1), (self.framed hV).inv s ∧ DataStructure.PriorityQueue.IndexedMinPQ.valid K ((self.framed hV).abs s) (DataStructure.PriorityQueue.IndexedMinPQ.Op.insert ⟨d.2.vertex, hv⟩ d.2.key)) fun (x : self.Handle × UpdateArgs) (x_1 : DataStructure.Memory.State) => 0
Uniform native realization of
insert. - realizes_decreaseKey : WordRAM.Realization.Realizes WordRAM.Basis.exact (fun (d : self.Handle × UpdateArgs) => self.decreaseKey d.1 d.2.vertex d.2.key) (WordRAM.Realization.appendWords self.handleWords updateArgsWords) WordRAM.Realization.WordEncoding.encode (fun (w : ℕ) (d : self.Handle × UpdateArgs) (s : DataStructure.Memory.State) => ∃ (n : ℕ) (hv : d.2.vertex < n) (K : ℕ) (hV : self.Valid w n K d.1), (self.framed hV).inv s ∧ DataStructure.PriorityQueue.IndexedMinPQ.valid K ((self.framed hV).abs s) (DataStructure.PriorityQueue.IndexedMinPQ.Op.decreaseKey ⟨d.2.vertex, hv⟩ d.2.key)) fun (x : self.Handle × UpdateArgs) (x_1 : DataStructure.Memory.State) => 0
Uniform native realization of
decreaseKey. - realizes_extractMin : WordRAM.Realization.Realizes WordRAM.Basis.exact self.extractMin self.handleWords WordRAM.Realization.WordEncoding.encode (fun (w : ℕ) (e : self.Handle) (s : DataStructure.Memory.State) => ∃ (n : ℕ) (K : ℕ) (hV : self.Valid w n K e), (self.framed hV).inv s) fun (x : self.Handle) (x_1 : DataStructure.Memory.State) => 0
Uniform native realization of erased
extractMin.
Composite framed refinement of Dijkstra.spec pairing M.framed hV with the direct-address
distance table T and immutable adjacency arrays A.
Entry domain for relaxTarget over M.
Uniform native realization of relaxTarget for any NativeMethods.
Entry domain for relaxWord over M.
Uniform native realization of relaxWord on Memory.inputGraph for any NativeMethods.
Entry domain for scanWord over M.
Uniform native realization of scanWord on Memory.inputGraph for any NativeMethods.
Entry domain for loopWord over M.
Uniform native realization of loopWord on Memory.inputGraph for any NativeMethods.
NativeAllocator: shared realization of runWord #
Dirty-allocation extension of NativeMethods for Dijkstra.Native.runWord on the standard
graph input encoding ListInstance.encode.
Allocate an empty priority queue of capacity
nin dirty memory at the current frontier.- run_alloc (n : ℕ) (s : DataStructure.Memory.State) : (DataStructure.Memory.spec 0).clientResult s (self.alloc n) = self.allocated n s.frontier ∧ (DataStructure.Memory.spec 0).clientState s (self.alloc n) = { mem := s.mem, frontier := s.frontier + self.span n }
- realizes_alloc : WordRAM.Realization.Realizes WordRAM.Basis.exact self.alloc WordRAM.Realization.wordWords M.handleWords (fun (w n : ℕ) (s : DataStructure.Memory.State) => WordRAM.Fits w (s.frontier + self.span n)) fun (x : ℕ) (x_1 : DataStructure.Memory.State) => 0
Uniform native realization of
alloc. - fits_alloc (G : Dijkstra.ListInstance) {w : ℕ} : WordRAM.Fits w (8 * (G.n + G.m + 2) * (G.maxWeight + 2)) → WordRAM.Fits w ((DataStructure.Memory.State.init G.encode).frontier + G.n + self.span G.n)
- init_empty (G : Dijkstra.ListInstance) {w : ℕ} : WordRAM.Fits w (8 * (G.n + G.m + 2) * (G.maxWeight + 2)) → let f := (DataStructure.Memory.State.init G.encode).frontier; let e := self.allocated G.n (f + G.n); let s := { mem := (DataStructure.Memory.State.init G.encode).mem, frontier := f + G.n + self.span G.n }; ∃ (hV : M.Valid w G.n (G.n * G.maxWeight) e), (M.framed hV).inv s ∧ (∀ (v : Fin G.n), (M.framed hV).abs s v = none) ∧ (M.framed hV).room s = 0 ∧ ∀ a ∈ (M.framed hV).footprint s, f + G.n ≤ a
Uniform native realization of runWord A.alloc M.extractMin M.insert M.decreaseKey.