Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.johnson

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

AHoF Johnson's Algorithm (all-pairs shortest paths): compute shortest paths between EVERY pair of vertices in a sparse, possibly negative-weight (but cycle-free) graph in O(V*E + V^2 log V) -- faster than Floyd-Warshall on sparse graphs. It adds a virtual source, runs Bellman-Ford to get a potential h(v) at each vertex, then REWEIGHTS every edge to w'(u,v) = w(u,v) + h(u) - h(v), which is provably non-negative, so Dijkstra can be run from each vertex. The key invariant the reweighting establishes is edge non-negativity: nonneg-reweighted? reweighted-weight = decide (0 <= reweighted-weight) over exact-rational reweighted edge weights. Proved native and axiom-free: the non-negativity test, and worked instances -- a reweighted weight of 4 passes; the certificate 0 <= 4 as a native nnrat/at-most; and a tight edge of weight 0 passes. That the potential h makes every reweighted edge non-negative is the classical invariant and is not proved here. The Bellman-Ford potential pass, the reweighting, and per-source Dijkstra are executable; what is proved is the reweighted-non-negativity decision at these instances. Requires nnrat/at-most, audit/decide-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.johnson` prints this classification.

johnson/nonneg-reweighted?

DefinitionSource, line 61

johnson/nonneg-reweighted? :
  (x₁ : ℚ≥0)
  → data/Bool

ℚ≥0 = nnrat/NonnegativeRational

johnson/reweighted-edge-nonneg

TheoremWorked exampleNo axiomsSource, line 72

johnson/reweighted-edge-nonneg :
  → johnson/nonneg-reweighted? 4 = data/true

= = equality/Eq

johnson/valid-reweight-at-least-zero

TheoremWorked exampleNo axiomsSource, line 80

johnson/valid-reweight-at-least-zero :
  → 0 ≤ 4

≤ = nnrat/at-most

johnson/zero-reweight-usable

TheoremWorked exampleNo axiomsSource, line 87

johnson/zero-reweight-usable :
  → johnson/nonneg-reweighted? 0 = data/true

= = equality/Eq