Morphism epimorphism if and only if surjective In the category of sets, I want to prove that a morphism is an epimorphism if and only if it is surjective.
In both directions, I'm having a hard time approaching this problem.
This is how far I got.
$$\text{Morphism is epimorphism} \implies \text{Morphism is surjective}:$$
Let $\phi: A \to B$ be an epimorphism. 
For any morphisms $\beta,\beta': B \to Y$, we have 
$$ \beta \ \circ \ \phi = \beta' \ \circ \phi \implies \beta = \beta'.
$$
$$\vdots$$
$$\text{Morphism is surjective}\implies \text{Morphism is epimorphism} :$$
Pick an arbitrary $b \in B$.
Since $\phi$ is surjective there exists an $a\in A$ such that $b = \phi(a)$.
Set $y = \beta(\phi(a)) = \beta'(\phi(a))$.
$$\vdots$$ 

I will give a constructive (or, more precisely, intuitionistic) proof.
First, the easy direction: surjective maps are epimorphisms. Indeed, if $f : X \to Y$ is surjective and $g_0 \circ f = g_1 \circ f$, then $g_0 = g_1$, i.e. for every $y \in Y$, $g_0 (y) = g_1 (y)$, because there is $x \in X$ such that $y = f(x)$ and therefore $g_0 (y) = g_0 (f (x)) = g_1 (f (x)) = g_1 (y)$.
Now, the harder direction: epimorphisms are surjective. Suppose $f : X \to Y$ is an epimorphism. Let $\Omega$ be the set of subsets of $\{ 0 \}$, let $g_0 : Y \to \Omega$ be the constant map with value $\{ 0 \}$, and let $g_1 : Y \to \Omega$ be defined as follows:
$$0 \in g_1 (y) \iff \exists x \in X . f (x) = y$$
By construction, $g_0 \circ f = g_1 \circ f$; but then $g_0 = g_1$, so for every $y \in Y$, there is $x \in X$ such that $f (x) = y$, i.e. $f : X \to Y$ is surjective.
