Documentation

CslibFrontier.Algorithms.WordRAM.EdmondsKarp.UniformFlow

Uniform Word-RAM program for dense Edmonds–Karp maximum flow and minimum cut #

Uniform Basis.exact flat program and O((n + 1) ^ 5) runtime bound for dense maximum flow and minimum s–t cut (exists_edmondsKarp_program).

Main definitions #

Main results #

References #

Uniform dense Edmonds–Karp flat program #

Word-RAM input n :: s :: t :: flattenMatrix N.cap: vertex count at address 1, source at 2, sink at 3, and row-major capacity matrix N.cap u v at 4 + u * n + v.

Output address of the final flow value f u v left by exists_edmondsKarp_program.

Output address of the final residual distance of x (< n iff x lies in the minimum cut) left by exists_edmondsKarp_program.

Memory frontier required by exists_edmondsKarp_program: 4 + 2 * n^2 + 2 * n.

theorem Cslib.Algorithms.WordRAM.EdmondsKarp.exists_edmondsKarp_program :
∃ (R : ℕ) (C : ℕ) (pc : ℕ), 0 < C ∧ ∃ (prog : WordRAM.Program WordRAM.Basis.exact R), ∀ {n : ℕ} (N : Lean.MaxFlow.Network (Fin n)) (B w : ℕ), N.s ≠ N.t → (∀ (u v : Fin n), N.cap u v ≤ B) → WordRAM.Fits w (ekWorkspace n) → WordRAM.Fits w (ekBound n B) → ∃ (y : WordRAM.Data R) (steps : ℕ) (res : ℕ) (f : N.Flow), have C_cut := {x : Fin n | y.mem (ekCutAddr n ↑x) < n}; WordRAM.Runs w prog (WordRAM.State.init (encodeFlowInput N)) { pc := pc, data := y } steps ∧ WordRAM.step w prog { pc := pc, data := y } = WordRAM.Outcome.halt res ∧ steps + 1 ≤ C * (n + 1) ^ 5 ∧ (∀ (u v : Fin n), y.mem (ekFlowAddr n ↑u ↑v) = f.toFun u v) ∧ f.IsMaxFlow ∧ N.IsMinCut C_cut ∧ C_cut = f.reachableCut ∧ f.value = ↑(N.cutCapacity C_cut) ∧ res = N.cutCapacity C_cut

Dense Edmonds–Karp on the Word-RAM ([EK72], Theorem 1; [CLRS09], Theorem 26.8): one uniform flat program over Basis.exact that, on encodeFlowInput N for any network N : Network (Fin n) with N.s ≠ N.t and capacities at most B, halts within C * (n + 1) ^ 5 instructions at every word width fitting ekWorkspace n and ekBound n B. This formalizes the dense O((n + 1) ^ 5) adjacency-matrix variant rather than the sparse O(|V| |E| ^ 2) adjacency-list bound of [CLRS09], Theorem 26.8. It returns the maximum flow value N.cutCapacity C_cut, stores a maximum flow f at ekFlowAddr, and marks the minimum cut C_cut = f.reachableCut at ekCutAddr < n.