# On the size of maximal binary codes with 2, 3, and 4 distances

Alexander Barg1 ,  Alexey Glazyrin2 ,  Wei-Jiun Kao3 ,  Ching-Yi Lai4 ,  Pin-
Chieh Tseng5 and  Wei-Hsuan Yu6

###### Abstract.

We address the maximum size of binary codes and binary constant weight codes
with few distances. Previous works established a number of bounds for these
quantities as well as the exact values for a range of small code lengths. As
our main results, we determine the exact size of maximal binary codes with two
distances for all lengths $n\geq 6$ as well as the exact size of maximal
binary constant weight codes with 2,3, and 4 distances for several values of
the weight and for all but small lengths.

1Department of ECE and ISR, University of Maryland, College Park, MD 20742,
USA. Email<EMAIL_ADDRESS>
2School of Mathematical and Statistical Sciences, University of Texas Rio
Grande Valley, Brownsville, TX 78520, USA. Email<EMAIL_ADDRESS>
3Institute of Mathematics, Academia Sinica, Taipei 10617, Taiwan. Email:
<EMAIL_ADDRESS>
4Institute of Communications Engineering, National Yang Ming Chiao Tung
University (NYCU), Hsinchu 30010, Taiwan, and Physics Division, National
Center for Theoretical Sciences, Taipei 10617, Taiwan. Email:
<EMAIL_ADDRESS>
5Institute of Communications Engineering and the Department of Applied
Mathematics, National Yang Ming Chiao Tung University (NYCU), Hsinchu 30010,
Taiwan. Email<EMAIL_ADDRESS>
6Department of Mathematics, National Central University, Taoyuan 32001,
Taiwan. Email<EMAIL_ADDRESS>
##  1\. Introduction

Let $M$ be a metric space with metric $d$ that defines the distance between
any pair of points in $M$. For a finite set $X\subset M$, the set of distinct
distances in $X$, defined as $\mathscr{D}(X)=\\{d(x,y):x\neq y\in X\\},$ is
called a distance set of $X$. We say that $X$ is an $s$-distance set in $M$ if
$|\mathscr{D}(X)|=s$. For instance, the eight vertices of a cube in
$\mathbb{R}^{3}$ form a three-distance set.

Denote by $A(M,s)$ the maximum cardinality of an $s$-distance set in $M$. If
$\mathscr{D}=\\{a_{1},\dots,a_{s}\\}$ is a set of allowed distances, then we
may also use a more detailed notation $A(M,\mathscr{D}).$ When the distances
are specified explicitly, e.g., $\mathscr{D}=\\{a,b\\},$ we also write
$A(M,\\{a,b\\})$ for the maximum size of s-distance sets in the space $M$ with
distances $a$ and $b$.

The maximum size of $s$-distance sets has been studied for a range of metric
spaces. The first to study it were Einhorn and Schoenberg [ES66a], [ES66b] who
addressed the case of the $n$-dimensional Euclidean space
$M={\mathbb{R}}^{n}$. This problem is still far from being resolved. As an
example, it was proved only recently that the only maximum three-distance set
in $\mathbb{R}^{3}$ is formed by the 12 vertices of a regular icosahedron, and
thus $A(\mathbb{R}^{3},3)=12$; similarly $A(\mathbb{R}^{3},5)=20,$ attained by
the vertex set of a dodecahedron (see [NS21], which also contains other
examples).

The problem of bounding the maximum cardinality of $s$-distance sets has been
actively studied for the case of $M=S^{n-1}({\mathbb{R}}),$ the unit sphere in
the $n$-dimensional real space. Delsarte, Goethals, and Seidel [DGS77] proved
a general upper estimate on the size of spherical $s$-distance sets called the
harmonic bound. Their results were improved in a series of recent papers
[Mus09, Noz11, BM11, MN11, BY13b, GY18, JTY+20, LY20] and other works that
focused in particular on the case of $s=2,3,4$. The case of two-distance
spherical codes is the most studied one. Apart from being of interest in their
own right, spherical 2-distance sets exhibit deep connections with a number of
well-known objects in algebraic combinatorics, notably strongly regular
graphs, tight frames, and spherical designs [DGS77, BB05, BGOY15]. Recently
the problem of bounding the maximum size of such codes was resolved for most
values of the dimension $n$ [GY18]. Bounds obtained in this paper form a
starting point of one of our theorems, and we provide more details on it in
the main text below. Further narrowing down the problem, many papers have
addressed the maximum size of spherical 2-distance sets in which every pair of
vectors have inner product $\alpha$ or $-\alpha$ for some value
$\alpha\in(0,1),$ also known as sets of equiangular lines. This problem also
enjoys long history in the literature with a number of links in algebraic
combinatorics, and we refer the reader to [BY13a, GY18, BDKS18, JTY+21] for
recent advances and a general overview.

The maximum cardinality problem for $s$-distance sets has also been studied
for metric spaces commonly considered in coding theory, starting with the
Hamming space $\mathcal{H}_{q}^{n}$ of $n$-dimensional vectors over a finite
field ${\mathbb{F}}_{q}.$ Linear two-distance codes in particular form a
classic object in coding theory because of their links to finite geometries,
see for instance an early survey [CK86] as well as recent works [SHS+21];
[BM22, Ch.7]. Linear codes with few weights are also often constructed in the
framework of cyclic codes and Boolean functions, in particular, bent functions
[Mes16]. This line of research is a subject of vast literature, starting with
classical families such as duals of 2-error-correcting BCH codes, Kerdock
codes and their relatives [MS77] and many other families. Some recent
additions to the literature are [WZHZ15, Din16, LLHQ21] (the reader is
cautioned that this sample is far from complete in many respects).

At the same time, most of the code families studied in the context of coding
theory limit not just on the number of distances but also aim at constructing
codes with large minimum distance. As a result, the codes thus obtained are of
cardinality that is much smaller than the maximum possible if the latter
constraint is removed. It is this problem that we seek to resolve in this
work: what is the maximum size of a binary code with two distances (linear or
not) when the minimum separation between distinct codewords is unrestricted?
In some cases, notably for binary codes with two distances we give a complete
answer, where previously the exact values were known only for a range of small
code lengths $n$.

In addition to $\mathcal{H}_{2}^{n}$ we study codes in the binary Johnson
space $\mathcal{J}^{n,w},$ formed of all binary vectors of length $n$ and
Hamming weight $w$ such that $2w\leq n$. For two vectors
$x,y\in\mathcal{J}^{n,w}$ we define the Johnson distance
$d_{J}(x,y)=(1/2)d_{H}(x,y),$ where $d_{H}(x,y)=|\\{i:x_{i}\neq y_{i}\\}|$ is
the Hamming distance. The problem of determining the maximum size of codes in
$\mathcal{J}^{n,w}$ with few distances recently was the subject of several
papers in coding theory literature [BM11, MN11]. This problem can also be
phrased in different terms that highlight connections in extremal
combinatorics. A code $C\subset\mathcal{J}^{n,w}$ can be thought of as a
family of $w$-subsets of an $n$-set, and $|x\cap y|=w-d_{J}(x,y),$ so
disallowing some values of the distance is tantamount to forbidding some
intersections of the subsets in the family. For instance, the celebrated
Erdős-Ko-Rado theorem [EKR61]; [FT18, GM16] is a statement about the maximum
size of a code in $\mathcal{J}^{n,w}$ with $\mathscr{D}=\\{1,2,\dots,w-t\\},$
where $t\geq 1$ is some fixed number. Generally, the problem of estimating the
maximum size of families of finite sets with a prescribed set of intersections
has been the subject of a long line of works in combinatorics; we refer to
recent overviews in [FT18, Ell22].

Following the convention of coding theory, we call an $s$-distance set in the
Hamming and Johnson spaces an $s$-code. The maximum cardinality of an $s$-code
can be bounded above using Delsarte’s linear programming (LP) method [Del73a];
however this approach typically does not yield closed-form results. The same
applies to Schrijver’s semidefinite programming (SDP) method [Sch05, GMS12]
which represents a far-reaching extension of the LP bound. Delsarte [Del73a,
Del73b] also proved a general upper bound on the size of $s$-codes, called the
harmonic bound; see also the paper [NS10] for a recent improvement. Relying on
the harmonic bound, the authors of [BM11] determined the maximum cardinality
$A(\mathcal{H}_{2}^{n},2)$ and $A(\mathcal{J}^{n,w},2)$ in a number of cases,
and paper [MN11] extended their results to $s=3$ and $4$.

Despite the described advances, the exact values of $A(M,s)$ for
$M=\mathcal{H}_{2}^{n}$ or $\mathcal{J}^{n,w}$ were known only for a limited
range of values of $n$. For instance, it was shown in [BM11] that
$A(\mathcal{H}_{2}^{n},2)=1+\binom{n}{2}$ for $6\leq n\leq 78$ with a number
of exceptions in that range left unresolved, and [MN11] showed that
$A(\mathcal{H}_{2}^{n},3)=n+\binom{n}{3}$ for $8\leq n\leq 37$ and $n=44$,
with the exception of $n=23,34,35$ (while $n=23$ constitutes a true exception
due to the fact that the dual Golay code ${\mathcal{G}}_{23}^{\bot}$ yields
$A(\mathcal{H}_{2}^{23},3)\geq 2048$, the other two values are not as we will
observe below). As one of our main results we prove

######  Theorem 1.1.

$A(\mathcal{H}_{2}^{n},2)=1+\binom{n}{2}$ for all $n\geq 6.$

The idea of the proof is to embed a binary code into a sphere $S^{n-1}$ and
relate its size to spherical two-distance sets and spherical equiangular sets,
relying on bounds for them proved recently in [GY18].

Table 1. Values of $A(J^{n,w},s)$ $w$ | 4 | 5 | 6 | 5 | 6 | 7 | 6 | 7 | any
---|---|---|---|---|---|---|---|---|---
$s$ | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | $w-1$
$A(\mathcal{J}^{n,w},s)=$ | $\binom{n-2}{2}$ | $\binom{n-3}{2}$ | $\binom{n-4}{2}$ | $\binom{n-2}{3}$ | $\binom{n-3}{3}$ | $\binom{n-4}{3}$ | $\binom{n-2}{3}$ | $\binom{n-3}{3}$ | $\binom{n-1}{w-1}$
for $n\geq$ | 9 | 12 | 35 | 12 | 16 | 20 | 15 | 20 | $2w$
Thm/Cor |  5.5(a) |  5.5(b) |  5.5(c) |  5.7(b) |  5.7(c) |  5.7(d) |  5.8(b) |  5.8(c) | 4.5

######  Remark 1.2.

The maximum size of 2-distance codes in $\mathcal{H}_{q}^{n}$ was recently
studied in [BDZZ21] which put forward a conjecture that

$A(\mathcal{H}^{n}_{q},\\{2,4\\})=1+\binom{n}{2}\text{ for }n\geq 6\text{ and
}q=2,3,4.$

We note that for $q=2$ this equality follows already from Theorem 2.2 (an
independent different proof was recently given in [LR21]). Our Theorem 1.1
extends this result to all values of the distances.

We further establish a number of exact general results for
$A(\mathcal{J}^{n,w},s)$ for $3\leq w\leq 7$ and $2\leq s\leq 4$, detailed in
Section 5. Here the main vehicle is application of the LP method. We remarked
above that general resuls based on it are difficult to come by; an observation
that makes our results possible is that a small subset of Delsarte’s
inequalities suffice to constrain the size of the code, and this small subset
can be analyzed in a general form rather than numerically. Outside the above
range of values of $s$ and $w$ we obtain a few new exact results by computer
relying on LP as well as on Schrijver’s SDP bound.

For convenience we list the new bounds for $A(\mathcal{J}^{n,w},s)$ in Table 1
with references to the statements proved in the main text. Earlier results
[MN11] additionally show that $A(\mathcal{J}^{n,6},2)=\binom{n-4}{2}$ for
$15\leq n\leq 24.$ We discuss these as well as other previously known and new
numerical results in Sec. 6 below.

Based on our new results and known bounds (including the Erdős-Ko-Rado
theorem), we formulate a general conjecture for $s$-distance sets in the
Johnson space.

######  Conjecture 1.3.

For all $w>s>0$ and sufficiently large $n\geq n_{0}(w,s)$,

$A(\mathcal{J}^{n,w},s)=\binom{n-w+s}{s}.$

The Erdős-Ko-Rado theorem corresponds to the case of $s$ consecutive distances
$\mathscr{D}=\\{1,2,\dots,s\\},$ see Sec. 4.2.

##  2\. The harmonic bound, its improvements and implications

###  2.1. The Hamming space

Recall that the set of polynomials

(1)
$\phi_{k}(x)=\sum_{j=0}^{k}(-1)^{j}\binom{x}{j}\binom{n-x}{k-j},k=0,1,\dots,n$

called the binary Krawtchouk polynomials, forms an orthogonal basis in the
space of real functions on $\\{0,1,\dots,n\\}$ with weight
$\binom{n}{i},i=0,\dots,n$ [Del73a], [MS77, Ch.5]. Any such function has a
unique expansion as a sum of Krawtchouk polynomials, namely $f(x)=\sum_{i\geq
0}f_{i}\phi_{i}(x),$ where $f_{i}=2^{-n}\sum_{j\geq
0}f(j)\phi_{i}(j)\binom{n}{j}.$

Delsarte [Del73a, Del73b] proved an upper bound on $A(\mathcal{H}_{2}^{n},s)$,
called the harmonic bound (it is derived relying on the dimension of the space
of spherical harmonics). In the next theorem we quote this bound accounting
for an improvement found in [NS10].

######  Theorem 2.1.

[NS10] Let $C\subset\mathcal{H}_{2}^{n}$ be an $s$-code with distances
$\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Consider the polynomial
$f(t)=\prod_{i}\frac{d_{i}-t}{d_{i}}=\sum_{k=0}^{s}f_{k}\phi_{k}(t)$. Then

$A(\mathcal{H}_{2}^{n},\mathscr{D})\leq\sum_{k:f_{k}>0}\binom{n}{k}.$

In [NS10] this theorem is proved for spherical codes, but it can be extended
to other polynomial metric spaces including $\mathcal{H}_{2}^{n}$ and
$\mathcal{J}^{n,w}$ using standard tools.

A concrete form of Theorem 2.1 under the condition that the sum of the code’s
distances does not exceed $\frac{1}{2}sn$ is as follows.

######  Theorem 2.2.

[BM11, Theorem $11$] Suppose that $\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$ is
such that $\sum_{i=1}^{s}d_{i}\leq\frac{1}{2}sn.$ Then

$A(\mathcal{H}_{2}^{n},\mathscr{D})\leq\sum_{i=0}^{s-2}\binom{n}{i}+\binom{n}{s}.$

This inequality is proved by showing that the assumption
$\sum_{i=1}^{s}d_{i}\leq\frac{1}{2}sn$ forces the coefficient $f_{s-1}$ of the
Krawtchouk expansion to be nonpositive, and thus the term $\binom{n}{s-1}$ is
missing from the sum.

A lower bound on $A(\mathcal{H}_{2}^{n},s)$ follows by an easy construction of
$s$-codes in $\mathcal{H}_{2}^{n}$ which sometimes enables one to prove tight
results.

######  Proposition 2.3.

[MN11, Eq.$(3.1)$] For $2s\leq n$, we have

$A(\mathcal{H}_{2}^{n},s)\geq\sum_{i=0}^{\lfloor\frac{s}{2}\rfloor}\binom{n}{s-2i}.$

###### Proof.

For $2s\leq n$, the set $C$ of all binary vectors of Hamming weight $k\leq s$
such that $k=s\leavevmode\nobreak\ (\text{mod}\,2)$ is an $s$-code with
distance set $\mathscr{D}(C)=\\{2,4,\dots,2s\\}$. ∎

###  2.2. The Johnson space

The results in the previous section have their analogs for the Johnson space
$\mathcal{J}^{n,w}.$ In this case the relevant family of orthogonal
polynomials are the Hahn polynomials, defined as

(2)
$\psi_{k}(x)=\sum_{j=0}^{k}(-1)^{j}\frac{\binom{k}{j}\binom{n+1-k}{j}}{\binom{w}{j}\binom{n-w}{j}}\binom{x}{j},\quad
k=0,1,\dots,w.$

The Hahn polynomials form an orthogonal basis in the function space
$f:\\{0,1,\dots,w\\}\to{\mathbb{R}}$ with weight
$\binom{w}{i}\binom{n-w}{i},i=0,1,\dots,w.$

The (improved) harmonic bound for the Johnson space has the following form.

######  Theorem 2.4.

[NS10] Let $C\subset\mathcal{J}^{n,w}$ be a constant weight $s$-code with
distances $\\{d_{1},\dots,d_{s}\\}$. Consider the polynomial
$f(t)=\prod_{i}\frac{d_{i}-t}{d_{i}}$. Suppose that the Hahn expansion of
$f(t)$ is $f(t)=\sum_{k=0}^{s}f_{k}\psi_{k}(t)$. Then

$|C|\leq\sum_{k:f_{k}>0}\binom{n}{k-1}\frac{n-2k+1}{k}.$

As remarked, this result appears in [NS10] for the case of spherical codes.
Starting with this theorem, one can prove the following upper bound on
$s$-codes in the Johnson space.

######  Theorem 2.5.

[BM11, Theorem $8$] Let $C\subset\mathcal{J}^{n,w}$ be an $s$-code with
distances $\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Suppose that

$\sum_{i=1}^{s}(w-d_{i})\geq\frac{s(w^{2}-(s-1)(2w-\frac{n}{2}))}{n-2(s-1)}.$

Then

$|C|\leq\binom{n}{s}-\binom{n}{s-1}\frac{n-2s+3}{n-s+2}.$

Similarly to Proposition 2.3, there is a general construction of $s$-codes in
the Johnson space that implies a lower bound on $A(\mathcal{J}^{n,w},s)$.

######  Proposition 2.6.

[EKR61] For $s\leq n-w$ we have

$A(\mathcal{J}^{n,w},s)\geq\binom{n-w+s}{s}.$

###### Proof.

For $s\leq n-w$, consider the set of binary vectors in $\mathcal{J}^{n,w}$
with ones in the first $w-s$ coordinates. Clearly, it forms an $s$-code of
size $\binom{n-w+s}{s}$ with distances $\\{1,\dots,s\\}$. ∎

##  3\. The maximum size of $2$-codes in the Hamming space: A proof of Theorem
1.1

We will prove Theorem 1.1 by reduction to spherical codes. Let
$C\subset\mathcal{H}_{2}^{n}$ be a binary code of length $n.$ Our plan is to
map $C$ on the sphere $S^{n-1}$ and view the result as a spherical
$2$-distance code. For that let $f:\mathcal{H}_{2}^{n}\to S^{n-1}$ be a map
given by $x=(x_{1},\dots,x_{n})\mapsto f(x)=(v_{1},\dots,v_{n})$, where
$v_{i}=\frac{1}{\sqrt{n}}(-1)^{x_{i}}$ for all $i$. Note that if
$d_{H}(x,y)=d$ then for the Euclidean inner product we obtain $\langle
f(x),f(y)\rangle=1-\frac{2d}{n}$. Thus, if $C$ is a binary 2-code with
distances $a$ and $b$, the set $f(C)$ forms a spherical $2$-code with inner
products $\alpha=1-\frac{2a}{n}$, $\beta=1-\frac{2b}{n}$.

