A physical Light routine builds all 3SUM target indicators from two bounded integer arrays
ProvedThreeSumFuture.light_dense_pair_producer3sumalgorithmsleanword-ram
Given two unsorted arrays of nonnegative integer keys below L=2^k, construct a finite Light routine that physically materializes a signed integer for every target in [0,2L). That integer is positive exactly when a pair of input keys has that sum. The routine preserves the caller memory below the output. Its step count is at most 24(nx+ny)+26L+2530·3^k+334, its high-water address is dst+12L, and the word and call-depth bounds are explicit. Repeated keys and empty arrays are allowed.
Preamble
import Theorems.Thm_ThreeSum_LightHistogram_histogram_meets import Theorems.Thm_ThreeSum_LightKaratsuba_meets import Mathlib.Algebra.Polynomial.Coeff import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity import Mathlib.Tactic.Ring open Light ThreeSum
Formal statement
theorem ThreeSumFuture.light_dense_pair_producer :
∀ hist mul : ℕ, ∃ stmt : Stmt,
∀ {P : Program} {entry half linear fill d : ℕ} {lim : Limits}
(self : P[entry]?=some stmt)
(histOK : P[hist]?=some (LightHistogram.histogramBody fill))
(procs : LightKaratsuba.Procs P mul half linear fill)
(μ : ℕ → ℤ) (x y : ℕ → ℕ) (sx nx sy ny k dst : ℕ)
(hsrcX : sx+nx≤dst) (hsrcY : sy+ny≤dst)
(hX : ∀ i<nx, μ (sx+i)=(x i:ℤ)) (hY : ∀ j<ny, μ (sy+j)=(y j:ℤ))
(hx : ∀ i<nx, x i<2^k) (hy : ∀ j<ny, y j<2^k)
(hspace : dst+12*2^k≤lim.space) (hw : (lim.space:ℤ)≤lim.word)
(hword : (LightKaratsuba.wordBound (2^k) (max nx ny):ℤ)≤lim.word)
(hd : d+k+2≤lim.depth),
Meets lim P entry d [sx,nx,sy,ny,2^k,dst] μ
(24*(nx+ny)+26*2^k+2530*3^k+334)
(fun _ ν => Kept μ ν dst ∧ ∀ t<2*2^k,
(0<ν (dst+t) ↔ ∃ i<nx, ∃ j<ny, x i+y j=t)) := by sorrySource
A bounded-coordinate construction for the uniform colored 3SUM indicator obligation https://prove2.me/theorems/37eba3bc-5d40-51d7-ab0b-b67f7c509af4. The histogram and Karatsuba routines are from the existing 3SUM implementation, and Light is due to Anthropic. Upstream source: https://github.com/Wang-jiong-han/3sum-weighted-cache/tree/e1ae71db2231f172c6541820e2ce0a54aa14fc64/Submission/ThreeSum.