If $f:M\to N$ is locally injective in the connected metric space $M$, and $g: N\to M$ such that $f(g(x))=x$ then $f$ is a homeomorphism Let $f: M\to N$ continuous and locally injective on the connected metric space $M$. ($N$ also is a metric space). If there is a continuous function $g: N\to M$ such that $f(g(x))=x$ for all $x\in N$ then $f$ is a homeomorphism between $M$ and $N$.
I've tried a lot of things to solve this. For example i have tried to show that $f$ is locally a homeomorphism and use the connectedness of $M$ to extend this for a global homeomorphism. Any hint will be appreciated!
 A: It suffices to show that $g$ is surjective since then we obtain $$g(f(x)) = g(f(g(g^{-1}(x))) = gg^{-1}(x) = x$$ implying that $f = g^{-1}$.
Claim: $\mathrm{Im}(g)$ is open
proof: Let $y = g(x)$ be in the image of $g$ and suppose towards contradiction that there exists a sequence of elements $y_1, y_2, \cdots$ converging to $y$ that are all outside the image of $g$. Then since $f(y) = f(g(x)) = x$, we have $f(y_1), f(y_2), \cdots \rightarrow x$. On the other hand since $f$ is locally injective, there exists some $\epsilon > 0$ such that for all sufficiently large $n$ we have $d(g(f(y_n)), g(x)) > \epsilon$. But this contradicts $g$ being continuous.
Claim: $\mathrm{Im}(g)$ is closed.
proof: If $y_1, y_2, \cdots \in \mathrm{Im}(g)$ and $y_1, y_2, \cdots \rightarrow y$, then $f(y_1), f(y_2), \cdots \rightarrow f(y)$. But we can rewrite the sequence as $f(g(g^{-1}(y_1))), f(g(g^{-1}(y_2))), \cdots \rightarrow f(y)$ which can be rewritten again as  $g^{-1}(y_1), g^{-1}(y_2), \cdots \rightarrow f(y)$. So by continuity $g(f(y)) = y$ so $y$ is in the image of $g$.
So since $\mathrm{Im}(g)$ is open and closed and $M$ is connected $\mathrm{Im}(g) = M$ so $g$ is surjective.
