Invertibility of adjacency matrices for random $d$-regular graphs

Abstract: Let $d\geq 3$ be a fixed integer and $A$ be the adjacency matrix of a random $d$-regular directed or undirected graph on $n$ vertices. We show there exist constants $\mathfrak d>0$, \begin{align*} {\mathbb P}(\text{$A$ is singular in $\mathbb R$})\leq n^{-\mathfrak{d}}, \end{align*} for $n$ sufficiently large. This answers an open problem by Frieze [12] and Vu [28,19]. The key idea is to study the singularity probability of adjacency matrices over a finite field ${\mathbb F}_p$. The proof combines a local central limit theorem and a large deviation estimate.

\section{Introduction}
The most famous combinatorial problem concerning random matrices is perhaps the ``singularity'' problem. In a standard setting, when the entries of the $n\times n$ matrix are i.i.d. Bernoulli random variables (taking values $\pm1$ with probability $1/2$), this problem was first done by Koml{\'o}s \cite{MR0221962,MR0238371}, where he showed the probability of being singular is $\OO(n^{-1/2})$.  This bound was significantly improved by
Kahn, Koml{\'o}s and Szemer{\'e}di \cite{MR1260107} to an exponential bound
\begin{align*}
\mathbb{P}(\text{random Bernoulli matrix is singular})< c^n,
\end{align*}
for $c=0.999$, for $c=3/4+\oo(1)$ by Tao and Vu \cite{MR2291914}, and by Rudelson and Vershynin \cite{MR2407948} . The often conjectured optimal value of
$c$ is $1/2 + \oo(1)$, and the best known value $c=1/\sqrt{2} + \oo(1)$ is due to Bourgain, Vu and Wood  \cite{MR2557947}.
Analogous results on singularity of symmetric Bernoulli matrices
were obtained in \cite{MR3158627, MR2891529,MR2267289}.

The above question can be reformulated for the
adjacency matrices of random graphs, either directed
or undirected. Both directed and undirected graphs are abundant in real life. One of the widely studied model in the undirected random graph literature is the Erd{\H o}s-R{\'e}nyi
graph $G(n,p)$. It was shown by Costello and Vu in \cite{MR2446482}, that the adjacency matrix of $G(n,p)$ is nonsingular with high probability whenever the edge connectivity probability $p$ is above the connectivity threshold $\ln n/n$. For directed  Erd{\H o}s-R{\'e}nyi
graph, a quantitative estimate on the smallest singular value was obtained by Basak and Rudelson in \cite{MR3620692, BR}.

Another intensively studied random graph model is the random $d$-regular graph. For the adjacency matrix of random $d$-regular graphs, its entries are no longer independent. The lack of independence poses significant difficulty for the singularity problem of random $d$-regular graphs. For undirected random $d$-regular graphs, when $d\geq n^{c}$ with any $c>0$, it follows from the bulk universality result \cite{fix2} by Landon, Sosoe and Yau, the adjacency matrix is nonsingular with high probability. For random $d$-regular directed graphs, it was first proven by Cook in \cite{MR3602844}, the adjacency matrix is nonsingular with high probability when $C\ln^2 n\leq d\leq n-C\ln^2 n$. Later in \cite{MR3545253}, it was proven by Litvak, Lytova, Tikhomirov, Tomczak-Jaegermann and Youssef that, when $C\leq d\leq n/(C\ln^2 n)$, the singularity probability is bounded by $\OO(\ln^3 d/\sqrt{d})$. Quantitative estimates on the smallest singular values were derived in \cite{Nik1, basak2018, Alex1}.

For random $d$-regular graphs, the most challenging case is when $d$ is a constant. It was posted as an open problem first appeared in \cite[Conjecture 8.4]{MR2432537} by Vu, and later collected in \cite[Section 9, Problem 7]{MR3728474} by Frieze  and \cite[Conjecture 5.8]{MR3727622} by Vu.
In \cite{Alex2}, it was proven by Litvak, Lytova, Tikhomirov, Tomczak-Jaegermann and Youssef that the adjacency matrix of random $d$-regular directed graphs has rank at least $n-1$ with high probability. In this paper we prove that the adjacency matrix of random $d$-regular directed and undirected graphs is nonsingular with high probability.

One  approach to estimate the singularity probability of random matrices is to decompose the null vectors $\mathbb S^{n-1}$ into subsets according to different structural properties, e.g., combinatorial dimension \cite{MR1260107,MR2291914}, compressible and imcompressible vectors \cite{MR2407948, Nik1,MR3602844,basak2018,MR2569075}, and statistics of jumps \cite{MR3620692, BR,MR3545253,Alex1,Alex3}.  Different from previous works, which directly study the singularity probability over ${\mathbb R}$, the key new idea in this paper is to study the singularity probability of adjacency matrices over a finite field ${\mathbb F}_p$. At first glance, this may seem wasteful, as we discard a great amount of information. Moreover, as a matrix over ${\mathbb F}_p$, the determinant of the adjacency matrix takes value in ${\mathbb F}_p$. One expects that the determinant takes value zero with probability about $1/p$. In other words, the adjacency matrix over ${\mathbb F}_p$ may be singular with positive probability. However, the benefit is that, over finite field ${\mathbb F}_p$ we can better understand the arithmetic structure of the null vectors, which enables us to obtain a sharp estimate of the singularity probability. We decompose the null vectors ${\mathbb F}_p^n$ into two classes, the equidistributed class where each number has approximately the same density, and the non-equidistributed class. We estimate the number of adjacency matrices which have a null vector in the equidistributed class using a local central limit theorem, and the number of adjacency matrices which have a null vector in the non-equidistributed class using a large deviation estimate.  In \cite{FLMS}, Ferber, Luh, McKinley and  Samotij use a similar idea to prove resilience results for random Bernoulli matrices.

After the appearance of the current preprint, the asymptotic nonsingularity of adjacency
matrices of random $d$-regular directed graphs and random $d$-regular undirected graphs with even number of vertices are proven by M{\'e}sz{\'a}ros \cite{AM}, and by
Nguyen and Wood \cite{NW}. The work of M{\'e}sz{\'a}ros \cite{AM} studies the distribution of the sandpile group of random $d$-regular graphs, and determines the distribution of $p$-Sylow subgroup of the sandpile group. Based on \cite{AM}, Nguyen and Wood in \cite{NW}, study the distribution of the cokernels of adjacency matrices of random $d$-regular graphs, and observe that the convergence of such distributions implies asymptotic nonsingularity of the matrices. Our model is slightly more general, and we obtain quantitative estimates on the singularity probability.

\noindent\textbf{Acknowledgement.} I am thankful to Elchanan Mossel and Mustazee Rahman for suggesting the problem of studying adjacency matrices of random $d$-regular graphs over finite fields. I am also grateful to Weifeng Sun for enlightening discussions, and to Nicholas Cook, Van Vu and Melanie Wood for helpful comments on the first draft of this paper.

\subsection{Main results}

We study the configuration model of random $d$-regular directed and undirected graphs, introduced by Bollob{\'a}s in \cite{MR595929} (ideas similar to the configuration model were also presented in \cite{MR0505796,MR545196,MR527727}). By a contiguity argument, our main results also hold for other random $d$-regular directed and undirected graph models, e.g. the uniform model, the sum of $d$ random permutations and the sum of $d$ random perfect matching matrices.

For the configuration model, one generates a random $d$-regular directed graph by the following procedure:
\begin{enumerate}
\item Associate to each vertex $k \in \{1,2,\cdots,n\}$ a fiber $F_k$ of $d$ points, so that there are
$
\left| \cup_{k\in \{1,2,\cdots,n\}}F_k\right|=nd
$
points in total.
\item Select a permutation ${\cal P}$ of the $nd$ points uniformly at random.
\item For any vertex $k \in \{1,2,\cdots,n\}$, and point $k'\in F_k$, we add a directed edge from vertex $k$ to vertex $\ell$ if the point ${\cal P}(k')$ belongs to fiber $F_{\ell}$.
\end{enumerate}
We denote the $d$-regular directed graphs obtained from the above procedure by $\mathsf{M}_{n,d}$, which is a multiset. It is easy to see from the construction procedure that $|\mathsf{M}_{n,d}|=(nd)!$. Let ${\cal G}\in \mathsf{M}_{n,d}$, one may identify ${\cal G}$ with a random $d$-regular bipartite graph on $n + n$ vertices in the obvious way. We denote $A$ = $A({\cal G})$ the adjacency matrix of ${\cal G}$, i.e. $A_{k\ell}$ is the number of directed edges from vertex $k$ to vertex $\ell$.

For the configuration model, one generates a random $d$-regular undirected graph on $n$ vertices with $2|dn$, by the following procedure:
\begin{enumerate}
\item Associate to each vertex $k \in \{1,2,\cdots,n\}$ a fiber $F_k$ of $d$ points, so that there are
$
\left| \cup_{k\in \{1,2,\cdots,n\}}F_k\right|=nd
$
points in total.
\item Select a pairing ${\cal P}$ of the $nd$ points uniformly at random, and add an edge from point $k'$ to point $\ell'$ if $\{k',\ell'\}\in{\cal P}$.
\item Collapse each fiber $F_k$ to the associated vertex $k$.
\end{enumerate}
We denote the $d$-regular undirected graphs obtained from the above procedure by $\mathsf{G}_{n,d}$, which is a multiset. It is easy to see from the construction procedure that $|\mathsf{G}_{n,d}|=2^{-nd/2}(nd)!/(nd/2)!$. Let ${\cal G}\in \mathsf{G}_{n,d}$, we denote $A$ = $A({\cal G})$ the adjacency matrix of ${\cal G}$, i.e. $A_{k\ell}$ is the number of edges between vertex $k$ and vertex $\ell$.

\begin{theorem}\label{thm:smcount}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$. Then over ${\mathbb F}_p$,
we have for $p\ll n^{\min\{1/4, (d-2)/2d\}}$
\begin{align}\label{e:smcountd}
\sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|= (1+\oo(1))|\mathsf{M}_{n,d}|,
\end{align}
and for $p\ll n^{\min\{1/8, (d-2)/(5d-6)\}}$
\begin{align}\label{e:smcountu}
\sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|= (1+\bm1(p=2)+\oo(1))|\mathsf{G}_{n,d}|,
\end{align}
for $n$ sufficiently large.
\end{theorem}

If an adjacency matrix $A({\cal G})$ is singular as a matrix in ${\mathbb F}_p$, then we have
\begin{align*}
|\{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}: A({\cal G}){\bm{v}}=\bm0 \}|\geq p-1.
\end{align*}
Therefore it follows from Theorem \ref{thm:smcount},
\begin{align*}
&(p-1)|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}) \text{ is singular in } {\mathbb F}_p\}|
\leq \sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|
= (1+\oo(1))|\mathsf{M}_{n,d}|,\\
&(p-1)|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}) \text{ is singular in } {\mathbb F}_p\}|
\leq \sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|
= (1+\oo(1))|\mathsf{G}_{n,d}|,
\end{align*}
and we obtain the next theorem.

\begin{theorem}\label{thm:spFp}
Let $d\geq 3$ be a fixed integer, and an odd prime number $p$ such that $\gcd(p,d)=1$. Let $A$ be the adjacency matrix of a random $d$-regular  graph on $n$ vertices. Then as a random matrix in ${\mathbb F}_p$,
\begin{align*}
\mathbb{P}(\text{$A$ is singular in ${\mathbb F}_p$})\leq \frac{1+\oo(1)}{p-1},
\end{align*}
for $n$ sufficiently large.
\end{theorem}

The entries of $A({\cal G})$ are all integers. Therefore, if $A({\cal G})$ is singular in ${\mathbb R}$, it is also singular in any finite field ${\mathbb F}_p$. The next theorem follows  by taking $p$ large in Theorem \ref{thm:spFp}.

\begin{theorem}\label{thm:spR}
Let $d\geq 3$ be a fixed integer. Let $A$ be the adjacency matrix of a random $d$-regular directed or undirected graph on $n$ vertices. Then there exist constants ${\mathfrak d}>0$,
\begin{align*}
\mathbb{P}(\text{$A$ is singular in ${\mathbb R}$})\leq n^{-{\mathfrak d}},
\end{align*}
for $n$ sufficiently large.
\end{theorem}

\begin{remark}
For random $d$-regular directed graphs we can take ${\mathfrak d}=\min\{1/4, (d-2)/2d\}$, and for random $d$-regular undirected graphs we can take ${\mathfrak d}=\min\{1/8, (d-2)/(5d-6)\}$.The probability that the adjacency matrix of a random $d$-regular graph is singular is at least polynomial in $1/n$. In fact, if a $d$-regular graph contains the subgraph in Figure \ref{f:K2d},
\begin{figure}
\center
\includegraphics[width=0.6\textwidth]{k2d2.png}
\caption{If a $d$-regular directed or undirected graph contains the above subgraph, its adjacency matrix is singular.}
\label{f:K2d}
\end{figure}
then its adjacency matrix is singular. As a consequence, it holds that $\mathbb{P}(\text{$A$ is singular in ${\mathbb R}$})\geq \OO(1)/n^{d-2}$.
\end{remark}

\begin{remark}
Theorem \ref{thm:spR} for random $d$-regular graphs with even number of vertices was recently proven by M{\'e}sz{\'a}ros \cite{AM}, and by
Nguyen and Wood \cite{NW}. Their approach studies the distribution of the sandpile group of random $d$-regular graphs.
Although the result in Theorem \ref{thm:spR} is stated for the configuration model, the same statement holds for other models, e.g. the uniform model, the sum of $d$ random permutations and the sum of $d$ random perfect matching matrices,  by a contiguity argument.
\end{remark}

\section{Random Walk Interpretation}
In this section, we enumerate $|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0 \text{ in } {\mathbb F}_p\}|$ and  $|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0 \text{ in } {\mathbb F}_p\}|$ as the number of certain walk paths. Before stating the result, we need to introduce some notations. We define the counting function $\Phi:\cup_{k\geq 1}{\mathbb F}_p^k\mapsto \mathbb{Z}^p$, given by
\begin{align*}
\Phi(a_1,a_2,\cdots, a_k)=\left(\sum_{i=1}^k \bm 1(a_i=0),\sum_{i=1}^k \bm 1(a_i=1), \cdots,\sum_{i=1}^k \bm 1(a_i=p-1)\right).
\end{align*}
We decompose the space ${\mathbb F}_p^n$ as
\begin{align*}
{\mathbb F}_p^n=\bigcup_{n_0,n_1,\cdots, n_{p-1}\in \mathbb{Z}_{\geq0}\atop n_0+n_1+\cdots+n_{p-1}=n}{\mathcal S}(n_0,n_1,\cdots, n_{p-1}),
\end{align*}
where
\begin{align*}
{\mathcal S}(n_0,n_1,\cdots, n_{p-1})=\{{\bm{v}}=(v_1,v_2,\cdots, v_n)\in {\mathbb F}_p^n: \Phi({\bm{v}})=(n_0,n_1,\cdots,n_{p-1})\}.
\end{align*}
The cardinality of ${\mathcal S}(n_0,n_1,\cdots, n_{p-1})$ is
\begin{align*}
\left|{\mathcal S}(n_0,n_1,\cdots, n_{p-1})\right|={n\choose n_0,n_1,\cdots,n_{p-1}}.
\end{align*}
We define the multiset ${\mathcal U}_{d,p}$
\begin{align}\begin{split}\label{e:defcU}
{\mathcal U}_{d,p}&=\{\Phi({\bm{a}}): {\bm{a}}=(a_1,a_2,\cdots,a_d)\in {\mathbb F}_p^d, a_1+a_2+\cdots+a_d=0\}.
\end{split}\end{align}
For any $a_1,a_2,\cdots, a_{d-1}\in {\mathbb F}_p$, there exists a unique $a_d\in{\mathbb F}_p$ such that $a_1+a_2+\cdots+a_d=0$. The multiset ${\mathcal U}_{d,p}$ has cardinality $p^{d-1}$, i.e. $|{\mathcal U}_{d,p}|=p^{d-1}$.
We denote ${\cal M}(n_0,n_1,\cdots, n_{p-1})$ the set of $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}$, such that
\begin{enumerate}
\item $m_{ij}=m_{ji}\in \mathbb{Z}_{\geq 0}$ for $0\leq i,j\leq p-1$ and $2|m_{ii}$ for $0\leq i\leq p-1$.
\item $\sum_{j=0}^{p-1}m_{ij}=dn_i$ for $0\leq i\leq p-1$.
\item  $\sum_{j=0}^{p-1}jm_{ij}\equiv 0 \Mod p$ for $0\leq i\leq p-1$.
\end{enumerate}
We denote
\begin{align*}
{\cal M}=\bigcup_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}{\cal M}(n_0, n_1, \cdots, n_{p-1}).
\end{align*}

\begin{proposition}\label{p:walkrepd}
Let $d\geq 3$ be a fixed integer, and $p$ a prime number. Fix ${\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})$, we have
\begin{align}\begin{split}\label{e:randomwalkd}
&\phantom{{}={}}|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0 \text{ in } {\mathbb F}_p\}|\\
&=\left(\prod_{j=0}^{p-1} (dn_j)!\right)|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_n)\in {\mathcal U}_{d,p}^n: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_n=(dn_0, dn_{1},\cdots, dn_{p-1})\}|\\
&=\left(\prod_{j=0}^{p-1} (dn_j)!\right)p^{n(d-1)}\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1})),
\end{split}\end{align}
where $X_1,X_2,\cdots, X_n$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$.
\end{proposition}

\begin{proposition}\label{p:walkrepu}
Let $d\geq 3$ be a fixed integer, and $p$ a prime number. Fix ${\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})$, we have
\begin{align}\begin{split}\label{e:randomwalku}
&\phantom{{}={}}|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0 \text{ in } {\mathbb F}_p\}|\\
&=\sum_{M\in {\cal M}(n_0, n_1,\cdots, n_{p-1})}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
&\times\prod_{i=0}^{p-1}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_i})\in {\mathcal U}_{d,p}^{n_i}: {\bm{u}}_1+{\bm{u}}_2+\cdots{\bm{u}}_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}) \}|\\
&=\sum_{M\in {\cal M}(n_0, n_1,\cdots, n_{p-1})}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}p^{n(d-1)}\\
&\times\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0}, m_{i1},\cdots, m_{ip-1})),
\end{split}\end{align}
where $X_1,X_2,\cdots, X_{n_i}$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$.
\end{proposition}

