Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

RAM loop clearing the odd sandbox cells

Proved
WilliamsonShmoys.ram_zero_odd_cells

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

program-logicram-model

This loop clears the odd memory cells before a sandboxed subprogram is started. In the odd-cell sandbox (SandboxedOddAt, SandboxOddRel), the subprogram's cell aaa lives in the host's odd cell 2a+12a+12a+1. The host must therefore make the odd cells hold exactly the subprogram's initial memory, which is zero outside its input.

Let a program ppp contain, at position zzz, the 9-instruction loop. It uses only the even cells 000, 222, 444, 666 (pointer, bound, step 222, zero) and the even real cell 000. If cell 222 holds 2K+12K+12K+1, the program reaches z+9z+9z+9 within 5K+55K+55K+5 operations, and for every i<Ki<Ki<K

nat′(2i+1)=0,real′(2i+1)=0.\mathrm{nat}'(2i+1)=0,\qquad \mathrm{real}'(2i+1)=0 .nat′(2i+1)=0,real′(2i+1)=0.

All natural cells other than 0,4,60,4,60,4,6 and the cleared odd cells are unchanged, and so are all real cells other than 000 and the cleared odd cells.

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
open Classical
Formal statement
theorem WilliamsonShmoys.ram_zero_odd_cells (p : List PlanarRAMInstruction) (z : ℕ)
    (hcode : CodeAt p z
    [natConst 0 1,
      natConst 4 2,
      natConst 6 0,
      realZero 0,
      natBranch 2 0 (z + 9) (z + 5),
      natStore 0 6,
      realStore 0 0,
      natAdd 0 0 4,
      jump (z + 4)])
    (K : ℕ) (M : ℕ → ℕ) (R : ℕ → ℝ) (h2 : M 2 = 2 * K + 1) :
    ∃ τ, τ ≤ 5 * K + 5 ∧ (planarRAMRun p ⟨z, M, R⟩ τ).pc = z + 9 ∧
      (∀ i, i < K → (planarRAMRun p ⟨z, M, R⟩ τ).natMem (2 * i + 1) = 0 ∧ (planarRAMRun p ⟨z, M, R⟩ τ).realMem (2 * i + 1) = 0) ∧
      (∀ a, a ≠ 0 → a ≠ 4 → a ≠ 6 → (∀ i, i < K → a ≠ 2 * i + 1) → (planarRAMRun p ⟨z, M, R⟩ τ).natMem a = M a) ∧
      (∀ a, a ≠ 0 → (∀ i, i < K → a ≠ 2 * i + 1) → (planarRAMRun p ⟨z, M, R⟩ τ).realMem a = R a) := by sorry
Source
RAM implementation of Williamson–Shmoys, The Design of Approximation Algorithms, Sect. 10.2 (subroutine call)

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