Showing there can't be a bijection between two sets Let $\mathcal{H} = \{ f : f:[0,1] \to [0,1] \} $. Then there is not bijection between $[0,1]$ and $\mathcal{H} $
This is a solution given in class which I have some questions:
Suppose there is a bijection. To each $f \in \mathcal{H} $, write the corresponding $f_a $ for $a \in [0,1]$. Define $g: [0,1] \to [0,1] $ by 
$$  g(x) = \left\{
     \begin{array}{lr}
       0 & : f_x(x) \neq 0\\
       1 & : f_x(x)=0
     \end{array}
   \right.
$$
I dont understand why from here it follows that $g = f_b$ for some $b \in [0,1]$ and how computing $g(b)$ gives a contradiction. 
 A: By hypothesis the map $\varphi:[0,1]\to\mathcal{H}:a\mapsto f_a$ is a bijection, so every $g\in\mathcal{H}$ is $\varphi(a)=f_a$ for some $a\in[0,1]$. In particular, the map $g$ defined in the question is in $\mathcal{H}$, so it must be $f_b$ for some $b\in[0,1]$: if it weren’t, the map $\varphi$ wouldn’t be a bijection (because it wouldn’t be a surjection).
Now $b\in[0,1]$, so $g(b)$ is defined. Specifically, $g(b)=0$ if $f_b(b)\ne 0$, and $g(b)=1$ if $f_b(b)=0$. But wait: $g=f_b$, so $g(b)=f_b(b)$. In other words, $g(b)=0$ if $g(b)=1$, and $g(b)=1$ if $g(b)=0$. That’s plainly absurd: no such $g$ can possibly exist. And that means that the map $\varphi$ could not have been a bijection after all.
In my view there is a better way to look at it that doesn’t involve a contradiction. Let $\varphi:[0,1]\to\mathcal{H}:a\mapsto f_a$ be any function from $[0,1]$ to $\mathcal{H}$. Define $g$ as in the question. Then the argument that I gave above shows that $g$ cannot be equal to $\varphi(b)=f_b$ for any $b\in[0,1]$. Thus, no map from $[0,1]$ to $\mathcal{H}$ can be a surjection: given any $\varphi:[0,1]\to\mathcal{H}:a\mapsto f_a$, we can construct a function $g\in\mathcal{H}$ by
$$g(x)=\begin{cases}
0,&\text{if }f_x(x)\ne 0\\
1,&\text{if }f_x(x)=0
\end{cases}$$
and show that $g$ is not in the range of $\varphi$.
A: $g = f_b$ for some $b$ because $a \mapsto f_a$ is a bijection -- every function is in the image of this map!
What does the definition of $g(b)$ say that it is? It all depends on what $f_b(b)$ is. Suppose it's zero, i.e., suppose
$$
f_b(b) = 0.
$$
...then $g(b) = 1$. But $g = f_b$, so 
$$
f_b(b) = 1.
$$
That's a contradiction. The other case is similar.  
A: $g(x)\in \mathcal{H}$, so since this set is (supposedly) bijective with $[0,1]$, that bijection maps $g(x)$ to some element, which we call $b$.
By the definition of $g(x)$, we must have $g(b)=0$ or $g(b)=1$.  In the former case, $f_b(b)\neq 0$, but $f_b(x)=g(x)$, so $g(b)\neq 0$, a contradiction.  In the latter case, $f_b(b)=0$, but $f_b(x)=g(x)$, so $g(b)=0$, again a contradiction.
This is Cantor's diagonalization argument.
