Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Two WordRAM models: simulation and runtime transfer

Definition
WordRAM_APSP_Bridge

by wurtle · Oct 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

3sumapspcomputational-modelsfine-grained-complexitysimulationwordram

Compare the WordRAM model with unsigned pointers, bit operations, and shifts to the WordRAM model with signed pointers and branching on sign. Both have bounded-word arithmetic and multiplication. Use the existing native-free programs for the former and the existing instruction lists for the latter.

For positive source word width w, widen the target to w+4 bits. Map a natural source address a to signed target address 8+2a. In the other direction map integer source address z to natural target address 8+2zigzag(z), where zigzag(a)=2a and zigzag(-a-1)=2a+1. Store source words by zero extension, put the source width in cell zero, and initialize other cells outside the image to zero. The final-memory relations require exact preservation of every mapped source word; reserved and scratch cells are unconstrained by those relations.

Runs start at program counter zero. The model with unsigned pointers starts unhalted with zero ticks. Define the time bound B(C,d,t,w)=C(t+w+1)(w+1)^d. Each simulation predicate requires that a source halt by fuel t yields a target halt by some fuel u≤B, with related final memory. Every target halt by fuel u must conversely arise from a source halt by some t≤u. Explicit halt in the model with unsigned pointers becomes accept in the other model. In the reverse direction, accept/reject becomes an explicit halt with the Boolean verdict encoded as 1/0 in reserved cell one.

UniformOperationalSimulation groups these two requirements, using one exponent d. The source memories are arbitrary total functions and source widths are positive.

For problem-level runtime transfer, use ordinary packed integer inputs in both machines: n in cell zero, followed by the input list, then zeros. The wordramSolvedBy predicate runs a native-free program in the model with unsigned pointers directly, requires a Boolean verdict in final cell zero, and interprets the signed output cells immediately after the input. It uses the given problem’s own instance type, input, acceptance condition, and output condition. This packed-word convention is the fine-grained interface; the NP-oriented BitIO interface remains available separately.

APSPSolves and WordRAMSolves require a fixed program and one time bound T(n), valid for every n and instance with input magnitudes at most n^κ and every physical word width above b(⌊log₂ n⌋+1). Widths in the model with unsigned pointers are positive; the model with signed pointers retains its original natural-width domain. WordRAMSolvedInTime quantifies a program, width coefficient, and time bound for every κ and uses the published BigO predicate. Identifiers containing APSP reflect the source namespace; the predicates quantify general problems.

FiniteIO Q K q bounds input length by B(n)=K(n+1)^q and requires that the output condition depend only on the first B(n) output words. The transfer bound is C(T(n)+B(n)+1)(⌊log₂ n⌋+1)^d. UniformTimeTransfer maps every correct source program/time witness to a target witness in both directions using this bound, starting from ordinary inputs and producing final outputs; initialization, conversion, and output recovery therefore count toward runtime. Target programs and constants are fixed before sizes, instances, and physical widths. The bound is independent of physical word width.

APSPBelow and WordRAMBelow mean solvability with some rational exponent strictly below a rational threshold R. FineGrainedTimeEquivalence equates these properties for every finite-I/O problem whenever q<R. The source problem adapter copies the published EndStatement problem fields into the equivalent TrulySubcubicAPSP problem structure so the existing 3SUM statement is reused.

Definition code
import Definitions.Def_WordRAM_Complexity_Programs
import Definitions.Def_TrulySubcubicAPSP_WordRAM
import Definitions.Def_TrulySubcubicAPSP_Problems
import Definitions.Def_TrulySubcubicAPSP_SourceSpecification

set_option autoImplicit false

namespace WordRAM.APSPBridge

/-- Four additional bits leave room for the tagged address map and signed addressing. -/
def widened (w : Width) : Width where
  bits := w.bits + 4
  positive := by omega

/-- Interleave nonnegative and negative signed addresses. -/
def zigzag : Int → Nat
  | .ofNat a => 2 * a
  | .negSucc a => 2 * a + 1

def unzigzag (a : Nat) : Int :=
  if a % 2 = 0 then Int.ofNat (a / 2) else Int.negSucc (a / 2)

/-- The original unsigned-addressed memory occupies positive even target cells. -/
def wordramAddress (a : Nat) : Int := Int.ofNat (8 + 2 * a)

/-- The signed-addressed memory occupies positive even target cells. -/
def apspAddress (a : Int) : Nat := 8 + 2 * zigzag a

/-- Copy each source word unchanged as an unsigned bit pattern. Cell zero supplies
the source width; the remaining cells outside the image start at zero. -/
def encodeWordRAMMemory (w : Width) (m : Memory w) : Int → BitVec (widened w).bits :=
  fun a =>
    if a = 0 then BitVec.ofNat (widened w).bits w.bits
    else if 8 ≤ a ∧ a % 2 = 0 then
      BitVec.ofNat (widened w).bits (m ((a.toNat - 8) / 2)).toNat
    else 0

/-- Cell zero supplies the source width. The other reserved cells, including
verdict cell one, start at zero. Signed source addresses are mapped by `zigzag`. -/
def encodeAPSPMemory (w : Width) (m : Int → BitVec w.bits) : Memory (widened w) :=
  fun a =>
    if a = 0 then BitVec.ofNat (widened w).bits w.bits
    else if 8 ≤ a ∧ a % 2 = 0 then
      BitVec.ofNat (widened w).bits (m (unzigzag ((a - 8) / 2))).toNat
    else 0

def WordRAMMemoryRelated (w : Width) (source : Memory w)
    (target : Int → BitVec (widened w).bits) : Prop :=
  ∀ a, target (wordramAddress a) =
    BitVec.ofNat (widened w).bits (source a).toNat

