Nearly k-Distance Sets

We say that a set of points \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S\subset {{\mathbb {R}}}^d$$\end{document}S⊂Rd is an \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon $$\end{document}ε-nearly k-distance set if there exist \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1\le t_1\le \ldots \le t_k$$\end{document}1≤t1≤…≤tk, such that the distance between any two distinct points in S falls into \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$[t_1,t_1+\varepsilon ]\cup \cdots \cup [t_k,t_k+\varepsilon ]$$\end{document}[t1,t1+ε]∪⋯∪[tk,tk+ε]. In this paper, we study the quantity \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} M_k(d) = \lim _{\varepsilon \rightarrow 0}\max {\{|S|:S\,\text { is an}\, \varepsilon \text {-nearly}\, k\text {-distance set in}\,{{\mathbb {R}}}^d\}} \end{aligned}$$\end{document}Mk(d)=limε→0max{|S|:Sis anε-nearlyk-distance set inRd}and its relation to the classical quantity \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_k(d)$$\end{document}mk(d): the size of the largest k-distance set in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\mathbb {R}}}^d$$\end{document}Rd. We obtain that \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_k(d)=m_k(d)$$\end{document}Mk(d)=mk(d) for \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k=2,3$$\end{document}k=2,3, as well as for any fixed k, provided that d is sufficiently large. The last result answers a question, proposed by Erdős, Makai, and Pach. We also address a closely related Turán-type problem, studied by Erdős, Makai, Pach, and Spencer in the 90s: given n points in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\mathbb {R}}}^d$$\end{document}Rd, how many pairs of them form a distance that belongs to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$[t_1,t_1+1]\cup \cdots \cup [t_k,t_k+1]$$\end{document}[t1,t1+1]∪⋯∪[tk,tk+1], where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$t_1,\dots ,t_k$$\end{document}t1,⋯,tk are fixed and any two points in the set are at distance at least 1 apart? We establish the connection between this quantity and a quantity closely related to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_k(d-1)$$\end{document}Mk(d-1), as well as obtain an exact answer for the same ranges k, d as above.


Introduction
Let us start with some definitions.We call any point set that determines at most  distances a -distance set.We denote by   () the cardinality of the largest -distance set in R  .A balanced complete -partite graph on  vertices is a graph whose vertices are partitioned into  groups of size ⌊/⌋ or ⌈/⌉, and in which two vertices are connected by an edge if and only if they belong to different groups.We denote by  (, ) the number of edges in a balanced complete -partite graph on  vertices.A set  ⊆ R  is separated if ‖ 1 −  2 ‖ ≥ 1 for any  1 ,  2 ∈  with  1 ̸ =  2 .Let us formulate the main result of this paper.
Theorem 1.The following holds for  ≤ 3 and any , and for any fixed  and  ≥  0 ().
Theorem 1 (ii) for  = 1 was proved by Erdős, Makai, Pach, and Spencer [11] (see Theorem 3 below).For  = 2, it was shown by Erdős, Makai, and Pach [10] in a slightly weaker form (see Theorem 6 below).Although (i) and (ii) are strongly related, the "max clique" problem in (i) has not been addressed before.Theorem 1 is a combination of Theorems 10 and 13 below.
In the long introductory section that follows, we tried to address several points: First, we relate the study of "nearly-equal distances" to that of "equal distances".The history of the latter is summarised in the next subsection, and the relation between the two notions is developed in Section 1.4, in which we give constructions of nearly -distance sets and compare them with the known constructions of -distance sets.
Second, we relate the older Turán-type problem on the number of "nearly-equal distances" to the proposed problem of determining the largest nearly -distance set.We give the history of this Turán-type problem in Section 1.2, introduce the study of nearly -distance sets in Section 1.3, and establish the first result that relates the two questions in Section 1. 4.
Third, we introduce some of the more technical, but important, notions used in the proofs in Section 2, and in particular -flat nearly -distance sets, defined in Section 1.3.1.It is via the notion of -flat nearly -distance sets that we actually establish the link between the "nearly -distance set" problem and the Turán-type problem.
Our main results are presented in Section 1.5, with their proofs in Section 2.

Equal distances
In 1946, Erdős [6] asked the following two questions, which greatly influenced the course of discrete geometry.Take a set  of  points on the plane.
Question 1.What is the smallest number of distinct distances that  can determine?
Question 2. What is the maximum number of equal distances that  can determine?
These questions have a rich history, and we refer the reader to the book of Brass, Moser and Pach [4] and the references therein.In the recent years, the development of algebraic methods in discrete geometry lead to a breakthrough of Guth and Katz [16], who showed that the quantity in the first question is Ω(/ log ), which almost matches Erdős' upper bound (/ log 1/2 ).For R  with  ≥ 3 Solymosi and Vu [28] proved that the quantity in the first question is Ω (︀  (2/)(+1)/(+2) )︀ , while Erdős proved the close and conjecturably sharp upper bound ( 2/ ).
Even though Questions 1 and 2 seem to have exactly the same flavour, (which is backed by, e.g., the fact that upper bounds in Question 2 imply lower bounds in Question 1), much less is known about Question 2. The best upper bound ( 4/3 ) is due to Spencer, Szemerédi, and Trotter [26], and the best lower bound is due to Erdős is Ω( 1+/ log log  ) for some  > 0. Interestingly, this problem becomes much simpler in dimensions  ≥ 4: there are point sets that determine quadratically many unit distances.(Brass [3] and Van Wamelen [30] determined the maximum number of unit distances exactly for  = 4 and Swanepoel [29] for even  ≥ 6 and large , respectively.)Stated slightly differently, Question 1 asks to determine   (2).The bounds mentioned above give Ω( log 1/2 ) ≤   (2) ≤ ( log ).In 1947, Kelly [17] showed that  2 (2) = 5.Larman, Rogers, and Seidel [22] showed that  2 () ≤ 1 2 ( + 1)( + 4).Several years later, Bannai, Bannai, and Stanton [1] and independently Blokhuis [2] found the following better bound, which additionally works for any : There is the following very natural construction of a -distance set in R  if  ≤  + 1: in R +1 , take all vectors in {0, 1} +1 with exactly  many 1's.Then they lie on a sphere in the hyperplane ∑︀   =  and determine only  + 1 distinct scalar products (and thus only  distinct distances).This gives the lower bound We will refer to (1) and (2) many times in the proofs.Table 1, taken from a paper of Szöllősi and Östergård [27], summarises the best known lower bounds on (and in some cases exact values of)   () for small values of  and .Note also that it is easy to see that for any  we have  1 () =  + 1 and for any  we have   (1) =  + 1.