\begin{proof}[Proof of Proposition \ref{p:walkrepd}]
We recall the configuration model for random $d$-regular directed graphs from the introduction that each vertex $k \in \{1,2,\cdots,n\}$ is associated with a fiber $F_k$ of $d$ points.  For each permutation ${\cal P}$ of the $nd$ points, we associate it a map $f_{{\cal P}}: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ in the following way. For any point $k'$, if ${\cal P}(k')=\ell'$ and $\ell'\in F_\ell$, then $f_{{\cal P}}(k')=v_\ell$. A given map $f: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ is from a permutation if
\begin{align}\label{e:permcond}
\sum_{k\in \{1,2,\cdots, n\}}\sum_{k'\in F_k}\bm1(f(k')=j)=dn_j, \quad i=0,1,\cdots, p-1.
\end{align}
If this is the case, the number of permutation ${\cal P}$ such that $f_{{\cal P}}=f$ is given by
\begin{align}\label{e:numpaird}
\prod_{j=0}^{p-1}(dn_j)!.
\end{align}
Let ${\cal G}\in \mathsf{M}_{n,d}$ corresponding to a permutation ${\cal P}$. $A({\cal G}){\bm{v}}=\bm 0$ in ${\mathbb F}_p$ if and only if for any $k\in \{1,2,\cdots, n\}$
\begin{align}\label{e:sum0d}
\sum_{k'\in F_k}f(k')=0.
\end{align}
Especially, $\Phi(f(k'):k'\in F_k) \in {\mathcal U}_{d,p}$ for any $k\in \{1,2,\cdots, n\}$. The number of maps $f: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ satisfying \eqref{e:permcond} and \eqref{e:sum0d} is given by
\begin{align}\label{e:nummapd}
|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_n)\in {\mathcal U}_{d,p}^n: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_n=(dn_0, dn_{1},\cdots, dn_{p-1})\}|.
\end{align}
The claim \eqref{e:randomwalkd} follows from \eqref{e:numpaird} and \eqref{e:nummapd}.
\end{proof}

\begin{proof}[Proof of Proposition \ref{p:walkrepu}]
We recall the configuration model for random $d$-regular undirected graphs  from the introduction that each vertex $k \in \{1,2,\cdots,n\}$ is associated with a fiber $F_k$ of $d$ points.  For each pairing ${\cal P}$ of the $nd$ points, we associate it a map $f_{{\cal P}}: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ in the following way. For any point $k'$, if $\{k',\ell'\}\in {\cal P}$ and $\ell'\in F_\ell$, then $f_{{\cal P}}(k')=v_\ell$. Given a map $f: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$, we denote its data matrix as
\begin{align*}
M_f=[m_{ij}]_{0\leq i,j\leq p-1}, \quad m_{ij}=\sum_{k\in \{1,2,\cdots, n\}}\sum_{k'\in F_k}\bm1(v_k=i)\bm1(f(k')=j).
\end{align*}
The map $f: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ is from a pairing ${\cal P}$ if for any $\{k', \ell'\}\in {\cal P}$ with $k'\in F_k$ and $\ell'\in F_\ell$, it holds $f(k')=v_{\ell}$ and $f(\ell')=v_k$. This is possible, if and only if its data matrix $M_f=[m_{ij}]_{0\leq i,j\leq p-1}$ satisfies
\begin{enumerate}
\item $m_{ij}=m_{ji}\in \mathbb{Z}_{\geq 0}$ for $0\leq i,j\leq p-1$ and $2|m_{ii}$ for $0\leq i\leq p-1$.
\item $\sum_{j=0}^{p-1}m_{ij}=dn_i$ for $0\leq i\leq p-1$.
\end{enumerate}
If this is the case, the number of pairings ${\cal P}$ such that $f_{{\cal P}}=f$ is given by
\begin{align}\label{e:numpair}
\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}.
\end{align}
Let ${\cal G}\in \mathsf{G}_{n,d}$ corresponding to a pairing ${\cal P}$. $A({\cal G}){\bm{v}}=\bm 0$ in ${\mathbb F}_p$ if and only if for any $k\in \{1,2,\cdots, n\}$
\begin{align}\label{e:sum0}
\sum_{k'\in F_k}f(k')=0.
\end{align}
Especially, $\Phi(f(k'):k'\in F_k) \in {\mathcal U}_{d,p}$ for any $k\in \{1,2,\cdots, n\}$. If this is the case, we have
\begin{align*}
0=\sum_{k\in \{1,2,\cdots, n\}}\bm1(v_k=i)\sum_{k'\in F_k}f(k')\equiv \sum_{j=0}^{p-1}jm_{ij} \Mod p,
\end{align*}
and thus the data matrix $M_f\in {\cal M}(n_0,n_1,\cdots, n_{p-1})$. Given a data matrix $M\in {\cal M}(n_0,n_1,\cdots, n_{p-1})$, the number of maps $f: \cup_{k\in \{1,2,\cdots, n\}}F_k\mapsto {\mathbb F}_p$ with data matrix $M$ satisfying \eqref{e:sum0} is given by
\begin{align}\label{e:nummap}
\prod_{i=0}^{p-1}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_i})\in {\mathcal U}_{d,p}^{n_i}: {\bm{u}}_1+{\bm{u}}_2+\cdots{\bm{u}}_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}) \}|.
\end{align}
The claim \eqref{e:randomwalku} follows from \eqref{e:numpair} and \eqref{e:nummap}.
\end{proof}

Let $X$ be a random vector uniform distributed over ${\mathcal U}_{d,p}$. The mean of $X$ is given by
\begin{align}\label{e:mean}
\mathbb{E}[X(j)]
=\frac{1}{p^{d-1}}\sum_{(a_1,a_2,\cdots,a_d)\in {\mathbb F}_p^d\atop a_1+a_2+\cdots+a_d=0}\sum_{k=1}^d\bm1(a_k=j)=\frac{d}{p},\quad j=0,1,\cdots,p-1.
\end{align}
The covariance of $X$ is given by
\begin{align}\begin{split}\label{e:cov}
&\phantom{{}={}}\mathbb{E}[(X(j)-d/p)(X(j')-d/p)]
=\frac{1}{p^{d-1}}\sum_{(a_1,a_2,\cdots,a_d)\in {\mathbb F}_p^d\atop a_1+a_2+\cdots+a_d=0}\sum_{1\leq k,k'\leq d}\bm1(a_k=j)\bm1(a_{k'}=j')-\frac{d^2}{p^2}\\
&=\frac{1}{p^{d-1}}\sum_{(a_1,a_2,\cdots,a_d)\in {\mathbb F}_p^d\atop a_1+a_2+\cdots+a_d=0}\left(\delta_{jj'}\sum_{1\leq k\leq d}\bm1(a_k=j)+\sum_{1\leq k\neq k'\leq d}\bm1(a_k=j)\bm1(a_{k'}=j')\right)-\frac{d^2}{p^2}=\frac{d}{p}\delta_{jj'}-\frac{d}{p^2},
\end{split}\end{align}
for any $j,j'=0,1,\cdots,p-1$.
We summarize \eqref{e:mean} and \eqref{e:cov} as
\begin{align}\label{e:meanandcov}
{\bm \mu}\deq \mathbb{E}[X]=(d/p,d/p,\cdots,d/p),\quad \Sigma\deq\mathbb{E}[(X-{\bm \mu})(X-{\bm \mu})^t]=\frac{d}{p}I_p-\frac{d}{p^2}\bm1\bm1^t.
\end{align}
We denote the characteristic function of $X$ as
\begin{align*}
\phi_{X}(\bmt)=\mathbb{E}[\exp\{\mathrm{i}\langle\bmt, X\rangle\}],\quad \phi_{X-{\bm \mu}}(\bmt)=\mathbb{E}[\exp\{\mathrm{i}\langle\bmt, X-{\bm \mu}\rangle\}]=e^{-\mathrm{i} \langle \bmt,{\bm \mu}\rangle}\phi_{X}(\bmt).
\end{align*}
The lattice spanned by vectors in ${\mathcal U}_{d,p}$ is the dual lattice of $\mathrm{span} \{(0,1/p, 2/p,\cdots, p-1/p), {\bm{e}}_1,{\bm{e}}_2,\cdots, {\bm{e}}_{p}\}$
in $\{(x_1, x_2,\cdots, x_p)\in {\mathbb R}^p: x_1+x_2+\cdots+x_p=d\}$, where ${\bm{e}}_1,{\bm{e}}_2,\cdots, {\bm{e}}_{p}$ is the standard base of ${\mathbb R}^p$. Therefore $|\phi_{X-{\bm \mu}}^n(\bmt)|=1$ if any only if
\begin{align}\label{e:line}
\bmt\in2\pi(0,1/p,2/p,\cdots, p-1/p)\mathbb{Z}+(1,1,\cdots,1){\mathbb R}.
\end{align}
The following proposition gives a quantitative estimate of the absolute value of the characteristic function $|\phi_{X-\mu}(\bmt)|$ when $\bmt$ is away from these lines \eqref{e:line}.
Fix small $\delta>0$. For $j=0,1,2,\cdots,p-1$, we define domains
\begin{align}\label{e:domainB}
B_j(\delta)=2\pi j(0,1/p,2/p,\cdots, (p-1)/p)+Q (\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|_2^2\leq \delta\}\times [0,2\sqrt{p}\pi]),
\end{align}
where $Q$ is an orthogonal transform, given by the $p\times p$ orthogonal matrix  $Q=[O, \bm1/\sqrt{p}]$, and $Q (\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|_2^2\leq \delta\}\times [0,2\sqrt{p}\pi])$ is the image of $\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|_2^2\leq \delta\}\times [0,2\sqrt{p}\pi]$ under the orthogonal transform $Q$.
\begin{proposition}\label{p:cfbound}
For any $\delta>0$ small enough, and $\bmt\in (2\pi {\mathbb R}^p/\mathbb{Z}^p)\setminus \cup_{j=0}^{p-1}B_j(\delta)$, there exists a constant $c(\delta)>0$,
\begin{align}\label{e:cfbound}
|\phi_{X-{\bm \mu}}(\bmt)|\leq 1-c(\delta)/p^3.
\end{align}
\end{proposition}
\begin{proof}
We prove \eqref{e:cfbound} by contradiction: if for some $\bmt$,
\begin{align}\label{e:cfbound2}
\left|\frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}e^{\mathrm{i} \langle \bmt, {\bm{w}}_j\rangle}\right|\geq 1-c(\delta)/p^3,
\end{align}
then $\bmt\in \cup_{j=0}^{p-1}B_j(\delta)$.
Without loss of generality, we can assume (by shifting $\bmt$) that $t_0=0$ and $|t_1|\leq 1/2p$. We denote $\psi=\arg \phi_X(\bmt)$. There exists a subset ${\mathcal U}'\in {\mathcal U}_{d,p}$, with $|{\mathcal U}'|\leq p^{d-2}/(2d)$, such that for any ${\bm{w}} \in {\mathcal U}_{d,p}\setminus {\mathcal U}'$, it holds
\begin{align}\label{e:smalldev}
\langle \bmt, {\bm{w}}\rangle=2\pi n_{\bm{w}}+\psi+\varepsilon_{\bm{w}}, \quad |\varepsilon_{\bm{w}}|\leq \frac{\varepsilon}{p},
\end{align}
where $1-\cos(\varepsilon/p)=2dc(\delta)/p^2$. Otherwise, we have
\begin{align*}
\left|\frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}e^{\mathrm{i} \langle \bmt, {\bm{w}}_j\rangle}\right|
&=\Re \frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}e^{\mathrm{i} \langle \bmt, {\bm{w}}_j\rangle-\mathrm{i}\psi}\\
&< \frac{1}{p^{d-1}}\left(|{\mathcal U}_{d,p}\setminus {\mathcal U}'|+\sum_{{\bm{w}}\in {\mathcal U}'} \cos(\varepsilon/p)\right)
=1-\frac{c(\delta)}{p^3},
\end{align*}
which contradicts with \eqref{e:cfbound2}. We show next that \eqref{e:smalldev} holds for all ${\bm{w}}\in {\mathcal U}_{d,p}$ with slightly worse error. We consider $d\times d$ arrays in ${\mathbb F}_p$ such that the sum of each row and column is zero (zero sum $d\times d$ arrays). Fix any ${\bm{a}}^1=(a^1_1,a^1_2,\cdots, a^1_d)\in {\mathbb F}_p^d$ with $a^1_1+a^1_2+\cdots+a^1_d=0$. The total number of zero sum $d\times d$ arrays with the first row given by ${\bm{a}}^1$ is $p^{(d-1)(d-2)}$. For any ${\bm{b}}=(b_1,b_2,\cdots, b_d)\in {\mathbb F}_p^d$ with $b_1+b_2+\cdots+b_d=0$ and ${\bm{b}}\neq {\bm{a}}^1$, the total number of zero sum $d\times d$ arrays with the first row given by ${\bm{a}}^1$ and one row or column given by ${\bm{b}}$ is at most $(d-1)p^{(d-1)(d-3)}+dp^{(d-2)(d-2)}$. Since $p^{(d-1)(d-2)}> ((d-1)p^{(d-1)(d-3)}+dp^{(d-2)(d-2)})|{\mathcal U}'|$, there exists a zero sum $d\times d$ arrays with rows given by ${\bm{a}}^1, {\bm{a}}^2,\cdots, {\bm{a}}^d$ and columns given by ${\bm{b}}^1, {\bm{b}}^2,\cdots,{\bm{b}}^d$ such that $\Phi({\bm{a}}^2), \Phi({\bm{a}}^3),\cdots, \Phi({\bm{a}}^d), \Phi({\bm{b}}^1), \Phi({\bm{b}}^2),\cdots, \Phi({\bm{b}}^d)\in {\mathcal U}_{b,p}\setminus {\mathcal U}'$. As a consequence, we have
\begin{align*}\begin{split}
\langle \bmt, \Phi({\bm{a}}^1)\rangle
&=
\sum_{i=1}^d\langle \bmt, \Phi({\bm{b}}^i)\rangle
-\sum_{i=2}^d\langle \bmt, \Phi({\bm{a}}^i)\rangle\\
&=2\pi \left(\sum_{i=1}^d n_{\Phi({\bm{b}}^i)}-\sum_{i=2}^d n_{\Phi({\bm{a}}^i)}\right)+\psi
+\left(\sum_{i=1}^d \varepsilon_{\Phi({\bm{b}}^i)}-\sum_{i=2}^d \varepsilon_{\Phi({\bm{a}}^i)}\right)\\
&\eqd2\pi n_{\Phi({\bm{a}}^1)}+\psi
+\varepsilon_{\Phi({\bm{a}}^1)},
\end{split}\end{align*}
where $|\varepsilon_{\Phi({\bm{a}}^1)}|\leq 2d\varepsilon/p$. Especially if we take ${\bm{a}}^1=(0,0,\cdots,0)$ then $\langle \bmt, \Phi({\bm{a}}^1)\rangle=0$, and we get $|\psi|\leq 2d\varepsilon/p$. We can absorb $\psi$ into the error term. Therefore, uniformly for all ${\bm{w}}\in {\mathcal U}_{d,p}$,
\begin{align}\label{e:twprod}
\langle \bmt, {\bm{w}}\rangle=2\pi n_{\bm{w}} +\varepsilon_{\bm{w}},\quad  |\varepsilon_{\bm{w}}|\leq \frac{4d\varepsilon}{p}.
\end{align}

We take two family of vectors ${\bm{u}}_k=(d-2){\bm{e}}_0+{\bm{e}}_k+{\bm{e}}_{p-k},{\bm{v}}_k=(d-3){\bm{e}}_0+{\bm{e}}_1+{\bm{e}}_{k-1}+{\bm{e}}_{p-k}\in {\mathcal U}_{d,p}$ for $k=2,3,\cdots, p-1$. By taking ${\bm{w}}={\bm{u}}_k, {\bm{v}}_k$ in \eqref{e:twprod}, we get
\begin{align*}
t_k=t_{k-1}+t_1+2\pi(n_{{\bm{v}}_k}-n_{{\bm{u}}_k})+(\varepsilon_{{\bm{v}}_k}-\varepsilon_{{\bm{u}}_k}), \quad k=2,3,\cdots,p-1,
\end{align*}
and therefore,
\begin{align}\label{e:diffbound}
t_k=kt_1+2\pi\sum_{j=2}^k (n_{{\bm{v}}_j}-n_{{\bm{u}}_j})+\sum_{j=2}^k(\varepsilon_{{\bm{v}}_j}-\varepsilon_{{\bm{u}}_j}).
\end{align}
We can shift each $t_k$ by $2\pi \mathbb{Z}$, and assume that
\begin{align*}
t_k=kt_1+\sum_{j=2}^k(\varepsilon_{{\bm{v}}_j}-\varepsilon_{{\bm{u}}_j}).
\end{align*}
Therefore, thanks to the bound \eqref{e:twprod}, we get $|t_k|\leq k/2p+8(k-1)d\varepsilon/p\leq1$ for all $1\leq k\leq p-1$, provided we take $\varepsilon$ small enough. Let $k_{\max}=\argmax_k t_k$ and $k_{\min}=\argmin_k t_k$. By taking ${\bm{w}}_1=(d-2){\bm{e}}_0+{\bm{e}}_{k_{\max}}+{\bm{e}}_{p-k_{\max}}$ and ${\bm{w}}_2=(d-3){\bm{e}}_0+{\bm{e}}_{k_{\min}}+{\bm{e}}_{k_{\max}-k_{\min}}+{\bm{e}}_{p-k_{\max}}$ in \eqref{e:twprod}, we get
\begin{align*}
3\geq |t_{k_{\max}}-t_{k_{\min}}-t_{k_{\max}-k_{\min}}|=|2\pi(n_{{\bm{w}}_2}-n_{{\bm{w}}_1})+(\varepsilon_{{\bm{w}}_2}-\varepsilon_{{\bm{w}}_1})|\geq 2\pi|n_{{\bm{w}}_2}-n_{{\bm{w}}_1}|-|\varepsilon_{{\bm{w}}_2}-\varepsilon_{{\bm{w}}_1}|.
\end{align*}
Therefore, $n_{{\bm{w}}_2}=n_{{\bm{w}}_1}$ and
\begin{align*}
|t_{k_{\min}}|\leq |t_{k_{\max}}-t_{k_{\min}}-t_{k_{\max}-k_{\min}}|=|\varepsilon_{{\bm{w}}_2}-\varepsilon_{{\bm{w}}_1}|\leq \frac{8d\varepsilon}{p}.
\end{align*}
By symmetry, we also have $|t_{k_{\max}}|\leq 8d\varepsilon/p$. It follows that $|t_0|,|t_1|,\cdots, |t_{p-1}|\leq \max\{|t_{k_{\max}}|, |t_{k_{\min}}|\}\leq 8d\varepsilon/p$. So $\bmt\in B_0(\delta)$ and the claim follows, provided we take $\varepsilon$ small enough.
\end{proof}

