The following is a theorem from the Linear Algebra Textbook by Friedberg, Insel, and Spence (5th Edition).
Theorem 6.38 (Sylvester's Law of Inertia). Let $H$ be a symmetric bilinear form on a finite-dimensional vector space $V$ over $\mathbb{R}.$ Then the number of positive entries and the number of negative entries in any diagonal matrix representation of $H$ are independent of the diagonal representation.
Please note that I understand the proof of the theorem and its details. Basically, the authors proved it by contradiction. By the way, to prove this result, we also need to show that there is an isomorphism between the space of all bilinear forms on V and $M_{n}(\mathbb{R}).$ Also, we need the fact that every real symmetric bilinear form on $V$ is diagonalizable. I can prove these two results, and that's all about the background.
To prove the theorem (Sylvester's Law of Inertia), the author did the following:
Suppose that $\beta$ and $\gamma$ are ordered bases for $\mathrm{V}$ that determine diagonal representations of $H .$ Without loss of generality, we may assume that $\beta$ and $\gamma$ are ordered so that on each diagonal the entries are in the order of positive, negative, and zero. It suffices to show that both representations have the same number of positive entries because the number of negative entries is equal to the difference between the rank and the mumber of positive entries. Let $p$ and $q$ be the number of positive diagonal entries in the matrix representations of $H$ with respect to $\beta$ and $\gamma$, respectively. We suppose that $p \neq q$ and arrive at a contradiction. Without loss of generality, assume that $p<q .$ Let $$ \beta=\left\{v_{1}, v_{2}, \ldots, v_{p}, \ldots, v_{r}, \ldots, v_{n}\right\} \text { and } \gamma=\left\{w_{1}, w_{2}, \ldots, w_{q}, \ldots, w_{r+\ldots,} w_{n}\right\} $$ where $r$ is the rank of $H$ and $n=\operatorname{dim}(\mathrm{V})$. Let $\mathrm{L}: \mathrm{V} \rightarrow \mathrm{R}^{p+r-q}$ be the mapping defined by $$ L(x)=\left(H\left(x, v_{1}\right), H\left(x, v_{2}\right), \ldots, H\left(x, v_{p}\right), H\left(x, w_{q+1}\right), \ldots, H\left(x, w_{r}\right)\right). $$
Then the rest of the proof is all about establishing a contradiction. This not super difficult. What I do not understand is the underlying motivation for defining such a linear map. The whole proof was like magic. How did someone come up with such a map? It does not look like a "natural" map at least to me. Is there any alternative proof of this theorem? I appreciate any help you could provide. Thanks so much.
Edit: From the suggestions of Captain Lama, I proved the result in a simple way. Let $U$ the subspace generated by the vectors $v_{1}, v_{2}, \ldots, v_{p}.$ Then using the linearity and diagonalizability of $H,$ we have that for any non-zero vector $x \in U,$ we must have $H(x, x) >0$ and dim$(U) =p$ is a maximal such dimension where $H$ is positive definite on $U.$ This shows that $p=q.$