Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

3SUM in O(n^1.960614) word-RAM steps

Proved
ThreeSum1960614.threeSum_1960614

by Yuxuan Xu · Oct 14, 2026 · Mathlib 0df444a (Lean v4.33.1)

3sumalgorithmsentropyword-ram

For every fixed natural integer-size exponent κ\kappaκ, there exist a finite deterministic word-RAM program PPP, a natural word-width constant bbb, and a natural-valued time function TTT. For every input size nnn, every list of nnn integers of absolute value at most nκn^\kappanκ, and every word width W≥b(⌊log⁡2n⌋+1)W\ge b(\lfloor\log_2n\rfloor+1)W≥b(⌊log2​n⌋+1), the program halts within T(n)T(n)T(n) steps and accepts exactly when three pairwise distinct positions sum to zero. Repeated values at different positions are allowed. For the reduced rational 1.960614=980307/5000001.960614=980307/5000001.960614=980307/500000, there is a natural KKK such that T(n)500000≤Kn980307T(n)^{500000}\le K n^{980307}T(n)500000≤Kn980307 for every n≥2n\ge2n≥2. This exact campaign goal remains unproved until the modified complete program and runtime bridge are closed; it is not asserted to follow from numeric checks alone.

Preamble
import Definitions.Def_ThreeSum1960614_Analysis
import Definitions.Def_TrulySubcubicAPSP_SourceSpecification

set_option autoImplicit false
set_option relaxedAutoImplicit false
open ThreeSum1960614
Formal statement
theorem ThreeSum1960614.threeSum_1960614 :
    EndStatement.ThreeSum.SolvedInTime 1.960614 := by sorry
Source
User-supplied 3sum_certificate_1p960614_v3/3sum_certificate_v3/PROOF.md (14 October 2026); Section 0: intended machine target; upstream https://github.com/c0ldzy17/three-sum-lean/tree/2b639655e07421b9ac743de9090459bab473a7c0
Read-back

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


declaration: ThreeSum1960614.threeSum_1960614 readback_model: GPT-6

For every natural number κ\kappaκ, there exist a finite program PPP, a natural number bbb, and a function T:N→NT:\mathbb N\to\mathbb NT:N→N, with the following two properties. First, there is a natural number KKK such that, for every natural number n≥2n\ge2n≥2, T(n)500000≤Kn980307T(n)^{500000}\le K n^{980307}T(n)500000≤Kn980307; these are exactly the denominator and numerator of the reduced rational number 1.960614=980307/5000001.960614=980307/5000001.960614=980307/500000. Second, for every natural number nnn, every function x:{0,…,n−1}→Zx:\{0,\ldots,n-1\}\to\mathbb Zx:{0,…,n−1}→Z satisfying ∣x(i)∣≤nκ|x(i)|\le n^\kappa∣x(i)∣≤nκ at every input position iii, and every natural word width W≥b(log⁡2Natn+1)W\ge b(\log_2^{\mathrm{Nat}}n+1)W≥b(log2Nat​n+1), executing PPP from program position 000 on the initial memory described below halts within T(n)T(n)T(n) steps, including the halting step, with some Boolean verdict and some final memory, and the verdict is true if and only if there exist positions i,j,k∈{0,…,n−1}i,j,k\in\{0,\ldots,n-1\}i,j,k∈{0,…,n−1} such that i≠ji\ne ji=j, j≠kj\ne kj=k, i≠ki\ne ki=k, and x(i)+x(j)+x(k)=0x(i)+x(j)+x(k)=0x(i)+x(j)+x(k)=0 as an equality of integers. The positions need not be ordered, equal integer values at different positions are allowed, and a position cannot be reused within the triple. Here log⁡2Natn=⌊log⁡2n⌋\log_2^{\mathrm{Nat}}n=\lfloor\log_2n\rfloorlog2Nat​n=⌊log2​n⌋ for n≥1n\ge1n≥1, while log⁡2Nat0=0\log_2^{\mathrm{Nat}}0=0log2Nat​0=0. The choices of P,b,TP,b,TP,b,T, and the witness KKK, may depend on κ\kappaκ, but the same P,b,TP,b,TP,b,T must work for all the indicated sizes, inputs, and widths; TTT depends only on nnn, and there is no upper bound on WWW. Memory has one cell for every integer address, each holding a WWW-bit word. An integer is loaded as its residue modulo 2W2^W2W; initially cell 000 holds the word for nnn, cell i+1i+1i+1 holds the word for x(i)x(i)x(i) for 0≤i<n0\le i<n0≤i<n, and every other cell, including every negative-address cell, holds the zero word. For W>0W>0W>0, a word with unsigned residue u∈{0,…,2W−1}u\in\{0,\ldots,2^W-1\}u∈{0,…,2W−1} is read as the signed integer uuu when u<2W−1u<2^{W-1}u<2W−1, and as u−2Wu-2^Wu−2W otherwise; for W=0W=0W=0 there is only the zero word and its signed value is 000. The program is a finite list of instructions whose direct cell addresses are arbitrary integers and whose jump positions are natural numbers. Its instructions can write the word for 111 to a directly named cell; write the sum, difference, or product of two directly named cells to a directly named cell, with word arithmetic modulo 2W2^W2W; load into a directly named cell the word at the integer address obtained by reading another directly named cell as signed; store the word from a directly named source cell at the integer address obtained by reading a directly named address cell as signed; branch to a specified program position precisely when the signed word in a directly named cell is negative, otherwise advance to the next position; accept; or reject. Each write updates only its destination cell and advances to the next position; an indirect store uses the address and source word in the memory before that update. Each instruction costs one step, including a branch, accept, or reject. Reading a program position at or beyond the end of its list acts as a reject instruction and costs a step. Running with zero available steps produces no halting result, even if the current instruction would accept or reject; exhausting the allotted steps before a halting instruction likewise gives no halting result, which does not satisfy the asserted correctness condition. Accept returns verdict true and reject returns verdict false, each with the memory at that step. There is no further requirement on the final memory because the output predicate for this problem is identically true. All natural sizes are included: for n=0n=0n=0 there is the unique empty input and its magnitude hypothesis is vacuous; for n=1n=1n=1 every admitted value has absolute value at most 111; and for n=0,1,2n=0,1,2n=0,1,2 a triple of distinct positions does not exist, so every admitted input must halt with rejection. The displayed time inequality places no condition on T(0)T(0)T(0) or T(1)T(1)T(1), although the halting requirement still applies to them; it does apply to n=2n=2n=2. When κ=0\kappa=0κ=0, n0=1n^0=1n0=1, including 00=10^0=100=1, so the nonempty admitted inputs contain only integers from {−1,0,1}\{-1,0,1\}{−1,0,1}; when n=0n=0n=0 and κ>0\kappa>0κ>0, 0κ=00^\kappa=00κ=0, still with an empty input. Neither bbb nor KKK is explicitly required to be positive. At sizes 000 and 111 the width lower bound is bbb; if b=0b=0b=0, every natural width, including W=0W=0W=0, is among the required widths, and in width zero the size, all input words, and the instruction's word for 111 are all zero. No separate hypothesis requires the size or the input integers to be representable without wrapping at a required width.

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

    Confirmed by the moderator at approval.

  • Endorsed by Yuxuan Xu · Oct 14, 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