Documentation

CslibFrontier.Algorithms.WordRAM.PushRelabel

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:

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 #

Main results #

References #

Problem instances, encodings, and pure-specification bridges #

An instance of the integral maximum-flow / minimum s–t cut problem on Fin n.

  • n : ℕ

    Number of vertices.

  • s : Fin self.n

    Source vertex.

  • t : Fin self.n

    Sink vertex.

  • cap : Fin self.n → Fin self.n → ℕ

    Nonnegative integral arc capacity matrix.

Maximum single-arc capacity in inst.

Optimal integer maximum-flow value as a natural number.

Encoded output word list [maxFlowValue, cutIndicators..., flowMatrix...]: length 1 + n + n * n, where entry 1 + v is 1 iff v ∈ inst.out.cut and entry 1 + n + u * n + v is inst.out.flow u v.

Word-RAM input encoding n :: s :: t :: flattenMatrix cap, of length 3 + n * n.

Word-size envelope (O(n² + n * maxCap)), so w = O(log n + log maxCap) suffices.

Explicit O(n³) instruction-count bound for Word-RAM relabel-to-front.

@[reducible, inline]

Register holding the base output address [len, maxFlowValue, cut..., flow...].

@[reducible, inline]

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.

Helper bridges between tabulate and id in RelabelToFront #

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.