Entry point edmondsProg and shared finishArbProg wrapper (internal) #
Implements finishArbProg (running edmondsCoreProg on the workspace and formatting the
length-prefixed parent list) and edmondsProg (loading initialized input into the workspace),
with Realizes .exact and O(n³) specifications.
Parameters for finishArbProg.
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.encFinishArbArgs_n (a : FinishArbArgs) (j : Fin 1) :
encFinishArbArgs a (Fin.castAdd 1 (Fin.castAdd 1 (Fin.castAdd 1 j))) = WordRAM.Realization.wordWords a.n j
@[simp]
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.encFinishArbArgs_outAddr (a : FinishArbArgs) (j : Fin 1) :
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.encFinishArbArgs_fits {w : ℕ} {a : FinishArbArgs} (h_n : WordRAM.Fits w a.n) (h_r : WordRAM.Fits w a.r) (h_ws : WordRAM.Fits w a.ws) (h_outAddr : WordRAM.Fits w a.outAddr) (j✝ : Fin 4) :
WordRAM.Fits w (encFinishArbArgs a j✝)
@[simp]
Word encoding of FinishArbArgs into 4 consecutive registers.
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.encFinishArbArgs_ws (a : FinishArbArgs) (j : Fin 1) :
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.encFinishArbArgs_r (a : FinishArbArgs) (j : Fin 1) :
encFinishArbArgs a (Fin.castAdd 1 (Fin.castAdd 1 (Fin.natAdd 1 j))) = WordRAM.Realization.wordWords a.r j
@[simp]
Runs edmondsCoreProg and writes the length-prefixed parent list (or 0 when infeasible) at
a.outAddr.
@[reducible, inline]
abbrev Cslib.Algorithms.WordRAM.Arborescence.Internal.FinishArbSafe (w : ℕ) (a : FinishArbArgs) (s₃ : DataStructure.Memory.State) :
Safety precondition for finishArbProg.
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.finishArbProg_spec {w n ws M₀ : ℕ} (root : Fin n) (a₀ : Lean.Arborescence.AdjTable n) (c₀ : Lean.Arborescence.CostTable ℤ n) (s₃ : DataStructure.Memory.State) (expected : List ℕ) (hfit_top : WordRAM.Fits w (ws + wsSize n + (n + 1) + 8)) (hs₃_fr : s₃.frontier = ws + wsSize n + (n + 1)) (hwb : WordRAM.Fits w (wordBound n M₀)) (ha₃ : ∀ (u col : Fin n), s₃.mem (curAdjBase ws n + ↑u * n + ↑col) = if a₀[↑u][↑col] = true then 1 else 0) (hc₃ : ∀ (u col : Fin n), s₃.mem (curCostBase ws n + ↑u * n + ↑col) = WordRAM.Signed.encode c₀[↑u][↑col]) (hB₀ : ∀ (u col : Fin n), c₀[↑u][↑col].natAbs ≤ M₀) (hexp :
match Lean.Arborescence.edmondsTableAux root n a₀ c₀ with
| some pTab => expected = List.map (fun (v : Fin n) => ↑pTab[↑v]) (List.finRange n)
| none => expected = []) :
have outAddr := ws + wsSize n;
have fa := { n := n, r := ↑root, ws := ws, outAddr := outAddr };
have s' := (DataStructure.Memory.spec 0).clientState s₃ (finishArbProg fa);
FinishArbSafe w fa s₃ ∧ (DataStructure.Memory.spec w).ValidHistory s₃ ((DataStructure.Memory.spec w).clientHistory s₃ (finishArbProg fa)) ∧ WordRAM.Realization.memoryCost (finishArbProg fa) s₃ ≤ 43 * n ^ 3 + 18 * n ^ 2 + 8 * n + 1 ∧ (DataStructure.Memory.spec 0).clientResult s₃ (finishArbProg fa) = outAddr ∧ WordRAM.outputList s'.mem outAddr = expected ∧ WordRAM.Fits w (outAddr + expected.length)
Word-RAM entry program solving rooted minimum-cost spanning in-arborescence for (n, root).
@[reducible, inline]
abbrev Cslib.Algorithms.WordRAM.Arborescence.Internal.EdmondsProgSafe (w : ℕ) (d : ℕ × ℕ) (s₀ : DataStructure.Memory.State) :
Safety precondition for edmondsProg.
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.edmondsProg_spec {w M₀ : ℕ} (I : ArborescenceInput) (hM : ∀ (u v : Fin I.n), (I.cost u v).natAbs ≤ M₀) (hwb : WordRAM.Fits w (wordBound I.n M₀)) :
have s₀ := DataStructure.Memory.State.init I.encode;
have d := (I.n, ↑I.root);
have outAddr := (DataStructure.Memory.spec 0).clientResult s₀ (edmondsProg d);
have s' := (DataStructure.Memory.spec 0).clientState s₀ (edmondsProg d);
EdmondsProgSafe w d s₀ ∧ (DataStructure.Memory.spec w).ValidHistory s₀ ((DataStructure.Memory.spec w).clientHistory s₀ (edmondsProg d)) ∧ WordRAM.Realization.memoryCost (edmondsProg d) s₀ ≤ 43 * I.n ^ 3 + 22 * I.n ^ 2 + 8 * I.n + 3 ∧ WordRAM.outputList s'.mem outAddr = I.expectedParentList ∧ WordRAM.Fits w (outAddr + I.expectedParentList.length)