RAM writing of the output bitmap from the chosen copy
ProvedWilliamsonShmoys.ram_output_bitmap_writeThis RAM program writes the final answer of the planar independent-set PTAS into the output bitmap. It keeps the vertices of the chosen copy that are not deleted by its shift class.
Let a program contain, at position , the 48-instruction program. On entry cell 32 holds , cell 28 an even , cell 20 a copy index , and cell 22 an odd base . The solver bit of vertex in the chosen copy is at , and the residue at . The program reaches within operations, and for every the output cell defined by planarRAMOutput satisfies
The output cells can coincide with the program's own registers when is small. The program therefore first writes the bits to the scratch cells and a sentinel to cell . It then copies the bits downwards with a loop that uses only cells and . Every read address lies above every write address , so no value is overwritten before it is read.
Formalization Note. Code placement is CodeAt from Def_WilliamsonShmoys_RAMExec.
import Mathlib import Definitions.Def_WilliamsonShmoys_RAMExec set_option autoImplicit false open WilliamsonShmoys PlanarRAMInstruction open Classical
theorem WilliamsonShmoys.ram_output_bitmap_write (p : List PlanarRAMInstruction) (o : ℕ)
(hcode : CodeAt p o
[natConst 0 0,
natConst 2 1,
natConst 4 2,
natConst 36 16,
natAdd 24 32 32,
natAdd 18 28 24,
natConst 30 0,
natConst 6 0,
natBranch 32 6 (o + 12) (o + 9),
natAdd 30 30 32,
natAdd 6 6 2,
jump (o + 8),
natAdd 26 30 0,
natAdd 30 30 30,
natAdd 30 30 30,
natAdd 30 30 30,
natAdd 30 30 30,
natConst 8 32,
natAdd 38 30 8,
natAdd 10 28 0,
natAdd 12 22 0,
natBranch 18 10 (o + 34) (o + 22),
natLoad 8 12,
natBranch 2 8 (o + 24) (o + 29),
natLoad 8 10,
natBranch 8 20 (o + 26) (o + 27),
natBranch 20 8 (o + 29) (o + 27),
natStore 38 2,
jump (o + 30),
natStore 38 0,
natAdd 10 10 4,
natAdd 12 12 4,
natAdd 38 38 36,
jump (o + 21),
natAdd 0 26 32,
natAdd 0 0 2,
natAdd 8 30 36,
natStore 8 8,
natAdd 1 0 0,
natAdd 1 1 1,
natAdd 1 1 1,
natAdd 1 1 1,
natLoad 1 1,
natBranch 0 1 (o + 48) (o + 44),
natStore 0 1,
natConst 1 1,
natSub 0 0 1,
jump (o + 38)])
(n LVB BB cc : ℕ) (hLe : LVB % 2 = 0) (hB : BB % 2 = 1) (hL : 32 + 16 * n * n + 16 * n ≤ LVB)
(M : ℕ → ℕ) (R : ℕ → ℝ) (h32 : M 32 = n) (h28 : M 28 = LVB) (h20 : M 20 = cc) (h22 : M 22 = BB) :
∃ τ, τ ≤ 26 * n + 29 ∧ (planarRAMRun p ⟨o, M, R⟩ τ).pc = o + 48 ∧
(∀ j, j < n → (planarRAMRun p ⟨o, M, R⟩ τ).natMem (2 + n * n + j) = (if 1 ≤ M (BB + 2 * j) ∧ M (LVB + 2 * j) ≠ cc then 1 else 0)) := by sorry