In the following subsection we recall some known bounds for equiangular lines.
The proof itself is formed of two parts presented in Sections 3.1, 3.2. The
first part reformulates the problem for spherical codes, connects it to
families of equiangular lines, and then narrows down the possible parameters
by using the known results about them. This leaves behind a set of exceptional
values of the distances, which we handle in the second part.

###  3.1. Bounds from spherical equiangular sets

We will need a few known results concerning equiangular line sets in
${\mathbb{R}}^{n}.$ Any such set is a finite collection of points on $S^{n-1}$
with pairwise inner products $\\{\alpha,-\alpha\\}$, $\alpha\in[0,1)$. Let
$M(n)$ be the size of the largest possible equiangular line set in $n$
dimensions and let $M_{\alpha}(n)$ be the size of the largest equiangular set
with inner products $\\{\alpha,-\alpha\\}$.

######  Theorem 3.1.

$\displaystyle(a)\;$ $\displaystyle M_{\alpha}(n)\leq 2n\text{ unless
$1/\alpha$ is an odd integer}\text{ (Neumann, see
\cite[cite]{[\@@bibref{}{LS73}{}{}]})};$ $\displaystyle(b)\;$ $\displaystyle
M_{\frac{1}{3}}(n)=28\text{ for }7\leq n\leq 15,\text{ and
}M_{\frac{1}{3}}(n)=2n-2\text{ for }n\geq 15.\text{
(\cite[cite]{[\@@bibref{}{LS73}{}{}]})};$ $\displaystyle(c)\;$ $\displaystyle
M_{\alpha}(n)\leq\frac{n(1-\alpha^{2})}{1-n\alpha^{2}}\text{ for all $\alpha$
and $n\in\mathbb{N}$ such that $n\alpha^{2}<1$}\text{ (Relative bound,
\cite[cite]{[\@@bibref{}{LS73}{}{}]})};$ $\displaystyle(d)\;$ $\displaystyle
M_{\frac{1}{a}}(n)\leq\frac{(a^{2}-2)(a^{2}-1)}{2}\text{ for all $n$ and $a$
such that $n\leq 3a^{2}-16$ and $a\geq 3$
}\text{(\cite[cite]{[\@@bibref{}{Yu17}{}{}]})};$ $\displaystyle(e)\;$
$\displaystyle M_{\frac{1}{a}}(n)\leq
n\left(\frac{2}{3}a^{2}+\frac{4}{7}\right)+2\text{ for all $a\geq 3$ and for
all $n\in\mathbb{N}$ (\cite[cite]{[\@@bibref{}{GY18}{}{}, Theorem 3]}).}$

Parts (a)-(c) of this theorem form classical results while parts (d) and (e)
represent recent results on bounds for equiangular lines.

######  Lemma 3.2.

$M_{\frac{1}{a}}(n)\leq\binom{n-1}{2}$ for $n\geq 7$ unless $a$ is an odd
integer and $n\in\\{a^{2}-1,a^{2}-2\\}$.

###### Proof.

The case-by-case proof below essentially follows the proof of [GY18, Theorem
2].

  1. (1)

If $a$ is not an odd integer, by Theorem 3.1(a), $M_{\frac{1}{a}}(n)\leq
2n\leq\binom{n-1}{2}$ for all $n\geq 7$. Therefore, below we will assume that
$a$ is an odd integer.

  2. (2)

Let $a^{2}\leq n\leq 3a^{2}-16.$ By Theorem 3.1(d),

$M_{\frac{1}{a}}(n)\leq\frac{(a^{2}-1)(a^{2}-2)}{2}\leq\binom{n-1}{2}.$

  3. (3)

For $n\leq a^{2}-3$, by Theorem 3.1(c),

$M_{\frac{1}{a}}(n)\leq\frac{n(a^{2}-1)}{a^{2}-n}=n+\frac{n^{2}-n}{a^{2}-n}\leq
n+\frac{n^{2}-n}{3}\leq\binom{n-1}{2}$

for all $n\geq 13$. If $7\leq n\leq 12$, then $a\geq 5$ (recall that $a$ is
odd) and, again using Theorem 3.1(c), we obtain

$M_{\frac{1}{a}}(n)\leq n+\frac{n^{2}-n}{a^{2}-n}\leq
n+\frac{n^{2}-n}{13}\leq\binom{n-1}{2}.$

  4. (4)

For the last remaining case, consider $n\geq 3a^{2}-15$. By Theorem 3.1(e),

$M_{\frac{1}{a}}(n)\leq n\left(\frac{2}{3}a^{2}+\frac{4}{7}\right)+2\leq
n\left(\frac{2}{3}\cdot\frac{n+15}{3}+\frac{4}{7}\right)+2\leq\binom{n-1}{2}$

for all $n\geq 20$. For $12\leq n\leq 19$ we have $a=3$, and by Theorem 3.1(b)

$M_{\frac{1}{a}}(n)=28\leq\binom{n-1}{2}.$

∎

Recall that $A(\mathcal{H}_{2}^{n},\\{a,b\\})$ is the maximum size of
$2$-codes in the Hamming space with distance set $\\{a,b\\}$ and $a>b$, and
let $g(n,\alpha,\beta)$ be the maximum size of a spherical $2$-code with inner
products $\alpha,\beta\in[-1,1)$.

######  Lemma 3.3.

Suppose that $-1\leq\alpha<\beta<1$ and $\alpha+\beta<0$. Let
$\gamma=\frac{2-(\alpha+\beta)}{\beta-\alpha}$. Then for $n\geq 6$,

$g(n,\alpha,\beta)\leq\binom{n}{2}$

unless $\gamma$ is an odd integer and $n\in\\{\gamma^{2}-2,\gamma^{2}-3\\}$.

###### Proof.

Consider a $2$-code $C=\\{x_{1},\dots,x_{N}\\}\subset S^{n-1}$ with inner
products $\alpha,\beta$. Let $t=\sqrt{\frac{2}{2-(\alpha+\beta)}}$ and let
$y\in S^{n}$ be the unit vector orthogonal to all $x_{i}\in C$. Then the set

$\\{tx_{i}+\sqrt{1-t^{2}}y:1\leq i\leq N\\}$

is an equiangular set in $S^{n}$ with inner product
$\frac{1}{\gamma}=\frac{\beta-\alpha}{2-(\alpha+\beta)}$. Thus,

$g(n,\alpha,\beta)\leq M_{\frac{1}{\gamma}}(n+1)\leq\binom{n}{2}$

unless $\gamma$ is one of the exceptional values in the statement of the Lemma
3.2. ∎

######  Theorem 3.4.

For $n\geq 6$,

$A(\mathcal{H}_{2}^{n},\\{a,b\\})\leq 1+\binom{n}{2}$

unless there is a positive integer $m$ such that $a=(m+1)(2m+1)$, $b=m(2m+1)$
and $n\in\\{(2m+1)^{2}-2,(2m+1)^{2}-3\\}$.

###### Proof.

If $a+b\leq n$, by Theorem 2.2, $A(\mathcal{H}_{2}^{n},a,b)\leq
1+\binom{n}{2}$. Now we assume $a+b>n$ and consider the corresponding
spherical $2$-code with scalar products $\alpha=1-\frac{2a}{n}$,
$\beta=1-\frac{2b}{n}$. Then $\alpha+\beta<0$. By Lemma 3.3,

$A(\mathcal{H}_{2}^{n},a,b)\leq g(n,\alpha,\beta)\leq\binom{n}{2}$

unless $\gamma=\frac{2-(\alpha+\beta)}{\beta-\alpha}$ is an odd integer and
$n\in\\{\gamma^{2}-2,\gamma^{2}-3\\}$. Write $\gamma=2m+1$ for some integer
$m$ and observe that

$\gamma=\frac{a+b}{a-b}=2m+1$

implies $\frac{a}{b}=\frac{m+1}{m}$. Denoting $k=\text{gcd}(a,b)$, we get
$a=(m+1)k$ and $b=mk$.

By a result of Rankin [Ran55], the size of a spherical code whose scalar
products are all negative cannot be larger than $n+1$. Since
$n+1\leq\binom{n}{2}$, it is sufficient to consider the case when $\beta\geq
0$, that is, when $b\leq n/2$. Note that $\alpha+\beta<0$ so $\alpha$ must be
negative and $a>n/2$. Using $n\in\\{(2m+1)^{2}-2,(2m+1)^{2}-3\\}$, we see that
$b\leq 2m^{2}+2m-1$ and $a\geq 2m^{2}+2m$. Since $b=mk$, $k<2m+2$. Since
$a=(m+1)k$, $k\geq 2m$. The only possible choices are $k=2m$ and $k=2m+1$.

Note that $\alpha+\beta<0$ is equivalent to $a+b>n$. If $k=2m$,
$a+b=2m(m+1)+2m^{2}=4m^{2}+2m\leq(2m+1)^{2}-3\leq n$ so this condition is not
satisfied. Therefore, the only remaining choice for $k$ is $2m+1$ and
$a=(m+1)(2m+1)$, $b=m(2m+1)$. ∎

###  3.2. Exceptional cases

Here we show that the exceptional cases in Theorem 3.4 cannot give rise to
spherical $2$-codes of large size. The main instrument in the proof is a bound
on spherical $2$-codes from [GY18].

######  Theorem 3.5.

[GY18, Corollary 4] Let $X\subset S^{n-1}$ be a spherical code with inner
products $\alpha,\beta$. Then

$|X|\leq\dfrac{n+2}{1-\frac{n-1}{n(1-\alpha)(1-\beta)}},$

if the right-hand side is positive.

######  Lemma 3.6.

For all $n\geq 6$,

$A(\mathcal{H}_{2}^{n},\\{a,b\\})\leq\binom{n}{2},$

given that $a=(m+1)(2m+1)$, $b=m(2m+1)$ and
$n\in\\{(2m+1)^{2}-2,(2m+1)^{2}-3\\}$ for some positive integer $m$.

###### Proof.

Using the same mapping to the sphere as above, we consider spherical $2$-codes
with scalar products $\alpha=1-\frac{2a}{n}$ and $\beta=1-\frac{2b}{n}$. Note
that

$n(1-\alpha)(1-\beta)=\frac{4ab}{n}=\frac{(2m+1)^{4}-(2m+1)^{2}}{n}.$

Since $(2m+1)^{2}$ is either $n+2$ or $n+3$,

$n(1-\alpha)(1-\beta)\geq\frac{(n+2)^{2}-(n+2)}{n}=\frac{(n+2)(n+1)}{n}.$

Therefore, by Theorem 3.5, the size of the set is no larger than

$\frac{n+2}{1-\frac{(n-1)n}{(n+2)(n+1)}}=\frac{(n+1)(n+2)^{2}}{4n+2}<\binom{n}{2}+1$

for all $n\geq 7$. One can also check that the upper bound in Theorem 3.5 is
less than $\binom{n}{2}$ when $n=6$, $m=1$. ∎

Now Theorem 1.1 follows by combining Proposition 2.3, Theorem 3.4 and Lemma
3.6.

######  Remark 3.7.

Another way to rule out the existence of large-size codes for the exceptional
sets of parameters is to rely on the LP method. This route relies on combining
the Delsarte inequalities (13) for degrees $k=2,n-2,n-1,n$, but it results in
a longer argument so we do not present it here. Similar (yet different)
arguments are used to bound $A(J^{n,w},s)$ in Section 5.

######  Remark 3.8.

As follows from [JTY+20], for large $n$ the value
$A(\mathcal{H}_{2}^{n},\\{d_{1},d_{2}\\})$ for some distance pairs
$d_{1},d_{2}$ is at most linear in $n.$ These results rely on certain
technical conditions related to spectral radius of some graphs which we do not
cite here. To give an example, for large $n$ the value
$A(\mathcal{H}^{n}_{2},\\{\frac{3n}{10},\frac{3n}{5}\\})\leq 3n+O(1)$, see
[JTY+20, Thm. 1.12].

##  4\. Bounds for $s$-codes in the Johnson space

###  4.1. Implications of the harmonic bound

In this section we derive some general bounds for $A(\mathcal{J}^{n,w},s)$
based on a refining of Theorem 2.5, which we state an proof next.

######  Theorem 4.1.

Let $C\subset\mathcal{J}^{n,w}$ be an $s$-code with distance set
$\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$, where $w\geq s+1$ and $s\geq 2$.
Suppose that

(3) $n\geq sw^{2}-2s(s-1)w+s(s-1)^{2}+2(s-1).$

Then $|C|\leq\binom{n}{s}-\binom{n}{s-1}+\binom{n}{s-2}$.

###### Proof.

From (3) we conclude that

$\frac{sw(n-2(s-1))-s(w^{2}-(s-1)(2w-\frac{n}{2}))}{n-2(s-1)}\geq\sum_{i=0}^{s-1}(w-i)-1.$

By Theorem 2.5, if

$\sum_{i=1}^{s}d_{i}\leq\frac{sw(n-2(s-1))-s(w^{2}-(s-1)(2w-\frac{n}{2})))}{n-2(s-1)},$

$|C|\leq\binom{n}{s}-\binom{n}{s-1}\frac{n-2s+3}{n-s+2}=\binom{n}{s}-\binom{n}{s-1}+\binom{n}{s-2}$.
This proves our claim except for the case of
$\mathscr{D}=\\{w,w-1,\dots,w-s+1\\}$. However, for this choice of the
distances the Johnson bound [Joh62], [MS77, p. 528] implies that

$|C|\leq\prod_{i=0}^{s-1}\frac{n-i}{w-i}\leq\binom{n}{s}-\binom{n}{s-1}+\binom{n}{s-2}.$

∎

This theorem implies the following bounds.

######  Corollary 4.2.

(4) $\displaystyle A(\mathcal{J}^{n,w},2)$
$\displaystyle\leq\binom{n}{2}-n+1=\binom{n-1}{2},\quad w\geq 3\text{ and
}n\geq 2w^{2}-4w+4,$ (5) $\displaystyle A(\mathcal{J}^{n,w},3)$
$\displaystyle\leq\binom{n}{3}-\binom{n}{2}+n=\binom{n-1}{3}+1,\quad w\geq
4\text{ and }n\geq 3w^{2}-12w+16$ (6) $\displaystyle A(\mathcal{J}^{n,w},4)$
$\displaystyle\leq\binom{n}{4}-\binom{n}{3}+\binom{n}{2}=\binom{n-1}{4}+n+1,$
$\displaystyle\hskip 72.26999ptw\geq 5\text{ and }n\geq 4w^{2}-24w+42.$

By fixing the value of $w$ we can obtain specific bounds for the maximum size
of $s$-codes. For instance, taking into account numerical results of
Propositions 6.2, 6.3, and 6.4 below, we obtain the following results:

(7) $\displaystyle A(\mathcal{J}^{n,3},2)=\binom{n-1}{2},\quad n\geq 6$ (8)
$\displaystyle\binom{n-1}{3}\leq
A(\mathcal{J}^{n,4},3)\leq\binom{n-1}{3}+1,\quad n\geq 11.$ (9)
$\displaystyle\binom{n-1}{4}\leq
A(\mathcal{J}^{n,5},4)\leq\binom{n-1}{4}+n+1\quad n\geq 15.$

These estimates in fact relate to a special situation when the code is allowed
to have all but one distances, or using the language of intersecting families,
forbidding a single intersection. In the next subsection we further explore
this point of view, removing the gap in last two of these estimates. Further,
in Sec. 5 we show how these improved bounds can be obtained using the Delsarte
inequalities.

###  4.2. EKR and forbidden intersections

As already mentioned, constant weight codes with a specified set of distances
can be equivalently described as families of finite sets with restricted
intersections. Switching to this language, in this subsection we prove one
simple corollary of the Erdős-Ko-Rado theorem that implies bounds for
$s$-codes with $w=s+1.$ We will use the following notation. A family
$\mathcal{F}$ of $w$-subsets of $[n]$ is called intersecting if $F_{1}\cap
F_{2}\neq\emptyset$ and it is called $t$-intersecting if $|F_{1}\cap
F_{2}|\geq t$ for any $F_{1},F_{2}\in\mathcal{F}.$ Let $m(n,w,t)$ be the
maximum size of a $t$-intersecting family.

######  Theorem 4.3.

[EKR61] For $1\leq t<w$ and $n\geq n_{0}(w,t)$

(10) $m(n,w,t)=\binom{n-t}{w-t}.$

If $t=1$ and $w\leq n/2,$ then $m(n,w)\leq\binom{n-1}{w-1}.$ If $w<n/2$ then
equality holds if and only if there is an $i\in[n]$ such that
$\mathcal{F}=\\{F\subset\binom{[n]}{w}:i\in F\\}.$

Clearly the family $\mathcal{F}=\\{F\in\binom{[n]}{w}:\\{1,2,\dots,t\\}\subset
F\\}$ has cardinality $\binom{n-t}{w-t}$ and therefore is optimal for $n\geq
n_{0}(w,t)$. The value of $n_{0}(w,t)$ was found in a series of papers
culminating with Wilson’s theorem [Wil84] stating that for all $t$

$n_{0}(w,t)=(w-t+1)(t+1).$

Rephrasing this for s-codes in $\mathcal{J}^{n,w}$, the largest size of a code
with distances $\mathscr{D}=\\{1,2,\dots,s=w-t\\}$ is

(11) $A(\mathcal{J}^{n,w},\mathscr{D})=\binom{n-w+s}{s}\text{ for all }s\leq
w-1,\;n\geq(s+1)(w-s+1).$

We will now prove a related result for $s=w-1$ (any single missing distance)
through a connection with families with forbidden intersections. Denote by
$m(n,w,\bar{l})$ the maximum size of a family $\mathcal{F}$ of $w$-subsets of
$[n]$ such that $|F\cap F^{\prime}|\neq l$ for any
$F,F^{\prime}\in\mathcal{F}$. The well-known Frankl-Füredi theorem [FF85]
asserts that for $w\geq 2l+2$ and sufficiently large $n$,

$m(n,w,\bar{l})\leq\binom{n-l-1}{w-l-1}.$

We first establish a simple (weaker) upper bound for $m(n,w,\bar{l})$ that
applies for all $n\geq 2w-l$ 111In all likelihood, it is available in the
literature, however we could not find an immediate reference..

######  Theorem 4.4.

Let $1\leq l\leq w-1$ and $n\geq 2w-l,$ then
$m(n,w,\bar{l})\leq\frac{w-l}{n-l}\binom{n}{w}.$

###### Proof.

