%~Mouliné par MaN_auto v.0.27.3 2022-11-08 09:44:09
\documentclass[AHL, Unicode, longabstracts]{cedram}

\usepackage{bm}
\usepackage{tikz-cd}









\usetikzlibrary{intersections}




\newcommand{\bbN}{\mathbb{N}}
\newcommand{\bbE}{\mathbb{E}}
\newcommand{\bbQ}{\mathbb{Q}}
\newcommand{\bbZ}{\mathbb{Z}}
\newcommand{\bbP}{\mathbb{P}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\GG}{\mathbb{G}}
\newcommand{\C}{\mathbb{C}}


\newcommand{\clM}{\mathcal{M}}
\newcommand{\clH}{\mathcal{H}}


\newcommand{\bfun}{\mathbf{1}}

\newcommand{\Sym}{\mathrm{Sym}}
\newcommand{\GL}{\mathrm{GL}}
\newcommand{\rmco}{\mathrm{co}}

\newcommand{\rmd}{\mathrm{d}}
\newcommand{\rim}{\mathrm{im}}
\newcommand{\rmdx}{\mathrm{dy}}
\newcommand{\Qp}{\bbQ_p}

\newcommand{\RP}{\R\mathrm{P}}
\newcommand{\QP}{\bbQ_p\mathrm{P}}
\newcommand{\Zp}{\bbZ_p}
\newcommand{\Zn}{\bbZ/p^n\bbZ}
\newcommand{\CP}{\mathbb{C}\mathrm{P}}

\newcommand{\la}{\lambda}



\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\graphicspath{{./figures/}}

\newcommand*{\mk}{\mkern -1mu}
\newcommand*{\Mk}{\mkern -2mu}
\newcommand*{\mK}{\mkern 1mu}
\newcommand*{\MK}{\mkern 2mu}

%\hypersetup{urlcolor=purple, linkcolor=blue, citecolor=red}

