RAM sweep reducing BFS levels modulo k
ProvedWilliamsonShmoys.ram_level_mod_sweepThis sweep turns the BFS labels into the residues used by Baker's shifting technique: it replaces every level label by the level modulo .
Let a program contain, at position , the 12-instruction loop over (cells 24 and 27). For each label it subtracts the offset (cell 17) and then reduces modulo (cell 16) by repeated subtraction. The labels sit at with . Assume , cells 13, 28, 11, 12, 19 hold , , , , , and every label satisfies . Then the program reaches within operations, and for every
All cells other than 22, 24, 27 and the label array are unchanged, as is the real memory. Applied after ram_bfs_baker_levels, where and , it produces , the index of the shift class that deletes .
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_level_mod_sweep (p : List PlanarRAMInstruction) (h : ℕ)
(hcode : CodeAt p h
[natConst 24 0,
natAdd 27 28 12,
natBranch 13 24 (h + 12) (h + 3),
natLoad 22 27,
natSub 22 22 17,
natBranch 16 22 (h + 6) (h + 8),
natSub 22 22 16,
jump (h + 5),
natStore 27 22,
natAdd 24 24 11,
natAdd 27 27 19,
jump (h + 2)])
(n k LVB : ℕ) (hk : 0 < k) (hLVB : 36 ≤ LVB) (M : ℕ → ℕ) (R : ℕ → ℝ)
(h13 : M 13 = n) (h16 : M 16 = k) (h17 : M 17 = n + 2) (h28 : M 28 = LVB) (h11 : M 11 = 1)
(h12 : M 12 = 0) (h19 : M 19 = 2)
(hb : ∀ j, j < n → n + 2 ≤ M (LVB + 2 * j) ∧ M (LVB + 2 * j) ≤ 2 * n + 2) :
∃ τ, τ ≤ (3 * n + 9) * n + 3 ∧
(planarRAMRun p ⟨h, M, R⟩ τ).pc = h + 12 ∧
(∀ j, j < n → (planarRAMRun p ⟨h, M, R⟩ τ).natMem (LVB + 2 * j) = (M (LVB + 2 * j) - (n + 2)) % k) ∧
(∀ a, a ≠ 22 → a ≠ 24 → a ≠ 27 → (∀ j, j < n → a ≠ LVB + 2 * j) →
(planarRAMRun p ⟨h, M, R⟩ τ).natMem a = M a) ∧
(planarRAMRun p ⟨h, M, R⟩ τ).realMem = R := by sorry