Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Equivalence of two WordRAM models up to polylogarithmic overhead

Open
WordRAM.APSPBridge.uniform_simulation_exists

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

3sumapspcomputational-modelsfine-grained-complexitysimulationwordram

The WordRAM models with unsigned pointers and with signed pointers admit two-way simulation and complete runtime transfer, with one natural overhead exponent d. Both support multiplication; the former also provides bit operations and shifts, while the latter branches on sign. At the operational level, every native-free program in the former model and every program in the latter has a fixed simulator in the other, preserving and reflecting successful halting and preserving every mapped source memory cell at target width w+4, within C(t+w+1)(w+1)^d steps. Accept/reject verdicts are preserved explicitly.

For every problem Q with input and observable output bounded by B(n)=K(n+1)^q, every input-magnitude exponent κ, and every correct source program with time bound T(n) at all sufficiently large word widths, there are a fixed target program, width threshold coefficient, and positive C solving the same problem within C(T(n)+B(n)+1)(⌊log₂ n⌋+1)^d steps. This holds in both directions. The target starts from ordinary packed input and produces the required verdict and signed output; conversion and output recovery count toward the bound. The same bound works at every physical word width above the new threshold, including arbitrarily large widths.

Consequently, for every rational R>q, existence of an algorithm with some rational exponent below R is equivalent in the two models. As applications, the same main theorem includes integer APSP at threshold 3 and integer 3SUM at threshold 2. A positive subcubic or subquadratic exponent saving is therefore preserved. Exact exponent bounds may acquire a polylogarithmic factor; no equality of exact-exponent complexity classes is claimed.

The theorem asserts existence of simulators and transferred programs. It has no unproved transfer hypothesis and no hidden assumption that the source problem already has a fast algorithm: the concrete APSP and 3SUM conclusions are equivalences.

Preamble
import Definitions.Def_WordRAM_APSP_Bridge

set_option autoImplicit false
Formal statement
theorem WordRAM.APSPBridge.uniform_simulation_exists :
    ∃ d : Nat,
      WordRAM.APSPBridge.UniformOperationalSimulation d ∧
      WordRAM.APSPBridge.UniformTimeTransfer d ∧
      WordRAM.APSPBridge.FineGrainedTimeEquivalence ∧
      (WordRAM.APSPBridge.APSPBelow TrulySubcubicAPSP.APSP 3 ↔
        WordRAM.APSPBridge.WordRAMBelow TrulySubcubicAPSP.APSP 3) ∧
      ((∃ r : Rat, r < 2 ∧ EndStatement.ThreeSum.SolvedInTime r) ↔
        WordRAM.APSPBridge.WordRAMBelow
          (WordRAM.APSPBridge.sourceProblem EndStatement.ThreeSum) 2) := by sorry
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

