Choosing the modulus in the Chan–He reduction #
The deterministic reduction from 3SUM to Convolution-3SUM after [ChanHe2020, Theorem 5.1]
hashes the numbers by x ↦ x mod pq. It finds the two primes p and q by exhaustive search
among the primes up to m = mPar n U. Both searches succeed and leave few elements badly hashed.
- An ordered pair of distinct elements of a set
Scollides moduloMifMdivides their difference;coll S Mcounts these ordered pairs. An element that collides with another one is heavy. There are at most as many heavy elements as colliding pairs (card_heavy_le_coll). The count is determined by the sizes of the residue classes (coll_eq_sum); the proofs below do not need this, a program that computes the count does. - A nonzero difference has at most
Λ = labelBits Uprime divisors. Summed over the candidatesqin the setQof primes, the pairs that collide moduloM₀ qnumber at mostΛtimes those that collide moduloM₀(sum_coll_mul_le). - Finite Markov and union bounds, as used in [CH20], show that some candidate is, for each
of the three sets, at most three times as bad as the average
(
Finset.exists_forall_mul_card_le_mul_sum,exists_prime_coll_le). So both searches succeed (firstP_spec,secondP_spec), and the moduluspqleaves at most9Λ²|S|²/|Q|²colliding pairs in each setS(modulus_spec). - There are at least
wPar n Uprimes up tomPar n U(wPar_le_card_primesLE, from the bound2^m ≤ (m + 1) lcm(1, …, m)of Mathlib). With that many candidates a setShas at most|S|²/(2n)heavy elements (card_heavy_modulus_le,le_card_primesLE_mPar_sq).
Directly adapted from Collisions.lean at the pinned
anthropics/formal-math@16a5ce41304fcdaea4e0be7c132e1c361dc26da5.
Main results #
modulus_spec,card_heavy_modulus_le: successful searches and quadratic shrinking.
References #
- T. M. Chan and Q. He, Reducing 3SUM to Convolution-3SUM, Theorem 5.1.
Colliding pairs and heavy elements #
Double counting. Summed over the candidates q ∈ Q, the pairs that collide modulo M₀ q
number at most labelBits U times those that collide modulo M₀: such a pair collides modulo
M₀, and q divides its difference. Coprimality of q and M₀ is not used, so the two primes
of a modulus are allowed to coincide.
The two searches succeed #
Both searches succeed, and the modulus leaves at most 9Λ²|S|²/|Q|² colliding pairs in each of
the three sets. (A search that fails returns 1, which is not in Q.)
With at least √(18n) Λ primes to choose from, each of the three sets S has at most
|S|²/(2n) heavy elements. This is why the sizes of the sets fall doubly exponentially along the
recursion.