\newcommand*{\romanenumi}{\renewcommand*{\theenumi}{\roman{enumi}}}
\newcommand*{\Romanenumi}{\renewcommand*{\theenumi}{\Roman{enumi}}}
\newcommand*{\alphenumi}{\renewcommand*{\theenumi}{\alph{enumi}}}
\newcommand*{\Alphenumi}{\renewcommand*{\theenumi}{\Alph{enumi}}}
\let\oldhat\hat
\renewcommand*{\hat}[1]{\mathchoice{\widehat{#1}}{\widehat{#1}}{\oldhat{#1}}{\oldhat{#1}}}
\let\oldforall\forall
\renewcommand*{\forall}{\mathrel{\oldforall}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title[Probabilistic enumerative geometry over $p$-adic numbers]{Probabilistic enumerative geometry over $p$-adic numbers: linear spaces on complete intersections}
\alttitle{Geométrie énumérative probabiliste sur les nombres $p$-adiques : espaces linéaires dans les intersections complètes}

\author[\initial{R.} \lastname{Ait El Manssour}]{\firstname{Rida} \lastname{Ait El Manssour}}
\address{MPI-MiS Leipzig,\\
Inselstra{\ss}e 22,\\
04103 Leipzig (Germany)}
\email{rida.manssour@mis.mpg.de}
\thanks{The first named author was supported by SISSA (Trieste).}

\author[\initial{A.} \lastname{Lerario}]{\firstname{Antonio} \lastname{Lerario}}
\address{SISSA, Via Bonomea 265,\\
34136 Trieste (Italy)}
\email{lerario@sissa.it}

\begin{abstract}
We compute the expectation of the number of linear spaces on a random complete intersection in $p$-adic projective space. Here ``random'' means that the coefficients of the polynomials defining the complete intersections are sampled uniformly from the $p$-adic integers. We show that as the prime $p$ tends to infinity the expected number of linear spaces on a random complete intersection tends to $1$. In the case of the number of lines on a random cubic in three-space and on the intersection of two random quadrics in four-space, we give an explicit formula for this expectation.
\end{abstract}

\begin{altabstract}
Nous calculons l'espérance du nombre d'espaces linéaires dans des intersections complètes aléatoires dans l'espace projectif $p$-adique. Ici ``aléatoire'' signifie que les coefficients des polynômes définissant les intersections complètes sont tirés uniformément parmi les entiers $p$-adiques. Nous montrons que lorsque le nombre premier $p$ tend vers l'infini, le nombre moyen d'espaces linéaires dans une intersection complète aléatoire tend vers $1$. Dans le cas du nombre de droites sur une cubique aléatoire en trois dimensions, et de l'intersection de deux quadriques aléatoires en quatre dimensions, nous donnons une formule explicite pour cette espérance.
\end{altabstract}


\datereceived{2021-02-10}
\daterevised{2022-06-29}
\dateaccepted{2022-08-19}

\editor{X. Caruso}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle

\section{Introduction}

\subsection{Classical and probabilistic enumerative geometry}
In this paper we deal with the enumerative problem of counting the number of $k$-dimensional projective subspaces (called ``$k$-flats'') on a complete intersection in $n$-dimensional $p$-adic projective space.

If this problem is approached over an algebraically closed field, it is a classic of enumerative geometry and we get a generic answer, e.g. there are $27$ lines on a generic cubic surface in $\CP^3$. At this point the word ``generic'' has its standard meaning from algebraic geometry: the generic object of a family has a property if this property is true for all the elements of the family except possibly for a proper algebraic subset of the family; below we will also exploit the measure-theoretic nature of this notion. Over a non--algebraically closed field, in general, we do not get such a generic answer and the number of solutions depends on the choice of the defining equations for the complete intersection. For instance, on a generic real cubic surface in $\RP^3$ the number of real lines can be either $3, 7, 15$ or $27$ (meaning that all possibilities occur for open sets in the space of cubics). Over the field of $p$-adic numbers, to our knowledge, it is not even clear what these generic possibilities are. In fact a cubic polynomial over $p$-adic fields needs to have a lot of variables ($22$) to ensure that the cubic surface has at least one line (see~\cite[Theorem~1.3 and Theorem~1.4]{brandes_dietmann_2020}).

This is a generalization of the problem of counting the number of zeroes of a polynomial of one variable: for the generic polynomial (i.e. for a polynomial whose discriminant is nonzero) the number of zeroes over $\C$ equals the degree of the polynomial; over a non-algebraically closed field (e.g. $\R$ or $\Qp$) it depends on the coefficients of the polynomial.

This motivates a probabilistic approach to the problem: when there is not a single \emph{generic} answer, we can put a probability distribution on the space of polynomials and ask for the \emph{expectation} of the number of solutions to the enumerative question. Over $\C$ this approach gives back the classical generic count.

Clearly the expectation of the number of solutions, in the non-algebraically closed case, depends on the choice of the probability distribution, but there are some distributions which are especially interesting as they have a clear geometric meaning: these are the distributions on the space of polynomials which are invariant under the action of the group of isometries of the projective space by change of variables; following the notation for the real case, we call them \emph{invariant distributions} (we will clarify this notion below). For these distributions there are no preferred points or directions in the projective space.

\begin{exem}
Let $\{\xi_\alpha\}_{|\alpha|=d}$ be a family of independent gaussian variables with:
\begin{equation}\label{eq:gaussian}
\xi_{\alpha_0\cdots\alpha_n}\sim N\left(0,\frac{d!}{\alpha_0!\cdots \alpha_n!}\right).
\end{equation}
Consider the following real polynomial with random coefficients:
\begin{equation}\label{eq:kostlan}
f(x)=\sum_{|\alpha|=d}\xi_{\alpha}\cdot x_0^{\alpha_0}\cdots x_n^{\alpha_n}.
\end{equation}
Using~\eqref{eq:kostlan} we can turn the space $\R[x_0,\,\ldots,\,x_n]_{(d)}$ of real homogeneous polynomials of degree $d$ into a gaussian space, i.e. a space with a gaussian probability distribution. This distribution is called the \emph{Kostlan} distribution. The scaling coefficient for the variances of the gaussian variables $\xi_\alpha$ is what makes the distribution invariant under isometries: for every orthogonal transformation $g\in O(n+1)$ the random polynomial $f\circ R$ obtained by a linear change of variables has the same distribution as $f$. In this way, if we denote by $Z(f_1,\,\ldots,\,f_\nu)\subset \RP^n$ the common zero set of the polynomials $f_1,\,\ldots,\,f_\nu$, if they are sampled at random as in~\eqref{eq:kostlan}, we have the notion of random complete intersection. The expected cardinality of $Z(f_1,\,\ldots,\,f_n)\subset \RP^n$, with each $f_j$ of degree $d_j$ and defined as in~\eqref{eq:kostlan}, is $\sqrt{d_1\,\cdots\,d_n}$, see~\cite{ShSm3}. The expected number of real lines on a random real cubic surface $Z(f)\subset \RP^3$ defined by picking $f$ as in~\eqref{eq:kostlan} is $6\sqrt{2}-3$, see~\cite{BLLP}.
\end{exem}

\begin{rema}
In the real case, the probabilistic approach goes back to Kac \cite{kac43}, who computed the expected number of real zeroes of a random polynomial with i.i.d. standard gaussian coefficients. The geometric point of view of invariant distributions was first adopted by Edelman, Kostlan, Shub and Smale~\cite{EdelmanKostlan95,EKS,ShSm3}, for counting the expectation of the number of solutions of a system of random equations. The extension of this approach to questions in real enumerative geometry was initiated by the second named author of this paper together with B\"urgisser~\cite{PSC} and with Basu, Lundberg and Peterson~\cite{BLLP}. In the real gaussian case the invariant distributions were classified by Kostlan~\cite{Kostlan95} and, in a recent work~\cite{3armoniche}, the first named author of this paper together with Belotti and Meroni provided a closed formula for the expectation of the number of real lines on a real random cubic surface for all the possible invariant distributions.
\end{rema}


\subsection{The \texorpdfstring{$p$}{p}-adic case}

Let us now move to the $p$-adic case. We begin by setting up the geometric framework for the enumerative problems of our interest. Given homogeneous polynomials $f_1,\,\ldots,\,f_\nu$ with coefficients in $\Zp$ and of degrees $d_1, \,\ldots,\,d_\nu\in \bbN$, we denote by $Z(f_1, \,\ldots,\,f_\nu)\subset \QP^n$ their common zero set in the $p$-adic projective space. If the list of degrees $d_1,\,\ldots,\,d_\nu$ satisfies
\begin{equation}\label{eq:codim}
\sum_{j=1}^{\nu}\binom{k+d_j}{d_j}=(k+1)(n-k),
\end{equation}
then for the generic choice of the polynomials, the number of $k$-flats on $Z(f_1,\,\ldots,\,f_\nu)$ is finite, see~\cite[Théorème~2.1]{debarremanivel}.

As we already observed, the number of solutions to our enumerative problem strongly depends on the coefficients of the polynomials. For instance, already in the case $\nu=1$, $k=0$, $d=3$ and $n=1$, the possibilities for the number of $p$-adic zeroes in $\QP^1$ of a cubic polynomial $f\in \Zp[x_0, x_1]_{(3)}$ with nonzero discriminant are $0, 1$ or $3$ (note the difference with the real case). It is therefore natural to approach this problem from the random point of view, and ask for the expectation of this number.

\begin{rema}
Before turning to the probabilistic side, let us briefly explain the meaning of the condition~\eqref{eq:codim}. We denote by $\Qp\GG_{k,n}$ the Grassmannian of $k$-flats in $\QP^n.$ Every element $\ell\in \Qp\GG_{k,n}$ can be seen as the projectivization $\ell=P(L)$ of a vector space $L\simeq \Qp^{k+1}\subset \Qp^{n+1}.$ The dimension of $\Qp\GG_{k,n}$ is $(k+1)(n-k)$ (the right hand side of~\eqref{eq:codim}). We denote by $\tau_{k,n}$ the tautological vector bundle on $\Qp\GG_{k,n}$:
\begin{equation}
\tau_{k,n}=\left\{(P(L), v)\in \Qp\GG_{k,n}\times \Qp^{n+1}\,\middle|\,v\in L\right\}.
\end{equation}
The dual of this bundle is denoted by $\tau_{k,n}^*$: the fiber of the dual bundle over a point $\ell=P(L)$ is the set of linear functions on $L.$ For every $d\in \bbN$ we denote by $\Sym^{(d)}(\tau_{k,n}^*)$ the $d^{\rm th}$ symmetric power of $\tau_{k,n}^*$: the fiber of $\Sym^{(d)}(\tau_{k,n}^*)$ over a point $\ell=P(L)$ is the set of homogeneous polynomial functions of degree $d$ on $L.$ Notice that every $f\in \Zp[x_0, \,\ldots,\,x_n]_{(d)}$ gives rise to a section $\sigma_f$ of $\Sym^{(d)}(\tau_{k,n}^*)$, defined by $\sigma_f(\ell)=f|_{L}$.

Given the list of degrees $d_1, \,\ldots,\, d_\nu$ we can consider the following vector bundle, with corresponding section:
\begin{equation} \label{eq:bundles}
\begin{tikzcd}
\bigoplus\limits_{j=1}^{\nu}\Qp^{
\left(\begin{smallmatrix}
d_j+k\\
d_j\end{smallmatrix}\right)} \arrow[rr, hook] & & {\bigoplus\limits_{j=1}^{\nu}\Sym^{(d_j)}\left(\tau_{k,n}^*\right)} \arrow[dd] \\
& & \\
& & {\Qp\GG_{k,n}} \arrow[uu, "\sigma_{f_1}\oplus \cdots \oplus \sigma_{f_\nu}"', bend right]
\end{tikzcd}
\end{equation}
The rank of this vector bundle is $\sum_{j=1}^{\nu}(\begin{smallmatrix}k+d_j\\d_j\end{smallmatrix})$ (the left hand side of~\eqref{eq:codim}). The zero locus of the section $\sigma_{f_1}\oplus \cdots \oplus \sigma_{f_\nu}$ consists of the set of $k$-flats which are contained in $Z(f_1,\, \ldots,\, f_\nu)$. In particular we see that, if~\eqref{eq:codim} is verified, for the generic choice of $f_1,\,\ldots,\, f_\nu$, the corresponding section vanishes at finitely many points (i.e. the zero locus of the section is zero-dimensional, in the language of~\cite{debarremanivel}).
\end{rema}

We now move to the probabilistic framework. The first step is to endow $\Zp[x_0,\, \ldots,\linebreak x_n]_{(d)}$ with a probability distribution. To this end, we endow $\Qp$ with the Haar measure $\lambda$, normalized such that $\lambda(\Zp)=1$. In this way the $p$-adic integers become a probability space, and we call the corresponding distribution the \emph{uniform} distribution. This is a special case of what is called a \emph{Gaussian} distribution on $p$-adic fields, see~\cite{EMMT}. Mimicking~\eqref{eq:kostlan}, we also turn the space of polynomials with coefficients in $\Zp$ into a probability space.

\begin{defi}
We define a probability distribution on $\Zp[x_0, \,\ldots,\, x_n]_{(d)}$ by
\begin{equation}\label{eq:random}
f(x)=\sum_{|\alpha|=d}\xi_{\alpha}\cdot x_0^{\alpha_0}\cdots x_n^{\alpha_n},
\end{equation}
where now $\{\xi_\alpha\}_{|\alpha|=d}$ is a family of i.i.d. uniform elements in $\Zp$. We will call this distribution the \emph{uniform} distribution.
\end{defi}

The uniform distribution on the space of polynomials is invariant under the action of $\GL_{n+1}(\Zp)$ by change of variables (Proposition~\ref{propo:invariant}) and it has therefore a clear geometric meaning. Notice that proper algebraic sets in $\Zp[x_0,\, \ldots,\, x_n]_{(d)}$ have probability zero: for instance, with probability one the zero set of a random polynomial is smooth. The natural map $f\mapsto \sigma_f$ induces a probability distribution on the space of sections of the bundle~\eqref{eq:bundles}. The zeroes of $\sigma_{f_1}\oplus \cdots \oplus \sigma_{f_\nu}$ are nondegenerate with probability one.

Our first theorem computes the expectation (below denoted by ``$\bbE$'') of the number of zeroes of the random section $\sigma_{f_1}\oplus\cdots \oplus \sigma_{f_\nu}$, under the assumption~\eqref{eq:codim}, i.e. the expectation of the number of $k$-flats on a random complete intersection $Z(f_1,\, \ldots,\, f_\nu)\subset \QP^n.$


\begin{theo}\label{thm:complete}
Let $f_1, \ldots, f_\nu$ be independent random polynomials of degrees $d_1,\, \ldots,\, d_\nu$ sampled from the uniform distribution~\eqref{eq:random}. Then
\begin{equation} \lim_{p\,\to\,\infty}\bbE\#
\left\{\text{$k$-flats on }Z\left(f_1,\, \ldots,\, f_\nu\right)\subset \QP^n\right\}=1.
\end{equation}
\end{theo}

\begin{rema}
Theorem~\ref{thm:complete} is in sharp contrast with its real analogue, at least for the case of hypersurfaces. Denoting by $C_n$ the number of lines on a generic hypersurface of degree~$2n-3$ in $\CP^n$ and by $E_n$ the expectation of the number of real lines on a random, Kostlan distributed real hypersurface of degree~$2n-3$ in $\RP^n$, \cite[Theorem~12]{BLLP} states that:
\begin{equation}
\lim_{n\,\to\,\infty}\frac{\log E_n}{\log C_n}=\frac{1}{2}.
\end{equation}
Since $C_n$ grows super-exponentially in $n$ (in fact $\log C_n=2n\log n+O(n)$), on hypersurfaces of degree~$2n-3$ in large dimensional projective spaces we expect to see many real lines -- there is in fact a deterministic lower bound for this number, see Section~\ref{sec:signed} below. Here, at least for large $p$, as a consequence of Theorem~\ref{thm:complete}, having many $p$-adic lines is an extremely rare event. In the $p$-adic case, we will also prove an asymptotic upper bound on our expectation as $n\to \infty$, see Theorem~\ref{thm:n} below.
\end{rema}

\begin{rema}
The probabilistic approach in the $p$-adic case has been introduced by~\cite{evans}, who first computed the expectation of the number of zeroes of a system of random equations (with respect to a probability distribution which is different from~\eqref{eq:random}). In the recent paper~\cite{pIGF}, the second named author of the current paper, together with Kulkarni, proved a generalization of the integral geometry formula to the $p$-adic setting, allowing to deduce some results on random systems of equations distributed as in~\eqref{eq:random}. Independently, the distribution of zeroes of a random uniform univariate polynomial was also recently studied by Caruso in~\cite{Caruso}. We notice that~\cite[Corollary~41]{pIGF} corresponds to the case $k=0$, $\nu=n$ of Theorem~\ref{thm:complete}, in which case we can actually prove the following result.
\end{rema}

\begin{theo}\label{thm:complete0}
Let $f_1,\, \ldots,\, f_n$ be independent random polynomials of degrees $d_1,\, \ldots,\, d_n$ sampled from the uniform distribution~\eqref{eq:random}. Then
\begin{equation}
\bbE\# Z\left(f_1,\,\ldots,\,f_n\right)=1.
\end{equation}
\end{theo}

As a corollary of this result we compute the expectation of the absolute value of the determinant of a matrix $M_n\in \Zp^{n\,\times\,n}$ filled with i.i.d. uniform elements in $\Zp$ (Corollary~\ref{coro:matrix}):

\begin{equation}\label{eq:M}
\bbE\left\{\left|\det M_n;\right|_p\right\}=\frac{(p-1)p^n}{p^{n+1}-1}.
\end{equation}

Another case of special interest is the count of the number of lines on a cubic surface in $\QP^3,$ for which we can prove the following sharper version of Theorem~\ref{thm:complete}.

\begin{theo}\label{thm:cubic}
The expected number of $p$-adic lines on a random uniform $p$-adic cubic surface in $\QP^3$ is $\frac{(p^3-1)(p^2+1)}{p^5-1}.$
\end{theo}

We also prove a similar result for the intersection of two random quadrics in $\QP^4$.

\begin{theo}\label{thm:quadrics}
The average number of $p$-adic lines on the intersection of two random quadrics in $\QP^4$ is $1$.
\end{theo}

The proof of Theorem~\ref{thm:complete} is based on a $p$-adic version of the Kac--Rice formula for sections of vector bundles (Theorem~\ref{thm:reduction}), which reduces the computation of the expectation of the number of zeroes of a random section to the expectation of the valuation of the determinant of a special random matrix $J$:
\begin{equation} \label{eq:JJ}
\bbE\#\left\{\text{$k$-flats on }Z\left(f_1,\, \ldots,\,f_\nu\right)\subset \QP^n\right\}=\mu\left(\Qp\GG_{k,n}\right)\cdot \bbE\left\{\left|\det(J)\right|_p\right\}.
\end{equation}

Here the matrix $J$ is a random square matrix with $(n-k)(k+1)$ columns and whose structure depends on $\nu, k$ and $d_1,\,\ldots,\,d_\nu$, and $\mu$ is a measure over $\Qp\GG_{k,n}$ defined in~\eqref{Volume Grass}. For instance, when $k=0$ the matrix $J=M_n$ is the above matrix filled with i.i.d. uniform elements in $\Zp$ (which explains~\eqref{eq:M}), but the general case is more complicated. Theorem~\ref{thm:complete} is based on the asymptotic analysis of~\eqref{eq:JJ}; Theorem~\ref{thm:cubic} and Theorem~\ref{thm:quadrics} require instead a more delicate study, based on a counting argument in the reduction modulo $p^m$.


\subsection{Signed counts}\label{sec:signed}
It is interesting to observe that over the reals there is a deterministic lower bound on the number of real lines on a generic cubic surface. In fact, generalizing a construction of Segre~\cite{Segre}, Okonek and Teleman~\cite{OkTel} and Kharlamov and Finashin~\cite{finkh} introduced a way to assign a sign to each line on the zero set of a hypersurface of degree~$2n-3$ in $\RP^n$. The signed count of the number of real lines does not depend on the hypersurface and gives $(2n-3)!!$, where for an integer $k$, we denote by $k!!$ the product of all odd numbers smaller than $k$. In particular there are always $3$ lines on a smooth real cubic surface, and exactly $3$ if counted with signs. This enriched count has been extended to any field~\cite{kass2017arithmetic}, and it gives an invariant with values in the Grothendieck--Witt group of the field. In the $p$-adic case however this is not enough to guarantee a solution: there are $p$-adic cubic surfaces with no lines on them.

In the real case the computation of the signed count can also be done in a probabilistic way, as showed in~\cite{BLLP}. Let us explain this point in the simplest case of cubics. Using the real version of the Kac--Rice formula, it can be proved that the expectation $E_3$ of the number of real lines on a random real cubic surface equals:
\begin{equation}\label{eq:E3}
E_3=\frac{1}{12\pi^2}\cdot \mu(\R\GG(1,3))\cdot \bbE\left|\det J\right|
\end{equation}
where $\mu(\R\GG(1,3))=2\pi^2$ is the volume of the real Grassmannian, and $J$ is the following matrix, filled with the random gaussian variables defined in~\eqref{eq:gaussian}:
\begin{equation}\label{eq:J}
J=
\begin{pmatrix}
\xi_{2010} &0 &\xi_{2001} &0 \\
\xi_{1110} &\xi_{2010} &\xi_{1101} &\xi_{2001} \\
\xi_{0210} &\xi_{1110} &\xi_{0201} &\xi_{1101} \\
0 &\xi_{0210} &0 &\xi_{0201}
\end{pmatrix}.
\end{equation}
Note that this matrix is the Jacobian, in local coordinates, of the random section $\sigma_f$ at $\ell_0=P(L_0)$, where $L_0=\{x_2=x_3=0\}\subset \R^4.$ As we already mentioned, the Kac--Rice approach works also over the $p$-adics, and it is our starting point for the proofs of Theorem~\ref{thm:complete} and Theorem~\ref{thm:cubic}. For instance, in the case of cubics:
\begin{equation}
\bbE\# \{\text{$p$-adic lines on a random cubic surface}\}=\mu(\Qp\GG(1,3))\cdot \bbE\left|\det J\right|_p
\end{equation}
where now $\mu(\Qp\GG(1,3))$ denotes the volume of the $p$-adic Grassmannian (defined in Section~\ref{sec:mms} below) and $J$ is the same matrix as in~\eqref{eq:J}, this time filled with uniform variables in $\Zp$.

The interesting point now is that in the real case the signed count can be obtained simply by computing the expectation of the quantity on the r.h.s. of~\eqref{eq:E3}, but where we remove the modulus from the determinant of $J$ see~\cite[Proposition~3]{BLLP}. (A similar statement holds true for higher dimensions/degrees). Mimicking the proof of~\cite[Proposition~2]{BLLP} we can compute the expectation of the determinant of $J$ in the $p$-adic case. Computing this expectation amounts now to compute the integral of a function with values in $\Qp$. We do this using the notion of \emph{Volkenborn integral}, which for a continuous function $f\, : \Zp^k \to \Qp$ is defined by the following limit (if it exists):
\[
\int_{\Zp^k}f(x)\rmdx=\lim_{n\,\rightarrow\,+\infty} \frac{1}{p^{kn}}\sum_{a_1=0}^{p^n-1}\cdots \sum_{a_k=0}^{p^n-1}f\left(a_1,\,\ldots,\,a_k\right).
\]
In the case of cubics, this would give:
\begin{multline*}
\bbE\{\det(J)\}\\
\begin{aligned}
&=\bbE\bigg\{\left(\xi_{2010}\xi_{0201}-\xi_{0210}\xi_{2001}\right)^2-\left(\xi_{2010}\xi_{1101}-\xi_{1110}\xi_{2001}\right)\left(\xi_{1110}\xi_{0201}-\xi_{0210}\xi_{1101}\right)\bigg\}\\
&=\int_{\Zp^6} (x_1x_6-x_3x_4)^2-(x_1x_5-x_2x_4)(x_2x_6-x_3x_5) \rmd x_1\ldots dx_6\\
&= \lim_{n\,\rightarrow\,+\infty}\frac{1}{p^{6n}}\sum_{0\,\le\,a_1,\,\ldots,\,a_6\,\le\,p^n-1}(a_1a_6-a_3a_4)^2-(a_1a_5-a_2a_4)(a_2a_6-a_3a_5)\\
&=\lim_{n\,\rightarrow\,+\infty}\frac{1}{p^{6n}}\cdot\frac{p^{6n}\left(p^n-1\right)^2\left(5p^{2n}+p^{n}-4\right)}{36}\\
&=-\frac{1}{9}\in \Qp.
\end{aligned}
\end{multline*}
We do not have a clear interpretation of the meaning of this number, but we believe this can be the starting point for future investigations.

\subsection{Structure of the paper}
The rest of the paper is organized as follow: Section~\ref{sect2} contains definitions and properties used to prove the main results. In Section~\ref{sect3.1} we prove our $p$-adic version of the Kac--Rice formula. The answer involves the expectation of the $p$-adic absolute value of the determinant of a random matrix of a certain shape, where in Section~\ref{Structure} we present the shape of that random matrix in different cases. Section~\ref{sect3.3} contains the proof of Theorem~\ref{thm:complete} which is based on the fact that our random matrix does not vanish with probability $1$. Sections~\ref{sect3.5}, \ref{sect3.6} contain proofs of Theorem~\ref{thm:cubic}, and Theorem~\ref{thm:quadrics}. These proofs rely on the $p$-adic version of the Kac--Rice formula theorem~\ref{thm:reduction} and computing the expectation of the $p$-adic absolute value of the determinant of our random matrix in the cases of lines on a cubic and lines on the intersection of two quadrics respectively. In Section~\ref{sect3.7} we give an asymptotic limit of the average of the number of lines on an hypersurface of degree~$2n-3$.

\subsection*{Acknowledgements}
The authors wish to thank Yassine El Maazouz and Avinash Kulkarni for stimulating discussions, Bernd Sturmfels for his constant support, and the anonymous referee for her/his helpful comments. 


\section{Preliminaries}\label{sect2}

\subsection{\texorpdfstring{$p$}{p}-adic spaces as metric measure spaces}\label{sec:mms}

Let $p$ be a prime number and denote by $|\cdot|_p$ the $p$-adic absolute value. We endow the space $\Qp^n$ with the norm $\|\cdot\|_p$ defined by:
\begin{equation}
\forall \left(a_1,\, \ldots,\, a_n\right)\in \Qp^n:\quad \left\|\left(a_1,\,\ldots,\,a_n\right)\right\|_p:=\sup_{i}|a_i|_p.
\end{equation}
In this way $\Qp^n$ becomes a metric space. We endow it also with the Haar measure $\la$ normalized over the unit ball $\Zp^n$. i.e. $\la(\Zp^n)=1$. In particular, for any ball $B(x; p^{-m})\subset \Qp^n$ we have:
\begin{equation}
\la\left(B\left(x; p^{-m}\right)\right)=p^{-nm}.
\end{equation}
The measure $\lambda$ is invariant under the group $\GL_n(\Zp)$, i.e. for every measurable set $U\subseteq \Qp^n$ and every element $M\in \GL_n(\Zp)$ we have $\lambda(M(U))=\lambda(U).$

Once restricted to $\Zp^n$, the measure $\lambda$ becomes a probability measure. We call the corresponding probability distribution on $\Zp^n$ the \emph{uniform distribution}. Using this terminology, we can restate the $\GL_n(\Zp)$--invariance of $\lambda$ as follows: let $\xi$ be a uniformly distributed random vector in $\Zp^n$; then for every $M\in \GL_n(\Zp)$ the vectors $\xi$ and $M\xi$ have the same distribution.

We view the set of $n\times n$ matrices as a subset of $\Qp^{n\times n}$, with the corresponding measure. Under this identification, the set $\GL_n(\Zp)$ is contained in $\Zp^{n\times n}$ and it consists of matrices which are invertible modulo $p$; its measure is given by~\cite[Theorem~4.1]{EVANS200289}:
\begin{equation}\label{eq:volGL}
\la\left(\GL_n\left(\Zp\right)\right)=\left(1-\tfrac{1}{p}\right)\cdots\left(1-\tfrac{1}{p^n}\right).
\end{equation}
More generally, again by~\cite{EVANS200289}, we have:
\begin{equation}\label{eq:12}
\la\left(\left\{ \left|\det(M)\right|_p=p^{- m}\right\}\right)=\Pi_n p^{-m}\frac{\Pi_{n+m-1}}{\Pi_m \cdot \Pi_{n-1}} 
\end{equation} 
where $\Pi_k=\left(1-\tfrac{1}{p}\right)\cdots\left(1-\tfrac{1}{p^k}\right)$.

We endow the Grassmannian $\Qp\GG_{k,n}$ with the normalized pushforward measure
\begin{equation}\label{Volume Grass}
\mu:=\frac{1}{\lambda\left(\GL_{n-k}(\Zp)\right)\lambda\left(\GL_{k+1}(\Zp)\right)}q_*\la,
\end{equation}
where the map $q: \GL_{n+1}(\bbZ_p) \to \Qp\GG_{k,n}$ is given by
\begin{equation}
q:M \mapsto \rim\left(M
\begin{pmatrix}
\bfun_{k+1}\\
0
\end{pmatrix}\right).
\end{equation} 
In this way the measure of the Grassmannian equals
\begin{equation}\label{eq: Volume Grass}
\mu\left(\Qp\GG_{k,n}\right)=\frac{\lambda\left(\GL_{n+1}(\Zp)\right)}{\lambda\left(\GL_{n-k}(\Zp)\right)\lambda\left(\GL_{k+1}(\Zp)\right)},
\end{equation}
reflecting the real case.

We refer the reader to~\cite{pIGF} for more details on the properties of $\Qp^n$ and related spaces as metric measure spaces. On these spaces continuous functions can be integrated and a useful proposition for the sequel is the following change of variable formula from~\cite{evans}.

\begin{prop}\label{Kac}
Let $X$ be an open subset of $\Qp^m$ and $f\, :X\to \Qp^n$ a continuously differentiable map. For all measurable subsets $Y$ of $\Qp^n$ we have:
\[
\int_Y \#\{f=y\}\rmd y=\int_{f^{-1}(Y)}\left|\det\left(Jf(x)\right)\right|_p\rmdx.
\]
\end{prop}

The next lemma, which is going to be used in the proofs of Theorem~\ref{thm:cubic} and Theorem~\ref{thm:quadrics}, gives the analogue of Riemann sums for performing integrals of continuous functions on $\Zp^n.$

\begin{lemm}\label{lemma:integral}
Let $f: \Zp^n \to \R$ be a continuous function. Then $f$ is integrable and its integral is given by:
\begin{equation}
\int_{\Zp^n} f(x)\rmdx=\lim_{m\,\rightarrow\, +\infty} \frac{1}{p^{mn}}\sum_{0\,\le\, a_1,\,\ldots,\,a_n\,\le\,p^m-1} f\left(a_1,\,\ldots,\,a_n\right)
\end{equation}
\end{lemm}

\begin{proof}
The proof is elementary.
Since $f$ is continuous, it is bounded and therefore integrable. For every $m\in \bbN$, consider the function:
\begin{equation}
f_m(x):=\sum_{0\,\le\,a_1,\,\ldots,\,a_n\,\le\,p^m-1} f\left(a_1,\,\ldots,\,a_n\right)\cdot \chi_{B\left(a;p^{-m}\right)}(x),
\end{equation}
where $a=(a_1,\, \ldots,\, a_n)$ and $\chi_{B(a;p^{-m})}$ is the indicator function of $B(a;p^{-m})$. The sequence of functions $\{f_m\}_{m\,\in\,\bbN}$ converge pointwise to $f$ and is dominated by the constant $\max_{x\,\in\,\Zp^n}|f(x)|$. Therefore:
\begin{align}
\int_{\Zp^n}f(x)dx&=\int_{\Zp^n}\lim_{m\,\to\,\infty}f_m(x)dx\\
&=\lim_{m\,\to\,\infty}\int_{\Zp^n}f_m(x)dx\\
&=\lim_{m\,\rightarrow\,+\infty} \lambda\left(B\left(0; p^{-m}\right)\right)\sum_{0\,\le\,a_1,\,\ldots,\,a_n\,\le \,p^m-1} f(a_1,\,\ldots,\,a_n)\\
&=\lim_{m\,\rightarrow\,+\infty} \frac{1}{p^{mn}}\sum_{0\,\le\,a_1,\,\ldots,\,a_n\,\le\,p^m-1} f(a_1,\,\ldots,\,a_n).
\end{align}
\end{proof}

Let us also recall the following proposition, which is going to be used in the proofs of Lemma~\ref{lemma:card} and Lemma~\ref{lemma:Fbr}; it is a consequence of the $p$--adic singular value decomposition, see~\cite[Theorem~3.1]{EVANS200289}.

\begin{prop}\label{SVD}
Let $M\in (\Zn)^{k\times k}$ with $\det(M) \ne 0$, then there exist unique integers $0\le u_1\le \cdots \le u_k\le n-1$ and $U,V \in GL_k(\Zn)$ such that:
\[
M=U
\begin{pmatrix}
p^{u_1} & & \\
& \ddots & \\
& & p^{u_k}
\end{pmatrix}V.
\]
\end{prop}


\subsection{The reduction modulo \texorpdfstring{$p^m$}{pm}}
For every $m\in \bbN$, let us denote by
\begin{equation} 
\pi_m\, : \Zp^k\to \left(\bbZ/p^m\bbZ\right)^k
\end{equation}
the map that sends a vector to its reduction modulo $p^m$. This map is a ring homomorphism and for a set $U\subseteq \Zp^n$ we denote by $N_m(U)$ the cardinality of $\pi_m(U).$ The following result from~\cite{pIGF} relates the volume of a set with the cardinality of its reduction modulo $p^m$.
\begin{lemm}[Lemma~25 from~\cite{pIGF}]\label{Cardinal}
Let $U \subseteq \Zp^n$ be an open and compact subset of an algebraic set. Then $N_m(U)$ equals the minimum number of affine balls of radius $p^{-m}$ that we need to cover $U$. In particular, if $U\subseteq \Zp^n$ is an open set, then
\begin{equation}
\lambda(U) = \lim_{m\,\to\,\infty} p^{-mn}N_m(U).
\end{equation}
\end{lemm}

In particular, since $\pi_m(\GL_n(\Zp))=\GL_n(\Zp/p^m\Zp)$, using~\eqref{eq:volGL} we see that:
\begin{equation}
\#\GL_n\left(\Zp/p^m\Zp\right)=p^{mn^2}\lambda\left(\GL_n(\Zp)\right)=p^{mn^2}\left(1-\tfrac{1}{p}\right)\cdots\left(1-\tfrac{1}{p^n}\right).
\end{equation}
More generally, for $\ell < m$, we have:
\begin{multline}\label{eq:Cardinal2}
\#\left\{M\in \left(\bbZ/p^m\bbZ\right)^{n\times n}\, \bigg|\, \left|\det(M)\right|_p=p^{-\ell}\right\}\\
=p^{mn^2}\lambda\left(\left\{M\in \Zp^{n\times n}\, \bigg|\, \left|\det(M)\right|_p=p^{-\ell}\right\}\right).
\end{multline}


\subsection{Random \texorpdfstring{$p$}{p}-adic polynomials} 
Let $\Qp[x_0,\,\ldots,\,x_n]_{(d)}$ be the space of homogeneous polynomials of degree $d$, $n+1$ variables and coefficients in $\Qp;$ denote by $D_{d, n}=\binom{d+n}{d}$ its dimension.

\begin{defi}
We define a random polynomial $f$ in $\Zp[x_0,\,\ldots,\,x_n]_{(d)}$ as follows:
\begin{equation}\label{eq:rp}
f=\sum_{|\alpha|=d}\xi_\alpha x_0^{\alpha_0}\cdots x_n^{\alpha_n}
\end{equation}
where $\xi_{\alpha}$ are independent random variables uniformly distributed in $\Zp$. We call the probability distribution induced by~\eqref{eq:rp} on $\Zp[x_0,\, \ldots,\,x_n]_{(d)}$ the \emph{uniform} distribution.
\end{defi}

Identifying a polynomial in $\Zp[x_0,\, \ldots,\, x_n]_{(d)}$ with the list of its coefficients (in the monomial basis), we see that the uniform distribution~\eqref{eq:rp} coincides with the uniform distribution on the unit ball $\Zp^{D_{d,n}}$ defined in Section~\ref{sec:mms}.

\begin{prop}\label{propo:invariant}
The uniform probability distribution on $\Zp[x_0,\,\ldots,\,x_n]_{(d)}$ is invariant under the action of $\GL_{n+1}(\Zp)$ by change of variables.
\end{prop}


\begin{proof}
Let us denote by $\rho:\GL_{n+1}(\Zp)\to \GL_{D_{d,n}}(\Qp)=\GL(\Qp[x_0,\,\ldots,\, x_n]_{(d)}) $ the representation by change of variables. Observe that for a matrix $M\in \GL_{n+1}(\Zp)$, the matrix $\rho(M)$ has coefficients in $\Zp$ and, since $\rho(M)^{-1}=\rho(M^{-1})$, its inverse also has coefficients in $\Zp$. It follows that $\rho(M)\in\GL_{D_{d,n}}(\Zp)$. The uniform probability distribution on $\Zp^{D_{d,n}}$ is invariant under elements in $\GL_{D_{d,n}}(\Zp)$ and therefore it is in particular invariant under change of variables in $\GL_{n+1}(\Zp)$.
\end{proof}

\section{Linear spaces on complete intersections}
\subsection{Counting \texorpdfstring{$k$}{k}-flats as zeroes of sections}\label{sect3.1}
We are going now to perform some preliminary reductions for our problem of counting the expectation of the number of $k$-flats on a random complete intersection.

Let $U\subset \Qp\GG_{k,n}$ be the open set consisting of all projective spaces $\ell=P(L)$ whose first entry of the Pl\"ucker coordinates is nonzero and denote by $\phi:U\to \Qp^{(n-k)\times (k+1)}$ the map:
\begin{equation}
\phi(\ell)=\phi\left(\rim
\begin{pmatrix}
\bfun_{k+1} \\
A
\end{pmatrix}\right)=A.
\end{equation}
This map is well defined and $(U,\phi)$ is a chart of the $p$-adic manifold $\Qp\GG_{k,n}$.

\begin{lemm}\label{lemma:disj}
Let $U_m=\phi^{-1}(B(0; p^{-m})).$ There exists $g_1,\,\ldots,\,g_{N_m}\in \GL_{n+1}(\Zp)$ such that the Grassmannian can be written as a disjoint union:
\begin{equation}
\Qp\GG_{k,n}=\bigcup_{i=1}^{N_m}\left(g_i\cdot U_m\right).
\end{equation}
Moreover:
\begin{equation}\label{eq:Um}
\mu(U_m)=p^{-m (k + 1)(n - k)}\quad \text{and}\quad N_m=\mu\left(\Qp\GG_{k,n}\right)\cdot p^{m (k + 1)(n - k)}.
\end{equation}
\end{lemm}

\begin{proof}
First observe that for every $g\in \GL_{n+1}(\Zp)$ the set $g\cdot U_m$ is open in $\Qp\GG_{k,n}$ and $\{g\cdot U_m\}_{g\,\in\,\GL_{n+1}(\Zp)}$ is an open cover of the Grassmannian. By compactness we can extract a finite subcover, and it remains to prove that the open sets from this finite cover can be taken to be disjoint.

Let us consider the following subgroup of $\GL_{n+1}(\Zp)$:
\begin{align}
\clH_m:=\bigg\{
\begin{bmatrix}
A &B\\
C&D
\end{bmatrix}
\in \GL_{n+1}(\bbZ_p) \, \bigg|&\, A \in GL_{k+1}\left(\bbZ_p\right),\, D\in GL_{n-k}(\bbZ_p),\\
&C\in B\left(0;p^{-m}\right),\, B\in \bbZ_p^{(k+1) (n-k)} \bigg\}.
\end{align}
We will show that given $g\in \GL_{n+1}(\Zp)$ and $X\in U_m$, then $g\cdot X \in U_m$ if and only if $g\in \clH_m$. Moreover, $\forall \, g_1,\,g_2 \in \GL_{n+1}(\Zp)$: either $g_1\cdot U_m=g_2 \cdot U_m$ or $g_1\cdot U_m\cap g_2\cdot U_m=\emptyset$. From this it follows that the previous cover of $\Qp\GG_{k,n}$ can be taken to be disjoint.

Set $X=[
\begin{smallmatrix}
\bfun_{k+1}\\
\hat{X}
\end{smallmatrix}]$ where $\hat{X}\in B(0;p^{-m})$ and $g=
[\begin{smallmatrix}
A &B\\
C&D
\end{smallmatrix}] \in \GL_{n+1}(\Zp)$. With this notation we have
\[
g\cdot X=
\begin{bmatrix} A+B\hat{X}\\
C+D\hat{X}
\end{bmatrix}\in U_m \Leftrightarrow
\begin{cases} 
\det\left(A+B\hat{X}\right) \ne 0\\
\left(C+D\hat{X}\right)\left(A+B\hat{X}\right)^{-1} \in B\left(0;p^{-m}\right).
\end{cases}
\]
Suppose first that $g\cdot X=
[\begin{smallmatrix}
A+B\hat{X}\\
C+D\hat{X}
\end{smallmatrix}]\in U_m$. Since $A+B\hat{X}\in \bbZ_p^{(k+1)\times(k+1)}$, we have
\[
\left | C+D\hat{X} \right |_p\leq \left | \left(C+D\hat{X}\right)\left(A+B\hat{X}\right)^{-1} \right|_p.
\]
It follows that $C+D\hat{X}\in B(0;p^{-m})$, which implies $ C\in B(0;p^{-m})$. By reducing $g$ modulo $p$, we get that
\[
\det(g)=\det(A)\cdot \det(D) \; (mod\; p)
\]
Therefore $A \in \GL_{k+1}(\Zp)$, and $D \in \GL_{n-k}(\Zp).$
The converse is trivial.

We will now prove that either $g_1\cdot U_m\cap g_2\cdot U_m = \emptyset$ or $g_1\cdot U_m = g_2\cdot U_m$. Suppose that $g_1\cdot U_m\cap g_2\cdot U_m \ne \emptyset$ i.e. $g_1^{-1}g_2\cdot U_m\cap U_m \ne \emptyset$. By the previous point $g_1^{-1}g_2\in \clH_m$ which implies $g_1^{-1}g_2\cdot U_m\subseteq U_m$. But by changing $g_1$ with $g_2$ we also have $g_2^{-1}g_1 \in \clH_m$, and therefore $g_2^{-1}g_1\cdot U_m \subseteq U_m$. Thus
\[
U_m = g_2^{-1}g_1 \cdot \left(g_1^{-1}g_2\cdot U_m \right) \subseteq g_2^{-1}g_1\cdot U_m \subseteq U_m.
\]
Which implies $g_2^{-1}g_1\cdot U_m = U_m$ i.e. $g_1\cdot U_m=g_2\cdot U_m$.

The properties~\eqref{eq:Um} follow immediately from the definition of the pushforward measure $\mu$ and the structure of $\clH_m$. Indeed,
\begin{align*}
\mu (U_m) &= \frac{\lambda \left(q^{-1} (U_m)\right)}{\lambda(GL_{k + 1 } (\Zp)) \lambda (GL_{n - k}(\Zp))} \\
&= \frac{ \lambda (\clH_m)}{ \lambda(GL_{k + 1 }(\Zp)) \lambda (GL_{n - k}(\Zp)) } =p^{- m (k + 1) (n - k)},
\\
\intertext{and}
\mu(\Qp\GG_{k, n}) &= N_m \cdot \mu (U_m).\qedhere
\end{align*}
\end{proof}

Recall now that for every $d\in \bbN$ we have denoted by $\Sym^{(d)}(\tau_{k,n}^*)$ the vector bundle which is the $d^{\,th}$ symmetric power of the dual of the tautological bundle on $\Qp\GG_{k,n}$: the fiber over a point $\ell=P(L)$ is the set of homogeneous polynomials of degree $d$ on $L\simeq \Qp^{k+1}.$ Given the list of degrees $d_1, \ldots, d_\nu$ satisfying~\eqref{eq:codim}, we define the vector bundle:
\begin{equation}
E=\bigoplus\limits_{j=1}^{\nu}\Sym^{(d_j)}\left(\tau_{k,n}^*\right)\to\Qp\GG_{k,n}
\end{equation}

Over the open set $U$ we have a trivialization of the vector bundle $E$:
\begin{equation}
\begin{tikzcd}
{E|_U} \arrow[rdd, "\pi"] \arrow[rr, "h"] & & {U\times\left(\bigoplus\limits_{j=1}^{\nu} \Qp^{\left(\begin{smallmatrix}
d_j+k\\
d_j\end{smallmatrix}\right)}\right)} \arrow[ldd, "p_1"] \\ & & \\
& U &
\end{tikzcd} 
\end{equation}

Given the list of polynomials $f_1, \ldots, f_\nu$ with degrees respectively $d_1,\ldots, d_\nu$ that satisfy~\eqref{eq:codim}, we get a section $\sigma_f:\Qp\GG_{k,n}\to E$ of the form \begin{equation}
\sigma_f=\sigma_{f_1}\oplus\cdots\oplus \sigma_{f_{\nu}}.
\end{equation}
If the polynomials $f_1, \ldots, f_\nu$ are random, we use the section $\sigma_f$ to define the random map
\begin{equation}\label{eq:psif}
\psi_f:=p_2\circ h\circ \sigma_f|_U \circ \phi^{-1} :\Qp^{(n-k)(k+1)} \to \bbQ_p^{(n-k)(k+1)}.
\end{equation} 
This map takes a matrix $A\in \Qp^{(n-k)\times (k+1)}$ and gives the list of coefficients of the restriction of the polynomials $f_1,\, \ldots,\, f_\nu$ to the subspace $\phi^{-1}(A).$ These coefficients clearly depend on the choice of the trivialization $h$ and we choose such trivialization in such a way that the components of the random map $\psi_f=(\psi_{f_1},\, \ldots,\, \psi_{f_{\nu}})$ are the coefficients of the polynomials
\begin{equation}\label{eq:trivi}
f_j\left(
\begin{pmatrix}
\bfun_{k+1} \\
A
\end{pmatrix}y\right)\in \Qp[y_0,\, \ldots,\, y_k]_{(d_j)}, \quad y=(y_0,\, \ldots, \,y_k),
\end{equation}
where the monomials are ordered w.r.t lexicographical ordering.

\begin{lemm}\label{lemma:ecco}
Using the above notations, for every $m\in \bbN$ we have
\begin{equation}
\bbE\#\left\{\sigma_f=0\right\}=N_m\cdot \bbE\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=0\right\}.
\end{equation}
\end{lemm}

\begin{proof}
Using Lemma~\ref{lemma:disj}, we can cover the Grassmannian with disjoint open sets $\{g_iU_m\}_{i=1}^{N_m}$ and therefore:
\begin{align}
\bbE\#\left\{\sigma_f=0\right\}&=\sum_{i=1}^{N_m}\bbE\#\left\{\sigma_f=0\right\}\cap g_iU_m\\
&=\sum_{i=1}^{N_m}\bbE\#\left\{\sigma_f\circ g_i=0\right\}\cap U_m\\
&=\sum_{i=1}^{N_m}\bbE\#\left\{\sigma_f=0\right\}\cap U_m\\
&=N_m \cdot \bbE\#\left\{\sigma_f=0\right\}\cap U_m,
\end{align}
where from the second to the third line we have used the $\GL_{n+1}(\Zp)$--invariance. On the other hand $\sigma_f$ vanishes at $\ell\in U_m$ if and only if $\psi_f$ vanishes at $\phi(\ell)\in B(0; p^{-m})$ and the conclusion follows.
\end{proof}

Recall that the total volume of the Grassmannian is given in~\eqref{eq: Volume Grass} by:
\[
\mu\left(\Qp\GG_{k,n}\right)=\frac{\lambda\left(\GL_{n+1}(\Zp)\right)}{\lambda\left(\GL_{n-k}(\Zp)\right)\lambda\left(\GL_{k+1}(\Zp)\right)}.
\]
The next result is our version of the $p$-adic Kac--Rice formula for sections of vector bundles: it allows us to reduce the calculation of the expectation of the number of zeroes of $\sigma_f$ to the evaluation of a random determinant.

\begin{theo}\label{thm:reduction}
Let $f_1,\, \ldots,\, f_\nu$ be random polynomial as before. The expected number of $k$-flats on $Z(f_1,\, \ldots,\, f_\nu)$ is given by:
\begin{equation*}
\bbE\#\left\{\sigma_f=0\right\}=\mu\left(\Qp\GG_{k,n}\right)\cdot \bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}.
\end{equation*}
\end{theo}
\begin{proof}
Let $D=(k+1)(n-k).$ For every 
\[
a=(a_1,\,\ldots, a_\nu) \in \bigoplus_{j=1}^\nu\Zp\left[x_0,\,\ldots,\,x_k\right]_{(d_j)}\simeq \Zp^D
\]
denote by $f_a=(f_{a_1},\,\ldots,\,f_{a_\nu})$ the list of polynomials in $n+1$ variables and of degrees $(d_1,\,\ldots,\,d_\nu)$ obtained as follows. For every $i=1,\,\ldots,\, \nu$ consider the polynomial $g_{a_i}\in \Qp[x_0,\,\ldots,\, x_k]_{(d_j)}$ whose coefficients are the entries of the vector $a_i$, and then set:
\begin{equation}
f_a(x_0,\,\ldots, \,x_n):=g_a(x_0,\,\ldots,\, x_k).
\end{equation}
(So $f_{a_i}$ is a polynomial on $\Qp^{n+1}$ which depends only on the first $k+1$ variables).

If $\xi\in \Zp^D$ denotes the list of coefficients of the random vector $f$, the list of the coefficients of $f-f_a$ is $\xi-a$. Observe that, given a random uniform vector $\xi\in \Zp^D$ and $a\in \Zp^{D}$ the random vector $\xi-a$ is also uniformly distributed in the unit ball; therefore $f$ and $f-f_a$ have the same distribution. It follows that for every $m\in \bbN$
\begin{equation}
\bbE\#\left\{\sigma_f=0\right\}\cap U_m=\bbE\#\left\{\sigma_{f-f_a}=0\right\}\cap U_m.
\end{equation}
On the other hand, by~\eqref{eq:trivi}, $\psi_{f_a}\equiv a$, and $A\in B(0; p^{-m})=\phi^{-1}(U_m)$ is a zero of $\psi_{f_a}$ if and only if $\psi_f(A)=a.$ Therefore:
\begin{equation}
\bbE\#\left\{\sigma_f=0\right\}\cap U_m=\bbE\#\left\{\psi_f=a\right\}\cap B\left(0; p^{-m}\right)=\bbE\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=a\right\}.
\end{equation}
We use now Proposition~\ref{Kac} and write:
\begin{align}\label{eq:fs}
\bbE\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=a\right\}&=\bbE\#\left\{\psi_f\middle|_{B\left(0\,;\, p^{-m}\right)}=0\right\}\\
&=\int_{\Zp^D}\bbE\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=a\right\}da\\
&=\bbE\int_{\Zp^D}\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=a\right\}da\\\label{eq:fs}
&=\bbE\int_{B\left(0\,;\,p^{-m}\right)}\left|\det \left(J\psi_f(x)\right)\right|_pdx.
\end{align}
Notice that as $x\to 0$ we have
\begin{equation}\label{eq:esti}
\left|\det\left(J\psi_f(x)\right)\right|_p=\left|\det \left(J\psi_f(0)\right)\right|_p+o(\|x\|),
\end{equation}
where the implied constant is uniformly bounded because the coefficients of the random vector $f$ range in the unit ball. Therefore, using~\eqref{eq:fs} and Lemma~\ref{lemma:ecco}, we can write for every $m\in \bbN$:
\begin{align}
\bbE\#\left\{\sigma_f=0\right\} &=N_m \bbE\#\left\{\psi_f\middle|_{B\left(0\,;\,p^{-m}\right)}=0\right\}\\
&=N_m \bbE\int_{B\left(0\,;\,p^{-m}\right)}\left|\det J\psi_f(x)\right|_p dx\\
&= \mu\left(\Qp\GG_{k,n}\right) \cdot p^{m (k + 1)(n - k)} \bbE\int_{B\left(0\,;\,p^{-m}\right)}\left|\det J\psi_f(x)\right|_p dx\quad~\eqref{eq:Um}\\
&=\mu\left(\Qp\GG_{k,n}\right) \cdot p^{m (k + 1)(n - k)} \bbE\\
&\mkern100mu\int_{B\left(0\,;\,p^{-m}\right)}\left(\left|\det\left(J\psi_f(0)\right)\right|_p+o(\|x\|)\right)dx\quad~\eqref{eq:esti}\nonumber\\
&=\lim_{m\,\to\,\infty}\left(\mu\left(\Qp\GG_{k,n}\right) \cdot p^{m (k + 1)(n - k)} \bbE\right.\\
&\mkern100mu\left.\int_{B\left(0\,;\,p^{-m}\right)}\left(\left|\det \left(J\psi_f(0)\right)\right|_p + o(\|x\|)\right)dx\right)\nonumber\\
&=\mu\left(\Qp\GG_{k,n}\right)\bbE\left|\det \left(J\psi_f(0)\right)\right|_p
\end{align}
This concludes the proof of Theorem~\ref{thm:reduction}.
\end{proof}


\subsection{The structure of the matrix \texorpdfstring{$J\psi_f(0)$}{J psif(0)}}\label{Structure}
The random matrix $J(\psi_f(0))$ is filled with random variables uniformly distributed in $\Zp$ and it has a special shape that we are going to compute.

Let us start with the case of points on the intersection of $n$ hypersurfaces in $\QP^n$ i.e. $\nu=n$. For all $ 1\le j\le n$, the polynomial $f_j$ has the form :
\begin{equation}
f_j = \sum_{|\alpha| = d_j} \xi_\alpha^{(j)}x_0^{\alpha_0}\cdots x_n^{\alpha_n}.
\end{equation}
Using~\eqref{eq:trivi}, we have:
\begin{align}
\psi_{f_j}(A)&=f_j\left(y_0
\begin{pmatrix}
1\\
t_1\\
\vdots\\
t_n
\end{pmatrix}\right)=\sum_{|\alpha|=d_j}\xi_\alpha^{(j)} t_1^{\alpha_1}\cdots t_n^{\alpha_n} y_0^{d_j}.
\end{align}
Therefore $\tfrac{\partial \psi_{f_j}(0)}{\partial t_i} = \xi^{(j)}_{d_j - 1, 0, \,\ldots,\,1,\,\ldots,\,0}$, thus $J\psi_f(0)$ has the following shape:
\begin{equation}\label{eq: k = 0}
J\psi_f(0) =
\begin{pmatrix}
\xi_{d_1-1,1,0,\,\ldots,\,0}^{(1)} & \dots & \xi_{d_1-1,0,\,\ldots,\,0,1}^{(1)}\\
\vdots & & \vdots\\
\xi_{d_n-1,1,0,\,\ldots,\,0}^{(n)}& \ldots & \xi_{d_n-1,0,\,\ldots,\,0,1}^{(n)}
\end{pmatrix}.
\end{equation}

Let us now consider the case of lines on a cubic surface i.e. $n=3$, $\nu=1$, and $d = 3$. In this case, for a matrix $A=(
\begin{smallmatrix}t_1&t_2\\t_3&t_4
\end{smallmatrix})$, using~\eqref{eq:trivi}, we can write:
\begin{align*}
\psi_f(A)&=f\left(y_0
\begin{pmatrix}
1\\
0\\
t_1\\
t_3
\end{pmatrix}+y_1
\begin{pmatrix}
0\\
1\\
t_2\\
t_4
\end{pmatrix}\right)\\
&=\sum_{|\alpha|=3}\xi_{\alpha}y_0^{\alpha_0}y_1^{\alpha_1}\left(y_0t_1+y_1t_2\right)^{\alpha_2}\left(y_0t_3+y_1t_4\right)^{\alpha_3}
\end{align*}
Therefore $J\psi_f(0)$ has the following shape:
\[
J\psi_f(0)=
\begin{pmatrix}
\xi_{2010} &0 &\xi_{2001} &0 \\
\xi_{1110} &\xi_{2010} &\xi_{1101} &\xi_{2001} \\
\xi_{0210} &\xi_{1110} &\xi_{0201} &\xi_{1101} \\
0 &\xi_{0210} &0 &\xi_{0201}
\end{pmatrix}.
\]
A simple computation generalizing this shows that for the case of lines on an hypersurface of degree~$2n-3$ we have (nonzero entries are uniform random variables in the unit ball):
\[
J\psi_f(0)=
\begin{pmatrix}
\xi_{1, 1}& 0& \dots & \xi_{1, n - 1}& 0\\
\xi_{2, 1}& \xi_{1, 1}& \dots & \xi_{2, n - 1}& \xi_{1, n - 1}\\
\vdots & \xi_{2, 1} & &\vdots & \xi_{2, n - 1}\\
\xi_{2n-3, 1}& \vdots && \xi_{2n-3, n-1}& \vdots\\
0& \xi_{2n - 3, 1} & \dots & 0& \xi_{2n-3,n-1}
\end{pmatrix}
\]
(here the variables $\xi_{i,j}$ are some of the coefficients of $f$).

Before giving the general construction let us study the case of lines on the intersection of two quadrics i.e. the case when $\nu = 2, d_1 = 2, d_2 = 2$, and $n = 4$.

In this case the matrix $A$ has the form
\[
A =
\begin{pmatrix}
t_0^{(1)} & t_1^{(1)} \\
t_0^{(2)} & t_1^{(2)} \\
t_0^{(3)} & t_1^{(3)}
\end{pmatrix},
\]
which implies
\begin{multline}
\psi_{f_1}(A)\\
\begin{aligned}
&= f_1\left(
\begin{pmatrix}
\bfun_2\\
A
\end{pmatrix}
\begin{pmatrix}
y_0\\
y_1
\end{pmatrix}
\right)\\
&= \sum_{|\alpha| = 2} \xi_\alpha^{(1)}y_0^{\alpha_0} y_1^{\alpha_1}\left(t_0^{(1)} y_0 + t_1^{(1)} y_1\right)^{\alpha_2} \left(t_0^{(2)} y_0 + t_1^{(2)} y_1\right)^{\alpha_3}\left(t_0^{(3)} y_0 + t_1^{(3)} y_1\right)^{\alpha_4}.
\end{aligned}
\end{multline}



Note that we have the following:
\begin{equation}
\tfrac{d \psi_{f_1}(0)}{d t_0^{(1)}} = \left(
\begin{matrix}
\xi^{(1)}_{ 1, 0, 1, 0, 0} \\ \xi^{(1)}_{0, 1, 1, 0, 0} \\ 0
\end{matrix}\right), \quad \tfrac{d \psi_{f_1}(0)}{d t_1^{(1)}} = \left(
\begin{matrix}
0 \\ \xi^{(1)}_{ 1, 0, 1, 0, 0} \\ \xi^{(1)}_{0, 1, 1, 0, 0} \\
\end{matrix}\right),\quad \tfrac{d \psi_{f_1}(0)}{d t_0^{(2)}} = \left(
\begin{matrix}
\xi^{(1)}_{ 1, 0, 0, 1, 0} \\ \xi^{(1)}_{0, 1, 0, 1, 0} \\ 0
\end{matrix}\right)
\end{equation}

\begin{equation}
\tfrac{d \psi_{f_1}(0)}{d t_1^{(1)}} = \left(
\begin{matrix}
0 \\ \xi^{(1)}_{ 1, 0, 0, 1, 0} \\ \xi^{(1)}_{0, 1, 0, 1, 0} \\
\end{matrix}\right), \quad\tfrac{d \psi_{f_1}(0)}{d t_0^{(3)}} = \left(
\begin{matrix}
\xi^{(1)}_{ 1, 0, 0, 0, 1} \\ \xi^{(1)}_{0, 1, 0, 0, 1} \\ 0
\end{matrix}\right),\quad \tfrac{d \psi_{f_1}(0)}{d t_1^{(1)}} = \left(
\begin{matrix}
0 \\ \xi^{(1)}_{ 1, 0, 0, 0, 1} \\ \xi^{(1)}_{0, 1, 0, 0, 1} \\
\end{matrix}\right).
\end{equation}

Therefore
\[
J\psi_{f_1} (0) =
\begin{pmatrix}
\xi^{(1)}_{1, 0, 1, 0, 0} & 0 & \xi^{(1)}_{1, 0, 0, 1,0} & 0 & \xi^{(1)}_{1, 0, 0, 0, 1} & 0\\
\xi^{(1)}_{0, 1, 1, 0, 0} & \xi^{(1)}_{1, 0, 1, 0, 0} & \xi^{(1)}_{0, 1, 0, 1, 0} & \xi^{(1)}_{1, 0, 0, 1, 0} & \xi^{(1)}_{0, 1, 0, 0, 1} & \xi^{(1)}_{1, 0, 0, 0, 1}\\
0 & \xi^{(1)}_{0, 1, 1, 0, 0} & 0 & \xi^{(1)}_{0, 1, 0, 1, 0} & 0 & \xi^{(1)}_{0, 1, 0, 0, 1 }
\end{pmatrix}.
\]
In a similar way we find that
\[
J\psi_{f_2}(0) =
\begin{pmatrix}
\xi^{(2)}_{1, 0, 1, 0, 0} & 0 & \xi^{(2)}_{1, 0, 0, 1,0} & 0 & \xi^{(2)}_{1, 0, 0, 0, 1} & 0\\
\xi^{(2)}_{0, 1, 1, 0, 0} & \xi^{(2)}_{1, 0, 1, 0, 0} & \xi^{(2)}_{0, 1, 0, 1, 0} & \xi^{(2)}_{1, 0, 0, 1, 0} & \xi^{(2)}_{0, 1, 0, 0, 1} & \xi^{(2)}_{1, 0, 0, 0, 1}\\
0 & \xi^{(2)}_{0, 1, 1, 0, 0} & 0 & \xi^{(2)}_{0, 1, 0, 1, 0} & 0 & \xi^{(2)}_{0, 1, 0, 0, 1 }
\end{pmatrix}.
\]
Therefore $J\psi_{f} (0)$ is given as follow:
\[
J\psi_{f} (0) =
\begin{pmatrix}
\xi^{(1)}_{1, 0, 1, 0, 0} & 0 & \xi^{(1)}_{1, 0, 0, 1,0} & 0 & \xi^{(1)}_{1, 0, 0, 0, 1} & 0\\
\xi^{(1)}_{0, 1, 1, 0, 0} & \xi^{(1)}_{1, 0, 1, 0, 0} & \xi^{(1)}_{0, 1, 0, 1, 0} & \xi^{(1)}_{1, 0, 0, 1, 0} & \xi^{(1)}_{0, 1, 0, 0, 1} & \xi^{(1)}_{1, 0, 0, 0, 1}\\
0 & \xi^{(1)}_{0, 1, 1, 0, 0} & 0 & \xi^{(1)}_{0, 1, 0, 1, 0} & 0 & \xi^{(1)}_{0, 1, 0, 0, 1 }\\
\xi^{(2)}_{1, 0, 1, 0, 0} & 0 & \xi^{(2)}_{1, 0, 0, 1,0} & 0 & \xi^{(2)}_{1, 0, 0, 0, 1} & 0\\
\xi^{(2)}_{0, 1, 1, 0, 0} & \xi^{(2)}_{1, 0, 1, 0, 0} & \xi^{(2)}_{0, 1, 0, 1, 0} & \xi^{(2)}_{1, 0, 0, 1, 0} & \xi^{(2)}_{0, 1, 0, 0, 1} & \xi^{(2)}_{1, 0, 0, 0, 1}\\
0 & \xi^{(2)}_{0, 1, 1, 0, 0} & 0 & \xi^{(2)}_{0, 1, 0, 1, 0} & 0 & \xi^{(2)}_{0, 1, 0, 0, 1 }
\end{pmatrix}.
\]
For the general case of $k$-flats on the complete intersection $Z(f_1,\,\ldots,\,f_\nu)$:
\[
J\psi_f(0)=
\begin{pmatrix}
M_1\\
\vdots\\
M_j\\
\vdots\\
M_\nu
\end{pmatrix},
\]
where $M_j$ is the Jacobian of the map given by the restriction of the polynomial $f_j$ to the space $\{x_{k+1}=\ldots=x_n=0\}$. Using again~\eqref{eq:trivi} we get:
\begin{multline}
f_j\left(
\begin{pmatrix}
\bfun_{k+1} \\
A
\end{pmatrix}y\right)\\
=\sum_\alpha \xi_\alpha^{(j)} y_0^{\alpha_0}\cdots y_k^{\alpha_k}\left(y_0t_0^{(1)}+\ldots+ y_kt_k^{(1)}\right)^{\alpha_{k+1}}\cdots \left(y_0t_0^{(n-k)}+\ldots+ y_kt_k^{(n-k)}\right)^{\alpha_n}
\end{multline}
Thus the row corresponding to $y_0^{u_0}\cdots y_k^{u_k}$ ($u_0+\ldots +u_k=d_j$) in the matrix $M_j$ is given as follows:
\begin{align}
&\left(\beta_{u_0-1,u_1,\,\cdots,\,u_k,1,0,\,\cdots,\,0}^{(j)},\,\cdots,\,\beta_{u_0,u_1,\,\cdots,\,u_k-1,1,0,\,\ldots,\,0}^{(j)}\right)\ldots\\
\ldots&\left(\beta_{u_0-1,u_1,\,\cdots,\,u_k,0,\,\cdots,\,0,1}^{(j)},\,\cdots,\,\beta_{u_0,u_1,\,\cdots,\,u_k-1,0,\,\cdots,\,0,1}^{(j)}\right)),
\end{align}
where
\[
\beta_{u_0,\,\ldots,\,u_i-1,\,\ldots,\,u_k,0\,\ldots,\,1,\,\ldots,\,0}^{(j)}=
\begin{cases}
0 \quad \text{if } u_i=0\\
\xi_{u_0,\,\ldots,\,u_i-1,\,\ldots,\,u_k,0\,\ldots,\,1,\,\ldots,\,0} ^{(j)}\quad \text{if } u_i\ge 1
\end{cases}
\]

\begin{rema}
Every entry that is not $0$ in the matrix $J\psi_f(0)$ is repeated exactly $k+1$ times and appears in different rows.
\end{rema}

\subsection{Proof of Theorem~\ref{thm:complete}}\label{sect3.3}
We first need to prove the following lemma:

\begin{lemm}\label{lemma : mod p}
Let $F \in \bbZ[x_1, \ldots, x_n] $ be a non-zero polynomial then:
\[
\lim_{p\,\rightarrow\,+ \infty} \frac{\#\left\{ F = 0 \text{ in } \bbZ/p\bbZ\right\}}{p^n} = 0.
\]
\end{lemm}

\begin{proof}
Let $m_1$ the degree of $x_1$ in the polynomial $F$. We can write $F$ as follows:
\[
F = P_{m_1} x_1^{m_1} + \cdots + P_1 x_1 + P_0.
\]
Then $\#\{ F = 0 \text{ in } \bbZ/p\bbZ\} \leq m_1 p ^{n - 1} + \#\{ P_{m_1} = 0 \text{ in } \bbZ/p\bbZ\}$ where $P_{m_1}$ involves a lower number of variables. We apply the same procedure several times and we get:
\[
\#\left\{ F = 0 \text{ in } \bbZ/p\bbZ\right\} \leq m_1 p^{ n - 1} + m_2 p^{ n - 2} + \cdots + m_n
\]
which conclude the proof.
\end{proof}

Now we apply the previous lemma to prove Theorem~\ref{thm:complete}. Note the:
\begin{align*}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}&\ge \bbP\left(\left|\det\left(J\psi_f(0)\right)\right|_p=1\right)\\
& = 1- \bbP\left(\det\left(J\psi_f(0)\right) = 0 \, (mod \, p)\right)\\
& = 1 - \frac{\#\left\{ \det\left(J\psi_f(0)\right) = 0 \text{ in } \bbZ/p\bbZ\right\}}{p^s}
\end{align*}
where $s$ denotes the number of random variables involved in the random matrix $J\psi_f(0)$.

Recall that $J\psi_f(0)$ is given as the jacobian matrix of the random section $\sigma_f$ of the vector bundle~\eqref{eq:bundles}. Since $\sigma_f$ is transversal to the zero section generically (by~\cite[Théorème~2.1]{debarremanivel}) then $J\psi_f(0)$ is non-singular with probability $1$, hence $\det(J\psi_f(0))$ can not be identically zero. Thus applying Lemma~\ref{lemma : mod p} we have that:
\begin{equation}\label{eq:1}
\lim_{p\,\rightarrow\,+ \infty} \bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}\ge 1.
\end{equation}
On the other hand we have: 
\begin{equation}\label{eq:2}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}\leq1,
\end{equation}
because $\det(J\psi_f(0))$ takes its values in $\Zp$. Using~\eqref{eq:volGL} for $\la(\GL_m(\Zp))$, we see that
\begin{equation}\label{eq:3}
\lim_{p\,\rightarrow\,+\infty}\frac{\la\left(\GL_{n+1}(\Zp)\right)}{\la\left(\GL_{k+1}(\Zp)\right)\cdot \la\left(\GL_{n-k}(\Zp)\right)}=1.
\end{equation} 
Hence, using Theorem~\ref{thm:reduction}, \eqref{eq:1}, \eqref{eq:2} and~\eqref{eq:3}, we conclude that
\begin{equation}
\lim_{p\,\to\,\infty}\bbE\#\left\{\text{$k$-flats on }Z\left(f_1,\,\ldots,\,f_\nu\right)\subset \QP^n\right\}=1.
\end{equation}


