Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.dijkstra
AHoF Dijkstra's Shortest Path: single-source shortest paths on a graph with NON-NEGATIVE edge weights. Unlike Bellman-Ford (which relaxes all edges V-1 times), Dijkstra greedily finalizes, at each step, the unvisited vertex with the smallest tentative distance -- correct precisely because non-negative weights guarantee that vertex's distance can no longer improve. Selecting the closer of two frontier vertices is: closer-vertex da na db nb = if da <= db then na else nb (return the id of the smaller-distance vertex), over exact-rational tentative distances. Proved native and axiom-free: the closest-vertex selection; worked choices (vertex 2 at 3 against vertex 5 at 8 picks 2; at 4 against 9 it picks 5); and the certificate 3 <= 8 as a native nnrat/at-most. Correctness of greedy finalization under non-negative weights is classical and is not proved here. The priority queue and edge relaxation are executable; what is proved is the closest-frontier selection at these instances. Requires nat, audit/decide-nnrat-at-most, logic/if-data, nnrat/at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.dijkstra` prints this classification.
dijkstra/closer-vertex
dijkstra/closer-vertex : (x₁ : ℚ≥0) (x₂ : ℕ) (x₃ : ℚ≥0) (x₄ : ℕ) → ℕ
ℕ = data/Natℚ≥0 = nnrat/NonnegativeRational
dijkstra/finalizes-closest
dijkstra/finalizes-closest : → dijkstra/closer-vertex 3 2 8 5 = 2
= = equality/Eq
dijkstra/finalizes-second-when-closer
dijkstra/finalizes-second-when-closer : → dijkstra/closer-vertex 9 2 4 5 = 5
= = equality/Eq
dijkstra/finalized-is-closest
dijkstra/finalized-is-closest : → 3 ≤ 8
≤ = nnrat/at-most