[proofplan]
The proof follows the same structure as [Sylvester's Law of Inertia](/theorems/429) for real symmetric bilinear forms.
We first diagonalise the Hermitian form (adapting the non-isotropic vector argument to the sesquilinear setting), then rescale by square roots of absolute values to reach the canonical form.
Uniqueness of $(p, q)$ follows from the same dimension argument: a positive-definite subspace and a non-positive subspace intersect only in $\{\mathbf{0}\}$.
[/proofplan]
[step:Diagonalise the Hermitian form by induction on dimension]
We adapt the diagonalisation argument from [Diagonalisation of Symmetric Bilinear Forms](/theorems/427) to the Hermitian setting.
If $\phi = 0$, any basis gives the zero matrix.
If $\phi \neq 0$, we find $v \in V$ with $\phi(v, v) \neq 0$.
Since $\phi$ is Hermitian, $\phi(v, v) = \overline{\phi(v, v)}$, so $\phi(v, v) \in \mathbb{R}$ for all $v$.
If $\phi(e_i, e_i) \neq 0$ for some basis vector $e_i$, take $v = e_i$.
If $\phi(e_i, e_i) = 0$ for all $i$ but $\phi(e_i, e_j) \neq 0$ for some $i \neq j$, write $\phi(e_i, e_j) = re^{i\theta}$ with $r > 0$ and set $v = e_i + e^{-i\theta}e_j$.
Then:
\begin{align*}
\phi(v, v) &= \phi(e_i, e_i) + e^{i\theta}\phi(e_j, e_i) + e^{-i\theta}\phi(e_i, e_j) + \phi(e_j, e_j) \\
&= 0 + e^{i\theta}\overline{re^{i\theta}} + e^{-i\theta} \cdot re^{i\theta} + 0 = r + r = 2r \neq 0.
\end{align*}
Take $W = v^\perp = \{w \in V : \phi(v, w) = 0\}$.
Since $\phi(v, v) \neq 0$, the functional $w \mapsto \phi(v, w)$ is nonzero, so $\dim W = n - 1$.
The intersection $\langle v \rangle \cap W = \{\mathbf{0}\}$ (since $c\phi(v, v) = 0$ implies $c = 0$), giving $V = \langle v \rangle \oplus W$.
By induction on $\dim V$, $\phi|_W$ can be diagonalised.
[/step]
[step:Rescale diagonal entries to $\pm 1$ and $0$]
After diagonalisation, $\phi$ has matrix $\mathrm{diag}(d_1, \dots, d_n)$ with $d_i \in \mathbb{R}$.
Reorder so that $d_1, \dots, d_p > 0$, $d_{p+1}, \dots, d_{p+q} < 0$, $d_{p+q+1} = \cdots = d_n = 0$.
For $i \leq p + q$, replace $e_i$ by $|d_i|^{-1/2}e_i$.
Then $\phi(f_i, f_i) = |d_i|^{-1} d_i = \mathrm{sgn}(d_i)$, so the matrix becomes $\mathrm{diag}(1, \dots, 1, -1, \dots, -1, 0, \dots, 0)$.
[/step]
[step:Prove uniqueness of $(p, q)$ by the positive-definite subspace dimension argument]
The uniqueness argument is identical to the real case in [Sylvester's Law of Inertia](/theorems/429).
Let $P = \langle f_1, \dots, f_p \rangle$ (positive part) and $N_0 = \langle f_{p+1}, \dots, f_n \rangle$ (non-positive part).
Any subspace $W$ on which $\phi$ is positive definite satisfies $W \cap N_0 = \{\mathbf{0}\}$: a nonzero vector $w \in W \cap N_0$ would have $\phi(w, w) > 0$ from $w \in W$ and $\phi(w, w) \leq 0$ from $w \in N_0$, a contradiction.
Therefore $\dim W \leq n - \dim N_0 = p$.
Since $P$ achieves this bound, $p$ is the maximal dimension of a positive-definite subspace, hence invariant.
By the same argument with signs reversed, $q$ is the maximal dimension of a negative-definite subspace, hence also invariant.
[/step]