Distinct-position 3SUM as a finite list of three-set problems #
Adapted from Anthropic's FromNumbers.lean, at
formal-math@16a5ce41304fcdaea4e0be7c132e1c361dc26da5. The three-set predicate and magnitude
bound come from its Definitions.lean (Definition 2.1 of [CH20]); the label,
splitting and multiplicity definitions come from PaperStatements.lean.
These elementary frontend steps are additions in that formalization, not the prime-modulus and heavy-element recursion of [ChanHe2020, Theorem 5.1]. They preserve multiplicities at distinct positions. No native preprocessing or charged running-time bound is proved here.
Main definitions #
HasThreeSetSolution: zero-sum elements selected from three finite sets.Bdd: an absolute-value bound on a finite set of integers.labelBits: a sufficient number of binary label digits.IsInput,inputs: the frontend relation and its finite executable enumeration.
Main results #
threeSum_iff_exists_mem_inputs: distinct-position correctness for the finite list.length_inputs: exactly2 * labelBits (2U)^2 + 2entries, counting repetitions.IsInput.bounds: the cardinality and magnitude bounds on each entry.
References #
A three-set solution remains a solution when each set grows.
The number of bits sufficient for all labels in [0, 2U].
Instances For
The label of an element of [-U, U]: its value shifted into [0, 2U].
Instances For
The set {0} if 0 occurs at three positions or more, and the empty set otherwise. This is the
one place where the reduction decides a case by itself: 0 occurs at three positions exactly when
0, 0, 0 is a solution.
Instances For
A set has three distinct elements with sum 0 iff one of the 2 (labelBits U)² three-set inputs,
obtained by splitting it by two binary digits, has a solution.
Positions instead of values: solutions that repeat a value #
Three different positions with sum 0: either the three values are distinct, or the solution repeats a value.
There is a solution that repeats a value iff one of two three-set inputs has a solution. The
first input leaves the search for -2a to the reduction. The second already contains the answer
for 0, 0, 0; see zeroSet.
The three-set inputs of the frontend.
- split {n U : ℕ} {x : Fin n → ℤ} {β β' : ℕ} (hβ : β < labelBits (2 * U)) (hβ' : β' < labelBits (2 * U)) (v : Bool) : IsInput U x (splitA (2 * U) β v (Finset.image x Finset.univ)) (splitB (2 * U) β β' v false (Finset.image x Finset.univ))
(splitB (2 * U) β β' v true (Finset.image x Finset.univ))
The set of values, split by two binary digits: for the solutions with three distinct values.
- twice {n U : ℕ} {x : Fin n → ℤ} : IsInput U x (twiceSet x) {0} (Finset.image x Finset.univ)
For the solutions
a, a, -2a. - zero {n U : ℕ} {x : Fin n → ℤ} : IsInput U x (zeroSet x) {0} {0}
For the solution
0, 0, 0.
Instances For
Each frontend input consists of sets of at most n elements, bounded in magnitude by 2U.
The hypothesis 1 ≤ n accounts for the singleton {0} used by the repeated-value cases.