Loop rule with a decreasing measure
ProvedWilliamsonShmoys.RAMSpec.loopprogram-logicram-model
Let be an invariant, an exit condition and a natural-number measure on states. Suppose that from every state satisfying but not , running reaches, within operations, a state satisfying with strictly smaller . Then for every ,
This is the total-correctness rule for loops; the cost is the per-iteration bound times the number of iterations, bounded by the initial measure.
Formalization Note. is planarRAMRun p s t, the -fold iterate of planarRAMStep p; triples are RAMSpec from Def_WilliamsonShmoys_RAMSpec.
Preamble
import Mathlib import Definitions.Def_WilliamsonShmoys_RAMSpec set_option autoImplicit false open WilliamsonShmoys
Formal statement
theorem WilliamsonShmoys.RAMSpec.loop (program : List PlanarRAMInstruction)
(I E : PlanarRAMState → Prop) (μ : PlanarRAMState → ℕ) (c : ℕ)
(hbody : ∀ s, I s → ¬ E s →
RAMReachesWithin program s (fun s' => I s' ∧ μ s' < μ s) c)
(m : ℕ) :
RAMSpec program (fun s => I s ∧ μ s ≤ m) (fun s => I s ∧ E s) (c * m) := by sorrySource
Program-logic infrastructure for the RAM model of Williamson–Shmoys, The Design of Approximation Algorithms, Theorem 10.11 (mission formalization)