Asymptotic distribution of values of isotropic quadratic forms at $S$-integral points

We prove an analogue of a theorem of Eskin-Margulis-Mozes: suppose we are given a finite set of places $S$ over $\mathbb{Q}$ containing the archimedean place and excluding the prime $2$, an irrational isotropic form ${{\mathbf q}}$ of rank $n\geq 4$ on $\mathbb{Q}_S$, a product of $p$-adic intervals $I_p$, and a product $\Omega$ of star-shaped sets. We show that unless $n=4$ and ${{\mathbf q}}$ is split in at least one place, the number of $S$-integral vectors ${\mathbf v} \in {\mathsf{T}} \Omega$ satisfying simultaneously ${\mathbf q}( {\mathbf v} ) \in I_p$ for $p \in S$ is asymptotically given by $$ \lambda({\mathbf q}, \Omega) | I| \cdot \prod_{p\in S_f} T_p^{n-2},$$ as ${\mathsf{T}}$ goes to infinity, where $| I |$ is the product of Haar measures of the $p$-adic intervals $I_p$. The proof uses dynamics of unipotent flows on $S$-arithmetic homogeneous spaces; in particular, it relies on an equidistribution result for certain translates of orbits applied to test functions with a controlled growth at infinity, specified by an $S$-arithmetic variant of the $ \alpha$-function introduced in the work of Eskin, Margulis, Mozes, and an $S$-arithemtic version of a theorem of Dani-Margulis.

, states that for any non-degenerate indefinite quadratic form q over R n , n ≥ 3, the set q(Z n ) of values of integral vectors is a dense subset of R if q is irrational, i.e. if q is not proportional to a form with rational coefficients. Both indefiniteness and irrationality conditions are easily seen to be necessary. Margulis' proof is based on a study of orbits of certain unipotent one-parameter groups on the space of lattices in R 3 . The idea of using unipotent flows dates back in an explicit form to Raghunathan and in implicit forms to Cassels and Swinnerton-Dyer. More precisely, Raghunathan observed that Oppenheim conjecture follows from the assertion that every bounded orbit of the orthogonal group SO(2, 1) on SL 3 (R)/SL 3 (Z) is compact. Raghunathan further conjectured in the mid-seventies that if G is a connected Lie group, Γ a lattice in G, and U a unipotent subgroup of G, then the closure of any orbit U x, for x ∈ G/Γ, is itself an orbit Lx, where L is a closed connected subgroup of G containing U . Note that the subgroup L depends on x. Raghunathan's conjecture was later proved by Ratner [21].
1.1. The Quantitative Oppenheim Conjecture. The Quantitative Oppenheim conjecture, a refinement of the Oppenheim conjecture, is about the asymptotic distribution of the values of q(v), where v runs over integral vectors in a large ball. To be more precise, let Ω be a radial set defined by Ω = {x ∈ R n : ||x|| < ρ(x/||x||)}, where ρ is a positive continuous function on the unit sphere and T Ω is the dilation of Ω by a factor T > 0. Let us also denote by N (a,b),q,Ω (T ) the number of integral vectors x ∈ T Ω such that q(x) ∈ (a, b).
In [7], Dani and Margulis obtained the asymptotic exact lower bound: for q an irrational indefinite quadratic form on R n with n ≥ 3, for a given interval (a, b) and a set Ω, we have lim inf T →∞ N (a,b),q,Ω (T ) λ q,Ω (b − a)T n−2 ≥ 1, where λ q,Ω is a constant such that denominator gives the asymptotic volume of the set {v ∈ T Ω : q(v) ∈ (a, b)}. The proof of the above theorem is based on studying the distribution of the shifted orbits of the form u t Kx, where u t is a certain one-parameter unipotent subgroup, K is a maximal compact subgroup of the orthogonal group SO(q) associated to q, and x ∈ SL n (R)/SL n (Z). A suitable choice of a function f on R n allows one to approximate the number of the integral vectors v in T Ω satisfying q(v) ∈ (a, b) by an integral of the form where dµ is the invariant probability measure on the space of unimodular lattices SL n (R)/SL n (Z), and f : SL n (R)/SL n (Z) → R is the Siegel transform of f defined by f (gΓ) = v∈gZ n f (v). Although f is an unbounded function to which the uniform version of Ratner's theorem proved in [7] does not directly apply, it is yet possible to establish asymptotically sharp lower bounds by approximating f from below by bounded functions.
The question of establishing an asymptotically sharp upper bound turns out to be substantially subtler. Note that, in general, the equidistribution results in [7] do not apply to arbitrary unbounded function. In the groundbreaking work [10], it is shown that if f has a controlled growth at infinity, then one can still establish this equidistribution result. The growth at infinity is measured by a family of functions α 1 , . . . , α n with origin in geometry of numbers. If Λ is a lattice in R n , then α i (Λ) −1 is the smallest value for the covolume of Λ ∩ L, where L ranges over all i-dimensional subspaces of R n for which Λ ∩ L is a lattice in L.
Setting α = max(α i ), one of the main results of [10] is that the equidistribution results of [7] continue to hold as long as the test function is majorized by α s for some s ∈ (0, 2). This is then used to show that if q is a form of signature (r, s) with r ≥ 3 and s ≥ 1, then lim T →∞ N (a,b),q,Ω (T ) λ q,Ω (b − a)T n−2 = 1.
For quadratic forms of signature (2,1) and (2,2), certain quadratic forms were constructed in [10] so that by choosing Ω to be the unit ball, for any ǫ > 0, N (a,b),q i ,Ω (T j ) ≫ T i j (log T j ) 1−ǫ for an infinite sequence T j → ∞. These counterexamples are very well approximable by rational forms. When q has signature (2,2), it is proven in [11] that if forms of a class called EWAS are excluded, then a similar asymptotic statement continues to hold.
1.2. The S-arithmetic Oppenheim Conjecture. The generalization we study in this article involves considering various places.
Let S f be a finite set of odd prime numbers and S = {∞} ∪ S f . Each element of S (S f , respectively) is called a place (a finite place, respectively). For p ∈ S f , the p-adic norm on Q is defined by |x| p = p −vp(x) , where v p (x) is the p-adic valuation of x. The completion of Q with respect to | · | p is the field of p-adic numbers and is denoted by Q p . We will sometimes write Q ∞ for R. When p ∈ S f , Q p contains a maximal compact subring Z p consisting of elements with norm at most 1. We also write U p = Z p − pZ p for the set of multiplicative units in Z p . When p = ∞, we set U p = {±1}. We will use the notation U n p = Z n p − p(Z n p ) for p ∈ S f and U n ∞ = S n−1 , the set of vectors of length 1 in R n .
For p ∈ S f , λ p stands for the Haar measure on Q p normalized so that λ p (Z p ) = 1. We denote by Q S = p∈S Q p the direct product of Q p , p ∈ S, and write Z S = {x ∈ Q S : |x| p ≤ 1, ∀p ∈ S} for the ring of S-adic integers. The function on Q n S defined by where v p p = max |(v p ) i | p for p ∈ S f , plays a role of the norm on R n [15]. Also, · ∞ denotes the usual Euclidean norm. We will also denote by λ S the product measure ⊗ p∈S λ p . The Haar measures on Q n p and Q n S are denoted by λ n p and λ n S , respectively. A quadratic form q on Q n S is an S-tuple (q p ) p∈S , where q p is a quadratic form on Q n p . The form q is called isotropic, if each q p is isotropic, that is, if there exists a non-zero vector v ∈ Q n p such that q p (v) = 0. A quadratic form over R is isotropic if and only if it is indefinite. q is called non-degenerate if each q p is non-degenerate, that is, the symmetric matrix β qp (v i , v j ) 1≤i,j≤n is invertible, where {v 1 , . . . , v n } is a basis of Q n p and β qp (v i , v j ) = (q p (v i + v j )− q p (v i )− q p (v j ))/2. Finally, we call q rational if there exist a single quadratic form q 0 (defined over Q) and an invertible element λ = (λ p ) p∈S ∈ Q S satisfying that q p = λ p q 0 for all p ∈ S. Otherwise q is called irrational.
Borel and Prasad proved the S-arithmetic Oppenheim conjecture over any number field k. In the case when k = Q, the theorem says that for a non-degenerate irrational isotropic quadratic form q on Q n S (n ≥ 3) and any given ǫ > 0, there exists a non-zero vector x ∈ Z n S with |q p (x)| < ǫ for all p ∈ S.
1.3. Statements of results. The goal of this paper is to prove a quantitative version of the theorem of Borel and Prasad mentioned above. Note that due to the presence of |S| valuations, we need to consider |S| parameters for the divergence to the infinity, etc.
Let T = (T p ) p∈S be an S-tuple of positive real numbers with the components T p ∈ p Z for p ∈ S f . Such an S-tuple T will be called an S-time. The set of all S-time vectors is denoted by T S . For T ∈ T S , write T = p∈S T p ., and m(T) = min p∈S T p . For T = (T p ), Similarly, T i = (T p,i ) p∈S → ∞ means that T p,i → ∞ for each p ∈ S. Since T is of the form (e t∞ , p t 1 1 , · · · , p ts s ), let us denote t = (t ∞ , t 1 , · · · , t s ) and consider S-parameter groups which we will use later. The notions t t ′ and t → ∞ are defined accordingly. For p ∈ S, let ρ p : U n p → R be a positive continuous function. For p ∈ S f , we will assume throughout the paper that ρ satisfies the following condition: ρ p (ux) = ρ p (x), ∀x ∈ U n p , ∀u ∈ U p . Define where Ω p is the set of vectors v p whose norm is bounded by the value of ρ p in the direction of v p . Condition (I ρ ) is indeed very mild and is satisfied by many sets of interest (e.g., the unit ball, which is defined by the constant function). Having fixed an S-time T, we denote by where a ∈ Q p and b ∈ Z. An S-adic interval I is a product of p-adic intervals I p , with p ∈ S. Let us denote |I| = λ p (I p ).

