Show that a map f: X → Y in a category is a monomorphism if and only if the following square is a pullback:
I am hoping others can point out errors I'm my logic and give suggests where to go next. Cheers.
Attempt
Necessary Condition
Take $f:X\rightarrow Y$ to be a monomorphism and assume the following square is a pullback

Then we need to show that $w:Z\rightarrow X$ is unique.
At this point I believe we want to assume that another morphism, say $w':Z\rightarrow X$ exists and satisfies the conditions $1_x\circ w'=u$ and $1_x\circ w'=v$ then conclude that $w'=w$ but this is where I get lost.
What we know is
- $u=v$ by assumption on $f$ a monomorphism
- $u=1_x\circ w'=v$
- $f\circ u = f\circ 1_x\circ w'=f\circ v$
So, my initial thought was to show that
$\begin{align} f\circ v&=f\circ 1_x \circ w'&\\ &=f\circ u \end{align}$
and
$\begin{align} f\circ v&= f\circ 1_x\circ w \\ &=f\circ u \end{align}$
therefore $w=w'$ but now I suspect that is not the correct method. My intuition tells me we must use $u=v$ somewhere to make the case $w=w'$
Can someone help point out how I can get to the conclusion that $w=w'$
Sufficient Condition
Take our above square to be a pullback and assume $f:X\rightarrow Y$ to be a monomorphism. What we now need to show is the for all $u,v:X\rightarrow Y$ $f\circ u=f\circ v$ implies that $u=v$.
What we know is
- $w$ is unique by assumption on pullback
we also have that
$\begin{align} f\circ v&=f\circ 1_x\circ w\\ &=f\circ w\\ & =f\circ 1_x\circ w\\ &=f\circ u\end{align}$
But, can I conclude that because $f\circ v=f\circ u$ we have $u=v$? I do not think so as I feel we should use that fact that $w$ is unique.
What I am wondering here is, how do I get to $u=v$.
Please be kind. I find Category Theory slightly beyond the grasp of my intellect, but all the more interesting.

First you should make clear what you mean by necessary and sufficient. If you have $A \Rightarrow B$ then $B$ is necessary condition of $A$ and $A$ is a sufficient condition for $B$. You want to show that $A \Leftrightarrow B$, that is $B$ is a necessary and sufficient condition for $A$. First you don't really make clear what $A$ and $B$ is. I assume $A=" f \text{ is a monomphism}"$ and $B="\text{the square is a pullback}"$. (What I would do is just use $\Rightarrow$ instead of necessary and sufficient, but that is probably a question of taste)
So for $A\Rightarrow B$ you should assume that $f$ is monomorphism and you have to show, not assume, that the square is a pullback. That is you have to show that there is a morphism $w$ and it is unique.
For the uniqueness you can show that $w'=1_x \circ w'= u = 1_x \circ w = w$. For the existence you just can take $w=u$ So what you were missing is $w'=1_x \circ w'$.
Now for $B \Rightarrow A$ you need to assume the square is a pullback and you want to show that $f$ is a monomorphism. That is you have to show that $v=u$. But you know that you can take both $u$ and $v$ as $w$ and since $w$ is unique they have to be equal.