\section{Proof of Theorem \ref{thm:smcount} for Random Directed $d$-regular Graphs}
Thanks to Proposition \ref{p:walkrepd}, we can rewrite the lefthand side of \eqref{e:smcountd} as
\begin{align*}
\sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|
&=\sum_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\sum_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}{n\choose n_0,n_1,\cdots, n_{p-1}}\left(\prod_{j=0}^{p-1} (dn_j)!\right)\times\\
&\phantom{{}={}}\times p^{n(d-1)}\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1})).
\end{align*}
Therefore Theorem \ref{thm:smcount} is equivalent to the following estiamte
\begin{align}\begin{split}\label{e:keyestd}
&\sum_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}\times\\
&\times p^{n(d-1)}\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1}))=1+\oo(1).
\end{split}\end{align}

To prove \eqref{e:keyestd}, we fix a large number ${\mathfrak b}>0$, and decompose those $p$-tuples $(n_0,n_1,\cdots,n_{p-1})$ into two classes:
\begin{enumerate}
\item (Equidistributed) ${\cal E}$ is the set of $p$-tuples $(n_0,n_1,\cdots,n_{p-1})\in \mathbb{Z}_{\geq 0}^n$, such that $\sum_{j=0}^{p-1}(n_j/n-1/p)^2\leq {\mathfrak b} \ln n/n$.
\item (Non-equidistributed) ${\cal N}$ is the set of $p$-tuples $(n_0,n_1,\cdots,n_{p-1})\in \mathbb{Z}_{\geq 0}^n$, which are not $(n,0,0,\cdots, 0)$ or equidistributed.
\end{enumerate}
In Section \ref{subs:lcltd}, we estimate the sum of terms in \eqref{e:keyestd} corresponding to equidistributed $p$-tuples using a local central limit theorem. In Section \ref{subs:ldpd}, we show that the sum of terms in \eqref{e:keyestd} corresponding to non-equidistributed $p$-tuples is small, via a large deviation estimate. Theorem \ref{thm:smcount} for random directed $d$-regular graphs follows from combining Proposition \ref{p:lcltd} and Proposition \ref{p:ldpd}.

\subsection{Local central limit theorem estimate}
\label{subs:lcltd}

In this section, we estimate the sum of terms in \eqref{e:keyestd} corresponding to equidistributed $p$-tuples $(n_0,n_1,\cdots,n_{p-1})$, using a local central limit theorem.
\begin{proposition}\label{p:lcltd}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$ and $p\ll n^{1/4}$. Then for $n$ sufficiently large
\begin{align}\label{e:equd}
\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal E}}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{\sqrt{n}}\right)\right)|\mathsf{M}_{n,d}|.
\end{align}
\end{proposition}

\begin{proof}
Thanks to Proposition \ref{p:walkrepd}, we have
\begin{align}\begin{split}\label{e:explcltd}
&\phantom{{}={}}\frac{1}{|\mathsf{M}_{n,d}|}\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal E}}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal E}}{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}\\
&\phantom{{}={}}\times p^{n(d-1)}\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1})),
\end{split}\end{align}
where $X_1,X_2,\cdots, X_n$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$ as defined in \eqref{e:defcU}.
For an equidistributed $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$, we denote ${\mathfrak n}_j=n_j/n$ for $j=0,1,\cdots, p-1$. Then by our definition of ${\cal E}$, we have
$\sum_{j=0}^{p-1}({\mathfrak n}_j-1/p)^2\leq {\mathfrak b} \ln n/n$. We estimate the first factor on the righthand side of \eqref{e:explcltd} using Stirling's formula,
\begin{align}\begin{split}\label{e:firstfactord}
&\phantom{{}={}}{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}p^{(d-1)n}\\
&=\left(1+\OO\left(\frac{p^2}{n}\right)\right)d^{\frac{p-1}{2}}
\exp\left\{(d-1)n\left(\sum_{j=0}^{p-1}{\mathfrak n}_j\ln {\mathfrak n}_j +\ln p\right)\right\}\\
&=\left(1+\OO\left(\frac{p(\ln n)^{3/2}}{\sqrt{n}}\right)\right)d^{\frac{p-1}{2}}
\exp\left\{\frac{(d-1)pn}{2}\sum_{j=0}^{p-1}({\mathfrak n}_j-1/p)^2\right\}.
\end{split}\end{align}

In the following, we estimate $\mathbb{P}(S_n=(dn_0, dn_{1},\cdots, dn_{p-1}))$, where $S_n=X_1+X_2+\cdots+X_n$.
We recall that $X_1, X_2,\cdots, X_n$ are independent copies of $X$, which is uniformly distributed over the multiset ${\mathcal U}_{d,p}$.
For a $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$, if $\sum_{j=0}^{p-1}jn_j\not\equiv 0 \Mod p$, then $\mathbb{P}(S_n=(dn_0,dn_1,\cdots, dn_{p-1}))=0$. We only need to consider $p$-tuples $(n_0,n_1,\cdots,n_{p-1})$ such that $\sum_{j=0}^{p-1}jn_j\equiv 0 \Mod p$. We denote ${\bm{n}}=(n_0,n_1,\cdots, n_{p-1})$. By inverse Fourier formula
\begin{align*}\begin{split}
\mathbb{P}(S_n=d{\bm{n}})
&=\frac{1}{(2\pi)^p}\int_{2\pi {\mathbb R}^p/\mathbb{Z}^p}\phi_X^n(\bmt)e^{-\mathrm{i} \langle \bmt, d{\bm{n}}\rangle}{\rm d} \bmt\\
&=\frac{1}{(2\pi)^p}\int_{2\pi {\mathbb R}^p/\mathbb{Z}^p}\phi_{X-{\bm \mu}}^n(\bmt)e^{-\mathrm{i} \langle \bmt, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} \bmt,
\end{split}\end{align*}
where $\phi_X(\bmt)$ and $\phi_{X-{\bm \mu}}(\bmt)$ are the characteristic functions of $X$ and $X-{\bm \mu}$ respectively.
We recall the domains $B_j(\delta)$ for $j=0,1,2,\cdots, p-1$ from \eqref{e:domainB}. Thanks to Proposition \ref{p:cfbound}, the characteristic function $|\phi^n_{X-{\bm \mu}}(\bmt)|$ is exponentially small outside those sets $B_j(\delta)$.
\begin{align}\begin{split}\label{e:integ1d}
\mathbb{P}(S_n=d{\bm{n}})
&=\frac{1}{(2\pi)^p}\sum_{j=0}^{p-1}\int_{2\pi B_j(\delta)}\phi_{X-{\bm \mu}}^n(\bmt)e^{-\mathrm{i} \langle \bmt, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} \bmt + e^{-c(\delta)n/p^3}\\
&=\frac{p}{(2\pi)^p}\int_{2\pi B_0(\delta)}\phi_{X-{\bm \mu}}^n(\bmt)e^{-\mathrm{i} \langle \bmt, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} \bmt + e^{-c(\delta)n/p^3},
\end{split}\end{align}
where we used the fact that the integrand is translation invariant by vectors $2\pi(0,1/p, 2/p,\cdots, p-1/p)\mathbb{Z}$.
For any $\bmt\in  B_0(\delta)$, by definition there exists ${\bm{x}}\in {\mathbb R}^{p-1}$ with $\|{\bm{x}}\|^2_2\leq \delta$ and $y\in [0,2\sqrt{p}\pi]$, such that $\bmt=Q({\bm{x}},y)=O{\bm{x}}+(y/\sqrt{p})\bm1$. By a change of variable, we can rewrite \eqref{e:integ1d} as
\begin{align}\begin{split}\label{e:integ2d}
&\phantom{{}={}}\frac{p}{(2\pi)^p}\int_{2\pi B_0(\delta)}\phi_{X-{\bm \mu}}^n(\bmt)e^{-\mathrm{i} \langle \bmt, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} \bmt\\
&=\frac{p}{(2\pi)^{p}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq \delta\}\times [0,2\sqrt{p}\pi]}\phi_{X-{\bm \mu}}^n(Q({\bm{x}},y))e^{-\mathrm{i} \langle Q({\bm{x}},y), d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} {\bm{x}}{\rm d} y\\
&=\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq \delta\}}\phi_{X-{\bm \mu}}^n(O{\bm{x}})e^{-\mathrm{i} \langle O{\bm{x}}, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} {\bm{x}},
\end{split}\end{align}
where we used that $\langle \bm1, X-{\bm \mu}\rangle=0$ and $\langle\bm1, d{\bm{n}}-n{\bm \mu}\rangle=0$. By Taylor expansion, the characteristic function is
\begin{align}\begin{split}\label{e:cf}
\phi_{X-{\bm \mu}}(O{\bm{x}})
&=\mathbb{E}\left[1+\mathrm{i}\langle O{\bm{x}}, X-{\bm \mu}\rangle-\frac{1}{2}\langle O{\bm{x}}, X-{\bm \mu}\rangle^2-\frac{\mathrm{i}}{6}\langle O{\bm{x}}, X-{\bm \mu}\rangle^3+\OO(\langle O{\bm{x}}, X-\mu\rangle^4)\right]\\
&=1-\frac{1}{2}{\bm{x}}^tO^t\Sigma O{\bm{x}}+\OO\left(\frac{\|{\bm{x}}\|_2^3}{p}\right)
=1-\frac{d}{2p}\|{\bm{x}}\|_2^2+\OO\left(\frac{\|{\bm{x}}\|_2^3}{p}\right),
\end{split}\end{align}
where we used $\Sigma=dI_p/p-d\bm1\bm1^t/p^2$ from \eqref{e:meanandcov}, and $O^t\Sigma O=d I_{p-1}/p$. Fix a large constant ${\mathfrak c}$, which will be chosen later.
For ${\mathfrak c} p^2\ln n/n\leq \|{\bm{x}}\|_2^2\leq \delta$, we have
\begin{align}\label{e:integ3d}
|\phi_{X-{\bm \mu}}(O{\bm{x}})|^n\leq \exp\left\{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p\ln n\right\},
\end{align}
which turns out to be negligible provided ${\mathfrak c}$ is large enough. In the following we will restrict the integral \eqref{e:integ2d} on the domain
$\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^2\ln n/n\}$. From \eqref{e:cf}, on the domain $\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^2\ln n/n\}$, we have
\begin{align*}
\phi_{X-{\bm \mu}}^n(O{\bm{x}})=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)e^{-\frac{dn}{2p}\|{\bm{x}}\|^2_2},
\end{align*}
and
\begin{align}\begin{split}\label{e:integ4d}
&\phantom{{}={}}\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^2\ln n/n\}}\phi_{X-{\bm \mu}}^n(O{\bm{x}})e^{-\mathrm{i} \langle O{\bm{x}}, d{\bm{n}}-n{\bm \mu}\rangle}{\rm d} {\bm{x}}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^2\ln n/n\}}e^{-\frac{dn}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t(d{\bm{n}}-n{\bm \mu})\rangle}{\rm d} {\bm{x}}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{ {\mathbb R}^{p-1}}e^{-\frac{dn}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t(d{\bm{n}}-n{\bm \mu})\rangle}{\rm d} {\bm{x}}+e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p\ln n}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{ {\mathbb R}^{p-1}}e^{-\frac{dn}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t(d{\bm{n}}-n{\bm \mu})\rangle}{\rm d} {\bm{x}}+e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p\ln n}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)p^{3/2}
\left(\frac{p}{2\pi d n}\right)^{\frac{p-1}{2}}e^{-\frac{dpn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}
+e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p\ln n}.
\end{split}\end{align}
The exponents in \eqref{e:firstfactord} and \eqref{e:integ4d} cancel
\begin{align*}
-\frac{dpn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2+\frac{(d-1)pn}{2}\sum_{j=0}^{p-1}({\mathfrak n}_j-1/p)^2
=-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2,
\end{align*}
where we used that $O^t$ is an isometry from $\{(x_1,x_2,\cdots, x_{p})\in {\mathbb R}^p: x_1+x_2+\cdots+x_p=0\}$ to ${\mathbb R}^{p-1}$.
Therefore, by combining the estimates \eqref{e:firstfactord}, \eqref{e:integ1d}, \eqref{e:integ2d}, \eqref{e:integ3d} and \eqref{e:integ4d}, we conclude that for any $p$-tuple $(n_0,n_1,\cdots,n_{p-1})\in {\cal E}$, with $\sum_{j=0}^{p-1}jn_j\equiv 0 \Mod p$,
\begin{align}\begin{split}\label{e:integ4.5}
&\phantom{{}={}}\frac{1}{|\mathsf{M}_{d,p}|}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=
\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)
p^{3/2}
\left(\frac{p}{2\pi n}\right)^{\frac{p-1}{2}}e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}+e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{(d-1){\mathfrak b} }{2}+\oo(1)\right)p\ln n}.
\end{split}\end{align}
For the second term on the righthand side of \eqref{e:integ4.5}, since the total number of $p$-tuples $(n_0,n_1,\cdots, n_{p-1})\in {\cal E}$ is bounded by $e^{p\ln n}$,
\begin{align}\label{e:secondtermd}
\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal E}}e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{(d-1){\mathfrak b} }{2}+\oo(1)\right)p\ln n}
=e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{(d-1){\mathfrak b}}{2}-1+\oo(1)\right)p\ln n},
\end{align}
which is negligible provided ${\mathfrak c}$ is large enough.

For the first term on the righthand side of \eqref{e:integ4.5} corresponding to the $p$-tuple $(n_0,n_1,\cdots,n_{p-1})\in {\cal E}$, with $\sum_{j=0}^{p-1}jn_j\equiv 0 \Mod p$, we can replace it by an average.
\begin{align*}\begin{split}
pe^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}
&=e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}
+\left(1+\OO\left(\frac{p(\ln n)^{1/2}}{n^{1/2}}\right)\right)
\sum_{j=1}^{p-1}e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}+{\bm{e}}_j-{\bm{e}}_0}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}.
\end{split}\end{align*}
Therefore, we can replace the sum over $p$-tuples $(n_0,n_1,\cdots,n_{p-1})\in {\cal E}$, with $\sum_{j=0}^{p-1}jn_j\equiv 0 \Mod p$ to the sum over all $p$-tuples $(n_0,n_1,\cdots,n_{p-1})\in {\cal E}$ with a factor $1/p$.
\begin{align}\begin{split}\label{e:integ5d}
&\phantom{{}={}}\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal E}\atop \sum_{j=0}^{p-1}jn_j\equiv 0\Mod p}
\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)
p^{3/2}
\left(\frac{p}{2\pi n}\right)^{\frac{p-1}{2}}e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}\\
&=\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal E}}
\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)
p^{1/2}
\left(\frac{p}{2\pi n}\right)^{\frac{p-1}{2}}e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}.
\end{split}\end{align}
In the following we estimate the sum in \eqref{e:integ5d}. The set of points $O^t({\bm{n}}/n-\bm\mu/d)$ for ${\bm{n}}=(n_0,n_1,\cdots, n_{p-1})\in {\cal E}$ is a subset of a lattice in ${\mathbb R}^{p-1}$. A set of base for this lattice is given by
\begin{align*}
O^t(e_{j}-e_{0})/n, \quad 0\leq j\leq p-1.
\end{align*}
The volume of the fundamental domain is $p^{1/2}/n^{p-1}$. By viewing \eqref{e:integ5d} as a Riemann sum, we can rewrite it as an integral on ${\mathbb R}^{p-1}$.
\begin{align}\begin{split}\label{e:integ6d}
&\phantom{{}={}}\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal E}}
\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)
p^{1/2}
\left(\frac{p}{2\pi n}\right)^{\frac{p-1}{2}}e^{-\frac{pn}{2}\left\|O^t \left(\frac{{\bm{n}}}{n}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right)
\left(\frac{pn}{2\pi}\right)^{\frac{p-1}{2}}\int_{\{{\bm{x}}\in{\mathbb R}^{p-1}:\|{\bm{x}}\|_2^2\leq {\mathfrak b}\ln n/n\}} e^{-\frac{pn}{2}\|{\bm{x}}\|^2}{\rm d} {\bm{x}}\\
&=\left(1+\OO\left(\frac{p^2(\ln n)^{3/2}}{n^{1/2}}\right)\right),
\end{split}\end{align}
provided ${\mathfrak b}$ is large enough. The claim \eqref{e:equd} follows from combining \eqref{e:integ4.5}, \eqref{e:secondtermd} and \eqref{e:integ6d}.
This finishes the proof of Proposition \ref{p:lcltd}.
\end{proof}

\subsection{Large deviation estimate}
\label{subs:ldpd}

In this section, we show that the sum of terms in \eqref{e:keyestd} corresponding to non-equidistributed $p$-tuples $(n_0,n_1,\cdots,n_{p-1})$ is small.
\begin{proposition}\label{p:ldpd}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$ and $p\ll n^{(d-2)/2d}$. Then for $n$ sufficiently large,
\begin{align}\label{e:noneqd}
\frac{1}{|\mathsf{M}_{n,d}|}\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\leq \frac{\OO(p^2)}{n^{(d-2)}}.
\end{align}
\end{proposition}
Thanks to Proposition \ref{p:walkrepd}, we have
\begin{align}\begin{split}\label{e:expldpd}
&\phantom{{}={}}\frac{1}{|\mathsf{M}_{n,d}|}\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal N}}{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}\\
&\phantom{{}={}}\times p^{n(d-1)}\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1})),
\end{split}\end{align}
where $X_1,X_2,\cdots, X_n$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$ as defined in \eqref{e:defcU}. We enumerate the elements of ${\mathcal U}_{d,p}$ as
\begin{align*}
{\mathcal U}_{d,p}=\{{\bm{w}}_1, {\bm{w}}_2,\cdots, {\bm{w}}_{p^{d-1}}\}, \quad {\bm{w}}_1=(d,0,0,\cdots,0).
\end{align*}
For any non-equidistributed $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$, we denote ${\mathfrak n}_j=n_j/n$ for $j=0,1,\cdots, p-1$. We estimate the first factor on the righthand side of \eqref{e:expldpd} using Stirling's formula,
\begin{align}\begin{split}\label{e:firstfactor2d}
{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}p^{n(d-1)}
\leq e^{\OO(p)}\exp\left\{(d-1)n\left(\ln p+\sum_{j=0}^{p-1} {\mathfrak n}_j\ln {\mathfrak n}_j\right)\right\}.
\end{split}\end{align}
For the random walk term in \eqref{e:expldpd}, we have the following large deviation bound
\begin{align}\label{e:secondfactor2d}
\mathbb{P}(X_1+X_2+\cdots+X_n=(dn_0, dn_{1},\cdots, dn_{p-1}))
\leq \exp\left\{n\inf_{\bmt\in {\mathbb R}^p} \log \mathbb{E}[e^{\langle \bmt, X\rangle}]-d\langle \bmt, \bm{\mathfrak n}\rangle\right\}.
\end{align}
Thus combining \eqref{e:firstfactor2d} and \eqref{e:secondfactor2d}, we get that
\begin{align*}
\begin{split}
&\phantom{{}={}}\frac{1}{|\mathsf{M}_{n,d}|}\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{M}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&\leq \sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal N}} e^{\OO(p)}\exp\left\{(d-1)n \ln p+(d-1)n\sum_{j=0}^{p-1} {\mathfrak n}_j\ln {\mathfrak n}_j+n\inf_{\bmt\in {\mathbb R}^p} \log \mathbb{E}[e^{\langle \bmt, X\rangle}]-d\langle \bmt, \bm{\mathfrak n}\rangle\right\}\\&=\sum_{(n_0,n_1,\cdots,n_{p-1}) \in {\cal N}} e^{\OO(p)} e^{n I({\mathfrak n}_0,{\mathfrak n}_1, \cdots, {\mathfrak n}_{p-1})},
\end{split}\end{align*}
where the rate function is given by
\begin{align}\label{e:ratefd}
I({\mathfrak n}_0,{\mathfrak n}_1, \cdots, {\mathfrak n}_{p-1})=(d-1)\ln p+(d-1)\sum_{j=0}^{p-1} {\mathfrak n}_j\ln {\mathfrak n}_j+\inf_{\bmt\in {\mathbb R}^p} \log \mathbb{E}[e^{\langle \bmt, X\rangle}]-d\langle \bmt, \bm{\mathfrak n}\rangle.
\end{align}
The rate function function is negative except for two points:  ${\mathfrak n}_0={\mathfrak n}_1=\cdots={\mathfrak n}_{p-1}=1/p$,
and  ${\mathfrak n}_0=1$, ${\mathfrak n}_1=\cdots={\mathfrak n}_{p-1}=0$. In the following proposition we give a quantitative estimate of the rate function.
\begin{proposition}\label{p:ldpbound}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$. The rate function as defined in \eqref{e:ratefd} satisfies: for any small $\delta> 0$, there exists a constant $c(\delta)>0$, such that
\begin{align}\label{e:ratebound}
I({\mathfrak n}_0, {\mathfrak n}_1,\cdots, {\mathfrak n}_{p-1})\leq -\frac{c(\delta)}{p},
\end{align}
unless
$ \max_{0\leq k\leq p}|{\mathfrak n}_k-1/p|\leq \delta/p$, or
${\mathfrak n}_0\geq 1-\delta/p$.
\end{proposition}