def APSPMemoryRelated (w : Width) (source : Int → BitVec w.bits)
    (target : Memory (widened w)) : Prop :=
  ∀ a, target (apspAddress a) =
    BitVec.ofNat (widened w).bits (source a).toNat

/-- A fresh run starts at PC zero, with no previous ticks and without a halt flag. -/
def wordramHalt (P : Complexity.Program .multiplication) (w : Width)
    (input : Memory w) (t : Nat) (output : Memory w) : Prop :=
  let s := WordRAM.run Uniform.noConstants (P.lower w) t { mem := input }
  s.halted = true ∧ s.mem = output

def apspHalt (P : List TrulySubcubicAPSP.Instr) (w : Width)
    (input : Int → BitVec w.bits) (t : Nat) (verdict : Bool)
    (output : Int → BitVec w.bits) : Prop :=
  TrulySubcubicAPSP.exec P t 0 input = some (verdict, output)

def simulationBound (C d t : Nat) (w : Width) : Nat :=
  C * (t + w.bits + 1) * (w.bits + 1) ^ d

/-- Each successful source halt is simulated with a polynomial-in-width overhead.
Conversely, every target halt comes from a source halt. A source explicit halt
becomes an APSP `accept`; every source memory cell remains observable. -/
def WordRAMToAPSP (P : Complexity.Program .multiplication)
    (Q : List TrulySubcubicAPSP.Instr) (C d : Nat) : Prop :=
  ∀ (w : Width) (input : Memory w),
    (∀ t output, wordramHalt P w input t output →
      ∃ u, u ≤ simulationBound C d t w ∧
        ∃ targetOutput,
          apspHalt Q (widened w) (encodeWordRAMMemory w input) u true targetOutput ∧
          WordRAMMemoryRelated w output targetOutput) ∧
    (∀ u verdict targetOutput,
      apspHalt Q (widened w) (encodeWordRAMMemory w input) u verdict targetOutput →
      verdict = true ∧
        ∃ t, t ≤ u ∧ ∃ output,
          wordramHalt P w input t output ∧
          WordRAMMemoryRelated w output targetOutput)

/-- The reverse simulation preserves the APSP verdict in reserved target cell
one, in addition to preserving the entire signed-addressed source memory. -/
def APSPToWordRAM (P : List TrulySubcubicAPSP.Instr)
    (Q : Complexity.Program .multiplication) (C d : Nat) : Prop :=
  ∀ (w : Width) (input : Int → BitVec w.bits),
    (∀ t verdict output, apspHalt P w input t verdict output →
      ∃ u, u ≤ simulationBound C d t w ∧ ∃ targetOutput,
        wordramHalt Q (widened w) (encodeAPSPMemory w input) u targetOutput ∧
        (targetOutput 1).toNat = verdict.toNat ∧
        APSPMemoryRelated w output targetOutput) ∧
    (∀ u targetOutput,
      wordramHalt Q (widened w) (encodeAPSPMemory w input) u targetOutput →
      ∃ t, t ≤ u ∧ ∃ verdict output,
        apspHalt P w input t verdict output ∧
        (targetOutput 1).toNat = verdict.toNat ∧
        APSPMemoryRelated w output targetOutput)

/-- A single exponent works for uniform simulators in both directions. -/
def UniformOperationalSimulation (d : Nat) : Prop :=
  (∀ P : Complexity.Program .multiplication,
    ∃ Q : List TrulySubcubicAPSP.Instr, ∃ C : Nat,
      0 < C ∧ WordRAMToAPSP P Q C d) ∧
  (∀ P : List TrulySubcubicAPSP.Instr,
    ∃ Q : Complexity.Program .multiplication, ∃ C : Nat,
      0 < C ∧ APSPToWordRAM P Q C d)

/-- Packed integer input for the unsigned-addressed machine: size in cell zero,
input entries in cells one onward, and zero in every remaining cell. -/
def packedInitialMemory (w : Width) (n : Nat) (input : List Int) : Memory w :=
  fun a => BitVec.ofInt w.bits (((n : Int) :: input).getD a 0)

/-- A genuine run of our native-free multiplication model. The final cell zero
is a Boolean verdict; signed output begins immediately after the input. -/
def wordramSolvedBy (Q : TrulySubcubicAPSP.Problem) {n : Nat} (x : Q.Instance n)
    (P : Complexity.Program .multiplication) (w : Width) (t : Nat) : Prop :=
  ∃ verdict : Bool, ∃ output : Memory w,
    wordramHalt P w (packedInitialMemory w n (Q.input x)) t output ∧
    (output 0).toNat = verdict.toNat ∧
    (verdict = true ↔ Q.yes x) ∧
    Q.output x (fun a => (output (1 + (Q.input x).length + a)).toInt)

/-- The published APSP input promise and its all-sufficiently-large-width
convention, with an explicit program and runtime witness. -/
def APSPSolves (Q : TrulySubcubicAPSP.Problem) (κ : Nat)
    (P : List TrulySubcubicAPSP.Instr) (b : Nat) (T : Nat → Nat) : Prop :=
  ∀ (n : Nat) (x : Q.Instance n),
    (∀ a ∈ Q.input x, a.natAbs ≤ n ^ κ) →
      ∀ W ≥ b * (Nat.log2 n + 1), Q.SolvedBy x P W (T n)

/-- The same input promise and width convention for our machine. Programs are
fixed before the size, instance, and physical word width are supplied. -/
def WordRAMSolves (Q : TrulySubcubicAPSP.Problem) (κ : Nat)
    (P : Complexity.Program .multiplication) (b : Nat) (T : Nat → Nat) : Prop :=
  ∀ (n : Nat) (x : Q.Instance n),
    (∀ a ∈ Q.input x, a.natAbs ≤ n ^ κ) →
      ∀ w : Width, b * (Nat.log2 n + 1) ≤ w.bits →
        wordramSolvedBy Q x P w (T n)

