Specification for contractTablesProg (internal) #
Proves cell-by-cell equivalence, admissibility, O(n²) memory cost, and table correspondence
between contractTablesProg and (contractAdjTable, contractReducedCostTable).
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.contractTablesProg_spec {w n ws k B_k : ℕ} (r x0 : Fin n) (a : Lean.Arborescence.AdjTable n) (c : Lean.Arborescence.CostTable ℤ n) (f : Lean.Arborescence.ParentTable n) (inCycle : Vector Bool n) (bEntry bExit : Vector (Option (Fin n)) n) (s₀ : DataStructure.Memory.State) (hk : k < n) (hws : WsFits w ws n) (hf : ws + wsSize n ≤ s₀.frontier) (hfit_diff : WordRAM.Fits w (4 * B_k + 2)) (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]) (hm : ∀ (y : Fin n), s₀.mem (frameMaskBase ws n k + ↑y) = if inCycle[↑y] = true then 1 else 0) (hfp : ∀ (x : Fin n), s₀.mem (frameParentBase ws n k + ↑x) = ↑f[↑x]) (hbe : ∀ (u : Fin n), s₀.mem (frameBEntryBase ws n k + ↑u) = optFinIdx bEntry[↑u]) (hbx : ∀ (col : Fin n), s₀.mem (frameBExitBase ws n k + ↑col) = optFinIdx bExit[↑col]) (hB : ∀ (u col : Fin n), c[↑u][↑col].natAbs ≤ B_k) :
have ca := { n := n, r := ↑r, x0 := ↑x0, ws := ws, k := k };
have s1 := (DataStructure.Memory.spec 0).clientState s₀ (contractLoopProg ca);
have cp := { src := nextAdjBase ws n, dst := curAdjBase ws n, len := 2 * (n * n) };
have s' := (DataStructure.Memory.spec 0).clientState s₀ (contractTablesProg ca);
have a' := Lean.Arborescence.contractAdjTable a inCycle bEntry bExit x0 r;
have c' := contractReducedCostTable a c f inCycle bEntry bExit x0;
(WordRAM.Realization.iterationSafe contractOuterStep ContractOuterStepSafe w ca n 0 s₀ ∧ WordRAM.Realization.iterationSafe copyStep CopyStepSafe w cp (2 * (n * n)) 0 s1) ∧ (DataStructure.Memory.spec w).ValidHistory s₀
((DataStructure.Memory.spec w).clientHistory s₀ (contractTablesProg ca)) ∧ WordRAM.Realization.memoryCost (contractTablesProg ca) s₀ ≤ (16 * n + 1) * n + 4 * (n * n) ∧ s'.frontier = s₀.frontier ∧ (∀ (addr : ℕ), ¬(ws ≤ addr ∧ addr < ws + 4 * (n * n)) → s'.mem addr = s₀.mem addr) ∧ (∀ (u col : Fin n), s'.mem (curAdjBase ws n + ↑u * n + ↑col) = if a'[↑u][↑col] = true then 1 else 0) ∧ ∀ (u col : Fin n), s'.mem (curCostBase ws n + ↑u * n + ↑col) = WordRAM.Signed.encode c'[↑u][↑col]