\begin{proof}
We take $\bmt=(d-1)/d((\ln {\mathfrak n}_0, \ln {\mathfrak n}_1,\cdots, \ln {\mathfrak n}_{p-1})+\ln p)$ in \eqref{e:ratefd}, the rate function $I$ is upper bounded by
\begin{align}\label{e:sharprate}
I({\mathfrak n}_0,{\mathfrak n}_1, \cdots, {\mathfrak n}_{p-1})\leq \log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)},
\end{align}
In the following, we prove that there exists a constant $c(\delta)>0$
\begin{align}\label{e:ratebound2}
\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)}\leq 1-\frac{c(\delta)}{p},
\end{align}
unless $ \max_{0\leq k\leq p}|{\mathfrak n}_k-1/p|\leq \delta/p$, or
${\mathfrak n}_0\geq 1-\delta/p$. Then the claim \eqref{e:ratebound} follows.

For any $\varepsilon>0$ and $d$-tuple $(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d$ such that $a_1+a_2+\cdots+a_d=0$, if
\begin{align*}
\frac{\min_{1\leq r\leq d}{\mathfrak n}_{a_r}}{\max_{1\leq r\leq d}{\mathfrak n}_{a_r}}\leq
\frac{1}{1+\varepsilon},
\end{align*}
then there exists a constant $c(\varepsilon)>0$ such that
\begin{align*}
\prod_{r=1}^d{\mathfrak n}_{a_r}^{\frac{d-1}{d}}\leq \frac{1-c(\varepsilon)}{d}\sum_{r=1}^d \prod_{1\leq s\leq d\atop s\neq r}{\mathfrak n}_{a_s}.
\end{align*}
Therefore, by the defining relation of the multiset ${\mathcal U}_{d,p}$ as in \eqref{e:defcU}, we have
\begin{align}\begin{split}\label{e:am-gm}
\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)}
&=\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}\prod_{r=1}^d {\mathfrak n}_{a_r}^{\frac{d-1}{d}}\\
&\leq \sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}\frac{1}{d}\left({1-1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}c(\varepsilon)}\right)\sum_{r=1}^d\prod_{1\leq s\leq d\atop s\neq r} {\mathfrak n}_{a_s}\\
&=\left(\sum_{j=0}^{p-1} {\mathfrak n}_j\right)^{d-1}-\frac{c(\varepsilon)}{d}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\sum_{r=1}^d\prod_{1\leq s\leq d\atop s\neq r} {\mathfrak n}_{a_s}\\
&\leq 1-\frac{c(\varepsilon)}{d}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\prod_{r=1}^{d-1}{\mathfrak n}_{a_r}.
\end{split}\end{align}
In the following, we take $\varepsilon=\delta/3$, and prove that there exists a constant $c(\delta)$
\begin{align}\label{e:ratebound3}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\prod_{r=1}^{d-1}{\mathfrak n}_{a_r}\geq \frac{c(\delta)}{p},
\end{align}
unless $ \max_{0\leq k\leq p}|{\mathfrak n}_k-1/p|\leq \delta/p$, or
${\mathfrak n}_0\geq 1-\delta/p$. Then the claim \eqref{e:ratebound2} follows.

We sort these numbers ${\mathfrak n}_0, {\mathfrak n}_1,\cdots, {\mathfrak n}_{p-1}$ as ${\mathfrak n}_{k_1}\geq {\mathfrak n}_{k_2}\geq \cdots \geq {\mathfrak n}_{k_{p}}$, then ${\mathfrak n}_{k_1}\geq 1/p$. We take the indices $t_1$ and $t_2$ such that ${\mathfrak n}_{k_{t_1}}>{\mathfrak n}_{k_1}/(1+\varepsilon)\geq {\mathfrak n}_{k_{t_1+1}}$, and ${\mathfrak n}_{k_{t_2}}>{\mathfrak n}_{k_1}/(1+\varepsilon)^2\geq {\mathfrak n}_{k_{t_2+1}}$. If ${\mathfrak n}_{k_{t_1+1}}+{\mathfrak n}_{k_{t_1+2}}+\cdots +{\mathfrak n}_{k_p}\geq \varepsilon$, by restricting the sum in \eqref{e:ratebound3} over $d$-tuples with $a_1=k_1$ and $a_2\in \{k_{t_1+1}, k_{t_1+2},\cdots, k_{p}\}$, we get
\begin{align*}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\sum_{r=1}^{d-1}{\mathfrak n}_{a_r}
\geq
{\mathfrak n}_{k_1}({\mathfrak n}_{k_{t_1+1}}+{\mathfrak n}_{k_{t_1+2}}+\cdots+{\mathfrak n}_{k_{p}})\sum_{a_3, a_4,\cdots, a_{d-1}\in {\mathbb F}_p}\prod_{r=3}^{d-1}{\mathfrak n}_{a_r}\geq \frac{\varepsilon}{p}.
\end{align*}
The claim \eqref{e:ratebound3} follows. So we can assume that ${\mathfrak n}_{k_{t_1+1}}+{\mathfrak n}_{k_{t_1+2}}+\cdots +{\mathfrak n}_{k_p}\leq  \varepsilon$ and thus ${\mathfrak n}_{k_{1}}+{\mathfrak n}_{k_{2}}+\cdots +{\mathfrak n}_{k_{t_1}}\geq  1-\varepsilon$.
If ${\mathfrak n}_{k_{t_2+1}}+{\mathfrak n}_{k_{t_2+2}}+\cdots +{\mathfrak n}_{k_p}\geq \varepsilon/p$, by restricting the sum in \eqref{e:ratebound3} over $d$-tuples with $a_1\in \{k_1, k_2,\cdots, k_{t_1}\}$ and $a_2\in \{k_{t_2+1}, k_{t_2+2},\cdots, k_{p}\}$, we get
\begin{align*}\begin{split}
&\phantom{{}={}}\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\sum_{r=1}^{d-1}{\mathfrak n}_{a_r}\\
&\geq
({\mathfrak n}_{k_{1}}+{\mathfrak n}_{k_{2}}+\cdots+{\mathfrak n}_{k_{t_1}})({\mathfrak n}_{k_{t_2+1}}+{\mathfrak n}_{k_{t_2+2}}+\cdots+{\mathfrak n}_{k_{p}})\sum_{a_3, a_4,\cdots, a_{d-1}\in {\mathbb F}_p}\prod_{r=3}^{d-1}{\mathfrak n}_{a_r}\geq \frac{(1-\varepsilon)\varepsilon}{p}.
\end{split}\end{align*}
The claim \eqref{e:ratebound3} follows. So we can assume that ${\mathfrak n}_{k_{t_2+1}}+{\mathfrak n}_{k_{t_2+2}}+\cdots +{\mathfrak n}_{k_p}\leq  \varepsilon/p$. There are three cases:
\begin{enumerate}
\item If $t_2=p$, then we have $\max_{0\leq k\leq p-1} {\mathfrak n}_k \leq (1+\varepsilon)^2\min_{0\leq k\leq p-1} {\mathfrak n}_k$. And it follows that $(1+\varepsilon)^{-2}/p\leq {\mathfrak n}_k \leq(1+\varepsilon)^{2}/p$ for $0\leq k\leq p-1$. The claim follows by taking $2\varepsilon+\varepsilon^2\leq \delta$.
\item If $t_2=1$, then we have ${\mathfrak n}_{k_1}\geq 1-\varepsilon/p$. If $k_1=0$, then the claim follows by taking $\varepsilon\leq \delta$. Otherwise, $k_1\neq 0$. By restricting the sum in \eqref{e:ratebound3} over $d$-tuples with $a_1=a_2=\cdots=a_{d-1}=k_1$, we get
\begin{align*}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\sum_{r=1}^{d-1}{\mathfrak n}_{a_r}
\geq
{\mathfrak n}_{k_1}^{d-1}\geq \left(1-\frac{\varepsilon}{p}\right)^{d-1}.
\end{align*}
The claim \eqref{e:ratebound3} follows.
\item If $1<t_2<p$, then we have ${\mathfrak n}_{k_1}\geq {\mathfrak n}_{k_2}\geq \cdots\geq {\mathfrak n}_{k_{t_2}}\geq {\mathfrak n}_{k_1}/(1+\varepsilon)^2$. And it follows $(1+\varepsilon)^{2}/t_2\geq {\mathfrak n}_{k_1}\geq {\mathfrak n}_{k_2}\geq \cdots\geq {\mathfrak n}_{k_{t_2}} \geq(1+\varepsilon)^{-2}/t_2\geq (1+\varepsilon){\mathfrak n}_{k_{t_2}+1}$. We will restrict the sum in \eqref{e:ratebound3} over $d$-tuples with $a_1,a_2,\cdots, a_{d-1}\in \{k_1, k_2,\cdots, k_{t_2}\}$, and $a_d\in \{k_{t_2+1}, k_{t_2+2}, \cdots, k_p\}$.
We take integer $q$ such that $t_2q\equiv -2(k_1+k_2+\cdots+k_{t_2})\Mod p$. The number of $(d-2)$-tuples $a_1,a_2,\cdots, a_{d-2}\in \{k_1, k_2,\cdots, k_{t_2}\}$ such that $a_1+a_2+\cdots+a_{d-2}\not\equiv q\Mod p$
is at least $(t_2-1)t_2^{d-3}$. For any $(d-2)$-tuple $a_1,a_2,\cdots, a_{d-2}\in \{k_1, k_2,\cdots, k_{t_2}\}$ such that $a_1+a_2+\cdots+a_{d-2}\not\equiv q\Mod p$, there exists at least one $a_{d-1}\in \{k_1, k_2,\cdots, k_{t_2}\}$ such that $a_1+a_2+\cdots+a_{d-1}\not\equiv -k_1,-k_2,\cdots,-k_{t_2}\Mod p$. Otherwise
\begin{align*}
t_2(a_1+a_2+\cdots+a_{d-2})+(k_1+k_2+\cdots+k_{t_2})\equiv -(k_1+k_2+\cdots+k_{t_2})\Mod p,
\end{align*}
and $a_1+a_2+\cdots+a_{d-2}\equiv q\Mod p$. This leads to a contradiction. Therefore, the number of $d$-tuples with $a_1,a_2,\cdots, a_{d-1}\in \{k_1, k_2,\cdots, k_{t_2}\}$, and $a_d\in \{k_{t_2+1}, k_{t_2+2}, \cdots, k_p\}$ is at least $(t_2-1)t_2^{d-3}$. By restricting the sum in \eqref{e:ratebound3} over $d$-tuples with $a_1,a_2,\cdots, a_{d-1}\in \{k_1, k_2,\cdots, k_{t_2}\}$, and $a_d\in \{k_{t_2+1}, k_{t_2+2}, \cdots, k_p\}$, we get
\begin{align*}
\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}1_{\frac{\min_{r} {\mathfrak n}_{a_r}}{\max_{r} {\mathfrak n}_{a_r}}\leq \frac{1}{1+\varepsilon}}\sum_{r=1}^{d-1}{\mathfrak n}_{a_r}
\geq
(t_2-1)t_2^{d-3} \left(\frac{1}{(1+\varepsilon)^2 t_2}\right)^{d-1}
\geq \frac{1}{2(1+\varepsilon)^{2d-2}p} .
\end{align*}
The claim \eqref{e:ratebound3} follows.
\end{enumerate}
This finishes the proof of Proposition \ref{p:ldpbound}.
\end{proof}

\begin{proof}[Proof of Proposition \ref{p:ldp}]
We further decompose the set of non-equidistributed $p$-tuples $(n_0,n_1,\cdots, n_{p-1})$ into four classes:
\begin{enumerate}
\item $p$-tuples $(n_0,n_1,\cdots, n_{p-1})\in {\cal N}$ with $\max_{0\leq j\leq p-1}|n_j/n-1/p|\leq \delta/p$.
\item $p$-tuples $(n_0,n_1,\cdots, n_{p-1})\in {\cal N}$  with ${\mathfrak b}\ln n/n<|n_0/n-1|\leq \delta/p$.
\item $p$-tuples $(n_0,n_1,\cdots, n_{p-1})\in {\cal N}$  with $|n_0/n-1|\leq {\mathfrak b}\ln n/n$.
\item The remaining non-equidistributed $p$-tuples.
\end{enumerate}

For the first class, $\max_{0\leq j\leq p-1}|n_j/n-1/p|\leq \delta/p$. The total number of such $p$-tuples is $e^{\OO(p\ln n)}$.
Given a $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$ in the first class,
we will derive a more precise estimate of \eqref{e:ratebound2}, by a perturbation argument. Let
\begin{align*}\begin{split}
&{\mathfrak n}_j=(1+\delta_j)/p,\quad j=0,1,\cdots, p-1.
\end{split}\end{align*}
where $\sum_{0\leq j\leq p-1}\delta_j=0$, $\max_{0\leq j\leq p-1}|\delta_j|\leq \delta$, and $\sum_j \delta_j^2\geq {\mathfrak b} p^2\ln n/n$.
We denote $\bm\delta=(\delta_0, \delta_1,\cdots, \delta_{p-1})$.
We use Taylor expansion, and rewrite the righthand side of \eqref{e:sharprate} as
\begin{align}\begin{split}\label{e:sumexp}
&\phantom{{}={}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)}
=\frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}(1+\delta_k)^{\frac{d-1}{d}{\bm{w}}_j(k)}
=\frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}e^{\frac{d-1}{d}\sum_{k=0}^{p-1}\left(\delta_k-(1+\OO(\delta))\frac{\delta_k^2}{2}\right){\bm{w}}_j(k)}\\
&=\frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}1+\frac{d-1}{d}\sum_{k=0}^{p-1}\left(\delta_k-(1+\OO(\delta))\frac{\delta_k^2}{2}\right){\bm{w}}_j(k)
+(1+\OO(\delta))\frac{(d-1)^2}{2d^2}
\left(\sum_{k=0}^{p-1}\delta_k {\bm{w}}_j(k)\right)^2
\\
&=1+\frac{d-1}{2d p^{d-1}}\left(-(1+\OO(\delta))dp^{d-2}\|\bm\delta\|_2^2+(1+\OO(\delta))\frac{d-1}{d}\sum_{j=1}^{p^{d-1}}\langle \bm\delta, {\bm{w}}_j\rangle^2\right)
\end{split}\end{align}
We recall from \eqref{e:cov} that
\begin{align*}
\sum_{j=1}^{p^{d-1}}{\bm{w}}_j{\bm{w}}_j^t=dp^{d-2}I_{p}+d(d-1)p^{d-3}\bm1\bm1^t.
\end{align*}
Therefore,
\begin{align}\begin{split}\label{e:finalbound}
\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)}
&=1+\frac{d-1}{2d p^{d-1}}\left(-(1+\OO(\delta))dp^{d-2}\|\bm\delta\|_2^2+(1+\OO(\delta))(d-1)p^{d-2}\|\bm\delta\|_2^2\right)\\
&=1-(1+\OO(\delta))\frac{d-1}{2dp}\|\bm\delta\|_2^2\leq 1-(1+\OO(\delta))\frac{d-1}{2d}\frac{{\mathfrak b} p\ln n}{n}.
\end{split}\end{align}
Thanks to  \eqref{e:sharprate}, we obtain an upper bound for the rate function from \eqref{e:finalbound}
\begin{align*}
I({\mathfrak n}_0,{\mathfrak n}_1,\cdots, {\mathfrak n}_{p-1})\leq -\left(\frac{(d-1){\mathfrak b}}{2d}+\oo(1)\right)\frac{p\ln n}{n}.
\end{align*}
The total contribution of terms in \eqref{e:noneqd} satisfying $\max_{0\leq j\leq p-1}|n_j/n-1/p|\leq \delta$ is bounded by
\begin{align}\label{e:case1d}
\exp\left\{-\left(\frac{(d-1){\mathfrak b}}{2d}+\oo(1)\right)p\ln n+\OO(p\ln n)\right\}=\frac{\oo(1)}{n^{(d-2)}},
\end{align}
provided that we take ${\mathfrak b}$ sufficiently large.