def WordRAMSolvedInTime (Q : TrulySubcubicAPSP.Problem) (r : Rat) : Prop :=
  ∀ κ : Nat, ∃ (P : Complexity.Program .multiplication) (b : Nat) (T : Nat → Nat),
    TrulySubcubicAPSP.BigO T r ∧ WordRAMSolves Q κ P b T

def ioBound (K q n : Nat) : Nat := K * (n + 1) ^ q

/-- Input length is bounded and the output condition observes only a bounded
prefix. The bound is an explicit polynomial, not an instance-dependent oracle. -/
def FiniteIO (Q : TrulySubcubicAPSP.Problem) (K q : Nat) : Prop :=
  (∀ (n : Nat) (x : Q.Instance n), (Q.input x).length ≤ ioBound K q n) ∧
  (∀ (n : Nat) (x : Q.Instance n) (f g : Nat → Int),
    (∀ a, a < ioBound K q n → f a = g a) → (Q.output x f ↔ Q.output x g))

/-- End-to-end runtime, including finite input packing and output recovery.
The overhead depends on the problem size, not on the physical word width. -/
def transferBound (C d K q : Nat) (T : Nat → Nat) (n : Nat) : Nat :=
  C * (T n + ioBound K q n + 1) * (Nat.log2 n + 1) ^ d

/-- Transfer witnesses in both directions. Each target must solve the original
problem from ordinary packed input, at every sufficiently large physical width. -/
def UniformTimeTransfer (d : Nat) : Prop :=
  ∀ (Q : TrulySubcubicAPSP.Problem) (K q : Nat), FiniteIO Q K q →
    (∀ (κ : Nat) (P : List TrulySubcubicAPSP.Instr) (b : Nat) (T : Nat → Nat),
      APSPSolves Q κ P b T →
        ∃ (P' : Complexity.Program .multiplication) (b' C : Nat),
          0 < C ∧ WordRAMSolves Q κ P' b' (transferBound C d K q T)) ∧
    (∀ (κ : Nat) (P : Complexity.Program .multiplication) (b : Nat) (T : Nat → Nat),
      WordRAMSolves Q κ P b T →
        ∃ (P' : List TrulySubcubicAPSP.Instr) (b' C : Nat),
          0 < C ∧ APSPSolves Q κ P' b' (transferBound C d K q T))

def APSPBelow (Q : TrulySubcubicAPSP.Problem) (R : Rat) : Prop :=
  ∃ r : Rat, r < R ∧ Q.SolvedInTime r

def WordRAMBelow (Q : TrulySubcubicAPSP.Problem) (R : Rat) : Prop :=
  ∃ r : Rat, r < R ∧ WordRAMSolvedInTime Q r

/-- Strict polynomial-exponent thresholds above the I/O exponent coincide.
This permits arbitrarily small exponent loss without asserting identical
exact-exponent runtime bounds. -/
def FineGrainedTimeEquivalence : Prop :=
  ∀ (Q : TrulySubcubicAPSP.Problem) (K q : Nat), FiniteIO Q K q →
    ∀ R : Rat, (q : Rat) < R → (APSPBelow Q R ↔ WordRAMBelow Q R)

/-- Preserve exactly the published source specification's instances, input,
decision predicate, and output predicate when moving between its namespaces. -/
def sourceProblem (Q : EndStatement.Problem) : TrulySubcubicAPSP.Problem where
  Instance := Q.Instance
  input := fun x => Q.input x
  yes := fun x => Q.yes x
  output := fun x out => Q.output x out

end WordRAM.APSPBridge
Source
Model sources: Torben Hagerup, Sorting and Searching on the Word RAM, STACS 1998, pp. 366–398; model conventions pp. 369–372. https://doi.org/10.1007/BFb0028575 . Josh Alman and Virginia Vassilevska Williams, Truly Subquadratic 3SUM and Truly Subcubic APSP via Triangles in Sparse Lopsided Graphs, 2026. https://arxiv.org/abs/2610.06783 . Formal source for the model with signed pointers: EndStatement.lean, revision e1a4e6508154ea59f030480661590a9fe3018011, https://github.com/anthropics/formal-math/blob/e1a4e6508154ea59f030480661590a9fe3018011/3sum-apsp/EndStatement.lean . This mission proposes a new operational and quantitative runtime bridge between the published formal models; neither cited paper states this exact theorem. The memory layouts, operational four-bit padding, and runtime-transfer bound are explicit conventions of this bridge.
Read-back

What the Lean code literally says, in plain math · gpt-6

widened. For every word width www whose bit count s=w.bitss=w.\mathrm{bits}s=w.bits is a positive natural number, this definition returns the positive word width with exactly s+4s+4s+4 bits; it has no dependence on a program, input, or problem size.

zigzag. This function sends each integer a≥0a\ge 0a≥0 to the natural number 2a2a2a, and sends each negative integer written uniquely as −(a+1)-(a+1)−(a+1) with a∈Na\in\mathbb Na∈N to 2a+12a+12a+1. In particular, 0,−1,1,−20,-1,1,-20,−1,1,−2 map respectively to 0,1,2,30,1,2,30,1,2,3.

unzigzag. For every natural number aaa, this function returns the integer a/2a/2a/2 when aaa is even, and the integer −(⌊a/2⌋+1)-(\lfloor a/2\rfloor+1)−(⌊a/2⌋+1) when aaa is odd, where natural-number division is rounded down. In particular it returns 000 at a=0a=0a=0.

