An upper bound on the size of Sidon sets

Abstract: In this entry point into the subject, combining two elementary proofs, we decrease the gap between the upper and lower bounds by $0.2\%$ in a classical combinatorial number theory problem. We show that the maximum size of a Sidon set of $\{ 1, 2, \ldots, n\}$ is at most $\sqrt{n}+ 0.998n^{1/4}$ for sufficiently large $n$.

\section{History}

In 1932 S.~Sidon asked a question of a fellow student P. Erd{\H{o}}s.
Their advisor was L.~Fej\'er, an outstanding mathematician (cf.~Fej\'er kernel) working on summability of infinite series, who  had a number of outstanding students who contributed to mathematical analysis
(M.~Fekete 1909 [Fekete's Lemma, see~\cite{FR}], G.~P\'olya 1912, John von Neumann 1926, P.~Erd\H os 1934, P. Tur\'an 1935, V.~T.~S\'os 1957). Sidon~\cite{S32} studying the $L_p$ norm of certain Fourier series proposed the
 following problem, which we present here in contemporary wording.

A set of numbers $A$ is  a {\em Sidon set}, or alternately a \emph{$B_2$-set}, if $a+b=c+d$, $a,b,c,d\in A$ imply $\{ a,b\}=\{ c,d\}$, i.e., all pairwise sums are distinct.

Let $S(n)$ denote the maximum size of a Sidon set can have when $A\subset \{ 1,2,\dots, n\} $ $= : [n]$. It is obvious that $S(n)\leq 2 \sqrt{n}$ since $\binom{|A|+1}{2}\leq 2n-1$. The sequence of powers of $2$, i.e.,  $1, 2, 4, 8,\dots$ is an (infinite) Sidon set showing $S(n)> \log_2 n$.
It is rather difficult to construct large Sidon sets, but Sidon found one showing $S(n)> n^{1/4}$.
Erd\H os immediately observed that the greedy algorithm gives $S(n)\geq n^{1/3}$ as follows.
If $A\subset [n]$ and $n> |A|^3$ then one can always find an $x\in [n]$ such that $x$ cannot be written as $x=a+b-c$, $a,b,c\in A$. Then $A\cup \{ x\}$ is a Sidon set as well.
In 1941, Erd\H{o}s and Tur\'an~\cite{ET41} observed that a result of Singer~\cite{S38} implies that $S(n)>\sqrt{n}$ infinitely many times. They also proved that
  \begin{equation*
  S(n) \leq n^{1/2}+O(n^{1/4}).
\end{equation*}
Lindstr\"{o}m~\cite{L69}  showed in 1969,  that for all $n$
 \begin{equation}\label{eq142}
  S(n) < n^{1/2}+n^{1/4}+1.
\end{equation}
This was slightly improved by Cilleruelo~\cite{C10} in 2010
 \begin{equation}\label{eq143}
  S(n) < n^{1/2}+n^{1/4}+\frac{1}{2}.
\end{equation}
The study of Sidon sets
became

a classic topic of additive number theory; see e.g., the survey by O’Bryant~\cite{B04}. The notion can be
extended in a natural way to (finite) groups and fields of characteristic zero see, e.g., Cilleruelo~\cite{C12}.
Many authors apply deep tools, although Ben Green~\cite{G01} notes that some approaches via Fourier analysis have the same spirit as the one in Erd\H{o}s-Tur\'an~\cite{ET41}.

The upper bound in~\eqref{eq142} has basically remained unmoved since 1969.
Erd\H{o}s~\cite{E94} offered \$500 for  a proof or disproof that for every $\varepsilon>0$ the equality
  $S(n)< \sqrt{n} + o(n^\varepsilon)$ holds.

\subsection{The aim of this paper, the main result}\label{ss_aim}

We improve the current best upper bound by $\Theta(n^{1/4})$.

\begin{theorem}\label{mainthm}
There exists a constant $\gamma \geq 0.002$ and a number  $n_0$ such that for every  $n> n_0$
 $$S(n) < n^{1/2}+n^{1/4}(1-\gamma).$$
\end{theorem}

The proof is elementary.
Since this bound is unlikely to be sharp, we did not optimize the computation.
In Section~\ref{sec_lind}, we recall Lindstr\"{o}m's argument~\cite{L69} and point out how introducing a slack term in a critical inequality  can imply possible improvements downstream.
In Section~\ref{sec:hypergraph} we present a different proof, a generalized version of an argument of Ruzsa~\cite{R93}.
We put his proof into a different framework and we explain, how introducing a slack term in a critical inequality there as well can lead  to a possible improvement.
In Section~\ref{sec_proof} we put the two proof methods together and leverage conditions on these slack terms to get Theorem~\ref{mainthm}.
In fact, we show that a very dense Sidon set must have large discrepancy on some initial segment of $[n]$, for related results see Cilleruelo~\cite{C12}, Erd\H{o}s and Freud~\cite{EF}.

Our second aim is to have a self-contained introduction to Sidon sets, so we describe a construction  matching the lower bound as well.
We also give two more examples for Sidon type problems, weak Sidon sets in Section~\ref{sec_weak} and
 thin Sidon sets in Section~\ref{sec_thin}, where our ideas can be used.
Overall, we do not think that our work deserves $0.2\%$ of Erd\H os' prize money, i.e., \$1,
 but we want to emphasize here the wonderful unity of mathematics by showing the many remarkable connections
 Sidon's problem has not only to Fourier analysis  but to abstract algebra and coding theory as well.

\section{Lindstr\"om's Upper Bound}\label{sec_lind}

In this Section we prove~\eqref{eq142}. Recall that $A$ is a Sidon set if all pairwise sums of its elements are distinct up to reordering.
\begin{theorem}[\cite{L69}]\label{X_lind}
Let $A \subseteq [n]$ be a Sidon set. Then $|A| < n^{1/2}+n^{1/4}+1.$
\end{theorem}
\begin{proof}
Let the elements of $A$ be $a_1 < \ldots < a_k$. Given $i < j$, call $j-i$ the \emph{order} of the difference $a_j-a_i$. We sum all
differences of order at most $\ell}   %%%%{M $, where $\ell}   %%%%{M $ will be chosen later to be around $n^{1/4}$. There are
$(k-1) + (k-2) + \ldots + (k- \ell}   %%%%{M)=
\ell}   %%%%{M (k-\frac{\ell}   %%%%{M +1}{2})$ such differences.
By the Sidon property these differences are all distinct. We get the lower bound
\begin{equation}\label{eqlind1}
\frac{1}{2}\ell}   %%%%{M ^2\left(k-\frac{\ell}   %%%%{M +1}{2}\right)^2 < 1+2+\ldots +\ell}   %%%%{M \left(k-\frac{\ell}   %%%%{M +1}{2}\right) \leq \sum_{1\leq i<j\leq k, \, j\le  i+\ell}   %%%%{M} (a_j-a_i).
  \end{equation}
On the other hand, due to cancellation, the sum of all differences of order $r$  is at most $r\times n$.  We get a lower bound on the sum of differences of order at most $\ell$:
  $\binom{\ell}   %%%%{M+1}{2} n$ for the right hand side of~\eqref{eqlind1}, hence  we obtain
\begin{equation}\label{X_sumdiff}
    \frac{1}{2}\ell}   %%%%{M ^2\left(k-\frac{\ell}   %%%%{M +1}{2}\right)^2 < \sum_{1\leq i<j\leq k, \, j\le  i+\ell}   %%%%{M} (a_j-a_i) < \frac{1}{2}\ell}   %%%%{M (\ell}   %%%%{M +1)n.
\end{equation}
Rearranging, we get
   $k -\frac{\ell}   %%%%{M +1}{2} < \sqrt{n (\ell}   %%%%{M+1)/\ell}   %%%%{M }$ \ which, using $\sqrt{1+x}\le 1+x/2$,  leads to
   \[  k < \sqrt{n} +  \frac{\sqrt{n}}{2\ell}   %%%%{M } + \frac{\ell}   %%%%{M }{2}+ \frac{1}{2}.
   \]
Substituting $\ell}   %%%%{M := \lfloor n^{1/4} \rfloor$ yields the claimed upper bound.
\end{proof}

\subsection{A Possible Improvement, Slackness}\label{ss_lind}
If the set of differences $\{(a_j-a_i): 1\leq i<j\leq k, \, j\le  i+\ell}   %%%%{M\}$ contains large values, then one can improve the upper bound on $k$. Define the non-negative slack term $C=C(A,\ell}   %%%%{M )$
as follows
\begin{equation}\label{X_ineqL}
    C = C(A,\ell}   %%%%{M ):= \left(\sum_{1\leq i<j\leq k, \, j\le i+\ell}   %%%%{M} (a_j-a_i)\right) - \sum_{1\leq i \leq \ell}   %%%%{M (k-({\ell}   %%%%{M +1})/{2})} i.
    \end{equation}
 We can add $C$, or any lower bound for it, to the left hand side of~\eqref{X_sumdiff} to obtain
$$k-\frac{\ell}   %%%%{M +1}{2} < \sqrt{\left(1+\frac{1}{\ell}   %%%%{M }-\frac{2C}{\ell}   %%%%{M ^2n}\right)n} .$$
Using $\sqrt{1+x} \leq 1+x/2$ we conclude
$$k < \sqrt{n} + \frac{\sqrt{n}}{2\ell}   %%%%{M } + \frac{\ell}   %%%%{M }{2} - \frac{C}{\ell}   %%%%{M ^2\sqrt{n}} + \frac{1}{2}.
  $$
We shall substitute here $\ell}   %%%%{M =(1-\alpha)n^{1/4}$  with some $0\leq \alpha <1$, and use it as follows
\begin{equation}\label{X_ineqL2}
    k < n^{1/2}+n^{1/4} - \frac{(2C/n) -n^{1/4}\alpha^2(1-\alpha)}{2(1-\alpha)^2} + \frac{1}{2}.
\end{equation}
This  clearly shows that if we knew $C=\Omega(n^{5/4})$ and $\alpha$ was sufficiently small, then Theorem~\ref{mainthm} would follow.

\section{Same Bound via Set Systems}\label{sec:hypergraph}

\subsection{An inequality from coding theory}
The following theorem is usually attri\-buted to Johnson~\cite{J62},
who used it to get upper bounds for error-correcting codes.
It was rediscovered several times, e.g., Bassalygo~\cite{Ba65}.
In hypergraph language (as in Lov\'asz's exercise book~\cite{LL}) it is a
 statement about the size of the ground set of a set system with bounded intersection sizes.
\begin{theorem}\label{setsthm}
Let $\mathcal{A}$ be a family  of $k$-sets $A_1,\dots,A_m}  %%%%{m $ such that the intersection $A_i\cap A_j$ of any distinct pair has cardinality at most $t}   %%%%{\lambda$. Then $v:= |\cup A_i| \geq \frac{k^2m}  %%%%{m }{t}   %%%%{\lambda m + k - t}   %%%%{\lambda}.$
\end{theorem}
\begin{proof}
Denote  $d_x$ the number of sets $A_i$ containing  the vertex $x$.
Given $A_i$, we have $\sum_j |A_i\cap A_j|\leq (m-1)t +k$.  This leads to the following chain of inequalities.
\begin{equation}\label{X_ineqF}
t}   %%%%{\lambda m}  %%%%{m(m}  %%%%{m-1)+m}  %%%%{m k \geq \sum_i \left(\sum_j |A_i\cap A_j|\right) = \sum d_x^2 \geq  \frac{(\sum d_x)^2}{v}= \frac{k^2m}  %%%%{m^2}{v}.
\end{equation}  \end{proof} \hfill

\subsection{A second combinatorial proof}\label{XXXXsec:hypergraph}

Here we prove~\eqref{eq143}.
The proof is a ge\-neralized version of an argument of Ruzsa~\cite{R93}, but we are going to use Johnson's inequality directly.
The slight improvement of Lindstr\"om's bound (1/2 instead of 1) is due to Cilleruelo~\cite{C10}
 who recalculated Ruzsa's argument more carefully.

\begin{theorem}\label{X_thm32}
Let $A \subseteq [n]$ be a Sidon set. Then $|A| < n^{1/2}+n^{1/4}+\frac{1}{2}.$
\end{theorem}

\begin{proof}
Set $k:=|A|$, $m}  %%%%{m$ a positive integer, and $A_i:=A+(i-1)$ for $i=1,\dots,m}  %%%%{m$.
Note that $\cup A_i \subseteq [n+m}  %%%%{m -1]$. The crucial observation is that $|A_i\cap A_j|\leq 1$ for $i\neq j$. Indeed, if there are two distinct elements $x,y \in A_i \cap A_j$ for some $i < j$ then there would exist elements $a,b,c,d \in A$ with $a+i=x=b+j$ and $c+i=y=d+j$, which would give us $a+d=b+c$. Since $A$ is a  Sidon set, this forces $\{a,d\}=\{b,c \}$ hence $x=y$, and Theorem~\ref{setsthm} is applicable with $t}   %%%%{\lambda = 1$,  $v \leq n+m}  %%%%{m -1$, and we get
$$(n+m}  %%%%{m-1)(m}  %%%%{m +k-1) \geq {k^2m}  %%%%{m }.  $$
Suppose $k\geq n^{1/2}+n^{1/4}$ and define $m:= \lceil n^{3/4}\rceil$. Then $(n+m-1)/k < \sqrt{n}$, so we obtain  $\sqrt{n} (m}  %%%%{m +k-1) > {km }. $
 This leads to
  $$ k < \sqrt{n} \frac{m-1}{m-\sqrt{n}}\leq n^{1/2} \frac{n^{3/4}-1}{n^{3/4}-n^{1/2}}=  n^{1/2}+n^{1/4}+1.$$
A more careful calculation, see Claim~\ref{le63}, completes the proof of Theorem~\ref{X_thm32}.
\end{proof}

\subsection{A possible improvement using variance}
Consider the family $\mathcal{A}$ in Theorem~\ref{setsthm}.
One can naturally get the idea that the lower bound in~\eqref{X_ineqF} can be improved if one knows that the variance of the degree sequence $\{d_x\}$ is large.
Define the non-negative {\it defect} term $K=K(\mathcal{A})$ as the difference
$$K(\mathcal{A}):=\sum d_x^2 - \frac{(\sum d_x)^2}{v}\quad =\sum_{x} (d_{ave}-d_x)^2.$$
We also call $K(\mathcal{A})$ or any lower bound $K$ of it a ``{\it gain}''.
Instead of~\eqref{X_ineqF} one obtains
\begin{equation}\label{ineqF}
t}   %%%%{\lambda m}  %%%%{m(m}  %%%%{m-1)+m}  %%%%{m k \geq   \frac{k^2m}  %%%%{m^2}{v} + K.
\end{equation}
 Using  $t}   %%%%{\lambda=1$ and  $v \leq n+m}  %%%%{m -1$  we get
$$m}  %%%%{m +k-1 > \frac{k^2m}  %%%%{m }{n+m}  %%%%{m } +\frac{K}{m}  %%%%{m}. $$
This rearranges to
$$\left(k-\frac{n+m}  %%%%{m }{2m}  %%%%{m }\right)^2 < (n+m}  %%%%{m )\left(1+\frac{m}  %%%%{m+n}{4m}  %%%%{m^2}-\frac{1}{m}  %%%%{m}-\frac{K}{m}  %%%%{m^2}\right)
 < (n+m}  %%%%{m )\left(1-\frac{4K-n}{4m}  %%%%{m^2}\right). $$
Define $m}  %%%%{m:=\lfloor n^{3/4} \rfloor$, and suppose that $K< 2n^{3/2}$, as otherwise one could easily obtain much stronger results.
Using $\sqrt{1+x} \leq 1+x/2$,
  we have
\begin{equation}\label{X_ineqF2}
    k <  \frac{n+m}  %%%%{m }{2m}  %%%%{m } + \sqrt{n}\cdot \sqrt{1+\frac{m}  %%%%{m}{n} -\frac{4K-n}{4m}  %%%%{m^2}- \frac{4K-n}{4m}  %%%%{m n} } \leq  n^{1/2}+n^{1/4}-\frac{K}{2n}+2.
\end{equation}
We shall use later that if
  $K> 2\gamma n^{5/4}+4n$, then~\eqref{X_ineqF2} implies Theorem~\ref{mainthm}.

\smallskip

\noindent Recall the following corollary of the Cauchy-Schwarz inequality about the variance of numbers.

\begin{lemma}\label{defect}
Let $(y_1, \ldots, y_v)$ be a sequence of real numbers with average $d$.
For a subset $X\subseteq [v]$ the average of the elements of $\{ d_x: x\in X\}$ is denoted by $d_X$.
Then $\sum(d-y_i)^2 \geq |X| (d-d_X)^2$.
\end{lemma}

\begin{proof}
We have
$$\sum_{i\in [v]} (d-y_i)^2 \geq
   \sum_{x\in X} (d-y_x)^2= |X| (d-d_X)^2 + \sum_{x\in X} y_x^2 -|X|d_X^2.
$$ \end{proof}

\section{Putting the two methods together:  Proof of Theorem~\ref{mainthm}}\label{sec_proof}

\begin{proof}[Proof of Theorem~\ref{mainthm}]
The proof is a combination of the proofs in the previous two sections.
Recall that $A=\{ a_1, a_2, \dots, a_k\}\subset [n]$ is a Sidon set,   $a_1 < \ldots < a_k$,
 $m}  %%%%{m=\lfloor n^{3/4} \rfloor$ is a positive integer,
 $\mathcal{A}$ is the family $\{ A_i: A_i:=A+(i-1)$ for $i=1,\dots,m}  %%%%{m\}$ with degree sequence  $\{ d_1, \dots, d_{n+m-1}\}$.
We may suppose that $n^{1/2}+ \frac{1}{2} n^{1/4}< k < n^{1/2}+ n^{1/4}+1/2$, hence the
average degree $d = \frac{km}  %%%%{m}{n+m-1} = n^{1/4}+O(1)$.

In this section we fix a ``small" $\alpha>0$ and a ``smaller" $\beta$, and an $ \varepsilon$ to
 get a positive $\gamma$ satisfying~\eqref{eq41}.
E.g., one can choose $\alpha = 0.137$, $\beta = 0.037$, $\varepsilon=0.235$
  and any $\gamma$ with $0.00204\geq \gamma> 0.002$, then these values satisfy
\begin{equation}\label{eq41}
\min\left\{{\varepsilon^2\beta}  , \frac{2(1-\alpha-2\varepsilon)^2(\alpha - 2\beta)-\alpha^2(1-\alpha)}{2(1-\alpha)^2} \right\} > \gamma .
\end{equation}
We also define $s=\lfloor \beta n^{3/4} \rfloor$, \ $r_1=|A \cap [s]|$,\  $r_2=|A \cap [n+1-s,n]|$, $r=r_1 + r_2$,
$R_1:=|A  \cap  [m-s]|$, $R_2:=|A \cap [n+1-m+s, n]|$, $R=R_1+R_2$, and   $\ell}   %%%%{M =\lfloor (1-\alpha)n^{1/4}\rfloor$.
In the course of the proof we distinguish three cases:
$r\leq 2(1-\varepsilon) n^{1/4}$, and $R\geq 2(1+\varepsilon)n^{1/4}$, and $2(1-\varepsilon) n^{1/4}< r\leq R< 2(1+\varepsilon)n^{1/4}$.

\subsection{The density of the initial segments of $A$.}\label{ss41}\quad
The first main idea is to have  a closer look at the variance of the degree sequence of $\mathcal A$.

\medskip
\Claim{4.1}{If $r\leq 2(1-\varepsilon) n^{1/4}$ then $K\geq 2\varepsilon^2 \beta {n^{5/4}}+O(n)$.}\label{cl41}
\medskip

\begin{proof}
Let $d_X = ({\sum_{ x\in X} d_x})/|X|$ be the average of the degrees for a set  $X\subset [n+m}  %%%%{m -1]$.
By the definition of the defect $K(\mathcal A)$ and by Lemma~\ref{defect} we have $K \geq |X|(d-d_X)^2$.
For $X=[s] \cup [n+m-s,n+m-1]$ we have
 $$d_X\ =\ \frac{1}{|X|}\sum_{i\in X} d_i \ = \ \frac{1}{2s}\sum_{1\leq j \leq s} \left(|A \cap [j]| + |A \cap [n+1-j,n]|\right) $$ $$\leq \frac{1}{2} |A \cap ([s] \cup [n+1-s,n])|\ =\  \frac{r}{2} \ \leq \ (1-\varepsilon)n^{1/4}.
  $$
Then, using \ $d-\frac{r}{2}\geq \varepsilon{n^{1/4}}+O(1)$, \ $|X|=2s$,\  and \ $s =\beta n^{3/4}+O(1)$, \ we have the required bound.
\end{proof}

\medskip
\Claim{4.2}{If \ $R\geq 2(1+\varepsilon) n^{1/4}$\  then\  $K\geq 2\varepsilon^2 \beta {n^{5/4}}+O(n)$.}\label{cl42}
\medskip

\begin{proof}
Set $X=[m}  %%%%{m-s+1,m}  %%%%{m] \cup [n,n+s-1]$.
Every $x \in [m}  %%%%{m-s+1,m}  %%%%{m]$ gets covered $|A \cap [m}  %%%%{m-s]|=R_1$ times just by the translates of $A\cap [m}  %%%%{m-s]$. Similarly, every $x \in [n,n+s-1]$ gets covered at least $|A \cap [n+1-m}  %%%%{m+s,n]|=R_2$ times.
Hence, $|d_X-d|\geq \frac{R}{2}-d \ge \varepsilon n^{1/4}$,  and using \ $|X|=2s$,\  and \ $s =\beta n^{3/4}+O(1)$, \ with the  application of  Lemma~\ref{defect} completes the proof.
  \end{proof}

\subsection{Large gaps in $A$}\label{ss42}\quad
The segment $[s+1,m}  %%%%{m -s]$ contains $R_1-r_1$ members of $A$, similarly $[n+1-m}  %%%%{m +s,n-s]$ contains $R_2-r_2$
of them, which  adds up to $R-r$.
After having Claims~\ref{ss41} and~\ref{ss42}
 we may assume that  $2(1-\varepsilon) n^{1/4}< r\leq R< 2(1+\varepsilon)n^{1/4}$,
hence $A\cap \left([s+1,m}  %%%%{m -s] \cup [n+1-m}  %%%%{m +s,n-s]\right)$ has fewer than $R-r< 4\varepsilon n^{1/4}$ elements.
Using these assumptions, we shall slightly modify  the proof of Theorem~\ref{X_lind} by defining
$\ell}   %%%%{M =\lfloor (1-\alpha)n^{1/4}\rfloor$.

The second idea of the proof is that with  $\ell}   %%%%{M$ defined as above we can find many differences $a_j-a_i$ of small order which are significantly larger than $k\ell}   %%%%{M$, hence we give a lower bound $C(A, \ell)$, which was defined in~\eqref{X_ineqL}, that provides the right hand side bound in \eqref{eq41}.

\medskip
\Claim{4.3}{If $2(1-\varepsilon) n^{1/4}< r\leq R< 2(1+\varepsilon)n^{1/4}$ and  $\ell}   %%%%{M$, $k$, and $m}  %%%%{m$ are defined as above, then $$
C(A, \ell)>  (1-\alpha-2\varepsilon)^2(\alpha - 2\beta)n^{5/4}+O(n). $$
}\label{cl43}

\begin{proof}
Consider the pairs $(a_i,a_j)$ with $a_i\le s < m}  %%%%{m-s < a_j$ and $j\leq i+\ell$.
Each such pair appears in the definition of $C(A,\ell)$ and each of such difference $a_j-a_i$ is at least
  $m}  %%%%{m-2s$ which exceeds $\ell}   %%%%{M (k-(\ell}   %%%%{M +1)/2)$, as $\alpha > 2\beta$.
 Each such pair adds a gain  at least $m}  %%%%{m-2s - (\ell}   %%%%{M (k-(\ell}   %%%%{M +1)/2)) \ge (\alpha-2\beta)n^{3/4}+O(n^{1/2})$ toward $C$ in~\eqref{X_ineqL}.

Given $a_i$ with $1\leq i\leq r_1$ we  choose $j$ as  $R_1< j \leq \ell +i$; there are
  $\ell-R_1+i$ possibilities, whenever this last quantity is positive.
Altogether we have at least $1+2+\ldots  +(\ell}   %%%%{M-R_1+r_1)> (\ell}   %%%%{M-R_1+r_1)^2/2$ such pairs.

Similarly, pairs $(a_i,a_j)$ with $a_i < n+1-m}  %%%%{m+s < n+1-s \le a_j$ and $j\leq i+\ell$ gives us more than $(\ell}   %%%%{M-R_2+r_2)^2/2$ such pairs.

Since\ $R_1-R_2-r_1-r_2=R-r\le   4\varepsilon n^{1/4}$, the total number of pairs is at least  $(2\ell}   %%%%{M-R+r)^2/4> (1-\alpha-2\varepsilon)^2n^{1/4}+O(1)$,
we get the lower bound for the total gain as stated.
\end{proof}

{\it Completing  the proof of Theorem~\ref{mainthm}:\quad}
The constraints in the above three claims cover all possibilities for $A$.

In the cases covered by Claims~\ref{ss41} and~\ref{ss42} we have
 got a large  defect $K(\mathcal{A})$ so inequalities~\eqref{eq41} and~\eqref{X_ineqF2}
 establish the required upper bound for $k$.
In the case covered by Claim~\ref{ss43} the large slackness term $C$ in the
inequality~\eqref{X_ineqL2} completes the proof of Theorem~\ref{mainthm}.
\end{proof}

\subsection{Remark}\label{ss43}
  Note that  one could optimize somewhat better the parameters $\alpha, \beta$, etc., but we did not see the point computing more digits of the optimal values.
 Much more refining should be possible by exploring the structure of a Sidon set more thoroughly; i.e., giving further conditions on the number of elements in some intervals.  For example, when $a\in A$ is close to $s$,  then one can improve the bounds from Claim~\ref{cl41}, as such $a$ will not contribute much to the degrees  of vertices in $X$. From the other side, when $a\in A$ is close to $1$, then $a$ will participate in larger gaps, and one can improve Claim~\ref{cl43}. The computation is rather delicate, and it improves the bound on $\gamma$ to $0.00342$. It is likely that it could be improved a bit further, with an additional analysis of the structure of $A$.

 There are discussion of the structure of dense Sidon sets in the blog of Gowers~\cite{gowers}, though probably there is no  obvious connection toward our proof.
It seems that further ideas are needed to get rid of the $n^{1/4}$ term in its entirety.

\section{Analogous Improvements for Weak Sidon Sets}\label{sec_weak}
A set of integers $A = \{ a_i \}$ is  a \emph{weak Sidon} set if all the pairwise sums $a_i+a_j$ are different for $i<j$. Note that for Sidon sets we
  need this to hold for $i \leq j$. Denote by $W(n)$
the size of the largest weak Sidon subset of $[n]$. The current best upper bound
\begin{equation}\label{eq5W}
W(n) \leq n^{1/4}+\sqrt{3}n^{1/4}+O(1)
  \end{equation}
is due to Kayll~\cite{K04}, who used a method analogous to Lindstr\"{o}m's~\cite{L69}. One could prove  \eqref{eq5W}  with the set systems method described in Section~\ref{sec:hypergraph}, see Ruzsa~\cite{R93}. Similarly,  as for the Sidon sets, exploiting the tension between the two arguments, we  get a slight improvement in the coefficient of the $n^{1/4}$ term.

\begin{theorem}\label{X_weakthm}
There exists a constant $\gamma \geq 0.0089$ such that $W(n) \leq n^{1/2}+n^{1/4}(\sqrt{3}-\gamma) + O(1)$.
\end{theorem}
The proof is almost identical to the proof of Theorem~\ref{mainthm}, therefore we just sketch it, highlighting only the salient differences.

\subsection{Counting differences up to order $\ell}   %%%%{M $}
We proceed almost exactly as in Section~\ref{sec_lind} and we use  the same notation. Take a weak Sidon set $1\leq a_1 < \ldots < a_k\leq n$ and sum all positive differences of order at most $\ell}   %%%%{M $.
The important difference is that some of these differences may be repeated.
Let
$$\mathcal{P}:= \left\{ p: 0< p=a_j-a_i = a_{j'}-a_{i'} \text{ for some } \{i,j\}\ne \{i',j'\}\right\}$$ be the set of repeated distances.
If a difference is repeated, then the participating members form an arithmetic progression of length $3$,
 either $a_i=a_{j'}$ or $a_j=a_{i'}$, so each member of $\mathcal{P}$ is repeated exactly twice.
Additionally, each member of $A$ could be at most once in the middle of such progression, implying
  $|\mathcal{P}|\leq k-2$.
Hence, in the left hand side of~\eqref{eqlind1} we can have the sum of positive integers only up to $\ell}   %%%%{M (k-(\ell}   %%%%{M+1)/2)-(k-2)$.
Instead of   (\ref{X_ineqL}) we obtain  the following.

\begin{equation*
    \frac{1}{2}\ell}   %%%%{M ^2(k-(\ell}   %%%%{M +1)/2)^2 + C \leq \frac{1}{2}\ell}   %%%%{M (\ell}   %%%%{M +1)n + \ell}   %%%%{M k^2,
\end{equation*}

\noindent where $C$ is any lower bound for
 $\sum \max\{ a_j-a_i -(\ell}   %%%%{M-1)k, 0\}$ for $i<j\leq i+\ell}   %%%%{M$.
We set $\ell}   %%%%{M =(\sqrt{3}-\alpha)n^{1/4}$, a bit less than what Kayll's proof used and obtain

\begin{equation}\label{X_ineqWL2}
    k \leq n^{1/2}+\sqrt{3}n^{1/4}+\frac{n^{1/4}\alpha^2}{2(\sqrt{3}-\alpha)} - \frac{C}{(\sqrt{3}-\alpha)^2n} +O(1).
\end{equation}

\subsection{Double counting with set systems}
We
proceed as in Section~\ref{sec:hypergraph}, with $A_1=A$ being our weak Sidon set, $A_i=A+(i-1)$ for $i \in [m}  %%%%{m]$ and $m}  %%%%{m =\lfloor \sqrt{3}n^{3/4}\rfloor$.
Since
 there are at most $k-2$ repeated distances, we conclude that the number of pairs of sets with intersection of size $2$ is at most $km}  %%%%{m$, and there is no
 intersection of size larger than $2$.
We get the following version of (\ref{ineqF}).
\begin{equation*
m}  %%%%{m(m}  %%%%{m-1)+2m}  %%%%{m k \geq \sum_i \left(\sum_j |A_i\cap A_j|\right) = \sum d_x^2 = \frac{1}{v} \left(\sum d_x\right)^2 +K.
\end{equation*}
This turns into the following version of (\ref{X_ineqF2}).

\begin{equation}\label{X_ineqWF2}
    k \leq n^{1/2}+\sqrt{3}n^{1/4}-\frac{K}{2n}+O(1).
\end{equation}

\subsection{Proof of Theorem \ref{X_weakthm}}  The analogues of  Claims~\ref{ss41} and~\ref{ss42}
imply that we can assume that $[s] \cup [n+1-s,n]$ contains more than $2(\sqrt{3}-\varepsilon)n^{1/4}$ elements of $A$ and $[s+1,m}  %%%%{m-s] \cup [n-m+s+1,n-s]$ contains fewer than $4\varepsilon
        n^{1/4}$ such elements, otherwise $\gamma> \beta\varepsilon^2$.
Hence,  the number of pairs $1 \leq i < j \leq i+\ell}   %%%%{M $ with $a_j - a_i > m}  %%%%{m-2s$ is at least ${(\sqrt{3}-\alpha-2\varepsilon)^2}\sqrt{n} + O(n^{1/4})$.
This gives us $C \geq  (\sqrt{3}-\alpha-2\varepsilon)^2(\alpha - 2\beta)n^{5/4}-O(n)$ in (\ref{X_ineqWL2}).
We obtain an improvement $\gamma$ in~\eqref{eq5W}
  in the constant in front of $n^{1/4}$ when
$$\min\left\{ {\beta\varepsilon^2}, \frac{(\sqrt{3}-\alpha-2\varepsilon)^2(\alpha - 2\beta)}{(\sqrt{3}-\alpha)^2} - \frac{\alpha^2}{2(\sqrt{3}-\alpha)}  \right\}> \gamma .$$
Choosing $\alpha = 0.273$, $\beta = 0.068$, $\varepsilon=0.363$ makes the left hand side larger than 0.00896, as claimed in  Theorem~\ref{X_weakthm}.
\qed

\section{$t}   %%%%{\lambda$-thin Sidon sets}\label{sec_thin}

A set of integers $A$ is  a $t}   %%%%{\lambda$-\emph{thin Sidon set} if
  $|A \cap (A+c)|\leq t}   %%%%{\lambda$ for every $c\neq 0$,  where $A+B:= \{ a+b: a\in A, B\in B\}$ and $A+c:= A+ \{ c\}$.
In other words, for every $c$, the equation $a_i-a_j=c$ has at most $t}   %%%%{\lambda$ different solutions $a_i,a_j\in A$.
The case $t}   %%%%{\lambda =1$ corresponds exactly to the Sidon sets.
A related notion, the so-called representation function
 $r_A(x) := |\{(a, a')\in A\times  A : x = a + a'\}|$ where $A$ is a subset in a field
 of characteristic zero, is heavily investigated, see, e.g., Cilleruelo~\cite{C12}.
Let $S_t}   %%%%{\lambda(n):=\max\{ |A|: A \subseteq [n],$ $A$ is $t}   %%%%{\lambda$-thin$\}$.
Caicedo, Martos,  and Trujillo proved that
\begin{theorem}[\cite{CMT}]\label{thm61}
We have $S_t}   %%%%{\lambda(n)= (1+o(1))\sqrt{t}   %%%%{\lambda n}$
while $t}   %%%%{\lambda$ is fixed and $n\to \infty$.
\end{theorem}

Using Theorem~\ref{setsthm} we prove in the next subsection the following upper bound.
 \begin{equation}\label{eq62}
 S_t}   %%%%{\lambda (n) < \sqrt{t}   %%%%{\lambda n} + (t}   %%%%{\lambda n)^{1/4} +\frac{1}{2}.
 \end{equation}
The method of Section 4 gives the following improved upper bound; we omit it's proof.
\begin{theorem}\label{thm66}
There exist a constants $\gamma =\gamma_t}   %%%%{\lambda >0$ and $n_t$ such that $S_t}   %%%%{\lambda (n) \leq (t}   %%%%{\lambda n)^{1/2}+(t}   %%%%{\lambda n)^{1/4}(1-\gamma)$ for every
$n> n_{t}   %%%%{\lambda}$.  \hfill \qed
\end{theorem}

\subsection{Upper bound calculation}

\begin{lemma}[Finding an integer]\label{le62}
Suppose that $f(x):= \alpha x^2 +\beta x + \gamma$, where  $\alpha, \gamma>0$, $\beta<0$ are real numbers.
If $\beta^2-4\alpha \gamma -\alpha^2>0$ then there exists a positive integer $m}  %%%%{m $ with $f(m}  %%%%{m)<0$.
\end{lemma}

\begin{proof} The equation $f(x)=0$ has two distinct real roots $m}  %%%%{m _1$ and $m}  %%%%{m _2$, we may suppose $m}  %%%%{m _2>m}  %%%%{m_1$.
These roots are positive since $f(x)>0$ for all $x\leq 0$.
Furthermore,  $f(x)<0$ if and only if $m}  %%%%{m _1< x< m}  %%%%{m_2$.
If $m}  %%%%{m _2-m_1>1$ then we find a positive integer $m}  %%%%{m $ between $m}  %%%%{m _1$ and $m}  %%%%{m _2$.
This condition is equivalent to the constraint Lemma~\ref{le62}.
   \end{proof}

\begin{claim}\label{le63}
Given $n\geq  t}   %%%%{\lambda \geq 1$ define $\kappa:= \sqrt{t}   %%%%{\lambda n} + (t}   %%%%{\lambda n)^{1/4} +\frac{1}{2}$.
Then there is a positive integer $m}  %%%%{m $ such that
\begin{equation}\label{eq60}
 (n+m}  %%%%{m -1) (t}   %%%%{\lambda m + \kappa -t}   %%%%{\lambda) < \kappa^2 m}  %%%%{m.
\end{equation}
\end{claim}

\begin{proof}
Rearranging~\eqref{eq60} one can see that we need a positive integer $m}  %%%%{m $ satisfying $f(m}  %%%%{m)<0$ where
  $f(x):= t}   %%%%{\lambda x^2+(nt}   %%%%{\lambda -\kappa^2+\kappa-2t}   %%%%{\lambda)x +(\kappa-t}   %%%%{\lambda)(n-1)$.
We claim that one can apply Lemma~\ref{le62} to this polynomial $f(x)$, where
$\alpha:=t}   %%%%{\lambda$, $\gamma:= (\kappa-t}   %%%%{\lambda)(n-1)$ are both  positive and
\[ \beta= nt}   %%%%{\lambda -\kappa^2+\kappa-2t}   %%%%{\lambda = -2(nt}   %%%%{\lambda)^{3/4} -\sqrt{nt}   %%%%{\lambda} -2t}   %%%%{\lambda +\frac{1}{4} <0.
\]
Finally,  the main constraint in Lemma~\ref{le62} is satisfied since
\begin{multline*}
\frac{1}{2}|\beta| = (nt}   %%%%{\lambda)^{3/4} +\frac{1}{2}\sqrt{nt}   %%%%{\lambda} +t}   %%%%{\lambda -\frac{1}{8}>
 \sqrt{nt}   %%%%{\lambda}\left((nt}   %%%%{\lambda)^{1/4} +\frac{1}{2}\right) \\ =\sqrt{nt}   %%%%{\lambda} \sqrt{k-\frac{1}{4}}
  > \sqrt{  t}   %%%%{\lambda (n-1) (k-t}   %%%%{\lambda) + \frac{1}{4}t}   %%%%{\lambda^2}.
   \end{multline*}
   \end{proof}

\begin{proof}[Proof of~\eqref{eq62}]
Let $A\subset [n]$ be a $k$-element $t}   %%%%{\lambda$-thin Sidon set.
Suppose, on the contrary, that $k\geq \kappa:= \sqrt{t}   %%%%{\lambda n} + (t}   %%%%{\lambda n)^{1/4} +\frac{1}{2}$.  Claim~\ref{le63} implies that
 there exists a positive $m}  %%%%{m $ such that
\[ n+m}  %%%%{m -1 < \frac{\kappa^2 m}  %%%%{m}{t}   %%%%{\lambda m}  %%%%{m + \kappa -t}   %%%%{\lambda}.
\]
The function $g(x):= x^2m}  %%%%{m /(t}   %%%%{\lambda m +x-t}   %%%%{\lambda)$ is strictly increasing for $x>0$,
so we obtain that $n+m}  %%%%{m -1< g(k)$.

Consider the hypergraph ${\mathcal{A}}:= \{ A_1, \dots, A_m}  %%%%{m \}$ with vertex set $[n+m}  %%%%{m -1]$ where $A_i:=A+(i-1)$.
Theorem~\ref{setsthm} gives $n+m}  %%%%{m -1\geq g(k)$,   a contradiction.
   \end{proof}

\subsection{A lower bound construction from finite fields}\label{ss62}
The definition of $t}   %%%%{\lambda$-thin Sidon sets naturally extends to every commutative group.
For completeness we recall the construction from~\cite{CMT} that
 in case of $q$ is a power of a prime number and $t}   %%%%{\lambda$ divides $q-1$, one has
 \begin{equation}\label{eq61}
   S_t}   %%%%{\lambda(\mathbb{Z}_{(q^2-1)/t}   %%%%{\lambda})\geq q.
 \end{equation}
For these $n=(q^2-1)/t}   %%%%{\lambda$ we have $S_t}   %%%%{\lambda(\mathbb{Z}_n)\geq \sqrt{t}   %%%%{\lambda n +1}$.
Since the set of primes  which are $\, \equiv 1 \mod t}   %%%%{\lambda$ are sufficiently ``dense"
 among the integers and trivially
$S_t}   %%%%{\lambda(n)\geq S_t}   %%%%{\lambda(\mathbb{Z}_n)$, one concludes the result in Theorem~\ref{thm61}.

To show~\eqref{eq61}  suppose that $t}   %%%%{\lambda$ divides $q-1$.
Let $\mathbb{F}_q$ be the finite field of size $q$, $g$ a primitive element of $\mathbb{F}_{q^2}$.
 Define
\begin{equation}\label{eq64}
    A_{q, t}   %%%%{\lambda}:= \{ x\in [(q^2-1)/t}   %%%%{\lambda]:  g^{x+ y(q^2-1)/t} -g  \in \mathbb{F}_q \textrm{ for some }y\in [t]\}.
\end{equation}
This is a straightforward modification of the Bose--Chowla~\cite{B42,BC} construction (the case $t}   %%%%{\lambda=1$) and one can show that
 $A_{q, t}   %%%%{\lambda}$ is a
$t}   %%%%{\lambda$-thin Sidon set in $\mathbb{Z}_{(q^2-1)/t}   %%%%{\lambda}$.
 \hfill \qed

\medskip

{\bf Acknowledgements:}
We thank to Bernard Lidicky assisting the optimization of formulaes.

Combinatorics (math.CO); Discrete Mathematics (cs.DM); Number Theory (math.NT)


Learning Region of Attraction for Nonlinear Systems

Abstract: Estimating the region of attraction (ROA) of general nonlinear autonomous systems remains a challenging problem and requires a case-by-case analysis. Leveraging the universal approximation property of neural networks, in this paper, we propose a counterexample-guided method to estimate the ROA of general nonlinear dynamical systems provided that they can be approximated by piecewise linear neural networks and that the approximation error can be bounded. Specifically, our method searches for robust Lyapunov functions using counterexamples, i.e., the states at which the Lyapunov conditions fail. We generate the counterexamples using Mixed-Integer Quadratic Programming. Our method is guaranteed to find a robust Lyapunov function in the parameterized function class, if exists, after collecting a finite number of counterexamples. We illustrate our method through numerical examples.

\subsection{Neural network training}
The decomposition of the nonlinear map $f(x) = Ax + f_{NN}(x) + w(x)$ in~\eqref{eq:nn_approx_dyn} is motivated by two facts: first, stability verification tools~\cite{chen2021learning, yin2020stability} for neural network dynamical systems have been developed; second, powerful and easy-to-use machine learning tools are available to train $f_{NN}(x)$ to high accuracy and keep the approximation error $w(x)$ small. In training $f_{NN}(x)$, we want to obtain a neural network model that not only achieves a small approximation error but also is easy to verify. In light of the latter objective, it is desirable to increase the number of \emph{stable} ReLUs in $f_{NN}(x)$, i.e., ReLUs that always output zero or one. For these ReLUs, we do not need to introduce binary variables in the MIQP~\eqref{eq:MIQP}. As a result, any training method that can increase the number of stable ReLUs can significantly improve the complexity of the verification. As shown in~\cite{xiao2018training}, applying $\ell_1$-regularization to the training objective generally works well in reducing the complexity of verification. Other training methods with the same goal are presented in~\cite{xiao2018training} as well.

\subsection{Identification of error bound}
For a given neural network $f_{NN}(x)$ which approximates the nonlinear map $f(x)$, we estimate an error bound in the form of~\eqref{eq:approx_err_bd} based on dense sampling of the ROI $\mathcal{X}$. This method is not meant to compete with the modeling error quantification methods in the literature. Instead, we use it to provide a reasonable error bound to set up the simulation.

By assumption $f(x)$ is locally Lipschitz continuous. Let $L_f$ ($L_N$) be an upper bound on the Lipschitz constant of $f(x)$ ($Ax + f_{NN}(x)$) over the ROI $\mathcal{X}$. Since $w(x)= f(x) - Ax - f_{NN}(x)$, we can upper bound the Lipschitz constant of $w(x)$ as $L_w = L_f + L_N$. Then we sample densely from the ROI $\mathcal{X}$ and in particular the samples $\mathcal{S}_\mathcal{X} = \{x^S_i\}_{i=0}^N \subset \mathcal{X}$ form a $\epsilon$-net of $\mathcal{X}$, i.e., for all $x \in \mathcal{X}$, there exists a sample $y \in \mathcal{S}_\mathcal{X}$ such that $\lVert x - y \rVert \leq \epsilon$. We define the admissible set of $(\gamma, \delta)$ as
\begin{equation*}
\Gamma =\{(\gamma, \delta) \vert \lVert w(x) \rVert_\infty  \leq \gamma \lVert x \rVert_\infty + \delta, \forall x \in \mathcal{S}_\mathcal{X} \}
\end{equation*}
and any pair $(\gamma^\prime, \delta^\prime) \in \Gamma$ gives an estimate of the upper bound in~\eqref{eq:approx_err_bd}. Since we want to keep $(\gamma^\prime, \delta^\prime)$ small, we let $\delta^\prime = \min \delta \text{ s.t. } (\gamma^\prime, \delta) \in \Gamma$. Note that there are infinitely many pairs in the admissible set and decreasing one parameter would increase the other one.

Given any admissible pair $(\gamma^\prime, \delta^\prime)$, for all $x \in \mathcal{X}$ we have
\begin{equation} \label{eq:err_bd_approx}
\begin{aligned}
\lVert w(x) \rVert_\infty &\leq \lVert w(x) - w(y)\rVert_\infty + \lVert w(y) \rVert_\infty  \\
&\leq L_w \lVert x - y \rVert_\infty + \gamma^\prime \lVert y \rVert_\infty  + \delta^\prime\\
& \leq L_w \lVert x - y \rVert_\infty + \gamma^\prime \lVert y - x \rVert_\infty + \gamma^\prime \lVert x \rVert_\infty  + \delta^\prime \\
& \leq \gamma^\prime \lVert x \rVert_\infty  + \delta^\prime + (L_w + \gamma^\prime) \epsilon
\end{aligned}
\end{equation}
where $y \in \mathcal{S}_\mathcal{X}$ is chosen such that $\lVert x - y \rVert \leq \epsilon$. Therefore, $\gamma = \gamma^\prime, \delta = \delta^\prime + (L_w + \gamma^\prime) \epsilon$ gives a valid upper bound for $\lVert w(x) \rVert_\infty$ over the ROI $\mathcal{X}$ if we assume $L_f$ is known. Otherwise, inequality~\eqref{eq:err_bd_approx} indicates that by choosing $\epsilon$ small enough, the admissible pair $(\gamma^\prime, \delta^\prime)$ obtained from sampling gives a good estimate of a deterministic error bound.

Since every pair from the admissible set $\Gamma$ generates an error bound estimate, we can combine $K$ admissible $(\gamma^\prime, \delta^\prime)$ pairs to obtain a tighter error bound as
\begin{equation} \label{eq:PWA_err_bd}
	\lVert w \rVert_\infty \leq \gamma_i^\prime \lVert x \rVert_\infty + \delta_i^\prime, \quad i = 1,\cdots, K
\end{equation}
from the sampling. One special, interesting choice is setting $\gamma^\prime = 0$ since in this case constraint~\eqref{eq:MIQP_w_set} in the MIQP becomes $\lVert w \rVert_{\infty} \leq \delta^\prime$ and is convex.

\begin{figure}[htb!]
	\centering
	\includegraphics[width = 0.6\columnwidth]{multiple_bounds.png}
	\caption{The neural network approximation errors are marked by the blue dots for a dense sample set over the ROI. The affine error bounds are denoted by the blue, orange, green, and red  lines corresponding to $(\gamma, \delta) = $ $(0, 0.0288)$, $(1.167, 0.0141)$, $(0.0233, 4.767 \times 10^{-3})$, $(0.0350, 4.026 \times 10^{-4})$, respectively.}
	\label{fig:err_bounds}
\end{figure}

\subsection{Robust Lyapunov function}
For the uncertain system~\eqref{eq:uncertain_dyn} with the uncertainty set $\mathcal{W}(x)$, we aim to show that the system trajectories converge to a neighborhood $\mathcal{B}$ of the origin. The neighborhood $\mathcal{B}$ is chosen according to the practical need of verification. Let $B_r = \{ x\in \mathbb{R}^{n_x} \vert \lVert x \rVert_\infty \leq r \} \subset \mathcal{X}$ denote an $\ell_\infty$ norm ball with radius $r > 0$ contained inside the ROI. The robust Lyapunov function is defined in the following theorem.

\begin{definition}[Successor set]
For the uncertain dynamics~\eqref{eq:uncertain_dyn}, we denote the successor set from a set $\mathcal{B}$ as $\text{succ}(\mathcal{B}) = \{y \in \mathbb{R}^{n_x} \vert \exists x \in \mathcal{B}, w \in \mathcal{W} \text{ s.t. } y = \hat{f}(x) + w\}$.
\end{definition}
\begin{theorem} \label{thm:Lyap}
	Consider the discrete-time uncertain system~\eqref{eq:uncertain_dyn} and assume there exists a continuous function $V(x): \mathcal{X} \mapsto \mathbb{R}$ satisfying
	\begin{subequations}
		\label{eq:robust_Lyap_cond}
		\begin{align}
		\begin{split} \label{eq:robust_Lyap_cond_1}
		&V(x) > 0, \forall x \in \mathcal{X} \setminus B_r,
		\end{split} \\
		\begin{split} \label{eq:robust_Lyap_cond_2}
		& V(\hat{f}(x) + w) - V(x) < 0, \forall x \in \mathcal{X}\setminus B_r, \forall w \in \mathcal{W}(x).
		\end{split}
		\end{align}
	\end{subequations}
	Denote $\underline{\Omega}_{\text{succ}(B_r)}(V)$ the smallest sublevel set of $V(x)$ that contains the successor set of $B_r$ and $\bar{\Omega}_{\mathcal{X}}(V)$ the largest sublevel set of $V(x)$ that is contained in $\mathcal{X}$. Then for all initial states $x_0 \in \bar{\Omega}_{\mathcal{X}}(V)$ of the uncertain system~\eqref{eq:uncertain_dyn}, we have $\lim_{k \rightarrow \infty} x_k \in \underline{\Omega}_{\text{succ}(B_r)}(V)$.
\end{theorem}
\begin{proof}
All trajectories starting from $x_0 \in \bar{\Omega}_\mathcal{X}(V)$ reach $B_r$ in a finite number of steps since $V(x)$ is upper bounded in $\mathcal{X}$ and its decrease in each step is lower bounded by a positive number as long as $x \notin B_r$. Once the state $x_k$ reaches $B_r$, it is mapped to $x_{k+1} \in \text{succ}(B_r) \subset \underline{\Omega}_{\text{succ}(B_r)}(V)$ in the next step. Whether $x_{k+1} \notin B_r$ or $x_{k+1} \in B_r$, the trajectory starting from $x_{k+1}$ will always stay in $\underline{\Omega}_{\text{succ}(B_r)}(V)$.
\end{proof}
We call any $V(x)$ satisfying constraints~\eqref{eq:robust_Lyap_cond_1} and~\eqref{eq:robust_Lyap_cond_2} a \emph{robust Lyapunov function} and those satisfying constraint~\eqref{eq:robust_Lyap_cond_1} a robust Lyapunov function candidate. Theorem~\ref{thm:Lyap} states that a robust Lyapunov function $V(x)$ certifies the convergence of system trajectories under uncertainty to a neighborhood of the origin whose size and shape is jointly decided by $V(x)$ and $B_r$. The largest sublevel set of $V(x)$ contained in the ROI $\mathcal{X}$ gives an estimate of robust ROA for the uncertain system, and $\tilde{\mathcal{O}} = \bar{\Omega}_{\mathcal{X}}(V)$ is also an inner-approximation of ROA of the original nonlinear system~\eqref{eq:sys_dyn}. In the rest of the paper, we refer to robust Lyapunov functions simply as Lyapunov functions.

\subsection{Lyapunov function parameterization}
To make the search for a Lyapunov function $V(x)$ tractable, we parameterize the Lyapunov function candidate as a quadratic function using predicted nominal trajectories of the uncertain system~\eqref{eq:uncertain_dyn} for a finite horizon as the basis. For a horizon of $k \geq 0$, the basis is given by
\begin{equation*}
z_k(x) = [ x^\top \ \hat{f}^{(1)}(x)^\top \ {\hat{f}^{(2)}(x)}^\top \ \cdots \ {\hat{f}^{(k)}(x)}^\top ]^\top
\end{equation*}
where $\hat{f}^{(i+1)}(x) = \hat{f}(\hat{f}^{(i)}(x))$ for $i \geq 0$ and $\hat{f}^{(0)}(x) = x$. By denoting $\mathbb{S}^n$ the set of $n \times n$-dimensional symmetric matrices, and $\mathbb{S}^n_{+}$ ($\mathbb{S}^n_{++}$) the set of $n \times n$-dimensional positive semidefinite (definite) matrices, the Lyapunov function candidate of \emph{order $k$} is defined as
\begin{equation} \label{eq:V_order}
	V_k(x; P) = z_k^\top(x) P z_k(x), \quad P \in \mathbb{S}_{++}^{n_x}.
\end{equation}
This parameterization is inspired by the non-monotonic Lyapunov function~\cite{ahmadi2008non} and finite-step Lyapunov function~\cite{bobiti2016sampling} methods which construct Lyapunov function candidates using system states several steps ahead. By construction, $V_k(x;P)$ is positive definite and readily satisfies constraint~\eqref{eq:robust_Lyap_cond_1}. In addition, the parameterization of $V_k(x;P)$ has two desirable properties: (i) $V_k(x;P)$ is a linear function in $P$ when the state $x$ is fixed, and (ii) for $k \geq 1$, $V_k(x;P)$ is a piecewise quadratic function in $x$ and its complexity can be easily tuned by the order $k$.

The first property indicates that the set of valid Lyapunov function candidates is convex. To show this, define the Lyapunov difference function as
\begin{equation}
\Delta V_k(x, w, P) = V_k(\hat{f}(x) + w; P) - V_k(x; P).
\end{equation}
From the first property of $V_k(x;P)$, we know that $\Delta V_k(x, w, P)$ is also a linear function in $P$ when the state $x$ and uncertainty $w$ are fixed. We describe the set of valid Lyapunov functions in the parameter space as
\begin{equation} \label{eq:target_set}
\begin{aligned}
\mathcal{F} = \{ P \in \mathbb{S}^{n_x} \vert 0 \prec P \preceq I ,  \Delta V_k(x, w, P) < 0, \forall x \in \mathcal{X}\setminus B_r, \forall w \in \mathcal{W}(x)\}
\end{aligned}
\end{equation}
and denote $\mathcal{F}$ the \emph{target set}. It follows that $\mathcal{F}$ is a convex set since it is defined by two linear matrix inequalities and infinitely many linear inequalities in $P$. The convexity of $\mathcal{F}$ is essential for the design of our main algorithm to search for Lyapunov functions.

The second property follows from the fact that the ReLU network $\hat{f}(x)$ is a piecewise affine function and so are $\hat{f}^{(i)}(x)$. By tuning the order $k$, we can parameterize functions with high complexity, i.e., piecewise quadratic functions with a large amount of partitions, by using a relatively small number of parameters.

After identifying the set of Lyapunov functions $\mathcal{F}$, our goal becomes finding a feasible point in $\mathcal{F}$ or proves that $\mathcal{F}$ is empty with the given parameters. Although the set $\mathcal{F}$ is convex, finding a feasible point in it is challenging due to the infinitely many constraints in~\eqref{eq:target_set} and the complexity of the underlying uncertain neural network dynamics~\eqref{eq:uncertain_dyn}.

\section{Introduction}
\input{introduction}

\section{Problem Statement}
\input{prob_statement}

\section{Parameterization of Robust Lyapunov functions}
\input{learning_Lyap}

\section{Sampling-based Lyapunov function synthesis}
\input{synthesis}

\section{Approximation of dynamical systems by neural networks}
\input{err_bound_assumption}

\section{Numerical examples}
\input{simulation}

\section{Conclusion}
\input{conclusion}

\small
\bibliographystyle{IEEEtran}

\subsection{2-D rational system}
Consider the $2$ dimensional discrete-time rational system adapted from~\cite[Example 2]{coutinho2013local}:
\begin{equation} \label{eq:rational}
x_1^+ = x_1 - \frac{x_1 + x_2^3}{1+ x_1^2}, \quad x_2^+ = x_2 + \frac{x_1^3 - 0.25x_2}{1 + x_2^2}.
\end{equation}
and denote the dynamics in~\eqref{eq:rational} as $x_+ = f(x)$. For the uncertain dynamics decomposition~\eqref{eq:uncertain_dyn}, we choose the Jacobian of $f(x)$ at the origin as matrix $A = [0 \ 0; 0 \ 0.75]$. Then we sample $22500$ states uniformly from the box $\mathcal{R} = \{x \in \mathbb{R}^2 \vert \lVert x \rVert_\infty \leq 1.5 \}$ and train a fully-connected ReLU network with the structure $2-100-100-100-2$ (three hidden layers with $100$ neurons each) with Keras~\cite{chollet2015keras} and the Adam optimizer~\cite{kingma2014adam} in $100$ epochs to approximate the error dynamics $f(x) - Ax$. Since the approximation error bound~\eqref{eq:approx_err_bd} is written in terms of the $\ell_\infty$ norm, the training loss function is set to the mean absolute error. Furthermore, in order to alleviate the practical computational cost of the MIQP~\eqref{eq:MIQP} in the analysis phase, we add $\ell_1$ regularization with weight  $10^{-4}$ during training.

We construct the ROI $\mathcal{X}$ by uniformly sampling initial states from the region $\mathcal{R}$ and simulate the trajectories of the system~\eqref{eq:rational} for $50$ steps. Then, the convex hull of the initial condition samples from which the trajectories converge to the origin is chosen as the reference ROI $\mathcal{X}_\text{ref} := \{ x \vert A_\text{ref} x \leq b_\text{ref} \}$. We tune the ROI by $\mathcal{X} = \tau \mathcal{X}_\text{ref} := \{x\vert A_\text{ref} \leq \tau b_\text{ref}\}$ with $0 < \tau \leq 1.0$. In this example, we set the scaling parameter $\tau = 0.9$. The sampled convergent initial states are marked as the black dots in Fig.~\ref{fig:rational_ROA} where the ROI is also plotted.

After training the neural network and fixing the ROI, we estimate the neural network approximation error by sampling a uniformly spaced grid from the ROI. The grid consists of $72306$ state samples which form an $\epsilon$-net of the ROI with $\epsilon \approx 0.005$. We plot the $(\lVert x \rVert_\infty, \lVert w \rVert_\infty)$ pairs for all the samples in Fig.~\ref{fig:err_bounds} and our estimated error bound with $(\gamma, \delta)$ gives an affine upper bound over all the sampled graph of $(\lVert x \rVert_\infty, \lVert w \rVert_\infty)$. Selected values of $(\gamma, \delta)$ and their corresponding affine bounds are plotted in Fig.~\ref{fig:err_bounds}. Although each pair $(\gamma, \delta)$ gives an estimate on the bound of the neural network approximation error, formulating a concave piecewise affine upper bound by combining different values of $(\gamma, \delta)$ is tighter than using a single one as discussed in Section~\ref{sec:applicability}. As shown in~\eqref{eq:err_bd_approx}, if the sampling is dense enough, the estimated error bounds from samples is close to the true bounds. In this section, we apply estimated error bounds from sampling for simplicity.

Finally, we run Algorithm~\ref{alg:ACCPM} to find a robust Lyapunov function for the considered neural network approximation system with the error bound given by the concave bound shown in Fig.~\ref{fig:err_bounds} using four pairs of $(\gamma, \delta)$ values. Let $B$ denote the neighborhood that is excluded from the search space in place of the $\ell_\infty$ norm ball $B_r$ in~\eqref{eq:robust_Lyap_cond}. For this example, we choose $B = \{x \in \mathbb{R}^2 \vert -0.05 \leq x_1 \leq 0.05, -0.2 \leq x_2 \leq 0.2\}$ as a rectangle according to the simulated uncertain dynamical system~\eqref{eq:uncertain_dyn}. Then we set the order of the Lyapunov function candidates to be $k = 1$ in~\eqref{eq:V_order} and initialize Algorithm~\ref{alg:ACCPM} with an empty sample set. Algorithm~\ref{alg:ACCPM} terminates in $6$ iterations with a total solver time of $748$ seconds. It successfully finds a robust Lyapunov function $V_1(x;P)$ with $P \in \mathbb{S}^{4}_{++}$. The resulting estimate of the ROA $\tilde{\mathcal{O}}$ which is the largest sublevel set of $V_1(x;P)$ is plotted in Fig.~\ref{fig:rational_ROA} together with several simulated trajectories of the uncertain system~\eqref{eq:uncertain_dyn}. We observe that the estimate ROA provided by $V_1(x;P)$ is close to the true ROA estimated by the samples.

As a comparison, we run Algorithm~\ref{alg:ACCPM} with error bound $(\gamma , \delta) = (0, 0.0288)$ which corresponds to the blue line in Fig~\ref{fig:err_bounds}. Since $\gamma = 0$, the constraint~\eqref{eq:MIQP_w_set} becomes convex at the cost of looser characterization of the approximation errors. With the same setup, Algorithm~\ref{alg:ACCPM} finds a robust Lyapunov function in $17$ iterations with the total solver time $3162$ seconds. The synthesized robust Lyapunov function generates an estimate ROA similar to that shown in Fig~\ref{fig:rational_ROA} with about $4$ times the running time.

\begin{figure}[htb!]
\centering
\includegraphics[width = 0.55 \columnwidth]{rational_ROA.png}
\caption{Estimate ROA of system~\eqref{eq:rational} through neural network approximation and synthesizing robust Lyapunov function. The estimate ROA $\tilde{O}$ is marked by the blue curve and the ROI is given by the red polytope with dashed lines. The set $B$ is a rectangle around the origin which is excluded from the search space of the verifier.}
\label{fig:rational_ROA}
\end{figure}

\subsection{3-D polynomial system}
Consider the $3$-dimensional continuous-time polynomial system in~\cite[Example B]{doban2017computation}:
\begin{equation} \label{eq:3d_system}
\begin{bmatrix}
\dot{x}_1 \\ \dot{x}_2 \\ \dot{x}_3
\end{bmatrix} =  \begin{bmatrix}
x_1(x_1^2 + x_2^2 - 1) 	- x_2(x_3^2 + 1) \\
x_2(x_1^2 + x_2^2 - 1) 	+ x_1(x_3^2 + 1)  \\
10 x_3(x_3^2 - 1)
\end{bmatrix}.
\end{equation}
We apply the Euler discretization method with sampling time $dt = 0.1$ seconds to discretize the dynamics and choose the Jacobian of the discretized dynamics at the origin as the $A$ matrix. Then we apply a $3-100-100-100-3$ fully-connected ReLU network to approximate the discrete-time dynamics over the box $\mathcal{R} = \{x \in  \mathbb{R}^3 \vert \lVert x \rVert_\infty \leq 1 \}$. The neural network is trained with $125000$ samples uniformly spaced in $\mathcal{R}$ by the same training method described in the $2$-dimensional example. The ROI is obtained similarly through simulation and we estimate the neural network approximation error bound from sampling. The samples form an $\epsilon$-net in the ROI with $\epsilon \approx 0.01$ and the error bound $(\gamma, \delta) = (0, 0.0165)$ is estimated from sampling.

We run Algorithm~\ref{alg:ACCPM} for the uncertain neural network dynamical system with the exclusion of $B = \{x \in \mathbb{R}^3 \vert \lVert x \rVert_\infty \leq 0.05\}$ from the ROI. The sample set is initialized as an empty set. With order $k = 2$, the algorithm terminates in one iteration with a total solver time of $10$ seconds. Upon termination, a robust Lyapunov function $V_2(x;P)$ is found whose largest sublevel set is shown in Fig~\ref{fig:ROA_slices} together with the ROI at slices $x_1 = 0$ and $x_3 = 0$. Simulated trajectories of the uncertain neural network dynamical system starting from uniformly spaced initial conditions inside the ROI are plotted in Fig.~\ref{fig:ROA_slices} to illustrate the system dynamics.

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.48\columnwidth}
		\includegraphics[width= \textwidth]{ROA_3d_face.png}
		\caption{Slice at $x_1 = 0$}
		\label{fig:slice_x_1}
	\end{subfigure}
 	\hfil
	\begin{subfigure}[b]{0.48\columnwidth}
		\centering
		\includegraphics[width= \textwidth]{ROA_3d_top.png}
		\caption{Slice at $x_3 = 0$}
		\label{fig:slice_x_3}
	\end{subfigure}
	\caption{Estimated ROA $\tilde{\mathcal{O}}$ (blue curve) given by the robust Lyapunov function and the ROI (red polytope with dashed lines) on slices $x_1 = 0$ and $x_3 = 0$. Simulated trajectories of the uncertain neural network dynamical system and their initial states (white dots) are projected to the corresponding slices for plotting. }
	\label{fig:ROA_slices}
\end{figure}

\subsection{Localization of the target set}
To handle the infinitely many linear constraints in~\eqref{eq:target_set}, we first observe that an over-approximation $\tilde{\mathcal{F}}$ of the target set $\mathcal{F}$ can be obtained by relaxing the Lyapunov difference constraint in~\eqref{eq:target_set} to hold only on a sample set with a finite number of state-disturbance pairs $\mathcal{S} = \{(x^S_i, w^S_i)\}_{i=1}^N$, i.e.,
\begin{equation*}
\begin{aligned}
\tilde{\mathcal{F}} = \{ P \in \mathbb{S}^{n_x} \vert 0 \prec P \preceq I , \Delta V_k(x, w, P) < 0,  \forall (x, w) \in \mathcal{S} \}
\end{aligned}
\end{equation*}
with samples $x^S_i \in \mathcal{X} \setminus B_r, w_i^S \in \mathcal{W}(x_i^S)$ for $i = 1,\cdots, N$. We call $\tilde{\mathcal{F}}$ a localization set of $\mathcal{F}$ and $\mathcal{F}\subseteq \tilde{\mathcal{F}}$ holds by definition. Since the localization set $\tilde{\mathcal{F}}$ is given by a finite number of convex inequalities, finding a feasible point in $\tilde{\mathcal{F}}$ or showing infeasibility of $\tilde{\mathcal{F}}$ can be done by solving a convex program efficiently. If for a sample set $\mathcal{S}$, the localization set $\tilde{\mathcal{F}}$ is empty, then we have a certificate that the target set $\mathcal{F}$ is empty. When the target set is nonempty, we can find a feasible point in $\mathcal{F}$ by iteratively expanding the sample set $\mathcal{S}$ and refining the localization set $\tilde{\mathcal{F}}$. However, expanding the sample set in an arbitrary or random way is not efficient or may not improve the over-approximation of $\mathcal{F}$; in order to obtain performance guarantees, we need to add samples that are informative at each iteration. This is done by alternating between a learner and a verifier to select the samples.

\subsection{Construction of the learner}
Given a sample set $\mathcal{S}$ and the corresponding localization set $\tilde{\mathcal{F}}$, the learner proposes a Lyapunov function candidate $V_k(x; P_{ac})$ with $P_{ac}$ as the analytic center of $\tilde{\mathcal{F}}$.

\begin{definition}[Analytic center~\cite{boyd2004convex}] \label{def:analytic_center}
	The analytic center $x_{ac}$ of a set of convex inequalities and linear equalities

	$h_i(x) \leq 0, i = 1,\! \cdots\!, m, \ Fx = g$,

	is defined as the solution of the convex problem
	\begin{equation*}
	\begin{aligned}
	\underset{x}{\mathrm{minimize}} & \quad - \sum_{i=1}^m  \log(-h_i(x))  \quad \text{subject to} \quad Fx = g.
	\end{aligned}
	\end{equation*}
\end{definition}

By the definition of analytic center, $P_{ac}$ is given by
\begin{equation}\label{eq:ac_optimization}
\begin{aligned}
P_{ac} := \underset{P}{\text{argmin}} \ -\sum_{(x, w)\in \mathcal{S}} \log( -\Delta V_k(x, w, P) ) - \log\det (I - P) - \log \det (P).
\end{aligned}
\end{equation}
where $- \log\det (I - P) - \log \det (P)$ is the barrier function of the set $\{P \vert 0 \prec P \prec I \}$. If problem~\eqref{eq:ac_optimization} is infeasible, the localization set $\tilde{\mathcal{F}}$ is empty and so is the target set $\mathcal{F}$. If problem~\eqref{eq:ac_optimization} is feasible, $V_k(x; P_{ac})$ is proposed by the learner as the Lyapunov function candidate based on the localization set $\tilde{\mathcal{F}}$ and is passed to the verifier.

\subsection{Construction of the verifier}
For the given Lyapunov function candidate $V_k(x;P_{ac})$ proposed by the learner, the verifier either validates $V_k(x;P_{ac})$ or rejects it by giving a counterexample $(x^*, w^*)$ at which $V_k(x;P_{ac})$ violates the Lyapunov difference condition~\eqref{eq:robust_Lyap_cond_2}, i.e., $\Delta V_k(x^*, w^*, P_{ac}) \geq 0$. This is done by solving the global optimization problem:
\begin{alignat}{2} \label{eq:verifier_formulation}
&p^* = \underset{x \in \mathcal{X} \setminus B_r, w \in \mathcal{W}(x)}{\mathrm{maximize}} \quad && \Delta V_k(x,w,P_{ac})
\end{alignat}
which is nonconvex. Denote $p^*$ the optimal value of~\eqref{eq:verifier_formulation} and $(x^*, w^*)$ the optimal solution. The verifier validates $V_k(x;P_{ac})$ if $p^* < 0$ and rejects $V_k(x;P_{ac})$ if $p^* \geq 0$ with $(x^*, w^*)$ as the counterexample. In the former case, we already have a valid Lyapunov function $V_k(x;P_{ac})$ for the uncertain system~\eqref{eq:uncertain_dyn}; in the latter case, the counterexample $(x^*, w^*)$ is added to the sample set $\mathcal{S}$ and the localization set $\tilde{\mathcal{F}}$ is updated. Then the learner generates a new Lyapunov function candidate based on the updated localization set. The alternation between the learner and the verifier is repeated until either a Lyapunov function in $\mathcal{F}$ is found or $\mathcal{F}$ is certified to be empty. We summarize our method in Algorithm~\ref{alg:ACCPM}.
\begin{algorithm}
	\KwData{Initial sample set $\mathcal{S}$}
	\KwResult{Infeasibility certificate or Lyapunov function}
	\While{True}{
		Update localization set $\tilde{\mathcal{F}}$ \\
		Call the learner \\
		\eIf{\eqref{eq:ac_optimization} is feasible}{Propose candidate $V_k(x;P_{ac})$ }{Return infeasibility certificate \\}
		Call the verifier \\
		\eIf{max~\eqref{eq:verifier_formulation} $< 0$}{Return Lyapunov function }{Generate counterexample $(x^*, w^*)$ \\
			Update sample set $\mathcal{S} = \mathcal{S} \cup \{(x^*, w^*)\}$}
	}
	\caption{Learning robust Lyapunov function}
	\label{alg:ACCPM}
\end{algorithm}
Solving a nonconvex optimization problem to global optimality is in general intractable, but for the uncertain neural network dynamical system~\eqref{eq:uncertain_dyn}, we are able to formulate problem~\eqref{eq:verifier_formulation} as a nonconvex mixed-integer quadratic program (MIQP) for which global optimization algorithms exists~\cite{belotti2013mixed, belotti2009branching}. In practice, Algorithm~\ref{alg:ACCPM} is easy to implement since solving nonconvex MIQPs to global optimality can be done in off-the-shell solvers such as Gurobi v9.0~\cite{gurobi}. Interested readers are referred to~\cite{chen2021learning} for more discussions on the complexity and solvability of MIQPs. Next, we show how to formulate problem~\eqref{eq:verifier_formulation} as an MIQP by exploiting the mixed-integer linear formulation of ReLU networks.

The formulation of the MIQP is based on the fact that the feedforward ReLU network $f_{NN}(x)$ can be described by a set of mixed-integer linear (MIL) constraints. For the $(\ell+1)$-th activation layer in the ReLU network described in \eqref{eq:network}, let $\underline{m}^{\ell}$ and $\bar{m}^{\ell}$ be the element-wise lower and upper bounds on the input, i.e., $\underline{m}_{\ell} \leq W_{\ell} z_{\ell} +b_{\ell}\leq \bar{m}_{\ell}$. Then the ReLU activation function is equivalent to the following set of mixed-integer linear constraints~\cite{tjeng2017evaluating}:
\begin{equation}
\begin{aligned} \label{eq:MIL_NN}
& z_{\ell+1} = \max(W_\ell z_\ell + b_\ell,0) \iff \\
& \begin{cases}
z_{\ell+1} \geq W_\ell z_\ell + b_\ell \\
z_{\ell+1} \leq W_\ell z_\ell + b_\ell - \mathrm{diag}(\underline{m}_\ell) (\mathbf{1}-t_\ell) \\
z_{\ell+1} \geq 0 \\
z_{\ell+1} \leq \mathrm{diag}(\bar{m}_\ell)  t_\ell,
\end{cases}
\end{aligned}
\end{equation}
where $t_{\ell} \in \{0,1\}^{n_{\ell+1}}$ is a vector of binary variables for the $(\ell+1)$-th activation layer. Since the input to the ReLU network is bounded in our considered problem, various methods are available to find the element-wise pre-activation bounds $\{\underline{m}_{\ell} , \bar{m}_{\ell}\}$ such as interval bound propagation~\cite{cheng2017maximum} and linear programming~\cite{wong2018provable}. By assembling the mixed-integer linear constraints~\eqref{eq:MIL_NN} for each layer, we obtain the mixed-integer linear representation of the ReLU network and also the nominal dynamics $x_+ = \hat{f}(x)$ in~\eqref{eq:uncertain_dyn}. Consequently, the composition $\hat{f}^{(i)}(x)$ for $i = 1, \cdots, k$ can be described by mixed-integer linear constraints as well.

With the given Lyapunov function candidate $V_k(x;P_{ac})$, problem~\eqref{eq:verifier_formulation} can be rewritten as
\begin{subequations}
	\label{eq:MIQP}
	\begin{align}
	\begin{split} \label{eq:MIQP_obj}
	\underset{x, y, w}{\text{maximize}} & \quad z_k^\top(y) P_{ac} z_k^\top(y) - z_k^\top(x) P_{ac} z_k^\top(x)
	\end{split} \\
	\begin{split} \label{eq:MIQP_dynanmics}
	\text{subject to} & \quad y = Ax + f_{NN}(x) + w
	\end{split}\\
	\begin{split} \label{eq:MIQP_w_set}
	& \quad \lVert w \rVert_\infty \leq \gamma \lVert x \rVert_\infty + \delta
	\end{split}\\
	\begin{split} \label{eq:MIQP_ROI}
	& \quad x \in \mathcal{X} \setminus B_r
	\end{split}
	\end{align}
\end{subequations}
where the MIL representation of constraint~\eqref{eq:MIQP_dynanmics} and basis $z_k(x), z_k(y)$ follows from that of the ReLU network, and the MIL representation of constraints~\eqref{eq:MIQP_w_set} and~\eqref{eq:MIQP_ROI} follow from that of the $\ell_\infty$ norm. Since the objective function~\eqref{eq:MIQP_obj} is quadratic and indefinite, problem~\eqref{eq:MIQP} is a nonconvex MIQP which can be solved by Gurobi to global optimality.

\subsection{Termination guarantee}
Algorithm~\ref{alg:ACCPM} is guaranteed to find a Lyapunov function in the target set under the following assumption:
\begin{assume} \label{assump:nonempty}
	The target set $\mathcal{F}$ defined in~\eqref{eq:target_set} is full-dimensional, i.e., there exists $P_c\in \mathbb{S}^{(k+1)n_x}$ and $\epsilon > 0$ such that $\{P \in \mathbb{S}^{(k+1)n_x} \vert \lVert P - P_c \rVert_F \leq \epsilon \} \subset \mathcal{F}$ where $\lVert \cdot \rVert_F$ is the Frobenius norm.
\end{assume}

\begin{theorem}
	\label{thm:termination}
	Under Assumption~\ref{assump:nonempty}, Algorithm~\ref{alg:ACCPM} finds a Lyapunov function in the target set $\mathcal{F}$ in at most $O(((k+1)n_x)^3/\epsilon^2)$ iterations.
\end{theorem}

Theorem~\ref{thm:termination} states that when the target set is full-dimensional, Algorithm~\ref{alg:ACCPM} is guaranteed to find a Lyapunov function in a finite number of steps. Such a guarantee follows from the termination guarantee of the analytic center cutting-plane method considered in~\cite{sun2002analytic} and this is the main reason we require the learner to propose the analytic center of the localization sets as Lyapunov function candidates. From an optimization point of view, the sampling-based method described in Algorithm~\ref{alg:ACCPM} is equivalent to finding a feasible solution in the target set through the analytic center cutting-plane method with the verifier serving as the cutting-plane oracle. The proof of Theorem~\ref{thm:termination} follows from that of \cite[Theorem 2]{chen2021learning} since our extension of the Lyapunov function synthesis method in~\cite{chen2021learning} to the uncertain dynamical system~\eqref{eq:uncertain_dyn} does not change the convexity  of the target set.

\begin{remark}
	When the target set is empty, we do not have a finite-step termination guarantee for the proposed algorithm. Therefore, Algorithm~\ref{alg:ACCPM} is semi-complete and in practice, we can add additional stopping criteria, e.g., maximum number of iterations, to Algorithm~\ref{alg:ACCPM}.
\end{remark}

To summarize, the sampling-based Lyapunov function synthesis method in~\cite{chen2021learning} looks for Lyapunov functions simply based on the mixed-integer representation of hybrid systems. This makes it suitable to verify the stability of neural network dynamical systems since modeling the behavior of ReLU network over a compact set through MIL constraints is straightforward. In this paper we extend this method to handle uncertain dynamical systems and apply it in a novel setting to estimate the ROA of nonlinear dynamical systems through their neural network approximations. The non-conservativeness and the finite-step termination guarantee provided by Theorem~\ref{thm:Lyap} makes this method favorable to analyze uncertain dynamical systems. However, this is obtained at the cost of the worst-case exponential complexity of the MIQP~\eqref{eq:MIQP}.