\subsection{Proof of Theorem~\ref{thm:complete0}}
From Section~\ref{Structure}, the matrix $J\psi_f(0)$ is given in~\eqref{eq: k = 0} as a random matrix with all entries which are random independent variables uniformly distributed in $\Zp$. This is independent of the choice of the degrees $d_1,\,\ldots,\,d_n$. Therefore, the expected number of points on $Z(f_1,\,\ldots,\,f_n)$ when the degrees $d_1,\,\ldots,\,d_n$ are arbitrary is the same when $d_1=\ldots=d_n=1$. Thus this is exactly the number of points in the intersection of $n$ generic hyperplanes lying in $\QP^n$. Therefore,
\[
\bbE\#Z\left(f_1,\,\ldots,\,f_n\right)=1.
\]

\begin{coro}\label{coro:matrix}
Let $M_n$ a random matrix in $\Zp^{n\times n}$ whose entries are random independent variables uniformly distributed in $\Zp$. Then:
\begin{equation}\label{eq:detM}
\bbE\left\{\left|\det(M_n)\right|_p\right\}=\frac{(p-1)p^n}{p^{n+1}-1}.
\end{equation}
\end{coro}


\begin{proof}
This is a direct consequence of Theorem~\ref{thm:complete0} and Theorem~\ref{thm:reduction}:
\begin{equation}
\begin{split}
1=\bbE\# Z(f_1,\,\ldots,\, f_n) &=\mu\left(\QP^n\right)\cdot \bbE\left\{\left|\det M_n\right|_p\right\}\\
&=\frac{p^{n+1}-1}{p^n(p-1)}\cdot \bbE\left\{\left|\det M_n\right|_p\right\},
\end{split}
\end{equation}
from which~\eqref{eq:detM} follows.
\end{proof}
\begin{rema}
The previous corollary can be also obtained by an inductive process on the size of the matrix. We refer to~\cite{EVANS200289} for more results about the distribution of the random matrix $M_n$.
\end{rema}


