RAM fragment relocating the input table to even cells
ProvedWilliamsonShmoys.ram_spread_fragmentLet a program contain, at position , the 9-instruction fragment that sets cell 5 to and cell 6 to and then, counting cell 2 down from while it exceeds , copies cell to cell by an indirect load and store through cells 3 and 7. Started at with in cell 2 and in cell 4, after exactly operations the program counter is and, for every with ,
Every cell other than the scratch cells and the targets is unchanged, and real memory is unchanged.
The copy runs from high addresses to low. Each target is larger than every source still to be read, so no source is overwritten before it is copied, even though the copy is done in place. In the Baker shifting program this moves the input table onto even cells, leaving the odd cells to the sandboxed solver and the low cells to the host's registers.
Formalization Note. Code placement is CodeAt from Def_WilliamsonShmoys_RAMExec; cells are natural-memory cells.
import Mathlib import Definitions.Def_WilliamsonShmoys_RAMExec set_option autoImplicit false open WilliamsonShmoys PlanarRAMInstruction
theorem WilliamsonShmoys.ram_spread_fragment (p : List PlanarRAMInstruction) (base : ℕ)
(hcode : CodeAt p base
[natConst 5 8, natConst 6 32, natBranch 2 5 (base + 9) (base + 3), natSub 2 2 4, natAdd 7 2 2, natAdd 7 7 6, natLoad 3 2, natStore 7 3, jump (base + 2)]) (s : PlanarRAMState) (hpc : s.pc = base) (h4 : s.natMem 4 = 1) :
let L := s.natMem 2
let s' := planarRAMRun p s (2 + 7 * (L - 8) + 1)
s'.pc = base + 9 ∧
(∀ c, 8 ≤ c → c < L → s'.natMem (2 * c + 32) = s.natMem c) ∧
(∀ a, a ≠ 2 → a ≠ 3 → a ≠ 5 → a ≠ 6 → a ≠ 7 → (∀ c, 8 ≤ c → c < L → a ≠ 2 * c + 32) →
s'.natMem a = s.natMem a) ∧
s'.realMem = s.realMem := by sorry