wordramAddress. For every natural-number source address aaa, this definition returns the integer target address 8+2a8+2a8+2a, without any modular reduction. Its image is exactly the even integer addresses at least 888.

apspAddress. For every integer source address aaa, this definition returns the natural-number target address 8+2z(a)8+2z(a)8+2z(a), where z(a)=2az(a)=2az(a)=2a for a≥0a\ge0a≥0 and z(−(b+1))=2b+1z(-(b+1))=2b+1z(−(b+1))=2b+1 for b∈Nb\in\mathbb Nb∈N. Addresses undergo no modular reduction; the image is exactly the even natural-number addresses at least 888.

encodeWordRAMMemory. Given a positive bit width sss and any memory m:N→{0,…,2s−1}m:\mathbb N\to\{0,\ldots,2^s-1\}m:N→{0,…,2s−1}, this defines an integer-addressed memory of (s+4)(s+4)(s+4)-bit words. Address 000 contains the (s+4)(s+4)(s+4)-bit encoding of sss. At every even integer address a≥8a\ge8a≥8, it contains the zero-extended unsigned source word m(⌊(a−8)/2⌋)m(\lfloor(a-8)/2\rfloor)m(⌊(a−8)/2⌋); every other address, including every negative address, contains zero. Thus source cell bbb is copied to cell 8+2b8+2b8+2b. The memory may have infinitely many nonzero source cells; no finite-support assumption is imposed.

encodeAPSPMemory. Given a positive bit width sss and any integer-addressed memory mmm of sss-bit words, this defines a natural-number-addressed memory of (s+4)(s+4)(s+4)-bit words. Cell 000 contains sss. At an even address a≥8a\ge8a≥8, let c=(a−8)/2c=(a-8)/2c=(a−8)/2; the cell contains the zero-extended unsigned bit pattern of m(c/2)m(c/2)m(c/2) if ccc is even, and of m(−(⌊c/2⌋+1))m(- (\lfloor c/2\rfloor+1))m(−(⌊c/2⌋+1)) if ccc is odd. Every remaining cell, including cell 111, contains zero. Equivalently, source address bbb is stored at 8+2z(b)8+2z(b)8+2z(b), where z(b)=2bz(b)=2bz(b)=2b for b≥0b\ge0b≥0 and z(−(j+1))=2j+1z(-(j+1))=2j+1z(−(j+1))=2j+1. There is no restriction on the source memory's support.

WordRAMMemoryRelated. For every positive source bit width sss, natural-number-addressed source memory mmm of sss-bit words, and integer-addressed target memory MMM of (s+4)(s+4)(s+4)-bit words, this proposition says that for every natural address aaa, M(8+2a)M(8+2a)M(8+2a) equals the zero-extension of the unsigned bit pattern m(a)m(a)m(a). It constrains all source cells, including arbitrarily large addresses, and leaves every target cell outside these addresses unconstrained.

APSPMemoryRelated. For every positive source bit width sss, integer-addressed source memory mmm of sss-bit words, and natural-number-addressed target memory MMM of (s+4)(s+4)(s+4)-bit words, this proposition says that for every integer address aaa, M(8+2z(a))M(8+2z(a))M(8+2z(a)) equals the zero-extension of the unsigned source bit pattern m(a)m(a)m(a), where z(a)=2az(a)=2az(a)=2a for a≥0a\ge0a≥0 and z(−(j+1))=2j+1z(-(j+1))=2j+1z(−(j+1))=2j+1. All positive and negative source cells are constrained; target cells outside this image, including cells 000 and 111, are not constrained by this relation.

wordramHalt. Given a fixed finite width-independent multiplication-model program PPP, a positive bit width sss, two arbitrary memories m,Mm,Mm,M on natural-number addresses with sss-bit words, and a natural fuel bound ttt, this proposition says that execution from memory mmm, program counter 000, tick count 000, and halt flag false, after being allowed ttt interpreter steps, has halt flag true and memory exactly MMM. The program permits copying, addition, subtraction, multiplication modulo 2s2^s2s, zero-filling left and right shifts by unsigned word values, bitwise AND, OR and NOT, unconditional jumps, unsigned equality/strict-order/non-strict-order branches, and explicit halt; operands may be natural immediates reduced modulo 2s2^s2s or memory reads, with natural direct addresses or indirect addresses obtained from unsigned pointer words. There are no native constants. Each executed instruction, including halt, costs one step; after halt the state stays fixed, and an invalid instruction fetch leaves the machine stuck without setting its halt flag. Thus this means explicit halt within ttt steps, not first halt exactly at ttt; it is false for t=0t=0t=0, and equality of output memories includes every address.

apspHalt. Given a finite signed-addressed program PPP, a positive bit width sss, arbitrary integer-addressed sss-bit input and output memories m,Mm,Mm,M, a natural fuel bound ttt, and a Boolean vvv, this proposition says that execution beginning at program position 000 with memory mmm returns exactly verdict vvv and final memory MMM within ttt steps. Instructions write the constant one, add, subtract or multiply words modulo 2s2^s2s, load or store indirectly using a pointer word's signed two's-complement value, branch to a natural program position on a negative signed word, accept, or reject; literal memory addresses are integers. Ordinary writes advance to the next instruction. Each instruction, including acceptance, rejection, or the default rejection for a fetch beyond the program, consumes one fuel step; zero fuel returns no result. Consequently the proposition is false at t=0t=0t=0, and a successful result need not first occur exactly at the supplied bound.