\subsection{Proof of Theorem~\ref{thm:cubic}}\label{sect3.5}
\begin{proof}
Applying Theorem~\ref{thm:reduction} in the case $k=1$, $\nu=1$ and $d=3$ we get:
\[
\bbE\#\left\{\sigma_f=0\right\}=\frac{\la\left(\GL_{4}(\bbZ_p)\right)}{\la\left(\GL_2(\Zp)\right)^2}\cdot \bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}.
\]
By~\eqref{eq:volGL} we have:
\begin{equation}\label{eq:sv}
\frac{\la\left(\GL_{4}(\bbZ_p)\right)}{\la\left(\GL_2(\Zp)\right)^2} =\frac{\left(p^3-1\right)\left(p^2+1\right)}{p^4(p-1)},
\end{equation}
it remains to compute $\bbE\{|\det(J\psi_f(0)|_p\}$ where
\[
J\psi_f(0)=
\begin{pmatrix}
\xi_1 & 0 & \xi_4 & 0\\
\xi_2 & \xi_1 & \xi_5 & \xi_4\\
\xi_3& \xi_2& \xi_6 & \xi_5\\
0& \xi_3 & 0& \xi_6
\end{pmatrix}
\]
and $\xi_1,\,\ldots,\,\xi_6$ are random variables i.i.d uniformly distributed in $\Zp$.

By Lemma~\ref{lemma:integral}, we can compute the expectation of $\det(J\psi_f(0))= (\xi_1\xi_6-\xi_3\xi_4)^2\linebreak-(\xi_1\xi_5-\xi_2\xi_4)(\xi_2\xi_6-\xi_3\xi_5)$ as:
\begin{multline}\label{eq:sum1}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}\\
=\lim_{n\,\rightarrow\,\infty} \frac{1}{p^{6n}}\sum_{0\,\le\,\xi_1,\,\ldots,\,\xi_6\,\le\,p^n-1} \left|\left(\xi_1\xi_6-\xi_3\xi_4\right)^2-\left(\xi_1\xi_5-\xi_2\xi_4\right)\left(\xi_2\xi_6-\xi_3\xi_5\right)\right|_p.
\end{multline}