Definition 1.1 (Counting and volume functions).
Fixing Ω as above, the counting and volume functions are defined respectively by N I,q,Ω (T) = card{v ∈ Z n S ∩ TΩ : q p (v p ) ∈ I p , ∀p ∈ S}, V I,q,Ω (T) = vol{v ∈ Q n S ∩ TΩ : q p (v p ) ∈ I p , ∀p ∈ S}, where card and vol denote the cardinality and the Haar measure λ n S . We start with the following statement about the asymptotic volume of the set of vectors in T p Ω p ⊆ Q n p with the condition q(v) ∈ I. This proposition will be proven in Section 4. Proposition 1.2. For a constant λ = λ(q, Ω), we have, The asymptotic behavior of N I,q,Ω (T) is more intricate than the volume asymptotics. The issue for real forms of signature (2, 1) and (2,2) persists in the S-arithmetic setup. Definition 1.3. Let q = (q p ) p∈S be an isotropic quadratic form on Q n S . We say that q is exceptional if either (1) n ≤ 3, or (2) n = 4 and for some p, q p is split, i.e., it is equivalent to the form See Section 2.2 for more details. Note that the set O S (n) of non-degenerate quadratic forms on Q n S can be identified with a Zariski open subset of p∈S sym n (Q p ), where sym n (Q p ) denotes the set of n × n symmetric matrices over Q n p . In this correspondence, a form q = (q p ) p∈S is associated to its Gram matrix. Theorem 1.4. Let D be a compact subset of non-exceptional quadratic forms on Q n S , I an Sinterval, and Ω as in (1). Then there exists a constant C = C(D, I, Ω) such that for any q ∈ D and any sufficiently large S-time T we have Note that this theorem is effective in the sense that the constant C can be explicitly given in terms of the data. The next theorem is our main result which provides asymptotically sharp bounds for N I,q,Ω (T). For the sake of simplicity, the theorem below is stated for an individual irrational form. Modifications of the proof, along the lines of the proofs in [10], can be made to establish a uniform version when q runs over a compact set of forms.
Theorem 1.5. Let q be an irrational isotropic form in O S (n), I be an S-interval, and Ω be as in (1). If q is not exceptional, then Remark 1.6. The proof given here establishes both the lower and the upper bound at the same time. It seems likely to us that an adaptation of the arguments in [7] can be used to establish the lower bound even when q is exceptional.
We will prove Theorem 1.5 using Theorem 6.2 and the following result which uses Theorem 1.7 as an important ingredient: Theorem 1.8. Set G = SL n (Q S ), Γ = SL n (Z S ), H = SO(q), and let φ : G/Γ → R be a continuous function, and ν be a positive continuous function on p∈S U n p . Assume that for some 0 < s < 2, we have |φ(∆)| < Cα S (∆) s for all ∆ ∈ G/Γ. Let x 0 ∈ G/Γ be such that Hx 0 is not closed. Then It is natural to inquire what happens in the case of exceptional forms. In this direction, we can prove the following theorem: Theorem 1.9. Let I ⊆ Q S be an S-interval and Ω be the product of unit balls in Q 3 p for p ∈ S. Then, there exist an isotropic irrational quadratic form on Q 3 S , a constant c > 0, and a sequence Since scalar multiples of a single form q cover all possible equivalence classes of isotropic quadratic forms over Q 3 p (this can be easily seen from the proof of Proposition 2.1), the above theorem shows that the counterexamples can be constructed in any equivalence class of quadratic forms. This theorem, however, leaves out the case of forms with four variables. It would be interesting to study these forms in details in the future. Remark 1.10. In this paper, sans serif roman letters are reserved for S-adic objects. Algebraic groups will be denoted by bold letters. For instance, when G = SL n , then G(Q p ) = SL n (Q p ) and G = p∈S G(Q p ). Elements of G, H, etc. are denoted by lower case g, h, etc.
Remark 1.11. In order to streamline the process of normalizing a vector across different places, we will use the following notation. For p ∈ S f and a real number x = p n , we set x ⋄ = p −n , viewed as a p-adic number. If x is a positive real number, then, by definition x ⋄ = x. If T = (T p ) p∈S is an S-time (which, as defined above, means that T p is a power of p for every p ∈ S f ), we define Remark 1.12. It would be interesting to extend the result to include the prime p = 2 in S. We expect some modifications to be necessary, for example, Proposition 4.2 and classification of quadratic forms depend on whether p is 2 or odd. Remark 1.13. It is likely that the results of this paper can be generalized to the case of arbitrary number fields. This, however, will inevitably involve using more number theory. For instance, one will need a classification of quadratic forms over finite extensions of p-adic fields, which is more complicated than that over p-adic fields.
The first author was supported by Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education (2016R1A6A3A01010035), the second author is supported by Samsung Science and Technology Foundation under Project No. SSTF-BA1601-03. We also acknowledge the support of Seoul National University, MSRI and Jacobs University during our visits. We are also grateful to the referees whose detailed comments helped us improve the paper.

Preliminaries
In this section, we recall some definitions about Q p -vector spaces and quadratic forms defined on them.
2.1. Norms on exterior products. Let 1 ≤ i ≤ n. One equips the ith exterior product i R n with an inner product defined by For v ∈ i R n , the induced norm is given by v = | v, v | 1/2 . Denote by e 1 , . . . , e n the canonical basis for R n . For J = {1 ≤ j 1 < . . . < j i ≤ n}, denote e J = e j 1 ∧ · · · ∧ e j i . As J runs over all subsets of {1, 2, . . . , n} of i elements, the set {e J } forms an orthonormal basis for i R n and hence J a J e J = J a 2 J 1/2 . The inner product defined above is preserved by the action of the orthogonal group O(n) on R n . The most convenient norm to work with, for our purpose, is given by v = max J |a J | p . The action of SL n (Z p ) on i Q n p preserves this norm. Indeed, since the entries of k ∈ SL n (Z p ) are p-adic integers, we immediately have the inequality kv p ≤ v p . Equality follows by applying this inequality to k −1 instead of k.

Quadratic forms.
In this subsection, we review the classification of quadratic forms over the p-adic fields Q p for odd primes p following [24]. Recall that a quadratic form q on R n has signature (r, s) if there is g ∈ GL n (R) such that Two quadratic forms over the field Q p are equivalent if and only if they have the same rank, the same discriminant, and the same Hasse invariant. Recall that the discriminant of a non-degenerate quadratic form over a field F is the image of the determinant of the Gram matrix G in the group F * /(F * ) 2 . This group contains 4 elements when F = Q p and p is an odd prime, representing the parity of v p (det G) and whether the image of det G in the residue field is a quadratic residue or not. Hasse invariant can take two values and is invariant under scalar multiplication. It follows that there are at most 8 different quadratic forms over Q p of any given dimension. A non-exceptional isotropic quadratic form q over Q p is called standard if it is of the form q(x) = x 1 x n + a 2 x 2 2 + · · · + a n−1 x 2 n−1 , where a i ∈ {1, p, u, pu} and for some j, k, −a j /a k is not a square.
Here u ∈ U p is a fixed element such that its image in Z p /pZ p is a non-residue. Any non-exceptional isotropic quadratic form is equivalent to a standard one.
2.3. Orthogonal groups. For a quadratic form q = (q p ) p∈S over Q S , we define the orthogonal group of q by SO(q) = p∈S SO(q p ), where SO(q p ) is the p-adic analytic group consisting of matrices of determinant 1 preserving the quadratic form q p . Let K ∞ be the maximal compact subgroup of SO(q ∞ ) which is isomorphic to SO(r) × SO(s), where (r, s) is the signature of q ∞ . For p ∈ S f , we define K p = SL n (Z p ) ∩ SO(q p ). It is easy to see that K p is a maximal subgroup of SO(q p ). Finally, we set K = p∈S K p and let m K , m Kp be the Haar measures on K, K p , respectively. Since K p is a subgroup of SL n (Z p ), the p-adic max norm on Q n p is invariant by K p . We will also need the following one-parameter subgroups. For each p ∈ S f , define We denote by A p the group consisting of all a p t with t ∈ Z when p ∈ S f , and t ∈ R when p = ∞.
Then we can define subgroups of SO(q) for a standard quadratic form q as The following simple fact about ternary forms will be used later.
Proposition 2.1. Let q be a non-degenerate isotropic ternary quadratic form over Q p . Then the group SO(q) is locally isomorphic to PSL 2 (Q p ).
Proof. This is well-known for R, so assume p ∈ S f . The conjugation action of SL 2 (Q p ) on the space of 2 × 2 matrices of trace zero over Q p preserves the determinant, which can be viewed as a non-degenerate isotropic ternary quadratic form q 0 . Since the kernel is ±I, and the corresponding Lie algebras are isomorphic, the orthogonal group of q 0 is locally isomorphic to PSL 2 (Q p ). For an arbitrary non-degenerate isotropic ternary quadratic form q and c ∈ Q p \{0}, the form cq has the same orthogonal group as q, and for an appropriate value of c has the same discriminant as q 0 .
The proof of the following fact is deferred to the appendix: Proposition 2.2. For given c 1 ∈ Q p and c 2 ∈ p Z , K p acts transitively on

