Let's check that $\mathbb{R}\approx\mathbb{R^2}$. First, we have to prove the following
Lemma:$\;\;\mathbb{R}\approx^\mathbb{N}2$
Dem: we shall assume the following (minimal) result about the real numbers:
(Expression of the real numbers of $(0,1)$ base b>1) Let $b>1$ be a natural number. For each real number $x$ in the interval $(0,1)$, there exists an unique sequence $(t_n)_{n\in\mathbb{N}}$ of whole numbers $0\leq t_n\leq b-1$ for all $n\in\mathbb{N}$,
$$x=\sum_{n\in\mathbb{N}}\frac{t_n}{b^{n+1}}$$
and the sequence $(t_n)_{n\in\mathbb{N}}$ has infinite terms distinct from $b-1$, that is, for each positive whole number $n$ there exists a whole number $N\geq n$ with $t_n\not=b-1$
We shall prove that $(0,1)\preccurlyeq^\mathbb{N}2\,$ and $\,^\mathbb{N}2\preccurlyeq(0,1)$, to then apply the Cantor-Bernstein theorem
- $(0,1)\preccurlyeq^\mathbb{N}2$:
For each $x\in(0,1)$, let $(t_n)_{n\in\mathbb{N}}$ the unique sequence of zeroes and ones, that exists according to the previous result, in the case in which $b=2$, such that $\displaystyle x=\sum_{n\in\mathbb{N}}\frac{t_n}{2^{n+1}}$ and $(t_n)_{n\in\mathbb{N}}$ has infinite zeroes. The sequence $(t_n)_{n\in\mathbb{N}}$ is an element of the set of all the functions from $\mathbb{N}$ to $\{0,1\}$, that is, to $^\mathbb{N}2$, and from the uniqueness that is granted from the previous result we can conclude that the function from $(0,1)$ to $^\mathbb{N}2$ that for each $x$ assigns $(t_n)_{n\in\mathbb{N}}$ is injective.
- $^\mathbb{N}2\preccurlyeq[0,1)$:
To each sequence $(t_n)_{n\in\mathbb{N}}$ of zeroes and ones, we associate the real number $\displaystyle x=\sum_{n\in\mathbb{N}}\frac{t_n}{3^{n+1}}$, that is the real number $x\in[0,1)$ whose expression in base $3$ is $(t_n)_{n\in\mathbb{N}}$. Since we have that the sequence $(t_n)_{n\in\mathbb{N}}$ has no term equal to $2$, then there are infinite terms different from $2$, and the function is injective.
And since $(0,1)\approx\mathbb{R}$ (for example, via the bijective function $f(x)=\text{tan}\big(\frac{\pi}{2}(2x-1)\big)$), we conclude that $\mathbb{R}\approx^\mathbb{N}2$
Now, since $\mathbb{R}\approx^\mathbb{N}2$, we have that $\mathbb{R}^2=\mathbb{R}\times\mathbb{R}\approx^\mathbb{N}2\times^\mathbb{N}2$, and to demonstrate that $\mathbb{R}\approx\mathbb{R^2}$ its enough to give a bijection between $^\mathbb{N}2$ and $^\mathbb{N}2\times^\mathbb{N}2$.
Let $f:^\mathbb{N}2\times^\mathbb{N}2\longmapsto^\mathbb{N}2$ defined by: for each $f,g\in^\mathbb{N}2,\;F(\langle f,g\rangle)$ is the function $f*g$ from $\mathbb{N}$ to $2$, that assigns each natural number $n$ to:
$$(f*g)(n)=\begin{cases} \displaystyle
f(k)\quad \text{if} n=2k \\
g(k)\quad \text{if} n=2k+1
\end{cases}$$
So that $f*g$ takes values $f(0),g(0),f(1),g(1),f(2),g(2),\dots$ and $f$ and $g$ can be recovered from $f*g$. The function $F$ is clearly bijective.
By definition a function $f:X\to Y$ is a subset of $X\times Y=\{\langle x,y\rangle\mid x\in X\wedge y\in Y\}$ such that for every $x\in X$ there is a unique $y\in Y$ such that $\langle x,y\rangle\in f$.
Now define $g:=\{\langle y,x\rangle\mid \langle x,y\rangle\in f\}\subseteq Y\times X$.
On base of injectivity and surjectivity of $f$ we will prove that $g$ is a function, i.e. that for every $y\in Y$ there is a unique $x\in X$ with $\langle y,x\rangle\in g$ or equivalently $\langle x,y\rangle\in f$.
Let $y\in Y$.
The surjectivity of $f$ guarantees that some $x\in X$ exists with $\langle x,y\rangle\in f$.
The injectivity of $f$ guarantees that this $x$ is unique, and proved is now that $g$ is indeed a function.
It remains to check whether we have indeed $f(g(y))=y$ for every $y\in Y$ and $g(f(x))=x$ for every $x\in X$.
For $y\in Y$ the following statements are equivalent:
- $f(g(y))=y$
- $\langle g(y),y\rangle\in f$
- $\exists z[z=g(y)\wedge\langle z,y\rangle\in f]$
- $\exists z[\langle y,z\rangle\in g\wedge\langle z,y\rangle\in f]$
- $\exists z[\langle y,z\rangle\in g\wedge\langle y,z\rangle\in g]$
- $\exists z[\langle y,z\rangle\in g]$
And it is obvious that the last statement is true because $g$ is a function on $Y$.
For $x\in X$ the following statements are equivalent:
- $g(f(x))=x$
- $\langle f(x),x\rangle\in g$
- $\exists z[z=f(x)\wedge\langle z,x\rangle\in g]$
- $\exists z[\langle x,z\rangle\in f\wedge\langle z,x\rangle\in g]$
- $\exists z[\langle x,z\rangle\in f\wedge\langle x,z\rangle\in f]$
- $\exists z[\langle x,z\rangle\in f]$
And it is obvious that the last statement is true because $f$ is a function on $X$.
Best Answer
First be precise about what you are proving: Let $f\colon X\to Y$ be a surjective map and $g\colon Y\to Z$ be a map such that $g\circ f$ is injective. Then $g$ is injective.
In your proof you never explicitly state where you are using the fact that $f$ is surjective. I would rewrite the first step as follows. Suppose that $g(a_1)=g(a_2)$ for some $a_1, a_2\in Y$. Since $f$ is surjective there exists $x, y\in X$ such that $f(x)=a_1$ and $f(y)=a_2$.
Then we can proceed with your proof. I would also recommend using words rather than symbols when writing proofs.
So to continue with the proof I would write, it follows that $g(f(x))=g(f(y))$. Since $g\circ f$ is injective it is the case that $x=y$ and hence $a_1=a_2$.