We are going now to introduce an alternative way of performing the summation in~\eqref{eq:sum1}.

Let us introduce first the following notation:
\begin{equation} 
\bbP^2\left(\Zn\right):=\left(\left(\Zn\right)^3\setminus (0,0,0)\right)\big/\sim,
\end{equation}
where $(x,y,z)\sim (x',y',z')$ if and only if there exists $\la$ invertible in $\Zn$ such that $(x,y,z)=\la(x',y',z')$. We call $[k_1:k_2:k_3]\in \bbP^2(\Zn)$ unit if at least one of the coordinates $k_i$ is invertible in $\Zn$

Observe that to every element $\bm{\xi} : = (\xi_1,\,\ldots, \,\xi_6)\in \Zp^6$ we can associate a matrix $M(\bm{ \xi })$ in $\Zp^{3\times 2}$:
\begin{equation} M(\bm{ \xi }) =
\begin{pmatrix}
\xi_1& \xi_4\\
\xi_2 & \xi_5\\
\xi_3& \xi_6
\end{pmatrix},
\end{equation}
as well as its reduction $\pi_n(M(\bm{ \xi }))\in (\bbZ/p^n\bbZ)^{3\times 2}$ modulo $p^n$. The determinant of $J\psi_f(0)$ is a function of the minors of $M(\bm{ \xi })$. Let $\clM\subset (\bbZ/p^n\bbZ)^{3\times 2}$ be the subset of matrices of maximal rank and let us consider the following map:
\begin{multline*}
h: \clM\subset \left(\bbZ/p^n\bbZ\right)^{3\times 2} \to \bbP^2\left(\bbZ/p^n\bbZ\right) \\
 \left(\xi_1,\, \ldots,\, \xi_6\right)\mapsto \left[\xi_1\xi_5-\xi_2\xi_4: \xi_1\xi_6-\xi_3\xi_4: \xi_2\xi_6-\xi_3\xi_5\right].