Nearly equal distances
Most of the results on -distance sets use proofs with an algebraic flavour and often use results on incidences of points and surfaces.In the 90s, Erdős, Makai, Pach, and Spencer [11] proposed the following variant of the problem, which is not of this type: given a set of  points on the plane, how many of the distances between the points could be nearly equal, that is, that fall into the interval [,  + 1] for some ?To avoid trivialities, we only consider separated sets.It turns out that the answer to this question is very different from the answer to Question 2: we can have as many as  2 nearly equal distances in a separated set of size 2.To see this, take 2 points of the form ( 1 ,  2 ), where  1 ∈ {0,  2 } and  2 ∈ {1, . . ., }.Then any distance between points with different  1 -coordinates is between  2 and √  4 +  2 <  2 + 1.This example turns out to be optimal.The following theorem was proved by Erdős, Makai, Pach, and Spencer [11].
Theorem 2 ( [11], Theorem 3).Let  be a separated set of  points in the plane.If  is sufficiently large, then, for every  > 0, the number of pairs of points in  whose distance lies in the interval [,  + 1] is at most ⌊ 2 /4⌋.This bound can be attained for every  ≥ (), where () is a suitable function of .
They have studied two natural types of generalisations: one deals with higher dimensions and the other with more intervals in which the distances may fall.Theorem 3 ([11], Theorem 5).Let  be a separated set of  points in R  .If  is sufficiently large, then for every  > 0, the number of pairs of points in  whose distance lies in the interval [,  + 1] is at most  (, ).This bound can be attained for every  ≥  0 (, ), where  0 (, ) is a suitable function of  and .
In the case of several intervals, Erdős, Makai, and Pach [9] proved the following theorem.

Theorem 4 ([9]
).Let  be a separated set of  points in the plane, and let  be a positive integer.Then for any  > 0 and sufficiently large  the following is true.For any  1 , . . .,   > 0, the number of pairs of points in  whose distance lies in This estimate is tight for every fixed  and for some  1 =  1 (, ), . . .,   =   (, ).
In [23] Makai, Pach and Spencer surveyed the results on this topic and also stated the following theorem that was supposed to appear in a follow-up paper by Erdős, Makai and Pach.
Theorem 5 (Theorem 2.4 in [23], stated without proof).Let  ≥ 2 be an integer and let  be a separated set of  points in R  .For any  > 0 and sufficiently large  the following is true.For any  1 ,  2 > 0 the number of pairs of points in  whose distance lies in This bound is asymptotically tight for some  1 =  1 () and  2 =  2 ().
The proof of this theorem was kept in the form of handwritten notes until recently, when Makai and Pach [10] placed on the arXiv a typed version of those notes (joint with Paul Erdős).There, they prove Theorem 5 in a stronger form.
[10], Theorem 2 also considered a less restrictive variant of the notion of nearly -distance sets.Let us denote by   () the maximum cardinality  such that for any  > 0 there exist  1 ≤ • • • ≤   and a set  ⊂ R  with || =  such that for any  1 ̸ =  2 ∈  we have In [10] they proved that   () = ( + 1)  , showing that "weakly" nearly -distance sets can be much bigger than -distance sets.

Nearly 𝑘-distance sets
We say that a separated set of points  is an -nearly -distance set with distances holds for any  1 ,  2 ∈  with  1 ̸ =  2 .By analogy with   (), for  ≥ 1 and  ≥ 0 let   () denote the largest number  such that for any  > 0 there exists an -nearly -distance set in R  of cardinality  . 1 Obviously,   () ≥   ().An expression equivalent to   () occurs in [10, page 19], where they speculate that "for k fixed, d sufficiently large probably   () =   ()."We confirm this later.
Note that the difficulty in relating the maximal cardinalities of -distance sets and nearly -distance sets lies in the fact that, in nearly -distance sets, distances of different order of magnitude may appear.If we additionally assume that  +1 ≤  for some universal constant  in the definition of nearly -distance sets, a compactness argument would immediately imply that   () equals this modified   () (see Lemma 15 below).
For ,  ≥ 1 let   (, ) denote the largest number  for which there is a separated set  ⊆ R  of  points and  real numbers is at least  .In these terms, Theorems 2-6 determine (or asymptotically determine) the quantity   (, ) for  = 1, 2 and  ≥ 2, as well as for  ≥ 1 and  = 2, provided that  is large enough.It is natural to state the following general problem.

Flat sets
A subspace of a Euclidean space means a linear subspace.A plane of a Euclidean space means an affine plane.
For reasons that appear to be technical, let us also introduce the following notions.We usually use the notation Γ (or Γ  ) to denote linear subspaces of R  , and Λ (or Λ  ) for affine planes.The angle between a vector  ̸ = 0 and a non-zero linear subspace Γ is the smallest angle that appears between  and the vectors in Γ ∖ {0}.For two points ,  ∈ R  we denote by  −  the vector pointing from  to .
For 1 ≤  ≤  ′ we say that a set of vectors  ⊆ R  ′ ∖ {0} is (, )-Flat if there exists a linear subspace Γ of dimension  such that the angle between any  ∈  and Γ is at most .(For  =  ′ this is considered to be true for any  ≥ 0.) If Γ is such subspace, we say that  is (, )-Flat with respect to Γ. Let  ⊆ R  ′ be a set of points and  be a point in  .We say that  is (, , )-flat (with respect to a linear -subspace then we define  to be (, 0, )-flat (for any  ∈  ) and (0, )-flat.
Surprisingly, the behaviour of   (, ) is asymptotically determined by the value of   () (see Proposition 8 and Theorem 12), thus the asymptotic solution of Problem 1 reduces to the following problem.

Constructions of nearly 𝑘-distance sets
In this subsection, we relate the quantities   (),   (, ),   (), and   ().For  ≥ 0 and  ≥ 1 let us define Conjecture 1.   ( + 1) =   () =  ′  () holds for all but finitely many pairs ,  ≥ 1.We do not have have any examples with   ( + 1) >   () or   () >  ′  (), and we believe that the first equality should always hold.However, there are constructions, that we will describe later, that suggest there could be some examples with   () >  ′  ().In Theorem 10 we show that the conjecture holds for every  and sufficiently large . .
∏︀  =1    (  ).Remark.The example given above can be turned into a globally flat set in R +1 , providing a lower bound on   ( + 1).Actually, we do not know of any case when a flat set would provide a strictly better bound on   () than a globally flat set.However, for some  and  there are extremal examples that are not globally flat.More precisely, for any ,  > 0 there is a  > 0 depending only on , such that we can construct a ( − 1, )-flat -nearly -distance set  of cardinality   () that is not globally ( − 1, )-flat.Indeed, for example, for any ,  > 0 we can construct (3, )-flat -nearly 2-distance sets of cardinality  2 (4) =  2 (3) = 6 (see Theorem 10) in R 4 as follows.Consider an equilateral triangle { 1 ,  2 ,  3 } in R 4 of side length  spanning a 2-dimensional plane .For each  ∈ [3] let   −   be a vector of length 1 orthogonal to .It is not hard to check that  = { 1 ,  2 ,  3 ,  1 ,  2 ,  3 } is a (3, )-flat -nearly 2-distance set if  = (, ) is sufficiently large.However, if  1 −  1 and  2 −  2 are orthogonal, then  is not globally (3, )-flat, where  can be taken to be /6.
We can give a lower bound on   (, ) in terms of   ().
For each  ∈  ′ , let Γ  be a ( − 1)-dimensional subspace such that  ′ is (,  − 1, )-flat with respect to Γ  .Further, let   be a unit vector that is orthogonal to Γ  .Replace each point  ∈  ′ with an arithmetic progression , then the distances between any point from   and any point from   for  ̸ = , are within 1/2 from the distance between  and .The set  = ⋃︀ ∈ ′   has cardinality .Define a graph  on  by putting an edge between two points if their distance is in Then  is an   ()-partite graph with equal parts.By definition, the number of edges in such graph is  (,   ()).This argument can easily be modified to deal with the case when   () ̸ |.
We point out the following difference between the case of  = 1 and  ≥ 2 of the known constructions with   (, ) nearly equal distances.Let  ⊆ R  be a set of  points and 1 ≤  1 ≤ • • • ≤   be reals such that the number of pairs { 1 ,  2 } with  1 ,  2 ∈  and with For  = 1 the known constructions are all of the type that was described in Proposition 8 with  ′ being globally ( − 1,   )-flat with   → 0, and thus the normal vectors   being almost parallel.However, this is not the case for  = 2.For  = 2,  = 4, as explained before, there are (3, )-flat -nearly 2-distance sets of cardinality  2 (4) in R 4 for any ,  > 0 that are not globally (3, /6)-flat, and hence the corresponding normal vectors   are not pairwise almost parallel.
Example from [10].The authors of [10] suggested that a construction in the same spirit as the one in Proposition 8 should give a close to optimal bound for   (, ).With the two propositions above in hand, their construction is easy to describe: take  1 , .
One then needs to optimise the value of  over all choices of   ,   , ℓ and .It is possible that  gives the value of   () and   ( + 1) in many cases.Evidently, in order to maximise , one should take  1 , . . .,  ℓ to be nearly equal.We add the following observation.
Observation.For any fixed , , there is a choice of , ℓ,   ,   that maximises  and such that ℓ =  − 1, that is, there is only one term of the form )︀ .Let us prove this.First, we observe that for any  ≥  +1, we may suppose that   ≤   /2.Otherwise, reducing the number of distances does not decrease .We need the following claim.
The proof is a simple calculation and is deferred to the appendix.Using this claim, we can replace any pair of binomial coefficients with   ,   ≥ 2 (,  > ) in (6) (6).
The largest 5-distance set in R 2 is of cardinality 12.We may construct -nearly 5-distance sets using product-type constructions as described in the list above, also of cardinality 12.
In addition, we can construct an -nearly 5-distance set of size 12 that is not of this product construction, and neither does it have the structure of a 5-distance set.Take a large equilateral triangle, and in each of its vertices put a rhombus of a much smaller size with angles /3 and 2/3 such that the angle of the corresponding sides of the rhombus and the triangle is /2 as shown on Figure 1.This example makes us suspect that there could be some exceptions to Conjecture 1.Though we also believe there are only finitely many examples with   () points that are not products of   -distance sets.
Figure 1: -nearly 5-distance set on the plane that is not product-type

