Condition for equality of modules generated by columns of matrices Let $R$ be a commutative ring with unit. Let $M_A$ denote the submodule of $R^m$ generated by columns of a matrix $A$ with entries in $R$. Suppose we are given two matrices $A,B \in R^{m \times k}$. I want to know if the following statement is true:

*

*$M_A = M_B$ if and only if there exists an invertible matrix $P \in R^{k \times k}$ such that $A = BP$.

Note that one direction is super-easy: if $A = BP$ for invertible $P$, then the columns of both $A$ and $B$ generate the same submodule of $R^m$. So really the question is about the other direction. This is what I have tried for the "only if" direction: since $M_A = M_B$, we know that one can find matrices $P, Q \in R^{k \times k}$ such that $A = BP$ and $B = AQ$. From this we deduce that $A(I - QP)= B(I - PQ) = 0$. From here on, I don't really know what to do, but most likely this approach is just too naive.
However, I think the answer is true for a ring $R$ when $R$ is a principal ideal ring. Does anybody have a reference to this result (the particular case I want is when $R = \mathbb{Z}_d$, so a reference to this will also suffice)? More generally, I'd like to know for which rings does this property hold, and where can I find a proof of this result.
EDIT: Actually now I'm beginning to think that the result may not be true in general for PIRs. However, some special cases are true. I know the following facts:
(i) If you replace PIR by PID (principal integral domain), then the result is true.
(ii) If you have a PIR, and both $A,B$ have one row, then the result is true. Proof goes like this: Since a PIR is a Hermite ring, there exists an invertible matrices $K,K'$ such that $AK = (s,0,\dots,0)$ and $BK' = (s',0,\dots,0)$. Thus $s,s'$ generate the same ideal, and thus they must be associates (which is a property of PIRs by a result of I.Kaplansky). The result now follows.
(iii) If you are allowed to add zero columns to both $A,B$, then also the result is true, because of the existence of the Howell normal form. (see this and the references therein).
I'd like to stress that I'm interested in the case when the ring is $\mathbb{Z}_d$.
 A: Interpreting the various matrices as maps between free modules in the usual way, the question becomes:
If $M$ is a submodule of $R^m$, and $\alpha,\beta: R^k\to M$ are epimorphisms, then must $\alpha$ and $\beta$ be equivalent, in the sense that there is an automorphism $f:R^k\to R^k$ with $\alpha = \beta f$?
For $R=\mathbb{Z}/d\mathbb{Z}$, or indeed any artinian $R$, the answer is yes, since then for finitely generated modules we have projective covers and a Krull-Schmidt theorem, so both $\alpha$ and $\beta$ are equivalent to the same epimorphism $\gamma:R^k=P(M)\oplus Q\to M$, where $P(M)$ is the projective cover of $M$, and $\gamma$ restricts to the usual map  $P(M)\to M$ on $P(M)$ and the zero map on $Q$.
However, the answer is no if $R$ has a stably free module $P$ that is not free. For then, suppose $P\oplus R^n\cong R^k$. Then we have two epimorphisms $R^k\to R^n$, one with kernel $P$, and one with kernel $R^{k-n}$. Since they have non-isomorphic kernels, these epimorphisms can't be equivalent.
A: I want to elaborate on the answer that I accepted above by Jeremy Rickard. The facts in the answer were not entirely obvious to me. But after some reading, I managed to put together some of the missing details. Hopefully, these details are useful to someone else too.
We record a few definitons that I found non-trivial; however I won't define everything (such as an artinian ring, and short exact sequences). We assume a commutative ring $R$ with unit. I will use the following references: [these lecture notes], [this Stacks project page], [this Stacks project page].
Definition 1: A $R$-module $P$ is called a projective module if there exists a $R$-module $Q$ such that $P \oplus Q$ is a free $R$-module. (Note: any free $R$-module is a projective $R$-module).
Definition 2: A $R$-module epimorphism $f: P \rightarrow M$ is called an essential surjection if for every strictly smaller submodule $Q \subset P$, we have $f(Q) \neq M$.
Definition 3: A $R$-module epimorphism $f: P \rightarrow M$ is called a projective cover if $P$ is a projective $R$-module, and $f$ is an essential surjection.
Next we record some facts that go into the proof.
Fact 1: Any finitely generated module over an artinian ring $R$ admits a projective cover. [see here]
Fact 2: Suppose $P$ is a projective $R$-module, $f: P \rightarrow M$ is a $R$-module homomorphism, and $g: N \rightarrow M$ is a $R$-module epimorphism. Then there is a $R$-module homomorphism $h: P \rightarrow N$ such $f = gh$. [Theorem 43.9]
Fact 3: [Theorem 43.9] Suppose $P$ is a projective $R$-module, and we have a short exact sequence of $R$-module homomorphisms
$\require{AMScd}$
\begin{CD}
0 @>>> N @>u>> M @>v>> P @>>> 0.
\end{CD}
Then the sequence is a split exact sequence, meaning that there exists a $R$-module isomorphism $w: M \rightarrow N \oplus P$ such that the following diagram commutes
$\require{AMScd}$
\begin{CD}
0 @>>> N @>u>> M @>v>> P @>>> 0 \\
@. @V=VV @VwVV @V=VV @. \\
0 @>>> N @>>> N \oplus P @>>> P @>>> 0.
\end{CD}
Now we may start the proof. We restate the theorem.
Theorem: For an artinian ring $R$, let $M$ be a finitely generated $R$-module, $N$ be a finitely generated free $R$-module, and $\alpha, \beta: N \rightarrow M$ are $R$-module epimorphisms. Then there exists an $R$-module isomorphism $f: N \rightarrow N$ such that $\alpha = \beta f$.
Proof: Since $R$ is an artinian ring, by Fact 1, there exists a projective cover $\mu: P \rightarrow M$. Now consider the maps $\alpha, \mu$ both of which are $R$-module epimorphisms. By Fact 2, noting that $N$ is a free $R$-module implying it is also a projective $R$-module, we get a homomorphism $h_{\alpha} : N \rightarrow P$ such that $\mu h_{\alpha} = \alpha$. Now, since $\mu$ is an essential surjection, $h_{\alpha}$ must be an epimorphism too. Thus we have the short exact sequence
$\require{AMScd}$
\begin{CD}
0 @>>> \ker(h_{\alpha}) @>>> N @>h_{\alpha}>> P @>>> 0.
\end{CD}
Then Fact 3 implies that there is a $R$-module isomorphism $\lambda_{\alpha}: N \rightarrow \ker(h_{\alpha}) \oplus P$ such that $h_{\alpha} = \pi_{\alpha} \lambda_{\alpha}$, where $\pi_{\alpha}: \ker(h_{\alpha}) \oplus P \rightarrow P$ is the projection map. Thus so far we have $\alpha = \mu \pi_{\alpha} \lambda_{\alpha}$, or equivalently $\alpha \lambda^{-1}_{\alpha} = \mu \pi_{\alpha}: \ker(h_{\alpha}) \oplus P \rightarrow M$. The map $\mu \pi_{\alpha}$ restricts to the projective cover $\mu$ on $P$.
We can repeat the same argument now for the map $\beta$ to get the corresponding maps $h_{\beta}, \lambda_{\beta}, \pi_{\beta}$. The end result is that we have the following isomorphisms between modules: $N \cong \ker(h_{\alpha}) \oplus P \cong \ker(h_{\beta}) \oplus P$. We would be done if we can show that we have an isomorphism $\ker(h_{\alpha}) \cong \ker(h_{\beta})$. But this follows by applying the Krull-Schmidt theorem, using the fact that $N$ is finitely generated (see discussion in comments below).
