I've been struggling to understand how the surjection of a function $f : X \rightarrow Y$ implies that it has a right inverse. My questions basically reside on the application of the axiom of choice to the proof.
First question: The axiom of choice states that, for any set $Y$, if $\varnothing \not\in Y$, then there exists a function $g : Y \rightarrow \bigcup_{y\in Y} X_y$. such that $\forall y \in Y g(y)\in X_y$. Why, if $f : X \rightarrow Y$ is surjective, $\varnothing \not\in Y$? I can't find my way on this one.
Second question: As far as I understand, $\bigcup_{y\in Y} X_y$ represents the union of a family of the sets $X_y$ indexed by the elements $y\in Y$. Hence, $\bigcup_{y\in Y} X_y$ is equal to $\{x : \exists y \in Y (x\in X_y)\}$. If $X_y$ is defined as $\{x\in X : y=f(x)\}$, then $\{x : \exists y\in Y (x\in X_y)\}$ is equal to $\{x : \exists y[y\in Y \land x\in X \land y=f(x)]\}$, which is the same as $\{x \in X : f(x) \in Y\}$. The set $\{x \in X : f(x) \in Y\}$ is equal to the inverse image $g[Y]$, which is equal to $X$, since $f : X \rightarrow Y$. Hence, $\bigcup_{y\in Y} X_y$ is equal to $X$ and $g : Y \rightarrow \bigcup_{y\in Y} X_y$ is equivalent to $g : Y \rightarrow X$. Is this correct?
Third question: If we define $X_y$ as being equal to $\{x\in X : y=f(x)\}$, then $\forall y\in Y g(y)\in X_y$ is equivalent to $\forall y \in Y g(y)\in X \land y=f(g(y))$. Is this also correct?
If my (incomlete) proof attempt is correct, the axiom of choice $g : Y \rightarrow \bigcup_{y\in Y} X_y$. such that $\forall y \in Y g(y)\in X_y$, considering $X_y$ equal to $\{x\in X : y=f(x)\}$, could be rewritten as $g : Y \rightarrow X$, such that $\forall y \in Y \hspace{0.5em} g(y)\in X \land y=f(g(y))$, which concludes our proof.
I apologize for the basic questions, but this all seems very confusing for me.