Let $\mathcal{F}$ be a family of $w$-subsets of $[n]$ no two of which
intersect on $l$ elements. Every set $F\in\mathcal{F}$ contains $\binom{w}{l}$
$l$-subsets, so the total number of $l$-subsets in all sets $F$ is
$|\mathcal{F}|\binom{w}{l}.$ Thus on average every $l$-subset is contained in
$E:=\frac{|\mathcal{F}|\binom{w}{l}}{\binom{n}{l}}$ sets $F$. Now fix an
$l$-subset $S$ that is contained in at least $E$ subsets of $\mathcal{F}$. By
$\mathcal{F}^{*}\subseteq\mathcal{F}$ denote the set of all subsets in
$\mathcal{F}$ containing $S$. For any $F,F^{\prime}\in\mathcal{F}^{*}$,
$|F\cap F^{\prime}|\neq l$ and thus $(F\backslash S)\cap(F^{\prime}\backslash
S)\neq\emptyset.$ This means that the collection $\\{F\backslash
S:F\in\mathcal{F}^{*}\\}$ forms an intersecting family in $[n]\backslash S$,
and so $E\leq\binom{n-l-1}{w-l-1}$ by the EKR theorem. The last inequality
implies that

$\displaystyle|\mathcal{F}|\leq\frac{\binom{n}{l}}{\binom{w}{l}}\binom{n-l-1}{w-l-1}=\frac{1}{\binom{w}{l}}\frac{w-l}{n-l}\binom{n}{l}\binom{n-l}{w-l}=\frac{w-l}{n-l}\binom{n}{w}.$

∎

######  Corollary 4.5.

$A(\mathcal{J}^{n,w},w-1)=\binom{n-1}{w-1}$ for $n\geq 2w$.

###### Proof.

We have

$A(\mathcal{J}^{n,w},w-1)\leq\max_{l}\frac{w-l}{n-l}\binom{n}{w}\leq\binom{n-1}{w-1}.$

At the same time, a $(w-1)$-code all of whose vectors contain a fixed point is
of size $\binom{n-1}{w-1},$ hence the equality. ∎

Concluding this section, note that the problem of the largest size of codes
with one forbidden intersection in the $q$-ary Hamming space, $q\geq 3$, was
recently resolved in [KLLM21].

##  5\. Using the Delsarte inequalities: Bounds for small $w$

###  5.1. Preliminaries

A powerful tool to estimate the maximum size of a code is provided by
Delsarte’s linear programming bound. We state this bound for
$\mathcal{H}_{2}^{n}$ and $\mathcal{J}^{n,w}$ in the following theorem,
adapting the statements to $s$-codes.

######  Theorem 5.1.

[Del73a] (a) Let $C\subset\mathcal{H}_{2}^{n}$ be an $s$-code with distances
$\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Then $|C|$ is bounded above by the
value of the linear program $\text{LP}_{H}(\mathscr{D})$ given by

(12) $1+\sum_{j=1}^{s}f_{j}\to\max,$

where $f_{j}\geq 0$ for $j=1,\dots,s$ and

(13) $\sum_{j=1}^{s}f_{j}\phi_{k}(d_{j})\geq-\binom{n}{k},\;k=0,\dots,n,$

and $\phi_{k}$ are the Krawtchouk polynomials (1).

(b) Let $C\subset\mathcal{J}^{n,w}$ be a constant weight $s$-code with
distances $\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Then $|C|$ is bounded above
by the value of linear program $\text{{LP}${}_{J}$}(\mathscr{D})$ given by

(14) $1+\sum_{j=1}^{s}f_{j}\to\max,$

where $f_{j}\geq 0$ for $j=1,\dots,s$ and

(15) $\sum_{j=1}^{s}f_{j}\psi_{k}(d_{j})\geq-1,\;k=0,1,\dots,w,$

and $\psi_{k}$ are the Hahn polynomials (2).

Relations (13) and (15) are called the Delsarte inequalities.

The linear programming bounds have been one of the main tools in estimating
the value of $A(M,s)$ for $M=\mathcal{H}_{2}^{n},\,\mathcal{J}^{n,w}$ as well
as for spherical codes. Direct application of these bounds is difficult
because of the need to exhaust all possible subsets $\mathscr{D}$; however it
is possible to restrict the search by using the integrality conditions quoted
in the next theorem.

######  Theorem 5.2.

[MN11] Let $C\subset\mathcal{J}^{n,w}$ be an $s$-code with distances
$\\{d_{1},\dots,d_{s}\\}$. Let $N(\mathcal{J}^{n,w},s)=\binom{n}{s-1}$ and

$K_{i}=\prod_{j\neq i}\frac{d_{j}}{d_{j}-d_{i}}\quad\text{for $i=1,\dots,s$.}$

If $|C|\geq 2N(\mathcal{J}^{n,w},s)$, then $K_{i}$ is an integer and

$|K_{i}|\leq\left\lfloor\frac{1}{2}+\sqrt{\frac{N(\mathcal{J}^{n,w},s)^{2}}{2N(\mathcal{J}^{n,w},s)-2}+\frac{1}{4}}\right\rfloor\quad\text{for
$i=1,\dots,s$.}$

This statement forms an analog of a much earlier result for few-distance sets
in ${\mathbb{R}}^{n}$, namely the Larman-Rogers-Seidel theorem [LRS77]. A
similar set of necessary conditions is also known for the Hamming space
[MN11].

###  5.2. Bounds for $s$-codes with small weight

The following theorem is proved by considering a subset of inequalities in the
LP bound. It allows us to calculate an upper bound of an $s$-code with fixed
distance sets. To obtain an upper bound on $A(\mathcal{J}^{n,w},s),$ we
exhaust all possible $s$-tuples, aided by the conditions in Theorem 5.2.

######  Theorem 5.3.

Let $C\subset\mathcal{J}^{n,w}$ be a $2$-code with distances $d_{1},d_{2}$.
Suppose that for some $k_{1},k_{2}\in\\{1,\dots,w\\}$

(16) $\psi_{k_{1}}(d_{1})\leq\psi_{k_{1}}(d_{2})$ and
$\psi_{k_{2}}(d_{2})\leq\psi_{k_{2}}(d_{1})$, (17)
$\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}>0$,

then

(18) $|C|\leq\frac{\begin{vmatrix}1&1&1\\\
1&\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
1&\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}}{\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}}.$

###### Proof.

Let $(f_{1},f_{2})$ be an optimal solution of Delsarte’s linear program
$\text{LP}_{J}$ (14)-(15), then $|C|\leq 1+f_{1}+f_{2}.$ The coefficients
$f_{1},f_{2}$ satisfy the Delsarte inequalities (15). Consider the
inequalities for a pair of degrees $k=k_{1},k_{2}$. Adding them and using (16)
we obtain

$\displaystyle 0$
$\displaystyle\geq(\psi_{k_{2}}(d_{2})-\psi_{k_{2}}(d_{1}))(1+\psi_{k_{1}}(d_{1})f_{1}+\psi_{k_{1}}(d_{2})f_{2})$
$\displaystyle\hskip
36.135pt+(\psi_{k_{1}}(d_{1})-\psi_{k_{1}}(d_{2}))(1+\psi_{k_{2}}(d_{1})f_{1}+\psi_{k_{2}}(d_{2})f_{2})$
$\displaystyle=\begin{vmatrix}0&-1&-1\\\
1&\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
1&\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}+\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{1}}(d_{2})\\\
\psi_{k_{2}}(d_{1})&\psi_{k_{2}}(d_{2})\end{vmatrix}(f_{1}+f_{2})$
$\displaystyle=\begin{vmatrix}-1&-1&-1\\\
1&\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
1&\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}+\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{1}}(d_{2})\\\
\psi_{k_{2}}(d_{1})&\psi_{k_{2}}(d_{2})\end{vmatrix}(1+f_{1}+f_{2}).$

Now using (17) we obtain the claimed bound. ∎

This theorem enables us to prove a number of exact estimates of
$A(\mathcal{J}^{n,w},2)$ for small $w.$ Before proceeding let us point out a
simple corollary for the case of $d_{1}=1,d_{2}=2.$ This is a known result,
which follows from Erdős-Ko-Rado (Thm. 4.3) supplemented with Wilson’s
theorem; see Sec. 4.2 for details and references.

######  Corollary 5.4.

If $n\geq 3w-3$ then

(19) $A(\mathcal{J}^{n,w},\\{1,2\\})=\binom{n-w+2}{2}.$

###### Proof.

Take in Theorem 5.3 $k_{1}=w,k_{2}=w-1.$ From (2) we find

$\displaystyle\psi_{w}(1)=-\frac{1}{n-w},\;\psi_{w}(2)=\frac{2}{(n-w)(n-w-1)}$
$\displaystyle\psi_{w-1}(1)=\frac{n-3w+2}{w(n-w)},\;\psi_{w-1}(2)=-\frac{2(2n-5w+4)}{w(n-w)(n-w-1)}.$

Then $\psi_{w}(2)-\psi_{w}(1)=\frac{n-w+1}{(n-w)(n-w-1)}\geq 0$ and
$\psi_{w-1}(1)-\psi_{w}(2)=\frac{(n-3w+3)(n-w+2)}{w(n-w-1)(n-w)}\geq 0,$ so
conditions (16) are satisfied. Further,

$\psi_{w}(1)\psi_{w-1}(2)-\psi_{w}(2)\psi_{w-1}(1)=\frac{2(n-2w+2)}{w(n-w-1)(n-w)^{2}}>0,$

so bound (18) applies. Evaluating it, we find that
$A(\mathcal{J}^{n,w},\\{1,2\\})$ is at most the right-hand side of (19).
Finally, Proposition 2.6 implies that (19) holds with equality. ∎

It is interesting that the positivity conditions (16), (17) recover the exact
bound for $n$ in Wilson’s theorem by a seemingly different argument.

Similar considerations enable one to recover some other known bounds for
$A(\mathcal{J}^{n,w},\mathscr{D})$. For instance, for
$\mathscr{D}=\\{w-1,w\\}$ we can take $k_{1}=2,k_{2}=1$ and check that (16),
(17) are satisfied. This yields $A(\mathcal{J}^{n,w},\\{w-1,w\\})\leq
n(n-1)/w(w-1),$ which coincides with the Johnson bound. Similarly, the
inequality $A(\mathcal{J}^{n,w},\\{1,2,3\\})\leq\binom{n-w+3}{3}$ can be
proved by taking $k_{1}=w,k_{2}=w-1,k_{3}=w-2$ and recovering the EKR upper
bound for all $n\geq 4w-8$, which is Wilson’s condition.

In the next theorem we use bound (18) to estimate the maximum size of constant
weight codes with 2 distances irrespective of the values of the distances;
however we will have to assume that the weight $w$ is small.

######  Theorem 5.5.

(a) $A(\mathcal{J}^{n,4},2)=\binom{n-2}{2}$ for $n\geq 9$.

(b) $A(\mathcal{J}^{n,5},2)=\binom{n-3}{2}$ for $n\geq 12$.

(c) $A(\mathcal{J}^{n,6},2)=\binom{n-4}{2}$ for $n\geq 35$.

###### Proof.

We will use Theorem 5.3 with $k_{i}=w+1-d_{i},i=1,2$. The scheme of the proof
is the same for each of the three cases. We illustrate it in detail for Part
(a).

(a) Theorem 5.2 restricts the possible values of distance pairs $d_{1},d_{2}$.
Namely, since $2N(\mathcal{J}^{n,4},2)=2n\leq\binom{n-2}{2}$ for $n\geq 9$, we
only need to consider the pairs $\\{1,2\\}$, $\\{2,3\\}$, $\\{2,4\\}$, and
$\\{3,4\\}$. Now let us use Theorem 5.3. For $\mathscr{D}=\\{1,2\\}$ we have
$k_{1}=4,k_{2}=3.$ Denote
$E_{1}=\psi_{k_{2}}(d_{1})-\psi_{k_{2}}(d_{2}),E_{2}=\psi_{k_{1}}(d_{2})-\psi_{k_{1}}(d_{1}),E_{3}=\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{1}}(d_{2})\\\
\psi_{k_{2}}(d_{1})&\psi_{k_{2}}(d_{2})\end{vmatrix}$, then we obtain

$\displaystyle
E_{1}=\frac{(n-2)(n-9)}{4(n-4)(n-5)},\;E_{2}=\frac{n-3}{(n-4)(n-5)},\;E_{3}=\frac{n-6}{2(n-4)^{2}(n-5)}.$

These fractions are nonnegative for all $n\geq 9,$ and thus from (18) we get

$|C|\leq\frac{(n-2)(n-3)}{2}=\binom{n-2}{2}.$

The remaining three cases are checked in a similar way. The obtained
expressions are listed in Appendix A.1. Altogether this argument proves that
for $n\geq 12$ the value of $A(\mathcal{J}^{n,4},2)\leq\binom{n-2}{2}.$
Together with the construction of Proposition 2.6 and Proposition 6.2, we
obtain the desired result.

(b) Since $2N(\mathcal{J}^{n,5},2)=2n\leq\binom{n-3}{2}$ for $n\geq 10$, by
Theorem 5.2, we only need to consider the distance pairs $\\{1,2\\}$,
$\\{2,3\\}$, $\\{2,4\\}$, $\\{3,4\\}$, $\\{4,5\\}$. The expressions listed in
Appendix A.2 show that $A(\mathcal{J}^{n,5},2)\leq\binom{n-3}{2}$ for $n\geq
18$. Along with the construction given in Proposition 2.6 and Proposition 6.2,
we obtain the desired result.

(c) Since $2N(\mathcal{J}^{n,6},2)=2n\leq\binom{n-4}{2}$ for $n\geq 12$, by
Theorem 5.2, we only need to consider the distance pairs $\\{1,2\\}$,
$\\{2,3\\}$, $\\{2,4\\}$, $\\{3,4\\}$, $\\{3,6\\}$, $\\{4,5\\}$, $\\{4,6\\}$,
$\\{5,6\\}$. The expressions listed in Appendix A.3 show that
$A(\mathcal{J}^{n,6},2)\leq\binom{n-4}{2}$ for $n\geq 35$. Along with the
construction of Proposition 2.6 we obtain the desired result. ∎

Theorem 5.3 affords a generalization for the case of $s$-codes with $s\geq 2.$

######  Theorem 5.6.

Let $C\subset\mathcal{J}^{n,w}$ be a $s$-code with distance
$\\{d_{1},\dots,d_{s}\\}$. Let $k_{1},\dots,k_{s}\in\\{1,\dots,w\\}$ and
$\bar{\psi}_{k}=(\psi_{k}(d_{1}),\dots,\psi_{k}(d_{s}))^{\top}$ for
$k=0,\dots,w$. Suppose that

(21<EMAIL_ADDRESS>3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\dots\hfil\hskip 3.61371pt&\bar{\psi}_{k_{j-1}}\hfil\hskip
3.61371pt&\bar{\psi}_{0}\hfil\hskip 3.61371pt&\bar{\psi}_{k_{j+1}}\hfil\hskip
3.61371pt&\dots\hfil\hskip 3.61371pt&\bar{\psi}_{k_{s}}\end{array}\leq 0$ for
$j=1,\dots,s$, (22)
$(-1)^{s+1}\begin{vmatrix}\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}<0$.

Then

(23) $|C|\leq\frac{\begin{vmatrix}1&1&\dots&1\\\
{\mathbf{1}}&\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}}{\begin{vmatrix}\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}}.$

###### Proof.

Let $(f_{1},\dots,f_{s})$ be an optimal solution of Delsarte’s linear program
$\text{LP}_{J}$ (14)-(15), then $|C|\leq 1+f_{1}+\dots+f_{s}.$ By the Delsarte
inequalities (15),

$1+\sum_{i=1}^{s}\psi_{k}(d_{i})f_{i}\geq 0,k=0,\dots,w.$

We will use a subset of these inequalities for the degrees
$k_{1},\dots,k_{s}$. On account of (21) we obtain

$\displaystyle 0\geq$
$\displaystyle(-1)^{s}\sum_{j=1}^{s}\begin{array}[]{|*7{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{1}\hfil\hskip 3.61371pt&\dots\hfil\hskip
3.61371pt&\bar{\psi}_{k_{j-1}}\hfil\hskip 3.61371pt&\bar{\psi}_{0}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{j+1}}\hfil\hskip 3.61371pt&\dots\hfil\hskip
3.61371pt&\bar{\psi}_{k_{s}}\end{array}\;\Big{(}1+\sum_{t=1}^{s}\psi_{k_{j}}(d_{t})f_{t}\Big{)}$
$\displaystyle=$ $\displaystyle(-1)^{s}\begin{vmatrix}0&-1&\dots&-1\\\
\bar{\psi}_{0}&\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}+(-1)^{s}\begin{vmatrix}\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}\sum_{t=1}^{s}f_{t}.$

Now recalling that $\psi_{0}\equiv 1$ and using assumption (22) we obtain

$1+f_{1}+\dots+f_{s}\leq\frac{\begin{vmatrix}1&1&\dots&1\\\
{\mathbf{1}}&\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}}{\begin{vmatrix}\bar{\psi}_{k_{1}}&\dots&\bar{\psi}_{k_{s}}\end{vmatrix}}.$

∎

In the next two statements we examine a number of implications of this
theorem. For the remainder of this section let $k_{i}=w+1-d_{i}$ for all $i$
as appropriate.

######  Theorem 5.7.

(a) $A(\mathcal{J}^{n,4},3)=\binom{n-1}{3}$ for $n\geq 11$.

(b) $A(\mathcal{J}^{n,5},3)=\binom{n-2}{3}$ for $n\geq 12$.

(b) $A(\mathcal{J}^{n,6},3)=\binom{n-3}{3}$ for $n\geq 16$.

(c) $A(\mathcal{J}^{n,7},3)=\binom{n-4}{3}$ for $n\geq 20$.

Note that Corollary 4.5 implies Part (a), with a stronger bound $n\geq 6.$

###### Proof.

We follow the pattern of Theorem 5.5, supplying details for a part of the
proof and moving the rest to the Appendix.

(a) Begin by noting that Theorem 5.2 restricts the possible values of
$d_{1},d_{2},d_{3}$. Namely, since
$2N(\mathcal{J}^{n,4},3)=2\binom{n}{2}\leq\binom{n-1}{3}$ for $n\geq 11$, we
only need to consider the distance sets $\\{1,2,3\\}$, $\\{1,3,4\\}$,
$\\{2,3,4\\}$. Now let us use Theorem 5.6. For $\mathscr{D}=\\{1,2,3\\}$ we
have $k_{1}=4,k_{2}=3,k_{3}=2.$ Let

