Relabel-to-Front Maximum Flow in O(|V|³) Word-RAM Time #
Lowers the executable Goldberg–Tarjan relabel-to-front maximum-flow algorithm
(Cslib.Algorithms.Lean.MaxFlow.relabelToFrontDense, [GT88], Sections 3–4;
[CLRS09], Sections 26.4–26.5) to the standard-basis word RAM (Cslib.WordRAM.Basis.standard),
proving O(n³) instruction bounds for both scalar maximum-flow value (Program.ComputesInTime)
and joint value + minimum s–t gap cut + maximum-flow matrix output
(Program.ComputesListInTime).
Input, workspace layout, and word bound #
An instance (Cslib.Algorithms.WordRAM.PushRelabel.Instance) specifies n : ℕ, terminals
s t : Fin n, and an n × n integer capacity matrix cap : Fin n → Fin n → ℕ. Its word-list
encoding Instance.encode (n :: s :: t :: flattenMatrix cap, length 3 + n * n) stores n, s,
t at addresses 1, 2, 3 and cap u v at 4 + u * n + v.
For s ≠ t, the structured solver solver allocates contiguous arrays past the input:
baseF = 4 + n * n: current preflow matrixflow[u, v] ≤ maxCap(n * nwords);baseE = 4 + 2 * n * n: vertex excesses(excess v).toNat ≤ n * maxCapforv ≠ s(nwords);baseH = 4 + 2 * n * n + n: vertex heightsheight[v] ≤ 2 * n - 1(nwords);baseC = 4 + 2 * n * n + 2 * n: current-arc scan indicescur[v] ≤ n(nwords);baseO = 4 + 2 * n * n + 3 * n: active-list vertex orderdone ++ todo(n - 2words);outBase = 4 + 2 * n * n + 4 * n: list output[1 + n + n², value, cut[0..n), flow[0..n²)].
Every array address, counter, height, capacity, residual capacity (≤ 2 * maxCap), excess
(≤ n * maxCap), and flow value fits below Instance.wordBound, i.e. O(log n + log maxCap)
word width (w = O(log n + log maxCap)). Both inner discharge and outer move-to-front loops
execute via ExecWithin.loop_potential against the PushRelabel operation run and pure state
potentials curPotential and rtfMeasure of RelabelToFront, paying O(1) per push, vertex-list
step, and current-arc advance and O(n) per relabel scan/list-shift, yielding total time
prTime n = 720 * n ^ 3 + 40 (O(n³)).
Main definitions #
Cslib.Algorithms.WordRAM.PushRelabel.Instance,Cslib.Algorithms.WordRAM.PushRelabel.Instance.toNetwork,Cslib.Algorithms.WordRAM.PushRelabel.Instance.maxCap,Cslib.Algorithms.WordRAM.PushRelabel.Instance.out,Cslib.Algorithms.WordRAM.PushRelabel.Instance.maxFlowValue,Cslib.Algorithms.WordRAM.PushRelabel.Instance.answerWords,Cslib.Algorithms.WordRAM.PushRelabel.Instance.encode,Cslib.Algorithms.WordRAM.PushRelabel.Instance.wordBound.Cslib.Algorithms.WordRAM.PushRelabel.prTime,Cslib.Algorithms.WordRAM.PushRelabel.outBase,Cslib.Algorithms.WordRAM.PushRelabel.acc,Cslib.Algorithms.WordRAM.PushRelabel.solver,Cslib.Algorithms.WordRAM.PushRelabel.program,Cslib.Algorithms.WordRAM.PushRelabel.flowProgram:O(n³)instruction budget, output registers (14and31), structured solver, list-output flat program (value, minimum gap cut, and flow), and scalar flow-value flat program overBasis.standard.
Main results #
Cslib.Algorithms.WordRAM.PushRelabel.Instance.isMaxFlow_out,Cslib.Algorithms.WordRAM.PushRelabel.Instance.isMinCut_out: maximum-flow and minimum-cut correctness ofinst.outwheninst.s ≠ inst.t.Cslib.Algorithms.WordRAM.PushRelabel.program_spec,Cslib.Algorithms.WordRAM.PushRelabel.computesListInTime_pushRelabel:O(n³)list execution (Program.ComputesListInTime) outputtinginst.answerWordsat any width admittinginst.wordBound.Cslib.Algorithms.WordRAM.PushRelabel.executes_maxFlowValue,Cslib.Algorithms.WordRAM.PushRelabel.computesInTime_maxFlowValue:O(n³)scalar execution (Program.ComputesInTime) returninginst.maxFlowValue.Cslib.Algorithms.WordRAM.PushRelabel.not_readsWidth_program,Cslib.Algorithms.WordRAM.PushRelabel.isRandFree_program,Cslib.Algorithms.WordRAM.PushRelabel.not_readsWidth_flowProgram,Cslib.Algorithms.WordRAM.PushRelabel.isRandFree_flowProgram: width-independence and determinism.
References #
Problem instances, encodings, and pure-specification bridges #
Flow network corresponding to inst.
Maximum single-arc capacity in inst.
Canonical pure relabel-to-front output on inst.
Optimal integer maximum-flow value as a natural number.
Explicit O(n³) instruction-count bound for Word-RAM relabel-to-front.
Register holding the base output address [len, maxFlowValue, cut..., flow...].
Output accumulator register holding maxFlowValue.
Register layout and structured Word-RAM solver #
Structured standard-basis Word-RAM relabel-to-front solver: writes
[1 + n + n², maxFlowValue, cut..., flow...] starting at outBase and leaves maxFlowValue in
register acc (31).
Flat Word-RAM relabel-to-front program computing inst.answerWords ([maxFlowValue, cutIndicators..., flowMatrix...]) via ExecutesList.
Flat Word-RAM relabel-to-front program computing scalar inst.maxFlowValue in register acc
via Executes.
Machine state invariants and representation uniqueness #
Initialization specifications #
Inner discharge lowering #
Outer relabel-to-front loop lowering #
Output extraction and main Word-RAM correctness / complexity theorems #
O(|V|³) Word-RAM relabel-to-front maximum flow & minimum gap cut (ExecutesList).
For any instance inst and word width w satisfying Fits w inst.wordBound, program halts
within prTime inst.n = 720 * n ^ 3 + 40 instructions (final halt included) and outputs
inst.answerWords = [maxFlowValue, cutIndicators..., flowMatrix...].
Fixed-program Program.ComputesListInTime certificate for O(n³) Word-RAM relabel-to-front
returning inst.answerWords (maxFlowValue, minimum gap cut, and maximum flow matrix).
O(|V|³) Word-RAM scalar maximum-flow value (Executes).
Fixed-program Program.ComputesInTime certificate for O(n³) Word-RAM relabel-to-front
returning inst.maxFlowValue.
program does not inspect the word width (width%).
program is deterministic (rand-free).
flowProgram does not inspect the word width (width%).
flowProgram is deterministic (rand-free).