Documentation

CslibFrontier.Algorithms.WordRAM.EdmondsKarp.Core

Core layout and fillRange primitive for dense Edmonds–Karp #

Shared memory layout (Ctx, distAddr, ekScratch, ekBound, CtxFits) and the relocatable memory-fill primitive (fillRange, fillRange_realizes, fillRange_spec, memoryCost_fillRange_le, validHistory_fillRange) used across CslibFrontier.Algorithms.WordRAM.EdmondsKarp.

Main definitions #

Main results #

Layout #

Solver context: n vertices, capacity matrix at matBase, scratch area at scratchBase, and a bound capBound on the capacities.

  • n : ℕ

    Number of vertices.

  • matBase : ℕ

    Base address of the row-major capacity matrix.

  • scratchBase : ℕ

    Base address of the solver's scratch area.

  • capBound : ℕ

    Upper bound on edge capacities.

Instances For

    Equivalence between Ctx and its four ℕ fields for word encoding.

    @[reducible, inline]

    Address of the breadth-first-search distance of x (n when x is not reached).

    @[reducible, inline]

    Words of scratch memory used by the solver: the flow matrix, distances and parents.

    @[reducible, inline]

    Every word the solver computes or stores is at most ekBound n B: round counts below n ^ 3, cut sums up to n * n * B, residual capacities up to 2 * B, flow updates up to 3 * B.

    @[reducible, inline]

    Layout and word-size requirements on a context: the matrix lies below the scratch area and both the scratch area and ekBound fit a word.

    fillRange primitive #

    Write val at the len addresses from base (d = ((base, val), len)).

    theorem Cslib.Algorithms.WordRAM.EdmondsKarp.fillRange_spec (base val len : ℕ) (s : DataStructure.Memory.State) :
    have s' := (DataStructure.Memory.spec 0).clientState s (fillRange ((base, val), len)); (∀ i < len, s'.mem (base + i) = val) ∧ ∀ (a : ℕ), a < base ∨ base + len ≤ a → s'.mem a = s.mem a

    fillRange ((base, val), len) writes val on [base, base + len) and nothing else.