When does the generating set of a finite rank $A$-module reduce to a basis of the $A/\mathfrak{m}$-vector space?

Let $A$ be a local ring with maximal ideal $\mathfrak{m}$ and let $k = A/\mathfrak{m}$ be the residue field. Let $M$ be a finitely generated $A$-module; so $M/\mathfrak{m}M$ is a finite dimensional $k$-vector space. From Atiyah and MacDonald Proposition 2.8, we know that if $x_1, \ldots, x_n \in M$ are such that their images in $M/\mathfrak{m}M$ form a (vector space) basis of $M/\mathfrak{m}M$, then the $x_i$ generate $M$. I would like to know if there is a sort of converse to this statement. More precisely:

With notation as above, suppose the elements $y_1, \ldots, y_n \in M$ form a generating set for $M$. Then how can one transform the set $\{y_i\}$ such that the images of the $y_i$ in $M/\mathfrak{m}M$ form a basis for $M/\mathfrak{m}M$ as a $k$-vector space?

Obviously the condition we need on the set $\{y_i\}$ is that their images in $M/\mathfrak{m}M$ are linearly independent and span $M/\mathfrak{m}M$. My question is really about what transformation (in the algorithmic sense) one needs to perform on $\{y_i\}$ such that this condition will hold.

My intuition is that one would need to apply some kind of 'saturation' to the generating set $\{y_i\}$ and then reduce the saturation, since the main obstacle is that we may have $\overline{y}_i = \overline{y}_j$ for some $i \neq j$ (where $\overline{y}_i$ denotes the image of $y_i$ in $M/\mathfrak{m}M$) which could lead to a loss of a basis element in $M/\mathfrak{m}M$.

In case the statement above is too general to be solvable, please consider the special case (which is in fact my real problem) where $A = \mathbb{Z}_p$ (the $p$-adic integers), so $\mathfrak{m} = (p)$ and $k = \mathbb{F}_p$, and $M$ is a submodule of $\mathbb{Z}_p^n$ (so $M$ is finitely generated and free) given as a set of basis elements. I want to find a basis for the reduction of $M$ modulo $(p)$ as an $\mathbb{F}_p$-vector space.

-
If $\{y_i\}$ is a minimal generating set, then $\{\overline{y}_i\}$ is a basis. – wxu Jun 6 '11 at 23:41
@wxu: Do you have a reference to a proof of that? What I don't understand is if $\{y_i\}$ is a minimal generating set, it can happen that one or more of the $\overline{y}_i$ are zero (let's say $n \geq 0$ of them are killed in the reduction). So given another (minimal) generating set $\{z_i\}$, how do we know that precisely $n$ of the $\overline{z}_i$ reduce to zero (so that $\operatorname{dim}_k(M/\mathfrak{m}M)$ is independent of the chosen generating set)? – Hamish Jun 7 '11 at 8:13
If one of the $y_i$:s were killed in the reduction, then it would be needed to generate all of $M/mM$. The remaining ones would suffice. Therefore by the result you cited the element $y_i$ is not needed as a generator in the first place, IOW the set was not minimal. On another note: The ring $\mathbf{Z}_p$ is a PID, so a submodule $M$ of a finitely generated free module $\mathbf{Z}_p$ is free. Moreover we know that over a PID all the bases of a f.g. free module have the same number of elements. – Jyrki Lahtonen Jun 7 '11 at 18:25