Can I construct a bijection between (0,1) and [0,1] using sets and sup/inf? (Proof verification) This question comes from a class I'm in currently:
Find a 1-1 onto map between $(0,1)$ and $[0,1]$.
Let $r \in (0,1)$. Now, define the function $f: (0,1) \rightarrow S$ such that 
$$ f(r) = s = \begin{cases} 
      \lbrace x \in \mathbb{R} \mid r \leq x <1/2 \rbrace, \quad r <1/2 \\
      \lbrace x \in \mathbb{R} \mid 1/2 < x \leq r \rbrace, \quad r \geq 1/2 
   \end{cases}
$$
This is clearly a bijection, for each element of $(0,1)$ is mapped to a unique element $s$, for every $s \in S$. Now, let us define the function $g: S \rightarrow [0,1]$ such that, for $s \in S$, 
$$ g(s) =\begin{cases} 
      \inf (s), \quad s \cap (1/2,1]= \emptyset\\
      \sup (s), \quad s \cap [0,1/2)=\emptyset
   \end{cases}
$$
This function $g$ is 1-1, for if it were not, then there would exist two unequal infimum or supremum for the same set. This $g$ is also onto, for $g$ maps $S$ onto the whole of $[0,1] = (0,1) \cup \lbrace 0,1\rbrace$. Therefore, $g$ is a bijection, implying that the composition $g \circ f$ is also a bijection between $(0,1)$ and $[0,1]$. 

First, note that there's a problem: if $r={1\over 2}$, then $f(r)=\emptyset$, so $g(f(r))$ is undefined.
However, that's not the only problem. Let's look at $g\circ f$ directly. If $r<{1\over 2}$, then $f(r)=[r, {1\over 2})$, which has empty intersection with $({1\over 2}, 1]$, so $g(f(r))=r$. Meanwhile, if $r>{1\over 2}$, then $f(r)=({1\over 2}, r]$, which has empty intersection with $[0, {1\over 2})$, so $g(f(r))=r$. 
To sum up: $g(f(r))=r$, for all $r$! (Except $r={1\over 2}$ where it isn't defined, but can be easily fixed.) Your statement that $g$ is onto is unjustified.
