An upper bound for the size of $s$-distance sets in real algebraic sets

In a recent paper Petrov and Pohoata developed a new algebraic method which combines the Croot-Lev-Pach Lemma from additive combinatorics and Sylvester's Law of Inertia for real quadratic forms. As an application, they gave a simple proof of the Bannai-Bannai-Stanton bound on the size of $s$-distance sets (subsets $\mbox{$\cal A$}\subseteq {\mathbb R}^n$ which determine at most $s$ different distances). In this paper we extend their work and prove upper bounds for the size of $s$-distance sets in various real algebraic sets. This way we obtain a novel and short proof for the bound of Delsarte-Goethals-Seidel on spherical $s$-distance sets and a generalization of a bound by Bannai-Kawasaki-Nitamizu-Sato on $s$-distance sets on unions of spheres. In our arguments we use the method of Petrov and Pohoata together with some Gr\"obner basis techniques.


Introduction
Let A ⊆ R n be an arbitrary set. Denote by d(A) the set of non-zero distances among the points of A: d(A) := {d(p 1 , p 2 ); p 1 , p 2 ∈ A, p 1 = p 2 }.
An s-distance set is a subset A ⊆ R n such that |d(A)| ≤ s. Here we mention just two theorems from the rich area of sets with few distances, more information can be found for example in [16], [3]. Bannai, Bannai and Stanton proved the following upper bound for the size of an s-distance set in [4,Theorem 1]. Theorem 1.1 Let n, s ≥ 1 be integers and suppose that A ⊆ R n is an sdistance set. Then
Delsarte, Goethals and Seidel investigated s-distance sets on the unit sphere S n−1 ⊆ R n . These are the spherical s-distance sets. They proved a general upper bound for the size of a spherical s-distance set in [12]. In their proof they used Delsarte's method (see [3,Subsection 2.2]). Theorem 1.2 (Delsarte, Goethals, and Seidel) Let n, s ≥ 1 be integers and suppose that A ⊆ S n−1 is an s-distance set. Then
Before stating our results, we introduce some notation. Let F be a field. In the following S = F[x 1 , . . . , x n ] = F [x] denotes the ring of polynomials in commuting variables x 1 , . . . , x n over F. Note that polynomials f ∈ S can be considered as functions on F n . For a subset Y of the polynomial ring S and a natural number s we denote by Y ≤s the set of polynomials from Y with degree at most s. Let I be an ideal of S = F [x]. The (affine) Hilbert function of the factor algebra S/I is the sequence of non-negative integers h S/I (0), h S/I (1), . . ., where h S/I (s) is the dimension over F of the factor space F[x 1 , . . . , x n ] ≤s /I ≤s (see [9,Section 9.3]). Our main technical result gives an upper bound for the size of an s-distance set, which is contained in a given real algebraic set. [x] be an ideal in the polynomial ring, and let A ⊆ R n be an s-distance set such that every polynomial from I vanishes on A . Then The proof is based on Gröbner basis theory and an improved version of the Croot-Pach-Lev Lemma (see [10] Lemma 1) over the reals. Petrov and Pohoata proved this [22,Theorem 1.2] and used it to give a new proof of Theorem 1.1. We generalize their result to give a new upper bound for the size of an s-distance set, which is contained in a given affine algebraic set in the real affine space R n .
We give several corollaries, where Theorem 1.3 is applied to specific ideals of the polynomial ring R [x], the first ones being the principal ideals I = (F ), with F ∈ R [x].
For example, when n = 2, then F defines a plane curve of degree d. Then for s ≥ d we obtain In particular, when F (x, y) = y 2 − f (x) gives a Weierstrass equation of an elliptic curve, then |A| ≤ 3s for s ≥ 3.