\end{multline*}
Observe that $h$ is surjective. Denote by $Q$ the set of elements $[k_1:k_2:k_3]\in \bbP^2(\Zn)$ such that $k_2^2-k_1k_3=0$, and by $S:=h^{-1}(Q)$ the set of matrices in $\clM$ for which the corresponding matrices in $\Zp^{4\times 4}$ have valuation of determinant greater or equal to $n$. Using this notation we see that the sum
\begin{equation}
\sum_{0\,\le\,\xi_1,\,\ldots,\,\xi_6\,\le\, p^n-1} \left|\left(\xi_1\xi_6-\xi_3\xi_4\right)^2-\left(\xi_1\xi_5-\xi_2\xi_4\right)\left(\xi_2\xi_6-\xi_3\xi_5\right)\right|_p
\end{equation}
is bounded from below by
\begin{equation}
L_n:=\sum_{\left[k_1:k_2:k_3\right]\,\not\in\,Q} \#h^{-1}\left(\left[k_1:k_2:k_3\right]\right)\cdot\left|k_2^2-k_1k_3\right|_p,
\end{equation}
and bounded from above by
\begin{equation}\label{eq:5}
R_n:=\sum_{\left[k_1;k_2;k_3\right]\not\in Q}\#h^{-1}\left(\left[k_1:k_2:k_3\right]\right)\cdot \left|k_2^2-k_1k_3\right|_p+
\frac{\#S}{p^n}.
\end{equation} 
In particular, from~\eqref{eq:sum1}, it will follow that:
\begin{equation}\label{eq:sum2}
\lim_{n\,\to\,\infty}\frac{L_n}{p^{6n}}\leq \bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\} \leq\lim_{n\,\to\,\infty} \frac{R_n}{p^{6n}}.
\end{equation}
In Lemma~\ref{lemma:S} below we will prove that
\begin{equation}\label{eq:10}
\lim_{n\,\rightarrow\,+\infty} \frac{\#S}{p^{7n}}=0,
\end{equation}
from which we deduce that:
\begin{equation}\label{eq:a}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\} =\lim_{n\,\to\, \infty}\frac{1}{p^{6n}}\sum_{\left[k_1:k_2:k_3\right]\,\not\in \,Q} \#h^{-1}\left(\left[k_1:k_2:k_3\right]\right)\cdot\left|k_2^2-k_1k_3\right|_p.
\end{equation}

Let us compute the cardinality of the fibers of $h$. To this end, let $[k_1:k_2:k_3]\in \bbP^2(\bbZ/p^n\bbZ)$. Without loss of generality we can assume that:
\begin{equation}
\left[k_1:k_2:k_3\right]= \left[p^{m_1}: p^{m_2}\lambda_2: p^{m_3}\lambda_3\right]
\end{equation}
with $m_1\leq m_2, m_3.$ In Lemma~\ref{lemma:card} we will show that:
\begin{equation} \label{eq:13}
\#h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}\right]\right)=p^{4n-3-m_1}(p-1)(p+1)\left(p^{m_1+1}-1\right).
\end{equation}


Let $0\le m\le n-1$ be such that $p^m$ is the largest power of $p$ that divides all $k_i$ in $[k_1:k_2:k_3]$; such elements $[k_1:k_2:k_3]$ with this property are in bijection with the unit elements in $\bbP^2(\bbZ/p^{n-m}\bbZ)$, via the map that sends $[k_1:k_2:k_3] $ to $[k_1/p^m: k_2/p^m: k_3/p^m]$. Then by~\eqref{eq:13} we have
\begin{equation}\label{eq:ba}
L_n\le\sum_{m=0}^{n-1}\sum_{ \substack{ \left[k_1 : k_2 : k_3\right] \text{ unit } \\\text{ in }\bbP^2\left(\bbZ/p^{n-m}\bbZ\right)}}
\alpha_n\cdot \left(p^{m+1}-1\right)\cdot \frac{\left|k_2^2-k_1k_3\right|_p}{p^{3m}}\le R_n
\end{equation} 
where $\alpha_n:=p^{4n-3}(p-1)(p+1)$.

We will need a further step of reduction. For $1\le k$ let us denote by $A(k)$ the number of unit elements $(k_1,k_2,k_3)\in (\bbZ/p^k\bbZ)^3$ such that
\[
k_2^2-k_1k_3=0\, \left(mod\; p^k\right),
\]
and set $A(0)=1-1/p^3$. We claim that:
\begin{equation}
\lim_{n\,\to\,\infty}\frac{L_n}{p^{6n}}=\lim_{n\,\to\,\infty}\frac{R_n}{p^{6n}}
\end{equation}

\begin{equation}\label{eq:limf}
=\lim_{n\,\to\,\infty}\frac{1}{p^{6n}}\alpha_n \cdot \sum_{m=0}^{n-1}\frac{p^{m+1}-1}{p^{3m}} \sum_{k=0}^{n-m-1} \frac{p^{3(n-m-k)}A(k)-p^{3(n-m-k-1)}A(k+1)}{p^{n-m-1}(p-1)p^k}.
\end{equation}
In fact $p^{3(n-m-k)}A(k)$ represents the number of unit elements 
\[
\left(k_1,k_2,k_3\right)\in \left(\bbZ/p^{n-m}\bbZ\right)^3
\]
such that $|k_2^2-k_1k_3|_p\le p^{-k}$. Therefore,
\[
\frac{p^{3(n-m-k)}A(k)-p^{3(n-m-k-1)}A(k+1)}{p^{n-m-1}(p-1)}
\]
represents the number of unit elements $[k_1:k_2:k_3]\in \bbP^2(\bbZ/p^{n-m}\bbZ)$ such that $|k_2^2-k_1k_3|_p=p^{-k}$. Therefore~\eqref{eq:limf} follows from~\eqref{eq:ba}.

Using the formula for $A(k)$, given below in Lemma~\ref{lemma:Ak}, we have:
\begin{multline*}
\sum_{k=1}^{n-m-1} \frac{A(k)p^{3(n-m-k)}-A(k+1)p^{3(n-m-k-1)}}{p^{k}}\\
\begin{aligned}
&= \sum_{k=1}^{n-m-1}p^{3(n-m-1)}\left(p^{-2k+3}-p^{-2k+1} -p^{-2k+2}+p^{-2k}\right)\\
&= p^{3(n-m-1)}\left(p-p^{-2(n-m-1)+1}-1+p^{-2(n-m-1)}\right),
\end{aligned}
\end{multline*}
and, for $k=0$:
\[
\frac{A(0)p^{3(n-m)}-A(1)p^{3(n-m-1)}}{p^0}=p^{3(n-m-1)}\left(p^3-p^2\right)
\]
In particular we have
%\small
\begin{align*}
&\alpha_n\sum_{m=0}^{n-1} \frac{p^{m+1}-1}{p^{2m}}\sum_{k=0}^{n-m-1} \frac{p^{3(n-m-k)}A(k)-p^{3(n-m-k-1)}A(k+1)}{p^{n+k-1}(p-1)}\\ =&\alpha_n\sum_{m=0}^{n-1}(p^{m+1}-1)p^{2n-5m-2}\left(\frac{p^3-p^2+p-1+p^{-2(n-m-1)}-p^{-2(n-m-1)+1}}{p-1}\right)
\\
=&\alpha_n\sum_{m=0}^{n-1}(p^{m+1}-1)\left(p^{2n-2}\left(p^2+1\right)p^{-5m}-p^{-3m}\right)
\\
=&\alpha_np^{2n-2}\left(p^2+1\right)\sum_{m=0}^{n-1}\left(p^{-4m+1}-p^{-5m}\right)-\alpha_n\sum_{m=0}^{n-1}\left(p^{-2m+1}-p^{-3m}\right)\\
=&\alpha_np^{2n-2}\left(p^2+1\right)\left(\frac{\left(p^{4n}-1\right)p^5}{p^{4n}\left(p^4-1\right)}-\frac{\left(p^{5n}-1\right)p^5}{p^{5n}\left(p^5-1\right)}\right)\\
&\mkern200mu -\alpha_n\left(\frac{p^{2n}-1}{p^{2n-3}\left(p^2-1\right)}-\frac{p^{3n}-1}{p^{3n-3}\left(p^3-1\right)}\right).
\end{align*}
It remains now to put the pieces together. Combining~\eqref{eq:a} with~\eqref{eq:limf}, and substituting the value for $\alpha_n$, we get:
\begin{multline*}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}\\
\begin{aligned}
&=\lim_{n\,\rightarrow\,\infty} \frac{1}{p^{6n}}p^{4n-3}(p-1)(p+1)p^{2n-2}\left(p^2+1\right)\left(\frac{p^5}{p^4-1}-\frac{p^5}{p^5-1}\right)\\
&=\frac{p^4}{p^4+p^3+p^2+p+1}.
\end{aligned}
\end{multline*}
Together with~\eqref{eq:sv} this finally gives:
\begin{equation*}
\bbE\#\left\{\sigma_f=0\right\}=\frac{\left(p^3-1\right)\left(p^2+1\right)}{p^5-1}.
\end{equation*}
This concludes the proof of Theorem~\ref{thm:cubic}. It remains to prove the lemmas that we have used in the proof.
\end{proof}

\begin{lemm}\label{lemma:card}
Using the above notations:
\begin{equation} \#h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}\right]\right)=p^{4n-3-m_1}(p-1)(p+1)\left(p^{m_1+1}-1\right).
\end{equation}
\end{lemm}

