Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

RAM fragment relocating the input table to even cells

Proved
WilliamsonShmoys.ram_spread_fragment

by もち · Nov 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

program-logicram-model

Let a program ppp contain, at position base\mathrm{base}base, the 9-instruction fragment that sets cell 5 to 888 and cell 6 to 323232 and then, counting cell 2 down from LLL while it exceeds 888, copies cell ccc to cell 2c+322c+322c+32 by an indirect load and store through cells 3 and 7. Started at base\mathrm{base}base with LLL in cell 2 and 111 in cell 4, after exactly 3+7 (L−8)3+7\,(L-8)3+7(L−8) operations the program counter is base+9\mathrm{base}+9base+9 and, for every ccc with 8≤c<L8\le c<L8≤c<L,

cell (2c+32)=original cell c.\text{cell }(2c+32)=\text{original cell }c.cell (2c+32)=original cell c.

Every cell other than the scratch cells 2,3,5,6,72,3,5,6,72,3,5,6,7 and the targets 2c+322c+322c+32 is unchanged, and real memory is unchanged.

The copy runs from high addresses to low. Each target 2c+322c+322c+32 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.

Preamble
import Mathlib
import Definitions.Def_WilliamsonShmoys_RAMExec

set_option autoImplicit false
open WilliamsonShmoys PlanarRAMInstruction
Formal statement
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
Source
RAM implementation of Williamson–Shmoys, The Design of Approximation Algorithms, Theorem 10.11 (mission formalization)

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me