3SUM in word-RAM steps
ProvedTrulySubquadratic3SUM.threeSum_199913For 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 time 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_199913 :
EndStatement.ThreeSum.SolvedInTime 1.99913 := by sorryRead-back
What the Lean code literally says, in plain math · Codex
For every natural number , including zero, there exist a finite deterministic program , natural numbers (not required to be positive), and a function such that for every natural number , corresponding to the exact rational exponent , and the following holds for every natural number , every integer array with at every position, and every natural word width , where and for . Starting at program position zero with in memory cell zero, in cell , and zero in every other integer-addressed cell, with all stored values reduced modulo , halts within steps, including its halting step, and returns a Boolean verdict and a final memory; its verdict is true if and only if there exist three pairwise distinct indices for which as an equality of integers. The array values themselves need not be distinct, and there is no additional condition on the final memory. The permitted program instructions are assignment of the constant to a fixed integer-addressed cell; addition, subtraction, or multiplication of two fixed cells into a fixed cell, with arithmetic modulo ; indirect loading into a fixed cell from the address stored in a fixed cell; indirect storing of a fixed cell's value at the address stored in a fixed cell; a jump to a fixed natural-numbered program position if the signed value in a fixed cell is negative; acceptance; and rejection. Indirect addresses and negativity tests use the signed interpretation of the -bit word; each instruction costs one step, execution proceeds to the next position unless a conditional jump is taken or the program halts, and a position past the program's end rejects in one step. The same must work for all these , arrays, and word widths, although they may depend on . Correctness and termination also apply when or , although the displayed time inequality is required only for ; every permitted input with , including the empty input, must be rejected. If the chosen is zero, the word-width quantifier includes .
Confirmed by the moderator at approval.