\begin{proof}
Now we need to compute $\#h^{-1}([k_1:k_2:k_3])$. This depends only on $m_1$ if we consider $[k_1:k_2:k_3]=[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}]$ as before. Indeed, let $g \in h^{-1}([p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}])$. By Proposition~\ref{SVD}, $g$ has the following form:
\[
g=
\begin{pmatrix}
U
\begin{pmatrix}
p^u & 0\\
0 & p^v
\end{pmatrix}V\\
x \hspace{35pt} y
\end{pmatrix} \in h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}\right]\right),
\]
where $u+v=m_1$ and $U,V$ are invertible matrices in $(\Zn)^{2\times2}$. This is equivalent to
\[
\begin{pmatrix}
U
\begin{pmatrix}
p^u & 0\\
0 & p^v
\end{pmatrix}\\
x' \hspace{35pt} y'
\end{pmatrix} \in h^{-1}\left(\left[p^{m_1}:\lambda_2p^{m_2}:\lambda_3p^{m_3}\right]\right),
\]
where $(x',y')=(x,y)\cdot V^{-1}.$ Set $U=\left(
\begin{smallmatrix}
a & b\\
c & d
\end{smallmatrix}\right)$, then we have
\begin{equation}
\begin{cases}
ay'p^u-bx'p^v=\lambda_2p^{m_2}(ad-bc)\\
cy'p^u-dx'p^v=\lambda_3p^{m_3}(ad-bc)
\end{cases}.
\end{equation}
The previous system is equivalent to
\[
\begin{pmatrix}
a & b\\
c & d
\end{pmatrix}
\begin{pmatrix}
y'p^u\\
-x'p^v
\end{pmatrix}=
\begin{pmatrix}
\lambda_2p^{m_2}(ad-bc)\\
\lambda_3p^{m_3}(ad-bc)
\end{pmatrix},
\]
which gives:
\begin{equation}\label{eq:11}
\begin{pmatrix}
y'p^u\\
-x'p^v
\end{pmatrix}=
\begin{pmatrix}
a & b\\
c & d
\end{pmatrix}^{-1}
\begin{pmatrix}
\lambda_2p^{m_2}(ad-bc)\\
\lambda_3p^{m_3}(ad-bc)
\end{pmatrix}.
\end{equation}
Notice that $m_2,m_3\ge u,v$. For all $z\in \Zn$ the equation $p^vx'=p^vz$ has $p^v$ solutions in $\Zn$. In fact, this is equivalent to $p^{n-v}$ divides $x'-z$. Thus~\eqref{eq:11} has exactly $p^up^v=p^{m_1}$ solutions, which means that we have $p^{m_1}$ choices for $(x,y)$. Therefore, using Lemma~\ref{Cardinal} and~\eqref{eq:12} we finally get:
\begin{multline}
\#h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}\right]\right)\\
=p^{m_1}\cdot \#\left\{M\in (\Zn)^{2\times 2}\, \middle|\, \left|\det(M)\right|_p=p^{-m_1}\right\}
\end{multline}

\begin{align}
&=p^{m_1}\cdot p^{4n}\cdot \la \left(\left\{M\in (\Zp)^{2\times 2}\, \middle|\, \left|\det(M)\right|_p=p^{-m_1}\right\}\right)\\
&=p^{4n-3-m_1}(p-1)(p+1)\left(p^{m_1+1}-1\right).
\end{align}
\end{proof}


\begin{lemm}\label{lemma:S}
Using the above notations we have:
\begin{equation}
\lim_{n\,\rightarrow\,\infty}\frac{\#S}{p^{7n}}=0.
\end{equation}
\end{lemm}


\begin{proof}
We claim first that the number of triples $(k_1,k_2,k_3)\in (\bbZ/p^n\bbZ)^3$ such that $k_2^2-k_1k_3=0$ is less than $2p^{2n}$.

Indeed, suppose first that $k_1=p^uk_1'\ne 0$ ($0\le u\le n-1$) with $k_1'$ invertible. Then $k_1k_3-k_2^2=0$ if and only if $p^uk_3=k_2^2\cdot k_1'^{-1}$. Fixing $k_1'$ and $k_2$, the last equation has either $p^u$ or $0$ solutions for $k_3$, depending on whether the valuation of $k_2$ is less than $u/2$ or not. Then the number of elements $k_2$ for which the equation has solutions is $\le p^{n-u/2}$. Therefore, the number of triples $(k_1,k_2,k_3)$ such that $k_2^2=k_1k_3$ and $k_1\ne 0$ is less than or equal to
\begin{equation*}
\sum_{u=0}^{n-1} p^{n-u-1}(p-1)p^up^{n-u/2}=p^{2n-1}(p-1)\cdot\frac{p^{n/2}-1}{p^{n/2}}\cdot \frac{p^{n/2}}{p^{n/2}-1} \leq 2p^{2n-1}(p-1).
\end{equation*}

For the case when $k_1=0$ we must have also $k_2=0$, hence in this case there exist $p^n$ triples $(k_1,k_2,k_3)$ solving $k_2^2-k_1k_3=0$. In particular the number of solution of $k_2^2-k_1k_3=0$ in $(\bbZ/p^n\bbZ)^3$ is less than $2p^{2n-1}(p-1)+p^n\leq 2p^{2n}$, as claimed.

By~\eqref{eq:13}, for every element $\left[k_1:k_2:k_3\right]\in \bbP^2(\bbZ/p^n\bbZ) $ we have
\[
\#h^{-1}(\left[k_1;k_2;k_3\right]) \le p^{4n-3}(p-1)(p+1)\frac{p^{n}-1}{p^{n-1}}.
\]
Therefore,
\[
\#S\le p^{4n-3}(p-1)(p+1)\frac{p^{n}-1}{p^{n-1}}2p^{2n}\leq O\left(p^{6n}\right),
\]
which immediately implies:
\[
\lim_{n\,\rightarrow\,\infty}\frac{\#S}{p^{7n}}=0.\qedhere
\]
\end{proof}

\begin{lemm}\label{lemma:Ak}
Using the above notations,
\begin{equation} 
\forall\, k\ge 1:\, A(k)=p^{2k}-p^{2k-2}
\end{equation}
\end{lemm}

\begin{proof}
Suppose $k_2$ is invertible, then also $k_1$ and $k_3$ must be invertible. By fixing specific values for $k_1$ and $k_2$, there exists only one possible value for $k_3$ for which $k_2^2-k_1k_3=0$. Therefore in this case we have $p^{2(k-1)}(p-1)^2$ elements $(k_1,k_2,k_3)$ satisfying the equation $k_2^2-k_1k_3=0$. Let us now suppose that $k_2$ is not invertible, then either $k_1$ or $k_3$ is invertible. Without loss of generality suppose $k_1$ is invertible, again $k_3$ can have only one unique value whenever you fix $k_2$ and $k_1$. Therefore in this case we have $2p^{2(k-1)}(p-1)$, and hence we get $A(k)=p^{2k}-p^{2k-2}$.
\end{proof}

\subsection{The intersection of two quadrics}\label{sect3.6} 
Let us consider now the problem of counting lines on a complete intersection of two quadrics ($\nu=2$ and $d_1=d_2=2$). Using Section~\ref{Structure}, the matrix $J\psi_f(0)$ in this case is given as follow:
\begin{equation}\label{eq:Jacobi}
J\psi_f(0)=
\begin{pmatrix}
a_1 & 0& b_1 & 0 & c_1 &0\\
a_2 & a_1 & b_2 & b_1 & c_2& c_1\\
0 & a_2 & 0 & b_2 & 0 & c_2\\
a'_1 & 0& b'_1 & 0 & c'_1 &0\\
a'_2 & a'_1 & b'_2 & b'_1 & c'_2& c'_1\\
0 & a'_2 & 0 & b'_2 & 0 & c'_2
\end{pmatrix}.
\end{equation} 
We can exchange some rows and columns, without changing the valuation of the determinant, and get the following matrix:
\[
\begin{pmatrix}
a_1 & b_1 & c_1 & 0& 0& 0 \\
a_2& b_2 & c_2 & a_1& b_1 & c_1\\
a'_1& b'_1& c'_1 & 0 & 0 &0\\
a'_2 & b'_2& c'_2 & a'_1 & b'_1 & c'_1\\
0& 0& 0 & a_2 & b_2 & c_2\\
0 & 0 & 0 & a'_2 & b'_2 & c'_2
\end{pmatrix}.
\]
Notice that in this case $\det(J\psi_f(0))=k_1k_4-k_2k_3 $ where $k_1,\,\ldots,\,k_4$ are the minors of the matrix
\[
\begin{pmatrix}
a_1 & b_1 & c_1\\
a_2& b_2 & c_2\\
a'_1& b'_1& c'_1\\
a'_2 & b'_2& c'_2
\end{pmatrix}.
\]
The special shape of this matrix allows us to apply the ideas of the proof of Theorem~\ref{thm:cubic} and get the following result.

\subsubsection{Proof of Theorem~\ref{thm:quadrics}}

\begin{proof}
Applying Theorem~\ref{thm:reduction} in the case $k=1$, $\nu=2$, and $n=4$ we get:
\begin{equation}
\bbE\#\left\{\sigma_f=0\right\}=\frac{\la\left(\GL_5(\Zp)\right)}{\la\left(\GL_3(\Zp)\right)\cdot \la\left(\GL_2(\Zp)\right)}\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\},
\end{equation}
where $J\psi_f(0)$ is given by~\eqref{eq:Jacobi}. By~\eqref{eq:volGL} we have:
\begin{equation}\label{eq:volume}
\frac{\la\left(\GL_5(\Zp)\right)}{\la\left(\GL_3(\Zp)\right)\cdot \la\left(\GL_2(\Zp)\right)}=\frac{\left(p^4-1\right)\left(p^5-1\right)}{p^6(p-1)\left(p^2-1\right)}.
\end{equation}
It remains to compute $\bbE\{|\det(J\psi_f(0))|_p\}$. By Lemma~\ref{lemma:integral} we have:
\begin{equation}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}=\lim_{n\,\to\,+\infty}\frac{1}{p^{12n}}\sum_{0\,\le\, \xi_1\,\ldots\,\xi_{12}\,\le\,p^n-1} \left|\det\left(M\left(\xi_1,\,\ldots,\,\xi_{12}\right)\right)\right|_p
\end{equation}
where
\begin{equation}\label{eq:17}
M\left(\xi_1,\,\ldots,\,\xi_{12}\right)=
\begin{pmatrix}
\xi_1 & \xi_2 & \xi_3 & 0& 0& 0 \\
\xi_4& \xi_5 & \xi_6 & \xi_1& \xi_2 & \xi_3\\
\xi_7& \xi_8& \xi_9 & 0 & 0 &0\\
\xi_{10} & \xi_{11}& \xi_{12} & \xi_4 & \xi_5 & \xi_6\\
0& 0& 0 & \xi_7 & \xi_8 & \xi_9\\
0 & 0 & 0 & \xi_{10} & \xi_{11} & \xi_{12}
\end{pmatrix}.
\end{equation}
We are going to follow the same reasoning of the proof of Theorem~\ref{thm:cubic}. Let us first consider the following surjective map:
\begin{align*}
h: \clM\subset \left(\bbZ/p^n\bbZ\right)^{4\times 3} &\to \bbP^3(\bbZ/p^n\bbZ) \\
 \left(\xi_1,\,\ldots,\,\xi_{12}\right)&\mapsto \left[k_1:k_2:k_3:k_4\right],
\end{align*}
where $\clM$ is the subset of matrices with full rank, and $k_1,\,\ldots,\,k_4$ are the minors of the following matrix:
\begin{equation}
\begin{pmatrix}
\xi_1 &\xi_2 &\xi_3\\
\xi_4 & \xi_5 &\xi_6\\
\xi_7 & \xi_8 & \xi_9\\
\xi_{10} & \xi_{11} & \xi_{12}
\end{pmatrix}.
\end{equation}
Therefore the sum
\begin{equation}
\sum_{0\,\le\,\xi_1\,\ldots\,\xi_{12}\,\le \,p^n-1}\left|\det\left(M\left(\xi_1, \,\ldots,\,\xi_{12}\right)\right)\right|_p
\end{equation}
is bounded from below by:
\[
L_n':=\sum_{\left[k_1:\cdots:k_4\right]\,\in\,\bbP^2\left(\Zn\right)\setminus Q} \#h^{-1}\left(\left[k_1:k_2:k_3:k_4\right]\right)\left|k_1k_4-k_2k_3\right|_p
\]
and from above by:
\[
R_n':=\sum_{\left[k_1:\cdots:k_4\right]\,\in\,\bbP^2\left(\Zn\right)\setminus Q} \#h^{-1}\left(\left[k_1:k_2:k_3:k_4\right]\right)\left|k_1k_4-k_2k_3\right|_p+ \frac{\#S}{p^n}.
\]
Here $Q$ is the set of $[k_1:k_2:k_3:k_4]\in \bbP^3(\bbZ/p^{n}\bbZ)$ such that $k_1k_4-k_2k_3=0$, and $S:=h^{-1}(Q)$ consists of matrices $ \clM$ for which the corresponding matrices $M(\xi_1,\,\ldots,\,\xi_{12}) \in (\Zp)^{6\times 6}$ have valuation of determinant greater or equal $n$.

We will show in Lemma~\ref{lemma:SS} below that:
\begin{equation}
\lim_{n\,\to\,+\infty}\frac{\#S}{p^{13n}}=0,
\end{equation}
which implies:

\begin{align}\label{eq:ex}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}&=\lim_{n\,\to\,+\infty}\frac{L_n'}{p^{12n}}\\
&=\lim_{n\,\to\,+\infty}\frac{R_n'}{p^{12n}}
\end{align}

Let us compute the cardinality of the fibers of $h$. To this end, let $[k_1:k_2:k_3 : k_4]\in \bbP^3(\bbZ/p^n\bbZ)$. Without loss of generality we can assume that:
\begin{equation}
\left[k_1:k_2:k_3:k_4\right]= \left[p^{m_1}: p^{m_1}\lambda_2: p^{m_3}\lambda_3:p^{m_4}\la_4\right],
\end{equation}
with $m_1\leq m_2, m_3,m_4.$ In Lemma~\ref{lemma:Fbr} we will show that:
\begin{multline}
h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}:\la_4p^{m_4}\right]\right)\\
= p^{9n-6-m_1}\left(p^{3}-1\right)\left(p^{m_1+1}-1\right)\left(p^{m_1+2}-1\right).
\end{multline}

