As ineff said, your solution is fine, and ineff has given you the other natural solution. Since you’re studying on your own, I just want to emphasize that if $G$ is a set, equivalence relations on $G$, partitions of $G$, and functions with domain $G$ are three ways of looking at essentially the same thing.
You’ve already seen that if $R$ is an equivalence relation on $G$, $\mathscr{P}(R)=\{[x]_R:x\in G\}$ is a partition of $G$ (where $[x]_R$ is the $R$-equivalence class of $x$), and if $\mathscr{Q}$ is a partition of $G$, then the relation $E(\mathscr{Q})$ defined by $$x\;E(\mathscr{Q})\;y \iff \exists Q\in\mathscr{Q} \big(x,y\in Q\big)$$ is an equivalence relation on $G$. Moreover, $E\big(\mathscr{P}(R)\big)=R$ for any equivalence relation $R$ on $G$, and $\mathscr{P}\big(E(\mathscr{Q})\big)=\mathscr{Q}$ for any partition $\mathscr{Q}$ of $G$. In other words, there’s a natural bijection between equivalence relations on $G$ and partitions of $G$ given by $R\mapsto\mathscr{P}(R),\mathscr{Q}\mapsto E(\mathscr{Q})$: every equivalence relation determines a partition, which in turn determines the original equivalence relation.
In this exercise you’ve shown that if $f$ is any function with domain $G$, the fibres of $f$ form a partition of $G$, say $\mathscr{P}(f)$. This correspondence also goes both ways. Suppose that $\mathscr{Q}$ is a partition of $G$. Define $g_\mathscr{Q}:G\to\mathscr{Q}$ by letting $g_\mathscr{Q}(x)$ be the unique member of $\mathscr{Q}$ containing $x$; clearly $g_\mathscr{Q}$ is a function with domain $G$, and it’s very easy to check that
$\qquad(1)\qquad\mathscr{P}(g_\mathscr{Q})=\mathscr{Q}$ for any partition $\mathscr{Q}$ of $G$, and
$\qquad(2)\qquad g_{\mathscr{P}(f)}=f$ for any function $f$ with domain $G$.
That is, we have a natural bijection between partitions of $G$ and functions with domain $G$ given by $\mathscr{Q}\mapsto g_\mathscr{Q},f\mapsto\mathscr{P}(f)$: every partition determines a function that in turn determines the original partition.
And of course these give rise to a natural bijection between equivalence relations on $G$ and functions with domain $G$.
You’ll be using all three points of view when you study quotient groups.
Best Answer
A direct computation is also fine: $$(PP^T)_{ij} = \sum_{k=1}^n P_{ik} P^T_{kj} = \sum_{k=1}^n P_{ik} P_{jk}$$ but $P_{ik}$ is usually 0, and so $P_{ik} P_{jk}$ is usually 0. The only time $P_{ik}$ is nonzero is when it is 1, but then there are no other $i' \neq i$ such that $P_{i'k}$ is nonzero ($i$ is the only row with a 1 in column $k$). In other words, $$\sum_{k=1}^n P_{ik} P_{jk} = \begin{cases} 1 & \text{if } i = j \\ 0 & \text{otherwise} \end{cases}$$ and this is exactly the formula for the entries of the identity matrix, so $$PP^T = I$$