Let $f: (M,d) \rightarrow (N,\rho)$ be a one-one and onto mapping. Prove that the following are equivalent:
$f$ is a homeomorphism.
$g: N\rightarrow \mathbb{R}$ is contiuous if and only if $gof: M \rightarrow \mathbb{R}$ is continuous.
To show $1 \implies 2$ I have proceeded in the following manner.
$f$ is a homeomorphism $\implies$ $f$ is continuous from $M \rightarrow N$ $\implies$ For any sequence $(x_{n})$ in $M$ converging to $x$ we have $f(x_{n}) \rightarrow f(x)$. Let, $g$ is continuous from $N \rightarrow \mathbb{R}$ Therefore, $g(f(x_{n}) \rightarrow g(f(x))$. Hence, $gof(x)$ is continuous in $M$.
Since, the statement 2 had an iff next, I assumed that $f$ is a homemomrphism and $gof$ is continuous and proved that $g$ is continuous.
Now, I am not sure how I have to show $2 \implies 1$
Source:Real Analysis by N.L Carothers Page 72, Problem 54
Let's generalise: let $f:X \to Y$ be a bijection between Tychonoff spaces. (all metrisable spaces are normal $T_1$ so Tychonoff, but we don't need the metric)
Let's show that 1 and 2 are equivalent :
Assume that 1 holds. Then to show 2 we need to show an equivalence again. The left to right one is just using that the composition of continuous maps is continuous. If OTOH $ g \circ f$ is continuous, we can write $g = (g \circ f) \circ f^{-1}$ where the composition is continuous as $f^{-1}$ is continuous by assumption 1. So 2. has been shown too, not using anything yet about our spaces.
Assume that 2. holds. We need to show 1, so $f$ is continuous and $f^{-1}$ is continuous (which exists because in all of this $f$ is a bijection) or alternatively, that $f$ is open.
To see that $f$ is continuous, let $O$ be open in $Y$ and we'll show that any $x \in f^{-1}[O]$ is an interior point of it, so take any $x \in f^{-1}[O]$; then $f(x) \in O$ and as $Y$ is Tychonoff, there is a continuous $g: Y \to \Bbb R$ such that $g(f(x)) = 0$ and $g[Y\setminus O]=\{1\}$. Now apply 2.: as we know $g$ is continuous, $g \circ f$ must be continuous too. Define $U = (g \circ f)^{-1}[(-\frac12, \frac12)]$ which is continuous as the inverse image of an open set under the continuous $g \circ f$ and contains $x$. Also $U \subseteq f^{-1}[O]$ (as otherwise for some $x'$ with $g(f(x')) \in (-\frac12,\frac12)$ we'd have $f(x') \notin O$ which means $g(f(x'))=1$ by construction of $g$.). So $x$ is an interior point of $f^{-1}[O]$ and that set is open, and so $f$ is continuous.
To see that $f$ is open, let $O$ be open in $X$ and let $y\in f[O]$, so $y=f(x)$ for some $x \in O$. We can find some $h: X \to \Bbb R$ continuous with $h(x)=0$ and $h[X\setminus O]=\{1\}$ because $X$ is also Tychonoff. Define $g: Y \to \Bbb R$ by $g(y)=h(f^{-1}(y))$, using that $f$ is a bijection. Then $g \circ f = (h \circ f^{-1}) \circ f = h$ so we know that $g \circ f$ is continuous. It follows that $g$ is continuous too by using the other implication of 2., and now $U=g^{-1}[(-\frac12,\frac12)]$ is open in $Y$ and $g(y)=h(f^{-1}(y))=h(x)=0$ so $y \in U$ and if $y' \in U$ would be in $X\setminus f[O]$ then $f^{-1}(y') \in X\setminus O$ and so $g(y')=h(f^{-1}(y')) = 1$, contradicting $y' \in U$. So $y \in U \subseteq f[O]$ and each $y \in f[O]$ is an interior point and $f[O]$ is open. QED.
Sorry for the somewhat abstract argument, but this shows to what generality we can extend such results. The condition 2. is the so-called universal property for the initial topology wrt real-valued functions on $Y$, so if you have studied some more general topology, it's quite obvious to look to Tychonoff spaces to prove such a theorem in (which have the initial topology wrt real-valued maps), plus exploiting that a bijection to an initial topology will be a homeomorphism in many cases...
In a similar vein, we can replace $X$ and $Y$ by zero-dimensional (Hausdorff?) spaces and simultaneously $\Bbb R$ by $\{0,1\}$ in the discrete topology, e.g.