Main results
Let us stress that all the sets that we consider in the paper are separated, which we assume tacitly for the rest of the paper.The first theorem deals with small values of  and is one of the main results of the paper.
For fixed  and large  we prove the following simple estimate.
Another main result of the paper is the following theorem, which gives the promised relation between   () and   (, ).
Again, in view of Proposition 8, we only need to show that   (, ) ≤  (,   ( − 1)).This is a consequence of the more general Theorem 28, presented in Section 2.5.
Observe that   (, ) ≤  (,   ()) is obvious from Turán's theorem and the definition of   ().Hence the difficulty in proving Theorem 12 lies in bounding   (, ) by the maximal cardinality of ( − 1, )-flat nearly -distance sets.Similarly, the difficulty in proving Theorem 13 is bounding   (, ) by the maximal cardinality of -distance sets in the space of one dimension smaller.
We note that many different classes of dense geometric graphs were studied from a similar perspective.We mention diameter graphs [29,19,21] and double-normal graphs [24,25,20].In some cases, the relationship between the largest clique and the maximum number of parts in an arbitrarily large complete multipartite graph is quite intricate, as it is the case for double-normal graphs, see [20].
Note that an extended abstract [14] of this work with the same title was accepted for the Eurocomb 2019 conference.

Proofs
The structure of this section is as follows.We start by giving sketches of the proofs of the theorems.The first subsection gives auxiliary results that are going to be used in the proof of Theorem 10, which is doubtless the hardest result in the paper.Most of this section can be skipped in the first reading.We summarise its content below.Subsections 2.2 and 2.3 are devoted to the proof of parts (i) and (ii) of Theorem 10, respectively.In subsection 2.4 we give a simple and short proof of Theorem 11.This is largely independent from the previous material.In Subsection 2.5 we give the proofs of Theorems 13 and 12.These proofs are almost completely independent of the previous subsections, they basically only require Theorem 10 as an input.
Subsection 2.1: The subsection starts with an important Lemma 14 that allows us to find a very precise structure in the graph of distances between the points in case we can split distances into 'small' and 'large': it splits into clusters of points at small distances, and the distances between any two points from different clusters are large.
Lemma 15 is a compactness statement, which states that, in case the ratio of the largest and the smallest distance is uniformly bounded, then a nearly -distance set converges to a usual -distance set, and, in particular, is at most as big.This gives the intuition that non-trivial cases in the proof of Theorem 10 deal with the case when  +1 /  >  for some  and arbitrarily large .The second part additionally tells us that, in case the ratio of two consecutive distances tends to 1, then these distances are 'glued', and in the limit we will have a ( − 1)-distance set.
Lemma 16 gives a simple upper bound on   () only based on Lemma 15.Lemmas 17-18 develop the machinery to deal with almost-flat sets.First, we translate the simple statement that if a vector (or a set) lies in several planes, then it lies in their intersection to the almost-flat setting.Somewhat surprisingly, this turns out to be quite tricky.Lemma 18 is a culmination of the subsection and is a key complement to Lemma 14.It translates to the almost-flat setting the following simple argument.Assume that we are given a nearly -distance set, and there is an  such that  +1 /  >  for some large .Then, using Lemma 14, we can split it into 'red clusters', such that inside the cluster each distance is at most   , while the distance between any two points in different red cluster is at least  +1 .Moreover, assume that for any red cluster   and a point  outside it the distances between  and points from   are very close to the same   ,  ≥  + 1 (for later reference in the sketches, let us call this 'property ⋆').Then it is easy to see that   should be nearly orthogonal to  −  for any  ∈   .Thus, the intuition tells us that all red clusters should be close to planes that are orthogonal to the plane of , where  is a set of points that includes exactly one point from each red cluster.This is not difficult to check for a set  that is 'not flat', e.g., an almost-regular simplex, but it requires preparations in general.
In the first reading, we recommend to read Lemma 14, as well as the statements of Lemmas 15 and 18 and omit the rest.

