Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

RAM fragment relocating the vertex weights to even cells

Proved
WilliamsonShmoys.ram_real_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 16-instruction fragment that relocates the real input (the vertex weights) to even cells. Started at base\mathrm{base}base with nnn in natural cell 0, 111 in cell 11 and 000 in cell 12, after exactly 5+(7(n−1)+1)+45+(7(n-1)+1)+45+(7(n−1)+1)+4 operations the program counter is base+16\mathrm{base}+16base+16 and, for every c<nc<nc<n,

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

Moreover real cells 000 and 2n+12n+12n+1 are 000, every other real cell outside the targets and cell 32 is unchanged, and only the natural scratch cells 2,3,6,72,3,6,72,3,6,7 change.

Real values can only be moved through a fixed real register, and every fixed real cell holds input data. The fragment therefore first parks real cell 0 in the odd cell 2n+12n+12n+1, which is neither a later source nor a target. It then copies c=n−1,…,1c=n-1,\dots,1c=n−1,…,1 downwards using real cell 0 as the register, restores cell 0's value to its target 32, and finally clears both auxiliary cells, so that later the sandboxed solver sees zeros there.

Formalization Note. Code placement is 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_real_spread_fragment (p : List PlanarRAMInstruction) (base : ℕ)
    (hcode : CodeAt p base
      [natAdd 2 0 12, natConst 6 32, natAdd 3 0 0, natAdd 3 3 11, realStore 3 0, natBranch 2 11 (base + 12) (base + 6), natSub 2 2 11, natAdd 7 2 2, natAdd 7 7 6, realLoad 0 2, realStore 7 0, jump (base + 5), realLoad 0 3, realStore 6 0, realSub 0 0 0, realStore 3 0]) (s : PlanarRAMState) (hpc : s.pc = base) (h11 : s.natMem 11 = 1)
    (h12 : s.natMem 12 = 0) :
    let n := s.natMem 0
    let s' := planarRAMRun p s (5 + (7 * (n - 1) + 1) + 4)
    s'.pc = base + 16 ∧
      (∀ c, c < n → s'.realMem (2 * c + 32) = s.realMem c) ∧
      s'.realMem 0 = 0 ∧ s'.realMem (2 * n + 1) = 0 ∧
      (∀ a, a ≠ 0 → a ≠ 32 → a ≠ 2 * n + 1 → (∀ c, c < n → a ≠ 2 * c + 32) →
        s'.realMem a = s.realMem a) ∧
      (∀ a, a ≠ 2 → a ≠ 3 → a ≠ 6 → a ≠ 7 → s'.natMem a = s.natMem a) := 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