RAM fragment computing
ProvedWilliamsonShmoys.ram_square_fragmentprogram-logicram-model
Let a program contain, at position , the 7-instruction fragment: set cell 4 to , cell 2 to and cell 3 to ; then, while cell 0 exceeds cell 3, add cell 0 to cell 2 and cell 4 to cell 3. Started at with in cell 0, after exactly operations the program counter is and
with every other cell, natural or real, unchanged. In the mission's input layout, is the length of the natural-memory input (two header cells and the adjacency table). The fragment uses only the cells freed by ram_pack_low_cells, and its correctness is proved by induction over the loop iterations.
Formalization Note. Code placement is CodeAt from Def_WilliamsonShmoys_RAMExec; cells are natural-memory cells.
Preamble
import Mathlib import Definitions.Def_WilliamsonShmoys_RAMExec set_option autoImplicit false open WilliamsonShmoys PlanarRAMInstruction
Formal statement
theorem WilliamsonShmoys.ram_square_fragment (p : List PlanarRAMInstruction) (base : ℕ)
(hcode : CodeAt p base
[natConst 4 1, natConst 2 2, natConst 3 0, natBranch 0 3 (base + 7) (base + 4), natAdd 2 2 0, natAdd 3 3 4, jump (base + 3)]) (s : PlanarRAMState) (hpc : s.pc = base) :
let n := s.natMem 0
let s' := planarRAMRun p s (4 * n + 4)
s'.pc = base + 7 ∧ s'.natMem 2 = 2 + n * n ∧ s'.natMem 3 = n ∧ s'.natMem 4 = 1 ∧
(∀ a, a ≠ 2 → a ≠ 3 → a ≠ 4 → s'.natMem a = s.natMem a) ∧ s'.realMem = s.realMem := by sorrySource
RAM implementation of Williamson–Shmoys, The Design of Approximation Algorithms, Theorem 10.11 (mission formalization)