Let $g$ be continuous on an interval $A$ and let $F$ be the set of points where $g$ fails to be injective, That is, $F = \{x \in A: f(x)=f(y)$ for some $y \neq x $ and $y \in A \}$
Show that $F$ is either empty or uncountable.
Case (i) $F$ is empty:
I can show this with a function that is monotonic and strictly increasing (or decreasing), then there are no points where $g$ is not an injection and $F$ is empty
Case (ii) $F$ is uncountable:
I can show this with a horizontal line, i.e. the whole of $g$ on $A$ is not an injection and $F$ is uncountable.
I need help formalizing a proof. 
Thanks!
 A: Let $$S=\{\,\langle x,y\rangle\in A^2\mid x<y, f(x)=f(y)\,\}.$$ 
Let $$T=\{\,\langle x,y\rangle\in S\mid \forall z\in(x,y)\colon f(z)=f(x)\,\}.$$
We distinguish three cases: $S=T=\emptyset$, $S=T\ne \emptyset$, and $T\ne S$.


*

*If $S$ is empty, then $F$ is also empty.

*If $T$ is not empty, say $\langle a,b\rangle\in T$, then the uncountable set $[a,b]$ is $\subseteq F$.

*If $T\ne S$ then there exists $\langle x,y\rangle \in S\setminus T$. For this, there exists $z\in(x,y)$ with $f(z)\ne f(x)$. Wlog. $f(z)>f(x)$ (the other case is analog). By the Intermediate Value Theorem, for every $c\in(f(x),f(z))$, we find $x_c\in(x,z)$ and $y_c\in(z,y)$ with $f(x_c)=f(y_c)=c$. We conclude that the uncountably set $[f(x),f(z))$ is $\subset f[F]$, hence $F$ is uncountable as well.

A: Suppose that $F$ is not empty. Let $x\neq y$ such that $f(x)=f(y)$. Let $U$ an open subset containing $f(x)$, since $f$ is continuous, $f^{-1}(U)$ is open. There exist open subsets $x\in V$ and $y\in W$ such that $V,W\subset f^{-1}(U)$. Since $x\neq y$, we can suppose that $V\cap W$ is empty. We can also suppose that $V$ and $W$ are intervals. This implies that $f(V)$ and $f(W)$ are intervals.
If the restriction of $f$ to $V$ or $W$ is constant. done.
If the restriction of $f$ to $V$ and $W$ is not constant, 


*

*$f(V)\cap f(W)$ contains an interval non trivial $I$ which contains $f(y)$. For $z\in I$, there exists $z_1\in V$ and $z_2\in W$ such that $f(z_1)=f(z_2)$, of course, $z_1\neq z_2$. done

*Suppose that $f(V)\cap f(W)=\{f(x)\}$. Without restricting the generality, suppose that $x<y, f(V)\subset (-\infty, f(x)), f(W)\subset (f(x),+\infty)$, then there exist $z_1,z_2\in (x,y)$ such that $z_1\in V, z_2\in W, f(z_1)<f(x), f(z_2)>f(x)$, since $f$ is continuous, there exists $t\in (z_1,z_2)$ such that $f(t)=f(x)=f(y)$. Again there exists a non trivial interval $A$ containing $t$ such that $A\cap V, A\cap W$ is empty and $f(A)\subset U$. If the restriction of $f$ to $A$ is constant, done. If this restriction is not constant, certainly $f(A)\cap f(V)$ or $f(A)\cap W$ contains an interval, we conclude like at 1. done.