For the second class, ${\mathfrak b} p\ln n/n<|n_0/n-1|\leq \delta/p$. The total number of such $p$-tuples is $e^{\OO(p\ln n)}$. Given a $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$ in the second class, we will derive a more precise estimate of \eqref{e:ratebound2}, by a perturbation argument. Let ${\mathfrak n}_0=1-\delta_0$, where $\delta_0\leq \delta/p$.

We decompose the $d$-tuples $(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d$ such that $a_1+a_2+\cdots+a_d=0$ into three sets: $\{(0,0,\cdots,0)\}$ and
\begin{align*}\begin{split}
&\cA_1=\{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d: a_1+a_2+\cdots+a_d=0, \sum_{r=1}^d \bm1(a_r=0)=0\},\\
&\cA_2=\{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d: a_1+a_2+\cdots+a_d=0, 0<\sum_{r=1}^d \bm1(a_r=0)<d\}.
\end{split}\end{align*}
For any $d$-tuple $(a_1, a_2,\cdots, a_d)\in \cA_2$, we have $\min_{1\leq r\leq d}{\mathfrak n}_{a_r}/ \max_{1\leq r\leq d}{\mathfrak n}_{a_r}\leq \delta_0/(1-\delta_0)$, and
\begin{align*}
\prod_{r=1}^d{\mathfrak n}_{a_r}^{\frac{d-1}{d}}\leq \left(4\delta_0\right)^{1/d}\frac{1}{d}\sum_{r=1}^d \prod_{1\leq s\leq d\atop s\neq r}{\mathfrak n}_{a_s}.
\end{align*}
Therefore, by the defining relation of the multiset ${\mathcal U}_{d,p}$ as in \eqref{e:defcU}, we have
\begin{align}\begin{split}\label{e:midbound}
&\phantom{{}={}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak n}_k^{\frac{d-1}{d}{\bm{w}}_j(k)}
=\sum_{(a_1,a_2,\cdots,a_{d})\in {\mathbb F}_p^d,\atop a_1+a_2+\cdots+a_d=\bm0}\prod_{r=1}^d {\mathfrak n}_{a_r}^{\frac{d-1}{d}}\\
&\leq{\mathfrak n}_0^{d-1}+\sum_{(a_1,a_2,\cdots,a_d)\in \cA_1}\frac{1}{d}\sum_{r=1}^d \prod_{1\leq s\leq d\atop s\neq r}{\mathfrak n}_{a_s}+\left(4\delta_0\right)^{1/d}\sum_{(a_1,a_2,\cdots,a_d)\in \cA_2}\frac{1}{d}\sum_{r=1}^d \prod_{1\leq s\leq d\atop s\neq r}{\mathfrak n}_{a_s}\\
&\leq{\mathfrak n}_0^{d-1}+({\mathfrak n}_1+{\mathfrak n}_2+\cdots+{\mathfrak n}_{p-1})^{d-1}+\left(4\delta_0\right)^{1/d}(1-{\mathfrak n}_0^{d-1})\\
&=1+\delta_0^{d-1}-\left(1-\left(4\delta_0\right)^{1/d}\right)\left(1-\left(1-\delta_0\right)^{d-1}\right).
\end{split}\end{align}
Therefore, thanks to \eqref{e:sharprate}, we get
\begin{align*}
I({\mathfrak n}_0,{\mathfrak n}_1,\cdots, {\mathfrak n}_{p-1})\leq -(1+\oo(1))(d-1)\delta_0
\end{align*}
provided that $\delta_0$ is small enough. Thus, the total contribution of terms in \eqref{e:noneqd} satisfying ${\mathfrak b} p\ln n/n<|n_0/n-1|\leq \delta/p$ is bounded by
\begin{align}\label{e:case2d}
\exp\left\{-(1+\oo(1)){\mathfrak b} (d-1)p\ln n+\OO(p\ln n)\right\}=\frac{\oo(1)}{n^{(d-2)}},
\end{align}
provided that we take ${\mathfrak b}$ sufficiently large.

For the third class, $|n_0/n-1|\leq {\mathfrak b} p\ln n/n$.
We rewrite \eqref{e:expldpd} in terms of number of walk paths,
\begin{align}\begin{split}\label{e:expldpd2}
&\sum_{(n_0,n_1,\cdots,n_{p-1})\in {\cal N}}{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}\\
&\times|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_n)\in {\mathcal U}_{d,p}^n: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_n=(dn_0, dn_{1},\cdots, dn_{p-1})\}|.
\end{split}\end{align}
Given a $p$-tuple $(n_0,n_1,\cdots,n_{p-1})$, in the third class with $n_0=n-m$ and $2\leq m\leq {\mathfrak b} p\ln n$, we reestimate the first factor on the righthand side of \eqref{e:expldpd2},
\begin{align}\begin{split}\label{e:entr}
{n\choose n_0,n_1,\cdots, n_{p-1}}{dn\choose dn_0,dn_1,\cdots, dn_{p-1}}^{-1}
\leq \frac{e^{\OO(m)}}{n^{(d-1)m}}\frac{(dn_1)! (dn_2)!\cdots (dn_{p-1})!}{n_1!n_2!\cdots n_{p-1}!}.
\end{split}\end{align}
For the number of walk paths in \eqref{e:expldpd2}, we recall that
\begin{align*}
{\mathcal U}_{d,p}=\{{\bm{w}}_1, {\bm{w}}_2,\cdots, {\bm{w}}_{p^{d-1}}\}, \quad {\bm{w}}_1=(d,0,0,\cdots,0),
\end{align*}
and notice that ${\bm{w}}_j(1)+{\bm{w}}_j(2)+\cdots {\bm{w}}_j(p-1)\geq 2$ for $2\leq j\leq p^{d-1}$. Moreover, since $n_0=n-m$, we have ${\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_n=(dn_0, dn_{1},\cdots, dn_{p-1})$, with $dn_1+dn_2+\cdots+dn_{p-1}=dm$.
Therefore,  ${\bm{u}}_i={\bm{w}}_1$ for all $1\leq i\leq n$, except for at most $dm/2$ of them, and we have
\begin{align}\begin{split}\label{e:pathest}
&\phantom{{}={}}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_n)\in {\mathcal U}_{d,p}^n: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_n=(dn_0, dn_{1},\cdots, dn_{p-1})\}|\\
&\leq \frac{(dm)!}{(dn_1)! (dn_2)!\cdots (dn_{p-1})!} \sum_{k=1}^{dm/2}n^k{dm-k-1\choose k-1}\leq\OO(1)\frac{(dm)!}{(dn_1)! (dn_2)!\cdots (dn_{p-1})!} n^{dm/2}.
\end{split}\end{align}
Putting \eqref{e:entr} and \eqref{e:pathest} together, the total contribution of terms in \eqref{e:noneqd} satisfying $|n_0/n-1|\leq {\mathfrak b} p\ln n/n$ is bounded by
\begin{align}\begin{split}\label{e:case3d}
&\phantom{{}={}}\sum_{m=2}^{{\mathfrak b} p\ln n}\sum_{n_1+n_2+\cdots+n_{p-1}=m}\frac{e^{\OO(m)}(dm)!}{n_1! n_2!\cdots n_{p-1}!}\frac{1}{n^{(d/2-1)m}}\\
&\leq
\sum_{m=2}^{{\mathfrak b} p\ln n}
\frac{e^{\OO(m)}(dm)!p^m}{m!n^{(d/2-1)m}}
\leq \sum_{m=2}^{{\mathfrak b} p\ln n}\left(\frac{\OO(1)p m^d}{m n^{d/2-1}}\right)^m
\leq \frac{\OO(1)p^2}{n^{d-2}}.
\end{split}\end{align}
provided that $p\ll n^{(d-2)/2d}$.

For the last class, the total number of such $p$-tuples is $e^{\OO(p\ln n)}$, and thanks to Proposition \ref{p:ldpbound}, each term is exponentially small, i.e. $e^{-c(\delta)n/p}$. Therefore the total contribution is
\begin{align}\label{e:case4d}
\exp\{-c(\delta) n/p+\OO(p\ln n)\}=\frac{\oo(1)}{n^{(d-2)}}.
\end{align}

The claim \eqref{e:noneqd} follows from combining the discussion of all four cases, \eqref{e:case1d}, \eqref{e:case2d}, \eqref{e:case3d} and \eqref{e:case4d}.
\end{proof}

\section{Proof of Theorem \ref{thm:smcount} for random undirected $d$-regular graphs}
Thanks to Proposition \ref{p:walkrepu}, we can rewrite the lefthand side of \eqref{e:smcountu} as
\begin{align*}
&\phantom{{}={}}\sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|
=\sum_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}\sum_{{\bm{v}}\in {\mathcal S}(n_0,n_1,\cdots, n_{p-1})} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\sum_{n_0,n_1,\cdots,n_{p-1}\in \mathbb{Z}_{\geq 0}, n_0<n\atop n_0+n_1+\cdots+n_{p-1}=n}{n\choose n_0,n_1,\cdots, n_{p-1}}\sum_{M\in {\cal M}(n_0, n_1,\cdots, n_{p-1})}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
& \times p^{(d-1)n}\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))\\
&=\sum_{M\in {\cal M}}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
 &\times p^{(d-1)n}\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1})),
\end{align*}
where for any $M\in{\cal M}$, $n_i(M)\deq\sum_{j=0}^{p-1}m_{ij}/d$ for $i=0,1,\cdots, p-1$.
Therefore Theorem \ref{thm:smcount} is equivalent to the following estiamte
\begin{align}\begin{split}\label{e:keyest}
&\frac{2^{nd/2}(nd/2)!}{(nd)!}\sum_{M\in {\cal M}}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
& \times p^{(d-1)n}\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))=1+\oo(1).
\end{split}\end{align}

To prove \eqref{e:keyest}, we fix a large number ${\mathfrak b}>0$, and decompose those $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal M}$ into two classes:
\begin{enumerate}
\item (Equidistributed) ${\cal E}$ is the set of $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal M}$, such that $\sum_{i,j=0}^{p-1}(m_{ij}/(dn)-1/p^2)^2\leq {\mathfrak b}\ln n/n$.
\item (Non-equidistributed) ${\cal N}$ is the set of $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal M}$ which are not equidistributed.
\end{enumerate}
In Section \ref{subs:lclt}, we estimate the sum of terms in \eqref{e:keyest} corresponding to equidistributed $p\times p$ symmetric matrices using a local central limit theorem. In Section \ref{subs:ldp}, we show that the sum of terms in \eqref{e:keyest} corresponding to non-equidistributed $p\times p$ symmtric matrices is small, via a large deviation estimate. Theorem \ref{thm:smcount} for random directed $d$-regular graphs follows from combining Proposition \ref{p:lclt} and Proposition \ref{p:ldp}.

\subsection{Local central limit theorem estimate}
\label{subs:lclt}

In this section, we estimate the sum of terms in \eqref{e:keyest} corresponding to equidistributed $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal M}$ using a local central limit theorem.
\begin{proposition}\label{p:lclt}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$ and $p\ll n^{1/8}$. Then
for $n$ sufficiently large
\begin{align}\label{e:equ}
\sum_{M \in {\cal E}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|=\left(1+\bm1(p=2)+\OO\left(\frac{p^4(\ln n)^{3/2}}{\sqrt{n}}\right)\right)|\mathsf{G}_{n,d}|.
\end{align}
\end{proposition}

\begin{proof}
Thanks to Proposition \ref{p:walkrepu}, we have
\begin{align}\begin{split}\label{e:explclt}
&\phantom{{}={}}\frac{1}{|\mathsf{G}_{n,d}|}\sum_{M \in {\cal E}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\frac{2^{nd/2}(nd/2)!}{(nd)!}\sum_{M\in {\cal E}}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
& \phantom{{}={}}\times p^{(d-1)n}\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1})),
\end{split}\end{align}
where $X_1,X_2,\cdots, X_{n_i}$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$ as defined in \eqref{e:defcU}.
In the rest of the proof, we simply write $n_i(M)$ as $n_i$ for $0\leq i\leq p-1$.

For an equidistributed $p\times p$ symmetric matrix $M=[m_{ij}]_{0\leq i,j\leq p-1}$, we denote ${\mathfrak m}_{ij}=m_{ij}/(dn)$ for $i,j=0,1,\cdots, p-1$, and ${\mathfrak n}_i=n_i/n$ for $i=0,1,\cdots, p-1$. Then we have ${\mathfrak n}_i=\sum_{j=0}^{p-1}{\mathfrak m}_{ij}$ for $i=0,1,\cdots, p-1$. Moreover, by our definition of equidistributed,
$\sum_{i,j=0}^{p-1}({\mathfrak m}_{ij}-1/p^2)^2\leq {\mathfrak b}\ln n/n$, and by the AM-GM inequality
$\sum_{j=0}^{p-1}({\mathfrak n}_j-1/p)^2\leq {\mathfrak b} p\ln n/n$. We estimate the first factor on the righthand side of \eqref{e:explclt} using Stirling's formula,
\begin{align}\begin{split}\label{e:firstfactor}
&\phantom{{}={}}\frac{2^{nd/2}(nd/2)!}{(nd)!}\sum_{M\in {\cal E}}{n\choose n_0,n_1,\cdots, n_{p-1}}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}
p^{(d-1)n}\\
&=\left(1+\OO\left(\frac{p^4}{n}\right)\right)
2^{p/2}\sqrt{\pi n}\frac{\prod_{0\leq i<j\leq p-1}\sqrt{2\pi m_{ij}}}{\prod_{i=0}^{p-1}\sqrt{2\pi n_i}}
e^{\frac{dn}{2}\sum_{i,j=0}^{p-1}{{\mathfrak m}_{ij}}\ln {\mathfrak m}_{ij}-n\sum_{j=0}^{p-1}{\mathfrak n}_j\ln {\mathfrak n}_j }p^{(d-1)n}\\
&=
\left(1+\OO\left(\frac{p^3(\ln n)^{3/2}}{\sqrt{n}}\right)\right)
2^{p/2}\sqrt{\pi n}\frac{\prod_{0\leq i<j\leq p-1}\sqrt{2\pi dn/p^2}}{\prod_{i=0}^{p-1}\sqrt{2\pi n/p}}
e^{\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2-\frac{np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}.
\end{split}\end{align}

In the following, we estimate the second factor on the righthand side of \eqref{e:explclt}, i.e. $\mathbb{P}(S_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))$, where $S_{n_i}=X_1+X_2+\cdots+X_{n_i}$.
We recall that $X_1, X_2,\cdots, X_{n_i}$ are independent copies of $X$, which is uniformly distributed over the multiset ${\mathcal U}_{d,p}$ as defined in \eqref{e:defcU}.
We use the notation ${\bm m}_i=(m_{i0}, m_{i1}, m_{i2}, \cdots, m_{ip-1})$. By inverse Fourier formula
\begin{align*}\begin{split}
\mathbb{P}(S_{n_i}={\bm m}_i)
&=\frac{1}{(2\pi)^p}\int_{2\pi {\mathbb R}^p/\mathbb{Z}^p}\phi_X^{n_i}(\bmt)e^{-\mathrm{i} \langle \bmt, {\bm m}_i\rangle}{\rm d} \bmt\\
&=\frac{1}{(2\pi)^p}\int_{2\pi {\mathbb R}^p/\mathbb{Z}^p}\phi_{X-{\bm \mu}}^{n_i}(\bmt)e^{-\mathrm{i} \langle \bmt, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} \bmt,
\end{split}\end{align*}
where $\phi_X(\bmt)$ and $\phi_{X-{\bm \mu}}(\bmt)$ are the characteristic functions of $X$ and $X-{\bm \mu}$ respectively.
We recall the domains $B_j(\delta)$ for $j=0,1,2,\cdots, p-1$ from \eqref{e:domainB}. Thanks to Proposition \ref{p:cfbound}, the characteristic function $|\phi^n_{X-{\bm \mu}}(\bmt)|$ is exponentially small outside those sets $B_j(\delta)$.
\begin{align}\begin{split}\label{e:integ1}
\mathbb{P}(S_{n_i}={\bm m}_i)
&=\frac{1}{(2\pi)^p}\sum_{j=0}^{p-1}\int_{2\pi B_j(\delta)}\phi_{X-{\bm \mu}}^{n_i}(\bmt)e^{-\mathrm{i} \langle \bmt, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} \bmt + e^{-c(\delta)n_i/p^3}\\
&=\frac{p}{(2\pi)^p}\int_{2\pi B_0(\delta)}\phi_{X-{\bm \mu}}^{n_i}(\bmt)e^{-\mathrm{i} \langle \bmt, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} \bmt + e^{-c(\delta)n_i/p^3},
\end{split}\end{align}
where we used the fact that $\sum_{j=0}^{p-1}jm_{ij}\equiv 0\Mod p$, and the integrand is translation invariant by vectors $2\pi(0,1/p, 2/p,\cdots, p-1/p)\mathbb{Z}$.
For any $\bmt\in  B_0(\delta)$, by definition there exists ${\bm{x}}\in {\mathbb R}^{p-1}$ with $\|{\bm{x}}\|^2_2\leq \delta$ and $y\in [0,2\sqrt{p}\pi]$, such that $\bmt=Q({\bm{x}},y)=O{\bm{x}}+(y/\sqrt{p})\bm1$. By a change of variable, we can rewrite \eqref{e:integ1} as
\begin{align}\begin{split}\label{e:integ2}
&\phantom{{}={}}\frac{p}{(2\pi)^p}\int_{2\pi B_0(\delta)}\phi_{X-{\bm \mu}}^{n_i}(\bmt)e^{-\mathrm{i} \langle \bmt, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} \bmt\\
&=\frac{p}{(2\pi)^{p}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq \delta\}\times [0,2\sqrt{p}\pi]}\phi_{X-{\bm \mu}}^{n_i}(Q({\bm{x}},y))e^{-\mathrm{i} \langle Q({\bm{x}},y), {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} {\bm{x}}{\rm d} y\\
&=\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq \delta\}}\phi_{X-{\bm \mu}}^{n_i}(O{\bm{x}})e^{-\mathrm{i} \langle O{\bm{x}}, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} {\bm{x}},
\end{split}\end{align}
where we used that $\langle \bm1, X-{\bm \mu}\rangle=0$ and $\langle\bm1, {\bm m}_i-n_i{\bm \mu}\rangle=0$. We recall the estimate of the characteristic function from \eqref{e:cf},
\begin{align}\begin{split}\label{e:cfu}
\phi_{X-{\bm \mu}}(O{\bm{x}})
=1-\frac{d}{2p}\|{\bm{x}}\|_2^2+\OO\left(\frac{\|{\bm{x}}\|_2^3}{p}\right).
\end{split}\end{align}
Fix a large constant ${\mathfrak c}$, which will be chosen later. For ${\mathfrak c} p^4\ln n/n\leq \|{\bm{x}}\|_2^2\leq \delta$, we have
\begin{align}\label{e:integ3}
|\phi_{X-{\bm \mu}}(O{\bm{x}})|^{n_i}\leq \exp\left\{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n\right\},
\end{align}
which turns out to be negligible provided ${\mathfrak c}$ is large enough. In the following we will restrict the integral \eqref{e:integ2} on the domain
$\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^4\ln n/n\}$. From \eqref{e:cfu}, on the domain $\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^4 \ln n/n\}$, we have
\begin{align*}
\phi_{X-{\bm \mu}}^{n_i}(O{\bm{x}})=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)e^{-\frac{dn_i}{2p}\|{\bm{x}}\|^2_2},
\end{align*}
and
\begin{align}\begin{split}\label{e:integ4}
&\phantom{{}={}}\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^4\ln n/n\}}\phi_{X-{\bm \mu}}^{n_i}(O{\bm{x}})e^{-\mathrm{i} \langle O{\bm{x}}, {\bm m}_i-n_i{\bm \mu}\rangle}{\rm d} {\bm{x}}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{\{{\bm{x}}\in {\mathbb R}^{p-1}:\|{\bm{x}}\|^2_2\leq {\mathfrak c} p^4\ln n/n\}}e^{-\frac{dn_i}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t({\bm m}_i-n_i{\bm \mu})\rangle}{\rm d} {\bm{x}}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{ {\mathbb R}^{p-1}}e^{-\frac{dn_i}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t({\bm m}_i-n_i{\bm \mu})\rangle}{\rm d} {\bm{x}}+\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n}\right)\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{p^{3/2}}{(2\pi)^{p-1}}\int_{ {\mathbb R}^{p-1}}e^{-\frac{dn_i}{2p}\|{\bm{x}}\|^2_2}e^{-\mathrm{i} \langle {\bm{x}}, O^t({\bm m}_i-n_i{\bm \mu})\rangle}{\rm d} {\bm{x}}+\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n}\right)\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)p^{3/2}
\left(\frac{p}{2\pi d n_i}\right)^{(p-1)/2}e^{-\frac{n_i pd}{2}\left\|O^t \left(\frac{{\bm m}_i}{d n_i}-\frac{{\bm \mu}}{d}\right)\right\|_2^2}
+\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n}\right)\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)p^{3/2}
\left(\frac{p^2}{2\pi d n}\right)^{(p-1)/2}e^{-\frac{nd}{2}\sum_{j=0}^{p-1}\left(\frac{{\mathfrak m}_{ij}}{{\mathfrak n}_i}-\frac{1}{p}\right)^2}
+\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n}\right).
\end{split}\end{align}
By our definition that $M$ is equidistributed,
$\sum_{i,j=0}^{p-1}({\mathfrak m}_{ij}-1/p^2)^2\leq {\mathfrak b}\ln n/n$, and by the AM-GM inequlity
$\sum_{j=0}^{p-1}({\mathfrak n}_j-1/p)^2\leq {\mathfrak b} p\ln n/n$.  We can rewrite the exponent in \eqref{e:integ4} as
\begin{align}\label{e:integ5}
-\frac{nd}{2}\sum_{j=0}^{p-1}\left(\frac{{\mathfrak m}_{ij}}{{\mathfrak n}_i}-\frac{1}{p}\right)^2
=-\frac{dnp}{2}\left(p\sum_{j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2-\left({\mathfrak n}_i-\frac{1}{p}\right)^2\right)+\OO\left(\frac{p^3(\ln n)^{3/2}}{n^{1/2}}\right).
\end{align}
It follows by combining \eqref{e:integ4} and \eqref{e:integ5},
\begin{align}\begin{split}\label{e:integ6}
&\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))=\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}+\oo(1)\right)p^2\ln n}\right)\\
&+\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)p^{3p/2}
\left(\frac{p^2}{2\pi d n}\right)^{(p^2-p)/2}e^{-\frac{dnp}{2}\left(p\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2-\sum_{i=0}^{p-1}\left({\mathfrak n}_i-\frac{1}{p}\right)^2\right)}.
\end{split}\end{align}
The exponents in \eqref{e:firstfactor} and \eqref{e:integ6} cancel
\begin{align}
\begin{split}
\label{e:integ7}
&\phantom{{}={}}\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2-\frac{np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2-\frac{dnp}{2}\left(p\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2-\sum_{i=0}^{p-1}\left({\mathfrak n}_i-\frac{1}{p}\right)^2\right)\\
&=-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2.
\end{split}\end{align}
Therefore, by combining the estimates \eqref{e:firstfactor}, \eqref{e:integ6} and \eqref{e:integ7}, we conclude that for any equidistributed $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal M}$,
\begin{align}\begin{split}\label{e:integ8}
&\frac{1}{|\mathsf{G}_{n,d}|}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|=\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{{\mathfrak b} d}{4}+\oo(1)\right)p^2\ln n}\right)\\
&+\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{2^{(p-1)/2}p^{(p^2+3p)/2}}{d^{(p^2-p)/4}(2\pi n)^{(p^2+p-2)/4}}
e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}.
\end{split}\end{align}
For the first term on the righthand side of \eqref{e:integ8}, we notice that the total number of $p\times p$ symmetric matrices in ${\cal E}$ is bounded by $e^{p^2\ln n}$,
\begin{align}\label{e:firstterm}
\sum_{M\in {\cal E}}\OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{{\mathfrak b} d}{4}+\oo(1)\right)p^2\ln n}\right)
\leq \OO\left(e^{-\left(\frac{{\mathfrak c} d}{2}-\frac{{\mathfrak b} d}{4}-1+\oo(1)\right)p^2\ln n}\right),
\end{align}
which is negligible provided ${\mathfrak c}$ is large enough.

For the second term on the righthand side of \eqref{e:integ8}, we denote $\tilde {\cal E}$ the set of $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p}$ such that
\begin{enumerate}
\item$m_{ij}=m_{ji}\in \mathbb{Z}_{\geq 0}$ for $0\leq i,j\leq p-1$ and $2|m_{ii}$ for $0\leq i\leq p-1$.
\item $\sum_{i,j=0}^{p-1}m_{ij}=dn$, and $\sum_{i,j=0}^{p-1}(m_{ij}/(dn)-1/p^2)^2\leq {\mathfrak b}\ln n/n$.
\end{enumerate}
The set ${\cal E}$ is a subset of $\tilde {\cal E}$ with the extra constraints: $\sum_{j=0}^{p-1}m_{ij}\equiv 0\Mod d$, and $\sum_{j=0}^{p-1}jm_{ij}\equiv 0 \Mod p$ for $i=0,1,\cdots, p-1$. In the following we prove that the sum over the set ${\cal E}$ in \eqref{e:explclt} can be replaced by the sum over the set $\tilde {\cal E}$ with a negligible error. We concentrate on the case $p$ is odd, and remark the modification for $p=2$ case later.

By our assumption $\gcd (p,d)=1$, for any vectors ${\bm{r}}=(r_0,r_1,\cdots, r_{p-1})\in \{0,1,\cdots,d-1\}^{p}$ with $r_0+r_1+\cdots+r_{p-1}\equiv 0 \Mod d$, and $\bm s=(s_0,s_1,\cdots, s_{p-1})\in \{0,1,\cdots, p-1\}^p$, there exists a $p\times p$ matrix $[\Delta m^{({\bm{r}}, \bm s)}_{ij}]_{0\leq i,j\leq p-1}$ with entries size $\OO(p)$ (not unique), such that
\begin{enumerate}
\item$\Delta m^{({\bm{r}}, \bm s)}_{ij}=\Delta m^{({\bm{r}},\bm s)}_{ji}\in \mathbb{Z}_{\geq 0}$ for $0\leq i,j\leq p-1$ and $2|\Delta m^{({\bm{r}},\bm s)}_{ii}$ for $0\leq i\leq p-1$.
\item $\sum_{i,j=0}^{p-1}\Delta m^{({\bm{r}},\bm s)}_{ij}=0$.
\item
$\sum_{j=0}^{p-1}\Delta m^{({\bm{r}},\bm s)}_{ij}\equiv r_i\Mod d$, $\sum_{j=0}^{p-1}j\Delta m_{ij}^{({\bm{r}},\bm s)}\equiv s_i \Mod p$, for $i=0,1,\cdots, p-1$.
\end{enumerate}
For the term on the righthand side of \eqref{e:integ8} corresponding to $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal E}$, we can rewrite it as an average of terms corresponding to $M^{({\bm{r}}, \bm s)}=[m^{({\bm{r}},\bm s)}_{ij}\deq m_{ij}+\Delta m_{ij}^{({\bm{r}}, \bm s)}]_{0\leq i,j\leq p-1}\in \tilde {\cal E}$, for ${\bm{r}}=(r_0,r_1,\cdots, r_{p-1})\in \{0,1,\cdots,d-1\}^{p}$ with $r_0+r_1+\cdots+r_{p-1}\equiv 0 \Mod d$, and $\bm s=(s_0,s_1,\cdots, s_{p-1})\in \{0,1,\cdots, p-1\}^p$,
\begin{align}\begin{split}\label{e:sumtE0}
&\phantom{{}={}}d^{p-1}p^p\left(1+\OO\left(\frac{p^4(\ln n)^{1/2}}{n^{1/2}}\right)\right)e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left(\frac{m_{ij}}{dn}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left(\frac{n_i}{n}-\frac{1}{p}\right)^2}\\
&=\sum_{{\bm{r}}\in \{0,1,\cdots, d-1\}^p\atop \sum_{i=0}^{p-1}r_i\equiv 0\Mod d}
\sum_{\bm s\in \{0,1,\cdots, p-1\}^p}
e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left(\frac{m_{ij}^{({\bm{r}},\bm s)}}{dn}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left(\frac{n_i^{({\bm{r}},\bm s)}}{n}-\frac{1}{p}\right)^2},
\end{split}\end{align}
where $n_i^{({\bm{r}},\bm s)}=\sum_{j=0}^{p-1}m_{ij}^{({\bm{r}},\bm s)}$, for $i=0,1,\cdots, p-1$. We sum \eqref{e:sumtE0} over all the $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in{\cal E}$, and get
\begin{align}\begin{split}\label{e:sumtE}
&\phantom{{}={}}d^{p-1}p^p\sum_{M\in {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{1/2}}{n^{1/2}}\right)\right)\sum_{M\in \tilde {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}.
\end{split}\end{align}

We remark that if $p=2$, we have instead that
\begin{align*}\begin{split}
&\phantom{{}={}}d^{p-1}p^{p-1}\sum_{M\in {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{1/2}}{n^{1/2}}\right)\right)\sum_{M\in \tilde {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2},
\end{split}\end{align*}
which differs from \eqref{e:sumtE} by a factor of $2$. As a consequence, this leads to $
\sum_{{\bm{v}}\in {\mathbb F}_p^n\setminus{\bm0}}|\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|= (2+\oo(1))|\mathsf{G}_{n,d}|
$.

In the following we estimate the sum in \eqref{e:sumtE}. The set of points $[m_{ij}/dn-1/p^2]_{0\leq i,j\leq p-1}$ for $M=[m_{ij}]_{0\leq i,j\leq p-1}\in \tilde {\cal E}$ is a subset of a lattice in ${\rm Sym}_p^0$, the Hilbert space of $p\times p$ real symmetric matrices with total sum zero, and inner product $\langle A, B\rangle=\Tr AB$. A set of base for this lattice is given by
\begin{align*}
(e_{ij}+e_{ji}-2e_{00})/dn, \quad 0\leq i<j\leq p-1, \quad (2e_{ii}-2e_{00})/dn, \quad 1\leq i\leq p-1.
\end{align*}
The volume of the fundamental domain is $2^{(p^2+3p-4)/4}p(dn)^{-(p^2+p-2)/2}$. By viewing \eqref{e:sumtE} as a Riemann sum, we can rewrite it as an integral on the space ${\rm Sym}_p^0$.
\begin{align}
\begin{split}\label{e:gaussianI}
&\phantom{{}={}}2^{(p^2+3p-4)/4}p(dn)^{-(p^2+p-2)/2}\sum_{M\in \tilde {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{1/2}}{n^{1/2}}\right)\right)
\int_{A\in {\rm Sym}_p^0:\|A\|_2^2\leq {\mathfrak b}\ln n/n}e^{-\frac{dnp^2}{4}\Tr A^2+\frac{(d-1)np}{2}\bm1^t A^2 \bm1}{\rm d} \vol(A).
\end{split}
\end{align}
We can rewrite the exponent as a quadratic form on the space ${\rm Sym}_p^{0}$,
\begin{align*}
-dnp^2\Tr A^2/4+(d-1)np\bm1^t A^2 \bm1/2
=\langle A, {\cal L}(A)\rangle,
\end{align*}
where the self-adjoint operator ${\cal L}: {\rm Sym}_p^0\mapsto {\rm Sym}_p^0$ is given by ${\cal L}(A)=-dnp^2A/4+(d-1)npA \bm1\bm1^t/4+(d-1)np\bm 1\bm1^tA /4$. The self-adjoint operator ${\cal L}$ is diagonalized by
\begin{enumerate}
\item If $A\in{\rm Sym}_p^0$, with row sums and column sums zero, then ${\cal L}(A)=(-dnp^2/4)A$. The total dimension of such matrices is $p(p-1)/2$.
\item If $A=[a_i+a_j]_{0\leq i,j\leq p-1}$ for some vector ${\bm{a}}=(a_0,a_1,\cdots, a_{p-1})\in {\mathbb R}^{p}$ with $a_0+a_1+\cdots+a_{p-1}=0$, then ${\cal L}(A)=(-np^2/4)A$. The total dimension of such matrices is $p-1$.
\end{enumerate}
From the discussion above, using the eigenvectors of the self-adjoint operator ${\cal L}$ as a base, the integral \eqref{e:gaussianI} decomposes into a product of Gaussian integrals, which can be estimated explicitly.
\begin{align}\begin{split}\label{e:integral}
&\phantom{{}={}}\int_{A\in {\rm Sym}_p^0:\|A\|_2^2\leq {\mathfrak b}\ln n/n}e^{-\frac{dnp^2}{4}\Tr A^2+\frac{(d-1)np}{2}\bm1^t A^2 \bm1}{\rm d} \vol(A)\\
&=\int_{A\in {\rm Sym}_p^0}e^{-\frac{dnp^2}{4}\Tr A^2+\frac{(d-1)np}{2}\bm1^t A^2 \bm1}{\rm d} \vol(A)+\OO\left(e^{-\left(\frac{{\mathfrak b}}{4}+\oo(1)\right)p^2\ln n}\right)\\
&=\left(\frac{4\pi}{dnp^2}\right)^{(p^2-p)/4}\left(\frac{4\pi}{np^2}\right)^{(p-1)/2}+\OO\left(e^{-\left(\frac{{\mathfrak b}}{4}+\oo(1)\right)p^2\ln n}\right).
\end{split}\end{align}
We can estimate the total contribution in \eqref{e:equ} from the second term on the righthand side of \eqref{e:integ8}, by combining the estimates \eqref{e:sumtE}, \eqref{e:gaussianI} and \eqref{e:integral}
\begin{align}\begin{split}\label{e:secondterm}
&\phantom{{}={}}\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)\frac{2^{(p-1)/2}p^{(p^2+3p)/2}}{d^{(p^2-p)/4}(2\pi n)^{(p^2+p-2)/4}}
\sum_{M\in {\cal E}}e^{-\frac{dnp^2}{4}\sum_{i,j=0}^{p-1}\left({\mathfrak m}_{ij}-\frac{1}{p^2}\right)^2+\frac{(d-1)np}{2}\sum_{j=0}^{p-1}\left({\mathfrak n}_j-\frac{1}{p}\right)^2}\\
&=\left(1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right)\right)
+\OO\left(e^{-\left(\frac{{\mathfrak b}}{4}+\oo(1)\right)p^2\ln n+\frac{p^2+p-2}{4}\ln (np^2)}\right)
=1+\OO\left(\frac{p^4(\ln n)^{3/2}}{n^{1/2}}\right),
\end{split}\end{align}
provided ${\mathfrak b}$ is large enough. Proposition \ref{p:lclt} follows from combining \eqref{e:firstterm} and \eqref{e:secondterm}.
\end{proof}

\subsection{Large deviation estimate}
\label{subs:ldp}