WordRAM.APSPBridge.uniform_simulation_exists. There exists one natural exponent ddd for which all five assertions below hold. Here the natural-addressed machine has memory on N\mathbb NN, positive bit width sss, and a fixed finite width-independent program with copy, modular addition/subtraction/multiplication, zero-filling shifts by unsigned word amounts, bitwise AND/OR/NOT, jumps, unsigned equality/order branches, and explicit halt; direct addresses are arbitrary naturals, indirect pointers are unsigned words, natural immediate constants are reduced modulo 2s2^s2s, and there are no native constants. Its runs start at program counter and tick count zero with halt flag false; every instruction including halt costs one step, and invalid fetches are stuck without halting. The signed-addressed machine has memory on Z\mathbb ZZ and finite programs with constant-one writes, modular addition/subtraction/multiplication, signed-pointer loads/stores, branches on a negative signed word, accept and reject; all instructions cost one step, including the default rejection at an out-of-range program position. Halting within a natural fuel bound means that the specified verdict and whole final memory have been returned by that bound, not necessarily for the first time exactly then; zero fuel never gives a successful halt. (i) For every natural-addressed program PPP there exist a signed-addressed program QQQ and positive natural CCC, fixed before the width and input, such that for every positive source width sss and every arbitrary source memory mmm, 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 every other cell zero: each explicit source halt within any bound ttt with memory m′m'm′ has a target acceptance 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 whose memory at 8+2a8+2a8+2a is the zero-extension of m′(a)m'(a)m′(a) for every aaa; conversely every target halt with any verdict and memory within any bound uuu is an acceptance and is matched by a source halt within some t≤ut\le ut≤u preserving all those cells. For every signed-addressed program PPP there likewise exist a natural-addressed program QQQ and positive natural CCC, fixed before width and input, such that for every positive source width sss and arbitrary integer-addressed input mmm, the target at width s+4s+4s+4 starts with cell zero equal to sss, source cell aaa zero-extended into cell 8+2z(a)8+2z(a)8+2z(a), and other cells zero, where z(a)=2az(a)=2az(a)=2a if a≥0a\ge0a≥0 and z(−(j+1))=2j+1z(-(j+1))=2j+1z(−(j+1))=2j+1 for j∈Nj\in\mathbb Nj∈N; each source halt within any bound ttt with verdict vvv and memory m′m'm′ has a target explicit 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 source cell and recording vvv as unsigned 000 or 111 in target cell 111, and every target halt within any bound uuu conversely arises from a source halt within some t≤ut\le ut≤u with those same memory and verdict equalities. These operational clauses impose no support restriction on source memories and no requirement on other final target cells. To state the remaining clauses, a problem consists of instances at each natural size, an integer input list, a decision predicate, and a predicate on a natural-indexed integer output sequence. Say a program solves such a problem for natural parameters κ,b\kappa,bκ,b and runtime function T:N→NT:\mathbb N\to\mathbb NT:N→N when, for every natural size nnn, every instance whose input integers have absolute value at most nκn^\kappanκ, and every physical width at least bL(n)bL(n)bL(n), it halts within T(n)T(n)T(n) steps from position zero on the packed input nnn followed by that input list, all words reduced modulo 2W2^W2W, where WWW is the physical bit width and every other cell initially zero, with the correct decision verdict and with the signed words immediately following the input satisfying the output predicate. Here L(n)=log2⁡n+1L(n)=\operatorname{log2}n+1L(n)=log2n+1, with log2⁡0=0\operatorname{log2}0=0log20=0 and otherwise the floor of the base-two logarithm; signed-addressed widths may be any natural, including zero, while natural-addressed widths must be positive, its halt must be explicit, and its final cell zero must contain the verdict as unsigned 000 or 111. There is no upper width bound. (ii) For every problem QQQ and every natural K,qK,qK,q such that every size-nnn input has length at most B(n)=K(n+1)qB(n)=K(n+1)^qB(n)=K(n+1)q and the output predicate has the same truth value on every two integer sequences agreeing at all indices below B(n)B(n)B(n), the following holds in both directions between the two machines: for every natural κ\kappaκ, source program PPP, natural bbb, and runtime function TTT, if PPP solves QQQ for those parameters, then there exist a target program P′P'P′, a natural b′b'b′, and positive natural CCC solving the same QQQ and κ\kappaκ at all target widths at least b′L(n)b'L(n)b′L(n) within C(T(n)+B(n)+1)L(n)dC(T(n)+B(n)+1)L(n)^dC(T(n)+B(n)+1)L(n)d steps. Target witnesses may depend on Q,K,q,κ,P,b,TQ,K,q,\kappa,P,b,TQ,K,q,κ,P,b,T, but not on size, instance, or physical width; no growth hypothesis on TTT is assumed. (iii) For every such Q,K,qQ,K,qQ,K,q and every rational threshold R>qR>qR>q, a signed-addressed solver exists at some rational exponent below RRR if and only if a natural-addressed solver exists at some rational exponent below RRR. In this statement and the remaining assertions, existence at exponent r=p/er=p/er=p/e in reduced form with e>0e>0e>0 means: for every natural κ\kappaκ there exist a program, natural bbb, and runtime function TTT solving for those parameters, and some natural AAA such that 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. Thus the exponent is fixed before κ\kappaκ, but the other witnesses may depend on κ\kappaκ; negative numerators are truncated to zero. (iv) Existence at some rational exponent strictly below 333 is equivalent for the two machines for the following all-pairs-shortest-path problem: a size-nnn instance is an integer-weighted directed graph on {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} in which every closed finite walk has nonnegative weight, walks may repeat vertices, and the empty walk has weight zero; input is the row-major edge-presence matrix followed by the row-major weights, with zero weights for absent edges. The decision predicate is always true; the empty graph at n=0n=0n=0 has no required output pairs. For each ordered pair (i,j)(i,j)(i,j), output positions 2(in+j)2(in+j)2(in+j) and 2(in+j)+12(in+j)+12(in+j)+1 must either be 111 and a realized walk weight no greater than every walk weight from iii to jjj, or have the first entry 000 and there be no such walk; in the latter case the distance entry is unconstrained. (v) Existence at some rational exponent strictly below 222 for the EndStatement signed-addressed machine, whose instruction, fuel, packed-input, signed-output and growth conventions are precisely the signed-addressed conventions just stated, is equivalent to existence below 222 for the natural-addressed machine on the unchanged problem with size-nnn instances x:{0,…,n−1}→Zx:\{0,\ldots,n-1\}\to\mathbb Zx:{0,…,n−1}→Z, input list x(0),…,x(n−1)x(0),\ldots,x(n-1)x(0),…,x(n−1), and decision predicate that three pairwise distinct indices have values summing to zero; its output predicate is always true, and its decision predicate is false for n<3n<3n<3. All size quantifiers include n=0,1n=0,1n=0,1, all magnitude exponents include κ=0\kappa=0κ=0 with 00=10^0=100=1, and width coefficients may be zero; correctness at sizes zero and one remains required although the growth inequality starts at two. In (ii) and (iii), K=0K=0K=0 forces empty input lists and output predicates independent of the output sequence; empty instance types make their instance conditions vacuous. The exponents witnessing the two sides of any equivalence need not agree, and no equivalence by itself asserts existence of a solver on either side.

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