Characterization of short exact sequences

The following is the first part of Proposition 2.9 in "Introduction to Commutative Algebra" by Atiyah & Macdonald.

Let $A$ be a commutative ring with $1$. Let $$M' \overset{u}{\longrightarrow}M\overset{v}{\longrightarrow}M''\longrightarrow 0\tag{1}$$ be sequence of $A$-modules and homomorphisms. Then the sequence (1) is exact if and only if for all $A$-modules $N$, the sequence $$0\longrightarrow \operatorname{Hom}(M'', N) \overset{\overline{v}}{\longrightarrow}\operatorname{Hom}(M, N)\overset{\overline{u}}{\longrightarrow}\operatorname{Hom}(M', N) \tag{2}$$ is exact.

Here, $\overline{v}$ is the map defined by $\overline{v}(f)=f\circ v$ for every $f\in\operatorname{Hom}(M'', N)$ and $\overline{u}$ is defined likewise.

The proof one of direction, namely $(2)\Rightarrow (1)$ is given in the book, which I am having some trouble understanding. So assuming (2) is exact sequence, the authors remark that "since $\overline{v}$ is injective for all $N$, it follows that $v$ is surjective". Could someone explain why this follows?

Given that $\overline{v}$ is injective, we know that whenever $f(v(x))=g(v(x))$ for all $x\in M$, we have $f=g$. I am not sure how we conclude from this surjectivity of $v$.

Thanks!

-
Let $N = \mbox{coker}(v)$, and let $p \in \mbox{Hom}(M'',N)$ be the quotient map $p:M'' \rightarrow N$. – Zach L. Apr 29 '13 at 0:54
@ZachL. Thank you! I have written my answer based on your hint. I hope it is correct. – Prism Apr 29 '13 at 1:42
@YACP: Dear YACP, thanks for collecting all the related links. It will be useful for future users. I just wanted to say that I did search before posting, and found some of those links you mentioned. But I couldn't find the proof of the bit I was looking after, so decided to post. – Prism Apr 29 '13 at 7:01

Here is an abstract way to think about this (which might not be what you're looking for):

The condition that $f\circ v=g\circ v\Rightarrow f=g$ for all $f,g\in\operatorname{Hom}(M'',N)$ says that $v$ is right-cancellative, that is, $v$ is an epimorphism in the category of $A$-modules. Epimorphisms in the category of $A$-modules are surjective on underlying sets.

-
Thanks for your answer. I don't know properties of cancellative epimorphisms; hopefully, I shall learn soon! – Prism Apr 29 '13 at 1:43
The answer you've provided proves the result I state about epimorphisms in the category of $A$-modules, so without even knowing it, you've already learned what I was talking about. – Jared Apr 29 '13 at 1:56

I think I have found the solution using Zach L's hint.

Let $N=\operatorname{coker}(v)=M''/\operatorname{Im}(v)$, and let $p\in\operatorname{Hom}(M'', N)$ be the canonical map $p: M''\to M''/\operatorname{Im(v)}=N$. We observe for every $x\in M$, we have $$p(v(x))=v(x)+\operatorname{Im}(v)=0+\operatorname{Im}(v)=0_{M''/\operatorname{Im(v)}}$$ So $p\circ v=0$. But we know that $\overline{v}$ is injective, that is, $\ker{\overline{v}}=\{0\}$. So $\overline{v}(p)=p\circ v=0$ implies $p=0$ (that is, the identically zero map), from which we get $M''/\operatorname{Im}(v)=0$, that is, $\operatorname{Im}(v)=M''$, proving that $v$ is surjective.

-