Let $f :\mathbb R \rightarrow\mathbb R$ be continuous function. Then prove that $(0,1)$ cannot be the image of $(0,1]$ i.e $f((0,1])\neq (0,1)$ ?
My solution:
Let us assume the contrary that, $f((0,1])=(0,1)$ or, $(0,1)$ is the image of $(0,1]$ under $f.$
We can find two sequences $(x_n)$ and $(y_n)$ in $(0,1)$ such that $x_n=\frac 1n$ and $y_n=1-\frac{1}{n+1},$ where $n\in\Bbb N.$ We note that, $\lim x_n=0\notin (0,1)$ and $\lim y_n=1\notin (0,1).$
Also, we observe that $x_n,y_n\in (0,1),\forall n\in\Bbb N.$ Now, as $(0,1)$ is the image of $(0,1]$ under $f$ we have, for each $x_n\in (0,1)$ some pre-images in $(0,1]$ whose image is $x_n.$ We choose any one of those many pre images possible in $(0,1]$ and call it, $p_n.$ So, for the sequence, $(x_n)$ we get a corresponding sequence, $(p_n)$ in $(0,1].$
Now, as $(0,1)$ is the image of $(0,1]$ under $f$ we have, for each $y_n\in (0,1)$ some pre-images in $(0,1]$ whose image is $y_n.$ We choose any one of those many pre images possible in $(0,1]$ and call it, $q_n.$ So, for the sequence, $(y_n)$ we get a corresponding sequence, $(q_n)$ in $(0,1].$
Also, we observe that, $f(p_n)=x_n,f(q_n)=y_n,\forall n\in\Bbb N.$
Now, $(p_n),(q_n)\subseteq (0,1]$ implies that, $(p_n),(q_n)$ are two bounded sequences in $(0,1).$ By Bolzano-Weierstrass's Theorem $\exists$ two convergent subsequences say, $(p_{n_k})$ and $q_{n_k}$ of $(p_n)$ and $(q_n)$ respectively.
Given, $f$ is continuous on $(0,1]$ so, if $\lim p_{n_k}=c_1,\lim q_{n_k}=c_2$ we have, $\lim f(p_{n_k})=f(c_1),\lim f(q_{n_k})=f(c_2),$ if $c_1,c_2\in (0,1].$ Now, as, $(0,1)$ is the image of $(0,1]$ under $f,$ so, $0\lt f(c_1),f(c_2)\lt 1.$ But, $f(c_1)=0$ and $f(c_2)=1.$ This is a contradiction.
So, $(0,1)$ cannot be the image of $(0,1]$ under $f.$
Is the above solution correct? This is because, I am implicitly assuming $c_1,c_2\in (0,1].$ Since, if $c_1,c_2\notin (0,1],$ and by our assumption we have, $f((0,1])=(0,1)$ so, we can't really gurantee whether $0\lt f(c_1),f(c_2)\lt 1$ still holds.
Is there a way to fix the proof?
Yes, this is precisely the reason why the proof in the original post fails.
Yes, the proof can be fixed with a slight modification.
The erroneous part in the proof in OP is the inequality $$0\lt f(c_1),f(c_2)\lt 1$$ which might not be true in general if $c_1,c_2\notin (0,1]$ as you mentioned.
But notice that, $f(c_1)=0$ and $f(c_2)=1$ still holds. This means, $c_1\neq c_2.$ Now, if $c_1,c_2\in (0,1]$ then the proof in the original post works perfectly. Now, the only possible limit point, that is not in $(0,1]$ is $0.$ So, if possible, only one of $c_1$ or $c_2$ will be zero.
If $c_1=0$ then, $c_2\in (0,1].$ This means, $0\lt f(c_2)\lt 1,$ from our assumption that $f((0,1])=(0,1).$ But, $f(c_2)=1,$ a contradiction.
Again, if $c_2=0$ then, $c_1\in (0,1].$ This means, $0\lt f(c_1)\lt 1,$ from our assumption that $f((0,1])=(0,1).$ But, $f(c_1)=0,$ a contradiction.
So, in all the cases, we have a contradiction.
So, rewriting the proof in OP with the correction and the fix is as follows: