TITLE: Does isometric immersion map boundary to boundary?
QUESTION [26 upvotes]: Let $M$ be a compact, connected, oriented, smooth Riemannian manifold with non-empty boundary. Let $f:M \to M$ be a smooth orientation preserving isometric immersion.
Is it true that $f(\partial M) \subseteq \partial M$?
Edit: In this paper, it is proved that any "local isometry" from a compact, connected metric space into itself is a homeomoprhism, where by a "local isometry", they mean  "locally preserving distance". 

Thus, if every isometric immersion is locally preserving distance, then our $f$ will be a homeomorphism (hence will map boundary to boundary). 

Is it true that isometric immersion $\Rightarrow$  locally preserving distance?
Motivation:
A positive answer to this question would imply that every smooth orientation preserving isometric imersion $M \to M$ is a Riemannian isometry (see details below**), Moreover, if two manifolds can be isometrically immersed in each other, then they are isometric (see remark 1 in the "updates and remarks" of this question).
In particular, to refute the conjecture "$f(\partial M) \subseteq \partial M$" it is enough to find such an immersion which is not surjective, or at least not an isometry.
Remarks:
(1) Compactness is essential. Look at $M=[0,\infty) \,,\,f(x)=x+1$.
(2) The claim clearly holds in dimension $1$ ($M$ must be a closed interval).

** Indeed, since $f(\partial M) \subseteq \partial M$ and it's easy to see that $f(M^o) \subseteq M^o$ we get that $f(M^o)$ is clopen in $M^o$, thus $f(M^o)=M^o$. Since $f(M)$ is closed in $M$, and contains $M^o$, we conclude $f(M)=M$, and so $f(\partial M)= \partial M,f(M^o)=M^o$. 
So, $f$ is a surjective $1$-Lipschitz map from a compact space to itself. (The $1$-Lipshictzity follows since isometric immersions preserve lengths of paths). Thus, it is a metric isometry. Hence, by the positive answer to this question, $f$ is smooth, and in fact a Riemannian isometry.

REPLY [8 votes]: The following relies on the answer of Anton Petrunin and his explanations.
Set $X:=\cap_{n\geq 1} f^n(M)$.
Claim 0: Each $x\in X$ is a limit point of a sequence $f^n(y)$ for some $y\in M$. Moreover, if $x\in X\cap M^\circ$, then $y$ can be chosen in $M^\circ$.
Proof of Claim 0: 
Assume $x\in X$. Then $x=f^n(y_n)$ for some $y_n\in M$ and each $n\geq 1$.
After passing to a subsequence, we may assume that $y_{n_l}\rightarrow y$.
Fix $\varepsilon>0$ and $K\geq 1$;
we show that for some $k\geq K$, $f^k(y)\in B_\varepsilon(x)$.
Choose $l\geq 1$, such that $k:=n_l\geq K$ and $y_{k}\in B_\varepsilon(y)$.
Then, since $f$ is distance non-increasing, $dist(f^k(y),f^k(y_k))\leq dist(y,y_k)<\varepsilon$.
The 'moreover' statement follows, since we can replace $y$ by $f^{k_0}(y)$,
and choose $k_0$ such that $f^{k_0}(y)\in M^\circ$; the latter is possible, since a subsequence of
$f^n(y)$ converges to $x\in M^\circ$.
Claim 1: For any $x\in M^\circ$ and $r>0$ such that $B_r(x)\subset M^\circ$  and $n\geq 1$, we have $f^n(B_r(x))=B_r(f^n(x))$.
We defer a proof of Claim 1 to the end.
Claim 2: $X^\circ$ is nonempty, indeed it coincides with the set of all limit points of sequences $f^n(y)$ for $y\in M^\circ$.  
Proof Claim 2: By Claim 0, each $x\in X\cap M^\circ \supset X^\circ$ is such a limit point. Conversely, if $x$ is such a limit point, then $x\in B_r(f^k(y))=f^k(B_r(y))\subset f^k(M)$ for (certain) arbitrary large $k$; here we choose $r$ such that $B_r(y)\in M^\circ$ and use Claim 1. Therefore $x\in X=\cap_{n\geq 1} f^n(M)$, since the intersection is decreasing. Actually the same argument shows, that $B_s(x)\subset X$ for each $s<r$ (or also $s\leq r$). As a consequence $x\in X^\circ$.
Claim 3: $X\cap M^\circ$ is open in $M^\circ$. (Clearly it is also closed, as $M$ is compact and nonempty by Claim 2).
Proof Claim 3: Combining Claim 1 and 2, we see that $X\cap M^\circ=X^\circ=X^\circ \cap M^\circ$ is open in $M^\circ$.
As $M^\circ$ is connected, Claim 3 implies:
Claim 4:  $X\cap M^\circ=M^\circ$. Since $X\subset M$ is closed, it follows that $X=M$, and thus $f(M)=M$.
Conclusion:Claim 4 implies that $f$ is a distance preserving homeomorphism by Całka, Corollary 3.5 and Corollary 4.4. In particular, $f(\partial M)=\partial M$.
A (standard) proof of Claim 1: First assume n=1: Since $f$ is $1$-Lipschitz, we have $f(B_r(x))\subset B_r(f(x))$ for any $x\in M^\circ$. To show equality, let $y\in B_r(f(x))$ arbitrary. There exists a path (of constant speed) $\gamma:[0,1]\rightarrow M^\circ$ of length $<r$ with $\gamma(0)=f(x)$ and $\gamma(1)=y$.
There exists a unique lifting of $\gamma$, i.e. a path $\eta:[0,1]\rightarrow M^\circ$ with $f\circ \eta=\gamma$ and $\eta(0)=x$. 
(The set $T\subset [0,1]$ of $t$'s for which there is a unique lifting of $\gamma$ on the intervall $[0,t]$ contains $0$. $T$ is open since $f$ is a local diffeomorphism on $M^\circ$. In addition, $T$ is closed: If $t_k\in T$ converges to $t\in [0,1]$, then there is a unique lift $\eta_0$ of $\gamma$ on $[0,t)$. Since $M$ is compact and $\eta_0$ is Lipschitz, we can extend it to a path $\eta_1:[0,t]\rightarrow M$, and we have automatically $f(\eta_1(s))=\gamma(s)$ for $s\in [0,t]$. Since $length(\eta_1)=length(\gamma\vert_{[0,t]})<r$ as $f$ is an infinitesimal isometry, we have $\eta_1(t)\in B_r(x)\subset M^\circ$ and therefore $t\in T$, as desired.)
Since $f$ is an (infinitesimal) isometry, length($\eta$)=length$(\gamma)<r$ and thus $\eta(1)\in B_r(x)$. 
Therefore $y=f(\eta(1))\in f(B_r(x))$, as claimed for $n=1$.
For arbitrary $n\geq 2$, note that $f^{n-1}(B_r(x))=B_r(f^{n-1}(x))$ by induction.
The domain invariance theorem (applied locally to $f^{n-1}$) implies that $f^{n-1}(M^\circ)\subset M^\circ$; hence if $B_r(x)\in M^\circ$, then so is
$f^{n-1}(B_r(x))$. Applying Claim 1 for $n=1$ to the ball $B_r(f^{n-1}(y))$ yields Claim 1 for $n$.