3SUM in word-RAM steps
ProvedTrulySubquadratic3SUM.threeSum_1999074For every fixed , there exist a finite deterministic word-RAM program , a natural constant , and a step bound that work for every input size and every word width . On integers of absolute value at most , the program halts within steps and accepts exactly when three pairwise distinct indices have values summing to zero. Repeated values at distinct positions are allowed, and inputs with fewer than three positions are rejected. The bound is : precisely, there is such that for every .
import Definitions.Def_TrulySubcubicAPSP_SourceSpecification set_option autoImplicit false set_option relaxedAutoImplicit false
theorem TrulySubquadratic3SUM.threeSum_1999074 :
EndStatement.ThreeSum.SolvedInTime 1.999074 := by sorryRead-back
What the Lean code literally says, in plain math · Codex
For every natural number , including , there exist a finite program , a natural number , and a function such that there exists a natural number with for every natural number , and such that the following correctness and termination condition holds. For every natural number , every integer sequence satisfying for every , and every natural-number word width , run from instruction position zero with memory addressed by all integers and containing -bit words: cell initially contains reduced modulo , cell contains reduced modulo for , and every other cell, including all negative-address cells, contains zero. Here is the natural-number base-two logarithm, equal to for and to zero at . There exist a Boolean verdict and a final memory such that execution halts with that verdict and memory within steps, with the halting instruction counted, and the verdict is true if and only if there exist satisfying , , , and as an equality of integers. There is no condition on the final memory or on an output array. The instructions allowed in are: put the word representing into a fixed integer-addressed cell; add, subtract, or multiply the words in two fixed cells and write the result to a fixed cell; load indirectly from the address obtained by interpreting a word in a fixed cell as signed; store indirectly at the signed address in a fixed cell; branch to a fixed natural-number instruction position if the signed word in a fixed cell is negative; accept; and reject. Word arithmetic is modulo , and signed interpretation uses two's-complement values. The writing instructions advance to the next instruction; a negative-test branch jumps to its target exactly when its test is negative and otherwise advances to the next instruction; reaching any instruction position outside the finite program executes reject. Each executed instruction costs one step, accept and reject terminate with true and false respectively, and a zero step budget yields no terminating result even at a halting instruction. The program, , the time function and the constant may depend on but must work for every allowed input and every qualifying width ; cannot depend on or on the entries of the input. The exponent is the exact rational number , and the displayed integer-power inequality is the entire asserted asymptotic bound: it applies for all , with no positive lower bound on the existential natural number . Termination and correctness also apply at and , although the asymptotic inequality does not constrain their times; all inputs must be rejected because three distinct positions do not exist. At the bound is , including the convention ; at the input-entry bound is vacuous because the sequence is empty. No hypothesis requires or : if the selected is zero, width zero is included, in which case every word and its signed value is zero. The input size and entries are encoded modulo the chosen width, rather than assumed separately to fit in that width.
Confirmed by the moderator at approval.