Documentation

CslibFrontier.Algorithms.Lean.MaxFlow.RealFlow

Maximum flows with capacities in a linearly ordered field #

Flows on a finite vertex type V with capacities W : V → V → K in a linearly ordered field K (for example ℝ or ℚ), and the max-flow min-cut theorem in this setting. The integral theory over ℕ, with algorithms, is in CslibFrontier.Algorithms.Lean.MaxFlow.Basic.

Source mapping. [Sch03], Section 10.1 (pp. 148–149), defines flows on a digraph with real capacities c : A → ℝ₊, conservation and the value as net outflow at s; Theorem 10.3 (Section 10.2, p. 150) is the max-flow min-cut theorem. This module differs in three ways:

Since capacities need not be integers, augmenting paths need not terminate. Instead, a maximum flow is obtained from linear-programming duality over K (Matrix.exists_isGreatest_of_bddAbove). Its optimality is then certified by the set of vertices reachable from s in the residual graph: if t were reachable, an augmentation along the reachability relation would increase the value.

Main definitions #

Main results #

References #

def Cslib.Algorithms.Lean.MaxFlow.realNetOut {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] (f : V × V → K) (v : V) :
K

The net outflow ∑ w, f (v, w) - ∑ u, f (u, v) of f at v. At the source s this is the value of the flow.

theorem Cslib.Algorithms.Lean.MaxFlow.realNetOut_add {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] (f g : V × V → K) (v : V) :
theorem Cslib.Algorithms.Lean.MaxFlow.realNetOut_smul {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] (c : K) (f : V × V → K) (v : V) :
realNetOut (c • f) v = c * realNetOut f v
theorem Cslib.Algorithms.Lean.MaxFlow.realNetOut_single {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [DecidableEq V] (a b : V) (c : K) (v : V) :
realNetOut (Pi.single (a, b) c) v = (if v = a then c else 0) - if v = b then c else 0

c units on the single arc (a, b) leave a and enter b.

def Cslib.Algorithms.Lean.MaxFlow.IsFeasibleRealFlow {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] (W : V → V → K) (s t : V) (f : V × V → K) :

A feasible s–t flow for the capacities W: every arc value f (u, v) lies between 0 and W u v, and inflow equals outflow at every vertex other than s and t.

def Cslib.Algorithms.Lean.MaxFlow.IsMaxRealFlow {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] (W : V → V → K) (s t : V) (val : K) :

val is the greatest value of a feasible s–t flow for the capacities W.

Flow across a cut #

theorem Cslib.Algorithms.Lean.MaxFlow.IsFeasibleRealFlow.realNetOut_eq_zero {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} {s t : V} {f : V × V → K} (hf : IsFeasibleRealFlow W s t f) {v : V} (hs : v ≠ s) (ht : v ≠ t) :
theorem Cslib.Algorithms.Lean.MaxFlow.IsFeasibleRealFlow.realNetOut_eq_sub {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} {s t : V} {f : V × V → K} [DecidableEq V] (hf : IsFeasibleRealFlow W s t f) {X : Finset V} (hs : s ∈ X) (ht : t ∉ X) :
realNetOut f s = ∑ u ∈ X, ∑ v ∈ Finset.univ \ X, f (u, v) - ∑ u ∈ X, ∑ v ∈ Finset.univ \ X, f (v, u)

The value of a feasible flow equals its net flow across any s–t cut X: the flow on arcs leaving X minus the flow on arcs entering X.

theorem Cslib.Algorithms.Lean.MaxFlow.IsFeasibleRealFlow.realNetOut_le_cutWeight {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} {s t : V} {f : V × V → K} [DecidableEq V] [IsStrictOrderedRing K] (hf : IsFeasibleRealFlow W s t f) {X : Finset V} (hs : s ∈ X) (ht : t ∉ X) :

Weak duality: the value of a feasible s–t flow is at most the weight of every s–t cut.

Existence of a maximum flow #

theorem Cslib.Algorithms.Lean.MaxFlow.exists_isMaxRealFlow {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} [IsStrictOrderedRing K] (hW : ∀ (u v : V), 0 ≤ W u v) (s t : V) :
∃ (f : V × V → K), IsFeasibleRealFlow W s t f ∧ IsMaxRealFlow W s t (realNetOut f s)

For non-negative capacities a maximum flow exists. Since the capacities need not be integers, it is obtained from linear-programming duality over K rather than from augmenting paths.

Max-flow min-cut #

def Cslib.Algorithms.Lean.MaxFlow.Residual {V : Type u_1} {K : Type u_2} [Field K] [LinearOrder K] (W : V → V → K) (f : V × V → K) (u v : V) :

The arc (u, v) has positive residual capacity for f: unused capacity on (u, v) or cancellable flow on (v, u).

theorem Cslib.Algorithms.Lean.MaxFlow.not_resReachable_of_isMaxRealFlow {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} {s t : V} {f : V × V → K} [IsStrictOrderedRing K] (hf : IsFeasibleRealFlow W s t f) (hmax : IsMaxRealFlow W s t (realNetOut f s)) (hst : s ≠ t) :

A maximum s–t flow admits no residual path from s to t when s ≠ t.

theorem Cslib.Algorithms.Lean.MaxFlow.isMaxRealFlow_minRealCutBetween {V : Type u_1} [Fintype V] {K : Type u_2} [Field K] [LinearOrder K] {W : V → V → K} {s t : V} [DecidableEq V] [IsStrictOrderedRing K] (hW : ∀ (u v : V), 0 ≤ W u v) (hst : s ≠ t) :

Max-flow min-cut theorem over a linearly ordered field ([Sch03], Theorem 10.3, p. 150, extended from ℝ to K; [FF62], Chapter I, Sections 4–8): for non-negative capacities W and distinct s and t, the greatest value of a feasible s–t flow is the minimum s–t cut weight. The maximum is attained (exists_isMaxRealFlow).