Proof of Theorem 10 (i):
The proof is by induction on .We look for the last 'big jump' in the sequence of distances, and additionally induct on the position  of this jump (the size of the jump being dependent on the position: the smaller  is, the bigger the jump is).If  =  (i.e.,   / −1 > ) then we use Lemma 18, even in the simple variant that we described above.In this case, the set  forms an almost-regular simplex, and we conclude that the red clusters must be almost-flat w.r.t. the plane, orthogonal to the plane of .We then use the fact that  −1 ( − ) 1 () <   () for large .If  < , then the argument is mostly similar, however, it has an additional twist to deal with one complication.Namely, we may not be able to guarantee that property ⋆ holds if two large distances have very small difference and thus apply Lemma 18.But then Lemma 15 (ii) helps us out, telling that in the limit these two distances glue.If this is the case, we ignore the orthogonality structure that can be given by Lemma 18, and apply a bound of the form  −1 () − () <   (), valid for  large w.r.t..
Proof of Theorem 10 (ii): The proof follows a very similar outline as part (i).The case of two distances uses the same ideas as part (i), even in a simpler form.The case of three distances, however, poses some complications.First, if  3 / 2 >  then the proof is as in the case  =  above.If  2 / 1 >  >  3 / 2 > 1 + 2/ then the proof is as above for  < , but with property ⋆, i.e., our main tool is the 'almost orthogonal decomposition' via Lemma 18.If  3 / 2 < 1 + 2/ then the two largest distances glue, and the argument as above allows us to finish the proof for  ≥ 6.However, this is not sufficient for small , which we deal with separately.We have two subcases in this situation, each of which allow us to get more information on our nearly 3-distance set.The first subcase is when  1 ≫  3 −  2 .In that case, we are again able to guarantee the almost-orthogonality of red clusters to the almost-regular simplex  (cf. Figure 2) and again finish using Lemma 18.The second subcase is when  1 is not so large w.r.t. 3 −  2 .We are then able to find additional structure in between any two red clusters, say   and  ℓ .Namely, if both distances  2 ,  3 appear from  ∈   to points in  ℓ , then at most one distance can appear between a point  ′ ∈  ℓ and any point in   .This turns out to be sufficient to settle this case.Such 'bizarre' cases as the last one also should give a hint on why it is difficult to extend the result to more distances.
We also note that an additional complication in both proofs is that we had to work with a notion of almost-flat sets (defined at the end of Section 2.1) instead of flat sets.This is only needed in order to prove Theorem 13.
We omit the sketch of proof of Theorem 11, which is short and simple, and go on to the Turán-type results.
Proof of Theorem 13: The proof essentially uses certain supersaturation-type results for the Turán's theorem, and then refines the geometric structure of the relations between the points until we get a contradiction.We argue indirectly.Let ℓ − 1 be the largest size of an almost-flat -nearly -distance set.The main (and the one that is less standard) extremal graph theory tool is the following supersaturation result of Erdős that states that, once the number of edges in an -vertex graph is at least  (, ℓ − 1) + 1, it contains a positive fraction of all (ℓ−2)-cliques containing some edge .Using this and some other results and ideas from exremal graph theory, we start with a graph that has one more edge than the theorem states and find the following configuration: a multipartite graph  1,1,2,...,2 with ℓ parts, where any two points in the configuration lie at a distance ≫  1/ , the distances between any two fixed parts all fall into the same interval [  ,   +  1/ ], and any angle       for   ,   belonging to the -th part and   belonging to the -th part,  ̸ = , is at most .Then, after rescaling, we get a separated set with all distances falling into [ ′  ,  ′  + ] for some  (thus the need for point of the set before the scaling to be far apart) and that can be shown to be almost-flat w.r.t.some hyperplanes.
Let us comment on the almost-flatness.Almost -flatness requires that the local flatness condition is satisfied for all but at most two vertices of the graph, and the reason for almostflatness here (and, as a consequence, additional complications in the proof of Theorem 10) is the result of Erdős that we cited.It does not guarantee a positive density of ℓ-cliques once we add an extra vertex (to do so, one has to add  2 extra edges, as in Theorem 12), it only guarantees a positive density of (ℓ − 2)-cliques sharing some edge.As a result, the final graph has the first two parts of size 1, and we cannot ensure the local flatness condition in these vertices.
The proof of Theorem 12 follows the same logic and thus we omit it here.Note that a statement similar to that of Lemma 14 was also used in [9].The next lemma follows by a standard compactness argument.

