[proofplan]
We first verify that $X^\top X$ is invertible, so the displayed formula for $H$ is well-defined. Symmetry follows from the transpose rule and the symmetry of $X^\top X$, while idempotence follows by multiplying $H$ by itself and cancelling $X^\top X$. The diagonal bounds are obtained by testing $H$ and $I_n-H$ on standard basis vectors, using symmetry and idempotence to rewrite the resulting quadratic forms as squared Euclidean norms. Finally, the trace is computed directly using cyclicity of trace for finite matrices.
[/proofplan]
custom_env
admin
[step:Show that $X^\top X$ is invertible]
Let
\begin{align*}
A := X^\top X \in \mathbb{R}^{p \times p}.
\end{align*}
The matrix $A$ is symmetric because
\begin{align*}
A^\top = (X^\top X)^\top = X^\top (X^\top)^\top = X^\top X = A.
\end{align*}
To prove that $A$ is invertible, let $v \in \mathbb{R}^p$ satisfy $Av=0$. Multiplying on the left by $v^\top$ gives
\begin{align*}
0 = v^\top A v = v^\top X^\top Xv = (Xv)^\top(Xv)=|Xv|^2.
\end{align*}
Hence $Xv=0$. Since $X$ has full column rank, its columns are linearly independent, so $Xv=0$ implies $v=0$. Thus $\ker A=\{0\}$. Since $A$ is a square $p \times p$ matrix, it is invertible.
[/step]
custom_env
admin
[step:Compute the transpose of $H$]
Since $A=X^\top X$ is symmetric and invertible, its inverse $A^{-1}$ is also symmetric:
\begin{align*}
(A^{-1})^\top = (A^\top)^{-1}=A^{-1}.
\end{align*}
Using the transpose rule $(BCD)^\top=D^\top C^\top B^\top$, we obtain
\begin{align*}
H^\top
&= \bigl(XA^{-1}X^\top\bigr)^\top \\
&= (X^\top)^\top (A^{-1})^\top X^\top \\
&= XA^{-1}X^\top \\
&= H.
\end{align*}
Therefore $H$ is symmetric.
[/step]
custom_env
admin
[step:Multiply $H$ by itself to prove idempotence]
Using associativity of matrix multiplication and the identity $A=X^\top X$, we compute
\begin{align*}
H^2
&= \bigl(XA^{-1}X^\top\bigr)\bigl(XA^{-1}X^\top\bigr) \\
&= XA^{-1}(X^\top X)A^{-1}X^\top \\
&= XA^{-1}AA^{-1}X^\top \\
&= XA^{-1}X^\top \\
&= H.
\end{align*}
Thus $H$ is idempotent.
[/step]
custom_env
admin
[step:Bound each diagonal entry using squared Euclidean norms]
Let $I_n \in \mathbb{R}^{n \times n}$ be the identity matrix. For each $i \in \{1,\dots,n\}$, let $e_i \in \mathbb{R}^n$ denote the $i$th standard basis vector. By definition of diagonal entries,
\begin{align*}
h_{ii}=e_i^\top H e_i.
\end{align*}
Since $H^\top=H$ and $H^2=H$, we have
\begin{align*}
h_{ii}
= e_i^\top H e_i
= e_i^\top H^2 e_i
= (He_i)^\top(He_i)
= |He_i|^2
\ge 0.
\end{align*}
Next define
\begin{align*}
K := I_n-H \in \mathbb{R}^{n \times n}.
\end{align*}
Then $K$ is symmetric and idempotent, because
\begin{align*}
K^\top = I_n-H^\top=I_n-H=K
\end{align*}
and
\begin{align*}
K^2
&= (I_n-H)^2 \\
&= I_n-2H+H^2 \\
&= I_n-H \\
&= K.
\end{align*}
Therefore
\begin{align*}
1-h_{ii}
&= e_i^\top I_n e_i-e_i^\top H e_i \\
&= e_i^\top K e_i \\
&= e_i^\top K^2 e_i \\
&= (Ke_i)^\top(Ke_i) \\
&= |Ke_i|^2 \\
&\ge 0.
\end{align*}
Hence $h_{ii}\le 1$. Combining the two inequalities gives
\begin{align*}
0 \le h_{ii}\le 1.
\end{align*}
[/step]
custom_env
admin
[step:Compute the sum of the diagonal entries by cyclicity of trace]
For a square matrix $M \in \mathbb{R}^{m \times m}$, write
\begin{align*}
\operatorname{tr}(M):=\sum_{j=1}^m M_{jj}.
\end{align*}
Thus
\begin{align*}
\sum_{i=1}^n h_{ii}=\operatorname{tr}(H).
\end{align*}
For matrices $B \in \mathbb{R}^{r \times s}$ and $C \in \mathbb{R}^{s \times r}$, direct expansion gives
\begin{align*}
\operatorname{tr}(BC)
&= \sum_{a=1}^r (BC)_{aa} \\
&= \sum_{a=1}^r \sum_{b=1}^s B_{ab}C_{ba} \\
&= \sum_{b=1}^s \sum_{a=1}^r C_{ba}B_{ab} \\
&= \operatorname{tr}(CB).
\end{align*}
Applying this cyclic trace identity first to $X$ and $A^{-1}X^\top$, and then using $A=X^\top X$, we get
\begin{align*}
\operatorname{tr}(H)
&= \operatorname{tr}(XA^{-1}X^\top) \\
&= \operatorname{tr}(A^{-1}X^\top X) \\
&= \operatorname{tr}(A^{-1}A) \\
&= \operatorname{tr}(I_p) \\
&= p.
\end{align*}
Therefore
\begin{align*}
\sum_{i=1}^n h_{ii}=p.
\end{align*}
This proves all asserted identities.
[/step]