Flow on compact manifold These questions seem simple, and but I have not found the answer on the web (I have no mathematician in my neighborhood).
Does a continuous injective function from $E$ to $E$ have to be surjective, where $E$ is either the $n$-sphere, the $n$-torus, or more generally a compact manifold without boundary? (I have found simple counterexamples in case the manifold is not compact, or has a boundary)
The case $E=S^1$ is solved in "An injective continuous map on the unit sphere is a homeomorphism", but I cannot generalize the argument.
The initial motivation of my question comes from a flow defined on a sphere (or torus), which is injective. And I need it to be surjective as well for it to define a new coordinate system on the sphere.
Thanks in advance!
 A: (This is written backwards, as I realized what tools were necessary. Sorry!)
Suppose that $M$ is a compact manifold without boundary of pure dimension $n$. Let $f : M \to N$ be a map which is continuous and injective, and let $N$ be a connected manifold of the same dimension as M. Then $f$ is also surjective.
Pf: The image must be compact, hence closed. We will show that the image is also open, hence by connectedness of $N$ it must be all of $N$ (it is obviously non-empty). The image is homeomorphic to $M$, using compactness again to guarantee that the set theoretic inverse is continuous, and hence the image is locally homeomorphic to $R^n$. (This is were we are using the assumption that $M$ has no boundary.) Since we can check whether the image is open by restricting to Euclidean charts in the codomain, we are reduced to the following lemma.
Lemma: Suppose that $V$ is a subset of $R^n$, so that with the induced subspace topology, $V$ is homeomorphic to a manifold of dimension $n$. Then $V$ is open in $R^n$.
Pf: We reduce again to the case that $V$ is homeomorphic to $R^n$. So we need to show that any subspace of $R^n$ homeomorphic to $R^n$ is as an open set.
This is a theorem in Hatcher, 2B.3: "If a subspace $X$ of $R^n$ is homeomorphic to an open set in $R^n$, the $X$ is itself open in $R^n$."
I'll copy the argument here. Let me know if you have any questions about it! (Or you can just go and read it in Hatcher. Not sure why I typed it up, but I did. Okay, I admit it. It was so that I would read his argument carefully...)
Proof:


*

*Regard $S^n$ as the one point compactification of $R^n$. We will show that $X$ is open in $S^n$.

*For a point $x \in X$, let $D$ be a neighborhood homeomorphic to a closed disc, and let $S$ be the boundary. 

*Then $S^n - D$ is open, and is connected by (lemma below - a computation in homology). Also, $S^n - S$ is open, and has two components. (Also by lemma below).

*Thus, $S^n - S$ is decomposed as the disjoint union of the connected sets $S^n - D$ and $D - S$, so these must be components of $S^n - S$. Thus, $D - S$ is open in $S^n$, since it is a component of the open set $S^n - S$, and hence it gives an open neighborhood of $x$ in $S^n$ which is contained in $X$. So $X$ is open.


Lemma: Homology computations (Hatcher 2B.1) 
a) If $D$ is a subspace of $S^n$ homeomorphic to $D^k$ for some $k \geq 0$, then $\tilde{H}_i(S^n - D) = 0$ for all $i$.
b) If $S$ is a subspace of $S^n$ homeomorphic to $S^k$ for some $k$ with $0 \leq k < n$, then $\tilde{H}_i(S^n - S) $ is $Z$ for $i = n - k - 1$ and 0 else.
Proofs:
a) 


*

*The proof is by induction. The case when $k = 0$ is easy, because then $S^n - D \cong R^n$. 

*$h : I^k \to D$ is a homeomorphism. Let $A = S^n \setminus h(I^{k-1} \times [0,1/2])$ and $B = S^n \setminus h(I^{k-1} \times [1/2,1])$. So $A \cap B = S^n - D$ and $A \cup B = S^n \setminus h(I^{k-1} \times {1/2})$. 

*The inductive step tells us $\tilde{H_i}(A \cup B) = 0$ for all $i$, so Mayer-Vietoris gives $\phi : \tilde{H_i}(S^n - D) \to \tilde{H_i}(A) \oplus \tilde{H_i}(B)$ for all $i$.

*This map $\Phi$ is induced by the inclusions $S^n - D \to A$. (There are signs in the Mayer-Vietoris sequence to make it exact, but ignore them here.) The point is that if there is an $i$-dimensional cycle $\alpha$ in $S^n - D$ that is not a boundary in $S^n - D$, then $\alpha$ is not a boundary in $A$ or $B$.

*We iterate this last idea, chopping up the last $I$ factor of $I^k$ into finer pieces to try to reduce to the lower dimension disc case. We end up with a sequence of $I_1 \supset \ldots$ of closed intervals in $I$ with intersection a point $p \in I$ so that $\alpha$ is not a boundary in $S^n \setminus h(I^{k-1} \times I_m$ for each $m$. By the inductive step, $\alpha$ is the boundary of a chain $\beta$ in $S^n \setminus h(I^{k-1} \times {p})$. Since $\beta$ is a finite linear combination of singular simplices, its support is compact, and hence will be contained in some $S^n \setminus h(I^{k-1} \times I_m)$. This is a contradiction, hence actually $\alpha$ was a boundary. 
b) The base case, when $S$ is two points, again is easy, as $S^n$ minus two points is $S^{n-1} \times R$. To do the inductive step, we write the k sphere $S$ as a union of two $k$ dimensional discs. Then let $A = S^n - D_1$ and $B = S^n - D_2$. Both of these have trivial reduced homology by the previous argument, and the Mayer Vietoris sequence gives isomorphisms $\tilde{H_i(S^n - S)} \cong \tilde{H_{i+1}}(S^n - (D_1 \cap D_2))$. (here we use that $A \cap B = S^n \setminus S$ and $A \cup B = S^n \setminus (D_1 \cap D_2)$.
