Closure in profinite topology Let $G$ be an abstract group (say, finitely generated).
Endow $G$ with the profinite topology. I would like to get comfortable with computing the closure of subgroups of $G$.
More specifically, I would like to understand how to use the profinite completion of $G$ to do that.
If $G$ is residually finite, I guess it makes our life easier because it embeds in its profinite completion. Is it then correct to compute the closure of $H$ by looking at $G$ inside the completion, computing closure there, and taking the preimage of the closure?
What if $G$ is not residually finite?
It would be nice to see two examples, one with $G$ residually finite and one with $G$ not residually finite, of computing closures of subgroups using the profinite completion of $G$ (if this is indeed possible). Maybe some Baumslag-Solitar groups can provide residually-finite/non-residually-finite groups adequate for illuminating examples.
 A: 
If $G$ is residually finite, I guess it makes our life easier because it embeds in its profinite completion. Is it then correct to compute the closure of $H$ by looking at $G$ inside the completion, computing closure there, and taking the preimage of the closure?

Yes, this is correct.  It's not clear to me that computing the closure in the profinite completion is any easier than just computing it in $G$ directly though.

What if $G$ is not residually finite?

Literally the exact same thing; residual finiteness doesn't make the proof any easier (it just makes the map from $G$ to its profinite completion injective, which is irrelevant to the argument).  Let $i:G\to\widehat{G}$ be the map from $G$ to its profinite completion.  Then for any subset $A\subseteq G$, the closure of $A$ is $i^{-1}(\overline{i(A)})$.  This is essentially immediate from the definition of the profinite topology: $x\in \overline{A}$ iff for every epimorphism $p:G\to F$ from $G$ to a finite group, $p(x)\in p(A)$.  But any such $p$ factors through $i$, and the topology of $\widehat{G}$ is defined such that $i(x)\in \overline{i(A)}$ iff $\tilde{p}(i(x))\in \tilde{p}(i(A))$ for all such $p$, where $\tilde{p}i=p$.  It follows that $\overline{A}=i^{-1}(\overline{i(A)})$.  Note that in particular, any closed subset of $G$ is a union of cosets of the kernel of $i$.
As for examples, I don't know of any particularly interesting or illustrative ones off the top of my head.  Is there some specific example that you want to know how to compute?
