# Quadratic forms and $p$-adic integers

I want to prove a result on equivalences of quadratic forms over $\mathbb{Q}_p$, with a control on the height of the change-of-basis matrix. (I am more generally interested in hermitian forms over division algebras over local fields, but for the purposes of this question the simplest case seems the most awkward.) I need the following result, which I can prove in a tedious way:

Let $p$ be a prime not equal to $2$ and $M \in \mathrm{M}_n(\mathbb{Z}_p)$. If there exists $A \in \mathrm{M}_n(\mathbb{Q}_p)$ such that $M = AA^t$ then there exists $B \in \mathrm{M}_n(\mathbb{Z}_p)$ such that $M = BB^t$.

(The difference between $A$ and $B$ is that $B$ has integer entries, while $A$ might not.)

I can prove this as follows: the quadratic form represented by $M$ can be diagonalised over $\mathbb{Z}_p$, so we may assume that $M$ is diagonal. We can also assume that its diagonal entries are contained in $\{ 1, p, u, pu \}$ for some fixed non-square unit $u$.

Since $M = AA^t$ this quadratic form is equivalent to the standard one over $\mathbb{Q}_p$. Thus $\det M$ is a square and it has Hasse invariant $+1$. This translates into conditions mod 4 on how many times $p$, $u$ and $pu$ appear (the conditions are different depending on whether $p$ is 1 or 3 mod 4). Thus there is a finite list of matrices of size at most 4 which have to be checked, and for each of these you can exhibit explicitly a suitable $B$.

Going through this list is quite tedious. Is there a more elegant proof of the result, or has it been written down somewhere already?

-

Let $V$ be the $n$-dimensional quadratic space over $\mathbb Q_p$ corresponding to the sum of $n$ squares. The matrix $M$ can be viewed as the Gram matrix for a $\mathbb Z_p$-lattice $L$ on $V$. Your condition on $M$ is equivalent to saying that $L$ is $\mathbb Z_p$-integral; so it must be inside a $\mathbb Z_p$-maximal lattice $K$ on $V$. Now, any two $\mathbb Z_p$ maximal lattices on $V$ are isometric. In particular, $K$ is isometric to the $\mathbb Z_p$-lattice $I_n$ ($I_n$ is maximal because $p$ is odd). Therefore, $I_n$ must contain an isometric copy of $L$, which is the same as saying that there exists an $B \in M_n(\mathbb Z_p)$ such that $M = BB^t$.