simulationBound. For arbitrary natural numbers C,d,tC,d,tC,d,t and a positive word width with bit count sss, the defined natural number is exactly C(t+s+1)(s+1)dC(t+s+1)(s+1)^dC(t+s+1)(s+1)d. In particular C=0C=0C=0 gives zero, d=0d=0d=0 removes the power factor, and t=0t=0t=0 still leaves the additive width term.

WordRAMToAPSP. For a fixed finite width-independent natural-addressed multiplication program PPP without native constants, a finite integer-addressed add/subtract/multiply/load/store/negative-branch/accept/reject program QQQ, and arbitrary naturals C,dC,dC,d, this proposition requires both following implications for every positive source bit width sss and every source memory mmm, with no support restriction. Initialize QQQ at width s+4s+4s+4 with cell 000 equal to sss, cell 8+2a8+2a8+2a equal to the zero-extended unsigned word m(a)m(a)m(a) for every natural aaa, and all other cells zero. For every natural ttt and memory m′m'm′, if PPP from its fresh state on mmm explicitly halts within ttt unit instruction steps with memory m′m'm′, there exist a natural u≤C(t+s+1)(s+1)du\le C(t+s+1)(s+1)^du≤C(t+s+1)(s+1)d and a target memory MMM such that QQQ from position zero accepts within uuu steps with memory MMM, and M(8+2a)M(8+2a)M(8+2a) equals the zero-extended m′(a)m'(a)m′(a) for every natural aaa. Conversely, for every natural uuu, Boolean vvv, and target memory MMM, if this initialized QQQ returns (v,M)(v,M)(v,M) within uuu steps, then vvv is true and there exist t≤ut\le ut≤u and a source memory m′m'm′ such that PPP explicitly halts within ttt steps with memory m′m'm′ and the same equality holds at every embedded source address. Source out-of-range fetches are stuck rather than successful halts; target out-of-range fetches reject. Both halting steps are counted, both start at program counter zero, and no run succeeds with zero fuel. The definition does not require C>0C>0C>0 and gives no additional conditions on target output cells outside the embedded memory.