Remark.
We can now easily derive Theorem 1.2 for s > 1. Indeed, consider the real polynomial of degree 2 which vanishes on S n−1 . Corollary 1.4 and the hockey-stick identity gives Next, assume that V = ∪ p i=1 S i , where the S i are spheres in R n . E. Bannai, K. Kawasaki, Y. Nitamizu, and T. Sato proved the following result in [5,Theorem 1] for the case when the spheres S i are concentric. We have a much shorter approach to the same bound, in a more general setting, without the assumption on the centers. Corollary 1.5 Let A be an s-distance set on the union V of p spheres in R n . Then We can easily apply Theorem 1.3 to obtain an upper bound for the size of s-distance sets in boxes. Corollary 1.6 Let B ⊆ R n be a box as above, and A ⊆ B an s-distance set. Then Remark. In the special case q = 2 we have hence we obtain the upper bound In the case when T i = T for 1 ≤ i ≤ n and |T | = 2, the Euclidean distance is essentially the same as the Hamming distance. For this case (1) was proved by Delsarte [11], see also [2, Theorem 1].
Remark. The bound is sharp, when q = 2, n = 2m and s = m. Then the 0,1 vectors of even Hamming weight give an extremal family A ⊆ R n .
Remark. The bound of Corollary 1.6 can be nicely formulated in terms of extended binomial coefficients (see [13,Example 8] or [8,Exercise 16]): Here n j q is an extended binomial coefficient giving the number of restricted compositions of j with n terms (summands), where each term is from the set {0, 1, . . . , q − 1}. In particular, we have n j 2 = n j . Remark. In [18] a weaker, but similar upper bound was given for the size of s-distance sets in boxes: The bound appearing in Corollary 1.6 presents an improvement by a factor of 2. Let α 1 , . . . , α n be n different elements of R, and X n = X n (α 1 , . . . , α n ) ⊆ R n be the set of permutations of α 1 , . . . , α n , where each permutation is considered as vector of length n. It was proved in [19, Section 2] that for s ≥ 0 where I n (i) is the number of permutations of n symbols with precisely i inversions. Using this, Theorem 1.3 implies the following bound: In [21, Section 5.1.1] Knuth gives a generating function for I n (i) and some explicit formulae for the values I n (i), i ≤ n.
Let 0 ≤ d ≤ n be integers and Y n,d ⊆ R n denote the set of 0,1-vectors of length n which have exactly d coordinate values of 1. The following (sharp) bound was obtained by Ray-Chaudhuri and Wilson [23,Theorem 3], formulated in terms of intersections rather than distances.
In some cases data about the complexification of a real affine algebraic set can be used to give a bound. We give next a statement of this type. For a subset X ⊆ F n of the affine space we write I(X) for the ideal of all polynomials f ∈ F [x] which vanish on X. Corollary 1.9 Let V ⊆ C n be an affine variety such that the projective closure V of V has dimension d and degree k. Suppose also that the ideal I(V ) of V is generated by polynomials over R. Let A ⊆ V ∩ R n be an s distance set. Then we have For instance, when in Corollary 1.9 the projective variety V is a curve of degree k, then the bound is ks + b for large s, where b is an integer. More specifically, when V is an elliptic curve such that V ⊆ C 2 is the set of zeroes of is a cubic polynomial without multiple roots, then in fact, the preceding bound becomes |A| ≤ 3s + b for s large (see also the remark after Corollary 1.4).
The rest of the paper is organized as follows. Section 2 contains some preliminaries on Gröbner bases, Hilbert functions, and related notions. Section 3 contains the proofs of the main theorem and the proof of the corollaries.

