RAM fragment packing cells 2–7 into cell 1
ProvedWilliamsonShmoys.ram_pack_low_cellsLet the program contain, at position , the 12 instructions that six times double cell 1 and then add cell , for . Started at from a state with natural memory , after exactly 12 operations the program counter is , every cell other than cell 1 is unchanged, and cell 1 holds
In the mission's input layout, cell 1 holds the accuracy parameter and cells hold adjacency bits (or zeros), all at most . So this fragment frees six fixed cells for use as working registers without losing information, a prerequisite for any loop in a host program, whose input otherwise fills every fixed address.
Formalization Note. Uses execInstr and CodeAt from Def_WilliamsonShmoys_RAMExec.
Preamble
import Mathlib import Definitions.Def_WilliamsonShmoys_RAMExec set_option autoImplicit false open WilliamsonShmoys PlanarRAMInstruction
Formal statement
theorem WilliamsonShmoys.ram_pack_low_cells (p : List PlanarRAMInstruction) (base : ℕ) (s : PlanarRAMState)
(hcode : CodeAt p base
[natAdd 1 1 1, natAdd 1 1 2, natAdd 1 1 1, natAdd 1 1 3, natAdd 1 1 1, natAdd 1 1 4, natAdd 1 1 1, natAdd 1 1 5, natAdd 1 1 1, natAdd 1 1 6, natAdd 1 1 1, natAdd 1 1 7])
(hpc : s.pc = base) :
planarRAMRun p s 12 =
{ pc := base + 12,
natMem := Function.update s.natMem 1
(64 * s.natMem 1 + 32 * s.natMem 2 + 16 * s.natMem 3 + 8 * s.natMem 4 +
4 * s.natMem 5 + 2 * s.natMem 6 + s.natMem 7),
realMem := s.realMem } := by sorry