The S-arithmetic Geometry of Numbers
In this section, we prove some basic results on the S-arithmetic geometry of numbers. Due to lack of reference in the S-arithmetic case, we provide proofs.
3.1. S-lattices and a generalization of the α function. The proof of Oppenheim conjecture is based on the dynamics of unipotent flow on the space of lattices, thus we need an analogous S-arithmetic notion.
Definition 3.1. Let V be a free Q S -module of rank n. A Z S -module ∆ is an S-lattice in V if there exist x 1 , . . . , x n ∈ V such that ∆ = Z S x 1 ⊕ · · · ⊕ Z S x n and V is generated by x 1 , . . . , x n as a Q S -module.
Note that an S-lattice is a discrete and cocompact subgroup of Q n S . The base lattice ∆ 0 is the S-lattice generated by the canonical basis e 1 , . . . , e n . Note that SL n (Q S ) acts on the set of lattices in Q n S and the orbit of ∆ 0 under this action can be identified with L S := SL n (Q S )/SL n (Z S ). For an S-lattice ∆, we say that a subspace L ⊆ Q n S is ∆-rational if the intersection L ∩ ∆ is an Slattice in L, that is, L is a subspace of Q n S generated by finite number of elements in ∆. Suppose that L is i-dimensional and The definition of d(L) is independent of the choice of basis. This is an analogue of the volume of the quotient space L/(L ∩ ∆) for lattices in R n . If L = {0}, we write d(L) = 1. We now show that there is indeed a more intimate connection between the L S and the space L of lattices (of covolume 1) in R n . More precisely, we show that the L S fibers over L in such a way that many natural functions on L S factor through the projection map.
Definition 3.2 (The projection map). Let ∆ ∈ L S . Define π(∆) to be the set of vectors v ∈ R n for which there exists w ∈ ∆ with w ∞ = v and w p ∈ Z n p for all p ∈ S f . Remark 3.3. For any vector v ∈ π(∆) there is exactly one vector w ∈ ∆ satisfying w ∞ = v. Indeed, if both w 1 and w 2 satisfy this property, then w = w 1 − w 2 ∈ ∆ is a non-zero vector with real component zero. This implies that ( p∈S f p m )w → 0 as m → ∞, which contradicts the discreteness of ∆. Proof. Since the p-adic components of the elements of π(∆) belong to the compact sets Z n p , for p ∈ S f , the vectors w = v ∞ cannot have an accumulation point, since then by passing to a subsequence, we can find an accumulation point for a sequence of vectors in ∆.
Start with a Z S -basis v 1 , . . . , v n for ∆. By replacing the vectors v i with certain Z S linear combinations of them, we may assume that the determinant of the matrix A p with columns v 1 p , . . . , v n p is a unit in Z p , for every p ∈ S f . Note that this is equivalent to the condition Write v = n k=1 c k v k , for c k ∈ Z S , and let c be the column vector with entries c 1 , . . . , c n . Since A p c = v p , A −1 p ∈ SL n (Z p ), and v p ∈ Z n p , we deduce that c ∈ Z n p for all p ∈ S f . This implies that c ∈ Z n , which proves our claim. Since ∆ is unimodular, (5) showing that π(∆) has covolume 1. The function α S is not only an analogue of the original function α, but is in fact intimately related to it. Proposition 3.6. For any ∆ ∈ L S , we have α S (∆) = α(π(∆)).
Similarly to the proof of Proposition 3.4, after possibly replacing v 1 , . . . , v i by another basis, we can assume that v 1 p ∧ · · · ∧ v i p p = 1 for all p ∈ S f . This implies that d( . The converse can be proven similarly.
Since S is fixed throughout the discussion, we will henceforth drop the superscript S in α S i and α S . We now define an S-adic Siegel transform.
Definition 3.7. Let f : Q n S → R be a bounded function vanishing outside a compact set. The S-adic Siegel transform of f is a function on G/Γ defined as follows: for g ∈ SL n (Q S ), More generally,f is defined on the space of S-lattices ∆ asf (∆) = v∈∆ f (v).
Since the diagonal embedding of Z n S in Q S is discrete, the defining sum involves only finitely many non-zero terms. The following lemma is a natural extension of Schmidt's theorem ( [23], Lemma 2) in geometry of numbers. Proof. Without loss of generality, we can assume that f is the characteristic function of B = p∈S B p , where B p is a ball of radius p np , for p ∈ S f and a ball of radius R for p = ∞. Set D = p∈S f p np and consider the scalar map δ : ∆ → ∆ defined by δ(x) = D · x. Note that if x ∈ ∆ ∩ B, then x p ≤ 1 for all p ∈ S f and x ∞ ≤ RD. In particular, π(δ(x)) will be inside a ball B ′ of radius RD. Note that Schmidt's lemma states that holds for any lattice ∆ ′ in R n , where the implies constant depends on B ′ . Using this fact and Remark 3.3 we obtain Lemma 3.9. Let ∆ be an S-lattice in Q n S and let L and M be two ∆-rational subspaces. Then we have that Proof. We first verify that if L and M are ∆-rational, then L ∩ M and L + M are also ∆rational. Since a subspace of Q n S is ∆-rational if and only if it is generated by elements of ∆, L + M is clearly a ∆-rational subspace of Q n S . On the other hand, consider a projection map π : Q n S → Q n S /∆. Note that the projection image π(H) of a subspace H in Q n S is closed if and only if H ∩ ∆ is a lattice subgroup in H, that is, H is ∆-rational. Since π is proper, if we set H = π −1 (π(L ∩ M )) = π −1 (π(L) ∩ π(M )), we can easily check that H is ∆-rational and for any ∆-rational subspace H, the inequality (6) is equivalent to Let {v 1 , . . . , v ℓ } and {w 1 , . . . , w m } be bases of p(L) and p(M ) consisting of elements in p(∆), respectively. Then since (p(L) ∩ p(∆)) The following Lemma is the S-arithmetic version of Lemma 3.10 in [10].
Lemma 3.10. The function α belongs to L r (SL n (Q S )/SL n (Z S )) for all values of 1 ≤ r < n.
Proof. Consider the map π : L S → L. Denote the invariant probability measures on L S and L by µ S and µ, respectively. We claim that π is measure-preserving, that is, for any measurable A ⊆ L R , we have µ S (π −1 (A)) = µ(A). To see this, define ν(A) = µ S (π −1 (A)). One can easily see that ν is an SL n (R)-invariant probability measure on L, implying that ν = µ. The result will immediately follows from Proposition 3.6.
We can now prove the following generalization of the classical Siegel's formula in geometry of numbers. Then The proof is based on the following lemma. For each p ∈ S, we denote by λ n p the Haar measure on Q n p normalized such that λ n p (Z n p ) = 1. Denote by δ p the delta measure at the zero point of Q n p .
Lemma 3.12. Let ν be an SL n (Q S )-invariant Radon measure on Q n S . Then ν is a linear combination of measures of the form p∈S ν p , where each ν p is either the Haar measure λ n p or the delta measure δ p .
Proof. Observe that if ν is a positive Radon measure on a locally compact space X invariant under the action of a group H, and H has a finite number of orbits, namely X 1 , . . . , X m , then ν naturally decomposes into the sum Let us now consider the case at hand, namely, the action of SL n (Q S ) on Q n S . Since the natural action of G = SL n (Q p ) on Q n p has two orbits on Q n p , the G-orbits in the action on Q n S are of the form p∈S X p , where X p is either the zero point or Q n p − {0}. Each orbit is a homogenous space G/L, where L is the stabilizer of an arbitrary point in the respective orbit. The invariant measure on the homogeneous space G/L, if exists, is unique up to a factor. The result follows.
Proof of Proposition 3.11. Note that by Lemmas 3.8 and 3.10, f is integrable. This implies that the map f → G/Γ f dµ defines a positive linear functional on the space of compactly supported continuous functions on Q n S , hence defines a Radon measure ν on Q n S . Since µ is G-invariant, so is ν. Using Lemma 3.12, ν splits as a linear combination of measures of the form p∈S ν p , where each ν p is either λ n p or the delta measure δ p . The coefficient of p∈S λ n p in this linear combination is one. Indeed, taking an increasing sequence of compactly supported non-negative continuous functions f n approximating the normalized characteristic functions of increasingly larger balls in Q n S , one obtains f n → 1, and Q n S f n dλ n S → 1. Similarly, by choosing a family f n of non-negative continuous functions with support in a ball of radius 1/n with |f n | ≤ 1 and f n (0) = 1, and applying the Lebesgue's dominated convergence theorem, we have which implies that the coefficient of f (0) is 1. It remains to be shown that the rest of the coefficients are zero. This can be obtained in a similar way from the fact that a lattice ∆ in Q n S cannot contain a non-zero point (v p ) p∈S with v p 0 = 0 for some p 0 ∈ S. Otherwise, one can find an appropriate sequence n i of S-integers, such that |n i | q → 0 for all q = p 0 and hence n i v → 0 contradicting the discreteness of ∆. From here, and by choosing appropriate sequences of continuous functions as above, we can deduce that the rest of the coefficients are zero.

3.2.
Integration on subvarieties. Now let us introduce volume forms of submanifolds in Q n S inherited from the volume form dλ n S of Q n S in order to measure the volumes of orbits of maximal compact subgroups of orthogonal groups in Q n S . Since such maximal compact subgroups are products of maximal compact subgroups at each place, it suffices to deal with volume forms of p-adic submanifolds in Q n p . Let us introduce two equivalent definitions of volume form on submanifolds. Recall that any orbit of the p-adic maximal compact subgroup K p = SL n (Z p ) ∩ SO(q p ) of SO(q p ) for a given quadratic form q p on Q n p is of the form {w ∈ Q n p : ||w|| p = p c 1 , q p (w) = c 2 }, where c 1 ∈ Z and c 2 ∈ Q p are some constants. Note that the above K p -orbit is an open subset of the (n − 1)-dimensional p-adic variety in Q n p given by {w ∈ Q n p : q p (w) = c 2 }. Hence from now on we will consider Y as a compact open subset of a d-dimensional p-adic variety in Q n p or a parallelepiped As in the real case, we can define the volume form of a p-adic submanifold by describing the volume form of its tangent space. Let Y be a parallelepiped Z p v 1 ⊕ · · · ⊕ Z p v d , where v 1 , . . . , v d are linearly independent in Q n p . Then the volume form ν ′ d of the parallelepiped is defined as where || · || is the maximum norm of d (Q n p ). We will use the fact (see [26,Theorem 9]) that the normalized measures ν d and ν ′ d are equal.

Passage to homogeneous dynamics
In this section, we define a p-adic analogue of J f function introduced in Section 3 in [10] for the real case. This function is used in Section 5 to relate the counting problem to the asymptotic formula of certain integrals on the space of S-lattices. Fix a prime p ∈ S f , and let q be a standard quadratic form on Q n p . Let π 1 : Q n p → Q p be the projection to the first coordinate and Q n p,+ be the set {x ∈ Q n p : π 1 (x) = 0}. We denote by p Z the subset of Q p consisting of powers of p. Lemma 4.1. Let f be a continuous function with compact support on Q n p,+ which satisfies the invariance property for all units u ∈ U p . Let ν be a non-negative continuous function on the unit sphere U n p such that where in the integral, x n = p r (ζ − q(0, x 2 , . . . , x n−1 , 0)). Then for any ǫ > 0, if t and v are sufficiently large, we have where c(K p ) = vol(K p .e 1 )/(1 − 1/p) and m is the normalized Haar measure on K p .
Proof. Let π i denote the projection onto the ith coordinate in Q n p , and a t := a p t = diag p t , 1, . . . , 1, p −t as before. Since f has compact support, for t ≫ 1, if f (a t w) = 0, we have This implies that on the support of the function k → f (a t kv), for t large enough we have Since ν is continuous and satisfies (I ν ), by choosing δ > 0 small enough we can assure that if t > t 0 (δ), and f (a t kv) = 0, then the following holds: For sufficiently large t, if f (a t kv) = 0, then the vector v ⋄ p p t , π 2 (kv), . . . , π n−1 (kv), v n will be at a bounded distance from e 1 .
Since the K p -invariant measure on the orbit K p .v is the push-forward of the normalized Haar measure on K, one can approximate the integral in (7) by the integration on the K p -orbit We remark that (I ν ) is an essential condition but (I f ) is not a real restriction since we can easily modify the given function to satisfy (I f ).
where vol = vol n−1 denote the (n − 1)-dimensional volume induced from Q n p .
Proof. Let us make the substitution w = p t v. This gives dw = 1/p nt dv, hence we have Replacing p −2t by p −t , the left integral in (12) can be changed to With the decomposition Q n p = z∈Z p −z U n p , write Since h has compact support, all but finitely many of h z are zero. We first claim that for h with supp h ⊆ U n p × Q p , , which has compact support in U n p × Q p . By a change of variables, we have where the last equality relies on the change of variables ζ ′ = p −2z 0 ζ. Now, using the decomposition (12), Proposition 4.2 follows for an arbitrary h. Now let us prove the claim. Let h satisfy supp h ⊆ U n p × Q p . Furthermore, since we put q(v) in the second variable and q is the quadratic form with p-adic integral coefficients, we can add the assumption that supp h ⊆ U n p × Z p . Let us denote by A k the subspace of the space of continuous functions on U n p × Z p which is spanned by the functions of the form h(v, where A ⊆ U n p and B ⊆ Z p are respectively the preimages of subsetsĀ ⊆ (Z/p k Z) n andB ⊆ Z/p k Z by the reduction map red k . We will also set A = ∞ k=1 A k . In view of Stone-Weierstrass theorem for p-adic fields ( [9]), A is dense in the space of all continuous functions on U n p × Z p . Let us denote the reduction maps Z p → Z p /p k Z p (and also Z n p → (Z p /p k Z p ) n ) by red k . Let h be a real-valued continuous function with compact support contained in U n p × Z p . We will do some reduction steps: we may assume that h(v, In It thus suffices to show that Let us define Here β is the associated bilinear form to the quadratic form q. Recall the polarization identity: We This equality implies that We will denote the induced quadratic form over Z p /p ℓ Z p by q as well. First observe that for ℓ/2 > t > k, we have For any choice of u ∈ A ℓ ∩ {u : q(u) = 0} there exist exactly |B ℓ | choices for w such that 2β(ū,w) ∈ B ℓ . Hence, in order to find µ n (C t (A, B)), it suffices to find the cardinality of the fibers of the map Φ : We will show that all the fibers have the same size. If Φ(u 1 , w 1 ) = Φ(u 2 , w 2 ), then u 1 ≡ u 2 (mod p t ). Conversely, suppose that u 1 ∈ A ℓ , q(u 1 ) and v = u 1 + p t w 1 for some w 1 which satisfies This shows that the fibers of Φ are in one-to-one correspondence with the equivalence classes of u ∈ A ℓ module p t . This implies that for all sets A, B satisfying (13), for ℓ ≥ t > k, we have Note that N t does not depend on ℓ. In the special case A = U n p and B = Z p , C t (A, B) is precisely the p −t -neighborhood of the set {u ∈ U n p : q(u) = 0}. It follows that lim t→∞ p t µ n (C t (U n p , Z p )) = µ n−1 ({u ∈ U n p : q(u) = 0}) = vol(K.e 1 ).
From here, for general A and B we obtain

Counting results
In this section, we prove Theorems 1.4 and 1.5. The proofs depend on an ergodic result which will be proven in the next section.
Proof of Theorem 1.4. Since any bounded set Ω is contained in a ball of radius r for some r > 0, for an upper bound, it suffices to prove the theorem for the case when Ω is a unit ball.
Without loss of generality, we may assume that there exists a compact set C ⊂ G so that every quadratic form in D is of the form q g for some g ∈ C, where q is a fixed standard form, since there are finitely many equivalence classes of quadratic forms over Q S . Since C is compact, there exists β such that for every g = (g p ) p∈S ∈ C and every v ∈ Q n S , β −1 v p p ≤ g p v p p ≤ β v p p for every p ∈ S. Let ǫ > 0 be given and g ∈ C be arbitrary. Let f = p∈S f p be a continuous non-negative function with compact support on Q n S such that then J f ( gv ⋄ /|T| ⋄ , q(gv)) ≥ 1 + ǫ. By Lemma 4.1 and Lemma 3.6 in [10], for sufficiently large t, if v satisfies (14). Summing over v ∈ Z n S , it follows that the number of vectors v ∈ Z n S satisfying (14) is bounded from above by Since (15) holds for all sufficiently large T, by summing over all (T ∞ /2 k∞ , T p /p k 1 , . . . , T s /p ks ), k ∞ , k 1 , . . . , k s ∈ N, the statement follows.
Proposition 5.1. Let f p : Q n p → R be a positive continuous function with compact support in Q n p,+ , and f = p∈S f p . Assume further that f p satisfies the property (I f ) when p ∈ S f . Let ν p : U n p → R be positive continuous functions satisfying the condition (I ν ) and ν = p∈S ν p . For a non-exceptional quadratic form q, ǫ > 0 and every g ∈ G, there exists a positive S-time t 0 so that for t ≻ t 0 , Proof. Since J f = p∈S J fp has compact support, by Theorem 1.4 for given g ∈ G, the number Take t 0 such that Lemma 4.1 and Lemma 3.6 in [10] hold for gv and ǫ/c. Then for t ≻ t 0 , Here C(f ) is a constant depending on f which comes from the fact that if Note that both terms in the second line of the equations are bounded by a constant depending on f .
In the rest of this section, we will deal with compactly supported continuous function h : For h as above, define Lemma 5.2. Let f and ν be as in Theorem 5.
for any unit u, we have that The change of variables p −r x n + q(0, x 2 , . . . , x n−1 , 0) = ζ yields p r dx n = dζ, and hence The result will now follow from Proposition 3.11, Proposition 4.2, and Lemma 3.9 in [10]. Computations proceed by a verbatim repetition of the proof of Lemma 3.9 in [10].
Proof of Proposition 1.2. Since Ω = p∈S Ω p ⊂ Q n S , it suffices to show that for any choice of intervals I p ⊆ Q p , p ∈ S, there exists a constant λ(q p , Ω p ) such that vol{v ∈ T p Ω p : q p (v) ∈ I} is asymptotically λ(q p , Ω p )T n−2 p . The case p = ∞ is in Lemma 3.8 (ii) of [10]. Hence, we may assume that p ∈ S f , and write I p = a + p b Z p , for a ∈ Q p and b ∈ Z.
Recall that for any v ∈ U n p and u ∈ U p . Substituting g −1 Ω p by Ω p , we may assume that q p is standard. Moreover, the function It would be slightly more convenient to work with the setΩ Note that z∈Z p (n−2)z K 1Ω p (p −z ke 1 )dm(k) is a summation over a finite set of z's. The result will now follow from the fact that Ω p = i≥0 p iΩ p is a disjoint union.
Proof of Theorem 1.5. We will start by introducing two function spaces: let L denote the space of real-valued functions F (v, ζ) on Q n S − {0} × Q S with support in an implicitly fixed compact set C, satisfying F (uv, ζ) = F (v, ζ) for all u ∈ U p , p ∈ S f . We equip L with the topology of uniform convergence on C. By L 0 , we denote the subspace of L consisting of the functions of the form where f = p∈S f p , ν = p∈S ν p , f p is continuous with compact support on Q n p,+ satisfying (I f ) and ν p is a non-negative continuous function on U n p satisfying (I ν ). We claim that L 0 is dense in L. In fact, it is easy to see from a p-adic Stone-Weierstrass Theorem (see [9]) that the approximation holds if the invariance properties are dropped from L and L 0 . With the invariance properties, one only needs to integrate the approximating function ν over p∈S U p with respect to the Haar measure to obtain the desired approximating function. This implies that for each and where 1Ω is the characteristic function of By Proposition 5.1, Theorem 6.2, and Proposition 5.2, there exist points x 1 , . . . , x ℓ ∈ G/Γ so that Hx i is closed, 1 ≤ i ≤ ℓ, and for each compact subset F of D − ∪ ℓ i=1 Hx i , there exists T 0 ≻ 0 so that for all T ≻ T 0 and x = gΓ ∈ F, From the definition of L(h), it follows that for T large enough, we have By approximating argument with h x , h ′ x with a suitable ǫ, for every θ > 0, there exist finitely many points x 1 , . . . , x ℓ with Hx i closed and for an arbitrary compact subset F ⊆ D − ∪ ℓ i=1 Hx i , there exists T 0 ≻ 0 such that for every x = gΓ ∈ F and every T ≻ T 0 , we obtain The claim will now follow from Proposition 1.2 and a standard geometric series argument.

S-arithmetic uniform equidistribution of unipotent flows
In this section we will prove an S-arithmetic version of a theorem in [7], which was mentioned in the introduction. Our proof builds upon ideas and results that were originated in [7] and were partially extended in the S-arithmetic setup in [27]. The general line of argument is similar to the one in [7]. In a number of places, technicalities arise that need to be handled differently.
Let G be a Q-algebraic group. With S and S f as above, set G = G(Q S ) = p∈S G(Q p ). Let Γ be an S-arithmetic subgroup of G, i.e. a group commensurable to G(Z S ). Note that G(Q p ) is naturally embedded in G. For each p ∈ S, let U p = {u p (z p ) : z p ∈ Q p } be a oneparameter unipotent Q p -subgroup, which means that u p : Q p → G(Q p ) is a non-trivial Q prational homomorphism. [21].
We will need a uniform version of Ratner's theorem for the action of unipotent groups on G/Γ, in the special case that Γ is an S-arithmetic subgroup. Let us mention that Ratner's main result in [21] was independently obtained in Margulis-Tomanov paper [18]. The following class of groups introduced by Tomanov plays an important role in this theorem. Definition 6.1. [27] A connected Q-algebraic subgroup P of G is a subgroup of class F relative to S if for each proper normal Q-algebraic subgroup Q of P, there exists p ∈ S such that (P/Q)(Q p ) contains a non-trivial unipotent element.
If P is a subgroup of class F in G, then for any subgroup P ′ of finite index in P(Q S ), P ′ ∩ Γ is an S-arithmetic lattice in P ′ . For a closed subgroup U of G, and a proper subgroup P of G of class F, we write X(P, U ) = {g ∈ G : U g ⊆ gP }. One can see that X(P, U ) is a Q S -algebraic subvariety of G. We will prove the following S-arithmetic version of [7, Theorem 3].
Theorem 6.2. Let G be a Q-algebraic group, G = G(Q S ), Γ an S-arithmetic lattice in G, and let µ denote the G-invariant probability measure on G/Γ. Let U = {(u p (z p )) p∈S |z p ∈ Q p } be a one-parameter unipotent Q S -subgroup of G, and let φ : G/Γ → R be a bounded continuous function. Let K be a compact subset of G/Γ, and let ǫ > 0. Then there exist finitely many proper subgroups P 1 , . . . , P k of G of class F, and compact subsets C i ⊆ X(P i , U), where P i = P i (Q S ), 1 ≤ i ≤ k, such that the following holds: given a compact subset F of K \ ∪ i C i Γ/Γ, for all x ∈ F and all T with m(T) ≫ 0, we have Following [7] and [27], we denote the set of singular points with respect to U by S(U ) = P∈F ,P =G X(P, U )Γ/Γ. Its complement G(U ) = G/Γ \ S(U ) will be called the set of generic points.
For a subset S ′ of S, the direct sum u S ′ : Q S ′ → G of one-parameter unipotent subgroups defined by u S ′ ((t p ) p∈S ′ ) = (u p (t p )) p∈S ′ is called a one-parameter unipotent Q S ′ -subgroup of G. If the subset S ′ is known from the context, we sometimes write u(t) instead of (u p (t p )) p∈S ′ .
When r > 0, we will use the notation I p (r) for the closed ball of radius r in Q p centered at zero. When p is a non-archimedean place, we will implicitly assume that r is a power of p. Any translation of I p (r), that is any set of the form b + I p (r), will be called an interval. When p ∈ S f , the ultrametric property of the norm implies that if J 1 and J 2 are two intervals with a non-empty intersection, then J 1 ⊆ J 2 or J 2 ⊆ J 1 . In the rest of this article, for a p-adic interval L = I p (r), we will writeL = I p (pr). We will start by recalling the following S-arithmetic version of the quantitative non-divergence theorem of Dani-Margulis which will later be needed in this paper: Theorem 3.3). Let G be a Q-algebraic group, G = G(Q S ), and Γ an Sarithmetic lattice in G, and µ denote the G-invariant probability measure on G/Γ. Let S ′ ⊆ S, and U = {u(t)|t ∈ Q S ′ } be a one-parameter unipotent Q S ′ -subgroup of G. Let ǫ > 0 and K ⊆ G/Γ be a compact set. Then there exists a compact subset K 1 such that for any x ∈ K 1 and any S ′interval I(T) in Q S ′ , we have Let Γ be an S-arithmetic lattice in G. If P is a subgroup of class F in G then for any subgroup P ′ of finite index in P(Q S ), we have P ′ ∩ Γ is an S-arithmetic lattice in P ′ . The following proposition has been proven in [27].
We will also need the following S-adic analogue of Theorem 2 in [7]. Theorem 6.5. Let G be a k-algebraic group, G = G(Q S ), and Γ be an S-arithmetic lattice in G. Let U (i) = {u (i) (t)|t ∈ Q S } be a sequence of one-parameter unipotent Q S -subgroup of G, such that u (i) (t) → u(t) for all t ∈ Q S , as i → ∞. Assume that the sequence (x i ) i≥1 ∈ G/Γ converges to the point x ∈ G(u(t)), and let m(T i ) → ∞. For any bounded continuous function φ : Let us briefly sketch the proof of this theorem. The main ingredient of the proof is the quantitative non-divergence theorem, whose S-adic analogue, Theorem 6.3, is proven in [27]. Arguing by contradiction, one assumes that there exists a sequence x i of points for which the statement is not true. Using the density of the set of generic points, one may assume that x i are generic for u t . Invoking the quantitative non-divergence again, one then shows that there is no escape of mass to infinity. Once we verify that the limiting measure is u(t)-invariant, the measure classification theorem of Ratner will finish the proof. For details, we refer the reader to [7].
Let P be a subgroup of class F in G. By Chevalley's theorem, there exists a k-rational representation ρ P : G → GL(V P ) such that N G (P) equals the stabilizer of a line in V spanned by a vector m ∈ V (Q). This representation and the vector m are fixed throughout this paper. Let χ be the k-rational character of N G (P) defined by χ(g)m = gm, for g ∈ N G (P). We denote N = {g ∈ G : gm = m} and N = N(Q S ). We also set Γ N = Γ ∩ N and Γ P = Γ ∩ N G (P). The orbit map η P : G → Gm ⊆ V P is defined by η P (g) = gm. The orbit Gm is isomorphic to the quasi-affine variety G/N and η is a quotient map. Set X = {g ∈ G : U g ⊆ gP} and let A P denote the Zariski closure of η P (X(P, U )). Clearly X is an algebraic variety of G defined over k S and X(Q S ) = X(P, U ). It is not hard to show (see [27]) that η −1 (A P ) = X(P, U ). It will be useful to consider the map Rep : G/Γ → V P defined as follows. For each x ∈ G/Γ, we define Rep(x) = {η P (g) : g ∈ G, x = gΓ}. For D ⊆ A P and for γ ∈ Γ, we define the γ-overlaps of D by O γ (D) = {gΓ : η P (g) ∈ D, η P (gγ) ∈ D} ⊆ G/Γ. Finally, we set The proof of the following lemma is straightforward: Lemma 6.6. For γ ∈ Γ and γ 1 ∈ Γ P , and D ⊆ A P we have For each subgroup P of class F relative to S, we will denote I P = {g ∈ G : ρ P (g)m P = m P }. A proof for the following proposition can be given along the same lines as the proof of Proposition 7.1 in [7]. Proposition 6.7. Suppose P is a subgroup of class F relative to S, and C ⊆ V P is compact. Assume also that K ⊆ G/Γ is compact. Then there exists a compact set C ⊆ G such that π( C) = {x ∈ K : Rep(x) ∩ C = ∅}. Proposition 6.8. Let P be a subgroup of class F relative to S and D ⊆ A P be compact. Let K ⊆ G/Γ be compact. Then the family {K ∩ O γ (D)} γ∈Γ contains only finitely many distinct elements. Moreover, for each γ ∈ Γ, there exists a compact set C γ ⊆ η −1 Proof. The argument for finiteness from Proposition 7.2. in [7] can be carried over verbatim to this case.
Let us denote by E the class of subsets of G of the form E = r i=1 η −1 P i (D i ), where P i are subgroups of class F and D i ⊆ A P i are compact. For such a set E (together with the given decomposition), we denote N (E) to be the family of all neighborhoods of the form Φ = We will refer to these neighborhoods as components of Φ. The following definition from [27] will also be used in this paper. Let δ > 0 be such that for any z ∈ Z * S , if for all p ′ ∈ S \ {p}, we have |z − 1| p ′ < δ, then z = 1. The existence of δ follows from the fact that the map from Z * S to R S defined by λ(x) = (log |x| p ) p∈S has a discrete image in a codimension-one subspace of R S . A subset A = p∈S A p ⊆ G is said to be S(p)-small if for all p ′ ∈ S \ {p} the following holds: if c ∈ Q * p ′ is such that c(A p ′ m) ∩ A p ′ m = ∅, then |c − 1| p ′ < δ. We will now prove a stronger version of a theorem in [27]. Theorem 6.9. Let p ∈ S, ǫ > 0, and let K ⊆ G/Γ be compact. For E ∈ E, there exists E ′ ∈ E such that the following holds: given Φ ∈ N (E ′ ), there exists a neighborhood Ω ⊇ π(E) such that for any one-parameter unipotent subgroup {u p (t)} of G, and any g ∈ G, and any r 0 > 0, one of the following holds: (1) A component of Φ contains {u p (t)gγ : t ∈ I p (r)} for some γ ∈ Γ.
Proof. It is clear that we can assume that E = η −1 P (C) and that E is S(p)-small. We will now proceed by the induction on dim P. The result is clearly valid for dim P = 0. Let us assume that it is known for all P with dimension at most n − 1 and that C ⊆ A P , with dim P = n. Applying Proposition 6.4 to C (viewed as a compact subset of the Zariski closed set A P ), we obtain a compact subset D of A P such that for any compact neighborhood Φ of D in A P , there exists a neighborhood Ψ of C in A P such that for any one-parameter subgroup {u p (t)} of GL(V P ), any point w ∈ V P \ Φ, and any interval I ⊆ Q p containing 0, we have λ p {t ∈ I : u p (t)w ∈ Ψ} ≤ ǫ · λ p {t ∈ T : u p (t)w ∈ Φ}.
Note that since the set of the roots of unity in Q p is finite, we can choose D such that ωD = D for every root of unity ω ∈ Q p , and thus D can be chosen to be S(p)-small. Now, let B = η −1 P (D). By Proposition 6.8 the family of sets {K ∩ O γ (D)} γ∈Γ is finite, hence consists of the sets K ∩ O γ j (D), for 1 ≤ j ≤ k. We assume that γ 1 = e. Moreover, we can write K ∩ O γ j (D) = π(C j ) for some compact subset C j ⊆ B ∩ Bγ −1 j ⊆ X(P ∩ γ j Pγ −1 j , W ). We claim that γ j ∈ Γ P for j ≥ 2. Assuming the contrary, we obtain ρ(γ j )m P = χ(γ j )m P . Since χ(γ j ) ∈ O * , we have η P (bγ j ) = χ(γ j )η P (b) ∈ D. Since D is S(p)-small, we obtain that χ(γ j ) is a root of unity in Q * p . This shows that Bγ j ⊆ η −1 (D) = B, which is a contradiction to the choice of γ j . From here we see that for j ≥ 2, P ∩ γ j Pγ −1 j is a proper subgroup of P. Hence there exists a subgroup P j of class F which is contained in the connected component of P ∩ γ j Pγ −1 j . Note that P j is of dimension less than n, and C j ⊆ X(P j , W ). We now set E j = η −1 P j (η P j (C j )) and apply the induction hypothesis to obtain E ′ j ∈ E such that for any choice of Φ j ∈ N (E ′ j ), we can find neighborhoods Ω j of E j such that for any one-parameter subgroup (u p (t)) t∈Qp of G, g ∈ G and r > 0, we have λ v {t ∈ I p (r)\I p (r 0 ) : u p (t)gΓ ∈ Ω j ∩ K} ≤ (ǫ/2k)r unless there exists γ ∈ Γ such that the set {u p (t)gγ : t ∈ I p (r)} is contained in a component of Φ j . Set E ′′ = n j=2 E ′ j ∈ E and E ′ = E ′′ ∩ B. Consider Φ ∈ N (E ′ ). This shows that there exists a neighborhood Ω ′ of π(E ′′ ) such that for any one-parameter unipotent subgroup {u p (t)} t∈Qp , every g ∈ G and r 0 > 0, we have Since D is S(p)-small, we can clearly choose Φ 1 to be S(p)-small. As ρ(u p (t)) is a one-parameter unipotent subgroup of GL(V ), and η P (C) is of relative size less than ǫ/4 in D, we can find a neighborhood Ψ of C in V satisfying for all v ∈ V \ Φ 1 , r > 0 and unipotent subgroups {u p (t)} t∈Qp . Let Ω = π(η P (Ψ)) ⊆ G/Γ. Assume that (1) does not hold for g ∈ G, a one-parameter subgroup {u p (t)} t∈Qp , and r 0 > 0. This implies that for every γ ∈ Γ, there exists t ∈ I p (r 0 ) such that u p (t)gγ ∈ G \ Φ. For q ∈ M, we consider the following sets: is an open subset of Q p , it is a disjoint union of intervals. We will also define J 3 (q) ⊆ J 1 (q) as follows: if v is an archimedean place, then J 3 (q) consists of those t ∈ J 1 (q) such that for some a ≥ 0, we have [t, t + a] ⊆ J 1 (q) and π(u(t + a)g) ∈ K 1 . If v is a non-archimedean place, then J 3 (q) consists of those t ∈ J 1 (q) such that there exists an interval J ⊆ Q p containing t and t ′ ∈ J such that π(u(t ′ )g) ∈ K 1 . Clearly J 3 (q) is open in Q p , and is hence a disjoint union of intervals. We first make the following claim: Claim: J 3 (q 1 ) ∩ J 3 (q 2 ) = ∅ for q 1 , q 2 ∈ M, unless q 2 = ωq 1 for some root of unity ω ∈ Q * p . In the archimedean case, if t ∈ J 3 (q 1 ) ∩ J 3 (q 2 ), then there exists a ≥ 0 such that [t, t + a] ⊆ J 1 (q 1 ) ∩ J 1 (q 2 ) and π(u(t + a)g) ∈ K 1 . If q j = η(γ j ) for j = 1, 2, then η(u(t + a)gγ 1 ) = η(u(t + a)gγ 2 ) ∈ Φ 1 , we will have q 1 , q 2 ∈ O(Φ) ∩ K 1 = ∅, unless γ −1 1 γ 2 ∈ Γ P , which implies that q 2 = ωq 1 .
Denote I p (a, r) = a + I p (r), and let L 1 be the family of those components L = I p (a, r 1 ) of J 1 (q) such that L ∩ I p (r 0 ) = ∅, and L 2 the rest of components. Note thatL ⊆ I p (r 0 ). This implies that λ p (L ∩ J 2 (q)) ≤ λ p (L ∩ J 3 (q)), which, in turn, shows that We now claim that L∈L 2 λ p (L) ≤ λ p (I p (r)). In fact, if L ∈ L 2 , then either L ⊆ I p (r 0 ) or I p (r 0 ) ⊆ L. If I p (r 0 ) ⊆ L for some L ∈ L 2 , then since components are disjoint, L 2 has precisely one element and the result follows. So, assume that for each L ∈ L 2 , we have L ⊆ I p (r 0 ). Then the disjointness of components implies that L∈L 2 λ p (L) ≤ λ p (I p (r 0 )). Proposition 6.10. Let G be a Q-algebraic group, G = G(Q S ), and Γ be an S-arithmetic lattice in G. Let U be a one-parameter unipotent subgroup of G. Assume that P 1 , . . . , P k are subgroups of class F for 1 ≤ i ≤ k, and let D i be a compact subset of A P i , and Θ i be a compact neighborhood of D i in V P i . For a given compact set K ⊆ G/Γ, there exists P ′ 1 , . . . , P ′ k of class F and compact subsets Proof. The proof of this proposition is very similar to the proof of Proposition 8.1 in [7]. Let us denote by I P the set of g ∈ G with g.m P = m P . We first claim that there exists a subgroup P ′ of class F such that X(I P , U ) ⊆ X(P ′ , U ). In fact, let P ′ be the smallest connected algebraic subgroup of G which contains all the unipotent elements of I P . Note that since P ′ is generated by unipotent subgroups, we have X k (G) = {1}, where X k (G) denotes the group of characters of G defined over k. It follows from Theorem 12.3 of [4] that P ′ ∩ Γ is a lattice in P ′ and P ′ is of class F. Let P ′ 1 , . . . , P ′ k be chosen as above such that X(I P i , U ) ⊆ X(P ′ , U ) for all 1 ≤ i ≤ k. We will also define Q i = {w ∈ Θ i : ρ P i (u p (t))w = w, ∀t ∈ Q p }. Using Proposition 6.7, we can find compact subsets This implies that C i ⊆ X(P i , U ). Consider the compact sets It thus suffices to show that for each 1 ≤ i ≤ k and γ ∈ Γ, for all large enough t we have is a compact subset of V P i which does not contain any fixed point of the flow ρ P i (u p (t)). Since ρ P i (u p (t)) is a unipotent one-parameter subgroup of GL(V P i ) the result follows.
Proof of Theorem 6.2. For a bounded continuous function φ defined on G/Γ, the one-parameter unipotent group (u(t)) and x ∈ G/Γ, we define Let us consider the above statement with S replaced by S ′ ⊆ S everywhere. We will prove the statement first for the case |S ′ | = 1. Then we will show that if the statement holds for S 1 and S 2 , then it must also hold for S 1 ∪ S 2 . Suppose that S ′ = {p} for some p ∈ S. We argue by contradiction. Assume that the statement of the theorem is not true. This implies the existence of a bounded continuous function φ : G/Γ → R, a compact subset K 1 ⊆ G/Γ, and ǫ > 0 such that for any proper subgroups P 1 , . . . , P k of class F, and any compact subsets C i ⊆ X(P i , U ), where P i = P(Q p ), 1 ≤ i ≤ k, there exists a compact set F of K 1 \ ∪ i C i Γ/Γ such that for all T 0 > 0, there exists T > T 0 , and x ∈ F such that ∆(φ, u(t), x, T ) > ǫ. Without loss of generality, we can assume that φ has compact support and is bounded in absolute value by 1. There exists a compact subset K ⊆ G/Γ such that for all x ∈ K 1 and all T , we have (17) λ p {t ∈ I p (T ) : u p (t)x ∈ K} < 1 3 λ p (I p (T )).
We can now apply this to construct an increasing sequence E i ⊆ E i+1 in E such that (1) The family {E i } i≥1 exhausts the singular set of U , i.e., ∞ i=1 E i = S(U ).
(2) For each i ≥ 1, there exists an open neighborhood Ω i ⊃ E i Γ/Γ such that for any compact set F ⊆ K \ E i+1 Γ/Γ, there exists T i+1 such that for all x ∈ F and T > T ′ i we have For i ≥ 1, write K ∩ π(E i ) = π(C j ) for some compact sets C j ∈ X(P j , U ), 1 ≤ j ≤ k. As we are arguing by contradiction, we can find a compact subset F i ⊆ K 1 \π(E i+1 ) such that for each T 0 there exists x ∈ F i and T ≥ T 0 such that ∆(φ, u p (t), x, T ) > ǫ. Without loss of generality, assume that T 1 < T 2 < · · · . This implies that there exists x i ∈ F i and σ i such that ∆(φ, u p (t), From (17) and (18), for each j ≥ 1 we obtain t j ∈ I(T j ) such that As y j ∈ K and K is compact, there exists a limit point y ∈ K. By construction, y ∈ Ω j for all j ≥ 1. This shows that y is not a singular point for U . Now, we can apply Theorem 6.5 to a convergent subsequence of {y j } and the corresponding subsequence of σ i , to obtain a contradiction. Let us now turn to the general case. Assume that the statement is known for S 1 , S 2 ⊆ S, and S 1 ∩ S 2 = ∅. We write U 1 = (u p (t p )) p∈S 1 and U 2 = (u p (t p )) p∈S 2 . Note that there exists a compact subset K 1 ⊆ G/Γ such that for all x ∈ K and any interval I(T j ) ⊆ Q S j , j = 1, 2, containing zero we have 1 Here, we have used the shorthands u 1 (t) = (u p (t p )) p∈S 1 and dλ 1 for the Haar measure on p∈S 1 Q p . By the induction hypothesis, there exist finitely many proper subgroups P 1 , . . . , P k of class F, and compact subsets C i ⊆ X(P i , U ), where P i = P i (Q S ), 1 ≤ i ≤ k, such that the following holds: for any compact subset F of K 1 \ ∪ i C i Γ/Γ there exists T 0 such that for all x ∈ F and S 1 -vector T 1 with m(T 1 ) > T 0 , we have Since C i Γ/Γ ⊆ G/Γ has measure zero, we can choose neighborhoods N i of C i Γ/Γ, each of measure at most ǫ/16k. Now, let φ i , 1 ≤ i ≤ k be a continuous function such whose restriction to N i is 1, and G/Γ φ i < ǫ/8k. By applying the induction hypothesis to φ 1 , . . . , φ k , we can find finitely many proper subgroups Q 1 , . . . , Q l of class F, and compact subsets such that the following holds: for any compact subset F of K \ ∪ i D i Γ/Γ, for all x ∈ F and m(T 2 ) sufficiently large, we have Since φ i (x) = 1 for all x ∈ N i , we obtain Note that by the choice of K 1 , we have λ 2 (A) ≥ (1 − ǫ/4)λ 2 (I(T 2 )). Combining this with (19), we obtain Decomposing u(t) = u 1 (t 1 )u 2 (t 2 ), and using Fubini's theorem, we obtain It follows that the collection of X(P i , U ), 1 ≤ i ≤ k and X(Q j , U ), 1 ≤ j ≤ l will satisfy the conditions of the theorem.

Equidistribution of translated orbits
Let G, H, and K be as before. In this section, we prove the equidistribution of the translated orbit a t Kg in G/Γ, where g ∈ G is fixed (or varies over a compact set), and t tends to infinity. The main result will be proven in two steps. In the first step-dealt with in this section-we assume that the test function in Theorem 1.8 is bounded. The main argument, which is purely dynamical, is based on approximating the integral above, with a similar one involving orbits shifted by unipotent elements. The advantage is that the latter can be handled using an Sarithmetic version of Dani-Margulis theorem, which is generally false for unbounded functions. We will eventually need to prove Theorem 1.8 for test functions with a moderate blowup at the cusp. This step requires an analysis of certain integrals involving the α-function, which is carried out in a later section.
Theorem 7.1. Let n ≥ 3 be a positive integer, and let G, H, K and a t be as above. Let φ : G/Γ → R be a bounded continuous function, and q p be a positive continuous function on U n p , and q = p∈S q p . Let x 0 ∈ G/Γ be such that the orbit Hx 0 is not closed. Then Here dµ denotes the G-invariant probability measure on G/Γ.
The proof of this theorem closely follows [7]. The integral of φ along the a t -translates of the K-orbits is approximated by a similar integral with a t replaced by the unipotent flow to which a generalized theorem of Dani and Margulis will be applied. One difference between the situation here and the one in [10] is that as {a t } is a Z-flow, the orbit needs to be "fattened up" in order to obtain rough approximations of the orbit of a unipotent flow, which is similar to intervals in Q p .
Fix a prime p ∈ S f . For simplicity, let us suppress the dependence of matrices introduced below on p. For α ∈ U p = {α : |α| = 1} and t ∈ Z, we set Note that d t = b t,α u t,α k t,α w α , {k t,α : t ∈ N, α ∈ U p } and {w α : α ∈ U p } embeds into K p (with the embedding of SL 2 (Q p ) into SO(q)). This is parallel to a similar formula in the real case. The only different is that w is constant in the real case, whereas here it depends on α.
Proof of Theorem 7.1. Without loss of generality, we may assume that φ and q are uniformly continuous. We first prove an analogous statement for (u z ) z∈Q S instead of (a t ) t∈T S . We will then deduce the statement for the latter from a similar statement for the former by an approximation process. First, we will show that under the assumptions of Theorem 1.8, we have Claim 1: There exist x 1 , . . . , x ℓ ∈ G/Γ such that the orbits Hx i are closed and each carries a finite H-invariant measure, such that for each compact set F ⊆ D − ℓ i=1 Hx i , for any T with m(T) sufficiently large, and all x ∈ F, we have Indeed, let P 1 , . . . , P k be the subgroups provided by Theorem 6.2 for the data (φ, KD, ǫ), and let C i ⊆ X(P i , U) be the corresponding compact sets. Define Let M be the subgroup of G generated by k −1 Uk, where k ∈ K. The normalizer L = N G (M ) contains K, hence is of the form L = EK where E is a normal subgroup of H. Since U ⊆ L and U is not included in any proper normal subgroup of H, we obtain M = H. Note that for any y ∈ Y i , we have k −1 Uk ⊆ yP i y −1 , for all k ∈ K. So H ⊆ yP i y −1 . It follows that there exists a subgroup of finite index P ′ i in P i such that H = yP ′ i y −1 for all y ∈ Y i . This implies that y −1 1 y 2 ∈ N G (H) for all y 1 , y 2 ∈ Y i . Hence Y i can be covered with a finite number of right cosets of H. Therefore, Note that P i ∩ Γ is a lattice in P i . Since X(P i , U) is an analytic subset of G, we have for every x ∈ F. From here it easily follows (using an analogue of Lemma 4.2 in [10]) that there exists an open subset W ⊆ G/Γ containing k i=1 C i Γ/Γ such that m({k ∈ K : kx ∈ W }) < ǫ for any x ∈ F. From the choice of C 1 , . . . , C k , we have that for every y ∈ KD − W and all T with m(T) ≫ 0, we have (20) 1 Let q be a bounded continuous function on K. It follows that We will now turn to the approximation part. Fix p ∈ S f . In what follows dα is the Haar measure on Z p normalized such that Up dα = 1. First note that We can now write Note that as t → ∞, b t,α and k t,α converge to 1 uniformly in α. Hence, for large values of t, we have Since q is continuous, we can partition U p into intervals I 1 , . . . , I r such that for each 1 ≤ i ≤ r, there exists w i ∈ K p such that |q(w −1 α k) − q(w i k)| < ǫ/4 for every α ∈ I i . This implies that It is clear that I i,t = {p −t α : α ∈ I i } has a measure comparable to p t . So, for sufficiently large t, we have We can now apply (20) to obtain the result.

Establishing upper bounds for certain integrals
In this section, we will prove Theorem 1.7. In the course of the proof we will need to consider a number of integrals that are intimately connected to the integral featured in Theorem 1.7. In the rest of this section, we fix p ∈ S f and denote by a t the linear transformation a p t defined in equation (2): a t e 1 = p t e 1 , a t e n = p −t e n , and a t e j = e j , 2 ≤ j ≤ n − 1.
Lemma 8.1. Let V be a finite dimensional vector space over Q p and let K be a compact subgroup of GL(V ). Let v ∈ V and W be a proper subspace of V such that for any finite index subgroup K ′ of K and any non-zero subspace W ′ ⊂ W , K ′ W ′ ⊆ W ′ . Then the subset (24) tran(v, W ) := {k ∈ K : kv ∈ W } ⊆ K has Haar measure zero.
Proof. Denote the Haar measure on K by m. Since K is compact, m(K) < ∞. Suppose that m(tran(v, W )) > 0. Take W ′ ⊆ W of the smallest dimension such that tran(v, W ′ ) has a positive measure. For each k ∈ K, set kW has dimension strictly lower than that of W ′ , by minimality, the intersection has measure zero. Thus {kW ′ : k ∈ K} is a finite set and K ′ := {k : kW ′ = W ′ } is of finite index in K. Then K ′ W ′ = W ′ ⊂ W ′ , contradicting to the condition that K ′ W ′ W ′ . Lemma 8.2. Let ρ be an analytic representation of SL n (Q p ) on a finite dimensional normed space (V, ) over Q p such that all elements of ρ (SL n (Z p )) preserve the norm on V . For g ∈ SL n (Q p ) and v ∈ V , we will denote ρ(g)(v) by gv. Let K be a closed analytic subgroup of SL n (Z p ). Assume that V has a decomposition Let Q be a closed subset of {v ∈ V : v p = 1}. Suppose that the following conditions are satisfied: (1) The subspace W − + W 0 satisfies the assumption of Lemma 8.1; (2) There is a positive integer ℓ such that for any nonzero v ∈ W − , Then for any s, 0 < s < ℓ, lim t→+∞ sup v∈Q K dm(k) a t kv s = 0, where m is the normalized Haar measure on K.
Proof. Let π : V → W + ⊕ W 0 and π + : V → W + denote the natural projections associated to the decomposition (25). For any v ∈ V and r ≥ 0, define We will show that the measure of D(v, r) is bounded by Cr ℓ , where C is uniform over all v ∈ Q. Recall that the Lie algebra Lie(K) is defined as the tangent space to the p-adic analytic manifold K at the identity. Consider the map f v : K → W + ⊕ W 0 defined by f v (k) = π(kv). Since K acts by linear transformations, the derivative of f v at the identity is given by (27) d e f v (x) = π(xv), x ∈ Lie(K) = T e K ⊆ sl n (Q p ).
For every v ∈ V , set For k ∈ K, also define the map m k : K → K by m k (k ′ ) = k ′ k. Note that m k (e) = k and d e m k : showing that rank d e f kv = rank d k f v . From the assumption, if f v (k) = 0, then kv ∈ W − , hence by the assumption of the theorem, codim ker d e f kv ≥ ℓ, which implies that codim ker d k f v ≥ ℓ. Let us denote by P(V ) the projective space on V , and by [v] the image of the non-zero vector v in P(V ). We know that if f : U → V is a p-adic analytic function, then the map x → rank d x f is lower semi-continuous, that is, lim inf y→x rank d y f ≥ rank d x f . This implies that for every v ∈ W − , there exists an open subset U containing [v] ∈ P(V ) such that for [w] ∈ U , we have codim ker d k f w ≥ ℓ. By compactness, there exists ǫ > 0 such if p(kv) ≤ ǫ v , then the map f v has a rank at least ℓ. Using the implicit function theorem for local fields (e.g. [25]), for any k ∈ K for which π(kv) ≤ ǫ v , we can choose local coordinate systems for U k ⊂ K at k and for W + ⊕ W 0 in which f v is given by f v (u 1 , . . . , u m ) = (u 1 , . . . , u ℓ , ψ ℓ+1 , . . . , ψ m ′ ), where m = dim K, m ′ = dim W 0 + dim W + and ψ j (u 1 , . . . , u m ) is an analytic function for j = ℓ + 1, . . . , m ′ depending smoothly on v. If r ≤ ǫ, for such a neighborhood U k , k ∈ D(v, r), there is a nonnegative α = α(k) satisfying We will now have to consider the set By Lemma 8.1, we have m(D + (v, 0)) = 0. We claim that this and the compactness of Q imply that Otherwise, pick a sequence r n → 0, and v n ∈ Q such that m(D + (v n , r n )) > ǫ for some ǫ. Upon passing to a subsequence, we can assume that v n converges to v.
Since a t | W 0 = Id W 0 and (28), we see that for a positive integer t, a t kv s ≥ π(kv) s hence for any v ∈ V , v = 1 and any r > 0. From the fact that m (D(v, 0)) = 0, On the other hand, since a t | W + = p −t Id W + , we get that a t kv s ≥ p ts π + (kv) s so that for any v ∈ V , r > 0 and r 1 > 0, K\D(v,r) dm(k) a t kv s ≤ Therefore for a given ǫ 0 > 0, since ℓ−s > 0, take r > 0 and r 1 > 0 such that Cr ℓ−s / p −s − p −ℓ < ǫ 0 /3 and m (D + (v, r 1 )) r −s < ǫ 0 /3. Then we can take t ′ > 0 such that if t > t ′ , then p −ts r −s 1 < ǫ 0 /3 so that K dm(k) a t kv s < ǫ 0 .
We now write V i for the i-th exterior power i Q n p , and denote by ρ i the i-th exterior power of the natural representation SL n (Q p ) on Q n p . Recall that for an i-tuple J = (j 1 , . . . , j i ), we define e J = e j 1 ∧ · · · ∧ e j i . It is easy to see that V i decomposes into a t -eigenspaces Then for any s, 0 < s < 2, Proof. Let us first consider the special case of n = 4, in which q p is given by , where a i ∈ {±1, ±u 0 , ±p, ±u 0 p}. Here u 0 ∈ U p is a representative of a quadratic non-residue in the quotient Z p /pZ p . Define the following subgroups of K. As above, if for any sufficiently small z 1 , z 2 , the elements u z 1 v, u ′ z 2 v ∈ W − ⊕ W 0 , then the coefficients of e 24 , e 34 vanish, i.e.
It is clear that any non-zero linear combination z 1 u 1 + z 2 u 2 is not in the set {x ∈ Lie(K) : xv ∈ W − }.
For i = 2, for v = x 12 e 12 + x 13 e 13 , we have Suppose that the form q is not exceptional, in other words, a 2 = −a 3 . For an arbitrary v, we claim that any non-zero linear combination z 1 u 1 +z 2 u 2 is not in the set {x ∈ Lie(K) : xv ∈ W − }, thus we get codimension of the set at least ℓ = 2. Indeed, if we solve the conditions for z 1 , z 2 , we obtain (x 12 /x 13 ) 2 = −a 3 /a 2 , and the right hand side is not a square unless a 2 = −a 3 . The case i = 1 is immediate. Thus the condition (2) of Lemma 8.2 is satisfied. By Lemma 8.2, for 0 < s < 2, we can see that lim t→∞ sup v∈Q i K dm(k) a t kv s = 0, for any i. Now let us consider n ≥ 5. Denote the embedding from SO(x 1 x 4 + a j 2 x 2 2 + a j 3 x 3 3 ) to SO(q p ) induced by e 1 → e 1 , e 2 → e j 2 , e 3 → e j 3 , e 4 → e n .
by ι(j 2 , j 3 ). We will denote the induced embedding on their Lie algebras by ι(j 2 , j 3 ) again. For a non-exceptional isotropic standard quadratic form q p on Q n p , for any given i and any vector v = and ι(j 2 , j 3 )(SO(x 1 x 4 + a j 2 x 2 2 + a j 3 x 3 3 )) acts nontrivially on v. Clearly, the embedding ι(j 2 , j 3 ) maps subgroups U and U ′ into subgroups of the maximal compact subgroup K of SO(q p ).
In the next lemma, we will combine the results over different places p ∈ S. Recall that for t = (t p ) p∈S , we set a t = (a tp ) p∈S . For p ∈ S, we denote by ǫ p the element of T for which t p = 1 and t q = 0 for q = p. Note that for p ∈ S f , a ǫp = a p 1 = diag p, 1, . . . , 1, p −1 as an element in SO(q p ) (or as an element embedded in SO(q)).
Lemma 8.4. Let n ≥ 4, q be a non-degenerate isotropic non-exceptional quadratic form over Q n S , and K be the maximal compact subgroup of SO(q) defined above. If q is not exceptional, then for any s ∈ (0, 2) and any c > 0, there exists a positive integer m such that for every lattice ∆ in Q n S , and every t ∈ R, with (37) R = {mǫ p : p ∈ S}.
the following inequality holds: Proof. First, let us assume that q is not exceptional, and let c > 0 be given. We will use Proposition 8.3 and the analogous statement in [10]. For each p ∈ S, one can find an integer m p > 0 such that for any v ∈ F (i), where F (i) is defined in (31) with v p = 1, and any t p > m p .

Note that
This implies that for t = mǫ p , p ∈ S, we have We deduce that for every nonzero v ∈ F (i), and t ∈ R, we have For a given S-lattice ∆ in Q n S and each i, there exists a ∆-rational subspace L i of dimension i satisfying that By substituting a wedge product of Z S -generators of L i ∩ ∆ for v in (39), we have that Let ω > 1 be such that for all v ∈ F (i), 1 ≤ i ≤ n − 1, and t ∈ R we have Let Ψ i be the set of ∆-rational subspaces L of dimension i for which We will prove inequality (38) by distinguishing two cases. First, assume that Ψ i = {L i }. Then by (42), we have where v and v ′ are wedge products of Z S -generators of L and L i respectively. By inequalities (41),(43) and the definition of α i , Let M be an element of Ψ i different from L, and let dim(M + L i ) = i + j for some j > 0. Using Lemma 3.9 and the inequality (42), we get that for any k ∈ K, The result follows from (44) and (45).
For p ∈ S f , we will set D + n = diag p λ 1 , p λ 2 , . . . , p λn ∈ GL n (Q p ) : λ 1 ≤ λ 2 ≤ · · · ≤ λ n , λ i ∈ Z . Every element g ∈ GL n (Q p ) admits a Cartan decomposition g = k 1 (g)d(g)k 2 (g), k 1 (g), k 2 (g) ∈ GL n (Z p ), d(g) ∈ D + n . We will write λ i (g), 1 ≤ i ≤ n when d(g) = diag p λ 1 (g) , p λ 2 (g) , . . . , p λn(g) . Proposition 8.5. Let U be a neighborhood of the identity element e in SL n (Z p ) given by; where · p is the maximum p-norm on the vector space of n × n matrices with respect to the standard basis. Then for any k ∈ U and d, d ′ ∈ D + n , and any 1 ≤ i ≤ n, we have Proof. First note that g p = p −λ 1 (g) . Let us denote (i, j)-entry of g by g ij . Let d = diag p λ 1 , . . . , p λn and d ′ = diag(p λ ′ 1 , . . . , p λ ′ n ) be in D + n . Then dkd ′ = (p λ i +λ ′ j k ij ). Since |k ii | p = 1 for 1 ≤ i ≤ n and |k ij | p < 1 for any i = j, we obtain Consider the representation ρ i of GL n (Q p ) on the i-th exterior product i (Q n p ) in the usual way and denote the maximum p-norm on i Q n p with respect to the standard basis by · p . When expressed in the standard basis of i (Q n p ), the entries of ρ i (g) are given by pairs (J, K), where J and K are i-element subsets of the set {1, 2, . . . , n}. More precisely, ρ i (g) = (det g JK ), where g JK is the i × i minor of g formed by the rows in J and columns in K. Note that the p-norm on i Q n p is also invariant under the action of GL n (Z p ). For k ∈ U , since |k ii | p = 1 and |k ij | < 1 for i = j, we readily see that | det(k JK )| = 1 if J = K and | det(k JK )| < 1, otherwise. This implies that ρ i (g) p = ρ i (dkd ′ ) p = p −(λ 1 (g)+···+λ i (g)) . Hence we obtain We remark that the above proposition also holds for D n − = diag p λ 1 , p λ 2 , . . . , p λn ∈ GL n (Q p ) : λ 1 ≥ λ 2 ≥ · · · ≥ λ n , λ i ∈ Z , instead of D n + . Corollary 8.6. Let H be a simply connected simple algebraic group in GL n (Q p ) and K the maximal compact subgroup SL n (Z p ) ∩ H of H. Let a t = diag(p −t , 1, . . . , 1, p t ) for t ∈ Z. Then there is a neighborhood U of e in K such that for t, s ≥ 0, we have a t U a s ⊂ Ka t a s K.
Take a neighborhood U of K satisfying the condition of Proposition 8.5. Then diag p λ 1 (atgas) , . . . , p λn(atgas) = diag p λ 1 (atas) , . . . , p λn(atas) = a t a s , so we get the result. Proposition 8.7. Let H = SO(q), K = SL n (Z p ) ∩ H and let F be a family of strictly positive functions on H having the following properties: (a) For every λ > 1, there exists a neighborhood V (λ), λ > 1 of the identity in H such that for all f ∈ F, λ −1 f (h) < f (gh) < λf (h) for any h ∈ H and g ∈ V (λ). (b) There exists a constant C > 0 such that for all p ∈ S f , and all h ∈ H, we have where a ǫp denotes the element diag(p, 1, . . . , 1, p −1 ).
Then there exists 0 < c = c(F) < 1 such that for any t 0 > 0 and b > 0 there exists B = B(t, b) < ∞ with the following property: If f ∈ F and Let C be an arbitrary compact set of unimodular lattices ∆ and let F be the family of f ǫ,s as ∆ runs over C. Then F satisfies the conditions of Proposition 8.7. From (59) it follows that there the constants b and c can be chosen uniformly for the family f ǫ,s ∈ F constant c and b. Since α i (h∆) s ≤ ǫ −i(n−i) f ǫ,s (h), by Proposition 8.7, we conclude that there exists a constant B > 0 such that for each i, all t ≻ 0 and all ∆ ∈ C, K α i (a t k∆) s dm(k) < B.
We will now use this bound to prove the main result. Define the set A(r) by (60) A(r) = {x ∈ G/Γ : α(x) ≤ r}.
Using Mahler's compactness criterion [15], we see that A(r) is compact for any r > 0.
By Theorem 1.7 and the fact that ν ∞ < ∞ , there exists C ′ > 0 such that On the other hand, since g r φ is compactly supported, we see that for sufficiently large t ∈ R >0 × N s in the cone generated by R (62) K (g r φ)(a t kx)ν(k)dm(k) − G/Γ (g r φ)(y)dg(y) K ν(k)dm(k) < ǫ/2, where dg is the normalized Haar measure on G/Γ. Since g r φ → φ as r → ∞, (61) and (62) show the theorem.

Counterexamples for ternary forms
In this section, we will prove Theorem 1.9 which partially shows that Theorem 1.5 is optimal in the sense that for some exceptional forms the asymptotics does not hold.
We will first introduce the family of quadratic forms which will be useful for the construction. Fix α p ∈ Q p , and define q αp (x) = x 2 1 + x 2 2 − α 2 p x 2 3 . Similarly, for an S-vector α = (α p ) p∈S ∈ Q S , we set q α = (q αp ) p∈S . In the case α ∈ Q, with a slight abuse of notation, we will also use q α as a shorthand for the quadratic form on Q n S associated to the constant S-vector with α p = α for all p ∈ S. We will first prove an S-adic version of a well-known fact from number theory adapted to fulfill our purpose.
Lemma 9.1. Given α ∈ Q, there exists a constant c α > 0 such that for a sufficiently large S-time T = (T p ) p∈S , there exists at least c α T log T vectors x = (x 1 , x 2 , x 3 ) ∈ Z 3 S which satisfy (1) q α (x) = 0.
(2) x i p = T p for every 1 ≤ i ≤ 3 and p ∈ S f .
Before we proceed to the proof, we emphasize that condition (2) is a stronger form of x = T p which is needed for the following arguments.
Proof. It will be slightly more convenient to first work with the quadratic form q ′ (x) = x 1 x 2 − x 2 3 , which is Q-equivalent to q α for every α. For p ∈ S f , write T p = p np , and set a = p∈S f p −np = T ∞ T −1 . We will consider triples x 1 = aku 2 , x 2 = akv 2 , x 3 = akuv, where u, k, v ∈ Z with gcd(u, v) = 1 and gcd(u, p) = gcd(v, p) = gcd(k, p) = 1 for all p ∈ S f . It is clear that x satisfies conditions (1) and (2). Moreover, the condition (3) will also be satisfied if k is chosen such that |u|, |v| ≤ T ∞ /3ak. It is well-known that the density of the pairs (u, v) with gcd(u, v) = 1 is c = 6/π 2 > 0. We can thus produce at least as many as 1≤k≤T∞/3a gcd(k,p)=1,p∈S c T ∞ 3ak = c T 1≤k≤T∞/3a gcd(k,p)=1, p∈S 1 k ≫ T log T solutions. Note that the forms q α can be obtained from q ′ applying a rational linear transformation A, which changes the real and p-adic norms by a bounded factor. This completes the proof.
We will need the following lemma, which is an S-arithmetic version of Lemma 3.15 in [10]. We will assume that Ω = p∈S U n p is the product of unit spheres, and drop it from the notation for the counting function. Proof. For the notational simplicity, we will set I ∞ = [1/4, 1/2] and I p = Z p for p ∈ S f . It will be clear that the proof works for any other choice of intervals. For α ∈ Q and T large, define L(α, T) = {x ∈ Z 3 S : q α (x) = 0, x ∞ ∈ [T ∞ /2, T ∞ ], x p = T p , ∀p ∈ S f }.
By Lemma 9.1, for large enough T, we have Note that if x = (x 1 , x 2 , x 3 ) ∈ L(α, T) then By condition (2) in Lemma 9.1, we also have |x 3 | p = T p = p mp for every p ∈ S. Set β 2 ∞ = α 2 − (1 + α 2 )T −2 ∞ , β 2 p = α 2 + u p p mp , where |u p | p = 1. Note that for sufficiently large T p , α 2 + u p p mp is a square in Q p and β is well-defined. A simple computation shows that for any x ∈ L(α, T) we have This implies that the N I,q β (T) ≥ card L(α, T) ≫ T log T 1−ǫ .
It is easy to see that the set of β obtained in this way is dense in Q S .
We can now prove Theorem 1.9. Assume that for a given T 0 , we denote by W (T 0 ) the set of γ ∈ Q S such that there exists β ∈ Q n S satisfying |β − γ| < T −3 and N I,q β (T) ≥ T log T 1−ǫ .
From the definition and Lemma 9.2, it is clear that W (T 0 ) ⊆ Q S is open and dense. Let T j be a sequence of S-times going to infinity. Then W = ∩ ∞ j=1 W (T j ) is a set of second category, and hence contains an irrational form. For any γ ∈ W , there exists an infinite sequence β i and T i satisfying |γ p − β i p | p < T i −3 for all p ∈ S and Set R i = T i . If x ∞ < R i , it is easy to see that q β i p (x) − q γ p (x) ∞ = O(R −1 i ) < 1/8 for i ≫ 1 and p ∈ S. This implies that q γ ∞ (x) ∈ [1/8, 2] and q γ p (x) ∈ Z p for p ∈ S f . The claim follows from here.
The argument when all q p are equivalent to x 1 x 2 − x 3 x 4 is similar. An argument along the same lines as the one given above, using the parametrization of the solutions to x 1 x 2 − x 3 x 4 given by x 1 = auv, x 2 = azw, x 3 = auz, x 4 = avw establishes the result in this case.
Since Y 0 = 0 and t X 0 B ′ X 0 = B ′ + pC 11 1 mod p 2 for some symmetric matrix C 11 1 , we can reduce the above equations as Take any Z 0 such that the first column is (v i+1 , . . . , v n ) and any W 0 satisfying t W 0 B ′′ W 0 = B ′′ mod p using the Witt theorem. Then it suffices to show that there is a matrix X 1 with the given first column satisfying the equation C 1 + t X 0 B ′ X 1 + t X 1 B ′ X 0 + t Z 0 B ′′ Z 0 = 0 mod p.
Step 3. We claim that for a given invertible symmetric matrix A and any symmetric matrix C, there is a solution X of the equation t XA + AX = C.
By considering the space of n by n matrices as a n 2 -dimensional vector space, we can rewrite the above equation by a 1n a 2n · · · · · · a nn        when A = (a st ), i = j; All entries are zero except j-th row is (a 1i , a 2i , . . . , a ni ), i = j.
Since t XA + AX and C are both symmetric, after removing rows repeated(for example, one of second row and (n+1)th row corresponding to c 12 and c 21 ) we get a linear equation from (Z/pZ) n 2 to (Z/pZ) n(n+1)/2 . Furthermore, from the fact that A is invertible, the rank of this reduced linear equation is exactly n(n + 1)/2 which tells us that there is a solution X. Now let us show that C 1 + t X 0 B ′ X 1 + t X 1 B ′ X 0 + t Z 0 B ′′ Z 0 = 0 mod p has a solution when C 1 , B ′ , X 0 , B ′′ , Z 0 and the first column of X 1 are given. That is, the first n 2 by n submatrix t (A 11 , . . . , A n1 ) of the equation (1) is erased together with the n variables [X] 1 .