A linear-time Light procedure writes a complete 3SUM certificate from target membership counts
ProvedThreeSumFuture.light_physical_singleton_reportFor any address of the four-cell Light store procedure, there is one finite statement that can be installed at any entry of an enclosing program. It takes two readable integer arrays of length m and an output address. The first array lists the targets. The second gives nonnegative integers, positive exactly at the targets represented as a sum of one element from each operand. The two input regions may independently lie before or after the writable region. Assuming the specified intermediate products, running sums and addresses fit the machine bounds, the procedure writes the complete cap-one grouped 3SUM report with zero exceptional owners, returns its verdict, and preserves all memory outside the 1+4m output cells. It takes at most 300m+150 steps. Empty lists and repeated target values are included.
import Definitions.Def_Submission_ThreeSum_LightArgumentTable import Definitions.Def_ThreeSumFuture_GroupedMomentReport import Mathlib.Algebra.BigOperators.Group.Finset.Basic open Light ThreeSum ThreeSumFuture.GroupedMomentReport open scoped BigOperators
theorem ThreeSumFuture.light_physical_singleton_report (write : ℕ) : ∃ stmt : Stmt,
∀ {P : Program} {entry depth ta ca dst : ℕ} {lim : Limits},
P[entry]?=some stmt → P[write]?=some (LightArgumentTable.stores 0 4) →
∀ (left right targets : List ℤ) (initial : ℕ → ℤ) (z : ℕ → ℤ) (c : ℕ → ℕ),
(∀ i : Fin targets.length, z i=targets.get i) →
(∀ i : Fin targets.length, 0<c i ↔ pairHit left right (targets.get i)) →
(lim.space:ℤ)≤lim.word → depth<lim.depth → (4:ℤ)≤lim.word →
(ta+targets.length≤dst ∨ dst+1+4*targets.length≤ta) →
(ca+targets.length≤dst ∨ dst+1+4*targets.length≤ca) →
ta+targets.length≤lim.space → ca+targets.length≤lim.space →
dst+1+4*targets.length≤lim.space →
(∀ j<targets.length, initial (ta+j)=z j) →
(∀ j<targets.length, initial (ca+j)=(c j:ℤ)) →
(∀ j<targets.length, |z j|≤lim.word) →
(∀ j<targets.length, (c j:ℤ)≤lim.word) →
(∀ j<targets.length, |(c j:ℤ)*z j|≤lim.word ∧ |(c j:ℤ)*z j*z j|≤lim.word) →
(∀ j≤targets.length, ((∑ i ∈ Finset.range j, c i : ℕ):ℤ)≤lim.word) →
Meets lim P entry depth [ta,ca,targets.length,dst] initial (300*targets.length+150)
(fun r out => Certificate left right targets 1 dst lim.space 0 out r ∧
SameOutside initial out dst (1+4*targets.length)) := by sorry