Specifications for bestEntryProg and bestExitProg (internal) #
Proves admissibility, O(n²) memory cost, and exact table correspondence with bestEntryTable
and reducedBestExitTable.
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.bestEntryProg_spec {w n ws k : ℕ} (hpos : 0 < n) (a : Lean.Arborescence.AdjTable n) (c : Lean.Arborescence.CostTable ℤ n) (inCycle : Vector Bool n) (s₀ : DataStructure.Memory.State) (hk : k < n) (hws : WsFits w ws n) (hf : ws + wsSize n ≤ s₀.frontier) (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) (hfit_c : ∀ (u col : Fin n), WordRAM.Fits w (WordRAM.Signed.encode c[↑u][↑col])) :
have la := { n := n, ws := ws, k := k };
have s' := (DataStructure.Memory.spec 0).clientState s₀ (bestEntryProg la);
have bEntry := Lean.Arborescence.bestEntryTable a c inCycle;
WordRAM.Realization.iterationSafe bestEntryOuterStep BestEntryOuterStepSafe w la n 0 s₀ ∧ (DataStructure.Memory.spec w).ValidHistory s₀ ((DataStructure.Memory.spec w).clientHistory s₀ (bestEntryProg la)) ∧ WordRAM.Realization.memoryCost (bestEntryProg la) s₀ ≤ (7 * n + 2) * n ∧ s'.frontier = s₀.frontier ∧ (∀ (addr : ℕ),
¬(candPredBase ws n ≤ addr ∧ addr < candCostBase ws n + n ∨ frameBEntryBase ws n k ≤ addr ∧ addr < frameBEntryBase ws n k + n) →
s'.mem addr = s₀.mem addr) ∧ ∀ (u : Fin n), s'.mem (frameBEntryBase ws n k + ↑u) = optFinIdx bEntry[↑u]
theorem Cslib.Algorithms.WordRAM.Arborescence.Internal.bestExitProg_spec {w n ws k B_k : ℕ} (hpos : 0 < n) (a : Lean.Arborescence.AdjTable n) (c : Lean.Arborescence.CostTable ℤ n) (f : Lean.Arborescence.ParentTable n) (inCycle : Vector Bool 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]) (hB : ∀ (u col : Fin n), c[↑u][↑col].natAbs ≤ B_k) :
have la := { n := n, ws := ws, k := k };
have s' := (DataStructure.Memory.spec 0).clientState s₀ (bestExitProg la);
have bExit := reducedBestExitTable a c f inCycle;
WordRAM.Realization.iterationSafe bestExitOuterStep BestExitOuterStepSafe w la n 0 s₀ ∧ (DataStructure.Memory.spec w).ValidHistory s₀ ((DataStructure.Memory.spec w).clientHistory s₀ (bestExitProg la)) ∧ WordRAM.Realization.memoryCost (bestExitProg la) s₀ ≤ (9 * n + 2) * n ∧ s'.frontier = s₀.frontier ∧ (∀ (addr : ℕ),
¬(candPredBase ws n ≤ addr ∧ addr < candCostBase ws n + n ∨ frameBExitBase ws n k ≤ addr ∧ addr < frameBExitBase ws n k + n) →
s'.mem addr = s₀.mem addr) ∧ ∀ (col : Fin n), s'.mem (frameBExitBase ws n k + ↑col) = optFinIdx bExit[↑col]