Auxiliary lemmas
Proof.We only give details of the proof of (ii), part (i) can be done similarly.We start with the first part of the statement.Take any sequence  1 ,  2 , . . ., satisfying the conditions and scale each   by  , = 1.Thus  is a ( − 1)-distance set, and so  = || ≤  −1 ( ′ ).Let us next show the second part of the statement.Taking the set  as above, we obtain that it must additionally be (, 0)-flat.This means that  lies in a -plane, thus  = || ≤  −1 ().
The statement below allows us to get a grip on   ().
Note the difference in the definition of  ′  () and the function  above.Proof.First note that  satisfies  (, Let  be a (, )-flat -nearly -distance set in R  with distances 1 ≤  1 < • • • <   and with sufficiently small , .We need to show that || ≤  (, ).For each  we induct on .
If    −1 + ≤ 3 holds for every 1 <  ≤  (or if  = 1), then by Lemma 15 (i) we have || ≤   () ≤  (, ).Otherwise, let  be the largest index such that The next three statements describe some cases when -flatness with respect to different subspaces can be "combined" into -flatness with respect to a smaller-dimensional subspace.For a linear subspace Γ we denote by Γ ⊥ the orthogonal complement of Γ, and for a vector  ∈ R  ∖ {0} we denote by  ⊥ the ( − 1)-dimensional subspace orthogonal to .
Lemma 17.For any  ′ > 0 there exists  0 > 0 such that the following is true for all 0 <  ≤  0 and all  ≥ 1.Let  ⊆ R  be a set of points, and let  ∈ .Further, let  ⊂ R  ∖ {0} be a set of vectors such that for every  ∈  the set  is (,  − 1,   )-flat with respect to  ⊥ .If  ≥ 1 is the smallest integer for which  is (,   )-Flat, then  is (,  − ,  ′ )-flat.
Proof.We are going to prove that for every  ′ > 0 there exists  0 > 0 such that the following is true for every 0 <  ≤  0 .Let  ∈ R  ∖ {0} be a vector, and let  ⊂ R  ∖ {0} be a set of vectors, such that for every  ∈  the angle between  and  ⊥ is at most   .(This is equivalent to |⟨/‖‖, /‖‖⟩| ≤   , hence also to that the angle between  and  ⊥ is at most   .)If  ≥ 1 is the the smallest integer for which  is (,   )-Flat, and  is (,   )-Flat with respect to Γ, then the angle between  and Γ ⊥ is at most  ′ .Applying this for every vector of the form  =  − , where  ∈  ∖ {}, implies the statement, since Γ ′ is of dimension  − .
Arguing indirectly, assume that for every  0 there is a  <  0 such that the angle between  and Γ ⊥ is larger than  ′ .We will show that then  is ( − 1,  −1 )-Flat with respect to Γ ∩  ⊥ .If  is sufficiently small, then  / ∈ Γ ⊥ , thus the dimension of Γ ∩  ⊥ is  − 1, contradicting the minimality assumption on .
2. For any  ′ ∈  ∖ {} there is a number  > 0 such that for any  ∈  we have Further, let  ≥ 1 be the lowest dimension such that  is (, ,   )-flat.Assume that for some  ∈  and  ≤  ′ the set  ∪  is (, , )-flat.Then  is (,  − , )-flat.
Proof.For || ≤ 1 the statement holds by definition.So we will suppose that || ≥ 2. Let  0 as in Lemma 17 with  ′ =  2 , and let  ′ ≤  0 be sufficiently small, to be further specified later.Let  ∈  be any point of .Assume that  ∪  is (, , )-flat with respect to a -dimensional subspace Γ  .Let   ( ) be the projection of  := { ′ −  : if  is sufficiently small and  is sufficiently large.Further, we have The proof of the following lemma is a simple calculation.
Proof.Let  be (, , )-flat with respect to Γ.We will show that for any ,  ∈  with  ̸ =  there is a vector  ∈ Γ such that the angle between  −  and  is at most 20() 1/2 .
Let   ,   ∈ Γ be vectors such that the angle between  −  and   , and the angle between  −  and   is at most .Further, assume that ‖ − ‖ = ‖  ‖ and ‖ − ‖ = ‖  ‖.The following claim, whose proof is deferred to the Appendix, finishes the proof.We need the following seemingly technical variant of -flatness, which is however crucial for proving Theorem 13.For  ≥ 1 we say that  is almost (, )-flat if  is (, , )-flat for all but at most two  ∈  .Note that this means if  is almost (0, )-flat and  ≤  2 , then | | ≤ 2. We also use the convention that for any  > 0 a set  is (0, )-flat if | | ≤ 2. Let   ( ′ , ) denote the largest number  such that for any ,  > 0 there exists an almost (, )-flat -nearly -distance set in R  ′ of cardinality .Note that   ( ′ , 0) = 2.For  ≥ 1 let   () =   (,  − 1).
Let us summarise the trivial inequalities between the different parameters we introduced: for any  ′ ≥  ≥ 0.

Proof of Theorem 10 (i)
We will prove that for any  ≥ 1 if  is sufficiently large compared to , then for any  ′ ≥  we have   ( ′ , ) =   ().This is sufficient in view of (10).We induct on .The case  = 1 is implied by Lemma 15 (i).Assume that the statement of Theorem 10 is true for every  ′ ≤  − 1 with  >   ′ .We will prove the statement for  and  >   , where the quantity   is chosen later.
For  > 0 and for an -nearly -distance set  with distances Note that since   () ≥ 1 holds for any , Lemma 22 with  = 1 implies the theorem.We phrased Lemma 22 in this seemingly strange form, because this way it is convenient to prove it by backwards induction on .
Proof.The proof is by backwards induction on .We start by showing that the statement is true for  =  with some sufficiently large   ≥ 4.
Let  ′ be as in Lemma 18, and 0 <  ≤  ′ be sufficiently small, to be set later.We may assume that   ≤ () and choose   such that   ≥ 2(  , ).We may apply Lemma 18, as Conditions 1, 2 are automatically satisfied if   ≤   ′ +1 .Let  be as in the Lemma with  =   .Since  is almost (,   )-flat, we have that  ∪  is (, ,   )-flat for all but at most two  ∈ .If  ∈  is such that  ∪  is (, ,   )-flat, then by Lemma 18 we obtain that  is (,  − , )-flat.
Case 1:  −  ≥  −1 .In this case we obtain where the first inequality is true by induction and by (1), the second is true if  is sufficiently large, and the third is true by (2).
We now turn to the induction step.Assume that the statement holds for every  + 1 with We may assume that ( +1 ) ≤ , otherwise we are done by induction.This implies that max <≤    −1 +  ≤  +1 .Thus, by Lemma 15 (ii) we may assume that there exists a sufficiently small constant  > 0 such that the following is true for sufficiently small   and   : Set  ′  = max {︀ 2  ,  +1 }︀ .We are ready to verify the statement of the lemma for sufficiently large   > 2 ′  .We separate two cases.Case 1: min <≤    −1 +  < 1 + .If  is a largest red clique then we obtain where the second inequality follows from (11) and the fact that  is an almost (,   )-flat   -nearly (−1)-distance set and that   ,   are sufficiently small, the third inequality follows by induction and by (1), the fourth is true if  is sufficiently large, and the last is true by (2).
Let  be a largest red clique and let  ∩  = {}.We will apply Lemma 18 to  ∪  with a sufficiently small  (to be chosen later) to bound ||.Let  ′ be as in Lemma 18 and 0 <  ≤  0 sufficiently small to be specified later.We may assume that   ≤ () and choose   such that   ≥ 2(  , ).Then Condition 1 is satisfied automatically.We may further assume that   ≤   ′ +1 .Then Condition 2 is satisfied as well with  if "all distances from a point in  to  fall in one interval".That is, to apply the Lemma, we need to as show that it is not possible to find indices  1 >  2 ≥  and points ,  ′ ∈  with  ̸ =  ′ and  1 ,  2 ∈ , such that If that would have been the case, then, by the triangle Thus, Condition 2 is indeed satisfied as well.
Using Lemma 18, we will show that  is almost ( − , )-flat.Since  is almost (,   )flat, we have that  ∪  is (, ,   )-flat for all but at most two points  ∈ .If  ∈  is such that  ∪  is (, ,   )-flat, then by Lemma 18 we obtain that  is (,  − , )-flat.Since this is true for all but at most two points  ∈ , we obtain that  is indeed almost ( − , )-flat.
Case 2.1:  −  ≥  −1 .In this case we obtain where the first inequality is true by induction and by ( 1), the second is true if  is sufficiently large, and the third is true by (2).
where the first inequality follows from (1), the second is true if  is sufficiently large, and the third follows from (2).
For  ≥ 1 in Claim 23 and in Claim24 we will prove that for any  ′ ≥  and  = 2, 3 we have   ( ′ , ) =   ().This is sufficient in view of (10).
Proof.Let ,  > 0 be sufficiently small and  be an almost (, )-flat -nearly 2-distance set in R  ′ with distances 1 ≤  1 <  2 .Then for all but at most two points  ∈  we have that  is (, , )-flat with respect to a -dimensional subspace Γ  .Let  > 3 be a sufficiently large constant to be specified later.We may assume that Let Γ be the subspace spanned by  −  = { 1 −  2 :  1 ,  2 ∈ } and let  be the dimension of Γ.Note that, since  is an -nearly 1-distance set,  approximately a regular simplex.Hence, if  is sufficiently small, there is an absolute  > 0 such that there is no  ∈  for which the set  is (,  − 1, )-flat.
Let  be any of the red cliques and let  ∩  = {}.We will apply Lemma 18 to  ∪  with a sufficiently small  (to be specified later).
Let  ′ be as in Lemma 18 and let 0 <  ≤  ′ be sufficiently small.We may assume that  ≤ () and that  ≥ (  , ).We may now apply Lemma 18, as Conditions 1, 2 are automatically satisfied if  ≤   ′ +1 .If  ≥ 2 and we have  <  1/(−1) , then  −1 < .Further, note that since we may assume that there is at least one blue edge, we have that || ≥ 2. Thus, there is no  for which  is (0, )-flat.In other words, there is no , for which  is ( − 1, )-flat if  − 1.Thus, if  is sufficiently small, then  is as in Lemma 18.
Since  is (, , )-flat for all but at most two  ∈ , for all but at most two (say  1 and  2 ) red cliques  we have that  ∪  is (, , )-flat for some  ∈ .Thus by Lemma 18 we obtain that if  is not  1 or  2 , then  is (,  − , )-flat for some  ∈ .Now, since  is an -nearly 1-distance set, Lemma 15 (i) implies that if  is not  1 or  2 , then we have || ≤  1 ( − ) =  −  + 1 if  and  are sufficiently small.We also have since there are only at most two  ∈  such that  is not (, , )-flat.
Proof.Let ,  > 0 be sufficiently small and  be an almost (, )-flat -nearly 3-distance set in R  ′ with distances 0 <  1 <  2 <  3 .Later we will apply Lemma 18 with a sufficiently small .Let  ′ be as in Lemma 18, and let 0 <  ≤  ′ be sufficiently small to be specified later.We may assume that  ≤ () and that  ≥ max{3, (, )} is sufficiently large.We may assume that  2  1 + ≥  or  3  2 + ≥  holds, otherwise we immediately obtain || ≤  3 () by Lemma 15 (i) if  and  are sufficiently small.We will analyse these two cases separately.
Let Γ be the subspace spanned by  −  = { 1 −  2 :  1 ,  2 ∈ }, and let  be the dimension of Γ.Note that, since  is an -nearly 1-distance set,  is approximately a regular simplex.Hence, there is an absolute  > 0 such that if  is sufficiently small, then for no  ∈ , the set  is (,  − 1, )-flat.
Let  be any of the red cliques and let  ∩  = {}.We will apply Lemma 18 to  ∪  with .Conditions 1, 2 of Lemma 18 are automatically satisfied if  ≤   ′ +1 .Moreover, if  ≥ 2 and we have  < , then  −1 < , thus  is as in Lemma 18. (The  = 1 case can be handled in the same way as in Claim 23.) Since  is (, , )-flat for all but at most two  ∈ , for every red clique , for all but at most two points  ∈ , we have that  ∪  is (, , )-flat.Thus, by Lemma 18 we obtain that every  is (,  − , )-flat for all but at most two  ∈ .Moreover, since  is an -nearly 2-distance set, we obtain that || ≤  2 ( ′ ,  − ) if  is sufficiently small.Noting further that || =  + 1, overall we obtain For sufficiently small  and any red clique , we have || ≤ 2 if  = .In this case it follows that || ≤ 2( + 1).Then for  ≥ 4 we have where the second inequality is true by a simple calculation, and the third is by (1).For  = 1, 2, 3 we have given that  3 (1) = 4,  3 (2) = 7 and  3 (3) = 12 (see Table 1).
where the second inequality is by the  = 2 case of the theorem (Claim 23) for sufficiently small .In this case, for  ≥ 9 we have where the second inequality is true by (1), the third by a simple calculation, and the fourth by (2).For  ≤ 8, using the known values and bounds of  2 () and  3 (), we check in the Appendix that Case 2:  2  1 + ≥  >  3  2 + .For every  1 ,  2 ∈  with  1 ̸ =  2 colour the pair { 1 ,  2 } with blue if ‖ 1 −  2 ‖ ≥  2 and with red otherwise.Let  be a largest blue clique in .Using Lemma 14, partition the set  into || red cliques  1 , . . .,  || .We split the analysis into two more subcases.
Case 2.1: Let  be one of the red cliques and let  ∩  = {}.We will apply Lemma 18 to  ∪  with , similarly as before.Condition 1 is automatically satisfied.To check Condition 2, note that for any  1 ,  2 ∈  and then by the triangle inequality we obtain that ℓ =  if  is sufficiently small.Thus, Condition 2. is satisfied as well if  ≤   ′ +1 and  is sufficiently small.
Let  be as in Lemma 18.If for some  ∈  we have that  is (, , )-flat, then  is (,  − , )-flat by Lemma 18. Further, note that the same is true for any red clique  with the same .Indeed, since  3  2 + < , Lemma 20 implies that if  is sufficiently small, then there is a  such that  is ( ′ , ,   )-flat for every  ′ ∈ , but there is no  ′ ∈  for which it is ( ′ ,  − 1,  −1 )-flat.This and Lemma 15 (i) imply that for all but at most two red cliques Overall, we obtain Then we either have  =  or  ≤ −1, and thus In the first case ( = ) for  ≥ 6 we have where the second inequality is by (1), the third is by a simple calculation, and the fourth is by (2).For 1 ≤  ≤ 5 we have 1).Finally, in the second case ( ≤  − 1) we do the same analysis as in the end of Case 1.
Case 2.2.1: Let  be a largest red clique.To bound the cardinality of  in this case we will not use Lemma 18, but we will use Lemma 17 directly.
Let  ∩  = {}, and let  be sufficiently small (to be specified later).For  ′ =  2 let  0 as in Lemma 17, and let  ≤  0 be sufficiently small.Further, let  be any point of , and let  = { ′ −  :  ′ ∈  ∖ {}}.Assume that  ≥ 1 is the smallest integer such that  is (,   )-Flat, and assume that  is (,   )-flat with respect to Γ. Let  ∈  be any point of  such that  ̸ = .Claim 25.For every  ′ ∈  ∖ {} the angle between the vectors ( − ) and if  is sufficiently large, and  is sufficiently small.Proof.Let  2 ,  3 be spheres centred at  ′ and of radii  2 and  3 respectively (see Figure 2).Then  is -close to one of them.We only spell out the proof in the case when  is -close to  1 , as the case when it is -close to  3 can be done very similarly.Note that  is also -close to  2 or  3 .If  is -close to  2 , then some simple calculation shows that for some absolute constant  1 the angle between the vectors ( − ) and then we claim that for some absolute constant  2 the angle between the vectors ( − ) and , and that the radius of  3 is much bigger than  1 .Thus, we can conclude that if  is sufficiently large, then the angle between the vectors ( − ) and Next, we will show that if for some  ∈  the set  ∪  is (, , )-flat, then  is (,  − , )-flat.This part of the proof is very similar to the proof of Lemma 17, but for completeness we spell it out with all details.
Assume that  ∪ is (, , )-flat with respect to a -dimensional subspace Γ  .Let   ( ) be the projection of  = { ′ −  : 2 )-Flat with respect to Γ ′  .The angle between ( ′ − ) and ( ′ − ) is at most  if  is sufficiently large and  is sufficiently small.The angle between ( ′ − ) and   ( ′ − ) is at most .Further, the angle between   ( ′ − ) and Γ  is at most   2 .These, together with the triangle inequality imply that  is (,   ,   )-flat with respect to By the minimality of , it follows than that   ≥ .
Let Λ  be the affine plane through  parallel to Γ ′  .For a point  ∈ R  ′ we denote by  ′  () the projection of  on Λ  .Similarly, for a set that is orthogonal to  ′ − .Claim 26.For any  ′ ∈  ∖ {} and any  ∈ , the projection  ′  () is (,  − 1,   )-flat with respect to ( ′ − ) ⊥ if  and  are sufficiently small and  is sufficiently large.
Overall, we obtain that Figure 3 where the second inequality was already proven in the previous cases.
Let  be sufficiently small, that will be specified later.Using Lemma 17, we will show that for any  ∈   the set   is (,  −  (), )-flat provided that ,  are sufficiently small, and  is sufficiently large.Let  0 be as in Lemma 17 for  ′ =  2 , and let  ≤  0 be sufficiently small.
We denote by Γ ′  the subspace spanned by the set of vectors { ℓ  −   : 1 ≤  ≤  ()}.Standard calculation shows that if  and  are sufficiently small, and  is sufficiently large, then there is no  <  () for which Γ ′  is (,   )-Flat .(On an intuitive level, this is the case because  is approximately a regular simplex.)On the other hand, Γ ′  is of dimension at most  (), thus it is ( (),   () )-Flat.
Let  ∈   be such that  ̸ = .If  is sufficiently small and  is sufficiently large, then for any 1 ≤  ≤  () the angle of the vectors ( ℓ  − ) and ( − ) is   ′ 2 -close to  2 .Indeed, this follows since the lengths ‖ ℓ  − ‖ and ‖ ℓ  − ‖ are -close to each other, and ‖ ℓ  − ‖ is at least  times as large as ‖ − ‖.Further, if  is sufficiently small and  is sufficiently large, then the angle of the vectors ( ℓ  −   ) and ( ℓ  − ) is at most   ′ 2 .Thus, the angle of ( − ) and ( ℓ  −   ) is   ′ -close to   2 .Assume that for some  ∈   the set   ∪  is (, , )-flat with respect to Γ  .Then using Lemma 17 after projecting to a subspace parallel to Γ  through , we obtain that   is (,  −  (), )-flat.We omitted the details of this argument, as they are essentially the same as the proof of Lemma 18 and of the proof of Case 2.2.1 after Claim 25.

Proof of Theorem 11
In order to prove the theorem, we will need the spherical analogues of our quantities.For a set  on a -sphere   ⊂ R  ′ centred at 0, we say that  is (, ,   )-flat if for each  ∈  it is (, , )-flat with respect to a -dimensional subspace Γ  that contains the vector  − 0. Note that we do not impose any conditions on the radius of the sphere.
Let    ( ′ , ) denote the largest number  such that for any ,  > 0 there is a (, ,   )flat -nearly -distance set of cardinality  on a -sphere   ⊂ R  ′ .
We call two subspaces Γ 1 and Γ 2 of R  intersecting-orthogonal if there is an orthogonal basis { 1 , . . .,   } of R  with indices 1 ≤  ≤  ≤  such that { 1 ,  2 . . .,   } is an orthogonal basis of Γ 1 and {  ,  +1 . . .,   } is an orthogonal basis of Γ 2 .Slightly abusing notation, we will also call two affine planes Λ 1 and Λ 2 of R  intersecting orthogonal if the subspaces For each ,  ′ , with 0 ≤  <  ′ , we are going to prove that   ( ′ , ),    ( ′ , ) ≤ 2( +1)  simultaneously by induction on .As the proof for   ( ′ , ) and for    ( ′ , ) are very similar, we only spell it out with details for    ( ′ , ), which is the slightly more complicated case.Then we will comment on how to modify the proof for   ( ′ , ).
The statement for    ( ′ , ) is clear for  = 0 and for any  ′ .Suppose that the statement holds for  − 1.More precisely, we assume that there exist  −1 ,  −1 > 0 such that any We are now going to prove a similar statement for  with   ,   > 0, where   ,   are sufficiently small compared to  −1 ,  −1 .
Fix some sufficiently small   ,   > 0. Take a (,   ,   )-flat   -nearly -distance set  of points on a sphere   .Let  be the radius of   , and let the  distances be 1 ≤  1 ≤ • • • ≤   .Note that we may also assume that  1 ≥ 2. Indeed, to get this, simply enlarge  from 0. Then the enlarged image is a (,   ,   )-flat 2  -nearly -distance set with distances Take any point  ∈  , and for each  ∈ [] let  −1  be the ( − 1)-sphere obtained as the intersection of   with the -sphere (,   ) of radius   centred at .Note that every point of  ∈  ∖ {} is contained in the   -neighbourhood of (,   ) for some .Further, let Γ  be a subspace of dimension  containing the vector  − 0 such that  is (, ,   )-flat with respect to Γ  .
Let  ′ be the largest index  such that   < , if there is any, and otherwise let  ′ = 0. Then all points at distance at most   ′ +   from  lie in a spherical cap with centre in  and of angular radius  1  1/2  for some constant  1 .Denote the set of these points by .For every  ∈ , let Λ  be the -dimensional affine plane (contained in the ( + 1)-dimensional affine plane spanned by   ) tangent to   at .Further, let Γ ′  be a -dimensional subspace parallel to Λ  .Then one can show (by combining a projection argument with standard calculations) that there is a universal constant  2 such that  is globally (,  2  1/2  )-flat with respect to Γ ′  .Recall that at the same time for every  ∈  we have that  is (, ,   )-flat with respect to a -dimensional subspace Γ  containing  − 0. Since Γ  contains the vector  − 0, the Proof.Take a construction  of a ( − 1, )-flat -nearly -distance set in R  in which the distances are at least / for a sufficiently large .Pick any  ∈ , and let Γ be a subspace of dimension ( − 1) such that  is (,  − 1, )-flat with respect to Γ. Let  ∈ R  be a point at distance 1 apart from  such that  −  is orthogonal to Γ. Then it is easy to see that  ∪ {} is an almost ( − 1, 3)-flat 3-nearly ( + 1)-distance set in R  if  is sufficiently small and  is sufficiently large.
Indeed, for any  ∈  ∖ {, } we have ⃒ ⃒ ‖ − ‖ − ‖ − ‖ ⃒ ⃒ ≤  if  is sufficiently large and  is sufficiently small.Thus, the only distance between points of  ∪ {} that is not -close to a distance between points of , is the distance ‖ − ‖.Then by the triangle inequality we obtain that  is a 3-nearly ( + 1)-distance set.Further, the angle between  −  and  −  is at most , if  is sufficiently small and  is sufficiently large.Thus, again, by the triangle inequality, for any  ∈  ∖ {, } we have that  is (,  − 1, 3)-flat.
Using the claim above, we may assume that  1 ≥  2  1/ .Indeed, assume the contrary.Since  ′′ is separated, a volume argument implies that for each vertex  ∈  ′′ , the number of vertices in  ′′ at distance at most  2  1/ from  is at most (4 2 )  .Thus, removing all edges from  ′′ that correspond to such distances, we only remove at most (4 2 )   2 edges.At the same time, we reduce the size of the set of possible intervals by at least 1.Hence, we apply Theorem 12 with  playing the role of , and obtain by using the hierarchy (16).
We note here that in the proof of Theorem 12, this step is automatic, since the removal of edges corresponding to small distances only change the potential value of .
Our next goal is to obtain a sufficiently structured subset of  ′′ .We need the following result of Erdős.
Theorem 30 ([8]).Every -vertex graph with at least  (, ℓ − 1) + 1 edges contains an edge that is contained in at least  ℓ−2 cliques of size ℓ, where  is a constant that depends only on ℓ.
Consider the graph  ′′ = ( ′′ , ), where the set of edges consist of all pairs of points { 1 ,  2 } for  1 ,  2 ∈  that satisfy Using the theorem above, we will show that the following lemma holds.
Lemma 31.For any fixed , there exists a choice of  1 =  1 () such that  ′′ contains a complete ℓ-partite subgraph  1,1,,..., with the distances between any two of its vertices strictly bigger than  1  1/ .Proof.We construct this multipartite graph in three steps.
Step 1.Using Theorem 30, we find an edge  = { 1 ,  2 } that is contained in at least  ℓ−2 cliques of size ℓ.Let  ′′ be the set of those edges of the ℓ-cliques, that are not incident to  1 or  2 .Further, let  be the set of the (ℓ − 2)-tuples formed by the ℓ − 2 vertices of the cliques that are different from  1 and  2 .The vertices of  form the first two parts of the multipartite graph.In what follows, we will work with the graph  ′′ induced on  ′′ ∖ { 1 ,  2 } by  ′′ .
Step 2. We select a set   of  vertices of  ′′ at random, and define a hypergraph  ′ on   as follows.Recall that  1 ≪ 1/ ≪ , 1/ℓ, 1/ (see (16); the exact dependency of  on ,  and of  1 on  shall be clear later), and consider the induced subgraph  ′ :=  ′′ [  ].  ′′ is separated, hence a volume argument implies that any vertex in  ′′ ∖ { 1 ,  2 } is at distance strictly bigger than  1  1/ from all but at most (4 )︀ , and for each pair the probability that it is at distance ≤  1  1/ is at most (4 1 )  /( − 2).The inequality in (i) is possible to satisfy by fixing ℓ,  and choosing  1 to be sufficiently small.
(ii) With probability at least /2, the edge density of the hypergraph  ′ =  ′′ [  ] is at least /2.Indeed, the average density of cliques should be the same as of  ′′ , i.e., at least .But if (ii) does not hold, then the average density is at most If we choose  1 < /2, then with positive probability both the property in (i) and in (ii) hold.Pick a subset   ⊆  ∖ { 1 ,  2 } that satisfies both.
Step 3. We apply the following hypergraph generalisation of the Kővári-Sós-Turán theorem due to Erdős.
Theorem 33 ( [18]).For any  > 0 and  ≥ 1 there exists  0 , such that for any  ≥  0 we have the following.Any graph on  vertices with at least  (︀
Take  ′ and set  := 1.Then do the following procedure.Clearly, if  in the beginning of the procedure was large enough, then at the end of the procedure  is still larger than some sufficiently large  .By running a procedure similar to the one above, we can shrink the parts   's further such that for any   ∈   and   ,   ∈   ( / ∈ {1, 2}) the angle ∠      is at most .If  is sufficiently large (see the hierarchy ( 16)), then at the end of this second procedure each   ( / ∈ {1, 2}) has at least 2 points.Thus, we obtain a subset  ⊂  ′ , such that  :=  ′′ [] is complete multipartite with parts  For each 3 ≤  ≤ ℓ let   = {  ,   }.Let  be the set { 1 , . . .,  ℓ } scaled by 1  2  1/ , that is, let  = 1  2  1/ { 1 , . . .,  ℓ }.We will show that  is an almost (−1, )-flat -nearly -distance set, and obtain the desired contradiction.Indeed, this set is separated, since all the distances between   and   for  ̸ =  were at least  2  1/ .Further, it is an -nearly -distance set, since the length of each of the intervals in which the distances fall is  ∈ {1, 2} we have that  is ( 1  2  1/   ,  − 1, )-flat with respect to the  − 1 dimensional subspace orthogonal to (  −   ).This finishes the proof Theorem 28.
We now turn to the proof of Theorem 12.We prove that for every  > 0 inequality (8) holds with intervals of the form [  ,   +  1/ ] where  = (, , ) if  is sufficiently large.As the proof is very similar to the proof of Theorem 28, we only sketch it, pointing out the differences.
Let ℓ :=   () + 1 and ,  > 0 be fixed such that there exists no ( − 1, )-flat -nearly -distance set in R  of cardinality ℓ.Assume on the contrary that for every  > 0 and  0 there is an  ≥  0 , there are  distances  After including  in the hierarchy of constants on the same level as , the proof is the same as that of (28) up to the point of Lemma 31.Instead of Lemma 31 we will use the following.
Lemma 34.For any fixed , there exists a choice  1 =  1 (, ) such that  ′′ contains a complete ℓ-partite subgraph  ,..., such that the distance between any two of its vertices is bigger than  1  1/ .The proof of Lemma 34 is very similar to the proof of Lemma 31, except that instead of Theorem 30 we use a result of Erdős and Simonovits [12] about the supersaturation of ℓ-cliques.(And then work with ℓ-uniform hypergraphs instead of ℓ − 2.) Therefore, we only give an outline of the proof.
Theorem 35 ( [12]).For any ℓ,  > 0 there is a  such that if a graph  on  vertices has at least  (, ℓ) +  2 edges, then it contains at least  ℓ cliques of size ℓ.
Sketch of proof of Lemma 34.We construct this multipartite graph in three steps.
Step 1.Using Theorem 35, we find  ℓ cliques of size ℓ.Let  ′′ be the set of the ℓ-cliques, and  be the set of the ℓ-tuples.In what follows, we will work with the graph  ′′ induced on  ′′ by  ′′ .
Step 2. Select  vertices of  ′′ at random, where  1 ≪ 1/ ≪ , 1/ℓ, 1/.Denote by   the set of  vertices that we chose and consider the induced subgraph  ′ :=  ′′ [  ].A similar calculation as in the proof of Lemma 31 implies the following.
Proof of Claim 21.Let  ′ be a the translate of  by   , and  ′ be the translate of  by  ′ .Then  ′ −  ′ is parallel   −   .Let  1 = ∠ ′ and  2 = ∠ ′  ′ .Then the angle between  ′ −  ′ and  −  is at most  1 +  2 , thus it is sufficient to show that  1 ,  2 ≤ 10() 1/2 .We will prove it for  2 , for  1 it can be done similarly.By the low of cosines we have
(  ) given by the following construction.For each  let   be a  distance set in R   of cardinality    (  ) and such that the distances in   are much larger (in terms of ) than the distances in  −1 7.   () ≥  ′  () holds for every ,  ≥ 1.
. .,   ,  1 ≤ ...≤   , such that ∑︀  =1   =  and ∑︀  =1   =  − 1. Next, represent the hyperplane  = 0 as R  1 × ...×R  .In each R   , take the following   -distance set: either the set that gives the lower bound (2) or, if   = 1, an arithmetic progression of length   + 1.Then combine the sets in the same way as in the proof of Proposition 7, obtaining a nearly -distance set in the hyperplane   = 0. Then extend it in R  as in Proposition 8. Assume that either ℓ = 0 and  1 > 1, or ℓ ≥ 1 and  ℓ = 1 <  ℓ+1 , and we have chosen arithmetic progressions in the first ℓ subspaces.The obtained set has  2 Examples with fixed  or .It is not true that   () =   () holds for every  and .There are several examples of  and  for which we need more than one multiplicative term to maximise (4), and hence   () ≥  ′  () >   ().Some of these examples we list below.When needed, we rely on the information from Table1.
Construct   by including in it   and all the points that form a red pair with   .By the triangle inequality each   is a red clique.Further, by the maximality of , each point from  forms a red distance with at least one point in , and thus  1 , . . .,   cover .Next, they are disjoint: if  ∈   ∩   , then both {,   } and {,   } are red, which by triangle inequality implies that either  =  or that {  ,   } is red (but the second possibility contradicts the definition of ).Finally, if  ∈   ,  ∈   ,  ̸ = , then {, } must be blue by the triangle inequality: otherwise ‖  −   ‖ ≤ ‖  − ‖ + ‖ − ‖ + ‖ −   ‖, and if all the pairs on the right are red, then {  ,   } is red.
Lemma 14.Let  ⊆ R  be a finite set.Assume that for every  1 ,  2 ∈  with  1 ̸ =  2 the pair { 1 ,  2 } is coloured with red or blue, such that the distance between the points in any blue pair is strictly more than 3 times as big as the distance between any red pair.If  is a largest blue clique in , then  can be partitioned into || vertex-disjoint red cliques  1 , ...,  || having the following properties.1.Each   shares exactly one vertex with .2.If  ∈   ,  ∈   and  ̸ = , then {, } is blue.Proof.Take a largest blue clique  = { 1 , . . .,   }.
and otherwise let   () be the largest index 1 <  ≤  such that    −1 + ≥ .Lemma 22.If   and   are sufficiently small and  >   for some sufficiently large   , then the following is true for every 1 ≤  ≤ .There exist   ≥  +1 ≥ . . .≥   such that if  is an almost (,   )-flat   -nearly -distance set in R  ′ , and for some  ≥  we have (  ) ≥ , then || ≤   ().