Preliminaries
A total ordering ≺ on the monomials x i 1 1 x i 2 2 · · · x in n composed from variables x 1 , x 2 , . . . , x n is a term order, if 1 is the minimal element of ≺, and uw ≺ vw holds for any monomials u, v, w with u ≺ v. Two important term orders are the lexicographic order ≺ l and the deglex order ≺ dl . We have n iff i k < j k holds for the smallest index k such that i k = j k . As for the deglex order, we have u ≺ dl v iff either deg u < deg v, or deg(u) = deg(v), and u ≺ l v. Let ≺ be a fixed term order. The leading monomial lm(f ) of a nonzero polynomial f from the ring S = F [x] is the largest (with respect to ≺) monomial which occurs with nonzero coefficient in the standard form of f .
Let I be an ideal of S. A finite subset G ⊆ I is a Gröbner basis of I if for every f ∈ I there exists a g ∈ G such that lm(g) divides lm(f ). It can be shown that G is in fact a basis of I. A fundamental result is (cf. [7, Chapter 1, Corollary 3.12] or [1, Corollary 1.6.5, Theorem 1.9.1]) that every nonzero ideal I of S has a Gröbner basis with respect to ≺.
A monomial w ∈ S is a standard monomial for I if it is not a leading monomial of any f ∈ I. Let Sm(≺, I, F) denote the set of all standard monomials of I with respect to the term-order ≺ over F. It is known (see [7, Chapter 1, Section 4]) that for a nonzero ideal I the set Sm(≺, I, F) is a basis of the factor space S/I over F. Hence every g ∈ S can be written uniquely as g = h + f where f ∈ I and h is a unique F-linear combination of monomials from Sm(≺, I, F).
If X ⊆ F n is a finite set, then an interpolation argument gives that every function from X to F is a polynomial function. The latter two facts imply that where I(X) is the ideal of all polynomials from S which vanish on X, and ≺ is an arbitrary term order. The initial ideal in(I) of I is the ideal in S generated by the set of mono- It is easy to see [9, Propositions 9.3.3 and 9.3.4] that the value at s of the Hilbert function h S/I is the number of standard monomials of degree at most s, where the ordering ≺ is deglex: In the case when I = I(X) for some X ⊆ F n , then h X (s) := h S/I (s) is the dimension of the space of functions from X to F which are polynomials of degree at most s.
Next we recall a known fact about the Hilbert function. It concerns the change of the coefficient field. Let F ⊂ K be fields and let I ⊆ F [x] be an ideal, and consider the corresponding ideal J = I · K[x] generated by I in K [x].
For the convenience of the reader we outline a simple proof.
Proof. It follows from Buchberger's criterion [9, Theorem 2.6.6] that a deglex Gröbner basis of I in F [x] will be a deglex Gröbner basis of J in K [x], implying that the initial ideals in(I) and in ( If 0 ≤ s < d, then Proof. By definition Using the fact that F [x] is a domain, we see that the dimension of the latter subspace is The statement now follows from the fact that if s ≥ d, then This matrix corresponds to a bilinear form of F A by the formula ,  Proof. We follow the argument of Theorem of [22,Theorem 1.1]. Let A ⊆ R n denote an s-distance set. Recall that d(A) denotes the set of (nonzero) distances among points of A. Define the 2n-variate polynomial by: Then we can apply Theorem 3.1 for p(x, y) whose degree is 2s. The matrix M(A, p) is a positive diagonal matrix, giving that It follows from Theorem 3.1 (ii) that  The preceding two equations imply that (3) and (2)

Proofs for the Corollaries
by Proposition 2.2.
Proof of Corollary 1.5. It is easy to verify that Let V = ∪ p i=1 S i , and assume, that the center of the sphere S i is the point (a 1,i , . . . , a n,i ) ∈ R n and the radius of S i is r i ∈ R for i = 1, . . . , p. Next consider the polynomials When s < 2p, the bound follows from the Bannai-Bannai-Stanton theorem.
Proof of Corollary 1.6: It is well-known and easily proved that the following set of polynomials is a (reduced) Gröbner basis of the ideal I(B) (with respect to any term order): This readily gives the (deglex) standard monomials for I(B): Sm(≺ dl , I(B), R) = |{x α 1 1 · . . . · x αn n : 0 ≤ α i ≤ q − 1 for each i}|.
It follows from Theorem 1.3 and equation (3) that This proves the statement.