In this section, we show that the sum of terms in \eqref{e:keyest} corresponding to non-equidistributed $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}$ is small.
\begin{proposition}\label{p:ldp}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$ and $p\ll n^{(d-2)/(5d-6)}$. Then for $n$ sufficiently large,
\begin{align}\label{e:noneq}
\frac{1}{|\mathsf{G}_{n,d}|}\sum_{M \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\leq \frac{\OO(p^{2d})}{n^{(d-2)}}.
\end{align}
\end{proposition}
Thanks to Proposition \ref{p:walkrepu}, we have
\begin{align}\begin{split}\label{e:expldp}
&\phantom{{}={}}\frac{1}{|\mathsf{G}_{n,d}|}\sum_{M \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&=\frac{2^{nd/2}(nd/2)!}{(nd)!}\sum_{M\in {\cal N}}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
& \phantom{{}={}}\times p^{(d-1)n}\prod_{i=0}^{p-1}\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))
\end{split}\end{align}
where $X_1,X_2,\cdots, X_{n_i}$ are independent copies of $X$, which is uniform distributed over ${\mathcal U}_{d,p}$ as defined in \eqref{e:defcU}.
In the rest of the proof, we simply write $n_i(M)$ as $n_i$ for $0\leq i\leq p-1$. For an non-equidistributed $p\times p$ symmetric matrix $M=[m_{ij}]_{0\leq i,j\leq p-1}$, we denote ${\mathfrak m}_{ij}=m_{ij}/(dn)$ for $i,j=0,1,\cdots, p-1$, and ${\mathfrak n}_i=n_i/n$ for $i=0,1,\cdots, p-1$. Then we have ${\mathfrak n}_i=\sum_{j=0}^{p-1}{\mathfrak m}_{ij}$ for $i=0,1,\cdots, p-1$. Moreover, by our definition of non-equidistributed,
$\sum_{i,j=0}^{p-1}({\mathfrak m}_{ij}-1/p^2)^2\geq {\mathfrak b}\ln n/n$. We estimate the first factor on the righthand side of \eqref{e:expldp} using Stirling's formula,
\begin{align}\begin{split}\label{e:firstfactor2}
&\phantom{{}={}}\frac{2^{nd/2}(nd/2)!}{(nd)!}{n\choose n_0,n_1,\cdots, n_{p-1}}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
&\leq e^{\OO(p^2\ln n)}
\exp\left\{\frac{dn}{2}\sum_{i,j=0}^{p-1}{{\mathfrak m}_{ij}}\ln {\mathfrak m}_{ij}-n\sum_{j=0}^{p-1}{\mathfrak n}_j\ln {\mathfrak n}_j \right\}.
\end{split}\end{align}
For the random walk term in \eqref{e:expldp}, we have the following large deviation bound
\begin{align*}
\mathbb{P}(X_1+X_2+\cdots+X_{n_i}=(m_{i0},m_{i1},\cdots, m_{ip-1}))
\leq \exp\left\{n\inf_{\bmt_i\in {\mathbb R}^p} {\mathfrak n}_i\log \mathbb{E}[e^{\langle \bmt_i, X\rangle}]-d\langle \bmt_i, \bm{\mathfrak m}_i\rangle\right\},
\end{align*}
where ${\mathfrak m}_i=({\mathfrak m}_{i0}, {\mathfrak m}_{i1},\cdots, {\mathfrak m}_{ip-1})$.
Thus we get that
\begin{align*}
\begin{split}
&\phantom{{}={}}\frac{1}{|\mathsf{G}_{n,d}|}\sum_{M \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))} |\{{\cal G}\in \mathsf{G}_{n,d}: A({\cal G}){\bm{v}}=\bm0\}|\\
&\leq
\sum_{M \in {\cal N}}\sum_{{\bm{v}}\in {\mathcal S}(n_0(M),n_1(M),\cdots, n_{p-1}(M))}
e^{\OO(p^2\ln n)}e^{nI({\mathfrak m}_0,{\mathfrak m}_1, \cdots, {\mathfrak m}_{p-1})}
\end{split}\end{align*}
where the rate function is given by
\begin{align}
\begin{split}\label{e:ratefu}
I({\mathfrak m}_0,{\mathfrak m}_1, \cdots, {\mathfrak m}_{p-1})
&=
(d-1)\ln p+\frac{d}{2}\sum_{i,j=0}^{p-1}{{\mathfrak m}_{ij}}\ln {\mathfrak m}_{ij}-\sum_{j=0}^{p-1}{\mathfrak n}_j\ln {\mathfrak n}_j\\
&+\sum_{j=0}^{p-1}\inf_{\bmt_j\in {\mathbb R}^p} {\mathfrak n}_j\log \mathbb{E}[e^{\langle \bmt_j, X\rangle}]-d\langle \bmt_j, \bm{\mathfrak m}_j\rangle.
\end{split}\end{align}

\begin{proposition}\label{p:ldpboundu}
Let $d\geq 3$ be a fixed integer, and a prime number $p$ such that $\gcd(p,d)=1$. The rate function as defined in \eqref{e:ratefu} satisfies: for any small $\delta> 0$, there exists a constant $c(\delta)>0$, such that
\begin{align}\label{e:rateboundu}
I({\mathfrak m}_0, {\mathfrak m}_1,\cdots, {\mathfrak m}_{p-1})\leq -\frac{c(\delta)}{p^2},
\end{align}
unless
$ \max_{0\leq i,j\leq p-1}|{\mathfrak m}_{ij}-1/p^2|\leq \delta/p^2$, or
${\mathfrak m}_{00}\geq 1-\delta/p$.
\end{proposition}

\begin{proof}
We take $\bmt_j=(d-1)/d((\ln ({\mathfrak m}_{j0}/{\mathfrak n}_j), \ln ({\mathfrak m}_{j1}/{\mathfrak n}_j),\cdots, \ln ({\mathfrak m}_{j p-1}/{\mathfrak n}_j))+\ln p)$ in \eqref{e:ratefu}, the rate function $I$ is upper bounded by
\begin{align}\begin{split}\label{e:sharprateu}
I({\mathfrak m}_0,{\mathfrak m}_1, \cdots, {\mathfrak m}_{p-1})
&\leq \frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}.
\end{split}\end{align}
In the following, we prove that there exists a constant $c(\delta)$
\begin{align}\label{e:ratebound2u}
\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}\leq -\frac{c(\delta)}{p^2},
\end{align}
unless $ \max_{0\leq i,j\leq p-1}|{\mathfrak m}_{ij}-1/p^2|\leq \delta/p^2$, or
${\mathfrak m}_{00}\geq 1-\delta/p$. Then the claim \eqref{e:rateboundu} follows.

Thanks to Proposition \ref{p:ldpbound}, for any ${\mathfrak n}_i>0$ and $\varepsilon>0$ sufficiently small,
\begin{align}\label{e:ldpboundcopy}
\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}\leq -\frac{c(\varepsilon)}{p},
\end{align}
unless $ \max_{0\leq k\leq p-1}|{\mathfrak m}_{ik}/{\mathfrak n}_i-1/p|\leq \varepsilon/p$, or
${\mathfrak m}_{i0}/{\mathfrak n}_i\geq 1-\varepsilon/p$. We decompose $\{0,1,\cdots, p-1\}=I_1\cup I_2\cup I_3$, where
\begin{align}\begin{split}\label{e:decompose}
&I_1=\{0\leq i\leq p-1: \max_{0\leq k\leq p-1}|{\mathfrak m}_{ik}/{\mathfrak n}_i-1/p|\leq \varepsilon/p\},\\
&I_2=\{0\leq i\leq p-1: {\mathfrak m}_{i0}/{\mathfrak n}_i\geq 1-\varepsilon/p\}, \quad I_3=\{0,1,\cdots, p-1\}\setminus (I_1\cup I_2).
\end{split}\end{align}
Thanks to \eqref{e:ldpboundcopy}, we have
\begin{align*}
\sum_{i\in I_3}{\mathfrak n}_i \log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}\leq -\frac{c(\varepsilon)}{p}\sum_{i\in I_3}{\mathfrak n}_i.
\end{align*}
Therefore, if $\sum_{i\in I_3}{\mathfrak n}_i\geq \varepsilon/p$ then \eqref{e:ratebound2u} holds. In the following we assume that $\sum_{i\in I_3}{\mathfrak n}_i\leq \varepsilon/p$. There are several cases:
\begin{enumerate}
\item $I_2=\emptyset$: From the discussion above, we have $\sum_{i\in I_3}{\mathfrak n}_i\leq \varepsilon/p$ and $\sum_{i\in I_1}{\mathfrak n}_i\geq 1-\varepsilon/p$. If $I_3\neq \emptyset$, we fix any $k\in I_3$. By the definition of $I_1$, we have $\sum_{i\in I_1}{\mathfrak n}_i\leq \sum_{i\in I_1}p{\mathfrak m}_{ik}/(1-\varepsilon)\leq p{\mathfrak n}_k/(1-\varepsilon)\leq \varepsilon/(1-\varepsilon)$, which leads to a contradiction. Therefore $I_3=\emptyset$ and $I_1=\{0,1,2,\cdots,p-1\}$. Then for any ${\mathfrak m}_{ij}$ and ${\mathfrak m}_{i'j'}$, we have
\begin{align*}
{\mathfrak m}_{ij}\leq \frac{1+\varepsilon}{1-\varepsilon}{\mathfrak m}_{ii'}=\frac{1+\varepsilon}{1-\varepsilon}{\mathfrak m}_{i'i}\leq \frac{(1+\varepsilon)^2}{(1-\varepsilon)^2}{\mathfrak m}_{i'j'}.
\end{align*}
It follows that $|{\mathfrak m}_{ij}-1/p^2|\leq \delta/p^2$ by taking $4\varepsilon/(1-\varepsilon)^2
\leq \delta$.

\item $I_2\neq \emptyset$:
Thanks to \eqref{e:midbound}, if $i\in I_2$,
\begin{align*}\begin{split}
&\phantom{{}={}}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
\leq -(1+\oo(1))(d-1){\mathfrak n}_i\left(1-\frac{{\mathfrak m}_{i0}}{{\mathfrak n}_i}\right)\\
&=-(1+\oo(1))(d-1)\left({\mathfrak n}_i-{\mathfrak m}_{i0}\right)=-(1+\oo(1))(d-1)\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}.
\end{split}\end{align*}
Therefore, if $\sum_{i\in I_2}\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}\geq \varepsilon/p^2$ then we have that \eqref{e:ratebound2u} holds. In the following, we assume $\sum_{i\in I_2}\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}\leq \varepsilon/p^2$. There are several cases.
\begin{enumerate}
\item $0\in I_1$: By the definition of $I_1$, for any $0\leq k\leq p-1$, we have
\begin{align*}
(1-\varepsilon){\mathfrak n}_0/p\leq{\mathfrak m}_{k0}={\mathfrak m}_{0k}\leq (1+\varepsilon){\mathfrak n}_0/p.
\end{align*}
Fix any $j\in I_2$. Again by the definition of $I_1$, $\sum_{i\in I_1\setminus\{0\}}{\mathfrak n}_i\leq \sum_{i\in I_1\setminus\{0\}}p{\mathfrak m}_{ij}/(1-\varepsilon/p)=\sum_{i\in I_1\setminus\{0\}}p{\mathfrak m}_{ji}/(1-\varepsilon/p)\leq \varepsilon/(p-\varepsilon)$. Therefore, $\sum_{1\leq i,k\leq p-1}{\mathfrak m}_{ik}\leq \sum_{i\in I_3}{\mathfrak n}_i+\sum_{i\in I_1\setminus\{0\}}{\mathfrak n}_i+\sum_{i\in I_2}\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}\leq \varepsilon/p+\varepsilon/(p-\varepsilon)+\varepsilon/p^2=\OO(\varepsilon)/p$. As a consequence, we get ${\mathfrak m}_{0k}={\mathfrak m}_{k0}=(1+\OO(\varepsilon))/(2p-1)$, for any $0\leq k\leq p-1$, and ${\mathfrak n}_0=(1+\OO(\varepsilon))p/(2p-1)$ and ${\mathfrak n}_k=(1+\OO(\varepsilon))/(2p-1)$ for $1\leq k\leq p-1$. In this case, the first term on the lefthand side of \eqref{e:ratebound2u} is small
\begin{align*}
\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}\leq (1+\OO(\varepsilon))\frac{d-2}{2}\left(\frac{\ln p}{2p-1}+\ln \frac{p}{2p-1}\right)+\OO\left(\frac{\varepsilon}{p}\ln \frac{\varepsilon}{p}\right),
\end{align*}
and \eqref{e:ratebound2u} holds.

\item $0\in I_2$: By the definition of $I_2$, we have $\sum_{i\in I_2\setminus\{0\}}{\mathfrak n}_i\leq \sum_{i\in I_2\setminus\{0\}}{\mathfrak m}_{i0}/(1-\varepsilon/p)\leq \sum_{1\leq k\leq p-1}{\mathfrak m}_{0k}/(1-\varepsilon/p)\leq \varepsilon/p(p-\varepsilon)$. By the definition of $I_1$, we have $\sum_{i\in I_1}{\mathfrak n}_i\leq \sum_{i\in I_1}p{\mathfrak m}_{i0}/(1-\varepsilon)\leq \sum_{1\leq k\leq p-1}p{\mathfrak m}_{0k}/(1-\varepsilon)\leq \varepsilon/p(1-\varepsilon)$. Combining the discussion above, we get
\begin{align*}\begin{split}
{\mathfrak m}_{00}
&\geq {\mathfrak n}_{0}-\varepsilon/p^2=1-\sum_{k=1}^{p-1}{\mathfrak n}_k-\varepsilon/p^2\\
&\geq 1-\varepsilon/p(p-\varepsilon)-\varepsilon/p(1-\varepsilon)-\varepsilon/p-\varepsilon/p^2.
\end{split}\end{align*}
It follows that ${\mathfrak m}_{00}\geq 1-\delta/p$ by taking $4\varepsilon/(1-\varepsilon)\leq \delta$.
\item $0\in I_3$: By the definition of $I_1$, we have $\sum_{i\in I_1}{\mathfrak n}_i\leq \sum_{i\in I_1}p{\mathfrak m}_{i0}/(1-\varepsilon)\leq \sum_{1\leq k\leq p-1}p{\mathfrak m}_{0k}/(1-\varepsilon)\leq p{\mathfrak n}_0/(1-\varepsilon)\leq \varepsilon/(1-\varepsilon)$. However, we also know that $\sum_{i\in I_3}{\mathfrak n}_i\leq \varepsilon/p$ and $\sum_{i\in I_2}\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}\leq \varepsilon/p^2$. This contradicts to the fact $\sum_{0\leq i\leq p-1}{\mathfrak n}_i=1$.

\end{enumerate}

\end{enumerate}

\end{proof}

\begin{proof}[Proof of Proposition \ref{p:ldp}]
We further decompose the set of non-equidistributed $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}$ into four classes:
\begin{enumerate}
\item $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal N}$ with $\max_{0\leq i,j\leq p-1}|m_{ij}/(dn)-1/p^2|\leq \delta/p^2$.
\item  $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal N}$ with ${\mathfrak b} p^3\ln n/n<|m_{00}/(dn)-1|\leq \delta/p$.
\item  $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}\in {\cal N}$ with $|m_{00}/(dn)-1|\leq {\mathfrak b} p^3\ln n/n$.
\item The remaining non-equidistributed  $p\times p$ symmetric matrices.
\end{enumerate}

