In solving some exercises in Sageev's notes on $CAT(0)$ cube complexes I've needed to use the following fact that I would like to know how to prove.
A group $G$ is residually finite if and only if the profinite topology on $G$ is Hausdorff.
Here the working definition of residually finite is that the trivial subgroup is separable; where a subgroup $H < G$ is separable if for all $g \in G-H$ there is a finite index $K < G$ with $H<K$ and $g \not\in K$.
The profinite topology is generated by the basis of cosets of finite index subgroups of $G$. It can also be shown that you could instead use cosets of finite index normal subgroups of $G$.
Any hints are appreciated, and I actually only need to understand the forward direction.