APSPToWordRAM. For a finite integer-addressed add/subtract/multiply/load/store/negative-branch/accept/reject program PPP, a fixed finite width-independent natural-addressed multiplication program QQQ without native constants, and arbitrary naturals C,dC,dC,d, the following holds for every positive source bit width sss and every integer-addressed source memory mmm. Initialize QQQ at width s+4s+4s+4 with cell 000 equal to sss, cell 8+2z(a)8+2z(a)8+2z(a) equal to the zero-extended unsigned word m(a)m(a)m(a) for every integer aaa, and all other cells zero, where z(a)=2az(a)=2az(a)=2a for a≥0a\ge0a≥0 and z(−(j+1))=2j+1z(-(j+1))=2j+1z(−(j+1))=2j+1. For every natural ttt, Boolean vvv, and source memory m′m'm′, a source return (v,m′)(v,m')(v,m′) from position zero within ttt steps implies the existence of a natural u≤C(t+s+1)(s+1)du\le C(t+s+1)(s+1)^du≤C(t+s+1)(s+1)d and target memory MMM such that QQQ from its fresh state explicitly halts within uuu steps with memory MMM, the unsigned value of M(1)M(1)M(1) is 111 for true vvv and 000 for false vvv, and M(8+2z(a))M(8+2z(a))M(8+2z(a)) is the zero-extension of m′(a)m'(a)m′(a) for every integer aaa. Conversely, for every natural uuu and memory MMM, any explicit halt of this initialized QQQ within uuu steps implies the existence of t≤ut\le ut≤u, a Boolean vvv, and a source memory m′m'm′ giving a source return (v,m′)(v,m')(v,m′) within ttt steps and exactly those same verdict-cell and embedded-memory equalities. All instruction and halting steps cost one; source out-of-range fetches reject, target invalid fetches are stuck, and zero fuel never succeeds. Neither finite support nor C>0C>0C>0 is required, and other target output cells are unconstrained.

UniformOperationalSimulation. For a natural exponent ddd, this proposition is the conjunction of two uniform existence assertions. Every finite width-independent natural-addressed multiplication program PPP without native constants has a finite signed-addressed arithmetic/load/store/negative-branch/accept/reject simulator QQQ and a positive natural constant CCC; every finite program PPP of the latter kind has a finite width-independent native-free multiplication simulator QQQ of the former kind and a positive natural constant CCC. In either direction Q,CQ,CQ,C are chosen before the positive source width sss, arbitrary source memory, and fuel bounds. The target width is s+4s+4s+4, cell 000 initially contains sss, every source bit pattern is zero-extended into cell 8+2a8+2a8+2a for natural source addresses or 8+2z(a)8+2z(a)8+2z(a) for integer source addresses, with z(a)=2az(a)=2az(a)=2a for a≥0a\ge0a≥0 and z(−(j+1))=2j+1z(-(j+1))=2j+1z(−(j+1))=2j+1, and other target cells initially vanish. Every source halt within any bound ttt has a target halt within some u≤C(t+s+1)(s+1)du\le C(t+s+1)(s+1)^du≤C(t+s+1)(s+1)d preserving every embedded memory cell. Every target halt within any bound uuu arises from a source halt within some t≤ut\le ut≤u preserving those same cells. Natural-addressed source explicit halts become acceptance and every target verdict is true; in the reverse direction the source Boolean verdict is recorded as unsigned 000 or 111 in target cell 111. Execution begins at position zero, natural-addressed runs begin unhalted with zero ticks, halting instructions cost one, signed-addressed invalid fetches reject, and natural-addressed invalid fetches do not halt. The same ddd serves both directions and all programs; the simulators and constants may depend on the source program.

packedInitialMemory. For every positive bit width sss, natural size nnn, and finite list of integers xxx, this defines a memory on all natural addresses: cell 000 contains nnn modulo 2s2^s2s, cells 111 through the length of xxx contain the entries of xxx in order, each reduced modulo 2s2^s2s, and every later cell contains zero. The size and the list length need not agree, and no representability or magnitude assumption is made; n=0n=0n=0 and the empty list are allowed.

wordramSolvedBy. Given a problem QQQ consisting of an instance type at each natural size, an integer input list, a decision predicate, and a predicate on integer output sequences, a natural size nnn (an implicit argument), an instance xxx of size nnn, a fixed finite width-independent natural-addressed multiplication program PPP without native constants, a positive bit width sss, and a natural bound ttt, this says that there exist a Boolean vvv and an sss-bit output memory MMM such that PPP, started at position zero, unhalted and with zero ticks, explicitly halts within ttt unit steps on the memory containing nnn in cell 000, QQQ's input list in subsequent cells, and zeros elsewhere, all entries reduced modulo 2s2^s2s. The unsigned value of M(0)M(0)M(0) must equal the Boolean encoding of vvv (000 or 111), vvv is true if and only if the decision predicate holds for xxx, and the output predicate must hold for the sequence whose term at each natural aaa is the signed two's-complement value of M(1+∣Q.input(x)∣+a)M(1+|Q.\mathrm{input}(x)|+a)M(1+∣Q.input(x)∣+a). Thus the output starts immediately after the input and is required even for a rejecting verdict. No input-size promise or adequacy of the width is assumed here; invalid fetches are not successful halts, and t=0t=0t=0 cannot satisfy the proposition.

APSPSolves. Given a problem QQQ with size-indexed instances, integer input lists, decision and output predicates, naturals κ,b\kappa,bκ,b, a fixed finite signed-addressed arithmetic/load/store/negative-branch/accept/reject program PPP, and a function T:N→NT:\mathbb N\to\mathbb NT:N→N, this proposition says: for every natural size nnn and every instance xxx of size nnn whose every input integer aaa satisfies ∣a∣≤nκ|a|\le n^\kappa∣a∣≤nκ, and for every natural bit width W≥b(log2⁡n+1)W\ge b(\operatorname{log2} n+1)W≥b(log2n+1), running PPP at position zero with nnn in cell 000, the input list in subsequent nonnegative cells, and zeros everywhere else (including negative addresses), all values reduced modulo 2W2^W2W, returns some Boolean vvv and memory MMM within T(n)T(n)T(n) unit steps. It requires v=truev=\mathrm{true}v=true if and only if QQQ's decision predicate holds, and requires QQQ's output predicate on the signed values M(1+∣Q.input(x)∣+a)M(1+|Q.\mathrm{input}(x)|+a)M(1+∣Q.input(x)∣+a) for all natural output indices aaa. Accept, reject, and default out-of-range rejection each count as a step. The program, bbb, and TTT are fixed for all n,x,Wn,x,Wn,x,W; there is no upper bound on WWW and the runtime bound is independent of WWW. Here log2⁡0=0\operatorname{log2}0=0log20=0 and it is the floor of the base-two logarithm for positive nnn; sizes zero and one are included, as are κ=0\kappa=0κ=0 with 00=10^0=100=1 and b=0b=0b=0, in which case width zero is also required. The input promise is vacuous for an empty input list; no instance satisfies any additional, unstated promise.

WordRAMSolves. Given a problem QQQ with size-indexed instances, integer input lists, decision and output predicates, naturals κ,b\kappa,bκ,b, a fixed finite width-independent natural-addressed multiplication program PPP without native constants, and a function T:N→NT:\mathbb N\to\mathbb NT:N→N, this requires that for every natural nnn, every instance xxx of size nnn whose input integers all satisfy ∣a∣≤nκ|a|\le n^\kappa∣a∣≤nκ, and every positive bit width s≥b(log2⁡n+1)s\ge b(\operatorname{log2}n+1)s≥b(log2n+1), the fresh run of PPP from position zero explicitly halts within T(n)T(n)T(n) unit instruction steps on memory containing nnn, followed by the input list, followed by zeros, with every value reduced modulo 2s2^s2s. Some Boolean vvv and final memory MMM must have the unsigned value of cell 000 equal to the encoding 000 or 111 of vvv, have vvv true exactly when the decision predicate holds, and satisfy the output predicate on the signed values in cells 1+∣Q.input(x)∣+a1+|Q.\mathrm{input}(x)|+a1+∣Q.input(x)∣+a, for every natural output index aaa. The output condition applies to either verdict. An invalid fetch does not count as a halt. The fixed program's natural immediates are reduced at each width. All sufficiently large positive physical widths are required with the same T(n)T(n)T(n) and no upper width bound; bbb may be zero but width zero is excluded. The cases n=0,1n=0,1n=0,1, κ=0\kappa=0κ=0, empty input lists, and empty instance types are included, with log2⁡0=0\operatorname{log2}0=0log20=0 and 00=10^0=100=1.

WordRAMSolvedInTime. For a problem QQQ with size-indexed instances, integer input lists and decision/output predicates, and any rational r=p/er=p/er=p/e in its reduced representation with positive denominator eee, this proposition requires that for every natural input-magnitude exponent κ\kappaκ there exist a finite width-independent native-free natural-addressed multiplication program PPP, a natural bbb, and T:N→NT:\mathbb N\to\mathbb NT:N→N such that for some natural AAA, T(n)e≤Anmax⁡(p,0)T(n)^e\le A n^{\max(p,0)}T(n)e≤Anmax(p,0) for every n≥2n\ge2n≥2, and the following correctness holds for every natural nnn and every size-nnn instance whose input integers have absolute values at most nκn^\kappanκ: at every positive width s≥b(log2⁡n+1)s\ge b(\operatorname{log2}n+1)s≥b(log2n+1), PPP explicitly halts within T(n)T(n)T(n) unit steps on the packed memory consisting of nnn, the input list, then zeros, all reduced modulo 2s2^s2s. Its final cell 000 is unsigned 000 or 111, indicating the truth of the decision predicate, and the signed words immediately after the input satisfy the output predicate. The witnesses may depend on κ\kappaκ, but not on nnn, the instance, or the physical width. Correctness includes n=0,1n=0,1n=0,1 while the displayed growth inequality does not; log2⁡0=0\operatorname{log2}0=0log20=0, 00=10^0=100=1, and b=0b=0b=0 is allowed. The definition accepts negative rrr, for which the exponent of nnn in the growth inequality is truncated to zero rather than interpreted as a negative power.

ioBound. For arbitrary natural K,q,nK,q,nK,q,n, this defines exactly K(n+1)qK(n+1)^qK(n+1)q. In particular it is 000 for K=0K=0K=0, it is KKK for q=0q=0q=0, and it is KKK at n=0n=0n=0.

FiniteIO. Given a problem QQQ with size-indexed instances, integer input lists and decision/output predicates and naturals K,qK,qK,q, this proposition is the conjunction of: for every natural size nnn and every size-nnn instance xxx, the input list has length at most B(n)=K(n+1)qB(n)=K(n+1)^qB(n)=K(n+1)q; and for every such n,xn,xn,x and every two integer sequences f,g:N→Zf,g:\mathbb N\to\mathbb Zf,g:N→Z, equality f(a)=g(a)f(a)=g(a)f(a)=g(a) at all natural indices a<B(n)a<B(n)a<B(n) implies equivalence of the output predicate evaluated at fff and at ggg. There is no restriction on the decision predicate, input magnitudes, or output magnitudes, and the conditions apply to all instances rather than only instances meeting a magnitude promise. At K=0K=0K=0 every input list must be empty and the output predicate must have the same truth value for every pair of sequences, though that value may be false; at n=0n=0n=0 the bound is KKK. Any condition at a size having no instances is vacuous.

transferBound. For arbitrary natural constants C,d,K,qC,d,K,qC,d,K,q, any function T:N→NT:\mathbb N\to\mathbb NT:N→N, and any natural size nnn, this defines exactly C(T(n)+K(n+1)q+1)(log2⁡n+1)dC\bigl(T(n)+K(n+1)^q+1\bigr)(\operatorname{log2}n+1)^dC(T(n)+K(n+1)q+1)(log2n+1)d, where log2⁡0=0\operatorname{log2}0=0log20=0 and log2⁡n=⌊log⁡2n⌋\operatorname{log2}n=\lfloor\log_2n\rfloorlog2n=⌊log2​n⌋ for positive nnn. The expression has no physical-word-width argument. It is zero if C=0C=0C=0, its logarithmic factor is one if d=0d=0d=0 or n∈{0,1}n\in\{0,1\}n∈{0,1}, and it includes the input/output polynomial even if T(n)=0T(n)=0T(n)=0.

UniformTimeTransfer. For a natural ddd, this proposition quantifies over every problem QQQ and every pair of naturals K,qK,qK,q for which, at every natural size nnn and every instance, the input length is at most B(n)=K(n+1)qB(n)=K(n+1)^qB(n)=K(n+1)q and the output predicate depends only on the first B(n)B(n)B(n) entries of its integer output sequence. It asserts transfer in both directions between finite signed-addressed arithmetic/load/store/negative-branch/accept/reject programs and finite width-independent native-free natural-addressed multiplication programs. In either direction, for every natural input-magnitude exponent κ\kappaκ, source program PPP, natural threshold coefficient bbb, and function T:N→NT:\mathbb N\to\mathbb NT:N→N, if the source correctly solves QQQ within T(n)T(n)T(n) steps for every nnn, every instance with input values bounded in absolute value by nκn^\kappanκ, and every source physical width at least b(log2⁡n+1)b(\operatorname{log2}n+1)b(log2n+1), then there exist a target program P′P'P′, natural b′b'b′, and positive natural CCC solving exactly the same instances at every target width at least b′(log2⁡n+1)b'(\operatorname{log2}n+1)b′(log2n+1) within C(T(n)+B(n)+1)(log2⁡n+1)dC(T(n)+B(n)+1)(\operatorname{log2}n+1)^dC(T(n)+B(n)+1)(log2n+1)d steps. Widths are arbitrary naturals for the signed-addressed machine, including zero when its threshold permits, and positive naturals for the natural-addressed machine. Both solvers start at position zero on ordinary packed input nnn, then the input integers, then zeros (also zero at all negative addresses for the signed-addressed machine), with values reduced modulo 2W2^W2W, where WWW is the physical bit width; signed outputs immediately after the input satisfy QQQ's output predicate. Correctness requires acceptance exactly for the decision predicate in the signed-addressed machine, and explicit halt with that Boolean encoded as unsigned 000 or 111 in cell zero in the natural-addressed machine. Halting steps count, signed-addressed out-of-range fetches reject, and natural-addressed invalid fetches do not halt. Witnesses P′,b′,CP',b',CP′,b′,C may depend on all preceding source data, but not on nnn, the instance, or physical width. The assertion does not assume any growth bound on TTT, includes n=0,1n=0,1n=0,1, κ=0\kappa=0κ=0, K=0K=0K=0 and q=0q=0q=0, and uses log2⁡0=0\operatorname{log2}0=0log20=0 and 00=10^0=100=1.

APSPBelow. For any problem QQQ with size-indexed instances and integer input/decision/output data, and any rational threshold RRR, this proposition asserts the existence of a rational r<Rr<Rr<R such that for every natural κ\kappaκ there exist a finite signed-addressed arithmetic/load/store/negative-branch/accept/reject program PPP, a natural bbb, and T:N→NT:\mathbb N\to\mathbb NT:N→N satisfying both: if r=p/er=p/er=p/e has positive reduced denominator eee, there is a natural AAA with T(n)e≤Anmax⁡(p,0)T(n)^e\le A n^{\max(p,0)}T(n)e≤Anmax(p,0) for all n≥2n\ge2n≥2; and for every natural size nnn, every size-nnn instance with all input absolute values at most nκn^\kappanκ, and every natural width W≥b(log2⁡n+1)W\ge b(\operatorname{log2}n+1)W≥b(log2n+1), PPP returns within T(n)T(n)T(n) counted instruction steps the correct Boolean verdict and a memory whose signed words immediately after the input satisfy the output predicate. The run starts at position zero with nnn, then the input list, then zeros, all reduced modulo 2W2^W2W, and negative cells initially zero; out-of-range fetches reject. The exponent rrr is chosen before κ\kappaκ; program, bbb, and TTT may depend on κ\kappaκ, but not on size, instance, or width. Sizes 0,10,10,1 still require correctness; b=0b=0b=0 includes width zero, log2⁡0=0\operatorname{log2}0=0log20=0, 00=10^0=100=1, and negative rational exponents use the displayed numerator truncation.

WordRAMBelow. For any problem QQQ with size-indexed instances and integer input/decision/output data, and any rational threshold RRR, this asserts that some rational r<Rr<Rr<R has the following property: for every natural κ\kappaκ, there exist a fixed finite width-independent natural-addressed multiplication program PPP without native constants, a natural bbb, and T:N→NT:\mathbb N\to\mathbb NT:N→N such that, writing r=p/er=p/er=p/e in reduced form with e>0e>0e>0, some natural AAA satisfies T(n)e≤Anmax⁡(p,0)T(n)^e\le A n^{\max(p,0)}T(n)e≤Anmax(p,0) for every n≥2n\ge2n≥2, and for every natural nnn, every size-nnn instance whose input absolute values are at most nκn^\kappanκ, and every positive physical width s≥b(log2⁡n+1)s\ge b(\operatorname{log2}n+1)s≥b(log2n+1), PPP explicitly halts within T(n)T(n)T(n) unit instruction steps on packed memory nnn, then input, then zeros, all reduced modulo 2s2^s2s. Final cell zero must be unsigned 000 or 111 and indicate exactly the decision predicate, and the signed output cells immediately after the input must satisfy the output predicate. An invalid fetch is not a successful halt. The exponent is chosen before κ\kappaκ, and each program, bbb, and TTT is fixed before the size, instance, and width. Correctness includes sizes 0,10,10,1 although the growth condition does not; b=0b=0b=0 still permits only positive widths, log2⁡0=0\operatorname{log2}0=0log20=0, 00=10^0=100=1, and a negative numerator is truncated to zero in the growth condition.

FineGrainedTimeEquivalence. For every problem QQQ and naturals K,qK,qK,q such that every size-nnn input has length at most K(n+1)qK(n+1)^qK(n+1)q and, for every instance and every two integer output sequences agreeing at indices below this bound, the output predicate has equivalent truth values, this proposition requires the following for every rational R>qR>qR>q: there exists a rational r<Rr<Rr<R with a signed-addressed arithmetic/load/store/negative-branch/accept/reject solver of exponent rrr if and only if there exists a rational r′<Rr'<Rr′<R with a native-free natural-addressed multiplication solver of exponent r′r'r′. An exponent p/ep/ep/e (positive reduced denominator) means that for every natural magnitude exponent κ\kappaκ there are a fixed finite program, a natural bbb, and T:N→NT:\mathbb N\to\mathbb NT:N→N with T(n)e≤Anmax⁡(p,0)T(n)^e\le A n^{\max(p,0)}T(n)e≤Anmax(p,0) for all n≥2n\ge2n≥2 and some natural AAA, solving every size-nnn instance whose input absolute values are at most nκn^\kappanκ, at every physical width at least b(log2⁡n+1)b(\operatorname{log2}n+1)b(log2n+1), within T(n)T(n)T(n) counted steps. Widths may be zero for the signed-addressed machine and must be positive for the natural-addressed machine. Runs use packed size and integer input, reduced modulo 2W2^W2W, where WWW is the physical bit width, with all other cells initially zero; they return the correct verdict and signed output immediately after the input, the natural-addressed verdict being encoded as unsigned 000 or 111 in final cell zero and requiring explicit halt. Correctness includes n=0,1n=0,1n=0,1, with log2⁡0=0\operatorname{log2}0=0log20=0 and 00=10^0=100=1; the growth condition truncates negative numerators. The two rational exponents, programs, width thresholds, and runtime functions need not coincide, and the equivalence itself does not assert that either solver exists. No conclusion at R≤qR\le qR≤q is included.

sourceProblem. For every problem QQQ in the namespace EndStatement, this constructs a problem in the namespace TrulySubcubicAPSP with exactly the same instance type at every natural size nnn, exactly the same integer input list for each instance, exactly the same decision predicate, and exactly the same output predicate for every integer sequence indexed by the naturals. No encoding, restriction on instances or integer magnitudes, or change to the output condition is applied; this declaration contains no assertion about programs or runtime.

Human review
  • Endorsed by Shuze Chen · Oct 9, 2026

    Confirmed by the moderator at approval.

  • Endorsed by wurtle · Oct 9, 2026

    Confirmed by the mission captain (proposal self-audit).

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