Prove $X(X^TX)^-X^T$ is idempotent and symmetric. Prove $X(X^TX)^-X^T$ is idempotent and symmetric where $(X^TX)^-$ denotes any "generalized inverse" of possibly singular matrix $X^TX$. $(X^TX)^-$ is a generalized inverse if and only if $X^TX(X^TX)^-X^TX=X^TX$.
Attempt: This is a generalization of "projection matrix" from linear regression. I have been stuck for a while. To show symmetry, we need $X(X^TX)^-X^T=X((X^TX)^-)^TX^T$. But it does not seem to be implied from definition that transpose of a generalized inverse is generalized inverse. The idempotency is also not obvious. Any hint or even counter-example is welcome. 
 A: Let $P := X(X^TX)^-X^T$. Then $P^2X = PX$, hence $P^2-P$ is zero on $\operatorname{im}X$. Also, $Pu = 0$ for $u\in\ker X^T$ and so $P^2-P$ is also zero on $\ker X^T$. But the whole space is the direct (orthogonal) sum of $\operatorname{im}X$ and $\ker X^T$. So $P^2-P = 0$, which means that $P$ is an idempotent.
Let us prove that $\ker P = \ker X^T$. Clearly, $\ker X^T\subset\ker P$. Conversely, let $u\in\ker P$. Then $u=v+w$ with $v\in\operatorname{im}X$ and $w\in\ker X^T$. We can write $v = Xz$. Then, since $Pw = 0$,
$$
X^Tv = X^TXz = X^TX(X^TX)^-X^TXz = X^TPXz = X^TPv = X^TPu = 0.
$$
Thus, $v\in\ker X^T\cap\operatorname{im}X = \{0\}$. This proves that indeed $u = w\in\ker X^T$.
Since $\operatorname{im}P\subset\operatorname{im}X$, this implies by counting dimensions that $\operatorname{im}P = \operatorname{im}X$. But an idempotent whose kernel and image are orthogonal to each other is symmetric. To see this, let $x$ and $y$ be vectors, $x = u+v$ and $y = w+z$ with $u,w\in\ker P$ and $v,z\in\operatorname{im}P$. Note that $Px = Pv = v$ and $Py = Pz = z$. So,
$$
x^T(Py) = x^Tz = v^Tz = v^Ty = (Px)^Ty = x^T(P^Ty).
$$
Since this holds for all $x$ and all $y$ it follows that $P = P^T$.