$\displaystyle
E_{1}=-\begin{array}[]{|*3{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{0}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\end{array}\,,\;E_{2}=-\begin{array}[]{|*3{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{0}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\end{array}\,,$ $\displaystyle
E_{3}=-\begin{array}[]{|*3{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{0}\end{array}\,,\;E_{4}=\begin{array}[]{|*3{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\end{array}\,.$

We compute

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)\left(n^{2}-14n+51\right)}{24(n-4)(n-5)^{2}(n-6)}\,,\;E_{2}=-\frac{(n-1)(n-3)(n-8)}{6(n-4)^{2}(n-5)(n-6)}\,,$
$\displaystyle\;E_{3}=-\frac{(n-2)(n-3)}{2(n-4)^{2}(n-5)^{2}},\;E_{4}=-\frac{1}{4(n-4)^{2}(n-5)}.$

These fractions are nonpositive for all $n\geq 8,$ and thus from (23) we get

$|C|\leq\frac{(n-1)(n-2)(n-3)}{6}=\binom{n-1}{3}.$

The remaining two cases are checked in a similar way. The obtained expressions
are listed in Appendix A.4. Altogether this argument proves that for $n\geq
11$ the value of $A(\mathcal{J}^{n,4},3)\leq\binom{n-1}{3}.$ Together with the
construction of Proposition 2.6, we obtain the desired result.

(b) Since $2N(\mathcal{J}^{n,5},3)=2\binom{n}{2}\leq\binom{n-2}{3}$ for $n\geq
13$, by Theorem 5.2, we only need to consider the distance triples
$\\{1,2,3\\}$, $\\{1,3,4\\}$, $\\{2,3,4\\}$, $\\{2,3,5\\}$, $\\{3,4,5\\}$. The
expressions listed in Appendix A.5 show that
$A(\mathcal{J}^{n,5},3)\leq\binom{n-2}{3}$ for $n\geq 21$. Along with the
construction in Proposition 2.6 and Proposition 6.3, we obtain the desired
result.

(c) Since $2N(\mathcal{J}^{n,6},3)=2\binom{n}{2}\leq\binom{n-3}{3}$ for $n\geq
15$, by Theorem 5.2, we only need to consider the distance triples
$\\{1,2,3\\}$, $\\{1,3,4\\}$, $\\{2,3,4\\}$, $\\{2,3,5\\}$, $\\{2,4,6\\}$
$\\{3,4,5\\}$, $\\{3,4,6\\}$, $\\{3,5,6\\}$, $\\{4,5,6\\}$. The expressions
listed in Appendix A.6 show that $A(\mathcal{J}^{n,6},3)\leq\binom{n-3}{3}$
for $n\geq 31$. Now Propositions 2.6 and 6.3 imply the desired result.

(d) Since $2N(\mathcal{J}^{n,7},3)=2\binom{n}{2}\leq\binom{n-4}{3}$ for $n\geq
17$, by Theorem 5.2, we only need to consider the distance triples
$\\{1,2,3\\}$, $\\{1,3,4\\}$, $\\{2,3,4\\}$, $\\{2,3,5\\}$, $\\{2,4,6\\}$
$\\{3,4,5\\}$, $\\{3,4,6\\}$, $\\{3,4,7\\}$ $\\{3,5,6\\}$, $\\{4,5,6\\}$,
$\\{4,6,7\\}$, $\\{5,6,7\\}$. The expressions listed in Appendix A.7 show that
$A(\mathcal{J}^{n,7},3)\leq\binom{n-4}{3}$ for $n\geq 50$. As above,
Propositions 2.6 and 6.3 imply the desired result. ∎

######  Theorem 5.8.

(a) $A(\mathcal{J}^{n,5},4)=\binom{n-1}{4}$ for $n\geq 15$.

(b) $A(\mathcal{J}^{n,6},4)=\binom{n-2}{4}$ for $n\geq 15$.

(c) $A(\mathcal{J}^{n,7},4)=\binom{n-3}{4}$ for $n\geq 24$.

Note that Corollary 4.5 implies Part (a), with a stronger bound $n\geq 8.$

###### Proof.

We again follow the pattern of Theorem 5.5 in writing the proof.

(a) Since $2N(\mathcal{J}^{n,5},4)=2\binom{n}{3}\leq\binom{n-1}{4}$ for $n\geq
15$, by Theorem 5.2, we only need to consider the distance tuples
$\\{1,2,3,4\\}$, $\\{2,3,4,5\\}$. Now let us use Theorem 5.6. For
$\mathscr{D}=\\{1,2,3,4\\}$ we have $k_{1}=5,k_{2}=4,k_{3}=3,k_{4}=2.$ Denote

$\displaystyle
E_{1}=\begin{array}[]{|*4{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{0}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{4}}\end{array}\,,\;E_{2}=\begin{array}[]{|*4{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{0}\hfil\hskip 3.61371pt&\bar{\psi}_{k_{3}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{4}}\end{array}\,,\;E_{3}=\begin{array}[]{|*4{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip 3.61371pt&\bar{\psi}_{0}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{4}}\end{array}\,,$ $\displaystyle
E_{4}=\begin{array}[]{|*4{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\hfil\hskip
3.61371pt&\bar{\psi}_{0}\end{array}\,,\;E_{5}=-\begin{array}[]{|*4{@{\hspace{.05in}}c}@{\hspace*{0in}}|}\hskip
3.61371pt\lx@intercol\hfil\bar{\psi}_{k_{1}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{2}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{3}}\hfil\hskip
3.61371pt&\bar{\psi}_{k_{4}}\end{array}\,,$

then we obtain

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-3)(n-4)(n-10)\left(n^{2}-15n+60\right)}{500(n-5)^{2}(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-2)(n-4)^{2}\left(n^{2}-17n+78\right)}{100(n-5)^{3}(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{(n-1)(n-3)(n-4)(n-10)}{25(n-5)^{2}(n-6)^{2}(n-7)^{2}},E_{4}=-\frac{3(n-2)(n-3)(n-4)}{25(n-5)^{3}(n-6)^{2}(n-7)},$
$\displaystyle E_{5}=-\frac{6(n-4)}{125(n-5)^{3}(n-6)(n-7)}.$

These fractions are nonpositive for all $n\geq 10,$ and thus from (23) we get

$|C|\leq\frac{(n-1)(n-2)(n-3)(n-4)}{24}=\binom{n-1}{4}.$

The remaining tuple $\\{2,3,4,5\\}$ is checked in a similar way. The obtained
expressions are listed Appendix A.8. Altogether this argument proves that for
$n\geq 15$ the value of $A(\mathcal{J}^{n,5},4)\leq\binom{n-1}{4}.$ Together
with the construction of Proposition 2.6, we obtain the desired result.

(b) Since $2N(\mathcal{J}^{n,6},4)=2\binom{n}{3}\leq\binom{n-2}{4}$ for $n\geq
17$, by Theorem 5.2, we only need to consider the distance sets
$\\{1,2,3,4\\}$, $\\{1,4,5,6\\}$, $\\{2,3,4,5\\}$, $\\{2,3,4,6\\}$,
$\\{2,4,5,6\\}$, $\\{3,4,5,6\\}$. The expressions listed in Appendix A.9 show
that $A(\mathcal{J}^{n,6},4)\leq\binom{n-2}{4}$ for $n\geq 30$. Now
Proposition 2.6 and Proposition 6.4 imply the desired result.

(c) Since $2N(\mathcal{J}^{n,7},4)=2\binom{n}{3}\leq\binom{n-3}{4}$ for $n\geq
20$, by Theorem 5.2, we only need to consider the distance sets
$\\{1,2,3,4\\}$, $\\{1,4,5,6\\}$, $\\{2,3,4,5\\}$, $\\{2,3,4,6\\}$,
$\\{2,4,5,6\\}$, $\\{3,4,5,6\\}$, $\\{3,4,6,7\\}$, $\\{4,5,6,7\\}$. The
expressions listed in Appendix A.10 show that
$A(\mathcal{J}^{n,7},4)\leq\binom{n-3}{4}$ for $n\geq 45$. As above,
Proposition 2.6 and Proposition 6.4 imply the desired result. ∎

Numerical results obtained in Sec. 6.2 relying on the SDP method imply that
the approach considered in this section generally is not strong enough to
tighten the gap between the lower and upper bounds. The limited scope of
Theorem 5.6 is highlighted already by the case of $w=7,s=2,$ where the
obtained upper bound falls short of reaching $\binom{n-2}{2}$ for large $n$.
See Remark 5.13 for the details.

###  5.3. Upper bounds on $2$-codes for large $n$

From the preceding results it is clear that for large $n$ the size of maximum
2-codes in the Johnson space $\mathcal{J}^{n,w}$ is proportional to $n^{2},$
namely $A(\mathcal{J}^{n,w},2)\leq cn^{2}+o(n^{2}).$ In this section we make
the first term of the asymptotics more precise by evaluating the behavior of
the bound in Theorem 5.3. As a result, we will compute the coefficient
$c=c(w,d_{1},d_{2})$.

We need some asymptotic estimates for the Hahn polynomials. More precise
results are abundant in the literature (e.g., [LW13]); however the simple
bound that stated below is easier to use to compute bounds on codes.

######  Proposition 5.9.

Let $k,x\in\\{1,2,\dots,w\\}.$ As $n\to\infty$, the Hahn polynomial has the
order $\psi_{k}(x)=\frac{1}{\binom{w}{x}}(A+Bn^{-1}+Cn^{-2})+O(n^{-3})$, where

$\displaystyle A$ $\displaystyle=\binom{w-k}{x},$ $\displaystyle B$
$\displaystyle=-kx\binom{w-k+1}{x},$ $\displaystyle C$
$\displaystyle=-kxw\binom{w-k+1}{x}+\frac{k(k-1)x(x-1)}{2}\binom{w-k+2}{x}.$

The proof of this proposition appears in the end of this section.

######  Corollary 5.10.

As $n\to\infty$,

$\displaystyle\psi_{k}(x)\sim\frac{\binom{w-k}{x}}{\binom{w}{x}}\text{ if
}x\leq w-k$ $\displaystyle\psi_{k}(x)\sim\frac{-kx}{\binom{w}{x}}\cdot
n^{-1}\text{ if }x=w-k+1$
$\displaystyle\psi_{k}(x)\sim\frac{k(k-1)x(x-1)}{2\binom{w}{x}}\cdot
n^{-2}\text{ if }x=w-k+2$ $\displaystyle\psi_{k}(x)=O(n^{-3})\text{ if }x\geq
w-k+3.$

The main result of this section is stated next.

######  Theorem 5.11.

As $n\to\infty$, $A(\mathcal{J}^{n,w},\\{d_{1},d_{2}\\})\leq
c(w,d_{1},d_{2})n^{2}(1+o(1)),$ where

(24)
$c(w,d_{1},d_{2})=\begin{cases}\displaystyle\frac{2\binom{w}{d_{2}}}{d_{1}d_{2}(w+1-d_{1})(w+1-d_{2})}&\text{if
}d_{1}=d_{2}-1\\\\[7.22743pt]
\displaystyle\frac{\binom{d_{2}-1}{d_{1}}\binom{w}{d_{2}}}{d_{1}d_{2}(w+1-d_{1})(w+1-d_{2})}&\text{if
}d_{1}<d_{2}-1.\end{cases}$

###### Proof.

First we analyze the case of $d_{1}+1=d_{2}.$ We have
$\psi_{k_{1}}(d_{1})\sim\frac{-k_{1}d_{1}}{\binom{w}{d_{1}}}\cdot n^{-1}$,
$\psi_{k_{1}}(d_{2})\sim\frac{k_{1}k_{2}d_{1}d_{2}}{2\binom{w}{d_{2}}}\cdot
n^{-2}$, $\psi_{k_{2}}(d_{1})\sim\frac{1}{\binom{w}{d_{1}}}$,
$\psi_{k_{2}}(d_{2})\sim\frac{-k_{2}d_{2}}{\binom{w}{d_{2}}}\cdot n^{-1}$. For
sufficiently large $n$, assumptions (16) of Theorem 5.3 holds. The order of
the $2$ by $2$ determinant is

$\begin{vmatrix}\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}\sim\begin{vmatrix}\frac{-k_{1}d_{1}}{\binom{w}{d_{1}}}\cdot
n^{-1}&\frac{1}{\binom{w}{d_{1}}}\\\
\frac{k_{1}k_{2}d_{1}d_{2}}{2\binom{w}{d_{2}}}\cdot
n^{-2}&\frac{-k_{2}d_{2}}{\binom{w}{d_{2}}}\cdot
n^{-1}\end{vmatrix}=\frac{k_{1}k_{2}d_{1}d_{2}}{2\binom{w}{d_{1}}\binom{w}{d_{2}}}\cdot
n^{-2},$

which is positive for sufficiently large $n$, so we can apply the bound (18).
The order of the $3$ by $3$ determinant is

$\begin{vmatrix}1&1&1\\\ 1&\psi_{k_{1}}(d_{1})&\psi_{k_{2}}(d_{1})\\\
1&\psi_{k_{1}}(d_{2})&\psi_{k_{2}}(d_{2})\end{vmatrix}\sim\begin{vmatrix}1&1&1\\\
1&\Theta(n^{-1})&\frac{1}{\binom{w}{d_{1}}}\\\
1&\Theta(n^{-2})&\Theta(n^{-1})\end{vmatrix}=\frac{1}{\binom{w}{d_{1}}}(1+o(1)),$

so the order of the upper bound is
$\frac{2\binom{w}{d_{2}}}{d_{1}d_{2}(w+1-d_{1})(w+1-d_{2})}\cdot n^{2}$.

Now suppose that $d_{1}+1<d_{2},$ then the order of $\psi_{k_{1}}(d_{1})$ and
$\psi_{k_{2}}(d_{2})$ are the same as above,
$\psi_{k_{2}}(d_{1})\sim\frac{\binom{d_{2}-1}{d_{1}}}{\binom{w}{d_{1}}}$, and
$\psi_{k_{1}}(d_{2})=O(n^{-3})$. Similar calculations show that assumptions
(16) and (17) of Theorem 5.3 hold, and the bound (18) gives the order
$\frac{\binom{d_{2}-1}{d_{1}}\binom{w}{d_{2}}}{d_{1}d_{2}(w+1-d_{1})(w+1-d_{2})}\cdot
n^{2}$. ∎

######  Remark 5.12.

The bound of Theorem 5.11 is tight in two notable cases. The case $d_{1}=1$
and $d_{2}=2$, where the correct constant is $c=\frac{1}{2}$, is already
covered by Corollary 5.4. In the case $d_{1}=w-1$ and $d_{2}=w$, Theorem 5.11
implies that $c\leq\frac{1}{w(w-1)}$. On the one hand, this coincides with the
Johnson bound [Joh62] already mentioned above. On the other hand, the
existence of 2-distance sets of this size for sufficiently large $n$
immediately follows from the celebrated work of Wilson on the existence of
balanced incomplete block designs [Wil75].

######  Remark 5.13.

As mentioned above, Theorem 5.6 is not strong enough to determine the bound on
$s$-codes in general, with an example that Theorem 5.6 cannot give an upper
bound $\binom{n-2}{2}$ when $w=7,s=2$. Indeed, consider $d_{1}=2$, $d_{2}=4$
in this case. This pair cannot be ruled out by Theorem 5.2, while Theorem 5.3
can only give an upper bound of $c(7,2,4)\cdot
n^{2}(1+o(1))=\frac{35}{64}n^{2}(1+o(1))$ asymptotically. In general, our
methods cannot deal with any pairs $(d_{1},d_{2})$ such that $d_{2}-d_{1}$
divides $d_{1}$ and $c(w,d_{1},d_{2})\geq\frac{1}{2}$.

Proof of Proposition 5.9 Recall the expression for $\psi_{k}(x)$ in (2). We
begin with finding the order of $\frac{\binom{n+1-k}{j}}{\binom{n-w}{j}}$. By
taking logarithms, we have

$\displaystyle\log\frac{\binom{n+1-k}{j}}{\binom{n-w}{j}}$
$\displaystyle=\log\frac{(n+1-k)\dots(n+2-k-j)}{(n-w)\dots(n-w-j+1)}$
$\displaystyle=\sum_{r=0}^{j-1}\left(\log\left(1-\frac{k+r-1}{n}\right)-\log\left(1-\frac{w+r}{n}\right)\right)$
$\displaystyle=\sum_{r=0}^{j-1}\left(\frac{(w+r)-(k+r-1)}{n}+\frac{(w+r)^{2}-(k+r-1)^{2}}{2n^{2}}\right)+O(n^{-3})$
$\displaystyle=j(w-k+1)\cdot n^{-1}+\frac{j(w-k+1)(j+w+k-2)}{2}\cdot
n^{-2}+O(n^{-3}).$

Expanding $\exp\Big{(}{\log\frac{\binom{n+1-k}{j}}{\binom{n-w}{j}}}\Big{)}$
into a power series, we obtain

$\displaystyle\frac{\binom{n+1-k}{j}}{\binom{n-w}{j}}$
$\displaystyle=1+j(w-k+1)\cdot
n^{-1}+\frac{j(w-k+1)(j+w+k-2)+j^{2}(w-k+1)^{2}}{2}\cdot n^{-2}$
$\displaystyle\quad+O(n^{-3})$ $\displaystyle=1+j(w-k+1)\cdot
n^{-1}+jw(w-k+1)n^{-2}$
$\displaystyle\quad+\frac{j(j-1)(w-k+1)(w-k+2)}{2}\cdot n^{-2}+O(n^{-3}),$

and

(25) $\psi_{k}(x)=\alpha+(w-k+1)\beta n^{-1}+w(w-k+1)\beta
n^{-2}+\binom{w-k+2}{2}\gamma n^{-2}+O(n^{-3}),$

where

$\displaystyle\alpha$
$\displaystyle=\sum_{j=0}^{k}(-1)^{j}\binom{k}{j}\frac{\binom{x}{j}}{\binom{w}{j}}=\frac{1}{\binom{w}{x}}\sum_{j=0}^{k}(-1)^{j}\binom{k}{j}\binom{w-j}{w-x}=\frac{\binom{w-k}{x}}{\binom{w}{x}}$
$\displaystyle\beta$
$\displaystyle=\sum_{j=0}^{k}(-1)^{j}j\binom{k}{j}\frac{\binom{x}{j}}{\binom{w}{j}}=\frac{k}{\binom{w}{x}}\sum_{j=0}^{k}(-1)^{j}\binom{k-1}{j-1}\binom{w-j}{w-x}=-k\frac{\binom{w-k}{x-1}}{\binom{w}{x}}$
$\displaystyle\gamma$
$\displaystyle=\sum_{j=0}^{k}(-1)^{j}j(j-1)\binom{k}{j}\frac{\binom{x}{j}}{\binom{w}{j}}=\frac{k(k-1)}{\binom{w}{x}}\sum_{j=0}^{k}(-1)^{j}\binom{k-2}{j-2}\binom{w-j}{w-x}$
$\displaystyle=k(k-1)\frac{\binom{w-k}{x-2}}{\binom{w}{x}},$

where the last step in each of these three equalities is a version of the
Vandermonde convolution.

##  6\. Numerical results

In this section we list some new numerical results for the size of $s$-codes
with small $s$ together with the previously known results of [BM11, MN11].
While many of them for large values of $n$ are superseded by the general
results listed in Table 1, for small $n$ the methods used in the previous
section are not strong enough to yield exact values. Here the numerical
results are useful in that they enable us to decrease the values on the code
length $n$ starting with which the general bounds apply. Further, the
numerical results also extend to values of $w$ that could not be handled by
the approach of Section 5. The results cited below combine the calculations
performed in [BM11, MN11] with several new sets of parameters found here. The
new sets were obtained by using either LP or Schrijver’s semidefinite
programming bounds (for reference, their statements are listed in Appendix B;
see [Sch05] for a complete treatment).

###  6.1. Bounds for 3-codes in the Hamming space

Unlike the case of $s=2$, for 3 distances we are able to obtain exact values
of $A(\mathcal{H}_{2}^{n},3)$ only for a set of small values of $n$. Namely,
the following is true.

######  Proposition 6.1.

For $8\leq n\leq 22,24\leq n\leq 37$ and $n=44$,
$A(\mathcal{H}_{2}^{n},3)=n+\binom{n}{3}.$

Most of these results were established in [BM11] and [MN11], and our
contribution is the values $n=34,35.$ Calculations are simplified by the
observation that the triples of distances in a 3-code satisfy certain
integrality conditions of LRS type similar to those listed in Theorem 5.2 for
the Johnson space [MN11]. Using them, we computed the upper bounds by
implementing the semidefinite program of Theorem B.1 and performing the
calculations for the allowable triples.

###  6.2. Bounds for $s$-codes in the Johnson space

Previously known explicit bounds for $A(\mathcal{J}^{n,w},2)$, cited from
[BM11, MN11], are as follows. Note that the results for $w=s+1$ are now fully
covered by our Corollary 4.5. The other cited results either augment our
bounds for small $n$, or simply remain the best known where our methods are
not powerful enough.

######  Proposition 6.2.

$A(\mathcal{J}^{n,w},2)=\binom{n-w+2}{2}$ if $n$ and $w$ satisfy one of the
following conditions:

  1. (1)

$w=3$ and $6\leq n\leq 46$;

  2. (2)

$w=4$ and $9\leq n\leq 46$;

  3. (3)

$w=5$ and $12\leq n\leq 46$;

  4. (4)

$w=6$ and $15\leq n\leq 24$ or $35\leq n\leq 46$ .

These results supplement the LP proof of Theorem 5.5 by lowering the smallest
value of $n$ for which the claims in the theorem apply. For $w=4,5,6$ the
added lengths are $9\leq n\leq 11,12\leq n\leq 17,$ and $15\leq n\leq 24$,
respectively.

Similarly, for $3$-codes we have the following statement due to [MN11] except
for the case $(n,w)=(12,5)$ which is new.

######  Proposition 6.3.

$A(\mathcal{J}^{n,w},3)=\binom{n-w+3}{3}$ if $n$ and $w$ satisfy one of the
following conditions:

  1. (1)

$w=4$ and $11\leq n\leq{58}$;

  2. (2)

$w=5$ and $12\leq n\leq{58}$;

  3. (3)

$w=6$ and $16\leq n\leq{58}$;

  4. (4)

$w=7$ and $20\leq n\leq{58}$;

  5. (5)

$w=8$ and $25\leq n\leq{58}$.

As above, Part (a) is completely covered by Cor 4.5. For $w=5,6,7$ these
results add a number of small values of $n$ to the LP proofs of Theorem 5.7:
namely, the added lengths are $12\leq n\leq 20,16\leq n\leq 30$, and $20\leq
n\leq 49$, respectively. For $w=8$ the LP argument does not yield any results,
so part (4) above remains the state of the art.

To obtain the result for the new pair $(12,5)$ we sharpened the calculation of
[MN11] as follows. Recall that the generalized LRS theorem (Theorem 5.2) gives
necessary integrality conditions for the distances of an $s$-code of
sufficiently large size. For the distances that satisfy these conditions, the
authors of [MN11] used the LP and harmonic bounds, arriving at their results.
At the same time, for the other cases, i.e., when the conditions are not
satisfied, they used a trivial upper bound $2N(\mathcal{J}^{n,w},s)-1$ on the
size of the code. We examined all the possible distance sets when the
$2N(\mathcal{J}^{n,w},s)-1$ is larger than $\binom{n-w+s}{s}$ in Proposition
2.6 and managed to rule them out using the LP bound. Moreover, we observed
that the LP bound applies for $n\leq 58$ while [MN11] has $n=50$ as the upper
limit in their statement.

Using the same approach for $s=4$, we managed to add two new sets of
parameters $(n,w)=(15,6),(16,6)$ to the results of [MN11]. These results are
collected in the next statement.

######  Proposition 6.4.

$A(\mathcal{J}^{n,w},4)=\binom{n-w+4}{4}$ if $n$ and $w$ satisfy one of the
following conditions:

  1. (1)

$w=5$ and $15\leq n\leq 70$;

  2. (2)

$w=6$ and $15\leq n\leq 70$;

  3. (3)

$w=7$ and $20\leq n\leq 70$;

  4. (4)

$w=8$ and $25\leq n\leq 70$;

  5. (5)

$w=9$ and $30\leq n\leq 70$;

  6. (6)

$w=10$ and $35\leq n\leq 40$ or $48\leq n\leq 70$;

  7. (7)

$w=11$ and $60\leq n\leq 70$.

For $w=6$ these results augment our LP proof in Theorem 5.8 to $n$ in the
segment $15\leq n\leq 29$, and for $n=7$ they contribute the values $20\leq
n\leq 44.$ For larger $w$ these results remain the best known.

In solving LP problems we relied on Mathematica, while for SDP problems we
used MATLAB with CVX toolbox [GB08],[GB14] and the MOSEK solver. All of our
source codes can be found on github:

https://github.com/PinChiehTseng/s-distance-set.

## Acknowledgement

We would like to thank Hiroshi Nozaki for helpful discussions.

AB was supported by NSF grant CCF2104489 and NSF-BSF grant CCF2110113. AG was
supported by NSF grant DMS-2054536. PCT and CYL were supported by the Ministry
of Science and Technology (MOST) in Taiwan under Grant MOST110-2628-E-A49-007,
MOST111-2119-M-A49-004, and MOST111-2119-M-001-002. WHY was supported by MOST
under Grant109-2628-M-008-002-MY4.

## References

  * [BB05] E. Bannai and E. Bannai.  A note on the spherical embeddings of strongly regular graphs.  European J. Combin., 26(8):1177–1179, 2005.  doi:10.1016/j.ejc.2004.07.003.
  * [BDKS18] I. Balla, F. Dräxler, P. Keevash, and B. Sudakov.  Equiangular lines and spherical codes in Euclidean space.  Invent. Math., 211(1):179–212, 2018.  doi:10.1007/s00222-017-0746-0.
  * [BDZZ21] P. Boyvalenkov, K. Delchev, D.V. Zinoviev, and V.A. Zinoviev.  On two-weight codes.  Discrete Math., 344(5):112318, 2021.  doi:10.1016/j.disc.2021.112318.
  * [BGOY15] A. Barg, A. Glazyrin, K. A. Okoudjou, and W.-H. Yu.  Finite two-distance tight frames.  Linear Algebra Appl., 475:163–175, 2015.  doi:10.1016/j.laa.2015.02.020.
  * [BM11] A. Barg and O. Musin.  Bounds on sets with few distances.  J. Comb. Theory Ser. A., 118(4):1465–1474, 2011.  doi:10.1016/j.jcta.2011.01.002.
  * [BM22] A. E. Brouwer and H. Van Maldeghem.  Strongly regular graphs, volume 182 of Encyclopedia of Mathematics and its Applications.  Cambridge University Press, Cambridge, New York, 2022.  doi:10.1017/9781009057226.014.
  * [BY13a] A. Barg and W.-H. Yu.  New bounds for equiangular lines.  In A. Barg and O. Musin, editors, Discrete Geometry and Algebraic Combinatorics, volume 625 of Contemporary Mathematics, pages 111–121. AMS, 2013.
  * [BY13b] A. Barg and W.-H. Yu.  New bounds for spherical two-distance sets.  Experimental Mathematics, 22(2):187–194, 2013.  doi:10.1080/10586458.2013.767725.
  * [CK86] R. Calderbank and W. M. Kantor.  The geometry of two-weight codes.  Bull. London Math. Soc., 18(2):97–122, 1986.  doi:10.1112/blms/18.2.97.
  * [Del73a] P. Delsarte.  An algebraic approach to the association schemes of coding theory.  Philips Res. Repts. Suppl., 10:880–886, 1973.
  * [Del73b] P. Delsarte.  Four fundamental parameters of a code and their combinatorial significance.  Inf. Control, 23(5):407–438, 1973.
  * [DGS77] P. Delsarte, J. M. Goethals, and J. J. Seidel.  Spherical codes and designs.  Geom. Dedicata, 6:363–388, 1977.  doi:10.1007/BF03187604.
  * [Din16] C. Ding.  A construction of binary linear codes from Boolean functions.  Discrete Math., 339(9):2288–2303, 2016.  doi:10.1016/j.disc.2016.03.029.
  * [EKR61] P. Erdős, C. Ko, and R. Rado.  Intersection theorems for systems of finite sets.  Quart. J. Math. Oxford, 12(12):313–320, 1961.  doi:10.1093/qmath/12.1.313.
  * [Ell22] D. Ellis.  Intersection problems in extremal combinatorics: theorems, techniques and questions old and new.  In Surveys in combinatorics 2022, volume 481 of London Math. Soc. Lecture Note Ser., pages 115–173. Cambridge Univ. Press, Cambridge, 2022.
  * [ES66a] S. J. Einhorn and I. J. Schoenberg.  On Euclidean sets having only two distances between points. I.  Akad. Wetensch. Proc. Ser. A 69=Indag. Math., 28:479–488, 1966\.
  * [ES66b] S. J. Einhorn and I. J. Schoenberg.  On Euclidean sets having only two distances between points. II.  Akad. Wetensch. Proc. Ser. A 69=Indag. Math., 28:489–504, 1966\.
  * [FF85] P. Frankl and Z. Füredi.  Forbidding just one intersection.  J. Combin. Theory Ser. A, 39:160–176, 1985.  doi:10.1016/0097-3165(85)90035-4.
  * [FT18] P. Frankl and N. Tokushige.  Extremal problems for finite sets, volume 86 of Student Mathematical Library.  American Mathematical Society, Providence, RI, 2018.
  * [GB08] M. Grant and S. Boyd.  Graph implementations for nonsmooth convex programs.  In V. Blondel, S. Boyd, and H. Kimura, editors, Recent Advances in Learning and Control, Lecture Notes in Control and Information Sciences, pages 95–110. Springer-Verlag Limited, 2008.  doi:10.1007/978-1-84800-155-8_7.
  * [GB14] M. Grant and S. Boyd.  CVX: MATLAB software for disciplined convex programming, version 2.1.  http://cvxr.com/cvx, 4 2014.
  * [GM16] C. Godsil and K. Meagher.  Erdős-Ko-Rado theorems: algebraic approaches, volume 149 of Cambridge Studies in Advanced Mathematics.  Cambridge University Press, Cambridge, Cambridge, UK, 2016.
  * [GMS12] D. Gijswijt, H. Mittelmann, and A. Schrijver.  Semidefinite code bounds based on quadruple distances.  IEEE Trans. Inf. Theory, 58(5):2697–2705, 2012.  doi:10.1109/TIT.2012.2184845.
  * [GY18] A. Glazyrin and W.-H. Yu.  Upper bounds for s-distance sets and equiangular lines.  Adv. Math., 330:810–833, 2018.  doi:10.1016/j.aim.2018.03.024.
  * [Joh62] S. Johnson.  A new upper bound for error-correcting codes.  IRE Trans. Inf. Theory, 8(3):203–207, 1962.  doi:10.1109/TIT.1962.1057714.
  * [JTY+20] Z. Jiang, J. Tidor, Y. Yao, S. Zhang, and Y. Zhao.  Spherical two-distance sets and eigenvalues of signed graphs, 2020.  URL: https://arxiv.org/abs/2006.06633.
  * [JTY+21] Z. Jiang, J. Tidor, Y. Yao, S. Zhang, and Y. Zhao.  Equiangular lines with a fixed angle.  Ann. of Math. (2), 194(3):729–743, 2021.  doi:10.4007/annals.2021.194.3.3.
  * [KLLM21] P. Keevash, N. Lifshitz, E. Long, and D. Minzer.  Forbidden intersections for codes, 2021.  URL: https://arxiv.org/abs/2103.05050.
  * [LLHQ21] K. Li, C. Li, T. Helleseth, and L. Qu.  Binary linear codes with few weights from two-to-one functions.  IEEE Trans. Inform. Theory, 67(7):4263–4275, 2021.  doi:10.1109/TIT.2021.3068743.
  * [LR21] I. Landjev and A. Rousseva.  On the maximal cardinality of binary two-weight codes.  C.R. Acad. Bulgaire Sci., 74(10):1423–1430, 2021.  doi:10.7546/CRABS.2021.10.01.
  * [LRS77] D.G. Larman, C.A. Rogers, and J.J. Seidel.  On two-distance sets in Euclidean space.  Bull. London Math. Soc., 9(3):261–267, 1977.  doi:10.1112/blms/9.3.261.
  * [LS73] P. W. H. Lemmens and J. J. Seidel.  Equiangular lines.  J. Algebra, 24:494–512, 1973.  doi:10.1016/0021-8693(73)90123-3.
  * [LW13] Y. Lin and H. Wong.  Global asymptotics of the Hahn polynomials.  Anal. Appl., 11(3):1350018 (47 pages), 2013.  doi:10.1142/S0219530513500188.
  * [LY20] F.-Y. Liu and W.-H. Yu.  Semidefinite programming bounds for spherical three-distance sets.  arXiv preprint arXiv:2005.01324, 2020.
  * [Mes16] S. Mesnager.  Bent Functions. Fundamentals and Results.  Springer Nature, Switzerland, 2016.  doi:10.1007/978-3-319-32595-8.
  * [MN11] O. Musin and H. Nozaki.  Bounds on three- and higher-distance sets.  Eur. J. Comb., 32(8):1182–1190, 2011.  doi:10.1016/j.ejc.2011.03.003.
  * [MS77] F. J. MacWilliams and N. J. A. Sloane.  The theory of error correcting codes.  Elsevier, North Holland, 1977.
  * [Mus09] O. R. Musin.  Spherical two-distance sets.  J. Combin. Theory Ser. A, 116(4):988–995, 2009.  doi:10.1016/j.jcta.2008.09.003.
  * [Noz11] H. Nozaki.  A generalization of Larman-Rogers-Seidel’s theorem.  Discrete Math., 311(10):792–799, 2011.  doi:10.1016/j.disc.2011.01.026.
  * [NS10] H. Nozaki and M. Shinohara.  On a generalization of distance sets.  J. Comb. Theory Ser. A., 117(7):810–826, 2010.  doi:10.1016/j.jcta.2009.11.001.
  * [NS21] H. Nozaki and M. Shinohara.  A proof of a dodecahedron conjecture for distance sets.  Graphs Combin., 37(5):1585–1603, 2021.  doi:10.1007/s00373-021-02318-5.
  * [Ran55] R. A. Rankin.  The closest packing of spherical caps in $n$ dimensions.  Glasg. Math. J., 2(3):139–144, 1955.  doi:10.1017/S2040618500033219.
  * [Sch05] A. Schrijver.  New code upper bounds from the Terwilliger algebra and semidefinite programming.  IEEE Trans. Inf. Theory, 51(8):2859–2866, 2005.  doi:10.1109/TIT.2005.851748.
  * [SHS+21] M. Shi, T. Honold, P. Solé, Y. Qiu, R. Wu, and Z. Sepasdar.  The geometry of two-weight codes over $\mathbb{Z}_{p^{m}}$.  IEEE Trans. Inform. Theory, 67(12):7769–7781, 2021.  doi:10.1109/TIT.2021.3114636.
  * [Wil75] R. M. Wilson.  An existence theory for pairwise balanced designs. III. Proof of the existence conjectures.  J. Combinatorial Theory Ser. A, 18:71–79, 1975.  doi:10.1016/0097-3165(75)90067-9.
  * [Wil84] R. M. Wilson.  The exact bound in the Erdős-Ko-Rado theorem.  Combinatorica, 4(2-3):247–257, 1984.  doi:10.1007/BF02579226.
  * [WZHZ15] X. Wang, D. Zheng, L. Hu, and X. Zeng.  The weight distributions of two classes of binary cyclic codes.  Finite Fields Appl., 34:192–207, 2015.  doi:10.1016/j.ffa.2015.01.012.
  * [Yu17] W.-H. Yu.  New bounds for equiangular lines and spherical two-distance sets.  SIAM J. Discrete Math., 31(2):908–917, 2017.  doi:10.1137/16M109377X.

## Appendix A

††footnotetext:  Note: The material in Appendices A and B serves as
supplementary data for the main text of the paper. It will appear in the
preprint version of this manuscript, but is not intended to be a part of the
published journal paper.

In this appendix we list the expressions that support proofs of the statements
of Theorems 5.5 to 5.8.

###  A.1. The case $w=4,s=2$

  1. (i)

$\mathscr{D}=\\{1,2\\}$

$\displaystyle
E_{1}=\frac{(n-9)(n-2)}{4(n-4)(n-5)},\;E_{2}=\frac{n-3}{(n-4)(n-5)},\;E_{3}=\frac{n-6}{2(n-4)^{2}(n-5)},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)}{2}=\binom{n-2}{2}.$

This bound holds true for $n\geq 9$.

  2. (ii)

$\mathscr{D}=\\{2,3\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-11)}{6(n-4)(n-5)},E_{2}=\frac{(n-2)(2n-15)}{2(n-4)(n-5)(n-6)},E_{3}=\frac{3n^{2}-41n+142}{4(n-4)(n-5)^{2}(n-6)},$
$\displaystyle|C|\leq\frac{(n-2)(n-1)\left(2n^{2}-28n+93\right)}{3\left(3n^{2}-41n+142\right)}\leq\binom{n-2}{2}.$

This bound holds true for $n\geq 11.$

  3. (iii)

$\mathscr{D}=\\{2,4\\}$

$\displaystyle
E_{1}=\frac{n}{2(n-4)},E_{2}=\frac{(n-2)(n-12)}{(n-4)(n-5)(n-6)},E_{3}=\frac{4(n-3)(n-8)}{(n-6)(n-5)(n-4)^{2}},$
$\displaystyle|C|\leq\frac{n(n-2)}{8}\leq\binom{n-2}{2}.$

This bound holds true for $n\geq 12.$

  4. (iv)

$\mathscr{D}=\\{3,4\\}$

$\displaystyle
E_{1}=\frac{n}{4(n-4)},E_{2}=\frac{3(n-1)}{2(n-4)(n-5)},E_{3}=\frac{3(n-2)}{(n-4)^{2}(n-5)},$
$\displaystyle|C|\leq\frac{n(n-1)}{12}\leq\binom{n-2}{2}.$

This bound holds true for $n\geq 6.$

###  A.2. The case $w=5,s=2$

  1. (i)

$\mathscr{D}=\\{1,2\\}$

$\displaystyle
E_{1}=\frac{(n-3)(n-12)}{5(n-5)(n-6)},E_{2}=\frac{n-4}{(n-5)(n-6)},E_{3}=\frac{2(n-8)}{5(n-5)^{2}(n-6)},$
$\displaystyle|C|\leq\frac{1}{2}(n-4)(n-3)=\binom{n-3}{2}.$

This bound holds true for $n\geq 12$.

  2. (ii)

$\mathscr{D}=\\{2,3\\}$

$\displaystyle
E_{1}=\frac{(n-2)(n^{2}-25n+138)}{10(n-5)(n-6)(n-7)},E_{2}=\frac{4(n-3)(n-10)}{5(n-5)(n-6)(n-7)},$
$\displaystyle
E_{3}=\frac{3\left(3n^{2}-55n+258\right)}{25(n-5)^{2}(n-6)(n-7)},$
$\displaystyle|C|\leq\frac{(n-3)(n-2)\left(5n^{2}-95n+408\right)}{6\left(3n^{2}-55n+258\right)}\leq\binom{n-3}{2}.$

This bound holds true for $n\geq 17$.

  3. (iii)

$\mathscr{D}=\\{2,4\\}$

$\displaystyle
E_{1}=\frac{(n-1)(3n-38)}{10(n-5)(n-6)},E_{2}=\frac{2(n-3)(2n^{2}-45n+244)}{5(n-5)(n-6)(n-7)(n-8)},$
$\displaystyle
E_{3}=\frac{4\left(8n^{3}-236n^{2}+2265n-7062\right)}{25(n-5)(n-6)^{2}(n-7)(n-8)},$
$\displaystyle|C|\leq\frac{(n-3)(n-1)\left(15n^{3}-420n^{2}+3764n-10832\right)}{8\left(8n^{3}-236n^{2}+2265n-7062\right)}\leq\binom{n-3}{2}.$

This bound holds true for $n\geq 14.$

  4. (iv)

$\mathscr{D}=\\{3,4\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-18)}{10(n-5)(n-6)},E_{2}=\frac{9(n-2)(n-11)}{10(n-5)(n-6)(n-7)},$
$\displaystyle
E_{3}=\frac{6(n-4)\left(3n^{2}-59n+306\right)}{25(n-7)(n-6)^{2}(n-5)^{2}},$
$\displaystyle|C|\leq\frac{(n-2)(n-1)\left(5n^{2}-105n+486\right)}{12\left(3n^{2}-59n+306\right)}\leq\binom{n-3}{2}.$

This bound holds true for $n\geq 18.$

  5. (v)

$\mathscr{D}=\\{4,5\\}$

$\displaystyle
E_{1}=\frac{n}{5(n-5)},E_{2}=\frac{8(n-1)}{5(n-5)(n-6)},E_{3}=\frac{4(n-2)}{(n-5)^{2}(n-6)},$
$\displaystyle|C|\leq\frac{1}{20}(n-1)n\leq\binom{n-3}{2}.$

This bound holds true for $n\geq 7.$

###  A.3. The case $w=6,s=2$

  1. (i)

$\mathscr{D}=\\{1,2\\}$

$\displaystyle
E_{1}=\frac{(n-4)(n-15)}{6(n-6)(n-7)},E_{2}=\frac{n-5}{(n-6)(n-7)},E_{3}=\frac{n-10}{3(n-6)^{2}(n-7)},$
$\displaystyle|C|\leq\frac{(n-4)(n-5)}{2}=\binom{n-4}{2}.$

This bound holds true for $n\geq 15$.

  2. (ii)

$\mathscr{D}=\\{2,3\\}$

$\displaystyle
E_{1}=\frac{(n-3)\left(n^{2}-33n+236\right)}{15(n-6)(n-7)(n-8)},E_{2}=\frac{(n-4)(2n-25)}{3(n-6)(n-7)(n-8)},E_{3}=\frac{n^{2}-23n+136}{5(n-6)^{2}(n-7)^{2}},$
$\displaystyle|C|\leq\frac{(n-3)(n-4)(n^{2}-24n+125)}{3(n^{2}-23n+136)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 23.$

  3. (iii)

$\mathscr{D}=\\{2,4\\}$

$\displaystyle
E_{1}=\frac{(n-2)\left(n^{2}-27n+172\right)}{5(n-6)(n-7)(n-8)},E_{2}=\frac{2(n-4)(n-11)(n-15)}{3(n-6)(n-7)(n-8)(n-9)},$
$\displaystyle
E_{3}=\frac{8(n-12)\left(n^{2}-27n+167\right)}{15(n-6)^{2}(n-7)(n-8)(n-9)},$
$\displaystyle|C|\leq\frac{(n-2)(n-4)(3n^{3}-104n^{2}+1145n-4020)}{8(n-12)(n^{2}-27n+167)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 35.$

  4. (iv)

$\mathscr{D}=\\{3,4\\}$

$\displaystyle
E_{1}=\frac{(n-2)(n-11)(n-28)}{20(n-6)(n-7)(n-8)},E_{2}=\frac{(n-3)\left(3n^{2}-75n+452\right)}{5(n-6)(n-7)(n-8)(n-9)},$
$\displaystyle
E_{3}=\frac{2\left(3n^{4}-136n^{3}+2334n^{2}-17831n+50916\right)}{25(n-9)(n-8)^{2}(n-7)^{2}(n-6)},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)(5n^{4}-240n^{3}+4019n^{2}-28528n+73488)}{8(3n^{4}-136n^{3}+2334n^{2}-17831n+50916)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 28$.

  5. (v)

$\mathscr{D}=\\{3,6\\}$

$\displaystyle
E_{1}=\frac{n}{2(n-6)},E_{2}=\frac{3(n-3)\left(n^{2}-33n+316\right)}{5(n-6)(n-7)(n-8)(n-9)},$
$\displaystyle
E_{3}=\frac{18(n-4)\left(n^{2}-32n+237\right)}{5(n-6)^{2}(n-7)(n-8)(n-9)},$
$\displaystyle|C|\leq\frac{n(n-3)(5n^{2}-109n+636)}{36(n^{2}-32n+237)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 27.$

  6. (vi)

$\mathscr{D}=\\{4,5\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-27)}{15(n-6)(n-7)},E_{2}=\frac{2(n-2)(2n-31)}{5(n-6)(n-7)(n-8)},E_{3}=\frac{2(n-4)\left(n^{2}-27n+200\right)}{3(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n^{2}-30n+181)}{10(n^{2}-27n+200)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 27.$

  7. (vii)

$\mathscr{D}=\\{4,6\\}$

$\displaystyle
E_{1}=\frac{n}{3(n-6)},E_{2}=\frac{4(n-2)(n-28)}{5(n-6)(n-7)(n-8)},E_{3}=\frac{8(n-3)(3n-56)}{5(n-6)^{2}(n-7)(n-8)},$
$\displaystyle|C|\leq\frac{n(n-2)(5n-68)}{24(3n-56)}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 28.$

  8. (viii)

$\mathscr{D}=\\{5,6\\}$

$\displaystyle
E_{1}=\frac{n}{6(n-6)},E_{2}=\frac{5(n-1)}{3(n-6)(n-7)},E_{3}=\frac{5(n-2)}{(n-6)^{2}(n-7)},$
$\displaystyle|C|\leq\frac{n(n-1)}{30}\leq\binom{n-4}{2}.$

This bound holds true for $n\geq 8.$

###  A.4. The case $w=4,s=3$

  1. (i)

$\mathscr{D}=\\{1,2,3\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)\left(n^{2}-14n+51\right)}{24(n-4)(n-5)^{2}(n-6)},\;E_{2}=-\frac{(n-1)(n-3)(n-8)}{6(n-4)^{2}(n-5)(n-6)},$
$\displaystyle\;E_{3}=-\frac{(n-2)(n-3)}{2(n-4)^{2}(n-5)^{2}},\;E_{4}=-\frac{1}{4(n-4)^{2}(n-5)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n-3)}{6}=\binom{n-1}{3}.$

This bound holds true for $n\geq 8$.

  2. (ii)

$\mathscr{D}=\\{1,3,4\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)}{8(n-4)^{2}(n-5)},E_{2}=-\frac{n(n-3)(n-11)}{4(n-4)(n-5)(n-6)(n-7)},$
$\displaystyle
E_{3}=-\frac{3(n-1)(n-3)(n-8)}{2(n-4)^{2}(n-5)(n-6)(n-7)},E_{4}=-\frac{3(n-2)}{(n-4)^{2}(n-5)(n-7)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-3)(n-8)}{24(n-6)}\leq\binom{n-1}{3}.$

This bound holds true for $n\geq 11.$

  3. (iii)

$\mathscr{D}=\\{2,3,4\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)}{24(n-4)^{2}(n-5)},E_{2}=-\frac{n(n-2)(n-3)}{4(n-4)^{2}(n-5)(n-6)},$
$\displaystyle
E_{3}=-\frac{3(n-1)(n-2)}{4(n-4)(n-5)^{2}(n-6)},E_{4}=-\frac{(n-2)(n-3)}{(n-4)^{2}(n-5)^{2}(n-6)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)}{24}\leq\binom{n-1}{3}.$

This bound holds true for $n\geq 7.$

###  A.5. The case $w=5,s=3$

  1. (i)

$\mathscr{D}=\\{1,2,3\\}$

$\displaystyle
E_{1}=-\frac{(n-2)(n-3)\left(n^{2}-19n+96\right)}{50(n-5)^{2}(n-6)(n-7)},E_{2}=-\frac{(n-2)(n-4)(n-12)}{10(n-5)^{2}(n-6)^{2}},$
$\displaystyle
E_{3}=-\frac{2(n-3)(n-4)(n-8)}{5(n-5)^{2}(n-6)^{2}(n-7)},E_{4}=-\frac{3(n-8)}{25(n-5)^{3}(n-6)},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)(n-4)}{6}\leq\binom{n-2}{3}.$

This bound holds true for $n\geq 12.$

  2. (ii)

$\mathscr{D}=\\{1,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-4)(n-9)(n-12)}{25(n-5)^{2}(n-6)^{2}(n-7)},E_{2}=-\frac{(n-1)(n-4)\left(n^{2}-29n+174\right)}{10(n-5)^{2}(n-6)(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{3(n-2)(n-4)\left(3n^{2}-55n+246\right)}{10(n-5)^{2}(n-6)^{2}(n-7)(n-8)},E_{4}=-\frac{6(n-4)\left(3n^{2}-53n+244\right)}{25(n-5)^{3}(n-6)(n-7)(n-8)},$
$\displaystyle|C|\leq\frac{\left(n-1\right)\left(n-2\right)\left(n-4\right)\left(2n^{2}-43n+219\right)}{12\left(3n^{2}-53n+244\right)}\leq\binom{n-2}{3}.$

This bound holds true for $n\geq 21.$

  3. (iii)

$\mathscr{D}=\\{2,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-4)\left(n^{2}-21n+126\right)}{100(n-5)^{2}(n-6)^{2}(n-7)},$
$\displaystyle
E_{2}=-\frac{2(n-1)(n-3)(n-10)(n-12)}{25(n-5)(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{3(n-2)(n-3)\left(3n^{2}-53n+236\right)}{25(n-5)^{2}(n-6)(n-7)^{2}(n-8)},$
$\displaystyle
E_{4}=-\frac{6(n-4)\left(4n^{3}-99n^{2}+819n-2274\right)}{125(n-5)^{2}(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n-3)\left(5n^{3}-125n^{2}+1050n-2904\right)}{24\left(4n^{3}-99n^{2}+819n-2274\right)}\leq\binom{n-2}{3}.$

This bound holds true for $n\geq 12.$

  4. (iv)

$\mathscr{D}=\\{2,3,5\\}$

$\displaystyle
E_{1}=-\frac{n(n-2)(n-3)(2n-35)}{50(n-5)^{2}(n-6)(n-7)},E_{2}=-\frac{2n(n-3)(n-4)(4n-47)}{25(n-5)^{2}(n-6)(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{3(n-2)(n-3)\left(3n^{2}-85n+508\right)}{25(n-5)^{2}(n-6)(n-7)^{2}(n-8)},E_{4}=-\frac{3(n-3)(n-4)\left(3n^{2}-55n+254\right)}{5(n-5)^{3}(n-6)(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{n(n-2)(n-3)\left(2n^{2}-45n+229\right)}{30\left(3n^{2}-55n+254\right)}\leq\binom{n-2}{3}.$

This bound holds true for $n\geq 20.$

  5. (v)

$\mathscr{D}=\\{3,4,5\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)}{50(n-5)^{2}(n-6)},E_{2}=-\frac{9n(n-2)(n-3)}{50(n-5)^{2}(n-6)(n-7)},$
$\displaystyle
E_{3}=-\frac{18(n-1)(n-2)(n-4)}{25(n-5)^{2}(n-6)^{2}(n-7)},E_{4}=-\frac{6(n-2)(n-3)(n-4)}{5(n-5)^{3}(n-6)^{2}(n-7)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)}{60}\leq\binom{n-2}{3}.$

This bound holds true for $n\geq 8.$

###  A.6. The case $w=6,s=3$

  1. (i)

$\mathscr{D}=\\{1,2,3\\}$

$\displaystyle
E_{1}=-\frac{(n-3)(n-4)\left(n^{2}-24n+155\right)}{90(n-6)^{2}(n-7)^{2}},E_{2}=-\frac{(n-3)(n-5)(n-9)(n-16)}{15(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle
E_{3}=-\frac{(n-4)(n-5)(n-10)}{3(n-6)^{2}(n-7)^{2}(n-8)},E_{4}=-\frac{(n-9)(n-10)}{15(n-6)^{3}(n-7)^{2}},$
$\displaystyle|C|\leq\frac{(n-3)(n-4)(n-5)}{6}=\binom{n-3}{3}.$

This bound holds true for $n\geq 16.$

  2. (ii)

$\mathscr{D}=\\{1,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-2)(n-3)\left(5n^{4}-240n^{3}+4187n^{2}-31704n+88304\right)}{300(n-6)(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-2)(n-5)\left(n^{3}-50n^{2}+685n-2832\right)}{20(n-6)^{2}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{3}=-\frac{(n-3)(n-5)\left(3n^{2}-68n+368\right)}{5(n-6)^{2}(n-7)^{2}(n-8)^{2}},E_{4}=-\frac{2\left(3n^{2}-70n+433\right)}{25(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)(n-5)\left(5n^{2}-145n+932\right)}{24\left(3n^{2}-70n+433\right)}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 31.$

  3. (iii)

$\mathscr{D}=\\{2,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-2)(n-3)\left(n^{4}-48n^{3}+895n^{2}-7464n+23152\right)}{300(n-6)(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-2)(n-4)(n-12)\left(n^{2}-28n+175\right)}{30(n-6)^{2}(n-7)(n-8)^{2}(n-9)},$
$\displaystyle
E_{3}=-\frac{(n-3)(n-4)\left(3n^{2}-67n+380\right)}{15(n-6)^{2}(n-7)^{2}(n-8)(n-9)},E_{4}=-\frac{2(n-12)\left(2n^{2}-39n+199\right)}{75(n-6)^{2}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)(n-4)\left(n^{3}-32n^{2}+347n-1220\right)}{8(n-12)\left(2n^{2}-39n+199\right)}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 19.$

  4. (iv)

$\mathscr{D}=\\{2,3,5\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-3)(n-5)\left(3n^{3}-140n^{2}+2081n-9876\right)}{225(n-6)^{2}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-4)\left(6n^{3}-238n^{2}+3057n-12785\right)}{45(n-6)(n-7)^{2}(n-8)(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{(n-3)(n-4)\left(n^{3}-43n^{2}+586n-2580\right)}{5(n-6)^{2}(n-7)^{2}(n-8)(n-9)(n-10)},$
$\displaystyle
E_{4}=-\frac{(n-5)\left(5n^{4}-230n^{3}+3909n^{2}-29144n+80432\right)}{15(n-6)^{2}(n-7)^{3}(n-8)(n-9)(n-10)},$
$\displaystyle|C|\leq\frac{(n-1)(n-3)(n-4)\left(3n^{4}-149n^{3}+2660n^{2}-20293n+55840\right)}{15\left(5n^{4}-230n^{3}+3909n^{2}-29144n+80432\right)}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 22.$

  5. (v)

$\mathscr{D}=\\{2,4,6\\}$

$\displaystyle E_{1}=-\frac{n(n-2)(n-3)(n-20)}{15(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{2}=-\frac{2n(n-4)(n-5)\left(n^{2}-31n+246\right)}{9(n-6)^{2}(n-7)(n-8)(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{8(n-2)(n-4)\left(n^{3}-51n^{2}+809n-4020\right)}{15(n-6)^{2}(n-7)(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{4}=-\frac{16(n-3)(n-5)(n-12)\left(3n^{2}-86n+536\right)}{15(n-6)^{3}(n-7)(n-8)^{2}(n-9)(n-10)},$
$\displaystyle|C|\leq\frac{n(n-2)(n-4)}{48}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 26.$

  6. (vi)

$\mathscr{D}=\\{3,4,5\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-4)\left(n^{2}-30n+281\right)}{300(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-3)(n-5)\left(3n^{2}-93n+724\right)}{75(n-6)^{2}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{3}=-\frac{2(n-2)(n-3)\left(3n^{2}-71n+436\right)}{25(n-6)(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{4}=-\frac{2(n-4)(n-5)(n-13)\left(n^{2}-20n+111\right)}{15(n-6)^{2}(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n-3)\left(n^{3}-34n^{2}+401n-1524\right)}{40(n-13)\left(n^{2}-20n+111\right)}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 15.$

  7. (vii)

$\mathscr{D}=\\{3,4,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-2)(n-3)(n-28)}{60(n-6)^{2}(n-7)(n-8)},E_{2}=-\frac{n(n-3)(n-4)(n-17)}{5(n-6)^{2}(n-7)(n-8)(n-9)},$
$\displaystyle
E_{3}=-\frac{2(n-2)(n-3)(n-28)(3n-37)}{25(n-6)(n-7)^{2}(n-8)^{2}(n-9)},E_{4}=-\frac{6(n-3)(n-4)\left(6n^{2}-155n+1036\right)}{25(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{n(n-2)(n-3)\left(5n^{2}-165n+1132\right)}{72\left(6n^{2}-155n+1036\right)}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 28.$

  8. (viii)

$\mathscr{D}=\\{3,5,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)}{30(n-6)^{2}(n-7)},E_{2}=-\frac{n(n-3)(n-4)(n-29)}{10(n-6)^{2}(n-7)(n-8)(n-9)},$
$\displaystyle
E_{3}=-\frac{(n-1)(n-3)(n-5)(n-20)}{(n-6)^{2}(n-7)^{2}(n-8)(n-9)},E_{4}=-\frac{3(n-2)(n-4)(n-5)(n-15)}{(n-6)^{3}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-3)}{90}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 29.$

  9. (ix)

$\mathscr{D}=\\{4,5,6\\}$

$\displaystyle
E_{1}=\frac{n(n-1)(n-2)}{90(n-6)^{2}(n-7)},E_{2}=\frac{2n(n-2)(n-3)}{15(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{3}=\frac{2(n-1)(n-2)(n-4)}{3(n-6)^{2}(n-7)^{2}(n-8)},E_{4}=-\frac{4(n-2)(n-3)(n-4)}{3(n-6)^{3}(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)}{120}\leq\binom{n-3}{3}.$

This bound holds true for $n\geq 9.$

###  A.7. The case $w=7,s=3$

  1. (i)

$\mathscr{D}=\\{1,2,3\\}$

$\displaystyle
E_{1}=\frac{(n-4)(n-5)(n-10)\left(n^{2}-29n+228\right)}{147(n-7)^{2}(n-8)^{2}(n-9)},E_{2}=\frac{(n-4)(n-6)(n-11)(n-20)}{21(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{3}=\frac{2(n-5)(n-6)(n-12)}{7(n-7)^{2}(n-8)^{2}(n-9)},E_{4}=-\frac{2(n-10)(n-11)(n-12)}{49(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{(n-4)(n-5)(n-6)}{6}=\binom{n-4}{3}.$

This bound holds true for $n\geq 20.$

  2. (ii)

$\mathscr{D}=\\{1,3,4\\}$

$\displaystyle
E_{1}=\frac{2(n-3)(n-4)\left(n^{3}-50n^{2}+789n-4020\right)}{245(n-7)^{2}(n-8)(n-9)^{2}},$
$\displaystyle
E_{2}=\frac{(n-3)(n-6)\left(n^{3}-64n^{2}+1075n-5340\right)}{35(n-7)^{2}(n-8)^{2}(n-9)^{2}},$
$\displaystyle
E_{3}=\frac{3(n-4)(n-6)(n-11)(n-17)}{7(n-7)^{2}(n-8)^{2}(n-9)^{2}},E_{4}=-\frac{24(n-11)\left(n^{2}-29n+225\right)}{245(n-7)^{3}(n-8)(n-9)^{2}},$
$\displaystyle|C|\leq\frac{(n-3)(n-4)(n-6)\left(2n^{2}-73n+555\right)}{24\left(n^{2}-29n+225\right)}\leq\binom{n-4}{3}.$

This bound holds true for $n\geq 41.$

  3. (iii)

$\mathscr{D}=\\{2,3,4\\}$

$\displaystyle
E_{1}=\frac{(n-3)(n-4)\left(n^{4}-60n^{3}+1409n^{2}-14790n+57600\right)}{735(n-7)^{2}(n-8)(n-9)^{2}(n-10)},$
$\displaystyle
E_{2}=\frac{4(n-3)(n-5)(n-12)(n-14)(n-25)}{245(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{3}=\frac{6(n-4)(n-5)\left(n^{2}-27n+186\right)}{49(n-7)^{2}(n-8)^{2}(n-9)^{2}},E_{4}=-\frac{8\left(4n^{3}-153n^{2}+1973n-8640\right)}{1715(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{(n-3)(n-4)(n-5)\left(7n^{3}-273n^{2}+3626n-15360\right)}{24\left(4n^{3}-153n^{2}+1973n-8640\right)}\leq\binom{n-4}{3}.$

This bound holds true for $n\geq 25.$

  4. (iv)

$\mathscr{D}=\\{2,3,5\\}$

$\displaystyle
E_{1}=\frac{(n-2)(n-4)\left(4n^{5}-319n^{4}+9922n^{3}-150411n^{2}+1112664n-3218220\right)}{735(n-7)(n-8)^{2}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle
E_{2}=\frac{4(n-2)(n-5)\left(4n^{4}-238n^{3}+5169n^{2}-48717n+168372\right)}{245(n-7)^{2}(n-8)(n-9)^{2}(n-10)(n-11)},$
$\displaystyle
E_{3}=\frac{2(n-4)(n-5)\left(3n^{3}-146n^{2}+2305n-11922\right)}{49(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-11)},$
$\displaystyle
E_{4}=-\frac{2\left(15n^{4}-880n^{3}+18907n^{2}-177514n+616824\right)}{343(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-2)(n-4)(n-5)\left(28n^{4}-1673n^{3}+36204n^{2}-335277n+1114398\right)}{30\left(15n^{4}-880n^{3}+18907n^{2}-177514n+616824\right)}\\\
&\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 23.$

  5. (v)

$\mathscr{D}=\\{2,4,6\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-3)(n-5)\left(15n^{3}-860n^{2}+15396n-87184\right)}{735(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{2}=\frac{2(n-1)(n-5)\left(2n^{4}-143n^{3}+3664n^{2}-40228n+160800\right)}{49(n-7)(n-8)^{2}(n-9)(n-10)(n-11)(n-12)},$
$\displaystyle
E_{3}=\frac{8(n-3)(n-5)\left(8n^{5}-660n^{4}+21005n^{3}-324540n^{2}+2446172n-7221360\right)}{245(n-7)^{2}(n-8)^{2}(n-9)(n-10)^{2}(n-11)(n-12)},$
$\displaystyle
E_{4}=-\frac{48(n-5)\left(2n^{2}-57n+398\right)Q}{1715(n-7)^{2}(n-8)^{3}(n-9)(n-10)^{2}(n-11)(n-12)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-3)(n-5)P}{144\left(2n^{2}-57n+398\right)Q}\leq\binom{n-4}{3},\end{aligned}$

where

$\displaystyle P$
$\displaystyle=105n^{6}-9380n^{5}+335496n^{4}-6191744n^{3}+62472912n^{2}-327751616n$
$\displaystyle\quad+699935232,$ $\displaystyle Q$
$\displaystyle=8n^{4}-504n^{3}+10997n^{2}-100866n+332240.$

This bound holds true for $n\geq 29.$

  6. (vi)

$\mathscr{D}=\\{3,4,5\\}$

$\displaystyle
E_{1}=\frac{(n-2)(n-3)(n-6)\left(n^{4}-66n^{3}+1745n^{2}-20448n+87840\right)}{1225(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle
E_{2}=\frac{3(n-2)(n-4)\left(n^{4}-68n^{3}+1669n^{2}-17642n+68160\right)}{245(n-7)(n-8)^{2}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle
E_{3}=\frac{8(n-3)(n-4)\left(3n^{4}-160n^{3}+3222n^{2}-28895n+97050\right)}{245(n-7)^{2}(n-8)(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{4}=-\frac{8(n-6)Q}{1715(n-7)^{2}(n-8)^{2}(n-9)^{3}(n-10)^{2}(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-2)(n-3)(n-4)P}{40Q}\leq\binom{n-4}{3},\end{aligned}$

where

$\displaystyle P$
$\displaystyle=7n^{6}-539n^{5}+17507n^{4}-302361n^{3}+2903826n^{2}-14643760n+30251400,$
$\displaystyle Q$
$\displaystyle=5n^{6}-375n^{5}+11786n^{4}-198771n^{3}+1896155n^{2}-9689568n+20692440.$

This bound holds true for $n\geq 27.$

  7. (vii)

$\mathscr{D}=\\{3,4,6\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-3)(n-5)(n-14)(n-20)(n-34)}{245(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{2}=\frac{3(n-1)(n-4)(n-6)(n-17)\left(n^{2}-37n+310\right)}{49(n-7)^{2}(n-8)^{2}(n-9)(n-10)(n-11)},$
$\displaystyle
E_{3}=\frac{24(n-3)(n-4)\left(n^{4}-70n^{3}+1749n^{2}-18740n+73100\right)}{245(n-7)^{2}(n-8)(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{4}=-\frac{72(n-5)(n-6)Q}{1715(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-3)(n-4)P}{72Q}\leq\binom{n-4}{3},\end{aligned}$

where

$\displaystyle P$
$\displaystyle=7n^{5}-560n^{4}+17017n^{3}-246980n^{2}+1720516n-4621280,$
$\displaystyle Q$
$\displaystyle=4n^{5}-291n^{4}+8382n^{3}-119717n^{2}+848126n-2384080.$

This bound holds true for $n\geq 34.$

  8. (viii)

$\mathscr{D}=\\{3,4,7\\}$

$\displaystyle
E_{1}=\frac{n(n-3)(n-4)\left(3n^{2}-161n+1930\right)}{245(n-7)^{2}(n-8)(n-9)(n-10)},$
$\displaystyle
E_{2}=\frac{3n(n-4)(n-5)\left(3n^{2}-103n+910\right)}{49(n-7)^{2}(n-8)(n-9)(n-10)(n-11)},$
$\displaystyle
E_{3}=\frac{24(n-3)(n-4)\left(n^{4}-70n^{3}+1974n^{2}-24815n+112850\right)}{245(n-7)^{2}(n-8)(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{4}=-\frac{24(n-4)(n-5)\left(n^{4}-68n^{3}+1664n^{2}-17557n+67710\right)}{35(n-7)^{3}(n-8)(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{n(n-3)(n-4)\left(3n^{4}-200n^{3}+4773n^{2}-48316n+176580\right)}{168\left(n^{4}-68n^{3}+1664n^{2}-17557n+67710\right)}\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 36.$

  9. (ix)

$\mathscr{D}=\\{3,5,6\\}$

$\displaystyle
E_{1}=\frac{2(n-1)(n-2)(n-4)\left(2n^{2}-82n+903\right)}{735(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=\frac{(n-1)(n-4)(n-6)(n-14)\left(n^{2}-68n+915\right)}{49(n-7)^{2}(n-8)^{2}(n-9)(n-10)(n-11)},$
$\displaystyle
E_{3}=\frac{5(n-2)(n-4)(n-14)\left(3n^{2}-118n+1083\right)}{49(n-7)(n-8)^{2}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle
E_{4}=-\frac{6(n-4)(n-6)\left(15n^{4}-910n^{3}+20839n^{2}-212584n+809256\right)}{343(n-7)^{2}(n-8)^{3}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-2)(n-4)\left(28n^{4}-1827n^{3}+43176n^{2}-432251n+1535730\right)}{90\left(15n^{4}-910n^{3}+20839n^{2}-212584n+809256\right)}\\\
&\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 50.$

  10. (x)

$\mathscr{D}=\\{4,5,6\\}$

$\displaystyle
E_{1}=\frac{(n-1)(n-2)(n-4)\left(n^{2}-41n+564\right)}{735(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=\frac{16(n-1)(n-3)(n-5)\left(n^{2}-42n+452\right)}{735(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{3}=\frac{8(n-2)(n-3)(n-6)\left(n^{2}-31n+258\right)}{49(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle
E_{4}=-\frac{8(n-4)(n-5)(n-6)\left(4n^{3}-171n^{2}+2543n-13548\right)}{343(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-2)(n-3)\left(7n^{3}-315n^{2}+5096n-25392\right)}{120\left(4n^{3}-171n^{2}+2543n-13548\right)}\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 20.$

  11. (xi)

$\mathscr{D}=\\{4,6,7\\}$

$\displaystyle
E_{1}=\frac{n(n-1)(n-2)}{49(n-7)^{2}(n-8)},E_{2}=\frac{8n(n-3)(n-4)(2n-85)}{245(n-7)^{2}(n-8)(n-9)(n-10)},$
$\displaystyle
E_{3}=\frac{192(n-1)(n-3)(n-5)(n-29)}{245(n-7)^{2}(n-8)^{2}(n-9)(n-10)},E_{4}=-\frac{24(n-2)(n-4)(n-5)(4n-87)}{35(n-7)^{3}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{n(n-1)(n-3)(5n-94)}{168(4n-87)}\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 43.$

  12. (xii)

$\mathscr{D}=\\{5,6,7\\}$

$\displaystyle
E_{1}=\frac{n(n-1)(n-2)}{147(n-7)^{2}(n-8)},E_{2}=\frac{5n(n-2)(n-3)}{49(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{3}=\frac{30(n-1)(n-2)(n-4)}{49(n-7)^{2}(n-8)^{2}(n-9)},E_{4}=-\frac{10(n-2)(n-3)(n-4)}{7(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{n(n-1)(n-2)}{210}\leq\binom{n-4}{3}.\end{aligned}$

This bound holds true for $n\geq 10.$

###  A.8. The case $w=5,s=4$

  1. (i)

$\mathscr{D}=\\{1,2,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-3)(n-4)(n-10)\left(n^{2}-15n+60\right)}{500(n-5)^{2}(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-2)(n-4)^{2}\left(n^{2}-17n+78\right)}{100(n-5)^{3}(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{(n-1)(n-3)(n-4)(n-10)}{25(n-5)^{2}(n-6)^{2}(n-7)^{2}},E_{4}=-\frac{3(n-2)(n-3)(n-4)}{25(n-5)^{3}(n-6)^{2}(n-7)},$
$\displaystyle E_{5}=-\frac{6(n-4)}{125(n-5)^{3}(n-6)(n-7)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n-3)(n-4)}{24}=\binom{n-1}{4}.$

This bound holds true for $n\geq 10.$

  2. (ii)

$\mathscr{D}=\\{2,3,4,5\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)^{2}(n-3)(n-4)}{500(n-5)^{3}(n-6)^{2}(n-7)},E_{2}=-\frac{2n(n-1)(n-2)(n-3)(n-4)}{125(n-5)^{2}(n-6)^{2}(n-7)(n-8)},$
$\displaystyle
E_{3}=-\frac{9n(n-2)(n-3)^{2}(n-4)}{125(n-5)^{3}(n-6)(n-7)^{2}(n-8)},$
$\displaystyle
E_{4}=-\frac{24(n-1)(n-2)(n-3)(n-4)}{125(n-5)^{2}(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle
E_{5}=-\frac{6(n-2)(n-3)(n-4)^{2}}{25(n-5)^{3}(n-6)^{2}(n-7)^{2}(n-8)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)(n-3)}{120}\leq\binom{n-1}{4}.$

This bound holds true for $n\geq 9.$

###  A.9. The case $w=6,s=4$

  1. (i)

$\mathscr{D}=\\{1,2,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-2)(n-3)(n-4)(n-13)\left(n^{2}-19n+100\right)}{1800(n-6)^{2}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-2)(n-3)(n-5)\left(n^{2}-23n+148\right)}{300(n-6)^{2}(n-7)^{3}(n-8)},$
$\displaystyle
E_{3}=-\frac{(n-2)(n-4)(n-5)(n-10)(n-15)}{60(n-6)^{3}(n-7)^{2}(n-8)(n-9)},E_{4}=-\frac{(n-3)(n-4)(n-5)(n-10)}{15(n-6)^{3}(n-7)^{3}(n-8)},$
$\displaystyle E_{5}=-\frac{n-10}{75(n-6)^{3}(n-7)^{2}},$
$\displaystyle|C|\leq\frac{(n-2)(n-3)(n-4)(n-5)}{24}=\binom{n-2}{4}.$

This bound holds true for $n\geq 15.$

  2. (ii)

$\mathscr{D}=\\{1,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)^{2}(n-3)(n-4)}{180(n-6)^{3}(n-7)^{2}(n-8)},$
$\displaystyle
E_{2}=-\frac{n(n-1)(n-2)(n-5)\left(n^{2}-27n+212\right)}{90(n-6)^{2}(n-7)(n-8)(n-9)(n-10)(n-11)},$
$\displaystyle
E_{3}=-\frac{2n(n-2)(n-3)(n-5)\left(n^{2}-26n+178\right)}{15(n-6)^{2}(n-7)^{2}(n-8)(n-9)(n-10)(n-11)},$
$\displaystyle
E_{4}=-\frac{2(n-1)(n-2)(n-4)(n-5)(n-15)}{3(n-6)^{3}(n-7)^{2}(n-8)(n-9)(n-11)},$
$\displaystyle
E_{5}=-\frac{4(n-2)(n-3)(n-4)\left(n^{2}-24n+125\right)}{3(n-6)^{3}(n-7)^{2}(n-8)(n-9)(n-10)(n-11)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)(n-5)\left(n^{2}-23n+136\right)}{240\left(n^{2}-24n+125\right)}\leq\binom{n-2}{4}.$

This bound holds true for $n\geq 17.$

  3. (iii)

$\mathscr{D}=\\{2,3,4,5\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-3)(n-4)(n-5)\left(n^{3}-34n^{2}+401n-1724\right)}{4500(n-6)^{2}(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-2)(n-4)^{2}\left(n^{3}-35n^{2}+431n-1855\right)}{450(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{(n-1)(n-3)(n-4)(n-5)\left(3n^{3}-108n^{2}+1289n-5120\right)}{225(n-6)^{2}(n-7)^{3}(n-8)(n-9)^{2}(n-10)},$
$\displaystyle
E_{4}=-\frac{(n-2)(n-3)(n-4)\left(4n^{3}-123n^{2}+1263n-4340\right)}{75(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle
E_{5}=-\frac{(n-4)(n-5)\left(5n^{4}-194n^{3}+2821n^{2}-18244n+44376\right)}{225(n-6)^{2}(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle|C|\leq\frac{(n-1)(n-2)(n-3)(n-4)\left(n^{4}-39n^{3}+571n^{2}-3729n+9120\right)}{20\left(5n^{4}-194n^{3}+2821n^{2}-18244n+44376\right)}\leq\binom{n-2}{4}.$

This bound holds true for $n\geq 15.$

  4. (iv)

$\mathscr{D}=\\{2,3,4,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-2)(n-3)^{2}(n-4)\left(n^{2}-33n+284\right)}{900(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=-\frac{n(n-2)(n-3)(n-4)(n-5)(n-12)(n-22)}{90(n-6)^{3}(n-7)(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{n(n-3)(n-4)^{2}(n-5)\left(n^{2}-27n+174\right)}{15(n-6)^{3}(n-7)^{2}(n-8)(n-9)^{2}(n-10)},$
$\displaystyle
E_{4}=-\frac{2(n-2)(n-3)(n-4)\left(2n^{3}-99n^{2}+1369n-5820\right)}{75(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle
E_{5}=-\frac{4(n-3)(n-4)(n-5)(n-12)\left(2n^{2}-39n+194\right)}{25(n-6)^{3}(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle|C|\leq\frac{n(n-2)(n-3)(n-4)\left(n^{2}-27n+158\right)}{144\left(2n^{2}-39n+194\right)}\leq\binom{n-2}{4}.$

This bound holds true for $n\geq 30.$

  5. (v)

$\mathscr{D}=\\{2,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)^{2}(n-3)(n-4)}{450(n-6)^{3}(n-7)^{2}(n-8)},$
$\displaystyle
E_{2}=-\frac{n(n-1)(n-2)(n-4)(n-5)(n-25)}{135(n-6)^{2}(n-7)^{2}(n-8)(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{4n(n-2)(n-3)(n-4)(n-5)(n-18)}{45(n-6)^{3}(n-7)(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{4}=-\frac{4(n-1)(n-2)(n-4)^{2}(n-14)}{9(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{5}=-\frac{8(n-2)(n-3)(n-4)(n-5)(5n-56)}{45(n-6)^{3}(n-7)^{2}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)(n-4)(3n-44)}{240(5n-56)}\leq\binom{n-2}{4}.$

This bound holds true for $n\geq 25.$

  6. (vi)

$\mathscr{D}=\\{3,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)^{2}(n-3)(n-4)}{1800(n-6)^{3}(n-7)^{2}(n-8)},E_{2}=-\frac{n(n-1)(n-2)(n-3)(n-4)(n-5)}{150(n-6)^{3}(n-7)^{2}(n-8)(n-9)},$
$\displaystyle
E_{3}=-\frac{n(n-2)(n-3)^{2}(n-4)}{25(n-6)^{2}(n-7)^{2}(n-8)^{2}(n-9)},$
$\displaystyle
E_{4}=-\frac{2(n-1)(n-2)(n-3)(n-4)(n-5)}{15(n-6)^{2}(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle
E_{5}=-\frac{(n-2)(n-3)(n-4)^{2}(n-5)}{5(n-6)^{3}(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{n(n-1)(n-2)(n-3)}{360}\leq\binom{n-2}{4}.$

This bound holds true for $n\geq 10.$

###  A.10. The case $w=7,s=4$

  1. (i)

$\mathscr{D}=\\{1,2,3,4\\}$

$\displaystyle
E_{1}=-\frac{(n-3)(n-4)(n-5)(n-16)\left(n^{2}-23n+150\right)}{5145(n-7)^{3}(n-8)^{2}(n-9)},$
$\displaystyle
E_{2}=-\frac{(n-3)(n-4)(n-6)(n-11)\left(n^{2}-29n+240\right)}{735(n-7)^{3}(n-8)^{2}(n-9)^{2}},$
$\displaystyle
E_{3}=-\frac{2(n-3)(n-5)(n-6)(n-12)(n-20)}{245(n-7)^{3}(n-8)^{3}(n-9)},$
$\displaystyle
E_{4}=-\frac{2(n-4)(n-5)(n-6)(n-11)(n-12)}{49(n-7)^{3}(n-8)^{3}(n-9)^{2}},$
$\displaystyle
E_{5}=-\frac{8(n-10)(n-11)(n-12)}{1715(n-7)^{4}(n-8)^{2}(n-9)},$
$\displaystyle|C|\leq\frac{(n-3)(n-4)(n-5)(n-6)}{24}=\binom{n-3}{4}.$

This bound holds true for $n\geq 20.$

  2. (ii)

$\mathscr{D}=\\{1,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-3)(n-4)(n-5)(n-6)\left(n^{3}-45n^{2}+728n-3856\right)}{1715(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)},$
$\displaystyle
E_{2}=-\frac{(n-1)(n-2)(n-4)(n-6)\left(n^{4}-68n^{3}+1871n^{2}-23068n+102720\right)}{735(n-7)^{3}(n-8)^{2}(n-9)(n-10)(n-11)(n-12)},$
$\displaystyle
E_{3}=-\frac{8(n-1)(n-3)(n-5)(n-6)\left(2n^{4}-136n^{3}+3409n^{2}-36656n+142272\right)}{735(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle
E_{4}=-\frac{8(n-2)(n-3)(n-6)^{2}\left(n^{3}-45n^{2}+668n-3216\right)}{49(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)(n-12)},$
$\displaystyle
E_{5}=-\frac{8(n-4)(n-5)(n-6)\left(4n^{4}-231n^{3}+4976n^{2}-47841n+172692\right)}{343(n-7)^{4}(n-8)^{2}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-2)(n-3)(n-6)\left(3n^{4}-176n^{3}+4029n^{2}-41296n+156816\right)}{120\left(4n^{4}-231n^{3}+4976n^{2}-47841n+172692\right)}\\\
&\leq\binom{n-3}{4}.\end{aligned}$

This bound holds true for $n\geq 23.$

  3. (iii)

$\mathscr{D}=\\{2,3,4,5\\}$

$\displaystyle
E_{1}=-\frac{(n-2)(n-3)(n-4)(n-6)A}{25725(n-7)^{2}(n-8)^{2}(n-9)^{3}(n-10)^{2}(n-11)},$
$\displaystyle
E_{2}=-\frac{4(n-2)(n-3)(n-5)(n-6)(n-14)\left(n^{4}-53n^{3}+1099n^{2}-10227n+35460\right)}{8575(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{3}=-\frac{6(n-2)(n-4)(n-5)\left(n^{4}-58n^{3}+1229n^{2}-11352n+38700\right)}{1715(n-7)^{2}(n-8)^{2}(n-9)^{3}(n-10)(n-11)},$
$\displaystyle
E_{4}=-\frac{16(n-3)(n-4)(n-5)(n-14)\left(2n^{2}-47n+285\right)}{1715(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle
E_{5}=-\frac{8(n-6)\left(5n^{4}-238n^{3}+4261n^{2}-34076n+103080\right)}{12005(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-2)(n-3)(n-4)(n-5)\left(7n^{4}-336n^{3}+6083n^{2}-49434n+150120\right)}{120\left(5n^{4}-238n^{3}+4261n^{2}-34076n+103080\right)}\\\
&\leq\binom{n-3}{4},\end{aligned}$

where

$\displaystyle A$
$\displaystyle=n^{6}-77n^{5}+2501n^{4}-44023n^{3}+442518n^{2}-2399880n+5461200.$

This bound holds true for $n\geq 22.$

  4. (iv)

$\mathscr{D}=\\{2,3,4,6\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-3)(n-4)(n-5)(n-6)A}{5145(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{2}=-\frac{4(n-1)(n-3)(n-5)^{2}(n-14)(n-16)\left(n^{2}-40n+332\right)}{1715(n-7)^{2}(n-8)^{3}(n-9)(n-10)^{2}(n-11)},$
$\displaystyle
E_{3}=-\frac{2(n-1)(n-4)(n-5)(n-6)\left(3n^{4}-187n^{3}+4228n^{2}-41548n+150720\right)}{343(n-7)^{2}(n-8)^{3}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle
E_{4}=-\frac{8(n-3)(n-4)(n-5)\left(4n^{4}-273n^{3}+6491n^{2}-65742n+243360\right)}{1715(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle
E_{5}=-\frac{48(n-5)(n-6)\left(8n^{5}-522n^{4}+13459n^{3}-171769n^{2}+1086792n-2729600\right)}{12005(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-3)(n-4)(n-5)\left(7n^{5}-511n^{4}+14364n^{3}-196196n^{2}+1306400n-3389952\right)}{144\left(8n^{5}-522n^{4}+13459n^{3}-171769n^{2}+1086792n-2729600\right)}\\\
&\leq\binom{n-3}{4},\end{aligned}$

where

$\displaystyle A$
$\displaystyle=n^{5}-80n^{4}+2527n^{3}-39548n^{2}+306604n-941120.$

This bound holds true for $n\geq 31.$

  5. (v)

$\mathscr{D}=\\{2,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{(n-1)(n-2)(n-3)(n-4)(n-5)(n-6)\left(n^{3}-45n^{2}+728n-4176\right)}{5145(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)},$
$\displaystyle
E_{2}=-\frac{2(n-1)(n-2)(n-4)(n-5)\left(2n^{4}-157n^{3}+4581n^{2}-57798n+265032\right)}{5145(n-7)^{2}(n-8)^{2}(n-9)^{2}(n-10)(n-11)(n-12)},$
$\displaystyle
E_{3}=-\frac{64(n-1)(n-3)(n-5)^{2}(n-14)(n-16)\left(n^{2}-41n+354\right)}{5145(n-7)^{2}(n-8)^{3}(n-9)(n-10)^{2}(n-11)(n-12)},$
$\displaystyle
E_{4}=-\frac{8(n-2)(n-3)(n-5)(n-6)\left(4n^{4}-221n^{3}+4585n^{2}-42276n+145944\right)}{343(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)(n-12)},$
$\displaystyle
E_{5}=-\frac{16(n-4)(n-5)(n-6)Q}{2401(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)^{2}(n-11)(n-12)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{(n-1)(n-2)(n-3)(n-5)P}{240Q}\leq\binom{n-3}{4},\end{aligned}$

where

$\displaystyle P$
$\displaystyle=7n^{5}-483n^{4}+13412n^{3}-185556n^{2}+1267296n-3387456,$
$\displaystyle Q$
$\displaystyle=8n^{5}-502n^{4}+12673n^{3}-161081n^{2}+1030386n-2646072.$

This bound holds true for $n\geq 29.$

  6. (vi)

$\mathscr{D}=\\{3,4,5,6\\}$

$\displaystyle
E_{1}=-\frac{\left(n-1\right)\left(n-2\right)\left(n-3\right)\left(n-4\right)\left(n-5\right)\left(n-6\right)\left(n^{3}-45n^{2}+728n-4656\right)}{25725\left(n-7\right)^{3}\left(n-8\right)^{3}\left(n-9\right)^{2}\left(n-10\right)},$
$\displaystyle
E_{2}=-\frac{\left(n-1\right)\left(n-2\right)\left(n-4\right)^{2}\left(n-6\right)\left(n^{3}-46n^{2}+769n-4620\right)}{1715\left(n-7\right)^{2}\left(n-8\right)^{3}\left(n-9\right)^{2}\left(n-10\right)\left(n-11\right)},$
$\displaystyle
E_{3}=-\frac{8\left(n-1\right)\left(n-3\right)\left(n-4\right)\left(n-5\right)\left(n-6\right)\left(n^{3}-47n^{2}+737n-3910\right)}{1715\left(n-7\right)^{3}\left(n-8\right)^{2}\left(n-9\right)^{2}\left(n-10\right)^{2}\left(n-11\right)},$
$\displaystyle
E_{4}=-\frac{8\left(n-2\right)\left(n-3\right)\left(n-4\right)\left(n-6\right)\left(n-15\right)\left(n^{2}-24n+155\right)}{343\left(n-7\right)^{2}\left(n-8\right)^{2}\left(n-9\right)^{3}\left(n-10\right)^{2}\left(n-11\right)},$
$\displaystyle
E_{5}=-\frac{24\left(n-4\right)\left(n-5\right)\left(n-6\right)^{2}\left(5n^{4}-246n^{3}+4585n^{2}-38568n+124776\right)}{12005\left(n-7\right)^{3}\left(n-8\right)^{3}\left(n-9\right)^{3}\left(n-10\right)^{2}\left(n-11\right)},$
$\displaystyle|C|\leq\frac{\left(n-1\right)\left(n-2\right)\left(n-3\right)\left(n-4\right)\left(7n^{4}-350n^{3}+6671n^{2}-58072n+189960\right)}{360\left(5n^{4}-246n^{3}+4585n^{2}-38568n+124776\right)}\leq\binom{n-3}{4}.$

This bound holds true for $n\geq 21$.

  7. (vii)

$\mathscr{D}=\\{3,4,6,7\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)(n-3)(n-4)(n-5)(n-38)}{1715(n-7)^{3}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{2}=-\frac{3n(n-1)(n-2)(n-4)(n-5)(n-6)(n-23)}{343(n-7)^{3}(n-8)^{2}(n-9)(n-10)(n-11)},$
$\displaystyle
E_{3}=-\frac{24n(n-3)(n-4)^{2}(n-5)\left(n^{2}-61n+730\right)}{1715(n-7)^{3}(n-8)(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{4}=-\frac{72(n-1)(n-3)(n-4)(n-5)(n-6)\left(4n^{2}-161n+1530\right)}{1715(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle
E_{5}=-\frac{72(n-2)(n-4)(n-5)^{2}(n-6)\left(2n^{2}-59n+459\right)}{245(n-7)^{4}(n-8)^{2}(n-9)^{2}(n-10)^{2}(n-11)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{n(n-1)(n-3)(n-4)\left(n^{2}-45n+410\right)}{504\left(2n^{2}-59n+459\right)}\leq\binom{n-3}{4}.\end{aligned}$

This bound holds true for $n\geq 45.$

  8. (viii)

$\mathscr{D}=\\{4,5,6,7\\}$

$\displaystyle
E_{1}=-\frac{n(n-1)(n-2)^{2}(n-3)(n-4)}{5145(n-7)^{3}(n-8)^{2}(n-9)},E_{2}=-\frac{16n(n-1)(n-2)(n-3)(n-4)(n-5)}{5145(n-7)^{3}(n-8)^{2}(n-9)(n-10)},$
$\displaystyle
E_{3}=-\frac{8n(n-2)(n-3)^{2}(n-4)(n-6)}{343(n-7)^{3}(n-8)^{2}(n-9)^{2}(n-10)},$
$\displaystyle
E_{4}=-\frac{32(n-1)(n-2)(n-3)(n-4)(n-5)(n-6)}{343(n-7)^{3}(n-8)^{3}(n-9)^{2}(n-10)},$
$\displaystyle
E_{5}=-\frac{8(n-2)(n-3)(n-4)^{2}(n-5)(n-6)}{49(n-7)^{4}(n-8)^{3}(n-9)^{2}(n-10)},$
$\displaystyle\begin{aligned}
|C|&\leq\frac{n(n-1)(n-2)(n-3)}{840}\leq\binom{n-3}{4}.\end{aligned}$

This bound holds true for $n\geq 11.$

##  Appendix B SDP bounds for $\mathcal{H}_{2}^{n}$ and $\mathcal{J}^{n,w}$

The general results of [Sch05] are specialized here for $s$-codes in
$\mathcal{H}_{2}^{n}$ or $\mathcal{J}^{n,w}$.

Consider an $s$-code $C$ in $\mathcal{H}_{2}^{n}$ with distances
$\\{d_{1},\dots,d_{s}\\}$. Its triple distance distribution is defined as

$\displaystyle x_{i,j}^{t}=\frac{1}{|C|\binom{n}{i-t,j-t,t}}|\\{(u,v,z)\in
C^{3}$ $\displaystyle:d_{H}(u,v)=i,d_{H}(u,z)=j,$
$\displaystyle\;\;d_{H}(v,z)=i+j-2t\\}|,$

The variables $x_{i,j}^{t}$ characterize the distance relations among triples
of codewords. Together with the fact the $C$ has only $s$ distances, we obtain
the following form of the SDP bound.

######  Theorem B.1.

Let $C\subset\mathcal{H}_{2}^{n}$ be an $s$-code with distance set
$\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Suppose that $x_{i,j}^{t}\in[0,1]$ for
$i,j,t\in\\{0,\dots,n\\}$ are variables satisfying the following conditions:

  1. i.

$x_{0,0}^{0}=1$;

  2. ii.

$0\leq x_{i,j}^{t}\leq x_{i,0}^{0}$ and $x_{i,0}^{0}+x_{j,0}^{0}\leq
1+x_{i,j}^{t}$;

  3. iii.

$x_{i,j}^{t}=x_{i^{\prime},j^{\prime}}^{t^{\prime}}$ if $(i,j,i+j-2t)$ is a
permutation of $(i^{\prime},j^{\prime},i^{\prime}+j^{\prime}-2t^{\prime})$;

  4. iv.

$x_{i,j}^{t}=0$ if one of $i$, $j$, and $i+j-2t$ is not in $\mathscr{D}$.

For $k=0,\dots,\lfloor\frac{n}{2}\rfloor$, define

(26)
$B_{k}=\left(\sum_{t}\binom{n-2k}{i-k}^{-\frac{1}{2}}\binom{n-2k}{j-k}^{-\frac{1}{2}}\beta_{i,j,k}^{t}x_{i,j}^{t}\right)_{i,j=k}^{n-k}$

where

$\beta_{i,j,k}^{t}=\sum_{u=0}^{n}(-1)^{u-t}\binom{u}{t}\binom{n-2k}{u-k}\binom{n-k-u}{i-u}\binom{n-k-u}{j-u}.$

Then

$|C|\leq{\rm max}\Big{\\{}\sum_{i=0}^{n}\binom{n}{i}x_{i,0}^{0}:B_{k}\text{ is
p.s-d. for all }k=0,\dots,\Big{\lfloor}\frac{n}{2}\Big{\rfloor}\Big{\\}}.$

Consider a constant weight $s$-code $C$ in $\mathcal{J}^{n,w}$ with distances
$\\{d_{1},\dots,d_{s}\\}$. Let $\chi^{A}$ be the indicator vector of a set
$A\subset\\{1.\dots,n\\}.$ Define a semidistance between two vectors
$u=(u_{1},\dots,u_{n}),$ $v=(v_{1},\dots,v_{n})\in\mathbb{F}_{2}^{n}$ as an
$n$-dimensional vector

$\bar{d}(u,v)=\chi^{\text{supp}(u)\setminus\text{supp}(v)},$

where $\text{supp}(u)=\\{i:u_{i}=1\\}$ is the support of $u$. Then the triple
distance distribution of $C$ is defined as

$x_{i,j}^{t,r}=\frac{1}{|C|\binom{w}{i-t,j-t,t}\binom{n-w}{i-r,j-r,r}}\lambda_{i,j}^{t,r},$

where

$\displaystyle\lambda_{i,j}^{t,r}=|\\{(u,v,z)\in C^{3}:d_{J}(u,v)$
$\displaystyle=i,d_{J}(u,z)=j,$
$\displaystyle\bar{d}(u,v)\cdot\bar{d}(u,z)=t,\bar{d}(v,u)\cdot\bar{d}(z,u)=r\\}|.$

Next we formulate Schrijver’s SDP bound for the Johnson space, taking account
of the fact that $C$ is an $s$-code and of the ensuing additional constraints
on the distance coefficients $x_{i,j}^{t,r}.$

######  Theorem B.2.

Let $C\subset\mathcal{J}^{n,w}$ be an $s$-code with distance set
$\mathscr{D}=\\{d_{1},\dots,d_{s}\\}$. Suppose that $x_{i,j}^{t,r}\in[0,1]$
for $i,j,t,r\in\\{0,\dots,{\rm min}\\{w,n-w\\}\\}$ are variables satisfying
the following conditions:

  1. i.

$x_{0,0}^{0,0}=1$;

  2. ii.

$0\leq x_{i,j}^{t,r}\leq x_{i,0}^{0,0}$ and $x_{i,0}^{0,0}+x_{j,0}^{0,0}\leq
1+x_{i,j}^{t,r}$;

  3. iii.

$x_{i,j}^{t,r}=x_{i^{\prime},j^{\prime}}^{t^{\prime},r^{\prime}}$ if
$t-r=t^{\prime}-r^{\prime}$ and $(i,j,i+j-t-r)$ is a permutation of
$(i^{\prime},j^{\prime},i^{\prime}+j^{\prime}-t^{\prime}-r^{\prime})$;

  4. iv.

$x_{i,j}^{t,r}=0$ if one of $i$, $j$, and $i+j-t-r$ is not in $\mathscr{D}$.

For $k=0,\dots,\lfloor\frac{w}{2}\rfloor$,
$l=0,\dots,\lfloor\frac{n-w}{2}\rfloor$, define

(27)
$B_{k,l}=\left(\sum_{t}\alpha(n,i,j,k,l)\beta_{i,j,k}^{t,w}\beta_{i,j,l}^{r,n-w}x_{i,j}^{t,r}\right)_{(i,j)=(k,l)}^{(n-k,n-l)}$

where

$\beta_{i,j,k}^{t,a}=\sum_{u=0}^{a}(-1)^{u-t}\binom{u}{t}\binom{a-2k}{u-k}\binom{a-k-u}{i-u}\binom{a-k-u}{j-u},$

for $a=w,n-w$, and

$\alpha(n,i,j,k,l)=\binom{n-2k}{i-k}^{-\frac{1}{2}}\binom{n-2k}{j-k}^{-\frac{1}{2}}\binom{n-2l}{i-l}^{-\frac{1}{2}}\binom{n-2l}{j-l}^{-\frac{1}{2}}.$

Then

$|C|\leq{\rm
max}\left\\{\sum_{i=0}^{n}\binom{w}{i}\binom{n-w}{i}x_{i,0}^{0,0}:B_{k,l}\text{
is p.s.-d. for all }k,l\right\\}.$