Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.dijkstra

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/dijkstra.clj1 definitions, 3 theorems

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

DefinitionSource, line 65

dijkstra/closer-vertex :
  (x₁ : ℚ≥0) (x₂ : ℕ) (x₃ : ℚ≥0) (x₄ : ℕ)
  → ℕ

ℕ = data/Natℚ≥0 = nnrat/NonnegativeRational

dijkstra/finalizes-closest

TheoremWorked exampleNo axiomsSource, line 76

dijkstra/finalizes-closest :
  → dijkstra/closer-vertex 3 2 8 5 = 2

= = equality/Eq

dijkstra/finalizes-second-when-closer

TheoremWorked exampleNo axiomsSource, line 87

dijkstra/finalizes-second-when-closer :
  → dijkstra/closer-vertex 9 2 4 5 = 5

= = equality/Eq

dijkstra/finalized-is-closest

TheoremWorked exampleNo axiomsSource, line 98

dijkstra/finalized-is-closest :
  → 3 ≤ 8

≤ = nnrat/at-most