For the first class, $\max_{0\leq i,j\leq p-1}|m_{ij}/(dn)-1/p^2|\leq \delta/p^2$. The total number of such $p\times p$ symmetric matrices is $e^{\OO(p^2\ln n)}$.
Given a $p\times p$ symmetric matrix $M=[m_{ij}]_{0\leq i,j\leq p-1}$ in the first class,
we will derive a more precise estimate of \eqref{e:ratebound2u}, by a perturbation argument. Let
\begin{align*}\begin{split}
&{\mathfrak m}_{ij}=(1+\delta_{ij})/p^2,\quad i=0,1,\cdots, p-1, \quad j=0,1,\cdots, p-1.
\end{split}\end{align*}
where $\delta_{ij}=\delta_{ji}$ for $0\leq i<j\leq p-1$, $\sum_{i,j=0}^{p-1}\delta_{ij}=0$, $\max_{0\leq i,j\leq p-1}|\delta_{ij}|\leq \delta$, and $\sum_{ij}\delta_{ij}^2\geq {\mathfrak b} p^4 \ln n/n$. We denote,
\begin{align}\label{e:constraint2}
{\mathfrak n}_i=\sum_{j=0}^{p-1}{\mathfrak m}_{ij}=(1+\delta_i)/p,\quad \delta_i=\sum_{j=0}^{p-1}\delta_{ij}/p.
\end{align}
We use Taylor expansion, and rewrite the first term in \eqref{e:sharprateu} as
\begin{align}\begin{split}\label{e:t1}
\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}
&=(d-2)\sum_{i=0}^{p-1}{\mathfrak n}_{i}\ln {\mathfrak n}_i
-\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln {\mathfrak m}_{ij}\\
&=(d-2)\sum_{i=0}^{p-1}\frac{1+\delta_i}{p}\ln\frac{1+\delta_i}{p}
-\frac{d-2}{2}\sum_{i,j=0}^{p-1}\frac{1+\delta_{ij}}{p^2}\ln \frac{1+\delta_{ij}}
{p^2}\\
&=(1+\OO(\delta))\left(\frac{d-2}{2p}\sum_{i=0}^{p-1}\delta_i^2-\frac{d-2}{4p^2}\sum_{i,j=0}^{p-1}\delta_{ij}^2\right).
\end{split}\end{align}
For the second term in \eqref{e:sharprateu}, similar to \eqref{e:sumexp} we have
\begin{align*}\begin{split}
&\phantom{{}={}}\log \frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak m}_{ik}^{\frac{d-1}{d}{\bm{w}}_j(k)}=\log \frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}e^{\frac{d-1}{d}{\bm{w}}_j(k)\ln(1+\delta_{ik})}\\
&=\log \frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}e^{\frac{d-1}{d}\sum_{k=0}^{p-1}{\bm{w}}_j(k)\left(\delta_{ik}-(1+\OO(\delta)\frac{\delta_{ik}^2}{2}\right)}\\
&=\log \frac{1}{p^{d-1}}\sum_{j=1}^{p^{d-1}}1+\frac{d-1}{d}\sum_{k=0}^{p-1}{\bm{w}}_j(k)\left(\delta_{ik}-(1+\OO(\delta)\frac{\delta_{ik}^2}{2}\right)+(1+\OO(\delta))\frac{(d-1)^2}{2d^2}\left(\sum_{k=0}^{p-1}{\bm{w}}_j(k)\delta_{ik}\right)^2
\\
&=\log 1+(d-1)\delta_i-(1+\OO(\delta))\frac{d-1}{2p}\sum_{k=0}^{p-1}\delta_{ik}^2+\frac{1+\OO(\delta)}{p^{d-1}}\frac{(d-1)^2}{2d^2}\sum_{j=1}^{p^{d-1}}\left(\sum_{k=0}^{p-1}{\bm{w}}_j(k)\delta_{ik}\right)^2\\
&=(d-1)\delta_i-(1+\OO(\delta))\frac{d-1}{2p}\sum_{k=0}^{p-1}\delta_{ik}^2+\frac{1+\OO(\delta)}{p^{d-1}}\frac{(d-1)^2}{2d^2}\sum_{j=1}^{p^{d-1}}\left(\sum_{k=0}^{p-1}{\bm{w}}_j(k)\delta_{ik}\right)^2-\frac{(d-1)^2}{2}\delta_i^2.
\end{split}\end{align*}
We can rewrite the second term in \eqref{e:sharprateu} as
\begin{align}\begin{split}\label{e:t2}
&\phantom{{}={}}\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
=-(d-1)\sum_{i=0}^{p-1}{\mathfrak n}_i\log {\mathfrak n}_i+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}{\mathfrak m}_{ik}^{\frac{d-1}{d}{\bm{w}}_j(k)}\\
&=-(d-1)\sum_{i=0}^{p-1}\frac{1+\delta_i}{p}\log \frac{1+\delta_i}{p}+\sum_{i=0}^{p-1}\frac{1+\delta_i}{p}\log \frac{1}{p^{2(d-1)}}\sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}e^{\frac{d-1}{d}{\bm{w}}_j(k)\ln(1+\delta_{ik})}\\
&=(1+\OO(\delta))\left(-\frac{d^2-3d+2}{2p}\sum_{i=0}^{p-1}\delta_i^2-\frac{d-1}{2p^2}\sum_{i,k=0}^{p-1}\delta_{ik}^2+\frac{1}{p^d}\frac{(d-1)^2}{2d^2}\sum_{i=0}^{p-1}\sum_{j=1}^{p^{d-1}}\left(\sum_{k=0}^{p-1}{\bm{w}}_j(k)\delta_{ik}\right)^2\right).
\end{split}\end{align}
We get the following estimate of \eqref{e:sharprateu} by combining \eqref{e:t1} and \eqref{e:t2},
\begin{align}\begin{split}\label{e:simple}
&\phantom{{}={}}\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}\\
&=(1+\OO(\delta))\left(-\frac{(d-2)^2}{2p}\sum_{i=0}^{p-1}\delta_i^2-\frac{3d-4}{4p^2}\sum_{i,k=0}^{p-1}\delta_{ik}^2+\frac{1}{p^d}\frac{(d-1)^2}{2d^2}\sum_{i=0}^{p-1}\sum_{j=1}^{p^{d-1}}\left(\sum_{k=0}^{p-1}{\bm{w}}_j(k)\delta_{ik}\right)^2\right).
\end{split}\end{align}
We denote the $p\times p^{d-1}$ matrix $W=[{\bm{w}}_1,{\bm{w}}_2,\cdots, {\bm{w}}_{p^{d-1}}]$ and $p\times p$ matrix $\bm\delta=[\delta_{ij}]_{0\leq i,j\leq p-1}$. Then $\bm \delta \in {\rm Sym}_p^0$, the Hilbert space of $p\times p$ real symmetric matrices with total sum zero, and inner product $\langle A, B\rangle=\Tr AB$. We can rewrite \eqref{e:simple} as a quadratic form on the space ${\rm Sym}_p^{0}$
\begin{align}\begin{split}\label{e:constraint3u}
&\phantom{{}={}}\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}\\
&=(1+\OO(\delta))\left(-\frac{(d-2)^2}{2p^3}\langle \bm\delta, \bm1 \bm1^t \bm\delta\rangle-\frac{3d-4}{4p^2}\langle \bm\delta, \bm\delta\rangle+\frac{1}{p^d}\frac{(d-1)^2}{2d^2}\langle \bm\delta, WW^t \bm\delta\rangle\right)\\
&=(1+\OO(\delta))\left(\frac{d^2-d-1}{2dp^3}\langle \bm\delta, \bm1 \bm1^t \bm\delta\rangle-\frac{d^2-2}{4dp^2}\langle \bm\delta, \bm\delta\rangle\right),
\end{split}\end{align}
where we used \eqref{e:cov},
\begin{align*}
WW^t=dp^{d-2}I_{p}+d(d-1)p^{d-3}\bm1\bm1^t.
\end{align*}
We can rewrite the first term in \eqref{e:constraint3u} as $\langle \bm\delta, \bm1 \bm1^t\bm\delta\rangle=\langle \bm\delta, {\cal L}(\bm\delta)\rangle$ where  the self-adjoint operator ${\cal L}: {\rm Sym}_p^0\mapsto {\rm Sym}_p^0$ is given by  ${\cal L}(\bm\delta)=\bm1\bm1^t \bm \delta/2+\bm\delta \bm1\bm1^t /2$.
The self-adjoint operator ${\cal L}$ is diagonalized by
\begin{enumerate}
\item If $\bm\delta\in{\rm Sym}_p^0$, with row sums and column sums zero, then ${\cal L}(\bm\delta)=\bm0$. The total dimension of such matrices is $p(p-1)/2$.
\item If $\bm\delta=[a_i+a_j]_{0\leq i,j\leq p-1}$ for some vector ${\bm{a}}=(a_0,a_1,\cdots, a_{p-1})\in {\mathbb R}^{p}$ with $a_0+a_1+\cdots+a_{p-1}=0$, then ${\cal L}(\bm\delta)=p\bm\delta/2$. The total dimension of such matrices is $p-1$.
\end{enumerate}
It follows from the spectral decomposition of the self-adjoint operator ${\cal L}$, we get
\begin{align*}
\langle \bm\delta, \bm1\bm1^t\bm\delta\rangle=\langle \bm\delta, {\cal L}(\bm\delta)\rangle\leq p\langle \bm\delta,\bm\delta\rangle/2,
\end{align*}
and
\begin{align*}
&\phantom{{}={}}\frac{d-2}{2}\sum_{i,j=0}^{p-1}{\mathfrak m}_{ij}\ln \frac{{\mathfrak n}_i{\mathfrak n}_j}{{\mathfrak m}_{ij}}+\sum_{i=0}^{p-1}{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
\leq -(1+\OO(\delta))\frac{d-1}{4dp^2}\langle \bm\delta,\bm\delta\rangle.
\end{align*}
The total contribution of terms in \eqref{e:noneq} satisfying $\max_{0\leq i,j\leq p-1}|m_{ij}/(dn)-1/p^2|\leq \delta/p^2$ is bounded by
\begin{align}\label{e:case1}
\exp\left\{-\left(\frac{{\mathfrak b} (d-1)}{4d}+\oo(1)\right)p^2\ln n+\OO(p^2\ln n)\right\}=\frac{\oo(1)}{n^{(d-2)}},
\end{align}
provided that we take ${\mathfrak b}$ sufficiently large.

For the second class, ${\mathfrak b} p^3\ln n/n<|m_{00}/(dn)-1|\leq \delta/p$. The total number of such $p\times p$ symmetric matrices is $e^{\OO(p^2\ln n)}$. Given a $p\times p$ symmetric matrix $M=[m_{ij}]_{0\leq i,j\leq p-1}$ in the second class, we will derive a more precise estimate of \eqref{e:ratebound2u}, by a perturbative argument. Let ${\mathfrak m}_{00}=1-\delta_{00}$, where $\delta_{00}\leq \delta/p$.
We recall the decomposition $\{0,1,2,\cdots, p-1\}=I_1\cup I_2\cup I_3$ from \eqref{e:decompose}. If $0\in I_3$, then
\begin{align*}
{\mathfrak n}_0\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{0k}}{{\mathfrak n}_0}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
\leq -\frac{(1-\delta_{00})c(\varepsilon)}{p}.
\end{align*}
Otherwise, $0\in I_2$. Similar argument as in the proof of Proposition \ref{p:ldpboundu}, we have
\begin{align}\label{e:i2i31}
\sum_{i\in I_2\cup I_3}
{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
\leq -(1+\oo(1))(d-1)\sum_{i\in I_2}\sum_{1\leq k\leq p-1}{\mathfrak m}_{ik}-\frac{c(\varepsilon)}{p}\sum_{i\in I_3}{\mathfrak n}_i.
\end{align}
Moreover, by the definition of the set $I_1$, we have $\sum_{i\in I_1}{\mathfrak n}_i\leq p/(1-\varepsilon)\sum_{i\in I_1}{\mathfrak m}_{i0}=p/(1-\varepsilon)\sum_{i\in I_1}{\mathfrak m}_{0i}$. Therefore,
\begin{align}\begin{split}\label{e:i2i32}
\delta_{00}=\sum_{0\leq i,j\leq p-1\atop (i,j)\neq (0,0)}{\mathfrak m}_{ij}
&\leq\sum_{i\in I_2\atop 1\leq k\leq p-1}{\mathfrak m}_{ik}+\sum_{i\in I_2\setminus\{0\}}{\mathfrak m}_{i0}+\frac{p}{1-\varepsilon}\sum_{i\in I_1}{\mathfrak m}_{0i}+\sum_{i\in I_3}{\mathfrak n}_i\\
&\leq \left(1+\frac{p}{1-\varepsilon}\right)\sum_{i\in I_2 \atop 1\leq k\leq p-1}{\mathfrak m}_{ik}+\sum_{i\in I_3}{\mathfrak n}_i.
\end{split}\end{align}
It follows from combining \eqref{e:i2i31} and \eqref{e:i2i32} we get
\begin{align*}
\sum_{i\in I_2\cup I_3}
{\mathfrak n}_i\log \sum_{j=1}^{p^{d-1}}\prod_{k=0}^{p-1}\left(\frac{{\mathfrak m}_{ik}}{{\mathfrak n}_i}\right)^{\frac{d-1}{d}{\bm{w}}_j(k)}
\leq -\frac{c(\varepsilon)\delta_{00}}{p}.
\end{align*}
Thus, the total contribution of terms in \eqref{e:noneq} satisfying ${\mathfrak b} p^3\ln n/n<|m_{00}/(dn)-1|\leq \delta/p$ is bounded by
\begin{align}\label{e:case2}
\exp\left\{-{\mathfrak b} c(\varepsilon)p^2\ln n+\OO(p^2\ln n)\right\}=\frac{\oo(1)}{n^{(d-2)}},
\end{align}
provided that we take ${\mathfrak b}$ sufficiently large.

For the third class, $|m_{00}/(dn)-1|\leq {\mathfrak b} p^3\ln n/n$. We denote
${\cal M}(r,\ell)\subset {\cal M}$ the set of $p\times p$ symmetric matrices $M=[m_{ij}]_{0\leq i,j\leq p-1}$ such that
$\ell=nd-m_{00}$, and $r=n-n_0(M)$. Then $\sum_{i=1}^{p-1}m_{0i}=\sum_{i=1}^{p-1} m_{i0}=\ell-dr$, and $\sum_{1\leq i,j\leq p-1}m_{ij}=2dr-\ell$. Especially, we have ${\cal M}(r,\ell)$ is nonempty only if $dr\leq \ell\leq 2dr$.
The total contribution of terms in \eqref{e:noneq} satisfying $|m_{00}/(dn)-1|\leq {\mathfrak b} p^3 \ln n/n$ is bounded by
\begin{align}\begin{split}\label{e:expldp3}
&\frac{2^{nd/2}(nd/2)!}{(nd)!}\sum_{2\leq r\leq {\mathfrak b} p^3\ln n/d\atop dr\leq\ell\leq 2dr}\sum_{M\in {\cal M}(r,\ell)}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
&\times\prod_{i=0}^{p-1}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_i(M)})\in {\mathcal U}_{d,p}^{n_i(M)}: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_{n_i(M)}=(m_{i0}, m_{i1},\cdots, m_{ip-1})\}|.
\end{split}\end{align}
We reestimate the first factor on the righthand side of \eqref{e:expldp3},
\begin{align}\begin{split}\label{e:expldp5}
&\phantom{{}={}}\frac{2^{nd/2}(nd/2)!}{(nd)!}{n\choose n_0(M),n_1(M),\cdots, n_{p-1}(M)}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=0}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}\\
&\leq\frac{e^{\OO(r)}}{n^{\ell/2-r}}
\frac{1}{n_1(M)!n_2(M)!\cdots n_{p-1}(M)!}\prod_{0\leq i<j\leq p-1}m_{ij}!\prod_{i=1}^{p-1}\frac{m_{ii}!}{2^{m_{ii}/2}(m_{ii}/2)!}.
\end{split}\end{align}
For the number of walk paths in \eqref{e:expldp3}, we notice that ${\bm{w}}_j(1)+{\bm{w}}_j(2)+\cdots {\bm{w}}_j(p-1)\geq 2$ for $2\leq j\leq p^{d-1}$. Moreover, we have ${\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_{n_0(M)}=(m_{00}, m_{01},\cdots, m_{0p-1})$, with $m_{01}+m_{02}+\cdots+m_{0p-1}=dn_{0}(M)-m_{00}=\ell-dr$. Therefore ${\bm{u}}_i={\bm{w}}_1$ for all $1\leq i\leq n_0(M)$, except for at most $(\ell-dr)/2$ of them. Therefore, we have
\begin{align}\begin{split}\label{e:pbound1}
&\phantom{{}={}}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_0(M)})\in {\mathcal U}_{d,p}^{n_0(M)}: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_{n_0(M)}=(m_{00}, m_{01},\cdots, m_{0p-1})\}|\\
&\leq \frac{(\ell-dr)!}{m_{01}! m_{02}!\cdots m_{0p-1}!} \sum_{k=1}^{(\ell-dr)/2}n^k{dm-k-1\choose k-1}\leq\OO(1)\frac{(\ell-dr)!}{m_{01}! m_{02}!\cdots m_{0p-1}!} n^{(\ell-dr)/2}.
\end{split}\end{align}
For the number of walk paths in \eqref{e:expldp3} corresponding to $i=1,2,\cdots, p-1$, we have the trivial bound
\begin{align}\begin{split}\label{e:pbound2}
&\phantom{{}={}}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_i(M)})\in {\mathcal U}_{d,p}^{n_i(M)}: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_{n_i(M)}=(m_{i0}, m_{i1},\cdots, m_{ip-1})\}|\\
&\leq \frac{(dn_i(M))!}{m_{i0}! m_{i1}!\cdots m_{ip-1}!}
\end{split}\end{align}
Combining the estimates \eqref{e:pbound1} and \eqref{e:pbound2}, we get the following bound on the number of walk paths in \eqref{e:expldp3},
\begin{align}\begin{split}\label{e:expldp6}
&\phantom{{}={}}\prod_{i=0}^{p-1}|\{({\bm{u}}_1,{\bm{u}}_2\cdots, {\bm{u}}_{n_i(M)})\in {\mathcal U}_{d,p}^{n_i(M)}: {\bm{u}}_1+{\bm{u}}_2+\cdots+{\bm{u}}_{n_i(M)}=(m_{i0}, m_{i1},\cdots, m_{ip-1})\}|\\
&\leq\OO(1) n^{(\ell-dr)/2}\frac{(\ell-dk)!}{m_{01}! m_{02}!\cdots m_{0p-1}!}
\prod_{i=1}^{p-1}\frac{(dn_i(M))!}{m_{i0}! m_{i1}!\cdots m_{ip-1}!}
.
\end{split}\end{align}
The total contribution of terms in \eqref{e:noneq} satisfying $|m_{00}/(dn)-1|\leq {\mathfrak b} p^3\ln n/n$ is bounded by
\begin{align}\begin{split}\label{e:case3}
&\phantom{{}={}}\sum_{2\leq r\leq {\mathfrak b} p^3\ln n/d\atop dr\leq\ell\leq 2dr}\sum_{M\in {\cal M}(r,\ell)}
\frac{e^{\OO(r)}(\ell-dr)!}{n^{(d/2-1)r}}
\prod_{i=1}^{p-1}\frac{(dn_i(M))!}{n_i(M)!}
\prod_{0\leq i<j\leq p-1}\frac{1}{m_{ij}!}\prod_{i=1}^{p-1}\frac{1}{2^{m_{ii}/2}(m_{ii}/2)!}\\
&\leq\sum_{2\leq r\leq {\mathfrak b} p^3\ln n/d\atop dr\leq\ell\leq 2dr}
\frac{e^{\OO(r)}(\ell-dr)!r^{(d-1)r}}{n^{(d/2-1)r}}
\sum_{M\in {\cal M}(r,\ell)}\prod_{i=1}^{p-1}\frac{1}{m_{i0}!}
\prod_{1\leq i\leq j\leq p-1}\frac{1}{(m_{ij}/(1+\delta_{ij}))!}\\
&\leq \sum_{2\leq r\leq {\mathfrak b} p^3\ln n/d\atop dr\leq \ell\leq 2dr }
\frac{e^{\OO(r)}r^{(d-1)r}}{n^{(d/2-1)r}}
\frac{p^{dr}}{(dr-\ell/2)!}\\
&\leq
\sum_{2\leq r\leq {\mathfrak b} p^3\ln n/d}
\left(\frac{\OO(1)p^d r^{(d/2-1)}}{n^{(d/2-1)}}\right)^r\leq \frac{\OO(1)p^{2d}}{n^{d-2}},
\end{split}\end{align}
provided that $p\ll n^{(d-2)/(5d-6)}$.

For the last class, the total number of such $p\times p$ symmetric matrices is $e^{\OO(p^2\ln n)}$, and thanks to Proposition \ref{p:ldpboundu}, each term is exponentially small, i.e. $e^{-c(\delta)n/p^2}$. Therefore the total contribution is
\begin{align}\label{e:case4}
\exp\{-c(\delta) n/p^2+\OO(p^2\ln n)\}=\frac{\oo(1)}{n^{(d-2)}}.
\end{align}

The claim \eqref{e:noneq} follows from combining the discussion of all four cases, \eqref{e:case1}, \eqref{e:case2}, \eqref{e:case3} and \eqref{e:case4}.
\end{proof}

Probability (math.PR); Combinatorics (math.CO)