Set $B(0)=1-\tfrac{1}{p^4}$ and for $k\ge 1$, let us denote by $B(k)$ the number of unit elements $(k_1,k_2,k_3,k_4)\in (\bbZ/p^k\bbZ)^4$ such that
\begin{equation}
k_1k_4-k_2k_3=0
\end{equation}
Reasoning as in the proof of Theorem~\ref{thm:cubic} we get:
\begin{multline}
L_n'
\\
\begin{aligned}
&\le \beta_n\cdot \sum_{m=0}^{n-1}\frac{(p^{m+1}-1)(p^{m+2}-1)}{p^{3m}(p-1)}\sum_{k=0}^{n-m-1}\frac{B(k)p^{4(n-m-k)}-B(k+1)p^{4(n-m-k-1)}}{p^{n-m-1+k}} \\
&\le R_n',
\end{aligned}
\end{multline}
where $\beta_n=p^{9n-6}(p^3-1)$.

By~\eqref{eq:ex} we get
\begin{equation}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}=\lim_{n\,\to\, \infty}\frac{T_n}{p^{12n}},
\end{equation}
where:
\begin{multline} 
T_n:=\\
\beta_n \sum_{m=0}^{n-1}\frac{\left(p^{m+1}-1\right)\left(p^{m+2}-1\right)}{p^{3m}(p-1)}\sum_{k=0}^{n-m-1}\frac{B(k)p^{4(n-m-k)}-B(k+1)p^{4(n-m-k-1)}}{p^{n-m-1+k}}.
\end{multline}

Using the formula for $B(k)$ which is given in Lemma~\ref{lemma:Bk} below we have, for $k\ge 1$:
\[
\frac{B(k)p^{4(n-m-k)}-B(k+1)p^{4(n-m-k-1)}}{p^k}=p^{4(n-m-1)}\left(p^{-2k+4}-2p^{-2k+2}+p^{-2k}\right),
\]
and
\begin{multline*}
\sum_{k=1}^{n-m-1}\frac{B(k)p^{4(n-m-k)}-B(k+1)p^{4(n-m-k-1)}}{p^{k}}\\
=p^{4(n-m-1)}\left(p^2-1-p^{-2n+2m+4}+p^{-2n+2m+2}\right).
\end{multline*}
For $k=0$ we have
\[
\frac{B(0)p^{4(n-m)}-B(1)p^{4(n-m-1)}}{p^0}=p^{4(n-m-1)}(p^4-p^3-p^2+p).
\]
Putting these two together, we have:
\begin{multline*}
\sum_{k=0}^{n-m-1}\frac{B(k)p^{4(n-m-k)}-B(k+1)p^{4(n-m-k-1)}}{p^{k}}\\
=p^{4(n-m-1)}\left(p^3+1\right)(p-1)-p^{2(n-m-1)}\left(p^2-1\right).
\end{multline*}
In particular,
\begin{align}
T_n&=\beta_n \sum_{m=0}^{n-1}\frac{\left(p^{m+1}-1\right)\left(p^{m+2}-1\right)}{p^{3m}}\left(p^3+1\right)p^{3(n-m-1)} \\
& - \beta_n \sum_{m=0}^{n-1}\frac{\left(p^{m+1}-1\right)\left(p^{m+2}-1\right)}{p^{3m}}(p+1)p^{n-m-1} \\
&=\beta_n\left(p^3+1\right)p^{3(n-1)}\sum_{m=0}^{n-1}\frac{p^{2m+3}-p^{m+2}-p^{m+1}+1}{p^{6m}}-\beta_n O\left(p^n\right)\\
&=\beta_n\left(p^3+1\right)p^{3(n-1)}\sum_{m=0}^{n-1}\left(p^{-4m+3}-p^{-5m+2}-p^{-5m+1}+p^{-6m}\right)-O(p^{10n})\\
&=\beta_n\left(p^3+1\right)p^{3(n-1)}\\
&\qquad\left(p^3\frac{p^{4n}-1}{p^4-1}\frac{p^4}{p^{4n}}-p^2\frac{p^{5n}-1}{p^5-1}\frac{p^5}{p^{5n}}-p\frac{p^{5n}-1}{p^5-1}\frac{p^5}{p^{5n}}+\frac{p^{6n}-1}{p^{6}-1}\frac{p^6}{p^{6n}}\right)\nonumber\\
&-O\left(p^{10n}\right)
\end{align}
Therefore,
\begin{align}
\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}=\lim_{n\,\to\,+\infty}\frac{T_n}{p^{12n}}=&\frac{p^6-1}{p^3}\left(\frac{p}{p^4-1}-\frac{p+1}{p^5-1}+\frac{1}{p^6-1}\right).
\end{align}
Multiplying this equation with~\eqref{eq:volume} we get:
\[
\bbE\#\left\{\text{lines on the intersection of two quadrics in } \QP^4\right\}=1.
\]
This concludes the proof of our Theorem~\ref{thm:quadrics}.
\end{proof}
It remains to prove the lemmas that we have used.

\begin{lemm}\label{lemma:Fbr}
Using the above notations we have:
\begin{multline}
h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}:\la_4p^{m_4}\right]\right)\\
= p^{9n-6-m_1}\left(p^{3}-1\right)\left(p^{m_1+1}-1\right)\left(p^{m_1+2}-1\right).
\end{multline}
\end{lemm}

\begin{proof}
Arguing as before, let us write a point in the fiber of $h$ as:
\[
g=
\begin{pmatrix}
U
\begin{pmatrix}
p^u & 0 & 0\\
0 & p^v & 0\\
0 & 0 & p^w
\end{pmatrix}V\\
x \hspace{29pt} y \hspace{29pt} z
\end{pmatrix} \in h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}: \la_4p^{m_4}\right]\right)
\]
where $u+v+w=m_1$ and $U,V$ are invertible matrices in $(\Zn)^{3\times3}$.

Set
\[
U=
\begin{pmatrix}
a&b&c\\
d&e&f\\
g&h&k
\end{pmatrix}.
\]
Then
\[
gV^{-1}=
\begin{pmatrix}
ap^u & bp^v & cp^w\\
dp^u & ep^v & fp^w\\
gp^u & hp^v & kp^w\\
x' & y' & z'
\end{pmatrix}\\
\in h^{-1}\left(\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}: \la_4p^{m_4}\right]\right)
\]
if and only if
\[
\begin{cases}
x'p^{v+w}(bf-ce)-y'p^{u+w}(af-cd)+z'p^{u+v}(ae-bd)=\la_2p^{m_2}\det(U)\\
x'p^{v+w}(bk-ch)-y'p^{u+w}(ak-cg)+z'p^{u+v}(ah-bg)=\la_3p^{m_3}\det(U)\\
x'p^{v+w}(ek-fh)-y'p^{u+w}(dk-fg)+z'p^{u+v}(dh-eg)=\la_4p^{m_4}\det(U)
\end{cases}
\]
In other words:
\[
\begin{pmatrix}
p^{v+w}x'\\
-p^{u+w}y'\\
p^{u+v}z'
\end{pmatrix}=\rmco(U)^{-1}
\begin{pmatrix}
\la_4p^{m_4}\\
\la_3p^{m_3}\\
\la_2p^{m_2}
\end{pmatrix}\det(U),
\]
where $\rmco(U)$ is the matrix of cofactors of $U$. This system has $p^{v+w}$ solutions for $x'$, $p^{u+w}$ for $y'$, and $p^{u+v}$ for $z'$. This means that we have $p^{2m_1}$ solutions for $(x,y,z)$. Therefore,
\begin{multline}
h^{-1} (\left[p^{m_1}:\la_2p^{m_2}:\la_3p^{m_3}:\la_4p^{m_4}\right]\\
=p^{2m_1}\cdot \#\left\{M\in (\Zn)^{3\times 3}\, \big|\, |\det(M)|_p=p^{-m_1}\right\}
\end{multline}
\begin{align}
&=p^{2m_1}\cdot p^{9n}\cdot \la\left(\left\{M\in (\Zp)^{3\times 3}\, \middle|\, \left|\det(M)\right|_p=p^{-m_1}\right\}\right)\\\label{eq:15}
&= p^{9n-6-m_1}\left(p^{3}-1\right)\left(p^{m_1+1}-1\right)\left(p^{m_1+2}-1\right).
\end{align}
\end{proof}

\begin{lemm}\label{lemma:SS}
Using the notations above we have:
\begin{equation}
\lim_{n\,\to\,+\infty}\frac{\#S}{p^{13n}}=0
\end{equation}
\end{lemm}

\begin{proof}
Notice that the number of elements $(k_1,k_2,k_3,k_4)\in (\bbZ/p^n\bbZ)^4$ such that $k_1k_4-k_2k_3=0$, viewing $(\bbZ/p^n\bbZ)^4\simeq (\bbZ/p^n\bbZ)^{2\times 2}$ represents the number of matrices in $(\Zn)^{2\times 2}$ with determinant $0$. Let us call this number $S_n$. It can be computed using~\eqref{eq:Cardinal2} and~\eqref{eq:12} as follows:

\begin{align*}
S_n&=p^{4n}-\sum_{m=0}^{n-1}\#\left\{ M\in \left(\Zn\right)^{2\times 2}\, \middle| \, \left|\det(M)\right|_p=p^{-m}\right\}\\
&=p^{4n}-p^{4n}\cdot \sum_{m=0}^{n-1} \la\left(\left\{ M\in \left(\Zp\right)^{2\times 2}\, \middle| \, \left|\det(M)\right|_p=p^{-m}\right\}\right)\\ &=p^{4n}-p^{4n}\cdot \sum_{m=0}^{n-1} \frac{\left(p^2-1\right)\left(p^{m+1}-1\right)}{p^{2m+3}}\\
&= p^{4n}-p^{3n-1}(p+1)\left(p^n-1\right)+p^{2n-1}\left(p^{2n}-1\right)\\
&= p^{3n}+p^{3n-1}-p^{2n-1}.
\end{align*}
Let $[p^{m_1}:\la_1p^{m_2}:\la_3p^{m_3}:\la_4p^{m_4}]\in \bbP^3(\Zn)$ with $m_1\le m_2,m_3,m_4$: this element has $p^{n-m_1-1}(p-1)$ representatives in $(\Zn)^4$. Moreover, the number of $(k_1,k_2,k_3,k_4)\in (\Zn)^4$ such that $p^{m_1}$ divides all the coordinates is $p^{4(n-m_1)}$. Therefore the number of $[k_1:k_2:k_3:k_4]$ such that $k_1k_4=k_2k_3$ is less than or equal to:
\[
\sum_{m=\left\lfloor\frac{n}{2}\right\rfloor}^{n-1}\frac{p^{4(n-m)}}{p^{(n-m-1)}(p-1)} + \frac{p^{3n}+p^{3n-1}-p^{2n-1}}{p^{n-\left\lfloor\frac{n}{2}\right\rfloor}(p-1)}=O\left(p^{5n/2}\right).
\]
On the other hand, by~\eqref{eq:15} every $[k_1:k_2:k_3:k_4]$ has at most $p^{8n-5}(p^{3}-1)\linebreak(p^{n}-1)(p^{n+1}-1)$ preimages under $h$. Thus, $\#S=O(p^{12n+n/2})$, and hence
\[
\lim_{n\,\rightarrow\,+\infty} \frac{\#S}{p^{13n}}=0.\qedhere
\]
\end{proof}

\begin{lemm}\label{lemma:Bk}
Using the above notations we have:
\[
\forall \, k\ge 1:\, B(k)=p^{3k}+p^{3k-1}-p^{3k-2}-p^{3k-3}.
\]
\end{lemm}

\begin{proof}
Suppose first that $k_1$ is invertible. Then $k_4=k_3k_2k_1^{-1}$, and in this case we have $p^{3k-1}(p-1)$ elements satisfying the equation $k_1k_4=k_2k_3$.

Suppose now that $k_1$ is not invertible, then there are two cases:
\begin{itemize}
\item[-] $k_2$ invertible. In this case $k_1k_4k_2^{-1}=k_3,$ and the number of elements $(k_1,k_2,k_3,\linebreak k_4)$ satisfying $k_1k_4=k_2k_3$ is $p^{3k-2}(p-1)$.
\item[-] $k_2$ not invertible. Then either $k_3$ or $k_4$ is invertible. Suppose $k_3$ is invertible: then $k_2=k_1k_4k_3^{-1}$. In this case we have $p^{3k-2}(p-1)$ elements verifying $k_4=k_3k_2k_1^{-1}$. Suppose now $k_3$ is not invertible, then $k_4$ is invertible and we have $k_1=k_2k_3k_4^{-1}$. In this case the number of solutions to our equation is $p^{3k-1}(p-1)$.
\end{itemize}
Adding up the resulting numbers from the previous cases, we get
\[
B(k)=p^{3k}+p^{3k-1}-p^{3k-2}-p^{3k-3}.\qedhere
\]
\end{proof}
\subsection{Lines on hypersurfaces: the limit as \texorpdfstring{$n\to \infty$}{n to infty}}\label{sect3.7}

\begin{theo}\label{thm:n}
Let $f\in \Zp[x_0,\,\ldots,\,x_n]_{(2n-3)}$ be a random uniform polynomial. Then:
\begin{equation}
\limsup_{n\,\to\,\infty}\bbE\#\left\{\text{lines on }Z(f)\subset \QP^n\right\}\leq \frac{1}{\lambda\left(\GL_2(\Zp)\right)}.
\end{equation}
\end{theo}

\begin{proof}
From Theorem~\ref{thm:reduction} we know that:
\[
\bbE\#\left\{\text{lines on }Z(f)\subset \QP^n\right\}=\frac{\la\left(\GL_{n+1}(\Zp)\right)}{\la\left(\GL_2(\Zp)\right) \la\left(\GL_{n-1}(\Zp)\right)}\bbE\left\{\left|\det\left(J\psi_f(0)\right)\right|_p\right\}.
\]
Notice that
\[
\lim_{n\,\rightarrow\,+\infty} \frac{\la\left(\GL_{n+1}\left(\Zp\right)\right)}{\la\left(\GL_{n-1}\left(\Zp\right)\right)}=1
\]
and also $\bbE\{|\det(J\psi_f(0))|_p\}\le 1$, then
\[
\limsup_{n\,\to\,\infty}\bbE\#\left\{\text{lines on }Z(f)\subset \QP^n\right\}\leq \frac{1}{\lambda\left(\GL_2\left(\Zp\right)\right)}.\qedhere
\]
\end{proof}

\begin{rema}
When $\nu=1$, it still makes sense to consider the previous limit over the numbers $n$ satisfying $\binom{d+k}{k}=(n-k)(k+1)$ for some $d$ and we get a similar result.
However in the general case of more equations, it is not clear which type of asymptotic to consider.
\end{rema}



\bibliography{Lerario}
\end{document}
