Documentation

Complexity.Algorithms.ThreeSum.ChanHe.Defs

Core Chan–He hashing and recursion data #

Direct adaptation of PaperStatements.lean, lines 1242–1365, from anthropics/formal-math@16a5ce41304fcdaea4e0be7c132e1c361dc26da5. These are finite mathematical constructions, not a native RAM implementation.

Main definitions #

References #

Collisions and heavy elements #

The number of ordered pairs of distinct elements of S that are congruent modulo M.

Instances For

    The elements of S that share their residue modulo M with another element of S. They play the role of the bad elements of [CH20]. The elements alone in their residue class modulo M are called light below; they play the role of the good elements of [CH20].

    Instances For

      The arrays of one node #

      The elements of S with remainder r modulo M.

      Instances For

        The array of the light elements of S. Cell i holds the element of the bucket of i if that bucket has exactly one element, and the padding value pad otherwise.

        Instances For

          The padding value 2U + 1. It is too large to take part in a solution among numbers of absolute value at most U.

          Instances For

            The array made from the first or the second set of a node.

            Instances For

              The third array of a node. A light element c of S is written as -c into the two cells r and r + M, where r is the remainder of -c. All other cells, and all cells from 2M on, hold -pad U.

              Instances For

                The choice of the modulus #

                The least element of a finite set of natural numbers, and 1 if the set is empty.

                Instances For
                  def Cslib.Algorithms.ThreeSum.ChanHe.firstP (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) :

                  The first prime: the least p in Q modulo which each of the three sets has at most 3Λ|S|²/|Q| colliding pairs. Here and below, Q is the set of candidate primes, and Λ bounds how many of them divide a nonzero difference of two elements. reduction takes the primes up to mPar n U for Q, and labelBits U for Λ.

                  Instances For
                    def Cslib.Algorithms.ThreeSum.ChanHe.secondP (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) (p : ℕ) :

                    The second prime, given the first: the least q in Q such that, in each of the three sets, at most the fraction 3Λ/|Q| of the pairs that collide modulo p still collide modulo pq.

                    Instances For
                      def Cslib.Algorithms.ThreeSum.ChanHe.modulus (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) :

                      The modulus of a node: the product of the two primes.

                      Instances For

                        The recursion tree #

                        A node of the recursion tree: three sets and the modulus chosen for them.

                        Instances For

                          The nodes on the first f levels of the recursion tree with root (S₁, S₂, S₃); for f = 0 there are none. A triple with an empty set is not a node and has no children. Any other triple is a node, and each of its three children replaces one of the sets by its heavy elements.

                          Instances For

                            The parameters #

                            ⌈log₂(⌊log₂ n⌋ + 2)⌉. In the recursion tree of reduction n U, for three sets of at most n ≥ 1 elements each, all of absolute value at most U (the hypotheses of the library's lemma ChanHe.reduction_correct), a set is empty after this many replacements by its heavy elements.

                            Instances For

                              The number of levels of the recursion tree that are built. Under the hypotheses named at height, each of the three sets of a node has been replaced at most height n - 1 times, because it is not empty. So a node has at most 3 (height n - 1) nodes above it.

                              Instances For

                                The number of primes that we want to choose from.

                                Instances For

                                  The bound m on the primes. There are at least wPar n U primes up to m (the library's lemma ChanHe.wPar_le_card_primesLE).

                                  Instances For

                                    The reduction for three sets #

                                    The reduction for three sets. Here n is an upper bound on the sizes of the three sets and U on the absolute values of their elements; both stay fixed through the recursion. The result is a list of nodes. The Convolution-3SUM instance of a node ν consists of the arrays arrXY ν.S₁ ν.M U, arrXY ν.S₂ ν.M U and arrZ ν.S₃ ν.M U, read at any length N ≥ 2 * mPar n U ^ 2.

                                    Instances For

                                      The three-array convolution instance attached to a recursion node.

                                      Instances For