Hopcroft–Karp iterative DFS augmentation phase on the word RAM #
Implements the O(m + r + |E|) word-RAM depth-first augmentation phase Internal.dfsPhaseCode
used by CslibFrontier.Algorithms.WordRAM.HopcroftKarp, matching
Cslib.Algorithms.Lean.MaxFlow.hkPhase ([HK73]; [CLRS09], Problem 26-6).
Main definitions #
Cslib.Algorithms.WordRAM.HopcroftKarp.Internal.dfsPhaseCode: clearsvis, runs explicit-stack DFS from every layer-0root, and rematchescolMatealong the collected disjoint augmenting paths.
Main results #
Cslib.Algorithms.WordRAM.HopcroftKarp.Internal.exec_dfsPhaseCode:O(m + r + |E|)instruction bound and exact agreement withhkPhase.
References #
Explicit-stack DFS augmentation phase (O(m + r + |E|) instructions per phase).
theorem Cslib.Algorithms.WordRAM.HopcroftKarp.Internal.exec_dfsPhaseCode {w bOff k : ℕ} {inst : SparseInstance} {mate : Vector (Option (Fin inst.m)) inst.r} {dist : Vector (Option ℕ) inst.m} (hM : Lean.MaxFlow.IsMatching inst.graph (Lean.MaxFlow.mateMatching mate)) (hk_le : k ≤ inst.m + 1) (x : WordRAM.Data 34) (hb : BaseRegs inst bOff x) (hcsr : CSRMem inst bOff x.mem) (hmate : MateMem inst bOff mate x.mem) (hdM : DistMem inst bOff dist x.mem) (hrk : x.regs rk = k) (hfit : WordRAM.Fits w (bOff + 7 * inst.m + 5 * inst.r + inst.numEdges + 8)) :
∃ (y : WordRAM.Data 34),
WordRAM.ExecWithin w dfsPhaseCode x y (49 * inst.m + 39 * inst.r + 76 * inst.numEdges + 11) ∧ (∀ (i : Fin 34), ↑i < 20 → y.regs i = x.regs i) ∧ MateMem inst bOff (Lean.MaxFlow.hkPhase inst.graph inst.adj mate dist k) y.mem ∧ ∀ (a : ℕ),
¬(bOff + inst.m + 1 + inst.numEdges ≤ a ∧ a < bOff + inst.m + 1 + inst.numEdges + 4 * inst.r + 6 * inst.m + 6) →
y.mem a = x.mem a
O(m + r + |E|) execution of dfsPhaseCode, agreeing with hkPhase.